home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / emacs / info / emacs-14 (.txt) < prev    next >
GNU Info File  |  1992-10-30  |  51KB  |  946 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.49 from the
  2. input file emacs.texi.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988, 1992 Richard M. Stallman.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  11. General Public License" are included exactly as in the original, and
  12. provided that the entire resulting derived work is distributed under the
  13. terms of a permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "The GNU Manifesto",
  17. "Distribution" and "GNU General Public License" may be included in a
  18. translation approved by the author instead of in the original English.
  19. File: emacs,  Node: Concepts of VC,  Next: Editing with VC,  Up: Version Control
  20. Concepts of Version Control
  21. ---------------------------
  22.    When a file is under version control, we also say that it is
  23. "registered" in the version control system.  Each registered file has a
  24. corresponding "master file" which represents the file's present state
  25. plus its change history, so that you can reconstruct from it either the
  26. current version or any specified earlier version.  Usually the master
  27. file also records a change comment for each version.
  28.    The file that is maintained under version control is sometimes called
  29. the "work file" corresponding to its master file.
  30.    To examine a file, you "check it out".  This extracts a version of
  31. the file (typically, the most recent) from the master.  If you want to
  32. edit the file, you must check it out "locked".  Only one user can do
  33. this at a time for any given source file.  When you are done with your
  34. editing, you must "check in" the new version.  This records the new
  35. version in the master file, and unlocks the source file so that other
  36. people can lock it and thus modify it.
  37.    These are the basic operations of version control. Checking in and
  38. checking out both use the single Emacs command `C-x C-q'
  39. (`vc-toggle-read-only').
  40. File: emacs,  Node: Editing with VC,  Next: Variables for Check-in/out,  Prev: Concepts of VC,  Up: Version Control
  41. Editing with Version Control
  42. ----------------------------
  43.    When you visit a file that is maintained using version control, the
  44. mode line displays `RCS' or `SCCS' to inform you that version control
  45. is in use, and also (in case you care) which low-level system the file
  46. is actually stored in.  Normally, such a source file is read-only, and
  47. the mode line indicates this with `%%'.)
  48.    These are the commands that you use to edit a file maintained with
  49. version control:
  50. `C-x C-q'
  51.      Check the visited file in or out.
  52. `C-x v u'
  53.      Revert the buffer and the file to the last checked in version.
  54. `C-x v c'
  55.      Remove the last-entered change from the master for the visited
  56.      file. This undoes your last check-in.
  57. `C-x v i'
  58.      Register the visited file in version control.
  59. (`C-x v' is the prefix key for version control commands; all of these
  60. commands except for `C-x C-q' start with `C-x v'.)
  61.    If you want to edit the file, type `C-x C-q'
  62. (`vc-toggle-read-only').  This "checks out" and locks the file, so that
  63. you can edit it.  The file is writable after check-out, but only for
  64. you, not for anyone else.
  65.    Emacs does not save backup files for source files that are maintained
  66. with version control.  If you want to make backup files despite version
  67. control, set the variable `vc-make-backups' to a non-`nil' value.
  68.    When you are finished editing the file, type `C-x C-q' again. When
  69. used on a file that is checked out, this command checks the file in. 
  70. But check-in does not start immediately; first, you must enter a "log
  71. entry"--a description of the changes in the new version. `C-x C-q' pops
  72. up a buffer for you to enter this in.  When you are finished typing in
  73. the log entry, type `C-c C-c' to terminate it; this is when actual
  74. check-in takes place.
  75.    Once you have checked in your changes, the file is unlocked, so that
  76. other users can lock it and modify it.
  77.    Normally the work file exists all the time, whether it is locked or
  78. not.  If you set `vc-keep-workfiles' to `nil', then checking in a new
  79. version with `C-x C-q' deletes the work file; but any attempt to visit
  80. the file with Emacs creates it again.
  81.    Actually, it is not impossible to lock a file that someone else has
  82. locked.  If you try to check out a file that is locked, `C-x C-q' asks
  83. you whether you want to "steal the lock."  If you say yes, the file
  84. becomes locked by you, but a message is sent to the person who had
  85. formerly locked the file, to inform him or her of what has happened.
  86.    If you want to discard your current set of changes and revert to the
  87. last version checked in, use `C-x v u' (`vc-revert-buffer'). This
  88. cancels your last check-out, leaving the file unlocked.  If you want to
  89. make a different set of changes, you must first check the file out
  90. again.  `C-x v u' requies confirmation, unless it sees that you haven't
  91. made any changes since the last checked-in version.
  92.    `C-x v u' is also the command to use if you lock a file and then
  93. don't actually change it.
  94.    You can even cancel a change after checking it in, with `C-x v c'
  95. (`vc-cancel-version').  Normally, `C-x v c' reverts your workfile and
  96. buffer to the previous version (the one that precedes the version that
  97. is deleted), but you can prevent the reversion by giving the command a
  98. prefix argument.  Then the buffer does not change.
  99.    This command with a prefix argument is useful when you have checked
  100. in a change and then discover a trivial error in it; you can cancel the
  101. erroneous check-in, fix the error, and repeat the check-in.
  102.    Be careful when invoking `C-x v c', as it is easy to throw away a
  103. lot of work with it.  To help you be careful, this command always asks
  104. for confirmation with `yes'.
  105.    You can register the visited file for version control using
  106. `C-x v i' (`vc-register').  This uses RCS if RCS is installed on your
  107. system; otherwise, it uses SCCS.
  108.    By default, the initial version number is 1.1.  If you want to use a
  109. different number, give `C-x v i' a prefix argument; then it reads the
  110. initial version number using the minibuffer.
  111.    After `C-x v i', the file is unlocked and read-only.  Type `C-x C-q'
  112. if you wish to edit it.
  113.    If `vc-initial-comment' is non-`nil', `C-x v i' reads an initial
  114. comment (much like a log entry) to describe the purpose of this source
  115. file.
  116. File: emacs,  Node: Variables for Check-in/out,  Next: Comparing Versions,  Prev: Editing with VC,  Up: Version Control
  117. Variables Affecting Check-in and Check-out
  118. ------------------------------------------
  119.    If `vc-suppress-confirm' is non-`nil', then `C-x C-q' and `C-x v i'
  120. can save the current buffer without asking, and `C-x v u' also operates
  121. without asking for confirmation. (This variable does not affect `C-x v
  122. c'; that is so drastic that it should always ask for confirmation.)
  123.    VC mode does much of its work by running the shell commands for RCS
  124. and SCCS.  If `vc-command-messages' is non-`nil', VC displays messages
  125. to indicate which shell commands it runs, and additional messages when
  126. the commands finish.
  127.    Normally, VC assumes that it can deduce the locked/unlocked state of
  128. files by looking at the file permissions of the work file; this is
  129. fast.  However, if the `RCS' or `SCCS' subdirectory is actually a
  130. symbolic link, then VC does not trust the file permissions to reflect
  131. this status.
  132.    You can specify the criterion for whether to trust the file
  133. permissions by setting the variable `vc-mistrust-permissions'.  Its
  134. value may be `t' (always mistrust the file permissions and check the
  135. master file), `nil' (always trust the file permissions), or a function
  136. of one argument which makes the decision.  The argument is the directory
  137. name of the `RCS' or `SCCS' subdirectory.  A non-`nil' value from the
  138. function says to mistrust the file permissions.
  139.    If you find that the file permissions of work files are changed
  140. erroneously, then you can set `vc-mistrust-permissions' to `t' so that
  141. VC always checks the master file.
  142. File: emacs,  Node: Log Entries,  Next: Change Logs and VC,  Prev: Snapshots,  Up: Version Control
  143. Log Entries
  144. -----------
  145.    When you're editing an initial or change comment for inclusion in a
  146. master file, finish your entry by typing `C-c C-c'.
  147. `C-c C-c'
  148.      Finish the comment edit normally (`vc-finish-logentry'). This
  149.      finishes check-in.
  150.    To abort check-in, just don't type `C-c C-c' in that buffer.  You
  151. can switch buffers and do other editing.  As long as you don't try to
  152. check in another file, the comment you were editing remains in its
  153. buffer, and you can go back to that buffer at any time to complete the
  154. check-in.
  155.    If you change several source files for the same reason, it is often
  156. convenient to specify the same log entry for many of the files.  To do
  157. this, use the history of previous log entries.  The commands `M-n',
  158. `M-p', `M-s' and `M-r' for doing this work just like the minibuffer
  159. history commands (except that they don't use the minibuffer).
  160.    The history of previous log entries is actually stored in previous
  161. pages of the log entry editing buffer; they are normally hidden by
  162. narrowing.
  163.    Each time you check in a file, the log entry buffer is put into VC
  164. Log mode, which involves running two hook variables: `text-mode-hook'
  165. and `vc-log-mode-hook'.
  166. File: emacs,  Node: Change Logs and VC,  Next: Version Headers,  Prev: Log Entries,  Up: Version Control
  167. Change Logs and VC
  168. ------------------
  169.    Emacs users often record brief summaries of program changes in a file
  170. called `ChangeLog', which is kept in the same directory as the source
  171. files, and is usually meant to be distributed along with the source
  172. files.  You can maintain `ChangeLog' from the version control logs with
  173. the following command.
  174. `C-x v a'
  175.      Visit the current directory's change log file and create new
  176.      entries for versions checked in since the most recent entry in the
  177.      change log file (`vc-update-change-log').
  178.      This command works with RCS only; it does not work with SCCS.
  179.    For example, suppose the first line of `ChangeLog' is dated 10 April
  180. 1992, and suppose the only check-in since then was by Nathaniel
  181. Bowditch to `rcs2log' on 8 May 1992 with log text `Ignore log messages
  182. that start with `#'.'.  Then `C-x v a' visits `ChangeLog' and inserts
  183. text like this:
  184.      Fri May  8 21:45:00 1992  Nathaniel Bowditch  (nat@apn.org)
  185.      
  186.              * rcs2log: Ignore log messages that start with `#'.
  187. You can then further edit as you wish.
  188.    A log entry whose text begins with `#' is not copied to `ChangeLog'.
  189.  For example, if you merely fix some misspellings in comments, you can
  190. log the change with an entry beginning with `#' to avoid putting such
  191. trivia into `ChangeLog'.
  192.    When `C-x v a' adds several change log entries at once, it groups
  193. related log entries together if they all are checked in by the same
  194. author at nearly the same time.  If the log entries for several such
  195. files all have the same text, it coalesces them into a single entry.
  196. For example, suppose the most recent check-ins have the following log
  197. entries:
  198. For `vc.texinfo':
  199.      Fix expansion typos.
  200. For `vc.el':
  201.      Don't call expand-file-name.
  202. For `vc-hooks.el':
  203.      Don't call expand-file-name.
  204.    They appear like this in `ChangeLog':
  205.      Wed Apr  1 08:57:59 1992  Nathaniel Bowditch  (nat@apn.org)
  206.      
  207.              * vc.texinfo: Fix expansion typos.
  208.      
  209.              * vc.el, vc-hooks.el: Don't call expand-file-name.
  210.    Normally, `C-x v a' separates log entries by a blank line, but you
  211. can mark several related log entries to be clumped together (without an
  212. intervening blank line) by starting the text of each related log entry
  213. with a label of the form `{CLUMPNAME} '.  The label itself is not
  214. copied to `ChangeLog'.  For example, suppose the log entries are:
  215. For `vc.texinfo':
  216.      {expand} Fix expansion typos.
  217. For `vc.el':
  218.      {expand} Don't call expand-file-name.
  219. For `vc-hooks.el':
  220.      {expand} Don't call expand-file-name.
  221.    Then the text in `ChangeLog' looks like this:
  222.      Wed Apr  1 08:57:59 1992  Nathaniel Bowditch  (nat@apn.org)
  223.      
  224.              * vc.texinfo: Fix expansion typos.
  225.              * vc.el, vc-hooks.el: Don't call expand-file-name.
  226.    Normally, the log entry for file `foo' is displayed as `* foo: TEXT
  227. OF LOG ENTRY'.  But by convention, the `:' after `foo' is omitted if
  228. the text of the log entry starts with `(FUNCTIONNAME): '.  For example,
  229. if the log entry for `vc.el' is `(vc-do-command): Check call-process
  230. status.', then the text in `ChangeLog' looks like this:
  231.      Wed May  6 10:53:00 1992  Nathaniel Bowditch  (nat@apn.org)
  232.      
  233.              * vc.el (vc-do-command): Check call-process status.
  234. File: emacs,  Node: Comparing Versions,  Next: VC Status,  Prev: Variables for Check-in/out,  Up: Version Control
  235. Comparing Versions
  236. ------------------
  237.    To compare two versions of a file, use `C-x v =' (`vc-diff').
  238.    Plain `C-x v =' compares the current buffer contents (saving them in
  239. the file if necessary) with the last checked-in version of the file.
  240. With a prefix argument, `C-x v =' reads a filename and two version
  241. numbers, and compares those versions of the file you specify.
  242.    If you supply a directory name instead of the name of a work file,
  243. this command compares the two specified versions of all registered files
  244. in that directory and its subdirectories.  You can also specify a
  245. snapshot name (*note Snapshots::.) instead of one or both version
  246. numbers.
  247.    You can specify a checked-in version by its number; you can specify
  248. the most recent checked-in version with `-'; and you can specify the
  249. current buffer contents with `+'.  Thus, you can compare two checked-in
  250. versions, or compare a checked-in version with the text you are editing.
  251.    This command works by running the `diff' utility, getting the
  252. options from the variable `diff-switches'.  It displays the output in a
  253. special buffer in another window.
  254. File: emacs,  Node: VC Status,  Next: Renaming and VC,  Prev: Comparing Versions,  Up: Version Control
  255. VC Status Commands
  256. ------------------
  257.    To get the detailed version control status of one file, type `C-x v
  258. l' (`vc-print-log').  It displays the history of changes to the current
  259. file, including the text of the log entries.  The output appears in a
  260. separate window.
  261.    When you are working on a large program, it's often useful to find
  262. all the files that are currently locked, or all the files maintained in
  263. version control at all.  You can do so using these commands, both of
  264. which operate on the branch of the file system starting at the current
  265. directory.
  266.    You can use `C-x v d' (`vc-directory') to show all the locked files
  267. in or beneath the current directory.  This includes all files that are
  268. locked by any user.
  269.    With a prefix argument, `C-x v d' shows all the version control
  270. activity in the current directory--it lists all files in or beneath the
  271. current directory that are maintained with version control.
  272. File: emacs,  Node: Renaming and VC,  Next: Snapshots,  Prev: VC Status,  Up: Version Control
  273. Renaming VC Work Files and Master Files
  274. ---------------------------------------
  275.    When you rename a registered file, you must also rename its master
  276. file correspondingly to get proper results.  Use `vc-rename-file' to
  277. rename the source file as you specify, and rename its master file
  278. accordingly.  It also updates any snapshots (*note Snapshots::.) that
  279. mention the file, so that they use the new name; despite this, the
  280. snapshot thus modified may not completely work (*note Snapshot
  281. Caveats::.).
  282.    You cannot use `vc-rename-file' on a file that is locked by someone
  283. else.
  284.    `vc-rename-file' is not bound to a key because it's not likely to be
  285. used frequently.
  286. File: emacs,  Node: Snapshots,  Next: Log Entries,  Prev: Renaming and VC,  Up: Version Control
  287. Snapshots
  288. ---------
  289.    A "snapshot" is a named set of file versions (one for each
  290. registered file) that you can treat as a unit.  One important kind of
  291. snapshot is a "release", a (theoretically) stable version of the system
  292. that is ready for distribution to users.
  293. * Menu:
  294. * Making Snapshots::        The snapshot facilities.
  295. * Snapshot Caveats::        Things to be careful of, when using snapshots.
  296. File: emacs,  Node: Making Snapshots,  Next: Snapshot Caveats,  Up: Snapshots
  297. Making and Using Snapshots
  298. ..........................
  299.    There are two basic commands for snapshots; one makes a snapshot
  300. with a given name, the other retrieves a named snapshot.
  301. `C-x v s NAME RET'
  302.      Define the last saved versions of every registered file in or
  303.      under the current directory as a snapshot named NAME
  304.      (`vc-create-snapshot').
  305. `C-x v r NAME RET'
  306.      Check out all registered files at or below the current directory
  307.      level using whatever versions correspond to the snapshot NAME
  308.      (`vc-retrieve-snapshot').
  309.      This function reports an error if any files are locked at or below
  310.      the current directory, without changing anything; this is to avoid
  311.      overwriting work in progress.
  312.    You shouldn't need to use `vc-retrieve-snapshot' very often; you can
  313. get difference reports between two snapshots without retrieving either
  314. one, using `C-x =' (*note Comparing Versions::.).  Thus, retrieving a
  315. snapshot is only necessary if you need to study or compile portions of
  316. the snapshot.
  317.    A snapshot uses a very small amount of resources--just enough to
  318. record the list of file names and which version belongs to the
  319. snapshot.  Thus, you need not hesitate to create snapshots whenever
  320. they are useful.
  321.    You can give a snapshot name as an argument to `C-x v =' (*note
  322. Comparing Versions::.).  Thus, you can use it to compare a snapshot
  323. against the current files, or two snapshots against each other, or a
  324. snapshot against a named version.
  325. File: emacs,  Node: Snapshot Caveats,  Prev: Making Snapshots,  Up: Snapshots
  326. Snapshot Caveats
  327. ................
  328.    VC's snapshot facilities are modeled on RCS's named-configuration
  329. support.  They use RCS's native facilities for this, so under VC
  330. snapshots made using RCS are visible even when you bypass VC.
  331.    For SCCS, VC implements snapshots itself.  The files it uses contain
  332. name/file/version-number triples.  These snapshots are visible only
  333. through VC.
  334.    File renaming and deletion can create some difficulties with
  335. snapshots. This is not a VC-specific problem, but a general design
  336. issue in version control systems that no one has solved very well yet.
  337.    If you rename a registered file, you need to rename its master along
  338. with it (the function `vc-rename-file' does this automatically). If you
  339. are using SCCS, you must also update the records of the snapshot, to
  340. mention the file by its new name (`vc-rename-file' does this, too). 
  341. This makes the snapshot remain valid for retrieval, but it does not
  342. solve all problems.
  343.    For example, some of the files in the program probably refer to
  344. others by name.  At the very least, the makefile probably mentions the
  345. file that you renamed.  If you retrieve an old snapshot, the renamed
  346. file is retrieved under its new name, which is not the name that the
  347. makefile expects.  So the program won't really work.
  348.    If you use snapshots, don't rename either work files or master files
  349. except by means of `vc-rename-file'.  It knows how to update snapshots
  350. so that you can still retrieve them.  An old snapshot that refers to a
  351. master file that no longer exists under the recorded name is invalid;
  352. VC can no longer retrieve it.  It would be beyond the scope of this
  353. manual to explain enough about RCS and SCCS to teach the reader how to
  354. update the snapshots by hand.
  355. File: emacs,  Node: Version Headers,  Prev: Change Logs and VC,  Up: Version Control
  356. Inserting Version Control Headers
  357. ---------------------------------
  358.    Sometimes it is convenient to put version identification strings
  359. directly into working files.  Certain special strings called "version
  360. headers" are replaced in each successive version by the number of that
  361. version.
  362.    You can use the `C-x v h' command (`vc-insert-headers') to insert a
  363. suitable header string.
  364. `C-x v h'
  365.      Insert headers in a file for use with your version-control system.
  366.    The default header string is `$ld$' for RCS and `%W%' for SCCS.  You
  367. can specify other headers to insert by setting the variable
  368. `vc-header-string'.  Its value (if non-`nil') should be the string to
  369. be inserted.  You can also specify a list of strings; then each string
  370. in the list is inserted as a separate header on a line of its own.  (It
  371. is often important to use "superfluous" backslashes when writing a Lisp
  372. string constant for this use, to prevent the string in the constant
  373. from being interpreted as a header itself if the Emacs Lisp file
  374. containing it is maintained with version control.)
  375.    Each header is inserted surrounded by tabs, inside comment
  376. delimiters, on a new line at the start of the buffer.  Normally the
  377. ordinary comment start and comment end strings of the current mode are
  378. used, but for certain modes, there are special comment delimiters for
  379. this purpose; the variable `vc-comment-alist' specifies them.  Each
  380. element of this list has the form `(MODE STARTER ENDER)'.
  381.    `vc-static-header-alist' is consulted to add further strings based
  382. on the name of the buffer.  Its value should be a list of dotted pairs;
  383. the CAR of each pair is a regular expression that should match the
  384. buffer name, and the CDR is the format to use on each header.  A string
  385. is inserted for each file name pattern that matches the buffer name,
  386. and for each header taken from `vc-header-string'.  The default value
  387. for `vc-static-header-alist' is:
  388.      (("\\.c$" .
  389.        "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
  390.      #endif /* lint */\n"))
  391. which specifies insertion of a string of this form:
  392.      #ifndef lint
  393.      static char vcid[] = "HEADER-STRING";
  394.      #endif /* lint */
  395. File: emacs,  Node: Emerge,  Next: Debuggers,  Prev: Version Control,  Up: Version 19
  396. Emerge
  397. ======
  398.    It's not unusual for programmers to get their signals crossed and
  399. modify the same program in two different directions.  To recover from
  400. this confusion, you need to merge the two versions.  Emerge makes this
  401. easier.
  402. * Menu:
  403. * Overview of Emerge::
  404. * Submodes of Emerge::
  405. * State of Difference::
  406. * Merge Commands::
  407. * Exiting Emerge::
  408. * Combining in Emerge::
  409. * Fine Points of Emerge::
  410. File: emacs,  Node: Overview of Emerge,  Next: Submodes of Emerge,  Up: Emerge
  411. Overview of Emerge
  412. ------------------
  413.    To start Emerge, run one of these four commands:
  414. `M-x emerge-files'
  415.      Merge two specified files.
  416. `M-x emerge-files-with-ancestor'
  417.      Merge two specified files, with reference to a common ancestor.
  418. `M-x emerge-buffers'
  419.      Merge two buffers (the currently accessible portions).
  420. `M-x emerge-buffers-with-ancestor'
  421.      Merge two buffers (the currently accessible portions) with
  422.      reference to a common ancestor in another buffer.
  423.    The Emerge commands compare two texts, and display the results in
  424. three buffers: one for each input text (the "A buffer" and the "B
  425. buffer"), and one (the "merge buffer") where merging takes place. The
  426. merge buffer does not show just the differences.  Rather, it shows you
  427. the full text, but wherever the input texts differ, you can choose
  428. which one of them to include in the merge buffer.
  429.    If a common ancestor version is available, from which the two texts
  430. to be merged were both derived, Emerge can use it to guess which
  431. alternative is right.  Wherever one current version agrees with the
  432. ancestor, Emerge presumes that the other current version is a deliberate
  433. change which should be kept in the merged version.  Use the
  434. "with-ancestor" commands if you want to specify a common ancestor text.
  435.  These commands read three file or buffer names--variant A, variant B,
  436. and the common ancestor.
  437.    After the comparison is done and the buffers are prepared, the actual
  438. merging starts.  You control the merging interactively by editing the
  439. merge buffer.  The merge buffer shows you a full merged text, not just
  440. differences.  For each point where the input texts differ, you can
  441. choose which one of them to include in the merge buffer.
  442.    The merge buffer has a special major mode, Emerge mode, with commands
  443. for making these choices.  But you can also edit the buffer with
  444. ordinary Emacs commands.
  445.    At any given time, the attention of Emerge is focused on one
  446. particular difference, called the "selected" difference.  This
  447. difference is marked off in the three buffers by
  448.      vvvvvvvvvvvvvvvvvvvv
  449. above and
  450.      ^^^^^^^^^^^^^^^^^^^^
  451. below.  Emerge numbers all the differences sequentially and the mode
  452. line always shows the number of the selected difference.
  453.    Normally, the merge buffer starts out with the A version of the text.
  454. But when the A version of a part of the buffer agrees with the common
  455. ancestor, then the B version is preferred for that part.
  456.    Normally, Emerge stores the merged output in place of the first input
  457. text (the A file or buffer).  If you give a prefix argument to
  458. `emerge-files' or `emerge-files-with-ancestor', it reads the name of
  459. the output file using the minibuffer.  (This is the last file name
  460. those commands read.)
  461.    If you abort Emerge with `C-u q', the output is not saved.
  462. File: emacs,  Node: Submodes of Emerge,  Next: State of Difference,  Prev: Overview of Emerge,  Up: Emerge
  463. Submodes of Emerge
  464. ------------------
  465.    You can choose between two modes for giving merge commands: Fast mode
  466. and Edit mode.  In Fast mode, basic Emerge commands are single
  467. characters, but ordinary Emacs commands are disabled.  This is
  468. convenient if you use only Emerge commands.
  469.    In Edit mode, all Emerge commands start with the prefix character
  470. `C-c', and the normal Emacs commands are also available.  This allows
  471. editing the merge buffer, but slows down Emerge operations.
  472.    Use `e' to switch to Edit mode, and `f' to switch to Fast mode. The
  473. mode line indicates Edit and Fast modes with `E' and `F'.
  474.    Emerge has two additional submodes that affect how particular merge
  475. commands work: Auto Advance mode and Skip Prefers mode.
  476.    If Auto Advance mode is in effect, the `a' and `b' commands advance
  477. to the next difference.  This lets you go through the merge faster
  478. doing ordinary things.  The mode line indicates Auto Advance mode with
  479.    If Skip Prefers mode is in effect, the `n' and `p' commands skip
  480. over differences in states prefer-A and prefer-B.  Thus you will only
  481. see differences for which neither version is presumed "correct".  The
  482. mode line indicates Skip Prefers mode with `S'.
  483.    Use the command `emerge-auto-advance-mode' to set or clear Auto
  484. Advance mode.  Use `emerge-skip-prefers-mode' to set or clear Skip
  485. Prefers mode.  A positive argument turns the mode on, a nonpositive
  486. argument turns it off, and no argument toggles it.
  487. File: emacs,  Node: State of Difference,  Next: Merge Commands,  Prev: Submodes of Emerge,  Up: Emerge
  488. State of a Difference
  489. ---------------------
  490.    In the merge buffer, a difference is marked `vvvvvvvvvvvvvvvvvvvv'
  491. above and `^^^^^^^^^^^^^^^^^^^^' below.  Such a difference can have one
  492. of seven states:
  493.      The difference is showing the A version.  The `a' command always
  494.      produces this state; the mode line indicates it with `A'.
  495.      The difference is showing the B version.  The `b' command always
  496.      produces this state; the mode line indicates it with `B'.
  497. default-A
  498. default-B
  499.      The difference is showing the A or the B state by default, because
  500.      you haven't made a choice.  All differences start in the default-A
  501.      state (and thus the merge buffer is a copy of the A buffer),
  502.      except those for which one alternative is "preferred" (see below).
  503.      When you select a difference, its state changes from default-A or
  504.      default-B to plain A or B.  Thus, the selected difference never has
  505.      state default-A or default-B, and these states are never displayed
  506.      in the mode line.
  507.      The command `d a' chooses default-A as the default state, and `d
  508.      b' chooses default-B.  This chosen default applies to all
  509.      differences which you haven't selected and for which no
  510.      alternative is preferred. If you are moving through the merge
  511.      sequentially, the differences you haven't selected are those
  512.      following the selected one.  Thus, while moving sequentially, you
  513.      can effectively make the A version the default for some sections
  514.      of the merge buffer and the B version the default for others by
  515.      using `d a' and `d b' at the end of each section.
  516. prefer-A
  517. prefer-B
  518.      The difference is showing the A or B state because it is
  519.      "preferred".  This means that you haven't made an explicit choice,
  520.      but one alternative seems likely to be right because the other
  521.      alternative agrees with the common ancestor.  Thus, where the A
  522.      buffer agrees with the common ancestor, the B version is
  523.      preferred, because chances are it is the one that was actually
  524.      changed.
  525.      These two states are displayed in the mode line as `A*' and `B*'.
  526. combined
  527.      The difference is showing a combination of the A and B states, as a
  528.      result of the `x c' or `x C' commands.
  529.      Once a difference is in this state, the `a' and `b' commands don't
  530.      do anything to it unless you give them a prefix argument.
  531.      The mode line displays this state as `comb'.
  532. File: emacs,  Node: Merge Commands,  Next: Exiting Emerge,  Prev: State of Difference,  Up: Emerge
  533. Merge Commands
  534. --------------
  535.    Here are the Merge commands for Fast mode; in Edit mode, precede
  536. these with `C-c' and turn all the letters into control characters.
  537.      Select the previous difference.
  538.      Select the next difference.
  539.      Choose the A version of this difference.
  540.      Choose the B version of this difference.
  541.      Select a particular difference; specify the sequence number of that
  542.      difference as a prefix argument.
  543. `M-x emerge-select-difference'
  544.      Select the run of differences containing the current location. 
  545.      You can use this command in the merge buffer or in the A or B
  546.      buffer.
  547.      Quit--finish the merge.  With an argument, abort the merge.
  548.      Go into fast mode.
  549.      Go into edit mode.
  550.      Recenter (like `C-l') all three windows.
  551.      Specify part of a prefix numeric argument.
  552. `DIGIT'
  553.      Also specify part of a prefix numeric argument.
  554. `d a'
  555.      Choose the A version as the default from here down in the merge
  556.      buffer.
  557. `d b'
  558.      Choose the B version as the default from here down in the merge
  559.      buffer.
  560. `c a'
  561.      Copy the A version of this difference into the kill ring.
  562. `c b'
  563.      Copy the B version of this difference into the kill ring.
  564. `i a'
  565.      Insert the A version of this difference at the point.
  566. `i b'
  567.      Insert the B version of this difference at the point.
  568.      Put the point and mark around the difference region.
  569.      Scroll all three windows down (like `M-v').
  570.      Scroll all three windows up (like `C-v').
  571.      Scroll all three windows left (like `C-x <').
  572.      Scroll all three windows right (like `C-x >').
  573.      Reset horizontal scroll on all three windows.
  574. `x 1'
  575.      Shrink the merge window to one line.  (Use `C-u l' to restore it
  576.      to full size.)
  577. `x c'
  578.      Combine the two versions of this difference.
  579. `x f'
  580.      Show the files/buffers Emerge is operating on in Help window. (Use
  581.      `C-u l' to restore windows.)
  582. `x j'
  583.      Join this difference with the following one. (`C-u x j' joins this
  584.      difference with the previous one.)
  585. `x s'
  586.      Split this difference into two differences.  Before you use this
  587.      command, position point in each of the three buffers to the place
  588.      where you want to split the difference.
  589. `x t'
  590.      Trim identical lines off top and bottom of the difference. Such
  591.      lines occur when the A and B versions are identical but differ
  592.      from the ancestor version.
  593. File: emacs,  Node: Exiting Emerge,  Next: Combining in Emerge,  Prev: Merge Commands,  Up: Emerge
  594. Exiting Emerge
  595. --------------
  596.    The `q' (`emerge-quit') command finishes the merge, storing the
  597. results into the output file.  It restores the A and B buffers to their
  598. proper contents, or kills them if they were created by Emerge.  It also
  599. disables the Emerge commands in the merge buffer, since executing them
  600. later could damage the contents of the various buffers.
  601.    `C-u q' aborts the merge.  Aborting means that Emerge does not write
  602. the output file.
  603.    If Emerge was called from another Lisp program, then its return value
  604. is `t' or `nil' to indicate success or failure.
  605. File: emacs,  Node: Combining in Emerge,  Next: Fine Points of Emerge,  Prev: Exiting Emerge,  Up: Emerge
  606. Combining the Two Versions
  607. --------------------------
  608.    Sometimes you want to keep *both* alternatives for a particular
  609. locus.  To do this, use `x c', which edits the merge buffer like this:
  610.      #ifdef NEW
  611.      VERSION FROM A FILE
  612.      #else /* NEW */
  613.      VERSION FROM B FILE
  614.      #endif /* NEW */
  615.    While this example shows C preprocessor conditionals delimiting the
  616. two alternative versions, you can specify the strings you want by
  617. setting the variable `emerge-combine-template' to a list of three
  618. strings. The default setting, which produces the results shown above,
  619. looks like this:
  620.      ("#ifdef NEW\n"
  621.       "#else /* NEW */\n"
  622.       "#endif /* NEW */\n")
  623. File: emacs,  Node: Fine Points of Emerge,  Prev: Combining in Emerge,  Up: Emerge
  624. Fine Points of Emerge
  625. ---------------------
  626.    You can have any number of merges going at once--just don't use any
  627. one buffer as input to more than one merge at once, since that will
  628. cause the read-only/modified/auto-save status save-and-restore to screw
  629.    Starting Emerge can take a long time because it needs to compare the
  630. files.  Emacs can't do anything else until `diff' finishes.  Perhaps in
  631. the future someone will change Emerge to do the comparison in the
  632. background when the input files are large--then you could keep on doing
  633. other things with Emacs until Emerge gets ready to accept commands.
  634.    After the merge has been set up, Emerge runs the hooks in
  635. `emerge-startup-hook'.
  636.    During the merge, you musn't try to edit the A and B buffers
  637. yourself. Emerge modifies them temporarily, but ultimately puts them
  638. back the way they were.
  639. File: emacs,  Node: Debuggers,  Next: Other New Modes,  Prev: Emerge,  Up: Version 19
  640. Running Debuggers Under Emacs
  641. =============================
  642.    The GUD (Grand Unified Debugger) library provides an interface to
  643. various symbolic debuggers from within Emacs.  We recommend the
  644. debugger GDB, which is free software, but you can also run DBX or SDB
  645. if you have them.
  646. * Menu:
  647. * Starting GUD::    How to start a debugger subprocess.
  648. * Debugger Operation::    Connection between the debugger and source buffers.
  649. * Commands of GUD::    Keybindings for common commands.
  650. * GUD Customization::    Defining your own commands for GUD.
  651. File: emacs,  Node: Starting GUD,  Next: Debugger Operation,  Up: Debuggers
  652. Starting GUD
  653. ------------
  654.    There are three commands for starting a debugger.  Each corresponds
  655. to a particular debugger program.
  656. `M-x gdb RET FILE RET'
  657. `M-x dbx RET FILE RET'
  658.      Run GDB or DBX in a subprocess of Emacs.  Both of these commands
  659.      select the buffer used for input and output to the debugger.
  660. `M-x sdb RET FILE RET'
  661.      Run SDB in a subprocess of Emacs.  SDB's messages do not mention
  662.      file names, so the Emacs interface to SDB depends on having a tags
  663.      table (*note Tags::.) to find which file each function is in.  If
  664.      you have not visited a tags table or the tags table doesn't list
  665.      one of the functions, you get a message saying `The sdb support
  666.      requires a valid tags table to work'.  If this happens, generate a
  667.      valid tags table in the working directory and try again.
  668.    You can only run one debugger process at a time.
  669. File: emacs,  Node: Debugger Operation,  Next: Commands of GUD,  Prev: Starting GUD,  Up: Debuggers
  670. Debugger Operation
  671. ------------------
  672.    When you run a debugger with GUD, the debugger displays source files
  673. via Emacs--Emacs finds the source file and moves point to the line
  674. where the program is executing.  An arrow (`=>') indicates the current
  675. execution line, and it stays put even if you move the cursor.
  676.    You can start editing the file at any time.  The arrow is not part of
  677. the file's text; it appears only on the screen.  If you do modify a
  678. source file, keep in mind that inserting or deleting lines will throw
  679. off the arrow's positioning; GUD has no way of figuring out which line
  680. corresponded before your changes to the line number in a debugger
  681. message.  Also, you'll typically have to recompile and restart the
  682. program for your changes to be reflected in the debugger's tables.
  683.    If you wish, you can control your debugger process entirely through
  684. the debugger buffer, which uses a variant of Shell mode.  All the usual
  685. commands for your debugger are available, and you can use the Shell mode
  686. history commands to repeat them.
  687. File: emacs,  Node: Commands of GUD,  Next: GUD Customization,  Prev: Debugger Operation,  Up: Debuggers
  688. Commands of GUD
  689. ---------------
  690.    GUD provides a command available in all buffers for setting
  691. breakpoints.  This command is defined globally because you need to use
  692. it in the source files' buffers.
  693. `C-x SPC'
  694.      Set a breakpoint on the line that point is on.
  695.    The debugger buffer has a number of keybindings for invoking common
  696. debugging commands quickly:
  697. `C-c C-l'
  698.      Display in another window the last line referred to in the GUD
  699.      buffer (that is, the line indicated in the last location message).
  700.      This runs the command `gud-refresh'.
  701. `C-c C-s'
  702.      Execute a single line of code (`gud-step').  If the code contains
  703.      a function call, execution stops after entering the called
  704.      function.
  705. `C-c C-n'
  706.      Execute a single line of code, stepping across entire function
  707.      calls at full speed (`gud-next').
  708. `C-c C-i'
  709.      Execute a single machine instruction (`gud-stepi').
  710. `C-c C-c'
  711.      Continue execution until the next breakpoint, or other event that
  712.      would normally stop the program (`gud-cont').
  713.    The above commands are common to all supported debuggers.  If you are
  714. using GDB or (some versions of) DBX, these additional commands are
  715. available:
  716. `C-c <'
  717.      Select the next enclosing stack frame (`gud-up').  This is
  718.      equivalent to the `up' command.
  719. `C-c >'
  720.      Select the next inner stack frame (`gud-down').  This is
  721.      equivalent to the `down' command.
  722.    If you are using GDB, two additional keybindings are available:
  723. `C-c C-f'
  724.      Run the program until the selected stack frame returns (or until it
  725.      stops for some other reason).
  726. `TAB'
  727.      Complete the symbol in the buffer before point, using the set of
  728.      all symbols known to GDB.
  729.    These commands interpret a prefix argument as a repeat count, when
  730. that makes sense.
  731.    After each command that changes the program counter, GUD displays the
  732. new current source line, and updates the location of the arrow.
  733. File: emacs,  Node: GUD Customization,  Prev: Commands of GUD,  Up: Debuggers
  734. GUD Customization
  735. -----------------
  736.    On startup, GUD executes one of the following hooks:
  737. `gdb-mode-hook', if you are using GDB; `dbx-mode-hook', if you are
  738. using DBX; and `sdb-mode-hook', if you are using SDB.  You can use
  739. these hooks to define custom keybindings for the debugger interaction
  740. buffer.
  741.    Here is a convenient way to define a command that sends a particular
  742. command string to the debugger, and set up a key binding for it in the
  743. debugger interaction buffer:
  744.      (gud-def FUNCTION CMDSTRING BINDING DOCSTRING)
  745.    This defines a command named FUNCTION which sends CMDSTRING to the
  746. debugger process, with documentation string DOCSTRING, and binds it to
  747. BINDING in the debugger buffer's mode.  (If BINDING is `nil', this
  748. defines the command but does not make a binding for it; you can make a
  749. binding explicitly, perhaps using one of the above hooks.)
  750.    Commands defined with `gud-def' handle prefix arguments by passing
  751. them to the debugger, appended to end of CMDSTRING with a space in
  752. between.  (This use of prefix arguments works with GDB and DBX, but not
  753. with SDB.)
  754.    You can also set up commands that you can send to the debugger while
  755. in another buffer, such as a source file.  Set the variable
  756. `gud-commands' to a list of strings containing debugger commands you
  757. might want to send.
  758. `C-x &'
  759.      Send a custom command to the debugger process
  760.      (`send-gud-command').  Normally, send the CAR of the
  761.      `gud-commands' list; a prefix argument specifies which element of
  762.      that list to use (counting from 0).
  763.      If the string contains `%s', `C-x &' substitutes a numeric value
  764.      found in the buffer at or near point.  It looks for decimal,
  765.      octal, or hexadecimal numbers, with `0x' allowed.  This lets you
  766.      define commands to chase pointers whose numeric values have been
  767.      displayed.
  768. File: emacs,  Node: Other New Modes,  Next: Key Sequence Changes,  Prev: Debuggers,  Up: Version 19
  769. Other New Modes
  770. ===============
  771.    There is now a Perl mode for editing Perl programs and an Icon mode
  772. for editing Icon programs.
  773.    C++ mode is like C mode, except that it understands C++ comment
  774. syntax and certain other differences between C and C++.  It also has a
  775. command `fill-c++-comment' which fills a paragraph made of comment
  776. lines. The command `comment-region' is useful in C++ mode for commenting
  777. out several consecutive lines, or removing the commenting out of such
  778. lines.
  779.    WordStar emulation is available--type `M-x wordstar-mode'. For more
  780. information, type `C-h f wordstar-mode RET'.
  781.    The command `C-o' in Buffer Menu mode now displays the current
  782. line's buffer in another window but does not select it.  This is like
  783. the existing command `o' which selects the current line's buffer in
  784. another window.
  785. * Menu:
  786. * Asm Mode::        A major mode for editing assembler files.
  787. * Edebug Mode::        A new Lisp debugger.
  788. * Editing Binary Files::Hexl mode lets you edit a binary file as numbers.
  789. File: emacs,  Node: Asm Mode,  Next: Edebug Mode,  Up: Other New Modes
  790. Asm Mode
  791. --------
  792.    Asm mode is a new major mode for editing files of assembler code. It
  793. defines these commands:
  794. `TAB'
  795.      `tab-to-tab-stop'.
  796. `LFD'
  797.      Insert a newline and then indent using `tab-to-tab-stop'.
  798.      Insert a colon and then remove the indentation from before the
  799.      label preceding colon.  Then do `tab-to-tab-stop'.
  800.      Insert or align a comment.
  801. File: emacs,  Node: Edebug Mode,  Next: Editing Binary Files,  Prev: Asm Mode,  Up: Other New Modes
  802. Edebug Mode
  803. -----------
  804.    Edebug is a new source-level debugger for Emacs Lisp programs.
  805.    To use Edebug, use the command `M-x edebug-defun' to "evaluate" a
  806. function definition in an Emacs Lisp file.  We put "evaluate" in
  807. quotation marks because it doesn't just evaluate the function, it also
  808. inserts additional information to support source-level debugging.
  809.    You must also do this:
  810.      (setq debugger 'edebug-debug)
  811. to cause errors and single-stepping to use Edebug instead of the usual
  812. Emacs Lisp debugger.
  813.    For more information, see `The Emacs Extensions Manual', which
  814. should be included in the Emacs 19 distribution.
  815. File: emacs,  Node: Editing Binary Files,  Prev: Edebug Mode,  Up: Other New Modes
  816. Editing Binary Files
  817. --------------------
  818.    There is a new major mode for editing binary files: Hexl mode.  To
  819. use it, use `M-x hexl-find-file' instead of `C-x C-f' to visit the
  820. file.  This command converts the file's contents to hexadecimal and lets
  821. you edit the translation.  When you save the file, it is converted
  822. automatically back to binary.
  823.    You can also use `M-x hexl-mode' to translate an existing buffer
  824. into hex.  This is useful if you visit a file normally and discover it
  825. is a binary file.
  826.    Hexl mode has a few other commands:
  827. `C-M-d'
  828.      Insert a byte with a code typed in decimal.
  829. `C-M-o'
  830.      Insert a byte with a code typed in octal.
  831. `C-M-x'
  832.      Insert a byte with a code typed in hex.
  833. `C-x ['
  834.      Move to the beginning of a 1k-byte "page".
  835. `C-x ]'
  836.      Move to the end of a 1k-byte "page".
  837. `M-g'
  838.      Move to an address specified in hex.
  839. `M-j'
  840.      Move to an address specified in decimal.
  841. `C-c C-c'
  842.      Leave Hexl mode, going back to the major mode this buffer had
  843.      before you invoked `hexl-mode'.
  844. File: emacs,  Node: Key Sequence Changes,  Next: Hook Changes,  Prev: Other New Modes,  Up: Version 19
  845. Changes in Key Sequences
  846. ========================
  847.    In Emacs 18, a key sequence was a sequence of characters, which
  848. represented keyboard input.
  849.    In Emacs 19, you can still use a sequence of characters as a key
  850. sequence, but you aren't limited to characters.  You can also use Lisp
  851. symbols which represent terminal function keys or mouse buttons.  If the
  852. function key has a word as its label, then that word is also the name of
  853. the symbol which represents the function key.  Other function keys are
  854. assigned Lisp names as follows:
  855. `kp-add', `kp-decimal', `kp-divide', ...
  856.      Keypad keys (to the right of the regular keyboard), with names or
  857.      punctuation
  858. `kp-0', `kp-1', ...
  859.      Keypad keys with digits
  860. `kp-f1', `kp-f2', `kp-f3', `kp-f4'
  861.      Keypad PF keys
  862. `left', `up', `right', `down'
  863.      Cursor arrow keys
  864.    A key sequence which contains non-characters must be a vector rather
  865. than a string.
  866.    Thus, to bind function key `f1' to `rmail', write the following:
  867.      (global-set-key [f1] 'rmail)
  868. (To find the name of a key, type `C-h k' and then the key.)
  869.    To bind the right-arrow key to the command `forward-char', you can
  870. use this expression:
  871.      (global-set-key [right] 'forward-char)
  872. using the Lisp syntax for a vector containing the symbol `right'.
  873.    And this is how to make `C-x RIGHTARROW' move forward a page:
  874.      (global-set-key [?\C-x right] 'forward-page)
  875. where `?\C-x' is the Lisp syntax for an integer whose value is the code
  876. for the character `C-x'.
  877.    You can use modifier keys such as CTRL, META and SHIFT with function
  878. keys.  To represent these modifiers, prepend the strings `C-', `M-' and
  879. `S-' to the symbol name.  Thus, here is how to make `M-RIGHTARROW' move
  880. forward a word:
  881.      (global-set-key [M-right] 'forward-word)
  882.    Emacs uses symbols to designate mouse buttons, too. The ordinary
  883. mouse events in Emacs are "click" events; these happen when you press a
  884. button and release it without moving the mouse. You can also get "drag"
  885. events, when you move the mouse while holding the button down.  Drag
  886. events happen when you finally let go of the button.
  887.    The symbols for basic click events are `mouse-1' for the leftmost
  888. button, `mouse-2' for the next, and so on.  Here is how you can
  889. redefine the second mouse button to split the current window:
  890.      (global-set-key [mouse-2] 'split-window-vertically)
  891.    The symbols for drag events are similar, but have the prefix `drag-'
  892. before the word `mouse'.  For example, dragging the left button
  893. generates a `drag-mouse-1' event.
  894.    You can also request events when the mouse button is pressed down.
  895. These events start with `down-' instead of `drag-'.  Such events are
  896. generated only if they have key bindings.  When you get a button-down
  897. event, a corresponding click or drag event will always follow.
  898.    The symbols for mouse events also indicate the status of the modifier
  899. keys, with the usual prefixes `C-', `M-' and `S-'. These always follow
  900. `drag-' or `down-'.
  901.    When mouse events occur in special parts of a frame or window, such
  902. as a mode line or a scroll bar, the event symbol shows nothing special.
  903.  The information about the special part is implicit in other data (the
  904. screen location of the event).  But `read-key-sequence' figures out this
  905. aspect of the event, and encodes it with make-believe prefix keys, all
  906. of which are symbols: `mode-line', `vertical-line',
  907. `horizontal-scrollbar' and `vertical-scrollbar'.  Thus, to define the
  908. command for clicking the left button in a mode line, you could use this
  909. key sequence:
  910.      [mode-line mouse-1]
  911.    You are not limited to defining individual function keys or mouse
  912. buttons; these can appear anywhere in a key sequence, just as characters
  913. can.  You can even mix together all three kinds of inputs in one key
  914. sequence--but mixing mouse buttons with keyboard inputs is probably not
  915. convenient for actual use.
  916. File: emacs,  Node: Hook Changes,  Prev: Key Sequence Changes,  Up: Version 19
  917. Changes Regarding Hooks
  918. =======================
  919.    A "hook variable" is a variable that exists so that you can store in
  920. it functions for Emacs to call on certain occasions.  (The functions
  921. that you put in hook variables are called "hook functions".)  Emacs 19
  922. has a new convention for naming hook variables that indicates more
  923. reliably how to use them.
  924.    All the variables whose names end in `-hook' are "normal hooks";
  925. their values are lists of functions to be called with no arguments. 
  926. You can use `add-hook' (see below) to install hook functions in these
  927. hooks.  We have made all Emacs hooks into normal hooks except when
  928. there is some reason this won't work.
  929.    A few hook-like variables are "abnormal"--they don't use the normal
  930. convention.  This is either because the user-supplied functions receive
  931. arguments, or because their return values matter.  These variables have
  932. names that end in `-function' (if the value is a single function) or
  933. `-functions' (if the value is a list of functions).
  934.    Thus, you can always tell from the variable's name precisely how to
  935. install a new hook function in the variable.  If the name indicates a
  936. normal hook, then you also know how to write your hook function.
  937.    To add a hook function to a normal hook, use `add-hook'.  It takes
  938. care of adding a new hook function to any functions already installed in
  939. a given hook.  It takes two arguments, the hook symbol and the function
  940. to add.  For example,
  941.      (add-hook 'text-mode-hook 'my-text-hook-function)
  942. is how to arrange to call `my-text-hook-function' when entering Text
  943. mode or related modes. Two new hooks are worth noting here.  Expansion
  944. of an abbrev first runs the hook `pre-abbrev-expand-hook'.
  945. `kill-buffer-hook' now runs whenever a buffer is killed.
  946.