简体   繁体   中英

Emacs: How to change “M-x” prompt to something else?

I have execute-extended-command bound to alt+a. So when in minibuffer, when i press it, the read-only prompt saying "Mx" is irrelevant for me. I want to change it to something else like "execute command:". How can i do that?

This prompt is hard-coded. You would need to either redefine read-extended-command , or advise completing-read (but that seems a fairly tenuous approach).

See Mx find-function RET read-extended-command RET

There are comments in the code referring to this very issue:

;; 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: ".

Honestly, given the lack of a clean solution, I wouldn't bother trying to do this.

Check out smex , which is an improvement upon the built-in execute-extended-command ; it allows you to customize the prompt via the variable smex-prompt-string .

Or, if you've got the Emacs source installed, you can jump straight to the implementation: just Mx find-function RET execute-extended-command RET

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM