本文介绍了如何重新定义“微型缓冲器”内的键模式的地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重新定义用于浏览历史记录的密钥,当内部的几个命令接受正则表达式并提供C-p / C-n历史记录导航。除了C-p / C-n之外,我想使用其他键。例如,当使用 replace-regexp 时,Cp和Cn可用于转到上一个和下一个元素。



我已经尝试了几件事情,但是不能使它工作。我想我在这里缺少大图。



我需要修改哪个模式图,何时和如何?我尝试的一切都失败了。



PS:请注意,我已经拥有自己的小模式,所有的键盘映射都是在这里提供的。

解决方案

要添加到@lawlist表示的内容(这是绑定密钥在 minibuffer-local-map ):



有多个minibuffer键盘映射,取决于在minibuffer中读取的内容以及如何。您可能想要使用哪些键映射取决于您正在使用哪个Emacs版本。



此外,还有与缓冲区交互的键盘映射 * Completions * 完成列表模式映射



为了在minibuffer中完成,主键映射是 minibuffer-local-完成地图



以下是一个列表的minibuffer键盘图。其中一些可能不适用于您的Emacs版本。




  • minibuffer-local-map

  • minibuffer-local-ns-map

  • minibuffer-local-isearch-map

  • minibuffer-local-completion-map li>
  • minibuffer-local-must-match-map

  • minibuffer- local-filename-completion-map

  • minibuffer-local-filename-must-match-map / li>
  • minibuffer-local-must-match-filename-map



此外,您可以使用 minibuffer-with-setup-hook (或 minibuffer-setup-hook 直接)在单个minibuffer读取期间即时添加键绑定。



我将添加此信息,因为它可以真正有用您正在操作minibuffer键盘映射:您可以使用 Ch Mk (命令 describe-keymap ),从库,以人类可读的形式查看给定minibuffer键盘映射的所有绑定。


I'm trying to redefine the keys used to navigate the history when inside several commands accepting regexps and offering C-p / C-n history navigation. I'd like to use other keys, in addition to C-p / C-n. For example when using occur or replace-regexp, C-p and C-n can be used to go to previous and next elements.

I've tried several things but can't make it work. I think I'm missing the "big picture" here.

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

P.S: Note that I've got my own minor mode with all my keymaps as adviced here.

解决方案

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

There are multiple minibuffer keymaps, depending on what is being read in the minibuffer, and how. And which of those keymaps you might want to use can depend on which Emacs version you are using.

In addition, there is also the keymap for interaction with buffer *Completions*: completion-list-mode-map.

For completion in the minibuffer, the main keymap is minibuffer-local-completion-map.

Here is a list of the minibuffer keymaps. Some of these might not be available (used) in your Emacs version.

  • 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 use minibuffer-with-setup-hook (or minibuffer-setup-hook directly) to add key bindings on the fly, for the duration of a single minibuffer reading.

I will add this info, since it can be really helpful when you are manipulating minibuffer keymaps: You can use C-h M-k (command describe-keymap), from library help-fns+.el, to see all of the bindings of a given minibuffer keymap in human-readable form.

这篇关于如何重新定义“微型缓冲器”内的键模式的地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 17:12