2

I want the current message in the Echo Area to keep showing up until the next message (which will also appear in the *Messages* buffer) is emitted.


But how my Emacs does now is:

$ emacs -q

Use M-x ielm to enter the *ielm* buffer, and let Emacs to emit a message:

ELISP> (message "This is a message.")

Then "This is a message." appears in the Echo Area.
So far, so good, as long as I don't make Emacs execute any commands.

But once Emacs is no longer idle, whether or not a new message is emitted, the "This is a message." in the Echo Area will disappear!

For example, after I move the cursor, the current message will disappear,
even though the *Messages* buffer indicates that there is no new message:

For information about GNU Emacs and the GNU system, type C-h C-a.
This is a message.

See, only two messages so far.

1 Answer 1

1

This is low-level behavior that you cannot change (unless you modify Emacs's C sources and recompile it).

AFAICT, this is done in src/keyboard.c. There is a hook, echo-area-clear-hook, whose value is nil, but we can use it as a search string to find out where it would be run from if it were non-nil. The corresponding name in the C source is Qecho_area_clear_hook (that's a general convention for translating Emacs Lisp names to their equivalent C names - if the latter exist of course), so the search gives:

$ grep -n -e Qecho_area_clear_hook` src/*.c
keyboard.c:1350:      safe_run_hooks (Qecho_area_clear_hook);
keyboard.c:3121:      safe_run_hooks (Qecho_area_clear_hook);
keyboard.c:3174:    safe_run_hooks (Qecho_area_clear_hook);
...

There are three places where the hook is called, so presumably there are three places in the code where the echo area is cleared. The above output was obtained with up-to-date (as of 2023/03/11) upstream sources, but depending on the version, you might get different output (perhaps different line numbers, although I suspect you will still find three places).


With thanks to @Kaligule for providing them in a comment, here are the links to the currently released Emacs 28.2 sources for the three places identified above: 1 2 3.


The three places are in the functions read_char (two places), one of which is presumably what's causing the clearing in the case you describe; and command_loop_1 which seems to be more specialized. You probably should read the read_char function to understand what's going on.

2
  • 1
    Links to the three code occurrences in latest emacs release (28.2): 1, 2, 3
    – Kaligule
    Mar 12, 2023 at 13:02
  • 1
    Thank you for providing the links!
    – NickD
    Mar 12, 2023 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.