From 07964b1a2e28b738c1631cf08ee42531a9d1ad6a Mon Sep 17 00:00:00 2001 From: Miciah Masters Date: Tue, 29 May 2018 16:57:17 -0400 Subject: [PATCH] Work around ido-mode remapping Spacemacs keys Add aliases for commands that ido-mode remaps that we want to bind to Spacemacs keys, and use these aliases in the Spacemacs key bindings so that these bindings invoke the original commands rather than the ido commands. See . --- CHANGELOG.develop | 3 +++ layers/+spacemacs/spacemacs-defaults/funcs.el | 12 ++++++++++++ layers/+spacemacs/spacemacs-defaults/keybindings.el | 8 ++++---- layers/+spacemacs/spacemacs-defaults/packages.el | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.develop b/CHANGELOG.develop index f53cde679..6262ade18 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -76,6 +76,9 @@ This file containes the change log for the next major version of Spacemacs. - Avoid importing already defined variables (except `PATH`/`MANPATH`). - Move all scrolling key bindings from ~SPC n~ to ~SPC N~ (Somelauw) - Overhaul the scroll transient state on ~SPC N~ prefix (Somelauw) +- Use Helm or Ivy (if one of these is enabled) for ~SPC a d~ (=dired=), + ~SPC F f~ (=find-file-other-frame=), ~SPC F b~ (=switch-to-buffer-other-frame=), + ~SPC F B~ (=display-buffer-other-frame=), and ~SPC F O~ (=dired-other-frame=). *** Layer changes **** GitHub - Add new package =magithub= diff --git a/layers/+spacemacs/spacemacs-defaults/funcs.el b/layers/+spacemacs/spacemacs-defaults/funcs.el index 1a271a944..bef1d210a 100644 --- a/layers/+spacemacs/spacemacs-defaults/funcs.el +++ b/layers/+spacemacs/spacemacs-defaults/funcs.el @@ -88,6 +88,18 @@ automatically applied to." :type '(list symbol)) +;; ido-mode remaps some commands to ido counterparts. We want default Emacs key +;; bindings (those under C-x) to use ido, but we want to use the original +;; commands in Spacemacs key bindings (those under M-m or SPC) so that they use +;; `read-file-name-function', `completing-read-function', +;; `completion-in-region-function', etc. configured by Helm or Ivy etc. The +;; following aliases allow us to bind Spacemacs keys to the original commands. +(defalias 'spacemacs/find-file-other-frame 'find-file-other-frame) +(defalias 'spacemacs/dired 'dired) +(defalias 'spacemacs/dired-other-frame 'dired-other-frame) +(defalias 'spacemacs/switch-to-buffer-other-frame 'switch-to-buffer-other-frame) +(defalias 'spacemacs/display-buffer-other-frame 'display-buffer-other-frame) + (defun spacemacs/indent-region-or-buffer () "Indent a region if selected, otherwise the whole buffer." (interactive) diff --git a/layers/+spacemacs/spacemacs-defaults/keybindings.el b/layers/+spacemacs/spacemacs-defaults/keybindings.el index 96255023c..2ccfa2c13 100644 --- a/layers/+spacemacs/spacemacs-defaults/keybindings.el +++ b/layers/+spacemacs/spacemacs-defaults/keybindings.el @@ -229,13 +229,13 @@ "fyy" 'spacemacs/copy-file-path) ;; frame ---------------------------------------------------------------------- (spacemacs/set-leader-keys - "Ff" 'find-file-other-frame + "Ff" 'spacemacs/find-file-other-frame "Fd" 'delete-frame "FD" 'delete-other-frames - "Fb" 'switch-to-buffer-other-frame - "FB" 'display-buffer-other-frame + "Fb" 'spacemacs/switch-to-buffer-other-frame + "FB" 'spacemacs/display-buffer-other-frame "Fo" 'other-frame - "FO" 'dired-other-frame + "FO" 'spacemacs/dired-other-frame "Fn" 'make-frame) ;; help ----------------------------------------------------------------------- (spacemacs/set-leader-keys diff --git a/layers/+spacemacs/spacemacs-defaults/packages.el b/layers/+spacemacs/spacemacs-defaults/packages.el index 1fcea94b9..515847936 100644 --- a/layers/+spacemacs/spacemacs-defaults/packages.el +++ b/layers/+spacemacs/spacemacs-defaults/packages.el @@ -72,7 +72,7 @@ (defun spacemacs-defaults/init-dired () (spacemacs/set-leader-keys - "ad" 'dired + "ad" 'spacemacs/dired "fj" 'dired-jump "jd" 'dired-jump "jD" 'dired-jump-other-window))