Fix for #4204: Don't bind if emacs leader is ""
When we try to bind leader + "m" and leader is the empty string, we end up binding to "m" directly which makes "m" all but unusable.
This commit is contained in:
parent
0b02475772
commit
bcdf346cb9
|
@ -106,24 +106,40 @@ pairs. For example,
|
||||||
|
|
||||||
(defalias 'evil-leader/set-key 'spacemacs/set-leader-keys)
|
(defalias 'evil-leader/set-key 'spacemacs/set-leader-keys)
|
||||||
|
|
||||||
|
(defun spacemacs//acceptable-leader-p (key)
|
||||||
|
"Return t if key is a string and non-empty."
|
||||||
|
(and (stringp key) (not (string= key ""))))
|
||||||
|
|
||||||
(defun spacemacs//init-leader-mode-map (mode map &optional minor)
|
(defun spacemacs//init-leader-mode-map (mode map &optional minor)
|
||||||
"Check for MAP-prefix. If it doesn't exist yet, use `bind-map'
|
"Check for MAP-prefix. If it doesn't exist yet, use `bind-map'
|
||||||
to create it and bind it to `dotspacemacs-major-mode-leader-key'
|
to create it and bind it to `dotspacemacs-major-mode-leader-key'
|
||||||
and `dotspacemacs-major-mode-emacs-leader-key'. If MODE is a
|
and `dotspacemacs-major-mode-emacs-leader-key'. If MODE is a
|
||||||
minor-mode, the third argument should be non nil."
|
minor-mode, the third argument should be non nil."
|
||||||
(let ((prefix (intern (format "%s-prefix" map))))
|
(let* ((prefix (intern (format "%s-prefix" map)))
|
||||||
|
(leader1 (when (spacemacs//acceptable-leader-p
|
||||||
|
dotspacemacs-major-mode-leader-key)
|
||||||
|
dotspacemacs-major-mode-leader-key))
|
||||||
|
(leader2 (when (spacemacs//acceptable-leader-p
|
||||||
|
dotspacemacs-leader-key)
|
||||||
|
(concat dotspacemacs-leader-key
|
||||||
|
(unless minor " m"))))
|
||||||
|
(emacs-leader1 (when (spacemacs//acceptable-leader-p
|
||||||
|
dotspacemacs-major-mode-emacs-leader-key)
|
||||||
|
dotspacemacs-major-mode-emacs-leader-key))
|
||||||
|
(emacs-leader2 (when (spacemacs//acceptable-leader-p
|
||||||
|
dotspacemacs-emacs-leader-key)
|
||||||
|
(concat dotspacemacs-emacs-leader-key
|
||||||
|
(unless minor " m"))))
|
||||||
|
(leaders (-non-nil (list leader1 leader2)))
|
||||||
|
(emacs-leaders (-non-nil (list emacs-leader1 emacs-leader2))))
|
||||||
(or (boundp prefix)
|
(or (boundp prefix)
|
||||||
(progn
|
(progn
|
||||||
(eval
|
(eval
|
||||||
`(bind-map ,map
|
`(bind-map ,map
|
||||||
:prefix-cmd ,prefix
|
:prefix-cmd ,prefix
|
||||||
,(if minor :minor-modes :major-modes) (,mode)
|
,(if minor :minor-modes :major-modes) (,mode)
|
||||||
:keys (,dotspacemacs-major-mode-emacs-leader-key
|
:keys ,emacs-leaders
|
||||||
,(concat dotspacemacs-emacs-leader-key
|
:evil-keys ,leaders))
|
||||||
(unless minor " m")))
|
|
||||||
:evil-keys (,dotspacemacs-major-mode-leader-key
|
|
||||||
,(concat dotspacemacs-leader-key
|
|
||||||
(unless minor " m")))))
|
|
||||||
(boundp prefix)))))
|
(boundp prefix)))))
|
||||||
|
|
||||||
(defun spacemacs/set-leader-keys-for-major-mode (mode key def &rest bindings)
|
(defun spacemacs/set-leader-keys-for-major-mode (mode key def &rest bindings)
|
||||||
|
|
Loading…
Reference in a new issue