home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-19.28-src.tgz / tar.out / fsf / emacs / info / emacs-11 (.txt) < prev    next >
GNU Info File  |  1996-09-28  |  49KB  |  911 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Overview of Emerge,  Next: Submodes of Emerge,  Up: Emerge
  4. Overview of Emerge
  5. ------------------
  6.    To start Emerge, run one of these four commands:
  7. `M-x emerge-files'
  8.      Merge two specified files.
  9. `M-x emerge-files-with-ancestor'
  10.      Merge two specified files, with reference to a common ancestor.
  11. `M-x emerge-buffers'
  12.      Merge two buffers.
  13. `M-x emerge-buffers-with-ancestor'
  14.      Merge two buffers with reference to a common ancestor in a third
  15.      buffer.
  16.    The Emerge commands compare two files or buffers, and display the
  17. comparison in three buffers: one for each input text (the "A buffer"
  18. and the "B buffer"), and one (the "merge buffer") where merging takes
  19. place.  The merge buffer shows the full merged text, not just the
  20. differences.  Wherever the two input texts differ, you can choose which
  21. one of them to include in the merge buffer.
  22.    The Emerge commands that take input from existing buffers use only
  23. the accessible portions of those buffers, if they are narrowed (*note
  24. Narrowing::.).
  25.    If a common ancestor version is available, from which the two texts
  26. to be merged were both derived, Emerge can use it to guess which
  27. alternative is right.  Wherever one current version agrees with the
  28. ancestor, Emerge presumes that the other current version is a deliberate
  29. change which should be kept in the merged version.  Use the
  30. `with-ancestor' commands if you want to specify a common ancestor text.
  31. These commands read three file or buffer names--variant A, variant B,
  32. and the common ancestor.
  33.    After the comparison is done and the buffers are prepared, the
  34. interactive merging starts.  You control the merging by typing special
  35. "merge commands" in the merge buffer.  The merge buffer shows you a
  36. full merged text, not just differences.  For each run of differences
  37. between the input texts, you can choose which one of them to keep, or
  38. edit them both together.
  39.    The merge buffer uses a special major mode, Emerge mode, with
  40. commands for making these choices.  But you can also edit the buffer
  41. with ordinary Emacs commands.
  42.    At any given time, the attention of Emerge is focused on one
  43. particular difference, called the "selected" difference.  This
  44. difference is marked off in the three buffers like this:
  45.      vvvvvvvvvvvvvvvvvvvv
  46.      TEXT THAT DIFFERS
  47.      ^^^^^^^^^^^^^^^^^^^^
  48. Emerge numbers all the differences sequentially and the mode line
  49. always shows the number of the selected difference.
  50.    Normally, the merge buffer starts out with the A version of the text.
  51. But when the A version of a difference agrees with the common ancestor,
  52. then the B version is initially preferred for that difference.
  53.    Emerge leaves the merged text in the merge buffer when you exit.  At
  54. that point, you can save it in a file with `C-x C-w'.  If you give a
  55. numeric argument to `emerge-files' or `emerge-files-with-ancestor', it
  56. reads the name of the output file using the minibuffer.  (This is the
  57. last file name those commands read.) Then exiting from Emerge saves the
  58. merged text in the output file.
  59.    Normally, Emerge commands save the output buffer in its file when you
  60. exit.  If you abort Emerge with `C-]', the Emerge command does not save
  61. the output buffer, but you can save it yourself if you wish.
  62. File: emacs,  Node: Submodes of Emerge,  Next: State of Difference,  Prev: Overview of Emerge,  Up: Emerge
  63. Submodes of Emerge
  64. ------------------
  65.    You can choose between two modes for giving merge commands: Fast mode
  66. and Edit mode.  In Fast mode, basic merge commands are single
  67. characters, but ordinary Emacs commands are disabled.  This is
  68. convenient if you use only merge commands.  In Edit mode, all merge
  69. commands start with the prefix key `C-c C-c', and the normal Emacs
  70. commands are also available.  This allows editing the merge buffer, but
  71. slows down Emerge operations.
  72.    Use `e' to switch to Edit mode, and `C-c C-c f' to switch to Fast
  73. mode.  The mode line indicates Edit and Fast modes with `E' and `F'.
  74.    Emerge has two additional submodes that affect how particular merge
  75. commands work: Auto Advance mode and Skip Prefers mode.
  76.    If Auto Advance mode is in effect, the `a' and `b' commands advance
  77. to the next difference.  This lets you go through the merge faster as
  78. long as you simply choose one of the alternatives from the input.  The
  79. mode line indicates Auto Advance mode with `A'.
  80.    If Skip Prefers mode is in effect, the `n' and `p' commands skip
  81. over differences in states prefer-A and prefer-B (*note State of
  82. Difference::.).  Thus you see only differences for which neither version
  83. is presumed "correct".  The mode line indicates Skip Prefers mode with
  84.    Use the command `s a' (`emerge-auto-advance-mode') to set or clear
  85. Auto Advance mode.  Use `s s' (`emerge-skip-prefers-mode') to set or
  86. clear Skip Prefers mode.  These commands turn on the mode with a
  87. positive argument, turns it off with a negative or zero argument, and
  88. toggle the mode with no argument.
  89. File: emacs,  Node: State of Difference,  Next: Merge Commands,  Prev: Submodes of Emerge,  Up: Emerge
  90. State of a Difference
  91. ---------------------
  92.    In the merge buffer, a difference is marked with lines of `v' and
  93. `^' characters.  Each difference has one of these seven states:
  94.      The difference is showing the A version.  The `a' command always
  95.      produces this state; the mode line indicates it with `A'.
  96.      The difference is showing the B version.  The `b' command always
  97.      produces this state; the mode line indicates it with `B'.
  98. default-A
  99. default-B
  100.      The difference is showing the A or the B state by default, because
  101.      you haven't made a choice.  All differences start in the default-A
  102.      state (and thus the merge buffer is a copy of the A buffer),
  103.      except those for which one alternative is "preferred" (see below).
  104.      When you select a difference, its state changes from default-A or
  105.      default-B to plain A or B.  Thus, the selected difference never has
  106.      state default-A or default-B, and these states are never displayed
  107.      in the mode line.
  108.      The command `d a' chooses default-A as the default state, and `d
  109.      b' chooses default-B.  This chosen default applies to all
  110.      differences which you haven't ever selected and for which no
  111.      alternative is preferred.  If you are moving through the merge
  112.      sequentially, the differences you haven't selected are those
  113.      following the selected one.  Thus, while moving sequentially, you
  114.      can effectively make the A version the default for some sections
  115.      of the merge buffer and the B version the default for others by
  116.      using `d a' and `d b' between sections.
  117. prefer-A
  118. prefer-B
  119.      The difference is showing the A or B state because it is
  120.      "preferred".  This means that you haven't made an explicit choice,
  121.      but one alternative seems likely to be right because the other
  122.      alternative agrees with the common ancestor.  Thus, where the A
  123.      buffer agrees with the common ancestor, the B version is
  124.      preferred, because chances are it is the one that was actually
  125.      changed.
  126.      These two states are displayed in the mode line as `A*' and `B*'.
  127. combined
  128.      The difference is showing a combination of the A and B states, as a
  129.      result of the `x c' or `x C' commands.
  130.      Once a difference is in this state, the `a' and `b' commands don't
  131.      do anything to it unless you give them a numeric argument.
  132.      The mode line displays this state as `comb'.
  133. File: emacs,  Node: Merge Commands,  Next: Exiting Emerge,  Prev: State of Difference,  Up: Emerge
  134. Merge Commands
  135. --------------
  136.    Here are the Merge commands for Fast mode; in Edit mode, precede them
  137. with `C-c C-c':
  138.      Select the previous difference.
  139.      Select the next difference.
  140.      Choose the A version of this difference.
  141.      Choose the B version of this difference.
  142. `C-u N j'
  143.      Select difference number N.
  144.      Select the difference containing point.  You can use this command
  145.      in the merge buffer or in the A or B buffer.
  146.      Quit--finish the merge.
  147. `C-]'
  148.      Abort--exit merging and do not save the output.
  149.      Go into Fast mode.  (In Edit mode, this is actually `C-c C-c f'.)
  150.      Go into Edit mode.
  151.      Recenter (like `C-l') all three windows.
  152.      Specify part of a prefix numeric argument.
  153. `DIGIT'
  154.      Also specify part of a prefix numeric argument.
  155. `d a'
  156.      Choose the A version as the default from here down in the merge
  157.      buffer.
  158. `d b'
  159.      Choose the B version as the default from here down in the merge
  160.      buffer.
  161. `c a'
  162.      Copy the A version of this difference into the kill ring.
  163. `c b'
  164.      Copy the B version of this difference into the kill ring.
  165. `i a'
  166.      Insert the A version of this difference at point.
  167. `i b'
  168.      Insert the B version of this difference at point.
  169.      Put point and mark around the difference.
  170.      Scroll all three windows down (like `M-v').
  171.      Scroll all three windows up (like `C-v').
  172.      Scroll all three windows left (like `C-x <').
  173.      Scroll all three windows right (like `C-x >').
  174.      Reset horizontal scroll on all three windows.
  175. `x 1'
  176.      Shrink the merge window to one line.  (Use `C-u l' to restore it
  177.      to full size.)
  178. `x c'
  179.      Combine the two versions of this difference (*note Combining in
  180.      Emerge::.).
  181. `x f'
  182.      Show the names of the files/buffers Emerge is operating on, in a
  183.      Help window.  (Use `C-u l' to restore windows.)
  184. `x j'
  185.      Join this difference with the following one.  (`C-u x j' joins
  186.      this difference with the previous one.)
  187. `x s'
  188.      Split this difference into two differences.  Before you use this
  189.      command, position point in each of the three buffers at the place
  190.      where you want to split the difference.
  191. `x t'
  192.      Trim identical lines off top and bottom of the difference.  Such
  193.      lines occur when the A and B versions are identical but differ
  194.      from the ancestor version.
  195. File: emacs,  Node: Exiting Emerge,  Next: Combining in Emerge,  Prev: Merge Commands,  Up: Emerge
  196. Exiting Emerge
  197. --------------
  198.    The `q' command (`emerge-quit') finishes the merge, storing the
  199. results into the output file if you specified one.  It restores the A
  200. and B buffers to their proper contents, or kills them if they were
  201. created by Emerge and you haven't changed them.  It also disables the
  202. Emerge commands in the merge buffer, since executing them later could
  203. damage the contents of the various buffers.
  204.    `C-]' aborts the merge.  This means exiting without writing the
  205. output file.  If you didn't specify an output file, then there is no
  206. real difference between aborting and finishing the merge.
  207.    If the Emerge command was called from another Lisp program, then its
  208. return value is `t' for successful completion, or `nil' if you abort.
  209. File: emacs,  Node: Combining in Emerge,  Next: Fine Points of Emerge,  Prev: Exiting Emerge,  Up: Emerge
  210. Combining the Two Versions
  211. --------------------------
  212.    Sometimes you want to keep *both* alternatives for a particular
  213. difference.  To do this, use `x c', which edits the merge buffer like
  214. this:
  215.      #ifdef NEW
  216.      VERSION FROM A BUFFER
  217.      #else /* NEW */
  218.      VERSION FROM B BUFFER
  219.      #endif /* NEW */
  220. While this example shows C preprocessor conditionals delimiting the two
  221. alternative versions, you can specify the strings to use by setting the
  222. variable `emerge-combine-versions-template' to a string of your choice.
  223. In the string, `%a' says where to put version A, and `%b' says where
  224. to put version B.  The default setting, which produces the results
  225. shown above, looks like this:
  226.      "#ifdef NEW\n%a#else /* NEW */\n%b#endif /* NEW */\n"
  227. File: emacs,  Node: Fine Points of Emerge,  Prev: Combining in Emerge,  Up: Emerge
  228. Fine Points of Emerge
  229. ---------------------
  230.    During the merge, you mustn't try to edit the A and B buffers
  231. yourself.  Emerge modifies them temporarily, but ultimately puts them
  232. back the way they were.
  233.    You can have any number of merges going at once--just don't use any
  234. one buffer as input to more than one merge at once, since the temporary
  235. changes made in these buffers would get in each other's way.
  236.    Starting Emerge can take a long time because it needs to compare the
  237. files fully.  Emacs can't do anything else until `diff' finishes.
  238. Perhaps in the future someone will change Emerge to do the comparison in
  239. the background when the input files are large--then you could keep on
  240. doing other things with Emacs until Emerge gets ready to accept
  241. commands.
  242.    After setting up the merge, Emerge runs the hook
  243. `emerge-startup-hook' (*note Hooks::.).
  244. File: emacs,  Node: C Mode,  Next: Fortran,  Prev: Emerge,  Up: Programs
  245. C Mode
  246. ======
  247.    In addition to the facilities of typical programming language major
  248. modes (*note Program Modes::.), C mode has various special facilities.
  249. `M-a'
  250. `M-e'
  251.      In C mode, `M-a' and `M-e' move by complete C statements
  252.      (`c-beginning-of-statement' and `c-end-of-statement').  These
  253.      commands do ordinary, textual sentence motion when in or next to a
  254.      comment.
  255. `M-q'
  256.      `M-q' in C mode runs `c-fill-paragraph', which is designed for
  257.      filling C comments.  (We assume you don't want to fill the actual
  258.      C code in a C program.)
  259. `C-c C-u'
  260.      Move back to the containing preprocessor conditional, setting the
  261.      mark at the starting point (`c-up-conditional').
  262.      A numeric argument acts as a repeat count.  With a negative
  263.      argument, this command moves forward to the end of the containing
  264.      preprocessor conditional.  When going backwards, `#elif' acts like
  265.      `#else' followed by `#if'.  When going forwards, `#elif' is
  266.      ignored.
  267. `C-c C-n'
  268.      Move forward across the next preprocessor conditional, setting the
  269.      mark at the starting point (`c-forward-conditional').
  270. `C-c C-p'
  271.      Move backward across the previous preprocessor conditional,
  272.      setting the at the starting point (`c-backward-conditional').
  273. `M-x c-macro-expand'
  274.      When you are debugging C code that uses macros, sometimes it is
  275.      hard to figure out precisely how the macros expand.  The command
  276.      `M-x c-macro-expand' runs the C preprocessor and shows you what
  277.      expansion results from the region.  The portion of the buffer
  278.      before the region is also included in preprocessing, for the sake
  279.      of macros defined there, but the output from this part isn't shown.
  280. `M-x c-backslash-region'
  281.      Insert or align `\' characters at the ends of the lines of the
  282.      region, except for the last such line.  This is useful after
  283.      writing or editing a C macro definition.
  284.      If a line already ends in `\', this command adjusts the amount of
  285.      whitespace before it.  Otherwise, it inserts a new `\'.
  286.    C++ mode is like C mode, except that it understands C++ comment
  287. syntax and certain other differences between C and C++.  It also has a
  288. command `M-x fill-c++-comment', which fills a paragraph made of C++
  289. comment lines.
  290.    The command `comment-region' is useful in C++ mode for commenting
  291. out several consecutive lines, or removing the commenting out of such
  292. lines.  (You don't need this command with C comment syntax because you
  293. don't need to put comment delimiters on each line.)  *Note Comments::.
  294. File: emacs,  Node: Fortran,  Next: Asm Mode,  Prev: C Mode,  Up: Programs
  295. Fortran Mode
  296. ============
  297.    Fortran mode provides special motion commands for Fortran statements
  298. and subprograms, and indentation commands that understand Fortran
  299. conventions of nesting, line numbers and continuation statements.
  300. Fortran mode has it's own Auto Fill mode that breaks long lines into
  301. proper Fortran continuation lines.
  302.    Special commands for comments are provided because Fortran comments
  303. are unlike those of other languages.  Built-in abbrevs optionally save
  304. typing when you insert Fortran keywords.
  305.    Use `M-x fortran-mode' to switch to this major mode.  This command
  306. runs the hook `fortran-mode-hook' (*note Hooks::.).
  307. * Menu:
  308. * Motion: Fortran Motion.     Moving point by statements or subprograms.
  309. * Indent: Fortran Indent.     Indentation commands for Fortran.
  310. * Comments: Fortran Comments.     Inserting and aligning comments.
  311. * Autofill: Fortran Autofill.     Auto fill minor mode for Fortran.
  312. * Columns: Fortran Columns.     Measuring columns for valid Fortran.
  313. * Abbrev: Fortran Abbrev.     Built-in abbrevs for Fortran keywords.
  314.    Fortran mode was contributed by Michael Prange.  It has been updated
  315. by Stephen A. Wood who has collated the contributions and suggestions
  316. of many users.
  317. File: emacs,  Node: Fortran Motion,  Next: Fortran Indent,  Up: Fortran
  318. Motion Commands
  319. ---------------
  320.    Fortran mode provides special commands to move by subprograms
  321. (functions and subroutines) and by statements.  There is also a command
  322. to put the region around one subprogram, convenient for killing it or
  323. moving it.
  324. `C-M-a'
  325.      Move to beginning of subprogram
  326.      (`beginning-of-fortran-subprogram').
  327. `C-M-e'
  328.      Move to end of subprogram (`end-of-fortran-subprogram').
  329. `C-M-h'
  330.      Put point at beginning of subprogram and mark at end
  331.      (`mark-fortran-subprogram').
  332. `C-c C-n'
  333.      Move to beginning of current or next statement
  334.      (`fortran-next-statement').
  335. `C-c C-p'
  336.      Move to beginning of current or previous statement
  337.      (`fortran-previous-statement').
  338. File: emacs,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
  339. Fortran Indentation
  340. -------------------
  341.    Special commands and features are needed for indenting Fortran code
  342. in order to make sure various syntactic entities (line numbers, comment
  343. line indicators and continuation line flags) appear in the columns that
  344. are required for standard Fortran.
  345. * Menu:
  346. * Commands: ForIndent Commands.  Commands for indenting Fortran.
  347. * Contline: ForIndent Cont.      How continuation lines indent.
  348. * Numbers:  ForIndent Num.       How line numbers auto-indent.
  349. * Conv:     ForIndent Conv.      Conventions you must obey to avoid trouble.
  350. * Vars:     ForIndent Vars.      Variables controlling Fortran indent style.
  351. File: emacs,  Node: ForIndent Commands,  Next: ForIndent Cont,  Up: Fortran Indent
  352. Fortran Indentation Commands
  353. ............................
  354. `TAB'
  355.      Indent the current line (`fortran-indent-line').
  356. `LFD'
  357.      Indent the current and start a new indented line
  358.      (`fortran-indent-new-line').
  359. `M-LFD'
  360.      Break the current line and set up a continuation line.
  361. `C-M-q'
  362.      Indent all the lines of the subprogram point is in
  363.      (`fortran-indent-subprogram').
  364.    Fortran mode redefines TAB to reindent the current line for Fortran
  365. (`fortran-indent-line').  This command indents Line numbers and
  366. continuation markers to their required columns, and independently
  367. indents the body of the statement based on its nesting in the program.
  368.    The key `LFD' runs the command `fortran-indent-new-line', which
  369. reindents the current line then makes and indents a new line.  This
  370. command is useful to reindent the closing statement of `do' loops and
  371. other blocks before starting a new line.
  372.    The key `C-M-q' runs `fortran-indent-subprogram', a command to
  373. reindent all the lines of the Fortran subprogram (function or
  374. subroutine) containing point.
  375.    The key `M-LFD' runs `fortran-split-line', which splits a line in
  376. the appropriate fashion for Fortran.  In a non-comment line, the second
  377. half becomes a continuation line and is indented accordingly.  In a
  378. comment line, both halves become separate comment lines.
  379. File: emacs,  Node: ForIndent Cont,  Next: ForIndent Num,  Prev: ForIndent Commands,  Up: Fortran Indent
  380. Continuation Lines
  381. ..................
  382.    Most modern Fortran compilers allow two ways of writing continuation
  383. lines.  If the first non-space character on a line is in column 5, then
  384. that line is a continuation of the previous line.  We call this "fixed
  385. format".  (In GNU Emacs we always count columns from 0.)  The variable
  386. `fortran-continuation-string' specifies what character to put on column
  387. 5.  A line that starts with a tab character followed by any digit
  388. except `0' is also a continuation line.  We call this style of
  389. continuation "tab format".
  390.    Fortran mode can make either style of continuation line, but you
  391. must specify which one you prefer.  The value of the variable
  392. `indent-tabs-mode' controls the choice: `nil' for fixed format, and
  393. non-`nil' for tab format.  You can tell which style is presently in
  394. effect by the presence or absence of the string `Tab' in the mode line.
  395.    If the text on a line starts with the conventional Fortran
  396. continuation marker `$', or if it begins with any non-whitespace
  397. character in column 5, Fortran mode treats it as a continuation line.
  398. When you indent a continuation line with TAB, it converts the line to
  399. the current continuation style.  When you split a Fortran statement
  400. with `M-LFD', the continuation marker on the newline is created
  401. according to the continuation style.
  402.    The setting of continuation style affects several other aspects of
  403. editing in Fortran mode.  In fixed format mode, the minimum column
  404. number for the body of a statement is 6.  Lines inside of Fortran
  405. blocks that are indented to larger column numbers always use only the
  406. space character for whitespace.  In tab format mode, the minimum column
  407. number for the statement body is 8, and the whitespace before column 8
  408. must always consist of one tab character.
  409.    When you enter Fortran mode for an existing file, it tries to deduce
  410. the proper continuation style automatically from the file contents.
  411. The first line that begins with either a tab character or six spaces
  412. determines the choice.  The variable `fortran-analyze-depth' specifies
  413. how many lines to consider (at the beginning of the file); if none of
  414. those lines indicates a style, then the variable
  415. `fortran-tab-mode-default' specifies the style.  If it is `nil', that
  416. specifies fixed format, and non-`nil' specifies tab format.
  417. File: emacs,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Cont,  Up: Fortran Indent
  418. Line Numbers
  419. ............
  420.    If a number is the first non-whitespace in the line, Fortran
  421. indentation assumes it is a line number and moves it to columns 0
  422. through 4.  (Columns always count from 0 in GNU Emacs.)
  423.    Line numbers of four digits or less are normally indented one space.
  424. The variable `fortran-line-number-indent' controls this; it specifies
  425. the maximum indentation a line number can have.  Line numbers are
  426. indented to right-justify them to end in column 4 unless that would
  427. require more than this maximum indentation.  The default value of the
  428. variable is 1.
  429.    Simply inserting a line number is enough to indent it according to
  430. these rules.  As each digit is inserted, the indentation is recomputed.
  431. To turn off this feature, set the variable
  432. `fortran-electric-line-number' to `nil'.  Then inserting line numbers
  433. is like inserting anything else.
  434. File: emacs,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
  435. Syntactic Conventions
  436. .....................
  437.    Fortran mode assumes that you follow certain conventions that
  438. simplify the task of understanding a Fortran program well enough to
  439. indent it properly:
  440.    * Two nested `do' loops never share a `continue' statement.
  441.    * Fortran keywords such as `if', `else', `then', `do' and others are
  442.      written without embedded whitespace or line breaks.
  443.      Fortran compilers generally ignore whitespace outside of string
  444.      constants, but Fortran mode does not recognize these keywords if
  445.      they are not contiguous.  Constructs such as `else if' or `end do'
  446.      are acceptable, but the second word should be on the same line as
  447.      the first and not on a continuation line.
  448. If you fail to follow these conventions, the indentation commands may
  449. indent some lines unaesthetically.  However, a correct Fortran program
  450. retains its meaning when reindented even if the conventions are not
  451. followed.
  452. File: emacs,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
  453. Variables for Fortran Indentation
  454. .................................
  455.    Several additional variables control how Fortran indentation works:
  456. `fortran-do-indent'
  457.      Extra indentation within each level of `do' statement (default 3).
  458. `fortran-if-indent'
  459.      Extra indentation within each level of `if' statement (default 3).
  460.      This value is also used for extra indentation within each level of
  461.      the Fortran 90 `where' statement.
  462. `fortran-structure-indent'
  463.      Extra indentation within each level of `structure', `union', or
  464.      `map' statements (default 3).
  465. `fortran-continuation-indent'
  466.      Extra indentation for bodies of continuation lines (default 5).
  467. `fortran-check-all-num-for-matching-do'
  468.      If this is `nil', indentation assumes that each `do' statement
  469.      ends on a `continue' statement.  Therefore, when computing
  470.      indentation for a statement other than `continue', it can save time
  471.      by not checking for a `do' statement ending there.  If this is
  472.      non-`nil', indenting any numbered statement must check for a `do'
  473.      that ends there.  The default is `nil'.
  474. `fortran-blink-matching-if'
  475.      If this is `t', indenting an `endif' statement moves the cursor
  476.      momentarily to the matching `if' statement to show where it is.
  477.      The default is `nil'.
  478. `fortran-minimum-statement-indent-fixed'
  479.      Minimum indentation for fortran statements when using fixed format
  480.      continuation line style.  Statement bodies are never indented less
  481.      than this much.  The default is 6.
  482. `fortran-minimum-statement-indent-tab'
  483.      Minimum indentation for fortran statements for tab format
  484.      continuation line style.  Statement bodies are never indented less
  485.      than this much.  The default is 8.
  486. File: emacs,  Node: Fortran Comments,  Next: Fortran Autofill,  Prev: Fortran Indent,  Up: Fortran
  487. Fortran Comments
  488. ----------------
  489.    The usual Emacs comment commands assume that a comment can follow a
  490. line of code.  In Fortran, the standard comment syntax requires an
  491. entire line to be just a comment.  Therefore, Fortran mode replaces the
  492. standard Emacs comment commands and defines some new variables.
  493.    Fortran mode can also handle a nonstandard comment syntax where
  494. comments start with `!' and can follow other text.  Because only some
  495. Fortran compilers accept this syntax, Fortran mode will not insert such
  496. comments unless you have said in advance to do so.  To do this, set the
  497. variable `comment-start' to `"!"' (*note Variables::.).
  498. `M-;'
  499.      Align comment or insert new comment (`fortran-comment-indent').
  500. `C-x ;'
  501.      Applies to nonstandard `!' comments only.
  502. `C-c ;'
  503.      Turn all lines of the region into comments, or (with argument)
  504.      turn them back into real code (`fortran-comment-region').
  505.    `M-;' in Fortran mode is redefined as the command
  506. `fortran-comment-indent'.  Like the usual `M-;' command, this
  507. recognizes any kind of existing comment and aligns its text
  508. appropriately; if there is no existing comment, a comment is inserted
  509. and aligned.  But inserting and aligning comments are not the same in
  510. Fortran mode as in other modes.
  511.    When a new comment must be inserted, if the current line is blank, a
  512. full-line comment is inserted.  On a non-blank line, a nonstandard `!'
  513. comment is inserted if you have said you want to use them.  Otherwise a
  514. full-line comment is inserted on a new line before the current line.
  515.    Nonstandard `!' comments are aligned like comments in other
  516. languages, but full-line comments are different.  In a standard
  517. full-line comment, the comment delimiter itself must always appear in
  518. column zero.  What can be aligned is the text within the comment.  You
  519. can choose from three styles of alignment by setting the variable
  520. `fortran-comment-indent-style' to one of these values:
  521. `fixed'
  522.      Align the text at a fixed column, which is the sum of
  523.      `fortran-comment-line-extra-indent' and the minimum statement
  524.      indentation.  This is the default.
  525.      The minimum statement indentation is
  526.      `fortran-minimum-statement-indent-fixed' for fixed format
  527.      continuation line style and `fortran-minimum-statement-indent-tab'
  528.      for tab format style.
  529. `relative'
  530.      Align the text as if it were a line of code, but with an additional
  531.      `fortran-comment-line-extra-indent' columns of indentation.
  532. `nil'
  533.      Don't move text in full-line columns automatically at all.
  534.    In addition, you can specify the character to be used to indent
  535. within full-line comments by setting the variable
  536. `fortran-comment-indent-char' to the single-character string you want
  537. to use.
  538.    Fortran mode introduces two variables `comment-line-start' and
  539. `comment-line-start-skip' which play for full-line comments the same
  540. roles played by `comment-start' and `comment-start-skip' for ordinary
  541. text-following comments.  Normally these are set properly by Fortran
  542. mode so you do not need to change them.
  543.    The normal Emacs comment command `C-x ;' has not been redefined.  If
  544. you use `!' comments, this command can be used with them.  Otherwise it
  545. is useless in Fortran mode.
  546.    The command `C-c ;' (`fortran-comment-region') turns all the lines
  547. of the region into comments by inserting the string `C$$$' at the front
  548. of each one.  With a numeric argument, it turns the region back into
  549. live code by deleting `C$$$' from the front of each line in it.  The
  550. string used for these comments can be controlled by setting the
  551. variable `fortran-comment-region'.  Note that here we have an example
  552. of a command and a variable with the same name; these two uses of the
  553. name never conflict because in Lisp and in Emacs it is always clear
  554. from the context which one is meant.
  555. File: emacs,  Node: Fortran Autofill,  Next: Fortran Columns,  Prev: Fortran Comments,  Up: Fortran
  556. Fortran Auto Fill Mode
  557. ----------------------
  558.    Fortran Auto Fill mode is a minor mode which automatically splits
  559. Fortran statements as you insert them when they become too wide.
  560. Splitting a statement involves making continuation lines using
  561. `fortran-continuation-string' (*Note ForIndent Cont::).  This splitting
  562. happens when you type SPC, RET, or TAB, and also in the Fortran
  563. indentation commands.
  564.    `M-x fortran-auto-fill-mode' turns Fortran Auto Fill mode on if it
  565. was off, or off if it was on.  This command works the same as `M-x
  566. auto-fill-mode' does for normal Auto Fill mode (*note Filling::.).  A
  567. positive numeric argument turns Fortran Auto Fill mode on, and a
  568. negative argument turns it off.  You can see when Fortran Auto Fill mode
  569. is in effect by the presence of the word `Fill' in the mode line,
  570. inside the parentheses.  Fortran Auto Fill mode is a minor mode, turned
  571. on or off for each buffer individually.  *Note Minor Modes::.
  572.    Fortran Auto Fill mode breaks lines at spaces or delimiters when the
  573. lines get longer than the desired width (the value of `fill-column').
  574. The delimiters that Fortran Auto Fill mode may break at are `,', `'',
  575. `+', `-', `/', `*', `=', and `)'.  The line break comes after the
  576. delimiter if the variable `fortran-break-before-delimiters' is `nil'.
  577. Otherwise (and by default), the break comes before the delimiter.
  578.    By default, Fortran Auto Fill mode is not enabled.  If you want this
  579. feature turned on permanently, add a hook function to
  580. `fortran-mode-hook' to execute `(fortran-auto-fill-mode 1)'.  *Note
  581. Hooks::.
  582. File: emacs,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Autofill,  Up: Fortran
  583. Checking Columns in Fortran
  584. ---------------------------
  585. `C-c C-r'
  586.      Display a "column ruler" momentarily above the current line
  587.      (`fortran-column-ruler').
  588. `C-c C-w'
  589.      Split the current window horizontally temporarily so that it is 72
  590.      columns wide.  This may help you avoid making lines longer than
  591.      the 72 character limit that some fortran compilers impose
  592.      (`fortran-window-create-momentarily').
  593.    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
  594. momentarily above the current line.  The comment ruler is two lines of
  595. text that show you the locations of columns with special significance in
  596. Fortran programs.  Square brackets show the limits of the columns for
  597. line numbers, and curly brackets show the limits of the columns for the
  598. statement body.  Column numbers appear above them.
  599.    Note that the column numbers count from zero, as always in GNU Emacs.
  600. As a result, the numbers may be one less than those you are familiar
  601. with; but the positions they indicate in the line are standard for
  602. Fortran.
  603.    The text used to display the column ruler depends on the value of
  604. the variable `indent-tabs-mode'.  If `indent-tabs-mode' is `nil', then
  605. the value of the variable `fortran-column-ruler-fixed' is used as the
  606. column ruler.  Otherwise, the variable `fortran-column-ruler-tab' is
  607. displayed.  By changing these variables, you can change the column
  608. ruler display.
  609.    For even more help, use `C-c C-w' (`fortran-window-create'), a
  610. command which splits the current window horizontally, making a window 72
  611. columns wide.  By editing in this window you can immediately see when
  612. you make a line too wide to be correct Fortran.
  613. File: emacs,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
  614. Fortran Keyword Abbrevs
  615. -----------------------
  616.    Fortran mode provides many built-in abbrevs for common keywords and
  617. declarations.  These are the same sort of abbrev that you can define
  618. yourself.  To use them, you must turn on Abbrev mode.  *Note Abbrevs::.
  619.    The built-in abbrevs are unusual in one way: they all start with a
  620. semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
  621. mode makes this possible by changing the syntax of semicolon to "word
  622. constituent."
  623.    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
  624. you insert `;c' and then insert a punctuation character such as a space
  625. or a newline, the `;c' expands automatically to `continue', provided
  626. Abbrev mode is enabled.
  627.    Type `;?' or `;C-h' to display a list of all the built-in Fortran
  628. abbrevs and what they stand for.
  629. File: emacs,  Node: Asm Mode,  Prev: Fortran,  Up: Programs
  630. Asm Mode
  631. ========
  632.    Asm mode is a major mode for editing files of assembler code.  It
  633. defines these commands:
  634. `TAB'
  635.      `tab-to-tab-stop'.
  636. `LFD'
  637.      Insert a newline and then indent using `tab-to-tab-stop'.
  638.      Insert a colon and then remove the indentation from before the
  639.      label preceding colon.  Then do `tab-to-tab-stop'.
  640.      Insert or align a comment.
  641.    The variable `asm-comment-char' specifies which character starts
  642. comments in assembler syntax.
  643. File: emacs,  Node: Building,  Next: Abbrevs,  Prev: Programs,  Up: Top
  644. Compiling and Testing Programs
  645. ******************************
  646.    The previous chapter discusses the Emacs commands that are useful for
  647. making changes in programs.  This chapter deals with commands that
  648. assist in the larger process of developing and maintaining programs.
  649. * Menu:
  650. * Compilation::                   Compiling programs in languages other
  651.                                     than Lisp (C, Pascal, etc.)
  652. * Debuggers::                      Running symbolic debuggers for
  653.                                     non-Lisp programs.
  654. * Executing Lisp::                Various modes for editing Lisp programs,
  655.                                     with different facilities for running
  656.                                     the Lisp programs.
  657. * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
  658. * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
  659. * Eval: Lisp Eval.                Executing a single Lisp expression in Emacs.
  660. * External Lisp::                 Communicating through Emacs with a
  661.                                     separate Lisp.
  662. File: emacs,  Node: Compilation,  Next: Debuggers,  Up: Building
  663. Running Compilations under Emacs
  664. ================================
  665.    Emacs can run compilers for noninteractive languages such as C and
  666. Fortran as inferior processes, feeding the error log into an Emacs
  667. buffer.  It can also parse the error messages and show you the source
  668. lines where compilation errors occurred.
  669. `M-x compile'
  670.      Run a compiler asynchronously under Emacs, with error messages to
  671.      `*compilation*' buffer.
  672. `M-x grep'
  673.      Run `grep' asynchronously under Emacs, with matching lines listed
  674.      in the buffer named `*grep*'.
  675. `M-x kill-compilation'
  676. `M-x kill-grep'
  677.      Kill the running compilation or `grep' subprocess.
  678. `C-x `'
  679.      Visit the locus of the next compiler error message or `grep' match.
  680. `C-c C-c'
  681.      Visit the locus of the error message that point is on.  This
  682.      command is used in the compilation buffer.
  683. `Mouse-2'
  684.      Visit the locus of the error message that you click on.
  685.    To run `make' or another compilation command, do `M-x compile'.
  686. This command reads a shell command line using the minibuffer, and then
  687. executes the command in an inferior shell, putting output in the buffer
  688. named `*compilation*'.  The current buffer's default directory is used
  689. as the working directory for the execution of the command; normally,
  690. therefore, the compilation happens in this directory.
  691.    When the shell command line is read, the minibuffer appears
  692. containing a default command line, which is the command you used the
  693. last time you did `M-x compile'.  If you type just RET, the same command
  694. line is used again.  For the first `M-x compile', the default is `make
  695. -k'.  The default compilation command comes from the variable
  696. `compile-command'; if the appropriate compilation command for a file is
  697. something other than `make -k', it can be useful for the file to
  698. specify a local value for `compile-command' (*note File Variables::.).
  699.    Starting a compilation displays the buffer `*compilation*' in
  700. another window but does not select it.  The buffer's mode line tells you
  701. whether compilation is finished, with the word `run' or `exit' inside
  702. the parentheses.  You do not have to keep this buffer visible;
  703. compilation continues in any case.  While a compilation is going on, the
  704. string `Compiling' appears in the mode lines of all windows.  When this
  705. string disappears, the compilation is finished.
  706.    To kill the compilation process, do `M-x kill-compilation'.  When
  707. the compiler process terminates, the mode line of the `*compilation*'
  708. buffer changes to say `signal' instead of `run'.  Starting a new
  709. compilation also kills any running compilation, as only one can exist
  710. at any time.  However, `M-x compile' asks for confirmation before
  711. actually killing a compilation that is running.
  712.    The `*compilation*' buffer uses a special major mode, Compilation
  713. mode.  This mode provides the keys SPC and DEL to scroll by screenfuls,
  714. and `M-n' and `M-p' to move to the next or previous error message.  You
  715. can also use `M-{' and `M-}' to move up or down to an error message for
  716. a different source file.
  717.    You can visit the source for any particular error message by moving
  718. point in `*compilation*' to that error message and typing `C-c C-c'
  719. (`compile-goto-error').  To parse the compiler error messages
  720. sequentially, type `C-x `' (`next-error').  The character following the
  721. `C-x' is the backquote or "grave accent," not the single-quote.  This
  722. command is available in all buffers, not just in `*compilation*'; it
  723. displays the next error message at the top of one window and source
  724. location of the error in another window.
  725.    The first time `C-x `' is used after the start of a compilation, it
  726. moves to the first error's location.  Subsequent uses of `C-x `'
  727. advance down to subsequent errors.  If you visit a specific error
  728. message with `C-c C-c' or `Mouse-2', subsequent `C-x `' commands
  729. advance from there.  When `C-x `' gets to the end of the buffer and
  730. finds no more error messages to visit, it fails and signals an Emacs
  731. error.
  732.    `C-u C-x `' starts scanning from the beginning of the compilation
  733. buffer.  This way, you can process the same set of errors again.
  734.    Just as you can run a compiler, you can also run `grep' and then
  735. visit the lines on which matches were found.  To do this, type `M-x
  736. grep' with an argument line that contains the same arguments you would
  737. give `grep' when running it normally: a `grep'-style regexp (usually in
  738. single-quotes to quote the shell's special characters) followed by file
  739. names which may use wildcards.  The output from `grep' goes in the
  740. `*grep*' buffer and the lines that matched can be found with `C-x `' as
  741. if they were compilation errors.
  742.    Note: a shell is used to run the compile command, but the shell is
  743. told that it should be noninteractive.  This means in particular that
  744. the shell starts up with no prompt.  If you find your usual shell
  745. prompt making an unsightly appearance in the `*compilation*' buffer, it
  746. means you have made a mistake in your shell's init file (`.cshrc' or
  747. `.shrc' or ...) by setting the prompt unconditionally.  The shell init
  748. file should set the prompt only if there already is a prompt.  In csh,
  749. here is how to do it:
  750.      if ($?prompt) set prompt = ...
  751. And here's how to do it in bash:
  752.      if [ "${PS1+set}" = set ]
  753.      then prompt=...
  754.      fi
  755.    There may well be other things that your shell's init file ought to
  756. do only for an interactive shell.  You can use the same method to
  757. conditionalize them.
  758.    The features of Compilation mode are also available in a minor mode
  759. called Compilation Minor mode.  This lets you parse error messages in
  760. any buffer, not just a normal compilation output buffer.  Type `M-x
  761. compilation-minor-mode' to enable the minor mode.  This defines the keys
  762. `C-c C-c' and `Mouse-2', as in the Compilation major mode.  In an
  763. Rlogin buffer (*note Remote Host::.), Compilation minor mode
  764. automatically accesses remote source files by FTP (*note File Names::.).
  765.    The MS-DOS "operating system" does not support asynchronous
  766. subprocesses; to work around this lack, `M-x compile' runs the
  767. compilation command synchronously on MS-DOS.  As a consequence, you must
  768. wait until the command finishes before you can do anything else in
  769. Emacs.  *Note MS-DOS::.
  770. File: emacs,  Node: Debuggers,  Next: Executing Lisp,  Prev: Compilation,  Up: Building
  771. Running Debuggers Under Emacs
  772. =============================
  773.    The GUD (Grand Unified Debugger) library provides an interface to
  774. various symbolic debuggers from within Emacs.  We recommend the debugger
  775. GDB, which is free software, but you can also run DBX, SDB or XDB if you
  776. have them.  GUD can also serve as an interface to the Perl's debugging
  777. mode.
  778. * Menu:
  779. * Starting GUD::    How to start a debugger subprocess.
  780. * Debugger Operation::    Connection between the debugger and source buffers.
  781. * Commands of GUD::    Key bindings for common commands.
  782. * GUD Customization::    Defining your own commands for GUD.
  783. File: emacs,  Node: Starting GUD,  Next: Debugger Operation,  Up: Debuggers
  784. Starting GUD
  785. ------------
  786.    There are five commands for starting a debugger, each corresponding
  787. to a particular debugger program.
  788. `M-x gdb RET FILE RET'
  789.      Run GDB as a subprocess of Emacs.  This command creates a buffer
  790.      for input and output to GDB, and switches to it.  If a GDB buffer
  791.      already exists, it just switches to that buffer.
  792. `M-x dbx RET FILE RET'
  793.      Similar, but run DBX instead of GDB.
  794. `M-x xdb RET FILE RET'
  795.      Similar, but run XDB instead of GDB.  Use the variable
  796.      `gud-xdb-directories' to specify directories to search for source
  797.      files.
  798. `M-x sdb RET FILE RET'
  799.      Similar, but run SDB instead of GDB.
  800.      Some versions of SDB do not mention source file names in their
  801.      messages.  When you use them, you need to have a valid tags table
  802.      (*note Tags::.) in order for GUD to find functions in the source
  803.      code.  If you have not visited a tags table or the tags table
  804.      doesn't list one of the functions, you get a message saying `The
  805.      sdb support requires a valid tags table to work'.  If this
  806.      happens, generate a valid tags table in the working directory and
  807.      try again.
  808. `M-x perldb RET FILE RET'
  809.      Run the Perl interpreter in debug mode to debug FILE, a Perl
  810.      program.
  811.    You can only run one debugger process at a time.
  812.    Each of these commands takes one argument: a command line to invoke
  813. the debugger.  In the simplest case, specify just the name of the
  814. executable file you want to debug.  You may also use options that the
  815. debugger supports.  However, shell wild cards and variables are not
  816. allowed.  GUD assumes that the first argument not preceded by a `-' is
  817. the executable file name.
  818. File: emacs,  Node: Debugger Operation,  Next: Commands of GUD,  Prev: Starting GUD,  Up: Debuggers
  819. Debugger Operation
  820. ------------------
  821.    When you run a debugger with GUD, the debugger uses an Emacs buffer
  822. for its ordinary input and output.  This is called the GUD buffer.  The
  823. debugger displays the source files of the program by visiting them in
  824. Emacs buffers.  An arrow (`=>') in one of these buffers indicates the
  825. current execution line.  Moving point in this buffer does not move the
  826. arrow.
  827.    You can start editing these source files at any time in the buffers
  828. that were made to display them.  The arrow is not part of the file's
  829. text; it appears only on the screen.  If you do modify a source file,
  830. keep in mind that inserting or deleting lines will throw off the arrow's
  831. positioning; GUD has no way of figuring out which line corresponded
  832. before your changes to the line number in a debugger message.  Also,
  833. you'll typically have to recompile and restart the program for your
  834. changes to be reflected in the debugger's tables.
  835.    If you wish, you can control your debugger process entirely through
  836. the debugger buffer, which uses a variant of Shell mode.  All the usual
  837. commands for your debugger are available, and you can use the Shell mode
  838. history commands to repeat them.  *Note Shell Mode::.
  839. File: emacs,  Node: Commands of GUD,  Next: GUD Customization,  Prev: Debugger Operation,  Up: Debuggers
  840. Commands of GUD
  841. ---------------
  842.    The GUD interaction buffer uses a variant of Shell mode, so the
  843. commands of Shell mode are available (*note Shell Mode::.).  GUD mode
  844. also provides commands for setting and clearing breakpoints, for
  845. selecting stack frames, and for stepping through the program.  These
  846. commands are available both in the GUD buffer and globally, but with
  847. different key bindings.
  848.    The breakpoint commands are usually used in source file buffers,
  849. because that is the way to specify where to set or clear the breakpoint.
  850. Here's the global command to set a breakpoint:
  851. `C-x SPC'
  852.      Set a breakpoint on the source line that point is on.
  853.    Here are the other special commands provided by GUD.  The keys
  854. starting with `C-c' are available only in the GUD interaction buffer.
  855. The bindings that start with `C-x C-a' are available in the GUD buffer
  856. and also in source files.
  857. `C-c C-l'
  858. `C-x C-a C-l'
  859.      Display in another window the last line referred to in the GUD
  860.      buffer (that is, the line indicated in the last location message).
  861.      This runs the command `gud-refresh'.
  862. `C-c C-s'
  863. `C-x C-a C-s'
  864.      Execute a single line of code (`gud-step').  If the line contains
  865.      a function call, execution stops after entering the called
  866.      function.
  867. `C-c C-n'
  868. `C-x C-a C-n'
  869.      Execute a single line of code, stepping across entire function
  870.      calls at full speed (`gud-next').
  871. `C-c C-i'
  872. `C-x C-a C-i'
  873.      Execute a single machine instruction (`gud-stepi').
  874. `C-c C-r'
  875. `C-x C-a C-r'
  876.      Continue execution without specifying any stopping point.  The
  877.      program will run until it hits a breakpoint, terminates, or gets a
  878.      signal that the debugger is checking for (`gud-cont').
  879. `C-c C-d'
  880. `C-x C-a C-d'
  881.      Delete the breakpoint(s) on the current source line, if any
  882.      (`gud-remove').  If you use this command in the GUD interaction
  883.      buffer, it applies to the line where the program last stopped.
  884. `C-c C-t'
  885. `C-x C-a C-t'
  886.      Set a temporary breakpoint on the current source line, if any.  If
  887.      you use this command in the GUD interaction buffer, it applies to
  888.      the line where the program last stopped.
  889.    The above commands are common to all supported debuggers.  If you are
  890. using GDB or (some versions of) DBX, these additional commands are
  891. available:
  892. `C-c <'
  893. `C-x C-a <'
  894.      Select the next enclosing stack frame (`gud-up').  This is
  895.      equivalent to the `up' command.
  896. `C-c >'
  897. `C-x C-a >'
  898.      Select the next inner stack frame (`gud-down').  This is
  899.      equivalent to the `down' command.
  900.    If you are using GDB, these additional key bindings are available:
  901. `TAB'
  902.      With GDB, complete a symbol name (`gud-gdb-complete-command').
  903.      This key is available only in the GUD interaction buffer, and
  904.      requires GDB versions 4.13 and later.
  905. `C-c C-f'
  906. `C-x C-a C-f'
  907.      Run the program until the selected stack frame returns (or until it
  908.      stops for some other reason).
  909.    These commands interpret a numeric argument as a repeat count, when
  910. that makes sense.
  911.