summaryrefslogtreecommitdiff
path: root/devdocs/elisp/command-overview.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/command-overview.html')
-rw-r--r--devdocs/elisp/command-overview.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/elisp/command-overview.html b/devdocs/elisp/command-overview.html
new file mode 100644
index 00000000..25d83fda
--- /dev/null
+++ b/devdocs/elisp/command-overview.html
@@ -0,0 +1,12 @@
+ <h3 class="section">Command Loop Overview</h3> <p>The first thing the command loop must do is read a key sequence, which is a sequence of input events that translates into a command. It does this by calling the function <code>read-key-sequence</code>. Lisp programs can also call this function (see <a href="key-sequence-input">Key Sequence Input</a>). They can also read input at a lower level with <code>read-key</code> or <code>read-event</code> (see <a href="reading-one-event">Reading One Event</a>), or discard pending input with <code>discard-input</code> (see <a href="event-input-misc">Event Input Misc</a>). </p> <p>The key sequence is translated into a command through the currently active keymaps. See <a href="key-lookup">Key Lookup</a>, for information on how this is done. The result should be a keyboard macro or an interactively callable function. If the key is <kbd>M-x</kbd>, then it reads the name of another command, which it then calls. This is done by the command <code>execute-extended-command</code> (see <a href="interactive-call">Interactive Call</a>). </p> <p>Prior to executing the command, Emacs runs <code>undo-boundary</code> to create an undo boundary. See <a href="maintaining-undo">Maintaining Undo</a>. </p> <p>To execute a command, Emacs first reads its arguments by calling <code>command-execute</code> (see <a href="interactive-call">Interactive Call</a>). For commands written in Lisp, the <code>interactive</code> specification says how to read the arguments. This may use the prefix argument (see <a href="prefix-command-arguments">Prefix Command Arguments</a>) or may read with prompting in the minibuffer (see <a href="minibuffers">Minibuffers</a>). For example, the command <code>find-file</code> has an <code>interactive</code> specification which says to read a file name using the minibuffer. The function body of <code>find-file</code> does not use the minibuffer, so if you call <code>find-file</code> as a function from Lisp code, you must supply the file name string as an ordinary Lisp function argument. </p> <p>If the command is a keyboard macro (i.e., a string or vector), Emacs executes it using <code>execute-kbd-macro</code> (see <a href="keyboard-macros">Keyboard Macros</a>). </p> <dl> <dt id="pre-command-hook">Variable: <strong>pre-command-hook</strong>
+</dt> <dd><p>This normal hook is run by the editor command loop before it executes each command. At that time, <code>this-command</code> contains the command that is about to run, and <code>last-command</code> describes the previous command. See <a href="command-loop-info">Command Loop Info</a>. </p></dd>
+</dl> <dl> <dt id="post-command-hook">Variable: <strong>post-command-hook</strong>
+</dt> <dd>
+<p>This normal hook is run by the editor command loop after it executes each command (including commands terminated prematurely by quitting or by errors). At that time, <code>this-command</code> refers to the command that just ran, and <code>last-command</code> refers to the command before that. </p> <p>This hook is also run when Emacs first enters the command loop (at which point <code>this-command</code> and <code>last-command</code> are both <code>nil</code>). </p>
+</dd>
+</dl> <p>Quitting is suppressed while running <code>pre-command-hook</code> and <code>post-command-hook</code>. If an error happens while executing one of these hooks, it does not terminate execution of the hook; instead the error is silenced and the function in which the error occurred is removed from the hook. </p> <p>A request coming into the Emacs server (see <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server">Emacs Server</a> in <cite>The GNU Emacs Manual</cite>) runs these two hooks just as a keyboard command does. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Command-Overview.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Command-Overview.html</a>
+ </p>
+</div>