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