home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / e17info.zip / EMACS / 19.17 / INFO / EMACS-10 (.txt) < prev    next >
GNU Info File  |  1993-07-18  |  50KB  |  901 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Comments,  Next: Balanced Editing,  Prev: Matching,  Up: Programs
  4. Manipulating Comments
  5. =====================
  6.    The comment commands insert, kill and align comments.
  7. `M-;'
  8.      Insert or align comment (`indent-for-comment').
  9. `C-x ;'
  10.      Set comment column (`set-comment-column').
  11. `C-u - C-x ;'
  12.      Kill comment on current line (`kill-comment').
  13. `M-LFD'
  14.      Like RET followed by inserting and aligning a comment
  15.      (`indent-new-comment-line').
  16. `M-x comment-region'
  17.      Add or remove comment delimiters on all the lines in the region.
  18.    The command that creates a comment is `M-;' (`indent-for-comment').
  19. If there is no comment already on the line, a new comment is created,
  20. aligned at a specific column called the "comment column".  The comment
  21. is created by inserting the string Emacs thinks comments should start
  22. with (the value of `comment-start'; see below).  Point is left after
  23. that string.  If the text of the line extends past the comment column,
  24. then the indentation is done to a suitable boundary (usually, at least
  25. one space is inserted).  If the major mode has specified a string to
  26. terminate comments, that is inserted after point, to keep the syntax
  27. valid.
  28.    `M-;' can also be used to align an existing comment.  If a line
  29. already contains the string that starts comments, then `M-;' just moves
  30. point after it and re-indents it to the conventional place.  Exception:
  31. comments starting in column 0 are not moved.
  32.    Some major modes have special rules for indenting certain kinds of
  33. comments in certain contexts.  For example, in Lisp code, comments which
  34. start with two semicolons are indented as if they were lines of code,
  35. instead of at the comment column.  Comments which start with three
  36. semicolons are supposed to start at the left margin.  Emacs understands
  37. these conventions by indenting a double-semicolon comment using TAB,
  38. and by not changing the indentation of a triple-semicolon comment at
  39.      ;; This function is just an example
  40.      ;;; Here either two or three semicolons are appropriate.
  41.      (defun foo (x)
  42.      ;;; And now, the first part of the function:
  43.        ;; The following line adds one.
  44.        (1+ x))           ; This line adds one.
  45.    In C code, a comment preceded on its line by nothing but whitespace
  46. is indented like a line of code.
  47.    Even when an existing comment is properly aligned, `M-;' is still
  48. useful for moving directly to the start of the comment.
  49.    `C-u - C-x ;' (`kill-comment') kills the comment on the current line,
  50. if there is one.  The indentation before the start of the comment is
  51. killed as well.  If there does not appear to be a comment in the line,
  52. nothing is done.  To reinsert the comment on another line, move to the
  53. end of that line, do `C-y', and then do `M-;' to realign it.  Note that
  54. `C-u - C-x ;' is not a distinct key; it is `C-x ;'
  55. (`set-comment-column') with a negative argument.  That command is
  56. programmed so that when it receives a negative argument it calls
  57. `kill-comment'.  However, `kill-comment' is a valid command which you
  58. could bind directly to a key if you wanted to.
  59.    The `M-x comment-region' command adds comment delimiters to the
  60. lines that start in the region, thus commenting them out.  With a
  61. negative argument, it does the opposite--it deletes comment delimiters
  62. from the lines in the region.
  63.    With a positive argument, `comment-region' adds comment delimiters
  64. and duplicates the last character of the comment start sequence as many
  65. times as the argument specifies.  Thus, in Lisp mode, `C-u 2 M-x
  66. comment-region' adds `;;' to each line.
  67.    Duplicating the comment delimiter is a way of calling attention to
  68. the comment.  It can also affect how the comment is indented.  In Lisp,
  69. for proper indentation, you should use an argument of two, if between
  70. defuns, and three, if within a defun.
  71. Multiple Lines of Comments
  72. --------------------------
  73.    If you are typing a comment and find that you wish to continue it on
  74. another line, you can use the command `M-LFD'
  75. (`indent-new-comment-line'), which terminates the comment you are
  76. typing, creates a new blank line afterward, and begins a new comment
  77. indented under the old one.  When Auto Fill mode is on, going past the
  78. fill column while typing a comment causes the comment to be continued in
  79. just this fashion.  If point is not at the end of the line when `M-LFD'
  80. is typed, the text on the rest of the line becomes part of the new
  81. comment line.
  82. Options Controlling Comments
  83. ----------------------------
  84.    The comment column is stored in the variable `comment-column'.  You
  85. can set it to a number explicitly.  Alternatively, the command `C-x ;'
  86. (`set-comment-column') sets the comment column to the column point is
  87. at.  `C-u C-x ;' sets the comment column to match the last comment
  88. before point in the buffer, and then does a `M-;' to align the current
  89. line's comment under the previous one.  Note that `C-u - C-x ;' runs
  90. the function `kill-comment' as described above.
  91.    The variable `comment-column' is per-buffer: setting the variable in
  92. the normal fashion affects only the current buffer, but there is a
  93. default value which you can change with `setq-default'.  *Note
  94. Locals::.  Many major modes initialize this variable for the current
  95. buffer.
  96.    The comment commands recognize comments based on the regular
  97. expression that is the value of the variable `comment-start-skip'.
  98. This regexp should not match the null string.  It may match more than
  99. the comment starting delimiter in the strictest sense of the word; for
  100. example, in C mode the value of the variable is `"/\\*+ *"', which
  101. matches extra stars and spaces after the `/*' itself.  (Note that `\\'
  102. is needed in Lisp syntax to include a `\' in the string, which is needed
  103. to deny the first star its special meaning in regexp syntax.  *Note
  104. Regexps::.)
  105.    When a comment command makes a new comment, it inserts the value of
  106. `comment-start' to begin it.  The value of `comment-end' is inserted
  107. after point, so that it will follow the text that you will insert into
  108. the comment.  In C mode, `comment-start' has the value `"/* "' and
  109. `comment-end' has the value `" */"'.
  110.    The variable `comment-multi-line' controls how `M-LFD'
  111. (`indent-new-comment-line') behaves when used inside a comment.  If
  112. `comment-multi-line' is `nil', as it normally is, then the comment on
  113. the starting line is terminated and a new comment is started on the new
  114. following line.  If `comment-multi-line' is not `nil', then the new
  115. following line is set up as part of the same comment that was found on
  116. the starting line.  This is done by not inserting a terminator on the
  117. old line, and not inserting a starter on the new line.  In languages
  118. where multi-line comments work, the choice of value for this variable
  119. is a matter of taste.
  120.    The variable `comment-indent-function' should contain a function
  121. that will be called to compute the indentation for a newly inserted
  122. comment or for aligning an existing comment.  It is set differently by
  123. various major modes.  The function is called with no arguments, but with
  124. point at the beginning of the comment, or at the end of a line if a new
  125. comment is to be inserted.  It should return the column in which the
  126. comment ought to start.  For example, in Lisp mode, the indent hook
  127. function bases its decision on how many semicolons begin an existing
  128. comment, and on the code in the preceding lines.
  129. File: emacs,  Node: Balanced Editing,  Next: Symbol Completion,  Prev: Comments,  Up: Programs
  130. Editing Without Unbalanced Parentheses
  131. ======================================
  132. `M-('
  133.      Put parentheses around next sexp(s) (`insert-parentheses').
  134. `M-)'
  135.      Move past next close parenthesis and re-indent
  136.      (`move-over-close-and-reindent').
  137.    The commands `M-(' (`insert-parentheses') and `M-)'
  138. (`move-over-close-and-reindent') are designed to facilitate a style of
  139. editing which keeps parentheses balanced at all times.  `M-(' inserts a
  140. pair of parentheses, either together as in `()', or, if given an
  141. argument, around the next several sexps, and leaves point after the open
  142. parenthesis.  Instead of typing `( F O O )', you can type `M-( F O O',
  143. which has the same effect except for leaving the cursor before the
  144. close parenthesis.  Then you can type `M-)', which moves past the close
  145. parenthesis, deleting any indentation preceding it (in this example
  146. there is none), and indenting with LFD after it.
  147. File: emacs,  Node: Symbol Completion,  Next: Documentation,  Prev: Balanced Editing,  Up: Programs
  148. Completion for Symbol Names
  149. ===========================
  150.    Usually completion happens in the minibuffer.  But one kind of
  151. completion is available in all buffers: completion for symbol names.
  152.    The character `M-TAB' runs a command to complete the partial symbol
  153. before point against the set of meaningful symbol names.  Any
  154. additional characters determined by the partial name are inserted at
  155. point.
  156.    If the partial name in the buffer has more than one possible
  157. completion and they have no additional characters in common, a list of
  158. all possible completions is displayed in another window.
  159.    There are two ways of determining the set of legitimate symbol names
  160. to complete against.  In most major modes, this uses a tag table (*note
  161. Tags::.); the legitimate symbol names are the tag names listed in the
  162. tag table file.  The command which implements this is `complete-tag'.
  163.    In Emacs-Lisp mode, the name space for completion normally consists
  164. of nontrivial symbols present in Emacs--those that have function
  165. definitions, values or properties.  However, if there is an
  166. open-parenthesis immediately before the beginning of the partial symbol,
  167. only symbols with function definitions are considered as completions.
  168. The command which implements this is `lisp-complete-symbol'.
  169. File: emacs,  Node: Documentation,  Next: Change Log,  Prev: Symbol Completion,  Up: Programs
  170. Documentation Commands
  171. ======================
  172.    As you edit Lisp code to be run in Emacs, the commands `C-h f'
  173. (`describe-function') and `C-h v' (`describe-variable') can be used to
  174. print documentation of functions and variables that you want to call.
  175. These commands use the minibuffer to read the name of a function or
  176. variable to document, and display the documentation in a window.
  177.    For extra convenience, these commands provide default arguments
  178. based on the code in the neighborhood of point.  `C-h f' sets the
  179. default to the function called in the innermost list containing point.
  180. `C-h v' uses the symbol name around or adjacent to point as its default.
  181.    Documentation on Unix commands, system calls and libraries can be
  182. obtained with the `M-x manual-entry' command.  This reads a topic as an
  183. argument, and displays the text on that topic from the Unix manual.
  184. `manual-entry' starts a background process that formats the manual
  185. page, by running the `man' program.  The result goes in a buffer named
  186. `*man TOPIC*'.  These buffers have a special major mode that
  187. facilitates scrolling and examining other manual pages.
  188.    Eventually the GNU project hopes to replace most man pages with
  189. better-organized manuals that you can browse with Info.  *Note Misc
  190. Help::.  Since this process is only partially completed, it is still
  191. useful to read manual pages.
  192. File: emacs,  Node: Change Log,  Next: Tags,  Prev: Documentation,  Up: Programs
  193. Change Logs
  194. ===========
  195.    The Emacs command `C-x 4 a' adds a new entry to the change log file
  196. for the file you are editing (`add-change-log-entry-other-window').
  197.    A change log file contains a chronological record of when and why you
  198. have changed a program, consisting of a sequence of entries describing
  199. individual changes.  Normally it is kept in a file called `ChangeLog'
  200. in the same directory as the file you are editing, or one of its parent
  201. directories.  A single `ChangeLog' file can record changes for all the
  202. files in its directory and all its subdirectories.
  203.    A change log entry starts with a header line that contains your name
  204. and the current date.  Aside from these header lines, every line in the
  205. change log starts with a space or a tab.  The bulk of the entry consists
  206. of "items", each of which starts with a line starting with whitespace
  207. and a star.  Here are two entries, each with two items:
  208.      Wed May  5 14:11:45 1993  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
  209.      
  210.          * man.el: Rename functions and variables `man-*' to `Man-*'.
  211.          (manual-entry): Make prompt string clearer.
  212.      
  213.          * simple.el (blink-matching-paren-distance): Change default to 12,000.
  214.      
  215.      Tue May  4 12:42:19 1993  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
  216.      
  217.          * vc.el (minor-mode-map-alist): Don't use it if it's void.
  218.          (vc-cancel-version): Doc fix.
  219.    One entry can describe several changes; each change should have its
  220. own item.  Normally there should be a blank line between items.  When
  221. items are related (parts of the same change, in different places), group
  222. them by leaving no blank line between them.  The second entry above
  223. contains two items grouped in this way.
  224.    `C-x 4 a' visits the change log file and creates a new entry unless
  225. the most recent entry is for today's date and your name.  It also
  226. creates a new item for the current file.  For many languages, it can
  227. even guess the name of the function or other object that was changed.
  228.    The change log file is visited in Change Log mode.  Each bunch of
  229. grouped item counts as one paragraph, and each entry is considered a
  230. page.  This facilitates editing the entries.  LFD and auto-fill indent
  231. each new line like the previous line; this is convenient for entering
  232. the contents of an entry.
  233. File: emacs,  Node: Tags,  Next: Emerge,  Prev: Change Log,  Up: Programs
  234. Tag Tables
  235. ==========
  236.    A "tag table" is a description of how a multi-file program is broken
  237. up into files.  It lists the names of the component files and the names
  238. and positions of the functions (or other named subunits) in each file.
  239. Grouping the related files makes it possible to search or replace
  240. through all the files with one command.  Recording the function names
  241. and positions makes possible the `M-.'  command which you can use to
  242. find the definition of a function without having to know which of the
  243. files it is in.
  244.    Tag tables are stored in files called "tag table files".  The
  245. conventional name for a tag table file is `TAGS'.
  246.    Each entry in the tag table records the name of one tag, the name of
  247. the file that the tag is defined in (implicitly), and the position in
  248. that file of the tag's definition.
  249.    Just what names from the described files are recorded in the tag
  250. table depends on the programming language of the described file.  They
  251. normally include all functions and subroutines, and may also include
  252. global variables, data types, and anything else convenient.  Each name
  253. recorded is called a "tag".
  254. * Menu:
  255. * Tag Syntax::          Tag syntax for various types of code and text
  256.                           files.
  257. * Create Tag Table::    Creating a tag table with `etags'.
  258. * Select Tag Table::    How to visit a tag table.
  259. * Find Tag::            Commands to find the definition of a specific
  260.                           tag.
  261. * Tags Search::         Using a tag table for searching and replacing.
  262. * Tags Stepping::       Visiting files in a tag table, one by one.
  263. * List Tags::           Listing and finding tags defined in a file.
  264. File: emacs,  Node: Tag Syntax,  Next: Create Tag Table,  Up: Tags
  265. Source File Tag Syntax
  266. ----------------------
  267.    In Lisp code, any function defined with `defun', any variable
  268. defined with `defvar' or `defconst', and in general the first argument
  269. of any expression that starts with `(def' in column zero, is a tag.
  270.    In Scheme code, tags include anything defined with `def' or with a
  271. construct whose name starts with `def'.  They also include variables
  272. set with `set!' at top level in the file.
  273.    In C code, any C function is a tag, and so is any typedef if `-t' is
  274. specified when the tag table is constructed.
  275.    In Yacc or Bison input files, each rule defines as a tag the
  276. nonterminal it constructs.  The portions of the file that contain C code
  277. are parsed as C code.
  278.    In Fortran code, functions and subroutines are tags.
  279.    In Prolog code, a tag name appears at the left margin.
  280.    In assembler code, labels appearing at the beginning of a line,
  281. followed by a colon, are tags.
  282.    In LaTeX text, the argument of any of the commands `\chapter',
  283. `\section', `\subsection', `\subsubsection', `\eqno', `\label', `\ref',
  284. `\cite', `\bibitem' and `\typeout' is a tag.
  285. File: emacs,  Node: Create Tag Table,  Next: Select Tag Table,  Prev: Tag Syntax,  Up: Tags
  286. Creating Tag Tables
  287. -------------------
  288.    The `etags' program is used to create a tag table file.  It knows
  289. the syntax of several languages, as described in *Note Tag Syntax::.
  290. Here is how to run `etags':
  291.      etags INPUTFILES...
  292. The `etags' program reads the specified files, and writes a tag table
  293. named `TAGS' in the current working directory.  `etags' recognizes the
  294. language used in an input file based on its file name and contents;
  295. there are no switches for specifying the language.  The `-t' switch
  296. tells `etags' to record typedefs in C code as tags.
  297.    If the tag table data become outdated due to changes in the files
  298. described in the table, the way to update the tag table is the same way
  299. it was made in the first place.  It is not necessary to do this often.
  300.    If the tag table fails to record a tag, or records it for the wrong
  301. file, then Emacs cannot possibly find its definition.  However, if the
  302. position recorded in the tag table becomes a little bit wrong (due to
  303. some editing in the file that the tag definition is in), the only
  304. consequence is a slight delay in finding the tag.  Even if the stored
  305. position is very wrong, Emacs will still find the tag, but it must
  306. search the entire file for it.
  307.    So you should update a tag table when you define new tags that you
  308. want to have listed, or when you move tag definitions from one file to
  309. another, or when changes become substantial.  Normally there is no need
  310. to update the tag table after each edit, or even every day.
  311. File: emacs,  Node: Select Tag Table,  Next: Find Tag,  Prev: Create Tag Table,  Up: Tags
  312. Selecting a Tag Table
  313. ---------------------
  314.    Emacs has at any time one "selected" tag table, and all the commands
  315. for working with tag tables use the selected one.  To select a tag
  316. table, type `M-x visit-tags-table', which reads the tag table file name
  317. as an argument.  The name `TAGS' in the default directory is used as the
  318. default file name.
  319.    All this command does is store the file name in the variable
  320. `tags-file-name'.  Emacs does not actually read in the tag table
  321. contents until you try to use them.  Setting this variable yourself is
  322. just as good as using `visit-tags-table'.  The variable's initial value
  323. is `nil'; that value tells all the commands for working with tag tables
  324. that they must ask for a tag table file name to use.
  325.    Using `visit-tags-table' to load a new tag table does not discard
  326. the other tables previously loaded.  The other tags commands use all
  327. the tag tables that are loaded; the first one they use is the one that
  328. mentions the current visited file.
  329.    You can specify a precise list of tag tables by setting the variable
  330. `tags-table-list' to a list of strings, like this:
  331.      (setq tags-table-list
  332.            '("~/emacs" "/usr/local/lib/emacs/src"))
  333. This tells the tags commands to look at the `TAGS' files in your
  334. `~/emacs' directory and in the `/usr/local/lib/emacs/src' directory.
  335. The order depends on which file you are in and which tags table
  336. mentions that file, as explained above.
  337. File: emacs,  Node: Find Tag,  Next: Tags Search,  Prev: Select Tag Table,  Up: Tags
  338. Finding a Tag
  339. -------------
  340.    The most important thing that a tag table enables you to do is to
  341. find the definition of a specific tag.
  342. `M-. TAG RET'
  343.      Find first definition of TAG (`find-tag').
  344. `C-u M-.'
  345.      Find next alternate definition of last tag specified.
  346. `C-u - M-.'
  347.      Go back to previous tag found.
  348. `M-x find-tag-regexp RET PATTERN RET'
  349.      Find a tag whose name matches PATTERN.
  350. `C-u M-x find-tag-regexp'
  351.      Find the next tag whose name matches the last pattern used.
  352. `C-x 4 . TAG RET'
  353.      Find first definition of TAG, but display it in another window
  354.      (`find-tag-other-window').
  355. `C-x 5 . TAG RET'
  356.      Find first definition of TAG, and create a new frame to select the
  357.      buffer (`find-tag-other-frame').
  358.    `M-.' (`find-tag') is the command to find the definition of a
  359. specified tag.  It searches through the tag table for that tag, as a
  360. string, and then uses the tag table info to determine the file that the
  361. definition is in and the approximate character position in the file of
  362. the definition.  Then `find-tag' visits that file, moves point to the
  363. approximate character position, and searches ever-increasing distances
  364. away to find the tag definition.
  365.    If an empty argument is given (just type RET), the sexp in the
  366. buffer before or around point is used as the TAG argument.  *Note
  367. Lists::, for info on sexps.
  368.    You don't need to give `M-.' the full name of the tag; a part will
  369. do.  This is because `M-.' finds tags in the table which contain TAG as
  370. a substring.  However, it prefers an exact match to a substring match.
  371.    To find other tags that match the same substring, give `find-tag' a
  372. numeric argument, as in `C-u M-.'; this does not read a tag name, but
  373. continues searching the tag table's text for another tag containing the
  374. same substring last used.  If you have a real META key, `M-0 M-.' is an
  375. easier alternative to `C-u M-.'.
  376.    Like most commands that can switch buffers, `find-tag' has a variant
  377. that displays the new buffer in another window, and one that makes a
  378. new frame for it.  The former is `C-x 4 .', which invokes the command
  379. `find-tag-other-window'.  The latter is `C-x 5 .', which invokes
  380. `find-tag-other-frame'.
  381.    To move back to places you've found tags recently, use `C-u - M-.';
  382. more generally, `M-.' with a negative numeric argument.  This command
  383. can take you to another buffer.  `C-x 4 .' with a negative argument
  384. finds the previous tag location in another window.
  385.    The new command `M-x find-tag-regexp' visits the tags that match a
  386. specified regular expression.  It is just like `M-.' except that it
  387. does regexp matching instead of substring matching.
  388.    Emacs comes with a tag table file `src/TAGS' that includes all the
  389. Lisp libraries and all the C sources of Emacs.  By specifying this file
  390. with `visit-tags-table' and then using `M-.' you can quickly find the
  391. source for any Emacs function.
  392. File: emacs,  Node: Tags Search,  Next: Tags Stepping,  Prev: Find Tag,  Up: Tags
  393. Searching and Replacing with Tag Tables
  394. ---------------------------------------
  395.    The commands in this section visit and search all the files listed
  396. in the selected tag table, one by one.  For these commands, the tag
  397. table serves only to specify a sequence of files to search.  A related
  398. command is `M-x grep' (*note Compilation::.).
  399. `M-x tags-search'
  400.      Search for the specified regexp through the files in the selected
  401.      tag table.
  402. `M-x tags-query-replace'
  403.      Perform a `query-replace' on each file in the selected tag table.
  404. `M-,'
  405.      Restart one of the commands above, from the current location of
  406.      point (`tags-loop-continue').
  407.    `M-x tags-search' reads a regexp using the minibuffer, then searches
  408. for matches in all the files in the selected tag table, one file at a
  409. time.  It displays the name of the file being searched so you can
  410. follow its progress.  As soon as it finds an occurrence, `tags-search'
  411. returns.
  412.    Having found one match, you probably want to find all the rest.  To
  413. find one more match, type `M-,' (`tags-loop-continue') to resume the
  414. `tags-search'.  This searches the rest of the current buffer, followed
  415. by the remaining files of the tag table.
  416.    `M-x tags-query-replace' performs a single `query-replace' through
  417. all the files in the tag table.  It reads a regexp to search for and a
  418. string to replace with, just like ordinary `M-x query-replace-regexp'.
  419. It searches much like `M-x tags-search' but repeatedly, processing
  420. matches according to your input.  *Note Replace::, for more information
  421. on query replace.
  422.    It is possible to get through all the files in the tag table with a
  423. single invocation of `M-x tags-query-replace'.  But since any
  424. unrecognized character causes the command to exit, you may need to
  425. continue where you left off.  `M-,' can be used for this.  It resumes
  426. the last tags search or replace command that you did.
  427.    The commands in this section carry out much broader searches than the
  428. `find-tags' family.  The `find-tags' commands search only for
  429. definitions of tags that match your substring or regexp.  The commands
  430. `tags-search' and `tags-query-replace' find every occurrence of the
  431. regexp, as ordinary search commands and replace commands do in the
  432. current buffer.
  433.    These commands create buffers only temporarily for the files that
  434. they have to search (those which are not already visited in Emacs
  435. buffers).  Buffers in which no match is found are quickly killed; the
  436. others continue to exist.
  437.    It may have struck you that `tags-search' is a lot like `grep'.  You
  438. can also run `grep' itself as an inferior of Emacs and have Emacs show
  439. you the matching lines one by one.  This works mostly the same as
  440. running a compilation and having Emacs show you where the errors were.
  441. *Note Compilation::.
  442. File: emacs,  Node: Tags Stepping,  Next: List Tags,  Prev: Tags Search,  Up: Tags
  443. Stepping Through a Tag Table
  444. ----------------------------
  445.    If you wish to process all the files in the selected tag table, but
  446. not in the specific ways that `M-x tags-search' and `M-x
  447. tags-query-replace' do, you can use `M-x next-file' to visit the files
  448. one by one.
  449. `C-u M-x next-file'
  450.      Visit the first file in the tag table, and prepare to advance
  451.      sequentially by files.
  452. `M-x next-file'
  453.      Visit the next file in the selected tag table.
  454. File: emacs,  Node: List Tags,  Prev: Tags Stepping,  Up: Tags
  455. Tag Table Inquiries
  456. -------------------
  457. `M-x list-tags'
  458.      Display a list of the tags defined in a specific program file.
  459. `M-x tags-apropos'
  460.      Display a list of all tags matching a specified regexp.
  461.    `M-x list-tags' reads the name of one of the files described by the
  462. selected tag table, and displays a list of all the tags defined in that
  463. file.  The "file name" argument is really just a string to compare
  464. against the names recorded in the tag table; it is read as a string
  465. rather than as a file name.  Therefore, completion and defaulting are
  466. not available, and you must enter the string the same way it appears in
  467. the tag table.  Do not include a directory as part of the file name
  468. unless the file name recorded in the tag table includes a directory.
  469.    `M-x tags-apropos' is like `apropos' for tags.  It reads a regexp,
  470. then finds all the tags in the selected tag table whose entries match
  471. that regexp, and displays the tag names found.
  472.    You can also perform completion in the buffer on the name space of
  473. tag names in the current tag tables.  *Note Symbol Completion::.
  474. File: emacs,  Node: Emerge,  Next: C Mode,  Prev: Tags,  Up: Programs
  475. Merging Files with Emerge
  476. =========================
  477.    It's not unusual for programmers to get their signals crossed and
  478. modify the same program in two different directions.  To recover from
  479. this confusion, you need to merge the two versions.  Emerge makes this
  480. easier.  See also *Note Comparing Files::.
  481. * Menu:
  482. * Overview of Emerge::        How to start Emerge.  Basic concepts.
  483. * Submodes of Emerge::      Fast mode vs. Edit mode.
  484.                   Skip Prefers mode and Auto Advance mode.
  485. * State of Difference::        You do the merge by specifying state A or B
  486.                   for each difference.
  487. * Merge Commands::        Commands for selecting a difference,
  488.                   changing states of differences, etc.
  489. * Exiting Emerge::        What to do when you've finished the merge.
  490. * Combining in Emerge::        How to keep both alternatives for a difference.
  491. * Fine Points of Emerge::   Misc.
  492. File: emacs,  Node: Overview of Emerge,  Next: Submodes of Emerge,  Up: Emerge
  493. Overview of Emerge
  494. ------------------
  495.    To start Emerge, run one of these four commands:
  496. `M-x emerge-files'
  497.      Merge two specified files.
  498. `M-x emerge-files-with-ancestor'
  499.      Merge two specified files, with reference to a common ancestor.
  500. `M-x emerge-buffers'
  501.      Merge two buffers.
  502. `M-x emerge-buffers-with-ancestor'
  503.      Merge two buffers with reference to a common ancestor in a third
  504.      buffer.
  505.    The Emerge commands compare two files or buffers, and display the
  506. comparison in three buffers: one for each input text (the "A buffer"
  507. and the "B buffer"), and one (the "merge buffer") where merging takes
  508. place.  The merge buffer shows the full merged text, not just the
  509. differences.  Wherever the two input texts differ, you can choose which
  510. one of them to include in the merge buffer.
  511.    The Emerge commands that take input from existing buffers use only
  512. the accessible portions of those buffers, if they are narrowed (*note
  513. Narrowing::.).
  514.    If a common ancestor version is available, from which the two texts
  515. to be merged were both derived, Emerge can use it to guess which
  516. alternative is right.  Wherever one current version agrees with the
  517. ancestor, Emerge presumes that the other current version is a deliberate
  518. change which should be kept in the merged version.  Use the
  519. `with-ancestor' commands if you want to specify a common ancestor text.
  520. These commands read three file or buffer names--variant A, variant B,
  521. and the common ancestor.
  522.    After the comparison is done and the buffers are prepared, the
  523. interactive merging starts.  You control the merging by typing special
  524. commands in the merge buffer.  The merge buffer shows you a full merged
  525. text, not just differences.  For each run of differences between the
  526. input texts, you can choose which one of them to keep, or edit them both
  527. together.
  528.    The merge buffer uses a special major mode, Emerge mode, with
  529. commands for making these choices.  But you can also edit the buffer
  530. with ordinary Emacs commands.
  531.    At any given time, the attention of Emerge is focused on one
  532. particular difference, called the "selected" difference.  This
  533. difference is marked off in the three buffers like this:
  534.      vvvvvvvvvvvvvvvvvvvv
  535.      TEXT THAT DIFFERS
  536.      ^^^^^^^^^^^^^^^^^^^^
  537. Emerge numbers all the differences sequentially and the mode line
  538. always shows the number of the selected difference.
  539.    Normally, the merge buffer starts out with the A version of the text.
  540. But when the A version of a part of the buffer agrees with the common
  541. ancestor, then the B version is preferred for that part.
  542.    Emerge leaves the merged text in the merge buffer when you exit.  At
  543. that point, you can save it in a file with `C-x C-w'.  If you give a
  544. prefix argument to `emerge-files' or `emerge-files-with-ancestor', it
  545. reads the name of the output file using the minibuffer.  (This is the
  546. last file name those commands read.) Then exiting from Emerge saves the
  547. merged text in the output file.
  548.    If you abort Emerge with `C-]', the output is not saved.
  549. File: emacs,  Node: Submodes of Emerge,  Next: State of Difference,  Prev: Overview of Emerge,  Up: Emerge
  550. Submodes of Emerge
  551. ------------------
  552.    You can choose between two modes for giving merge commands: Fast mode
  553. and Edit mode.  In Fast mode, basic Emerge commands are single
  554. characters, but ordinary Emacs commands are disabled.  This is
  555. convenient if you use only Emerge commands.
  556.    In Edit mode, all Emerge commands start with the prefix key `C-c
  557. C-c', and the normal Emacs commands are also available.  This allows
  558. editing the merge buffer, but slows down Emerge operations.
  559.    Use `e' to switch to Edit mode, and `C-c C-c f' to switch to Fast
  560. mode.  The mode line indicates Edit and Fast modes with `E' and `F'.
  561.    Emerge has two additional submodes that affect how particular merge
  562. commands work: Auto Advance mode and Skip Prefers mode.
  563.    If Auto Advance mode is in effect, the `a' and `b' commands advance
  564. to the next difference.  This lets you go through the merge faster as
  565. long as you simply choose one of the alternatives from the input.  The
  566. mode line indicates Auto Advance mode with `A'.
  567.    If Skip Prefers mode is in effect, the `n' and `p' commands skip
  568. over differences in states prefer-A and prefer-B.  Thus you see only
  569. differences for which neither version is presumed "correct".  The mode
  570. line indicates Skip Prefers mode with `S'.
  571.    Use the command `s a' (`emerge-auto-advance-mode') to set or clear
  572. Auto Advance mode.  Use `s s' (`emerge-skip-prefers-mode') to set or
  573. clear Skip Prefers mode.  These commands turn on the mode with a
  574. positive argument, turns it off with a negative or zero argument, and
  575. toggle the mode with no argument.
  576. File: emacs,  Node: State of Difference,  Next: Merge Commands,  Prev: Submodes of Emerge,  Up: Emerge
  577. State of a Difference
  578. ---------------------
  579.    In the merge buffer, a difference is marked with lines of `v' and
  580. `^' characters.  Each difference has one of these seven states:
  581.      The difference is showing the A version.  The `a' command always
  582.      produces this state; the mode line indicates it with `A'.
  583.      The difference is showing the B version.  The `b' command always
  584.      produces this state; the mode line indicates it with `B'.
  585. default-A
  586. default-B
  587.      The difference is showing the A or the B state by default, because
  588.      you haven't made a choice.  All differences start in the default-A
  589.      state (and thus the merge buffer is a copy of the A buffer),
  590.      except those for which one alternative is "preferred" (see below).
  591.      When you select a difference, its state changes from default-A or
  592.      default-B to plain A or B.  Thus, the selected difference never has
  593.      state default-A or default-B, and these states are never displayed
  594.      in the mode line.
  595.      The command `d a' chooses default-A as the default state, and `d
  596.      b' chooses default-B.  This chosen default applies to all
  597.      differences which you haven't selected and for which no
  598.      alternative is preferred.  If you are moving through the merge
  599.      sequentially, the differences you haven't selected are those
  600.      following the selected one.  Thus, while moving sequentially, you
  601.      can effectively make the A version the default for some sections
  602.      of the merge buffer and the B version the default for others by
  603.      using `d a' and `d b' at the end of each section.
  604. prefer-A
  605. prefer-B
  606.      The difference is showing the A or B state because it is
  607.      "preferred".  This means that you haven't made an explicit choice,
  608.      but one alternative seems likely to be right because the other
  609.      alternative agrees with the common ancestor.  Thus, where the A
  610.      buffer agrees with the common ancestor, the B version is
  611.      preferred, because chances are it is the one that was actually
  612.      changed.
  613.      These two states are displayed in the mode line as `A*' and `B*'.
  614. combined
  615.      The difference is showing a combination of the A and B states, as a
  616.      result of the `x c' or `x C' commands.
  617.      Once a difference is in this state, the `a' and `b' commands don't
  618.      do anything to it unless you give them a prefix argument.
  619.      The mode line displays this state as `comb'.
  620. File: emacs,  Node: Merge Commands,  Next: Exiting Emerge,  Prev: State of Difference,  Up: Emerge
  621. Merge Commands
  622. --------------
  623.    Here are the Merge commands for Fast mode; in Edit mode, precede them
  624. with `C-c C-c':
  625.      Select the previous difference.
  626.      Select the next difference.
  627.      Choose the A version of this difference.
  628.      Choose the B version of this difference.
  629.      Select a particular difference; specify the sequence number of that
  630.      difference as a prefix argument.
  631.      Select the difference containing point.  You can use this command
  632.      in the merge buffer or in the A or B buffer.
  633.      Quit--finish the merge.
  634. `C-]'
  635.      Abort--exit merging and do not save the output.
  636.      Go into Fast mode.  (In Edit mode, this is actually `C-c C-c f'.)
  637.      Go into Edit mode.
  638.      Recenter (like `C-l') all three windows.
  639.      Specify part of a prefix numeric argument.
  640. `DIGIT'
  641.      Also specify part of a prefix numeric argument.
  642. `d a'
  643.      Choose the A version as the default from here down in the merge
  644.      buffer.
  645. `d b'
  646.      Choose the B version as the default from here down in the merge
  647.      buffer.
  648. `c a'
  649.      Copy the A version of this difference into the kill ring.
  650. `c b'
  651.      Copy the B version of this difference into the kill ring.
  652. `i a'
  653.      Insert the A version of this difference at the point.
  654. `i b'
  655.      Insert the B version of this difference at the point.
  656.      Put the point and mark around the difference region.
  657.      Scroll all three windows down (like `M-v').
  658.      Scroll all three windows up (like `C-v').
  659.      Scroll all three windows left (like `C-x <').
  660.      Scroll all three windows right (like `C-x >').
  661.      Reset horizontal scroll on all three windows.
  662. `x 1'
  663.      Shrink the merge window to one line.  (Use `C-u l' to restore it
  664.      to full size.)
  665. `x c'
  666.      Combine the two versions of this difference.
  667. `x f'
  668.      Show the files/buffers Emerge is operating on in Help window.
  669.      (Use `C-u l' to restore windows.)
  670. `x j'
  671.      Join this difference with the following one.  (`C-u x j' joins
  672.      this difference with the previous one.)
  673. `x s'
  674.      Split this difference into two differences.  Before you use this
  675.      command, position point in each of the three buffers to the place
  676.      where you want to split the difference.
  677. `x t'
  678.      Trim identical lines off top and bottom of the difference.  Such
  679.      lines occur when the A and B versions are identical but differ
  680.      from the ancestor version.
  681. File: emacs,  Node: Exiting Emerge,  Next: Combining in Emerge,  Prev: Merge Commands,  Up: Emerge
  682. Exiting Emerge
  683. --------------
  684.    The `q' command (`emerge-quit') finishes the merge, storing the
  685. results into the output file if you specified one.  It restores the A
  686. and B buffers to their proper contents, or kills them if they were
  687. created by Emerge and you haven't changed them.  It also disables the
  688. Emerge commands in the merge buffer, since executing them later could
  689. damage the contents of the various buffers.
  690.    `C-]' aborts the merge.  This means exiting without writing the
  691. output file.  If you didn't specify an output file, then there is no
  692. real difference between aborting and finishing the merge.
  693.    If Emerge was called from another Lisp program, then its return value
  694. is `t' for successful completion, or `nil' if you abort.
  695. File: emacs,  Node: Combining in Emerge,  Next: Fine Points of Emerge,  Prev: Exiting Emerge,  Up: Emerge
  696. Combining the Two Versions
  697. --------------------------
  698.    Sometimes you want to keep *both* alternatives for a particular
  699. locus.  To do this, use `x c', which edits the merge buffer like this:
  700.      #ifdef NEW
  701.      VERSION FROM A FILE
  702.      #else /* NEW */
  703.      VERSION FROM B FILE
  704.      #endif /* NEW */
  705. While this example shows C preprocessor conditionals delimiting the two
  706. alternative versions, you can specify the strings you want by setting
  707. the variable `emerge-combine-versions-template' to a string of your
  708. choice.  In the string, `%a' says where to put version A, and `%b' says
  709. where to put version B.  The default setting, which produces the
  710. results shown above, looks like this:
  711.      "#ifdef NEW\n%a#else /* NEW */\n%b#endif /* NEW */\n"
  712. File: emacs,  Node: Fine Points of Emerge,  Prev: Combining in Emerge,  Up: Emerge
  713. Fine Points of Emerge
  714. ---------------------
  715.    During the merge, you mustn't try to edit the A and B buffers
  716. yourself.  Emerge modifies them temporarily, but ultimately puts them
  717. back the way they were.
  718.    You can have any number of merges going at once--just don't use any
  719. one buffer as input to more than one merge at once, since the temporary
  720. changes made in these buffers would get in each other's way.
  721.    Starting Emerge can take a long time because it needs to compare the
  722. files fully.  Emacs can't do anything else until `diff' finishes.
  723. Perhaps in the future someone will change Emerge to do the comparison in
  724. the background when the input files are large--then you could keep on
  725. doing other things with Emacs until Emerge gets ready to accept
  726. commands.
  727.    After setting up the merge, Emerge runs the hook
  728. `emerge-startup-hook' (*note Hooks::.).
  729. File: emacs,  Node: C Mode,  Next: Fortran,  Prev: Emerge,  Up: Programs
  730. C Mode
  731. ======
  732.    In addition to the facilities of typical programming language major
  733. modes (*note Program Modes::.), C mode has various special facilities.
  734. `M-a'
  735. `M-e'
  736.      In C mode, `M-a' and `M-e' now move by complete C statements
  737.      (`c-beginning-of-statement' and `c-end-of-statement').  These
  738.      commands do ordinary, textual sentence motion when in or next to a
  739.      comment.
  740. `M-q'
  741.      `M-q' in C mode runs `c-fill-paragraph', which is designed for
  742.      filling C comments.  (We assume you don't want to fill the actual
  743.      C code in a C program.)
  744. `C-c C-u'
  745.      Move back to the containing preprocessor conditional, setting the
  746.      mark at the starting point (`c-up-conditional').
  747.      A prefix argument acts as a repeat count.  With a negative
  748.      argument, this command moves forward to the end of the containing
  749.      preprocessor conditional.  When going backwards, `#elif' acts like
  750.      `#else' followed by `#if'.  When going forwards, `#elif' is
  751.      ignored.
  752. `C-c C-n'
  753.      Move forward across the next preprocessor conditional, setting the
  754.      mark at the starting point (`c-forward-conditional').
  755. `C-c C-p'
  756.      Move backward across the previous preprocessor conditional,
  757.      setting the at the starting point (`c-backward-conditional').
  758. `M-x c-macro-expand'
  759.      When you are debugging C code that uses macros, sometimes it is
  760.      hard to figure out precisely how the macros expand.  The command
  761.      `M-x c-macro-expand' runs the C preprocessor and shows you what
  762.      expansion results from the region.  The portion of the buffer
  763.      before the region is also included in preprocessing, for the sake
  764.      of macros defined there, but the output from this part isn't shown.
  765. `M-x c-backslash-region'
  766.      Insert or align `\' characters at the ends of the lines of the
  767.      region, except for the last such line.  This is useful after
  768.      writing or editing a C macro definition.
  769.      If a line already ends in `\', this command adjusts the amount of
  770.      whitespace before it.  Otherwise, it inserts a new `\'.
  771.    C++ mode is like C mode, except that it understands C++ comment
  772. syntax and certain other differences between C and C++.  It also has a
  773. command `M-x fill-c++-comment', which fills a paragraph made of C++
  774. comment lines.
  775.    The command `comment-region' is useful in C++ mode for commenting
  776. out several consecutive lines, or removing the commenting out of such
  777. lines.  (You don't need this command with C comment syntax because you
  778. don't need to put comment delimiters on each line.)  *Note Comments::.
  779. File: emacs,  Node: Fortran,  Next: Asm Mode,  Prev: C Mode,  Up: Programs
  780. Fortran Mode
  781. ============
  782.    Fortran mode provides special motion commands for Fortran statements
  783. and subprograms, and indentation commands that understand Fortran
  784. conventions of nesting, line numbers and continuation statements.
  785. Fortran mode has it's own Auto Fill mode that breaks long lines into
  786. proper Fortran continuation lines.
  787.    Special commands for comments are provided because Fortran comments
  788. are unlike those of other languages.
  789.    Built-in abbrevs optionally save typing when you insert Fortran
  790. keywords.
  791.    Use `M-x fortran-mode' to switch to this major mode.  This command
  792. runs the hook `fortran-mode-hook' (*note Hooks::.).
  793. * Menu:
  794. * Motion: Fortran Motion.      Moving point by statements or subprograms.
  795. * Indent: Fortran Indent.      Indentation commands for Fortran.
  796. * Comments: Fortran Comments.  Inserting and aligning comments.
  797. * Autofill: Fortran Autofill.  Auto fill minor mode for Fortran.
  798. * Columns: Fortran Columns.    Measuring columns for valid Fortran.
  799. * Abbrev: Fortran Abbrev.      Built-in abbrevs for Fortran keywords.
  800.    Fortran mode was contributed by Michael Prange.  It has been updated
  801. by Stephen A. Wood who has collated the contributions and suggestions
  802. of many users.
  803. File: emacs,  Node: Fortran Motion,  Next: Fortran Indent,  Up: Fortran
  804. Motion Commands
  805. ---------------
  806.    Fortran mode provides special commands to move by subprograms
  807. (functions and subroutines) and by statements.  There is also a command
  808. to put the region around one subprogram, convenient for killing it or
  809. moving it.
  810. `C-M-a'
  811.      Move to beginning of subprogram
  812.      (`beginning-of-fortran-subprogram').
  813. `C-M-e'
  814.      Move to end of subprogram (`end-of-fortran-subprogram').
  815. `C-M-h'
  816.      Put point at beginning of subprogram and mark at end
  817.      (`mark-fortran-subprogram').
  818. `C-c C-n'
  819.      Move to beginning of current or next statement
  820.      (`fortran-next-statement').
  821. `C-c C-p'
  822.      Move to beginning of current or previous statement
  823.      (`fortran-previous-statement').
  824. File: emacs,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
  825. Fortran Indentation
  826. -------------------
  827.    Special commands and features are needed for indenting Fortran code
  828. in order to make sure various syntactic entities (line numbers, comment
  829. line indicators and continuation line flags) appear in the columns that
  830. are required for standard Fortran.
  831. * Menu:
  832. * Commands: ForIndent Commands.  Commands for indenting Fortran.
  833. * Contline: ForIndent Cont.      How continuation lines indent.
  834. * Numbers:  ForIndent Num.       How line numbers auto-indent.
  835. * Conv:     ForIndent Conv.      Conventions you must obey to avoid trouble.
  836. * Vars:     ForIndent Vars.      Variables controlling Fortran indent style.
  837. File: emacs,  Node: ForIndent Commands,  Next: ForIndent Cont,  Up: Fortran Indent
  838. Fortran Indentation Commands
  839. ............................
  840. `TAB'
  841.      Indent the current line (`fortran-indent-line').
  842. `LFD'
  843.      Indent the current and start a new indented line
  844.      (`fortran-indent-new-line').
  845. `M-LFD'
  846.      Break the current line and set up a continuation line.
  847. `C-M-q'
  848.      Indent all the lines of the subprogram point is in
  849.      (`fortran-indent-subprogram').
  850.    Fortran mode redefines TAB to reindent the current line for Fortran
  851. (`fortran-indent-line').  This command indents Line numbers and
  852. continuation markers to their required columns, and independently
  853. indents the body of the statement based on its nesting in the program.
  854.    The key `LFD' runs the command `fortran-indent-new-line', which
  855. reindents the current line then makes and indents a new line.  This
  856. command is useful to reindent the closing statement of `do' loops and
  857. other blocks before starting a new line.
  858.    The key `C-M-q' runs `fortran-indent-subprogram', a command to
  859. reindent all the lines of the Fortran subprogram (function or
  860. subroutine) containing point.
  861.    The key `M-LFD' runs `fortran-split-line', which splits a line in
  862. the appropriate fashion for Fortran.  In a non-comment line, the second
  863. half becomes a continuation line and is indented accordingly.  In a
  864. comment line, both halves become separate comment lines.
  865. File: emacs,  Node: ForIndent Cont,  Next: ForIndent Num,  Prev: ForIndent Commands,  Up: Fortran Indent
  866. Continuation Lines
  867. ..................
  868.    Most modern Fortran compilers allow two ways of writing continuation
  869. lines.  If the first non-space character on a line is in column 5, then
  870. that line is a continuation of the previous line.  We call this "fixed
  871. format".  (In GNU Emacs we always count columns from 0.)  A line that
  872. starts with a tab character followed by any digit except `0' is also a
  873. continuation line.  We call this style of continuation "tab format".
  874.    Fortran mode can make either style of continuation line, but you
  875. must specify which one you prefer.  The value of the variable
  876. `indent-tabs-mode' controls the choice: `nil' for fixed format, and
  877. non-`nil' for tab format.  You can tell which style is presently in
  878. effect by the presence or absence of the string `Tab' in the mode line.
  879.    If the text on a line starts with the conventional Fortran
  880. continuation marker `$', or if it begins with any non-whitespace
  881. character in column 5, Fortran mode treats it as a continuation line.
  882. When you indent a continuation line with TAB, it converts the line to
  883. the current continuation style.  When you split a Fortran statement
  884. with `M-LFD', the continuation marker on the newline is created
  885. according to the continuation style.
  886.    The setting of continuation style affects several other aspects of
  887. editing in Fortran mode.  In fixed format mode, the minimum column
  888. number for the body of a statement is 6.  Lines inside of Fortran
  889. blocks that are indented to larger column numbers always use only the
  890. space character for whitespace.  In tab format mode, the minimum column
  891. number for the statement body is 8, and the whitespace before column 8
  892. must always consist of one tab character.
  893.    When you enter Fortran mode for an existing file, it tries to deduce
  894. the proper continuation style automatically from the file contents.
  895. The first line that begins with either a tab character or six spaces
  896. determines the choice.  The variable `fortran-analyze-depth' specifies
  897. how many lines to consider (at the beginning of the file); if none of
  898. those lines indicates a style, then the variable
  899. `fortran-tab-mode-default' specifies the style.  If it is `nil', that
  900. specifies fixed format, and non-`nil' specifies tab format.
  901.