mini.texi 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. @node Minibuffer, M-x, Undo, Top
  2. @chapter The Minibuffer
  3. @cindex minibuffer
  4. The @dfn{minibuffer} is the facility used by XEmacs commands to read
  5. arguments more complicated than a single number. Minibuffer arguments
  6. can be file names, buffer names, Lisp function names, XEmacs command
  7. names, Lisp expressions, and many other things, depending on the command
  8. reading the argument. You can use the usual XEmacs editing commands in
  9. the minibuffer to edit the argument text.
  10. @cindex prompt
  11. When the minibuffer is in use, it appears in the echo area, and the
  12. cursor moves there. The beginning of the minibuffer line displays a
  13. @dfn{prompt} which says what kind of input you should supply and how it
  14. will be used. Often this prompt is derived from the name of the command
  15. that the argument is for. The prompt normally ends with a colon.
  16. @cindex default argument
  17. Sometimes a @dfn{default argument} appears in parentheses after the
  18. colon; it, too, is part of the prompt. The default is used as the
  19. argument value if you enter an empty argument (e.g., by just typing @key{RET}).
  20. For example, commands that read buffer names always show a default, which
  21. is the name of the buffer that will be used if you type just @key{RET}.
  22. @kindex C-g
  23. The simplest way to enter a minibuffer argument is to type the text
  24. you want, terminated by @key{RET} which exits the minibuffer. You can
  25. cancel the command that wants the argument, and get out of the
  26. minibuffer, by typing @kbd{C-g}.
  27. Since the minibuffer uses the screen space of the echo area, it can
  28. conflict with other ways XEmacs customarily uses the echo area. Here is
  29. how XEmacs handles such conflicts:
  30. @itemize @bullet
  31. @item
  32. If a command gets an error while you are in the minibuffer, this does
  33. not cancel the minibuffer. However, the echo area is needed for the
  34. error message and therefore the minibuffer itself is hidden for a
  35. while. It comes back after a few seconds, or as soon as you type
  36. anything.
  37. @item
  38. If in the minibuffer you use a command whose purpose is to print a
  39. message in the echo area, such as @kbd{C-x =}, the message is printed
  40. normally, and the minibuffer is hidden for a while. It comes back
  41. after a few seconds, or as soon as you type anything.
  42. @item
  43. Echoing of keystrokes does not take place while the minibuffer is in
  44. use.
  45. @end itemize
  46. @menu
  47. * File: Minibuffer File. Entering file names with the minibuffer.
  48. * Edit: Minibuffer Edit. How to edit in the minibuffer.
  49. * Completion:: An abbreviation facility for minibuffer input.
  50. * Minibuffer History:: Reusing recent minibuffer arguments.
  51. * Repetition:: Re-executing commands that used the minibuffer.
  52. @end menu
  53. @node Minibuffer File, Minibuffer Edit, Minibuffer, Minibuffer
  54. @section Minibuffers for File Names
  55. Sometimes the minibuffer starts out with text in it. For example, when
  56. you are supposed to give a file name, the minibuffer starts out containing
  57. the @dfn{default directory}, which ends with a slash. This is to inform
  58. you which directory the file will be found in if you do not specify a
  59. directory.
  60. For example, the minibuffer might start out with these contents:
  61. @example
  62. Find File: /u2/emacs/src/
  63. @end example
  64. @noindent
  65. where @samp{Find File:@: } is the prompt. Typing @kbd{buffer.c}
  66. specifies the file @file{/u2/emacs/src/buffer.c}. To find files in
  67. nearby directories, use @kbd{..}; thus, if you type
  68. @kbd{../lisp/simple.el}, you will get the file named
  69. @file{/u2/emacs/lisp/simple.el}. Alternatively, you can kill with
  70. @kbd{M-@key{DEL}} the directory names you don't want (@pxref{Words}).
  71. If you don't want any of the default, you can kill it with @kbd{C-a
  72. C-k}. But you don't need to kill the default; you can simply ignore it.
  73. Insert an absolute file name, one starting with a slash or a tilde,
  74. after the default directory. For example, to specify the file
  75. @file{/etc/termcap}, just insert that name, giving these minibuffer
  76. contents:
  77. @example
  78. Find File: /u2/emacs/src//etc/termcap
  79. @end example
  80. @noindent
  81. @cindex // in file name
  82. @cindex double slash in file name
  83. @cindex slashes repeated in file name
  84. XEmacs gives a special meaning to a double slash (which is not normally
  85. a useful thing to write): it means, ``ignore everything before the
  86. second slash in the pair.'' Thus, @samp{/u2/emacs/src/} is ignored in
  87. the example above, and you get the file @file{/etc/termcap}.
  88. @vindex insert-default-directory
  89. If you set @code{insert-default-directory} to @code{nil}, the default
  90. directory is not inserted in the minibuffer. This way, the minibuffer
  91. starts out empty. But the name you type, if relative, is still
  92. interpreted with respect to the same default directory.
  93. @node Minibuffer Edit, Completion, Minibuffer File, Minibuffer
  94. @section Editing in the Minibuffer
  95. The minibuffer is an XEmacs buffer (albeit a peculiar one), and the
  96. usual XEmacs commands are available for editing the text of an argument
  97. you are entering.
  98. Since @key{RET} in the minibuffer is defined to exit the minibuffer,
  99. you can't use it to insert a newline in the minibuffer. To do that,
  100. type @kbd{C-o} or @kbd{C-q C-j}. (Recall that a newline is really the
  101. character control-J.)
  102. The minibuffer has its own window which always has space on the screen
  103. but acts as if it were not there when the minibuffer is not in use.
  104. When the minibuffer is in use, its window is just like the others; you
  105. can switch to another window with @kbd{C-x o}, edit text in other
  106. windows and perhaps even visit more files, before returning to the
  107. minibuffer to submit the argument. You can kill text in another window,
  108. return to the minibuffer window, and then yank the text to use it in the
  109. argument. @xref{Windows}.
  110. There are some restrictions on the use of the minibuffer window,
  111. however. You cannot switch buffers in it---the minibuffer and its
  112. window are permanently attached. Also, you cannot split or kill the
  113. minibuffer window. But you can make it taller in the normal fashion with
  114. @kbd{C-x ^}. If you enable Resize-Minibuffer mode, then the
  115. minibuffer window expands vertically as necessary to hold the text that
  116. you put in the minibuffer. Use @kbd{M-x resize-minibuffer-mode} to
  117. enable or disable this minor mode (@pxref{Minor Modes}).
  118. @kindex C-M-v
  119. If while in the minibuffer you issue a command that displays help text
  120. of any sort in another window, you can use the @kbd{C-M-v} command while
  121. in the minibuffer to scroll the help text. This lasts until you exit
  122. the minibuffer. This feature is especially useful if a completing
  123. minibuffer gives you a list of possible completions. @xref{Other Window}.
  124. @vindex minibuffer-confirm-incomplete
  125. If the variable @code{minibuffer-confirm-incomplete} is @code{t}, you
  126. are asked for confirmation if there is no known completion for the text
  127. you typed. For example, if you attempted to visit a non-existent file,
  128. the minibuffer might read:
  129. @example
  130. Find File: chocolate_bar.c [no completions, confirm]
  131. @end example
  132. If you press @kbd{Return} again, that confirms the filename. Otherwise,
  133. you can continue editing it.
  134. XEmacs supports recursive use of the minibuffer. However, it is easy
  135. to do this by accident (because of autorepeating keyboards, for example)
  136. and get confused. Therefore, most XEmacs commands that use the
  137. minibuffer refuse to operate if the minibuffer window is selected. If
  138. the minibuffer is active but you have switched to a different window,
  139. recursive use of the minibuffer is allowed---if you know enough to try
  140. to do this, you probably will not get confused.
  141. @vindex enable-recursive-minibuffers
  142. If you set the variable @code{enable-recursive-minibuffers} to a
  143. non-@code{nil}, recursive use of the minibuffer is always allowed.
  144. @node Completion, Minibuffer History, Minibuffer Edit, Minibuffer
  145. @section Completion
  146. @cindex completion
  147. For certain kinds of arguments, you can use @dfn{completion} to enter
  148. the argument value. Completion means that you type part of the
  149. argument, then XEmacs visibly fills in the rest, or as much as
  150. can be determined from the part you have typed.
  151. When completion is available, certain keys---@key{TAB}, @key{RET}, and
  152. @key{SPC}---are rebound to complete the text present in the
  153. minibuffer into a longer string that it stands for, by matching it
  154. against a set of @dfn{completion alternatives} provided by the command
  155. reading the argument. @kbd{?} is defined to display a list of possible
  156. completions of what you have inserted.
  157. For example, when @kbd{M-x} uses the minibuffer to read the name of a
  158. command, it provides a list of all available XEmacs command names to
  159. complete against. The completion keys match the text in the minibuffer
  160. against all the command names, find any additional name characters
  161. implied by the ones already present in the minibuffer, and add those
  162. characters to the ones you have given. This is what makes it possible
  163. to type @kbd{M-x inse @key{SPC} b @key{RET}} instead of @kbd{M-x
  164. insert-buffer @key{RET}} (for example).
  165. Case is normally significant in completion because it is significant
  166. in most of the names that you can complete (buffer names, file names and
  167. command names). Thus, @samp{fo} does not complete to @samp{Foo}. When
  168. you are completing a name in which case does not matter, case may be
  169. ignored for completion's sake if specified by program.
  170. When a completion list is displayed, the completions will highlight as
  171. you move the mouse over them. Clicking the middle mouse button on any
  172. highlighted completion will ``select'' it just as if you had typed it in
  173. and hit @key{RET}.
  174. @menu
  175. * Example: Completion Example.
  176. * Commands: Completion Commands.
  177. * Strict Completion::
  178. * Options: Completion Options.
  179. @end menu
  180. @node Completion Example, Completion Commands, Completion, Completion
  181. @subsection Completion Example
  182. @kindex TAB
  183. @findex minibuffer-complete
  184. A concrete example may help here. If you type @kbd{M-x au @key{TAB}},
  185. the @key{TAB} looks for alternatives (in this case, command names) that
  186. start with @samp{au}. There are several, including
  187. @code{auto-fill-mode} and @code{auto-save-mode}---but they are all the
  188. same as far as @code{auto}, so the @samp{au} in the minibuffer changes
  189. to @samp{auto}.
  190. If you type @key{TAB} again immediately, there are multiple
  191. possibilities for the very next character---it could be any of
  192. @samp{c-}---so no more characters are added; instead, @key{TAB}
  193. displays a list of all possible completions in another window.
  194. If you go on to type @kbd{-f @key{TAB}}, this @key{TAB} sees
  195. @samp{auto-f}. The only command name starting this way is
  196. @code{auto-fill-mode}, so completion fills in the rest of that. You now
  197. have @samp{auto-fill-mode} in the minibuffer after typing just @kbd{au
  198. @key{TAB} f @key{TAB}}. Note that @key{TAB} has this effect because in
  199. the minibuffer it is bound to the command @code{minibuffer-complete}
  200. when completion is available.
  201. @node Completion Commands, Strict Completion, Completion Example, Completion
  202. @subsection Completion Commands
  203. Here is a list of the completion commands defined in the minibuffer
  204. when completion is available.
  205. @table @kbd
  206. @item @key{TAB}
  207. Complete the text in the minibuffer as much as possible
  208. (@code{minibuffer-complete}).
  209. @item @key{SPC}
  210. Complete the minibuffer text, but don't go beyond one word
  211. (@code{minibuffer-complete-word}).
  212. @item @key{RET}
  213. Submit the text in the minibuffer as the argument, possibly completing
  214. first as described below (@code{minibuffer-complete-and-exit}).
  215. @item ?
  216. Print a list of all possible completions of the text in the minibuffer
  217. (@code{minibuffer-list-completions}).
  218. @item @key{button2}
  219. Select the highlighted text under the mouse as a minibuffer response.
  220. When the minibuffer is being used to prompt the user for a completion,
  221. any valid completions which are visible on the screen will be highlighted
  222. when the mouse moves over them. Clicking @key{button2} will select the
  223. highlighted completion and exit the minibuffer.
  224. (@code{minibuf-select-highlighted-completion}).
  225. @end table
  226. @kindex SPC
  227. @findex minibuffer-complete-word
  228. @key{SPC} completes much like @key{TAB}, but never goes beyond the
  229. next hyphen or space. If you have @samp{auto-f} in the minibuffer and
  230. type @key{SPC}, it finds that the completion is @samp{auto-fill-mode},
  231. but it stops completing after @samp{fill-}. This gives
  232. @samp{auto-fill-}. Another @key{SPC} at this point completes all the
  233. way to @samp{auto-fill-mode}. @key{SPC} in the minibuffer when
  234. completion is available runs the command
  235. @code{minibuffer-complete-word}.
  236. Here are some commands you can use to choose a completion from a
  237. window that displays a list of completions:
  238. @table @kbd
  239. @findex mouse-choose-completion
  240. @item button2up
  241. Clicking mouse button 2 on a completion in the list of possible
  242. completions chooses that completion (@code{mouse-choose-completion}).
  243. You normally use this command while point is in the minibuffer; but you
  244. must click in the list of completions, not in the minibuffer itself.
  245. @findex switch-to-completions
  246. @item @key{PRIOR}
  247. @itemx M-v
  248. Typing @key{PRIOR} or @kbd{M-v}, while in the minibuffer, selects the
  249. window showing the completion list buffer
  250. (@code{switch-to-completions}). This paves the way for using the
  251. commands below. (Selecting that window in the usual ways has the same
  252. effect, but this way is more convenient.)
  253. @findex choose-completion
  254. @item @key{RET}
  255. Typing @key{RET} @emph{in the completion list buffer} chooses the
  256. completion that point is in or next to (@code{choose-completion}). To
  257. use this command, you must first switch windows to the window that shows
  258. the list of completions.
  259. @findex next-list-mode-item
  260. @item @key{RIGHT}
  261. @itemx @key{TAB}
  262. @itemx C-f
  263. Typing the right-arrow key @key{RIGHT}, @key{TAB} or @kbd{C-f} @emph{in
  264. the completion list buffer} moves point to the following completion
  265. (@code{next-list-mode-item}).
  266. @findex previous-list-mode-item
  267. @item @key{LEFT}
  268. @itemx C-b
  269. Typing the left-arrow key @key{LEFT} or @kbd{C-b} @emph{in the
  270. completion list buffer} moves point toward the beginning of the buffer,
  271. to the previous completion (@code{previous-list-mode-item}).
  272. @end table
  273. @node Strict Completion, Completion Options, Completion Commands, Completion
  274. @subsection Strict Completion
  275. There are three different ways that @key{RET} can work in completing
  276. minibuffers, depending on how the argument will be used.
  277. @itemize @bullet
  278. @item
  279. @dfn{Strict} completion is used when it is meaningless to give any
  280. argument except one of the known alternatives. For example, when
  281. @kbd{C-x k} reads the name of a buffer to kill, it is meaningless to
  282. give anything but the name of an existing buffer. In strict
  283. completion, @key{RET} refuses to exit if the text in the minibuffer
  284. does not complete to an exact match.
  285. @item
  286. @dfn{Cautious} completion is similar to strict completion, except that
  287. @key{RET} exits only if the text was an exact match already, not
  288. needing completion. If the text is not an exact match, @key{RET} does
  289. not exit, but it does complete the text. If it completes to an exact
  290. match, a second @key{RET} will exit.
  291. Cautious completion is used for reading file names for files that must
  292. already exist.
  293. @item
  294. @dfn{Permissive} completion is used when any string whatever is
  295. meaningful, and the list of completion alternatives is just a guide.
  296. For example, when @kbd{C-x C-f} reads the name of a file to visit, any
  297. file name is allowed, in case you want to create a file. In
  298. permissive completion, @key{RET} takes the text in the minibuffer
  299. exactly as given, without completing it.
  300. @end itemize
  301. The completion commands display a list of all possible completions in
  302. a window whenever there is more than one possibility for the very next
  303. character. Also, typing @kbd{?} explicitly requests such a list. If
  304. the list of completions is long, you can scroll it with @kbd{C-M-v}
  305. (@pxref{Other Window}).
  306. @node Completion Options, , Strict Completion, Completion
  307. @subsection Completion Options
  308. @vindex completion-ignored-extensions
  309. When completion is done on file names, certain file names are usually
  310. ignored. The variable @code{completion-ignored-extensions} contains a
  311. list of strings; a file whose name ends in any of those strings is
  312. ignored as a possible completion. The standard value of this variable
  313. has several elements including @code{".o"}, @code{".elc"}, @code{".dvi"}
  314. and @code{"~"}. The effect is that, for example, @samp{foo} can
  315. complete to @samp{foo.c} even though @samp{foo.o} exists as well.
  316. However, if @emph{all} the possible completions end in ``ignored''
  317. strings, then they are not ignored. Ignored extensions do not apply to
  318. lists of completions---those always mention all possible completions.
  319. @vindex completion-auto-help
  320. If a completion command finds the next character is undetermined, it
  321. automatically displays a list of all possible completions. If the variable
  322. @code{completion-auto-help} is set to @code{nil}, this does not happen,
  323. and you must type @kbd{?} to display the possible completions.
  324. @vindex minibuffer-confirm-incomplete
  325. If the variable @code{minibuffer-confirm-incomplete} is set to @code{t},
  326. then in contexts where @code{completing-read} allows answers that are
  327. not valid completions, an extra @key{RET} must be typed to confirm the
  328. response. This is helpful for catching typos.
  329. @cindex Icomplete mode
  330. Icomplete mode presents a constantly-updated display that tells you
  331. what completions are available for the text you've entered so far. The
  332. command to enable or disable this minor mode is @kbd{M-x
  333. icomplete-mode}.
  334. @node Minibuffer History, Repetition, Completion, Minibuffer
  335. @section Minibuffer History
  336. @cindex minibuffer history
  337. @cindex history of minibuffer input
  338. Every argument that you enter with the minibuffer is saved on a
  339. @dfn{minibuffer history list} so that you can use it again later in
  340. another argument. Special commands load the text of an earlier argument
  341. in the minibuffer. They discard the old minibuffer contents, so you can
  342. think of them as moving through the history of previous arguments.
  343. @table @kbd
  344. @item @key{UP}
  345. @itemx M-p
  346. Move to the next earlier argument string saved in the minibuffer history
  347. (@code{previous-history-element}).
  348. @item @key{DOWN}
  349. @itemx M-n
  350. Move to the next later argument string saved in the minibuffer history
  351. (@code{next-history-element}).
  352. @item M-r @var{regexp} @key{RET}
  353. Move to an earlier saved argument in the minibuffer history that has a
  354. match for @var{regexp} (@code{previous-matching-history-element}).
  355. @item M-s @var{regexp} @key{RET}
  356. Move to a later saved argument in the minibuffer history that has a
  357. match for @var{regexp} (@code{next-matching-history-element}).
  358. @end table
  359. @kindex M-p @r{(minibuffer history)}
  360. @kindex M-n @r{(minibuffer history)}
  361. @findex next-history-element
  362. @findex previous-history-element
  363. The simplest way to reuse the saved arguments in the history list is
  364. to move through the history list one element at a time. While in the
  365. minibuffer, use @kbd{M-p} or up-arrow (@code{previous-history-element})
  366. to ``move to'' the next earlier minibuffer input, and use @kbd{M-n} or
  367. down-arrow (@code{next-history-element}) to ``move to'' the next later
  368. input.
  369. The previous input that you fetch from the history entirely replaces
  370. the contents of the minibuffer. To use it as the argument, exit the
  371. minibuffer as usual with @key{RET}. You can also edit the text before
  372. you reuse it; this does not change the history element that you
  373. ``moved'' to, but your new argument does go at the end of the history
  374. list in its own right.
  375. For many minibuffer arguments there is a ``default'' value. In some
  376. cases, the minibuffer history commands know the default value. Then you
  377. can insert the default value into the minibuffer as text by using
  378. @kbd{M-n} to move ``into the future'' in the history.
  379. @findex previous-matching-history-element
  380. @findex next-matching-history-element
  381. @kindex M-r @r{(minibuffer history)}
  382. @kindex M-s @r{(minibuffer history)}
  383. There are also commands to search forward or backward through the
  384. history; they search for history elements that match a regular
  385. expression that you specify with the minibuffer. @kbd{M-r}
  386. (@code{previous-matching-history-element}) searches older elements in
  387. the history, while @kbd{M-s} (@code{next-matching-history-element})
  388. searches newer elements. By special dispensation, these commands can
  389. use the minibuffer to read their arguments even though you are already
  390. in the minibuffer when you issue them. As with incremental searching,
  391. an uppercase letter in the regular expression makes the search
  392. case-sensitive (@pxref{Search Case}).
  393. All uses of the minibuffer record your input on a history list, but
  394. there are separate history lists for different kinds of arguments. For
  395. example, there is a list for file names, used by all the commands that
  396. read file names.
  397. There are several other very specific history lists, including one for
  398. command names read by @kbd{M-x}, one for buffer names, one for arguments
  399. of commands like @code{query-replace}, and one for compilation commands
  400. read by @code{compile}. Finally, there is one ``miscellaneous'' history
  401. list that most minibuffer arguments use.
  402. @c Do wee need this?
  403. @ignore
  404. @vindex history-length
  405. The variable @code{history-length} specifies the maximum length of a
  406. minibuffer history list; once a list gets that long, the oldest element
  407. is deleted each time an element is added. If the value of
  408. @code{history-length} is @code{t}, though, there is no maximum length
  409. and elements are never deleted.
  410. @end ignore
  411. @node Repetition, , Minibuffer History, Minibuffer
  412. @section Repeating Minibuffer Commands
  413. @cindex command history
  414. @cindex history of commands
  415. Every command that uses the minibuffer at least once is recorded on a
  416. special history list, together with the values of its arguments, so that
  417. you can repeat the entire command. In particular, every use of
  418. @kbd{M-x} is recorded there, since @kbd{M-x} uses the minibuffer to read
  419. the command name.
  420. @findex list-command-history
  421. @c widecommands
  422. @table @kbd
  423. @item C-x @key{ESC} @key{ESC}
  424. Re-execute a recent minibuffer command (@code{repeat-complex-command}).
  425. @item M-p
  426. Within @kbd{C-x @key{ESC} @key{ESC}}, move to previous recorded command
  427. (@code{previous-history-element}).
  428. @item M-n
  429. Within @kbd{C-x @key{ESC} @key{ESC}}, move to the next (more recent)
  430. recorded command (@code{next-history-element}).
  431. @item M-x list-command-history
  432. Display the entire command history, showing all the commands
  433. @kbd{C-x @key{ESC} @key{ESC}} can repeat, most recent first.
  434. @end table
  435. @kindex C-x ESC ESC
  436. @findex repeat-complex-command
  437. @kbd{C-x @key{ESC} @key{ESC}} is used to re-execute a recent
  438. minibuffer-using command. With no argument, it repeats the last such
  439. command. A numeric argument specifies which command to repeat; one
  440. means the last one, and larger numbers specify earlier ones.
  441. @kbd{C-x @key{ESC} @key{ESC}} works by turning the previous command
  442. into a Lisp expression and then entering a minibuffer initialized with
  443. the text for that expression. If you type just @key{RET}, the command
  444. is repeated as before. You can also change the command by editing the
  445. Lisp expression. Whatever expression you finally submit is what will be
  446. executed. The repeated command is added to the front of the command
  447. history unless it is identical to the most recently executed command
  448. already there.
  449. Even if you don't understand Lisp syntax, it will probably be obvious
  450. which command is displayed for repetition. If you do not change the text,
  451. you can be sure the command will repeat exactly as before.
  452. @kindex M-n
  453. @kindex M-p
  454. @findex next-complex-command
  455. @findex previous-complex-command
  456. If you are in the minibuffer for @kbd{C-x @key{ESC} @key{ESC}} and the
  457. command shown to you is not the one you want to repeat, you can move
  458. around the list of previous commands using @kbd{M-n} and @kbd{M-p}.
  459. @kbd{M-p} replaces the contents of the minibuffer with the next earlier
  460. recorded command, and @kbd{M-n} replaces it with the next later command.
  461. After finding the desired previous command, you can edit its expression
  462. and then resubmit it by typing @key{RET}. Any editing you have done on
  463. the command to be repeated is lost if you use @kbd{M-n} or @kbd{M-p}.
  464. @kbd{M-n} and @kbd{M-p} are specially defined within @kbd{C-x @key{ESC}
  465. @key{ESC}} to run the commands @code{previous-history-element} and
  466. @code{next-history-element}.
  467. @vindex command-history
  468. The list of previous commands using the minibuffer is stored as a Lisp
  469. list in the variable @code{command-history}. Each element of the list
  470. is a Lisp expression which describes one command and its arguments.
  471. Lisp programs can reexecute a command by feeding the corresponding
  472. @code{command-history} element to @code{eval}.