root/branches/2.1/info/efaq-2

Revision 3212, 49.7 kB (checked in by miyoshi, 5 years ago)

Sync up with Emacs-21.3.

Line 
1 This is ../info/efaq, produced by makeinfo version 4.2 from faq.texi.
2
3 INFO-DIR-SECTION Emacs
4 START-INFO-DIR-ENTRY
5 * Emacs FAQ: (efaq).    Frequently Asked Questions about Emacs.
6 END-INFO-DIR-ENTRY
7
8    Copyright 1994,1995,1996,1997,1998,1999,2000 Reuven M. Lerner
9 Copyright 1992,1993 Steven Byrnes
10 Copyright 1990,1991,1992 Joseph Brian Wells
11 This list of frequently asked questions about GNU Emacs with answers
12 ("FAQ") may be translated into other languages, transformed into other
13 formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new
14 information.
15
16    The same conditions apply to any derivative of the FAQ as apply to
17 the FAQ itself.  Every copy of the FAQ must include this notice or an
18 approved translation, information on who is currently maintaining the
19 FAQ and how to contact them (including their e-mail address), and
20 information on where the latest version of the FAQ is archived
21 (including FTP information).
22
23    The FAQ may be copied and redistributed under these conditions,
24 except that the FAQ may not be embedded in a larger literary work
25 unless that work itself allows free copying and redistribution.
26
27    [This version has been somewhat edited from the last-posted version
28 (as of August 1999) for inclusion in the Emacs distribution.]
29
30 
31 File: efaq,  Node: Wrapping words automatically,  Next: Spell-checkers,  Prev: Controlling case sensitivity,  Up: Common requests
32
33 How do I make Emacs wrap words for me?
34 ======================================
35
36    Use `auto-fill-mode', activated by typing `M-x auto-fill-mode'.  The
37 default maximum line width is 70, determined by the variable
38 `fill-column'.  To learn how to turn this on automatically, see *Note
39 Turning on auto-fill by default::.
40
41 
42 File: efaq,  Node: Spell-checkers,  Next: Checking TeX and *roff documents,  Prev: Wrapping words automatically,  Up: Common requests
43
44 Where can I get a better spelling checker for Emacs?
45 ====================================================
46
47    Use Ispell.  *Note Ispell::.
48
49 
50 File: efaq,  Node: Checking TeX and *roff documents,  Next: Changing load-path,  Prev: Spell-checkers,  Up: Common requests
51
52 How can I spell-check TeX or *roff documents?
53 =============================================
54
55    Use Ispell.  Ispell can handle TeX and *roff documents.  *Note
56 Ispell::.
57
58 
59 File: efaq,  Node: Changing load-path,  Next: Using an already running Emacs process,  Prev: Checking TeX and *roff documents,  Up: Common requests
60
61 How do I change `load-path'?
62 ============================
63
64    In general, you should only add to the `load-path'.  You can add
65 directory /DIR/SUBDIR to the load path like this:
66
67      (setq load-path (cons "/dir/subdir/" load-path))
68
69    To do this relative to your home directory:
70
71      (setq load-path (cons "~/mysubdir/" load-path)
72
73 
74 File: efaq,  Node: Using an already running Emacs process,  Next: Compiler error messages,  Prev: Changing load-path,  Up: Common requests
75
76 How do I use an already running Emacs from another window?
77 ==========================================================
78
79    `emacsclient', which comes with Emacs, is for editing a file using
80 an already running Emacs rather than starting up a new Emacs.  It does
81 this by sending a request to the already running Emacs, which must be
82 expecting the request.
83
84    * Setup:
85
86      Emacs must have executed the `server-start' function for
87      `emacsclient' to work.  This can be done either by a command line
88      option:
89
90           emacs -f server-start
91
92      or by invoking `server-start' from `.emacs':
93
94           (if (SOME CONDITIONS ARE MET) (server-start))
95
96      When this is done, Emacs starts a subprocess running a program
97      called `emacsserver'.  `emacsserver' creates a Unix domain socket.
98      The socket is either named `.emacs_server', in the user's home
99      directory, or `esrv-USERID-SYSTEMNAME', in the `/tmp' directory,
100      depending on how `emacsserver' was compiled.
101
102      To get your news reader, mail reader, etc., to invoke
103      `emacsclient', try setting the environment variable `EDITOR' (or
104      sometimes `VISUAL') to the value `emacsclient'.  You may have to
105      specify the full pathname of the `emacsclient' program instead.
106      Examples:
107
108           # csh commands:
109           setenv EDITOR emacsclient
110          
111           # using full pathname
112           setenv EDITOR /usr/local/emacs/etc/emacsclient
113          
114           # sh command:
115           EDITOR=emacsclient ; export EDITOR
116
117    * Normal use:
118
119      When `emacsclient' is run, it connects to the `.emacs_server'
120      socket and passes its command line options to `server'.  When
121      `server' receives these requests, it sends this information to the
122      the Emacs process, which at the next opportunity will visit the
123      files specified.  (Line numbers can be specified just like with
124      Emacs.)  The user will have to switch to the Emacs window by hand.
125      When the user is done editing a file, the user can type `C-x #'
126      (or `M-x server-edit') to indicate this.  If there is another
127      buffer requested by `emacsclient', Emacs will switch to it;
128      otherwise `emacsclient' will exit, signaling the calling program
129      to continue.
130
131      `emacsclient' and `server' must be running on machines which share
132      the same filesystem for this to work.  The pathnames that
133      `emacsclient' specifies should be correct for the filesystem that
134      the Emacs process sees.  The Emacs process should not be suspended
135      at the time `emacsclient' is invoked.  On Unix and GNU/Linux
136      systems, `emacsclient' should either be invoked from another X
137      window, or from a shell window inside Emacs itself, or from
138      another interactive session, e.g., by means of a `screen' program.
139
140      There is an enhanced version of `emacsclient'/server called
141      `gnuserv', written by Andy Norman <ange@hplb.hpl.hp.com> which is
142      available in the Emacs Lisp Archive (*note Packages that do not
143      come with Emacs::).  `gnuserv' uses Internet domain sockets, so it
144      can work across most network connections.  It also supports the
145      execution of arbitrary Emacs Lisp forms and does not require the
146      client program to wait for completion.
147
148      The alpha version of an enhanced `gnuserv' is available at
149
150      `ftp://ftp.wellfleet.com/netman/psmith/emacs/gnuserv-2.1alpha.tar.gz'
151
152
153 
154 File: efaq,  Node: Compiler error messages,  Next: Indenting switch statements,  Prev: Using an already running Emacs process,  Up: Common requests
155
156 How do I make Emacs recognize my compiler's funny error messages?
157 =================================================================
158
159    The variable `compilation-error-regexp-alist' helps control how
160 Emacs parses your compiler output.  It is a list of triplets of the
161 form: `(REGEXP FILE-IDX LINE-IDX)', where REGEXP, FILE-IDX and LINE-IDX
162 are strings.  To help determine what the constituent elements should
163 be, load `compile.el' and then type `C-h v
164 compilation-error-regexp-alist <RET>' to see the current value.  A good
165 idea is to look at `compile.el' itself as the comments included for
166 this variable are quite useful--the regular expressions required for
167 your compiler's output may be very close to one already provided.  Once
168 you have determined the proper regexps, use the following to inform
169 Emacs of your changes:
170
171      (setq compilation-error-regexp-alist
172            (cons '(REGEXP FILE-IDX LINE-IDX)
173               compilation-error-regexp-alist))
174
175 
176 File: efaq,  Node: Indenting switch statements,  Next: Customizing C and C++ indentation,  Prev: Compiler error messages,  Up: Common requests
177
178 How do I change the indentation for `switch'?
179 =============================================
180
181    Many people want to indent their `switch' statements like this:
182
183      f()
184      {
185        switch(x) {
186          case A:
187            x1;
188            break;
189          case B:
190            x2;
191            break;
192          default:
193            x3;
194        }
195      }
196
197    The solution at first appears to be: set `c-indent-level' to 4 and
198 `c-label-offset' to -2.  However, this will give you an indentation
199 spacing of four instead of two.
200
201    The _real_ solution is to use `cc-mode' (the default mode for C
202 programming in Emacs 20 and later) and add the following line to yoyr
203 `.emacs':
204
205      (c-set-offset 'case-label '+)
206
207    There appears to be no way to do this with the old `c-mode'.
208
209 
210 File: efaq,  Node: Customizing C and C++ indentation,  Next: Horizontal scrolling,  Prev: Indenting switch statements,  Up: Common requests
211
212 How to customize indentation in C, C++, and Java buffers?
213 =========================================================
214
215    The Emacs `cc-mode' features an interactive procedure for
216 customizing the indentation style, which is fully explained in the `CC
217 Mode' manual that is part of the Emacs distribution, see *Note
218 Customization Indentation: (ccmode)Customizing Indentation.  Here's a
219 short summary of the procedure:
220
221   1. Go to the beginning of the first line where you don't like the
222      indentation and type `C-c C-o'.  Emacs will prompt you for the
223      syntactic symbol; type <RET> to accept the default it suggests.
224
225   2. Emacs now prompts for the offset of this syntactic symbol, showing
226      the default (the current definition) inside parentheses.  You can
227      choose one of these:
228
229     `0'
230           No extra indentation.
231
232     `+'
233           Indent one basic offset.
234
235     `-'
236           Outdent one basic offset.
237
238     `++'
239           Indent two basic offsets
240
241     `--'
242           Outdent two basic offsets.
243
244     `*'
245           Indent half basic offset.
246
247     `/'
248           Outdent half basic offset.
249
250   3. After choosing one of these symbols, type `C-c C-q' to reindent
251      the line or the block according to what you just specified.
252
253   4. If you don't like the result, go back to step 1.  Otherwise, add
254      the following line to your `.emacs':
255
256           (c-set-offset 'SYNTACTIC-SYMBOL OFFSET)
257
258      where SYNTACTIC-SYMBOL is the name Emacs shows in the minibuffer
259      when you type `C-c C-o' at the beginning of the line, and OFFSET
260      is one of the indentation symbols listed above (`+', `/', `0',
261      etc.) that you've chosen during the interactive procedure.
262
263   5. Go to the next line whose indentation is not to your liking and
264      repeat the process there.
265
266    It is recommended to put all the resulting `(c-set-offset ...)'
267 customizations inside a C mode hook, like this:
268
269      (defun my-c-mode-hook ()
270        (c-set-offset ...)
271        (c-set-offset ...))
272      (add-hook 'c-mode-hook 'my-c-mode-hook)
273
274 Using `c-mode-hook' avoids the need to put a `(require 'cc-mode)' into
275 your `.emacs' file, because `c-set-offset' might be unavailable when
276 `cc-mode' is not loaded.
277
278    Note that `c-mode-hook' runs for C source files only; use
279 `c++-mode-hook' for C++ sources, `java-mode-hook' for Java sources,
280 etc.  If you want the same customizations to be in effect in _all_
281 languages supported by `cc-mode', use `c-mode-common-hook'.
282
283 
284 File: efaq,  Node: Horizontal scrolling,  Next: Overwrite mode,  Prev: Customizing C and C++ indentation,  Up: Common requests
285
286 How can I make Emacs automatically scroll horizontally?
287 =======================================================
288
289    In Emacs 21 and later, this is on by default: if the variable
290 `truncate-lines' is non-`nil' in the current buffer, Emacs
291 automatically scrolls the display horizontally when point moves off the
292 left or right edge of the window.
293
294    In Emacs 20, use the `hscroll-mode'.  Here is some information from
295 the documentation, available by typing `C-h f hscroll-mode <RET>':
296
297    Automatically scroll horizontally when the point moves off the left
298 or right edge of the window.
299
300    - Type `M-x hscroll-mode' to enable it in the current buffer.
301
302    - Type `M-x hscroll-global-mode' to enable it in every buffer.
303
304    - `turn-on-hscroll' is useful in mode hooks as in:
305
306           (add-hook 'text-mode-hook 'turn-on-hscroll)
307
308    - `hscroll-margin' controls how close the cursor can get to the edge
309      of the window.
310
311    - `hscroll-step-percent' controls how far to jump once we decide to
312      do so.
313
314 
315 File: efaq,  Node: Overwrite mode,  Next: Turning off beeping,  Prev: Horizontal scrolling,  Up: Common requests
316
317 How do I make Emacs "typeover" or "overwrite" instead of inserting?
318 ===================================================================
319
320    `M-x overwrite-mode' (a minor mode).  This toggles `overwrite-mode'
321 on and off, so exiting from `overwrite-mode' is as easy as another `M-x
322 overwrite-mode'.
323
324    On some systems, <Insert> toggles `overwrite-mode' on and off.
325
326 
327 File: efaq,  Node: Turning off beeping,  Next: Turning the volume down,  Prev: Overwrite mode,  Up: Common requests
328
329 How do I stop Emacs from beeping on a terminal?
330 ===============================================
331
332    Martin R. Frank <martin@cc.gatech.edu> writes:
333
334    Tell Emacs to use the "visible bell" instead of the audible bell,
335 and set the visible bell to nothing.
336
337    That is, put the following in your `TERMCAP' environment variable
338 (assuming you have one):
339
340      ... :vb=: ...
341
342    And evaluate the following Lisp form:
343
344      (setq visible-bell t)
345
346 
347 File: efaq,  Node: Turning the volume down,  Next: Automatic indentation,  Prev: Turning off beeping,  Up: Common requests
348
349 How do I turn down the bell volume in Emacs running under X?
350 ============================================================
351
352    On X Window system, you can adjust the bell volume and duration for
353 all programs with the shell command `xset'.
354
355    Invoking `xset' without any arguments produces some basic
356 information, including the following:
357
358      usage:  xset [-display host:dpy] option ...
359        To turn bell off:
360            -b                b off               b 0
361        To set bell volume, pitch and duration:
362             b [vol [pitch [dur]]]          b on
363
364 
365 File: efaq,  Node: Automatic indentation,  Next: Matching parentheses,  Prev: Turning the volume down,  Up: Common requests
366
367 How do I tell Emacs to automatically indent a new line to the indentation of the previous line?
368 ===============================================================================================
369
370    Such behavior is automatic in Emacs 20 and later.  From the
371 `etc/NEWS' file for Emacs 20.2:
372
373      ** In Text mode, now only blank lines separate paragraphs.  This makes
374      it possible to get the full benefit of Adaptive Fill mode in Text mode,
375      and other modes derived from it (such as Mail mode).  <TAB> in Text
376      mode now runs the command `indent-relative'; this makes a practical
377      difference only when you use indented paragraphs.
378      
379      As a result, the old Indented Text mode is now identical to Text mode,
380      and is an alias for it.
381      
382      If you want spaces at the beginning of a line to start a paragraph, use
383      the new mode, Paragraph Indent Text mode.
384
385    If you have `auto-fill-mode' turned on (*note Turning on auto-fill
386 by default::), you can tell Emacs to prefix every line with a certain
387 character sequence, the "fill prefix".  Type the prefix at the
388 beginning of a line, position point after it, and then type `C-x .'
389 (`set-fill-prefix') to set the fill prefix.  Thereafter, auto-filling
390 will automatically put the fill prefix at the beginning of new lines,
391 and `M-q' (`fill-paragraph') will maintain any fill prefix when
392 refilling the paragraph.
393
394    If you have paragraphs with different levels of indentation, you will
395 have to set the fill prefix to the correct value each time you move to a
396 new paragraph.  To avoid this hassle, try one of the many packages
397 available from the Emacs Lisp Archive (*note Packages that do not come
398 with Emacs::.)  Look up "fill" and "indent" in the Lisp Code Directory
399 for guidance.
400
401 
402 File: efaq,  Node: Matching parentheses,  Next: Hiding #ifdef lines,  Prev: Automatic indentation,  Up: Common requests
403
404 How do I show which parenthesis matches the one I'm looking at?
405 ===============================================================
406
407    As of version 19, Emacs comes with `paren.el', which (when loaded)
408 will automatically highlight matching parentheses whenever point (i.e.,
409 the cursor) is located over one.  To load `paren.el' automatically,
410 include the line
411
412      (require 'paren)
413
414    in your `.emacs' file.  Alan Shutko <shutkoa@ugsolutions.com>
415 reports that as of version 20.1, you must also call `show-paren-mode' in
416 your `.emacs' file:
417
418      (show-paren-mode 1)
419
420    Customize will let you turn on `show-paren-mode'.  Use `M-x
421 customize-group <RET> paren-showing <RET>'.  From within Customize, you
422 can also go directly to the "paren-showing" group.
423
424    Alternatives to paren include:
425
426    * If you're looking at a right parenthesis (or brace or bracket) you
427      can delete it and reinsert it.  Emacs will momentarily move the
428      cursor to the matching parenthesis.
429
430    * `M-C-f' (`forward-sexp') and `M-C-b' (`backward-sexp') will skip
431      over one set of balanced parentheses, so you can see which
432      parentheses match.  (You can train it to skip over balanced
433      brackets and braces at the same time by modifying the syntax
434      table.)
435
436    * Here is some Emacs Lisp that will make the <%> key show the
437      matching parenthesis, like in `vi'.  In addition, if the cursor
438      isn't over a parenthesis, it simply inserts a % like normal.
439
440           ;; By an unknown contributor
441          
442           (global-set-key "%" 'match-paren)
443          
444           (defun match-paren (arg)
445             "Go to the matching paren if on a paren; otherwise insert %."
446             (interactive "p")
447             (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
448                   ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
449                   (t (self-insert-command (or arg 1)))))
450
451
452 
453 File: efaq,  Node: Hiding #ifdef lines,  Next: Repeating commands,  Prev: Matching parentheses,  Up: Common requests
454
455 In C mode, can I show just the lines that will be left after `#ifdef' commands are handled by the compiler?
456 ===========================================================================================================
457
458    `M-x hide-ifdef-mode'.  (This is a minor mode.)  You might also want
459 to try `cpp.el', available at the Emacs Lisp Archive (*note Packages
460 that do not come with Emacs::).
461
462 
463 File: efaq,  Node: Repeating commands,  Next: Valid X resources,  Prev: Hiding #ifdef lines,  Up: Common requests
464
465 Is there an equivalent to the `.' (dot) command of vi?
466 ======================================================
467
468    (`.' is the redo command in `vi'.  It redoes the last
469 insertion/deletion.)
470
471    As of Emacs 20.3, there is indeed a `repeat' command (`C-x z') that
472 repeats the last command.  If you preface it with a prefix argument,
473 the prefix arg is applied to the command.
474
475    You can also type `C-x <ESC> <ESC>' (`repeat-complex-command') to
476 reinvoke commands that used the minibuffer to get arguments.  In
477 `repeat-complex-command' you can type `M-p' and `M-n' (and also
478 up-arrow and down-arrow, if your keyboard has these keys) to scan
479 through all the different complex commands you've typed.
480
481    To repeat a set of commands, use keyboard macros.  (*note Keyboard
482 Macros: (emacs)Keyboard Macros.)
483
484    If you're really desperate for the `.' command, use VIPER, a `vi'
485 emulation mode which comes with Emacs, and which appears to support it.
486 (*Note VIPER::.)
487
488 
489 File: efaq,  Node: Valid X resources,  Next: Evaluating Emacs Lisp code,  Prev: Repeating commands,  Up: Common requests
490
491 What are the valid X resource settings (i.e., stuff in .Xdefaults)?
492 ===================================================================
493
494    *note Resources X: (emacs)Resources X.
495
496    You can also use a resource editor, such as editres (for X11R5 and
497 onwards), to look at the resource names for the menu bar, assuming Emacs
498 was compiled with the X toolkit.
499
500 
501 File: efaq,  Node: Evaluating Emacs Lisp code,  Next: Changing the length of a Tab,  Prev: Valid X resources,  Up: Common requests
502
503 How do I execute ("evaluate") a piece of Emacs Lisp code?
504 =========================================================
505
506    There are a number of ways to execute ("evaluate", in Lisp lingo) an
507 Emacs Lisp "form":
508
509    * If you want it evaluated every time you run Emacs, put it in a file
510      named `.emacs' in your home directory.  This is known as "your
511      `.emacs' file," and contains all of your personal customizations.
512
513    * You can type the form in the `*scratch*' buffer, and then type
514      <LFD> (or `C-j') after it.  The result of evaluating the form will
515      be inserted in the buffer.
516
517    * In `emacs-lisp-mode', typing `M-C-x' evaluates a top-level form
518      before or around point.
519
520    * Typing `C-x C-e' in any buffer evaluates the Lisp form immediately
521      before point and prints its value in the echo area.
522
523    * Typing `M-:' or `M-x eval-expression' allows you to type a Lisp
524      form in the minibuffer which will be evaluated once you press
525      <RET>.
526
527    * You can use `M-x load-file' to have Emacs evaluate all the Lisp
528      forms in a file.  (To do this from Lisp use the function `load'
529      instead.)
530
531      The functions `load-library', `eval-region',
532      `eval-current-buffer', `require', and `autoload' are also useful;
533      see *Note Emacs Lisp documentation::, if you want to learn more
534      about them.
535
536
537 
538 File: efaq,  Node: Changing the length of a Tab,  Next: Inserting > at the beginning of each line,  Prev: Evaluating Emacs Lisp code,  Up: Common requests
539
540 How do I change Emacs's idea of the <TAB> character's length?
541 =============================================================
542
543    Set the variable `default-tab-width'.  For example, to set <TAB>
544 stops every 10 characters, insert the following in your `.emacs' file:
545
546      (setq default-tab-width 10)
547
548    Do not confuse variable `tab-width' with variable `tab-stop-list'.
549 The former is used for the display of literal <TAB> characters.  The
550 latter controls what characters are inserted when you press the <TAB>
551 character in certain modes.
552
553 
554 File: efaq,  Node: Inserting > at the beginning of each line,  Next: Underlining paragraphs,  Prev: Changing the length of a Tab,  Up: Common requests
555
556 How do I insert `>' at the beginning of every line?
557 ===================================================
558
559    To do this to an entire buffer, type `M-< M-x replace-regexp <RET> ^
560 <RET> > <RET>'.
561
562    To do this to a region, use `string-insert-rectangle'.  Set the mark
563 (`C-<SPC>') at the beginning of the first line you want to prefix, move
564 the cursor to last line to be prefixed, and type `M-x
565 string-insert-rectangle <RET>'.  To do this for the whole buffer, type
566 `C-x h M-x string-insert-rectangle <RET>'.
567
568    If you are trying to prefix a yanked mail message with `>', you
569 might want to set the variable `mail-yank-prefix'.  Better yet, use the
570 Supercite package (*note Supercite::), which provides flexible citation
571 for yanked mail and news messages; it is included in Emacs since
572 version 19.20.  *Note Changing the included text prefix::, for
573 additional information.
574
575 
576 File: efaq,  Node: Underlining paragraphs,  Next: Repeating a command as many times as possible,  Prev: Inserting > at the beginning of each line,  Up: Common requests
577
578 How do I insert "_^H" before each character in a region to get an underlined paragraph?
579 =======================================================================================
580
581    Mark the region and then type `M-x underline-region <RET>'.
582
583 
584 File: efaq,  Node: Repeating a command as many times as possible,  Next: Forcing the cursor to remain in the same column,  Prev: Underlining paragraphs,  Up: Common requests
585
586 How do I repeat a command as many times as possible?
587 ====================================================
588
589    Use `C-x (' and `C-x )' to make a keyboard macro that invokes the
590 command and then type `M-0 C-x e'.
591
592    Any messages your command prints in the echo area will be suppressed.
593
594    If you need to repeat a command a small number of times, you can use
595 `C-x z', see *Note Repeating commands::.
596
597 
598 File: efaq,  Node: Forcing the cursor to remain in the same column,  Next: Forcing Emacs to iconify itself,  Prev: Repeating a command as many times as possible,  Up: Common requests
599
600 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?
601 ====================================================================================================================================
602
603    `M-x picture-mode'.
604
605 
606 File: efaq,  Node: Forcing Emacs to iconify itself,  Next: Using regular expressions,  Prev: Forcing the cursor to remain in the same column,  Up: Common requests
607
608 How do I tell Emacs to iconify itself?
609 ======================================
610
611    `C-z' iconifies Emacs when running under X and suspends Emacs
612 otherwise.  *note Misc X: (emacs)Misc X.
613
614 
615 File: efaq,  Node: Using regular expressions,  Next: Replacing text across multiple files,  Prev: Forcing Emacs to iconify itself,  Up: Common requests
616
617 How do I use regexps (regular expressions) in Emacs?
618 ====================================================
619
620    *note Regexps: (emacs)Regexps.
621
622    The `or' operator is `\|', not `|', and the grouping operators are
623 `\(' and `\)'.  Also, the string syntax for a backslash is `\\'.  To
624 specify a regular expression like `xxx\(foo\|bar\)' in a Lisp string,
625 use `xxx\\(foo\\|bar\\)'.
626
627    Note the doubled backslashes!
628
629    * Unlike in Unix `grep', `sed', etc., a complement character set
630      (`[^...]')  can match a newline character (<LFD> a.k.a.  `C-j'
631      a.k.a. `\n'), unless newline is mentioned as one of the characters
632      not to match.
633
634    * The character syntax regexps (e.g., `\sw') are not meaningful
635      inside character set regexps (e.g., `[aeiou]').  (This is actually
636      typical for regexp syntax.)
637
638
639 
640 File: efaq,  Node: Replacing text across multiple files,  Next: Documentation for etags,  Prev: Using regular expressions,  Up: Common requests
641
642 How do I perform a replace operation across more than one file?
643 ===============================================================
644
645    The "tags" feature of Emacs includes the command
646 `tags-query-replace' which performs a query-replace across all the
647 files mentioned in the `TAGS' file.  *note Tags Search: (emacs)Tags
648 Search.
649
650    As of Emacs 19.29, Dired mode (`M-x dired <RET>', or `C-x d')
651 supports the command `dired-do-query-replace', which allows users to
652 replace regular expressions in multiple files.
653
654 
655 File: efaq,  Node: Documentation for etags,  Next: Disabling backups,  Prev: Replacing text across multiple files,  Up: Common requests
656
657 Where is the documentation for `etags'?
658 =======================================
659
660    The `etags' man page should be in the same place as the `emacs' man
661 page.
662
663    Quick command-line switch descriptions are also available.  For
664 example, `etags -H'.
665
666 
667 File: efaq,  Node: Disabling backups,  Next: Disabling auto-save-mode,  Prev: Documentation for etags,  Up: Common requests
668
669 How do I disable backup files?
670 ==============================
671
672    You probably don't want to do this, since backups are useful,
673 especially when something goes wrong.
674
675    To avoid seeing backup files (and other "uninteresting" files) in
676 Dired, load `dired-x' by adding the following to your `.emacs' file:
677
678      (add-hook 'dired-load-hook
679                (lambda ()
680                 (load "dired-x")))
681
682    With `dired-x' loaded, `M-o' toggles omitting in each dired buffer.
683 You can make omitting the default for new dired buffers by putting the
684 following in your `.emacs':
685
686      (add-hook 'dired-mode-hook 'dired-omit-toggle)
687
688    If you're tired of seeing backup files whenever you do an `ls' at
689 the Unix shell, try GNU `ls' with the `-B' option.  GNU `ls' is part of
690 the GNU Fileutils package, available from `ftp.gnu.org' and its mirrors
691 (*note Current GNU distributions::).
692
693    To disable or change the way backups are made, *note (emacs)Backup
694 Names::.
695
696    Beginning with Emacs 21.1, you can control where Emacs puts backup
697 files by customizing the variable `backup-directory-alist'.  This
698 variable's value specifies that files whose names match specific patters
699 should have their backups put in certain directories.  A typical use is
700 to add the element `("." . DIR)' to force Emacs to put *all* backup
701 files in the directory `dir'.
702
703 
704 File: efaq,  Node: Disabling auto-save-mode,  Next: Going to a line by number,  Prev: Disabling backups,  Up: Common requests
705
706 How do I disable `auto-save-mode'?
707 ==================================
708
709    You probably don't want to do this, since auto-saving is useful,
710 especially when Emacs or your computer crashes while you are editing a
711 document.
712
713    Instead, you might want to change the variable `auto-save-interval',
714 which specifies how many keystrokes Emacs waits before auto-saving.
715 Increasing this value forces Emacs to wait longer between auto-saves,
716 which might annoy you less.
717
718    You might also want to look into Sebastian Kremer's `auto-save'
719 package, available from the Lisp Code Archive (*note Packages that do
720 not come with Emacs::).  This package also allows you to place all
721 auto-save files in one directory, such as `/tmp'.
722
723    To disable or change how `auto-save-mode' works, *note (emacs)Auto
724 Save::.
725
726 
727 File: efaq,  Node: Going to a line by number,  Next: Modifying pull-down menus,  Prev: Disabling auto-save-mode,  Up: Common requests
728
729 How can I go to a certain line given its number?
730 ================================================
731
732    Are you sure you indeed need to go to a line by its number?  Perhaps
733 all you want is to display a line in your source file for which a
734 compiler printed an error message?  If so, compiling from within Emacs
735 using the `M-x compile' and `M-x recompile' commands is a much more
736 effective way of doing that.  Emacs automatically intercepts the compile
737 error messages, inserts them into a special buffer called
738 `*compilation*', and lets you visit the locus of each message in the
739 source.  Type `C-x `' to step through the offending lines one by one.
740 Click `Mouse-2' or press <RET> on a message text in the `*compilation*'
741 buffer to go to the line whose number is mentioned in that message.
742
743    But if you indeed need to go to a certain text line, type `M-x
744 goto-line <RET>'.  Emacs will prompt you for the number of the line and
745 go to that line.
746
747    You can do this faster by invoking `goto-line' with a numeric
748 argument that is the line's number.  For example, `C-u 286 M-x
749 goto-line <RET>' will jump to line number 286 in the current buffer.
750
751    If you need to use this command frequently, you might consider
752 binding it to a key.  The following snippet, if added to your `~/.emacs'
753 file, will bind the sequence `C-x g' to `goto-line':
754
755       (global-set-key "\C-xg" 'goto-line)
756
757 
758 File: efaq,  Node: Modifying pull-down menus,  Next: Deleting menus and menu options,  Prev: Going to a line by number,  Up: Common requests
759
760 How can I create or modify new pull-down menu options?
761 ======================================================
762
763    Each menu title (e.g., `File', `Edit', `Buffers') represents a local
764 or global keymap.  Selecting a menu title with the mouse displays that
765 keymap's non-nil contents in the form of a menu.
766
767    So to add a menu option to an existing menu, all you have to do is
768 add a new definition to the appropriate keymap.  Adding a `Forward Word'
769 item to the `Edit' menu thus requires the following Lisp code:
770
771      (define-key global-map
772        [menu-bar edit forward]
773        '("Forward word" . forward-word))
774
775 The first line adds the entry to the global keymap, which includes
776 global menu bar entries.  Replacing the reference to `global-map' with
777 a local keymap would add this menu option only within a particular mode.
778
779    The second line describes the path from the menu-bar to the new
780 entry.  Placing this menu entry underneath the `File' menu would mean
781 changing the word `edit' in the second line to `file'.
782
783    The third line is a cons cell whose first element is the title that
784 will be displayed, and whose second element is the function that will be
785 called when that menu option is invoked.
786
787    To add a new menu, rather than a new option to an existing menu, we
788 must define an entirely new keymap:
789
790      (define-key global-map [menu-bar words]
791        (cons "Words" (make-sparse-keymap "Words")))
792
793    The above code creates a new sparse keymap, gives it the name
794 `Words', and attaches it to the global menu bar.  Adding the `Forward
795 Word' item to this new menu would thus require the following code:
796
797      (define-key global-map
798        [menu-bar words forward]
799        '("Forward word" . forward-word))
800
801 Note that because of the way keymaps work, menu options are displayed
802 with the more recently defined items at the top.  Thus if you were to
803 define menu options `foo', `bar', and `baz' (in that order), the menu
804 option `baz' would appear at the top, and `foo' would be at the bottom.
805
806    One way to avoid this problem is to use the function
807 `define-key-after', which works the same as `define-key', but lets you
808 modify where items appear.  The following Lisp code would insert the
809 `Forward Word' item in the `Edit' menu immediately following the `Undo'
810 item:
811
812      (define-key-after
813        (lookup-key global-map [menu-bar edit])
814        [forward]
815        '("Forward word" . forward-word)
816        'undo)
817
818    Note how the second and third arguments to `define-key-after' are
819 different from those of `define-key', and that we have added a new
820 (final) argument, the function after which our new key should be
821 defined.
822
823    To move a menu option from one position to another, simply evaluate
824 `define-key-after' with the appropriate final argument.
825
826    More detailed information--and more examples of how to create and
827 modify menu options--are in the `Emacs Lisp Reference Manual', under
828 "Menu Keymaps".  (*Note Emacs Lisp documentation::, for information on
829 this manual.)
830
831 
832 File: efaq,  Node: Deleting menus and menu options,  Next: Turning on syntax highlighting,  Prev: Modifying pull-down menus,  Up: Common requests
833
834 How do I delete menus and menu options?
835 =======================================
836
837    The simplest way to remove a menu is to set its keymap to `nil'.
838 For example, to delete the `Words' menu (*note Modifying pull-down
839 menus::), use:
840
841      (define-key global-map [menu-bar words] nil)
842
843    Similarly, removing a menu option requires redefining a keymap entry
844 to `nil'.  For example, to delete the `Forward word' menu option from
845 the `Edit' menu (we added it in *Note Modifying pull-down menus::), use:
846
847      (define-key global-map [menu-bar edit forward] nil)
848
849 
850 File: efaq,  Node: Turning on syntax highlighting,  Next: Scrolling only one line,  Prev: Deleting menus and menu options,  Up: Common requests
851
852 How do I turn on syntax highlighting?
853 =====================================
854
855    `font-lock-mode' is the standard way to have Emacs perform syntax
856 highlighting in the current buffer.  With `font-lock-mode' turned on,
857 different types of text will appear in different colors.  For instance,
858 if you turn on `font-lock-mode' in a programming mode, variables will
859 appear in one face, keywords in a second, and comments in a third.
860
861    Earlier versions of Emacs supported hilit19, a similar package.  Use
862 of hilit19 is now considered non-standard, although `hilit19.el' comes
863 with the stock Emacs distribution.  It is no longer maintained.
864
865    To turn `font-lock-mode' on within an existing buffer, use `M-x
866 font-lock-mode <RET>'.
867
868    To automatically invoke `font-lock-mode' when a particular major
869 mode is invoked, set the major mode's hook.  For example, to fontify all
870 `c-mode' buffers, add the following to your `.emacs' file:
871
872      (add-hook 'c-mode-hook 'turn-on-font-lock)
873
874    To automatically invoke `font-lock-mode' for all major modes, you
875 can turn on `global-font-lock-mode' by including the following line in
876 your `.emacs' file:
877
878      (global-font-lock-mode 1)
879
880 This instructs Emacs to turn on font-lock mode in those buffers for
881 which a font-lock mode definition has been provided (in the variable
882 `font-lock-global-modes').  If you edit a file in `pie-ala-mode', and
883 no font-lock definitions have been provided for `pie-ala' files, then
884 the above setting will have no effect on that particular buffer.
885
886    Highlighting a buffer with `font-lock-mode' can take quite a while,
887 and cause an annoying delay in display, so several features exist to
888 work around this.
889
890    In Emacs 21 and later, turning on `font-lock-mode' automatically
891 activates the new "Just-In-Time fontification" provided by
892 `jit-lock-mode'.  `jit-lock-mode' defers the fontification of portions
893 of buffer until you actually need to see them, and can also fontify
894 while Emacs is idle.  This makes display of the visible portion of a
895 buffer almost instantaneous.  For details about customizing
896 `jit-lock-mode', type `C-h f jit-lock-mode <RET>'.
897
898    In versions of Emacs before 21, different levels of decoration are
899 available, from slight to gaudy.  More decoration means you need to wait
900 more time for a buffer to be fontified (or a faster machine).  To
901 control how decorated your buffers should become, set the value of
902 `font-lock-maximum-decoration' in your `.emacs' file, with a `nil'
903 value indicating default (usually minimum) decoration, and a `t' value
904 indicating the maximum decoration.  For the gaudiest possible look,
905 then, include the line
906
907      (setq font-lock-maximum-decoration t)
908
909 in your `.emacs' file.  You can also set this variable such that
910 different modes are highlighted in a different ways; for more
911 information, see the documentation for `font-lock-maximum-decoration'
912 with `C-h v' (or `M-x describe-variable <RET>').
913
914    You might also want to investigate `fast-lock-mode' and
915 `lazy-lock-mode', versions of `font-lock-mode' that speed up
916 highlighting.  These are the alternatives for `jit-lock-mode' in
917 versions of Emacs before 21.1.  The advantage of `lazy-lock-mode' is
918 that it only fontifies buffers when certain conditions are met, such as
919 after a certain amount of idle time, or after you have finished
920 scrolling through text.  See the documentation for `lazy-lock-mode' by
921 typing `C-h f `lazy-lock-mode'' (`M-x describe-function <RET>
922 lazy-lock-mode <RET>').
923
924    Also see the documentation for the function `font-lock-mode',
925 available by typing `C-h f font-lock-mode' (`M-x describe-function
926 <RET> font-lock-mode <RET>').
927
928    For more information on font-lock mode, take a look at the
929 `font-lock-mode' FAQ, maintained by Jari Aalto
930 <jari.aalto@ntc.nokia.com> at
931
932    `ftp://cs.uta.fi/pub/ssjaaa/ema-font.gui'
933
934    To print buffers with the faces (i.e., colors and fonts) intact, use
935 `M-x ps-print-buffer-with-faces' or `M-x ps-print-region-with-faces'.
936 You will need a way to send text to a PostScript printer, or a
937 PostScript interpreter such as Ghostscript; consult the documentation
938 of the variables `ps-printer-name', `ps-lpr-command', and
939 `ps-lpr-switches' for more details.
940
941 
942 File: efaq,  Node: Scrolling only one line,  Next: Replacing highlighted text,  Prev: Turning on syntax highlighting,  Up: Common requests
943
944 How can I force Emacs to scroll only one line when I move past the bottom of the screen?
945 ========================================================================================
946
947    Place the following Lisp form in your `.emacs' file:
948
949      (setq scroll-step 1)
950
951    *note Scrolling: (emacs)Scrolling.
952
953 
954 File: efaq,  Node: Replacing highlighted text,  Next: Editing MS-DOS files,  Prev: Scrolling only one line,  Up: Common requests
955
956 How can I replace highlighted text with what I type?
957 ====================================================
958
959    Use `delete-selection-mode', which you can start automatically by
960 placing the following Lisp form in your `.emacs' file:
961
962      (delete-selection-mode t)
963
964    According to the documentation string for `delete-selection-mode'
965 (which you can read using `M-x describe-function <RET>
966 delete-selection-mode <RET>'):
967
968      When ON, typed text replaces the selection if the selection is
969      active.  When OFF, typed text is just inserted at point.
970
971    This mode also allows you to delete (not kill) the highlighted
972 region by pressing <DEL>.
973
974 
975 File: efaq,  Node: Editing MS-DOS files,  Next: Filling paragraphs with a single space,  Prev: Replacing highlighted text,  Up: Common requests
976
977 How can I edit MS-DOS files using Emacs?
978 ========================================
979
980    As of Emacs 20, detection and handling of MS-DOS (and Windows) files
981 is performed transparently.  You can open MS-DOS files on a Unix system,
982 edit it, and save it without having to worry about the file format.
983
984    When editing an MS-DOS style file, the mode line will indicate that
985 it is a DOS file.  On Unix and GNU/Linux systems, and also on a
986 Macintosh, the string `(DOS)' will appear near the left edge of the
987 mode line; on DOS and Windows, where the DOS end-of-line (EOL) format
988 is the default, a backslash (`\') will appear in the mode line.
989
990    If you are running a version of Emacs before 20.1, get `crypt++'
991 from the Emacs Lisp Archive (*note Packages that do not come with
992 Emacs::).  Among other things, `crypt++' transparently modifies MS-DOS
993 files as they are loaded and saved, allowing you to ignore the
994 different conventions that Unix and MS-DOS have for delineating the end
995 of a line.
996
997 
998 File: efaq,  Node: Filling paragraphs with a single space,  Next: Escape sequences in shell output,  Prev: Editing MS-DOS files,  Up: Common requests
999
1000 How can I tell Emacs to fill paragraphs with a single space after each period?
1001 ==============================================================================
1002
1003    Ulrich Mueller <ulm@vsnhd1.cern.ch> suggests adding the following
1004 two lines to your `.emacs' file:
1005
1006      (setq sentence-end "[.?!][]\"')}]*\\($\\|[ \t]\\)[ \t\n]*")
1007      (setq sentence-end-double-space nil)
1008
1009 
1010 File: efaq,  Node: Escape sequences in shell output,  Prev: Filling paragraphs with a single space,  Up: Common requests
1011
1012 Why do I get these strange escape sequences when I run
1013 ======================================================
1014
1015    `ls' from the Shell mode?
1016
1017    This happens because `ls' is aliased to `ls --color' in your shell
1018 init file.  You have two alternatives to solve this:
1019
1020    * Make the alias conditioned on the `EMACS' variable in the
1021      environment.  When Emacs runs a subsidiary shell, it exports the
1022      `EMACS' variable with the value `t' to that shell.  You can
1023      unalias `ls' when that happens, thus limiting the alias to your
1024      interactive sessions.
1025
1026    * Install the `ansi-color' package (bundled with Emacs 21.1 and
1027      later), which converts these ANSI escape sequences into colors.
1028
1029 
1030 File: efaq,  Node: Bugs and problems,  Next: Compiling and installing Emacs,  Prev: Common requests,  Up: Top
1031
1032 Bugs and problems
1033 *****************
1034
1035    The Emacs manual lists some common kinds of trouble users could get
1036 into, see *Note Dealing with Emacs Trouble: (emacs)Lossage, so you
1037 might look there if the problem you encounter isn't described in this
1038 chapter.  If you decide you've discovered a bug, see *Note Reporting
1039 Bugs: (emacs)Bugs, for instructions how to do that.
1040
1041    The file `etc/PROBLEMS' in the Emacs distribution lists various
1042 known problems with building and using Emacs on specific platforms;
1043 type `C-h P' to read it.
1044
1045 * Menu:
1046
1047 * Problems with very large files::
1048 * ^M in the shell buffer::
1049 * Shell process exits abnormally::
1050 * Problems with Shell Mode on MS-Windows::
1051 * Termcap/Terminfo entries for Emacs::
1052 * Spontaneous entry into isearch-mode::
1053 * Problems talking to certain hosts::
1054 * Errors with init files::
1055 * Emacs ignores X resources::
1056 * Emacs ignores frame parameters::
1057 * Emacs takes a long time to visit files::
1058 * Editing files with $ in the name::
1059 * Shell mode loses the current directory::
1060 * Security risks with Emacs::
1061 * Dired claims that no file is on this line::
1062
1063 
1064 File: efaq,  Node: Problems with very large files,  Next: ^M in the shell buffer,  Prev: Bugs and problems,  Up: Bugs and problems
1065
1066 Does Emacs have problems with files larger than 8 megabytes?
1067 ============================================================
1068
1069    Old versions (i.e., anything before 19.29) of Emacs had problems
1070 editing files larger than 8 megabytes.  As of version 19.29, the
1071 maximum buffer size is at least 2^27-1, or 134,217,727 bytes, or 132
1072 MBytes.  Emacs 20 can be compiled on some 64-bit systems in a way that
1073 enlarges the buffer size up to 576,460,752,303,423,487 bytes, or
1074 549,755,813 GBytes.
1075
1076    If you are using a version of Emacs older than 19.29 and cannot
1077 upgrade, you will have to recompile. Leonard N. Zubkoff <lnz@lucid.com>
1078 suggests putting the following two lines in `src/config.h' before
1079 compiling Emacs to allow for 26-bit integers and pointers (and thus file
1080 sizes of up to 33,554,431 bytes):
1081
1082      #define VALBITS 26
1083      #define GCTYPEBITS 5
1084
1085 This method may result in "ILLEGAL DATATYPE" and other random errors on
1086 some machines.
1087
1088    David Gillespie <daveg@csvax.cs.caltech.edu> explains how this
1089 problems crops up; while his numbers are true only for pre-19.29
1090 versions of Emacs, the theory remains the same with current versions.
1091
1092      Emacs is largely written in a dialect of Lisp; Lisp is a
1093      freely-typed language in the sense that you can put any value of
1094      any type into any variable, or return it from a function, and so
1095      on.  So each value must carry a "tag" along with it identifying
1096      what kind of thing it is, e.g., integer, pointer to a list,
1097      pointer to an editing buffer, and so on.  Emacs uses standard
1098      32-bit integers for data objects, taking the top 8 bits for the
1099      tag and the bottom 24 bits for the value.  So integers (and
1100      pointers) are somewhat restricted compared to true C integers and
1101      pointers.
1102
1103 
1104 File: efaq,  Node: ^M in the shell buffer,  Next: Shell process exits abnormally,  Prev: Problems with very large files,  Up: Bugs and problems
1105
1106 How do I get rid of `^M' or echoed commands in my shell buffer?
1107 ===============================================================
1108
1109    Try typing `M-x shell-strip-ctrl-m <RET>' while in `shell-mode' to
1110 make them go away.  If that doesn't work, you have several options:
1111
1112    For `tcsh', put this in your `.cshrc' (or `.tcshrc') file:
1113
1114      if ($?EMACS) then
1115          if ("$EMACS" == t) then
1116              if ($?tcsh) unset edit
1117              stty nl
1118          endif
1119      endif
1120
1121    Or put this in your `.emacs_tcsh' file:
1122
1123      unset edit
1124      stty nl
1125
1126    Alternatively, use `csh' in your shell buffers instead of `tcsh'.
1127 One way is:
1128
1129      (setq explicit-shell-file-name "/bin/csh")
1130
1131 and another is to do this in your `.cshrc' (or `.tcshrc') file:
1132
1133      setenv ESHELL /bin/csh
1134
1135 (You must start Emacs over again with the environment variable properly
1136 set for this to take effect.)
1137
1138    You can also set the `ESHELL' environment variable in Emacs Lisp
1139 with the following Lisp form,
1140
1141      (setenv "ESHELL" "/bin/csh")
1142
1143    The above solutions try to prevent the shell from producing the `^M'
1144 characters in the first place.  If this is not possible (e.g., if you
1145 use a Windows shell), you can get Emacs to remove these characters from
1146