键入C-x时Emacs迷你缓冲消息

时间:2011-10-16 12:32:50

标签: emacs elisp

好。当我输入密钥系列的一些第一个密钥时,emacs会在一段时间后将这些密钥写入迷你缓冲区。这样:键入C-x 4会使C-x 4-在迷你缓冲区中可见。

问题是:可以修改吗?我正在考虑制作一些类似于将键帮助(由C-h生成时键入一些键)与此字符串组合在一起的内容。 等待此消息的间隔也可以缩短吗? 它是子程序吗?

已编辑,新问题

当我退出带有C-x C-c的emacs并且有修改过的缓冲区时,会有一条消息,询问我是否要保存它们。 我怎么知道此消息在这里?我试图查看(minibuffer-prompt) (minibuffer-contents) (buffer-substring (point-min) (point-max)),选择(select-window (minibuffer-window))。什么都没有给我带来结果。

3 个答案:

答案 0 :(得分:7)

是的,用户选项echo-keystrokes控制在迷你缓冲区中显示前缀键之前经过的时间。来自(emacs)Echo Area Customization

User Option: echo-keystrokes
     This variable determines how much time should elapse before command
     characters echo.  Its value must be an integer or floating point
     number, which specifies the number of seconds to wait before
     echoing.  If the user types a prefix key (such as `C-x') and then
     delays this many seconds before continuing, the prefix key is
     echoed in the echo area.  (Once echoing begins in a key sequence,
     all subsequent characters in the same key sequence are echoed
     immediately.)

     If the value is zero, then command input is not echoed.

答案 1 :(得分:1)

您可以通过将suggest-key-bindings设置为更大/更小的数字来控制此帮助消息的时间。

(setq suggest-key-bindings 5) ; wait 5 seconds

没有简单的方法来自定义行为,您必须编辑execute-extended-command的C代码,或使用替换它也提供帮助。替换的一种可能性是anything-complete库,它替换了execute-extended-command(注意:我没有尝试过)。它建立在包anything之上,这与标准的Emacs不同。

答案 2 :(得分:0)

I wrote working version of what I wanted to implement.

要使用(require 'keylist),请将最后一行或两行复制到.emacs并取消注释。

正如您可以看到这段代码,我使用了这个

(not cursor-in-echo-area)
(not (minibufferp))
(not (= 13 (aref (this-command-keys-vector) 0)))

了解我的迷你缓冲区或回声区域是否正在使用中。 它们之间的区别在于迷你缓冲区用于读取,而回波区域用于发送消息。 当您键入C-x C-c光标放在回显区域时,cursor-in-echo-area的值会更改。

最后一个字符串(= 13 (aref (this-command-keys-vector) 0))是最有趣的。它用于捕捉query-replace之类的内容。进行替换时,(this-command-keys-vector)显示RET是第一个按下的键,然后是你的选择键(y,n)。至于我没有以RET开头的键序列,我对此感到满意。