How to redefine the key inside the minibuffer mode card?

I am trying to redefine the keys used to navigate history when, within several commands, it accepts regular expressions and offers Cp / Cn history navigation. I would like to use keys other than Cp / Cn. For example, when using the replace or regexp function, Cp and Cn can be used to skip to the previous and next elements.

I tried a few things, but can't get it to work. I think the "big picture" is missing here.

Which mode map do I need to change, when and how? Everything I tried failed.

PS: Please note that I have my own minor mode with all my layouts, as described here.

+6
source share
2 answers

I assume that you just need minibuffer-local-map . Subsequent definitions using keys previously assigned to this key card will exceed previous definitions. To disable key pre-assignment, simply create a new definition and set the last part to nil instead of 'function-name .

 (define-key minibuffer-local-map (kbd "<f6>") 'help-for-help) 

Here is an excerpt from Emacs Trunk .../lisp/bindings.el :

 (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) (define-key map [next] 'next-history-element) (define-key map [down] 'next-history-element) (define-key map [XF86Forward] 'next-history-element) (define-key map "\ep" 'previous-history-element) (define-key map [prior] 'previous-history-element) (define-key map [up] 'previous-history-element) (define-key map [XF86Back] 'previous-history-element) (define-key map "\es" 'next-matching-history-element) (define-key map "\er" 'previous-matching-history-element) ;; Override the global binding (which calls indent-relative via ;; indent-for-tab-command). The alignment that indent-relative tries to ;; do doesn't make much sense here since the prompt messes it up. (define-key map "\t" 'self-insert-command) (define-key map [C-tab] 'file-cache-minibuffer-complete)) 
+5
source

To add to what @lawlist said (which was supposed to bind the key in minibuffer-local-map ):

There are several mini-buffers, mini-buffers, depending on what is read in the minibuffer and how. And which of these layouts you might want to use may depend on which version of Emacs you are using.

In addition, there is also a key combination for interacting with the *Completions* : completion-list-mode-map buffer.

To complete the minibuffer operation, the main layout is minibuffer-local-completion-map .

Here is a list of mini buffers. Some of them may not be available (used) in your version of Emacs.

  • minibuffer-local-map
  • minibuffer-local-ns-map
  • minibuffer-local-isearch-map
  • minibuffer-local-completion-map
  • minibuffer-local-must-match-map
  • minibuffer-local-filename-completion-map
  • minibuffer-local-filename-must-match-map
  • minibuffer-local-must-match-filename-map

In addition, you can directly use minibuffer-with-setup-hook (or minibuffer-setup-hook ) to add on-the-fly key bindings throughout the minibuffer.

I will add this information, as it can be very useful when manipulating mini-buffers: you can use Ch Mk (the describe-keymap ), from the help-fns+.el , to see all the bindings of the given mini-buffer keyboard in a readable form .

+5
source

Source: https://habr.com/ru/post/957298/


All Articles