home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / GNU-Emacs-FAQ / part2 < prev    next >
Encoding:
Internet Message Format  |  1999-01-14  |  37.4 KB

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!news.kodak.com!news-nysernet-16.sprintlink.net!news-east1.sprintlink.net!news-peer1.sprintlink.net!news.sprintlink.net!news-peer.gip.net!news-dc.gip.net!news.gsl.net!gip.net!news-feed.netvision.net.il!194.90.1.15.MISMATCH!news!not-for-mail
  2. From: Reuven M. Lerner <reuven@netvision.net.il>
  3. Newsgroups: gnu.emacs.help,comp.emacs,comp.answers,news.answers
  4. Subject: GNU Emacs Frequently Asked Questions (FAQ), part 2/5
  5. Supersedes: <GNU-Emacs-FAQ-2_906123014@news.netvision.net.il>
  6. Followup-To: gnu.emacs.help
  7. Date: 13 Jan 1999 01:03:31 +0200
  8. Organization: GNU Emacs FAQ Central
  9. Lines: 936
  10. Approved: news-answers-request@MIT.EDU
  11. Expires: 20 Feb 1999 22:57:05 GMT
  12. Message-ID: <GNU-Emacs-FAQ-2_916181825@news.netvision.net.il>
  13. Reply-To: reuven@netvision.net.il
  14. NNTP-Posting-Host: ras7-p79.hfa.netvision.net.il
  15. X-Trace: news.netvision.net.il 916182669 24540 62.0.149.79 (12 Jan 1999 23:11:09 GMT)
  16. X-Complaints-To: abuse@netvision.net.il
  17. NNTP-Posting-Date: 12 Jan 1999 23:11:09 GMT
  18. Summary: Questions and answers having to do with GNU Emacs
  19. Keywords: GNU Emacs editors questions
  20. Xref: senator-bedfellow.mit.edu gnu.emacs.help:60638 comp.emacs:50860 comp.answers:34639 news.answers:148788
  21.  
  22. Archive-name: GNU-Emacs-FAQ/part2
  23.  
  24. ------------------------------------------------------------
  25.  
  26. If you are viewing this text in a GNU Emacs Buffer, you can type "M-2 C-x
  27. $" to get an overview of just the questions.  Then, when you want to look
  28. at the text of the answers, just type "C-x $".
  29.  
  30. To search for a question numbered XXX, type "M-C-s ^XXX:", followed by a
  31. C-r if that doesn't work.  Type RET to end the search.
  32.  
  33. If you have w3-mode installed (see question 111), you can visit ftp and
  34. HTTP uniform resource locators (URLs) by placing the cursor on the URL and
  35. typing M-x w3-follow-url-at-point.
  36.  
  37. The FAQ is posted in five parts; if you are missing a section or would
  38. prefer to read the FAQ in a single file, see question 22.
  39.  
  40. ------------------------------------------------------------
  41.  
  42.  
  43.  
  44. Status of Emacs
  45.  
  46. 23:  Where does the name "Emacs" come from?
  47.  
  48.   Emacs originally was an acronym for Editor MACroS.  RMS says he "picked
  49.   the name Emacs because `E' was not in use as an abbreviation on ITS at
  50.   the time."  The first Emacs was a set of macros written in 1976 at MIT by
  51.   RMS for the editor TECO (Text Editor and COrrector, originally Tape
  52.   Editor and COrrector) under ITS on a PDP-10.  RMS had already extended
  53.   TECO with a "real-time" full screen mode with reprogrammable keys.  Emacs
  54.   was started by Guy Steele <gls@east.sun.com> as a project to unify the
  55.   many divergent TECO command sets and key bindings at MIT, and completed
  56.   by RMS.
  57.  
  58.   Many people have said that TECO code looks a lot like line noise.  See
  59.   alt.lang.teco if you are interested.  Someone has written a TECO
  60.   implementation in Emacs Lisp (to find it, see question 90); it would be
  61.   an interesting project to run the original TECO Emacs inside of Emacs.
  62.  
  63.   For some not-so-serious alternative reasons for Emacs to have that name,
  64.   check out etc/JOKES (see question 4).
  65.  
  66. 24:  What is the latest version of Emacs?
  67.  
  68.   Emacs 20.3 is the current version as of this writing.
  69.  
  70. 25:  What is different about Emacs 20?
  71.  
  72.   To find out what has changed in recent versions, type C-h n (M-x
  73.   view-emacs-news).  The oldest changes are at the bottom of the file, so
  74.   you might want to read it starting there, rather than at the top.
  75.  
  76.   The differences between Emacs versions 18 and 19 was rather dramatic; the
  77.   introduction of frames, faces, and colors on windowing systems was
  78.   obvious to even the most casual user.
  79.  
  80.   There are differences between Emacs versions 19 and 20 as well, but many
  81.   are more subtle or harder to find.  Among the changes are the inclusion
  82.   of MULE code for languages that use non-Latin characters, the "customize"
  83.   facility for modifying variables without having to use Lisp, and
  84.   automatic conversion of files from Macintosh, Microsoft, and Unix
  85.   platforms.
  86.  
  87.   A number of older Lisp packages, such as Gnus, Supercite and the
  88.   calendar/diary, have been updated and enhanced to work with Emacs 20, and
  89.   are now included with the standard distribution.
  90.  
  91.  
  92. Common Things People Want To Do
  93.  
  94. 26:  How do I set up a .emacs file properly?
  95.  
  96.   See "Init File" in the on-line manual.
  97.  
  98.   WARNING: In general, new Emacs users should not have .emacs files,
  99.   because it causes confusing non-standard behavior.  Then they send
  100.   questions to help-gnu-emacs asking why Emacs isn't behaving as
  101.   documented.  :-)
  102.  
  103.   Emacs 20 includes the new "customize" facility, which can be invoked
  104.   using M-x customize RET.  This allows users who are unfamiliar with Emacs
  105.   Lisp to modify their .emacs files in a relatively straightforward way,
  106.   using menus rather than Lisp code.  Not all packages support Customize as
  107.   of this writing, but the number is growing fairly steadily.
  108.  
  109.   While Customize might indeed make it easier to configure Emacs, consider
  110.   taking a bit of time to learn Emacs Lisp and modifying your .emacs
  111.   directly. Simple configuration options are described rather completely in
  112.   the "Init File" section of the on-line manual, for users interested in
  113.   performing frequently requested, basic tasks.
  114.  
  115. 27:  How do I debug a .emacs file?
  116.  
  117.   Start Emacs with the "-debug-init" command-line option.  This enables the
  118.   Emacs Lisp debugger before evaluating your .emacs file, and places you in
  119.   the debugger if something goes wrong.  The top line in the trace-back
  120.   buffer will be the error message, and the second or third line of that
  121.   buffer will display the Lisp code from your .emacs file that caused the
  122.   problem.
  123.  
  124.   You can also evaluate an individual function or argument to a function in
  125.   your .emacs file by moving the cursor to the end of the function or
  126.   argument and typing "C-x C-e" (M-x eval-last-sexp).
  127.  
  128.   Use "C-h v" (M-x describe-variable) to check the value of variables which
  129.   you are trying to set or use.
  130.  
  131. 28:  How do I make Emacs display the current line (or column) number?
  132.  
  133.   To have Emacs automatically display the current line number of the point
  134.   in the mode line, do "M-x line-number-mode".  You can also put the form
  135.  
  136.     (setq line-number-mode t)
  137.  
  138.   in your .emacs file to achieve this whenever you start Emacs.  Note that
  139.   Emacs will not display the line number if the buffer is larger than the
  140.   value of the variable line-number-display-limit.
  141.  
  142.   As of Emacs 20, you can similarly display the current column with "M-x
  143.   column-number-mode", or by putting the form
  144.  
  145.     (setq column-number-mode t) 
  146.  
  147.   in your .emacs file.
  148.  
  149.   The "%c" format specifier in the variable mode-line-format will insert
  150.   the current column's value into the mode line.  See the documentation for
  151.   mode-line-format (using "C-h v mode-line-format RET") for more
  152.   information on how to set and use this variable.
  153.  
  154.   Users of all Emacs versions can display the current column using Per
  155.   Abrahamsen's <abraham@iesd.auc.dk> "column" package.  See question 90 for
  156.   instructions on how to get it.
  157.  
  158.   None of the vi emulation modes provide the "set number" capability of vi
  159.   (as far as we know).
  160.  
  161. 29:  How can I modify the titlebar to contain the current filename?
  162.  
  163.   The contains of an Emacs frame's titlebar is controlled by the variable
  164.   frame-title-format, which has the same structure as the variable
  165.   mode-line-format.  (Use "C-h v" or "M-x describe-variable" to get
  166.   information about one or both of these variables.)
  167.  
  168.   By default, the titlebar for a frame does contain the name of the buffer
  169.   currently being visited, except if there is a single frame.  In such a
  170.   case, the titlebar contains the name of the user and the machine at which
  171.   Emacs was invoked.  This is done by setting frame-title-format to the
  172.   default value of
  173.  
  174.      (multiple-frames "%b" ("" invocation-name "@" system-name))
  175.  
  176.   To modify the behavior such that frame titlebars contain the buffer's
  177.   name regardless of the number of existing frames, include the following
  178.   in your .emacs:
  179.  
  180.     (setq frame-title-format "%b")
  181.  
  182. 30:  How do I turn on abbrevs by default just in mode XXX?
  183.  
  184.   Put this in your .emacs file:
  185.  
  186.     (condition-case ()
  187.        (quietly-read-abbrev-file)
  188.       (file-error nil))
  189.  
  190.     (add-hook 'XXX-mode-hook
  191.               (function
  192.                 (lambda ()
  193.                  (setq abbrev-mode t))))
  194.  
  195. 31:  How do I turn on auto-fill mode by default?
  196.  
  197.   To turn on auto-fill mode just once for one buffer, use "M-x
  198.   auto-fill-mode".
  199.  
  200.   To turn it on for every buffer in a certain mode, you must use the hook
  201.   for that mode.  For example, to turn on auto-fill mode for all text
  202.   buffers, including the following in your .emacs file:
  203.  
  204.     (add-hook 'text-mode-hook 'turn-on-auto-fill)
  205.  
  206.   If you want auto-fill mode on in all major modes, do this:
  207.  
  208.     (setq-default auto-fill-function 'do-auto-fill)
  209.  
  210. 32:  How do I make Emacs use a certain major mode for certain files?
  211.  
  212.   If you want to use XXX mode for all files which end with the extension
  213.   ".YYY", this will do it for you:
  214.  
  215.     (setq auto-mode-alist (cons '("\\.YYY\\'" . XXX-mode) auto-mode-alist))
  216.  
  217.   Otherwise put this somewhere in the first line of any file you want to
  218.   edit in XXX mode (in the second line, if the first line begins with
  219.   "#!"):
  220.  
  221.     -*-XXX-*-
  222.  
  223.   Beginning with Emacs 19, the variable interpreter-mode-alist specifies
  224.   which mode to use when loading a shell script.  (Emacs determines which
  225.   interpreter you're using by examining the first line of the file.)  This
  226.   feature only applies when the file name doesn't indicate which mode to
  227.   use.  Use "C-h v" (or M-x describe-variable) on interpreter-mode-alist to
  228.   learn more.
  229.  
  230. 33:  How do I search for, delete, or replace unprintable (8-bit or control)
  231.      characters?
  232.  
  233.   To search for a single character that appears in the buffer as, for
  234.   example, "\237", you can type "C-s C-q 2 3 7".  (This assumes the value
  235.   of search-quote-char is 17 (i.e., `C-q').)  Searching for ALL unprintable
  236.   characters is best done with a regular expression ("regexp") search.  The
  237.   easiest regexp to use for the unprintable chars is the complement of the
  238.   regexp for the printable chars.
  239.  
  240.     Regexp for the printable chars: [\t\n\r\f -~]
  241.     Regexp for the unprintable chars: [^\t\n\r\f -~]
  242.  
  243.   To type these special characters in an interactive argument to
  244.   isearch-forward-regexp or re-search-forward, you need to use C-q.  (`\t',
  245.   `\n', `\r', and `\f' stand respectively for TAB, LFD, RET, and C-l.)  So,
  246.   to search for unprintable characters using re-search-forward:
  247.  
  248.     M-x re-search-forward RET [^ TAB C-q LFD C-q RET C-q C-l SPC -~] RET
  249.  
  250.   Using isearch-forward-regexp:
  251.  
  252.     M-C-s [^ TAB RET C-q RET C-q C-l SPC -~]
  253.  
  254.   To delete all unprintable characters, simply use replace-regexp:
  255.  
  256.     M-x replace-regexp RET [^ TAB C-q LFD C-q RET C-q C-l SPC -~] RET RET
  257.  
  258.   Replacing is similar to the above.  To replace all unprintable characters
  259.   with a colon, use:
  260.  
  261.     M-x replace-regexp RET [^ TAB C-q LFD C-q RET C-q C-l SPC -~] RET : RET
  262.  
  263.   NOTE: * You don't need to quote TAB with either isearch or typing
  264.           something in the minibuffer.
  265.  
  266. 34:  How can I highlight a region of text in Emacs?
  267.  
  268.   If you are using a windowing system such as X, you can cause the region
  269.   to be highlighted when the mark is active by including
  270.  
  271.         (transient-mark-mode t)
  272.  
  273.   in your .emacs file.  (Also see question 66.)
  274.  
  275. 35:  How do I control Emacs's case-sensitivity when searching/replacing?
  276.  
  277.   For searching, the value of the variable case-fold-search determines
  278.   whether they are case sensitive:
  279.  
  280.     (setq case-fold-search nil) ; make searches case sensitive
  281.     (setq case-fold-search t)   ; make searches case insensitive
  282.  
  283.   Similarly, for replacing the variable case-replace determines whether
  284.   replacements preserve case.
  285.  
  286.   To change the case sensitivity just for one major mode, use the major
  287.   mode's hook.  For example:
  288.  
  289.     (add-hook 'XXX-mode-hook
  290.           (function
  291.            (lambda ()
  292.              (setq case-fold-search nil))))
  293.  
  294. 36:  How do I make Emacs wrap words for me?
  295.  
  296.   Use auto-fill mode, activated by typing "M-x auto-fill-mode".  The
  297.   default maximum line width is 70, determined by the variable fill-column.
  298.   To learn how to turn this on automatically, see question 31.
  299.  
  300. 37:  Where can I get a better spelling checker for Emacs?
  301.  
  302.   Use Ispell.  See question 110.
  303.  
  304. 38:  How can I spell-check TeX or *roff documents?
  305.  
  306.   Use Ispell.  See question 110.  Ispell can handle TeX and *roff
  307.   documents.
  308.  
  309. 39:  How do I change load-path?
  310.  
  311.   In general, you should only *add* to the load-path.  You can add
  312.   directory /XXX/YYY to the load path like this:
  313.  
  314.     (setq load-path (cons "/XXX/YYY/" load-path))
  315.  
  316.   To do this relative to your home directory:
  317.  
  318.     (setq load-path (cons "~/YYY/" load-path)
  319.  
  320. 40:  How do I use an already running Emacs from another window?
  321.  
  322.   Emacsclient, which comes with Emacs, is for editing a file using an
  323.   already running Emacs rather than starting up a new Emacs.  It does this
  324.   by sending a request to the already running Emacs, which must be
  325.   expecting the request.
  326.  
  327.   * Setup
  328.  
  329.     Emacs must have executed the "server-start" function for emacsclient to
  330.     work.  This can be done either by a command line option:
  331.  
  332.       emacs -f server-start
  333.  
  334.     or by invoking server-start from the .emacs file:
  335.  
  336.       (if (some conditions are met) (server-start))
  337.  
  338.     When this is done, Emacs starts a subprocess running a program called
  339.     "server".  "server" creates a Unix domain socket in the user's home
  340.     directory named .emacs_server.
  341.  
  342.     To get your news reader, mail reader, etc., to invoke emacsclient, try
  343.     setting the environment variable EDITOR (or sometimes VISUAL) to the
  344.     value "emacsclient".  You may have to specify the full pathname of the
  345.     emacsclient program instead.  Examples:
  346.  
  347.       # csh commands:
  348.       setenv EDITOR emacsclient
  349.       setenv EDITOR /usr/local/emacs/etc/emacsclient  # using full pathname
  350.  
  351.       # sh command:
  352.       EDITOR=emacsclient ; export EDITOR
  353.  
  354.   * Normal use
  355.  
  356.     When emacsclient is run, it connects to the ".emacs_server" socket and
  357.     passes its command line options to "server".  When "server" receives
  358.     these requests, it sends this information on the the Emacs process,
  359.     which at the next opportunity will visit the files specified.  (Line
  360.     numbers can be specified just like with Emacs.)  The user will have to
  361.     switch to the Emacs window by hand.  When the user is done editing a
  362.     file, the user can type "C-x #" (or M-x server-edit) to indicate this.
  363.     If there is another buffer requested by emacsclient, Emacs will switch
  364.     to it; otherwise emacsclient will exit, signaling the calling program
  365.     to continue.
  366.  
  367.     NOTE: "emacsclient" and "server" must be running on machines which
  368.     share the same filesystem for this to work.  The pathnames that
  369.     emacsclient specifies should be correct for the filesystem that the
  370.     Emacs process sees.  The Emacs process should not be suspended at the
  371.     time emacsclient is invoked.  emacsclient should either be invoked from
  372.     another X window or from a shell window inside Emacs itself.
  373.  
  374.     There is an enhanced version of emacsclient/server called "gnuserv" by
  375.     Andy Norman <ange@hplb.hpl.hp.com> which is available in the Emacs Lisp
  376.     Archive (see question 90).  Gnuserv uses Internet domain sockets, so it
  377.     can work across most network connections.  It also supports the
  378.     execution of arbitrary Emacs Lisp forms and does not require the client
  379.     program to wait for completion.
  380.  
  381.     The alpha version of an enhanced version of gnuserv is available at
  382.  
  383.         ftp://ftp.wellfleet.com/netman/psmith/emacs/gnuserv-2.1alpha.tar.gz
  384.  
  385. 41:  How do I make Emacs recognize my compiler's funny error messages?
  386.  
  387.   The variable compilation-error-regexp-alist helps control how Emacs
  388.   parses your compiler output.  It is a list of triples of the form:
  389.  
  390.         (REGEXP FILE-IDX LINE-IDX)
  391.  
  392.   where REGEXP, FILE-IDX and LINE-IDX are strings.  To help determine what
  393.   the constituent elements should be, load compile.el and then use
  394.  
  395.         C-h v compilation-error-regexp-alist RET
  396.  
  397.   to see the current value.  A good idea is to look at compile.el itself as
  398.   the comments included for this variable are quite useful -- the regular
  399.   expressions required for your compiler's output may be very close to one
  400.   already provided.  Once you have determined the proper regexps, use the
  401.   following to inform Emacs of your changes:
  402.  
  403.         (setq compilation-error-regexp-alist
  404.               (cons '(REGEXP FILE-IDX LINE-IDX)
  405.                  compilation-error-regexp-alist))
  406.  
  407. 42:  How do I indent switch statements like this?
  408.  
  409.   Many people want to indent their switch statements like this:
  410.  
  411.     f()
  412.     {
  413.       switch(x) {
  414.         case A:
  415.           x1;
  416.           break;
  417.         case B:
  418.           x2;
  419.           break;
  420.         default:
  421.           x3;
  422.       }
  423.     }
  424.  
  425.   The solution at first appears to be: set c-indent-level to 4 and
  426.   c-label-offset to -2.  However, this will give you an indentation spacing
  427.   of four instead of two.
  428.  
  429.   The solution is to use cc-mode (the default mode for C programming in
  430.   Emacs 20) and add the following line:
  431.  
  432.     (c-set-offset 'case-label '+)
  433.  
  434.   There appears to be no way to do this with the old c-mode.
  435.  
  436. 43:  How can I make Emacs automatically scroll horizontally?
  437.  
  438.   Use hscroll-mode, included in Emacs 20.  Here is some information from
  439.   the documentation, available by typing C-h f hscroll-mode RET:
  440.  
  441.     Automatically scroll horizontally when the point moves off the
  442.     left or right edge of the window.  
  443.  
  444.     - Type "M-x hscroll-mode" to enable it in the current buffer.
  445.     - Type "M-x hscroll-global-mode" to enable it in every buffer.
  446.     - "turn-on-hscroll" is useful in mode hooks as in:
  447.           (add-hook 'text-mode-hook 'turn-on-hscroll)
  448.  
  449.     - hscroll-margin controls how close the cursor can get to the edge 
  450.       of the window.
  451.     - hscroll-step-percent controls how far to jump once we decide to do so.
  452.  
  453. 44:  How do I make Emacs "typeover" or "overwrite" instead of inserting?
  454.  
  455.   M-x overwrite-mode (a minor mode).  This toggles overwrite-mode on and
  456.   off, so exiting from overwrite-mode is as easy as another M-x
  457.   overwrite-mode.
  458.  
  459.   On some workstations, the "Insert" key toggles overwrite-mode on and off.
  460.  
  461. 45:  How do I stop Emacs from beeping on a terminal?
  462.  
  463.   Martin R. Frank <martin@cc.gatech.edu> writes:
  464.  
  465.     Tell Emacs to use the "visible bell" instead of the audible bell, and
  466.     set the visible bell to nothing.
  467.  
  468.     That is, put the following in your TERMCAP environment variable
  469.     (assuming you have one):
  470.  
  471.       ... :vb=: ...                    
  472.  
  473.     And evaluate the following Lisp form:
  474.  
  475.       (setq visible-bell t)
  476.  
  477. 46:  How do I turn down the bell volume in Emacs running under X Windows?
  478.  
  479.   You can adjust the bell volume and duration for all programs with the
  480.   shell command xset.
  481.  
  482.   Invoking xset without any arguments produces some basic information,
  483.   including the following:
  484.  
  485.     usage:  xset [-display host:dpy] option ...
  486.       To turn bell off:
  487.           -b                b off               b 0
  488.       To set bell volume, pitch and duration:
  489.            b [vol [pitch [dur]]]          b on
  490.  
  491. 47:  How do I tell Emacs to automatically indent a new line to the
  492.      indentation of the previous line?
  493.  
  494.   Such behavior is automatic in Emacs 20.  From the NEWS file for Emacs
  495.   20.2:
  496.  
  497.     ** In Text mode, now only blank lines separate paragraphs.  This makes
  498.     it possible to get the full benefit of Adaptive Fill mode in Text mode,
  499.     and other modes derived from it (such as Mail mode).  TAB in Text mode
  500.     now runs the command indent-relative; this makes a practical difference
  501.     only when you use indented paragraphs.
  502.  
  503.     As a result, the old Indented Text mode is now identical to Text mode,
  504.     and is an alias for it.
  505.  
  506.     If you want spaces at the beginning of a line to start a paragraph, use
  507.     the new mode, Paragraph Indent Text mode.
  508.  
  509.   If you have auto-fill mode on (see question 31), you can tell Emacs to
  510.   prefix every line with a certain character sequence, the "fill prefix."
  511.   Type the prefix at the beginning of a line, position point after it, and
  512.   then type "C-x ." (set-fill-prefix) to set the fill prefix.  Thereafter,
  513.   auto-filling will automatically put the fill prefix at the beginning of
  514.   new lines, and M-q (fill-paragraph) will maintain any fill prefix when
  515.   refilling the paragraph.
  516.  
  517.   NOTE: If you have paragraphs with different levels of indentation, you
  518.   will have to set the fill prefix to the correct value each time you move
  519.   to a new paragraph.  To avoid this hassle, try one of the many packages
  520.   available from the Emacs Lisp Archive (see question 90.)  Look up "fill"
  521.   and "indent" in the Lisp Code Directory for guidance.
  522.  
  523. 48:  How do I show which parenthesis matches the one I'm looking at?
  524.  
  525.   As of version 19, Emacs comes with paren.el, which (when loaded) will
  526.   automatically highlight matching parentheses whenever point (i.e., the
  527.   cursor) is located over one.  To load paren automatically, include the
  528.   line
  529.  
  530.     (require 'paren)
  531.  
  532.   in your .emacs file.  Alan Shutko <shutkoa@ugsolutions.com> reports that
  533.   as of version 20.1, you must also call show-paren-mode in your .emacs
  534.   file:
  535.  
  536.     (show-paren-mode 1)
  537.  
  538.   The "customize" facility will let you turn on show-paren-mode.  Use M-x
  539.   customize-group RET paren-showing RET.  From within customize, you can
  540.   also go directly to the "paren-showing" group.
  541.  
  542.   Alternatives to paren include:
  543.  
  544.   * If you're looking at a right parenthesis (or brace or bracket) you can
  545.     delete it and reinsert it.  Emacs will blink the cursor on the matching
  546.     parenthesis.
  547.  
  548.   * M-C-f (forward-sexp) and M-C-b (backward-sexp) will skip over one set
  549.     of balanced parentheses, so you can see which parentheses match.  (You
  550.     can train it to skip over balanced brackets and braces at the same time
  551.     by modifying the syntax table.)
  552.  
  553.   * Here is some Emacs Lisp that will make the % key show the matching
  554.     parenthesis, like in vi.  In addition, if the cursor isn't over a
  555.     parenthesis, it simply inserts a % like normal.
  556.  
  557.       ;; By an unknown contributor
  558.  
  559.       (global-set-key "%" 'match-paren)
  560.  
  561.       (defun match-paren (arg)
  562.         "Go to the matching parenthesis if on parenthesis otherwise insert %."
  563.         (interactive "p")
  564.         (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
  565.               ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
  566.               (t (self-insert-command (or arg 1)))))
  567.  
  568. 49:  In C mode, can I show just the lines that will be left after #ifdef
  569.      commands are handled by the compiler?
  570.  
  571.   M-x hide-ifdef-mode.  (This is a minor mode.)  You might also want to try
  572.   cpp.el, available at the Emacs Lisp Archive (see question 90).
  573.  
  574. 50:  Is there an equivalent to the `.' (dot) command of vi?
  575.  
  576.   (`.' is the redo command in vi.  It redoes the last insertion/deletion.)
  577.  
  578.   The next version of 
  579.  
  580.   No, not really, because Emacs doesn't have a special insertion mode.
  581.  
  582.   You can type "C-x ESC ESC" (repeat-complex-command) to reinvoke commands
  583.   that used the minibuffer to get arguments.  In repeat-complex-command you
  584.   can type M-p and M-n to scan through all the different complex commands
  585.   you've typed.
  586.  
  587.   To repeat a set of commands, use keyboard macros.  (See "Keyboard Macros"
  588.   in the on-line manual.)
  589.  
  590.   If you're really desperate for the `.' command, use VIPER, which comes
  591.   with Emacs, and which appears to support it.  (See question 107.)
  592.  
  593. 51:  What are the valid X resource settings (i.e., stuff in .Xdefaults)?
  594.  
  595.   See Emacs man page, or "Resources X" in the on-line manual.
  596.  
  597.   You can also use a resource editor, such as editres (for X11R5 and
  598.   onwards), to look at the resource names for the menu bar, assuming Emacs
  599.   was compiled with the X toolkit.
  600.  
  601. 52:  How do I execute ("evaluate") a piece of Emacs Lisp code?
  602.  
  603.   There are a number of ways to execute ("evaluate," in Lisp lingo) an
  604.   Emacs Lisp "form":
  605.  
  606.   * If you want it evaluated every time you run Emacs, put it in a file
  607.     named ".emacs" in your home directory.  This is known as your ".emacs
  608.     file," and contains all of your personal customizations.
  609.  
  610.   * You can type the form in the *scratch* buffer, and then type LFD (or
  611.     C-j) after it.  The result of evaluating the form will be inserted in
  612.     the buffer.
  613.  
  614.   * In Emacs-Lisp mode, typing M-C-x evaluates a top-level form before or
  615.     around point.
  616.  
  617.   * Typing "C-x C-e" in any buffer evaluates the Lisp form immediately
  618.     before point and prints its value in the echo area.
  619.  
  620.   * Typing M-: or M-x eval-expression allows you to type a Lisp form
  621.     in the minibuffer which will be evaluated.
  622.  
  623.   * You can use M-x load-file to have Emacs evaluate all the Lisp forms in
  624.     a file.  (To do this from Lisp use the function "load" instead.)
  625.  
  626.   These functions are also useful (see question 16 if you want to learn
  627.   more about them):
  628.  
  629.     load-library, eval-region, eval-current-buffer, require, autoload
  630.  
  631. 53:  How do I change Emacs's idea of the tab character's length?
  632.  
  633.   Set the variable default-tab-width.  For example, to set tab stops every
  634.   10 characters, insert the following in your .emacs file:
  635.  
  636.     (setq default-tab-width 10)
  637.  
  638.   Do not confuse variable tab-width with variable tab-stop-list.  The
  639.   former is used for the display of literal tab characters.  The latter
  640.   controls what characters are inserted when you press the TAB character in
  641.   certain modes.
  642.  
  643. 54:  How do I insert `>' at the beginning of every line?
  644.  
  645.   To do this to an entire buffer, type "M-< M-x replace-regexp RET ^ RET >
  646.   RET".
  647.  
  648.   To do this to a region, use "string-rectangle" ("C-x r t").  Set the mark
  649.   (`C-SPC') at the beginning of the first line you want to prefix, move the
  650.   cursor to last line to be prefixed, and type "C-x r t > RET".  To do this
  651.   for the whole buffer, type "C-x h C-x r t > RET".
  652.  
  653.   If you are trying to prefix a yanked mail message with '>', you might
  654.   want to set the variable mail-yank-prefix.  Better yet, get the Supercite
  655.   package (see question 105), which provides flexible citation for yanked
  656.   mail and news messages.
  657.  
  658. 55:  How do I insert "_^H" before each character in a region to get an
  659.      underlined paragraph?
  660.  
  661.   M-x underline-region.
  662.  
  663. 56:  How do I repeat a command as many times as possible?
  664.  
  665.   Use "C-x (" and "C-x )" to make a keyboard macro that invokes the command
  666.   and then type "M-0 C-x e".
  667.  
  668.   WARNING: any messages your command prints in the echo area will be
  669.   suppressed.
  670.  
  671. 57:  How do I make Emacs behave like this: when I go up or down, the cursor
  672.      should stay in the same column even if the line is too short?
  673.  
  674.   M-x picture-mode.
  675.  
  676. 58:  How do I tell Emacs to iconify itself?
  677.  
  678.   "C-z" iconifies Emacs when running under X Windows and suspends Emacs
  679.   otherwise.  See "Misc X" in the on-line manual.
  680.  
  681. 59:  How do I use regexps (regular expressions) in Emacs?
  682.  
  683.   See "Regexps" in the on-line manual.
  684.  
  685.   WARNING: The "or" operator is `\|', not `|', and the grouping operators
  686.   are `\(' and `\)'.  Also, the string syntax for a backslash is `\\'.  To
  687.   specify a regular expression like xxx\(foo\|bar\) in a Lisp string, use
  688.  
  689.      "xxx\\(foo\\|bar\\)"
  690.  
  691.   Notice the doubled backslashes!
  692.  
  693.   WARNING: Unlike in Unix grep, sed, etc., a complement character set
  694.   ([^...])  can match a newline character (LFD aka C-j aka \n), unless
  695.   newline is mentioned as one of the characters not to match.
  696.  
  697.   WARNING: The character syntax regexps (e.g., "\sw") are not meaningful
  698.   inside character set regexps (e.g., "[aeiou]").  (This is actually
  699.   typical for regexp syntax.)
  700.  
  701. 60:  How do I perform a replace operation across more than one file?
  702.  
  703.   The "tags" feature of Emacs includes the command tags-query-replace which
  704.   performs a query-replace across all the files mentioned in the TAGS file.
  705.   See "Tags Search" in the on-line manual.
  706.  
  707.   As of Emacs 19.29, Dired mode ("M-x dired RET", or C-x d) supports the
  708.   command dired-do-query-replace, which allows users to replace regular
  709.   expressions in multiple files.
  710.  
  711. 61:  Where is the documentation for "etags"?
  712.  
  713.   The "etags" man page should be in the same place as the "emacs" man page.
  714.  
  715.   Quick command-line switch descriptions are also available.  For example,
  716.   "etags -H".
  717.  
  718. 62:  How do I disable backup files?
  719.  
  720.   You probably don't want to do this, since backups are useful.
  721.  
  722.   To avoid seeing backup files (and other "uninteresting" files) in Dired,
  723.   load dired-x by adding the following to your .emacs file:
  724.  
  725.     (add-hook 'dired-load-hook
  726.               (function (lambda ()
  727.                           (load "dired-x"))))
  728.  
  729.   With dired-x loaded, `M-o' toggles omitting in each dired buffer.  You
  730.   can make omitting the default for new dired buffers by putting the
  731.   following in your .emacs:
  732.  
  733.     (setq initial-dired-omit-files-p t)
  734.  
  735.   If you're tired of seeing backup files whenever you do an "ls" at the
  736.   Unix shell, try GNU ls with the "-B" option.  GNU ls is part of the GNU
  737.   fileutils package, available at mirrors of ftp.gnu.org (see question 92).
  738.  
  739.   To disable or change how backups are made, see "Backup Names" in the
  740.   on-line manual.
  741.  
  742. 63:  How do I disable auto-save-mode?
  743.  
  744.   You probably don't want to do this, since auto-saving is useful,
  745.   especially when Emacs or your computer crashes while you are editing a
  746.   document.
  747.  
  748.   Instead, you might want to change the variable auto-save-interval, which
  749.   specifies how many keystrokes Emacs waits before auto-saving.  Increasing
  750.   this value forces Emacs to wait longer between auto-saves, which might
  751.   annoy you less.
  752.  
  753.   You might also want to look into Sebastian Kremer's auto-save package,
  754.   available from the Lisp Code Archive (see question 90).  This package
  755.   also allows you to place all auto-save files in one directory, such as
  756.   /tmp.
  757.  
  758.   To disable or change how auto-save-mode works, see "Auto Save" in the
  759.   on-line manual.
  760.  
  761. 64:  How can I create or modify new pull-down menu options?
  762.  
  763.   Each menu title (e.g., Buffers, File, Edit) represents a local or global
  764.   keymap.  Selecting a menu title with the mouse displays that keymap's
  765.   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 add a
  768.   new definition to the appropriate keymap.  Adding a "forward word"
  769.   command 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 global
  776.   menu bar entries.  Replacing the reference to "global-map" with a local
  777.   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 entry.
  780.   Placing this menu entry underneath the "File" menu would mean changing
  781.   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 will
  784.   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 must
  788.   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 "Words",
  794.   and attaches it to the global menu bar.  Adding the "forward word"
  795.   command 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), menu option
  804.   "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 define-key-after,
  807.   which works the same as define-key, but lets you modify where items
  808.   appear.  The following Lisp code would insert the "forward word" function
  809.   in the "edit" menu immediately following the "undo" option:
  810.  
  811.     (define-key-after
  812.       (lookup-key global-map [menu-bar edit])
  813.       [forward]
  814.       '("Forward word" . forward-word)
  815.       'undo)
  816.  
  817.   Note how the second and third arguments to define-key-after are different
  818.   from those of define-key, and that we have added a new (final) argument,
  819.   the function after which our new key should be defined.
  820.  
  821.   To move a menu option from one position to another, simply evaluate
  822.   define-key-after with the appropriate final argument.
  823.  
  824.   More detailed information -- and more examples of how to create and
  825.   modify menu options -- are in the Emacs Lisp Reference Manual, under
  826.   "Keymaps."  (See question 16 for information on this manual.)
  827.  
  828. 65:  How do I delete menus and menu options?
  829.  
  830.   The simplest way to remove a menu is to set its keymap to nil.  For
  831.   example, to delete the "Words" menu (from question 64), use:
  832.  
  833.     (define-key global-map [menu-bar words] nil)
  834.  
  835.   Similarly, removing a menu option requires redefining a keymap entry to
  836.   nil.  For example, to delete the "Forward word" menu option from the
  837.   "Edit" menu (we added it in question 64), use:
  838.  
  839.     (define-key global-map [menu-bar edit forward] nil)
  840.  
  841. 66:  How do I turn on syntax highlighting?
  842.  
  843.   Font-lock mode is the standard way to have Emacs perform syntax
  844.   highlighting.  With font-lock mode invoked, different types of text will
  845.   appear in different colors.  For instance, if you turn on font-lock in a
  846.   programming mode, variables will appear in one face, keywords in a
  847.   second, and comments in a third.
  848.  
  849.   Earlier versions of Emacs supported hilit19, a similar package.  Use of
  850.   hilit19 is now considered non-standard, although hilit19.el comes with
  851.   the stock Emacs distribution.  It is no longer maintained.
  852.  
  853.   To turn font-lock mode on within an existing buffer, use "M-x
  854.   font-lock-mode RET".
  855.  
  856.   To automatically invoke font-lock mode when a particular major mode is
  857.   invoked, set the major mode's hook.  For example, to fontify all c-mode
  858.   buffers, add the following to your .emacs file:
  859.  
  860.     (add-hook 'c-mode-hook 'turn-on-font-lock)
  861.  
  862.   To automatically invoke font-lock mode for all major modes, you can turn
  863.   on global-font-lock mode by including the following line in your .emacs
  864.   file:
  865.  
  866.     (global-font-lock-mode 1)
  867.  
  868.   This instructs Emacs to turn on font-lock mode in those buffers for which
  869.   a font-lock mode definition has been provided (in the variable
  870.   font-lock-global-modes).  If you edit a file in pie-ala-mode, and no
  871.   font-lock definitions have been provided for pie-ala files, then the
  872.   above setting will have no effect on that particular buffer.
  873.  
  874.   Highlighting with font-lock mode can take quite a while, and thus
  875.   different levels of decoration are available, from slight to gaudy.  To
  876.   control how decorated your buffers should become, set the value of
  877.   font-lock-maximum-decoration in your .emacs file, with a nil value
  878.   indicating default (usually minimum) decoration, and a t value indicating
  879.   the maximum decoration.  For the gaudiest possible look, then, include
  880.   the line
  881.  
  882.     (setq font-lock-maximum-decoration t)
  883.  
  884.   in your .emacs file.  You can also set this variable such that different
  885.   modes are highlighted in a different ways; for more information, see the
  886.   documentation for font-lock-maximum-decoration with "C-h v" (or "M-x
  887.   describe-variable RET").
  888.  
  889.   You might also want to investigate fast-lock-mode and lazy-lock-mode,
  890.   versions of font-lock-mode that speed up highlighting.  The advantage of
  891.   lazy-lock-mode is that it only fontifies buffers when certain conditions
  892.   are met, such as after a certain amount of idle time, or after you have
  893.   finished scrolling through text.  See the documentation for
  894.   lazy-lock-mode by typing C-h f lazy-lock-mode ("M-x describe-function RET
  895.   lazy-lock-mode RET").
  896.  
  897.   Also see the documentation for the function font-lock-mode, available by
  898.   typing C-h f font-lock-mode ("M-x describe-function RET font-lock-mode
  899.   RET").
  900.  
  901.   For more information on font-lock mode, take a look at the font-lock mode
  902.   FAQ, maintained by Jari Aalto <jari.aalto@ntc.nokia.com> at
  903.  
  904.     ftp://cs.uta.fi/pub/ssjaaa/ema-font.gui
  905.  
  906.   To print buffers with the faces (i.e., colors and fonts) intact, use
  907.   "M-x ps-print-buffer-with-faces" or "M-x ps-print-region-with-faces".
  908.  
  909. 67:  How can I force Emacs to scroll only one line when I move past the
  910.      bottom of the screen?
  911.  
  912.   Place the following Lisp form in your .emacs file:
  913.  
  914.     (setq scroll-step 1)
  915.  
  916.   Also see "Scrolling" in the on-line manual.
  917.  
  918. 68:  How can I replace highlighted text with what I type?
  919.  
  920.   Use delete-selection mode, which you can start automatically by placing
  921.   the following Lisp form in your .emacs file:
  922.  
  923.     (delete-selection-mode t)
  924.  
  925.   According to the documentation string for delete-selection mode (which
  926.   you can read using M-x describe-function RET delete-selection-mode RET):
  927.  
  928.     When ON, typed text replaces the selection if the selection is active.
  929.     When OFF, typed text is just inserted at point.
  930.  
  931.   This mode also allows you to delete (not kill) the highlighted region by
  932.   pressing DEL.
  933.  
  934. 69:  How can I edit MS-DOS files using Emacs?
  935.  
  936.   As of Emacs 20, detection and handling of MS-DOS (and Windows) files is
  937.   performed transparently. You can open MS-DOS files on a Unix system, edit
  938.   it, and save it without having to worry about the file format.
  939.  
  940.   When editing an MS-DOS style file, a backslash (\) will appear in the
  941.   mode line.
  942.  
  943.   If you are running an earlier version of Emacs, get crypt++ from the
  944.   Emacs Lisp Archive (see question 90).  Among other things, crypt++
  945.   transparently modifies MS-DOS files as they are loaded and saved,
  946.   allowing you to ignore the different conventions that Unix and MS-DOS
  947.   have for delineating the end of a line.
  948.  
  949. 70:  How can I tell Emacs to fill paragraphs with a single space after
  950.      each period?
  951.  
  952.   Ulrich Mueller <ulm@vsnhd1.cern.ch> suggests adding the following two
  953.   lines to your .emacs file:
  954.  
  955.     (setq sentence-end "[.?!][]\"')}]*\\($\\|[ \t]\\)[ \t\n]*")
  956.     (setq sentence-end-double-space nil)
  957.  
  958.