1

I want to be able to use M-v hotkey in the emacs search mode to paste text. I know I can add the binding to the isearch-mode-map but when I try to bind yank as a method, it yanks the text in the current buffer, not the search input. How can I find which command is invoked when C-y is pressed in the search mode?

egdmitry
  • 2,071
  • 15
  • 18
  • Use `isearch-yank-kill` instead of `yank`. – artscan May 13 '14 at 23:50
  • Try `(lookup-key isearch-mode-map (kbd "C-y"))` – artscan May 13 '14 at 23:52
  • Awesome, thanks! Feel free to answer this. I am also interested on how to be able to find mode maps or key mappings when the minibuffer is used. Are there any tricks to do so? `lookup-key` looks helpful, but how do I find currently used mode maps when I am interacting with something? – egdmitry May 14 '14 at 00:40

2 Answers2

3

Use isearch-yank-kill instead of yank. Try (lookup-key isearch-mode-map (kbd "C-y")). I use minibuffer-inactive-mode-map, minibuffer-local-map, minibuffer-local-completion-map. You can get exhaustive list of maps by C-hv-mapTAB. Function (current-local-map) can help. See also http://www.gnu.org/software/emacs/manual/html_node/elisp/Controlling-Active-Maps.html

Upd.: Name of current local keymap, definition of function keymap-symbol, see https://stackoverflow.com/a/14490054/1937596

If you use

(setq enable-recursive-minibuffers t)

you can, while in minibuffer, call (eval-expression) by hotkey and execute (current-local-map) or (keymap-symbol (current-local-map))

Community
  • 1
  • 1
artscan
  • 2,340
  • 15
  • 26
  • But what would be the way to execute `(current-local-map)` while I am already in the minibuffer for example (or anything that expects some input)? – egdmitry May 14 '14 at 04:20
3

Typing C-sC-hkC-y will tell you:

C-y runs the command isearch-yank-kill.

More generally, type C-hk whilst isearching, followed by the key sequence you want to know about. Analogous to C-hk when you're not searching, of course.

Typing C-hb whilst isearching displays all of the isearch bindings, which is likewise analogous to the output for C-hb when you're not searching.

The other isearch help bindings are C-hm to show you the mode help, and C-hC-h which gives you a menu to all of the above.

phils
  • 71,335
  • 11
  • 153
  • 198