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).


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'.
  • Will this keymap be applied even if my prompts have nothing to do with filenames?
    – Malabarba
    Jan 8 '15 at 17:05

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):


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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