New feature: set optimal slice from BoundingBox information.
[bpt/emacs.git] / doc / emacs / misc.texi
CommitLineData
6bf7aab6 1@c This is part of the Emacs manual.
acaf905b 2@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2012
42e96065 3@c Free Software Foundation, Inc.
6bf7aab6
DL
4@c See file emacs.texi for copying conditions.
5@iftex
6@chapter Miscellaneous Commands
7
8 This chapter contains several brief topics that do not fit anywhere
b8ecfdfe 9else: viewing ``document files'', reading Usenet news, running shell
d14202c2
CY
10commands and shell subprocesses, using a single shared Emacs for
11utilities that expect to run an editor as a subprocess, printing
12hardcopy, sorting text, narrowing display to part of the buffer,
f404f8bc
CY
13editing binary files, saving an Emacs session for later resumption,
14following hyperlinks, browsing images, emulating other editors, and
15various diversions and amusements.
6bf7aab6
DL
16
17@end iftex
2e7cfad6
LT
18
19@ifnottex
20@raisesections
21@end ifnottex
22
856ce114 23@node Gnus
6bf7aab6
DL
24@section Gnus
25@cindex Gnus
b8ecfdfe
CY
26@cindex Usenet news
27@cindex newsreader
6bf7aab6 28
b8ecfdfe
CY
29 Gnus is an Emacs package primarily designed for reading and posting
30Usenet news. It can also be used to read and respond to messages from
31a number of other sources---email, remote directories, digests, and so
32on. Here we introduce Gnus and describe several basic features.
d3ea5f55 33@ifnottex
6bf7aab6 34For full details, see @ref{Top, Gnus,, gnus, The Gnus Manual}.
d3ea5f55 35@end ifnottex
6bf7aab6 36@iftex
a42dbee1 37For full details on Gnus, type @kbd{C-h i} and then select the Gnus
6bf7aab6
DL
38manual.
39@end iftex
40
6bf7aab6 41@menu
8838673e
GM
42* Buffers of Gnus:: The group, summary, and article buffers.
43* Gnus Startup:: What you should know about starting Gnus.
b8ecfdfe
CY
44* Gnus Group Buffer:: A short description of Gnus group commands.
45* Gnus Summary Buffer:: A short description of Gnus summary commands.
6bf7aab6
DL
46@end menu
47
48@node Buffers of Gnus
49@subsection Gnus Buffers
50
b8ecfdfe
CY
51 Gnus uses several buffers to display information and to receive
52commands. The three most commonly-used Gnus buffers are the
53@dfn{group buffer}, the @dfn{summary buffer} and the @dfn{article
54buffer}.
55
56 The @dfn{group buffer} contains a list of article sources (e.g.@:
57newsgroups and email inboxes), which are collectively referred to as
58@dfn{groups}. This is the first buffer Gnus displays when it starts
59up. It normally displays only the groups to which you subscribe and
60that contain unread articles. From this buffer, you can select a
61group to read.
62
63 The @dfn{summary buffer} lists the articles in a single group,
64showing one article per line. By default, it displays each article's
65author, subject, and line
66@iftex
67number.
68@end iftex
69@ifnottex
70number, but this is customizable; @xref{Summary Buffer Format,,, gnus,
71The Gnus Manual}.
72@end ifnottex
73The summary buffer is created when you select a group in the group
74buffer, and is killed when you exit the group.
75
76 From the summary buffer, you can choose an article to view. The
77article is displayed in the @dfn{article buffer}. In normal Gnus
78usage, you view this buffer but do not select it---all useful Gnus
79commands can be invoked from the summary buffer. But you can select
80the article buffer, and execute Gnus commands from it, if you wish.
6bf7aab6
DL
81
82@node Gnus Startup
83@subsection When Gnus Starts Up
84
b8ecfdfe
CY
85@findex gnus
86@cindex @file{.newsrc} file
87 If your system has been set up for reading Usenet news, getting
88started with Gnus is easy---just type @kbd{M-x gnus}.
89
90 On starting up, Gnus reads your @dfn{news initialization file}: a
91file named @file{.newsrc} in your home directory which lists your
92Usenet newsgroups and subscriptions (this file is not unique to Gnus;
93it is used by many other newsreader programs). It then tries to
94contact the system's default news server, which is typically specified
8fc85b20 95by the @env{NNTPSERVER} environment variable.
b8ecfdfe
CY
96
97 If your system does not have a default news server, or if you wish
98to use Gnus for reading email, then before invoking @kbd{M-x gnus} you
99need to tell Gnus where to get news and/or mail. To do this,
100customize the variables @code{gnus-select-method} and/or
101@code{gnus-secondary-select-methods}.
102@iftex
103See the Gnus manual for details.
104@end iftex
105@ifnottex
106@xref{Finding the News,,, gnus, The Gnus Manual}.
107@end ifnottex
6bf7aab6 108
b8ecfdfe
CY
109 Once Gnus has started up, it displays the group buffer. By default,
110the group buffer shows only a small number of @dfn{subscribed groups}.
111Groups with other statuses---@dfn{unsubscribed}, @dfn{killed}, or
112@dfn{zombie}---are hidden. The first time you start Gnus, any group
113to which you are not subscribed is made into a killed group; any group
114that subsequently appears on the news server becomes a zombie group.
6bf7aab6 115
b8ecfdfe
CY
116 To proceed, you must select a group in the group buffer to open the
117summary buffer for that group; then, select an article in the summary
118buffer to view its article buffer in a separate window. The following
119sections explain how to use the group and summary buffers to do this.
6bf7aab6 120
b8ecfdfe
CY
121 To quit Gnus, type @kbd{q} in the group buffer. This automatically
122records your group statuses in the files @file{.newsrc} and
123@file{.newsrc.eld}, so that they take effect in subsequent Gnus
124sessions.
6bf7aab6 125
b8ecfdfe
CY
126@node Gnus Group Buffer
127@subsection Using the Gnus Group Buffer
6bf7aab6 128
b8ecfdfe 129 The following commands are available in the Gnus group buffer:
6bf7aab6
DL
130
131@table @kbd
b8ecfdfe
CY
132@kindex SPC @r{(Gnus Group mode)}
133@findex gnus-group-read-group
134@item @key{SPC}
135Switch to the summary buffer for the group on the current line.
6bf7aab6 136
b8ecfdfe
CY
137@kindex l @r{(Gnus Group mode)}
138@kindex A s @r{(Gnus Group mode)}
139@findex gnus-group-list-groups
140@item l
141@itemx A s
142In the group buffer, list only the groups to which you subscribe and
143which contain unread articles (this is the default listing).
6bf7aab6
DL
144
145@kindex L @r{(Gnus Group mode)}
b8ecfdfe 146@kindex A u @r{(Gnus Group mode)}
6bf7aab6
DL
147@findex gnus-group-list-all-groups
148@item L
b8ecfdfe
CY
149@itemx A u
150List all subscribed and unsubscribed groups, but not killed or zombie
151groups.
6bf7aab6 152
b8ecfdfe
CY
153@kindex A k @r{(Gnus Group mode)}
154@findex gnus-group-list-all-groups
155@item A k
156List killed groups.
157
158@kindex A z @r{(Gnus Group mode)}
159@findex gnus-group-list-all-groups
160@item A z
161List zombie groups.
6bf7aab6
DL
162
163@kindex u @r{(Gnus Group mode)}
164@findex gnus-group-unsubscribe-current-group
165@cindex subscribe groups
166@cindex unsubscribe groups
167@item u
b8ecfdfe
CY
168Toggle the subscription status of the group on the current line
169(i.e.@: turn a subscribed group into an unsubscribed group, or vice
170versa). Invoking this on a killed or zombie group turns it into an
171unsubscribed group.
6bf7aab6 172
b8ecfdfe 173@kindex C-k @r{(Gnus Group mode)}
6bf7aab6
DL
174@findex gnus-group-kill-group
175@item C-k
b8ecfdfe
CY
176Kill the group on the current line. Killed groups are not recorded in
177the @file{.newsrc} file, and they are not shown in the @kbd{l} or
178@kbd{L} listings.
6bf7aab6 179
b8ecfdfe
CY
180@kindex DEL @r{(Gnus Group mode)}
181@item @key{DEL}
182Move point to the previous group containing unread articles.
6bf7aab6 183
b8ecfdfe
CY
184@kindex n @r{(Gnus Group mode)}
185@findex gnus-group-next-unread-group
186@findex gnus-summary-next-unread-article
187@item n
188Move point to the next unread group.
6bf7aab6 189
b8ecfdfe
CY
190@kindex p @r{(Gnus Group mode)}
191@findex gnus-group-prev-unread-group
192@findex gnus-summary-prev-unread-article
193@item p
194Move point to the previous unread group.
6bf7aab6 195
b8ecfdfe
CY
196@kindex q @r{(Gnus Group mode)}
197@findex gnus-group-exit
198@item q
199Update your Gnus settings, and quit Gnus.
200@end table
6bf7aab6 201
b8ecfdfe
CY
202@node Gnus Summary Buffer
203@subsection Using the Gnus Summary Buffer
6bf7aab6 204
b8ecfdfe 205 The following commands are available in the Gnus summary buffer:
6bf7aab6 206
b8ecfdfe
CY
207@table @kbd
208@kindex SPC @r{(Gnus Summary mode)}
209@findex gnus-group-read-group
210@item @key{SPC}
211If there is no article selected, select the article on the current
212line and display its article buffer. Otherwise, try scrolling the
213selected article buffer in its window; on reaching the end of the
214buffer, select the next unread article.
6bf7aab6 215
b8ecfdfe
CY
216Thus, you can read through all articles by repeatedly typing
217@key{SPC}.
6bf7aab6 218
b8ecfdfe 219@kindex DEL @r{(Gnus Summary mode)}
6bf7aab6 220@findex gnus-summary-prev-page
b8ecfdfe
CY
221@item @key{DEL}
222Scroll the text of the article backwards.
6bf7aab6 223
b8ecfdfe 224@kindex n @r{(Gnus Summary mode)}
6bf7aab6
DL
225@findex gnus-group-next-unread-group
226@findex gnus-summary-next-unread-article
227@item n
b8ecfdfe 228Select the next unread article.
6bf7aab6 229
b8ecfdfe 230@kindex p @r{(Gnus Summary mode)}
6bf7aab6
DL
231@findex gnus-group-prev-unread-group
232@findex gnus-summary-prev-unread-article
233@item p
b8ecfdfe 234Select the previous unread article.
6bf7aab6
DL
235
236@kindex s @r{(Gnus Summary mode)}
237@findex gnus-summary-isearch-article
238@item s
b8ecfdfe
CY
239Do an incremental search on the selected article buffer, as if you
240switched to the buffer and typed @kbd{C-s} (@pxref{Incremental
241Search}).
6bf7aab6
DL
242
243@kindex M-s @r{(Gnus Summary mode)}
244@findex gnus-summary-search-article-forward
245@item M-s @var{regexp} @key{RET}
b8ecfdfe 246Search forward for articles containing a match for @var{regexp}.
6bf7aab6 247
b8ecfdfe
CY
248@kindex q @r{(Gnus Summary mode)}
249@item q
250Exit the summary buffer and return to the group buffer.
6bf7aab6
DL
251@end table
252
856ce114
CY
253@node Document View
254@section Document Viewing
255@cindex DVI file
256@cindex PDF file
257@cindex PS file
7877f373 258@cindex PostScript file
856ce114
CY
259@cindex OpenDocument file
260@cindex Microsoft Office file
261@cindex DocView mode
262@cindex mode, DocView
263@cindex document viewer (DocView)
264@findex doc-view-mode
6bf7aab6 265
b8ecfdfe
CY
266 DocView mode is a major mode for viewing DVI, PostScript (PS), PDF,
267OpenDocument, and Microsoft Office documents. It provides features
268such as slicing, zooming, and searching inside documents. It works by
269converting the document to a set of images using the @command{gs}
270(GhostScript) command and other external tools @footnote{@code{gs} is
271a hard requirement. For DVI files, @code{dvipdf} or @code{dvipdfm} is
272needed. For OpenDocument and Microsoft Office documents, the
273@code{unoconv} tool is needed.}, and displaying those images.
6bf7aab6 274
856ce114
CY
275@findex doc-view-toggle-display
276@findex doc-view-toggle-display
277@cindex doc-view-minor-mode
b8ecfdfe
CY
278 When you visit a document file that can be displayed with DocView
279mode, Emacs automatically uses DocView mode @footnote{The needed
280external tools for the document type must be available, and Emacs must
281be running in a graphical frame and have PNG image support. If any of
282these requirements is not fulfilled, Emacs falls back to another major
283mode.}. As an exception, when you visit a PostScript file, Emacs
284switches to PS mode, a major mode for editing PostScript files as
285text; however, it also enables DocView minor mode, so you can type
286@kbd{C-c C-c} to view the document with DocView. In either DocView
287mode or DocView minor mode, repeating @kbd{C-c C-c}
288(@code{doc-view-toggle-display}) toggles between DocView and the
289underlying file contents.
290
291 You can explicitly enable DocView mode with the command @code{M-x
292doc-view-mode}. You can toggle DocView minor mode with @code{M-x
856ce114 293doc-view-minor-mode}.
6bf7aab6 294
856ce114
CY
295 When DocView mode starts, it displays a welcome screen and begins
296formatting the file, page by page. It displays the first page once
297that has been formatted.
6bf7aab6 298
856ce114
CY
299 To kill the DocView buffer, type @kbd{k}
300(@code{doc-view-kill-proc-and-buffer}). To bury it, type @kbd{q}
301(@code{quit-window}).
6bf7aab6 302
856ce114 303@menu
b8ecfdfe
CY
304* Navigation: DocView Navigation. Navigating DocView buffers.
305* Searching: DocView Searching. Searching inside documents.
306* Slicing: DocView Slicing. Specifying which part of a page is displayed.
307* Conversion: DocView Conversion. Influencing and triggering conversion.
856ce114 308@end menu
6bf7aab6 309
b8ecfdfe
CY
310@node DocView Navigation
311@subsection DocView Navigation
6bf7aab6 312
b8ecfdfe 313 In DocView mode, you can scroll the current page using the usual
856ce114
CY
314Emacs movement keys: @kbd{C-p}, @kbd{C-n}, @kbd{C-b}, @kbd{C-f}, and
315the arrow keys.
6bf7aab6 316
856ce114
CY
317@vindex doc-view-continuous
318 By default, the line-motion keys @kbd{C-p} and @kbd{C-n} stop
319scrolling at the beginning and end of the current page, respectively.
320However, if you change the variable @code{doc-view-continuous} to a
321non-@code{nil} value, then @kbd{C-p} displays the previous page if you
322are already at the beginning of the current page, and @kbd{C-n}
323displays the next page if you are at the end of the current page.
6bf7aab6 324
856ce114
CY
325@findex doc-view-next-page
326@findex doc-view-previous-page
b8ecfdfe
CY
327@kindex n @r{(DocView mode)}
328@kindex p @r{(DocView mode)}
329@kindex C-x ] @r{(DocView mode)}
330@kindex C-x [ @r{(DocView mode)}
856ce114
CY
331 You can also display the next page by typing @kbd{n}, @key{next} or
332@kbd{C-x ]} (@code{doc-view-next-page}). To display the previous
333page, type @kbd{p}, @key{prior} or @kbd{C-x [}
334(@code{doc-view-previous-page}).
6bf7aab6 335
856ce114
CY
336@findex doc-view-scroll-up-or-next-page
337@findex doc-view-scroll-down-or-previous-page
b8ecfdfe
CY
338@kindex SPC @r{(DocView mode)}
339@kindex DEL @r{(DocView mode)}
340 @key{SPC} (@code{doc-view-scroll-up-or-next-page}) is a convenient
341way to advance through the document. It scrolls within the current
342page or advances to the next. @key{DEL} moves backwards in a similar
343way (@code{doc-view-scroll-down-or-previous-page}).
6bf7aab6 344
856ce114
CY
345@findex doc-view-first-page
346@findex doc-view-last-page
347@findex doc-view-goto-page
b8ecfdfe
CY
348@kindex M-< @r{(DocView mode)}
349@kindex M-> @r{(DocView mode)}
856ce114
CY
350 To go to the first page, type @kbd{M-<}
351(@code{doc-view-first-page}); to go to the last one, type @kbd{M->}
352(@code{doc-view-last-page}). To jump to a page by its number, type
353@kbd{M-g M-g} or @kbd{M-g g} (@code{doc-view-goto-page}).
6bf7aab6 354
b8ecfdfe
CY
355@findex doc-view-enlarge
356@findex doc-view-shrink
357@vindex doc-view-resolution
358@kindex + @r{(DocView mode)}
359@kindex - @r{(DocView mode)}
360 You can enlarge or shrink the document with @kbd{+}
361(@code{doc-view-enlarge}) and @kbd{-} (@code{doc-view-shrink}). These
362commands work by reconverting the document at the new size. To
363specify the default size for DocView, customize the variable
364@code{doc-view-resolution}.
365
366@node DocView Searching
367@subsection DocView Searching
368
369 In DocView mode, you can search the file's text for a regular
856ce114
CY
370expression (@pxref{Regexps}). The interface for searching is inspired
371by @code{isearch} (@pxref{Incremental Search}).
372
373@findex doc-view-search
374@findex doc-view-search-backward
375@findex doc-view-show-tooltip
376 To begin a search, type @kbd{C-s} (@code{doc-view-search}) or
377@kbd{C-r} (@code{doc-view-search-backward}). This reads a regular
378expression using a minibuffer, then echoes the number of matches found
379within the document. You can move forward and back among the matches
380by typing @kbd{C-s} and @kbd{C-r}. DocView mode has no way to show
381the match inside the page image; instead, it displays a tooltip (at
382the mouse position) listing all matching lines in the current page.
383To force display of this tooltip, type @kbd{C-t}
384(@code{doc-view-show-tooltip}).
385
386 To start a new search, use the search command with a prefix
387argument; i.e., @kbd{C-u C-s} for a forward search or @kbd{C-u C-r}
388for a backward search.
389
b8ecfdfe
CY
390@node DocView Slicing
391@subsection DocView Slicing
856ce114
CY
392
393Documents often have wide margins for printing. They are annoying
394when reading the document on the screen, because they use up screen
395space and can cause inconvenient scrolling.
396
397@findex doc-view-set-slice
398@findex doc-view-set-slice-using-mouse
399 With DocView you can hide these margins by selecting a @dfn{slice}
400of pages to display. A slice is a rectangle within the page area;
401once you specify a slice in DocView, it applies to whichever page you
402look at.
403
404 To specify the slice numerically, type @kbd{s s}
405(@code{doc-view-set-slice}); then enter the top left pixel position
406and the slice's width and height.
407@c ??? how does this work?
408
409 A more convenient graphical way to specify the slice is with @kbd{s
410m} (@code{doc-view-set-slice-using-mouse}), where you use the mouse to
411select the slice.
412@c ??? How does this work?
413
db8a5a18
TH
414 The most convenient way is to set the optimal slice by using
415BoundingBox information automatically determined from the document by
416typing @kbd{s b} (@code{doc-view-set-slice-using-mouse}).
417
856ce114
CY
418@findex doc-view-reset-slice
419 To cancel the selected slice, type @kbd{s r}
420(@code{doc-view-reset-slice}). Then DocView shows the entire page
421including its entire margins.
422
b8ecfdfe
CY
423@node DocView Conversion
424@subsection DocView Conversion
856ce114
CY
425
426@vindex doc-view-cache-directory
427@findex doc-view-clear-cache
b8ecfdfe 428 For efficiency, DocView caches the images produced by @command{gs}.
856ce114
CY
429The name of this directory is given by the variable
430@code{doc-view-cache-directory}. You can clear the cache directory by
431typing @code{M-x doc-view-clear-cache}.
432
433@findex doc-view-kill-proc
434@findex doc-view-kill-proc-and-buffer
b8ecfdfe
CY
435 To force reconversion of the currently viewed document, type @kbd{r}
436or @kbd{g} (@code{revert-buffer}). To kill the converter process
437associated with the current buffer, type @kbd{K}
856ce114
CY
438(@code{doc-view-kill-proc}). The command @kbd{k}
439(@code{doc-view-kill-proc-and-buffer}) kills the converter process and
440the DocView buffer.
441
856ce114 442@node Shell
6bf7aab6
DL
443@section Running Shell Commands from Emacs
444@cindex subshell
445@cindex shell commands
446
b8ecfdfe
CY
447 Emacs has commands for passing single command lines to shell
448subprocesses, and for running a shell interactively with input and
449output to an Emacs buffer, and for running a shell in a terminal
bd4af791
DL
450emulator window.
451
6bf7aab6
DL
452@table @kbd
453@item M-! @var{cmd} @key{RET}
88c5c7c8 454Run the shell command @var{cmd} and display the output
6bf7aab6
DL
455(@code{shell-command}).
456@item M-| @var{cmd} @key{RET}
88c5c7c8 457Run the shell command @var{cmd} with region contents as input;
6bf7aab6
DL
458optionally replace the region with the output
459(@code{shell-command-on-region}).
26e533e2 460@item M-& @var{cmd} @key{RET}
88c5c7c8
CY
461Run the shell command @var{cmd} asynchronously, and display the output
462(@code{async-shell-command}).
6bf7aab6 463@item M-x shell
88c5c7c8
CY
464Run a subshell with input and output through an Emacs buffer. You can
465then give commands interactively.
3b65ce47 466@item M-x term
88c5c7c8
CY
467Run a subshell with input and output through an Emacs buffer. You can
468then give commands interactively. Full terminal emulation is
469available.
6bf7aab6
DL
470@end table
471
a73a3461
CY
472@vindex exec-path
473 Whenever you specify a relative file name for an executable program
474(either in the @var{cmd} argument to one of the above commands, or in
475other contexts), Emacs searches for the program in the directories
476specified by the variable @code{exec-path}. The value of this
477variable must be a list of directory names; the default value is
478initialized from the environment variable @env{PATH} when Emacs is
479started (@pxref{General Variables}).
480
ab192107 481 @kbd{M-x eshell} invokes a shell implemented entirely in Emacs. It
88c5c7c8
CY
482is documented in its own manual.
483@ifnottex
484@xref{Top,Eshell,Eshell, eshell, Eshell: The Emacs Shell}.
485@end ifnottex
486@iftex
487See the Eshell Info manual, which is distributed with Emacs.
488@end iftex
ab192107 489
6bf7aab6
DL
490@menu
491* Single Shell:: How to run one shell command and return.
492* Interactive Shell:: Permanent shell taking input via Emacs.
493* Shell Mode:: Special Emacs commands used with permanent shell.
e51d6b23 494* Shell Prompts:: Two ways to recognize shell prompts.
6bf7aab6 495* History: Shell History. Repeating previous commands in a shell buffer.
df9d7630 496* Directory Tracking:: Keeping track when the subshell changes directory.
6bf7aab6 497* Options: Shell Options. Options for customizing Shell mode.
3b65ce47
DL
498* Terminal emulator:: An Emacs window as a terminal emulator.
499* Term Mode:: Special Emacs commands used in Term mode.
6bf7aab6 500* Remote Host:: Connecting to another computer.
37e5d54a 501* Serial Terminal:: Connecting to a serial port.
6bf7aab6
DL
502@end menu
503
504@node Single Shell
505@subsection Single Shell Commands
506
507@kindex M-!
508@findex shell-command
509 @kbd{M-!} (@code{shell-command}) reads a line of text using the
88c5c7c8 510minibuffer and executes it as a shell command, in a subshell made just
6bf7aab6 511for that command. Standard input for the command comes from the null
fc98b4ba
RS
512device. If the shell command produces any output, the output appears
513either in the echo area (if it is short), or in an Emacs buffer named
1c64e6ed 514@file{*Shell Command Output*}, displayed in another window (if the
88c5c7c8
CY
515output is long).
516
517 For instance, one way to decompress a file named @file{foo.gz} is to
518type @kbd{M-! gunzip foo.gz @key{RET}}. That shell command normally
519creates the file @file{foo} and produces no terminal output.
520
521 A numeric argument to @code{shell-command}, e.g.@: @kbd{M-1 M-!},
522causes it to insert terminal output into the current buffer instead of
523a separate buffer. It puts point before the output, and sets the mark
524after the output. For instance, @kbd{M-1 M-! gunzip < foo.gz
525@key{RET}} would insert the uncompressed form of the file
526@file{foo.gz} into the current buffer.
527
528 Provided the specified shell command does not end with @samp{&}, it
529runs @dfn{synchronously}, and you must wait for it to exit before
530continuing to use Emacs. To stop waiting, type @kbd{C-g} to quit;
531this sends a @code{SIGINT} signal to terminate the shell command (this
532is the same signal that @kbd{C-c} normally generates in the shell).
533Emacs then waits until the command actually terminates. If the shell
534command doesn't stop (because it ignores the @code{SIGINT} signal),
535type @kbd{C-g} again; this sends the command a @code{SIGKILL} signal,
536which is impossible to ignore.
537
538@kindex M-&
539@findex async-shell-command
540 A shell command that ends in @samp{&} is executed
541@dfn{asynchronously}, and you can continue to use Emacs as it runs.
542You can also type @kbd{M-&} (@code{async-shell-command}) to execute a
543shell command asynchronously; this is exactly like calling @kbd{M-!}
544with a trailing @samp{&}, except that you do not need the @samp{&}.
545The output buffer for asynchronous shell commands is named
546@samp{*Async Shell Command*}. Emacs inserts the output into this
547buffer as it comes in, whether or not the buffer is visible in a
548window.
26e533e2 549
6bf7aab6
DL
550@kindex M-|
551@findex shell-command-on-region
88c5c7c8 552 @kbd{M-|} (@code{shell-command-on-region}) is like @kbd{M-!}, but
6bf7aab6 553passes the contents of the region as the standard input to the shell
88c5c7c8
CY
554command, instead of no input. With a numeric argument, it deletes the
555old region and replaces it with the output from the shell command.
556
557 For example, you can use @kbd{M-|} with the @command{gpg} program to
558see what keys are in the buffer. If the buffer contains a GnuPG key,
559type @kbd{C-x h M-| gpg @key{RET}} to feed the entire buffer contents
560to @command{gpg}. This will output the list of keys to the
1c64e6ed 561@file{*Shell Command Output*} buffer.
d408f8d0 562
6bf7aab6 563@vindex shell-file-name
88c5c7c8
CY
564 The above commands use the shell specified by the variable
565@code{shell-file-name}. Its default value is determined by the
ab192107 566@env{SHELL} environment variable when Emacs is started. If the file
a73a3461
CY
567name is relative, Emacs searches the directories listed in
568@code{exec-path} (@pxref{Shell}).
6bf7aab6 569
6bf7aab6 570 To specify a coding system for @kbd{M-!} or @kbd{M-|}, use the command
54b6e2d1 571@kbd{C-x @key{RET} c} immediately beforehand. @xref{Communication Coding}.
6bf7aab6
DL
572
573@vindex shell-command-default-error-buffer
88c5c7c8
CY
574 By default, error output is intermixed with the regular output in
575the output buffer. But if you change the value of the variable
576@code{shell-command-default-error-buffer} to a string, error output is
577inserted into a buffer of that name.
6bf7aab6
DL
578
579@node Interactive Shell
88c5c7c8 580@subsection Interactive Subshell
6bf7aab6
DL
581
582@findex shell
88c5c7c8 583 To run a subshell interactively, type @kbd{M-x shell}. This creates
1c64e6ed 584(or reuses) a buffer named @file{*shell*}, and runs a shell subprocess
88c5c7c8
CY
585with input coming from and output going to that buffer. That is to
586say, any terminal output from the subshell goes into the buffer,
587advancing point, and any terminal input for the subshell comes from
588text in the buffer. To give input to the subshell, go to the end of
589the buffer and type the input, terminated by @key{RET}.
590
591 While the subshell is waiting or running a command, you can switch
592windows or buffers and perform other editing in Emacs. Emacs inserts
593the output from the subshell into the Shell buffer whenever it has
594time to process it (e.g.@: while waiting for keyboard input).
6bf7aab6 595
df9d7630
RS
596@cindex @code{comint-highlight-input} face
597@cindex @code{comint-highlight-prompt} face
88c5c7c8
CY
598 In the Shell buffer, prompts are displayed with the face
599@code{comint-highlight-prompt}, and submitted input lines are
600displayed with the face @code{comint-highlight-input}. This makes it
601easier to distinguish input lines from the shell output.
602@xref{Faces}.
603
604 To make multiple subshells, invoke @kbd{M-x shell} with a prefix
605argument (e.g. @kbd{C-u M-x shell}). Then the command will read a
606buffer name, and create (or reuse) a subshell in that buffer. You can
1c64e6ed
GM
607also rename the @file{*shell*} buffer using @kbd{M-x rename-uniquely},
608then create a new @file{*shell*} buffer using plain @kbd{M-x shell}.
ab192107 609Subshells in different buffers run independently and in parallel.
6bf7aab6
DL
610
611@vindex explicit-shell-file-name
b2c8319e 612@cindex environment variables for subshells
60a96371
GM
613@cindex @env{ESHELL} environment variable
614@cindex @env{SHELL} environment variable
88c5c7c8
CY
615 To specify the shell file name used by @kbd{M-x shell}, customize
616the variable @code{explicit-shell-file-name}. If this is @code{nil}
617(the default), Emacs uses the environment variable @env{ESHELL} if it
618exists. Otherwise, it usually uses the variable
619@code{shell-file-name} (@pxref{Single Shell}); but if the default
620directory is remote (@pxref{Remote Files}), it prompts you for the
621shell file name.
6bf7aab6 622
df9d7630
RS
623 Emacs sends the new shell the contents of the file
624@file{~/.emacs_@var{shellname}} as input, if it exists, where
625@var{shellname} is the name of the file that the shell was loaded
626from. For example, if you use bash, the file sent to it is
88c5c7c8
CY
627@file{~/.emacs_bash}. If this file is not found, Emacs tries with
628@file{~/.emacs.d/init_@var{shellname}.sh}.
df9d7630 629
6bf7aab6 630 To specify a coding system for the shell, you can use the command
ab192107
RS
631@kbd{C-x @key{RET} c} immediately before @kbd{M-x shell}. You can
632also change the coding system for a running subshell by typing
633@kbd{C-x @key{RET} p} in the shell buffer. @xref{Communication
634Coding}.
6bf7aab6 635
ed91b7ed 636@cindex @env{INSIDE_EMACS} environment variable
b2c8319e 637@cindex @env{EMACS} environment variable
88c5c7c8
CY
638 Emacs sets the environment variable @env{INSIDE_EMACS} in the
639subshell to @samp{@var{version},comint}, where @var{version} is the
640Emacs version (e.g.@: @samp{24.1}). Programs can check this variable
641to determine whether they are running inside an Emacs subshell. (It
642also sets the @env{EMACS} environment variable to @code{t}, if that
643environment variable is not already defined. However, this
644environment variable is deprecated; programs that use it should switch
645to using @env{INSIDE_EMACS} instead.)
6bf7aab6
DL
646
647@node Shell Mode
648@subsection Shell Mode
649@cindex Shell mode
650@cindex mode, Shell
651
88c5c7c8
CY
652 The major mode for Shell buffers is Shell mode. Many of its special
653commands are bound to the @kbd{C-c} prefix, and resemble the usual
654editing and job control characters present in ordinary shells, except
655that you must type @kbd{C-c} first. Here is a list of Shell mode
656commands:
6bf7aab6
DL
657
658@table @kbd
659@item @key{RET}
660@kindex RET @r{(Shell mode)}
661@findex comint-send-input
88c5c7c8
CY
662Send the current line as input to the subshell
663(@code{comint-send-input}). Any shell prompt at the beginning of the
664line is omitted (@pxref{Shell Prompts}). If point is at the end of
665buffer, this is like submitting the command line in an ordinary
666interactive shell. However, you can also invoke @key{RET} elsewhere
667in the shell buffer to submit the current line as input.
6bf7aab6
DL
668
669@item @key{TAB}
670@kindex TAB @r{(Shell mode)}
88c5c7c8
CY
671@findex completion-at-point
672Complete the command name or file name before point in the shell
673buffer (@code{completion-at-point}). This uses the usual Emacs
674completion rules (@pxref{Completion}), with the completion
675alternatives being file names, environment variable names, the shell
676command history, and history references (@pxref{History References}).
6bf7aab6
DL
677
678@vindex shell-completion-fignore
679@vindex comint-completion-fignore
680The variable @code{shell-completion-fignore} specifies a list of file
fc98b4ba
RS
681name extensions to ignore in Shell mode completion. The default
682setting is @code{nil}, but some users prefer @code{("~" "#" "%")} to
683ignore file names ending in @samp{~}, @samp{#} or @samp{%}. Other
6bf7aab6
DL
684related Comint modes use the variable @code{comint-completion-fignore}
685instead.
686
687@item M-?
688@kindex M-? @r{(Shell mode)}
689@findex comint-dynamic-list-filename@dots{}
88c5c7c8
CY
690Display temporarily a list of the possible completions of the file
691name before point (@code{comint-dynamic-list-filename-completions}).
6bf7aab6
DL
692
693@item C-d
694@kindex C-d @r{(Shell mode)}
695@findex comint-delchar-or-maybe-eof
76dd3692 696Either delete a character or send @acronym{EOF}
6bf7aab6 697(@code{comint-delchar-or-maybe-eof}). Typed at the end of the shell
88c5c7c8
CY
698buffer, this sends @acronym{EOF} to the subshell. Typed at any other
699position in the buffer, this deletes a character as usual.
6bf7aab6
DL
700
701@item C-c C-a
702@kindex C-c C-a @r{(Shell mode)}
fc98b4ba 703@findex comint-bol-or-process-mark
6bf7aab6 704Move to the beginning of the line, but after the prompt if any
fc98b4ba
RS
705(@code{comint-bol-or-process-mark}). If you repeat this command twice
706in a row, the second time it moves back to the process mark, which is
707the beginning of the input that you have not yet sent to the subshell.
708(Normally that is the same place---the end of the prompt on this
709line---but after @kbd{C-c @key{SPC}} the process mark may be in a
710previous line.)
6bf7aab6
DL
711
712@item C-c @key{SPC}
713Accumulate multiple lines of input, then send them together. This
714command inserts a newline before point, but does not send the preceding
715text as input to the subshell---at least, not yet. Both lines, the one
716before this newline and the one after, will be sent together (along with
717the newline that separates them), when you type @key{RET}.
718
719@item C-c C-u
720@kindex C-c C-u @r{(Shell mode)}
721@findex comint-kill-input
722Kill all text pending at end of buffer to be sent as input
e51d6b23
LT
723(@code{comint-kill-input}). If point is not at end of buffer,
724this only kills the part of this text that precedes point.
6bf7aab6
DL
725
726@item C-c C-w
727@kindex C-c C-w @r{(Shell mode)}
728Kill a word before point (@code{backward-kill-word}).
729
730@item C-c C-c
731@kindex C-c C-c @r{(Shell mode)}
732@findex comint-interrupt-subjob
733Interrupt the shell or its current subjob if any
734(@code{comint-interrupt-subjob}). This command also kills
735any shell input pending in the shell buffer and not yet sent.
736
737@item C-c C-z
738@kindex C-c C-z @r{(Shell mode)}
739@findex comint-stop-subjob
740Stop the shell or its current subjob if any (@code{comint-stop-subjob}).
741This command also kills any shell input pending in the shell buffer and
742not yet sent.
743
744@item C-c C-\
745@findex comint-quit-subjob
746@kindex C-c C-\ @r{(Shell mode)}
747Send quit signal to the shell or its current subjob if any
748(@code{comint-quit-subjob}). This command also kills any shell input
749pending in the shell buffer and not yet sent.
750
751@item C-c C-o
752@kindex C-c C-o @r{(Shell mode)}
97f59309
MB
753@findex comint-delete-output
754Delete the last batch of output from a shell command
755(@code{comint-delete-output}). This is useful if a shell command spews
3226d6ca 756out lots of output that just gets in the way.
97f59309
MB
757
758@item C-c C-s
759@kindex C-c C-s @r{(Shell mode)}
760@findex comint-write-output
761Write the last batch of output from a shell command to a file
762(@code{comint-write-output}). With a prefix argument, the file is
763appended to instead. Any prompt at the end of the output is not
764written.
6bf7aab6
DL
765
766@item C-c C-r
767@itemx C-M-l
768@kindex C-c C-r @r{(Shell mode)}
769@kindex C-M-l @r{(Shell mode)}
770@findex comint-show-output
771Scroll to display the beginning of the last batch of output at the top
772of the window; also move the cursor there (@code{comint-show-output}).
773
774@item C-c C-e
775@kindex C-c C-e @r{(Shell mode)}
776@findex comint-show-maximum-output
777Scroll to put the end of the buffer at the bottom of the window
778(@code{comint-show-maximum-output}).
779
780@item C-c C-f
781@kindex C-c C-f @r{(Shell mode)}
782@findex shell-forward-command
783@vindex shell-command-regexp
784Move forward across one shell command, but not beyond the current line
785(@code{shell-forward-command}). The variable @code{shell-command-regexp}
786specifies how to recognize the end of a command.
787
788@item C-c C-b
789@kindex C-c C-b @r{(Shell mode)}
790@findex shell-backward-command
791Move backward across one shell command, but not beyond the current line
792(@code{shell-backward-command}).
793
6bf7aab6 794@item M-x dirs
88c5c7c8
CY
795Ask the shell for its working directory, and update the Shell buffer's
796default directory. @xref{Directory Tracking}.
6bf7aab6
DL
797
798@item M-x send-invisible @key{RET} @var{text} @key{RET}
799@findex send-invisible
800Send @var{text} as input to the shell, after reading it without
801echoing. This is useful when a shell command runs a program that asks
802for a password.
803
e5b7fee6
EZ
804Please note that Emacs will not echo passwords by default. If you
805really want them to be echoed, evaluate the following Lisp
806expression:
6bf7aab6
DL
807
808@example
e5b7fee6
EZ
809(remove-hook 'comint-output-filter-functions
810 'comint-watch-for-password-prompt)
6bf7aab6
DL
811@end example
812
813@item M-x comint-continue-subjob
814@findex comint-continue-subjob
815Continue the shell process. This is useful if you accidentally suspend
816the shell process.@footnote{You should not suspend the shell process.
817Suspending a subjob of the shell is a completely different matter---that
818is normal practice, but you must use the shell to continue the subjob;
819this command won't do it.}
820
821@item M-x comint-strip-ctrl-m
822@findex comint-strip-ctrl-m
823Discard all control-M characters from the current group of shell output.
824The most convenient way to use this command is to make it run
825automatically when you get output from the subshell. To do that,
826evaluate this Lisp expression:
827
828@example
829(add-hook 'comint-output-filter-functions
830 'comint-strip-ctrl-m)
831@end example
832
833@item M-x comint-truncate-buffer
834@findex comint-truncate-buffer
835This command truncates the shell buffer to a certain maximum number of
836lines, specified by the variable @code{comint-buffer-maximum-size}.
837Here's how to do this automatically each time you get output from the
838subshell:
839
840@example
841(add-hook 'comint-output-filter-functions
842 'comint-truncate-buffer)
843@end example
844@end table
845
6bf7aab6
DL
846@cindex Comint mode
847@cindex mode, Comint
848 Shell mode is a derivative of Comint mode, a general-purpose mode for
849communicating with interactive subprocesses. Most of the features of
850Shell mode actually come from Comint mode, as you can see from the
bd9e9287
MB
851command names listed above. The special features of Shell mode include
852the directory tracking feature, and a few user commands.
6bf7aab6
DL
853
854 Other Emacs features that use variants of Comint mode include GUD
855(@pxref{Debuggers}) and @kbd{M-x run-lisp} (@pxref{External Lisp}).
856
857@findex comint-run
858 You can use @kbd{M-x comint-run} to execute any program of your choice
859in a subprocess using unmodified Comint mode---without the
860specializations of Shell mode.
861
e51d6b23
LT
862@node Shell Prompts
863@subsection Shell Prompts
864
e51d6b23
LT
865@cindex prompt, shell
866 A prompt is text output by a program to show that it is ready to
867accept new user input. Normally, Comint mode (and thus Shell mode)
88c5c7c8
CY
868automatically figures out part of the buffer is a prompt, based on the
869output of the subprocess. (Specifically, it assumes that any received
870output line which doesn't end with a newline is a prompt.)
871
872 Comint mode divides the buffer into two types of @dfn{fields}: input
873fields (where user input is typed) and output fields (everywhere
874else). Prompts are part of the output fields. Most Emacs motion
875commands do not cross field boundaries, unless they move over multiple
876lines. For instance, when point is in the input field on a shell
877command line, @kbd{C-a} puts point at the beginning of the input
878field, after the prompt. Internally, the fields are implemented using
879the @code{field} text property (@pxref{Text Properties,,, elisp, the
880Emacs Lisp Reference Manual}).
881
882@vindex comint-use-prompt-regexp
883@vindex shell-prompt-pattern
884 If you change the variable @code{comint-use-prompt-regexp} to a
885non-@code{nil} value, then Comint mode recognize prompts using a
886regular expression (@pxref{Regexps}). In Shell mode, the regular
887expression is specified by the variable @code{shell-prompt-pattern}.
888The default value of @code{comint-use-prompt-regexp} is @code{nil},
889because this method for recognizing prompts is unreliable, but you may
890want to set it to a non-@code{nil} value in unusual circumstances. In
891that case, Emacs does not divide the Comint buffer into fields, so the
892general motion commands behave as they normally do in buffers without
893special text properties. However, you can use the paragraph motion
894commands to conveniently navigate the buffer (@pxref{Paragraphs}); in
895Shell mode, Emacs uses @code{shell-prompt-pattern} as paragraph
896boundaries.
e51d6b23 897
6bf7aab6
DL
898@node Shell History
899@subsection Shell Command History
900
901 Shell buffers support three ways of repeating earlier commands. You
982dcb1b
RS
902can use keys like those used for the minibuffer history; these work
903much as they do in the minibuffer, inserting text from prior commands
904while point remains always at the end of the buffer. You can move
905through the buffer to previous inputs in their original place, then
906resubmit them or copy them to the end. Or you can use a
907@samp{!}-style history reference.
6bf7aab6
DL
908
909@menu
910* Ring: Shell Ring. Fetching commands from the history list.
911* Copy: Shell History Copying. Moving to a command and then copying it.
912* History References:: Expanding @samp{!}-style history references.
913@end menu
914
915@node Shell Ring
916@subsubsection Shell History Ring
917
918@table @kbd
919@findex comint-previous-input
920@kindex M-p @r{(Shell mode)}
921@item M-p
982dcb1b 922@itemx C-@key{UP}
6bf7aab6
DL
923Fetch the next earlier old shell command.
924
925@kindex M-n @r{(Shell mode)}
926@findex comint-next-input
927@item M-n
982dcb1b 928@itemx C-@key{DOWN}
6bf7aab6
DL
929Fetch the next later old shell command.
930
931@kindex M-r @r{(Shell mode)}
f2608df3
CY
932@findex comint-history-isearch-backward-regexp
933@item M-r
934Begin an incremental regexp search of old shell commands.
6bf7aab6 935
2a4a9af9
NR
936@item C-c C-x
937@kindex C-c C-x @r{(Shell mode)}
6bf7aab6
DL
938@findex comint-get-next-from-history
939Fetch the next subsequent command from the history.
91179e97 940
2a4a9af9
NR
941@item C-c .
942@kindex C-c . @r{(Shell mode)}
91179e97
RS
943@findex comint-input-previous-argument
944Fetch one argument from an old shell command.
2a4a9af9
NR
945
946@item C-c C-l
947@kindex C-c C-l @r{(Shell mode)}
948@findex comint-dynamic-list-input-ring
949Display the buffer's history of shell commands in another window
950(@code{comint-dynamic-list-input-ring}).
6bf7aab6
DL
951@end table
952
88c5c7c8
CY
953 Shell buffers provide a history of previously entered shell
954commands. To reuse shell commands from the history, use the editing
955commands @kbd{M-p}, @kbd{M-n}, @kbd{M-r} and @kbd{M-s}. These work
956just like the minibuffer history commands (@pxref{Minibuffer
957History}), except that they operate within the Shell buffer rather
958than the minibuffer.
6bf7aab6 959
982dcb1b
RS
960 @kbd{M-p} fetches an earlier shell command to the end of the shell
961buffer. Successive use of @kbd{M-p} fetches successively earlier
962shell commands, each replacing any text that was already present as
963potential shell input. @kbd{M-n} does likewise except that it finds
964successively more recent shell commands from the buffer.
965@kbd{C-@key{UP}} works like @kbd{M-p}, and @kbd{C-@key{DOWN}} like
966@kbd{M-n}.
6bf7aab6 967
f2608df3
CY
968 The history search command @kbd{M-r} begins an incremental regular
969expression search of previous shell commands. After typing @kbd{M-r},
970start typing the desired string or regular expression; the last
971matching shell command will be displayed in the current line.
972Incremental search commands have their usual effects---for instance,
973@kbd{C-s} and @kbd{C-r} search forward and backward for the next match
974(@pxref{Incremental Search}). When you find the desired input, type
975@key{RET} to terminate the search. This puts the input in the command
976line. Any partial input you were composing before navigating the
74600a6f
S
977history list is restored when you go to the beginning or end of the
978history ring.
6bf7aab6
DL
979
980 Often it is useful to reexecute several successive shell commands that
981were previously executed in sequence. To do this, first find and
982reexecute the first command of the sequence. Then type @kbd{C-c C-x};
983that will fetch the following command---the one that follows the command
984you just repeated. Then type @key{RET} to reexecute this command. You
985can reexecute several successive commands by typing @kbd{C-c C-x
986@key{RET}} over and over.
987
91179e97
RS
988 The command @kbd{C-c .}@: (@code{comint-input-previous-argument})
989copies an individual argument from a previous command, like @kbd{ESC
990.} in Bash. The simplest use copies the last argument from the
991previous shell command. With a prefix argument @var{n}, it copies the
992@var{n}th argument instead. Repeating @kbd{C-c .} copies from an
993earlier shell command instead, always using the same value of @var{n}
994(don't give a prefix argument when you repeat the @kbd{C-c .}
995command).
996
6bf7aab6
DL
997 These commands get the text of previous shell commands from a special
998history list, not from the shell buffer itself. Thus, editing the shell
999buffer, or even killing large parts of it, does not affect the history
1000that these commands access.
1001
1002@vindex shell-input-ring-file-name
1003 Some shells store their command histories in files so that you can
e51d6b23 1004refer to commands from previous shell sessions. Emacs reads
6bf7aab6
DL
1005the command history file for your chosen shell, to initialize its own
1006command history. The file name is @file{~/.bash_history} for bash,
1007@file{~/.sh_history} for ksh, and @file{~/.history} for other shells.
1008
1009@node Shell History Copying
1010@subsubsection Shell History Copying
1011
1012@table @kbd
1013@kindex C-c C-p @r{(Shell mode)}
1014@findex comint-previous-prompt
1015@item C-c C-p
1016Move point to the previous prompt (@code{comint-previous-prompt}).
1017
1018@kindex C-c C-n @r{(Shell mode)}
1019@findex comint-next-prompt
1020@item C-c C-n
1021Move point to the following prompt (@code{comint-next-prompt}).
1022
1023@kindex C-c RET @r{(Shell mode)}
55f62691 1024@findex comint-copy-old-input
6bf7aab6 1025@item C-c @key{RET}
932fd020
CY
1026Copy the input command at point, inserting the copy at the end of the
1027buffer (@code{comint-copy-old-input}). This is useful if you move
1028point back to a previous command. After you copy the command, you can
1029submit the copy as input with @key{RET}. If you wish, you can edit
1030the copy before resubmitting it. If you use this command on an output
1031line, it copies that line to the end of the buffer.
2a4a9af9
NR
1032
1033@item Mouse-2
55f62691
LT
1034If @code{comint-use-prompt-regexp} is @code{nil} (the default), copy
1035the old input command that you click on, inserting the copy at the end
1036of the buffer (@code{comint-insert-input}). If
1037@code{comint-use-prompt-regexp} is non-@code{nil}, or if the click is
1038not over old input, just yank as usual.
6bf7aab6
DL
1039@end table
1040
1041 Moving to a previous input and then copying it with @kbd{C-c
2a4a9af9
NR
1042@key{RET}} or @kbd{Mouse-2} produces the same results---the same
1043buffer contents---that you would get by using @kbd{M-p} enough times
1044to fetch that previous input from the history list. However, @kbd{C-c
1045@key{RET}} copies the text from the buffer, which can be different
1046from what is in the history list if you edit the input text in the
1047buffer after it has been sent.
6bf7aab6
DL
1048
1049@node History References
1050@subsubsection Shell History References
1051@cindex history reference
1052
df9d7630
RS
1053 Various shells including csh and bash support @dfn{history
1054references} that begin with @samp{!} and @samp{^}. Shell mode
1055recognizes these constructs, and can perform the history substitution
1056for you.
1057
1058 If you insert a history reference and type @key{TAB}, this searches
1059the input history for a matching command, performs substitution if
1060necessary, and places the result in the buffer in place of the history
1061reference. For example, you can fetch the most recent command
1062beginning with @samp{mv} with @kbd{! m v @key{TAB}}. You can edit the
1063command if you wish, and then resubmit the command to the shell by
1064typing @key{RET}.
1065
1066@vindex comint-input-autoexpand
1067@findex comint-magic-space
1068 Shell mode can optionally expand history references in the buffer
1069when you send them to the shell. To request this, set the variable
1070@code{comint-input-autoexpand} to @code{input}. You can make
1071@key{SPC} perform history expansion by binding @key{SPC} to the
1072command @code{comint-magic-space}.
6bf7aab6 1073
df9d7630 1074 Shell mode recognizes history references when they follow a prompt.
e51d6b23 1075@xref{Shell Prompts}, for how Shell mode recognizes prompts.
df9d7630
RS
1076
1077@node Directory Tracking
1078@subsection Directory Tracking
1079@cindex directory tracking
6bf7aab6 1080
df9d7630
RS
1081@vindex shell-pushd-regexp
1082@vindex shell-popd-regexp
1083@vindex shell-cd-regexp
1084 Shell mode keeps track of @samp{cd}, @samp{pushd} and @samp{popd}
88c5c7c8
CY
1085commands given to the subshell, in order to keep the Shell buffer's
1086default directory (@pxref{File Names}) the same as the shell's working
1087directory. It recognizes these commands by examining lines of input
1088that you send.
6bf7aab6 1089
df9d7630 1090 If you use aliases for these commands, you can tell Emacs to
88c5c7c8
CY
1091recognize them also, by setting the variables
1092@code{shell-pushd-regexp}, @code{shell-popd-regexp}, and
1093@code{shell-cd-regexp} to the appropriate regular expressions
1094(@pxref{Regexps}). For example, if @code{shell-pushd-regexp} matches
1095the beginning of a shell command line, that line is regarded as a
1096@code{pushd} command. These commands are recognized only at the
1097beginning of a shell command line.
df9d7630
RS
1098
1099@findex dirs
88c5c7c8
CY
1100 If Emacs gets confused about changes in the working directory of the
1101subshell, type @kbd{M-x dirs}. This command asks the shell for its
1102working directory and updates the default directory accordingly. It
1103works for shells that support the most common command syntax, but may
1104not work for unusual shells.
df9d7630
RS
1105
1106@findex dirtrack-mode
88c5c7c8
CY
1107@cindex Dirtrack mode
1108@cindex mode, Dirtrack
1109@vindex dirtrack-list
1110 You can also use Dirtrack mode, a buffer-local minor mode that
1111implements an alternative method of tracking the shell's working
1112directory. To use this method, your shell prompt must contain the
1113working directory at all times, and you must supply a regular
1114expression for recognizing which part of the prompt contains the
1115working directory; see the documentation of the variable
1116@code{dirtrack-list} for details. To use Dirtrack mode, type @kbd{M-x
1117dirtrack-mode} in the Shell buffer, or add @code{dirtrack-mode} to
1118@code{shell-mode-hook} (@pxref{Hooks}).
6bf7aab6
DL
1119
1120@node Shell Options
1121@subsection Shell Mode Options
1122
1123@vindex comint-scroll-to-bottom-on-input
1124 If the variable @code{comint-scroll-to-bottom-on-input} is
1125non-@code{nil}, insertion and yank commands scroll the selected window
67cf9997 1126to the bottom before inserting. The default is @code{nil}.
6bf7aab6
DL
1127
1128@vindex comint-scroll-show-maximum-output
1129 If @code{comint-scroll-show-maximum-output} is non-@code{nil}, then
e59d2bef
RS
1130arrival of output when point is at the end tries to scroll the last
1131line of text to the bottom line of the window, showing as much useful
67cf9997
CY
1132text as possible. (This mimics the scrolling behavior of most
1133terminals.) The default is @code{t}.
6bf7aab6 1134
fcc91da6
RS
1135@vindex comint-move-point-for-output
1136 By setting @code{comint-move-point-for-output}, you can opt for
6bf7aab6
DL
1137having point jump to the end of the buffer whenever output arrives---no
1138matter where in the buffer point was before. If the value is
1139@code{this}, point jumps in the selected window. If the value is
021037cb 1140@code{all}, point jumps in each window that shows the Comint buffer. If
6bf7aab6
DL
1141the value is @code{other}, point jumps in all nonselected windows that
1142show the current buffer. The default value is @code{nil}, which means
1143point does not jump to the end.
1144
982dcb1b
RS
1145@vindex comint-prompt-read-only
1146 If you set @code{comint-prompt-read-only}, the prompts in the Comint
66dd6a00 1147buffer are read-only.
982dcb1b 1148
6bf7aab6
DL
1149@vindex comint-input-ignoredups
1150 The variable @code{comint-input-ignoredups} controls whether successive
1151identical inputs are stored in the input history. A non-@code{nil}
1152value means to omit an input that is the same as the previous input.
1153The default is @code{nil}, which means to store each input even if it is
1154equal to the previous input.
1155
1156@vindex comint-completion-addsuffix
1157@vindex comint-completion-recexact
1158@vindex comint-completion-autolist
1159 Three variables customize file name completion. The variable
1160@code{comint-completion-addsuffix} controls whether completion inserts a
1161space or a slash to indicate a fully completed file or directory name
1162(non-@code{nil} means do insert a space or slash).
1163@code{comint-completion-recexact}, if non-@code{nil}, directs @key{TAB}
1164to choose the shortest possible completion if the usual Emacs completion
1165algorithm cannot add even a single character.
1166@code{comint-completion-autolist}, if non-@code{nil}, says to list all
1167the possible completions whenever completion is not exact.
1168
fc98b4ba 1169@vindex shell-completion-execonly
6bf7aab6 1170 Command completion normally considers only executable files.
fc98b4ba 1171If you set @code{shell-completion-execonly} to @code{nil},
6bf7aab6
DL
1172it considers nonexecutable files as well.
1173
1174@findex shell-pushd-tohome
1175@findex shell-pushd-dextract
1176@findex shell-pushd-dunique
1177 You can configure the behavior of @samp{pushd}. Variables control
1178whether @samp{pushd} behaves like @samp{cd} if no argument is given
1179(@code{shell-pushd-tohome}), pop rather than rotate with a numeric
1180argument (@code{shell-pushd-dextract}), and only add directories to the
1181directory stack if they are not already on it
1182(@code{shell-pushd-dunique}). The values you choose should match the
1183underlying shell, of course.
1184
3b65ce47 1185@node Terminal emulator
df9d7630 1186@subsection Emacs Terminal Emulator
3b65ce47
DL
1187@findex term
1188
932fd020 1189 To run a subshell in a terminal emulator, use @kbd{M-x term}. This
1c64e6ed 1190creates (or reuses) a buffer named @file{*terminal*}, and runs a
932fd020
CY
1191subshell with input coming from your keyboard, and output going to
1192that buffer.
df9d7630
RS
1193
1194 The terminal emulator uses Term mode, which has two input modes. In
88c5c7c8 1195line mode, Term basically acts like Shell mode (@pxref{Shell Mode}).
3b65ce47 1196
88c5c7c8 1197 In char mode, each character is sent directly to the subshell, as
16152b76 1198``terminal input''. Any ``echoing'' of your input is the
df9d7630
RS
1199responsibility of the subshell. The sole exception is the terminal
1200escape character, which by default is @kbd{C-c} (@pxref{Term Mode}).
3b65ce47
DL
1201Any ``terminal output'' from the subshell goes into the buffer,
1202advancing point.
1203
df9d7630
RS
1204 Some programs (such as Emacs itself) need to control the appearance
1205on the terminal screen in detail. They do this by sending special
1206control codes. The exact control codes needed vary from terminal to
1207terminal, but nowadays most terminals and terminal emulators
1208(including @code{xterm}) understand the ANSI-standard (VT100-style)
1209escape sequences. Term mode recognizes these escape sequences, and
1210handles each one appropriately, changing the buffer so that the
1211appearance of the window matches what it would be on a real terminal.
1212You can actually run Emacs inside an Emacs Term window.
1213
88c5c7c8
CY
1214 You can also Term mode to communicate with a device connected to a
1215serial port. @xref{Serial Terminal}.
37e5d54a
GM
1216
1217 The file name used to load the subshell is determined the same way
df9d7630 1218as for Shell mode. To make multiple terminal emulators, rename the
1c64e6ed 1219buffer @file{*terminal*} to something different using @kbd{M-x
df9d7630
RS
1220rename-uniquely}, just as with Shell mode.
1221
1222 Unlike Shell mode, Term mode does not track the current directory by
1223examining your input. But some shells can tell Term what the current
1224directory is. This is done automatically by @code{bash} version 1.15
1225and later.
3b65ce47
DL
1226
1227@node Term Mode
1228@subsection Term Mode
1229@cindex Term mode
1230@cindex mode, Term
1231
df9d7630 1232 The terminal emulator uses Term mode, which has two input modes. In
88c5c7c8
CY
1233line mode, Term basically acts like Shell mode (@pxref{Shell Mode}).
1234In char mode, each character is sent directly to the subshell, except
1235for the Term escape character, normally @kbd{C-c}.
df9d7630
RS
1236
1237 To switch between line and char mode, use these commands:
3b65ce47 1238
3b65ce47 1239@table @kbd
91179e97 1240@kindex C-c C-j @r{(Term mode)}
88c5c7c8 1241@findex term-line-mode
91179e97 1242@item C-c C-j
88c5c7c8
CY
1243Switch to line mode (@code{term-line-mode}). Do nothing if already in
1244line mode.
3b65ce47 1245
91179e97 1246@kindex C-c C-k @r{(Term mode)}
88c5c7c8 1247@findex term-char-mode
91179e97 1248@item C-c C-k
88c5c7c8
CY
1249Switch to char mode (@code{term-char-mode}). Do nothing if already in
1250char mode.
3b65ce47
DL
1251@end table
1252
df9d7630
RS
1253 The following commands are only available in char mode:
1254
3b65ce47
DL
1255@table @kbd
1256@item C-c C-c
1257Send a literal @key{C-c} to the sub-shell.
1258
6f8ca5e4
RS
1259@item C-c @var{char}
1260This is equivalent to @kbd{C-x @var{char}} in normal Emacs. For
1261example, @kbd{C-c o} invokes the global binding of @kbd{C-x o}, which
1262is normally @samp{other-window}.
3b65ce47
DL
1263@end table
1264
88c5c7c8
CY
1265@cindex paging in Term mode
1266 Term mode has a page-at-a-time feature. When enabled, it makes
1267output pause at the end of each screenful:
3b65ce47
DL
1268
1269@table @kbd
1270@kindex C-c C-q @r{(Term mode)}
1271@findex term-pager-toggle
1272@item C-c C-q
df9d7630 1273Toggle the page-at-a-time feature. This command works in both line
88c5c7c8
CY
1274and char modes. When the feature is enabled, the mode-line displays
1275the word @samp{page}, and each time Term receives more than a
1276screenful of output, it pauses and displays @samp{**MORE**} in the
1277mode-line. Type @key{SPC} to display the next screenful of output, or
1278@kbd{?} to see your other options. The interface is similar to the
1279@code{more} program.
3b65ce47
DL
1280@end table
1281
6bf7aab6
DL
1282@node Remote Host
1283@subsection Remote Host Shell
1284@cindex remote host
1285@cindex connecting to remote host
1286@cindex Telnet
1287@cindex Rlogin
1288
3b65ce47
DL
1289 You can login to a remote computer, using whatever commands you
1290would from a regular terminal (e.g.@: using the @code{telnet} or
1291@code{rlogin} commands), from a Term window.
1292
df9d7630
RS
1293 A program that asks you for a password will normally suppress
1294echoing of the password, so the password will not show up in the
1295buffer. This will happen just as if you were using a real terminal,
1296if the buffer is in char mode. If it is in line mode, the password is
1297temporarily visible, but will be erased when you hit return. (This
1298happens automatically; there is no special password processing.)
3b65ce47 1299
df9d7630 1300 When you log in to a different machine, you need to specify the type
e51d6b23
LT
1301of terminal you're using, by setting the @env{TERM} environment
1302variable in the environment for the remote login command. (If you use
1303bash, you do that by writing the variable assignment before the remote
88c5c7c8
CY
1304login command, without a separating comma.) Terminal types
1305@samp{ansi} or @samp{vt100} will work on most systems.
df9d7630 1306
37e5d54a
GM
1307@node Serial Terminal
1308@subsection Serial Terminal
1309@cindex terminal, serial
1310@findex serial-term
1311
1312 If you have a device connected to a serial port of your computer,
88c5c7c8
CY
1313you can communicate with it by typing @kbd{M-x serial-term}. This
1314command asks for a serial port name and speed, and switches to a new
1315Term mode buffer. Emacs communicates with the serial device through
1316this buffer just like it does with a terminal in ordinary Term mode.
37e5d54a
GM
1317
1318 The speed of the serial port is measured in bits per second. The
1319most common speed is 9600 bits per second. You can change the speed
1320interactively by clicking on the mode line.
1321
1322 A serial port can be configured even more by clicking on ``8N1'' in
1323the mode line. By default, a serial port is configured as ``8N1'',
1324which means that each byte consists of 8 data bits, No parity check
1325bit, and 1 stopbit.
1326
37e5d54a
GM
1327 If the speed or the configuration is wrong, you cannot communicate
1328with your device and will probably only see garbage output in the
1329window.
1330
abb9615e 1331@node Emacs Server
6bf7aab6
DL
1332@section Using Emacs as a Server
1333@pindex emacsclient
1334@cindex Emacs as a server
1335@cindex server, using Emacs as
60a96371 1336@cindex @env{EDITOR} environment variable
6bf7aab6 1337
88c5c7c8
CY
1338 Various programs can invoke your choice of editor to edit a
1339particular piece of text. For instance, version control programs
1340invoke an editor to enter version control logs (@pxref{Version
1341Control}), and the Unix @command{mail} utility invokes an editor to
1342enter a message to send. By convention, your choice of editor is
1343specified by the environment variable @env{EDITOR}. If you set
1344@env{EDITOR} to @samp{emacs}, Emacs would be invoked, but in an
1345inconvenient way---by starting a new Emacs process. This is
8cec98c0
CY
1346inconvenient because the new Emacs process doesn't share buffers, a
1347command history, or other kinds of information with any existing Emacs
1348process.
1349
1350 You can solve this problem by setting up Emacs as an @dfn{edit
1351server}, so that it ``listens'' for external edit requests and acts
1352accordingly. There are two ways to start an Emacs server:
6bf7aab6 1353
88c5c7c8 1354@itemize
d9d81805 1355@findex server-start
88c5c7c8
CY
1356@item
1357Run the command @code{server-start} in an existing Emacs process:
1358either type @kbd{M-x server-start}, or put the expression
1359@code{(server-start)} in your init file (@pxref{Init File}). The
1360existing Emacs process is the server; when you exit Emacs, the server
1361dies with the Emacs process.
8cec98c0
CY
1362
1363@cindex daemon, Emacs
88c5c7c8
CY
1364@item
1365Run Emacs as a @dfn{daemon}, using the @samp{--daemon} command-line
1366option. @xref{Initial Options}. When Emacs is started this way, it
1367calls @code{server-start} after initialization, and returns control to
1368the calling terminal instead of opening an initial frame; it then
1369waits in the background, listening for edit requests.
1370@end itemize
df9d7630 1371
8cec98c0 1372@cindex @env{TEXEDIT} environment variable
88c5c7c8
CY
1373 Either way, once an Emacs server is started, you can use a shell
1374command called @command{emacsclient} to connect to the Emacs process
1375and tell it to visit a file. You can then set the @env{EDITOR}
1376environment variable to @samp{emacsclient}, so that external programs
1377will use the existing Emacs process for editing.@footnote{Some
1378programs use a different environment variable; for example, to make
1379@TeX{} use @samp{emacsclient}, set the @env{TEXEDIT} environment
1380variable to @samp{emacsclient +%d %s}.}
6bf7aab6 1381
82b9073d
RS
1382@vindex server-name
1383 You can run multiple Emacs servers on the same machine by giving
1384each one a unique ``server name'', using the variable
4f256c8e
RS
1385@code{server-name}. For example, @kbd{M-x set-variable @key{RET}
1386server-name @key{RET} foo @key{RET}} sets the server name to
d9d81805 1387@samp{foo}. The @code{emacsclient} program can specify a server by
8cec98c0 1388name, using the @samp{-s} option (@pxref{emacsclient Options}).
82b9073d 1389
e793a940 1390@findex server-eval-at
88c5c7c8
CY
1391 If you have defined a server by a unique server name, it is possible
1392to connect to the server from another Emacs instance and evaluate Lisp
1393expressions on the server, using the @code{server-eval-at} function.
1394For instance, @code{(server-eval-at "foo" '(+ 1 2))} evaluates the
1395expression @code{(+ 1 2)} on the @samp{foo} server, and returns
1396@code{3}. (If there is no server with that name, an error is
1397signaled.) Currently, this feature is mainly useful for developers.
e793a940 1398
8cec98c0
CY
1399@menu
1400* Invoking emacsclient:: Connecting to the Emacs server.
1401* emacsclient Options:: Emacs client startup options.
1402@end menu
6bf7aab6 1403
8cec98c0
CY
1404@node Invoking emacsclient
1405@subsection Invoking @code{emacsclient}
1406@cindex @code{emacsclient} invocation
1407
1408 The simplest way to use the @command{emacsclient} program is to run
1409the shell command @samp{emacsclient @var{file}}, where @var{file} is a
1410file name. This connects to an Emacs server, and tells that Emacs
1411process to visit @var{file} in one of its existing frames---either a
0be641c0 1412graphical frame, or one in a text terminal (@pxref{Frames}). You
a568b1f9 1413can then select that frame to begin editing.
8cec98c0
CY
1414
1415 If there is no Emacs server, the @command{emacsclient} program halts
1416with an error message. If the Emacs process has no existing
1417frame---which can happen if it was started as a daemon (@pxref{Emacs
8b72835c 1418Server})---then Emacs opens a frame on the terminal in which you
6a5ca7c8
CY
1419called @command{emacsclient}.
1420
1421 You can also force @command{emacsclient} to open a new frame on a
0be641c0 1422graphical display, or on a text terminal, using the @samp{-c} and
6a5ca7c8
CY
1423@samp{-t} options. @xref{emacsclient Options}.
1424
0be641c0
CY
1425 If you are running on a single text terminal, you can switch between
1426@command{emacsclient}'s shell and the Emacs server using one of two
1427methods: (i) run the Emacs server and @command{emacsclient} on
6a5ca7c8
CY
1428different virtual terminals, and switch to the Emacs server's virtual
1429terminal after calling @command{emacsclient}; or (ii) call
1430@command{emacsclient} from within the Emacs server itself, using Shell
1431mode (@pxref{Interactive Shell}) or Term mode (@pxref{Term Mode});
1432@code{emacsclient} blocks only the subshell under Emacs, and you can
1433still use Emacs to edit the file.
a568b1f9 1434
8cec98c0
CY
1435@kindex C-x #
1436@findex server-edit
a568b1f9
CY
1437 When you finish editing @var{file} in the Emacs server, type
1438@kbd{C-x #} (@code{server-edit}) in its buffer. This saves the file
1439and sends a message back to the @command{emacsclient} program, telling
1440it to exit. Programs that use @env{EDITOR} usually wait for the
da0bbbc4 1441``editor''---in this case @command{emacsclient}---to exit before doing
a568b1f9 1442something else.
8cec98c0
CY
1443
1444 You can also call @command{emacsclient} with multiple file name
1445arguments: @samp{emacsclient @var{file1} @var{file2} ...} tells the
1446Emacs server to visit @var{file1}, @var{file2}, and so forth. Emacs
1447selects the buffer visiting @var{file1}, and buries the other buffers
1448at the bottom of the buffer list (@pxref{Buffers}). The
1449@command{emacsclient} program exits once all the specified files are
1450finished (i.e., once you have typed @kbd{C-x #} in each server
1451buffer).
6bf7aab6 1452
8cec98c0
CY
1453@vindex server-kill-new-buffers
1454@vindex server-temp-file-regexp
1455 Finishing with a server buffer also kills the buffer, unless it
1456already existed in the Emacs session before the server was asked to
1457create it. However, if you set @code{server-kill-new-buffers} to
1458@code{nil}, then a different criterion is used: finishing with a
1459server buffer kills it if the file name matches the regular expression
1460@code{server-temp-file-regexp}. This is set up to distinguish certain
1461``temporary'' files.
7448f7a2 1462
8cec98c0
CY
1463 Each @kbd{C-x #} checks for other pending external requests to edit
1464various files, and selects the next such file. You can switch to a
1465server buffer manually if you wish; you don't have to arrive at it
1466with @kbd{C-x #}. But @kbd{C-x #} is the way to tell
1467@command{emacsclient} that you are finished.
b1a92ebf 1468
8cec98c0 1469@vindex server-window
6a5ca7c8
CY
1470 If you set the value of the variable @code{server-window} to a
1471window or a frame, @kbd{C-x #} always displays the next server buffer
1472in that window or in that frame.
6bf7aab6 1473
8cec98c0
CY
1474@node emacsclient Options
1475@subsection @code{emacsclient} Options
1476@cindex @code{emacsclient} options
6bf7aab6 1477
8cec98c0
CY
1478 You can pass some optional arguments to the @command{emacsclient}
1479program, such as:
6bf7aab6
DL
1480
1481@example
8cec98c0 1482emacsclient -c +12 @var{file1} +4:3 @var{file2}
6bf7aab6
DL
1483@end example
1484
df9d7630 1485@noindent
78b6d6d2
CY
1486The @samp{+@var{line}} or @samp{+@var{line}:@var{column}} arguments
1487specify line numbers, or line and column numbers, for the next file
1488argument. These behave like the command line arguments for Emacs
1489itself. @xref{Action Arguments}.
8cec98c0
CY
1490
1491 The other optional arguments recognized by @command{emacsclient} are
1492listed below:
1493
1494@table @samp
1495@item -a @var{command}
1496@itemx --alternate-editor=@var{command}
1497Specify a command to run if @code{emacsclient} fails to contact Emacs.
ae742cb5 1498This is useful when running @code{emacsclient} in a script.
6bf7aab6 1499
932fd020 1500As a special exception, if @var{command} is the empty string, then
453e4522
CY
1501@code{emacsclient} starts Emacs in daemon mode (as @command{emacs
1502--daemon}) and then tries connecting again.
932fd020 1503
d9d81805 1504@cindex @env{ALTERNATE_EDITOR} environment variable
932fd020
CY
1505The environment variable @env{ALTERNATE_EDITOR} has the same effect as
1506the @samp{-a} option. If both are present, the latter takes
8cec98c0
CY
1507precedence.
1508
6a00f380 1509@cindex client frame
8cec98c0 1510@item -c
6a00f380
CY
1511Create a new graphical @dfn{client frame}, instead of using an
1512existing Emacs frame. If you omit a filename argument while supplying
1513the @samp{-c} option, the new frame displays the @file{*scratch*}
1514buffer (@pxref{Buffers}). See below for the special behavior of
1515@kbd{C-x C-c} in a client frame.
1516
467a33d0
CY
1517If Emacs is unable to create a new graphical frame (e.g.@: if it is
1518unable to connect to the X server), it tries to create a text terminal
1519client frame, as though you had supplied the @samp{-t} option instead
1520(see below).
1521
1522On MS-Windows, a single Emacs session cannot display frames on both
1523graphical and text terminals, nor on multiple text terminals. Thus,
1524if the Emacs server is running on a text terminal, the @samp{-c}
1525option, like the @samp{-t} option, creates a new frame in the server's
1526current text terminal. @xref{Windows Startup}.
8cec98c0 1527
88c5c7c8 1528@item -F @var{alist}
18a4ce5e
AR
1529@itemx --frame-parameters=@var{alist}
1530Set the parameters for a newly-created graphical frame
1531(@pxref{Frame Parameters}).
1532
8cec98c0
CY
1533@item -d @var{display}
1534@itemx --display=@var{display}
1535Tell Emacs to open the given files on the X display @var{display}
1536(assuming there is more than one X display available).
1537
1538@item -e
1539@itemx --eval
1540Tell Emacs to evaluate some Emacs Lisp code, instead of visiting some
1541files. When this option is given, the arguments to
1542@command{emacsclient} are interpreted as a list of expressions to
1543evaluate, @emph{not} as a list of files to visit.
1544
1545@item -f @var{server-file}
1546@itemx --server-file=@var{server-file}
d9d81805 1547@cindex @env{EMACS_SERVER_FILE} environment variable
8cec98c0 1548@cindex server file
01bfa900
CY
1549@vindex server-use-tcp
1550@vindex server-host
8cec98c0
CY
1551Specify a @dfn{server file} for connecting to an Emacs server via TCP.
1552
01bfa900 1553An Emacs server usually uses an operating system feature called a
8cec98c0
CY
1554``local socket'' to listen for connections. Some operating systems,
1555such as Microsoft Windows, do not support local sockets; in that case,
01bfa900
CY
1556Emacs uses TCP instead. When you start the Emacs server, Emacs
1557creates a server file containing some TCP information that
1558@command{emacsclient} needs for making the connection. By default,
1559the server file is in @file{~/.emacs.d/server/}. On Microsoft
1560Windows, if @command{emacsclient} does not find the server file there,
1561it looks in the @file{.emacs.d/server/} subdirectory of the directory
1562pointed to by the @env{APPDATA} environment variable. You can tell
1563@command{emacsclient} to use a specific server file with the @samp{-f}
1564or @samp{--server-file} option, or by setting the
1565@env{EMACS_SERVER_FILE} environment variable.
1566
1567Even if local sockets are available, you can tell Emacs to use TCP by
1568setting the variable @code{server-use-tcp} to @code{t}. One advantage
1569of TCP is that the server can accept connections from remote machines.
1570For this to work, you must (i) set the variable @code{server-host} to
1571the hostname or IP address of the machine on which the Emacs server
1572runs, and (ii) provide @command{emacsclient} with the server file.
1573(One convenient way to do the latter is to put the server file on a
1574networked file system such as NFS.)
5b8b9fa7 1575
ddb54206
CY
1576@vindex server-port
1577 When the Emacs server is using TCP, the variable @code{server-port}
1578determines the port number to listen on; the default value,
1579@code{nil}, means to choose a random port when the server starts.
1580
8cec98c0
CY
1581@item -n
1582@itemx --no-wait
1583Let @command{emacsclient} exit immediately, instead of waiting until
1584all server buffers are finished. You can take as long as you like to
1585edit the server buffers within Emacs, and they are @emph{not} killed
1586when you type @kbd{C-x #} in them.
1587
fdeb32ec
CY
1588@item --parent-id @var{ID}
1589Open an @command{emacsclient} frame as a client frame in the parent X
1590window with id @var{ID}, via the XEmbed protocol. Currently, this
1591option is mainly useful for developers.
1592
0b973fc5
DW
1593@item -q
1594@itemx --quiet
1595Do not let @command{emacsclient} display messages about waiting for
1596Emacs or connecting to remote server sockets.
1597
8cec98c0
CY
1598@item -s @var{server-name}
1599@itemx --socket-name=@var{server-name}
1600Connect to the Emacs server named @var{server-name}. The server name
1601is given by the variable @code{server-name} on the Emacs server. If
1602this option is omitted, @command{emacsclient} connects to the first
1603server it finds. (This option is not supported on MS-Windows.)
1604
1605@item -t
1606@itemx --tty
1607@itemx -nw
6a00f380
CY
1608Create a new client frame on the current text terminal, instead of
1609using an existing Emacs frame. This is similar to the @samp{-c}
1610option, above, except that it creates a text terminal frame
1611(@pxref{Non-Window Terminals}). If you omit a filename argument while
1612supplying this option, the new frame displays the @file{*scratch*}
1613buffer (@pxref{Buffers}). See below for the special behavior of
1614@kbd{C-x C-c} in a client frame.
1615
467a33d0
CY
1616On MS-Windows, a single Emacs session cannot display frames on both
1617graphical and text terminals, nor on multiple text terminals. Thus,
1618if the Emacs server is using the graphical display, @samp{-t} behaves
1619like @samp{-c} (see above); whereas if the Emacs server is running on
1620a text terminal, it creates a new frame in its current text terminal.
1621@xref{Windows Startup}.
8cec98c0
CY
1622@end table
1623
467a33d0
CY
1624 The new graphical or text terminal frames created by the @samp{-c}
1625or @samp{-t} options are considered @dfn{client frames}. Any new
1626frame that you create from a client frame is also considered a client
1627frame. If you type @kbd{C-x C-c} (@code{save-buffers-kill-terminal})
1628in a client frame, that command does not kill the Emacs session as it
1629normally does (@pxref{Exiting}). Instead, Emacs deletes the client
1630frame; furthermore, if the client frame has an @command{emacsclient}
1631waiting to regain control (i.e.@: if you did not supply the @samp{-n}
1632option), Emacs deletes all other frames of the same client, and marks
1633the client's server buffers as finished, as though you had typed
1634@kbd{C-x #} in all of them. If it so happens that there are no
1635remaining frames after the client frame(s) are deleted, the Emacs
1636session exits.
1637
1638 As an exception, when Emacs is started as a daemon, all frames are
1639considered client frames, and @kbd{C-x C-c} never kills Emacs. To
1640kill a daemon session, type @kbd{M-x kill-emacs}.
1641
1642 Note that the @samp{-t} and @samp{-n} options are contradictory:
1643@samp{-t} says to take control of the current text terminal to create
1644a new client frame, while @samp{-n} says not to take control of the
1645text terminal. If you supply both options, Emacs visits the specified
1646files(s) in an existing frame rather than a new client frame, negating
1647the effect of @samp{-t}.
8cec98c0 1648
abb9615e 1649@node Printing
66bb4d9a 1650@section Printing Hard Copies
6bf7aab6 1651@cindex hardcopy
66bb4d9a 1652@cindex printing
6bf7aab6 1653
88c5c7c8
CY
1654 Emacs provides commands for printing hardcopies of either an entire
1655buffer or part of one. You can invoke the printing commands directly,
1656as detailed below, or using the @samp{File} menu on the menu bar.
eb5ed549
CY
1657
1658@findex htmlfontify-buffer
1659 Aside from the commands described in this section, you can also
88c5c7c8
CY
1660print hardcopies from Dired (@pxref{Operating on Files}) and the diary
1661(@pxref{Displaying the Diary}). You can also ``print'' an Emacs
1662buffer to HTML with the command @kbd{M-x htmlfontify-buffer}, which
1663converts the current buffer to a HTML file, replacing Emacs faces with
1664CSS-based markup. Furthermore, Org mode allows you to ``print'' Org
1665files to a variety of formats, such as PDF (@pxref{Org Mode}).
6bf7aab6
DL
1666
1667@table @kbd
1668@item M-x print-buffer
88c5c7c8
CY
1669Print hardcopy of current buffer with page headings containing the
1670file name and page number.
6bf7aab6
DL
1671@item M-x lpr-buffer
1672Print hardcopy of current buffer without page headings.
1673@item M-x print-region
1674Like @code{print-buffer} but print only the current region.
1675@item M-x lpr-region
1676Like @code{lpr-buffer} but print only the current region.
1677@end table
1678
1679@findex print-buffer
1680@findex print-region
1681@findex lpr-buffer
1682@findex lpr-region
1683@vindex lpr-switches
88c5c7c8
CY
1684@vindex lpr-commands
1685 On most operating system, the above hardcopy commands submit files
1686for printing by calling the @command{lpr} program. To change the
1687printer program, customize the variable @code{lpr-command}. To
1688specify extra switches to give the printer program, customize the list
1689variable @code{lpr-switches}. Its value should be a list of option
1690strings, each of which should start with @samp{-} (e.g.@: the option
1691string @code{"-w80"} specifies a line width of 80 columns). The
1692default is the empty list, @code{nil}.
6bf7aab6
DL
1693
1694@vindex printer-name
88c5c7c8
CY
1695@vindex lpr-printer-switch
1696 To specify the printer to use, set the variable @code{printer-name}.
1697The default, @code{nil}, specifies the default printer. If you set it
1698to a printer name (a string), that name is passed to @command{lpr}
1699with the @samp{-P} switch; if you are not using @command{lpr}, you
1700should specify the switch with @code{lpr-printer-switch}.
6bf7aab6
DL
1701
1702@vindex lpr-headers-switches
6bf7aab6 1703@vindex lpr-add-switches
88c5c7c8
CY
1704 The variable @code{lpr-headers-switches} similarly specifies the
1705extra switches to use to make page headers. The variable
1706@code{lpr-add-switches} controls whether to supply @samp{-T} and
1707@samp{-J} options (suitable for @command{lpr}) to the printer program:
1708@code{nil} means don't add them (this should be the value if your
1709printer program is not compatible with @command{lpr}).
6bf7aab6 1710
66bb4d9a 1711@menu
8838673e 1712* PostScript:: Printing buffers or regions as PostScript.
66bb4d9a
EZ
1713* PostScript Variables:: Customizing the PostScript printing commands.
1714* Printing Package:: An optional advanced printing interface.
1715@end menu
1716
abb9615e 1717@node PostScript
856ce114 1718@subsection PostScript Hardcopy
6bf7aab6 1719
3b65ce47 1720 These commands convert buffer contents to PostScript,
6bf7aab6
DL
1721either printing it or leaving it in another Emacs buffer.
1722
1723@table @kbd
1724@item M-x ps-print-buffer
3b65ce47 1725Print hardcopy of the current buffer in PostScript form.
6bf7aab6 1726@item M-x ps-print-region
3b65ce47 1727Print hardcopy of the current region in PostScript form.
6bf7aab6 1728@item M-x ps-print-buffer-with-faces
3b65ce47
DL
1729Print hardcopy of the current buffer in PostScript form, showing the
1730faces used in the text by means of PostScript features.
6bf7aab6 1731@item M-x ps-print-region-with-faces
3b65ce47 1732Print hardcopy of the current region in PostScript form, showing the
6bf7aab6
DL
1733faces used in the text.
1734@item M-x ps-spool-buffer
2f298da2 1735Generate and spool a PostScript image for the current buffer text.
6bf7aab6 1736@item M-x ps-spool-region
2f298da2 1737Generate and spool a PostScript image for the current region.
6bf7aab6 1738@item M-x ps-spool-buffer-with-faces
2f298da2 1739Generate and spool a PostScript image for the current buffer, showing the faces used.
6bf7aab6 1740@item M-x ps-spool-region-with-faces
2f298da2
VJL
1741Generate and spool a PostScript image for the current region, showing the faces used.
1742@item M-x ps-despool
1743Send the spooled PostScript to the printer.
3b65ce47 1744@item M-x handwrite
2f298da2 1745Generate/print PostScript for the current buffer as if handwritten.
6bf7aab6
DL
1746@end table
1747
1748@findex ps-print-region
1749@findex ps-print-buffer
1750@findex ps-print-region-with-faces
1751@findex ps-print-buffer-with-faces
88c5c7c8
CY
1752 The @code{ps-print-buffer} and @code{ps-print-region} commands print
1753buffer contents in PostScript form. One command prints the entire
1754buffer; the other, just the region. The commands
1755@code{ps-print-buffer-with-faces} and
1756@code{ps-print-region-with-faces} behave similarly, but use PostScript
1757features to show the faces (fonts and colors) of the buffer text.
2f298da2
VJL
1758
1759 Interactively, when you use a prefix argument (@kbd{C-u}), the command
1760prompts the user for a file name, and saves the PostScript image in that file
1761instead of sending it to the printer.
1762
6bf7aab6
DL
1763@findex ps-spool-region
1764@findex ps-spool-buffer
1765@findex ps-spool-region-with-faces
1766@findex ps-spool-buffer-with-faces
2f298da2 1767 The commands whose names have @samp{spool} instead of @samp{print},
3b65ce47 1768generate the PostScript output in an Emacs buffer instead of sending
6bf7aab6
DL
1769it to the printer.
1770
2f298da2 1771@findex ps-despool
88c5c7c8
CY
1772 Use the command @code{ps-despool} to send the spooled images to the
1773printer. This command sends the PostScript generated by
1774@samp{-spool-} commands (see commands above) to the printer. With a
1775prefix argument (@kbd{C-u}), it prompts for a file name, and saves the
1776spooled PostScript image in that file instead of sending it to the
1777printer.
2f298da2 1778
3b65ce47
DL
1779@findex handwrite
1780@cindex handwriting
88c5c7c8 1781 @kbd{M-x handwrite} is more frivolous. It generates a PostScript
3b65ce47 1782rendition of the current buffer as a cursive handwritten document. It
fc98b4ba
RS
1783can be customized in group @code{handwrite}. This function only
1784supports ISO 8859-1 characters.
3b65ce47 1785
abb9615e 1786@node PostScript Variables
856ce114 1787@subsection Variables for PostScript Hardcopy
6bf7aab6
DL
1788
1789@vindex ps-lpr-command
1790@vindex ps-lpr-switches
1791@vindex ps-printer-name
3b65ce47 1792 All the PostScript hardcopy commands use the variables
6bf7aab6
DL
1793@code{ps-lpr-command} and @code{ps-lpr-switches} to specify how to print
1794the output. @code{ps-lpr-command} specifies the command name to run,
1795@code{ps-lpr-switches} specifies command line options to use, and
1796@code{ps-printer-name} specifies the printer. If you don't set the
1797first two variables yourself, they take their initial values from
1798@code{lpr-command} and @code{lpr-switches}. If @code{ps-printer-name}
1799is @code{nil}, @code{printer-name} is used.
1800
1801@vindex ps-print-header
6bf7aab6
DL
1802 The variable @code{ps-print-header} controls whether these commands
1803add header lines to each page---set it to @code{nil} to turn headers
550135d1
EZ
1804off.
1805
1806@cindex color emulation on black-and-white printers
1807@vindex ps-print-color-p
1808 If your printer doesn't support colors, you should turn off color
1809processing by setting @code{ps-print-color-p} to @code{nil}. By
1810default, if the display supports colors, Emacs produces hardcopy output
1811with color information; on black-and-white printers, colors are emulated
1812with shades of gray. This might produce illegible output, even if your
1813screen colors only use shades of gray.
1814
2f298da2
VJL
1815 Alternatively, you can set @code{ps-print-color-p} to @code{black-white} to
1816print colors on black/white printers.
1817
550135d1 1818@vindex ps-use-face-background
df9d7630
RS
1819 By default, PostScript printing ignores the background colors of the
1820faces, unless the variable @code{ps-use-face-background} is
1821non-@code{nil}. This is to avoid unwanted interference with the zebra
1822stripes and background image/text.
6bf7aab6
DL
1823
1824@vindex ps-paper-type
1825@vindex ps-page-dimensions-database
1826 The variable @code{ps-paper-type} specifies which size of paper to
1827format for; legitimate values include @code{a4}, @code{a3},
1828@code{a4small}, @code{b4}, @code{b5}, @code{executive}, @code{ledger},
1829@code{legal}, @code{letter}, @code{letter-small}, @code{statement},
1830@code{tabloid}. The default is @code{letter}. You can define
1831additional paper sizes by changing the variable
1832@code{ps-page-dimensions-database}.
1833
1834@vindex ps-landscape-mode
1835 The variable @code{ps-landscape-mode} specifies the orientation of
1836printing on the page. The default is @code{nil}, which stands for
1837``portrait'' mode. Any non-@code{nil} value specifies ``landscape''
1838mode.
1839
1840@vindex ps-number-of-columns
1841 The variable @code{ps-number-of-columns} specifies the number of
1842columns; it takes effect in both landscape and portrait mode. The
1843default is 1.
1844
1845@vindex ps-font-family
1846@vindex ps-font-size
1847@vindex ps-font-info-database
1848 The variable @code{ps-font-family} specifies which font family to use
1849for printing ordinary text. Legitimate values include @code{Courier},
1850@code{Helvetica}, @code{NewCenturySchlbk}, @code{Palatino} and
1851@code{Times}. The variable @code{ps-font-size} specifies the size of
1852the font for ordinary text. It defaults to 8.5 points.
1853
adee28ff
EZ
1854@vindex ps-multibyte-buffer
1855@cindex Intlfonts for PostScript printing
1856@cindex fonts for PostScript printing
1857 Emacs supports more scripts and characters than a typical PostScript
1858printer. Thus, some of the characters in your buffer might not be
1859printable using the fonts built into your printer. You can augment
1860the fonts supplied with the printer with those from the GNU Intlfonts
1861package, or you can instruct Emacs to use Intlfonts exclusively. The
1862variable @code{ps-multibyte-buffer} controls this: the default value,
76dd3692 1863@code{nil}, is appropriate for printing @acronym{ASCII} and Latin-1
adee28ff 1864characters; a value of @code{non-latin-printer} is for printers which
76dd3692 1865have the fonts for @acronym{ASCII}, Latin-1, Japanese, and Korean
adee28ff
EZ
1866characters built into them. A value of @code{bdf-font} arranges for
1867the BDF fonts from the Intlfonts package to be used for @emph{all}
1868characters. Finally, a value of @code{bdf-font-except-latin}
76dd3692 1869instructs the printer to use built-in fonts for @acronym{ASCII} and Latin-1
adee28ff
EZ
1870characters, and Intlfonts BDF fonts for the rest.
1871
1872@vindex bdf-directory-list
021037cb 1873 To be able to use the BDF fonts, Emacs needs to know where to find
adee28ff
EZ
1874them. The variable @code{bdf-directory-list} holds the list of
1875directories where Emacs should look for the fonts; the default value
1876includes a single directory @file{/usr/local/share/emacs/fonts/bdf}.
1877
6bf7aab6 1878 Many other customization variables for these commands are defined and
adee28ff 1879described in the Lisp files @file{ps-print.el} and @file{ps-mule.el}.
6bf7aab6 1880
abb9615e 1881@node Printing Package
856ce114 1882@subsection Printing Package
66bb4d9a
EZ
1883@cindex Printing package
1884
1885 The basic Emacs facilities for printing hardcopy can be extended
1886using the Printing package. This provides an easy-to-use interface
1887for choosing what to print, previewing PostScript files before
1888printing, and setting various printing options such as print headers,
1889landscape or portrait modes, duplex modes, and so forth. On GNU/Linux
1890or Unix systems, the Printing package relies on the @file{gs} and
1891@file{gv} utilities, which are distributed as part of the GhostScript
1892program. On MS-Windows, the @file{gstools} port of Ghostscript can be
1893used.
1894
1895@findex pr-interface
1896 To use the Printing package, add @code{(require 'printing)} to your
aada47fc
RS
1897init file (@pxref{Init File}), followed by @code{(pr-update-menus)}.
1898This function replaces the usual printing commands in the menu bar
1899with a @samp{Printing} submenu that contains various printing options.
1900You can also type @kbd{M-x pr-interface RET}; this creates a
1c64e6ed 1901@file{*Printing Interface*} buffer, similar to a customization buffer,
aada47fc
RS
1902where you can set the printing options. After selecting what and how
1903to print, you start the print job using the @samp{Print} button (click
1904@kbd{mouse-2} on it, or move point over it and type @kbd{RET}). For
1905further information on the various options, use the @samp{Interface
1906Help} button.
66bb4d9a 1907
f404f8bc 1908@node Sorting
6bf7aab6
DL
1909@section Sorting Text
1910@cindex sorting
1911
1912 Emacs provides several commands for sorting text in the buffer. All
982dcb1b
RS
1913operate on the contents of the region.
1914They divide the text of the region into many @dfn{sort records},
6bf7aab6
DL
1915identify a @dfn{sort key} for each record, and then reorder the records
1916into the order determined by the sort keys. The records are ordered so
1917that their keys are in alphabetical order, or, for numeric sorting, in
1918numeric order. In alphabetic sorting, all upper-case letters `A' through
76dd3692 1919`Z' come before lower-case `a', in accord with the @acronym{ASCII} character
6bf7aab6
DL
1920sequence.
1921
1922 The various sort commands differ in how they divide the text into sort
1923records and in which part of each record is used as the sort key. Most of
1924the commands make each line a separate sort record, but some commands use
1925paragraphs or pages as sort records. Most of the sort commands use each
1926entire sort record as its own sort key, but some use only a portion of the
1927record as the sort key.
1928
1929@findex sort-lines
1930@findex sort-paragraphs
1931@findex sort-pages
1932@findex sort-fields
1933@findex sort-numeric-fields
efd68b8a 1934@vindex sort-numeric-base
6bf7aab6
DL
1935@table @kbd
1936@item M-x sort-lines
1937Divide the region into lines, and sort by comparing the entire
1938text of a line. A numeric argument means sort into descending order.
1939
1940@item M-x sort-paragraphs
1941Divide the region into paragraphs, and sort by comparing the entire
1942text of a paragraph (except for leading blank lines). A numeric
1943argument means sort into descending order.
1944
1945@item M-x sort-pages
1946Divide the region into pages, and sort by comparing the entire
1947text of a page (except for leading blank lines). A numeric
1948argument means sort into descending order.
1949
1950@item M-x sort-fields
1951Divide the region into lines, and sort by comparing the contents of
1952one field in each line. Fields are defined as separated by
1953whitespace, so the first run of consecutive non-whitespace characters
1954in a line constitutes field 1, the second such run constitutes field
19552, etc.
1956
1957Specify which field to sort by with a numeric argument: 1 to sort by
1958field 1, etc. A negative argument means count fields from the right
1959instead of from the left; thus, minus 1 means sort by the last field.
1960If several lines have identical contents in the field being sorted, they
021037cb 1961keep the same relative order that they had in the original buffer.
6bf7aab6
DL
1962
1963@item M-x sort-numeric-fields
1964Like @kbd{M-x sort-fields} except the specified field is converted
1965to an integer for each line, and the numbers are compared. @samp{10}
1966comes before @samp{2} when considered as text, but after it when
efd68b8a
GM
1967considered as a number. By default, numbers are interpreted according
1968to @code{sort-numeric-base}, but numbers beginning with @samp{0x} or
1969@samp{0} are interpreted as hexadecimal and octal, respectively.
6bf7aab6
DL
1970
1971@item M-x sort-columns
1972Like @kbd{M-x sort-fields} except that the text within each line
1973used for comparison comes from a fixed range of columns. See below
1974for an explanation.
1975
1976@item M-x reverse-region
1977Reverse the order of the lines in the region. This is useful for
1978sorting into descending order by fields or columns, since those sort
1979commands do not have a feature for doing that.
1980@end table
1981
1982 For example, if the buffer contains this:
1983
1984@smallexample
1985On systems where clash detection (locking of files being edited) is
1986implemented, Emacs also checks the first time you modify a buffer
1987whether the file has changed on disk since it was last visited or
1988saved. If it has, you are asked to confirm that you want to change
1989the buffer.
1990@end smallexample
1991
1992@noindent
1993applying @kbd{M-x sort-lines} to the entire buffer produces this:
1994
1995@smallexample
1996On systems where clash detection (locking of files being edited) is
1997implemented, Emacs also checks the first time you modify a buffer
1998saved. If it has, you are asked to confirm that you want to change
1999the buffer.
2000whether the file has changed on disk since it was last visited or
2001@end smallexample
2002
2003@noindent
2004where the upper-case @samp{O} sorts before all lower-case letters. If
2005you use @kbd{C-u 2 M-x sort-fields} instead, you get this:
2006
2007@smallexample
2008implemented, Emacs also checks the first time you modify a buffer
2009saved. If it has, you are asked to confirm that you want to change
2010the buffer.
2011On systems where clash detection (locking of files being edited) is
2012whether the file has changed on disk since it was last visited or
2013@end smallexample
2014
2015@noindent
2016where the sort keys were @samp{Emacs}, @samp{If}, @samp{buffer},
2017@samp{systems} and @samp{the}.
2018
2019@findex sort-columns
2020 @kbd{M-x sort-columns} requires more explanation. You specify the
2021columns by putting point at one of the columns and the mark at the other
2022column. Because this means you cannot put point or the mark at the
2023beginning of the first line of the text you want to sort, this command
2684ed46 2024uses an unusual definition of ``region'': all of the line point is in is
6bf7aab6
DL
2025considered part of the region, and so is all of the line the mark is in,
2026as well as all the lines in between.
2027
2028 For example, to sort a table by information found in columns 10 to 15,
2029you could put the mark on column 10 in the first line of the table, and
2030point on column 15 in the last line of the table, and then run
2031@code{sort-columns}. Equivalently, you could run it with the mark on
2032column 15 in the first line and point on column 10 in the last line.
2033
2034 This can be thought of as sorting the rectangle specified by point and
2035the mark, except that the text on each line to the left or right of the
2036rectangle moves along with the text inside the rectangle.
2037@xref{Rectangles}.
2038
2039@vindex sort-fold-case
2040 Many of the sort commands ignore case differences when comparing, if
2041@code{sort-fold-case} is non-@code{nil}.
2042
f404f8bc
CY
2043@c Picture Mode documentation
2044@ifnottex
2045@include picture-xtra.texi
2046@end ifnottex
6bf7aab6 2047
6bf7aab6 2048
f404f8bc 2049@node Editing Binary Files
6bf7aab6
DL
2050@section Editing Binary Files
2051
2052@cindex Hexl mode
2053@cindex mode, Hexl
2054@cindex editing binary files
c965d0ac 2055@cindex hex editing
6bf7aab6
DL
2056 There is a special major mode for editing binary files: Hexl mode. To
2057use it, use @kbd{M-x hexl-find-file} instead of @kbd{C-x C-f} to visit
2058the file. This command converts the file's contents to hexadecimal and
2059lets you edit the translation. When you save the file, it is converted
2060automatically back to binary.
2061
2062 You can also use @kbd{M-x hexl-mode} to translate an existing buffer
2063into hex. This is useful if you visit a file normally and then discover
2064it is a binary file.
2065
2066 Ordinary text characters overwrite in Hexl mode. This is to reduce
2067the risk of accidentally spoiling the alignment of data in the file.
2068There are special commands for insertion. Here is a list of the
2069commands of Hexl mode:
2070
2071@c I don't think individual index entries for these commands are useful--RMS.
2072@table @kbd
2073@item C-M-d
2074Insert a byte with a code typed in decimal.
2075
2076@item C-M-o
2077Insert a byte with a code typed in octal.
2078
2079@item C-M-x
2080Insert a byte with a code typed in hex.
2081
2082@item C-x [
16152b76 2083Move to the beginning of a 1k-byte ``page''.
6bf7aab6
DL
2084
2085@item C-x ]
16152b76 2086Move to the end of a 1k-byte ``page''.
6bf7aab6
DL
2087
2088@item M-g
2089Move to an address specified in hex.
2090
2091@item M-j
2092Move to an address specified in decimal.
2093
2094@item C-c C-c
2095Leave Hexl mode, going back to the major mode this buffer had before you
2096invoked @code{hexl-mode}.
2097@end table
2098
c965d0ac 2099@noindent
fc98b4ba 2100Other Hexl commands let you insert strings (sequences) of binary
021037cb
EZ
2101bytes, move by @code{short}s or @code{int}s, etc.; type @kbd{C-h a
2102hexl-@key{RET}} for details.
c965d0ac
EZ
2103
2104
abb9615e 2105@node Saving Emacs Sessions
6bf7aab6
DL
2106@section Saving Emacs Sessions
2107@cindex saving sessions
24cd2514
EZ
2108@cindex restore session
2109@cindex remember editing session
2110@cindex reload files
6bf7aab6
DL
2111@cindex desktop
2112
6a51fedc
RS
2113 Use the desktop library to save the state of Emacs from one session
2114to another. Once you save the Emacs @dfn{desktop}---the buffers,
2115their file names, major modes, buffer positions, and so on---then
2116subsequent Emacs sessions reload the saved desktop.
6bf7aab6 2117
6a51fedc 2118@findex desktop-save
080e83d1 2119@vindex desktop-save-mode
6a51fedc 2120 You can save the desktop manually with the command @kbd{M-x
1096b4a0
RS
2121desktop-save}. You can also enable automatic saving of the desktop
2122when you exit Emacs, and automatic restoration of the last saved
2123desktop when Emacs starts: use the Customization buffer (@pxref{Easy
2124Customization}) to set @code{desktop-save-mode} to @code{t} for future
932fd020 2125sessions, or add this line in your init file (@pxref{Init File}):
6bf7aab6
DL
2126
2127@example
080e83d1 2128(desktop-save-mode 1)
6bf7aab6
DL
2129@end example
2130
080e83d1
LH
2131@findex desktop-change-dir
2132@findex desktop-revert
e4a0188a 2133@vindex desktop-path
932fd020
CY
2134 If you turn on @code{desktop-save-mode} in your init file, then when
2135Emacs starts, it looks for a saved desktop in the current directory.
e4a0188a
GM
2136(More precisely, it looks in the directories specified by
2137@var{desktop-path}, and uses the first desktop it finds.)
932fd020
CY
2138Thus, you can have separate saved desktops in different directories,
2139and the starting directory determines which one Emacs reloads. You
2140can save the current desktop and reload one saved in another directory
2141by typing @kbd{M-x desktop-change-dir}. Typing @kbd{M-x
2142desktop-revert} reverts to the desktop previously reloaded.
080e83d1 2143
6a51fedc 2144 Specify the option @samp{--no-desktop} on the command line when you
b9ed2fa6 2145don't want it to reload any saved desktop. This turns off
5bfef96c
EZ
2146@code{desktop-save-mode} for the current session. Starting Emacs with
2147the @samp{--no-init-file} option also disables desktop reloading,
932fd020
CY
2148since it bypasses the init file, where @code{desktop-save-mode} is
2149usually turned on.
6bf7aab6 2150
a3f7375f
RS
2151@vindex desktop-restore-eager
2152 By default, all the buffers in the desktop are restored at one go.
2153However, this may be slow if there are a lot of buffers in the
2154desktop. You can specify the maximum number of buffers to restore
2155immediately with the variable @code{desktop-restore-eager}; the
16152b76 2156remaining buffers are restored ``lazily'', when Emacs is idle.
a3f7375f 2157
080e83d1 2158@findex desktop-clear
080e83d1
LH
2159@vindex desktop-globals-to-clear
2160@vindex desktop-clear-preserve-buffers-regexp
6a51fedc
RS
2161 Type @kbd{M-x desktop-clear} to empty the Emacs desktop. This kills
2162all buffers except for internal ones, and clears the global variables
2163listed in @code{desktop-globals-to-clear}. If you want this to
080e83d1 2164preserve certain buffers, customize the variable
6a51fedc
RS
2165@code{desktop-clear-preserve-buffers-regexp}, whose value is a regular
2166expression matching the names of buffers not to kill.
17a4f5ec 2167
89b5d9ab
RS
2168 If you want to save minibuffer history from one session to
2169another, use the @code{savehist} library.
2170
abb9615e 2171@node Recursive Edit
6bf7aab6
DL
2172@section Recursive Editing Levels
2173@cindex recursive editing level
2174@cindex editing level, recursive
2175
2176 A @dfn{recursive edit} is a situation in which you are using Emacs
2177commands to perform arbitrary editing while in the middle of another
2178Emacs command. For example, when you type @kbd{C-r} inside of a
2179@code{query-replace}, you enter a recursive edit in which you can change
2180the current buffer. On exiting from the recursive edit, you go back to
2181the @code{query-replace}.
2182
2183@kindex C-M-c
2184@findex exit-recursive-edit
2185@cindex exiting recursive edit
2186 @dfn{Exiting} the recursive edit means returning to the unfinished
2187command, which continues execution. The command to exit is @kbd{C-M-c}
2188(@code{exit-recursive-edit}).
2189
2190 You can also @dfn{abort} the recursive edit. This is like exiting,
2191but also quits the unfinished command immediately. Use the command
2192@kbd{C-]} (@code{abort-recursive-edit}) to do this. @xref{Quitting}.
2193
2194 The mode line shows you when you are in a recursive edit by displaying
2195square brackets around the parentheses that always surround the major and
021037cb 2196minor mode names. Every window's mode line shows this in the same way,
6bf7aab6
DL
2197since being in a recursive edit is true of Emacs as a whole rather than
2198any particular window or buffer.
2199
2200 It is possible to be in recursive edits within recursive edits. For
2201example, after typing @kbd{C-r} in a @code{query-replace}, you may type a
2202command that enters the debugger. This begins a recursive editing level
2203for the debugger, within the recursive editing level for @kbd{C-r}.
2204Mode lines display a pair of square brackets for each recursive editing
2205level currently in progress.
2206
982dcb1b 2207 Exiting the inner recursive edit (such as with the debugger @kbd{c}
6bf7aab6
DL
2208command) resumes the command running in the next level up. When that
2209command finishes, you can then use @kbd{C-M-c} to exit another recursive
2210editing level, and so on. Exiting applies to the innermost level only.
2211Aborting also gets out of only one level of recursive edit; it returns
2212immediately to the command level of the previous recursive edit. If you
2213wish, you can then abort the next recursive editing level.
2214
2215 Alternatively, the command @kbd{M-x top-level} aborts all levels of
25ed034e
CY
2216recursive edits, returning immediately to the top-level command
2217reader. It also exits the minibuffer, if it is active.
6bf7aab6
DL
2218
2219 The text being edited inside the recursive edit need not be the same text
2220that you were editing at top level. It depends on what the recursive edit
2221is for. If the command that invokes the recursive edit selects a different
2222buffer first, that is the buffer you will edit recursively. In any case,
2223you can switch buffers within the recursive edit in the normal manner (as
2224long as the buffer-switching keys have not been rebound). You could
2225probably do all the rest of your editing inside the recursive edit,
2226visiting files and all. But this could have surprising effects (such as
2227stack overflow) from time to time. So remember to exit or abort the
2228recursive edit when you no longer need it.
2229
2230 In general, we try to minimize the use of recursive editing levels in
2231GNU Emacs. This is because they constrain you to ``go back'' in a
2232particular order---from the innermost level toward the top level. When
2233possible, we present different activities in separate buffers so that
2234you can switch between them as you please. Some commands switch to a
2235new major mode which provides a command to switch back. These
2236approaches give you more flexibility to go back to unfinished tasks in
2237the order you choose.
2238
abb9615e 2239@node Emulation
6bf7aab6
DL
2240@section Emulation
2241@cindex emulating other editors
2242@cindex other editors
2243@cindex EDT
2244@cindex vi
d0960fb3 2245@cindex PC key bindings
3b65ce47 2246@cindex scrolling all windows
d0960fb3
RS
2247@cindex PC selection
2248@cindex Motif key bindings
2249@cindex Macintosh key bindings
3b65ce47 2250@cindex WordStar
6bf7aab6
DL
2251
2252 GNU Emacs can be programmed to emulate (more or less) most other
2253editors. Standard facilities can emulate these:
2254
2255@table @asis
3b65ce47
DL
2256@item CRiSP/Brief (PC editor)
2257@findex crisp-mode
2258@vindex crisp-override-meta-x
2259@findex scroll-all-mode
b1a92ebf
DL
2260@cindex CRiSP mode
2261@cindex Brief emulation
4946337d 2262@cindex emulation of Brief
b1a92ebf 2263@cindex mode, CRiSP
84f4a531
CY
2264@kbd{M-x crisp-mode} enables key bindings to emulate the CRiSP/Brief
2265editor. Note that this rebinds @kbd{M-x} to exit Emacs unless you set
2266the variable @code{crisp-override-meta-x}. You can also use the
2267command @kbd{M-x scroll-all-mode} or set the variable
b1a92ebf
DL
2268@code{crisp-load-scroll-all} to emulate CRiSP's scroll-all feature
2269(scrolling all windows together).
3b65ce47 2270
6bf7aab6
DL
2271@item EDT (DEC VMS editor)
2272@findex edt-emulation-on
2273@findex edt-emulation-off
84f4a531
CY
2274Turn on EDT emulation with @kbd{M-x edt-emulation-on}; restore normal
2275command bindings with @kbd{M-x edt-emulation-off}.
6bf7aab6
DL
2276
2277Most of the EDT emulation commands are keypad keys, and most standard
2278Emacs key bindings are still available. The EDT emulation rebindings
2279are done in the global keymap, so there is no problem switching
2280buffers or major modes while in EDT emulation.
2281
3f724e9a
DL
2282@item TPU (DEC VMS editor)
2283@findex tpu-edt-on
2284@cindex TPU
2285@kbd{M-x tpu-edt-on} turns on emulation of the TPU editor emulating EDT.
2286
6bf7aab6
DL
2287@item vi (Berkeley editor)
2288@findex viper-mode
2289Viper is the newest emulator for vi. It implements several levels of
2290emulation; level 1 is closest to vi itself, while level 5 departs
2291somewhat from strict emulation to take advantage of the capabilities of
2292Emacs. To invoke Viper, type @kbd{M-x viper-mode}; it will guide you
2293the rest of the way and ask for the emulation level. @inforef{Top,
2294Viper, viper}.
2295
2296@item vi (another emulator)
2297@findex vi-mode
2298@kbd{M-x vi-mode} enters a major mode that replaces the previously
2299established major mode. All of the vi commands that, in real vi, enter
2300``input'' mode are programmed instead to return to the previous major
2301mode. Thus, ordinary Emacs serves as vi's ``input'' mode.
2302
2303Because vi emulation works through major modes, it does not work
2304to switch buffers during emulation. Return to normal Emacs first.
2305
2306If you plan to use vi emulation much, you probably want to bind a key
2307to the @code{vi-mode} command.
2308
2309@item vi (alternate emulator)
2310@findex vip-mode
2311@kbd{M-x vip-mode} invokes another vi emulator, said to resemble real vi
2312more thoroughly than @kbd{M-x vi-mode}. ``Input'' mode in this emulator
2313is changed from ordinary Emacs so you can use @key{ESC} to go back to
2314emulated vi command mode. To get from emulated vi command mode back to
2315ordinary Emacs, type @kbd{C-z}.
2316
2317This emulation does not work through major modes, and it is possible
2318to switch buffers in various ways within the emulator. It is not
2319so necessary to assign a key to the command @code{vip-mode} as
2320it is with @code{vi-mode} because terminating insert mode does
2321not use it.
2322
2323@inforef{Top, VIP, vip}, for full information.
3b65ce47
DL
2324
2325@item WordStar (old wordprocessor)
2326@findex wordstar-mode
2327@kbd{M-x wordstar-mode} provides a major mode with WordStar-like
d0960fb3 2328key bindings.
6bf7aab6
DL
2329@end table
2330
abb9615e 2331@node Hyperlinking
3f724e9a
DL
2332@section Hyperlinking and Navigation Features
2333
88c5c7c8
CY
2334 The following subsections describe convenience features for handling
2335URLs and other types of links occurring in Emacs buffer text.
3f724e9a 2336
b1a92ebf
DL
2337@menu
2338* Browse-URL:: Following URLs.
39791e03 2339* Goto Address mode:: Activating URLs.
b1a92ebf 2340* FFAP:: Finding files etc. at point.
b1a92ebf
DL
2341@end menu
2342
2343@node Browse-URL
2344@subsection Following URLs
3f724e9a 2345@cindex World Wide Web
b1a92ebf 2346@cindex Web
3f724e9a
DL
2347@findex browse-url
2348@findex browse-url-at-point
2349@findex browse-url-at-mouse
3f724e9a
DL
2350@cindex Browse-URL
2351@cindex URLs
b1a92ebf
DL
2352
2353@table @kbd
fc98b4ba 2354@item M-x browse-url @key{RET} @var{url} @key{RET}
b1a92ebf
DL
2355Load a URL into a Web browser.
2356@end table
2357
88c5c7c8
CY
2358 The Browse-URL package allows you to easily follow URLs from within
2359Emacs. Most URLs are followed by invoking a web browser;
2360@samp{mailto:} URLs are followed by invoking the @code{compose-mail}
2361Emacs command to send mail to the specified address (@pxref{Sending
2362Mail}).
df9d7630 2363
88c5c7c8
CY
2364 The command @kbd{M-x browse-url} prompts for a URL, and follows it.
2365If point is located near a plausible URL, that URL is offered as the
2366default. The Browse-URL package also provides other commands which
2367you might like to bind to keys, such as @code{browse-url-at-point} and
2368@code{browse-url-at-mouse}.
3f724e9a 2369
88c5c7c8 2370@vindex browse-url-mailto-function
b1a92ebf 2371@vindex browse-url-browser-function
39cf6a8d 2372 You can customize Browse-URL's behavior via various options in the
88c5c7c8
CY
2373@code{browse-url} Customize group. In particular, the option
2374@code{browse-url-mailto-function} lets you define how to follow
2375@samp{mailto:} URLs, while @code{browse-url-browser-function} lets you
2376define how to follow other types of URLs. For more information, view
2377the package commentary by typing @kbd{C-h P browse-url @key{RET}}.
3f724e9a 2378
39791e03 2379@node Goto Address mode
b1a92ebf 2380@subsection Activating URLs
39791e03 2381@findex goto-address-mode
88c5c7c8 2382@cindex mode, Goto Address
39791e03 2383@cindex Goto Address mode
3f724e9a 2384@cindex URLs, activating
b1a92ebf
DL
2385
2386@table @kbd
39791e03 2387@item M-x goto-address-mode
b1a92ebf
DL
2388Activate URLs and e-mail addresses in the current buffer.
2389@end table
2390
88c5c7c8
CY
2391@kindex C-c RET @r{(Goto Address mode)}
2392@findex goto-address-at-point
2393 You can make Emacs mark out URLs specially in the current buffer, by
2394typing @kbd{M-x goto-address-mode}. When this buffer-local minor mode
2395is enabled, it finds all the URLs in the buffer, highlights them, and
2396turns them into clickable buttons. You can follow the URL by typing
2397@kbd{C-c @key{RET}} (@code{goto-address-at-point}) while point is on
2398its text; or by clicking with @kbd{Mouse-2}, or by clicking
2399@kbd{Mouse-1} quickly (@pxref{Mouse References}). Following a URL is
2400done by calling @code{browse-url} as a subroutine
2401(@pxref{Browse-URL}).
39791e03
CY
2402
2403 It can be useful to add @code{goto-address-mode} to mode hooks and
88c5c7c8
CY
2404hooks for displaying an incoming message
2405(e.g.@: @code{rmail-show-message-hook} for Rmail, and
2406@code{mh-show-mode-hook} for MH-E). This is not needed for Gnus,
2407which has a similar feature of its own.
3f724e9a 2408
b1a92ebf
DL
2409@node FFAP
2410@subsection Finding Files and URLs at Point
3f724e9a
DL
2411@findex find-file-at-point
2412@findex ffap
37ed0ee5 2413@findex dired-at-point
b1a92ebf
DL
2414@findex ffap-next
2415@findex ffap-menu
b1a92ebf
DL
2416@cindex finding file at point
2417
88c5c7c8
CY
2418 The FFAP package replaces certain key bindings for finding files,
2419such as @kbd{C-x C-f}, with commands that provide more sensitive
2420defaults. These commands behave like the ordinary ones when given a
2421prefix argument. Otherwise, they get the default file name or URL
2422from the text around point. If what is found in the buffer has the
2423form of a URL rather than a file name, the commands use
2424@code{browse-url} to view it (@pxref{Browse-URL}).
b1a92ebf 2425
df9d7630 2426 This feature is useful for following references in mail or news
88c5c7c8
CY
2427buffers, @file{README} files, @file{MANIFEST} files, and so on. For
2428more information, view the package commentary by typing @kbd{C-h P
2429ffap @key{RET}}.
b1a92ebf
DL
2430
2431@cindex FFAP minor mode
2432@findex ffap-mode
88c5c7c8
CY
2433 To enable FFAP, type @kbd{M-x ffap-bindings}. This makes the
2434following key bindings, and also installs hooks for additional FFAP
2435functionality in Rmail, Gnus and VM article buffers.
b1a92ebf
DL
2436
2437@table @kbd
df9d7630 2438@item C-x C-f @var{filename} @key{RET}
b1a92ebf 2439@kindex C-x C-f @r{(FFAP)}
df9d7630
RS
2440Find @var{filename}, guessing a default from text around point
2441(@code{find-file-at-point}).
b79529b7
JL
2442@item C-x C-r
2443@kindex C-x C-r @r{(FFAP)}
2444@code{ffap-read-only}, analogous to @code{find-file-read-only}.
2445@item C-x C-v
2446@kindex C-x C-v @r{(FFAP)}
2447@code{ffap-alternate-file}, analogous to @code{find-alternate-file}.
2448@item C-x d @var{directory} @key{RET}
2449@kindex C-x d @r{(FFAP)}
2450Start Dired on @var{directory}, defaulting to the directory name at
37ed0ee5 2451point (@code{dired-at-point}).
b79529b7
JL
2452@item C-x C-d
2453@code{ffap-list-directory}, analogous to @code{list-directory}.
b1a92ebf
DL
2454@item C-x 4 f
2455@kindex C-x 4 f @r{(FFAP)}
df9d7630 2456@code{ffap-other-window}, analogous to @code{find-file-other-window}.
b79529b7
JL
2457@item C-x 4 r
2458@code{ffap-read-only-other-window}, analogous to
2459@code{find-file-read-only-other-window}.
2460@item C-x 4 d
166bc0c8 2461@code{ffap-dired-other-window}, like @code{dired-other-window}.
b1a92ebf
DL
2462@item C-x 5 f
2463@kindex C-x 5 f @r{(FFAP)}
df9d7630 2464@code{ffap-other-frame}, analogous to @code{find-file-other-frame}.
b79529b7
JL
2465@item C-x 5 r
2466@code{ffap-read-only-other-frame}, analogous to
2467@code{find-file-read-only-other-frame}.
2468@item C-x 5 d
2469@code{ffap-dired-other-frame}, analogous to @code{dired-other-frame}.
df9d7630
RS
2470@item M-x ffap-next
2471Search buffer for next file name or URL, then find that file or URL.
df9d7630
RS
2472@item S-Mouse-3
2473@kindex S-Mouse-3 @r{(FFAP)}
b1a92ebf 2474@code{ffap-at-mouse} finds the file guessed from text around the position
df9d7630
RS
2475of a mouse click.
2476@item C-S-Mouse-3
2477@kindex C-S-Mouse-3 @r{(FFAP)}
2478Display a menu of files and URLs mentioned in current buffer, then
2479find the one you select (@code{ffap-menu}).
b1a92ebf
DL
2480@end table
2481
abb9615e 2482@node Amusements
6bf7aab6
DL
2483@section Other Amusements
2484@cindex boredom
6bf7aab6 2485
ecd0b990
CY
2486@findex animate-birthday-present
2487@cindex animate
84f4a531
CY
2488 The @code{animate} package makes text dance (e.g. @kbd{M-x
2489animate-birthday-present}).
50dd7bc6 2490
6bf7aab6
DL
2491@findex blackbox
2492@findex mpuz
3b65ce47 2493@findex 5x5
6bf7aab6 2494@cindex puzzles
ab192107 2495 @kbd{M-x blackbox}, @kbd{M-x mpuz} and @kbd{M-x 5x5} are puzzles.
6bf7aab6
DL
2496@code{blackbox} challenges you to determine the location of objects
2497inside a box by tomography. @code{mpuz} displays a multiplication
2498puzzle with letters standing for digits in a code that you must
2499guess---to guess a value, type a letter and then the digit you think it
3b65ce47 2500stands for. The aim of @code{5x5} is to fill in all the squares.
6bf7aab6 2501
ecd0b990
CY
2502@findex bubbles
2503 @kbd{M-x bubbles} is a game in which the object is to remove as many
2504bubbles as you can in the smallest number of moves.
2505
b1a92ebf
DL
2506@findex decipher
2507@cindex ciphers
2508@cindex cryptanalysis
ecd0b990
CY
2509 @kbd{M-x decipher} helps you to cryptanalyze a buffer which is
2510encrypted in a simple monoalphabetic substitution cipher.
2511
2512@findex dissociated-press
2513 @kbd{M-x dissociated-press} scrambles the text in the current Emacs
2514buffer, word by word or character by character, writing its output to
1c64e6ed 2515a buffer named @file{*Dissociation*}. A positive argument tells it to
ecd0b990
CY
2516operate character by character, and specifies the number of overlap
2517characters. A negative argument tells it to operate word by word, and
2518specifies the number of overlap words. Dissociated Press produces
2519results fairly like those of a Markov chain, but is however, an
2520independent, ignoriginal invention; it techniquitously copies several
2521consecutive characters from the sample text between random jumps,
2522unlike a Markov chain which would jump randomly after each word or
2523character. Keep dissociwords out of your documentation, if you want
2524it to be well userenced and properbose.
b1a92ebf 2525
6bf7aab6 2526@findex dunnet
ecd0b990 2527 @kbd{M-x dunnet} runs an text-based adventure game.
6bf7aab6 2528
ecd0b990
CY
2529@findex gomoku
2530@cindex Go Moku
2531 If you want a little more personal involvement, try @kbd{M-x gomoku},
2532which plays the game Go Moku with you.
2533
2534@cindex tower of Hanoi
2535@findex hanoi
2536 If you are a little bit bored, you can try @kbd{M-x hanoi}. If you are
2537considerably bored, give it a numeric argument. If you are very, very
2538bored, try an argument of 9. Sit back and watch.
3b65ce47
DL
2539
2540@findex life
2541@cindex Life
ecd0b990
CY
2542 @kbd{M-x life} runs Conway's ``Life'' cellular automaton.
2543
88c5c7c8 2544@findex landmark
ecd0b990 2545@cindex landmark game
88c5c7c8
CY
2546 @kbd{M-x landmark} runs a relatively non-participatory game in which
2547a robot attempts to maneuver towards a tree at the center of the
2548window based on unique olfactory cues from each of the four
2549directions.
3b65ce47 2550
b1a92ebf
DL
2551@findex morse-region
2552@findex unmorse-region
88c5c7c8 2553@findex nato-region
b1a92ebf
DL
2554@cindex Morse code
2555@cindex --/---/.-./.../.
88c5c7c8
CY
2556 @kbd{M-x morse-region} converts the text in the region to Morse
2557code; @kbd{M-x unmorse-region} converts it back. @kbd{M-x
2558nato-region} converts the text in the region to NATO phonetic
2559alphabet; @kbd{M-x denato-region} converts it back.
b1a92ebf
DL
2560
2561@findex pong
2562@cindex Pong game
3b65ce47
DL
2563@findex tetris
2564@cindex Tetris
3b65ce47
DL
2565@findex snake
2566@cindex Snake
ecd0b990
CY
2567 @kbd{M-x pong}, @kbd{M-x snake} and @kbd{M-x tetris} are
2568implementations of the well-known Pong, Snake and Tetris games.
3b65ce47 2569
ecd0b990
CY
2570@findex solitaire
2571@cindex solitaire
2572 @kbd{M-x solitaire} plays a game of solitaire in which you jump pegs
2573across other pegs.
6bf7aab6 2574
834d56ed 2575@findex zone
ecd0b990
CY
2576 The command @kbd{M-x zone} plays games with the display when Emacs
2577is idle.
2578
88c5c7c8
CY
2579@findex doctor
2580@cindex Eliza
2581 Finally, if you find yourself frustrated, try describing your
2582problems to the famous psychotherapist Eliza. Just do @kbd{M-x
2583doctor}. End each input by typing @key{RET} twice.
ab5796a9 2584
2e7cfad6
LT
2585@ifnottex
2586@lowersections
2587@end ifnottex