2

I'm reading (info "(elisp) Command Overview"):

Variable: post-command-hook
: ... ...
: This hook is also run when Emacs first enters the command loop (at which point this-command and last-command are both nil).

Users may need to know the exact time point referred to here to determine how to utilize this feature. But after searching in (info "(elisp) Startup Summary"), no relevant information was found.

1 Answer 1

3

The sequence to entering the command loop for the first time is:

main()                  /* defined in src/emacs.c */
Frecursive_edit()       /* defined in src/keyboard.c */
recursive_edit_1()      /* ditto */
command_loop()          /* ditto */
5
  • The manual (Summary: Sequence of Actions at Startup) currently says that Emacs starts mainly through 31 steps. I just want to figure out at which step the time mentioned in the question falls, or between which two steps.
    – shynur
    Aug 10, 2023 at 6:11
  • 1
    Calling normal-top-level (and hence all of those listed steps) is (essentially) the very first thing that command_loop does.
    – phils
    Aug 10, 2023 at 6:42
  • I suspect the call to post-command-hook in question will be the one near the top of command_loop_1. There are things about that code which I do not understand, though, so I can't say much more about it.
    – phils
    Aug 10, 2023 at 6:58
  • It seems that whether to mention "post-command-hook is also run when Emacs first enters the command loop" in the manual is not important, because its value cannot be changed at the beginning of startup unless you modify Emacs C source code.
    – shynur
    Aug 10, 2023 at 7:01
  • Perhaps the note is for users who are dumping their own Emacs executable. That might be a way to give it an initial non-nil value before the command loop is entered.
    – phils
    Aug 10, 2023 at 7:04

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.