Rebinded key becomes un-changeable
Hi, I have this code to inherite most of the ibuffer key bindings while still keep the "j" and "k" bindings. (eval-after-load 'ibuffer '(progn ;; use the standard ibuffer bindings as a base (set-keymap-parent (evil-get-auxiliary-keymap ibuffer-mode-map 'normal t) (assq-delete-all 'menu-bar (copy-keymap ibuffer-mode-map))) (evil-define-key 'normal ibuffer-mode-map "j" 'ibuffer-forward-line) (evil-define-key 'normal ibuffer-mode-map "k" 'ibuffer-backward-line) (evil-define-key 'normal ibuffer-mode-map "J" 'ibuffer-jump-to-buffer) ; "j" )) This works fine however if I rebind the <backspace> before the previous code like this: (define-key evil-normal-state-map (kbd "<backspace>") 'scroll-down) The <backspace> key would then "fixed" to my binding (scroll-down) instead of the ibuffer binding. Is there any "better" way of rebinding evil keys? Or, is it possible for Evil to handle this situation? Thanks, York
I finally got the <backspace> binded in ibuffer by "forcing" rebind like this: (eval-after-load 'ibuffer '(progn ;; use the standard ibuffer bindings as a base (set-keymap-parent (evil-get-auxiliary-keymap ibuffer-mode-map 'normal t) (assq-delete-all 'menu-bar (copy-keymap ibuffer-mode-map))) (evil-define-key 'normal ibuffer-mode-map "j" 'ibuffer-forward-line) (evil-define-key 'normal ibuffer-mode-map "k" 'ibuffer-backward-line) (evil-define-key 'normal ibuffer-mode-map "J" 'ibuffer-jump-to-buffer) ; "j" (evil-define-key 'normal ibuffer-mode-map (kbd "DEL") 'ibuffer-unmark-backward))) But the question is: why wasn't this binding "overwritten" from the "copy-keymap"? Thanks, York On Thu, Aug 11, 2011 at 3:04 PM, York Zhao <[email protected]> wrote: Hi, I have this code to inherite most of the ibuffer key bindings while still keep the "j" and "k" bindings. (eval-after-load 'ibuffer '(progn ;; use the standard ibuffer bindings as a base (set-keymap-parent (evil-get-auxiliary-keymap ibuffer-mode-map 'normal t) (assq-delete-all 'menu-bar (copy-keymap ibuffer-mode-map))) (evil-define-key 'normal ibuffer-mode-map "j" 'ibuffer-forward-line) (evil-define-key 'normal ibuffer-mode-map "k" 'ibuffer-backward-line) (evil-define-key 'normal ibuffer-mode-map "J" 'ibuffer-jump-to-buffer) ; "j" )) This works fine however if I rebind the <backspace> before the previous code like this: (define-key evil-normal-state-map (kbd "<backspace>") 'scroll-down) The <backspace> key would then "fixed" to my binding (scroll-down) instead of the ibuffer binding. Is there any "better" way of rebinding evil keys? Or, is it possible for Evil to handle this situation? Thanks, York
Sorry, (kbd "DEL") doesn't work, should be (kbd "<backspace>"). I thought they were the same. On Thu, Aug 11, 2011 at 3:19 PM, York Zhao <[email protected]> wrote: I finally got the <backspace> binded in ibuffer by "forcing" rebind like this: (eval-after-load 'ibuffer '(progn ;; use the standard ibuffer bindings as a base (set-keymap-parent (evil-get-auxiliary-keymap ibuffer-mode-map 'normal t) (assq-delete-all 'menu-bar (copy-keymap ibuffer-mode-map))) (evil-define-key 'normal ibuffer-mode-map "j" 'ibuffer-forward-line) (evil-define-key 'normal ibuffer-mode-map "k" 'ibuffer-backward-line) (evil-define-key 'normal ibuffer-mode-map "J" 'ibuffer-jump-to-buffer) ; "j" (evil-define-key 'normal ibuffer-mode-map (kbd "DEL") 'ibuffer-unmark-backward))) But the question is: why wasn't this binding "overwritten" from the "copy-keymap"? Thanks, York On Thu, Aug 11, 2011 at 3:04 PM, York Zhao <[email protected]> wrote: Hi, I have this code to inherite most of the ibuffer key bindings while still keep the "j" and "k" bindings. (eval-after-load 'ibuffer '(progn ;; use the standard ibuffer bindings as a base (set-keymap-parent (evil-get-auxiliary-keymap ibuffer-mode-map 'normal t) (assq-delete-all 'menu-bar (copy-keymap ibuffer-mode-map))) (evil-define-key 'normal ibuffer-mode-map "j" 'ibuffer-forward-line) (evil-define-key 'normal ibuffer-mode-map "k" 'ibuffer-backward-line) (evil-define-key 'normal ibuffer-mode-map "J" 'ibuffer-jump-to-buffer) ; "j" )) This works fine however if I rebind the <backspace> before the previous code like this: (define-key evil-normal-state-map (kbd "<backspace>") 'scroll-down) The <backspace> key would then "fixed" to my binding (scroll-down) instead of the ibuffer binding. Is there any "better" way of rebinding evil keys? Or, is it possible for Evil to handle this situation? Thanks, York
On 2011-08-11 21:04 +0200, York Zhao wrote:
I have this code to inherite most of the ibuffer key bindings while still keep the "j" and "k" bindings. ... This works fine however if I rebind the <backspace> before the previous code like this:
(define-key evil-normal-state-map (kbd "<backspace>") 'scroll-down)
The <backspace> key would then "fixed" to my binding (scroll-down) instead of the ibuffer binding.
This is because the key binding for (kbd "<backspace>") prevents the <backspace> event from being translated into the ASCII character DEL (that is, ?\d), which is what ibuffer binds. The immediate solution is therefore to add a binding for <backspace> instead: (evil-define-key 'normal ibuffer-mode-map (kbd "<backspace>") 'ibuffer-unmark-backward) However, there is a problem: <backspace> bindings aren't recognized at all when running Emacs in the terminal, where Backspace /is/ DEL. So Evil should always bind (kbd "DEL") instead of (kbd "<backspace>"). This has been fixed in commit 8fc3c40. -- Vegard
The immediate solution is therefore to add a binding for <backspace> instead
That was exactly what I was doing before getting the commit 8fc3c40, but now I no long need this workaround, thanks a lot and thank you for telling me the difference between the two. York On Fri, Aug 12, 2011 at 10:07 AM, Vegard Øye <[email protected]> wrote: On 2011-08-11 21:04 +0200, York Zhao wrote:
I have this code to inherite most of the ibuffer key bindings while still keep the "j" and "k" bindings. ... This works fine however if I rebind the <backspace> before the previous code like this:
(define-key evil-normal-state-map (kbd "<backspace>") 'scroll-down)
The <backspace> key would then "fixed" to my binding (scroll-down) instead of the ibuffer binding.
This is because the key binding for (kbd "<backspace>") prevents the <backspace> event from being translated into the ASCII character DEL (that is, ?\d), which is what ibuffer binds. The immediate solution is therefore to add a binding for <backspace> instead: (evil-define-key 'normal ibuffer-mode-map (kbd "<backspace>") 'ibuffer-unmark-backward) However, there is a problem: <backspace> bindings aren't recognized at all when running Emacs in the terminal, where Backspace /is/ DEL. So Evil should always bind (kbd "DEL") instead of (kbd "<backspace>"). This has been fixed in commit 8fc3c40. -- Vegard _______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
participants (2)
-
Vegard Øye -
York Zhao