summaryrefslogtreecommitdiff
path: root/devdocs/elisp/command-history.html
blob: c10cfdadf2627f5f83f1d5d9ec44ec3648a7b93f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 <h3 class="section">Command History</h3>    <p>The command loop keeps a history of the complex commands that have been executed, to make it convenient to repeat these commands. A <em>complex command</em> is one for which the interactive argument reading uses the minibuffer. This includes any <kbd>M-x</kbd> command, any <kbd>M-:</kbd> command, and any command whose <code>interactive</code> specification reads an argument from the minibuffer. Explicit use of the minibuffer during the execution of the command itself does not cause the command to be considered complex. </p> <dl> <dt id="command-history">Variable: <strong>command-history</strong>
</dt> <dd>
<p>This variable’s value is a list of recent complex commands, each represented as a form to evaluate. It continues to accumulate all complex commands for the duration of the editing session, but when it reaches the maximum size (see <a href="minibuffer-history">Minibuffer History</a>), the oldest elements are deleted as new ones are added. </p> <div class="example"> <pre class="example">command-history
⇒ ((switch-to-buffer "chistory.texi")
    (describe-key "^X^[")
    (visit-tags-table "~/emacs/src/")
    (find-tag "repeat-complex-command"))
</pre>
</div> </dd>
</dl> <p>This history list is actually a special case of minibuffer history (see <a href="minibuffer-history">Minibuffer History</a>), with one special twist: the elements are expressions rather than strings. </p> <p>There are a number of commands devoted to the editing and recall of previous commands. The commands <code>repeat-complex-command</code>, and <code>list-command-history</code> are described in the user manual (see <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Repetition.html#Repetition">Repetition</a> in <cite>The GNU Emacs Manual</cite>). Within the minibuffer, the usual minibuffer history commands are available. </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-History.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Command-History.html</a>
  </p>
</div>