2

ibuffer uses / as a prefix key for filter commands, like ibuffer-filter-by-name (/n).

As an evil user, I wanted to use a different prefix, since evil uses / for searching.

I use space as a leader-key, so I decided to put the filter commands behind space/.

The ibuffer / prefix is an anonymous keymap, so I had to bind my new key to the result of a lookup-key call:

(bind-map-for-mode-inherit ivan/ibuffer-leader-map ivan/leader-map
  :major-modes (ibuffer-mode)
  :bindings
  ("/" (lookup-key ibuffer-mode-map "/")))  ; <= here

It works, but is there a cleaner way to do it?

I say it's an anonymous keymap because I wasn't able to find any variable bound to it. Running (lookup-key ibuffer-mode-map "/") just prints out the keymap body:

(keymap
 (92 . ibuffer-clear-filter-groups)
 ...
 (109 . ibuffer-filter-by-used-mode))

1 Answer 1

2

It looks like the answer is yes, you are right. And there is no cleaner way to deal with it - but see below, for one suggestion.

I'd suggest filing an enhancement request that Emacs add a variable for this keymap: M-x report-emacs-bug.

You can of course define your own map variable for this, basing its value on the current ibuffer.el code. But that won't automatically pick up future changes to the Ibuffer code.

In general, I think it is a good idea for prefix keys to have associated keymap variables. That makes it easy for users to, e.g., move such a map to a different prefix key.

1
  • 1
    I liked your suggestion. I just filed an enhancement request.
    – ivan
    Feb 19, 2017 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.