(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
[emacs.git] / man / faq.texi
blobc698f7b899f55077e3734084446c2b8e8ec8a837
1 \input texinfo   @c -*- coding: latin-1; mode: texinfo; -*-
2 @c %**start of header
3 @setfilename ../info/efaq
4 @settitle GNU Emacs FAQ
5 @c %**end of header
7 @setchapternewpage odd
9 @c This is used in many places
10 @set VER 21.3
12 @copying
13 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
14 Copyright 1994,1995,1996,1997,1998,1999,2000 Reuven M. Lerner@*
15 Copyright 1992,1993 Steven Byrnes@*
16 Copyright 1990,1991,1992 Joseph Brian Wells@*
18 @quotation
19 This list of frequently asked questions about GNU Emacs with answers
20 ("FAQ") may be translated into other languages, transformed into other
21 formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information.
23 The same conditions apply to any derivative of the FAQ as apply to the FAQ
24 itself.  Every copy of the FAQ must include this notice or an approved
25 translation, information on who is currently maintaining the FAQ and how to
26 contact them (including their e-mail address), and information on where the
27 latest version of the FAQ is archived (including FTP information).
29 The FAQ may be copied and redistributed under these conditions, except that
30 the FAQ may not be embedded in a larger literary work unless that work
31 itself allows free copying and redistribution.
33 [This version has been somewhat edited from the last-posted version
34 (as of August 1999) for inclusion in the Emacs distribution.]
35 @end quotation
36 @end copying
38 @dircategory Emacs
39 @direntry
40 * Emacs FAQ: (efaq).    Frequently Asked Questions about Emacs.
41 @end direntry
43 @c The @titlepage stuff only appears in the printed version
44 @titlepage
45 @sp 10
46 @center @titlefont{GNU Emacs FAQ}
48 @c The following two commands start the copyright page.
49 @page
50 @vskip 0pt plus 1filll
51 @insertcopying
52 @end titlepage
54 @node    Top, FAQ notation, (dir), (dir)
56 This is the GNU Emacs FAQ, last updated on @today{}.
58 The FAQ is maintained as a Texinfo document, allowing us to create HTML,
59 Info, and TeX documents from a single source file, and is slowly but
60 surely being improved.  Please bear with us as we improve on this
61 format.  This FAQ is maintained as a part of GNU Emacs.  If you find
62 any errors, or have any suggestions, please use @kbd{M-x report-emacs-bug}
63 to report them.
65 @menu
66 * FAQ notation::
67 * General questions::
68 * Getting help::
69 * Status of Emacs::
70 * Common requests::
71 * Bugs and problems::
72 * Compiling and installing Emacs::
73 * Finding Emacs and related packages::
74 * Major packages and programs::
75 * Key bindings::
76 * Alternate character sets::
77 * Mail and news::
78 * Concept index::
79 @end menu
81 @c ------------------------------------------------------------
82 @node FAQ notation, General questions, Top, Top
83 @chapter FAQ notation
84 @cindex FAQ notation
86 This chapter describes notation used in the GNU Emacs FAQ, as well as in
87 the Emacs documentation.  Consult this section if this is the first time
88 you are reading the FAQ, or if you are confused by notation or terms
89 used in the FAQ.
91 @menu
92 * Basic keys::
93 * Extended commands::
94 * On-line manual::
95 * File-name conventions::
96 * Common acronyms::
97 @end menu
99 @node Basic keys, Extended commands, FAQ notation, FAQ notation
100 @section What do these mean: @kbd{C-h}, @kbd{C-M-a}, @key{RET}, @kbd{@key{ESC} a}, etc.?
101 @cindex Basic keys
102 @cindex Control key, notation for
103 @cindex @key{Meta} key, notation for
104 @cindex Control-Meta characters, notation for
105 @cindex @kbd{C-h}, definition of
106 @cindex @kbd{C-M-h}, definition of
107 @cindex @key{DEL}, definition of
108 @cindex @key{ESC}, definition of
109 @cindex @key{LFD}, definition of
110 @cindex @key{RET}, definition of
111 @cindex @key{SPC}, definition of
112 @cindex @key{TAB}, definition of
113 @cindex Notation for keys
115 @itemize @bullet
117 @item
118 @kbd{C-x}: press the @key{x} key while holding down the @key{Control} key
120 @item
121 @kbd{M-x}: press the @key{x} key while holding down the @key{Meta} key
122 (if your computer doesn't have a @key{Meta} key, @pxref{No Meta key})
124 @item
125 @kbd{M-C-x}: press the @key{x} key while holding down both @key{Control}
126 and @key{Meta}
128 @item
129 @kbd{C-M-x}: a synonym for the above
131 @item
132 @key{LFD}: Linefeed or Newline; same as @kbd{C-j}
134 @item
135 @key{RET}: @key{Return}, sometimes marked @key{Enter}; same as @kbd{C-m}
137 @item
138 @key{DEL}: @key{Delete}, usually @strong{not} the same as
139 @key{Backspace}; same as @kbd{C-?} (see @ref{Backspace invokes help}, if
140 deleting invokes Emacs help)
142 @item
143 @key{ESC}: Escape; same as @kbd{C-[}
145 @item
146 @key{TAB}: Tab; same as @kbd{C-i}
148 @item
149 @key{SPC}: Space bar
151 @end itemize
153 Key sequences longer than one key (and some single-key sequences) are
154 written inside quotes or on lines by themselves, like this:
156 @display
157   @kbd{M-x frobnicate-while-foo RET}
158 @end display
160 @noindent
161 Any real spaces in such a key sequence should be ignored; only @key{SPC}
162 really means press the space key.
164 The ASCII code sent by @kbd{C-x} (except for @kbd{C-?}) is the value
165 that would be sent by pressing just @key{x} minus 96 (or 64 for
166 upper-case @key{X}) and will be from 0 to 31.  On Unix and GNU/Linux
167 terminals, the ASCII code sent by @kbd{M-x} is the sum of 128 and the
168 ASCII code that would be sent by pressing just @key{x}.  Essentially,
169 @key{Control} turns off bits 5 and 6 and @key{Meta} turns on bit
170 7@footnote{
171 DOS and Windows terminals don't set bit 7 when the @key{Meta} key is
172 pressed.}.
174 @kbd{C-?} (aka @key{DEL}) is ASCII code 127.  It is a misnomer to call
175 @kbd{C-?}  a ``control'' key, since 127 has both bits 5 and 6 turned ON.
176 Also, on very few keyboards does @kbd{C-?} generate ASCII code 127.
178 @inforef{Text Characters, Text Characters, emacs}, and @inforef{Keys,
179 Keys, emacs}, for more information.  (@xref{On-line manual}, for more
180 information about Info.)
182 @node Extended commands, On-line manual, Basic keys, FAQ notation
183 @section What does @file{M-x @var{command}} mean?
184 @cindex Extended commands
185 @cindex Commands, extended
186 @cindex M-x, meaning of
188 @kbd{M-x @var{command}} means type @kbd{M-x}, then type the name of the
189 command, then type @key{RET}.  (@xref{Basic keys}, if you're not sure
190 what @kbd{M-x} and @key{RET} mean.)
192 @kbd{M-x} (by default) invokes the command
193 @code{execute-extended-command}.  This command allows you to run any
194 Emacs command if you can remember the command's name.  If you can't
195 remember the command's name, you can type @key{TAB} and @key{SPC} for
196 completion, @key{?} for a list of possibilities, and @kbd{M-p} and
197 @kbd{M-n} (or up-arrow and down-arrow on terminals that have these
198 editing keys) to see previous commands entered.  An Emacs @dfn{command}
199 is an @dfn{interactive} Emacs function.
201 @cindex @key{Do} key
202 Your system administrator may have bound other key sequences to invoke
203 @code{execute-extended-command}.  A function key labeled @kbd{Do} is a
204 good candidate for this, on keyboards that have such a key.
206 If you need to run non-interactive Emacs functions, see @ref{Evaluating
207 Emacs Lisp code}.
209 @node On-line manual, File-name 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
216 When we refer you to some @var{topic} in the on-line manual, you can
217 read this manual node inside Emacs (assuming nothing is broken) by
218 typing @kbd{C-h i m emacs @key{RET} m @var{topic} @key{RET}}.
220 This invokes Info, the GNU hypertext documentation browser.  If you don't
221 already know how to use Info, type @key{?} from within Info.
223 If we refer to @var{topic}:@var{subtopic}, type @kbd{C-h i m emacs
224 @key{RET} m @var{topic} @key{RET} m @var{subtopic} @key{RET}}.
226 If these commands don't work as expected, your system administrator may
227 not have installed the Info files, or may have installed them
228 improperly.  In this case you should complain.
230 @xref{Getting a printed manual}, if you would like a paper copy of the
231 Emacs manual.
233 @node File-name conventions, Common acronyms, On-line manual, FAQ notation
234 @section What are @file{etc/SERVICE}, @file{src/config.h}, and @file{lisp/default.el}?
235 @cindex File-name conventions
236 @cindex Conventions for file names
237 @cindex Directories and files that come with Emacs
239 These are files that come with Emacs.  The Emacs distribution is divided
240 into subdirectories; the important ones are @file{etc}, @file{lisp}, and
241 @file{src}.
243 If you use Emacs, but don't know where it is kept on your system, start
244 Emacs, then type @kbd{C-h v data-directory @key{RET}}.  The directory
245 name displayed by this will be the full pathname of the installed
246 @file{etc} directory.  (This full path is recorded in the Emacs variable
247 @code{data-directory}, and @kbd{C-h v} displays the value and the
248 documentation of a variable.)
250 The location of your Info directory (i.e., where on-line documentation
251 is stored) is kept in the variable @code{Info-default-directory-list}.  Use
252 @kbd{C-h v Info-default-directory-list @key{RET}} to see the value of
253 this variable, which will be a list of directory names.  The last
254 directory in that list is probably where most Info files are stored.  By
255 default, Info documentation is placed in @file{/usr/local/info}.
257 Some of these files are available individually via FTP or e-mail; see
258 @ref{Informational files for Emacs}.  They all are available in the
259 source distribution.  Many of the files in the @file{etc} directory are
260 also available via the Emacs @samp{Help} menu, or by typing @kbd{C-h ?}
261 (@kbd{M-x help-for-help}).
263 Your system administrator may have removed the @file{src} directory and
264 many files from the @file{etc} directory.
266 @node Common acronyms,  , File-name conventions, FAQ notation
267 @section What are FSF, LPF, OSF, GNU, RMS, FTP, and GPL?
268 @cindex FSF, definition of
269 @cindex LPF, definition of
270 @cindex OSF, definition of
271 @cindex GNU, definition of
272 @cindex RMS, definition of
273 @cindex Stallman, Richard, acronym for
274 @cindex Richard Stallman, acronym for
275 @cindex FTP, definition of
276 @cindex GPL, definition of
277 @cindex Acronyms, definitions for
278 @cindex Common acronyms, definitions for
280 @table @asis
282 @item FSF
283 Free Software Foundation
285 @item LPF
286 League for Programming Freedom
288 @item OSF
289 Open Software Foundation
291 @item GNU
292 GNU's Not Unix
294 @item RMS
295 Richard Matthew Stallman
297 @item FTP
298 File Transfer Protocol
300 @item GPL
301 GNU General Public License
303 @end table
305 Avoid confusing the FSF, the LPF, and the OSF.  The LPF opposes
306 look-and-feel copyrights and software patents.  The FSF aims to make
307 high quality free software available for everyone.  The OSF is a
308 consortium of computer vendors which develops commercial software for
309 Unix systems.
311 The word ``free'' in the title of the Free Software Foundation refers to
312 ``freedom,'' not ``zero dollars.''  Anyone can charge any price for
313 GPL-covered software that they want to.  However, in practice, the
314 freedom enforced by the GPL leads to low prices, because you can always
315 get the software for less money from someone else, since everyone has
316 the right to resell or give away GPL-covered software.
318 @c ------------------------------------------------------------
319 @node    General questions, Getting help, FAQ notation, Top
320 @chapter General questions
321 @cindex General questions
323 This chapter contains general questions having to do with Emacs, the
324 Free Software Foundation, and related organizations.
326 @menu
327 * The LPF::
328 * Real meaning of copyleft::
329 * Guidelines for newsgroup postings::
330 * Newsgroup archives::
331 * Reporting bugs::
332 * Unsubscribing from Emacs lists::
333 * Contacting the FSF::
334 @end menu
336 @node The LPF, Real meaning of copyleft, General questions, General questions
337 @section What is the LPF?
338 @cindex LPF, description of
339 @cindex League for Programming Freedom
340 @cindex Software patents, opposition to
341 @cindex Patents for software, opposition to
343 The LPF opposes the expanding danger of software patents and
344 look-and-feel copyrights.  To get more information, feel free to contact
345 the LPF via e-mail or otherwise.  You may also contact
346 @email{jbw@@cs.bu.edu, Joe Wells}; he will be happy to talk to you
347 about the LPF.
349 You can find more information about the LPF in the file @file{etc/LPF}.
350 More papers describing the LPF's views are available on the Internet and
351 also from @uref{http://lpf.ai.mit.edu/, the LPF home page}.
353 @node Real meaning of copyleft, Guidelines for newsgroup postings, The LPF, General questions
354 @section What is the real legal meaning of the GNU copyleft?
355 @cindex Copyleft, real meaning of
356 @cindex GPL, real meaning of
357 @cindex General Public License, real meaning of
358 @cindex Discussion of the GPL
360 The real legal meaning of the GNU General Public License (copyleft) will
361 only be known if and when a judge rules on its validity and scope.
362 There has never been a copyright infringement case involving the GPL to
363 set any precedents.  Please take any discussion regarding this issue to
364 the newsgroup @uref{news:gnu.misc.discuss}, which was created to hold the
365 extensive flame wars on the subject.
367 RMS writes:
369 @quotation
370 The legal meaning of the GNU copyleft is less important than the spirit,
371 which is that Emacs is a free software project and that work pertaining
372 to Emacs should also be free software.  ``Free'' means that all users
373 have the freedom to study, share, change and improve Emacs.  To make
374 sure everyone has this freedom, pass along source code when you
375 distribute any version of Emacs or a related program, and give the
376 recipients the same freedom that you enjoyed.
377 @end quotation
379 @node Guidelines for newsgroup postings, Newsgroup archives, Real meaning of copyleft, General questions
380 @section  What are appropriate messages for @uref{news:gnu.emacs.help}, @uref{news:gnu.emacs.bug}, @uref{news:comp.emacs}, etc.?
381 @cindex Newsgroups, appropriate messages for
382 @cindex GNU newsgroups, appropriate messages for
383 @cindex Usenet groups, appropriate messages for
384 @cindex Mailing lists, appropriate messages for
385 @cindex Posting messages to newsgroups
387 @cindex GNU mailing lists
388 The file @file{etc/MAILINGLISTS} describes the purpose of each GNU
389 mailing list.  (@xref{Informational files for Emacs}, if you want a copy
390 of the file.)  For those lists which are gatewayed with newsgroups, it
391 lists both the newsgroup name and the mailing list address.
393 The newsgroup @uref{news:comp.emacs} is for discussion of Emacs programs
394 in general.  This includes Emacs along with various other
395 implementations, such as XEmacs, JOVE, MicroEmacs, Freemacs, MG,
396 Unipress, CCA, and Epsilon.
398 Many people post Emacs questions to @uref{news:comp.emacs} because they
399 don't receive any of the @code{gnu.*} newsgroups.  Arguments have been
400 made both for and against posting GNU-Emacs-specific material to
401 @uref{news:comp.emacs}.  You have to decide for yourself.
403 Messages advocating ``non-free'' software are considered unacceptable on
404 any of the @code{gnu.*} newsgroups except for @uref{news:gnu.misc.discuss},
405 which was created to hold the extensive flame-wars on the subject.
406 ``Non-free'' software includes any software for which the end user can't
407 freely modify the source code and exchange enhancements.  Be careful to
408 remove the @code{gnu.*} groups from the @samp{Newsgroups:} line when
409 posting a followup that recommends such software.
411 @uref{news:gnu.emacs.bug} is a place where bug reports appear, but avoid
412 posting bug reports to this newsgroup directly (@pxref{Reporting bugs}).
414 @node Newsgroup archives, Reporting bugs, Guidelines for newsgroup postings, General questions
415 @section Where can I get old postings to @uref{news:gnu.emacs.help} and other GNU groups?
416 @cindex Archived postings from @code{gnu.emacs.help}
417 @cindex Usenet archives for GNU groups
418 @cindex Old Usenet postings for GNU groups
420 The FSF has maintained archives of all of the GNU mailing lists for many
421 years, although there may be some unintentional gaps in coverage.  The
422 archive is not particularly well organized or easy to retrieve
423 individual postings from, but pretty much everything is there.
425 The archive is at @uref{ftp://ftp-mailing-list-archives.gnu.org}.
427 The archive can be browsed over the web at 
428 @uref{http://mail.gnu.org/archive/html/, the GNU mail archive}.
430 Web-based Usenet search services, such as
431 @uref{http://groups.google.com, Google}, also archive the
432 @code{gnu.*} groups.
434 @node Reporting bugs, Unsubscribing from Emacs lists, Newsgroup archives, General questions
435 @section Where should I report bugs and other problems with Emacs?
436 @cindex Bug reporting
437 @cindex Good bug reports
438 @cindex How to submit a bug report
439 @cindex Reporting bugs
441 The correct way to report Emacs bugs is by e-mail to
442 @email{bug-gnu-emacs@@gnu.org}.  Anything sent here also appears in the
443 newsgroup @uref{news:gnu.emacs.bug}, but please use e-mail instead of
444 news to submit the bug report.  This ensures a reliable return address
445 so you can be contacted for further details.
447 Be sure to read the ``Bugs'' section of the Emacs manual before reporting
448 a bug to bug-gnu-emacs!  The manual describes in detail how to submit a
449 useful bug report.  (@xref{On-line manual}, if you don't know how to read the
450 manual.)
452 RMS says:
454 @quotation
455 Sending bug reports to @email{help-gnu-emacs@@gnu.org} (which has the
456 effect of posting on @uref{news:gnu.emacs.help}) is undesirable because
457 it takes the time of an unnecessarily large group of people, most of
458 whom are just users and have no idea how to fix these problem.
459 @email{bug-gnu-emacs@@gnu.org} reaches a much smaller group of people
460 who are more likely to know what to do and have expressed a wish to
461 receive more messages about Emacs than the others.
462 @end quotation
464 RMS says it is sometimes fine to post to @uref{news:gnu.emacs.help}:
466 @quotation
467 If you have reported a bug and you don't hear about a possible fix,
468 then after a suitable delay (such as a week) it is okay to post on
469 @code{gnu.emacs.help} asking if anyone can help you.
470 @end quotation
472 If you are unsure whether you have found a bug, consider the following
473 non-exhaustive list, courtesy of RMS:
475 @quotation
476 If Emacs crashes, that is a bug.  If Emacs gets compilation errors
477 while building, that is a bug.  If Emacs crashes while building, that
478 is a bug.  If Lisp code does not do what the documentation says it
479 does, that is a bug.
480 @end quotation
482 @node Unsubscribing from Emacs lists, Contacting the FSF, Reporting bugs, General questions
483 @section  How do I unsubscribe from this mailing list?
484 @cindex Unsubscribing from GNU mailing lists
485 @cindex Removing yourself from GNU mailing lists
487 If you are receiving a GNU mailing list named @var{list}, you might be
488 able to unsubscribe from it by sending a request to the address
489 @email{@var{list}-request@@gnu.org}.  However, this will not work if you are
490 not listed on the main mailing list, but instead receive the mail from a
491 distribution point.  In that case, you will have to track down at which
492 distribution point you are listed.  Inspecting the @samp{Received} headers
493 on the mail messages may help, along with liberal use of the @samp{EXPN} or
494 @samp{VRFY} sendmail commands through @samp{telnet @var{site-address}
495 smtp}.  Ask your postmaster for help, if you cannot figure out these
496 details.
498 @node Contacting the FSF,  , Unsubscribing from Emacs lists, General questions
499 @section  What is the current address of the FSF?
500 @cindex Snail mail address of the FSF
501 @cindex Postal address of the FSF
502 @cindex Contracting the FSF
503 @cindex Free Software Foundation, contacting
505 @table @asis
507 @item E-mail
508 gnu@@gnu.org
510 @item Telephone
511 +1-617-542-5942
513 @item Fax
514 +1-617-542-2652
516 @item World Wide Web
517 @uref{http://www.gnu.org/}
519 @item Postal address
520 Free Software Foundation@*
521 59 Temple Place - Suite 330@*
522 Boston, MA 02111-1307@*
523 USA@*
525 @end table
527 @cindex Ordering GNU software
528 For details on how to order items directly from the FSF, see the
529 @uref{http://www.gnu.org/order/order.html, GNU Web site}, and also the
530 files @file{etc/ORDERS}, @file{ORDERS.EUROPE}, and @file{ORDERS.JAPAN}.
532 @c ------------------------------------------------------------
533 @node Getting help, Status of Emacs, General questions, Top
534 @chapter Getting help
535 @cindex Getting help
537 This chapter tells you how to get help with Emacs
539 @menu
540 * Basic editing::
541 * Learning how to do something::
542 * Getting a printed manual::
543 * Emacs Lisp documentation::
544 * Installing Texinfo documentation::
545 * Printing a Texinfo file::
546 * Viewing Info files outside of Emacs::
547 * Informational files for Emacs::
548 * Help installing Emacs::
549 * Obtaining the FAQ::
550 @end menu
552 @node Basic editing, Learning how to do something, Getting help, Getting help
553 @section I'm just starting Emacs; how do I do basic editing?
554 @cindex Basic editing with Emacs
555 @cindex Beginning editing
556 @cindex Tutorial, invoking the
557 @cindex Self-paced tutorial, invoking the
558 @cindex Help system, entering the
560 Type @kbd{C-h t} to invoke the self-paced tutorial.  Just typing @kbd{C-h}
561 enters the help system.
563 Your system administrator may have changed @kbd{C-h} to act like
564 @key{DEL} to deal with local keyboards.  You can use @kbd{M-x
565 help-for-help} instead to invoke help.  To discover what key (if any)
566 invokes help on your system, type @kbd{M-x where-is @key{RET}
567 help-for-help @key{RET}}.  This will print a comma-separated list of key
568 sequences in the echo area.  Ignore the last character in each key
569 sequence listed.  Each of the resulting key sequences invokes help.
571 Emacs help works best if it is invoked by a single key whose value
572 should be stored in the variable @code{help-char}.
574 There is also a WWW-based tutorial for Emacs 18, much of which is also
575 relevant for later versions of Emacs, available at
577 @uref{http://kufacts.cc.ukans.edu/cwis/writeups/misc/emacsguide.html}
579 @node Learning how to do something, Getting a printed manual, Basic editing, Getting help
580 @section How do I find out how to do something in Emacs?
581 @cindex Help for Emacs
582 @cindex Learning to do something in Emacs
583 @cindex Reference card for Emacs
584 @cindex Overview of help systems
586 There are several methods for finding out how to do things in Emacs.
588 @itemize @bullet
590 @cindex Reading the Emacs manual
591 @item
592 The complete text of the Emacs manual is available on-line via the Info
593 hypertext reader.  Type @kbd{C-h i} to invoke Info.  Typing @key{h}
594 immediately after entering Info will provide a short tutorial on how to
595 use it.
597 @cindex Lookup a subject in a manual
598 @cindex Index search in a manual
599 @item
600 To quickly locate the section of the manual which discusses a certain
601 issue, or describes a command or a variable, type @kbd{C-h i m emacs
602 @key{RET} i @var{topic} @key{RET}}, where @var{topic} is the name of the
603 topic, the command, or the variable which you are looking for.  If this
604 does not land you on the right place in the manual, press @kbd{,}
605 (comma) repeatedly until you find what you need.  (The @kbd{i} and
606 @kbd{,} keys invoke the index-searching functions, which look for the
607 @var{topic} you type in all the indices of the Emacs manual.)
609 @cindex Apropos
610 @item
611 You can list all of the commands whose names contain a certain word
612 (actually which match a regular expression) using @kbd{C-h a} (@kbd{M-x
613 command-apropos}).
615 @cindex Command description in the manual
616 @item
617 The command @kbd{C-h C-f} (@code{Info-goto-emacs-command-node}) prompts
618 for the name of a command, and then attempts to find the section in the
619 Emacs manual where that command is described.
621 @cindex Finding commands and variables
622 @item
623 You can list all of the functions and variables whose names contain a
624 certain word using @kbd{M-x apropos}.
626 @item
627 You can list all of the functions and variables whose documentation
628 matches a regular expression or a string, using @kbd{M-x
629 apropos-documentation}.
631 @item
632 You can order a hardcopy of the manual from the FSF.  @xref{Getting a
633 printed manual}.
635 @cindex Reference cards, in other languages
636 @item
637 You can get a printed reference card listing commands and keys to
638 invoke them.  You can order one from the FSF for $1 (or 10 for $5),
639 or you can print your own from the @file{etc/refcard.tex} or
640 @file{etc/refcard.ps} files in the Emacs distribution.  Beginning with
641 version 21.1, the Emacs distribution comes with translations of the
642 reference card into several languages; look for files named
643 @file{etc/@var{lang}-refcard.*}, where @var{lang} is a two-letter code
644 of the language.  For example, the German version of the reference card
645 is in the files @file{etc/de-refcard.tex} and @file{etc/de-refcard.ps}.
647 @item
648 There are many other commands in Emacs for getting help and
649 information.  To get a list of these commands, type @samp{?} after
650 @kbd{C-h}.
652 @end itemize
654 @node Getting a printed manual, Emacs Lisp documentation, Learning how to do something, Getting help
655 @section How do I get a printed copy of the Emacs manual?
656 @cindex Printed Emacs manual, obtaining
657 @cindex Manual, obtaining a printed or HTML copy of
658 @cindex Emacs manual, obtaining a printed or HTML copy of
660 You can order a printed copy of the Emacs manual from the FSF.  For
661 details see the @uref{http://www.gnu.org/order/order.html, GNU Web site}
662 and the file @file{etc/ORDERS}.
664 @c The number 620 below is version-dependent!
665 The full Texinfo source for the manual also comes in the @file{man}
666 directory of the Emacs distribution, if you're daring enough to try to
667 print out this 620-page manual yourself (@pxref{Printing a Texinfo
668 file}).
670 If you absolutely have to print your own copy, and you don't have @TeX{},
671 you can get a PostScript version from
673 @uref{http://www.gnu.org/manual/emacs/ps/emacs.ps.gz}
675 @cindex HTML version of Emacs manual, obtaining
676 An HTML version of the manual is at
678 @uref{www.gnu.org/manual/emacs/index.html}
680 @xref{Learning how to do something}, for how to view the manual on-line.
682 @node Emacs Lisp documentation, Installing Texinfo documentation, Getting a printed manual, Getting help
683 @section Where can I get documentation on Emacs Lisp?
684 @cindex Documentation on Emacs Lisp
685 @cindex Function documentation
686 @cindex Variable documentation
687 @cindex Emacs Lisp Reference Manual
688 @cindex Reference manual for Emacs Lisp
690 Within Emacs, you can type @kbd{C-h f} to get the documentation for a
691 function, @kbd{C-h v} for a variable.
693 For more information, obtain the Emacs Lisp Reference Manual.  Details
694 on ordering it from FSF are on the
695 @uref{http://www.gnu.org/order/order.html, GNU Web site} and in the file
696 @file{etc/ORDERS}.
698 The Emacs Lisp Reference Manual is also available on-line, in Info
699 format.  Texinfo source for the manual (along with pregenerated Info
700 files) is available at
702 @uref{ftp://ftp.gnu.org/pub/gnu/emacs/elisp-manual-21-2.6.tar.gz}
704 and all mirrors of @samp{ftp.gnu.org} (for a list, @pxref{Current GNU
705 distributions}).  @xref{Installing Texinfo documentation}, if you want
706 to install the Info files, or @ref{Printing a Texinfo file}, if you want
707 to use the Texinfo source to print the manual yourself.
709 An HTML version of the Emacs Lisp Reference Manual is available at
711 @uref{http://www.gnu.org/manual/elisp-manual-21-2.6/elisp.html}
713 @node Installing Texinfo documentation, Printing a Texinfo file, Emacs Lisp documentation, Getting help
714 @section How do I install a piece of Texinfo documentation?
715 @cindex Texinfo documentation, installing
716 @cindex Installing Texinfo documentation
717 @cindex New Texinfo files, installing
718 @cindex Documentation, installing new Texinfo files
719 @cindex Info files, how to install
721 First, you must turn the Texinfo files into Info files.  You may do this
722 using the stand-alone @file{makeinfo} program, available as part of the latest
723 Texinfo package at
725 @uref{ftp://ftp.gnu.org/pub/gnu/texinfo/texinfo-4.0.tar.gz}
727 and all mirrors of @samp{ftp.gnu.org} (for a list, @pxref{Current GNU
728 distributions}).
730 For information about the Texinfo format, read the Texinfo manual which
731 comes with the Texinfo package.  This manual also comes installed in
732 Info format, so you can read it on-line; type @kbd{C-h i m texinfo
733 @key{RET}}.
735 Alternatively, you could use the Emacs command @kbd{M-x
736 texinfo-format-buffer}, after visiting the Texinfo source file of the
737 manual you want to convert.
739 Neither @code{texinfo-format-buffer} nor @file{makeinfo} installs the
740 resulting Info files in Emacs's Info tree.  To install Info files,
741 perform these steps:
743 @enumerate
744 @item
745 Move the files to the @file{info} directory in the installed Emacs
746 distribution.  @xref{File-name conventions}, if you don't know where that
749 @item
750 Run the @code{install-info} command, which is part of the Texinfo
751 distribution, to update the main Info directory menu, like this:
753 @example
754  install-info --info-dir=@var{dir-path} @var{dir-path}/@var{file}
755 @end example
757 @noindent
758 where @var{dir-path} is the full path to the directory where you copied
759 the produced Info file(s), and @var{file} is the name of the Info file
760 you produced and want to install.
762 If you don't have the @code{install-info} command installed, you can
763 edit the file @file{info/dir} in the installed Emacs distribution, and
764 add a line for the top level node in the Info package that you are
765 installing.  Follow the examples already in this file.  The format is:
767 @example
768 * Topic: (relative-pathname).  Short description of topic.
769 @end example
771 @end enumerate
773 If you want to install Info files and you don't have the necessary
774 privileges, you have several options:
776 @itemize @bullet
777 @item
778 Info files don't actually need to be installed before being used.  You
779 can feed a file name to the @code{Info-goto-node} command (invoked by
780 pressing @key{g} in Info mode) by typing the name of the file in
781 parentheses.  This goes to the node named ``Top'' in that file.  For
782 example, to view a Info file named @file{@var{info-file}} in your home
783 directory, you can type this:
785 @example
786 @kbd{C-h i g (~/@var{info-file}) @key{RET}}
787 @end example
789 @item
790 You can create your own Info directory.  You can tell Emacs where that
791 Info directory is by adding its pathname to the value of the variable
792 @code{Info-default-directory-list}.  For example, to use a private Info
793 directory which is a subdirectory of your home directory named @file{Info},
794 you could put this in your @file{.emacs} file:
796 @lisp
797 (setq Info-default-directory-list
798       (cons "~/Info" Info-default-directory-list))
799 @end lisp
801 You will need a top-level Info file named @file{dir} in this directory
802 which has everything the system @file{dir} file has in it, except it should
803 list only entries for Info files in that directory.  You might not need
804 it if all files in this directory were referenced by other @file{dir}
805 files.  The node lists from all @file{dir} files in
806 @code{Info-default-directory-list} are merged by the Info system.
808 @end itemize
810 @node Printing a Texinfo file, Viewing Info files outside of Emacs, Installing Texinfo documentation, Getting help
811 @section How do I print a Texinfo file?
812 @cindex Printing a Texinfo file
813 @cindex Texinfo file, printing
814 @cindex Printing documentation
816 You can't get nicely printed output from Info files; you must still have
817 the original Texinfo source file for the manual you want to print.
819 Assuming you have @TeX{} installed on your system, follow these steps:
821 @enumerate
823 @item
824 Make sure the first line of the Texinfo file looks like this:
826 @example
827 \input texinfo
828 @end example
830 You may need to change @samp{texinfo} to the full pathname of the
831 @file{texinfo.tex} file, which comes with Emacs as
832 @file{man/texinfo.tex} (or copy or link it into the current directory).
834 @item
835 Type @kbd{texi2dvi @var{texinfo-source}}, where @var{texinfo-source} is
836 the name of the Texinfo source file for which you want to produce a
837 printed copy.
839 The @samp{texi2dvi} script is part of the GNU Texinfo distribution
840 (@pxref{Installing Texinfo documentation}).
842 @item
843 Print the DVI file @file{@var{texinfo-source}.dvi} in the normal way for
844 printing DVI files at your site.  For example, if you have a PostScript
845 printer, run the @code{dvips} program to print the DVI file on that
846 printer.
848 @end enumerate
850 To get more general instructions, retrieve the latest Texinfo package
851 (@pxref{Installing Texinfo documentation}).
853 @node Viewing Info files outside of Emacs, Informational files for Emacs, Printing a Texinfo file, Getting help
854 @section Can I view Info files without using Emacs?
855 @cindex Viewing Info files
856 @cindex Info file viewers
857 @cindex Alternative Info file viewers
859 Yes.  Here are some alternative programs:
861 @itemize @bullet
863 @item
864 @code{info}, a stand-alone version of the Info program, comes as part of
865 the Texinfo package.  @xref{Installing Texinfo documentation}, for
866 details.
868 @item
869 Xinfo, a stand-alone version of the Info program that runs under X
870 Window system.  You can get it at
871 @uref{ftp://ftp.gnu.org/pub/gnu/xinfo/xinfo-1.01.01.tar.gz} and all
872 mirrors of @samp{ftp.gnu.org} (see @ref{Current GNU distributions}, for a
873 list of mirrors).
875 @item
876 Tkinfo, an Info viewer that runs under X Window system and uses Tcl/Tk.
877 You can get Tkinfo at
878 @uref{http://math-www.uni-paderborn.de/~axel/tkinfo/}.
880 @end itemize
882 @node Informational files for Emacs, Help installing Emacs, Viewing Info files outside of Emacs, Getting help
883 @section What informational files are available for Emacs?
884 @cindex Informational files included with Emacs
885 @cindex Files included with Emacs
886 @cindex @file{COPYING}, description of file
887 @cindex @file{DISTRIB}, description of file
888 @cindex @file{FTP}, description of file
889 @cindex @file{GNU}, description of file
890 @cindex @file{INTERVIEW}, description of file
891 @cindex @file{LPF}, description of file
892 @cindex @file{MACHINES}, description of file
893 @cindex @file{MAILINGLISTS}, description of file
894 @cindex @file{NEWS}, description of file
895 @cindex @file{SERVICE}, description of file
896 @cindex @file{SUN-SUPPORT}, description of file
898 This isn't a frequently asked question, but it should be!  A variety of
899 informational files about Emacs and relevant aspects of the GNU project
900 are available for you to read.
902 The following files are available in the @file{etc} directory of the
903 Emacs distribution (see @ref{File-name conventions}, if you're not sure
904 where that is).
906 @table @file
908 @item COPYING
909 Emacs General Public License
911 @item DISTRIB
912 Emacs Availability Information, including the popular "Free Software
913 Foundation Order Form"
915 @item FTP
916 How to get GNU Software by Internet FTP or by UUCP
918 @item GNU
919 The GNU Manifesto
921 @item INTERVIEW
922 Richard Stallman discusses his public-domain UNIX-compatible software
923 system with BYTE editors
925 @item LPF
926 Why you should join the League for Programming Freedom
928 @item MACHINES
929 Status of Emacs on Various Machines and Systems
931 @item MAILINGLISTS
932 GNU Project Electronic Mailing Lists
934 @item NEWS
935 Emacs news, a history of recent user-visible changes
937 @item SERVICE
938 GNU Service Directory
940 @item SUN-SUPPORT
941 including "Using Emacstool with GNU Emacs"
943 @end table
945 Latest versions of the above files also available at
947 @uref{ftp://ftp.gnu.org/pub/gnu/GNUinfo/}
949 More GNU information, including back issues of the @cite{GNU's
950 Bulletin}, are at
952 @uref{http://www.gnu.org/bulletins/bulletins.html} and
954 @uref{http://www.cs.pdx.edu/~trent/gnu/gnu.html}
956 @node Help installing Emacs, Obtaining the FAQ, Informational files for Emacs, Getting help
957 @section Where can I get help in installing Emacs?
958 @cindex Installation help
959 @cindex Help installing Emacs
961 @xref{Installing Emacs}, for some basic installation hints, and see
962 @ref{Problems building Emacs}, or @ref{Linking with -lX11 fails}, if you
963 have problems with the installation.
965 The file @file{etc/SERVICE} (see @ref{File-name conventions}, if you're
966 not sure where that is) lists companies and individuals willing to sell
967 you help in installing or using Emacs.  An up-to-date version this file
968 is available on @samp{ftp.gnu.org} (@pxref{Informational files for
969 Emacs}).
971 @node Obtaining the FAQ,  , Help installing Emacs, Getting help
972 @section Where can I get the latest version of this FAQ?
973 @cindex FAQ, obtaining the
974 @cindex Latest FAQ version, obtaining the
975 @cindex Retrieving the latest FAQ version
976 @cindex E-mail, retrieving the FAQ via
977 @cindex Web, reading the FAQ on the
979 The Emacs FAQ is available in several ways:
981 @itemize @bullet
983 @item
984 Inside of Emacs itself.  You can get it from selecting the @samp{Emacs
985 FAQ} option from the @samp{Help} menu of the Emacs menu bar at the top
986 of any Emacs frame, or by typing @kbd{C-h F} (@kbd{M-x view-emacs-FAQ}).
988 @item
989 Via USENET.  If you can read news, the FAQ should be available in your
990 news spool, in both the @uref{news:gnu.emacs.help} and
991 @uref{news:comp.emacs} newsgroups.  Every news reader should allow you
992 to read any news article that is still in the news spool, even if you
993 have read the article before.  You may need to read the instructions for
994 your news reader to discover how to do this.  In @file{rn}, this command
995 will do this for you at the article selection level:
997 @example
998 ?GNU Emacs Frequently Asked Questions?rc:m
999 @end example
1001 In Gnus, you should type @kbd{C-u C-x C-s} from the @file{*Summary*}
1002 buffer or @kbd{C-u @key{SPC}} from the @file{*Newsgroup*} buffer to view
1003 all articles in a newsgroup.
1005 If the FAQ articles have expired and have been deleted from your news
1006 spool, it might (or might not) do some good to complain to your news
1007 administrator, because the most recent FAQ should not expire for a
1008 while.
1010 @item
1011 Via HTTP or FTP.  You can always fetch the latest FAQ from
1013 @uref{http://www.lerner.co.il/emacs/} and
1015 @uref{ftp://ftp.lerner.co.il/pub/emacs/}
1017 @item
1018 In the Emacs distribution.  Since Emacs 18.56, the FAQ at the time
1019 of release has been part of the Emacs distribution as either
1020 @file{etc/FAQ} or @file{man/faq.texi} (@pxref{File-name conventions}).
1022 @item
1023 Via the World Wide Web.  A hypertext version is available at
1025 @uref{http://www.lerner.co.il/emacs/}
1027 @item
1028 Via anonymous ftp and e-mail from @file{rtfm.mit.edu} (and its mirror in
1029 Europe), the main repository for FAQs and other items posted to
1030 news.answers.  The Emacs FAQs are available at
1032 @uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/} and
1034 @uref{ftp://ftp.uni-paderborn.de/pub/doc/FAQ/comp/emacs/}
1036 If you do not have access to anonymous FTP, you can access the archives
1037 using the @file{rtfm.mit.edu} mail server.  The Emacs FAQ can be
1038 retrieved by sending mail to @email{mail-server@@rtfm.mit.edu} with a
1039 blank subject and containing
1041 @example
1042 send usenet/news.answers/GNU-Emacs-FAQ/diffs
1043 send usenet/news.answers/GNU-Emacs-FAQ/part1
1044 send usenet/news.answers/GNU-Emacs-FAQ/part2
1045 send usenet/news.answers/GNU-Emacs-FAQ/part3
1046 send usenet/news.answers/GNU-Emacs-FAQ/part4
1047 send usenet/news.answers/GNU-Emacs-FAQ/part5
1048 @end example
1050 For more information, send email to @email{mail-server@@rtfm.mit.edu}
1051 with "help" and "index" in the body on separate lines.
1053 @item
1054 As the very last resort, you can e-mail a request to
1055 @email{emacs-faq@@lerner.co.il}.  Don't do this unless you have made a
1056 good-faith effort to obtain the FAQ list via one of the methods listed
1057 above.
1059 @end itemize
1061 @c ------------------------------------------------------------
1062 @node    Status of Emacs, Common requests, Getting help, Top
1063 @chapter Status of Emacs
1064 @cindex Status of Emacs
1066 This chapter gives you basic information about Emacs, including its
1067 latest version status.
1069 @menu
1070 * Origin of the term Emacs::
1071 * Latest version of Emacs::
1072 * New in Emacs 20::
1073 * New in Emacs 21::
1074 @end menu
1076 @node Origin of the term Emacs, Latest version of Emacs, Status of Emacs, Status of Emacs
1077 @section Where does the name ``Emacs'' come from?
1078 @cindex Origin of the term ``Emacs''
1079 @cindex Emacs name origin
1080 @cindex TECO
1081 @cindex Original version of Emacs
1083 Emacs originally was an acronym for Editor MACroS.  RMS says he ``picked
1084 the name Emacs because @key{E} was not in use as an abbreviation on ITS at
1085 the time.''  The first Emacs was a set of macros written in 1976 at MIT
1086 by RMS for the editor TECO (Text Editor and COrrector, originally Tape
1087 Editor and COrrector) under ITS on a PDP-10.  RMS had already extended
1088 TECO with a ``real-time'' full-screen mode with reprogrammable keys.
1089 Emacs was started by @email{gls@@east.sun.com, Guy Steele} as a project
1090 to unify the many divergent TECO command sets and key bindings at MIT,
1091 and completed by RMS.
1093 Many people have said that TECO code looks a lot like line noise; you
1094 can read more at @uref{news:alt.lang.teco}.  Someone has written a TECO
1095 implementation in Emacs Lisp (to find it, see @ref{Packages that do not
1096 come with Emacs}); it would be an interesting project to run the
1097 original TECO Emacs inside of Emacs.
1099 @cindex Why Emacs?
1100 For some not-so-serious alternative reasons for Emacs to have that
1101 name, check out the file @file{etc/JOKES} (@pxref{File-name
1102 conventions}).
1104 @node Latest version of Emacs, New in Emacs 20, Origin of the term Emacs, Status of Emacs
1105 @section What is the latest version of Emacs?
1106 @cindex Version, latest
1107 @cindex Latest version of Emacs
1109 Emacs @value{VER} is the current version as of this writing.
1111 @node New in Emacs 20,  New in Emacs 21, Latest version of Emacs, Status of Emacs
1112 @section What is different about Emacs 20?
1113 @cindex Differences between Emacs 19 and Emacs 20
1114 @cindex Emacs 20, new features in
1116 To find out what has changed in recent versions, type @kbd{C-h n}
1117 (@kbd{M-x view-emacs-news}).  The oldest changes are at the bottom of
1118 the file, so you might want to read it starting there, rather than at
1119 the top.
1121 The differences between Emacs versions 18 and 19 was rather dramatic;
1122 the introduction of frames, faces, and colors on windowing systems was
1123 obvious to even the most casual user.
1125 There are differences between Emacs versions 19 and 20 as well, but many
1126 are more subtle or harder to find.  Among the changes are the inclusion
1127 of MULE code for languages that use non-Latin characters and for mixing
1128 several languages in the same document; the ``Customize'' facility for
1129 modifying variables without having to use Lisp; and automatic conversion
1130 of files from Macintosh, Microsoft, and Unix platforms.
1132 A number of older Lisp packages, such as Gnus, Supercite and the
1133 calendar/diary, have been updated and enhanced to work with Emacs 20,
1134 and are now included with the standard distribution.
1137 @node New in Emacs 21, , New in Emacs 20, Status of Emacs
1138 @section What is different about Emacs 21?
1139 @cindex Differences between Emacs 20 and Emacs 21
1140 @cindex Emacs 21, new features in
1141 @cindex Recently introduced features
1143 @cindex Variable-size fonts
1144 @cindex Toolbar support
1145 Emacs 21 features a thorough rewrite of the display engine.  The new
1146 display engine supports variable-size fonts, images, and can play sounds
1147 on platforms which support that.  As a result, the visual appearance of
1148 Emacs, when it runs on a windowed display, is much more reminiscent of
1149 modern GUI programs, and includes 3D widgets (used for the mode line and
1150 the scroll bars), a configurable and extensible toolbar, tooltips
1151 (a.k.a.@: balloon help), and other niceties.
1153 @cindex Colors on text-only terminals
1154 @cindex TTY colors
1155 In addition, Emacs 21 supports faces on text-only terminals.  This means
1156 that you can now have colors when you run Emacs on a GNU/Linux console
1157 and on @code{xterm} with @kbd{emacs -nw}.
1159 @c ------------------------------------------------------------
1160 @node    Common requests, Bugs and problems, Status of Emacs, Top
1161 @chapter Common requests
1162 @cindex Common requests
1164 @menu
1165 * Setting up a customization file::
1166 * Debugging a customization file::
1167 * Colors on a TTY::
1168 * Displaying the current line or column::
1169 * Displaying the current file name in the titlebar::
1170 * Turning on abbrevs by default::
1171 * Turning on auto-fill by default::
1172 * Associating modes with files::
1173 * Working with unprintable characters::
1174 * Highlighting a region::
1175 * Controlling case sensitivity::
1176 * Wrapping words automatically::
1177 * Spell-checkers::
1178 * Checking TeX and *roff documents::
1179 * Changing load-path::
1180 * Using an already running Emacs process::
1181 * Compiler error messages::
1182 * Indenting switch statements::
1183 * Customizing C and C++ indentation::
1184 * Horizontal scrolling::
1185 * Overwrite mode::
1186 * Turning off beeping::
1187 * Turning the volume down::
1188 * Automatic indentation::
1189 * Matching parentheses::
1190 * Hiding #ifdef lines::
1191 * Repeating commands::
1192 * Valid X resources::
1193 * Evaluating Emacs Lisp code::
1194 * Changing the length of a Tab::
1195 * Inserting > at the beginning of each line::
1196 * Underlining paragraphs::
1197 * Repeating a command as many times as possible::
1198 * Forcing the cursor to remain in the same column::
1199 * Forcing Emacs to iconify itself::
1200 * Using regular expressions::
1201 * Replacing text across multiple files::
1202 * Documentation for etags::
1203 * Disabling backups::
1204 * Disabling auto-save-mode::
1205 * Going to a line by number::
1206 * Modifying pull-down menus::
1207 * Deleting menus and menu options::
1208 * Turning on syntax highlighting::
1209 * Scrolling only one line::
1210 * Replacing highlighted text::
1211 * Editing MS-DOS files::
1212 * Filling paragraphs with a single space::
1213 * Escape sequences in shell output::
1214 @end menu
1216 @node Setting up a customization file, Colors on a TTY, Common requests, Common requests
1217 @section How do I set up a @file{.emacs} file properly?
1218 @cindex @file{.emacs} file, setting up
1219 @cindex @file{.emacs} file, locating
1220 @cindex Init file, setting up
1221 @cindex Customization file, setting up
1223 @inforef{Init File, Init File, emacs}.
1225 In general, new Emacs users should not have @file{.emacs} files, because
1226 it causes confusing non-standard behavior.  Then they send questions to
1227 @email{help-gnu-emacs@@gnu.org} asking why Emacs isn't behaving as
1228 documented.
1230 Beginning with version 20.1, Emacs includes the new Customize
1231 facility, which can be invoked using @kbd{M-x customize @key{RET}}.
1232 This allows users who are unfamiliar with Emacs Lisp to modify their
1233 @file{.emacs} files in a relatively straightforward way, using menus
1234 rather than Lisp code.  Not all packages support Customize as of this
1235 writing, but the number is growing fairly steadily.
1237 While Customize might indeed make it easier to configure Emacs,
1238 consider taking a bit of time to learn Emacs Lisp and modifying your
1239 @file{.emacs} directly.  Simple configuration options are described
1240 rather completely in @inforef{Init File, Init File, emacs}, for users
1241 interested in performing frequently requested, basic tasks.
1243 Sometimes users are unsure as to where their @file{.emacs} file should
1244 be found.  Visiting the file as @file{~/.emacs} from Emacs will find
1245 the correct file.
1247 @node Colors on a TTY, Debugging a customization file, Setting up a customization file, Common requests
1248 @section How do I get colors and syntax highlighting on a TTY?
1249 @cindex Colors on a TTY
1250 @cindex Syntax highlighting on a TTY
1251 @cindex Console, colors
1253 In Emacs 21.1 and later, colors and faces are supported in non-windowed mode,
1254 i.e.@: on Unix and GNU/Linux text-only terminals and consoles, and when
1255 invoked as @samp{emacs -nw} on X and MS-Windows.  (Colors and faces were
1256 supported in the MS-DOS port since Emacs 19.29.)  Emacs automatically
1257 detects color support at startup and uses it if available.  If you think
1258 that your terminal supports colors, but Emacs won't use them, check the
1259 @code{termcap} entry for your display type for color-related
1260 capabilities.
1262 The command @kbd{M-x list-colors-display} pops up a window which
1263 exhibits all the colors Emacs knows about on the current display.
1265 Syntax highlighting is usually turned off by default; see @ref{Turning
1266 on syntax highlighting}, for instructions how to turn it on.
1268 @node Debugging a customization file, Displaying the current line or column, Colors on a TTY, Common requests
1269 @section How do I debug a @file{.emacs} file?
1270 @cindex Debugging @file{.emacs} file
1271 @cindex @file{.emacs} debugging
1272 @cindex Init file debugging
1273 @cindex @samp{-debug-init} option
1275 Start Emacs with the @samp{-debug-init} command-line option.  This
1276 enables the Emacs Lisp debugger before evaluating your @file{.emacs}
1277 file, and places you in the debugger if something goes wrong.  The top
1278 line in the @file{trace-back} buffer will be the error message, and the
1279 second or third line of that buffer will display the Lisp code from your
1280 @file{.emacs} file that caused the problem.
1282 You can also evaluate an individual function or argument to a function
1283 in your @file{.emacs} file by moving the cursor to the end of the
1284 function or argument and typing @kbd{C-x C-e} (@kbd{M-x
1285 eval-last-sexp}).
1287 Use @kbd{C-h v} (@kbd{M-x describe-variable}) to check the value of
1288 variables which you are trying to set or use.
1290 @node Displaying the current line or column, Displaying the current file name in the titlebar, Debugging a customization file, Common requests
1291 @section How do I make Emacs display the current line (or column) number?
1292 @cindex @code{line-number-mode}
1293 @cindex Displaying the current line or column
1294 @cindex Line number, displaying the current
1295 @cindex Column, displaying the current
1296 @cindex @code{mode-line-format}
1298 To have Emacs automatically display the current line number of the point
1299 in the mode line, do @kbd{M-x line-number-mode}.  You can also put the
1300 form
1302 @lisp
1303 (setq line-number-mode t)
1304 @end lisp
1306 @noindent
1307 in your @file{.emacs} file to achieve this whenever you start Emacs.
1308 (Line number display is on by default, unless your site-specific
1309 initialization disables it.) Note that Emacs will not display the line
1310 number if the buffer's size in bytes is larger than the value of the
1311 variable @code{line-number-display-limit}.
1313 As of Emacs 20, you can similarly display the current column with
1314 @kbd{M-x column-number-mode}, or by putting the form
1316 @lisp
1317 (setq column-number-mode t)
1318 @end lisp
1320 @noindent
1321 in your @file{.emacs} file.
1323 The @code{"%c"} format specifier in the variable @code{mode-line-format}
1324 will insert the current column's value into the mode line.  See the
1325 documentation for @code{mode-line-format} (using @kbd{C-h v
1326 mode-line-format @key{RET}}) for more information on how to set and use
1327 this variable.
1329 Users of all Emacs versions can display the current column using the
1330 @samp{column} package written by @email{abraham@@dina.kvl.dk, Per
1331 Abrahamsen}.  @xref{Packages that do not come with Emacs}, for
1332 instructions on how to get it.
1334 @cindex Set number capability in @code{vi} emulators
1335 None of the @code{vi} emulation modes provide the ``set number''
1336 capability of @code{vi} (as far as we know).  The @samp{setnu} package
1337 written by @email{kyle@@wonderworks.com, Kyle Jones} provides this
1338 feature.  So too does @samp{wb-line-number}, written by
1339 @email{naoki.y.nakamura@@nifty.com, Naoki Nakamura}.
1341 @node Displaying the current file name in the titlebar, Turning on abbrevs by default, Displaying the current line or column, Common requests
1342 @section How can I modify the titlebar to contain the current file name?
1343 @cindex Titlebar, displaying the current file name in
1344 @cindex File name, displaying in the titlebar
1345 @cindex @code{frame-title-format}
1347 The contents of an Emacs frame's titlebar is controlled by the variable
1348 @code{frame-title-format}, which has the same structure as the variable
1349 @code{mode-line-format}.  (Use @kbd{C-h v} or @kbd{M-x
1350 describe-variable} to get information about one or both of these
1351 variables.)
1353 By default, the titlebar for a frame does contain the name of the buffer
1354 currently being visited, except if there is a single frame.  In such a
1355 case, the titlebar contains Emacs invocation name and the name of the
1356 machine at which Emacs was invoked.  This is done by setting
1357 @code{frame-title-format} to the default value of
1359 @lisp
1360 (multiple-frames "%b" ("" invocation-name "@@" system-name))
1361 @end lisp
1363 To modify the behavior such that frame titlebars contain the buffer's
1364 name regardless of the number of existing frames, include the following
1365 in your @file{.emacs}:
1367 @lisp
1368 (setq frame-title-format "%b")
1369 @end lisp
1371 @node Turning on abbrevs by default, Turning on auto-fill by default, Displaying the current file name in the titlebar, Common requests
1372 @section How do I turn on abbrevs by default just in mode @var{mymode}?
1373 @cindex Abbrevs, turning on by default
1375 Put this in your @file{.emacs} file:
1377 @lisp
1378 (condition-case ()
1379    (quietly-read-abbrev-file)
1380   (file-error nil))
1382 (add-hook '@var{mymode}-mode-hook
1383           (lambda ()
1384            (setq abbrev-mode t)))
1385 @end lisp
1387 @node Turning on auto-fill by default, Associating modes with files, Turning on abbrevs by default, Common requests
1388 @section How do I turn on @code{auto-fill-mode} by default?
1389 @cindex @code{auto-fill-mode}, activating automatically
1390 @cindex Filling automatically
1391 @cindex Automatic entry to @code{auto-fill-mode}
1393 To turn on @code{auto-fill-mode} just once for one buffer, use @kbd{M-x
1394 auto-fill-mode}.
1396 To turn it on for every buffer in a certain mode, you must use the hook
1397 for that mode.  For example, to turn on @code{auto-fill} mode for all
1398 text buffers, including the following in your @file{.emacs} file:
1400 @lisp
1401 (add-hook 'text-mode-hook 'turn-on-auto-fill)
1402 @end lisp
1404 If you want @code{auto-fill} mode on in all major modes, do this:
1406 @lisp
1407 (setq-default auto-fill-function 'do-auto-fill)
1408 @end lisp
1410 @node Associating modes with files, Working with unprintable characters, Turning on auto-fill by default, Common requests
1411 @section How do I make Emacs use a certain major mode for certain files?
1412 @cindex Associating modes with files
1413 @cindex File extensions and modes
1414 @cindex @code{auto-mode-alist}, modifying
1415 @cindex Modes, associating with file extensions
1417 If you want to use a certain mode @var{foo} for all files whose names end
1418 with the extension @file{.@var{bar}}, this will do it for you:
1420 @lisp
1421 (setq auto-mode-alist (cons '("\\.@var{bar}\\'" . @var{foo}-mode) auto-mode-alist))
1422 @end lisp
1424 Otherwise put this somewhere in the first line of any file you want to
1425 edit in the mode @var{foo} (in the second line, if the first line begins
1426 with @samp{#!}):
1428 @example
1429 -*- @var{foo} -*-
1430 @end example
1432 @cindex Major mode for shell scripts
1433 Beginning with Emacs 19, the variable @code{interpreter-mode-alist}
1434 specifies which mode to use when loading a shell script.  (Emacs
1435 determines which interpreter you're using by examining the first line of
1436 the script.)  This feature only applies when the file name doesn't
1437 indicate which mode to use.  Use @kbd{C-h v} (or @kbd{M-x
1438 describe-variable}) on @code{interpreter-mode-alist} to learn more.
1440 @node Working with unprintable characters, Highlighting a region, Associating modes with files, Common requests
1441 @section How do I search for, delete, or replace unprintable (eight-bit or control) characters?
1442 @cindex Unprintable characters, working with
1443 @cindex Working with unprintable characters
1444 @cindex Control characters, working with
1445 @cindex Eight-bit characters, working with
1446 @cindex Searching for unprintable characters
1447 @cindex Regexps and unprintable characters
1449 To search for a single character that appears in the buffer as, for
1450 example, @samp{\237}, you can type @kbd{C-s C-q 2 3 7}.  (This assumes
1451 the value of @code{search-quote-char} is 17 (i.e., @kbd{C-q}).)
1452 Searching for @strong{all} unprintable characters is best done with a
1453 regular expression (@dfn{regexp}) search.  The easiest regexp to use for
1454 the unprintable chars is the complement of the regexp for the printable
1455 chars.
1457 @itemize @bullet
1459 @item
1460 Regexp for the printable chars: @samp{[\t\n\r\f -~]}
1462 @item
1463 Regexp for the unprintable chars: @samp{[^\t\n\r\f -~]}
1465 @end itemize
1467 To type these special characters in an interactive argument to
1468 @code{isearch-forward-regexp} or @code{re-search-forward}, you need to
1469 use @kbd{C-q}.  (@samp{\t}, @samp{\n}, @samp{\r}, and @samp{\f} stand
1470 respectively for @key{TAB}, @key{LFD}, @key{RET}, and @kbd{C-l}.)  So,
1471 to search for unprintable characters using @code{re-search-forward}:
1473 @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}}
1475 Using @code{isearch-forward-regexp}:
1477 @kbd{C-M-s [^ @key{TAB} @key{LFD} C-q @key{RET} C-q C-l @key{SPC} -~]}
1479 To delete all unprintable characters, simply use replace-regexp:
1481 @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}}
1483 Replacing is similar to the above.  To replace all unprintable
1484 characters with a colon, use:
1486 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}
1488 @itemize @bullet
1490 @item
1491 You don't need to quote @key{TAB} with either isearch or typing
1492 something in the minibuffer.
1494 @end itemize
1496 @node Highlighting a region, Controlling case sensitivity, Working with unprintable characters, Common requests
1497 @section How can I highlight a region of text in Emacs?
1498 @cindex Highlighting text
1499 @cindex Text, highlighting
1500 @cindex @code{transient-mark-mode}
1501 @cindex Region, highlighting a
1503 You can cause the region to be highlighted when the mark is active by
1504 including
1506 @lisp
1507 (transient-mark-mode t)
1508 @end lisp
1510 @noindent
1511 in your @file{.emacs} file.  (Also see @ref{Turning on syntax
1512 highlighting}.)
1514 @node Controlling case sensitivity, Wrapping words automatically, Highlighting a region, Common requests
1515 @section How do I control Emacs's case-sensitivity when searching/replacing?
1516 @cindex @code{case-fold-search}
1517 @cindex Case sensitivity of searches
1518 @cindex Searching without case sensitivity
1519 @cindex Ignoring case in searches
1521 For searching, the value of the variable @code{case-fold-search}
1522 determines whether they are case sensitive:
1524 @lisp
1525 (setq case-fold-search nil) ; make searches case sensitive
1526 (setq case-fold-search t)   ; make searches case insensitive
1527 @end lisp
1529 @cindex Case sensitivity in replacements
1530 @cindex Replacing, and case sensitivity
1531 @cindex @code{case-replace}
1532 Similarly, for replacing, the variable @code{case-replace} determines
1533 whether replacements preserve case.
1535 To change the case sensitivity just for one major mode, use the major
1536 mode's hook.  For example:
1538 @lisp
1539 (add-hook '@var{foo}-mode-hook
1540           (lambda ()
1541            (setq case-fold-search nil)))
1542 @end lisp
1544 @node Wrapping words automatically, Spell-checkers, Controlling case sensitivity, Common requests
1545 @section How do I make Emacs wrap words for me?
1546 @cindex Wrapping word automatically
1547 @cindex Wrapping lines
1548 @cindex Line wrap
1549 @cindex @code{auto-fill-mode}, introduction to
1550 @cindex Maximum line width, default value
1551 @cindex @code{fill-column}, default value
1553 Use @code{auto-fill-mode}, activated by typing @kbd{M-x auto-fill-mode}.
1554 The default maximum line width is 70, determined by the variable
1555 @code{fill-column}.  To learn how to turn this on automatically, see
1556 @ref{Turning on auto-fill by default}.
1558 @node Spell-checkers, Checking TeX and *roff documents, Wrapping words automatically, Common requests
1559 @section Where can I get a better spelling checker for Emacs?
1560 @cindex Checking spelling
1561 @cindex Spelling, checking text documents
1563 Use Ispell.  @xref{Ispell}.
1565 @node Checking TeX and *roff documents, Changing load-path, Spell-checkers, Common requests
1566 @section How can I spell-check @TeX{} or *roff documents?
1567 @cindex Spelling, checking @TeX{} documents
1568 @cindex @TeX{} documents, checking spelling in
1570 Use Ispell.  Ispell can handle @TeX{} and *roff documents.
1571 @xref{Ispell}.
1573 @node Changing load-path, Using an already running Emacs process, Checking TeX and *roff documents, Common requests
1574 @section How do I change @code{load-path}?
1575 @cindex @code{load-path}, modifying
1576 @cindex Modifying @code{load-path}
1577 @cindex Adding to @code{load-path}
1579 In general, you should only add to the @code{load-path}.  You can add
1580 directory @var{/dir/subdir} to the load path like this:
1582 @lisp
1583 (setq load-path (cons "/dir/subdir/" load-path))
1584 @end lisp
1586 To do this relative to your home directory:
1588 @lisp
1589 (setq load-path (cons "~/mysubdir/" load-path)
1590 @end lisp
1592 @node Using an already running Emacs process, Compiler error messages, Changing load-path, Common requests
1593 @section How do I use an already running Emacs from another window?
1594 @cindex @code{emacsclient}
1595 @cindex Emacs server functions
1596 @cindex Using an existing Emacs process
1598 @code{emacsclient}, which comes with Emacs, is for editing a file using
1599 an already running Emacs rather than starting up a new Emacs.  It does
1600 this by sending a request to the already running Emacs, which must be
1601 expecting the request.
1603 @itemize @bullet
1605 @item
1606 Setup:
1608 Emacs must have executed the @code{server-start} function for
1609 @samp{emacsclient} to work.  This can be done either by a command line
1610 option:
1612 @example
1613 emacs -f server-start
1614 @end example
1616 or by invoking @code{server-start} from @file{.emacs}:
1618 @lisp
1619 (if (@var{some conditions are met}) (server-start))
1620 @end lisp
1622 When this is done, Emacs creates a Unix domain socket.
1623 The socket is either named @file{.emacs_server}, in the user's home directory,
1624 or @file{esrv-@var{userid}-@var{systemname}}, in the @file{/tmp}
1625 directory, depending on your system.  See @code{server-socket-name}.
1627 To get your news reader, mail reader, etc., to invoke
1628 @samp{emacsclient}, try setting the environment variable @code{EDITOR}
1629 (or sometimes @code{VISUAL}) to the value @samp{emacsclient}.  You may
1630 have to specify the full pathname of the @samp{emacsclient} program
1631 instead.  Examples:
1633 @example
1634 # csh commands:
1635 setenv EDITOR emacsclient
1637 # using full pathname
1638 setenv EDITOR /usr/local/emacs/etc/emacsclient
1640 # sh command:
1641 EDITOR=emacsclient ; export EDITOR
1642 @end example
1644 @item
1645 Normal use:
1647 When @samp{emacsclient} is run, it connects to the @file{.emacs_server}
1648 socket and passes its command line options to @samp{server}.  When
1649 @samp{server} receives these requests, it sends this information to the
1650 the Emacs process, which at the next opportunity will visit the files
1651 specified.  (Line numbers can be specified just like with Emacs.)  The
1652 user will have to switch to the Emacs window by hand.  When the user is
1653 done editing a file, the user can type @kbd{C-x #} (or @kbd{M-x
1654 server-edit}) to indicate this.  If there is another buffer requested by
1655 @code{emacsclient}, Emacs will switch to it; otherwise
1656 @code{emacsclient} will exit, signaling the calling program to continue.
1658 @samp{emacsclient} and @samp{server} must be running on machines which
1659 share the same filesystem for this to work.  The pathnames that
1660 @samp{emacsclient} specifies should be correct for the filesystem that
1661 the Emacs process sees.  The Emacs process should not be suspended at
1662 the time @samp{emacsclient} is invoked.  On Unix and GNU/Linux systems,
1663 @samp{emacsclient} should either be invoked from another X window, or
1664 from a shell window inside Emacs itself, or from another interactive
1665 session, e.g., by means of a @code{screen} program.
1667 @cindex @code{gnuserv}
1668 There is an enhanced version of @samp{emacsclient}/server called
1669 @samp{gnuserv}, written by @email{ange@@hplb.hpl.hp.com, Andy Norman}
1670 (@pxref{Packages that do not come with Emacs}).  @samp{gnuserv} uses
1671 Internet domain sockets, so it can work across most network connections.
1672 It also supports the execution of arbitrary Emacs Lisp forms and does
1673 not require the client program to wait for completion.
1675 The alpha version of an enhanced @samp{gnuserv} is available at
1677 @uref{ftp://ftp.wellfleet.com/netman/psmith/emacs/gnuserv-2.1alpha.tar.gz}
1679 The version available from @uref{http://meltin.net/hacks/emacs/} is
1680 more recent, and has been tested with Emacs 21.2.
1682 @end itemize
1684 @node Compiler error messages, Indenting switch statements, Using an already running Emacs process, Common requests
1685 @section How do I make Emacs recognize my compiler's funny error messages?
1686 @cindex Compiler error messages, recognizing
1687 @cindex Recognizing non-standard compiler errors
1688 @cindex Regexps for recognizing compiler errors
1689 @cindex Errors, recognizing compiler
1691 The variable @code{compilation-error-regexp-alist} helps control how
1692 Emacs parses your compiler output.  It is a list of triplets of the form:
1693 @code{(@var{regexp} @var{file-idx} @var{line-idx})}, where @var{regexp},
1694 @var{file-idx} and @var{line-idx} are strings.  To help determine what
1695 the constituent elements should be, load @file{compile.el} and then type
1696 @kbd{C-h v compilation-error-regexp-alist @key{RET}} to see the current
1697 value.  A good idea is to look at @file{compile.el} itself as the
1698 comments included for this variable are quite useful---the regular
1699 expressions required for your compiler's output may be very close to one
1700 already provided.  Once you have determined the proper regexps, use the
1701 following to inform Emacs of your changes:
1703 @lisp
1704 (setq compilation-error-regexp-alist
1705       (cons '(@var{regexp} @var{file-idx} @var{line-idx})
1706          compilation-error-regexp-alist))
1707 @end lisp
1709 @node Indenting switch statements, Customizing C and C++ indentation, Compiler error messages, Common requests
1710 @section How do I change the indentation for @code{switch}?
1711 @cindex @code{switch}, indenting
1712 @cindex Indenting of @code{switch}
1714 Many people want to indent their @code{switch} statements like this:
1716 @example
1719   switch(x) @{
1720     case A:
1721       x1;
1722       break;
1723     case B:
1724       x2;
1725       break;
1726     default:
1727       x3;
1728   @}
1730 @end example
1732 The solution at first appears to be: set @code{c-indent-level} to 4 and
1733 @code{c-label-offset} to -2.  However, this will give you an indentation
1734 spacing of four instead of two.
1736 The @emph{real} solution is to use @code{cc-mode} (the default mode for
1737 C programming in Emacs 20 and later) and add the following line to yoyr
1738 @file{.emacs}:
1740 @lisp
1741 (c-set-offset 'case-label '+)
1742 @end lisp
1744 There appears to be no way to do this with the old @code{c-mode}.
1746 @node Customizing C and C++ indentation, Horizontal scrolling, Indenting switch statements, Common requests
1747 @section How to customize indentation in C, C@t{++}, and Java buffers?
1748 @cindex Indentation, how to customize
1749 @cindex Customize indentation
1751 The Emacs @code{cc-mode} features an interactive procedure for
1752 customizing the indentation style, which is fully explained in the
1753 @cite{CC Mode} manual that is part of the Emacs distribution, see
1754 @ref{Customizing Indentation, , Customization Indentation, ccmode,
1755 The CC Mode Manual}.  Here's a short summary of the procedure:
1757 @enumerate
1758 @item
1759 Go to the beginning of the first line where you don't like the
1760 indentation and type @kbd{C-c C-o}.  Emacs will prompt you for the
1761 syntactic symbol; type @key{RET} to accept the default it suggests.
1763 @item
1764 Emacs now prompts for the offset of this syntactic symbol, showing the
1765 default (the current definition) inside parentheses.  You can choose
1766 one of these:
1768 @table @code
1769 @item 0
1770 No extra indentation.
1771 @item +
1772 Indent one basic offset.
1773 @item -
1774 Outdent one basic offset.
1775 @item ++
1776 Indent two basic offsets
1777 @item --
1778 Outdent two basic offsets.
1779 @item *
1780 Indent half basic offset.
1781 @item /
1782 Outdent half basic offset.
1783 @end table
1785 @item
1786 After choosing one of these symbols, type @kbd{C-c C-q} to reindent
1787 the line or the block according to what you just specified.
1789 @item
1790 If you don't like the result, go back to step 1.  Otherwise, add the
1791 following line to your @file{.emacs}:
1793 @lisp
1794 (c-set-offset '@var{syntactic-symbol} @var{offset})
1795 @end lisp
1797 @noindent
1798 where @var{syntactic-symbol} is the name Emacs shows in the minibuffer
1799 when you type @kbd{C-c C-o} at the beginning of the line, and
1800 @var{offset} is one of the indentation symbols listed above (@code{+},
1801 @code{/}, @code{0}, etc.) that you've chosen during the interactive
1802 procedure.
1804 @item
1805 Go to the next line whose indentation is not to your liking and repeat
1806 the process there.
1807 @end enumerate
1809 It is recommended to put all the resulting @code{(c-set-offset ...)}
1810 customizations inside a C mode hook, like this:
1812 @lisp
1813 (defun my-c-mode-hook ()
1814   (c-set-offset ...)
1815   (c-set-offset ...))
1816 (add-hook 'c-mode-hook 'my-c-mode-hook)
1817 @end lisp
1819 @noindent
1820 Using @code{c-mode-hook} avoids the need to put a @w{@code{(require
1821 'cc-mode)}} into your @file{.emacs} file, because @code{c-set-offset}
1822 might be unavailable when @code{cc-mode} is not loaded.
1824 Note that @code{c-mode-hook} runs for C source files only; use
1825 @code{c++-mode-hook} for C@t{++} sources, @code{java-mode-hook} for
1826 Java sources, etc.  If you want the same customizations to be in
1827 effect in @emph{all} languages supported by @code{cc-mode}, use
1828 @code{c-mode-common-hook}.
1830 @node Horizontal scrolling, Overwrite mode, Customizing C and C++ indentation, Common requests
1831 @section How can I make Emacs automatically scroll horizontally?
1832 @cindex @code{hscroll-mode}
1833 @cindex Horizontal scrolling
1834 @cindex Scrolling horizontally
1836 In Emacs 21 and later, this is on by default: if the variable
1837 @code{truncate-lines} is non-@code{nil} in the current buffer, Emacs
1838 automatically scrolls the display horizontally when point moves off the
1839 left or right edge of the window.
1841 In Emacs 20, use the @code{hscroll-mode}.  Here is some information from
1842 the documentation, available by typing @kbd{C-h f hscroll-mode @key{RET}}:
1844 Automatically scroll horizontally when the point moves off the
1845 left or right edge of the window.
1847 @itemize @minus
1848 @item
1849 Type @kbd{M-x hscroll-mode} to enable it in the current buffer.
1851 @item
1852 Type @kbd{M-x hscroll-global-mode} to enable it in every buffer.
1854 @item
1855 @code{turn-on-hscroll} is useful in mode hooks as in:
1857 @lisp
1858 (add-hook 'text-mode-hook 'turn-on-hscroll)
1859 @end lisp
1861 @item
1862 @code{hscroll-margin} controls how close the cursor can get to the
1863 edge of the window.
1865 @item
1866 @code{hscroll-step-percent} controls how far to jump once we decide to do so.
1867 @end itemize
1869 @node Overwrite mode, Turning off beeping, Horizontal scrolling, Common requests
1870 @section How do I make Emacs "typeover" or "overwrite" instead of inserting?
1871 @cindex @key{Insert}
1872 @cindex @code{overwrite-mode}
1873 @cindex Overwriting existing text
1874 @cindex Toggling @code{overwrite-mode}
1876 @kbd{M-x overwrite-mode} (a minor mode).  This toggles
1877 @code{overwrite-mode} on and off, so exiting from @code{overwrite-mode}
1878 is as easy as another @kbd{M-x overwrite-mode}.
1880 On some systems, @key{Insert} toggles @code{overwrite-mode} on and off.
1882 @node Turning off beeping, Turning the volume down, Overwrite mode, Common requests
1883 @section How do I stop Emacs from beeping on a terminal?
1884 @cindex Beeping, turning off
1885 @cindex Visible bell
1886 @cindex Bell, visible
1888 @email{martin@@cc.gatech.edu, Martin R. Frank} writes:
1890 Tell Emacs to use the @dfn{visible bell} instead of the audible bell,
1891 and set the visible bell to nothing.
1893 That is, put the following in your @code{TERMCAP} environment variable
1894 (assuming you have one):
1896 @example
1897 ... :vb=: ...
1898 @end example
1900 And evaluate the following Lisp form:
1902 @example
1903 (setq visible-bell t)
1904 @end example
1906 @node Turning the volume down, Automatic indentation, Turning off beeping, Common requests
1907 @section How do I turn down the bell volume in Emacs running under X?
1908 @cindex Bell, volume of
1909 @cindex Volume of bell
1911 On X Window system, you can adjust the bell volume and duration for all
1912 programs with the shell command @code{xset}.
1914 Invoking @code{xset} without any arguments produces some basic
1915 information, including the following:
1917 @example
1918 usage:  xset [-display host:dpy] option ...
1919   To turn bell off:
1920       -b                b off               b 0
1921   To set bell volume, pitch and duration:
1922        b [vol [pitch [dur]]]          b on
1923 @end example
1925 @node Automatic indentation, Matching parentheses, Turning the volume down, Common requests
1926 @section How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
1927 @cindex Indenting new lines
1928 @cindex New lines, indenting of
1929 @cindex Previous line, indenting according to
1930 @cindex Text indentation
1932 Such behavior is automatic in Emacs 20 and later.  From the
1933 @file{etc/NEWS} file for Emacs 20.2:
1935 @example
1936 ** In Text mode, now only blank lines separate paragraphs.  This makes
1937 it possible to get the full benefit of Adaptive Fill mode in Text mode,
1938 and other modes derived from it (such as Mail mode).  @key{TAB} in Text
1939 mode now runs the command @code{indent-relative}; this makes a practical
1940 difference only when you use indented paragraphs.
1942 As a result, the old Indented Text mode is now identical to Text mode,
1943 and is an alias for it.
1945 If you want spaces at the beginning of a line to start a paragraph, use
1946 the new mode, Paragraph Indent Text mode.
1947 @end example
1949 @cindex Prefixing lines
1950 @cindex Fill prefix
1951 If you have @code{auto-fill-mode} turned on (@pxref{Turning on auto-fill
1952 by default}), you can tell Emacs to prefix every line with a certain
1953 character sequence, the @dfn{fill prefix}.  Type the prefix at the
1954 beginning of a line, position point after it, and then type @kbd{C-x .}
1955 (@code{set-fill-prefix}) to set the fill prefix.  Thereafter,
1956 auto-filling will automatically put the fill prefix at the beginning of
1957 new lines, and @kbd{M-q} (@code{fill-paragraph}) will maintain any fill
1958 prefix when refilling the paragraph.
1960 If you have paragraphs with different levels of indentation, you will
1961 have to set the fill prefix to the correct value each time you move to a
1962 new paragraph.  There are many packages available to deal with this
1963 (@pxref{Packages that do not come with Emacs}).  Look for ``fill'' and
1964 ``indent'' keywords for guidance.
1966 @node Matching parentheses, Hiding #ifdef lines, Automatic indentation, Common requests
1967 @section How do I show which parenthesis matches the one I'm looking at?
1968 @cindex Parentheses, matching
1969 @cindex @file{paren.el}
1970 @cindex Highlighting matching parentheses
1971 @cindex Pairs of parentheses, highlighting
1972 @cindex Matching parentheses
1974 As of version 19, Emacs comes with @file{paren.el}, which (when loaded)
1975 will automatically highlight matching parentheses whenever point (i.e.,
1976 the cursor) is located over one.  To load @file{paren.el} automatically,
1977 include the line
1979 @lisp
1980 (require 'paren)
1981 @end lisp
1983 in your @file{.emacs} file.  @email{shutkoa@@ugsolutions.com, Alan Shutko}
1984 reports that as of version 20.1, you must also call @code{show-paren-mode} in
1985 your @file{.emacs} file:
1987 @lisp
1988 (show-paren-mode 1)
1989 @end lisp
1991 Customize will let you turn on @code{show-paren-mode}.  Use @kbd{M-x
1992 customize-group @key{RET} paren-showing @key{RET}}.  From within
1993 Customize, you can also go directly to the ``paren-showing'' group.
1995 Alternatives to paren include:
1997 @itemize @bullet
1999 @item
2000 If you're looking at a right parenthesis (or brace or bracket) you can
2001 delete it and reinsert it.  Emacs will momentarily move the cursor to
2002 the matching parenthesis.
2004 @item
2005 @kbd{C-M-f} (@code{forward-sexp}) and @kbd{C-M-b} (@code{backward-sexp})
2006 will skip over one set of balanced parentheses, so you can see which
2007 parentheses match.  (You can train it to skip over balanced brackets
2008 and braces at the same time by modifying the syntax table.)
2010 @cindex Show matching paren as in @code{vi}
2011 @item
2012 Here is some Emacs Lisp that will make the @key{%} key show the matching
2013 parenthesis, like in @code{vi}.  In addition, if the cursor isn't over a
2014 parenthesis, it simply inserts a % like normal.
2016 @lisp
2017 ;; By an unknown contributor
2019 (global-set-key "%" 'match-paren)
2021 (defun match-paren (arg)
2022   "Go to the matching paren if on a paren; otherwise insert %."
2023   (interactive "p")
2024   (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
2025         ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
2026         (t (self-insert-command (or arg 1)))))
2027 @end lisp
2029 @end itemize
2031 @node Hiding #ifdef lines, Repeating commands, Matching parentheses, Common requests
2032 @section In C mode, can I show just the lines that will be left after @code{#ifdef} commands are handled by the compiler?
2033 @cindex @code{#ifdef}, selective display of
2034 @cindex @code{hide-ifdef-mode}
2035 @cindex Hiding @code{#ifdef} text
2036 @cindex Selectively displaying @code{#ifdef} code
2038 @kbd{M-x hide-ifdef-mode}.  (This is a minor mode.)  You might also want
2039 to investigate @file{cpp.el}, which is distributed with Emacs.
2041 @node Repeating commands, Valid X resources, Hiding #ifdef lines, Common requests
2042 @section Is there an equivalent to the @code{.} (dot) command of vi?
2043 @cindex Repeating commands as with @code{vi}
2044 @cindex Command, repeat last
2045 @cindex @code{.}, equivalent to @code{vi} command
2047 (@code{.} is the redo command in @code{vi}.  It redoes the last
2048 insertion/deletion.)
2050 As of Emacs 20.3, there is indeed a @code{repeat} command (@kbd{C-x z})
2051 that repeats the last command.  If you preface it with a prefix
2052 argument, the prefix arg is applied to the command.
2054 You can also type @kbd{C-x @key{ESC} @key{ESC}}
2055 (@code{repeat-complex-command}) to reinvoke commands that used the
2056 minibuffer to get arguments.  In @code{repeat-complex-command} you can
2057 type @kbd{M-p} and @kbd{M-n} (and also up-arrow and down-arrow, if your
2058 keyboard has these keys) to scan through all the different complex
2059 commands you've typed.
2061 To repeat a set of commands, use keyboard macros.  (@inforef{Keyboard
2062 Macros, Keyboard Macros, emacs}.)
2064 If you're really desperate for the @code{.} command, use VIPER, a
2065 @code{vi} emulation mode which comes with Emacs, and which appears to
2066 support it.  (@xref{VIPER}.)
2068 @node Valid X resources, Evaluating Emacs Lisp code, Repeating commands, Common requests
2069 @section What are the valid X resource settings (i.e., stuff in .Xdefaults)?
2070 @cindex Resources, X
2071 @cindex X resources
2072 @cindex Setting X resources
2074 @inforef{X Resources, X Resources, emacs}.
2076 You can also use a resource editor, such as editres (for X11R5 and
2077 onwards), to look at the resource names for the menu bar, assuming Emacs
2078 was compiled with the X toolkit.
2080 @node Evaluating Emacs Lisp code, Changing the length of a Tab, Valid X resources, Common requests
2081 @section How do I execute ("evaluate") a piece of Emacs Lisp code?
2082 @cindex Evaluating Lisp code
2083 @cindex Lisp forms, evaluating
2085 There are a number of ways to execute (@dfn{evaluate}, in Lisp lingo) an
2086 Emacs Lisp @dfn{form}:
2088 @itemize @bullet
2090 @item
2091 If you want it evaluated every time you run Emacs, put it in a file
2092 named @file{.emacs} in your home directory.  This is known as ``your
2093 @file{.emacs} file,'' and contains all of your personal customizations.
2095 @item
2096 You can type the form in the @file{*scratch*} buffer, and then type
2097 @key{LFD} (or @kbd{C-j}) after it.  The result of evaluating the form
2098 will be inserted in the buffer.
2100 @item
2101 In @code{emacs-lisp-mode}, typing @kbd{C-M-x} evaluates a top-level form
2102 before or around point.
2104 @item
2105 Typing @kbd{C-x C-e} in any buffer evaluates the Lisp form immediately
2106 before point and prints its value in the echo area.
2108 @item
2109 Typing @kbd{M-:} or @kbd{M-x eval-expression} allows you to type a Lisp
2110 form in the minibuffer which will be evaluated once you press @key{RET}.
2112 @item
2113 You can use @kbd{M-x load-file} to have Emacs evaluate all the Lisp
2114 forms in a file.  (To do this from Lisp use the function @code{load}
2115 instead.)
2117 The functions @code{load-library}, @code{eval-region},
2118 @code{eval-current-buffer}, @code{require}, and @code{autoload} are also
2119 useful; see @ref{Emacs Lisp documentation}, if you want to learn more
2120 about them.
2122 @end itemize
2124 @node Changing the length of a Tab, Inserting > at the beginning of each line, Evaluating Emacs Lisp code, Common requests
2125 @section How do I change Emacs's idea of the @key{TAB} character's length?
2126 @cindex Tab length
2127 @cindex Length of tab character
2128 @cindex @code{default-tab-width}
2130 Set the variable @code{default-tab-width}.  For example, to set
2131 @key{TAB} stops every 10 characters, insert the following in your
2132 @file{.emacs} file:
2134 @lisp
2135 (setq default-tab-width 10)
2136 @end lisp
2138 Do not confuse variable @code{tab-width} with variable
2139 @code{tab-stop-list}.  The former is used for the display of literal
2140 @key{TAB} characters.  The latter controls what characters are inserted
2141 when you press the @key{TAB} character in certain modes.
2143 @node Inserting > at the beginning of each line, Underlining paragraphs, Changing the length of a Tab, Common requests
2144 @section How do I insert @samp{>} at the beginning of every line?
2145 @cindex Prefix character, inserting in mail/news replies
2146 @cindex Replies to mail/news, inserting a prefix character
2147 @cindex @code{mail-yank-prefix}
2148 @cindex Mail replies, inserting a prefix character
2149 @cindex News replies, inserting a prefix character
2151 To do this to an entire buffer, type @kbd{M-< M-x replace-regexp
2152 @key{RET} ^ @key{RET} > @key{RET}}.
2154 To do this to a region, use @code{string-insert-rectangle}.
2155 Set the mark (@kbd{C-@key{SPC}}) at the beginning of the first line you
2156 want to prefix, move the cursor to last line to be prefixed, and type
2157 @kbd{M-x string-insert-rectangle @key{RET}}.  To do this for the whole
2158 buffer, type @kbd{C-x h M-x string-insert-rectangle @key{RET}}.
2160 If you are trying to prefix a yanked mail message with @samp{>}, you
2161 might want to set the variable @code{mail-yank-prefix}.  Better yet, use
2162 the Supercite package (@pxref{Supercite}), which provides flexible
2163 citation for yanked mail and news messages; it is included in Emacs
2164 since version 19.20.  @xref{Changing the included text prefix}, for
2165 additional information.
2167 @node Underlining paragraphs, Repeating a command as many times as possible, Inserting > at the beginning of each line, Common requests
2168 @section How do I insert "_^H" before each character in a region to get an underlined paragraph?
2169 @cindex Underlining a region of text
2170 @cindex @code{underline-region}
2172 Mark the region and then type @kbd{M-x underline-region @key{RET}}.
2174 @node Repeating a command as many times as possible, Forcing the cursor to remain in the same column, Underlining paragraphs, Common requests
2175 @section How do I repeat a command as many times as possible?
2176 @cindex Repeating commands many times
2177 @cindex Commands, repeating many times
2179 Use @kbd{C-x (} and @kbd{C-x )} to make a keyboard macro that invokes
2180 the command and then type @kbd{M-0 C-x e}.
2182 Any messages your command prints in the echo area will be suppressed.
2184 If you need to repeat a command a small number of times, you can use
2185 @kbd{C-x z}, see @ref{Repeating commands}.
2187 @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
2188 @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?
2189 @cindex @code{picture-mode}
2190 @cindex Remaining in the same column, regardless of contents
2191 @cindex Vertical movement in empty documents
2193 @kbd{M-x picture-mode}.
2195 @node Forcing Emacs to iconify itself, Using regular expressions, Forcing the cursor to remain in the same column, Common requests
2196 @section How do I tell Emacs to iconify itself?
2197 @cindex Iconification under the X Window System
2198 @cindex X Window System and iconification
2199 @cindex Suspending Emacs
2201 @kbd{C-z} iconifies Emacs when running under X and suspends Emacs
2202 otherwise.  @inforef{Frame Commands, Frame Commands, emacs}.
2204 @node Using regular expressions, Replacing text across multiple files, Forcing Emacs to iconify itself, Common requests
2205 @section How do I use regexps (regular expressions) in Emacs?
2206 @cindex Regexps
2207 @cindex Regular expressions
2208 @cindex Differences between Unix and Emacs regexps
2209 @cindex Unix regeps, differences from Emacs
2210 @cindex Text strings, putting regexps in
2212 @inforef{Regexps, Regexps, emacs}.
2214 The @code{or} operator is @samp{\|}, not @samp{|}, and the grouping operators
2215 are @samp{\(} and @samp{\)}.  Also, the string syntax for a backslash is
2216 @samp{\\}.  To specify a regular expression like @samp{xxx\(foo\|bar\)}
2217 in a Lisp string, use @samp{xxx\\(foo\\|bar\\)}.
2219 Note the doubled backslashes!
2221 @itemize @bullet
2223 @item
2224 Unlike in Unix @file{grep}, @file{sed}, etc., a complement character set
2225 (@samp{[^...]})  can match a newline character (@key{LFD} a.k.a.@:
2226 @kbd{C-j} a.k.a.@: @samp{\n}), unless newline is mentioned as one of the
2227 characters not to match.
2229 @item
2230 The character syntax regexps (e.g., @samp{\sw}) are not
2231 meaningful inside character set regexps (e.g., @samp{[aeiou]}).  (This
2232 is actually typical for regexp syntax.)
2234 @end itemize
2236 @node Replacing text across multiple files, Documentation for etags, Using regular expressions, Common requests
2237 @section How do I perform a replace operation across more than one file?
2238 @cindex Replacing strings across files
2239 @cindex Multiple files, replacing across
2240 @cindex Files, replacing strings across multiple
2242 The ``tags'' feature of Emacs includes the command
2243 @code{tags-query-replace} which performs a query-replace across all the
2244 files mentioned in the @file{TAGS} file.  @inforef{Tags Search, Tags Search,
2245 emacs}.
2247 As of Emacs 19.29, Dired mode (@kbd{M-x dired @key{RET}}, or @kbd{C-x
2248 d}) supports the command @code{dired-do-query-replace}, which allows
2249 users to replace regular expressions in multiple files.
2251 @node Documentation for etags, Disabling backups, Replacing text across multiple files, Common requests
2252 @section Where is the documentation for @code{etags}?
2253 @cindex Documentation for @code{etags}
2254 @cindex @code{etags}, documentation for
2256 The @code{etags} man page should be in the same place as the
2257 @code{emacs} man page.
2259 Quick command-line switch descriptions are also available.  For example,
2260 @samp{etags -H}.
2262 @node Disabling backups, Disabling auto-save-mode, Documentation for etags, Common requests
2263 @section How do I disable backup files?
2264 @cindex Backups, disabling
2265 @cindex Disabling backups
2267 You probably don't want to do this, since backups are useful, especially
2268 when something goes wrong.
2270 To avoid seeing backup files (and other "uninteresting" files) in Dired,
2271 load @code{dired-x} by adding the following to your @file{.emacs} file:
2273 @lisp
2274 (add-hook 'dired-load-hook
2275           (lambda ()
2276            (load "dired-x")))
2277 @end lisp
2279 With @code{dired-x} loaded, @kbd{M-o} toggles omitting in each dired buffer.
2280 You can make omitting the default for new dired buffers by putting the
2281 following in your @file{.emacs}:
2283 @lisp
2284 (add-hook 'dired-mode-hook 'dired-omit-toggle)
2285 @end lisp
2287 If you're tired of seeing backup files whenever you do an @samp{ls} at
2288 the Unix shell, try GNU @code{ls} with the @samp{-B} option.  GNU
2289 @code{ls} is part of the GNU Fileutils package, available from
2290 @samp{ftp.gnu.org} and its mirrors (@pxref{Current GNU distributions}).
2292 To disable or change the way backups are made, @inforef{Backup Names, ,
2293 emacs}.
2295 @cindex Backup files in a single directory
2296 Beginning with Emacs 21.1, you can control where Emacs puts backup files
2297 by customizing the variable @code{backup-directory-alist}.  This
2298 variable's value specifies that files whose names match specific patters
2299 should have their backups put in certain directories.  A typical use is
2300 to add the element @code{("." . @var{dir})} to force Emacs to put
2301 @strong{all} backup files in the directory @file{dir}.
2303 @node Disabling auto-save-mode, Going to a line by number, Disabling backups, Common requests
2304 @section How do I disable @code{auto-save-mode}?
2305 @cindex Disabling @code{auto-save-mode}
2306 @cindex Auto-saving
2307 @cindex Saving at frequent intervals
2309 You probably don't want to do this, since auto-saving is useful,
2310 especially when Emacs or your computer crashes while you are editing a
2311 document.
2313 Instead, you might want to change the variable
2314 @code{auto-save-interval}, which specifies how many keystrokes Emacs
2315 waits before auto-saving.  Increasing this value forces Emacs to wait
2316 longer between auto-saves, which might annoy you less.
2318 You might also want to look into Sebastian Kremer's @code{auto-save}
2319 package (@pxref{Packages that do not come with Emacs}).  This
2320 package also allows you to place all auto-save files in one directory,
2321 such as @file{/tmp}.
2323 To disable or change how @code{auto-save-mode} works, @inforef{Auto
2324 Save, , emacs}.
2326 @node Going to a line by number, Modifying pull-down menus, Disabling auto-save-mode, Common requests
2327 @section How can I go to a certain line given its number?
2328 @cindex Going to a line by number
2329 @cindex Compilation error messages
2330 @cindex Recompilation
2332 Are you sure you indeed need to go to a line by its number?  Perhaps all
2333 you want is to display a line in your source file for which a compiler
2334 printed an error message?  If so, compiling from within Emacs using the
2335 @kbd{M-x compile} and @kbd{M-x recompile} commands is a much more
2336 effective way of doing that.  Emacs automatically intercepts the compile
2337 error messages, inserts them into a special buffer called
2338 @code{*compilation*}, and lets you visit the locus of each message in
2339 the source.  Type @kbd{C-x `} to step through the offending lines one by
2340 one.  Click @kbd{Mouse-2} or press @key{RET} on a message text in the
2341 @code{*compilation*} buffer to go to the line whose number is mentioned
2342 in that message.
2344 But if you indeed need to go to a certain text line, type @kbd{M-x
2345 goto-line @key{RET}}.  Emacs will prompt you for the number of the line
2346 and go to that line.
2348 You can do this faster by invoking @code{goto-line} with a numeric
2349 argument that is the line's number.  For example, @kbd{C-u 286 M-x
2350 goto-line @key{RET}} will jump to line number 286 in the current
2351 buffer.
2353 If you need to use this command frequently, you might consider binding
2354 it to a key.  The following snippet, if added to your @file{~/.emacs}
2355 file, will bind the sequence @kbd{C-x g} to @code{goto-line}:
2357 @lisp
2358  (global-set-key "\C-xg" 'goto-line)
2359 @end lisp
2362 @node Modifying pull-down menus, Deleting menus and menu options, Going to a line by number, Common requests
2363 @section How can I create or modify new pull-down menu options?
2364 @cindex Pull-down menus, creating or modifying
2365 @cindex Menus, creating or modifying
2366 @cindex Creating new menu options
2367 @cindex Modifying pull-down menus
2368 @cindex Menus and keymaps
2369 @cindex Keymaps and menus
2371 Each menu title (e.g., @samp{File}, @samp{Edit}, @samp{Buffers})
2372 represents a local or global keymap.  Selecting a menu title with the
2373 mouse displays that keymap's non-nil contents in the form of a menu.
2375 So to add a menu option to an existing menu, all you have to do is add a
2376 new definition to the appropriate keymap.  Adding a @samp{Forward Word}
2377 item to the @samp{Edit} menu thus requires the following Lisp code:
2379 @lisp
2380 (define-key global-map
2381   [menu-bar edit forward]
2382   '("Forward word" . forward-word))
2383 @end lisp
2385 @noindent
2386 The first line adds the entry to the global keymap, which includes
2387 global menu bar entries.  Replacing the reference to @code{global-map}
2388 with a local keymap would add this menu option only within a particular
2389 mode.
2391 The second line describes the path from the menu-bar to the new entry.
2392 Placing this menu entry underneath the @samp{File} menu would mean
2393 changing the word @code{edit} in the second line to @code{file}.
2395 The third line is a cons cell whose first element is the title that will
2396 be displayed, and whose second element is the function that will be
2397 called when that menu option is invoked.
2399 To add a new menu, rather than a new option to an existing menu, we must
2400 define an entirely new keymap:
2402 @lisp
2403 (define-key global-map [menu-bar words]
2404   (cons "Words" (make-sparse-keymap "Words")))
2405 @end lisp
2407 The above code creates a new sparse keymap, gives it the name
2408 @samp{Words}, and attaches it to the global menu bar.  Adding the
2409 @samp{Forward Word} item to this new menu would thus require the
2410 following code:
2412 @lisp
2413 (define-key global-map
2414   [menu-bar words forward]
2415   '("Forward word" . forward-word))
2416 @end lisp
2418 @noindent
2419 Note that because of the way keymaps work, menu options are displayed
2420 with the more recently defined items at the top.  Thus if you were to
2421 define menu options @samp{foo}, @samp{bar}, and @samp{baz} (in that
2422 order), the menu option @samp{baz} would appear at the top, and
2423 @samp{foo} would be at the bottom.
2425 One way to avoid this problem is to use the function @code{define-key-after},
2426 which works the same as @code{define-key}, but lets you modify where items
2427 appear.  The following Lisp code would insert the @samp{Forward Word}
2428 item in the @samp{Edit} menu immediately following the @samp{Undo} item:
2430 @lisp
2431 (define-key-after
2432   (lookup-key global-map [menu-bar edit])
2433   [forward]
2434   '("Forward word" . forward-word)
2435   'undo)
2436 @end lisp
2438 Note how the second and third arguments to @code{define-key-after} are
2439 different from those of @code{define-key}, and that we have added a new
2440 (final) argument, the function after which our new key should be
2441 defined.
2443 To move a menu option from one position to another, simply evaluate
2444 @code{define-key-after} with the appropriate final argument.
2446 More detailed information---and more examples of how to create and
2447 modify menu options---are in the @cite{Emacs Lisp Reference Manual}, under
2448 ``Menu Keymaps''.  (@xref{Emacs Lisp documentation}, for information on
2449 this manual.)
2451 @node Deleting menus and menu options, Turning on syntax highlighting, Modifying pull-down menus, Common requests
2452 @section How do I delete menus and menu options?
2453 @cindex Deleting menus and menu options
2454 @cindex Menus, deleting
2456 The simplest way to remove a menu is to set its keymap to @samp{nil}.
2457 For example, to delete the @samp{Words} menu (@pxref{Modifying pull-down
2458 menus}), use:
2460 @lisp
2461 (define-key global-map [menu-bar words] nil)
2462 @end lisp
2464 Similarly, removing a menu option requires redefining a keymap entry to
2465 @code{nil}.  For example, to delete the @samp{Forward word} menu option
2466 from the @samp{Edit} menu (we added it in @ref{Modifying pull-down
2467 menus}), use:
2469 @lisp
2470 (define-key global-map [menu-bar edit forward] nil)
2471 @end lisp
2473 @node Turning on syntax highlighting, Scrolling only one line, Deleting menus and menu options, Common requests
2474 @section How do I turn on syntax highlighting?
2475 @cindex Syntax highlighting
2476 @cindex @code{font-lock-mode}
2477 @cindex Highlighting based on syntax
2478 @cindex Colorizing text
2479 @cindex FAQ, @code{font-lock-mode}
2481 @code{font-lock-mode} is the standard way to have Emacs perform syntax
2482 highlighting in the current buffer.  With @code{font-lock-mode} turned
2483 on, different types of text will appear in different colors.  For
2484 instance, if you turn on @code{font-lock-mode} in a programming mode,
2485 variables will appear in one face, keywords in a second, and comments in
2486 a third.
2488 @cindex hilit19 is deprecated
2489 Earlier versions of Emacs supported hilit19, a similar package.  Use of
2490 hilit19 is now considered non-standard, although @file{hilit19.el} comes
2491 with the stock Emacs distribution.  It is no longer maintained.
2493 To turn @code{font-lock-mode} on within an existing buffer, use @kbd{M-x
2494 font-lock-mode @key{RET}}.
2496 To automatically invoke @code{font-lock-mode} when a particular major
2497 mode is invoked, set the major mode's hook.  For example, to fontify all
2498 @code{c-mode} buffers, add the following to your @file{.emacs} file:
2500 @lisp
2501 (add-hook 'c-mode-hook 'turn-on-font-lock)
2502 @end lisp
2504 To automatically invoke @code{font-lock-mode} for all major modes, you
2505 can turn on @code{global-font-lock-mode} by including the following line
2506 in your @file{.emacs} file:
2508 @lisp
2509 (global-font-lock-mode 1)
2510 @end lisp
2512 @noindent
2513 This instructs Emacs to turn on font-lock mode in those buffers for
2514 which a font-lock mode definition has been provided (in the variable
2515 @code{font-lock-global-modes}).  If you edit a file in
2516 @code{pie-ala-mode}, and no font-lock definitions have been provided for
2517 @code{pie-ala} files, then the above setting will have no effect on that
2518 particular buffer.
2520 Highlighting a buffer with @code{font-lock-mode} can take quite a while,
2521 and cause an annoying delay in display, so several features exist to
2522 work around this.
2524 @cindex Just-In-Time syntax highlighting
2525 In Emacs 21 and later, turning on @code{font-lock-mode} automatically
2526 activates the new @dfn{Just-In-Time fontification} provided by
2527 @code{jit-lock-mode}.  @code{jit-lock-mode} defers the fontification of
2528 portions of buffer until you actually need to see them, and can also
2529 fontify while Emacs is idle.  This makes display of the visible portion
2530 of a buffer almost instantaneous.  For details about customizing
2531 @code{jit-lock-mode}, type @kbd{C-h f jit-lock-mode @key{RET}}.
2533 @cindex Levels of syntax highlighting
2534 @cindex Decoration level, in @code{font-lock-mode}
2535 In versions of Emacs before 21, different levels of decoration are
2536 available, from slight to gaudy.  More decoration means you need to wait
2537 more time for a buffer to be fontified (or a faster machine).  To
2538 control how decorated your buffers should become, set the value of
2539 @code{font-lock-maximum-decoration} in your @file{.emacs} file, with a
2540 @code{nil} value indicating default (usually minimum) decoration, and a
2541 @code{t} value indicating the maximum decoration.  For the gaudiest
2542 possible look, then, include the line
2544 @lisp
2545 (setq font-lock-maximum-decoration t)
2546 @end lisp
2548 @noindent
2549 in your @file{.emacs} file.  You can also set this variable such that
2550 different modes are highlighted in a different ways; for more
2551 information, see the documentation for
2552 @code{font-lock-maximum-decoration} with @kbd{C-h v} (or @kbd{M-x
2553 describe-variable @key{RET}}).
2555 @cindex Lazy font-lock
2556 You might also want to investigate @code{fast-lock-mode} and
2557 @code{lazy-lock-mode}, versions of @code{font-lock-mode} that speed up
2558 highlighting.  These are the alternatives for @code{jit-lock-mode} in
2559 versions of Emacs before 21.1.  The advantage of @code{lazy-lock-mode}
2560 is that it only fontifies buffers when certain conditions are met, such
2561 as after a certain amount of idle time, or after you have finished
2562 scrolling through text.  See the documentation for @code{lazy-lock-mode}
2563 by typing @kbd{C-h f @code{lazy-lock-mode}} (@kbd{M-x describe-function
2564 @key{RET} lazy-lock-mode @key{RET}}).
2566 Also see the documentation for the function @code{font-lock-mode},
2567 available by typing @kbd{C-h f font-lock-mode} (@kbd{M-x
2568 describe-function @key{RET} font-lock-mode @key{RET}}).
2570 For more information on font-lock mode, take a look at the
2571 @code{font-lock-mode} FAQ, maintained by
2572 @email{jari.aalto@@ntc.nokia.com, Jari Aalto} at
2574 @uref{ftp://cs.uta.fi/pub/ssjaaa/ema-font.gui}
2576 To print buffers with the faces (i.e., colors and fonts) intact, use
2577 @kbd{M-x ps-print-buffer-with-faces} or @kbd{M-x
2578 ps-print-region-with-faces}.  You will need a way to send text to a
2579 PostScript printer, or a PostScript interpreter such as Ghostscript;
2580 consult the documentation of the variables @code{ps-printer-name},
2581 @code{ps-lpr-command}, and @code{ps-lpr-switches} for more details.
2583 @node Scrolling only one line, Replacing highlighted text, Turning on syntax highlighting, Common requests
2584 @section How can I force Emacs to scroll only one line when I move past the bottom of the screen?
2585 @cindex Scrolling only one line
2586 @cindex Reducing the increment when scrolling
2588 Place the following Lisp form in your @file{.emacs} file:
2590 @lisp
2591 (setq scroll-step 1)
2592 @end lisp
2594 @inforef{Scrolling, Scrolling, emacs}.
2596 @node Replacing highlighted text, Editing MS-DOS files, Scrolling only one line, Common requests
2597 @section How can I replace highlighted text with what I type?
2598 @cindex @code{delete-selection-mode}
2599 @cindex Replacing highlighted text
2600 @cindex Highlighting and replacing text
2602 Use @code{delete-selection-mode}, which you can start automatically by
2603 placing the following Lisp form in your @file{.emacs} file:
2605 @lisp
2606 (delete-selection-mode t)
2607 @end lisp
2609 According to the documentation string for @code{delete-selection-mode}
2610 (which you can read using @kbd{M-x describe-function @key{RET}
2611 delete-selection-mode @key{RET}}):
2613 @quotation
2614 When ON, typed text replaces the selection if the selection is active.
2615 When OFF, typed text is just inserted at point.
2616 @end quotation
2618 This mode also allows you to delete (not kill) the highlighted region by
2619 pressing @key{DEL}.
2621 @node Editing MS-DOS files, Filling paragraphs with a single space, Replacing highlighted text, Common requests
2622 @section How can I edit MS-DOS files using Emacs?
2623 @cindex Editing MS-DOS files
2624 @cindex MS-DOS files, editing
2625 @cindex Microsoft files, editing
2626 @cindex Windows files, editing
2628 As of Emacs 20, detection and handling of MS-DOS (and Windows) files is
2629 performed transparently.  You can open MS-DOS files on a Unix system,
2630 edit it, and save it without having to worry about the file format.
2632 When editing an MS-DOS style file, the mode line will indicate that it
2633 is a DOS file.  On Unix and GNU/Linux systems, and also on a Macintosh,
2634 the string @samp{(DOS)} will appear near the left edge of the mode line;
2635 on DOS and Windows, where the DOS end-of-line (EOL) format is the
2636 default, a backslash (@samp{\}) will appear in the mode line.
2638 If you are running a version of Emacs before 20.1, get @code{crypt++}
2639 (@pxref{Packages that do not come with Emacs}).  Among other things, 
2640 @code{crypt++} transparently modifies MS-DOS files as they are loaded
2641 and saved, allowing you to ignore the different conventions that Unix
2642 and MS-DOS have for delineating the end of a line.
2644 @node Filling paragraphs with a single space,  Escape sequences in shell output, Editing MS-DOS files, Common requests
2645 @section How can I tell Emacs to fill paragraphs with a single space after each period?
2646 @cindex One space following periods
2647 @cindex Single space following periods
2648 @cindex Periods, one space following
2650 @email{ulm@@vsnhd1.cern.ch, Ulrich Mueller} suggests adding the
2651 following two lines to your @file{.emacs} file:
2653 @lisp
2654 (setq sentence-end "[.?!][]\"')@}]*\\($\\|[ \t]\\)[ \t\n]*")
2655 (setq sentence-end-double-space nil)
2656 @end lisp
2658 @node Escape sequences in shell output, , Filling paragraphs with a single space, Common requests
2659 @section Why these strange escape sequences from @code{ls} from the Shell mode?
2660 @cindex Escape sequences in @code{ls} output
2661 @cindex @code{ls} in Shell mode
2663 This happens because @code{ls} is aliased to @samp{ls --color} in your
2664 shell init file.  You have two alternatives to solve this:
2666 @itemize @bullet
2667 @item
2668 Make the alias conditioned on the @code{EMACS} variable in the
2669 environment.  When Emacs runs a subsidiary shell, it exports the
2670 @code{EMACS} variable with the value @code{t} to that shell.  You can
2671 unalias @code{ls} when that happens, thus limiting the alias to your
2672 interactive sessions.
2674 @item
2675 Install the @code{ansi-color} package (bundled with Emacs 21.1 and
2676 later), which converts these ANSI escape sequences into colors.
2677 @end itemize
2679 @c ------------------------------------------------------------
2680 @node    Bugs and problems, Compiling and installing Emacs, Common requests, Top
2681 @chapter Bugs and problems
2682 @cindex Bugs and problems
2684 The Emacs manual lists some common kinds of trouble users could get
2685 into, see @ref{Lossage, , Dealing with Emacs Trouble, emacs, The GNU
2686 Emacs Manual}, so you might look there if the problem you encounter
2687 isn't described in this chapter.  If you decide you've discovered a bug,
2688 see @ref{Bugs, , Reporting Bugs, emacs, The GNU Emacs Manual}, for
2689 instructions how to do that.
2691 The file @file{etc/PROBLEMS} in the Emacs distribution lists various
2692 known problems with building and using Emacs on specific platforms;
2693 type @kbd{C-h P} to read it.
2695 @menu
2696 * Problems with very large files::
2697 * ^M in the shell buffer::
2698 * Shell process exits abnormally::
2699 * Problems with Shell Mode on MS-Windows::
2700 * Termcap/Terminfo entries for Emacs::
2701 * Spontaneous entry into isearch-mode::
2702 * Problems talking to certain hosts::
2703 * Errors with init files::
2704 * Emacs ignores X resources::
2705 * Emacs ignores frame parameters::
2706 * Emacs takes a long time to visit files::
2707 * Editing files with $ in the name::
2708 * Shell mode loses the current directory::
2709 * Security risks with Emacs::
2710 * Dired claims that no file is on this line::
2711 @end menu
2713 @node Problems with very large files, ^M in the shell buffer, Bugs and problems, Bugs and problems
2714 @section Does Emacs have problems with files larger than 8 megabytes?
2715 @cindex Very large files, opening
2716 @cindex Large files, opening
2717 @cindex Opening very large files
2718 @cindex Maximum file size
2719 @cindex Files, maximum size
2721 Old versions (i.e., anything before 19.29) of Emacs had problems editing
2722 files larger than 8 megabytes.  As of version 19.29, the maximum buffer
2723 size is at least 2^27-1, or 134,217,727 bytes, or 132 MBytes.  Emacs 20
2724 can be compiled on some 64-bit systems in a way that enlarges the buffer
2725 size up to 576,460,752,303,423,487 bytes, or 549,755,813 GBytes.
2727 If you are using a version of Emacs older than 19.29 and cannot upgrade,
2728 you will have to recompile. @email{lnz@@lucid.com, Leonard N. Zubkoff}
2729 suggests putting the following two lines in @file{src/config.h} before
2730 compiling Emacs to allow for 26-bit integers and pointers (and thus file
2731 sizes of up to 33,554,431 bytes):
2733 @example
2734 #define VALBITS 26
2735 #define GCTYPEBITS 5
2736 @end example
2738 @noindent
2739 This method may result in "ILLEGAL DATATYPE" and other random errors on
2740 some machines.
2742 @email{daveg@@csvax.cs.caltech.edu, David Gillespie} explains how this
2743 problems crops up; while his numbers are true only for pre-19.29
2744 versions of Emacs, the theory remains the same with current versions.
2746 @quotation
2747 Emacs is largely written in a dialect of Lisp; Lisp is a freely-typed
2748 language in the sense that you can put any value of any type into any
2749 variable, or return it from a function, and so on.  So each value
2750 must carry a @dfn{tag} along with it identifying what kind of thing it
2751 is, e.g., integer, pointer to a list, pointer to an editing buffer, and
2752 so on.  Emacs uses standard 32-bit integers for data objects, taking the
2753 top 8 bits for the tag and the bottom 24 bits for the value.  So
2754 integers (and pointers) are somewhat restricted compared to true C
2755 integers and pointers.
2756 @end quotation
2758 @node ^M in the shell buffer, Shell process exits abnormally, Problems with very large files, Bugs and problems
2759 @section How do I get rid of @samp{^M} or echoed commands in my shell buffer?
2760 @cindex Shell buffer, echoed commands and @samp{^M} in
2761 @cindex Echoed commands in @code{shell-mode}
2763 Try typing @kbd{M-x shell-strip-ctrl-m @key{RET}} while in @code{shell-mode} to
2764 make them go away.  If that doesn't work, you have several options:
2766 For @code{tcsh}, put this in your @file{.cshrc} (or @file{.tcshrc})
2767 file:
2769 @example
2770 if ($?EMACS) then
2771     if ("$EMACS" == t) then
2772         if ($?tcsh) unset edit
2773         stty nl
2774     endif
2775 endif
2776 @end example
2778 Or put this in your @file{.emacs_tcsh} file:
2780 @example
2781 unset edit
2782 stty nl
2783 @end example
2785 Alternatively, use @code{csh} in your shell buffers instead of
2786 @code{tcsh}.  One way is:
2788 @lisp
2789 (setq explicit-shell-file-name "/bin/csh")
2790 @end lisp
2792 @noindent
2793 and another is to do this in your @file{.cshrc} (or @file{.tcshrc})
2794 file:
2796 @example
2797 setenv ESHELL /bin/csh
2798 @end example
2800 @noindent
2801 (You must start Emacs over again with the environment variable properly
2802 set for this to take effect.)
2804 You can also set the @code{ESHELL} environment variable in Emacs Lisp
2805 with the following Lisp form,
2807 @lisp
2808 (setenv "ESHELL" "/bin/csh")
2809 @end lisp
2811 The above solutions try to prevent the shell from producing the
2812 @samp{^M} characters in the first place.  If this is not possible
2813 (e.g., if you use a Windows shell), you can get Emacs to remove these
2814 characters from the buffer by adding this to your @file{.emacs} init
2815 file:
2817 @smalllisp
2818 (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m)
2819 @end smalllisp
2821 On a related note: If your shell is echoing your input line in the shell
2822 buffer, you might want to try the following command in your shell
2823 start-up file:
2825 @example
2826 stty -icrnl -onlcr -echo susp ^Z
2827 @end example
2829 @node Shell process exits abnormally, Problems with Shell Mode on MS-Windows, ^M in the shell buffer, Bugs and problems
2830 @section Why do I get "Process shell exited abnormally with code 1"?
2831 @cindex Abnormal exits from @code{shell-mode}
2832 @cindex @code{shell-mode} exits
2833 @cindex Process shell exited
2835 The most likely reason for this message is that the @samp{env} program
2836 is not properly installed.  Compile this program for your architecture,
2837 and install it with @samp{a+x} permission in the architecture-dependent
2838 Emacs program directory.  (You can find what this directory is at your
2839 site by inspecting the value of the variable @code{exec-directory} by
2840 typing @kbd{C-h v exec-directory @key{RET}}.)
2842 You should also check for other programs named @samp{env} in your path
2843 (e.g., SunOS has a program named @file{/usr/bin/env}).  We don't
2844 understand why this can cause a failure and don't know a general
2845 solution for working around the problem in this case.
2847 The @samp{make clean} command will remove @samp{env} and other vital
2848 programs, so be careful when using it.
2850 It has been reported that this sometimes happened when Emacs was started
2851 as an X client from an xterm window (i.e., had a controlling tty) but the
2852 xterm was later terminated.
2854 See also @samp{PROBLEMS} (in the @file{etc} subdirectory of the
2855 top-level directory when you unpack the Emacs source) for other
2856 possible causes of this message.
2858 @node Problems with Shell Mode on MS-Windows, Termcap/Terminfo entries for Emacs, Shell process exits abnormally, Bugs and problems
2859 @section Why do I get an error message when I try to run @kbd{M-x shell}?
2861 @cindex Shell Mode, and MS-Windows
2862 @cindex @code{explicit-shell-file-name}
2863 On MS-Windows, this might happen because Emacs tries to look for the
2864 shell in a wrong place.  The default file name @file{/bin/sh} is
2865 usually incorrect for non-Unix systems.  If you know where your shell
2866 executable is, set the variable @code{explicit-shell-file-name} in
2867 your @file{.emacs} file to point to its full file name, like this:
2869 @lisp
2870 (setq explicit-shell-file-name "d:/shells/bash.exe")
2871 @end lisp
2873 If you don't know what shell does Emacs use, try the @kbd{M-!}
2874 command; if that works, put the following line into your
2875 @file{.emacs}:
2877 @lisp
2878 (setq explicit-shell-file-name shell-file-name)
2879 @end lisp
2881 @cindex Antivirus programs, and Shell Mode
2882 Some people have trouble with Shell Mode because of intrusive
2883 antivirus software; disabling the resident antivirus program solves
2884 the problems in those cases.
2886 @node Termcap/Terminfo entries for Emacs, Spontaneous entry into isearch-mode, Problems with Shell Mode on MS-Windows, Bugs and problems
2887 @section Where is the termcap/terminfo entry for terminal type "emacs"?
2888 @cindex Termcap
2889 @cindex Terminfo
2890 @cindex Emacs entries for termcap/terminfo
2892 The termcap entry for terminal type @samp{emacs} is ordinarily put in
2893 the @samp{TERMCAP} environment variable of subshells.  It may help in
2894 certain situations (e.g., using rlogin from shell buffer) to add an
2895 entry for @samp{emacs} to the system-wide termcap file.  Here is a
2896 correct termcap entry for @samp{emacs}:
2898 @example
2899 emacs:tc=unknown:
2900 @end example
2902 To make a terminfo entry for @samp{emacs}, use @code{tic} or
2903 @code{captoinfo}.  You need to generate
2904 @file{/usr/lib/terminfo/e/emacs}.  It may work to simply copy
2905 @file{/usr/lib/terminfo/d/dumb} to @file{/usr/lib/terminfo/e/emacs}.
2907 Having a termcap/terminfo entry will not enable the use of full screen
2908 programs in shell buffers.  Use @kbd{M-x terminal-emulator} for that
2909 instead.
2911 A workaround to the problem of missing termcap/terminfo entries is to
2912 change terminal type @samp{emacs} to type @samp{dumb} or @samp{unknown}
2913 in your shell start up file.  @code{csh} users could put this in their
2914 @file{.cshrc} files:
2916 @example
2917 if ("$term" == emacs) set term=dumb
2918 @end example
2920 @node Spontaneous entry into isearch-mode, Problems talking to certain hosts, Termcap/Terminfo entries for Emacs, Bugs and problems
2921 @section Why does Emacs spontaneously start displaying "I-search:" and beeping?
2922 @cindex Spontaneous entry into isearch-mode
2923 @cindex isearch-mode, spontaneous entry into
2924 @cindex Beeping without obvious reason
2926 Your terminal (or something between your terminal and the computer) is
2927 sending @kbd{C-s} and @kbd{C-q} for flow control, and Emacs is receiving
2928 these characters and interpreting them as commands.  (The @kbd{C-s}
2929 character normally invokes the @code{isearch-forward} command.)  For
2930 possible solutions, see @ref{Handling C-s and C-q with flow control}.
2932 @node Problems talking to certain hosts, Errors with init files, Spontaneous entry into isearch-mode, Bugs and problems
2933 @section Why can't Emacs talk to certain hosts (or certain hostnames)?
2934 @cindex Hosts, Emacs cannot talk to
2935 @cindex @code{gethostbyname}, problematic version
2937 The problem may be that Emacs is linked with a wimpier version of
2938 @code{gethostbyname} than the rest of the programs on the machine.  This
2939 is often manifested as a message on startup of ``X server not responding.
2940 Check your @samp{DISPLAY} environment variable.'' or a message of
2941 ``Unknown host'' from @code{open-network-stream}.
2943 On a Sun, this may be because Emacs had to be linked with the static C
2944 library.  The version of @code{gethostbyname} in the static C library
2945 may only look in @file{/etc/hosts} and the NIS (YP) maps, while the
2946 version in the dynamic C library may be smart enough to check DNS in
2947 addition to or instead of NIS.  On a Motorola Delta running System V
2948 R3.6, the version of @code{gethostbyname} in the standard library works,
2949 but the one that works with NIS doesn't (the one you get with -linet).
2950 Other operating systems have similar problems.
2952 Try these options:
2954 @itemize @bullet
2956 @item
2957 Explicitly add the host you want to communicate with to @file{/etc/hosts}.
2959 @item
2960 Relink Emacs with this line in @file{src/config.h}:
2962 @example
2963 #define LIBS_SYSTEM -lresolv
2964 @end example
2966 @item
2967 Replace @code{gethostbyname} and friends in @file{libc.a} with more
2968 useful versions such as the ones in @file{libresolv.a}.  Then relink
2969 Emacs.
2971 @item
2972 If you are actually running NIS, make sure that @code{ypbind} is
2973 properly told to do DNS lookups with the correct command line switch.
2975 @end itemize
2977 @node Errors with init files, Emacs ignores X resources, Problems talking to certain hosts, Bugs and problems
2978 @section Why does Emacs say "Error in init file"?
2979 @cindex Error in @file{.emacs}
2980 @cindex Error in init file
2981 @cindex Init file, errors in
2982 @cindex @file{.emacs} file, errors in
2983 @cindex Debugging @file{.emacs} file
2985 An error occurred while loading either your @file{.emacs} file or the
2986 system-wide file @file{lisp/default.el}.  Emacs 21.1 and later pops the
2987 @file{*Messages*} buffer, and puts there some additional information
2988 about the error, to provide some hints for debugging.
2990 For information on how to debug your @file{.emacs} file, see
2991 @ref{Debugging a customization file}.
2993 It may be the case that you need to load some package first, or use a
2994 hook that will be evaluated after the package is loaded.  A common case
2995 of this is explained in @ref{Terminal setup code works after Emacs has
2996 begun}.
2998 @node Emacs ignores X resources, Emacs ignores frame parameters, Errors with init files, Bugs and problems
2999 @section Why does Emacs ignore my X resources (my .Xdefaults file)?
3000 @cindex X resources being ignored
3001 @cindex Ignored X resources
3002 @cindex @file{.Xdefaults}
3004 As of version 19, Emacs searches for X resources in the files specified
3005 by the following environment variables:
3007 @itemize @bullet
3009 @item @code{XFILESEARCHPATH}
3010 @item @code{XUSERFILESEARCHPATH}
3011 @item @code{XAPPLRESDIR}
3013 @end itemize
3015 This emulates the functionality provided by programs written using the
3016 Xt toolkit.
3018 @code{XFILESEARCHPATH} and @code{XUSERFILESEARCHPATH} should be a list
3019 of file names separated by colons.  @code{XAPPLRESDIR} should be a list
3020 of directory names separated by colons.
3022 Emacs searches for X resources:
3024 @enumerate
3026 @item
3027 specified on the command line, with the @samp{-xrm RESOURCESTRING} option,
3029 @item
3030 then in the value of the @samp{XENVIRONMENT} environment variable,
3032 @itemize @minus
3034 @item
3035 or if that is unset, in the file named
3036 @file{~/.Xdefaults-@var{hostname}} if it exists (where @var{hostname} is
3037 the name of the machine Emacs is running on),
3039 @end itemize
3041 @item
3042 then in the screen-specific and server-wide resource properties provided
3043 by the server,
3045 @itemize @minus
3047 @item
3048 or if those properties are unset, in the file named @file{~/.Xdefaults}
3049 if it exists,
3051 @end itemize
3053 @item
3054 then in the files listed in @samp{XUSERFILESEARCHPATH},
3056 @itemize @minus
3058 @item
3059 or in files named @file{@var{lang}/Emacs} in directories listed in
3060 @samp{XAPPLRESDIR} (where @var{lang} is the value of the @code{LANG}
3061 environment variable), if the @samp{LANG} environment variable is set,
3062 @item
3063 or in files named Emacs in the directories listed in @samp{XAPPLRESDIR}
3064 @item
3065 or in @file{~/@var{lang}/Emacs} (if the @code{LANG} environment variable
3066 is set),
3067 @item
3068 or in @file{~/Emacs},
3070 @end itemize
3072 @item
3073 then in the files listed in  @code{XFILESEARCHPATH}.
3075 @end enumerate
3077 @node Emacs ignores frame parameters, Emacs takes a long time to visit files, Emacs ignores X resources, Bugs and problems
3078 @section Why don't my customizations of the frame parameters work?
3079 @cindex Frame parameters
3081 This probably happens because you have set the frame parameters in the
3082 variable @code{initial-frame-alist}.  That variable holds parameters
3083 used only for the first frame created when Emacs starts.  To customize
3084 the parameters of all frames, change the variable
3085 @code{default-frame-alist} instead.
3087 These two variables exist because many users customize the initial frame
3088 in a special way.  For example, you could determine the position and
3089 size of the initial frame, but would like to control the geometry of the
3090 other frames by individually positioning each one of them.
3093 @node Emacs takes a long time to visit files, Editing files with $ in the name, Emacs ignores frame parameters, Bugs and problems
3094 @section Why does Emacs take 20 seconds to visit a file?
3095 @cindex Visiting files takes a long time
3096 @cindex Delay when visiting files
3097 @cindex Files, take a long time to visit
3099 Old versions of Emacs (i.e., versions before Emacs 20.x) often
3100 encountered this when the master lock file, @file{!!!SuperLock!!!}, has
3101 been left in the lock directory somehow.  Delete it.
3103 @email{meuer@@geom.umn.edu, Mark Meuer} says that NeXT NFS has a bug
3104 where an exclusive create succeeds but returns an error status.  This
3105 can cause the same problem.  Since Emacs's file locking doesn't work
3106 over NFS anyway, the best solution is to recompile Emacs with
3107 @code{CLASH_DETECTION} undefined.
3109 @node Editing files with $ in the name, Shell mode loses the current directory, Emacs takes a long time to visit files, Bugs and problems
3110 @section How do I edit a file with a @samp{$} in its name?
3111 @cindex Editing files with @samp{$} in the name
3112 @cindex @samp{$} in file names
3113 @cindex File names containing @samp{$}, editing
3115 When entering a file name in the minibuffer, Emacs will attempt to expand
3116 a @samp{$} followed by a word as an environment variable.  To suppress
3117 this behavior, type @kbd{$$} instead.
3119 @node Shell mode loses the current directory, Security risks with Emacs, Editing files with $ in the name, Bugs and problems
3120 @section Why does shell mode lose track of the shell's current directory?
3121 @cindex Current directory and @code{shell-mode}
3122 @cindex @code{shell-mode} and current directory
3123 @cindex Directory, current in @code{shell-mode}
3125 Emacs has no way of knowing when the shell actually changes its
3126 directory.  This is an intrinsic limitation of Unix.  So it tries to
3127 guess by recognizing @samp{cd} commands.  If you type @kbd{cd} followed
3128 by a directory name with a variable reference (@kbd{cd $HOME/bin}) or
3129 with a shell metacharacter (@kbd{cd ../lib*}), Emacs will fail to
3130 correctly guess the shell's new current directory.  A huge variety of
3131 fixes and enhancements to shell mode for this problem have been written
3132 to handle this problem (@pxref{Finding a package with particular
3133 functionality}).
3135 You can tell Emacs the shell's current directory with the command
3136 @kbd{M-x dirs}.
3138 @node Security risks with Emacs, Dired claims that no file is on this line, Shell mode loses the current directory, Bugs and problems
3139 @section Are there any security risks in Emacs?
3140 @cindex Security with Emacs
3141 @cindex @samp{movemail} and security
3142 @cindex @code{file-local-variable} and security
3143 @cindex Synthetic X events and security
3144 @cindex X events and security
3146 @itemize @bullet
3148 @item
3149 The @file{movemail} incident.  (No, this is not a risk.)
3151 In his book @cite{The Cuckoo's Egg}, Cliff Stoll describes this in
3152 chapter 4.  The site at LBL had installed the @file{/etc/movemail}
3153 program setuid root.  (As of version 19, @file{movemail} is in your
3154 architecture-specific directory; type @kbd{C-h v exec-directory
3155 @key{RET}} to see what it is.)  Since @code{movemail} had not been
3156 designed for this situation, a security hole was created and users could
3157 get root privileges.
3159 @code{movemail} has since been changed so that this security hole will
3160 not exist, even if it is installed setuid root.  However,
3161 @code{movemail} no longer needs to be installed setuid root, which
3162 should eliminate this particular risk.
3164 We have heard unverified reports that the 1988 Internet worm took
3165 advantage of this configuration problem.
3167 @item
3168 The @code{file-local-variable} feature.  (Yes, a risk, but easy to
3169 change.)
3171 There is an Emacs feature that allows the setting of local values for
3172 variables when editing a file by including specially formatted text near
3173 the end of the file.  This feature also includes the ability to have
3174 arbitrary Emacs Lisp code evaluated when the file is visited.
3175 Obviously, there is a potential for Trojan horses to exploit this
3176 feature.
3178 Emacs 18 allowed this feature by default; users could disable it by
3179 setting the variable @code{inhibit-local-variables} to a non-nil value.
3181 As of Emacs 19, Emacs has a list of local variables that create a
3182 security risk.  If a file tries to set one of them, it asks the user to
3183 confirm whether the variables should be set.  You can also tell Emacs
3184 whether to allow the evaluation of Emacs Lisp code found at the bottom
3185 of files by setting the variable @code{enable-local-eval}.
3187 For more information, @inforef{File Variables, File Variables, emacs}.
3189 @item
3190 Synthetic X events.  (Yes, a risk; use @samp{MIT-MAGIC-COOKIE-1} or
3191 better.)
3193 Emacs accepts synthetic X events generated by the @code{SendEvent}
3194 request as though they were regular events.  As a result, if you are
3195 using the trivial host-based authentication, other users who can open X
3196 connections to your X workstation can make your Emacs process do
3197 anything, including run other processes with your privileges.
3199 The only fix for this is to prevent other users from being able to open
3200 X connections.  The standard way to prevent this is to use a real
3201 authentication mechanism, such as @samp{MIT-MAGIC-COOKIE-1}.  If using
3202 the @code{xauth} program has any effect, then you are probably using
3203 @samp{MIT-MAGIC-COOKIE-1}.  Your site may be using a superior
3204 authentication method; ask your system administrator.
3206 If real authentication is not a possibility, you may be satisfied by
3207 just allowing hosts access for brief intervals while you start your X
3208 programs, then removing the access.  This reduces the risk somewhat by
3209 narrowing the time window when hostile users would have access, but
3210 @emph{does not eliminate the risk}.
3212 On most computers running Unix and X, you enable and disable
3213 access using the @code{xhost} command.  To allow all hosts access to
3214 your X server, use
3216 @example
3217 xhost +
3218 @end example
3220 @noindent
3221 at the shell prompt, which (on an HP machine, at least) produces the
3222 following message:
3224 @example
3225 access control disabled, clients can connect from any host
3226 @end example
3228 To deny all hosts access to your X server (except those explicitly
3229 allowed by name), use
3231 @example
3232 xhost -
3233 @end example
3235 On the test HP computer, this command generated the following message:
3237 @example
3238 access control enabled, only authorized clients can connect
3239 @end example
3241 @end itemize
3243 @node Dired claims that no file is on this line,  , Security risks with Emacs, Bugs and problems
3244 @section Dired says, "no file on this line" when I try to do something.
3245 @cindex Dired does not see a file
3247 @c FIXME: I think this is fixed in Emacs 21, but I didn't have time to
3248 @c check.
3249 Chances are you're using a localized version of Unix that doesn't use US
3250 date format in dired listings.  You can check this by looking at dired
3251 listings or by typing @kbd{ls -l} to a shell and looking at the dates that
3252 come out.
3254 Dired uses a regular expression to find the beginning of a file name.
3255 In a long Unix-style directory listing (@samp{ls -l}), the file name
3256 starts after the date.  The regexp has thus been written to look for the
3257 date, the format of which can vary on non-US systems.
3259 There are two approaches to solving this.  The first one involves
3260 setting things up so that @samp{ls -l} outputs US date format.  This can
3261 be done by setting the locale.  See your OS manual for more information.
3263 The second approach involves changing the regular expression used by
3264 dired, @code{dired-move-to-filename-regexp}.
3266 @c ------------------------------------------------------------
3267 @node Compiling and installing Emacs, Finding Emacs and related packages, Bugs and problems, Top
3268 @chapter    Compiling and installing Emacs
3269 @cindex    Compiling and installing Emacs
3271 @menu
3272 * Installing Emacs::
3273 * Updating Emacs::
3274 * Problems building Emacs::
3275 * Linking with -lX11 fails::
3276 @end menu
3278 @node Installing Emacs, Updating Emacs, Compiling and installing Emacs, Compiling and installing Emacs
3279 @section How do I install Emacs?
3280 @cindex Installing Emacs
3281 @cindex Unix systems, installing Emacs on
3282 @cindex Downloading and installing Emacs
3283 @cindex Retrieving and installing Emacs
3284 @cindex Building Emacs from source
3285 @cindex Source code, building Emacs from
3286 @cindex Unpacking and installing Emacs
3288 This answer is meant for users of Unix and Unix-like systems.  Users of
3289 other operating systems should see the series of questions beginning
3290 with @ref{Emacs for MS-DOS}, which describe where to get non-Unix source
3291 and binaries, and how to install Emacs on those systems.
3293 For Unix and Unix-like systems, the easiest way is often to compile it
3294 from scratch.  You will need:
3296 @itemize @bullet
3298 @item
3299 Emacs sources.  @xref{Current GNU distributions}, for a list of ftp sites
3300 that make them available.  On @file{ftp.gnu.org}, the main GNU
3301 distribution site, sources are available as
3303 @uref{ftp://ftp.gnu.org/pub/gnu/emacs/emacs-@value{VER}.tar.gz}
3305 The above will obviously change as new versions of Emacs come out.  For
3306 instance, when Emacs 21.42 is released, it will most probably be
3307 available as
3309 @uref{ftp://ftp.gnu.org/pub/gnu/emacs/emacs-21.42.tar.gz}
3311 Again, you should use one of the GNU mirror sites (see @ref{Current GNU
3312 distributions}, and adjust the URL accordingly) so as to reduce load on
3313 @file{ftp.gnu.org}.
3315 @item
3316 @code{gzip}, the GNU compression utility.  You can get @code{gzip} via
3317 anonymous ftp at mirrors of @file{ftp.gnu.org} sites; it should compile
3318 and install without much trouble on most systems.  Once you have
3319 retrieved the Emacs sources, you will probably be able to uncompress
3320 them with the command
3322 @example
3323 gunzip --verbose emacs-@value{VER}.tar.gz
3324 @end example
3326 @noindent
3327 changing the Emacs version (@value{VER}), as necessary.  Once
3328 @code{gunzip} has finished doing its job, a file by the name of
3329 @file{emacs-@value{VER}.tar} should be in your build directory.
3331 @item
3332 @code{tar}, the @dfn{tape archiving} program, which moves multiple files
3333 into and out of archive files, or @dfn{tarfiles}.  All of the files
3334 comprising the Emacs source come in a single tarfile, and must be
3335 extracted using @code{tar} before you can build Emacs.  Typically, the
3336 extraction command would look like
3338 @example
3339 tar -xvvf emacs-@value{VER}.tar
3340 @end example
3342 @noindent
3343 The @samp{x} indicates that we want to extract files from this tarfile,
3344 the two @samp{v}s force verbose output, and the @samp{f} tells
3345 @code{tar} to use a disk file, rather than one on the tape drive.
3347 If you're using GNU @code{tar} (available at mirrors of
3348 @file{ftp.gnu.org}), you can combine this step and the previous one by
3349 using the command
3351 @example
3352 tar -zxvvf emacs-@value{VER}.tar.gz
3353 @end example
3355 @noindent
3356 The additional @samp{z} at the beginning of the options list tells GNU
3357 @code{tar} to uncompress the file with @code{gunzip} before extracting
3358 the tarfile's components.
3360 @end itemize
3362 At this point, the Emacs sources (all 70+ megabytes of them) should be
3363 sitting in a directory called @file{emacs-@value{VER}}.  On most common
3364 Unix and Unix-like systems, you should be able to compile Emacs (with X
3365 Window system support) with the following commands:
3367 @example
3368 cd emacs-@value{VER}       # change directory to emacs-@value{VER}
3369 ./configure         # configure Emacs for your particular system
3370 make                # use Makefile to build components, then Emacs
3371 @end example
3373 If the @code{make} completes successfully, the odds are fairly good that
3374 the build has gone well.  (@xref{Problems building Emacs}, if you weren't
3375 successful.)
3377 By default, Emacs is installed in the following directories:
3379 @table @file
3380 @item /usr/local/bin
3381 binaries.
3383 @item /usr/local/share/emacs/@value{VER}
3384 Lisp code and support files.
3386 @item /usr/local/info
3387 Info documentation.
3388 @end table
3390 To install files in those default directories, become the superuser and
3391 type
3393 @example
3394 make install
3395 @end example
3397 Note that @samp{make install} will overwrite @file{/usr/local/bin/emacs}
3398 and any Emacs Info files that might be in @file{/usr/local/info}.
3400 Much more verbose instructions (with many more hints and suggestions)
3401 come with the Emacs sources, in the file @file{INSTALL}.
3403 @node Updating Emacs, Problems building Emacs, Installing Emacs, Compiling and installing Emacs
3404 @section How do I update Emacs to the latest version?
3405 @cindex Updating Emacs
3407 @xref{Installing Emacs}, and follow the instructions there for
3408 installation.
3410 Most files are placed in version-specific directories.  Emacs
3411 @value{VER}, for instance, places files in
3412 @file{/usr/local/share/emacs/@value{VER}}.
3414 Upgrading should overwrite only, @file{/usr/local/bin/emacs} (the Emacs
3415 binary) and documentation in @file{/usr/local/info}.  Back up these
3416 files before you upgrade, and you shouldn't have too much trouble.
3418 @node Problems building Emacs, Linking with -lX11 fails, Updating Emacs, Compiling and installing Emacs
3419 @section What should I do if I have trouble building Emacs?
3420 @cindex Problems building Emacs
3421 @cindex Errors when building Emacs
3423 First look in the file @file{etc/PROBLEMS} (where you unpack the Emacs
3424 source) to see if there is already a solution for your problem.  Next,
3425 look for other questions in this FAQ that have to do with Emacs
3426 installation and compilation problems.
3428 If you'd like to have someone look at your problem and help solve it,
3429 see @ref{Help installing Emacs}.
3431 If you cannot find a solution in the documentation, send a message to
3432 @email{bug-gnu-emacs@@gnu.org}.
3434 Please don't post it to @uref{news:gnu.emacs.help} or send e-mail to
3435 @email{help-gnu-emacs@@gnu.org}.  For further guidelines, see
3436 @ref{Guidelines for newsgroup postings} and @ref{Reporting bugs}.
3438 @node Linking with -lX11 fails,  , Problems building Emacs, Compiling and installing Emacs
3439 @section Why does linking Emacs with -lX11 fail?
3440 @cindex Linking with -lX11 fails
3441 @cindex lX11, linking fails with
3443 Emacs needs to be linked with the static version of the X11 library,
3444 @file{libX11.a}.  This may be missing.
3446 On OpenWindows, you may need to use @code{add_services} to add the
3447 "OpenWindows Programmers" optional software category from the CD-ROM.
3449 On HP-UX 8.0, you may need to run @code{update} again to load the
3450 X11-PRG ``fileset''.  This may be missing even if you specified ``all
3451 filesets'' the first time.  If @file{libcurses.a} is missing, you may
3452 need to load the ``Berkeley Development Option.''
3454 @email{zoo@@armadillo.com, David Zuhn} says that MIT X builds shared
3455 libraries by default, and only shared libraries, on those platforms that
3456 support them.  These shared libraries can't be used when undumping
3457 @code{temacs} (the last stage of the Emacs build process).  To get
3458 regular libraries in addition to shared libraries, add this to
3459 @file{site.cf}:
3461 @example
3462 #define ForceNormalLib YES
3463 @end example
3465 Other systems may have similar problems.  You can always define
3466 @code{CANNOT_DUMP} and link with the shared libraries instead.
3468 @cindex X Menus don't work
3469 To get the Xmenu stuff to work, you need to find a copy of MIT's
3470 @file{liboldX.a}.
3472 @c ------------------------------------------------------------
3473 @node Finding Emacs and related packages, Major packages and programs, Compiling and installing Emacs, Top
3474 @chapter Finding Emacs and related packages
3475 @cindex Finding Emacs and related packages
3477 @menu
3478 * Finding Emacs on the Internet::
3479 * Finding a package with particular functionality::
3480 * Packages that do not come with Emacs::
3481 * Current GNU distributions::
3482 * Difference between Emacs and XEmacs::
3483 * Emacs for MS-DOS::
3484 * Emacs for Windows::
3485 * Emacs for OS/2::
3486 * Emacs for Atari ST::
3487 * Emacs for the Amiga ::
3488 * Emacs for NeXTSTEP::
3489 * Emacs for Apple computers::
3490 * Emacs for VMS and DECwindows::
3491 * Modes for various languages::
3492 * Translating names to IP addresses::
3493 @end menu
3495 @node Finding Emacs on the Internet, Finding a package with particular functionality, Finding Emacs and related packages, Finding Emacs and related packages
3496 @section Where can I get Emacs on the net (or by snail mail)?
3497 @cindex Finding Emacs on the Internet
3498 @cindex Snail mail, ordering Emacs via
3499 @cindex Postal service, ordering Emacs via
3500 @cindex Distribution, retrieving Emacs
3501 @cindex Internet, retrieving from
3503 Look in the files @file{etc/DISTRIB} and @file{etc/FTP} for information
3504 on nearby archive sites and @file{etc/ORDERS} for mail orders.  If you
3505 don't already have Emacs, see @ref{Informational files for Emacs}, for how
3506 to get these files.
3508 @xref{Installing Emacs}, for information on how to obtain and build the latest
3509 version of Emacs, and see @ref{Current GNU distributions}, for a list of
3510 archive sites that make GNU software available.
3512 @node Finding a package with particular functionality, Packages that do not come with Emacs, Finding Emacs on the Internet, Finding Emacs and related packages
3513 @section How do I find a Emacs Lisp package that does XXX?
3514 @cindex Package, finding
3515 @cindex Finding an Emacs Lisp package
3516 @cindex Functionality, finding a particular package
3518 First of all, you should check to make sure that the package isn't
3519 already available.  For example, typing @kbd{M-x apropos @key{RET}
3520 wordstar @key{RET}} lists all functions and variables containing the
3521 string @samp{wordstar}.
3523 It is also possible that the package is on your system, but has not been
3524 loaded.  To see which packages are available for loading, look through
3525 your computer's lisp directory (@pxref{File-name conventions}).  The Lisp
3526 source to most packages contains a short description of how they
3527 should be loaded, invoked, and configured---so before you use or
3528 modify a Lisp package, see if the author has provided any hints in the
3529 source code.
3531 The command @kbd{C-h p} (@code{finder-by-keyword}) allows you to browse
3532 the constituent Emacs packages.
3534 For advice on how to find extra packages that are not part of Emacs,
3535 see @ref{Packages that do not come with Emacs}.
3537 @node Packages that do not come with Emacs, Current GNU distributions, Finding a package with particular functionality, Finding Emacs and related packages
3538 @section Where can I get Emacs Lisp packages that don't come with Emacs?
3539 @cindex Unbundled packages
3540 @cindex Finding other packages
3541 @cindex Lisp packages that do not come with Emacs
3542 @cindex Packages, those that do not come with Emacs
3543 @cindex Emacs Lisp List
3544 @cindex Emacs Lisp Archive
3546 @uref{http://www.anc.ed.ac.uk/~stephen/emacs/ell.html, The Emacs Lisp
3547 List (ELL)}, maintained by @email{stephen@@anc.ed.ac.uk, Stephen Eglen},
3548 aims to provide one compact list with links to all of the current Emacs
3549 lisp files on the internet.  The ELL can be browsed over the web, or
3550 from Emacs with @uref{http://www.anc.ed.ac.uk/~stephen/emacs/ell.el, 
3551 the @file{ell} package}.
3553 Many authors post their packages to the @uref{news:gnu.emacs.sources,
3554 Emacs sources newsgroup}.  You can search the archives of this
3555 group with @uref{http://groups.google.com, Google}, for example.
3557 Several packages are stored in
3558 @uref{http://emacswiki.org/elisp/, the Lisp area of the Emacs Wiki}.
3560 For a long time, the Emacs Lisp Archive provided a central repository
3561 for Emacs packages.  Sadly, it has not been active for some time,
3562 although you can still access the old files at
3564 @uref{ftp://ftp.cis.ohio-state.edu/pub/emacs-lisp/WWW/index.html}
3566 @node Current GNU distributions, Difference between Emacs and XEmacs, Packages that do not come with Emacs, Finding Emacs and related packages
3567 @section Where can I get other up-to-date GNU stuff?
3568 @cindex Current GNU distributions
3569 @cindex Sources for current GNU distributions
3570 @cindex Stuff, current GNU
3571 @cindex Up-to-date GNU stuff
3572 @cindex Finding current GNU software
3573 @cindex Official GNU software sites
3575 The most up-to-date official GNU software is normally kept at
3577 @uref{ftp://ftp.gnu.org/pub/gnu}
3579 Read the files @file{etc/DISTRIB} and @file{etc/FTP} for more
3580 information.
3582 A list of sites mirroring @samp{ftp.gnu.org} can be found at
3584 @uref{http://www.gnu.org/order/ftp.html}
3586 @node Difference between Emacs and XEmacs, Emacs for MS-DOS, Current GNU distributions, Finding Emacs and related packages
3587 @section What is the difference between Emacs and XEmacs (formerly "Lucid Emacs")?
3588 @cindex XEmacs
3589 @cindex Difference Emacs and XEmacs
3590 @cindex Lucid Emacs
3591 @cindex Epoch
3593 First of all, they're both GNU Emacs.  XEmacs is just as much a later
3594 version of GNU Emacs as the FSF-distributed version.  This FAQ refers to
3595 the latest version to be distributed by the FSF as ``Emacs,'' partly
3596 because the XEmacs maintainers now refer to their product using the
3597 ``XEmacs'' name, and partly because there isn't any accurate way to
3598 differentiate between the two without getting mired in paragraphs of
3599 legalese and history.
3601 XEmacs, which began life as Lucid Emacs, is based on an early version of
3602 Emacs 19 and Epoch, an X-aware version of Emacs 18.
3604 Emacs (i.e., the version distributed by the FSF) has a larger installed
3605 base and now always contains the MULE multilingual facilities.
3606 XEmacs can do some clever tricks with X and MS-Windows, such as
3607 putting arbitrary graphics in a buffer.  Similar facilities have been
3608 implemented for Emacs as part of a new redisplay implementation for
3609 Emacs 21, and are available in the latest Emacs releases.
3610 Emacs and XEmacs each come with
3611 Lisp packages that are lacking in the other; RMS says that the FSF would
3612 include more packages that come with XEmacs, but that the XEmacs
3613 maintainers don't always keep track of the authors of contributed code,
3614 which makes it impossible for the FSF to have certain legal papers
3615 signed.  (Without these legal papers, the FSF will not distribute Lisp
3616 packages with Emacs.)  The two versions have some
3617 significant differences at the Lisp programming level.
3619 Many XEmacs features have found their way into recent versions of Emacs,
3620 and more features can be expected in the future, but there are still many
3621 differences between the two.
3623 The latest stable branch of XEmacs as of this writing is 21.4; you can
3624 get it at
3626 @uref{ftp://ftp.xemacs.org/pub/xemacs/xemacs-21.4/xemacs-21.4.12.tar.gz}
3628 More information about XEmacs, including a list of frequently asked
3629 questions (FAQ), is available at
3631 @uref{http://www.xemacs.org/}
3633 @node Emacs for MS-DOS, Emacs for Windows, Difference between Emacs and XEmacs, Finding Emacs and related packages
3634 @section Where can I get Emacs for my PC running MS-DOS?
3635 @cindex MS-DOS, Emacs for
3636 @cindex DOS, Emacs for
3637 @cindex Compiling Emacs for DOS
3638 @cindex Emacs for MS-DOS
3639 @cindex Tools needed to compile Emacs under DOS
3641 A pre-built binary distribution of Emacs is available from the
3642 SimTel.NET archives.  This version apparently works under MS-DOS and
3643 Windows (3.X, 9X, ME, NT, and 2000) and supports long file names under
3644 Windows 9X, Windows ME, and Windows 2000.  More information is available
3645 from
3647 @uref{http://www.simtel.net/pub/djgpp/v2gnu/emacs.README}
3649 The binary itself is available in the files @file{em*.zip} in the
3650 directory
3652 @uref{http://www.simtel.net/pub/djgpp/v2gnu/}
3654 If you prefer to compile Emacs for yourself, you can do so with the
3655 current distribution directly.  You will need a 386 (or
3656 better) processor, and to be running MS-DOS 3.0 or later.  According to
3657 @email{eliz@@is.elta.co.il, Eli Zaretskii} and
3658 @email{hankedr@@dms.auburn.edu, Darrel Hankerson}, you will need the
3659 following:
3661 @table @emph
3663 @item Compiler
3664 DJGPP version 1.12 maint 1 or later.  Djgpp 2.0 or later is
3665 recommended, since 1.x is very old an unmaintained.  Djgpp 2 supports
3666 long file names on Windows 9X/ME/2K.
3668 You can get the latest release of DJGPP by retrieving all of
3669 the files in
3671 @uref{http://www.simtel.net/pub/gnu/djgpp/v2*}
3673 @item Unpacking program
3674 The easiest way is to use @code{djtar} which comes with DJGPP v2.x,
3675 because it can open gzip'ed tarfiles (i.e., those ending with
3676 @file{.tar.gz}) in one step.  @code{Djtar} comes in
3677 @file{djdev@var{nnn}.zip} archive (where @var{nnn} is the DJGPP version
3678 number), from the URL mentioned above.
3680 @strong{Warning!}  Do @strong{not} use the popular WinZip program to
3681 unpack the Emacs distribution!  WinZip is known to corrupt some of the
3682 files by converting them to the DOS CR-LF format, it doesn't always
3683 preserve the directory structure recorded in the compressed Emacs
3684 archive, and commits other atrocities.  Some of these problems could
3685 actually prevent Emacs from building successfully!
3687 @item make, mv, sed, and rm
3688 All of these utilities are available at
3690 @uref{http://www.simtel.net/pub/gnu/djgpp/v2gnu}
3692 16-bit utilities can be found in GNUish, at
3694 @uref{http://www.simtel.net/pub/gnuish/}
3696 @noindent
3697 (@code{mv} and @code{rm} are in the Fileutils package, @code{sed} and
3698 @code{make} are each one in a separate package named after them.)
3700 @end table
3702 The files @file{INSTALL} (near its end) and @file{etc/PROBLEMS} in the
3703 directory of the Emacs sources contains some additional information
3704 regarding Emacs under MS-DOS.
3706 For a list of other MS-DOS implementations of Emacs (and Emacs
3707 look-alikes), consult the list of "Emacs implementations and literature,"
3708 available at
3710 @uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/}
3712 Note that while many of these programs look similar to Emacs, they often
3713 lack certain features, such as the Emacs Lisp extension language.
3715 @node Emacs for Windows, Emacs for OS/2, Emacs for MS-DOS, Finding Emacs and related packages
3716 @section Where can I get Emacs for Microsoft Windows
3717 @cindex FAQ for NT Emacs
3718 @cindex Emacs for MS-Windows
3719 @cindex Microsoft Windows, Emacs for
3720 @cindex Windows 9X, ME, NT, 2K, and CE, Emacs for
3722 For information on Emacs for Windows 95 and NT, read the FAQ produced by
3723 @email{voelker@@cs.washington.edu, Geoff Voelker}, available at
3725 @uref{http://www.gnu.org/software/emacs/windows/ntemacs.html}
3727 @xref{Emacs for MS-DOS}, for Windows 3.1.
3729 A port of Emacs 20.7 for Windows CE, based on NTEmacs, is available at
3731 @uref{http://www.rainer-keuchel.de/software.html}
3733 @noindent
3734 This port was done by @email{coyxc@@rainer-keuchel.de, Rainer Keuchel},
3735 and supports all Emacs features except async subprocesses and menus.
3736 You will need MSVC 6.0 and a Windows CE SDK to build this port.
3738 @node Emacs for OS/2, Emacs for Atari ST, Emacs for Windows, Finding Emacs and related packages
3739 @section Where can I get Emacs for my PC running OS/2?
3740 @cindex OS/2, Emacs for
3742 Emacs 20.6 is ported for emx on OS/2 2.0 or 2.1, and is available at
3744 @uref{ftp://hobbes.nmsu.edu/pub/os2/apps/editors/emacs/e206*.zip}
3746 @noindent
3747 and also at
3749 @uref{http://archiv.leo.org/pub/comp/os/os2/leo/gnu/emacs%2d20/}
3751 Instructions for installation, basic setup, and other useful information
3752 for OS/2 users of Emacs can be found at
3754 @uref{http://userpage.fu-berlin.de/~oheiabbd/emacs/emacs206-os2.html}
3756 @node Emacs for Atari ST, Emacs for the Amiga , Emacs for OS/2, Finding Emacs and related packages
3757 @section Where can I get Emacs for my Atari ST?
3758 @cindex Atari ST, Emacs for
3759 @cindex TOS, Emacs for
3761 Roland Schäuble reports that Emacs 18.58 running on plain TOS and MiNT
3762 is available at
3763 @uref{ftp://atari.archive.umich.edu/Editors/Emacs-18-58/1858b-d3.zoo}.
3765 @node Emacs for the Amiga , Emacs for NeXTSTEP, Emacs for Atari ST, Finding Emacs and related packages
3766 @section Where can I get Emacs for my Amiga?
3767 @cindex Amiga, Emacs for
3769 The files you need are available at
3771 @uref{ftp://ftp.wustl.edu/pub/aminet/util/gnu/}
3773 @email{dgilbert@@gamiga.guelphnet.dweomer.org, David Gilbert} has released a
3774 beta version of Emacs 19.25 for the Amiga.  You can get the binary at
3776 @uref{ftp://ftp.wustl.edu/pub/aminet/util/gnu/a2.0bEmacs-bin.lha}
3778 @node Emacs for NeXTSTEP, Emacs for Apple computers, Emacs for the Amiga , Finding Emacs and related packages
3779 @section Where can I get Emacs for NeXTSTEP?
3780 @cindex NeXTSTEP, Emacs for
3782 Emacs.app is a NeXTSTEP version of Emacs 19.34 which supports colors,
3783 menus, and multiple frames.  You can get it from
3785 @uref{ftp://next-ftp.peak.org/pub/next/apps/emacs/Emacs_for_NeXTstep.4.20a1.NIHS.b.tar.gz}
3787 @node Emacs for Apple computers, Emacs for VMS and DECwindows, Emacs for NeXTSTEP, Finding Emacs and related packages
3788 @section Where can I get Emacs for my Apple computer?
3789 @cindex Apple computers, Emacs for
3790 @cindex Macintosh, Emacs for
3792 An unofficial port of GNU Emacs 18.59 to the Macintosh is available at a
3793 number of ftp sites, the home being
3794 @uref{ftp://ftp.cs.cornell.edu/pub/parmet/Emacs-1.17.sit.bin}.
3796 A port of Emacs 20.4 is available at
3797 @uref{http://www.cs.hku.hk/~choi/emacs/index.html}.
3799 Beginning with version 21.1, the Macintosh is supported in the official
3800 Emacs distribution; see the files @file{mac/README} and
3801 @file{mac/INSTALL} in the Emacs distribution for build instructions.
3803 Apple's forthcoming "OS X" is based largely on NeXTSTEP and OpenStep.
3804 @xref{Emacs for NeXTSTEP}, for more details about that version.
3806 @node Emacs for VMS and DECwindows, Modes for various languages, Emacs for Apple computers, Finding Emacs and related packages
3807 @section Where do I get Emacs that runs on VMS under DECwindows?
3808 @cindex DECwindows, Emacs for
3809 @cindex VMS, Emacs for
3811 Up-to-date information about GNU software (including Emacs) for VMS is
3812 available at @uref{http://vms.gnu.org/}.
3814 @node Modes for various languages, Translating names to IP addresses, Emacs for VMS and DECwindows, Finding Emacs and related packages
3815 @section Where can I get modes for Lex, Yacc/Bison, Bourne shell, csh, C@t{++}, Objective-C, Pascal, Java, and Awk?
3816 @cindex Awk, mode for
3817 @cindex @code{awk-mode}
3818 @cindex Bison, mode for
3819 @cindex Bourne Shell, mode for
3820 @cindex C@t{++}, mode for
3821 @cindex Java, mode for
3822 @cindex Lex mode
3823 @cindex Objective-C, mode for
3824 @cindex @code{pascal-mode}
3825 @cindex Shell mode
3826 @cindex Yacc mode
3827 @cindex @file{csh} mode
3828 @cindex @code{sh-mode}
3829 @cindex @code{cc-mode}
3831 Most of these modes are now available in standard Emacs distribution.
3832 To get additional modes, see @ref{Finding a package with particular
3833 functionality}.  
3835 Barry Warsaw's @code{cc-mode} now works for C, C@t{++}, Objective-C, and
3836 Java code.  It is distributed with Emacs, but has
3837 @uref{http://cc-mode.sourceforge.net/, its own homepage}.
3839 @node Translating names to IP addresses,  , Modes for various languages, Finding Emacs and related packages
3840 @section What is the IP address of XXX.YYY.ZZZ?
3841 @cindex Translating names to IP addresses
3842 @cindex IP addresses from names
3843 @cindex Using BIND to translate addresses
3844 @cindex DNS and IP addresses
3846 If you are on a Unix machine, try using the @samp{nslookup} command,
3847 included in the Berkeley BIND package.  For example, to find the IP
3848 address of @samp{ftp.gnu.org}, you would type @code{nslookup
3849 ftp.gnu.org}.
3851 Your computer should then provide the IP address of that machine.
3853 If your site's nameserver is deficient, you can use IP addresses to FTP
3854 files.  You can get this information by e-mail:
3856 @example
3857 To: dns@@[134.214.84.25]    (to grasp.insa-lyon.fr)
3858 Body: ip XXX.YYY.ZZZ        (or "help" for more information
3859                              and options - no quotes)
3860 @end example
3862 @noindent
3865 @example
3866 To: resolve@@[147.31.254.130]         (to laverne.cs.widener.edu)
3867 Body: site XXX.YYY.ZZZ
3868 @end example
3870 @c ------------------------------------------------------------
3871 @node Major packages and programs, Key bindings, Finding Emacs and related packages, Top
3872 @chapter Major packages and programs
3873 @cindex Major packages and programs
3875 @menu
3876 * VM::
3877 * Supercite::
3878 * Calc::
3879 * VIPER::
3880 * AUCTeX::
3881 * BBDB::
3882 * Ispell::
3883 * w3-mode::
3884 * EDB::
3885 * Mailcrypt::
3886 * JDE::
3887 * Patch::
3888 @end menu
3890 @node VM, Supercite, Major packages and programs, Major packages and programs
3891 @section VM (View Mail) --- another mail reader within Emacs, with MIME support
3892 @cindex VM
3893 @cindex Alternative mail software
3894 @cindex View Mail
3895 @cindex E-mail reader, VM
3897 @table @b
3899 @item Author
3900 @email{kyle_jones@@wonderworks.com, Kyle Jones}
3902 @item Latest version
3903 7.15
3905 @item Distribution
3906 @uref{ftp://ftp.wonderworks.com/pub/vm/vm.tar.gz}
3908 @item Informational newsgroup
3909 @uref{news:gnu.emacs.vm.info}@*
3911 @item Bug reports newsgroup
3912 @uref{news:gnu.emacs.vm.bug}@*
3913 Or send reports to @email{bug-vm@@wonderworks.com}
3914 @end table
3916 VM 7 works well with Emacs 21. Older versions of VM suitable for use
3917 with older versions of Emacs are available from
3918 @uref{ftp://ftp.wonderworks.com/pub/vm/, the same FTP site}.
3921 @node Supercite, Calc, VM, Major packages and programs
3922 @section Supercite --- mail and news citation package within Emacs
3923 @cindex Supercite
3924 @cindex Superyank
3925 @cindex Mail and news citations
3926 @cindex News and mail citations
3927 @cindex Citations in mail and news
3929 @table @b
3931 @item Author
3932 @email{barry@@python.org, Barry Warsaw}
3934 @item Latest version
3935 3.54 (comes bundled with Emacs since version 20)
3937 @item Distribution
3938 @uref{http://www.python.org/emacs/supercite.tar.gz}
3940 @item Mailing list
3941 Subscription requests to @email{supercite-request@@python.org}@*
3942 Submissions @email{supercite@@python.org}
3944 @end table
3946 Superyank is an old version of Supercite.
3948 @node Calc, VIPER, Supercite, Major packages and programs
3949 @section Calc --- poor man's Mathematica within Emacs
3950 @cindex Programmable calculator
3951 @cindex Calc
3952 @cindex Mathematical package
3954 @table @b
3956 @item Author
3957 @email{daveg@@csvax.cs.caltech.edu, Dave Gillespie}
3959 @item Latest version
3960 2.02f
3962 @item Distribution
3963 @uref{ftp://ftp.gnu.org/pub/gnu/calc/calc-2.02f.tar.gz}
3965 @end table
3967 Note that Calc 2.02f needs patching to work with Emacs 21 and later.
3969 @cindex @code{calculator}, a package
3970 Emacs 21.1 and later comes with a package called @file{calculator.el}.
3971 It doesn't support all the mathematical wizardry offered by Calc, such
3972 as matrices, special functions, and statistics, but is more than
3973 adequate as a replacement for @code{xcalc} and similar programs.
3975 @node VIPER, AUCTeX, Calc, Major packages and programs
3976 @section VIPER --- @code{vi} emulation for Emacs
3977 @cindex @code{vi} emulation
3978 @cindex VIPER
3979 @cindex Emulation of @code{vi}
3981 Since Emacs 19.29, the preferred @code{vi} emulation in Emacs is VIPER
3982 (@kbd{M-x viper-mode @key{RET}}), which comes with Emacs.  It extends
3983 and supersedes VIP (including VIP 4.3) and provides @code{vi} emulation
3984 at several levels, from one that closely follows @code{vi} to one that
3985 departs from @code{vi} in several significant ways.
3987 For Emacs 19.28 and earlier, the following version of VIP is generally
3988 better than the one distributed with Emacs:
3990 @table @b
3991 @item Author
3992 @email{sane@@cs.uiuc.edu, Aamod Sane}
3994 @item Latest version
3997 @item Distribution
3998 @uref{ftp://archive.cis.ohio-state.edu/pub/emacs-lisp/old-archive/modes/vip-mode.tar.Z}
4000 @end table
4002 @node AUCTeX, BBDB, VIPER, Major packages and programs
4003 @section AUCTeX --- enhanced LaTeX mode with debugging facilities
4004 @cindex Mode for @TeX{}
4005 @cindex @TeX{} mode
4006 @cindex AUCTeX mode for editing @TeX{}
4007 @cindex Writing and debugging @TeX{}
4009 @table @b
4011 @item Authors
4012 @email{krab@@iesd.auc.dk, Kresten Krab Thorup} and@*
4013 @email{abraham@@dina.kvl.dk, Per Abrahamsen}
4015 @item Maintainer
4016 @email{dak@@gnu.org, David Kastrup}
4018 @item Latest version
4019 11.13
4021 @item Distribution
4022 @uref{http://savannah.gnu.org/download/auctex/stable.pkg/11.13/auctex-11.13.tar.gz}
4024 @item Web site
4025 @uref{http://www.gnu.org/software/auctex/}
4027 @item Mailing list:
4028 Subscription requests to @email{auc-tex-subscribe@@sunsite.dk}@*
4029 Submissions to @email{auc-tex@@sunsite.dk}@*
4030 Development team is at @email{auc-tex_mgr@@sunsite.dk}
4032 @end table
4034 @node BBDB, Ispell, AUCTeX, Major packages and programs
4035 @section BBDB --- personal Info Rolodex integrated with mail/news readers
4036 @cindex BBDB
4037 @cindex Rolodex-like functionality
4038 @cindex Integrated contact database
4039 @cindex Contact database
4040 @cindex Big Brother Database
4041 @cindex Address book
4043 @table @b
4045 @item Maintainer
4046 @email{waider@@waider.ie, Ronan Waide}
4048 @item Latest version
4049 2.34
4051 @item Distribution
4052 @uref{http://bbdb.sourceforge.net/}
4054 @item Mailing lists
4055 Subscription requests to @email{bbdb-info-request@@lists.sourceforge.net}@*
4056 Submissions to @email{bbdb-info@@lists.sourceforge.net}@*
4057 Release announcements: @email{bbdb-announce-request@@lists.sourceforge.net}
4059 @end table
4061 @node Ispell, w3-mode, BBDB, Major packages and programs
4062 @section Ispell --- spell checker in C with interface for Emacs
4063 @cindex Spell-checker
4064 @cindex Checking spelling
4065 @cindex Ispell
4067 @table @b
4069 @item Author
4070 @email{geoff@@itcorp.com, Geoff Kuenning}
4072 @item Latest version
4073 3.1.20
4075 @item Distribution
4076 @uref{ftp://ftp.cs.ucla.edu/pub/ispell/ispell-3.1.20.tar.gz}@*
4078 @item Web site
4079 @uref{http://fmg-www.cs.ucla.edu/geoff/ispell.html}
4081 @end table
4083 @itemize @bullet
4085 @item
4086 Do not ask Geoff to send you the latest version of Ispell. He does not
4087 have free e-mail.
4089 @item
4090 This Ispell program is distinct from GNU Ispell 4.0. GNU Ispell 4.0 is
4091 no longer a supported product.
4093 @end itemize
4095 @node w3-mode, EDB, Ispell, Major packages and programs
4096 @section w3-mode --- A World Wide Web browser inside of Emacs
4097 @cindex WWW browser
4098 @cindex Web browser
4099 @cindex HTML browser in Emacs
4100 @cindex @code{w3-mode}
4102 @table @b
4104 @item Author
4105 @email{wmperry@@spry.com, Bill Perry}
4107 @item Latest version
4108 4.0pre.39
4110 @item Distribution
4111 @uref{ftp://ftp.cs.indiana.edu/pub/elisp/w3/w3.tar.gz}
4113 @item Mailing lists
4114 Receive announcements from @email{w3-announce-request@@indiana.edu}@*
4115 Become a beta tester at @email{w3-beta-request@@indiana.edu}@*
4116 Help to develop @code{w3-mode} at @email{w3-dev@@indiana.edu}
4118 @end table
4120 @node EDB, Mailcrypt, w3-mode, Major packages and programs
4121 @section EDB --- Database program for Emacs; replaces forms editing modes
4122 @cindex EDB
4123 @cindex Database
4124 @cindex Forms mode
4126 @table @b
4127 @item Author
4128 @email{mernst@@theory.lcs.mit.edu, Michael Ernst}
4130 @item Latest version
4131 1.21
4133 @item Distribution
4134 @uref{ftp://theory.lcs.mit.edu/pub/emacs/edb}
4136 @end table
4138 @node Mailcrypt, JDE, EDB, Major packages and programs
4139 @section Mailcrypt --- PGP interface within Emacs mail and news
4140 @cindex PGP
4141 @cindex GPG
4142 @cindex Interface to PGP from Emacs mail and news
4143 @cindex News, interface to PGP from
4144 @cindex Mail, interface to PGP from
4145 @cindex Encryption software, interface to
4147 @table @b
4149 @item Authors
4150 @email{patl@@lcs.mit.edu, Patrick J. LoPresti} and
4151 @email{jin@@atype.com, Jin S. Choi}
4153 @item Maintainer
4154 @email{warner-mailcrypt@@lothar.com, Brian Warner}
4156 @item Latest version
4157 3.5.8
4159 @item Distribution
4160 @uref{http://dl.sourceforge.net/sourceforge/mailcrypt/mailcrypt-3.5.8.tar.gz}
4162 @item Web site
4163 @uref{http://mailcrypt.sourceforge.net/}
4165 @end table
4167 @node JDE, Patch, Mailcrypt, Major packages and programs
4168 @section JDE --- Integrated development environment for Java
4169 @cindex Java development environment
4170 @cindex Integrated Java development environment
4171 @cindex JDE
4173 @table @b
4175 @item Author
4176 @email{paulk@@mathworks.com, Paul Kinnucan}
4178 @item Mailing list
4179 jde-subscribe@@sunsite.auc.dk
4181 @item Latest version
4182 2.1.1
4184 @item Web site
4185 @uref{http://sunsite.auc.dk/jde/}
4187 @end table
4189 @node Patch,  , JDE, Major packages and programs
4190 @section Patch --- program to apply "diffs" for updating files
4191 @cindex Updating files with diffs
4192 @cindex Patching source files with diffs
4193 @cindex Diffs and patching
4194 @cindex @file{patch}
4196 @table @b
4198 @item Author
4199 @email{lwall@@wall.org, Larry Wall} (with GNU modifications)
4201 @item Latest version
4202 2.5.4
4204 @item Distribution
4205 @xref{Current GNU distributions}.
4207 @end table
4209 @c ------------------------------------------------------------
4210 @node Key bindings, Alternate character sets, Major packages and programs, Top
4211 @chapter Key bindings
4212 @cindex Key bindings
4214 @menu
4215 * Binding keys to commands::
4216 * Invalid prefix characters::
4217 * Terminal setup code works after Emacs has begun::
4218 * Using function keys under X::
4219 * Working with function and arrow keys::
4220 * X key translations for Emacs::
4221 * Handling C-s and C-q with flow control::
4222 * Binding C-s and C-q::
4223 * Backspace invokes help::
4224 * stty and Backspace key::
4225 * Swapping keys::
4226 * Producing C-XXX with the keyboard::
4227 * No Meta key::
4228 * No Escape key::
4229 * Compose Character::
4230 * Binding combinations of modifiers and function keys::
4231 * Meta key does not work in xterm::
4232 * ExtendChar key does not work as Meta::
4233 @end menu
4235 @node Binding keys to commands, Invalid prefix characters, Key bindings, Key bindings
4236 @section How do I bind keys (including function keys) to commands?
4237 @cindex Binding keys to commands
4238 @cindex Keys, binding to commands
4239 @cindex Commands, binding keys to
4241 Keys can be bound to commands either interactively or in your
4242 @file{.emacs} file.  To interactively bind keys for all modes, type
4243 @kbd{M-x global-set-key @key{RET} @var{key} @var{cmd} @key{RET}}.
4245 To bind a key just in the current major mode, type @kbd{M-x
4246 local-set-key @key{RET} @var{key} @var{cmd} @key{RET}}.
4248 @inforef{Key Bindings, Key Bindings, emacs}, for further details.
4250 To make the process of binding keys interactively eaiser, use the
4251 following ``trick'': First bind the key interactively, then immediately
4252 type @kbd{C-x @key{ESC} @key{ESC} C-a C-k C-g}.  Now, the command needed
4253 to bind the key is in the kill ring, and can be yanked into your
4254 @file{.emacs} file.  If the key binding is global, no changes to the
4255 command are required.  For example,
4257 @lisp
4258 (global-set-key (quote [f1]) (quote help-for-help))
4259 @end lisp
4261 @noindent
4262 can be placed directly into the @file{.emacs} file.  If the key binding is
4263 local, the command is used in conjunction with the "add-hook" command.
4264 For example, in tex-mode, a local binding might be
4266 @lisp
4267 (add-hook 'tex-mode-hook
4268   (lambda ()
4269    (local-set-key (quote [f1]) (quote help-for-help))))
4270 @end lisp
4273 @itemize @bullet
4275 @item
4276 Control characters in key sequences, in the form yanked from the kill
4277 ring are given in their graphic form---i.e., @key{CTRL} is shown as
4278 @samp{^}, @key{TAB} as a set of spaces (usually 8), etc.  You may want
4279 to convert these into their vector or string forms.
4281 @item
4282 If a prefix key of the character sequence to be bound is already
4283 bound as a complete key, then you must unbind it before the new
4284 binding.  For example, if @kbd{ESC @{} is previously bound:
4286 @lisp
4287 (global-unset-key [?\e ?@{])   ;;   or
4288 (local-unset-key [?\e ?@{])
4289 @end lisp
4291 @item
4292 Aside from commands and ``lambda lists,'' a vector or string also
4293 can be bound to a key and thus treated as a macro.  For example:
4295 @lisp
4296 (global-set-key [f10] [?\C-x?\e?\e?\C-a?\C-k?\C-g])  ;;  or
4297 (global-set-key [f10] "\C-x\e\e\C-a\C-k\C-g")
4298 @end lisp
4300 @end itemize
4302 @node Invalid prefix characters, Terminal setup code works after Emacs has begun, Binding keys to commands, Key bindings
4303 @section Why does Emacs say "Key sequence XXX uses invalid prefix characters"?
4304 @cindex Prefix characters, invalid
4305 @cindex Invalid prefix characters
4306 @cindex Misspecified key sequences
4308 Usually, one of two things has happened.  In one case, the control
4309 character in the key sequence has been misspecified (e.g. @samp{C-f}
4310 used instead of @samp{\C-f} within a Lisp expression).  In the other
4311 case, a @dfn{prefix key} in the keystroke sequence you were trying to bind
4312 was already bound as a @dfn{complete key}.  Historically, the @samp{ESC [}
4313 prefix was usually the problem, in which case you should evaluate either
4314 of these forms before attempting to bind the key sequence:
4316 @lisp
4317 (global-unset-key [?\e ?[])  ;;  or
4318 (global-unset-key "\e[")
4319 @end lisp
4321 @node Terminal setup code works after Emacs has begun, Using function keys under X, Invalid prefix characters, Key bindings
4322 @section Why doesn't this [terminal or window-system setup] code work in my @file{.emacs} file, but it works just fine after Emacs starts up?
4323 @cindex Terminal setup code in @file{.emacs}
4325 During startup, Emacs initializes itself according to a given code/file
4326 order.  If some of the code executed in your @file{.emacs} file needs to
4327 be postponed until the initial terminal or window-system setup code has
4328 been executed but is not, then you will experience this problem (this
4329 code/file execution order is not enforced after startup).
4331 To postpone the execution of Emacs Lisp code until after terminal or
4332 window-system setup, treat the code as a @dfn{lambda list} and set the
4333 value of either the @code{term-setup-hook} or @code{window-setup-hook}
4334 variable to this lambda function.  For example,
4336 @lisp
4337 (add-hook 'term-setup-hook
4338           (lambda ()
4339            (when (string-match "\\`vt220" (or (getenv "TERM") ""))
4340              ;; Make vt220's "Do" key behave like M-x:
4341              (global-set-key [do] 'execute-extended-command))))
4342 @end lisp
4344 For information on what Emacs does every time it is started, see the
4345 @file{lisp/startup.el} file.
4347 @node Using function keys under X, Working with function and arrow keys, Terminal setup code works after Emacs has begun, Key bindings
4348 @section How do I use function keys under X?
4349 @cindex Function keys
4350 @cindex X Window System and function keys
4351 @cindex Binding function keys
4353 With Emacs 19, functions keys under X are bound like any other key.  @xref{Binding keys to commands}, for details.
4355 @node Working with function and arrow keys, X key translations for Emacs, Using function keys under X, Key bindings
4356 @section How do I tell what characters or symbols my function or arrow keys emit?
4357 @cindex Working with arrow keys
4358 @cindex Arrow keys, symbols generated by
4359 @cindex Working with function keys
4360 @cindex Function keys, symbols generated by
4361 @cindex Symbols generated by function keys
4363 Type @kbd{C-h c} then the function or arrow keys.  The command will
4364 return either a function key symbol or character sequence (see the
4365 Emacs on-line documentation for an explanation).  This works for other
4366 keys as well.
4368 @node X key translations for Emacs, Handling C-s and C-q with flow control, Working with function and arrow keys, Key bindings
4369 @section How do I set the X key ``translations'' for Emacs?
4370 @cindex X key translations
4371 @cindex Key translations under X
4372 @cindex Translations for keys under X
4374 Emacs is not written using the Xt library by default, so there are no
4375 ``translations'' to be set.  (We aren't sure how to set such translations
4376 if you do build Emacs with Xt; please let us know if you've done this!)
4378 The only way to affect the behavior of keys within Emacs is through
4379 @code{xmodmap} (outside Emacs) or @code{define-key} (inside Emacs).  The
4380 @code{define-key} command should be used in conjunction with the
4381 @code{function-key-map} map.  For instance,
4383 @lisp
4384 (define-key function-key-map [M-@key{TAB}] [?\M-\t])
4385 @end lisp
4387 @noindent
4388 defines the @kbd{M-@key{TAB}} key sequence.
4390 @node Handling C-s and C-q with flow control, Binding C-s and C-q, X key translations for Emacs, Key bindings
4391 @section How do I handle @kbd{C-s} and @kbd{C-q} being used for flow control?
4392 @cindex Flow control, @kbd{C-s} and @kbd{C-q} with
4393 @cindex @kbd{C-s} and @kbd{C-q} with flow control
4395 @kbd{C-s} and @kbd{C-q} are used in the XON/XOFF flow control protocol.
4396 This messes things up when you're using Emacs over a serial line,
4397 because Emacs binds these keys to commands by default.  Because Emacs
4398 won't honor them as flow control characters, too many of these
4399 characters are not passed on and overwhelm output buffers.  Sometimes,
4400 intermediate software using XON/XOFF flow control will prevent Emacs
4401 from ever seeing @kbd{C-s} and @kbd{C-q}.
4403 Possible solutions:
4405 @itemize @bullet
4407 @item
4408 Disable the use of @kbd{C-s} and @kbd{C-q} for flow control.
4410 You need to determine the cause of the flow control.
4412 @itemize @minus
4414 @item
4415 your terminal
4417 Your terminal may use XON/XOFF flow control to have time to display
4418 all the characters it receives.  For example, VT series terminals do
4419 this.  It may be possible to turn this off from a setup menu.  For
4420 example, on a VT220 you may select ``No XOFF'' in the setup menu.  This
4421 is also true for some terminal emulation programs on PCs.
4423 When you turn off flow control at the terminal, you will also need to
4424 turn it off at the other end, which might be at the computer you are
4425 logged in to or at some terminal server in between.
4427 If you turn off flow control, characters may be lost; using a printer
4428 connected to the terminal may fail.  You may be able to get around
4429 this problem by modifying the @samp{termcap} entry for your terminal to
4430 include extra NUL padding characters.
4432 @item
4433 a modem
4435 If you are using a dialup connection, the modems may be using
4436 XON/XOFF flow control.  It's not clear how to get around this.
4438 @item
4439 a router or terminal server
4441 Some network box between the terminal and your computer may be using
4442 XON/XOFF flow control.  It may be possible to make it use some other
4443 kind of flow control.  You will probably have to ask your local
4444 network experts for help with this.
4446 @item
4447 @code{tty} and/or @code{pty} devices
4449 If your connection to Emacs goes through multiple @code{tty} and/or
4450 @code{pty} devices, they may be using XON/XOFF flow control even when it
4451 is not necessary.
4453 @email{eirik@@theory.tn.cornell.edu, Eirik Fuller} writes:
4455 @quotation
4456 Some versions of @code{rlogin} (and possibly @code{telnet}) do not pass
4457 flow control characters to the remote system to which they connect.  On
4458 such systems, Emacs on the remote system cannot disable flow control on
4459 the local system.  Sometimes @samp{rlogin -8} will avoid this problem.
4461 One way to cure this is to disable flow control on the local host (the
4462 one running @code{rlogin}, not the one running @code{rlogind}) using the
4463 @code{stty} command, before starting the @code{rlogin} process.  On many
4464 systems, @samp{stty start u stop u} will do this.
4466 Some versions of @samp{tcsh} will prevent even this from working.  One
4467 way around this is to start another shell before starting rlogin,
4468 and issue the @samp{stty} command to disable flow control from that shell.
4469 @end quotation
4471 Use @samp{stty -ixon} instead of @samp{stty start u stop u} on some systems.
4473 @end itemize
4475 @item
4476 Make Emacs speak the XON/XOFF flow control protocol.
4478 You can make Emacs treat @kbd{C-s} and @kbd{C-q} as flow control characters by
4479 evaluating the form
4481 @lisp
4482 (enable-flow-control)
4483 @end lisp
4485 @noindent
4486 to unconditionally enable flow control or
4488 @lisp
4489 (enable-flow-control-on "vt100" "h19")
4490 @end lisp
4492 @noindent
4493 (using your terminal names instead of @samp{vt100} or @samp{h19}) to
4494 enable selectively.  These commands will automatically swap @kbd{C-s}
4495 and @kbd{C-q} to @kbd{C-\} and @kbd{C-^}.  Variables can be used to
4496 change the default swap keys (@code{flow-control-c-s-replacement} and
4497 @code{flow-control-c-q-replacement}).
4499 If you are fixing this for yourself, simply put the form in your
4500 @file{.emacs} file.  If you are fixing this for your entire site, the
4501 best place to put it is in the @file{site-lisp/site-start.el} file.
4502 (Here @file{site-lisp} is actually a subdirectory of your Emacs
4503 installation directory, typically @file{/usr/local/share/emacs}.)
4504 Putting this form in @file{site-lisp/default.el} has the problem that
4505 if the user's @file{.emacs} file has an error, this will prevent
4506 @file{default.el} from being loaded and Emacs may be unusable for the
4507 user, even for correcting their @file{.emacs} file (unless they're
4508 smart enough to move it to another name).
4510 @code{enable-flow-control} can be invoked interactively as well:
4511 @kbd{M-x enable-flow-control @key{RET}}.
4513 @end itemize
4515 For further discussion of this issue, read the file @file{etc/PROBLEMS}
4516 (in the Emacs source directory when you unpack the Emacs distribution).
4518 @node Binding C-s and C-q, Backspace invokes help, Handling C-s and C-q with flow control, Key bindings
4519 @section How do I bind @kbd{C-s} and @kbd{C-q} (or any key) if these keys are filtered out?
4520 @cindex Binding @kbd{C-s} and @kbd{C-q}
4521 @cindex @kbd{C-s} and @kbd{C-q}, binding
4523 To bind @kbd{C-s} and @kbd{C-q}, use either @code{enable-flow-control}
4524 or @code{enable-flow-control-on}.  @xref{Handling C-s and C-q with flow
4525 control}, for usage and implementation details.
4527 To bind other keys, use @code{keyboard-translate}.  @xref{Swapping
4528 keys}, for usage details.  To do this for an entire site, you should
4529 swap the keys in @file{site-lisp/site-start.el}.  @xref{Handling C-s
4530 and C-q with flow control}, for an explanation of why
4531 @file{site-lisp/default.el} should not be used.
4533 @itemize @bullet
4535 @item
4536 If you do this for an entire site, the users will be confused by
4537 the disparity between what the documentation says and how Emacs
4538 actually behaves.
4540 @end itemize
4542 @node Backspace invokes help, stty and Backspace key, Binding C-s and C-q, Key bindings
4543 @section Why does the @key{Backspace} key invoke help?
4544 @cindex Backspace key invokes help
4545 @cindex Help invoked by Backspace
4546 @cindex DEL key does not delete
4548 The @key{Backspace} key (on most keyboards) generates ASCII code 8.
4549 @kbd{C-h} sends the same code.  In Emacs by default @kbd{C-h} invokes
4550 help-command.  This is intended to be easy to remember since the first
4551 letter of @samp{help} is @samp{h}.  The easiest solution to this problem
4552 is to use @kbd{C-h} (and @key{Backspace}) for help and @key{DEL} (the
4553 @key{Delete} key) for deleting the previous character.
4555 For many people this solution may be problematic:
4557 @itemize @bullet
4559 @item
4560 They normally use @key{Backspace} outside of Emacs for deleting the
4561 previous character.  This can be solved by making @key{DEL} the command
4562 for deleting the previous character outside of Emacs.  On many Unix
4563 systems, this command will remap @key{DEL}:
4565 @example
4566 stty erase `^?'
4567 @end example
4569 @item
4570 The user may prefer the @key{Backspace} key for deleting the
4571 previous character because it is more conveniently located on their
4572 keyboard or because they don't even have a separate @key{Delete} key.
4573 In this case, the @key{Backspace} key should be made to behave like
4574 @key{Delete}.  There are several methods.
4576 @itemize @minus
4577 @item
4578 Some terminals (e.g., VT3## terminals) and terminal emulators (e.g.,
4579 TeraTerm) allow the character generated by the @key{Backspace} key to be
4580 changed from a setup menu.
4582 @item
4583 You may be able to get a keyboard that is completely programmable, or a
4584 terminal emulator that supports remapping of any key to any other key.
4586 @item
4587 With Emacs 21.1 and later, you can control the effect of the
4588 @key{Backspace} and @key{Delete} keys, on both dumb terminals and a
4589 windowed displays, by customizing the option
4590 @code{normal-erase-is-backspace-mode}, or by invoking @kbd{M-x
4591 normal-erase-is-backspace}.  See the documentation of these symbols
4592 (@pxref{Emacs Lisp documentation}) for more info.
4594 @item
4595 It is possible to swap the @key{Backspace} and @key{DEL} keys inside
4596 Emacs:
4598 @lisp
4599 (keyboard-translate ?\C-h ?\C-?)
4600 @end lisp
4602 @noindent
4603 This is the recommended method of forcing @key{Backspace} to act as
4604 @key{DEL}, because it works even in modes which bind @key{DEL} to
4605 something other than @code{delete-backward-char}.
4607 Similarly, you could remap @key{DEL} to act as @kbd{C-d}, which by
4608 default deletes forward:
4610 @lisp
4611 (keyboard-translate ?\C-? ?\C-d)
4612 @end lisp
4614 @xref{Swapping keys}, for further details about @code{keyboard-translate}.
4616 @item
4617 Another approach is to switch key bindings and put help on @kbd{C-x h}
4618 instead:
4620 @lisp
4621 (global-set-key "\C-h" 'delete-backward-char)
4623 ;;; overrides mark-whole-buffer
4624 (global-set-key "\C-xh" 'help-command)
4625 @end lisp
4627 @noindent
4628 This method is not recommended, though: it only solves the problem for
4629 those modes which bind @key{DEL} to @code{delete-backward-char}.  Modes
4630 which bind @key{DEL} to something else, such as @code{view-mode}, will
4631 not work as you expect when you press the @key{Backspace} key.  For this
4632 reason, we recommend the @code{keyboard-translate} method, shown
4633 above.
4635 Other popular key bindings for help are @kbd{M-?} and @kbd{C-x ?}.
4636 @end itemize
4638 Don't try to bind @key{DEL} to @code{help-command}, because there are
4639 many modes that have local bindings of @key{DEL} that will interfere.
4641 @end itemize
4643 When Emacs 21 or later runs on a windowed display, it binds the
4644 @key{Delete} key to a command which deletes the character at point, to
4645 make Emacs more consistent with keyboard operation on these systems.
4647 For more information about troubleshooting this problem, see @ref{DEL
4648 Does Not Delete, , If @key{DEL} Fails to Delete, emacs, The GNU Emacs
4649 Manual}.
4651 @node stty and Backspace key, Swapping keys, Backspace invokes help, Key bindings
4652 @section Why doesn't Emacs look at the @file{stty} settings for @key{Backspace} vs. @key{Delete}?
4653 @cindex @file{stty} and Emacs
4654 @cindex Backspace and @file{stty}
4655 @cindex Delete and @file{stty}
4657 Good question!
4659 @c FIXME: RMS explained the reasons for this on emacs-hackers.  It's
4660 @c probably worth putting that explanation here.
4662 @node Swapping keys, Producing C-XXX with the keyboard, stty and Backspace key, Key bindings
4663 @section How do I swap two keys?
4664 @cindex Swapping keys
4665 @cindex Keys, swapping
4666 @cindex @code{keyboard-translate}
4668 In Emacs 19, you can swap two keys (or key sequences) by using the
4669 @code{keyboard-translate} function.  For example, to turn @kbd{C-h} into
4670 @key{DEL} and @key{DEL} to @kbd{C-h}, use
4672 @lisp
4673 (keyboard-translate ?\C-h ?\C-?)  ; translate `C-h' to DEL
4674 (keyboard-translate ?\C-? ?\C-h)  ; translate DEL to `C-h'.
4675 @end lisp
4677 @noindent
4678 The first key sequence of the pair after the function identifies what is
4679 produced by the keyboard; the second, what is matched for in the
4680 keymaps.
4682 Keyboard translations are not the same as key bindings in keymaps.
4683 Emacs contains numerous keymaps that apply in different situations, but
4684 there is only one set of keyboard translations, and it applies to every
4685 character that Emacs reads from the terminal.  Keyboard translations
4686 take place at the lowest level of input processing; the keys that are
4687 looked up in keymaps contain the characters that result from keyboard
4688 translation.
4690 @inforef{Keyboard Translations, Keyboard Translations, emacs}.
4692 @node Producing C-XXX with the keyboard, No Meta key, Swapping keys, Key bindings
4693 @section How do I produce C-XXX with my keyboard?
4694 @cindex Producing control characters
4695 @cindex Generating control characters
4696 @cindex Control characters, generating
4698 On terminals (but not under X), some common "aliases" are:
4700 @table @asis
4702 @item @kbd{C-2}  or  @kbd{C-@key{SPC}}
4703 @kbd{C-@@}
4705 @item @kbd{C-6}
4706 @kbd{C-^}
4708 @item @kbd{C-7}  or  @kbd{C-S--}
4709 @kbd{C-_}
4711 @item @kbd{C-4}
4712 @kbd{C-\}
4714 @item @kbd{C-5}
4715 @kbd{C-]}
4717 @item @kbd{C-/}
4718 @kbd{C-?}
4720 @end table
4722 Often other aliases exist; use the @kbd{C-h c} command and try
4723 @key{CTRL} with all of the digits on your keyboard to see what gets
4724 generated.  You can also try the @kbd{C-h w} command if you know the
4725 name of the command.
4727 @node No Meta key, No Escape key, Producing C-XXX with the keyboard, Key bindings
4728 @section What if I don't have a @key{Meta} key?
4729 @cindex No @key{Meta} key
4730 @cindex @key{Meta} key, what to do if you lack it
4732 On many keyboards, the @key{Alt} key acts as @key{Meta}, so try it.
4734 Instead of typing @kbd{M-a}, you can type @kbd{@key{ESC} a}.  In fact,
4735 Emacs converts @kbd{M-a} internally into @kbd{@key{ESC} a} anyway
4736 (depending on the value of @code{meta-prefix-char}).  Note that you
4737 press @key{Meta} and @key{a} together, but with @key{ESC}, you press
4738 @key{ESC}, release it, and then press @key{a}.
4740 @node No Escape key, Compose Character, No Meta key, Key bindings
4741 @section What if I don't have an @key{Escape} key?
4742 @cindex No Escape key
4743 @cindex Lacking an Escape key
4744 @cindex Escape key, lacking
4746 Type @kbd{C-[} instead.  This should send ASCII code 27 just like an
4747 Escape key would.  @kbd{C-3} may also work on some terminal (but not
4748 under X).  For many terminals (notably DEC terminals) @key{F11}
4749 generates @key{ESC}.  If not, the following form can be used to bind it:
4751 @lisp
4752 ;;; F11 is the documented ESC replacement on DEC terminals.
4753 (define-key function-key-map [f11] [?\e])
4754 @end lisp
4756 @node Compose Character, Binding combinations of modifiers and function keys, No Escape key, Key bindings
4757 @section Can I make my @key{Compose Character} key behave like a @key{Meta} key?
4758 @cindex @key{Compose Character} key, using as @key{Meta}
4759 @cindex @key{Meta}, using @key{Compose Character} for
4761 On a dumb terminal such as a VT220, no.  It is rumored that certain
4762 VT220 clones could have their @key{Compose} key configured this way.  If
4763 you're using X, you might be able to do this with the @code{xmodmap}
4764 command.
4766 @node Binding combinations of modifiers and function keys, Meta key does not work in xterm, Compose Character, Key bindings
4767 @section How do I bind a combination of modifier key and function key?
4768 @cindex Modifiers and function keys
4769 @cindex Function keys and modifiers
4770 @cindex Binding modifiers and function keys
4772 With Emacs 19 and later, you can represent modified function keys in
4773 vector format by adding prefixes to the function key symbol.  For
4774 example (from the on-line documentation):
4776 @lisp
4777 (global-set-key [?\C-x right] 'forward-page)
4778 @end lisp
4780 @noindent
4781 where @samp{?\C-x} is the Lisp character constant for the character @kbd{C-x}.
4783 You can use the modifier keys @key{Control}, @key{Meta}, @key{Hyper},
4784 @key{Super}, @key{Alt}, and @key{Shift} with function keys.  To
4785 represent these modifiers, prepend the strings @samp{C-}, @samp{M-},
4786 @samp{H-}, @samp{s-}, @samp{A-}, and @samp{S-} to the symbol name.  Here
4787 is how to make @kbd{H-M-RIGHT} move forward a word:
4789 @lisp
4790 (global-set-key [H-M-right] 'forward-word)
4791 @end lisp
4793 @itemize @bullet
4795 @item
4796 Not all modifiers are permitted in all situations.  @key{Hyper},
4797 @key{Super}, and @key{Alt} are not available on Unix character
4798 terminals.  Non-ASCII keys and mouse events (e.g. @kbd{C-=} and
4799 @kbd{Mouse-1}) also fall under this category.
4801 @end itemize
4803 @xref{Binding keys to commands}, for general key binding instructions.
4805 @node Meta key does not work in xterm, ExtendChar key does not work as Meta, Binding combinations of modifiers and function keys, Key bindings
4806 @section Why doesn't my @key{Meta} key work in an @code{xterm} window?
4807 @cindex @key{Meta} key and @code{xterm}
4808 @cindex Xterm and @key{Meta} key
4810 @inforef{Single-Byte Character Support, Single-Byte Character Set
4811 Support, emacs}.
4813 If the advice in the Emacs manual fails, try all of these methods before
4814 asking for further help:
4816 @itemize @bullet
4818 @item
4819 You may have big problems using @code{mwm} as your window manager.
4820 (Does anyone know a good generic solution to allow the use of the
4821 @key{Meta} key in Emacs with @file{mwm}?)
4823 @item
4824 For X11: Make sure it really is a @key{Meta} key.  Use @code{xev} to
4825 find out what keysym your @key{Meta} key generates.  It should be either
4826 @code{Meta_L} or @code{Meta_R}.  If it isn't, use @file{xmodmap} to fix
4827 the situation.  If @key{Meta} does generate @code{Meta_L} or
4828 @code{Meta_R}, but @kbd{M-x} produces a non-ASCII character, put this in
4829 your @file{~/.Xdefaults} file:
4831 @example
4832  XTerm*eightBitInput:   false
4833  XTerm*eightBitOutput:  true
4834 @end example
4836 @item
4837 Make sure the @code{pty} the @code{xterm} is using is passing 8 bit
4838 characters.  @samp{stty -a} (or @samp{stty everything}) should show
4839 @samp{cs8} somewhere.  If it shows @samp{cs7} instead, use @samp{stty
4840 cs8 -istrip} (or @samp{stty pass8}) to fix it.
4842 @item
4843 If there is an @code{rlogin} connection between @code{xterm} and Emacs, the
4844 @samp{-8} argument may need to be given to rlogin to make it pass all 8 bits
4845 of every character.
4847 @item
4848 If Emacs is running on Ultrix, it is reported that evaluating
4849 @code{(set-input-mode t nil)} helps.
4851 @item
4852 If all else fails, you can make @code{xterm} generate @kbd{@key{ESC} W} when
4853 you type @kbd{M-W}, which is the same conversion Emacs would make if it
4854 got the @kbd{M-W} anyway.  In X11R4, the following resource
4855 specification will do this:
4857 @example
4858 XTerm.VT100.EightBitInput: false
4859 @end example
4861 @noindent
4862 (This changes the behavior of the @code{insert-eight-bit} action.)
4864 With older @code{xterm}s, you can specify this behavior with a translation:
4866 @example
4867 XTerm.VT100.Translations: #override \
4868   Meta<KeyPress>: string(0x1b) insert()
4869 @end example
4871 @noindent
4872 You might have to replace @samp{Meta} with @samp{Alt}.
4874 @end itemize
4876 @node ExtendChar key does not work as Meta,  , Meta key does not work in xterm, Key bindings
4877 @section Why doesn't my @key{ExtendChar} key work as a @key{Meta} key under HP-UX 8.0 and 9.x?
4878 @cindex @key{ExtendChar} key as @key{Meta}
4879 @cindex @key{Meta}, using @key{ExtendChar} for
4880 @cindex HP-UX, the @key{ExtendChar} key
4882 This is a result of an internationalization extension in X11R4 and the
4883 fact that HP is now using this extension.  Emacs assumes that the
4884 @code{XLookupString} function returns the same result regardless of the
4885 @key{Meta} key state which is no longer necessarily true.  Until Emacs
4886 is fixed, the temporary kludge is to run this command after each time
4887 the X server is started but preferably before any xterm clients are:
4889 @example
4890 xmodmap -e 'remove mod1 = Mode_switch'
4891 @end example
4893 @c FIXME: Emacs 21 supports I18N in X11; does that mean that this bug is
4894 @c solved?
4896 This will disable the use of the extra keysyms systemwide, which may be
4897 undesirable if you actually intend to use them.
4899 @c ------------------------------------------------------------
4900 @node Alternate character sets, Mail and news, Key bindings, Top
4901 @chapter Alternate character sets
4902 @cindex Alternate character sets
4904 @menu
4905 * Emacs does not display 8-bit characters::
4906 * Inputting eight-bit characters::
4907 * Kanji and Chinese characters::
4908 * Right-to-left alphabets::
4909 @end menu
4911 @node Emacs does not display 8-bit characters, Inputting eight-bit characters, Alternate character sets, Alternate character sets
4912 @section How do I make Emacs display 8-bit characters?
4913 @cindex Displaying eight-bit characters
4914 @cindex Eight-bit characters, displaying
4916 @inforef{Single-Byte Character Support, Single-byte Character Set
4917 Support, emacs}.  On a Unix, when Emacs runs on a text-only terminal
4918 display or is invoked with @samp{emacs -nw}, you typically need to use
4919 @code{set-terminal-coding-system} to tell Emacs what the terminal can
4920 display, even after setting the language environment; otherwise
4921 non-ASCII characters will display as @samp{?}.  On other operating
4922 systems, such as MS-DOS and MS-Windows, Emacs queries the OS about the
4923 character set supported by the display, and sets up the required
4924 terminal coding system automatically.
4926 @node Inputting eight-bit characters, Kanji and Chinese characters, Emacs does not display 8-bit characters, Alternate character sets
4927 @section How do I input eight-bit characters?
4928 @cindex Entering eight-bit characters
4929 @cindex Eight-bit characters, entering
4930 @cindex Input, 8-bit characters
4932 Various methods are available for input of eight-bit characters.  See
4933 @inforef{Single-Byte Character Support, Single-byte Character Set
4934 Support, emacs}.  For more sophisticated methods, @inforef{Input
4935 Methods, Input Methods, emacs}.
4937 @node Kanji and Chinese characters, Right-to-left alphabets, Inputting eight-bit characters, Alternate character sets
4938 @section Where can I get an Emacs that handles kanji, Chinese, or other Far-Eastern character sets?
4939 @cindex Kanji, handling with Emacs
4940 @cindex Chinese, handling with Emacs
4941 @cindex Japanese, handling with Emacs
4942 @cindex Korean, handling with Emacs
4944 Emacs 20 and later includes many of the features of MULE, the MULtilingual
4945 Enhancement to Emacs.  @xref{Installing Emacs}, for information on where
4946 to find and download the latest version of Emacs.
4948 @node Right-to-left alphabets,  , Kanji and Chinese characters, Alternate character sets
4949 @section Where is an Emacs that can handle Semitic (right-to-left) alphabets?
4950 @cindex Right-to-left alphabets
4951 @cindex Hebrew, handling with Emacs
4952 @cindex Semitic alphabets
4953 @cindex Arabic alphabets
4955 Emacs 20 and later supports Hebrew characters (ISO 8859-8), but does not
4956 yet support right-to-left character entry and display.
4958 @email{joel@@exc.com, Joel M. Hoffman} has written a Lisp package called
4959 @file{hebrew.el} that allows right-to-left editing of Hebrew.  It
4960 reportedly works out of the box with Emacs 19, but requires patches for
4961 Emacs 18.  Write to Joel if you want the patches or package.
4963 @c FIXME: Should we mention Ehud Karni's package?
4965 @file{hebrew.el} requires a Hebrew screen font, but no other hardware support.
4966 Joel has a screen font for PCs running MS-DOS or GNU/Linux.
4968 You might also try to query archie for files named with @file{hebrew};
4969 several ftp sites in Israel may also have the necessary files.
4971 @c ------------------------------------------------------------
4972 @node Mail and news, Concept index, Alternate character sets, Top
4973 @chapter Mail and news
4974 @cindex Mail and news
4976 @menu
4977 * Changing the included text prefix::
4978 * Saving a copy of outgoing mail::
4979 * Expanding aliases when sending mail::
4980 * Rmail thinks all messages are one big one::
4981 * Sorting the messages in an Rmail folder::
4982 * Rmail writes to /usr/spool/mail::
4983 * Recovering mail files when Rmail munges them::
4984 * Replying to the sender of a message::
4985 * MIME with Emacs mail packages::
4986 * Automatically starting a mail or news reader::
4987 * Reading news with Emacs::
4988 * Gnus does not work with NNTP::
4989 * Viewing articles with embedded underlining::
4990 * Saving a multi-part Gnus posting::
4991 * Starting Gnus faster::
4992 * Catching up in all newsgroups::
4993 * Killing based on nonstandard headers::
4994 * Removing flashing messages::
4995 * Catch-up is slow in Gnus::
4996 * Gnus hangs for a long time::
4997 * Learning more about Gnus::
4998 @end menu
5000 @node Changing the included text prefix, Saving a copy of outgoing mail, Mail and news, Mail and news
5001 @section How do I change the included text prefix in mail/news followups?
5002 @cindex Prefix in mail/news followups, changing
5003 @cindex Included text prefix, changing
5004 @cindex Setting the included text character
5005 @cindex Quoting in mail messages
5007 If you read mail with Rmail or news with Gnus, set the variable
5008 @code{mail-yank-prefix}.  For VM, set @code{vm-included-text-prefix}.
5009 For mh-e, set @code{mh-ins-buf-prefix}.
5011 For fancier control of citations, use Supercite.  @xref{Supercite}.
5013 To prevent Emacs from including various headers of the replied-to
5014 message, set the value of @code{mail-yank-ignored-headers} to an
5015 appropriate regexp.
5017 @node Saving a copy of outgoing mail, Expanding aliases when sending mail, Changing the included text prefix, Mail and news
5018 @section How do I save a copy of outgoing mail?
5019 @cindex Saving a copy of outgoing mail
5020 @cindex Copying outgoing mail to a file
5021 @cindex Filing outgoing mail
5022 @cindex Automatic filing of outgoing mail
5023 @cindex Mail, saving outgoing automatically
5025 You can either mail yourself a copy by including a @samp{BCC} header in the
5026 mail message, or store a copy of the message directly to a file by
5027 including an @samp{FCC} header.
5029 If you use standard mail, you can automatically create a @samp{BCC} to
5030 yourself by putting
5032 @lisp
5033 (setq mail-self-blind t)
5034 @end lisp
5036 @noindent
5037 in your @file{.emacs} file.  You can automatically include an @samp{FCC}
5038 field by putting something like the following in your @file{.emacs}
5039 file:
5041 @lisp
5042 (setq mail-archive-file-name (expand-file-name "~/outgoing"))
5043 @end lisp
5045 The output file will be in Unix mail format, which can be read directly
5046 by VM, but not always by Rmail.  @xref{Learning how to do something}.
5048 If you use @code{mh-e}, add an @samp{FCC} or @samp{BCC} field to your
5049 components file.
5051 It does not work to put @samp{set record filename} in the @file{.mailrc}
5052 file.
5054 @node Expanding aliases when sending mail, Rmail thinks all messages are one big one, Saving a copy of outgoing mail, Mail and news
5055 @section Why doesn't Emacs expand my aliases when sending mail?
5056 @cindex Expanding aliases when sending mail
5057 @cindex Mail alias expansion
5058 @cindex Sending mail with aliases
5060 @itemize @bullet
5062 @item
5063 You must separate multiple addresses in the headers of the mail buffer
5064 with commas.  This is because Emacs supports RFC822 standard addresses
5065 like this one:
5067 @example
5068 To: Willy Smith <wks@@xpnsv.lwyrs.com>
5069 @end example
5071 However, you do not need to---and probably should not, unless your
5072 system's version of @file{/usr/ucb/mail} (a.k.a.@: @code{mailx})
5073 supports RFC822---separate addresses with commas in your
5074 @file{~/.mailrc} file.
5076 @item
5077 Emacs normally only reads the @file{.mailrc} file once per session,
5078 when you start to compose your first mail message.  If you edit
5079 @file{.mailrc}, you can type @kbd{M-x rebuild-mail-abbrevs @key{RET}} to
5080 make Emacs reread @file{~/.mailrc}.
5082 @item
5083 If you like, you can expand mail aliases as abbrevs, as soon as you
5084 type them in.  To enable this feature, execute the following:
5086 @lisp
5087 (add-hook 'mail-mode-hook 'mail-abbrevs-setup)
5088 @end lisp
5090 Note that the aliases are expanded automatically only after you type
5091 @key{RET} or a punctuation character (e.g. @kbd{,}).  You can force their
5092 expansion by moving point to the end of the alias and typing @kbd{C-x a e}
5093 (@kbd{M-x expand-abbrev}).
5094 @end itemize
5096 @node Rmail thinks all messages are one big one, Sorting the messages in an Rmail folder, Expanding aliases when sending mail, Mail and news
5097 @section Why does Rmail think all my saved messages are one big message?
5098 @cindex Rmail thinks all messages are one large message
5100 A file created through the @samp{FCC} field in a message is in Unix mail
5101 format, not the format that Rmail uses (BABYL format).  Rmail will try
5102 to convert a Unix mail file into BABYL format on input, but sometimes it
5103 makes errors.  For guaranteed safety, you can make the
5104 @file{saved-messages} file be an inbox for your Rmail file by using the
5105 function @code{set-rmail-inbox-list}.
5107 @node Sorting the messages in an Rmail folder, Rmail writes to /usr/spool/mail, Rmail thinks all messages are one big one, Mail and news
5108 @section How can I sort the messages in my Rmail folder?
5109 @cindex Rmail, sorting messages in
5110 @cindex Folder, sorting messages in an Rmail
5111 @cindex Sorting messages in an Rmail folder
5113 In Rmail, type @kbd{C-c C-s C-h} to get a list of sorting functions
5114 and their key bindings.
5116 @node Rmail writes to /usr/spool/mail, Recovering mail files when Rmail munges them, Sorting the messages in an Rmail folder, Mail and news
5117 @section Why does Rmail need to write to @file{/usr/spool/mail}?
5118 @cindex Rmail and @file{/usr/spool/mail}
5119 @cindex @file{/usr/spool/mail} and Rmail
5121 This is the behavior of the @code{movemail} program which Rmail uses.
5122 This indicates that @code{movemail} is configured to use lock files.
5124 RMS writes:
5126 @quotation
5127 Certain systems require lock files to interlock access to mail files.
5128 On these systems, @code{movemail} must write lock files, or you risk losing
5129 mail.  You simply must arrange to let @code{movemail} write them.
5131 Other systems use the @code{flock} system call to interlock access.  On
5132 these systems, you should configure @code{movemail} to use @code{flock}.
5133 @end quotation
5135 @node Recovering mail files when Rmail munges them, Replying to the sender of a message, Rmail writes to /usr/spool/mail, Mail and news
5136 @section How do I recover my mail files after Rmail munges their format?
5137 @cindex Recovering munged mail files
5138 @cindex Rmail munged my files
5139 @cindex Mail files, recovering those munged by Rmail
5141 If you have just done @kbd{M-x rmail-input} on a file and you don't want
5142 to save it in Rmail's format (called BABYL), just kill the buffer (with
5143 @kbd{C-x k}).
5145 @cindex Exporting messages as Unix mail files
5146 If you typed @kbd{M-x rmail} and it read some messages out of your inbox
5147 and you want to put them in a Unix mail file, use @kbd{C-o} on each
5148 message.
5150 @cindex Converting from BABYL to Unix mail format
5151 @cindex @code{unrmail} command
5152 If you want to convert an existing file from BABYL format to Unix mail
5153 format, use the command @kbd{M-x unrmail}: it will prompt you for the
5154 input and output file names.
5156 @pindex b2m
5157 Alternatively, you could use the @code{b2m} program supplied with
5158 Emacs.  @code{b2m} is a filter, and is used like this:
5160 @example
5161  b2m < @var{babyl-file} > @var{mbox-file}
5162 @end example
5164 @noindent
5165 where @var{babyl-file} is the name of the BABYL file, and
5166 @var{mbox-file} is the name of the file where the converted mail will
5167 be written.
5169 @node Replying to the sender of a message, MIME with Emacs mail packages, Recovering mail files when Rmail munges them, Mail and news
5170 @section How can I force Rmail to reply to the sender of a message, but not the other recipients?
5171 @cindex Replying only to the sender of a message
5172 @cindex Sender, replying only to
5173 @cindex Rmail, replying to the sender of a message in
5175 @email{isaacson@@seas.upenn.edu, Ron Isaacson} says: When you hit
5176 @key{r} to reply in Rmail, by default it CCs all of the original
5177 recipients (everyone on the original @samp{To} and @samp{CC}
5178 lists). With a prefix argument (i.e., typing @kbd{C-u} before @key{r}),
5179 it replies only to the sender.  However, going through the whole
5180 @kbd{C-u} business every time you want to reply is a pain.  This is the
5181 best fix I've been able to come up with:
5183 @lisp
5184 (defun rmail-reply-t ()
5185   "Reply only to the sender of the current message. (See rmail-reply.)"
5186   (interactive)
5187   (rmail-reply t))
5189 (add-hook 'rmail-mode-hook
5190   (lambda ()
5191     (define-key rmail-mode-map "r" 'rmail-reply-t)
5192     (define-key rmail-mode-map "R" 'rmail-reply)))
5193 @end lisp
5195 @node MIME with Emacs mail packages, Automatically starting a mail or news reader, Replying to the sender of a message, Mail and news
5196 @section How can I get my favorite Emacs mail package to support MIME?
5197 @cindex MIME and Emacs mail packages
5198 @cindex Mail packages and MIME
5199 @cindex FAQ for MIME and Emacs
5201 Read the Emacs MIME FAQ, maintained by @email{trey@@cs.berkeley.edu,
5202 MacDonald Hall Jackson} at
5204 @uref{http://bmrc.berkeley.edu/~trey/emacs/mime.html}
5206 Version 6.x of VM supports MIME.  @xref{VM}.  Gnus supports MIME in mail
5207 and news messages as of version 5.8.1 (Pterodactyl).  Rmail has limited
5208 support for single-part MIME messages beginning with Emacs 20.3.
5210 @node Automatically starting a mail or news reader, Reading news with Emacs, MIME with Emacs mail packages, Mail and news
5211 @section How do I make Emacs automatically start my mail/news reader?
5212 @cindex Mail reader, starting automatically
5213 @cindex News reader, starting automatically
5214 @cindex Starting mail/news reader automatically
5216 To start Emacs in Gnus:
5218 @example
5219 emacs -f gnus
5220 @end example
5222 @noindent
5223 in Rmail:
5225 @example
5226 emacs -f rmail
5227 @end example
5229 A more convenient way to start with Gnus:
5231 @example
5232 alias gnus 'emacs -f gnus'
5233 gnus
5234 @end example
5236 It is probably unwise to automatically start your mail or news reader
5237 from your @file{.emacs} file.  This would cause problems if you needed to run
5238 two copies of Emacs at the same time.  Also, this would make it difficult for
5239 you to start Emacs quickly when you needed to.
5241 @node Reading news with Emacs, Gnus does not work with NNTP, Automatically starting a mail or news reader, Mail and news
5242 @section How do I read news under Emacs?
5243 @cindex Reading news under Emacs
5244 @cindex Usenet reader in Emacs
5245 @cindex Gnus newsreader
5247 Use @kbd{M-x gnus}.  It is documented in Info (@pxref{Learning how to do
5248 something}).
5250 @node Gnus does not work with NNTP, Viewing articles with embedded underlining, Reading news with Emacs, Mail and news
5251 @section Why doesn't Gnus work via NNTP?
5252 @cindex Gnus and NNTP
5253 @cindex NNTP, Gnus fails to work with
5255 There is a bug in NNTP version 1.5.10, such that when multiple requests
5256 are sent to the NNTP server, the server only handles the first one
5257 before blocking waiting for more input which never comes.  NNTP version
5258 1.5.11 claims to fix this.
5260 You can work around the bug inside Emacs like this:
5262 @lisp
5263 (setq nntp-maximum-request 1)
5264 @end lisp
5266 You can find out what version of NNTP your news server is running by
5267 telnetting to the NNTP port (usually 119) on the news server machine
5268 (i.e., @kbd{telnet server-machine 119}).  The server should give its
5269 version number in the welcome message.  Type @kbd{quit} to get out.
5271 @xref{Spontaneous entry into isearch-mode}, for some additional ideas.
5273 @node Viewing articles with embedded underlining, Saving a multi-part Gnus posting, Gnus does not work with NNTP, Mail and news
5274 @section How do I view news articles with embedded underlining (e.g., ClariNews)?
5275 @cindex Underlining, embedded in news articles
5276 @cindex News articles with embedded underlining
5277 @cindex Embedded underlining in news articles
5279 Underlining appears like this:
5281 @example
5282 _^Hu_^Hn_^Hd_^He_^Hr_^Hl_^Hi_^Hn_^Hi_^Hn_^Hg
5283 @end example
5285 @email{abraham@@dina.kvl.dk, Per Abrahamsen} suggests using the following
5286 code, which uses the underline face to turn such text into true
5287 underlining, inconjunction with Gnus:
5289 @lisp
5290 (defun gnus-article-prepare-overstrike ()
5291   ;; Prepare article for overstrike commands.
5292   (save-excursion
5293     (set-buffer gnus-article-buffer)
5294     (let ((buffer-read-only nil))
5295     (goto-char (point-min))
5296       (while (search-forward "\b" nil t)
5297         (let ((next (following-char))
5298               (previous (char-after (- (point) 2))))
5299           (cond ((eq next previous)
5300                  (delete-region (- (point) 2) (point))
5301                  (put-text-property (point) (1+ (point))
5302                                     'face 'bold))
5303                 ((eq next ?_)
5304                  (delete-region (1- (point)) (1+ (point)))
5305                  (put-text-property (1- (point)) (point)
5306                                     'face 'underline))
5307                 ((eq previous ?_)
5308                  (delete-region (- (point) 2) (point))
5309                  (put-text-property (point) (1+ (point))
5310                                     'face 'underline))))))))
5312 (add-hook 'gnus-article-prepare-hook 'gnus-article-prepare-overstrike)
5313 @end lisp
5315 Latest versions of Gnus do such a conversion automatically.
5317 If you prefer to do away with underlining altogether, you can
5318 destructively remove it with @kbd{M-x ununderline-region}; do this
5319 automatically via
5321 @lisp
5322 (add-hook 'gnus-article-prepare-hook
5323   (lambda () (ununderline-region (point-min) (point-max))))
5324 @end lisp
5326 @node Saving a multi-part Gnus posting, Starting Gnus faster, Viewing articles with embedded underlining, Mail and news
5327 @section How do I save all the items of a multi-part posting in Gnus?
5328 @cindex Multi-part postings in Gnus, saving
5329 @cindex Saving multi-part postings in Gnus
5330 @cindex Gnus, saving multi-part postings in
5332 Use @code{gnus-uu}.  Type @kbd{C-c C-v C-h} in the Gnus summary buffer
5333 to see a list of available commands.
5335 @node Starting Gnus faster, Catching up in all newsgroups, Saving a multi-part Gnus posting, Mail and news
5336 @section How do I make Gnus start up faster?
5337 @cindex Faster, starting Gnus
5338 @cindex Starting Gnus faster
5339 @cindex Gnus, starting faster
5341 From the Gnus FAQ (@pxref{Learning more about Gnus}):
5343 @quotation
5344 @email{pktiwari@@eos.ncsu.edu, Pranav Kumar Tiwari} writes: I posted
5345 the same query recently and I got an answer to it. I am going to
5346 repeat the answer. What you need is a newer version of gnus, version
5347 5.0.4+. I am using 5.0.12 and it works fine with me with the
5348 following settings:
5350 @lisp
5351 (setq gnus-check-new-newsgroups nil
5352       gnus-read-active-file 'some
5353       gnus-nov-is-evil nil
5354       gnus-select-method '(nntp gnus-nntp-server))
5355 @end lisp
5356 @end quotation
5358 @node Catching up in all newsgroups, Killing based on nonstandard headers, Starting Gnus faster, Mail and news
5359 @section How do I catch up all newsgroups in Gnus?
5360 @cindex Catching up all newsgroups in Gnus
5361 @cindex Gnus, Catching up all newsgroups in
5363 In the @file{*Newsgroup*} buffer, type @kbd{M-< C-x ( c y C-x ) M-0 C-x e}
5365 Leave off the initial @kbd{M-<} if you only want to catch up from point
5366 to the end of the @file{*Newsgroup*} buffer.
5368 @node Killing based on nonstandard headers, Removing flashing messages, Catching up in all newsgroups, Mail and news
5369 @section Why can't I kill in Gnus based on the Newsgroups/Keywords/Control headers?
5370 @cindex Killing articles based on nonstandard headers
5371 @cindex Newsgroups header, killing articles based on
5372 @cindex Keywords header, killing articles based on
5373 @cindex Control header, killing articles based on
5375 Gnus will complain that the @samp{Newsgroups}, @samp{Keywords}, and
5376 @samp{Control} headers are ``Unknown header'' fields.
5378 For the @samp{Newsgroups} header, there is an easy workaround: kill on the
5379 @samp{Xref} header instead, which will be present on any cross-posted article
5380 (as long as your site carries the cross-post group).
5382 If you really want to kill on one of these headers, you can do it like
5383 this:
5385 @lisp
5386 (gnus-kill nil "^Newsgroups: .*\\(bad\\.group\\|worse\\.group\\)")
5387 @end lisp
5389 @node Removing flashing messages, Catch-up is slow in Gnus, Killing based on nonstandard headers, Mail and news
5390 @section How do I get rid of flashing messages in Gnus for slow connections?
5391 @cindex Flashing Gnus messages, removing
5392 @cindex Removing flashing Gnus messages
5393 @cindex Slow connections causing flashing messages in Gnus
5394 @cindex Gnus, flashing messages in
5396 Set @code{nntp-debug-read} to @code{nil}.
5398 @node Catch-up is slow in Gnus, Gnus hangs for a long time, Removing flashing messages, Mail and news
5399 @section Why is catch up slow in Gnus?
5400 @cindex Slow catch up in Gnus
5401 @cindex Gnus is slow when catching up
5402 @cindex Crosspostings make Gnus catching up slow
5404 Because Gnus is marking crosspostings read.  You can control this with
5405 the variable @code{gnus-use-cross-reference}.
5407 @node Gnus hangs for a long time, Learning more about Gnus, Catch-up is slow in Gnus, Mail and news
5408 @section Why does Gnus hang for a long time when posting?
5409 @cindex Hangs in Gnus
5410 @cindex Gnus hangs while posting
5411 @cindex Posting, Gnus hangs wile
5413 @email{tale@@uunet.uu.net, David Lawrence} explains:
5415 @quotation
5416 The problem is almost always interaction between NNTP and C News.  NNTP
5417 POST asks C News's @code{inews} to not background itself but rather hang
5418 around and give its exit status so it knows whether the post was successful.
5419 (That wait will on some systems not return the exit status of the
5420 waited for job is a different sort of problem.)  It ends up taking a
5421 long time because @code{inews} is calling @code{relaynews}, which often
5422 waits for another @code{relaynews} to free the lock on the news system
5423 so it can file the article.
5425 My preferred solution is to change @code{inews} to not call
5426 @code{relaynews}, but rather use @code{newsspool}.  This loses some
5427 error-catching functionality, but is for the most part safe as
5428 @code{inews} will detect a lot of the errors on its own.  The C News
5429 folks have sped up @code{inews}, too, so speed should look better to
5430 most folks as that update propagates around.
5431 @end quotation
5433 @node Learning more about Gnus,  , Gnus hangs for a long time, Mail and news
5434 @section Where can I find out more about Gnus?
5435 @cindex FAQ for Gnus
5436 @cindex Gnus FAQ
5437 @cindex Learning more about Gnus
5439 For more information on Gnus, consult the Gnus manual and FAQ, which are
5440 part of the Gnus distribution.
5442 @node Concept index,  , Mail and news, Top
5443 @unnumbered Concept Index
5444 @printindex cp
5446 @contents
5447 @bye