desudesudesu
desudesudesu

Reputation: 2335

Emacs minibuffer message when typing C-x

Well. When I type some first keys of the key series, emacs write those keys in minibuffer after some interval of time. Like that: Typing C-x 4 will make C-x 4- visible in minibuffer.

The question is: can this be modified? I was thinking about making something like combining part of key-help (generated by C-h when type some keys) with this string. Can interval for waiting this message be shorten too? Is it subroutine?

Edited, new question

There is a message when I quit emacs with C-x C-c and have modified buffers, that ask me if I want to save them. How can I know that this message is here? I tried to look in (minibuffer-prompt) (minibuffer-contents) (buffer-substring (point-min) (point-max)), selecting (select-window (minibuffer-window)). Nothing gives me results.

Upvotes: 5

Views: 1102

Answers (3)

Drew
Drew

Reputation: 30699

Yes, the user option echo-keystrokes controls how much time elapses before the prefix key is shown in the minibuffer. From (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.

Upvotes: 7

desudesudesu
desudesudesu

Reputation: 2335

I wrote working version of what I wanted to implement.

To use, (require 'keylist), copy one or two last lines to .emacs and uncomment them.

As you can see through this code, I used this

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

to find out, if my minibuffer, or echo area is in use. The difference between them is that minibuffer is used to read, and echo area is used to message something. When you type C-x C-c cursor is placed in echo area, and value of cursor-in-echo-area is changed.

The last string (= 13 (aref (this-command-keys-vector) 0)) is the most funny. It is used to catch things like query-replace. When making raplacements, (this-command-keys-vector) shows that RET is the first key pressed, then keys of your choise(y,n). As far as I don't have key-sequences starting with RET, i am okay with this.

Upvotes: 0

Trey Jackson
Trey Jackson

Reputation: 74450

You can control the timing of this help message by setting suggest-key-bindings to a larger/smaller number.

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

There is no easy way to customize the behavior, you'd have to edit the C code for execute-extended-command, or use a replacement for it which also provides the help. One possibility for a replacement is the anything-complete library which has a replacement for execute-extended-command (note: I haven't tried it). It builds on top of the package anything, which is a different experience than the standard Emacs.

Upvotes: 1

Related Questions