cofi / evil-leader Goto Github PK
View Code? Open in Web Editor NEW<leader> key for evil
License: GNU General Public License v3.0
<leader> key for evil
License: GNU General Public License v3.0
I use this
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key "/t" (kbd ":bd!"))
and when I type space and tab in emacs, it shows SPC TAB is undefined.
Spacemacs has a primary leader Space.
And you can access specific mode keybindings with Space m something
.
But it has a secondary leader "," to shorten those mode keybindings to just , something
.
Is there a way to do this with just evil-leader?
Hello there,
I have a file called "evil-conf.el" which my .emacs imports:
(when (not (package-installed-p 'evil))
(package-install 'evil))
(when (not (package-installed-p 'evil-leader))
(package-install 'evil-leader))
(require 'elscreen)
(require 'evil-leader)
(require 'evil)
(setq evil-leader/in-all-states t)
(setq evil-leader/leader ",")
(evil-mode nil)
(global-evil-leader-mode 1)
(evil-mode 1)
[... more conf ...]
This works fine when emacs loads up, but if I try within Emacs to do "load-file" and then ".emacs" I get the error:
evil-leader-mode: Wrong type argument: keymapp, nil
It's annoying, because it force me to close Emacs each time I change .emacs.
I know the error stems from that file due to messages:
Loading /Users/adinapoli/.emacs...
Loading /Users/adinapoli/.emacs.d/hsenv.el (source)...done
Loading /Users/adinapoli/.emacs.d/util.el (source)...done
Loading /Users/adinapoli/.emacs.d/evil-conf.el (source)...
evil-leader-mode: Wrong type argument: keymapp, nil
Any idea? I've also tried to remove the (set-leader) instruction, but the error persist, interestingly.
Thanks!
A.
I'm trying to use the letter m as my leader, but it's the only key that doesn't work for some reason. I've tried:
(evil-leader/set-leader "m")
and
(evil-leader/set-leader "\155")
.
(read-kbd-macro "m")
returns "m", so that looks ok. Any ideas?
After I turned on js3-mode, I started to notice, that there is some kind of conflict between those two. I have leader set as "". Regardless of the evil state, the leader is active, but the combinations work only in normal state. Please let me know, if there is more info i could provide.
Hello, one happy user here.
Some non-editing major modes that run in Emacs mode (magit, for instance) could put evil-leader to good use without requiring to punch non-normal-prefix
. Thus, ",b" would work on magit as if it were in normal mode.
Something like
(add-hook 'magit-mode-hook (lambda () (local-set-key evil-leader/leader <?>))
My question is: what should <?>
be for achieving what I want? I hope there is a trick with keymappings that achieves that.
BTW, this is somewhat related to #2
I think it might be useful.
Hi!
This plugin is awesome and brings my emacs workflow even nearer my vim one. However, I notice that in some buffers, the bindings don't work, i.e Ibuffer backtrace. Would it be possible to force the evil-leader bindings globally, somehow?
Thanks,
Marcelo.
I did a little bit of testing and it appears that that maps of more than one key are not supported. This is a request for support of maps such as
(evil-leader/set-key "nt" 'nav-toggle)
If evil-mode
is enabled before global-evil-leader-mode
the order of the global enabler functions is wrong, resulting in evil-local-mode
being never enabled when global-evil-leader-mode
checks.
Workaround: Enable global-evil-leader-mode
before evil-mode
Using the below configuration file (and the latest version of evil-mode and evil-leader as a submodule in my .emacs/modules
directory), I am able to reproduce a bug where <leader> b
is defined, but <leader> <SPC>
is not. The same weirdness occurs with a leader key of ",".
(require 'cl-lib)
(cl-pushnew "~/.emacs.d/modules/evil-mode" load-path)
(cl-pushnew "~/.emacs.d/modules/evil-leader" load-path)
(require 'evil)
(require 'evil-leader)
(global-evil-leader-mode +1)
(evil-mode +1)
(global-evil-leader-mode +1)
;; set-leader is finicky and doesn't reject keys it doesn't understand
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key (kbd "<SPC>") #'backward-word)
(evil-leader/set-key (kbd "b") #'backward-word)
Here is the section of the output of C-h b
related to evil-leader bindings.
`evil-normal-state-local-minor-mode' Minor Mode Bindings:
key binding
--- -------
SPC Prefix Command
SPC b backward-word
Note: as a workaround, modifying the default map directly fixes the problem.
(define-key evil-leader--default-map (kbd "<SPC>") #'backward-word)
Ah! okay. It turns out you have to do
(evil-leader/set-key "SPC" #'backward-word)
Since my workflow is heavily dependent on evil-leader (https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-evil.el), I found second leader key is useful.
The second key is reserved for less used commands with some graphic hint, like https://github.com/abo-abo/hydra
for example, I map <leader>ww
to save file, hint is not necessary in this case.
but for sort-lines
, I cannot remember its hotkey "sl" because I seldom use sort-lines
, so a little hint is helpful to make my actually use the hotkey.
I have evil-leader enabled in my ~/.emacs. If I make a change (unrelated to evil/evil-leader) and reload the config file, evil-leader is always disabled and has to be manually invoked.
Define a key with one char in another prefix key is not allowed. But the expected behavior will be p binds to one and ps binds to another cmd.
"p" 'projectile-switch-project "ps" 'smex
This situation could get worse if evil-leader/set-key-for-mode
is used.
(evil-leader/set-key
"p" )
(evil-leader/set-key 'minor-mode
"ps" <another_cmd>)
Then the original "p" bindings will be overwritten without warning.
Hey guys.
In my emacs.org
, I've got the following configuration:
(evil-leader/set-leader "<SPC>")
(setq evil-leader/in-all-states t)
(evil-mode nil)
(global-evil-leader-mode)
(evil-mode 1)
I needed to use it like that as without the extra (evil-mode nil)
, leader wasn't bound in *Messages*
buffer. I found the solution in #10
This works as expected, binding leader in *Messages*
(which is ultimately what I'm trying to achieve), however, when opening new i.e Yaml buffer, I'm getting the following error message:
File mode specification error: (error "To bind the key C-SPC, use [?\\C- ], not [C-SPC]")
progn: To bind the key C-SPC, use [?\C- ], not [C-SPC]
The full and lengthy stacktrace which I'm getting with this is:
Debugger entered--Lisp error: (error "To bind the key C-SPC, use [?\\C- ], not [C-SPC]")
define-key((keymap (67108896 keymap (119 keymap (61 . balance-windows) (114 . toggle-window-split)) (64 . google-this-noconfirm) (27 . ace-jump-mode-pop-mark) (33 . google-this-search) (83 . helm-org-agenda-files-headings) (111 keymap (116 keymap (116 . org-set-tags)) (112 . org-iswitchb) (115 . org-schedule) (111 . org-open-at-point) (110 keymap (110 . org-add-note)) (76 . org-insert-link-global) (108 . org-store-link) (103 . helm-multi-swoop-org) (101 . org-edit-special) (100 . org-deadline) (99 keymap (113 . org-clock-cancel) (111 . org-clock-out) (99 . org-clock-in))) (116 . org-todo) (115 . helm-semantic-or-imenu) (98 keymap (100 . bookmark-delete) (108 . helm-bookmarks) (98 . bookmark-jump) (97 . bookmark-set)) (112 keymap (100 . projectile-dired) (115 . helm-projectile-switch-project) (102 . helm-projectile-find-file-dwim) (114 . helm-projectile-recentf) (107 . helm-projectile-find-file-in-known-projects) (112 . helm-projectile-find-file)) (104 keymap (109 . helm-man-woman) (63 . help-for-help) (100 . helm-dash-at-point) (71 . helm-do-ag) (103 . helm-projectile-ag) (105 . helm-imenu) (102 . helm-for-files) (98 . helm-bookmarks)) (102 . helm-find-files) (32 . helm-mini) (42 . helm-swoop-from-evil-search) (47 . helm-swoop) (63 . helm-descbinds) (103 keymap (116 . magit-diff-working-tree) (118 . vc-revision-other-window) (109 . magit-branch-popup) (110 keymap (98 . magit-create-branch)) (99 . magit-commit) (76 . magit-file-log) (108 . magit-log) (115 . magit-status) (98 . magit-blame-mode) (97 . vc-annotate)) (45 . helm-flycheck) (113 . delete-window) (49 . delete-other-windows) (100 . dired))) [C-SPC] (keymap (119 keymap (61 . balance-windows) (114 . toggle-window-split)) (64 . google-this-noconfirm) (27 . ace-jump-mode-pop-mark) (33 . google-this-search) (83 . helm-org-agenda-files-headings) (111 keymap (116 keymap (116 . org-set-tags)) (112 . org-iswitchb) (115 . org-schedule) (111 . org-open-at-point) (110 keymap (110 . org-add-note)) (76 . org-insert-link-global) (108 . org-store-link) (103 . helm-multi-swoop-org) (101 . org-edit-special) (100 . org-deadline) (99 keymap (113 . org-clock-cancel) (111 . org-clock-out) (99 . org-clock-in))) (116 . org-todo) (115 . helm-semantic-or-imenu) (98 keymap (100 . bookmark-delete) (108 . helm-bookmarks) (98 . bookmark-jump) (97 . bookmark-set)) (112 keymap (100 . projectile-dired) (115 . helm-projectile-switch-project) (102 . helm-projectile-find-file-dwim) (114 . helm-projectile-recentf) (107 . helm-projectile-find-file-in-known-projects) (112 . helm-projectile-find-file)) (104 keymap (109 . helm-man-woman) (63 . help-for-help) (100 . helm-dash-at-point) (71 . helm-do-ag) (103 . helm-projectile-ag) (105 . helm-imenu) (102 . helm-for-files) (98 . helm-bookmarks)) (102 . helm-find-files) (32 . helm-mini) (42 . helm-swoop-from-evil-search) (47 . helm-swoop) (63 . helm-descbinds) (103 keymap (116 . magit-diff-working-tree) (118 . vc-revision-other-window) (109 . magit-branch-popup) (110 keymap (98 . magit-create-branch)) (99 . magit-commit) (76 . magit-file-log) (108 . magit-log) (115 . magit-status) (98 . magit-blame-mode) (97 . vc-annotate)) (45 . helm-flycheck) (113 . delete-window) (49 . delete-other-windows) (100 . dired)))
(progn (define-key evil-emacs-state-local-map prefixed map) (define-key evil-insert-state-local-map prefixed map))
(if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed map) (define-key evil-insert-state-local-map prefixed map)))
(progn (evil-normalize-keymaps) (define-key evil-motion-state-local-map no-prefix map) (define-key evil-normal-state-local-map no-prefix map) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed map) (define-key evil-insert-state-local-map prefixed map))) (if (and no-prefix-rx (string-match-p no-prefix-rx (symbol-name major-mode))) (progn (define-key evil-emacs-state-local-map no-prefix map) (define-key evil-insert-state-local-map no-prefix map))))
(if evil-leader-mode (progn (evil-normalize-keymaps) (define-key evil-motion-state-local-map no-prefix map) (define-key evil-normal-state-local-map no-prefix map) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed map) (define-key evil-insert-state-local-map prefixed map))) (if (and no-prefix-rx (string-match-p no-prefix-rx (symbol-name major-mode))) (progn (define-key evil-emacs-state-local-map no-prefix map) (define-key evil-insert-state-local-map no-prefix map)))) (define-key evil-motion-state-local-map no-prefix nil) (define-key evil-normal-state-local-map no-prefix nil) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed nil) (define-key evil-insert-state-local-map prefixed nil) (if (and no-prefix-rx (string-match-p no-prefix-rx (symbol-name major-mode))) (progn (define-key evil-emacs-state-local-map no-prefix nil) (define-key evil-insert-state-local-map no-prefix nil))))))
(let* ((prefixed (read-kbd-macro (concat evil-leader/non-normal-prefix evil-leader/leader))) (no-prefix (read-kbd-macro evil-leader/leader)) (mode-map (cdr (assoc major-mode evil-leader--mode-maps))) (map (or mode-map evil-leader--default-map)) (no-prefix-rx (if evil-leader/no-prefix-mode-rx (mapconcat (function identity) evil-leader/no-prefix-mode-rx "\\|") nil))) (if evil-leader-mode (progn (evil-normalize-keymaps) (define-key evil-motion-state-local-map no-prefix map) (define-key evil-normal-state-local-map no-prefix map) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed map) (define-key evil-insert-state-local-map prefixed map))) (if (and no-prefix-rx (string-match-p no-prefix-rx (symbol-name major-mode))) (progn (define-key evil-emacs-state-local-map no-prefix map) (define-key evil-insert-state-local-map no-prefix map)))) (define-key evil-motion-state-local-map no-prefix nil) (define-key evil-normal-state-local-map no-prefix nil) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed nil) (define-key evil-insert-state-local-map prefixed nil) (if (and no-prefix-rx (string-match-p no-prefix-rx (symbol-name major-mode))) (progn (define-key evil-emacs-state-local-map no-prefix nil) (define-key evil-insert-state-local-map no-prefix nil)))))))
(let ((last-message (current-message))) (setq evil-leader-mode (if (eq arg (quote toggle)) (not evil-leader-mode) (> (prefix-numeric-value arg) 0))) (let* ((prefixed (read-kbd-macro (concat evil-leader/non-normal-prefix evil-leader/leader))) (no-prefix (read-kbd-macro evil-leader/leader)) (mode-map (cdr (assoc major-mode evil-leader--mode-maps))) (map (or mode-map evil-leader--default-map)) (no-prefix-rx (if evil-leader/no-prefix-mode-rx (mapconcat (function identity) evil-leader/no-prefix-mode-rx "\\|") nil))) (if evil-leader-mode (progn (evil-normalize-keymaps) (define-key evil-motion-state-local-map no-prefix map) (define-key evil-normal-state-local-map no-prefix map) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed map) (define-key evil-insert-state-local-map prefixed map))) (if (and no-prefix-rx (string-match-p no-prefix-rx (symbol-name major-mode))) (progn (define-key evil-emacs-state-local-map no-prefix map) (define-key evil-insert-state-local-map no-prefix map)))) (define-key evil-motion-state-local-map no-prefix nil) (define-key evil-normal-state-local-map no-prefix nil) (if evil-leader/in-all-states (progn (define-key evil-emacs-state-local-map prefixed nil) (define-key evil-insert-state-local-map prefixed nil) (if (and no-prefix-rx (string-match-p no-prefix-rx ...)) (progn (define-key evil-emacs-state-local-map no-prefix nil) (define-key evil-insert-state-local-map no-prefix nil))))))) (run-hooks (quote evil-leader-mode-hook) (if evil-leader-mode (quote evil-leader-mode-on-hook) (quote evil-leader-mode-off-hook))) (if (called-interactively-p (quote any)) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (message "Evil-Leader mode %sabled" (if evil-leader-mode "en" "dis"))))))
evil-leader-mode()
run-hooks(evil-local-mode-hook evil-local-mode-off-hook)
(let ((last-message (current-message))) (setq evil-local-mode (if (eq arg (quote toggle)) (not evil-local-mode) (> (prefix-numeric-value arg) 0))) (cond ((evil-disabled-buffer-p)) (evil-local-mode (setq emulation-mode-map-alists (evil-concat-lists (quote (evil-mode-map-alist)) emulation-mode-map-alists)) (evil-initialize-local-keymaps) (if (eq major-mode (quote turn-on-evil-mode)) (progn (setq major-mode (quote fundamental-mode)))) (if evil-state nil (evil-initialize-state)) (add-hook (quote input-method-activate-hook) (quote evil-activate-input-method) t t) (add-hook (quote input-method-deactivate-hook) (quote evil-deactivate-input-method) t t) (add-hook (quote activate-mark-hook) (quote evil-visual-activate-hook) nil t) (add-hook (quote pre-command-hook) (quote evil-repeat-pre-hook)) (add-hook (quote pre-command-hook) (quote evil-jump-hook) nil t) (add-hook (quote post-command-hook) (quote evil-repeat-post-hook))) (t (evil-refresh-mode-line) (remove-hook (quote pre-command-hook) (quote evil-jump-hook) t) (remove-hook (quote activate-mark-hook) (quote evil-visual-activate-hook) t) (remove-hook (quote input-method-activate-hook) (quote evil-activate-input-method) t) (remove-hook (quote input-method-deactivate-hook) (quote evil-deactivate-input-method) t) (evil-change-state nil))) (run-hooks (quote evil-local-mode-hook) (if evil-local-mode (quote evil-local-mode-on-hook) (quote evil-local-mode-off-hook))) (if (called-interactively-p (quote any)) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (message "Evil-Local mode %sabled" (if evil-local-mode "en" "dis"))))))
evil-local-mode(-1)
(progn (evil-local-mode -1) (funcall (function evil-initialize)))
(if evil-local-mode (progn (evil-local-mode -1) (funcall (function evil-initialize))) (funcall (function evil-initialize)))
(if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode (progn (evil-local-mode -1) (funcall (function evil-initialize))) (funcall (function evil-initialize))))
(if evil-local-mode-set-explicitly nil (if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode (progn (evil-local-mode -1) (funcall (function evil-initialize))) (funcall (function evil-initialize)))))
(save-current-buffer (set-buffer buf) (if evil-local-mode-set-explicitly nil (if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode (progn (evil-local-mode -1) (funcall (function evil-initialize))) (funcall (function evil-initialize))))) (setq evil-local-mode-major-mode major-mode))
(progn (save-current-buffer (set-buffer buf) (if evil-local-mode-set-explicitly nil (if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode (progn (evil-local-mode -1) (funcall (function evil-initialize))) (funcall (function evil-initialize))))) (setq evil-local-mode-major-mode major-mode)))
(if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (if evil-local-mode-set-explicitly nil (if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode (progn (evil-local-mode -1) (funcall ...)) (funcall (function evil-initialize))))) (setq evil-local-mode-major-mode major-mode))))
(while --dolist-tail-- (setq buf (car --dolist-tail--)) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (if evil-local-mode-set-explicitly nil (if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode (progn ... ...) (funcall ...)))) (setq evil-local-mode-major-mode major-mode)))) (setq --dolist-tail-- (cdr --dolist-tail--)))
(let ((--dolist-tail-- evil-mode-buffers) buf) (while --dolist-tail-- (setq buf (car --dolist-tail--)) (if (buffer-live-p buf) (progn (save-current-buffer (set-buffer buf) (if evil-local-mode-set-explicitly nil (if (eq evil-local-mode-major-mode major-mode) nil (if evil-local-mode ... ...))) (setq evil-local-mode-major-mode major-mode)))) (setq --dolist-tail-- (cdr --dolist-tail--))))
evil-mode-enable-in-buffers()
run-hooks(after-change-major-mode-hook)
run-mode-hooks(yaml-mode-hook)
yaml-mode()
set-auto-mode-0(yaml-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
find-file-noselect-1(#<buffer main.yml<skylake>> "~/b-box/ansible/roles/skylake/tasks/main.yml" nil nil "~/b-box/ansible/roles/skylake/tasks/main.yml" (10354841 2052))
find-file-noselect("/home/zerodi/b-box/ansible/roles/skylake/tasks/main.yml" nil nil nil)
find-file("/home/zerodi/b-box/ansible/roles/skylake/tasks/main.yml")
mapc(find-file ("/home/zerodi/b-box/ansible/roles/skylake/tasks/main.yml"))
(let ((helm--reading-passwd-or-string t)) (mapc (quote find-file) (helm-marked-candidates)))
helm-find-many-files("/home/zerodi/b-box/ansible/roles/skylake/tasks/main.yml")
funcall(helm-find-many-files "/home/zerodi/b-box/ansible/roles/skylake/tasks/main.yml")
(progn (funcall action selection))
(if (and selection action) (progn (funcall action selection)))
(let ((source (or helm-saved-current-source (helm-get-current-source))) non-essential) (setq selection (helm-coerce-selection (or selection helm-saved-selection (helm-get-selection) (and (assoc (quote accept-empty) source) "")) source)) (if preserve-saved-action nil (setq helm-saved-action nil)) (if (and selection action) (progn (funcall action selection))))
helm-execute-selection-action-1()
(unwind-protect (helm-execute-selection-action-1) (let ((it (get-buffer helm-action-buffer))) (if it (kill-buffer it))) (helm-log-run-hook (quote helm-after-action-hook)))
helm-execute-selection-action()
(if helm-quit nil (helm-execute-selection-action))
(prog1 (if helm-quit nil (helm-execute-selection-action)) (helm-log (concat "[End session] " (make-string 41 45))))
(let (helm-source-name helm-current-source helm-in-persistent-action helm-quit (helm-buffer (or any-buffer helm-buffer))) (let ((orig-vars57806 (mapcar (function (lambda (v) (cons v ...))) helm-restored-variables))) (unwind-protect (progn (helm-initialize any-resume any-input any-default any-sources) (helm-display-buffer helm-buffer) (if helm-prevent-escaping-from-minibuffer (progn (helm--remap-mouse-mode 1))) (add-hook (quote post-command-hook) (quote helm--maybe-update-keymap)) (add-hook (quote post-command-hook) (quote helm--update-header-line)) (helm-log "show prompt") (unwind-protect (helm-read-pattern-maybe any-prompt any-input any-preselect any-resume any-keymap any-default any-history) (helm-cleanup))) (let* ((--cl-var-- orig-vars57806) (value nil) (var nil)) (while (consp --cl-var--) (setq value (car --cl-var--) var (car-safe (prog1 value ...))) (set var value) (setq --cl-var-- (cdr --cl-var--))) nil) (helm-log "restore variables"))) (prog1 (if helm-quit nil (helm-execute-selection-action)) (helm-log (concat "[End session] " (make-string 41 45)))))
(condition-case _v (let (helm-source-name helm-current-source helm-in-persistent-action helm-quit (helm-buffer (or any-buffer helm-buffer))) (let ((orig-vars57806 (mapcar (function (lambda ... ...)) helm-restored-variables))) (unwind-protect (progn (helm-initialize any-resume any-input any-default any-sources) (helm-display-buffer helm-buffer) (if helm-prevent-escaping-from-minibuffer (progn (helm--remap-mouse-mode 1))) (add-hook (quote post-command-hook) (quote helm--maybe-update-keymap)) (add-hook (quote post-command-hook) (quote helm--update-header-line)) (helm-log "show prompt") (unwind-protect (helm-read-pattern-maybe any-prompt any-input any-preselect any-resume any-keymap any-default any-history) (helm-cleanup))) (let* ((--cl-var-- orig-vars57806) (value nil) (var nil)) (while (consp --cl-var--) (setq value (car --cl-var--) var (car-safe ...)) (set var value) (setq --cl-var-- (cdr --cl-var--))) nil) (helm-log "restore variables"))) (prog1 (if helm-quit nil (helm-execute-selection-action)) (helm-log (concat "[End session] " (make-string 41 45))))) ((debug quit) (helm-restore-position-on-quit) (helm-log (concat "[End session (quit)] " (make-string 34 45))) nil))
(unwind-protect (condition-case _v (let (helm-source-name helm-current-source helm-in-persistent-action helm-quit (helm-buffer (or any-buffer helm-buffer))) (let ((orig-vars57806 (mapcar (function ...) helm-restored-variables))) (unwind-protect (progn (helm-initialize any-resume any-input any-default any-sources) (helm-display-buffer helm-buffer) (if helm-prevent-escaping-from-minibuffer (progn ...)) (add-hook (quote post-command-hook) (quote helm--maybe-update-keymap)) (add-hook (quote post-command-hook) (quote helm--update-header-line)) (helm-log "show prompt") (unwind-protect (helm-read-pattern-maybe any-prompt any-input any-preselect any-resume any-keymap any-default any-history) (helm-cleanup))) (let* ((--cl-var-- orig-vars57806) (value nil) (var nil)) (while (consp --cl-var--) (setq value ... var ...) (set var value) (setq --cl-var-- ...)) nil) (helm-log "restore variables"))) (prog1 (if helm-quit nil (helm-execute-selection-action)) (helm-log (concat "[End session] " (make-string 41 45))))) ((debug quit) (helm-restore-position-on-quit) (helm-log (concat "[End session (quit)] " (make-string 34 45))) nil)) (if (fboundp (quote advice-add)) (progn (advice-remove (quote tramp-read-passwd) (function helm--advice-tramp-read-passwd)) (advice-remove (quote ange-ftp-get-passwd) (function helm--advice-ange-ftp-get-passwd))) (ad-deactivate (quote tramp-read-passwd)) (ad-deactivate (quote ange-ftp-get-passwd))) (helm-log "helm-alive-p = %S" (setq helm-alive-p nil)) (helm--remap-mouse-mode -1) (setq helm-alive-p nil) (setq helm-pattern "") (and old--cua (cua-mode 1)) (helm-log-save-maybe))
(let ((non-essential t) (input-method-verbose-flag helm-input-method-verbose-flag) (old--cua cua-mode) (helm--maybe-use-default-as-input (and (null any-input) (or helm--maybe-use-default-as-input (let* ((--cl-var-- ...) (s nil) (--cl-flag-- t) --cl-var--) (while (and ... ...) (setq --cl-var-- ...)) --cl-var--))))) (and cua-mode (cua-mode -1)) (unwind-protect (condition-case _v (let (helm-source-name helm-current-source helm-in-persistent-action helm-quit (helm-buffer (or any-buffer helm-buffer))) (let ((orig-vars57806 (mapcar ... helm-restored-variables))) (unwind-protect (progn (helm-initialize any-resume any-input any-default any-sources) (helm-display-buffer helm-buffer) (if helm-prevent-escaping-from-minibuffer ...) (add-hook ... ...) (add-hook ... ...) (helm-log "show prompt") (unwind-protect ... ...)) (let* (... ... ...) (while ... ... ... ...) nil) (helm-log "restore variables"))) (prog1 (if helm-quit nil (helm-execute-selection-action)) (helm-log (concat "[End session] " (make-string 41 45))))) ((debug quit) (helm-restore-position-on-quit) (helm-log (concat "[End session (quit)] " (make-string 34 45))) nil)) (if (fboundp (quote advice-add)) (progn (advice-remove (quote tramp-read-passwd) (function helm--advice-tramp-read-passwd)) (advice-remove (quote ange-ftp-get-passwd) (function helm--advice-ange-ftp-get-passwd))) (ad-deactivate (quote tramp-read-passwd)) (ad-deactivate (quote ange-ftp-get-passwd))) (helm-log "helm-alive-p = %S" (setq helm-alive-p nil)) (helm--remap-mouse-mode -1) (setq helm-alive-p nil) (setq helm-pattern "") (and old--cua (cua-mode 1)) (helm-log-save-maybe)))
helm-internal((helm-source-buffers-list helm-source-recentf helm-source-buffer-not-found) nil nil nil nil "*helm mini*" nil nil nil)
apply(helm-internal ((helm-source-buffers-list helm-source-recentf helm-source-buffer-not-found) nil nil nil nil "*helm mini*" nil nil nil))
(if (keywordp (car plist)) (progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda (key) (plist-get plist key))) helm-argument-keys))) (apply fn plist))
(if (and helm-alive-p (eq fn (function helm))) (if (helm-alive-p) (error "Error: Trying to run helm within a running helm session") (save-current-buffer (set-buffer (helm-buffer-get)) (prog1 (message "Aborting an helm session running in background") (helm-keyboard-quit)))) (if (keywordp (car plist)) (progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda (key) (plist-get plist key))) helm-argument-keys))) (apply fn plist)))
(let ((fn (cond ((or (and helm-alive-p (plist-get plist :allow-nest)) (and helm-alive-p (memq ... plist))) (function helm-nest)) ((keywordp (car plist)) (function helm)) (t (function helm-internal))))) (if (and helm-alive-p (eq fn (function helm))) (if (helm-alive-p) (error "Error: Trying to run helm within a running helm session") (save-current-buffer (set-buffer (helm-buffer-get)) (prog1 (message "Aborting an helm session running in background") (helm-keyboard-quit)))) (if (keywordp (car plist)) (progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda ... ...)) helm-argument-keys))) (apply fn plist))))
helm((helm-source-buffers-list helm-source-recentf helm-source-buffer-not-found) nil nil nil nil "*helm mini*" nil nil nil)
apply(helm ((helm-source-buffers-list helm-source-recentf helm-source-buffer-not-found) nil nil nil nil "*helm mini*" nil nil nil))
(progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda (key) (plist-get plist key))) helm-argument-keys)))
(if (keywordp (car plist)) (progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda (key) (plist-get plist key))) helm-argument-keys))) (apply fn plist))
(if (and helm-alive-p (eq fn (function helm))) (if (helm-alive-p) (error "Error: Trying to run helm within a running helm session") (save-current-buffer (set-buffer (helm-buffer-get)) (prog1 (message "Aborting an helm session running in background") (helm-keyboard-quit)))) (if (keywordp (car plist)) (progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda (key) (plist-get plist key))) helm-argument-keys))) (apply fn plist)))
(let ((fn (cond ((or (and helm-alive-p (plist-get plist :allow-nest)) (and helm-alive-p (memq ... plist))) (function helm-nest)) ((keywordp (car plist)) (function helm)) (t (function helm-internal))))) (if (and helm-alive-p (eq fn (function helm))) (if (helm-alive-p) (error "Error: Trying to run helm within a running helm session") (save-current-buffer (set-buffer (helm-buffer-get)) (prog1 (message "Aborting an helm session running in background") (helm-keyboard-quit)))) (if (keywordp (car plist)) (progn (setq helm--local-variables (append helm--local-variables (helm-parse-keys plist))) (apply fn (mapcar (function (lambda ... ...)) helm-argument-keys))) (apply fn plist))))
helm(:sources (helm-source-buffers-list helm-source-recentf helm-source-buffer-not-found) :buffer "*helm mini*" :ff-transformer-show-only-basename nil :truncate-lines t)
helm-mini()
call-interactively(helm-mini nil nil)
command-execute(helm-mini)
Strangely, if I try to open this file for a second time, it works as expected.
What would be the advised way of fixing this error and / or making leader work in *Messages*
buffer?
Thanks!
First, thanks for the plugin.
I use SPC as my leader.
I'm using the markdown-mode package. This package has a the gfm-mode
as well, which provides GitHub flavored markdown. This mode has markdown-mode
as its parent.
So I have this on my configuration:
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . gfm-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))
(evil-leader/set-key-for-mode 'gfm-mode
"ml" 'markdown-insert-link
)
But when I'm editing a file on gfm-mode, I get "SPC m is undefined".
If I change the evil-leader line to markdown-mode
instead, and if I effectivelly run markdown-mode
, it works. However that doesn't help much because I want to use gfm-mode
(which is derivated from the former).
My complete configuration is available on my dotfiles repository.
Thanks.
secondary leader key could be bound to new commands.
I need this because my hotkeys is almost used up but I have still lots of commands to bind.
evil-leader doesn't seem to be bound in Help buffers despite working in other buffers and evil-mode being enabled in help-mode. Why is it not bound in help-mode?
It would be nice if evil-leader would allow one key to simultaneously be bound to a different action for each evil state.
For example, allow all of the following to be active at the same time:
(evil-leader/set-key-for-mode 'motion 'help-mode "x" 'foo)
(evil-leader/set-key-for-mode 'normal 'help-mode "x" 'bar)
(evil-leader/set-key-for-mode 'insert 'help-mode "x" 'baz)
While set-key-for-mode
is helpful for emacs modes, as far as I can tell there is no way to associate a key with an evil mode (normal-mode, visual-mode for example).
In VIM, one might do this for example:
vmap <leader>r :retab
nmap <leader>r :some_other_function
I couldn't find a way to do this with evil-leader.
Perhaps set-key-for-evil-mode
could be added?
With 0.2.1, I was able to bind leader to SPC via (setq evil-leader/leader " ")
. This no longer works with the latest version.
Vim actually provides two leader keys: <Leader>
and <LocalLeader>
which can be set via mapleader
and maplocalleader
respectively. And as the Vim documentation says:
<LocalLeader>
is just like<Leader>
, except that it uses "maplocalleader" instead of "mapleader".<LocalLeader>
is to be used for mappings which are local to a buffer.
For example in Vim I have bound <Leader>w
to C-w
in order to avoid the control key. This is a command which affect the whole Vim "frame"/tab. I have also bound <LocalLeader>s
to :sort<CR>
in visual mode which only affects a single buffer. While in this case I could bind both with the same leader key it is nice to have different leader keys for different scopes. It would it make possible to have bindings like <Leader>q
for ZZ
and <LocalLeader>q
for :write|bdelete<CR>
for example.
Hi, I'm using evil-leader
for a while now, but now that I want to add this mapping it doesn't work:
(evil-leader/set-key "ls" 'helm-buffer-list)
It gives Wrong type argument: commandp, helm-buffer-list
, I don't know why with this particular function just doesn't work, seeing helm-buffer-list definition it doesn't take any arguments.
Could anyone help, why this particular mapping is not working?
please make it more clear why evil-leader
is useful (either in this issue, but preferably in the readme).
for instance, this also seems to work fine to get some basic "leader key" behaviour:
(defvar my-leader-map
(make-sparse-keymap)
"Keymap for 'leader key' shortcuts.")
(evil-define-key 'normal global-map "," my-leader-map)
(define-key my-leader-map " " 'whitespace-cleanup)
(define-key my-leader-map "b" 'list-buffers)
clearly i'm missing something. please enlighten me. :)
From Vim I am used to typing arbitrary long stuff after pressing leader.
E.g. <leader>ba
to close the current buffer
or <leader>b "
to switch to another buffer.
Debugger entered--Lisp error: (error "Key sequence b SPC starts with non-prefix key b")Debugger entered--Lisp error: (error "Key sequence b SPC starts with non-prefix key b")
If I (setq evil-leader/leader "SPC")
, it doesn't seem to work in Dired but works as expected everywhere else (I have it enabled globally). Setting it to something else, e.g. ,
seems to work fine.
I tried unsetting SPC
with:
(add-hook 'dired-mode-hook '(lambda ()
(local-unset-key (kbd "SPC"))))
but it seems that evil-mode is somehow preventing modifications to that mode map.
Any idea how I can get this to work?
My leader key is assigned to <SPC>
.
(evil-leader/set-leader "<SPC>")
(global-evil-leader-mode)
But now I cannot use <SPC>
in motion mode, in particular:
d<SPC>
to delete one letter under cursor;c<SPC>
to delete one letter under cursor and enter insert mode.Obviously the following line "causes" my problem.
(if evil-leader-mode
(progn
(evil-normalize-keymaps)
(define-key evil-motion-state-local-map no-prefix map) <---------
I assume you cannot simply move the mapping for motion
state under evil-leader/in-all-states
without breaking many current configurations, but perhaps it is possible to create another parameter to control motion
state, enabled by default?
UPDATE: Apparently, without this line leader key will not work in visual
state. So need to find a better solution, rather than the workaround I proposed above.
Is it possible to dynamically assign a key from a variable? Something like this does not work.
(evil-leader/set-key "ax" (make-symbol some-defun-name-as-string))
elpa/evil-leader-20130316.333/evil-leader.el:73: (define-key evil-visual-state-map-state-map key evil-leader/map)))
i have this
(evil-leader/set-key "rr" (lambda (arg)
(load-file "~/.emacs.d/init.el")))
but it doesnt work. it gives me wrong type argument: commandp.
how can i fix that?
Say I there's a bunch of keybindings under the C-c x
prefix already defined, e.g. C-c x s
, C-c x f
etc. Now I want to also have the same bindings under <leader> x s/f/etc
. Is it possible to say something like (evil-leader/set-keys-from-prefix "x" "C-c x")
(assuming the C-c x
bindings are already loaded) instead of hardcoding individual (evil-leader/set-key "x s" #'do-the-x-s-thing "f" #'do-the-x-f-thing …)
?
To reproduce:
emacs -q
Evaluate
(let ((default-directory "/usr/share/emacs/site-lisp"))
(normal-top-level-add-subdirs-to-load-path))
(let ((default-directory "~/.emacs.d/"))
(normal-top-level-add-subdirs-to-load-path))
(require 'evil-leader)
(require 'evil)
(setq evil-leader/in-all-states t)
(evil-leader/set-leader ",")
(global-evil-leader-mode 1)
(evil-mode 1)
(evil-leader/set-key
"tt" 'display-time-mode)
The same example works with
(evil-leader/set-leader "")
Thank you for sharing your code!
Hi Michael,
I'm looking for a way to share leader keys between clojure-mode
, and some derived modes like clojurex-mode
, clojurec-mode
, and clojurescript-mode
.
As these modes are derived I expected all my Clojure leaders keys to work in a cljs
file, but they don't. Before I dig further into copying things around with set-keymap-parent
and keymap--merge-bindings
I wonder, should I expect clojurescript-mode
to pick up clojure-mode
s leader keys?
If not, any recommendation for how best to share these keys would be greatly appreciated! I'm currently thinking of looping over (cdddr (assoc 'clojure-mode evil-leader--mode-maps))
and calling define-key
repeatedly as you do in evil-leader--mode-maps
although that seems a little fragile given I'm relying on private vars…
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.