(calcFunc-esimplify, calcFunc-simplify, calcFunc-subst): Use
[bpt/emacs.git] / man / faq.texi
CommitLineData
35f07cbc 1\input texinfo @c -*-texinfo-*- -*- coding: latin-1 -*-
71e68827 2@c %**start of header
35ab2989 3@setfilename ../info/efaq
71e68827
DL
4@settitle GNU Emacs FAQ
5@c %**end of header
6
7@setchapternewpage odd
8
ed5c18e2
EZ
9@c This is used in many places
10@set VER 21.1
11
71e68827
DL
12@c The @ifinfo stuff only appears in the Info version
13@ifinfo
4c2ca4f3 14@dircategory Emacs
0d17cd5c 15@direntry
35ab2989 16* Emacs FAQ: (efaq). Frequently Asked Questions about Emacs.
0d17cd5c
DL
17@end direntry
18
ed5c18e2 19Copyright 1994,1995,1996,1997,1998,1999,2000 Reuven M. Lerner@*
010bb2f0
DL
20Copyright 1992,1993 Steven Byrnes@*
21Copyright 1990,1991,1992 Joseph Brian Wells@*
71e68827
DL
22
23This list of frequently asked questions about GNU Emacs with answers
24("FAQ") may be translated into other languages, transformed into other
25formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information.
26
27The same conditions apply to any derivative of the FAQ as apply to the FAQ
28itself. Every copy of the FAQ must include this notice or an approved
29translation, information on who is currently maintaining the FAQ and how to
30contact them (including their e-mail address), and information on where the
31latest version of the FAQ is archived (including FTP information).
32
33The FAQ may be copied and redistributed under these conditions, except that
34the FAQ may not be embedded in a larger literary work unless that work
35itself allows free copying and redistribution.
0d17cd5c
DL
36
37[This version has been somewhat edited from the last-posted version
38(as of August 1999) for inclusion in the Emacs distribution.]
39
71e68827
DL
40@end ifinfo
41
42@c The @titlepage stuff only appears in the printed version
43@titlepage
44@sp 10
45@center @titlefont{GNU Emacs FAQ}
46
47@c The following two commands start the copyright page.
48@page
49@vskip 0pt plus 1filll
ed5c18e2 50Copyright @copyright{} 1994,1995,1996,1997,1998,1999,2000 Reuven M. Lerner@*
010bb2f0
DL
51Copyright @copyright{} 1992,1993 Steven Byrnes@*
52Copyright @copyright{} 1990,1991,1992 Joseph Brian Wells@*
71e68827
DL
53
54This list of frequently asked questions about GNU Emacs with answers
55("FAQ") may be translated into other languages, transformed into other
56formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information.
57
58The same conditions apply to any derivative of the FAQ as apply to the FAQ
59itself. Every copy of the FAQ must include this notice or an approved
60translation, information on who is currently maintaining the FAQ and how to
61contact them (including their e-mail address), and information on where the
62latest version of the FAQ is archived (including FTP information).
63
64The FAQ may be copied and redistributed under these conditions, except that
65the FAQ may not be embedded in a larger literary work unless that work
66itself allows free copying and redistribution.
0d17cd5c
DL
67
68[This version has been somewhat edited from the last-posted version
69(as of August 1999) for inclusion in the Emacs distribution.]
71e68827
DL
70@end titlepage
71
72@node Top, FAQ notation, (dir), (dir)
73
74This is the GNU Emacs FAQ, last updated on @today{}.
75
ed5c18e2
EZ
76The FAQ is maintained as a Texinfo document, allowing us to create HTML,
77Info, and TeX documents from a single source file, and is slowly but
78surely being improved. Please bear with us as we improve on this
79format. If you have any suggestions or questions, please contact
71e68827
DL
80@email{emacs-faq@@lerner.co.il, the FAQ maintainers}.
81
82@menu
83* FAQ notation::
84* General questions::
85* Getting help::
86* Status of Emacs::
87* Common requests::
88* Bugs and problems::
89* Compiling and installing Emacs::
90* Finding Emacs and related packages::
91* Major packages and programs::
92* Key bindings::
93* Alternate character sets::
94* Mail and news::
95* Concept index::
96@end menu
97
98@c ------------------------------------------------------------
99@node FAQ notation, General questions, Top, Top
100@chapter FAQ notation
101@cindex FAQ notation
102
ed5c18e2 103This chapter describes notation used in the GNU Emacs FAQ, as well as in
71e68827
DL
104the Emacs documentation. Consult this section if this is the first time
105you are reading the FAQ, or if you are confused by notation or terms
106used in the FAQ.
107
108@menu
109* Basic keys::
110* Extended commands::
111* On-line manual::
f8635375 112* File-name conventions::
71e68827
DL
113* Common acronyms::
114@end menu
115
116@node Basic keys, Extended commands, FAQ notation, FAQ notation
718fb8a1 117@section What do these mean: @kbd{C-h}, @kbd{C-M-a}, @key{RET}, @kbd{@key{ESC} a}, etc.?
71e68827
DL
118@cindex Basic keys
119@cindex Control key, notation for
120@cindex @key{Meta} key, notation for
ed5c18e2 121@cindex Control-Meta characters, notation for
71e68827 122@cindex @kbd{C-h}, definition of
718fb8a1 123@cindex @kbd{C-M-h}, definition of
71e68827
DL
124@cindex @key{DEL}, definition of
125@cindex @key{ESC}, definition of
126@cindex @key{LFD}, definition of
127@cindex @key{RET}, definition of
128@cindex @key{SPC}, definition of
129@cindex @key{TAB}, definition of
ed5c18e2 130@cindex Notation for keys
71e68827
DL
131
132@itemize @bullet
133
134@item
135@kbd{C-x}: press the @key{x} key while holding down the @key{Control} key
136
137@item
138@kbd{M-x}: press the @key{x} key while holding down the @key{Meta} key
ed5c18e2 139(if your computer doesn't have a @key{Meta} key, @pxref{No Meta key})
71e68827
DL
140
141@item
142@kbd{M-C-x}: press the @key{x} key while holding down both @key{Control}
143and @key{Meta}
144
145@item
146@kbd{C-M-x}: a synonym for the above
147
148@item
149@key{LFD}: Linefeed or Newline; same as @kbd{C-j}
150
151@item
152@key{RET}: @key{Return}, sometimes marked @key{Enter}; same as @kbd{C-m}
153
154@item
ed5c18e2
EZ
155@key{DEL}: @key{Delete}, usually @strong{not} the same as
156@key{Backspace}; same as @kbd{C-?} (see @ref{Backspace invokes help}, if
157deleting invokes Emacs help)
71e68827
DL
158
159@item
160@key{ESC}: Escape; same as @kbd{C-[}
161
162@item
163@key{TAB}: Tab; same as @kbd{C-i}
164
165@item
166@key{SPC}: Space bar
167
168@end itemize
169
170Key sequences longer than one key (and some single-key sequences) are
ed5c18e2
EZ
171written inside quotes or on lines by themselves, like this:
172
173@display
174 @kbd{M-x frobnicate-while-foo RET}
175@end display
176
177@noindent
178Any real spaces in such a key sequence should be ignored; only @key{SPC}
179really means press the space key.
71e68827
DL
180
181The ASCII code sent by @kbd{C-x} (except for @kbd{C-?}) is the value
182that would be sent by pressing just @key{x} minus 96 (or 64 for
f8635375 183upper-case @key{X}) and will be from 0 to 31. On Unix and GNU/Linux
ed5c18e2
EZ
184terminals, the ASCII code sent by @kbd{M-x} is the sum of 128 and the
185ASCII code that would be sent by pressing just @key{x}. Essentially,
186@key{Control} turns off bits 5 and 6 and @key{Meta} turns on bit
1877@footnote{
188DOS and Windows terminals don't set bit 7 when the @key{Meta} key is
189pressed.}.
71e68827
DL
190
191@kbd{C-?} (aka @key{DEL}) is ASCII code 127. It is a misnomer to call
ed5c18e2 192@kbd{C-?} a ``control'' key, since 127 has both bits 5 and 6 turned ON.
71e68827
DL
193Also, on very few keyboards does @kbd{C-?} generate ASCII code 127.
194
ed438271
EZ
195@inforef{Text Characters, Text Characters, emacs}, and @inforef{Keys,
196Keys, emacs}, for more information. (@xref{On-line manual}, for more
197information about Info.)
71e68827
DL
198
199@node Extended commands, On-line manual, Basic keys, FAQ notation
200@section What does @file{M-x @var{command}} mean?
201@cindex Extended commands
202@cindex Commands, extended
203@cindex M-x, meaning of
204
205@kbd{M-x @var{command}} means type @kbd{M-x}, then type the name of the
ed5c18e2 206command, then type @key{RET}. (@xref{Basic keys}, if you're not sure
71e68827
DL
207what @kbd{M-x} and @key{RET} mean.)
208
209@kbd{M-x} (by default) invokes the command
210@code{execute-extended-command}. This command allows you to run any
211Emacs command if you can remember the command's name. If you can't
212remember the command's name, you can type @key{TAB} and @key{SPC} for
213completion, @key{?} for a list of possibilities, and @kbd{M-p} and
ed5c18e2
EZ
214@kbd{M-n} (or up-arrow and down-arrow on terminals that have these
215editing keys) to see previous commands entered. An Emacs @dfn{command}
216is an @dfn{interactive} Emacs function.
71e68827 217
ed5c18e2 218@cindex @key{Do} key
71e68827
DL
219Your system administrator may have bound other key sequences to invoke
220@code{execute-extended-command}. A function key labeled @kbd{Do} is a
ed5c18e2 221good candidate for this, on keyboards that have such a key.
71e68827 222
ed5c18e2
EZ
223If you need to run non-interactive Emacs functions, see @ref{Evaluating
224Emacs Lisp code}.
71e68827 225
f8635375 226@node On-line manual, File-name conventions, Extended commands, FAQ notation
71e68827
DL
227@section How do I read topic XXX in the on-line manual?
228@cindex On-line manual, reading topics in
229@cindex Reading topics in the on-line manual
230@cindex Finding topics in the on-line manual
231@cindex Info, finding topics in
232
ed5c18e2
EZ
233When we refer you to some @var{topic} in the on-line manual, you can
234read this manual node inside Emacs (assuming nothing is broken) by
235typing @kbd{C-h i m emacs @key{RET} m @var{topic} @key{RET}}.
71e68827
DL
236
237This invokes Info, the GNU hypertext documentation browser. If you don't
238already know how to use Info, type @key{?} from within Info.
239
ed5c18e2
EZ
240If we refer to @var{topic}:@var{subtopic}, type @kbd{C-h i m emacs
241@key{RET} m @var{topic} @key{RET} m @var{subtopic} @key{RET}}.
71e68827 242
ed5c18e2
EZ
243If these commands don't work as expected, your system administrator may
244not have installed the Info files, or may have installed them
245improperly. In this case you should complain.
71e68827 246
0d17cd5c 247@xref{Getting a printed manual}, if you would like a paper copy of the
71e68827
DL
248Emacs manual.
249
f8635375 250@node File-name conventions, Common acronyms, On-line manual, FAQ notation
71e68827 251@section What are @file{etc/SERVICE}, @file{src/config.h}, and @file{lisp/default.el}?
f8635375
EZ
252@cindex File-name conventions
253@cindex Conventions for file names
71e68827
DL
254@cindex Directories and files that come with Emacs
255
256These are files that come with Emacs. The Emacs distribution is divided
257into subdirectories; the important ones are @file{etc}, @file{lisp}, and
258@file{src}.
259
260If you use Emacs, but don't know where it is kept on your system, start
261Emacs, then type @kbd{C-h v data-directory @key{RET}}. The directory
262name displayed by this will be the full pathname of the installed
ed5c18e2
EZ
263@file{etc} directory. (This full path is recorded in the Emacs variable
264@code{data-directory}, and @kbd{C-h v} displays the value and the
265documentation of a variable.)
71e68827
DL
266
267The location of your Info directory (i.e., where on-line documentation
268is stored) is kept in the variable @code{Info-default-directory-list}. Use
ed5c18e2 269@kbd{C-h v Info-default-directory-list @key{RET}} to see the value of
71e68827
DL
270this variable, which will be a list of directory names. The last
271directory in that list is probably where most Info files are stored. By
272default, Info documentation is placed in @file{/usr/local/info}.
273
ed5c18e2
EZ
274Some of these files are available individually via FTP or e-mail; see
275@ref{Informational files for Emacs}. They all are available in the
276source distribution. Many of the files in the @file{etc} directory are
ed438271 277also available via the Emacs @samp{Help} menu, or by typing @kbd{C-h ?}
ed5c18e2 278(@kbd{M-x help-for-help}).
71e68827
DL
279
280Your system administrator may have removed the @file{src} directory and
281many files from the @file{etc} directory.
282
f8635375 283@node Common acronyms, , File-name conventions, FAQ notation
71e68827
DL
284@section What are FSF, LPF, OSF, GNU, RMS, FTP, and GPL?
285@cindex FSF, definition of
286@cindex LPF, definition of
287@cindex OSF, definition of
288@cindex GNU, definition of
289@cindex RMS, definition of
290@cindex Stallman, Richard, acronym for
291@cindex Richard Stallman, acronym for
292@cindex FTP, definition of
293@cindex GPL, definition of
294@cindex Acronyms, definitions for
295@cindex Common acronyms, definitions for
296
297@table @asis
298
299@item FSF
300Free Software Foundation
301
302@item LPF
303League for Programming Freedom
304
305@item OSF
306Open Software Foundation
307
308@item GNU
309GNU's Not Unix
310
311@item RMS
312Richard Matthew Stallman
313
314@item FTP
315File Transfer Protocol
316
317@item GPL
318GNU General Public License
319
320@end table
321
322Avoid confusing the FSF, the LPF, and the OSF. The LPF opposes
323look-and-feel copyrights and software patents. The FSF aims to make
324high quality free software available for everyone. The OSF is a
325consortium of computer vendors which develops commercial software for
326Unix systems.
327
ed5c18e2
EZ
328The word ``free'' in the title of the Free Software Foundation refers to
329``freedom,'' not ``zero dollars.'' Anyone can charge any price for
71e68827
DL
330GPL-covered software that they want to. However, in practice, the
331freedom enforced by the GPL leads to low prices, because you can always
ed5c18e2 332get the software for less money from someone else, since everyone has
71e68827
DL
333the right to resell or give away GPL-covered software.
334
335@c ------------------------------------------------------------
336@node General questions, Getting help, FAQ notation, Top
337@chapter General questions
338@cindex General questions
339
ed5c18e2 340This chapter contains general questions having to do with Emacs, the
71e68827
DL
341Free Software Foundation, and related organizations.
342
343@menu
344* The LPF::
345* Real meaning of copyleft::
346* Guidelines for newsgroup postings::
347* Newsgroup archives::
348* Reporting bugs::
349* Unsubscribing from Emacs lists::
350* Contacting the FSF::
351@end menu
352
353@node The LPF, Real meaning of copyleft, General questions, General questions
354@section What is the LPF?
355@cindex LPF, description of
356@cindex League for Programming Freedom
357@cindex Software patents, opposition to
358@cindex Patents for software, opposition to
359
360The LPF opposes the expanding danger of software patents and
361look-and-feel copyrights. To get more information, feel free to contact
362the LPF via e-mail or otherwise. You may also contact
ed5c18e2 363@email{jbw@@cs.bu.edu, Joe Wells}; he will be happy to talk to you
71e68827
DL
364about the LPF.
365
366You can find more information about the LPF in the file @file{etc/LPF}.
367More papers describing the LPF's views are available on the Internet and
ed5c18e2 368also from @uref{http://lpf.ai.mit.edu/, the LPF home page}.
71e68827
DL
369
370@node Real meaning of copyleft, Guidelines for newsgroup postings, The LPF, General questions
371@section What is the real legal meaning of the GNU copyleft?
372@cindex Copyleft, real meaning of
373@cindex GPL, real meaning of
374@cindex General Public License, real meaning of
375@cindex Discussion of the GPL
376
377The real legal meaning of the GNU General Public License (copyleft) will
378only be known if and when a judge rules on its validity and scope.
379There has never been a copyright infringement case involving the GPL to
380set any precedents. Please take any discussion regarding this issue to
381the newsgroup @uref{news:gnu.misc.discuss}, which was created to hold the
382extensive flame wars on the subject.
383
384RMS writes:
385
386@quotation
387The legal meaning of the GNU copyleft is less important than the spirit,
388which is that Emacs is a free software project and that work pertaining
ed5c18e2
EZ
389to Emacs should also be free software. ``Free'' means that all users
390have the freedom to study, share, change and improve Emacs. To make
391sure everyone has this freedom, pass along source code when you
392distribute any version of Emacs or a related program, and give the
393recipients the same freedom that you enjoyed.
71e68827
DL
394@end quotation
395
396@node Guidelines for newsgroup postings, Newsgroup archives, Real meaning of copyleft, General questions
397@section What are appropriate messages for @uref{news:gnu.emacs.help}, @uref{news:gnu.emacs.bug}, @uref{news:comp.emacs}, etc.?
398@cindex Newsgroups, appropriate messages for
399@cindex GNU newsgroups, appropriate messages for
400@cindex Usenet groups, appropriate messages for
401@cindex Mailing lists, appropriate messages for
ed5c18e2 402@cindex Posting messages to newsgroups
71e68827 403
ed5c18e2
EZ
404@cindex GNU mailing lists
405The file @file{etc/MAILINGLISTS} describes the purpose of each GNU
406mailing list. (@xref{Informational files for Emacs}, if you want a copy
71e68827
DL
407of the file.) For those lists which are gatewayed with newsgroups, it
408lists both the newsgroup name and the mailing list address.
409
ed5c18e2
EZ
410The newsgroup @uref{news:comp.emacs} is for discussion of Emacs programs
411in general. This includes Emacs along with various other
412implementations, such as XEmacs, JOVE, MicroEmacs, Freemacs, MG,
413Unipress, CCA, and Epsilon.
71e68827
DL
414
415Many people post Emacs questions to @uref{news:comp.emacs} because they
ed5c18e2
EZ
416don't receive any of the @code{gnu.*} newsgroups. Arguments have been
417made both for and against posting GNU-Emacs-specific material to
71e68827
DL
418@uref{news:comp.emacs}. You have to decide for yourself.
419
ed5c18e2
EZ
420Messages advocating ``non-free'' software are considered unacceptable on
421any of the @code{gnu.*} newsgroups except for @uref{news:gnu.misc.discuss},
71e68827 422which was created to hold the extensive flame-wars on the subject.
ed5c18e2 423``Non-free'' software includes any software for which the end user can't
71e68827 424freely modify the source code and exchange enhancements. Be careful to
ed5c18e2
EZ
425remove the @code{gnu.*} groups from the @samp{Newsgroups:} line when
426posting a followup that recommends such software.
71e68827
DL
427
428@uref{news:gnu.emacs.bug} is a place where bug reports appear, but avoid
ed5c18e2 429posting bug reports to this newsgroup directly (@pxref{Reporting bugs}).
71e68827
DL
430
431@node Newsgroup archives, Reporting bugs, Guidelines for newsgroup postings, General questions
432@section Where can I get old postings to @uref{news:gnu.emacs.help} and other GNU groups?
433@cindex Archived postings from @uref{news:gnu.emacs.help}
434@cindex Usenet archives for GNU groups
435@cindex Old Usenet postings for GNU groups
436
437The FSF has maintained archives of all of the GNU mailing lists for many
438years, although there may be some unintentional gaps in coverage. The
439archive is not particularly well organized or easy to retrieve
440individual postings from, but pretty much everything is there.
441
442The archive is at @uref{ftp://ftp-mailing-list-archives.gnu.org}.
443
444As of this writing, the archives are not yet working.
445
446Web-based Usenet search services, such as
447@uref{http://www.dejanews.com, DejaNews}, also archive the
ed5c18e2 448@code{gnu.*} groups.
71e68827
DL
449
450@node Reporting bugs, Unsubscribing from Emacs lists, Newsgroup archives, General questions
451@section Where should I report bugs and other problems with Emacs?
452@cindex Bug reporting
453@cindex Good bug reports
454@cindex How to submit a bug report
455@cindex Reporting bugs
456
457The correct way to report Emacs bugs is by e-mail to
458@email{bug-gnu-emacs@@gnu.org}. Anything sent here also appears in the
459newsgroup @uref{news:gnu.emacs.bug}, but please use e-mail instead of
460news to submit the bug report. This ensures a reliable return address
461so you can be contacted for further details.
462
ed5c18e2 463Be sure to read the ``Bugs'' section of the Emacs manual before reporting
71e68827 464a bug to bug-gnu-emacs! The manual describes in detail how to submit a
ed5c18e2 465useful bug report. (@xref{On-line manual}, if you don't know how to read the
71e68827
DL
466manual.)
467
468RMS says:
469
470@quotation
471Sending bug reports to @email{help-gnu-emacs@@gnu.org} (which has the
472effect of posting on @uref{news:gnu.emacs.help}) is undesirable because
473it takes the time of an unnecessarily large group of people, most of
474whom are just users and have no idea how to fix these problem.
475@email{bug-gnu-emacs@@gnu.org} reaches a much smaller group of people
476who are more likely to know what to do and have expressed a wish to
477receive more messages about Emacs than the others.
478@end quotation
479
480RMS says it is sometimes fine to post to @uref{news:gnu.emacs.help}:
481
482@quotation
483If you have reported a bug and you don't hear about a possible fix,
484then after a suitable delay (such as a week) it is okay to post on
ed5c18e2 485@code{gnu.emacs.help} asking if anyone can help you.
71e68827
DL
486@end quotation
487
488If you are unsure whether you have found a bug, consider the following
489non-exhaustive list, courtesy of RMS:
490
491@quotation
492If Emacs crashes, that is a bug. If Emacs gets compilation errors
493while building, that is a bug. If Emacs crashes while building, that
494is a bug. If Lisp code does not do what the documentation says it
495does, that is a bug.
496@end quotation
497
498@node Unsubscribing from Emacs lists, Contacting the FSF, Reporting bugs, General questions
499@section How do I unsubscribe from this mailing list?
500@cindex Unsubscribing from GNU mailing lists
501@cindex Removing yourself from GNU mailing lists
502
ed5c18e2
EZ
503If you are receiving a GNU mailing list named @var{list}, you might be
504able to unsubscribe from it by sending a request to the address
505@email{@var{list}-request@@gnu.org}. However, this will not work if you are
71e68827
DL
506not listed on the main mailing list, but instead receive the mail from a
507distribution point. In that case, you will have to track down at which
508distribution point you are listed. Inspecting the @samp{Received} headers
ed5c18e2
EZ
509on the mail messages may help, along with liberal use of the @samp{EXPN} or
510@samp{VRFY} sendmail commands through @samp{telnet @var{site-address}
511smtp}. Ask your postmaster for help, if you cannot figure out these
512details.
71e68827
DL
513
514@node Contacting the FSF, , Unsubscribing from Emacs lists, General questions
515@section What is the current address of the FSF?
516@cindex Snail mail address of the FSF
517@cindex Postal address of the FSF
518@cindex Contracting the FSF
519@cindex Free Software Foundation, contacting
520
521@table @asis
522
523@item E-mail
524gnu@@gnu.org
525
526@item Telephone
527+1-617-542-5942
528
529@item Fax
530+1-617-542-2652
531
532@item World Wide Web
533@uref{http://www.gnu.org/}
534
535@item Postal address
536Free Software Foundation@*
53759 Temple Place - Suite 330@*
538Boston, MA 02111-1307@*
539USA@*
540
541@end table
542
ed5c18e2
EZ
543@cindex Ordering GNU software
544For details on how to order items directly from the FSF, see the
545@uref{http://www.gnu.org/order/order.html, GNU Web site}, and also the
546files @file{etc/ORDERS}, @file{ORDERS.EUROPE}, and @file{ORDERS.JAPAN}.
71e68827
DL
547
548@c ------------------------------------------------------------
549@node Getting help, Status of Emacs, General questions, Top
550@chapter Getting help
551@cindex Getting help
552
ed5c18e2 553This chapter tells you how to get help with Emacs
71e68827
DL
554
555@menu
556* Basic editing::
557* Learning how to do something::
558* Getting a printed manual::
559* Emacs Lisp documentation::
560* Installing Texinfo documentation::
561* Printing a Texinfo file::
562* Viewing Info files outside of Emacs::
563* Informational files for Emacs::
564* Help installing Emacs::
565* Obtaining the FAQ::
566@end menu
567
568@node Basic editing, Learning how to do something, Getting help, Getting help
569@section I'm just starting Emacs; how do I do basic editing?
570@cindex Basic editing with Emacs
571@cindex Beginning editing
572@cindex Tutorial, invoking the
573@cindex Self-paced tutorial, invoking the
574@cindex Help system, entering the
575
576Type @kbd{C-h t} to invoke the self-paced tutorial. Just typing @kbd{C-h}
577enters the help system.
578
579Your system administrator may have changed @kbd{C-h} to act like
580@key{DEL} to deal with local keyboards. You can use @kbd{M-x
581help-for-help} instead to invoke help. To discover what key (if any)
582invokes help on your system, type @kbd{M-x where-is @key{RET}
583help-for-help @key{RET}}. This will print a comma-separated list of key
584sequences in the echo area. Ignore the last character in each key
585sequence listed. Each of the resulting key sequences invokes help.
586
587Emacs help works best if it is invoked by a single key whose value
588should be stored in the variable @code{help-char}.
589
590There is also a WWW-based tutorial for Emacs 18, much of which is also
ed5c18e2 591relevant for later versions of Emacs, available at
71e68827
DL
592
593@uref{http://kufacts.cc.ukans.edu/cwis/writeups/misc/emacsguide.html}
594
595@node Learning how to do something, Getting a printed manual, Basic editing, Getting help
596@section How do I find out how to do something in Emacs?
597@cindex Help for Emacs
598@cindex Learning to do something in Emacs
599@cindex Reference card for Emacs
600@cindex Overview of help systems
601
602There are several methods for finding out how to do things in Emacs.
603
604@itemize @bullet
605
ed5c18e2 606@cindex Reading the Emacs manual
71e68827
DL
607@item
608The complete text of the Emacs manual is available on-line via the Info
609hypertext reader. Type @kbd{C-h i} to invoke Info. Typing @key{h}
610immediately after entering Info will provide a short tutorial on how to
611use it.
612
ed5c18e2
EZ
613@cindex Lookup a subject in a manual
614@cindex Index search in a manual
71e68827 615@item
ed5c18e2
EZ
616To quickly locate the section of the manual which discusses a certain
617issue, or describes a command or a variable, type @kbd{C-h i m emacs
618@key{RET} i @var{topic} @key{RET}}, where @var{topic} is the name of the
619topic, the command, or the variable which you are looking for. If this
620does not land you on the right place in the manual, press @kbd{,}
621(comma) repeatedly until you find what you need. (The @kbd{i} and
622@kbd{,} keys invoke the index-searching functions, which look for the
623@var{topic} you type in all the indices of the Emacs manual.)
624
625@cindex Apropos
71e68827
DL
626@item
627You can list all of the commands whose names contain a certain word
628(actually which match a regular expression) using @kbd{C-h a} (@kbd{M-x
629command-apropos}).
630
ed5c18e2
EZ
631@cindex Command description in the manual
632@item
633The command @kbd{C-h C-f} (@code{Info-goto-emacs-command-node}) prompts
634for the name of a command, and then attempts to find the section in the
635Emacs manual where that command is described.
636
637@cindex Finding commands and variables
71e68827
DL
638@item
639You can list all of the functions and variables whose names contain a
640certain word using @kbd{M-x apropos}.
641
ed5c18e2
EZ
642@item
643You can list all of the functions and variables whose documentation
644matches a regular expression or a string, using @kbd{M-x
645apropos-documentation}.
646
647@item
648You can order a hardcopy of the manual from the FSF. @xref{Getting a
649printed manual}.
650
651@cindex Reference cards, in other languages
652@item
653You can get a printed reference card listing commands and keys to
654invoke them. You can order one from the FSF for $1 (or 10 for $5),
655or you can print your own from the @file{etc/refcard.tex} or
656@file{etc/refcard.ps} files in the Emacs distribution. Beginning with
657version 21.1, the Emacs distribution comes with translations of the
658reference card into several languages; look for files named
659@file{etc/@var{lang}-refcard.*}, where @var{lang} is a two-letter code
660of the language. For example, the German version of the reference card
661is in the files @file{etc/de-refcard.tex} and @file{etc/de-refcard.ps}.
662
71e68827
DL
663@item
664There are many other commands in Emacs for getting help and
665information. To get a list of these commands, type @samp{?} after
666@kbd{C-h}.
667
668@end itemize
669
670@node Getting a printed manual, Emacs Lisp documentation, Learning how to do something, Getting help
671@section How do I get a printed copy of the Emacs manual?
672@cindex Printed Emacs manual, obtaining
617cb2b9
EZ
673@cindex Manual, obtaining a printed or HTML copy of
674@cindex Emacs manual, obtaining a printed or HTML copy of
71e68827
DL
675
676You can order a printed copy of the Emacs manual from the FSF. For
ed5c18e2
EZ
677details see the @uref{http://www.gnu.org/order/order.html, GNU Web site}
678and the file @file{etc/ORDERS}.
71e68827 679
ed5c18e2
EZ
680@c The number 620 below is version-dependent!
681The full Texinfo source for the manual also comes in the @file{man}
71e68827 682directory of the Emacs distribution, if you're daring enough to try to
ed5c18e2 683print out this 620-page manual yourself (@pxref{Printing a Texinfo
71e68827
DL
684file}).
685
686If you absolutely have to print your own copy, and you don't have @TeX{},
687you can get a PostScript version from
688
0d17cd5c 689@uref{http://www.gnu.org/manual/emacs/ps/emacs.ps.gz}
71e68827 690
617cb2b9 691@cindex HTML version of Emacs manual, obtaining
ed5c18e2 692An HTML version of the manual is at
71e68827 693
0d17cd5c 694@uref{www.gnu.org/manual/emacs/index.html}
71e68827 695
0d17cd5c 696@xref{Learning how to do something}, for how to view the manual on-line.
71e68827
DL
697
698@node Emacs Lisp documentation, Installing Texinfo documentation, Getting a printed manual, Getting help
699@section Where can I get documentation on Emacs Lisp?
700@cindex Documentation on Emacs Lisp
701@cindex Function documentation
702@cindex Variable documentation
703@cindex Emacs Lisp Reference Manual
704@cindex Reference manual for Emacs Lisp
705
706Within Emacs, you can type @kbd{C-h f} to get the documentation for a
707function, @kbd{C-h v} for a variable.
708
ed5c18e2
EZ
709For more information, obtain the Emacs Lisp Reference Manual. Details
710on ordering it from FSF are on the
711@uref{http://www.gnu.org/order/order.html, GNU Web site} and in the file
712@file{etc/ORDERS}.
71e68827
DL
713
714The Emacs Lisp Reference Manual is also available on-line, in Info
715format. Texinfo source for the manual (along with pregenerated Info
716files) is available at
717
ed5c18e2 718@uref{ftp://ftp.gnu.org/pub/gnu/emacs/elisp-manual-21-2.6.tar.gz}
71e68827 719
ed5c18e2
EZ
720and all mirrors of @samp{ftp.gnu.org} (for a list, @pxref{Current GNU
721distributions}). @xref{Installing Texinfo documentation}, if you want
722to install the Info files, or @ref{Printing a Texinfo file}, if you want
723to use the Texinfo source to print the manual yourself.
71e68827 724
ed5c18e2 725An HTML version of the Emacs Lisp Reference Manual is available at
71e68827 726
ed5c18e2 727@uref{http://www.gnu.org/manual/elisp-manual-21-2.6/elisp.html}
71e68827
DL
728
729@node Installing Texinfo documentation, Printing a Texinfo file, Emacs Lisp documentation, Getting help
730@section How do I install a piece of Texinfo documentation?
731@cindex Texinfo documentation, installing
732@cindex Installing Texinfo documentation
733@cindex New Texinfo files, installing
734@cindex Documentation, installing new Texinfo files
ed5c18e2 735@cindex Info files, how to install
71e68827
DL
736
737First, you must turn the Texinfo files into Info files. You may do this
738using the stand-alone @file{makeinfo} program, available as part of the latest
739Texinfo package at
740
ed5c18e2 741@uref{ftp://ftp.gnu.org/pub/gnu/texinfo/texinfo-4.0.tar.gz}
71e68827 742
ed5c18e2
EZ
743and all mirrors of @samp{ftp.gnu.org} (for a list, @pxref{Current GNU
744distributions}).
71e68827
DL
745
746For information about the Texinfo format, read the Texinfo manual which
ed5c18e2
EZ
747comes with the Texinfo package. This manual also comes installed in
748Info format, so you can read it on-line; type @kbd{C-h i m texinfo
749@key{RET}}.
750
751Alternatively, you could use the Emacs command @kbd{M-x
752texinfo-format-buffer}, after visiting the Texinfo source file of the
753manual you want to convert.
71e68827
DL
754
755Neither @code{texinfo-format-buffer} nor @file{makeinfo} installs the
ed5c18e2
EZ
756resulting Info files in Emacs's Info tree. To install Info files,
757perform these steps:
71e68827
DL
758
759@enumerate
ed5c18e2
EZ
760@item
761Move the files to the @file{info} directory in the installed Emacs
f8635375 762distribution. @xref{File-name conventions}, if you don't know where that
ed5c18e2 763is.
71e68827 764
ed5c18e2
EZ
765@item
766Run the @code{install-info} command, which is part of the Texinfo
767distribution, to update the main Info directory menu, like this:
768
769@example
770 install-info --info-dir=@var{dir-path} @var{dir-path}/@var{file}
771@end example
71e68827 772
ed5c18e2
EZ
773@noindent
774where @var{dir-path} is the full path to the directory where you copied
775the produced Info file(s), and @var{file} is the name of the Info file
776you produced and want to install.
777
778If you don't have the @code{install-info} command installed, you can
779edit the file @file{info/dir} in the installed Emacs distribution, and
780add a line for the top level node in the Info package that you are
781installing. Follow the examples already in this file. The format is:
71e68827
DL
782
783@example
784* Topic: (relative-pathname). Short description of topic.
785@end example
786
787@end enumerate
788
789If you want to install Info files and you don't have the necessary
790privileges, you have several options:
791
792@itemize @bullet
71e68827
DL
793@item
794Info files don't actually need to be installed before being used. You
795can feed a file name to the @code{Info-goto-node} command (invoked by
796pressing @key{g} in Info mode) by typing the name of the file in
ed5c18e2
EZ
797parentheses. This goes to the node named ``Top'' in that file. For
798example, to view a Info file named @file{@var{info-file}} in your home
799directory, you can type this:
71e68827 800
ed438271
EZ
801@example
802@kbd{C-h i g (~/@var{info-file}) @key{RET}}
803@end example
71e68827
DL
804
805@item
ed5c18e2 806You can create your own Info directory. You can tell Emacs where that
71e68827
DL
807Info directory is by adding its pathname to the value of the variable
808@code{Info-default-directory-list}. For example, to use a private Info
ed5c18e2 809directory which is a subdirectory of your home directory named @file{Info},
71e68827
DL
810you could put this in your @file{.emacs} file:
811
812@lisp
813(setq Info-default-directory-list
814 (cons "~/Info" Info-default-directory-list))
815@end lisp
816
817You will need a top-level Info file named @file{dir} in this directory
ed5c18e2 818which has everything the system @file{dir} file has in it, except it should
71e68827
DL
819list only entries for Info files in that directory. You might not need
820it if all files in this directory were referenced by other @file{dir}
821files. The node lists from all @file{dir} files in
822@code{Info-default-directory-list} are merged by the Info system.
823
824@end itemize
825
826@node Printing a Texinfo file, Viewing Info files outside of Emacs, Installing Texinfo documentation, Getting help
827@section How do I print a Texinfo file?
828@cindex Printing a Texinfo file
829@cindex Texinfo file, printing
ed5c18e2 830@cindex Printing documentation
71e68827
DL
831
832You can't get nicely printed output from Info files; you must still have
833the original Texinfo source file for the manual you want to print.
834
835Assuming you have @TeX{} installed on your system, follow these steps:
836
837@enumerate
838
ed5c18e2
EZ
839@item
840Make sure the first line of the Texinfo file looks like this:
71e68827
DL
841
842@example
843\input texinfo
844@end example
845
ed5c18e2
EZ
846You may need to change @samp{texinfo} to the full pathname of the
847@file{texinfo.tex} file, which comes with Emacs as
848@file{man/texinfo.tex} (or copy or link it into the current directory).
71e68827 849
ed5c18e2
EZ
850@item
851Type @kbd{texi2dvi @var{texinfo-source}}, where @var{texinfo-source} is
852the name of the Texinfo source file for which you want to produce a
853printed copy.
71e68827 854
ed5c18e2
EZ
855The @samp{texi2dvi} script is part of the GNU Texinfo distribution
856(@pxref{Installing Texinfo documentation}).
71e68827 857
ed5c18e2
EZ
858@item
859Print the DVI file @file{@var{texinfo-source}.dvi} in the normal way for
860printing DVI files at your site. For example, if you have a PostScript
861printer, run the @code{dvips} program to print the DVI file on that
862printer.
71e68827
DL
863
864@end enumerate
865
866To get more general instructions, retrieve the latest Texinfo package
0d17cd5c 867(@pxref{Installing Texinfo documentation}).
71e68827
DL
868
869@node Viewing Info files outside of Emacs, Informational files for Emacs, Printing a Texinfo file, Getting help
870@section Can I view Info files without using Emacs?
871@cindex Viewing Info files
872@cindex Info file viewers
873@cindex Alternative Info file viewers
874
875Yes. Here are some alternative programs:
876
877@itemize @bullet
878
ed5c18e2
EZ
879@item
880@code{info}, a stand-alone version of the Info program, comes as part of
881the Texinfo package. @xref{Installing Texinfo documentation}, for
882details.
71e68827 883
ed5c18e2
EZ
884@item
885Xinfo, a stand-alone version of the Info program that runs under X
886Window system. You can get it at
71e68827 887@uref{ftp://ftp.gnu.org/pub/gnu/xinfo/xinfo-1.01.01.tar.gz} and all
ed5c18e2
EZ
888mirrors of @samp{ftp.gnu.org} (see @ref{Current GNU distributions}, for a
889list of mirrors).
71e68827 890
ed5c18e2
EZ
891@item
892Tkinfo, an Info viewer that runs under X Window system and uses Tcl/Tk.
893You can get Tkinfo at
894@uref{http://math-www.uni-paderborn.de/~axel/tkinfo/}.
71e68827
DL
895
896@end itemize
897
898@node Informational files for Emacs, Help installing Emacs, Viewing Info files outside of Emacs, Getting help
899@section What informational files are available for Emacs?
900@cindex Informational files included with Emacs
901@cindex Files included with Emacs
902@cindex @file{COPYING}, description of file
903@cindex @file{DISTRIB}, description of file
71e68827
DL
904@cindex @file{FTP}, description of file
905@cindex @file{GNU}, description of file
906@cindex @file{INTERVIEW}, description of file
907@cindex @file{LPF}, description of file
908@cindex @file{MACHINES}, description of file
909@cindex @file{MAILINGLISTS}, description of file
910@cindex @file{NEWS}, description of file
911@cindex @file{SERVICE}, description of file
912@cindex @file{SUN-SUPPORT}, description of file
913
914This isn't a frequently asked question, but it should be! A variety of
915informational files about Emacs and relevant aspects of the GNU project
916are available for you to read.
917
918The following files are available in the @file{etc} directory of the
f8635375 919Emacs distribution (see @ref{File-name conventions}, if you're not sure
ed5c18e2 920where that is).
71e68827
DL
921
922@table @file
923
924@item COPYING
925Emacs General Public License
926
927@item DISTRIB
928Emacs Availability Information, including the popular "Free Software
929Foundation Order Form"
930
71e68827
DL
931@item FTP
932How to get GNU Software by Internet FTP or by UUCP
933
934@item GNU
935The GNU Manifesto
936
937@item INTERVIEW
938Richard Stallman discusses his public-domain UNIX-compatible software
939system with BYTE editors
940
941@item LPF
942Why you should join the League for Programming Freedom
943
944@item MACHINES
945Status of Emacs on Various Machines and Systems
946
947@item MAILINGLISTS
948GNU Project Electronic Mailing Lists
949
950@item NEWS
ed5c18e2 951Emacs news, a history of recent user-visible changes
71e68827
DL
952
953@item SERVICE
954GNU Service Directory
955
956@item SUN-SUPPORT
957including "Using Emacstool with GNU Emacs"
958
959@end table
960
961Latest versions of the above files also available at
962
963@uref{ftp://ftp.gnu.org/pub/gnu/GNUinfo/}
964
ed5c18e2
EZ
965More GNU information, including back issues of the @cite{GNU's
966Bulletin}, are at
71e68827
DL
967
968@uref{http://www.gnu.org/bulletins/bulletins.html} and
969
970@uref{http://www.cs.pdx.edu/~trent/gnu/gnu.html}
971
972@node Help installing Emacs, Obtaining the FAQ, Informational files for Emacs, Getting help
973@section Where can I get help in installing Emacs?
974@cindex Installation help
975@cindex Help installing Emacs
976
ed5c18e2
EZ
977@xref{Installing Emacs}, for some basic installation hints, and see
978@ref{Problems building Emacs}, or @ref{Linking with -lX11 fails}, if you
979have problems with the installation.
71e68827 980
f8635375 981The file @file{etc/SERVICE} (see @ref{File-name conventions}, if you're
ed5c18e2
EZ
982not sure where that is) lists companies and individuals willing to sell
983you help in installing or using Emacs. An up-to-date version this file
984is available on @samp{ftp.gnu.org} (@pxref{Informational files for
985Emacs}).
71e68827
DL
986
987@node Obtaining the FAQ, , Help installing Emacs, Getting help
988@section Where can I get the latest version of this FAQ?
989@cindex FAQ, obtaining the
990@cindex Latest FAQ version, obtaining the
991@cindex Retrieving the latest FAQ version
992@cindex E-mail, retrieving the FAQ via
993@cindex Web, reading the FAQ on the
994
995The Emacs FAQ is available in several ways:
996
997@itemize @bullet
998
999@item
ed5c18e2
EZ
1000Inside of Emacs itself. You can get it from selecting the @samp{Emacs
1001FAQ} option from the @samp{Help} menu of the Emacs menu bar at the top
1002of any Emacs frame, or by typing @kbd{C-h F} (@kbd{M-x view-emacs-FAQ}).
71e68827
DL
1003
1004@item
1005Via USENET. If you can read news, the FAQ should be available in your
1006news spool, in both the @uref{news:gnu.emacs.help} and
1007@uref{news:comp.emacs} newsgroups. Every news reader should allow you
1008to read any news article that is still in the news spool, even if you
1009have read the article before. You may need to read the instructions for
1010your news reader to discover how to do this. In @file{rn}, this command
1011will do this for you at the article selection level:
1012
1013@example
1014?GNU Emacs Frequently Asked Questions?rc:m
1015@end example
1016
1017In Gnus, you should type @kbd{C-u C-x C-s} from the @file{*Summary*}
1018buffer or @kbd{C-u @key{SPC}} from the @file{*Newsgroup*} buffer to view
1019all articles in a newsgroup.
1020
ed5c18e2
EZ
1021If the FAQ articles have expired and have been deleted from your news
1022spool, it might (or might not) do some good to complain to your news
71e68827
DL
1023administrator, because the most recent FAQ should not expire for a
1024while.
1025
ed5c18e2
EZ
1026@item
1027Via HTTP or FTP. You can always fetch the latest FAQ from
71e68827
DL
1028
1029@uref{http://www.lerner.co.il/emacs/} and
1030
1031@uref{ftp://ftp.lerner.co.il/pub/emacs/}
1032
1033@item
1034In the Emacs distribution. Since Emacs 18.56, the FAQ at the time
ed438271
EZ
1035of release has been part of the Emacs distribution as either
1036@file{etc/FAQ} or @file{man/faq.texi} (@pxref{File-name conventions}).
71e68827
DL
1037
1038@item
1039Via the World Wide Web. A hypertext version is available at
1040
1041@uref{http://www.lerner.co.il/emacs/}
1042
1043@item
1044Via anonymous ftp and e-mail from @file{rtfm.mit.edu} (and its mirror in
1045Europe), the main repository for FAQs and other items posted to
1046news.answers. The Emacs FAQs are available at
1047
1048@uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/} and
1049
1050@uref{ftp://ftp.uni-paderborn.de/pub/doc/FAQ/comp/emacs/}
1051
1052If you do not have access to anonymous FTP, you can access the archives
1053using the @file{rtfm.mit.edu} mail server. The Emacs FAQ can be
1054retrieved by sending mail to @email{mail-server@@rtfm.mit.edu} with a
1055blank subject and containing
1056
1057@example
1058send usenet/news.answers/GNU-Emacs-FAQ/diffs
1059send usenet/news.answers/GNU-Emacs-FAQ/part1
1060send usenet/news.answers/GNU-Emacs-FAQ/part2
1061send usenet/news.answers/GNU-Emacs-FAQ/part3
1062send usenet/news.answers/GNU-Emacs-FAQ/part4
1063send usenet/news.answers/GNU-Emacs-FAQ/part5
1064@end example
1065
1066For more information, send email to @email{mail-server@@rtfm.mit.edu}
1067with "help" and "index" in the body on separate lines.
1068
1069@item
1070As the very last resort, you can e-mail a request to
1071@email{emacs-faq@@lerner.co.il}. Don't do this unless you have made a
ed5c18e2 1072good-faith effort to obtain the FAQ list via one of the methods listed
71e68827
DL
1073above.
1074
1075@end itemize
1076
1077@c ------------------------------------------------------------
1078@node Status of Emacs, Common requests, Getting help, Top
1079@chapter Status of Emacs
1080@cindex Status of Emacs
1081
ed5c18e2 1082This chapter gives you basic information about Emacs, including its
71e68827
DL
1083latest version status.
1084
1085@menu
1086* Origin of the term Emacs::
1087* Latest version of Emacs::
1088* New in Emacs 20::
ed5c18e2 1089* New in Emacs 21::
71e68827
DL
1090@end menu
1091
1092@node Origin of the term Emacs, Latest version of Emacs, Status of Emacs, Status of Emacs
ed5c18e2
EZ
1093@section Where does the name ``Emacs'' come from?
1094@cindex Origin of the term ``Emacs''
71e68827
DL
1095@cindex Emacs name origin
1096@cindex TECO
1097@cindex Original version of Emacs
1098
ed5c18e2 1099Emacs originally was an acronym for Editor MACroS. RMS says he ``picked
71e68827 1100the name Emacs because @key{E} was not in use as an abbreviation on ITS at
ed5c18e2 1101the time.'' The first Emacs was a set of macros written in 1976 at MIT
71e68827
DL
1102by RMS for the editor TECO (Text Editor and COrrector, originally Tape
1103Editor and COrrector) under ITS on a PDP-10. RMS had already extended
ed5c18e2 1104TECO with a ``real-time'' full-screen mode with reprogrammable keys.
71e68827
DL
1105Emacs was started by @email{gls@@east.sun.com, Guy Steele} as a project
1106to unify the many divergent TECO command sets and key bindings at MIT,
1107and completed by RMS.
1108
1109Many people have said that TECO code looks a lot like line noise; you
1110can read more at @uref{news:alt.lang.teco}. Someone has written a TECO
ed5c18e2
EZ
1111implementation in Emacs Lisp (to find it, see @ref{Packages that do not
1112come with Emacs}); it would be an interesting project to run the
1113original TECO Emacs inside of Emacs.
71e68827 1114
ed5c18e2 1115@cindex Why Emacs?
71e68827 1116For some not-so-serious alternative reasons for Emacs to have that
f8635375 1117name, check out the file @file{etc/JOKES} (@pxref{File-name
ed5c18e2 1118conventions}).
71e68827
DL
1119
1120@node Latest version of Emacs, New in Emacs 20, Origin of the term Emacs, Status of Emacs
1121@section What is the latest version of Emacs?
1122@cindex Version, latest
ed5c18e2 1123@cindex Latest version of Emacs
71e68827 1124
ed5c18e2 1125Emacs @value{VER} is the current version as of this writing.
71e68827 1126
ed5c18e2 1127@node New in Emacs 20, New in Emacs 21, Latest version of Emacs, Status of Emacs
71e68827
DL
1128@section What is different about Emacs 20?
1129@cindex Differences between Emacs 19 and Emacs 20
1130@cindex Emacs 20, new features in
71e68827
DL
1131
1132To find out what has changed in recent versions, type @kbd{C-h n}
1133(@kbd{M-x view-emacs-news}). The oldest changes are at the bottom of
1134the file, so you might want to read it starting there, rather than at
1135the top.
1136
1137The differences between Emacs versions 18 and 19 was rather dramatic;
1138the introduction of frames, faces, and colors on windowing systems was
1139obvious to even the most casual user.
1140
1141There are differences between Emacs versions 19 and 20 as well, but many
1142are more subtle or harder to find. Among the changes are the inclusion
ed5c18e2
EZ
1143of MULE code for languages that use non-Latin characters and for mixing
1144several languages in the same document; the ``Customize'' facility for
1145modifying variables without having to use Lisp; and automatic conversion
1146of files from Macintosh, Microsoft, and Unix platforms.
71e68827
DL
1147
1148A number of older Lisp packages, such as Gnus, Supercite and the
1149calendar/diary, have been updated and enhanced to work with Emacs 20,
1150and are now included with the standard distribution.
1151
1152
ed5c18e2
EZ
1153@node New in Emacs 21, , New in Emacs 20, Status of Emacs
1154@section What is different about Emacs 21?
1155@cindex Differences between Emacs 20 and Emacs 21
1156@cindex Emacs 21, new features in
1157@cindex Recently introduced features
1158
1159@cindex Variable-size fonts
1160@cindex Toolbar support
1161Emacs 21 features a thorough rewrite of the display engine. The new
1162display engine supports variable-size fonts, images, and can play sounds
1163on platforms which support that. As a result, the visual appearence of
1164Emacs, when it runs on a windowed display, is much more reminiscent of
1165modern GUI programs, and includes 3D widgets (used for the mode line and
1166the scroll bars), a configurable and extensible toolbar, tooltips
1167(a.k.a.@: balloon help), and other niceties.
1168
b82e13af 1169@cindex Colors on text-only terminals
ed5c18e2 1170@cindex TTY colors
b82e13af 1171In addition, Emacs 21 supports faces on text-only terminals. This means
ed5c18e2
EZ
1172that you can now have colors when you run Emacs on a GNU/Linux console
1173and on @code{xterm} with @kbd{emacs -nw}.
1174
71e68827
DL
1175@c ------------------------------------------------------------
1176@node Common requests, Bugs and problems, Status of Emacs, Top
1177@chapter Common requests
1178@cindex Common requests
1179
1180@menu
1181* Setting up a customization file::
1182* Debugging a customization file::
ed5c18e2 1183* Colors on a TTY::
71e68827 1184* Displaying the current line or column::
f8635375 1185* Displaying the current file name in the titlebar::
71e68827
DL
1186* Turning on abbrevs by default::
1187* Turning on auto-fill by default::
1188* Associating modes with files::
1189* Working with unprintable characters::
1190* Highlighting a region::
1191* Controlling case sensitivity::
1192* Wrapping words automatically::
1193* Spell-checkers::
1194* Checking TeX and *roff documents::
1195* Changing load-path::
1196* Using an already running Emacs process::
1197* Compiler error messages::
1198* Indenting switch statements::
d891bf01 1199* Customizing C and C++ indentation::
71e68827
DL
1200* Horizontal scrolling::
1201* Overwrite mode::
1202* Turning off beeping::
1203* Turning the volume down::
1204* Automatic indentation::
1205* Matching parentheses::
1206* Hiding #ifdef lines::
1207* Repeating commands::
1208* Valid X resources::
1209* Evaluating Emacs Lisp code::
1210* Changing the length of a Tab::
1211* Inserting > at the beginning of each line::
1212* Underlining paragraphs::
1213* Repeating a command as many times as possible::
1214* Forcing the cursor to remain in the same column::
1215* Forcing Emacs to iconify itself::
1216* Using regular expressions::
1217* Replacing text across multiple files::
1218* Documentation for etags::
1219* Disabling backups::
1220* Disabling auto-save-mode::
8b3f7f7d 1221* Going to a line by number::
71e68827
DL
1222* Modifying pull-down menus::
1223* Deleting menus and menu options::
1224* Turning on syntax highlighting::
1225* Scrolling only one line::
1226* Replacing highlighted text::
1227* Editing MS-DOS files::
1228* Filling paragraphs with a single space::
a5ffa690 1229* Escape sequences in shell output::
71e68827
DL
1230@end menu
1231
ed5c18e2 1232@node Setting up a customization file, Colors on a TTY, Common requests, Common requests
71e68827
DL
1233@section How do I set up a @file{.emacs} file properly?
1234@cindex @file{.emacs} file, setting up
1235@cindex Init file, setting up
1236@cindex Customization file, setting up
1237
1238@inforef{Init File, Init File, emacs}
1239
1240In general, new Emacs users should not have @file{.emacs} files, because
1241it causes confusing non-standard behavior. Then they send questions to
1242@email{help-gnu-emacs@@gnu.org} asking why Emacs isn't behaving as
1243documented.
1244
ed5c18e2
EZ
1245Beginning with version 20.1, Emacs includes the new Customize
1246facility, which can be invoked using @kbd{M-x customize @key{RET}}.
1247This allows users who are unfamiliar with Emacs Lisp to modify their
1248@file{.emacs} files in a relatively straightforward way, using menus
1249rather than Lisp code. Not all packages support Customize as of this
1250writing, but the number is growing fairly steadily.
71e68827 1251
ed5c18e2 1252While Customize might indeed make it easier to configure Emacs,
71e68827 1253consider taking a bit of time to learn Emacs Lisp and modifying your
ed5c18e2 1254@file{.emacs} directly. Simple configuration options are described
71e68827
DL
1255rather completely in @inforef{Init File, Init File, emacs}, for users
1256interested in performing frequently requested, basic tasks.
1257
ed5c18e2
EZ
1258@node Colors on a TTY, Debugging a customization file, Setting up a customization file, Common requests
1259@section How do I get colors and syntax highlighting on a TTY?
1260@cindex Colors on a TTY
1261@cindex Syntax highlighting on a TTY
1262@cindex Console, colors
1263
1264As of Emacs 21.1, colors and faces are supported in non-windowed mode,
b82e13af 1265i.e.@: on Unix and GNU/Linux text-only terminals and consoles, and when
ed5c18e2
EZ
1266invoked as @samp{emacs -nw} on X and MS-Windows. (Colors and faces were
1267supported in the MS-DOS port since Emacs 19.29.) Emacs automatically
1268detects color support at startup and uses it if available. If you think
1269that your terminal supports colors, but Emacs won't use them, check the
1270@code{termcap} entry for your display type for color-related
1271capabilities.
1272
1273The command @kbd{M-x list-colors-display} pops up a window which
1274exhibits all the colors Emacs knows about on the current display.
1275
1276Syntax highlighting is usually turned off by default; see @ref{Turning
1277on syntax highlighting}, for instructions how to turn it on.
1278
1279@node Debugging a customization file, Displaying the current line or column, Colors on a TTY, Common requests
71e68827
DL
1280@section How do I debug a @file{.emacs} file?
1281@cindex Debugging @file{.emacs} file
1282@cindex @file{.emacs} debugging
1283@cindex Init file debugging
ed5c18e2 1284@cindex @samp{-debug-init} option
71e68827
DL
1285
1286Start Emacs with the @samp{-debug-init} command-line option. This
1287enables the Emacs Lisp debugger before evaluating your @file{.emacs}
1288file, and places you in the debugger if something goes wrong. The top
1289line in the @file{trace-back} buffer will be the error message, and the
1290second or third line of that buffer will display the Lisp code from your
1291@file{.emacs} file that caused the problem.
1292
1293You can also evaluate an individual function or argument to a function
1294in your @file{.emacs} file by moving the cursor to the end of the
1295function or argument and typing @kbd{C-x C-e} (@kbd{M-x
1296eval-last-sexp}).
1297
1298Use @kbd{C-h v} (@kbd{M-x describe-variable}) to check the value of
1299variables which you are trying to set or use.
1300
f8635375 1301@node Displaying the current line or column, Displaying the current file name in the titlebar, Debugging a customization file, Common requests
71e68827
DL
1302@section How do I make Emacs display the current line (or column) number?
1303@cindex @code{line-number-mode}
1304@cindex Displaying the current line or column
1305@cindex Line number, displaying the current
1306@cindex Column, displaying the current
1307@cindex @code{mode-line-format}
1308
1309To have Emacs automatically display the current line number of the point
1310in the mode line, do @kbd{M-x line-number-mode}. You can also put the
1311form
1312
1313@lisp
1314(setq line-number-mode t)
1315@end lisp
1316
ed5c18e2 1317@noindent
71e68827 1318in your @file{.emacs} file to achieve this whenever you start Emacs.
ed5c18e2
EZ
1319(Line number display is on by default, unless your site-specific
1320initialization disables it.) Note that Emacs will not display the line
1321number if the buffer's size in bytes is larger than the value of the
1322variable @code{line-number-display-limit}.
71e68827
DL
1323
1324As of Emacs 20, you can similarly display the current column with
1325@kbd{M-x column-number-mode}, or by putting the form
1326
1327@lisp
1328(setq column-number-mode t)
1329@end lisp
1330
ed5c18e2 1331@noindent
71e68827
DL
1332in your @file{.emacs} file.
1333
ed5c18e2
EZ
1334The @code{"%c"} format specifier in the variable @code{mode-line-format}
1335will insert the current column's value into the mode line. See the
71e68827
DL
1336documentation for @code{mode-line-format} (using @kbd{C-h v
1337mode-line-format @key{RET}}) for more information on how to set and use
1338this variable.
1339
ed5c18e2
EZ
1340Users of all Emacs versions can display the current column using the
1341@samp{column} package written by @email{abraham@@dina.kvl.dk, Per
1342Abrahamsen}. @xref{Packages that do not come with Emacs}, for
1343instructions on how to get it.
71e68827 1344
ed5c18e2
EZ
1345@cindex Set number capability in @code{vi} emulators
1346None of the @code{vi} emulation modes provide the ``set number''
1347capability of @code{vi} (as far as we know).
71e68827 1348
f8635375
EZ
1349@node Displaying the current file name in the titlebar, Turning on abbrevs by default, Displaying the current line or column, Common requests
1350@section How can I modify the titlebar to contain the current file name?
1351@cindex Titlebar, displaying the current file name in
1352@cindex File name, displaying in the titlebar
71e68827
DL
1353@cindex @code{frame-title-format}
1354
ed5c18e2 1355The contents of an Emacs frame's titlebar is controlled by the variable
71e68827
DL
1356@code{frame-title-format}, which has the same structure as the variable
1357@code{mode-line-format}. (Use @kbd{C-h v} or @kbd{M-x
1358describe-variable} to get information about one or both of these
1359variables.)
1360
1361By default, the titlebar for a frame does contain the name of the buffer
1362currently being visited, except if there is a single frame. In such a
ed438271
EZ
1363case, the titlebar contains Emacs invocation name and the name of the
1364machine at which Emacs was invoked. This is done by setting
71e68827
DL
1365@code{frame-title-format} to the default value of
1366
1367@lisp
1368(multiple-frames "%b" ("" invocation-name "@@" system-name))
1369@end lisp
1370
1371To modify the behavior such that frame titlebars contain the buffer's
1372name regardless of the number of existing frames, include the following
1373in your @file{.emacs}:
1374
1375@lisp
1376(setq frame-title-format "%b")
1377@end lisp
1378
f8635375 1379@node Turning on abbrevs by default, Turning on auto-fill by default, Displaying the current file name in the titlebar, Common requests
ed5c18e2 1380@section How do I turn on abbrevs by default just in mode @var{mymode}?
71e68827
DL
1381@cindex Abbrevs, turning on by default
1382
1383Put this in your @file{.emacs} file:
1384
1385@lisp
1386(condition-case ()
1387 (quietly-read-abbrev-file)
1388 (file-error nil))
1389
ed5c18e2 1390(add-hook '@var{mymode}-mode-hook
bed44076
SM
1391 (lambda ()
1392 (setq abbrev-mode t)))
71e68827
DL
1393@end lisp
1394
1395@node Turning on auto-fill by default, Associating modes with files, Turning on abbrevs by default, Common requests
1396@section How do I turn on @code{auto-fill-mode} by default?
1397@cindex @code{auto-fill-mode}, activating automatically
1398@cindex Filling automatically
1399@cindex Automatic entry to @code{auto-fill-mode}
1400
1401To turn on @code{auto-fill-mode} just once for one buffer, use @kbd{M-x
1402auto-fill-mode}.
1403
1404To turn it on for every buffer in a certain mode, you must use the hook
1405for that mode. For example, to turn on @code{auto-fill} mode for all
1406text buffers, including the following in your @file{.emacs} file:
1407
1408@lisp
1409(add-hook 'text-mode-hook 'turn-on-auto-fill)
1410@end lisp
1411
1412If you want @code{auto-fill} mode on in all major modes, do this:
1413
1414@lisp
1415(setq-default auto-fill-function 'do-auto-fill)
1416@end lisp
1417
1418@node Associating modes with files, Working with unprintable characters, Turning on auto-fill by default, Common requests
1419@section How do I make Emacs use a certain major mode for certain files?
1420@cindex Associating modes with files
1421@cindex File extensions and modes
1422@cindex @code{auto-mode-alist}, modifying
1423@cindex Modes, associating with file extensions
1424
ed5c18e2
EZ
1425If you want to use a certain mode @var{foo} for all files whose names end
1426with the extension @file{.@var{bar}}, this will do it for you:
71e68827
DL
1427
1428@lisp
ed5c18e2 1429(setq auto-mode-alist (cons '("\\.@var{bar}\\'" . @var{foo}-mode) auto-mode-alist))
71e68827
DL
1430@end lisp
1431
1432Otherwise put this somewhere in the first line of any file you want to
ed5c18e2
EZ
1433edit in the mode @var{foo} (in the second line, if the first line begins
1434with @samp{#!}):
71e68827
DL
1435
1436@example
ed5c18e2 1437-*- @var{foo} -*-
71e68827
DL
1438@end example
1439
ed5c18e2 1440@cindex Major mode for shell scripts
71e68827
DL
1441Beginning with Emacs 19, the variable @code{interpreter-mode-alist}
1442specifies which mode to use when loading a shell script. (Emacs
1443determines which interpreter you're using by examining the first line of
ed5c18e2 1444the script.) This feature only applies when the file name doesn't
71e68827
DL
1445indicate which mode to use. Use @kbd{C-h v} (or @kbd{M-x
1446describe-variable}) on @code{interpreter-mode-alist} to learn more.
1447
1448@node Working with unprintable characters, Highlighting a region, Associating modes with files, Common requests
1449@section How do I search for, delete, or replace unprintable (eight-bit or control) characters?
1450@cindex Unprintable characters, working with
1451@cindex Working with unprintable characters
1452@cindex Control characters, working with
1453@cindex Eight-bit characters, working with
1454@cindex Searching for unprintable characters
1455@cindex Regexps and unprintable characters
1456
1457To search for a single character that appears in the buffer as, for
1458example, @samp{\237}, you can type @kbd{C-s C-q 2 3 7}. (This assumes
1459the value of @code{search-quote-char} is 17 (i.e., @kbd{C-q}).)
ed5c18e2
EZ
1460Searching for @strong{all} unprintable characters is best done with a
1461regular expression (@dfn{regexp}) search. The easiest regexp to use for
1462the unprintable chars is the complement of the regexp for the printable
71e68827
DL
1463chars.
1464
1465@itemize @bullet
1466
1467@item
1468Regexp for the printable chars: @samp{[\t\n\r\f -~]}
1469
1470@item
1471Regexp for the unprintable chars: @samp{[^\t\n\r\f -~]}
1472
1473@end itemize
1474
1475To type these special characters in an interactive argument to
1476@code{isearch-forward-regexp} or @code{re-search-forward}, you need to
1477use @kbd{C-q}. (@samp{\t}, @samp{\n}, @samp{\r}, and @samp{\f} stand
1478respectively for @key{TAB}, @key{LFD}, @key{RET}, and @kbd{C-l}.) So,
1479to search for unprintable characters using @code{re-search-forward}:
1480
1481@kbd{M-x re-search-forward @key{RET} [^ @key{TAB} C-q @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~] @key{RET}}
1482
1483Using @code{isearch-forward-regexp}:
1484
718fb8a1 1485@kbd{C-M-s [^ @key{TAB} @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~]}
71e68827
DL
1486
1487To delete all unprintable characters, simply use replace-regexp:
1488
1489@kbd{M-x replace-regexp @key{RET} [^ @key{TAB} C-q @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~] @key{RET} @key{RET}}
1490
1491Replacing is similar to the above. To replace all unprintable
1492characters with a colon, use:
1493
1494M-x replace-regexp @key{RET} [^ @key{TAB} C-q @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~] @key{RET} : @key{RET}
1495
1496@itemize @bullet
1497
ed5c18e2
EZ
1498@item
1499You don't need to quote @key{TAB} with either isearch or typing
71e68827
DL
1500something in the minibuffer.
1501
1502@end itemize
1503
1504@node Highlighting a region, Controlling case sensitivity, Working with unprintable characters, Common requests
1505@section How can I highlight a region of text in Emacs?
1506@cindex Highlighting text
1507@cindex Text, highlighting
1508@cindex @code{transient-mark-mode}
1509@cindex Region, highlighting a
1510
ed438271
EZ
1511You can cause the region to be highlighted when the mark is active by
1512including
71e68827
DL
1513
1514@lisp
1515(transient-mark-mode t)
1516@end lisp
1517
ed438271 1518@noindent
ed5c18e2
EZ
1519in your @file{.emacs} file. (Also see @ref{Turning on syntax
1520highlighting}.)
71e68827
DL
1521
1522@node Controlling case sensitivity, Wrapping words automatically, Highlighting a region, Common requests
1523@section How do I control Emacs's case-sensitivity when searching/replacing?
1524@cindex @code{case-fold-search}
1525@cindex Case sensitivity of searches
71e68827
DL
1526@cindex Searching without case sensitivity
1527@cindex Ignoring case in searches
1528
1529For searching, the value of the variable @code{case-fold-search}
1530determines whether they are case sensitive:
1531
1532@lisp
1533(setq case-fold-search nil) ; make searches case sensitive
1534(setq case-fold-search t) ; make searches case insensitive
1535@end lisp
1536
ed5c18e2
EZ
1537@cindex Case sensitivity in replacements
1538@cindex Replacing, and case sensitivity
1539@cindex @code{case-replace}
1540Similarly, for replacing, the variable @code{case-replace} determines
71e68827
DL
1541whether replacements preserve case.
1542
1543To change the case sensitivity just for one major mode, use the major
1544mode's hook. For example:
1545
1546@lisp
ed5c18e2 1547(add-hook '@var{foo}-mode-hook
bed44076
SM
1548 (lambda ()
1549 (setq case-fold-search nil)))
71e68827
DL
1550@end lisp
1551
1552@node Wrapping words automatically, Spell-checkers, Controlling case sensitivity, Common requests
1553@section How do I make Emacs wrap words for me?
1554@cindex Wrapping word automatically
ed5c18e2
EZ
1555@cindex Wrapping lines
1556@cindex Line wrap
71e68827
DL
1557@cindex @code{auto-fill-mode}, introduction to
1558@cindex Maximum line width, default value
1559@cindex @code{fill-column}, default value
1560
1561Use @code{auto-fill-mode}, activated by typing @kbd{M-x auto-fill-mode}.
1562The default maximum line width is 70, determined by the variable
ed5c18e2
EZ
1563@code{fill-column}. To learn how to turn this on automatically, see
1564@ref{Turning on auto-fill by default}.
71e68827
DL
1565
1566@node Spell-checkers, Checking TeX and *roff documents, Wrapping words automatically, Common requests
1567@section Where can I get a better spelling checker for Emacs?
1568@cindex Checking spelling
1569@cindex Spelling, checking text documents
1570
1571Use Ispell. @xref{Ispell}.
1572
1573@node Checking TeX and *roff documents, Changing load-path, Spell-checkers, Common requests
1574@section How can I spell-check @TeX{} or *roff documents?
1575@cindex Spelling, checking @TeX{} documents
1576@cindex @TeX{} documents, checking spelling in
1577
1578Use Ispell. Ispell can handle @TeX{} and *roff documents.
1579@xref{Ispell}.
1580
1581@node Changing load-path, Using an already running Emacs process, Checking TeX and *roff documents, Common requests
1582@section How do I change @code{load-path}?
1583@cindex @code{load-path}, modifying
1584@cindex Modifying @code{load-path}
1585@cindex Adding to @code{load-path}
1586
1587In general, you should only add to the @code{load-path}. You can add
ed5c18e2 1588directory @var{/dir/subdir} to the load path like this:
71e68827
DL
1589
1590@lisp
ed5c18e2 1591(setq load-path (cons "/dir/subdir/" load-path))
71e68827
DL
1592@end lisp
1593
1594To do this relative to your home directory:
1595
1596@lisp
ed5c18e2 1597(setq load-path (cons "~/mysubdir/" load-path)
71e68827
DL
1598@end lisp
1599
1600@node Using an already running Emacs process, Compiler error messages, Changing load-path, Common requests
1601@section How do I use an already running Emacs from another window?
1602@cindex @code{emacsclient}
1603@cindex Emacs server functions
1604@cindex Using an existing Emacs process
1605
1606@code{emacsclient}, which comes with Emacs, is for editing a file using
1607an already running Emacs rather than starting up a new Emacs. It does
1608this by sending a request to the already running Emacs, which must be
1609expecting the request.
1610
1611@itemize @bullet
1612
1613@item
ed5c18e2 1614Setup:
71e68827
DL
1615
1616Emacs must have executed the @code{server-start} function for
1617@samp{emacsclient} to work. This can be done either by a command line
1618option:
1619
1620@example
1621emacs -f server-start
1622@end example
1623
1624or by invoking @code{server-start} from @file{.emacs}:
1625
1626@lisp
ed5c18e2 1627(if (@var{some conditions are met}) (server-start))
71e68827
DL
1628@end lisp
1629
1630When this is done, Emacs starts a subprocess running a program called
ed438271
EZ
1631@samp{emacsserver}. @samp{emacsserver} creates a Unix domain socket.
1632The socket is either named @file{.emacs_server}, in the user's home directory,
1633or @file{esrv-@var{userid}-@var{systemname}}, in the @file{/tmp}
1de6bfb1 1634directory, depending on how @samp{emacsserver} was compiled.
71e68827
DL
1635
1636To get your news reader, mail reader, etc., to invoke
1637@samp{emacsclient}, try setting the environment variable @code{EDITOR}
1638(or sometimes @code{VISUAL}) to the value @samp{emacsclient}. You may
1639have to specify the full pathname of the @samp{emacsclient} program
1640instead. Examples:
1641
1642@example
1643# csh commands:
1644setenv EDITOR emacsclient
1645
1646# using full pathname
1647setenv EDITOR /usr/local/emacs/etc/emacsclient
1648
1649# sh command:
1650EDITOR=emacsclient ; export EDITOR
1651@end example
1652
ed5c18e2
EZ
1653@item
1654Normal use:
71e68827
DL
1655
1656When @samp{emacsclient} is run, it connects to the @file{.emacs_server}
1657socket and passes its command line options to @samp{server}. When
ed5c18e2 1658@samp{server} receives these requests, it sends this information to the
71e68827
DL
1659the Emacs process, which at the next opportunity will visit the files
1660specified. (Line numbers can be specified just like with Emacs.) The
1661user will have to switch to the Emacs window by hand. When the user is
1662done editing a file, the user can type @kbd{C-x #} (or @kbd{M-x
1663server-edit}) to indicate this. If there is another buffer requested by
ed5c18e2
EZ
1664@code{emacsclient}, Emacs will switch to it; otherwise
1665@code{emacsclient} will exit, signaling the calling program to continue.
71e68827
DL
1666
1667@samp{emacsclient} and @samp{server} must be running on machines which
1668share the same filesystem for this to work. The pathnames that
1669@samp{emacsclient} specifies should be correct for the filesystem that
1670the Emacs process sees. The Emacs process should not be suspended at
ed5c18e2 1671the time @samp{emacsclient} is invoked. On Unix and GNU/Linux systems,
ed438271
EZ
1672@samp{emacsclient} should either be invoked from another X window, or
1673from a shell window inside Emacs itself, or from another interactive
1674session, e.g., by means of a @code{screen} program.
71e68827 1675
ed5c18e2 1676@cindex @code{gnuserv}
71e68827 1677There is an enhanced version of @samp{emacsclient}/server called
ed5c18e2
EZ
1678@samp{gnuserv}, written by @email{ange@@hplb.hpl.hp.com, Andy Norman}
1679which is available in the Emacs Lisp Archive (@pxref{Packages that do
1680not come with Emacs}). @samp{gnuserv} uses Internet domain sockets, so
1681it can work across most network connections. It also supports the
1682execution of arbitrary Emacs Lisp forms and does not require the client
1683program to wait for completion.
71e68827 1684
ed5c18e2 1685The alpha version of an enhanced @samp{gnuserv} is available at
71e68827
DL
1686
1687@uref{ftp://ftp.wellfleet.com/netman/psmith/emacs/gnuserv-2.1alpha.tar.gz}
1688
1689@end itemize
1690
1691@node Compiler error messages, Indenting switch statements, Using an already running Emacs process, Common requests
1692@section How do I make Emacs recognize my compiler's funny error messages?
1693@cindex Compiler error messages, recognizing
1694@cindex Recognizing non-standard compiler errors
1695@cindex Regexps for recognizing compiler errors
1696@cindex Errors, recognizing compiler
1697
1698The variable @code{compilation-error-regexp-alist} helps control how
ed5c18e2
EZ
1699Emacs parses your compiler output. It is a list of triplets of the form:
1700@code{(@var{regexp} @var{file-idx} @var{line-idx})}, where @var{regexp},
1701@var{file-idx} and @var{line-idx} are strings. To help determine what
1702the constituent elements should be, load @file{compile.el} and then type
1703@kbd{C-h v compilation-error-regexp-alist @key{RET}} to see the current
1704value. A good idea is to look at @file{compile.el} itself as the
1705comments included for this variable are quite useful---the regular
1706expressions required for your compiler's output may be very close to one
1707already provided. Once you have determined the proper regexps, use the
1708following to inform Emacs of your changes:
71e68827
DL
1709
1710@lisp
1711(setq compilation-error-regexp-alist
ed5c18e2 1712 (cons '(@var{regexp} @var{file-idx} @var{line-idx})
71e68827
DL
1713 compilation-error-regexp-alist))
1714@end lisp
1715
d891bf01 1716@node Indenting switch statements, Customizing C and C++ indentation, Compiler error messages, Common requests
71e68827
DL
1717@section How do I change the indentation for @code{switch}?
1718@cindex @code{switch}, indenting
1719@cindex Indenting of @code{switch}
1720
1721Many people want to indent their @code{switch} statements like this:
1722
1723@example
1724f()
1725@{
1726 switch(x) @{
1727 case A:
1728 x1;
1729 break;
1730 case B:
1731 x2;
1732 break;
1733 default:
1734 x3;
1735 @}
1736@}
1737@end example
1738
1739The solution at first appears to be: set @code{c-indent-level} to 4 and
1740@code{c-label-offset} to -2. However, this will give you an indentation
1741spacing of four instead of two.
1742
ed5c18e2
EZ
1743The @emph{real} solution is to use @code{cc-mode} (the default mode for
1744C programming in Emacs 20 and later) and add the following line to yoyr
1745@file{.emacs}:
71e68827
DL
1746
1747@lisp
1748(c-set-offset 'case-label '+)
1749@end lisp
1750
1751There appears to be no way to do this with the old @code{c-mode}.
1752
d891bf01
EZ
1753@node Customizing C and C++ indentation, Horizontal scrolling, Indenting switch statements, Common requests
1754@section How to customize indentation in C, C@t{++}, and Java buffers?
1755@cindex Indentation, how to customize
1756@cindex Customize indentation
1757
1758The Emacs @code{cc-mode} features an interactive procedure for
1759customizing the indentation style, which is fully explained in the
1760@cite{CC Mode} manual that is part of the Emacs distribution, see
1761@ref{Customizing Indentation, , Customization Indentation, ccmode,
1762The CC Mode Manual}. Here's a short summary of the procedure:
1763
1764@enumerate
1765@item
1766Go to the beginning of the first line where you don't like the
1767indentation and type @kbd{C-c C-o}. Emacs will prompt you for the
1768syntactic symbol; type @key{RET} to accept the default it suggests.
1769
1770@item
1771Emacs now prompts for the offset of this syntactic symbol, showing the
1772default (the current definition) inside parentheses. You can choose
1773one of these:
1774
1775@table @code
1776@item 0
1777No extra indentation.
1778@item +
1779Indent one basic offset.
1780@item -
1781Outdent one basic offset.
1782@item ++
1783Indent two basic offsets
1784@item --
1785Outdent two basic offsets.
1786@item *
1787Indent half basic offset.
1788@item /
809eb587 1789Outdent half basic offset.
d891bf01
EZ
1790@end table
1791
1792@item
1793After choosing one of these symbols, type @kbd{C-c C-q} to reindent
1794the line or the block according to what you just specified.
1795
1796@item
1797If you don't like the result, go back to step 1. Otherwise, add the
1798following line to your @file{.emacs}:
1799
1800@lisp
1801(c-set-offset '@var{syntactic-symbol} @var{offset})
1802@end lisp
1803
1804@noindent
1805where @var{syntactic-symbol} is the name Emacs shows in the minibuffer
1806when you type @kbd{C-c C-o} at the beginning of the line, and
1807@var{offset} is one of the indentation symbols listed above (@code{+},
1808@code{/}, @code{0}, etc.) that you've chosen during the interactive
1809procedure.
1810
1811@item
1812Go to the next line whose indentation is not to your liking and repeat
1813the process there.
1814@end enumerate
1815
1816It is recommended to put all the resulting @code{(c-set-offset ...)}
1817customizations inside a C mode hook, like this:
1818
1819@lisp
1820(defun my-c-mode-hook ()
1821 (c-set-offset ...)
1822 (c-set-offset ...))
1823(add-hook 'c-mode-hook 'my-c-mode-hook)
1824@end lisp
1825
1826@noindent
1827Using @code{c-mode-hook} avoids the need to put a @w{@code{(require
1828'cc-mode)}} into your @file{.emacs} file, because @code{c-set-offset}
1829might be unavailable when @code{cc-mode} is not loaded.
1830
1831Note that @code{c-mode-hook} runs for C source files only; use
1832@code{c++-mode-hook} for C@t{++} sources, @code{java-mode-hook} for
1833Java sources, etc. If you want the same customizations to be in
1834effect in @emph{all} languages supported by @code{cc-mode}, use
1835@code{c-mode-common-hook}.
1836
1837@node Horizontal scrolling, Overwrite mode, Customizing C and C++ indentation, Common requests
71e68827
DL
1838@section How can I make Emacs automatically scroll horizontally?
1839@cindex @code{hscroll-mode}
1840@cindex Horizontal scrolling
1841@cindex Scrolling horizontally
1842
ed5c18e2
EZ
1843In Emacs 21 and later, this is on by default: if the variable
1844@code{truncate-lines} is non-@code{nil} in the current buffer, Emacs
1845automatically scrolls the display horizontally when point moves off the
1846left or right edge of the window.
1847
1848In Emacs 20, use the @code{hscroll-mode}. Here is some information from
71e68827
DL
1849the documentation, available by typing @kbd{C-h f hscroll-mode @key{RET}}:
1850
1851Automatically scroll horizontally when the point moves off the
1852left or right edge of the window.
1853
1854@itemize @minus
ed5c18e2
EZ
1855@item
1856Type @kbd{M-x hscroll-mode} to enable it in the current buffer.
71e68827 1857
ed5c18e2
EZ
1858@item
1859Type @kbd{M-x hscroll-global-mode} to enable it in every buffer.
1860
1861@item
1862@code{turn-on-hscroll} is useful in mode hooks as in:
71e68827
DL
1863
1864@lisp
1865(add-hook 'text-mode-hook 'turn-on-hscroll)
1866@end lisp
1867
ed5c18e2
EZ
1868@item
1869@code{hscroll-margin} controls how close the cursor can get to the
71e68827
DL
1870edge of the window.
1871
ed5c18e2
EZ
1872@item
1873@code{hscroll-step-percent} controls how far to jump once we decide to do so.
71e68827
DL
1874@end itemize
1875
1876@node Overwrite mode, Turning off beeping, Horizontal scrolling, Common requests
1877@section How do I make Emacs "typeover" or "overwrite" instead of inserting?
1878@cindex @key{Insert}
1879@cindex @code{overwrite-mode}
1880@cindex Overwriting existing text
1881@cindex Toggling @code{overwrite-mode}
1882
1883@kbd{M-x overwrite-mode} (a minor mode). This toggles
1884@code{overwrite-mode} on and off, so exiting from @code{overwrite-mode}
1885is as easy as another @kbd{M-x overwrite-mode}.
1886
ed5c18e2 1887On some systems, @key{Insert} toggles @code{overwrite-mode} on and off.
71e68827
DL
1888
1889@node Turning off beeping, Turning the volume down, Overwrite mode, Common requests
1890@section How do I stop Emacs from beeping on a terminal?
1891@cindex Beeping, turning off
1892@cindex Visible bell
1893@cindex Bell, visible
1894
1895@email{martin@@cc.gatech.edu, Martin R. Frank} writes:
1896
ed5c18e2
EZ
1897Tell Emacs to use the @dfn{visible bell} instead of the audible bell,
1898and set the visible bell to nothing.
71e68827
DL
1899
1900That is, put the following in your @code{TERMCAP} environment variable
1901(assuming you have one):
1902
1903@example
1904... :vb=: ...
1905@end example
1906
1907And evaluate the following Lisp form:
1908
1909@example
1910(setq visible-bell t)
1911@end example
1912
1913@node Turning the volume down, Automatic indentation, Turning off beeping, Common requests
97878c08 1914@section How do I turn down the bell volume in Emacs running under X?
71e68827
DL
1915@cindex Bell, volume of
1916@cindex Volume of bell
1917
ed5c18e2
EZ
1918On X Window system, you can adjust the bell volume and duration for all
1919programs with the shell command @code{xset}.
71e68827 1920
ed5c18e2
EZ
1921Invoking @code{xset} without any arguments produces some basic
1922information, including the following:
71e68827
DL
1923
1924@example
1925usage: xset [-display host:dpy] option ...
1926 To turn bell off:
1927 -b b off b 0
1928 To set bell volume, pitch and duration:
1929 b [vol [pitch [dur]]] b on
1930@end example
1931
1932@node Automatic indentation, Matching parentheses, Turning the volume down, Common requests
1933@section How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
1934@cindex Indenting new lines
1935@cindex New lines, indenting of
1936@cindex Previous line, indenting according to
ed5c18e2 1937@cindex Text indentation
71e68827 1938
ed5c18e2
EZ
1939Such behavior is automatic in Emacs 20 and later. From the
1940@file{etc/NEWS} file for Emacs 20.2:
71e68827
DL
1941
1942@example
1943** In Text mode, now only blank lines separate paragraphs. This makes
1944it possible to get the full benefit of Adaptive Fill mode in Text mode,
1945and other modes derived from it (such as Mail mode). @key{TAB} in Text
1946mode now runs the command @code{indent-relative}; this makes a practical
1947difference only when you use indented paragraphs.
1948
1949As a result, the old Indented Text mode is now identical to Text mode,
1950and is an alias for it.
1951
1952If you want spaces at the beginning of a line to start a paragraph, use
1953the new mode, Paragraph Indent Text mode.
1954@end example
1955
ed5c18e2
EZ
1956@cindex Prefixing lines
1957@cindex Fill prefix
1958If you have @code{auto-fill-mode} turned on (@pxref{Turning on auto-fill
1959by default}), you can tell Emacs to prefix every line with a certain
1960character sequence, the @dfn{fill prefix}. Type the prefix at the
1961beginning of a line, position point after it, and then type @kbd{C-x .}
71e68827
DL
1962(@code{set-fill-prefix}) to set the fill prefix. Thereafter,
1963auto-filling will automatically put the fill prefix at the beginning of
1964new lines, and @kbd{M-q} (@code{fill-paragraph}) will maintain any fill
1965prefix when refilling the paragraph.
1966
1967If you have paragraphs with different levels of indentation, you will
1968have to set the fill prefix to the correct value each time you move to a
1969new paragraph. To avoid this hassle, try one of the many packages
1970available from the Emacs Lisp Archive (@pxref{Packages that do not come
ed5c18e2
EZ
1971with Emacs}.) Look up ``fill'' and ``indent'' in the Lisp Code
1972Directory for guidance.
71e68827
DL
1973
1974@node Matching parentheses, Hiding #ifdef lines, Automatic indentation, Common requests
1975@section How do I show which parenthesis matches the one I'm looking at?
1976@cindex Parentheses, matching
1977@cindex @file{paren.el}
1978@cindex Highlighting matching parentheses
1979@cindex Pairs of parentheses, highlighting
1980@cindex Matching parentheses
1981
1982As of version 19, Emacs comes with @file{paren.el}, which (when loaded)
1983will automatically highlight matching parentheses whenever point (i.e.,
1984the cursor) is located over one. To load @file{paren.el} automatically,
1985include the line
1986
1987@lisp
1988(require 'paren)
1989@end lisp
1990
1991in your @file{.emacs} file. @email{shutkoa@@ugsolutions.com, Alan Shutko}
1992reports that as of version 20.1, you must also call @code{show-paren-mode} in
1993your @file{.emacs} file:
1994
1995@lisp
1996(show-paren-mode 1)
1997@end lisp
1998
ed5c18e2
EZ
1999Customize will let you turn on @code{show-paren-mode}. Use @kbd{M-x
2000customize-group @key{RET} paren-showing @key{RET}}. From within
2001Customize, you can also go directly to the ``paren-showing'' group.
71e68827 2002
ed5c18e2 2003Alternatives to paren include:
71e68827
DL
2004
2005@itemize @bullet
2006
2007@item
2008If you're looking at a right parenthesis (or brace or bracket) you can
ed5c18e2
EZ
2009delete it and reinsert it. Emacs will momentarily move the cursor to
2010the matching parenthesis.
71e68827
DL
2011
2012@item
718fb8a1 2013@kbd{C-M-f} (@code{forward-sexp}) and @kbd{C-M-b} (@code{backward-sexp})
71e68827
DL
2014will skip over one set of balanced parentheses, so you can see which
2015parentheses match. (You can train it to skip over balanced brackets
ed5c18e2 2016and braces at the same time by modifying the syntax table.)
71e68827 2017
ed5c18e2 2018@cindex Show matching paren as in @code{vi}
71e68827
DL
2019@item
2020Here is some Emacs Lisp that will make the @key{%} key show the matching
ed5c18e2 2021parenthesis, like in @code{vi}. In addition, if the cursor isn't over a
71e68827
DL
2022parenthesis, it simply inserts a % like normal.
2023
2024@lisp
2025;; By an unknown contributor
2026
2027(global-set-key "%" 'match-paren)
2028
2029(defun match-paren (arg)
2030 "Go to the matching paren if on a paren; otherwise insert %."
2031 (interactive "p")
2032 (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
2033 ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
2034 (t (self-insert-command (or arg 1)))))
2035@end lisp
2036
2037@end itemize
2038
2039@node Hiding #ifdef lines, Repeating commands, Matching parentheses, Common requests
2040@section In C mode, can I show just the lines that will be left after @code{#ifdef} commands are handled by the compiler?
2041@cindex @code{#ifdef}, selective display of
2042@cindex @code{hide-ifdef-mode}
2043@cindex Hiding @code{#ifdef} text
2044@cindex Selectively displaying @code{#ifdef} code
2045
2046@kbd{M-x hide-ifdef-mode}. (This is a minor mode.) You might also want
2047to try @file{cpp.el}, available at the Emacs Lisp Archive
2048(@pxref{Packages that do not come with Emacs}).
2049
2050@node Repeating commands, Valid X resources, Hiding #ifdef lines, Common requests
2051@section Is there an equivalent to the @code{.} (dot) command of vi?
ed5c18e2 2052@cindex Repeating commands as with @code{vi}
71e68827 2053@cindex Command, repeat last
ed5c18e2 2054@cindex @code{.}, equivalent to @code{vi} command
71e68827 2055
ed5c18e2
EZ
2056(@code{.} is the redo command in @code{vi}. It redoes the last
2057insertion/deletion.)
71e68827 2058
ed5c18e2 2059As of Emacs 20.3, there is indeed a @code{repeat} command (@kbd{C-x z})
71e68827
DL
2060that repeats the last command. If you preface it with a prefix
2061argument, the prefix arg is applied to the command.
2062
2063You can also type @kbd{C-x @key{ESC} @key{ESC}}
2064(@code{repeat-complex-command}) to reinvoke commands that used the
2065minibuffer to get arguments. In @code{repeat-complex-command} you can
ed5c18e2
EZ
2066type @kbd{M-p} and @kbd{M-n} (and also up-arrow and down-arrow, if your
2067keyboard has these keys) to scan through all the different complex
71e68827
DL
2068commands you've typed.
2069
2070To repeat a set of commands, use keyboard macros. (@inforef{Keyboard
2071Macros, Keyboard Macros, emacs}.)
2072
ed5c18e2
EZ
2073If you're really desperate for the @code{.} command, use VIPER, a
2074@code{vi} emulation mode which comes with Emacs, and which appears to
2075support it. (@xref{VIPER}.)
71e68827
DL
2076
2077@node Valid X resources, Evaluating Emacs Lisp code, Repeating commands, Common requests
2078@section What are the valid X resource settings (i.e., stuff in .Xdefaults)?
2079@cindex Resources, X
2080@cindex X resources
2081@cindex Setting X resources
2082
2083@inforef{Resources X, Resources X, emacs}.
2084
2085You can also use a resource editor, such as editres (for X11R5 and
2086onwards), to look at the resource names for the menu bar, assuming Emacs
2087was compiled with the X toolkit.
2088
2089@node Evaluating Emacs Lisp code, Changing the length of a Tab, Valid X resources, Common requests
2090@section How do I execute ("evaluate") a piece of Emacs Lisp code?
2091@cindex Evaluating Lisp code
2092@cindex Lisp forms, evaluating
2093
ed5c18e2
EZ
2094There are a number of ways to execute (@dfn{evaluate}, in Lisp lingo) an
2095Emacs Lisp @dfn{form}:
71e68827
DL
2096
2097@itemize @bullet
2098
2099@item
2100If you want it evaluated every time you run Emacs, put it in a file
ed5c18e2
EZ
2101named @file{.emacs} in your home directory. This is known as ``your
2102@file{.emacs} file,'' and contains all of your personal customizations.
71e68827
DL
2103
2104@item
2105You can type the form in the @file{*scratch*} buffer, and then type
2106@key{LFD} (or @kbd{C-j}) after it. The result of evaluating the form
2107will be inserted in the buffer.
2108
2109@item
718fb8a1 2110In @code{emacs-lisp-mode}, typing @kbd{C-M-x} evaluates a top-level form
71e68827
DL
2111before or around point.
2112
2113@item
2114Typing @kbd{C-x C-e} in any buffer evaluates the Lisp form immediately
2115before point and prints its value in the echo area.
2116
2117@item
2118Typing @kbd{M-:} or @kbd{M-x eval-expression} allows you to type a Lisp
ed5c18e2 2119form in the minibuffer which will be evaluated once you press @key{RET}.
71e68827
DL
2120
2121@item
2122You can use @kbd{M-x load-file} to have Emacs evaluate all the Lisp
2123forms in a file. (To do this from Lisp use the function @code{load}
2124instead.)
2125
2126The functions @code{load-library}, @code{eval-region},
2127@code{eval-current-buffer}, @code{require}, and @code{autoload} are also
ed5c18e2
EZ
2128useful; see @ref{Emacs Lisp documentation}, if you want to learn more
2129about them.
71e68827
DL
2130
2131@end itemize
2132
2133@node Changing the length of a Tab, Inserting > at the beginning of each line, Evaluating Emacs Lisp code, Common requests
2134@section How do I change Emacs's idea of the @key{TAB} character's length?
2135@cindex Tab length
2136@cindex Length of tab character
2137@cindex @code{default-tab-width}
2138
2139Set the variable @code{default-tab-width}. For example, to set
2140@key{TAB} stops every 10 characters, insert the following in your
2141@file{.emacs} file:
2142
2143@lisp
2144(setq default-tab-width 10)
2145@end lisp
2146
2147Do not confuse variable @code{tab-width} with variable
2148@code{tab-stop-list}. The former is used for the display of literal
2149@key{TAB} characters. The latter controls what characters are inserted
2150when you press the @key{TAB} character in certain modes.
2151
2152@node Inserting > at the beginning of each line, Underlining paragraphs, Changing the length of a Tab, Common requests
2153@section How do I insert @samp{>} at the beginning of every line?
2154@cindex Prefix character, inserting in mail/news replies
2155@cindex Replies to mail/news, inserting a prefix character
2156@cindex @code{mail-yank-prefix}
2157@cindex Mail replies, inserting a prefix character
2158@cindex News replies, inserting a prefix character
2159
2160To do this to an entire buffer, type @kbd{M-< M-x replace-regexp
2161@key{RET} ^ @key{RET} > @key{RET}}.
2162
1e1e6d52 2163To do this to a region, use @code{string-insert-rectangle}.
71e68827
DL
2164Set the mark (@kbd{C-@key{SPC}}) at the beginning of the first line you
2165want to prefix, move the cursor to last line to be prefixed, and type
1e1e6d52
GM
2166@kbd{M-x string-insert-rectangle @key{RET}}. To do this for the whole
2167buffer, type @kbd{C-x h M-x string-insert-rectangle @key{RET}}.
71e68827
DL
2168
2169If you are trying to prefix a yanked mail message with @samp{>}, you
ed5c18e2 2170might want to set the variable @code{mail-yank-prefix}. Better yet, use
71e68827 2171the Supercite package (@pxref{Supercite}), which provides flexible
ed5c18e2
EZ
2172citation for yanked mail and news messages; it is included in Emacs
2173since version 19.20. @xref{Changing the included text prefix}, for
2174additional information.
71e68827
DL
2175
2176@node Underlining paragraphs, Repeating a command as many times as possible, Inserting > at the beginning of each line, Common requests
2177@section How do I insert "_^H" before each character in a region to get an underlined paragraph?
2178@cindex Underlining a region of text
2179@cindex @code{underline-region}
2180
ed5c18e2 2181Mark the region and then type @kbd{M-x underline-region @key{RET}}.
71e68827
DL
2182
2183@node Repeating a command as many times as possible, Forcing the cursor to remain in the same column, Underlining paragraphs, Common requests
2184@section How do I repeat a command as many times as possible?
ed5c18e2
EZ
2185@cindex Repeating commands many times
2186@cindex Commands, repeating many times
71e68827
DL
2187
2188Use @kbd{C-x (} and @kbd{C-x )} to make a keyboard macro that invokes
2189the command and then type @kbd{M-0 C-x e}.
2190
2191Any messages your command prints in the echo area will be suppressed.
2192
ed5c18e2
EZ
2193If you need to repeat a command a small number of times, you can use
2194@kbd{C-x z}, see @ref{Repeating commands}.
2195
71e68827
DL
2196@node Forcing the cursor to remain in the same column, Forcing Emacs to iconify itself, Repeating a command as many times as possible, Common requests
2197@section How do I make Emacs behave like this: when I go up or down, the cursor should stay in the same column even if the line is too short?
2198@cindex @code{picture-mode}
2199@cindex Remaining in the same column, regardless of contents
2200@cindex Vertical movement in empty documents
2201
2202@kbd{M-x picture-mode}.
2203
2204@node Forcing Emacs to iconify itself, Using regular expressions, Forcing the cursor to remain in the same column, Common requests
2205@section How do I tell Emacs to iconify itself?
97878c08
EZ
2206@cindex Iconification under the X Window System
2207@cindex X Window System and iconification
71e68827
DL
2208@cindex Suspending Emacs
2209
97878c08 2210@kbd{C-z} iconifies Emacs when running under X and suspends Emacs
71e68827
DL
2211otherwise. @inforef{Misc X, Misc X, emacs}.
2212
2213@node Using regular expressions, Replacing text across multiple files, Forcing Emacs to iconify itself, Common requests
2214@section How do I use regexps (regular expressions) in Emacs?
2215@cindex Regexps
2216@cindex Regular expressions
2217@cindex Differences between Unix and Emacs regexps
2218@cindex Unix regeps, differences from Emacs
2219@cindex Text strings, putting regexps in
2220
2221@inforef{Regexps, Regexps, emacs}.
2222
ed5c18e2 2223The @code{or} operator is @samp{\|}, not @samp{|}, and the grouping operators
71e68827
DL
2224are @samp{\(} and @samp{\)}. Also, the string syntax for a backslash is
2225@samp{\\}. To specify a regular expression like @samp{xxx\(foo\|bar\)}
2226in a Lisp string, use @samp{xxx\\(foo\\|bar\\)}.
2227
ed5c18e2 2228Note the doubled backslashes!
71e68827
DL
2229
2230@itemize @bullet
2231
ed5c18e2
EZ
2232@item
2233Unlike in Unix @file{grep}, @file{sed}, etc., a complement character set
2234(@samp{[^...]}) can match a newline character (@key{LFD} a.k.a.@:
2235@kbd{C-j} a.k.a.@: @samp{\n}), unless newline is mentioned as one of the
71e68827
DL
2236characters not to match.
2237
ed5c18e2
EZ
2238@item
2239The character syntax regexps (e.g., @samp{\sw}) are not
71e68827
DL
2240meaningful inside character set regexps (e.g., @samp{[aeiou]}). (This
2241is actually typical for regexp syntax.)
2242
2243@end itemize
2244
2245@node Replacing text across multiple files, Documentation for etags, Using regular expressions, Common requests
2246@section How do I perform a replace operation across more than one file?
2247@cindex Replacing strings across files
2248@cindex Multiple files, replacing across
2249@cindex Files, replacing strings across multiple
2250
ed5c18e2 2251The ``tags'' feature of Emacs includes the command
71e68827 2252@code{tags-query-replace} which performs a query-replace across all the
ed5c18e2 2253files mentioned in the @file{TAGS} file. @inforef{Tags Search, Tags Search,
71e68827
DL
2254emacs}.
2255
2256As of Emacs 19.29, Dired mode (@kbd{M-x dired @key{RET}}, or @kbd{C-x
2257d}) supports the command @code{dired-do-query-replace}, which allows
2258users to replace regular expressions in multiple files.
2259
2260@node Documentation for etags, Disabling backups, Replacing text across multiple files, Common requests
ed5c18e2
EZ
2261@section Where is the documentation for @code{etags}?
2262@cindex Documentation for @code{etags}
2263@cindex @code{etags}, documentation for
71e68827 2264
ed5c18e2
EZ
2265The @code{etags} man page should be in the same place as the
2266@code{emacs} man page.
71e68827
DL
2267
2268Quick command-line switch descriptions are also available. For example,
2269@samp{etags -H}.
2270
2271@node Disabling backups, Disabling auto-save-mode, Documentation for etags, Common requests
2272@section How do I disable backup files?
2273@cindex Backups, disabling
2274@cindex Disabling backups
2275
ed5c18e2
EZ
2276You probably don't want to do this, since backups are useful, especially
2277when something goes wrong.
71e68827
DL
2278
2279To avoid seeing backup files (and other "uninteresting" files) in Dired,
ed5c18e2 2280load @code{dired-x} by adding the following to your @file{.emacs} file:
71e68827
DL
2281
2282@lisp
2283(add-hook 'dired-load-hook
bed44076
SM
2284 (lambda ()
2285 (load "dired-x")))
71e68827
DL
2286@end lisp
2287
ed5c18e2 2288With @code{dired-x} loaded, @kbd{M-o} toggles omitting in each dired buffer.
71e68827
DL
2289You can make omitting the default for new dired buffers by putting the
2290following in your @file{.emacs}:
2291
2292@lisp
90df7433 2293(add-hook 'dired-mode-hook 'dired-omit-toggle)
71e68827
DL
2294@end lisp
2295
ed5c18e2
EZ
2296If you're tired of seeing backup files whenever you do an @samp{ls} at
2297the Unix shell, try GNU @code{ls} with the @samp{-B} option. GNU
2298@code{ls} is part of the GNU Fileutils package, available from
2299@samp{ftp.gnu.org} and its mirrors (@pxref{Current GNU distributions}).
2300
2301To disable or change the way backups are made, @inforef{Backup Names, ,
2302emacs}.
71e68827 2303
ed5c18e2
EZ
2304@cindex Backup files in a single directory
2305Beginning with Emacs 21.1, you can control where Emacs puts backup files
2306by customizing the variable @code{backup-directory-alist}. This
2307variable's value specifies that files whose names match specific patters
2308should have their backups put in certain directories. A typical use is
2309to add the element @code{("." . @var{dir})} to force Emacs to put
2310@strong{all} backup files in the directory @file{dir}.
71e68827 2311
8b3f7f7d 2312@node Disabling auto-save-mode, Going to a line by number, Disabling backups, Common requests
71e68827
DL
2313@section How do I disable @code{auto-save-mode}?
2314@cindex Disabling @code{auto-save-mode}
2315@cindex Auto-saving
2316@cindex Saving at frequent intervals
2317
2318You probably don't want to do this, since auto-saving is useful,
2319especially when Emacs or your computer crashes while you are editing a
2320document.
2321
2322Instead, you might want to change the variable
2323@code{auto-save-interval}, which specifies how many keystrokes Emacs
2324waits before auto-saving. Increasing this value forces Emacs to wait
2325longer between auto-saves, which might annoy you less.
2326
2327You might also want to look into Sebastian Kremer's @code{auto-save}
2328package, available from the Lisp Code Archive (@pxref{Packages that do not come
2329with Emacs}). This
2330package also allows you to place all auto-save files in one directory,
2331such as @file{/tmp}.
2332
ed5c18e2
EZ
2333To disable or change how @code{auto-save-mode} works, @inforef{Auto
2334Save, , emacs}.
71e68827 2335
8b3f7f7d
EZ
2336@node Going to a line by number, Modifying pull-down menus, Disabling auto-save-mode, Common requests
2337@section How can I go to a certain line given its number?
2338@cindex Going to a line by number
2339@cindex Compilation error messages
2340@cindex Recompilation
2341
2342Are you sure you indeed need to go to a line by its number? Perhaps all
2343you want is to display a line in your source file for which a compiler
2344printed an error message? If so, compiling from within Emacs using the
2345@kbd{M-x compile} and @kbd{M-x recompile} commands is a much more
2346effective way of doing that. Emacs automatically intercepts the compile
2347error messages, inserts them into a special buffer called
2348@code{*compilation*}, and lets you visit the locus of each message in
2349the source. Type @kbd{C-x `} to step through the offending lines one by
2350one. Click @kbd{Mouse-2} or press @key{RET} on a message text in the
2351@code{*compilation*} buffer to go to the line whose number is mentioned
2352in that message.
2353
2354But if you indeed need to go to a certain text line, type @kbd{M-x
2355goto-line @key{RET}}. Emacs will prompt you for the number of the line
2356and go to that line.
2357
2358You can do this faster by invoking @code{goto-line} with a numeric
2359argument that is the line's number. For example, @kbd{C-u 286 M-x
2360goto-line @key{RET}} will jump to line number 286 in the current
2361buffer.
2362
2363If you need to use this command frequently, you might consider binding
2364it to a key. The following snippet, if added to your @file{~/.emacs}
2365file, will bind the sequence @kbd{C-x g} to @code{goto-line}:
2366
2367@lisp
2368 (global-set-key "\C-xg" 'goto-line)
2369@end lisp
2370
2371
2372@node Modifying pull-down menus, Deleting menus and menu options, Going to a line by number, Common requests
71e68827
DL
2373@section How can I create or modify new pull-down menu options?
2374@cindex Pull-down menus, creating or modifying
2375@cindex Menus, creating or modifying
2376@cindex Creating new menu options
2377@cindex Modifying pull-down menus
2378@cindex Menus and keymaps
2379@cindex Keymaps and menus
2380
ed5c18e2
EZ
2381Each menu title (e.g., @samp{File}, @samp{Edit}, @samp{Buffers})
2382represents a local or global keymap. Selecting a menu title with the
2383mouse displays that keymap's non-nil contents in the form of a menu.
71e68827
DL
2384
2385So to add a menu option to an existing menu, all you have to do is add a
ed5c18e2
EZ
2386new definition to the appropriate keymap. Adding a @samp{Forward Word}
2387item to the @samp{Edit} menu thus requires the following Lisp code:
71e68827
DL
2388
2389@lisp
2390(define-key global-map
2391 [menu-bar edit forward]
2392 '("Forward word" . forward-word))
2393@end lisp
2394
ed5c18e2 2395@noindent
71e68827
DL
2396The first line adds the entry to the global keymap, which includes
2397global menu bar entries. Replacing the reference to @code{global-map}
2398with a local keymap would add this menu option only within a particular
2399mode.
2400
2401The second line describes the path from the menu-bar to the new entry.
ed5c18e2
EZ
2402Placing this menu entry underneath the @samp{File} menu would mean
2403changing the word @code{edit} in the second line to @code{file}.
71e68827
DL
2404
2405The third line is a cons cell whose first element is the title that will
2406be displayed, and whose second element is the function that will be
2407called when that menu option is invoked.
2408
2409To add a new menu, rather than a new option to an existing menu, we must
2410define an entirely new keymap:
2411
2412@lisp
2413(define-key global-map [menu-bar words]
2414 (cons "Words" (make-sparse-keymap "Words")))
2415@end lisp
2416
ed5c18e2
EZ
2417The above code creates a new sparse keymap, gives it the name
2418@samp{Words}, and attaches it to the global menu bar. Adding the
2419@samp{Forward Word} item to this new menu would thus require the
2420following code:
71e68827
DL
2421
2422@lisp
2423(define-key global-map
2424 [menu-bar words forward]
2425 '("Forward word" . forward-word))
2426@end lisp
2427
ed5c18e2 2428@noindent
71e68827
DL
2429Note that because of the way keymaps work, menu options are displayed
2430with the more recently defined items at the top. Thus if you were to
ed5c18e2
EZ
2431define menu options @samp{foo}, @samp{bar}, and @samp{baz} (in that
2432order), the menu option @samp{baz} would appear at the top, and
2433@samp{foo} would be at the bottom.
71e68827
DL
2434
2435One way to avoid this problem is to use the function @code{define-key-after},
2436which works the same as @code{define-key}, but lets you modify where items
ed5c18e2
EZ
2437appear. The following Lisp code would insert the @samp{Forward Word}
2438item in the @samp{Edit} menu immediately following the @samp{Undo} item:
71e68827
DL
2439
2440@lisp
2441(define-key-after
2442 (lookup-key global-map [menu-bar edit])
2443 [forward]
2444 '("Forward word" . forward-word)
2445 'undo)
2446@end lisp
2447
2448Note how the second and third arguments to @code{define-key-after} are
2449different from those of @code{define-key}, and that we have added a new
2450(final) argument, the function after which our new key should be
2451defined.
2452
2453To move a menu option from one position to another, simply evaluate
2454@code{define-key-after} with the appropriate final argument.
2455
ed5c18e2
EZ
2456More detailed information---and more examples of how to create and
2457modify menu options---are in the @cite{Emacs Lisp Reference Manual}, under
ed438271
EZ
2458``Menu Keymaps''. (@xref{Emacs Lisp documentation}, for information on
2459this manual.)
71e68827
DL
2460
2461@node Deleting menus and menu options, Turning on syntax highlighting, Modifying pull-down menus, Common requests
2462@section How do I delete menus and menu options?
2463@cindex Deleting menus and menu options
2464@cindex Menus, deleting
2465
2466The simplest way to remove a menu is to set its keymap to @samp{nil}.
ed5c18e2 2467For example, to delete the @samp{Words} menu (@pxref{Modifying pull-down
71e68827
DL
2468menus}), use:
2469
2470@lisp
2471(define-key global-map [menu-bar words] nil)
2472@end lisp
2473
2474Similarly, removing a menu option requires redefining a keymap entry to
ed5c18e2
EZ
2475@code{nil}. For example, to delete the @samp{Forward word} menu option
2476from the @samp{Edit} menu (we added it in @ref{Modifying pull-down
2477menus}), use:
71e68827
DL
2478
2479@lisp
2480(define-key global-map [menu-bar edit forward] nil)
2481@end lisp
2482
2483@node Turning on syntax highlighting, Scrolling only one line, Deleting menus and menu options, Common requests
2484@section How do I turn on syntax highlighting?
2485@cindex Syntax highlighting
2486@cindex @code{font-lock-mode}
2487@cindex Highlighting based on syntax
2488@cindex Colorizing text
2489@cindex FAQ, @code{font-lock-mode}
2490
2491@code{font-lock-mode} is the standard way to have Emacs perform syntax
ed5c18e2
EZ
2492highlighting in the current buffer. With @code{font-lock-mode} turned
2493on, different types of text will appear in different colors. For
2494instance, if you turn on @code{font-lock-mode} in a programming mode,
2495variables will appear in one face, keywords in a second, and comments in
2496a third.
71e68827 2497
ed5c18e2 2498@cindex hilit19 is deprecated
71e68827
DL
2499Earlier versions of Emacs supported hilit19, a similar package. Use of
2500hilit19 is now considered non-standard, although @file{hilit19.el} comes
2501with the stock Emacs distribution. It is no longer maintained.
2502
2503To turn @code{font-lock-mode} on within an existing buffer, use @kbd{M-x
2504font-lock-mode @key{RET}}.
2505
2506To automatically invoke @code{font-lock-mode} when a particular major
2507mode is invoked, set the major mode's hook. For example, to fontify all
2508@code{c-mode} buffers, add the following to your @file{.emacs} file:
2509
2510@lisp
2511(add-hook 'c-mode-hook 'turn-on-font-lock)
2512@end lisp
2513
2514To automatically invoke @code{font-lock-mode} for all major modes, you
2515can turn on @code{global-font-lock-mode} by including the following line
2516in your @file{.emacs} file:
2517
2518@lisp
2519(global-font-lock-mode 1)
2520@end lisp
2521
ed5c18e2 2522@noindent
71e68827
DL
2523This instructs Emacs to turn on font-lock mode in those buffers for
2524which a font-lock mode definition has been provided (in the variable
2525@code{font-lock-global-modes}). If you edit a file in
2526@code{pie-ala-mode}, and no font-lock definitions have been provided for
2527@code{pie-ala} files, then the above setting will have no effect on that
2528particular buffer.
2529
ed5c18e2
EZ
2530Highlighting a buffer with @code{font-lock-mode} can take quite a while,
2531and cause an annoying delay in display, so several features exist to
2532work around this.
2533
2534@cindex Just-In-Time syntax highlighting
2535In Emacs 21 and later, turning on @code{font-lock-mode} automatically
2536activates the new @dfn{Just-In-Time fontification} provided by
2537@code{jit-lock-mode}. @code{jit-lock-mode} defers the fontification of
2538portions of buffer until you actually need to see them, and can also
2539fontify while Emacs is idle. This makes display of the visible portion
2540of a buffer almost instantaneous. For details about customizing
2541@code{jit-lock-mode}, type @kbd{C-h f jit-lock-mode @key{RET}}.
2542
2543@cindex Levels of syntax highlighting
2544@cindex Decoration level, in @code{font-lock-mode}
2545In versions of Emacs before 21, different levels of decoration are
2546available, from slight to gaudy. More decoration means you need to wait
2547more time for a buffer to be fontified (or a faster machine). To
71e68827
DL
2548control how decorated your buffers should become, set the value of
2549@code{font-lock-maximum-decoration} in your @file{.emacs} file, with a
2550@code{nil} value indicating default (usually minimum) decoration, and a
2551@code{t} value indicating the maximum decoration. For the gaudiest
2552possible look, then, include the line
2553
2554@lisp
2555(setq font-lock-maximum-decoration t)
2556@end lisp
2557
ed5c18e2 2558@noindent
71e68827
DL
2559in your @file{.emacs} file. You can also set this variable such that
2560different modes are highlighted in a different ways; for more
2561information, see the documentation for
2562@code{font-lock-maximum-decoration} with @kbd{C-h v} (or @kbd{M-x
2563describe-variable @key{RET}}).
2564
ed5c18e2 2565@cindex Lazy font-lock
71e68827
DL
2566You might also want to investigate @code{fast-lock-mode} and
2567@code{lazy-lock-mode}, versions of @code{font-lock-mode} that speed up
ed5c18e2
EZ
2568highlighting. These are the alternatives for @code{jit-lock-mode} in
2569versions of Emacs before 21.1. The advantage of @code{lazy-lock-mode}
2570is that it only fontifies buffers when certain conditions are met, such
2571as after a certain amount of idle time, or after you have finished
2572scrolling through text. See the documentation for @code{lazy-lock-mode}
2573by typing @kbd{C-h f @code{lazy-lock-mode}} (@kbd{M-x describe-function
2574@key{RET} lazy-lock-mode @key{RET}}).
71e68827
DL
2575
2576Also see the documentation for the function @code{font-lock-mode},
2577available by typing @kbd{C-h f font-lock-mode} (@kbd{M-x
2578describe-function @key{RET} font-lock-mode @key{RET}}).
2579
2580For more information on font-lock mode, take a look at the
2581@code{font-lock-mode} FAQ, maintained by
2582@email{jari.aalto@@ntc.nokia.com, Jari Aalto} at
2583
2584@uref{ftp://cs.uta.fi/pub/ssjaaa/ema-font.gui}
2585
2586To print buffers with the faces (i.e., colors and fonts) intact, use
2587@kbd{M-x ps-print-buffer-with-faces} or @kbd{M-x
ed5c18e2
EZ
2588ps-print-region-with-faces}. You will need a way to send text to a
2589PostScript printer, or a PostScript interpreter such as Ghostscript;
2590consult the documentation of the variables @code{ps-printer-name},
2591@code{ps-lpr-command}, and @code{ps-lpr-switches} for more details.
71e68827
DL
2592
2593@node Scrolling only one line, Replacing highlighted text, Turning on syntax highlighting, Common requests
2594@section How can I force Emacs to scroll only one line when I move past the bottom of the screen?
2595@cindex Scrolling only one line
2596@cindex Reducing the increment when scrollng
2597
2598Place the following Lisp form in your @file{.emacs} file:
2599
2600@lisp
2601(setq scroll-step 1)
2602@end lisp
2603
2604@inforef{Scrolling, Scrolling, emacs}.
2605
2606@node Replacing highlighted text, Editing MS-DOS files, Scrolling only one line, Common requests
2607@section How can I replace highlighted text with what I type?
2608@cindex @code{delete-selection-mode}
2609@cindex Replacing highlighted text
2610@cindex Highlighing and replacing text
2611
ed5c18e2 2612Use @code{delete-selection-mode}, which you can start automatically by
71e68827
DL
2613placing the following Lisp form in your @file{.emacs} file:
2614
2615@lisp
2616(delete-selection-mode t)
2617@end lisp
2618
ed5c18e2
EZ
2619According to the documentation string for @code{delete-selection-mode}
2620(which you can read using @kbd{M-x describe-function @key{RET}
71e68827
DL
2621delete-selection-mode @key{RET}}):
2622
2623@quotation
2624When ON, typed text replaces the selection if the selection is active.
2625When OFF, typed text is just inserted at point.
2626@end quotation
2627
2628This mode also allows you to delete (not kill) the highlighted region by
2629pressing @key{DEL}.
2630
2631@node Editing MS-DOS files, Filling paragraphs with a single space, Replacing highlighted text, Common requests
2632@section How can I edit MS-DOS files using Emacs?
2633@cindex Editing MS-DOS files
2634@cindex MS-DOS files, editing
2635@cindex Microsoft files, editing
2636@cindex Windows files, editing
2637
2638As of Emacs 20, detection and handling of MS-DOS (and Windows) files is
ed5c18e2 2639performed transparently. You can open MS-DOS files on a Unix system,
71e68827
DL
2640edit it, and save it without having to worry about the file format.
2641
ed5c18e2
EZ
2642When editing an MS-DOS style file, the mode line will indicate that it
2643is a DOS file. On Unix and GNU/Linux systems, and also on a Macintosh,
2644the string @samp{(DOS)} will appear near the left edge of the mode line;
2645on DOS and Windows, where the DOS end-of-line (EOL) format is the
2646default, a backslash (@samp{\}) will appear in the mode line.
71e68827 2647
ed5c18e2
EZ
2648If you are running a version of Emacs before 20.1, get @code{crypt++}
2649from the Emacs Lisp Archive (@pxref{Packages that do not come with
2650Emacs}). Among other things, @code{crypt++} transparently modifies
2651MS-DOS files as they are loaded and saved, allowing you to ignore the
2652different conventions that Unix and MS-DOS have for delineating the end
2653of a line.
71e68827 2654
a5ffa690 2655@node Filling paragraphs with a single space, Escape sequences in shell output, Editing MS-DOS files, Common requests
71e68827
DL
2656@section How can I tell Emacs to fill paragraphs with a single space after each period?
2657@cindex One space following periods
2658@cindex Single space following periods
2659@cindex Periods, one space following
2660
2661@email{ulm@@vsnhd1.cern.ch, Ulrich Mueller} suggests adding the
2662following two lines to your @file{.emacs} file:
2663
2664@lisp
2665(setq sentence-end "[.?!][]\"')@}]*\\($\\|[ \t]\\)[ \t\n]*")
2666(setq sentence-end-double-space nil)
2667@end lisp
2668
a5ffa690
EZ
2669@node Escape sequences in shell output, , Filling paragraphs with a single space, Common requests
2670@section Why do I get these strange escape sequences when I run
2671@code{ls} from the Shell mode?
2672@cindex Escape sequences in @code{ls} output
2673@cindex @code{ls} in Shell mode
2674
2675This happens because @code{ls} is aliased to @samp{ls --color} in your
2676shell init file. You have two alternatives to solve this:
2677
2678@itemize @bullet
2679@item
2680Make the alias conditioned on the @code{EMACS} variable in the
2681environment. When Emacs runs a subsidiary shell, it exports the
2682@code{EMACS} variable with the value @code{t} to that shell. You can
2683unalias @code{ls} when that happens, thus limiting the alias to your
2684interactive sessions.
2685
2686@item
2687Install the @code{ansi-color} package (bundled with Emacs 21.1 and
2688later), which converts these ANSI escape sequences into colors.
2689@end itemize
2690
71e68827
DL
2691@c ------------------------------------------------------------
2692@node Bugs and problems, Compiling and installing Emacs, Common requests, Top
2693@chapter Bugs and problems
2694@cindex Bugs and problems
2695
6576d908
EZ
2696The Emacs manual lists some common kinds of trouble users could get
2697into, see @ref{Lossage, , Dealing with Emacs Trouble, emacs, The GNU
2698Emacs Manual}, so you might look there if the problem you encounter
6281f965
EZ
2699isn't described in this chapter. If you decide you've discovered a bug,
2700see @ref{Bugs, , Reporting Bugs, emacs, The GNU Emacs Manual}, for
6576d908
EZ
2701instructions how to do that.
2702
2703The file @file{etc/PROBLEMS} in the Emacs distribution lists various
6281f965
EZ
2704known problems with building and using Emacs on specific platforms;
2705type @kbd{C-h P} to read it.
6576d908 2706
71e68827
DL
2707@menu
2708* Problems with very large files::
2709* ^M in the shell buffer::
2710* Shell process exits abnormally::
d891bf01 2711* Problems with Shell Mode on MS-Windows::
71e68827
DL
2712* Termcap/Terminfo entries for Emacs::
2713* Spontaneous entry into isearch-mode::
2714* Problems talking to certain hosts::
2715* Errors with init files::
2716* Emacs ignores X resources::
8b3f7f7d 2717* Emacs ignores frame parameters::
71e68827
DL
2718* Emacs takes a long time to visit files::
2719* Editing files with $ in the name::
2720* Shell mode loses the current directory::
2721* Security risks with Emacs::
2722* Dired claims that no file is on this line::
2723@end menu
2724
2725@node Problems with very large files, ^M in the shell buffer, Bugs and problems, Bugs and problems
2726@section Does Emacs have problems with files larger than 8 megabytes?
2727@cindex Very large files, opening
2728@cindex Large files, opening
2729@cindex Opening very large files
2730@cindex Maximum file size
2731@cindex Files, maximum size
2732
2733Old versions (i.e., anything before 19.29) of Emacs had problems editing
2734files larger than 8 megabytes. As of version 19.29, the maximum buffer
ed5c18e2
EZ
2735size is at least 2^27-1, or 134,217,727 bytes, or 132 MBytes. Emacs 20
2736can be compiled on some 64-bit systems in a way that enlarges the buffer
2737size up to 576,460,752,303,423,487 bytes, or 549,755,813 GBytes.
71e68827 2738
ed5c18e2
EZ
2739If you are using a version of Emacs older than 19.29 and cannot upgrade,
2740you will have to recompile. @email{lnz@@lucid.com, Leonard N. Zubkoff}
2741suggests putting the following two lines in @file{src/config.h} before
2742compiling Emacs to allow for 26-bit integers and pointers (and thus file
2743sizes of up to 33,554,431 bytes):
71e68827
DL
2744
2745@example
2746#define VALBITS 26
2747#define GCTYPEBITS 5
2748@end example
2749
ed5c18e2 2750@noindent
71e68827
DL
2751This method may result in "ILLEGAL DATATYPE" and other random errors on
2752some machines.
2753
2754@email{daveg@@csvax.cs.caltech.edu, David Gillespie} explains how this
2755problems crops up; while his numbers are true only for pre-19.29
2756versions of Emacs, the theory remains the same with current versions.
2757
2758@quotation
2759Emacs is largely written in a dialect of Lisp; Lisp is a freely-typed
2760language in the sense that you can put any value of any type into any
2761variable, or return it from a function, and so on. So each value
ed5c18e2
EZ
2762must carry a @dfn{tag} along with it identifying what kind of thing it
2763is, e.g., integer, pointer to a list, pointer to an editing buffer, and
2764so on. Emacs uses standard 32-bit integers for data objects, taking the
71e68827
DL
2765top 8 bits for the tag and the bottom 24 bits for the value. So
2766integers (and pointers) are somewhat restricted compared to true C
2767integers and pointers.
2768@end quotation
2769
2770@node ^M in the shell buffer, Shell process exits abnormally, Problems with very large files, Bugs and problems
2771@section How do I get rid of @samp{^M} or echoed commands in my shell buffer?
2772@cindex Shell buffer, echoed commands and @samp{^M} in
2773@cindex Echoed commands in @code{shell-mode}
2774
2775Try typing @kbd{M-x shell-strip-ctrl-m @key{RET}} while in @code{shell-mode} to
2776make them go away. If that doesn't work, you have several options:
2777
ed5c18e2
EZ
2778For @code{tcsh}, put this in your @file{.cshrc} (or @file{.tcshrc})
2779file:
71e68827
DL
2780
2781@example
2782if ($?EMACS) then
2783 if ("$EMACS" == t) then
2784 if ($?tcsh) unset edit
2785 stty nl
2786 endif
2787endif
2788@end example
2789
2790Or put this in your @file{.emacs_tcsh} file:
2791
2792@example
2793unset edit
2794stty nl
2795@end example
2796
ed5c18e2
EZ
2797Alternatively, use @code{csh} in your shell buffers instead of
2798@code{tcsh}. One way is:
71e68827
DL
2799
2800@lisp
2801(setq explicit-shell-file-name "/bin/csh")
2802@end lisp
2803
ed5c18e2 2804@noindent
71e68827
DL
2805and another is to do this in your @file{.cshrc} (or @file{.tcshrc})
2806file:
2807
2808@example
2809setenv ESHELL /bin/csh
2810@end example
2811
ed5c18e2 2812@noindent
71e68827
DL
2813(You must start Emacs over again with the environment variable properly
2814set for this to take effect.)
2815
2816You can also set the @code{ESHELL} environment variable in Emacs Lisp
2817with the following Lisp form,
2818
2819@lisp
2820(setenv "ESHELL" "/bin/csh")
2821@end lisp
2822
d891bf01
EZ
2823The above solutions try to prevent the shell from producing the
2824@samp{^M} characters in the first place. If this is not possible
2825(e.g., if you use a Windows shell), you can get Emacs to remove these
2826characters from the buffer by adding this to your @file{.emacs} init
2827file:
2828
2829@smalllisp
2830(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m)
2831@end smalllisp
2832
71e68827
DL
2833On a related note: If your shell is echoing your input line in the shell
2834buffer, you might want to try the following command in your shell
2835start-up file:
2836
2837@example
2838stty -icrnl -onlcr -echo susp ^Z
2839@end example
2840
d891bf01 2841@node Shell process exits abnormally, Problems with Shell Mode on MS-Windows, ^M in the shell buffer, Bugs and problems
71e68827
DL
2842@section Why do I get "Process shell exited abnormally with code 1"?
2843@cindex Abnormal exits from @code{shell-mode}
2844@cindex @code{shell-mode} exits
ed5c18e2 2845@cindex Process shell exited
71e68827
DL
2846
2847The most likely reason for this message is that the @samp{env} program
2848is not properly installed. Compile this program for your architecture,
2849and install it with @samp{a+x} permission in the architecture-dependent
2850Emacs program directory. (You can find what this directory is at your
2851site by inspecting the value of the variable @code{exec-directory} by
2852typing @kbd{C-h v exec-directory @key{RET}}.)
2853
2854You should also check for other programs named @samp{env} in your path
2855(e.g., SunOS has a program named @file{/usr/bin/env}). We don't
2856understand why this can cause a failure and don't know a general
2857solution for working around the problem in this case.
2858
2859The @samp{make clean} command will remove @samp{env} and other vital
2860programs, so be careful when using it.
2861
2862It has been reported that this sometimes happened when Emacs was started
2863as an X client from an xterm window (i.e., had a controlling tty) but the
2864xterm was later terminated.
2865
d891bf01
EZ
2866See also @samp{PROBLEMS} (in the @file{etc} subdirectory of the
2867top-level directory when you unpack the Emacs source) for other
2868possible causes of this message.
2869
2870@node Problems with Shell Mode on MS-Windows, Termcap/Terminfo entries for Emacs, Shell process exits abnormally, Bugs and problems
2871@section Why do I get an error message when I try to run @kbd{M-x shell}?
2872
2873@cindex Shell Mode, and MS-Windows
2874@cindex @code{explicit-shell-file-name}
2875On MS-Windows, this might happen because Emacs tries to look for the
2876shell in a wrong place. The default file name @file{/bin/sh} is
2877usually incorrect for non-Unix systems. If you know where your shell
2878executable is, set the variable @code{explicit-shell-file-name} in
2879your @file{.emacs} file to point to its full file name, like this:
2880
2881@lisp
2882(setq explicit-shell-file-name "d:/shells/bash.exe")
2883@end lisp
71e68827 2884
d891bf01
EZ
2885If you don't know what shell does Emacs use, try the @kbd{M-!}
2886command; if that works, put the following line into your
2887@file{.emacs}:
2888
2889@lisp
2890(setq explicit-shell-file-name shell-file-name)
2891@end lisp
2892
2893@cindex Antivirus programs, and Shell Mode
2894Some people have trouble with Shell Mode because of intrusive
2895antivirus software; disabling the resident antivirus program solves
2896the problems in those cases.
2897
2898@node Termcap/Terminfo entries for Emacs, Spontaneous entry into isearch-mode, Problems with Shell Mode on MS-Windows, Bugs and problems
71e68827
DL
2899@section Where is the termcap/terminfo entry for terminal type "emacs"?
2900@cindex Termcap
2901@cindex Terminfo
2902@cindex Emacs entries for termcap/terminfo
2903
2904The termcap entry for terminal type @samp{emacs} is ordinarily put in
2905the @samp{TERMCAP} environment variable of subshells. It may help in
2906certain situations (e.g., using rlogin from shell buffer) to add an
2907entry for @samp{emacs} to the system-wide termcap file. Here is a
2908correct termcap entry for @samp{emacs}:
2909
2910@example
2911emacs:tc=unknown:
2912@end example
2913
ed5c18e2
EZ
2914To make a terminfo entry for @samp{emacs}, use @code{tic} or
2915@code{captoinfo}. You need to generate
2916@file{/usr/lib/terminfo/e/emacs}. It may work to simply copy
2917@file{/usr/lib/terminfo/d/dumb} to @file{/usr/lib/terminfo/e/emacs}.
71e68827
DL
2918
2919Having a termcap/terminfo entry will not enable the use of full screen
2920programs in shell buffers. Use @kbd{M-x terminal-emulator} for that
2921instead.
2922
2923A workaround to the problem of missing termcap/terminfo entries is to
ed5c18e2
EZ
2924change terminal type @samp{emacs} to type @samp{dumb} or @samp{unknown}
2925in your shell start up file. @code{csh} users could put this in their
2926@file{.cshrc} files:
71e68827
DL
2927
2928@example
2929if ("$term" == emacs) set term=dumb
2930@end example
2931
2932@node Spontaneous entry into isearch-mode, Problems talking to certain hosts, Termcap/Terminfo entries for Emacs, Bugs and problems
2933@section Why does Emacs spontaneously start displaying "I-search:" and beeping?
2934@cindex Spontaneous entry into isearch-mode
2935@cindex isearch-mode, spontaneous entry into
2936@cindex Beeping without obvious reason
2937
2938Your terminal (or something between your terminal and the computer) is
2939sending @kbd{C-s} and @kbd{C-q} for flow control, and Emacs is receiving
2940these characters and interpreting them as commands. (The @kbd{C-s}
2941character normally invokes the @code{isearch-forward} command.) For
ed5c18e2 2942possible solutions, see @ref{Handling C-s and C-q with flow control}.
71e68827
DL
2943
2944@node Problems talking to certain hosts, Errors with init files, Spontaneous entry into isearch-mode, Bugs and problems
2945@section Why can't Emacs talk to certain hosts (or certain hostnames)?
2946@cindex Hosts, Emacs cannot talk to
2947@cindex @code{gethostbyname}, problematic version
2948
2949The problem may be that Emacs is linked with a wimpier version of
2950@code{gethostbyname} than the rest of the programs on the machine. This
ed5c18e2
EZ
2951is often manifested as a message on startup of ``X server not responding.
2952Check your @samp{DISPLAY} environment variable.'' or a message of
2953``Unknown host'' from @code{open-network-stream}.
71e68827
DL
2954
2955On a Sun, this may be because Emacs had to be linked with the static C
2956library. The version of @code{gethostbyname} in the static C library
2957may only look in @file{/etc/hosts} and the NIS (YP) maps, while the
2958version in the dynamic C library may be smart enough to check DNS in
2959addition to or instead of NIS. On a Motorola Delta running System V
2960R3.6, the version of @code{gethostbyname} in the standard library works,
2961but the one that works with NIS doesn't (the one you get with -linet).
2962Other operating systems have similar problems.
2963
2964Try these options:
2965
2966@itemize @bullet
2967
2968@item
2969Explicitly add the host you want to communicate with to @file{/etc/hosts}.
2970
2971@item
2972Relink Emacs with this line in @file{src/config.h}:
2973
2974@example
2975#define LIBS_SYSTEM -lresolv
2976@end example
2977
2978@item
2979Replace @code{gethostbyname} and friends in @file{libc.a} with more
2980useful versions such as the ones in @file{libresolv.a}. Then relink
2981Emacs.
2982
2983@item
ed5c18e2
EZ
2984If you are actually running NIS, make sure that @code{ypbind} is
2985properly told to do DNS lookups with the correct command line switch.
71e68827
DL
2986
2987@end itemize
2988
2989@node Errors with init files, Emacs ignores X resources, Problems talking to certain hosts, Bugs and problems
2990@section Why does Emacs say "Error in init file"?
2991@cindex Error in @file{.emacs}
2992@cindex Error in init file
2993@cindex Init file, errors in
2994@cindex @file{.emacs} file, errors in
2995@cindex Debugging @file{.emacs} file
2996
2997An error occurred while loading either your @file{.emacs} file or the
ed5c18e2
EZ
2998system-wide file @file{lisp/default.el}. Emacs 21.1 and later pops the
2999@file{*Messages*} buffer, and puts there some additional information
3000about the error, to provide some hints for debugging.
71e68827 3001
ed5c18e2
EZ
3002For information on how to debug your @file{.emacs} file, see
3003@ref{Debugging a customization file}.
71e68827
DL
3004
3005It may be the case that you need to load some package first, or use a
3006hook that will be evaluated after the package is loaded. A common case
3007of this is explained in @ref{Terminal setup code works after Emacs has
3008begun}.
3009
8b3f7f7d 3010@node Emacs ignores X resources, Emacs ignores frame parameters, Errors with init files, Bugs and problems
71e68827
DL
3011@section Why does Emacs ignore my X resources (my .Xdefaults file)?
3012@cindex X resources being ignored
3013@cindex Ignored X resources
3014@cindex @file{.Xdefaults}
3015
3016As of version 19, Emacs searches for X resources in the files specified
3017by the following environment variables:
3018
3019@itemize @bullet
3020
3021@item @code{XFILESEARCHPATH}
3022@item @code{XUSERFILESEARCHPATH}
3023@item @code{XAPPLRESDIR}
3024
3025@end itemize
3026
ed5c18e2
EZ
3027This emulates the functionality provided by programs written using the
3028Xt toolkit.
71e68827
DL
3029
3030@code{XFILESEARCHPATH} and @code{XUSERFILESEARCHPATH} should be a list
3031of file names separated by colons. @code{XAPPLRESDIR} should be a list
3032of directory names separated by colons.
3033
3034Emacs searches for X resources:
3035
3036@enumerate
3037
ed5c18e2
EZ
3038@item
3039specified on the command line, with the @samp{-xrm RESOURCESTRING} option,
3040
3041@item
3042then in the value of the @samp{XENVIRONMENT} environment variable,
71e68827
DL
3043
3044@itemize @minus
3045
ed5c18e2
EZ
3046@item
3047or if that is unset, in the file named
3048@file{~/.Xdefaults-@var{hostname}} if it exists (where @var{hostname} is
3049the name of the machine Emacs is running on),
71e68827
DL
3050
3051@end itemize
3052
ed5c18e2
EZ
3053@item
3054then in the screen-specific and server-wide resource properties provided
3055by the server,
71e68827
DL
3056
3057@itemize @minus
3058
ed5c18e2
EZ
3059@item
3060or if those properties are unset, in the file named @file{~/.Xdefaults}
3061if it exists,
71e68827
DL
3062
3063@end itemize
3064
ed5c18e2
EZ
3065@item
3066then in the files listed in @samp{XUSERFILESEARCHPATH},
71e68827
DL
3067
3068@itemize @minus
3069
ed5c18e2
EZ
3070@item
3071or in files named @file{@var{lang}/Emacs} in directories listed in
3072@samp{XAPPLRESDIR} (where @var{lang} is the value of the @code{LANG}
3073environment variable), if the @samp{LANG} environment variable is set,
3074@item
3075or in files named Emacs in the directories listed in @samp{XAPPLRESDIR}
3076@item
3077or in @file{~/@var{lang}/Emacs} (if the @code{LANG} environment variable
3078is set),
3079@item
3080or in @file{~/Emacs},
71e68827
DL
3081
3082@end itemize
3083
ed5c18e2
EZ
3084@item
3085then in the files listed in @code{XFILESEARCHPATH}.
71e68827
DL
3086
3087@end enumerate
3088
8b3f7f7d
EZ
3089@node Emacs ignores frame parameters, Emacs takes a long time to visit files, Emacs ignores X resources, Bugs and problems
3090@section Why don't my customizations of the frame parameters work?
3091@cindex Frame parameters
3092
3093This probably happens because you have set the frame parameters in the
3094variable @code{initial-frame-alist}. That variable holds parameters
3095used only for the first frame created when Emacs starts. To customize
3096the parameters of all frames, change the variable
3097@code{default-frame-alist} instead.
3098
3099These two variables exist because many users customize the initial frame
3100in a special way. For example, you could determine the position and
3101size of the initial frame, but would like to control the geometry of the
3102other frames by individually positioning each one of them.
3103
3104
3105@node Emacs takes a long time to visit files, Editing files with $ in the name, Emacs ignores frame parameters, Bugs and problems
71e68827
DL
3106@section Why does Emacs take 20 seconds to visit a file?
3107@cindex Visiting files takes a long time
3108@cindex Delay when visiting files
3109@cindex Files, take a long time to visit
3110
3111Old versions of Emacs (i.e., versions before Emacs 20.x) often
ed5c18e2 3112encountered this when the master lock file, @file{!!!SuperLock!!!}, has
71e68827
DL
3113been left in the lock directory somehow. Delete it.
3114
3115@email{meuer@@geom.umn.edu, Mark Meuer} says that NeXT NFS has a bug
3116where an exclusive create succeeds but returns an error status. This
3117can cause the same problem. Since Emacs's file locking doesn't work
3118over NFS anyway, the best solution is to recompile Emacs with
3119@code{CLASH_DETECTION} undefined.
3120
3121@node Editing files with $ in the name, Shell mode loses the current directory, Emacs takes a long time to visit files, Bugs and problems
3122@section How do I edit a file with a @samp{$} in its name?
3123@cindex Editing files with @samp{$} in the name
f8635375
EZ
3124@cindex @samp{$} in file names
3125@cindex File names containing @samp{$}, editing
71e68827 3126
f8635375 3127When entering a file name in the minibuffer, Emacs will attempt to expand
71e68827
DL
3128a @samp{$} followed by a word as an environment variable. To suppress
3129this behavior, type @kbd{$$} instead.
3130
3131@node Shell mode loses the current directory, Security risks with Emacs, Editing files with $ in the name, Bugs and problems
3132@section Why does shell mode lose track of the shell's current directory?
3133@cindex Current directory and @code{shell-mode}
3134@cindex @code{shell-mode} and current directory
3135@cindex Directory, current in @code{shell-mode}
3136
3137Emacs has no way of knowing when the shell actually changes its
3138directory. This is an intrinsic limitation of Unix. So it tries to
ed5c18e2
EZ
3139guess by recognizing @samp{cd} commands. If you type @kbd{cd} followed
3140by a directory name with a variable reference (@kbd{cd $HOME/bin}) or
3141with a shell metacharacter (@kbd{cd ../lib*}), Emacs will fail to
3142correctly guess the shell's new current directory. A huge variety of
3143fixes and enhancements to shell mode for this problem have been written
3144to handle this problem. Check the Lisp Code Directory (@pxref{Finding a
3145package with particular functionality}).
71e68827
DL
3146
3147You can tell Emacs the shell's current directory with the command
3148@kbd{M-x dirs}.
3149
3150@node Security risks with Emacs, Dired claims that no file is on this line, Shell mode loses the current directory, Bugs and problems
3151@section Are there any security risks in Emacs?
3152@cindex Security with Emacs
3153@cindex @samp{movemail} and security
3154@cindex @code{file-local-variable} and security
3155@cindex Synthetic X events and security
3156@cindex X events and security
3157
3158@itemize @bullet
3159
ed5c18e2
EZ
3160@item
3161The @file{movemail} incident. (No, this is not a risk.)
71e68827 3162
ed5c18e2
EZ
3163In his book @cite{The Cuckoo's Egg}, Cliff Stoll describes this in
3164chapter 4. The site at LBL had installed the @file{/etc/movemail}
71e68827
DL
3165program setuid root. (As of version 19, @file{movemail} is in your
3166architecture-specific directory; type @kbd{C-h v exec-directory
ed5c18e2 3167@key{RET}} to see what it is.) Since @code{movemail} had not been
71e68827
DL
3168designed for this situation, a security hole was created and users could
3169get root privileges.
3170
ed5c18e2 3171@code{movemail} has since been changed so that this security hole will
71e68827 3172not exist, even if it is installed setuid root. However,
ed5c18e2 3173@code{movemail} no longer needs to be installed setuid root, which
71e68827
DL
3174should eliminate this particular risk.
3175
3176We have heard unverified reports that the 1988 Internet worm took
3177advantage of this configuration problem.
3178
ed5c18e2
EZ
3179@item
3180The @code{file-local-variable} feature. (Yes, a risk, but easy to
3181change.)
71e68827
DL
3182
3183There is an Emacs feature that allows the setting of local values for
3184variables when editing a file by including specially formatted text near
3185the end of the file. This feature also includes the ability to have
3186arbitrary Emacs Lisp code evaluated when the file is visited.
3187Obviously, there is a potential for Trojan horses to exploit this
3188feature.
3189
3190Emacs 18 allowed this feature by default; users could disable it by
3191setting the variable @code{inhibit-local-variables} to a non-nil value.
3192
3193As of Emacs 19, Emacs has a list of local variables that create a
3194security risk. If a file tries to set one of them, it asks the user to
3195confirm whether the variables should be set. You can also tell Emacs
3196whether to allow the evaluation of Emacs Lisp code found at the bottom
3197of files by setting the variable @code{enable-local-eval}.
3198
3199For more information, @inforef{File Variables, File Variables, emacs}.
3200
ed5c18e2
EZ
3201@item
3202Synthetic X events. (Yes, a risk; use @samp{MIT-MAGIC-COOKIE-1} or
3203better.)
71e68827 3204
ed5c18e2
EZ
3205Emacs accepts synthetic X events generated by the @code{SendEvent}
3206request as though they were regular events. As a result, if you are
3207using the trivial host-based authentication, other users who can open X
71e68827
DL
3208connections to your X workstation can make your Emacs process do
3209anything, including run other processes with your privileges.
3210
3211The only fix for this is to prevent other users from being able to open
3212X connections. The standard way to prevent this is to use a real
3213authentication mechanism, such as @samp{MIT-MAGIC-COOKIE-1}. If using
ed5c18e2 3214the @code{xauth} program has any effect, then you are probably using
71e68827
DL
3215@samp{MIT-MAGIC-COOKIE-1}. Your site may be using a superior
3216authentication method; ask your system administrator.
3217
3218If real authentication is not a possibility, you may be satisfied by
3219just allowing hosts access for brief intervals while you start your X
3220programs, then removing the access. This reduces the risk somewhat by
3221narrowing the time window when hostile users would have access, but
3222@emph{does not eliminate the risk}.
3223
97878c08 3224On most computers running Unix and X, you enable and disable
ed5c18e2 3225access using the @code{xhost} command. To allow all hosts access to
71e68827
DL
3226your X server, use
3227
3228@example
3229xhost +
3230@end example
3231
ed5c18e2 3232@noindent
71e68827
DL
3233at the shell prompt, which (on an HP machine, at least) produces the
3234following message:
3235
3236@example
3237access control disabled, clients can connect from any host
3238@end example
3239
3240To deny all hosts access to your X server (except those explicitly
3241allowed by name), use
3242
3243@example
3244xhost -
3245@end example
3246
3247On the test HP computer, this command generated the following message:
3248
3249@example
3250access control enabled, only authorized clients can connect
3251@end example
3252
3253@end itemize
3254
3255@node Dired claims that no file is on this line, , Security risks with Emacs, Bugs and problems
3256@section Dired says, "no file on this line" when I try to do something.
3257@cindex Dired does not see a file
3258
ed5c18e2
EZ
3259@c FIXME: I think this is fixed in Emacs 21, but I didn't have time to
3260@c check.
71e68827
DL
3261Chances are you're using a localized version of Unix that doesn't use US
3262date format in dired listings. You can check this by looking at dired
ed5c18e2 3263listings or by typing @kbd{ls -l} to a shell and looking at the dates that
71e68827
DL
3264come out.
3265
3266Dired uses a regular expression to find the beginning of a file name.
ed5c18e2
EZ
3267In a long Unix-style directory listing (@samp{ls -l}), the file name
3268starts after the date. The regexp has thus been written to look for the
3269date, the format of which can vary on non-US systems.
71e68827
DL
3270
3271There are two approaches to solving this. The first one involves
ed5c18e2
EZ
3272setting things up so that @samp{ls -l} outputs US date format. This can
3273be done by setting the locale. See your OS manual for more information.
71e68827
DL
3274
3275The second approach involves changing the regular expression used by
3276dired, @code{dired-move-to-filename-regexp}.
3277
3278@c ------------------------------------------------------------
3279@node Compiling and installing Emacs, Finding Emacs and related packages, Bugs and problems, Top
3280@chapter Compiling and installing Emacs
3281@cindex Compiling and installing Emacs
3282
3283@menu
3284* Installing Emacs::
3285* Updating Emacs::
3286* Problems building Emacs::
3287* Linking with -lX11 fails::
3288@end menu
3289
3290@node Installing Emacs, Updating Emacs, Compiling and installing Emacs, Compiling and installing Emacs
3291@section How do I install Emacs?
3292@cindex Installing Emacs
3293@cindex Unix systems, installing Emacs on
3294@cindex Downloading and installing Emacs
3295@cindex Retrieving and installing Emacs
3296@cindex Building Emacs from source
3297@cindex Source code, building Emacs from
3298@cindex Unpacking and installing Emacs
3299
3300This answer is meant for users of Unix and Unix-like systems. Users of
3301other operating systems should see the series of questions beginning
3302with @ref{Emacs for MS-DOS}, which describe where to get non-Unix source
ed5c18e2 3303and binaries, and how to install Emacs on those systems.
71e68827
DL
3304
3305For Unix and Unix-like systems, the easiest way is often to compile it
3306from scratch. You will need:
3307
3308@itemize @bullet
3309
3310@item
0d17cd5c 3311Emacs sources. @xref{Current GNU distributions}, for a list of ftp sites
71e68827 3312that make them available. On @file{ftp.gnu.org}, the main GNU
ed5c18e2 3313distribution site, sources are available as
71e68827 3314
ed5c18e2 3315@uref{ftp://ftp.gnu.org/pub/gnu/emacs/emacs-@value{VER}.tar.gz}
71e68827
DL
3316
3317The above will obviously change as new versions of Emacs come out. For
ed5c18e2
EZ
3318instance, when Emacs 21.42 is released, it will most probably be
3319available as
71e68827 3320
ed5c18e2 3321@uref{ftp://ftp.gnu.org/pub/gnu/emacs/emacs-21.42.tar.gz}
71e68827 3322
ed5c18e2 3323Again, you should use one of the GNU mirror sites (see @ref{Current GNU
0d17cd5c 3324distributions}, and adjust the URL accordingly) so as to reduce load on
71e68827
DL
3325@file{ftp.gnu.org}.
3326
3327@item
3328@code{gzip}, the GNU compression utility. You can get @code{gzip} via
3329anonymous ftp at mirrors of @file{ftp.gnu.org} sites; it should compile
3330and install without much trouble on most systems. Once you have
3331retrieved the Emacs sources, you will probably be able to uncompress
3332them with the command
3333
3334@example
ed5c18e2 3335gunzip --verbose emacs-@value{VER}.tar.gz
71e68827
DL
3336@end example
3337
ed5c18e2
EZ
3338@noindent
3339changing the Emacs version (@value{VER}), as necessary. Once
3340@code{gunzip} has finished doing its job, a file by the name of
3341@file{emacs-@value{VER}.tar} should be in your build directory.
71e68827
DL
3342
3343@item
ed5c18e2
EZ
3344@code{tar}, the @dfn{tape archiving} program, which moves multiple files
3345into and out of archive files, or @dfn{tarfiles}. All of the files
71e68827 3346comprising the Emacs source come in a single tarfile, and must be
ed5c18e2 3347extracted using @code{tar} before you can build Emacs. Typically, the
71e68827
DL
3348extraction command would look like
3349
3350@example
ed5c18e2 3351tar -xvvf emacs-@value{VER}.tar
71e68827
DL
3352@end example
3353
ed5c18e2 3354@noindent
71e68827
DL
3355The @samp{x} indicates that we want to extract files from this tarfile,
3356the two @samp{v}s force verbose output, and the @samp{f} tells
ed5c18e2 3357@code{tar} to use a disk file, rather than one on the tape drive.
71e68827 3358
ed5c18e2 3359If you're using GNU @code{tar} (available at mirrors of
71e68827
DL
3360@file{ftp.gnu.org}), you can combine this step and the previous one by
3361using the command
3362
3363@example
ed5c18e2 3364tar -zxvvf emacs-@value{VER}.tar.gz
71e68827
DL
3365@end example
3366
ed5c18e2
EZ
3367@noindent
3368The additional @samp{z} at the beginning of the options list tells GNU
3369@code{tar} to uncompress the file with @code{gunzip} before extracting
3370the tarfile's components.
71e68827
DL
3371
3372@end itemize
3373
ed5c18e2
EZ
3374At this point, the Emacs sources (all 70+ megabytes of them) should be
3375sitting in a directory called @file{emacs-@value{VER}}. On most common
3376Unix and Unix-like systems, you should be able to compile Emacs (with X
3377Window system support) with the following commands:
71e68827
DL
3378
3379@example
ed5c18e2 3380cd emacs-@value{VER} # change directory to emacs-@value{VER}
71e68827
DL
3381./configure # configure Emacs for your particular system
3382make # use Makefile to build components, then Emacs
3383@end example
3384
3385If the @code{make} completes successfully, the odds are fairly good that
ed5c18e2 3386the build has gone well. (@xref{Problems building Emacs}, if you weren't
71e68827
DL
3387successful.)
3388
3389By default, Emacs is installed in the following directories:
3390
3391@table @file
71e68827 3392@item /usr/local/bin
ed5c18e2 3393binaries.
71e68827 3394
ed5c18e2
EZ
3395@item /usr/local/share/emacs/@value{VER}
3396Lisp code and support files.
71e68827
DL
3397
3398@item /usr/local/info
ed5c18e2 3399Info documentation.
71e68827
DL
3400@end table
3401
3402To install files in those default directories, become the superuser and
3403type
3404
3405@example
3406make install
3407@end example
3408
ed5c18e2 3409Note that @samp{make install} will overwrite @file{/usr/local/bin/emacs}
71e68827
DL
3410and any Emacs Info files that might be in @file{/usr/local/info}.
3411
3412Much more verbose instructions (with many more hints and suggestions)
3413come with the Emacs sources, in the file @file{INSTALL}.
3414
3415@node Updating Emacs, Problems building Emacs, Installing Emacs, Compiling and installing Emacs
3416@section How do I update Emacs to the latest version?
3417@cindex Updating Emacs
3418
3419@xref{Installing Emacs}, and follow the instructions there for
3420installation.
3421
ed5c18e2
EZ
3422Most files are placed in version-specific directories. Emacs
3423@value{VER}, for instance, places files in
3424@file{/usr/local/share/emacs/@value{VER}}.
71e68827
DL
3425
3426Upgrading should overwrite only, @file{/usr/local/bin/emacs} (the Emacs
3427binary) and documentation in @file{/usr/local/info}. Back up these
3428files before you upgrade, and you shouldn't have too much trouble.
3429
3430@node Problems building Emacs, Linking with -lX11 fails, Updating Emacs, Compiling and installing Emacs
3431@section What should I do if I have trouble building Emacs?
3432@cindex Problems building Emacs
3433@cindex Errors when building Emacs
3434
d891bf01
EZ
3435First look in the file @file{etc/PROBLEMS} (where you unpack the Emacs
3436source) to see if there is already a solution for your problem. Next,
3437look for other questions in this FAQ that have to do with Emacs
3438installation and compilation problems.
71e68827
DL
3439
3440If you'd like to have someone look at your problem and help solve it,
ed5c18e2 3441see @ref{Help installing Emacs}.
71e68827
DL
3442
3443If you cannot find a solution in the documentation, send a message to
3444@email{bug-gnu-emacs@@gnu.org}.
3445
ec45fa10 3446Please don't post it to @uref{news:gnu.emacs.help} or send e-mail to
ed5c18e2
EZ
3447@email{help-gnu-emacs@@gnu.org}. For further guidelines, see
3448@ref{Guidelines for newsgroup postings} and @ref{Reporting bugs}.
71e68827
DL
3449
3450@node Linking with -lX11 fails, , Problems building Emacs, Compiling and installing Emacs
3451@section Why does linking Emacs with -lX11 fail?
3452@cindex Linking with -lX11 fails
3453@cindex lX11, linking fails with
3454
3455Emacs needs to be linked with the static version of the X11 library,
3456@file{libX11.a}. This may be missing.
3457
ed5c18e2 3458On OpenWindows, you may need to use @code{add_services} to add the
71e68827
DL
3459"OpenWindows Programmers" optional software category from the CD-ROM.
3460
ed5c18e2
EZ
3461On HP-UX 8.0, you may need to run @code{update} again to load the
3462X11-PRG ``fileset''. This may be missing even if you specified ``all
3463filesets'' the first time. If @file{libcurses.a} is missing, you may
3464need to load the ``Berkeley Development Option.''
71e68827
DL
3465
3466@email{zoo@@armadillo.com, David Zuhn} says that MIT X builds shared
3467libraries by default, and only shared libraries, on those platforms that
3468support them. These shared libraries can't be used when undumping
ed5c18e2
EZ
3469@code{temacs} (the last stage of the Emacs build process). To get
3470regular libraries in addition to shared libraries, add this to
3471@file{site.cf}:
71e68827
DL
3472
3473@example
3474#define ForceNormalLib YES
3475@end example
3476
3477Other systems may have similar problems. You can always define
ed5c18e2 3478@code{CANNOT_DUMP} and link with the shared libraries instead.
71e68827 3479
ed5c18e2 3480@cindex X Menus don't work
71e68827
DL
3481To get the Xmenu stuff to work, you need to find a copy of MIT's
3482@file{liboldX.a}.
3483
3484@c ------------------------------------------------------------
3485@node Finding Emacs and related packages, Major packages and programs, Compiling and installing Emacs, Top
3486@chapter Finding Emacs and related packages
3487@cindex Finding Emacs and related packages
3488
3489@menu
3490* Finding Emacs on the Internet::
3491* Finding a package with particular functionality::
3492* Packages that do not come with Emacs::
3493* Submitting to the Emacs Lisp Archive::
3494* Current GNU distributions::
3495* Difference between Emacs and XEmacs::
3496* Emacs for MS-DOS::
3497* Emacs for Windows::
3498* Emacs for OS/2::
3499* Emacs for Atari ST::
3500* Emacs for the Amiga ::
3501* Emacs for NeXTSTEP::
3502* Emacs for Apple computers::
3503* Emacs for VMS and DECwindows::
3504* Modes for various languages::
3505* Translating names to IP addresses::
3506@end menu
3507
3508@node Finding Emacs on the Internet, Finding a package with particular functionality, Finding Emacs and related packages, Finding Emacs and related packages
3509@section Where can I get Emacs on the net (or by snail mail)?
3510@cindex Finding Emacs on the Internet
3511@cindex Snail mail, ordering Emacs via
3512@cindex Postal service, ordering Emacs via
3513@cindex Distribution, retrieving Emacs
3514@cindex Internet, retreiving from
3515
3516Look in the files @file{etc/DISTRIB} and @file{etc/FTP} for information
3517on nearby archive sites and @file{etc/ORDERS} for mail orders. If you
ed5c18e2 3518don't already have Emacs, see @ref{Informational files for Emacs}, for how
71e68827
DL
3519to get these files.
3520
0d17cd5c 3521@xref{Installing Emacs}, for information on how to obtain and build the latest
ed5c18e2 3522version of Emacs, and see @ref{Current GNU distributions}, for a list of
71e68827
DL
3523archive sites that make GNU software available.
3524
3525@node Finding a package with particular functionality, Packages that do not come with Emacs, Finding Emacs on the Internet, Finding Emacs and related packages
3526@section How do I find a Emacs Lisp package that does XXX?
3527@cindex Package, finding
3528@cindex Finding an Emacs Lisp package
3529@cindex Functionality, finding a particular package
3530
3531First of all, you should check to make sure that the package isn't
3532already available. For example, typing @kbd{M-x apropos @key{RET}
3533wordstar @key{RET}} lists all functions and variables containing the
3534string @samp{wordstar}.
3535
3536It is also possible that the package is on your system, but has not been
3537loaded. To see which packages are available for loading, look through
f8635375 3538your computer's lisp directory (@pxref{File-name conventions}). The Lisp
fd599dee 3539source to most packages contains a short description of how they
ed5c18e2 3540should be loaded, invoked, and configured---so before you use or
71e68827
DL
3541modify a Lisp package, see if the author has provided any hints in the
3542source code.
3543
3544If a package does not come with Emacs, check the Lisp Code Directory.
3545The LCD was originally maintained by @email{brennan@@hal.com, Dave
3546Brennan}, but was recently taken over by @email{toby@@world.std.com,
3547toby knudsen}, who maintains @uref{http://www.emacs.org}. The LCD is
3548currently being reorganized and updated, but you can meanwhile find many
3549packages at @uref{ftp://ftp.emacs.org/pub}.
3550
3551For now, you can search through the LCD with @file{lispdir.el}, which is
3552in the process of being updated. Download it from the LCD, in the
3553@file{emacs-lisp-attic/misc} directory, and then evaluate the following
3554Lisp form (@pxref{Evaluating Emacs Lisp code}):
3555
3556@lisp
3557(setq lisp-code-directory
3558 "/anonymous@@ftp.emacs.org:pub/emacs-lisp-attic/emacs-lisp/LCD-datafile.gz"
3559 elisp-archive-host "ftp.emacs.org"
3560 elisp-archive-directory "/pub/emacs-lisp-attic/emacs-lisp/")
3561@end lisp
3562
3563Once you have installed @file{lispdir.el}, you can use @kbd{M-x
3564lisp-dir-apropos} to search the listing. For example, @kbd{M-x
3565lisp-dir-apropos @key{RET} ange-ftp @key{RET}} produces this output:
3566
3567@example
3568 GNU Emacs Lisp Code Directory Apropos --- "ange-ftp"
3569"~/" refers to archive.cis.ohio-state.edu:pub/elisp-archive/
3570
3571 ange-ftp (4.18) 15-Jul-1992
3572 Andy Norman, <ange@@hplb.hpl.hp.com>
3573 ~/packages/ange-ftp.tar.Z
3574 transparent FTP Support for GNU Emacs
3575 auto-save (1.19) 01-May-1992
3576 Sebastian Kremer, <sk@@thp.uni-koeln.de>
3577 ~/misc/auto-save.el.Z
3578 Safer autosaving with support for ange-ftp and /tmp
3579 ftp-quik (1.0) 28-Jul-1993
3580 Terrence Brannon, <tb06@@pl122f.eecs.lehigh.edu>
3581 ~/modes/ftp-quik.el.Z
3582 Quik access to dired'ing of ange-ftp and normal paths
3583@end example
3584
3585@node Packages that do not come with Emacs, Submitting to the Emacs Lisp Archive, Finding a package with particular functionality, Finding Emacs and related packages
3586@section Where can I get Emacs Lisp packages that don't come with Emacs?
3587@cindex Unbundled packages
3588@cindex Finding other packages
3589@cindex Lisp packages that do not come with Emacs
3590@cindex Packages, those that do not come with Emacs
3591@cindex Emacs Lisp Archive, description of
3592@cindex Archive, description of the Emacs Lisp
3593
3594First, check the Lisp Code Directory to find the name of the package you
3595are looking for (@pxref{Finding a package with particular
3596functionality}). Next, check local archives and the Emacs Lisp Archive
3597to find a copy of the relevant files. If you still haven't found it,
3598you can send e-mail to the author asking for a copy. If you find Emacs
3599Lisp code that doesn't appear in the LCD, please submit a copy to the
3600LCD (@pxref{Submitting to the Emacs Lisp Archive}).
3601
3602You can access the Emacs Lisp Archive at
3603
3604@uref{ftp://archive.cis.ohio-state.edu/pub/emacs-lisp/}
3605
ed5c18e2
EZ
3606@noindent
3607or at
3608
3609@uref{http://www.cis.ohio-state.edu/emacs-lisp}
3610
3611@noindent
71e68827
DL
3612Retrieve and read the file @file{README} first.
3613
3614@itemize @bullet
3615
ed5c18e2
EZ
3616@item
3617The archive maintainers do not have time to answer individual
71e68827
DL
3618requests for packages or the list of packages in the archive. If you
3619cannot use FTP or UUCP to access the archive yourself, try to find a
3620friend who can, but please don't ask the maintainers.
3621
ed5c18e2
EZ
3622@item
3623Any files with names ending in @file{.Z}, @file{.z}, or @file{.gz} are
71e68827
DL
3624compressed, so you should use "binary" mode in FTP to retrieve them.
3625You should also use binary mode whenever you retrieve any files with
ed5c18e2 3626names ending in @file{.elc}.
71e68827
DL
3627
3628@end itemize
3629
3630@node Submitting to the Emacs Lisp Archive, Current GNU distributions, Packages that do not come with Emacs, Finding Emacs and related packages
3631@section How do I submit code to the Emacs Lisp Archive?
3632@cindex Submitting code to the Emacs Lisp Archive
3633@cindex Emacs Lisp Archive, submissions to
3634@cindex Lisp Archive, submissions to
3635@cindex Archive, submitting to the Emacs Lisp
3636
3637Guidelines and procedures for submission to the archive can be found in
ed5c18e2 3638the file @file{GUIDELINES} in the archive directory (@pxref{Packages that
71e68827
DL
3639do not come with Emacs}). It covers documentation, copyrights,
3640packaging, submission, and the Lisp Code Directory Record. Anonymous
3641FTP uploads are not permitted. Instead, all submissions are mailed to
3642@email{elisp-archive@@cis.ohio-state.edu}. The @file{lispdir.el}
3643package has a function named @code{submit-lcd-entry} which will help you
3644with this.
3645
3646@node Current GNU distributions, Difference between Emacs and XEmacs, Submitting to the Emacs Lisp Archive, Finding Emacs and related packages
3647@section Where can I get other up-to-date GNU stuff?
3648@cindex Current GNU distributions
3649@cindex Sources for current GNU distributions
3650@cindex Stuff, current GNU
3651@cindex Up-to-date GNU stuff
3652@cindex Finding current GNU software
3653@cindex Official GNU software sites
3654
3655The most up-to-date official GNU software is normally kept at
3656
3657@uref{ftp://ftp.gnu.org/pub/gnu}
3658
3659Read the files @file{etc/DISTRIB} and @file{etc/FTP} for more
3660information.
3661
3662A list of sites mirroring @samp{ftp.gnu.org} can be found at
3663
3664@uref{http://www.gnu.org/order/ftp.html}
3665
3666@node Difference between Emacs and XEmacs, Emacs for MS-DOS, Current GNU distributions, Finding Emacs and related packages
3667@section What is the difference between Emacs and XEmacs (formerly "Lucid Emacs")?
3668@cindex XEmacs
3669@cindex Difference Emacs and XEmacs
3670@cindex Lucid Emacs
3671@cindex Epoch
3672
3673First of all, they're both GNU Emacs. XEmacs is just as much a later
3674version of GNU Emacs as the FSF-distributed version. This FAQ refers to
ed5c18e2 3675the latest version to be distributed by the FSF as ``Emacs,'' partly
71e68827 3676because the XEmacs maintainers now refer to their product using the
ed5c18e2 3677``XEmacs'' name, and partly because there isn't any accurate way to
71e68827
DL
3678differentiate between the two without getting mired in paragraphs of
3679legalese and history.
3680
3681XEmacs, which began life as Lucid Emacs, is based on an early version of
3682Emacs 19 and Epoch, an X-aware version of Emacs 18.
3683
3684Emacs (i.e., the version distributed by the FSF) has a larger installed
0d17cd5c 3685base and now always contains the MULE multilingual facilities.
97878c08 3686XEmacs can do some clever tricks with X and MS-Windows, such as
0d17cd5c
DL
3687putting arbitrary graphics in a buffer. Similar facilities have been
3688implemented for Emacs as part of a new redisplay implementation for
ed5c18e2 3689Emacs 21, and are available in the latest Emacs releases.
0d17cd5c 3690Emacs and XEmacs each come with
71e68827
DL
3691Lisp packages that are lacking in the other; RMS says that the FSF would
3692include more packages that come with XEmacs, but that the XEmacs
3693maintainers don't always keep track of the authors of contributed code,
3694which makes it impossible for the FSF to have certain legal papers
3695signed. (Without these legal papers, the FSF will not distribute Lisp
0d17cd5c
DL
3696packages with Emacs.) The two versions have some
3697significant differences at the Lisp programming level.
71e68827
DL
3698
3699Many XEmacs features have found their way into recent versions of Emacs,
3700and more features can be expected in the future, but there are still many
3701differences between the two.
3702
ed5c18e2
EZ
3703The latest stable version of XEmacs as of this writing is 21.1; you can
3704get it at
3705
3706@uref{ftp://ftp.xemacs.org/pub/xemacs/current/xemacs-21.1.13.tar.gz}
3707
3708More information about XEmacs, including a list of frequently asked
3709questions (FAQ), is available at
3710
3711@uref{http://www.xemacs.org/}
3712
71e68827
DL
3713@node Emacs for MS-DOS, Emacs for Windows, Difference between Emacs and XEmacs, Finding Emacs and related packages
3714@section Where can I get Emacs for my PC running MS-DOS?
3715@cindex MS-DOS, Emacs for
3716@cindex DOS, Emacs for
3717@cindex Compiling Emacs for DOS
3718@cindex Emacs for MS-DOS
3719@cindex Tools needed to compile Emacs under DOS
3720
ed5c18e2
EZ
3721A pre-built binary distribution of Emacs is available from the
3722SimTel.NET archives. This version apparently works under MS-DOS and
3723Windows (3.X, 9X, ME, NT, and 2000) and supports long file names under
3724Windows 9X, Windows ME, and Windows 2000. More information is available
3725from
71e68827
DL
3726
3727@uref{ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/emacs.README}
3728
ed5c18e2 3729The binary itself is available in the files @file{em*.zip} in the
71e68827
DL
3730directory
3731
3732@uref{ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/}
3733
0d17cd5c
DL
3734If you prefer to compile Emacs for yourself, you can do so with the
3735current distribution directly. You will need a 386 (or
3736better) processor, and to be running MS-DOS 3.0 or later. According to
71e68827
DL
3737@email{eliz@@is.elta.co.il, Eli Zaretskii} and
3738@email{hankedr@@dms.auburn.edu, Darrel Hankerson}, you will need the
3739following:
3740
3741@table @emph
3742
3743@item Compiler
ed5c18e2
EZ
3744DJGPP version 1.12 maint 1 or later. Djgpp 2.0 or later is
3745recommended, since 1.x is very old an unmaintained. Djgpp 2 supports
f8635375 3746long file names on Windows 9X/ME/2K.
71e68827 3747
ed5c18e2 3748You can get the latest release of DJGPP by retrieving all of
71e68827
DL
3749the files in
3750
ed5c18e2 3751@uref{ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2*}
71e68827 3752
ed5c18e2
EZ
3753@item Unpacking program
3754The easiest way is to use @code{djtar} which comes with DJGPP v2.x,
71e68827 3755because it can open gzip'ed tarfiles (i.e., those ending with
ed5c18e2
EZ
3756@file{.tar.gz}) in one step. @code{Djtar} comes in
3757@file{djdev@var{nnn}.zip} archive (where @var{nnn} is the DJGPP version
3758number), from the URL mentioned above.
3759
3760@strong{Warning!} Do @strong{not} use the popular WinZip program to
3761unpack the Emacs distribution! WinZip is known to corrupt some of the
3762files by converting them to the DOS CR-LF format, it doesn't always
3763preserve the directory structure recorded in the compressed Emacs
3764archive, and commits other atrocities. Some of these problems could
3765actually prevent Emacs from building successfully!
71e68827
DL
3766
3767@item make, mv, sed, and rm
3768All of these utilities are available at
3769
3770@uref{ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu}
3771
377216-bit utilities can be found in GNUish, at
3773
3774@uref{ftp://ftp.simtel.net/pub/simtelnet/gnu/gnuish}
3775
ed5c18e2
EZ
3776@noindent
3777(@code{mv} and @code{rm} are in the Fileutils package, @code{sed} and
3778@code{make} are each one in a separate package named after them.)
3779
71e68827
DL
3780@end table
3781
d891bf01
EZ
3782The files @file{INSTALL} (near its end) and @file{etc/PROBLEMS} in the
3783directory of the Emacs sources contains some additional information
3784regarding Emacs under MS-DOS.
71e68827
DL
3785
3786For a list of other MS-DOS implementations of Emacs (and Emacs
3787look-alikes), consult the list of "Emacs implementations and literature,"
3788available at
3789
3790@uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/}
3791
3792Note that while many of these programs look similar to Emacs, they often
3793lack certain features, such as the Emacs Lisp extension language.
3794
3795@node Emacs for Windows, Emacs for OS/2, Emacs for MS-DOS, Finding Emacs and related packages
3796@section Where can I get Emacs for Microsoft Windows
3797@cindex FAQ for NT Emacs
d891bf01 3798@cindex Emacs for MS-Windows
71e68827 3799@cindex Microsoft Windows, Emacs for
d891bf01 3800@cindex Windows 9X, ME, NT, 2K, and CE, Emacs for
71e68827
DL
3801
3802For information on Emacs for Windows 95 and NT, read the FAQ produced by
3803@email{voelker@@cs.washington.edu, Geoff Voelker}, available at
3804
0d17cd5c 3805@uref{http://www.gnu.org/software/emacs/windows/ntemacs.html}
71e68827 3806
0d17cd5c 3807@xref{Emacs for MS-DOS}, for Windows 3.1.
71e68827 3808
d891bf01
EZ
3809A port of Emacs 20.7 for Windows CE, based on NTEmacs, is available at
3810
3811@uref{http://www.rainer-keuchel.de/software.html}
3812
3813@noindent
3814This port was done by @email{coyxc@@rainer-keuchel.de, Rainer Keuchel},
3815and supports all Emacs features except async subprocesses and menus.
3816You will need MSVC 6.0 and a Windows CE SDK to build this port.
3817
71e68827
DL
3818@node Emacs for OS/2, Emacs for Atari ST, Emacs for Windows, Finding Emacs and related packages
3819@section Where can I get Emacs for my PC running OS/2?
3820@cindex OS/2, Emacs for
3821
bb2628a7 3822Emacs 20.6 is ported for emx on OS/2 2.0 or 2.1, and is available at
71e68827 3823
bb2628a7
EZ
3824@uref{ftp://hobbes.nmsu.edu/pub/os2/apps/editors/emacs/e206*.zip}
3825
3826@noindent
3827and also at
3828
3829@uref{http://archiv.leo.org/pub/comp/os/os2/leo/gnu/emacs%2d20/}
3830
3831Instructions for installation, basic setup, and other useful information
3832for OS/2 users of Emacs can be found at
3833
3834@uref{http://userpage.fu-berlin.de/~oheiabbd/emacs/emacs206-os2.html}
71e68827
DL
3835
3836@node Emacs for Atari ST, Emacs for the Amiga , Emacs for OS/2, Finding Emacs and related packages
3837@section Where can I get Emacs for my Atari ST?
3838@cindex Atari ST, Emacs for
3839@cindex TOS, Emacs for
3840
3841