1

I'm editing my keybinds mode-by-mode, and I've now come to the query-replace-map.

I want to define my keybinds in a mode-hook to keep my files logically consistent, but I cannot determine which mode the command query-replace activates.

I've tried M-x describe-mode, but activating the minibuffer immediately disables query-replace, thus I cannot look at the list of modes the buffer is currently in.

Or are query-replace/isearch-query-replace even modes?
If not, what sort of functionality is this, and how should I handle the rebinding of keys in these peculiarities (using mode-hooks or any other method that I might not know of)?

Also are there any other caveats when dealing with these pseudo-modes?

2

query-replace is just a command, it is not a major or minor mode. Before the phase in which it prompts for what to do with each match, it has no special bindings and uses minibuffer-local-map (this is where the usual keys for input history, M-r, M-p and M-n are bound, for example). The second phase uses query-replace-map.

If there is a particular keybinding you want to change, in recent versions of Emacs you can find out which keymap contains it by using describe-key (bound by default to C-h k). You can usually use that even while a command is prompting you in the minibuffer, which is how I found that M-r is bound in minibuffer-local-map

Unfortunately, that doesn't work for keys in the second phase of query-replace! So how did I find out what map is used then? Well, since it's name starts with query-replace-map I could have simply guessed, but what I actually did was read the source code of query-replace (which led me to perform-replace which is where query-replace-map is used).

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.