Emacs:如何将“M-x”提示更改为其他内容?

时间:2012-03-26 10:37:35

标签: emacs

execute-extended-command绑定了alt + a。因此,当我在迷你缓冲区中按下它时,只读“M-x”的提示对我来说无关紧要。我想将其更改为“执行命令:”之类的其他内容。我怎么能这样做?

2 个答案:

答案 0 :(得分:6)

此提示是硬编码的。您需要重新定义read-extended-command,或建议completing-read(但这似乎是一种相当脆弱的方法)。

参见 M-x find-function RET read-extended-command RET

代码中有评论指的是这个问题:

;; This isn't strictly correct if `execute-extended-command'
;; is bound to anything else (e.g. [menu]).
;; It could use (key-description (this-single-command-keys)),
;; but actually a prompt other than "M-x" would be confusing,
;; because "M-x" is a well-known prompt to read a command
;; and it serves as a shorthand for "Extended command: ".

老实说,鉴于缺乏一个干净的解决方案,我不打算尝试这样做。

答案 1 :(得分:5)

查看smex,这是对内置execute-extended-command的改进;它允许您通过变量smex-prompt-string自定义提示。

或者,如果你已经安装了Emacs源代码,你可以直接跳转到实现:只需 Mx find-function RET execute-extended-command RET