3

In one of my packages, I use a loop with completing-read to query the user for a list of words. Inside the prompt, I'd like to bind DEL to a different command.

How can I achieve that?

The solution also needs to work with ido-completing-read (possibly with small modifications of course).

2 Answers 2

1

There are of course keymaps you can bind stuff to. For example you could temporarily merge minibuffer-local-filename-completion-map with your extra keys. From the documentation:

Local keymap for minibuffer input with completion for filenames.
Gets combined either with `minibuffer-local-completion-map' or
with `minibuffer-local-must-match-map'.
1
  • Will this keymap be applied even if my prompts have nothing to do with filenames?
    – Malabarba
    Commented Jan 8, 2015 at 17:05
1

Just have your command bind the key you want in the appropriate minibuffer keymap, and then unbind it there when the command is done.

[You do not need to merge keymaps. You just need to bind the key in a map that is already being used (whether it was merged or not).]

The minibuffer keymaps that involve completion (depending on your Emacs version):

minibuffer-local-completion-map  
minibuffer-local-filename-completion-map
minibuffer-local-filename-must-match-map        
minibuffer-local-must-match-filename-map
minibuffer-local-must-match-map 

Your Answer

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

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