home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / emacs.i07 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  50.1 KB  |  1,164 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.47 from the
  2. input file emacs.tex.
  3.  
  4.    This file documents the GNU Emacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  15. General Public License" are included exactly as in the original, and
  16. provided that the entire resulting derived work is distributed under the
  17. terms of a permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions, except that the sections entitled "The GNU Manifesto",
  22. "Distribution" and "GNU General Public License" may be included in a
  23. translation approved by the author instead of in the original English.
  24.  
  25. 
  26. File: emacs,  Node: Paragraphs,  Next: Pages,  Prev: Sentences,  Up: Text
  27.  
  28. Paragraphs
  29. ==========
  30.  
  31.    The Emacs commands for manipulating paragraphs are also `Meta-' keys.
  32.  
  33. `M-['
  34.      Move back to previous paragraph beginning
  35.      (`backward-paragraph').
  36.  
  37. `M-]'
  38.      Move forward to next paragraph end (`forward-paragraph').
  39.  
  40. `M-h'
  41.      Put point and mark around this or next paragraph
  42.      (`mark-paragraph').
  43.  
  44.    `Meta-[' moves to the beginning of the current or previous paragraph,
  45. while `Meta-]' moves to the end of the current or next paragraph. Blank
  46. lines and text formatter command lines separate paragraphs and are not
  47. part of any paragraph.  Also, an indented line starts a new paragraph.
  48.  
  49.    In major modes for programs (as opposed to Text mode), paragraphs
  50. begin and end only at blank lines.  This makes the paragraph commands
  51. continue to be useful even though there are no paragraphs per se.
  52.  
  53.    When there is a fill prefix, then paragraphs are delimited by all
  54. lines which don't start with the fill prefix.  *Note Filling::.
  55.  
  56.    When you wish to operate on a paragraph, you can use the command
  57. `Meta-h' (`mark-paragraph') to set the region around it.  This command
  58. puts point at the beginning and mark at the end of the paragraph point
  59. was in.  If point is between paragraphs (in a run of blank lines, or at
  60. a boundary), the paragraph following point is surrounded by point and
  61. mark.  If there are blank lines preceding the first line of the
  62. paragraph, one of these blank lines is included in the region.  Thus,
  63. for example, `M-h C-w' kills the paragraph around or after point.
  64.  
  65.    The precise definition of a paragraph boundary is controlled by the
  66. variables `paragraph-separate' and `paragraph-start'.  The value of
  67. `paragraph-start' is a regexp that should match any line that either
  68. starts or separates paragraphs.  The value of `paragraph-separate' is
  69. another regexp that should match only lines that separate paragraphs
  70. without being part of any paragraph.  Lines that start a new paragraph
  71. and are contained in it must match both regexps.  For example, normally
  72. `paragraph-start' is `"^[ \t\n\f]"' and `paragraph-separate' is `"^[
  73. \t\f]*$"'.
  74.  
  75.    Normally it is desirable for page boundaries to separate paragraphs.
  76. The default values of these variables recognize the usual separator for
  77. pages.
  78.  
  79. 
  80. File: emacs,  Node: Pages,  Next: Filling,  Prev: Paragraphs,  Up: Text
  81.  
  82. Pages
  83. =====
  84.  
  85.    Files are often thought of as divided into "pages" by the "formfeed"
  86. character (ASCII Control-L, octal code 014).  For example, if a file is
  87. printed on a line printer, each page of the file, in this sense, will
  88. start on a new page of paper.  Emacs treats a page-separator character
  89. just like any other character.  It can be inserted with `C-q C-l', or
  90. deleted with DEL.  Thus, you are free to paginate your file or not. 
  91. However, since pages are often meaningful divisions of the file,
  92. commands are provided to move over them and operate on them.
  93.  
  94. `C-x ['
  95.      Move point to previous page boundary (`backward-page').
  96.  
  97. `C-x ]'
  98.      Move point to next page boundary (`forward-page').
  99.  
  100. `C-x C-p'
  101.      Put point and mark around this page (or another page)
  102.      (`mark-page').
  103.  
  104. `C-x l'
  105.      Count the lines in this page (`count-lines-page').
  106.  
  107.    The `C-x [' (`backward-page') command moves point to immediately
  108. after the previous page delimiter.  If point is already right after a
  109. page delimiter, it skips that one and stops at the previous one.  A
  110. numeric argument serves as a repeat count.  The `C-x ]' (`forward-page')
  111. command moves forward past the next page delimiter.
  112.  
  113.    The `C-x C-p' command (`mark-page') puts point at the beginning of
  114. the current page and the mark at the end.  The page delimiter at the end
  115. is included (the mark follows it).  The page delimiter at the front is
  116. excluded (point follows it).  This command can be followed by `C-w' to
  117. kill a page which is to be moved elsewhere.  If it is inserted after a
  118. page delimiter, at a place where `C-x ]' or `C-x [' would take you, then
  119. the page will be properly delimited before and after once again.
  120.  
  121.    A numeric argument to `C-x C-p' is used to specify which page to go
  122. to, relative to the current one.  Zero means the current page.  One
  123. means the next page, and -1 means the previous one.
  124.  
  125.    The `C-x l' command (`count-lines-page') is good for deciding where
  126. to break a page in two.  It prints in the echo area the total number of
  127. lines in the current page, and then divides it up into those preceding
  128. the current line and those following, as in
  129.  
  130.      Page has 96 (72+25) lines
  131.  
  132. Notice that the sum is off by one; this is correct if point is not at
  133. the beginning of a line.
  134.  
  135.    The variable `page-delimiter' should have as its value a regexp that
  136. matches the beginning of a line that separates pages.  This is what
  137. defines where pages begin.  The normal value of this variable is
  138. `"^\f"', which matches a formfeed character at the beginning of a line.
  139.  
  140. 
  141. File: emacs,  Node: Filling,  Next: Case,  Prev: Pages,  Up: Text
  142.  
  143. Filling Text
  144. ============
  145.  
  146.    With Auto Fill mode, text can be "filled" (broken up into lines that
  147. fit in a specified width) as you insert it.  If you alter existing text
  148. it may no longer be properly filled; then explicit commands for filling
  149. can be used.
  150.  
  151. * Menu:
  152.  
  153. * Auto Fill::      Auto Fill mode breaks long lines automatically.
  154. * Fill Commands:: Commands to refill paragraphs and center lines.
  155. * Fill Prefix::   Filling when every line is indented or in a comment, etc.
  156.  
  157. 
  158. File: emacs,  Node: Auto Fill,  Next: Fill Commands,  Prev: Filling,  Up: Filling
  159.  
  160. Auto Fill Mode
  161. --------------
  162.  
  163.    "Auto Fill" mode is a minor mode in which lines are broken
  164. automatically when they become too wide.  Breaking happens only when
  165. you type a SPC or RET.
  166.  
  167. `M-x auto-fill-mode'
  168.      Enable or disable Auto Fill mode.
  169.  
  170. `SPC'
  171. `RET'
  172.      In Auto Fill mode, break lines when appropriate.
  173.  
  174.    `M-x auto-fill-mode' turns Auto Fill mode on if it was off, or off if
  175. it was on.  With a positive numeric argument it always turns Auto Fill
  176. mode on, and with a negative argument always turns it off.  You can see
  177. when Auto Fill mode is in effect by the presence of the word `Fill' in
  178. the mode line, inside the parentheses.  Auto Fill mode is a minor mode,
  179. turned on or off for each buffer individually.  *Note Minor Modes::.
  180.  
  181.    In Auto Fill mode, lines are broken automatically at spaces when
  182. they get longer than the desired width.  Line breaking and
  183. rearrangement takes place only when you type SPC or RET.  If you wish
  184. to insert a space or newline without permitting line-breaking, type
  185. `C-q SPC' or `C-q LFD' (recall that a newline is really a linefeed). 
  186. Also, `C-o' inserts a newline without line breaking.
  187.  
  188.    Auto Fill mode works well with Lisp mode, because when it makes a new
  189. line in Lisp mode it indents that line with TAB.  If a line ending in a
  190. comment gets too long, the text of the comment is split into two
  191. comment lines.  Optionally new comment delimiters are inserted at the
  192. end of the first line and the beginning of the second so that each line
  193. is a separate comment; the variable `comment-multi-line' controls the
  194. choice (*note Comments::.).
  195.  
  196.    Auto Fill mode does not refill entire paragraphs.  It can break
  197. lines but cannot merge lines.  So editing in the middle of a paragraph
  198. can result in a paragraph that is not correctly filled.  The easiest
  199. way to make the paragraph properly filled again is usually with the
  200. explicit fill commands.
  201.  
  202.    Many users like Auto Fill mode and want to use it in all text files.
  203. The section on init files says how to arrange this permanently for
  204. yourself. *Note Init File::.
  205.  
  206. 
  207. File: emacs,  Node: Fill Commands,  Next: Fill Prefix,  Prev: Auto Fill,  Up: Filling
  208.  
  209. Explicit Fill Commands
  210. ----------------------
  211.  
  212. `M-q'
  213.      Fill current paragraph (`fill-paragraph').
  214.  
  215. `M-g'
  216.      Fill each paragraph in the region (`fill-region').
  217.  
  218. `C-x f'
  219.      Set the fill column (`set-fill-column').
  220.  
  221. `M-x fill-region-as-paragraph.'
  222.      Fill the region, considering it as one paragraph.
  223.  
  224. `M-s'
  225.      Center a line.
  226.  
  227.    To refill a paragraph, use the command `Meta-q' (`fill-paragraph'). 
  228. It causes the paragraph that point is inside, or the one after point if
  229. point is between paragraphs, to be refilled.  All the line-breaks are
  230. removed, and then new ones are inserted where necessary.  `M-q' can be
  231. undone with `C-_'.  *Note Undo::.
  232.  
  233.    To refill many paragraphs, use `M-g' (`fill-region'), which divides
  234. the region into paragraphs and fills each of them.
  235.  
  236.    `Meta-q' and `Meta-g' use the same criteria as `Meta-h' for finding
  237. paragraph boundaries (*note Paragraphs::.).  For more control, you can
  238. use `M-x fill-region-as-paragraph', which refills everything between
  239. point and mark.  This command recognizes only blank lines as paragraph
  240. separators.
  241.  
  242.    A numeric argument to `M-g' or `M-q' causes it to "justify" the text
  243. as well as filling it.  This means that extra spaces are inserted to
  244. make the right margin line up exactly at the fill column.  To remove the
  245. extra spaces, use `M-q' or `M-g' with no argument.
  246.  
  247.    The command `Meta-s' (`center-line') centers the current line within
  248. the current fill column.  With an argument, it centers several lines
  249. individually and moves past them.
  250.  
  251.    The maximum line width for filling is in the variable `fill-column'.
  252. Altering the value of `fill-column' makes it local to the current
  253. buffer; until that time, the default value is in effect.  The default is
  254. initially 70.  *Note Locals::.
  255.  
  256.    The easiest way to set `fill-column' is to use the command `C-x f'
  257. (`set-fill-column').  With no argument, it sets `fill-column' to the
  258. current horizontal position of point.  With a numeric argument, it uses
  259. that as the new fill column.
  260.  
  261. 
  262. File: emacs,  Node: Fill Prefix,  Prev: Fill Commands,  Up: Filling
  263.  
  264. The Fill Prefix
  265. ---------------
  266.  
  267.    To fill a paragraph in which each line starts with a special marker
  268. (which might be a few spaces, giving an indented paragraph), use the
  269. "fill prefix" feature.  The fill prefix is a string which Emacs expects
  270. every line to start with, and which is not included in filling.
  271.  
  272. `C-x .'
  273.      Set the fill prefix (`set-fill-prefix').
  274.  
  275. `M-q'
  276.      Fill a paragraph using current fill prefix (`fill-paragraph').
  277.  
  278. `M-x fill-individual-paragraphs'
  279.      Fill the region, considering each change of indentation as
  280.      starting a new paragraph.
  281.  
  282.    To specify a fill prefix, move to a line that starts with the desired
  283. prefix, put point at the end of the prefix, and give the command
  284. `C-x .' (`set-fill-prefix').  That's a period after the `C-x'.  To turn
  285. off the fill prefix, specify an empty prefix: type `C-x .' with point
  286. at the beginning of a line.
  287.  
  288.    When a fill prefix is in effect, the fill commands remove the fill
  289. prefix from each line before filling and insert it on each line after
  290. filling. The fill prefix is also inserted on new lines made
  291. automatically by Auto Fill mode.  Lines that do not start with the fill
  292. prefix are considered to start paragraphs, both in `M-q' and the
  293. paragraph commands; this is just right if you are using paragraphs with
  294. hanging indentation (every line indented except the first one).  Lines
  295. which are blank or indented once the prefix is removed also separate or
  296. start paragraphs; this is what you want if you are writing
  297. multi-paragraph comments with a comment delimiter on each line.
  298.  
  299.    The fill prefix is stored in the variable `fill-prefix'.  Its value
  300. is a string, or `nil' when there is no fill prefix.  This is a
  301. per-buffer variable; altering the variable affects only the current
  302. buffer, but there is a default value which you can change as well. 
  303. *Note Locals::.
  304.  
  305.    Another way to use fill prefixes is through `M-x
  306. fill-individual-paragraphs'.  This function divides the region into
  307. groups of consecutive lines with the same amount and kind of
  308. indentation and fills each group as a paragraph using its indentation
  309. as a fill prefix.
  310.  
  311. 
  312. File: emacs,  Node: Case,  Prev: Filling,  Up: Text
  313.  
  314. Case Conversion Commands
  315. ========================
  316.  
  317.    Emacs has commands for converting either a single word or any
  318. arbitrary range of text to upper case or to lower case.
  319.  
  320. `M-l'
  321.      Convert following word to lower case (`downcase-word').
  322.  
  323. `M-u'
  324.      Convert following word to upper case (`upcase-word').
  325.  
  326. `M-c'
  327.      Capitalize the following word (`capitalize-word').
  328.  
  329. `C-x C-l'
  330.      Convert region to lower case (`downcase-region').
  331.  
  332. `C-x C-u'
  333.      Convert region to upper case (`upcase-region').
  334.  
  335.    The word conversion commands are the most useful.  `Meta-l'
  336. (`downcase-word') converts the word after point to lower case, moving
  337. past it.  Thus, repeating `Meta-l' converts successive words. `Meta-u'
  338. (`upcase-word') converts to all capitals instead, while `Meta-c'
  339. (`capitalize-word') puts the first letter of the word into upper case
  340. and the rest into lower case.  All these commands convert several words
  341. at once if given an argument.  They are especially convenient for
  342. converting a large amount of text from all upper case to mixed case,
  343. because you can move through the text using `M-l', `M-u' or `M-c' on
  344. each word as appropriate, occasionally using `M-f' instead to skip a
  345. word.
  346.  
  347.    When given a negative argument, the word case conversion commands
  348. apply to the appropriate number of words before point, but do not move
  349. point. This is convenient when you have just typed a word in the wrong
  350. case: you can give the case conversion command and continue typing.
  351.  
  352.    If a word case conversion command is given in the middle of a word,
  353. it applies only to the part of the word which follows point.  This is
  354. just like what `Meta-d' (`kill-word') does.  With a negative argument,
  355. case conversion applies only to the part of the word before point.
  356.  
  357.    The other case conversion commands are `C-x C-u' (`upcase-region')
  358. and `C-x C-l' (`downcase-region'), which convert everything between
  359. point and mark to the specified case.  Point and mark do not move.
  360.  
  361. 
  362. File: emacs,  Node: Programs,  Next: Running,  Prev: Text,  Up: Top
  363.  
  364. Editing Programs
  365. ****************
  366.  
  367.    Emacs has many commands designed to understand the syntax of
  368. programming languages such as Lisp and C.  These commands can
  369.  
  370.    * Move over or kill balanced expressions or "sexps" (*note Lists::.).
  371.  
  372.    * Move over or mark top-level balanced expressions ("defuns", in
  373.      Lisp; functions, in C).
  374.  
  375.    * Show how parentheses balance (*note Matching::.).
  376.  
  377.    * Insert, kill or align comments (*note Comments::.).
  378.  
  379.    * Follow the usual indentation conventions of the language (*note
  380.      Grinding::.).
  381.  
  382.    The commands for words, sentences and paragraphs are very useful in
  383. editing code even though their canonical application is for editing
  384. human language text.  Most symbols contain words (*note Words::.);
  385. sentences can be found in strings and comments (*note Sentences::.). 
  386. Paragraphs per se are not present in code, but the paragraph commands
  387. are useful anyway, because Lisp mode and C mode define paragraphs to
  388. begin and end at blank lines (*note Paragraphs::.).  Judicious use of
  389. blank lines to make the program clearer will also provide interesting
  390. chunks of text for the paragraph commands to work on.
  391.  
  392.    The selective display feature is useful for looking at the overall
  393. structure of a function (*note Selective Display::.).  This feature
  394. causes only the lines that are indented less than a specified amount to
  395. appear on the screen.
  396.  
  397. * Menu:
  398.  
  399. * Program Modes::       Major modes for editing programs.
  400. * Lists::               Expressions with balanced parentheses.
  401.                          There are editing commands to operate on them.
  402. * Defuns::              Each program is made up of separate functions.
  403.                          There are editing commands to operate on them.
  404. * Grinding::            Adjusting indentation to show the nesting.
  405. * Matching::            Insertion of a close-delimiter flashes matching open.
  406. * Comments::            Inserting, illing and aligning comments.
  407. * Balanced Editing::    Inserting two matching parentheses at once, etc.
  408. * Lisp Completion::     Completion on symbol names in Lisp code.
  409. * Documentation::       Getting documentation of functions you plan to call.
  410. * Change Log::          Maintaining a change history for your program.
  411. * Tags::                Go direct to any function in your program in one
  412.                          command.  Tags remembers which file it is in.
  413. * Fortran::        Fortran mode and its special features.
  414.  
  415. 
  416. File: emacs,  Node: Program Modes,  Next: Lists,  Prev: Programs,  Up: Programs
  417.  
  418. Major Modes for Programming Languages
  419. =====================================
  420.  
  421.    Emacs also has major modes for the programming languages Lisp,
  422. Scheme (a variant of Lisp), C, Fortran and Muddle.  Ideally, a major
  423. mode should be implemented for each programming language that you might
  424. want to edit with Emacs; but often the mode for one language can serve
  425. for other syntactically similar languages.  The language modes that
  426. exist are those that someone decided to take the trouble to write.
  427.  
  428.    There are several forms of Lisp mode, which differ in the way they
  429. interface to Lisp execution.  *Note Lisp Modes::.
  430.  
  431.    Each of the programming language modes defines the TAB key to run an
  432. indentation function that knows the indentation conventions of that
  433. language and updates the current line's indentation accordingly.  For
  434. example, in C mode TAB is bound to `c-indent-line'.  LFD is normally
  435. defined to do RET followed by TAB; thus, it too indents in a
  436. mode-specific fashion.
  437.  
  438.    In most programming languages, indentation is likely to vary from
  439. line to line.  So the major modes for those languages rebind DEL to
  440. treat a tab as if it were the equivalent number of spaces (using the
  441. command `backward-delete-char-untabify').  This makes it possible to
  442. rub out indentation one column at a time without worrying whether it is
  443. made up of spaces or tabs.  Use `C-b C-d' to delete a tab character
  444. before point, in these modes.
  445.  
  446.    Programming language modes define paragraphs to be separated only by
  447. blank lines, so that the paragraph commands remain useful.  Auto Fill
  448. mode, if enabled in a programming language major mode, indents the new
  449. lines which it creates.
  450.  
  451.    Turning on a major mode calls a user-supplied function called the
  452. "mode hook", which is the value of a Lisp variable.  For example,
  453. turning on C mode calls the value of the variable `c-mode-hook' if that
  454. value exists and is non-`nil'.  Mode hook variables for other
  455. programming language modes include `lisp-mode-hook',
  456. `emacs-lisp-mode-hook', `lisp-interaction-mode-hook',
  457. `scheme-mode-hook' and `muddle-mode-hook'.  The mode hook function
  458. receives no arguments.
  459.  
  460. 
  461. File: emacs,  Node: Lists,  Next: Defuns,  Prev: Program Modes,  Up: Programs
  462.  
  463. Lists and Sexps
  464. ===============
  465.  
  466.    By convention, Emacs keys for dealing with balanced expressions are
  467. usually `Control-Meta-' characters.  They tend to be analogous in
  468. function to their `Control-' and `Meta-' equivalents.  These commands
  469. are usually thought of as pertaining to expressions in programming
  470. languages, but can be useful with any language in which some sort of
  471. parentheses exist (including English).
  472.  
  473.    These commands fall into two classes.  Some deal only with "lists"
  474. (parenthetical groupings).  They see nothing except parentheses,
  475. brackets, braces (whichever ones must balance in the language you are
  476. working with), and escape characters that might be used to quote those.
  477.  
  478.    The other commands deal with expressions or "sexps".  The word `sexp'
  479. is derived from "s-expression", the ancient term for an expression in
  480. Lisp.  But in Emacs, the notion of `sexp' is not limited to Lisp.  It
  481. refers to an expression in whatever language your program is written in.
  482. Each programming language has its own major mode, which customizes the
  483. syntax tables so that expressions in that language count as sexps.
  484.  
  485.    Sexps typically include symbols, numbers, and string constants, as
  486. well as anything contained in parentheses, brackets or braces.
  487.  
  488.    In languages that use prefix and infix operators, such as C, it is
  489. not possible for all expressions to be sexps.  For example, C mode does
  490. not recognize `foo + bar' as a sexp, even though it is a C expression;
  491. it recognizes `foo' as one sexp and `bar' as another, with the `+' as
  492. punctuation between them.  This is a fundamental ambiguity: both `foo +
  493. bar' and `foo' are legitimate choices for the sexp to move over if
  494. point is at the `f'.  Note that `(foo + bar)' is a sexp in C mode.
  495.  
  496.    Some languages have obscure forms of syntax for expressions that
  497. nobody has bothered to make Emacs understand properly.
  498.  
  499. `C-M-f'
  500.      Move forward over a sexp (`forward-sexp').
  501.  
  502. `C-M-b'
  503.      Move backward over a sexp (`backward-sexp').
  504.  
  505. `C-M-k'
  506.      Kill sexp forward (`kill-sexp').
  507.  
  508. `C-M-u'
  509.      Move up and backward in list structure (`backward-up-list').
  510.  
  511. `C-M-d'
  512.      Move down and forward in list structure (`down-list').
  513.  
  514. `C-M-n'
  515.      Move forward over a list (`forward-list').
  516.  
  517. `C-M-p'
  518.      Move backward over a list (`backward-list').
  519.  
  520. `C-M-t'
  521.      Transpose expressions (`transpose-sexps').
  522.  
  523. `C-M-@'
  524.      Put mark after following expression (`mark-sexp').
  525.  
  526.    To move forward over a sexp, use `C-M-f' (`forward-sexp').  If the
  527. first significant character after point is an opening delimiter (`(' in
  528. Lisp; `(', `[' or `{' in C), `C-M-f' moves past the matching closing
  529. delimiter.  If the character begins a symbol, string, or number,
  530. `C-M-f' moves over that.  If the character after point is a closing
  531. delimiter, `C-M-f' just moves past it.  (This last is not really moving
  532. across a sexp; it is an exception which is included in the definition
  533. of `C-M-f' because it is as useful a behavior as anyone can think of
  534. for that situation.)
  535.  
  536.    The command `C-M-b' (`backward-sexp') moves backward over a sexp. 
  537. The detailed rules are like those above for `C-M-f', but with
  538. directions reversed.  If there are any prefix characters (singlequote,
  539. backquote and comma, in Lisp) preceding the sexp, `C-M-b' moves back
  540. over them as well.
  541.  
  542.    `C-M-f' or `C-M-b' with an argument repeats that operation the
  543. specified number of times; with a negative argument, it moves in the
  544. opposite direction.
  545.  
  546.    The sexp commands move across comments as if they were whitespace, in
  547. languages such as C where the comment-terminator can be recognized.  In
  548. Lisp, and other languages where comments run until the end of a line,
  549. it is very difficult to ignore comments when parsing backwards;
  550. therefore, in such languages the sexp commands treat the text of
  551. comments as if it were code.
  552.  
  553.    Killing a sexp at a time can be done with `C-M-k' (`kill-sexp').
  554. `C-M-k' kills the characters that `C-M-f' would move over.
  555.  
  556.    The "list commands" move over lists like the sexp commands but skip
  557. blithely over any number of other kinds of sexps (symbols, strings,
  558. etc). They are `C-M-n' (`forward-list') and `C-M-p' (`backward-list'). 
  559. The main reason they are useful is that they usually ignore comments
  560. (since the comments usually do not contain any lists).
  561.  
  562.    `C-M-n' and `C-M-p' stay at the same level in parentheses, when
  563. that's possible.  To move up one (or N) levels, use `C-M-u'
  564. (`backward-up-list'). `C-M-u' moves backward up past one unmatched
  565. opening delimiter.  A positive argument serves as a repeat count; a
  566. negative argument reverses direction of motion and also requests
  567. repetition, so it moves forward and up one or more levels.
  568.  
  569.    To move down in list structure, use `C-M-d' (`down-list').  In Lisp
  570. mode, where `(' is the only opening delimiter, this is nearly the same
  571. as searching for a `('.  An argument specifies the number of levels of
  572. parentheses to go down.
  573.  
  574.    A somewhat random-sounding command which is nevertheless easy to use
  575. is `C-M-t' (`transpose-sexps'), which drags the previous sexp across
  576. the next one.  An argument serves as a repeat count, and a negative
  577. argument drags backwards (thus canceling out the effect of `C-M-t' with
  578. a positive argument).  An argument of zero, rather than doing nothing,
  579. transposes the sexps ending after point and the mark.
  580.  
  581.    To make the region be the next sexp in the buffer, use `C-M-@'
  582. (`mark-sexp') which sets mark at the same place that `C-M-f' would move
  583. to.  `C-M-@' takes arguments like `C-M-f'.  In particular, a negative
  584. argument is useful for putting the mark at the beginning of the
  585. previous sexp.
  586.  
  587.    The list and sexp commands' understanding of syntax is completely
  588. controlled by the syntax table.  Any character can, for example, be
  589. declared to be an opening delimiter and act like an open parenthesis.
  590. *Note Syntax::.
  591.  
  592. 
  593. File: emacs,  Node: Defuns,  Next: Grinding,  Prev: Lists,  Up: Programs
  594.  
  595. Defuns
  596. ======
  597.  
  598.    In Emacs, a parenthetical grouping at the top level in the buffer is
  599. called a "defun".  The name derives from the fact that most top-level
  600. lists in a Lisp file are instances of the special form `defun', but any
  601. top-level parenthetical grouping counts as a defun in Emacs parlance
  602. regardless of what its contents are, and regardless of the programming
  603. language in use.  For example, in C, the body of a function definition
  604. is a defun.
  605.  
  606. `C-M-a'
  607.      Move to beginning of current or preceding defun
  608.      (`beginning-of-defun').
  609.  
  610. `C-M-e'
  611.      Move to end of current or following defun (`end-of-defun').
  612.  
  613. `C-M-h'
  614.      Put region around whole current or following defun (`mark-defun').
  615.  
  616.    The commands to move to the beginning and end of the current defun
  617. are `C-M-a' (`beginning-of-defun') and `C-M-e' (`end-of-defun').
  618.  
  619.    If you wish to operate on the current defun, use `C-M-h'
  620. (`mark-defun') which puts point at the beginning and mark at the end of
  621. the current or next defun.  For example, this is the easiest way to get
  622. ready to move the defun to a different place in the text.  In C mode,
  623. `C-M-h' runs the function `mark-c-function', which is almost the same
  624. as `mark-defun'; the difference is that it backs up over the argument
  625. declarations, function name and returned data type so that the entire C
  626. function is inside the region.
  627.  
  628.    Emacs assumes that any open-parenthesis found in the leftmost column
  629. is the start of a defun.  Therefore, never put an open-parenthesis at
  630. the left margin in a Lisp file unless it is the start of a top level
  631. list. Never put an open-brace or other opening delimiter at the
  632. beginning of a line of C code unless it starts the body of a function. 
  633. The most likely problem case is when you want an opening delimiter at
  634. the start of a line inside a string.  To avoid trouble, put an escape
  635. character (`\', in C and Emacs Lisp, `/' in some other Lisp dialects)
  636. before the opening delimiter.  It will not affect the contents of the
  637. string.
  638.  
  639.    In the remotest past, the original Emacs found defuns by moving
  640. upward a level of parentheses until there were no more levels to go up.
  641.  This always required scanning all the way back to the beginning of the
  642. buffer, even for a small function.  To speed up the operation, Emacs
  643. was changed to assume that any `(' (or other character assigned the
  644. syntactic class of opening-delimiter) at the left margin is the start
  645. of a defun.  This heuristic was nearly always right and avoided the
  646. costly scan; however, it mandated the convention described above.
  647.  
  648. 
  649. File: emacs,  Node: Grinding,  Next: Matching,  Prev: Defuns,  Up: Programs
  650.  
  651. Indentation for Programs
  652. ========================
  653.  
  654.    The best way to keep a program properly indented ("ground") is to use
  655. Emacs to re-indent it as you change it.  Emacs has commands to indent
  656. properly either a single line, a specified number of lines, or all of
  657. the lines inside a single parenthetical grouping.
  658.  
  659. * Menu:
  660.  
  661. * Basic Indent::
  662. * Multi-line Indent::   Commands to reindent many lines at once.
  663. * Lisp Indent::        Specifying how each Lisp function should be indented.
  664. * C Indent::        Choosing an indentation style for C code.
  665.  
  666. 
  667. File: emacs,  Node: Basic Indent,  Next: Multi-line Indent,  Prev: Grinding,  Up: Grinding
  668.  
  669. Basic Program Indentation Commands
  670. ----------------------------------
  671.  
  672. `TAB'
  673.      Adjust indentation of current line.
  674.  
  675. `LFD'
  676.      Equivalent to RET followed by TAB (`newline-and-indent').
  677.  
  678.    The basic indentation command is TAB, which gives the current line
  679. the correct indentation as determined from the previous lines.  The
  680. function that TAB runs depends on the major mode; it is
  681. `lisp-indent-line' in Lisp mode, `c-indent-line' in C mode, etc.  These
  682. functions understand different syntaxes for different languages, but
  683. they all do about the same thing.  TAB in any programming language
  684. major mode inserts or deletes whitespace at the beginning of the
  685. current line, independent of where point is in the line.  If point is
  686. inside the whitespace at the beginning of the line, TAB leaves it at
  687. the end of that whitespace; otherwise, TAB leaves point fixed with
  688. respect to the characters around it.
  689.  
  690.    Use `C-q TAB' to insert a tab at point.
  691.  
  692.    When entering a large amount of new code, use LFD
  693. (`newline-and-indent'), which is equivalent to a RET followed by a TAB.
  694.  LFD creates a blank line, and then gives it the appropriate
  695. indentation.
  696.  
  697.    TAB indents the second and following lines of the body of an
  698. parenthetical grouping each under the preceding one; therefore, if you
  699. alter one line's indentation to be nonstandard, the lines below will
  700. tend to follow it.  This is the right behavior in cases where the
  701. standard result of TAB is unaesthetic.
  702.  
  703.    Remember that an open-parenthesis, open-brace or other opening
  704. delimiter at the left margin is assumed by Emacs (including the
  705. indentation routines) to be the start of a function.  Therefore, you
  706. must never have an opening delimiter in column zero that is not the
  707. beginning of a function, not even inside a string.  This restriction is
  708. vital for making the indentation commands fast; you must simply accept
  709. it.  *Note Defuns::, for more information on this.
  710.  
  711. 
  712. File: emacs,  Node: Multi-line Indent,  Next: Lisp Indent,  Prev: Basic Indent,  Up: Grinding
  713.  
  714. Indenting Several Lines
  715. -----------------------
  716.  
  717.    When you wish to re-indent several lines of code which have been
  718. altered or moved to a different level in the list structure, you have
  719. several commands available.
  720.  
  721. `C-M-q'
  722.      Re-indent all the lines within one list (`indent-sexp').
  723.  
  724. `C-u TAB'
  725.      Shift an entire list rigidly sideways so that its first line is
  726.      properly indented.
  727.  
  728. `C-M-\'
  729.      Re-indent all lines in the region (`indent-region').
  730.  
  731.    You can re-indent the contents of a single list by positioning point
  732. before the beginning of it and typing `C-M-q' (`indent-sexp' in Lisp
  733. mode, `indent-c-exp' in C mode; also bound to other suitable functions
  734. in other modes).  The indentation of the line the sexp starts on is not
  735. changed; therefore, only the relative indentation within the list, and
  736. not its position, is changed.  To correct the position as well, type a
  737. TAB before the `C-M-q'.
  738.  
  739.    If the relative indentation within a list is correct but the
  740. indentation of its beginning is not, go to the line the list begins on
  741. and type `C-u TAB'.  When TAB is given a numeric argument, it moves all
  742. the lines in the grouping starting on the current line sideways the
  743. same amount that the current line moves.  It is clever, though, and
  744. does not move lines that start inside strings, or C preprocessor lines
  745. when in C mode.
  746.  
  747.    Another way to specify the range to be re-indented is with point and
  748. mark.  The command `C-M-\' (`indent-region') applies TAB to every line
  749. whose first character is between point and mark.
  750.  
  751. 
  752. File: emacs,  Node: Lisp Indent,  Next: C Indent,  Prev: Multi-line Indent,  Up: Grinding
  753.  
  754. Customizing Lisp Indentation
  755. ----------------------------
  756.  
  757.    The indentation pattern for a Lisp expression can depend on the
  758. function called by the expression.  For each Lisp function, you can
  759. choose among several predefined patterns of indentation, or define an
  760. arbitrary one with a Lisp program.
  761.  
  762.    The standard pattern of indentation is as follows: the second line
  763. of the expression is indented under the first argument, if that is on
  764. the same line as the beginning of the expression; otherwise, the second
  765. line is indented underneath the function name.  Each following line is
  766. indented under the previous line whose nesting depth is the same.
  767.  
  768.    If the variable `lisp-indent-offset' is non-`nil', it overrides the
  769. usual indentation pattern for the second line of an expression, so that
  770. such lines are always indented `lisp-indent-offset' more columns than
  771. the containing list.
  772.  
  773.    The standard pattern is overridded for certain functions.  Functions
  774. whose names start with `def' always indent the second line by
  775. `lisp-body-indention' extra columns beyond the open-parenthesis
  776. starting the expression.
  777.  
  778.    The standard pattern can be overridden in various ways for individual
  779. functions, according to the `lisp-indent-hook' property of the function
  780. name.  There are four possibilities for this property:
  781.  
  782. `nil'
  783.      This is the same as no property; the standard indentation pattern
  784.      is used.
  785.  
  786. `defun'
  787.      The pattern used for function names that start with `def' is used
  788.      for this function also.
  789.  
  790. a number, NUMBER
  791.      The first NUMBER arguments of the function are "distinguished"
  792.      arguments; the rest are considered the "body" of the expression. 
  793.      A line in the expression is indented according to whether the
  794.      first argument on it is distinguished or not.  If the argument is
  795.      part of the body, the line is indented `lisp-body-indent' more
  796.      columns than the open-parenthesis starting the containing
  797.      expression.  If the argument is distinguished and is either the
  798.      first or second argument, it is indented twice that many extra
  799.      columns. If the argument is distinguished and not the first or
  800.      second argument, the standard pattern is followed for that line.
  801.  
  802. a symbol, SYMBOL
  803.      SYMBOL should be a function name; that function is called to
  804.      calculate the indentation of a line within this expression.  The
  805.      function receives two arguments:
  806.     STATE
  807.           The value returned by `parse-partial-sexp' (a Lisp primitive
  808.           for indentation and nesting computation) when it parses up to
  809.           the beginning of this line.
  810.  
  811.     POS
  812.           The position at which the line being indented begins.
  813.  
  814.      It should return either a number, which is the number of columns of
  815.      indentation for that line, or a list whose car is such a number. 
  816.      The difference between returning a number and returning a list is
  817.      that a number says that all following lines at the same nesting
  818.      level should be indented just like this one; a list says that
  819.      following lines might call for different indentations.  This makes
  820.      a difference when the indentation is being computed by `C-M-q'; if
  821.      the value is a number, `C-M-q' need not recalculate indentation
  822.      for the following lines until the end of the list.
  823.  
  824. 
  825. File: emacs,  Node: C Indent,  Prev: Lisp Indent,  Up: Grinding
  826.  
  827. Customizing C Indentation
  828. -------------------------
  829.  
  830.    Two variables control which commands perform C indentation and when.
  831.  
  832.    If `c-auto-newline' is non-`nil', newlines are inserted both before
  833. and after braces that you insert, and after colons and semicolons.
  834. Correct C indentation is done on all the lines that are made this way.
  835.  
  836.    If `c-tab-always-indent' is non-`nil', the TAB command in C mode
  837. does indentation only if point is at the left margin or within the
  838. line's indentation.  If there is non-whitespace to the left of point,
  839. then TAB just inserts a tab character in the buffer.  Normally, this
  840. variable is `nil', and TAB always reindents the current line.
  841.  
  842.    C does not have anything analogous to particular function names for
  843. which special forms of indentation are desirable.  However, it has a
  844. different need for customization facilities: many different styles of C
  845. indentation are in common use.
  846.  
  847.    There are six variables you can set to control the style that Emacs C
  848. mode will use.
  849.  
  850. `c-indent-level'
  851.      Indentation of C statements within surrounding block.  The
  852.      surrounding block's indentation is the indentation of the line on
  853.      which the open-brace appears.
  854.  
  855. `c-continued-statement-offset'
  856.      Extra indentation given to a substatement, such as the then-clause
  857.      of an if or body of a while.
  858.  
  859. `c-brace-offset'
  860.      Extra indentation for line if it starts with an open brace.
  861.  
  862. `c-brace-imaginary-offset'
  863.      An open brace following other text is treated as if it were this
  864.      far to the right of the start of its line.
  865.  
  866. `c-argdecl-indent'
  867.      Indentation level of declarations of C function arguments.
  868.  
  869. `c-label-offset'
  870.      Extra indentation for line that is a label, or case or default.
  871.  
  872.    The variable `c-indent-level' controls the indentation for C
  873. statements with respect to the surrounding block.  In the example
  874.  
  875.          {
  876.            foo ();
  877.  
  878. the difference in indentation between the lines is `c-indent-level'.
  879. Its standard value is 2.
  880.  
  881.    If the open-brace beginning the compound statement is not at the
  882. beginning of its line, the `c-indent-level' is added to the indentation
  883. of the line, not the column of the open-brace.  For example,
  884.  
  885.      if (losing) {
  886.        do_this ();
  887.  
  888. One popular indentation style is that which results from setting
  889. `c-indent-level' to 8 and putting open-braces at the end of a line in
  890. this way.  I prefer to put the open-brace on a separate line.
  891.  
  892.    In fact, the value of the variable `c-brace-imaginary-offset' is
  893. also added to the indentation of such a statement.  Normally this
  894. variable is zero.  Think of this variable as the imaginary position of
  895. the open brace, relative to the first nonblank character on the line. 
  896. By setting this variable to 4 and `c-indent-level' to 0, you can get
  897. this style:
  898.  
  899.      if (x == y) {
  900.          do_it ();
  901.          }
  902.  
  903.    When `c-indent-level' is zero, the statements inside most braces
  904. will line up right under the open brace.  But there is an exception made
  905. for braces in column zero, such as surrounding a function's body.  The
  906. statements just inside it do not go at column zero.  Instead,
  907. `c-brace-offset' and `c-continued-statement-offset' (see below) are
  908. added to produce a typical offset between brace levels, and the
  909. statements are indented that far.
  910.  
  911.    `c-continued-statement-offset' controls the extra indentation for a
  912. line that starts within a statement (but not within parentheses or
  913. brackets).  These lines are usually statements that are within other
  914. statements, such as the then-clauses of `if' statements and the bodies
  915. of `while' statements.  This parameter is the difference in indentation
  916. between the two lines in
  917.  
  918.      if (x == y)
  919.        do_it ();
  920.  
  921. Its standard value is 2.  Some popular indentation styles correspond to
  922. a value of zero for `c-continued-statement-offset'.
  923.  
  924.    `c-brace-offset' is the extra indentation given to a line that
  925. starts with an open-brace.  Its standard value is zero; compare
  926.  
  927.      if (x == y)
  928.        {
  929.  
  930. with
  931.  
  932.      if (x == y)
  933.        do_it ();
  934.  
  935. if `c-brace-offset' were set to 4, the first example would become
  936.  
  937.      if (x == y)
  938.            {
  939.  
  940.    `c-argdecl-indent' controls the indentation of declarations of the
  941. arguments of a C function.  It is absolute: argument declarations
  942. receive exactly `c-argdecl-indent' spaces.  The standard value is 5,
  943. resulting in code like this:
  944.  
  945.      char *
  946.      index (string, char)
  947.           char *string;
  948.           int char;
  949.  
  950.    `c-label-offset' is the extra indentation given to a line that
  951. contains a label, a case statement, or a `default:' statement.  Its
  952. standard value is -2, resulting in code like this
  953.  
  954.      switch (c)
  955.        {
  956.        case 'x':
  957.  
  958. If `c-label-offset' were zero, the same code would be indented as
  959.  
  960.      switch (c)
  961.        {
  962.          case 'x':
  963.  
  964. This example assumes that the other variables above also have their
  965. standard values.
  966.  
  967.    I strongly recommend that you try out the indentation style produced
  968. by the standard settings of these variables, together with putting open
  969. braces on separate lines.  You can see how it looks in all the C source
  970. files of GNU Emacs.
  971.  
  972. 
  973. File: emacs,  Node: Matching,  Next: Comments,  Prev: Grinding,  Up: Programs
  974.  
  975. Automatic Display Of Matching Parentheses
  976. =========================================
  977.  
  978.    The Emacs parenthesis-matching feature is designed to show
  979. automatically how parentheses match in the text.  Whenever a
  980. self-inserting character that is a closing delimiter is typed, the
  981. cursor moves momentarily to the location of the matching opening
  982. delimiter, provided that is on the screen. If it is not on the screen,
  983. some text starting with that opening delimiter is displayed in the echo
  984. area.  Either way, you can tell what grouping is being closed off.
  985.  
  986.    In Lisp, automatic matching applies only to parentheses.  In C, it
  987. applies to braces and brackets too.  Emacs knows which characters to
  988. regard as matching delimiters based on the syntax table, which is set
  989. by the major mode.  *Note Syntax::.
  990.  
  991.    If the opening delimiter and closing delimiter are mismatched--such
  992. as in `[x)'--a warning message is displayed in the echo area.  The
  993. correct matches are specified in the syntax table.
  994.  
  995.    Two variables control parenthesis match display. 
  996. `blink-matching-paren' turns the feature on or off; `nil' turns it off,
  997. but the default is `t' to turn match display on. 
  998. `blink-matching-paren-distance' specifies how many characters back to
  999. search to find the matching opening delimiter.  If the match is not
  1000. found in that far, scanning stops, and nothing is displayed.  This is
  1001. to prevent scanning for the matching delimiter from wasting lots of
  1002. time when there is no match.  The default is 4000.
  1003.  
  1004. 
  1005. File: emacs,  Node: Comments,  Next: Balanced Editing,  Prev: Matching,  Up: Programs
  1006.  
  1007. Manipulating Comments
  1008. =====================
  1009.  
  1010.    The comment commands insert, kill and align comments.
  1011.  
  1012. `M-;'
  1013.      Insert or align comment (`indent-for-comment').
  1014.  
  1015. `C-x ;'
  1016.      Set comment column (`set-comment-column').
  1017.  
  1018. `C-u - C-x ;'
  1019.      Kill comment on current line (`kill-comment').
  1020.  
  1021. `M-LFD'
  1022.      Like RET followed by inserting and aligning a comment
  1023.      (`indent-new-comment-line').
  1024.  
  1025.    The command that creates a comment is `Meta-;'
  1026. (`indent-for-comment'). If there is no comment already on the line, a
  1027. new comment is created, aligned at a specific column called the
  1028. "comment column".  The comment is created by inserting the string Emacs
  1029. thinks comments should start with (the value of `comment-start'; see
  1030. below).  Point is left after that string.  If the text of the line
  1031. extends past the comment column, then the indentation is done to a
  1032. suitable boundary (usually, at least one space is inserted).  If the
  1033. major mode has specified a string to terminate comments, that is
  1034. inserted after point, to keep the syntax valid.
  1035.  
  1036.    `Meta-;' can also be used to align an existing comment.  If a line
  1037. already contains the string that starts comments, then `M-;' just moves
  1038. point after it and re-indents it to the conventional place.  Exception:
  1039. comments starting in column 0 are not moved.
  1040.  
  1041.    Some major modes have special rules for indenting certain kinds of
  1042. comments in certain contexts.  For example, in Lisp code, comments which
  1043. start with two semicolons are indented as if they were lines of code,
  1044. instead of at the comment column.  Comments which start with three
  1045. semicolons are supposed to start at the left margin.  Emacs understands
  1046. these conventions by indenting a double-semicolon comment using TAB,
  1047. and by not changing the indentation of a triple-semicolon comment at
  1048. all.
  1049.  
  1050.      ;; This function is just an example
  1051.      ;;; Here either two or three semicolons are appropriate.
  1052.      (defun foo (x)
  1053.      ;;; And now, the first part of the function:
  1054.        ;; The following line adds one.
  1055.        (1+ x))           ; This line adds one.
  1056.  
  1057.    In C code, a comment preceded on its line by nothing but whitespace
  1058. is indented like a line of code.
  1059.  
  1060.    Even when an existing comment is properly aligned, `M-;' is still
  1061. useful for moving directly to the start of the comment.
  1062.  
  1063.    `C-u - C-x ;' (`kill-comment') kills the comment on the current line,
  1064. if there is one.  The indentation before the start of the comment is
  1065. killed as well.  If there does not appear to be a comment in the line,
  1066. nothing is done.  To reinsert the comment on another line, move to the
  1067. end of that line, do `C-y', and then do `M-;' to realign it.  Note that
  1068. `C-u - C-x ;' is not a distinct key; it is `C-x ;'
  1069. (`set-comment-column') with a negative argument.  That command is
  1070. programmed so that when it receives a negative argument it calls
  1071. `kill-comment'.  However, `kill-comment' is a valid command which you
  1072. could bind directly to a key if you wanted to.
  1073.  
  1074. Multiple Lines of Comments
  1075. --------------------------
  1076.  
  1077.    If you are typing a comment and find that you wish to continue it on
  1078. another line, you can use the command `Meta-LFD'
  1079. (`indent-new-comment-line'), which terminates the comment you are
  1080. typing, creates a new blank line afterward, and begins a new comment
  1081. indented under the old one.  When Auto Fill mode is on, going past the
  1082. fill column while typing a comment causes the comment to be continued
  1083. in just this fashion.  If point is not at the end of the line when
  1084. `M-LFD' is typed, the text on the rest of the line becomes part of the
  1085. new comment line.
  1086.  
  1087. Options Controlling Comments
  1088. ----------------------------
  1089.  
  1090.    The comment column is stored in the variable `comment-column'.  You
  1091. can set it to a number explicitly.  Alternatively, the command `C-x ;'
  1092. (`set-comment-column') sets the comment column to the column point is
  1093. at.  `C-u C-x ;' sets the comment column to match the last comment
  1094. before point in the buffer, and then does a `Meta-;' to align the
  1095. current line's comment under the previous one.  Note that `C-u - C-x ;'
  1096. runs the function `kill-comment' as described above.
  1097.  
  1098.    `comment-column' is a per-buffer variable; altering the variable
  1099. affects only the current buffer, but there is a default value which you
  1100. can change as well.  *Note Locals::.  Many major modes initialize this
  1101. variable for the current buffer.
  1102.  
  1103.    The comment commands recognize comments based on the regular
  1104. expression that is the value of the variable `comment-start-skip'. 
  1105. This regexp should not match the null string.  It may match more than
  1106. the comment starting delimiter in the strictest sense of the word; for
  1107. example, in C mode the value of the variable is `"/\\*+ *"', which
  1108. matches extra stars and spaces after the `/*' itself.  (Note that `\\'
  1109. is needed in Lisp syntax to include a `\' in the string, which is needed
  1110. to deny the first star its special meaning in regexp syntax.  *Note
  1111. Regexps::.)
  1112.  
  1113.    When a comment command makes a new comment, it inserts the value of
  1114. `comment-start' to begin it.  The value of `comment-end' is inserted
  1115. after point, so that it will follow the text that you will insert into
  1116. the comment.  In C mode, `comment-start' has the value `"/* "' and
  1117. `comment-end' has the value `" */"'.
  1118.  
  1119.    `comment-multi-line' controls how `M-LFD' (`indent-new-comment-line')
  1120. behaves when used inside a comment.  If `comment-multi-line' is `nil',
  1121. as it normally is, then the comment on the starting line is terminated
  1122. and a new comment is started on the new following line.  If
  1123. `comment-multi-line' is not `nil', then the new following line is set
  1124. up as part of the same comment that was found on the starting line.
  1125. This is done by not inserting a terminator on the old line, and not
  1126. inserting a starter on the new line.  In languages where multi-line
  1127. comments work, the choice of value for this variable is a matter of
  1128. taste.
  1129.  
  1130.    The variable `comment-indent-hook' should contain a function that
  1131. will be called to compute the indentation for a newly inserted comment
  1132. or for aligning an existing comment.  It is set differently by various
  1133. major modes.  The function is called with no arguments, but with point
  1134. at the beginning of the comment, or at the end of a line if a new
  1135. comment is to be inserted.  It should return the column in which the
  1136. comment ought to start. For example, in Lisp mode, the indent hook
  1137. function bases its decision on how many semicolons begin an existing
  1138. comment, and on the code in the preceding lines.
  1139.  
  1140. 
  1141. File: emacs,  Node: Balanced Editing,  Next: Lisp Completion,  Prev: Comments,  Up: Programs
  1142.  
  1143. Editing Without Unbalanced Parentheses
  1144. ======================================
  1145.  
  1146. `M-('
  1147.      Put parentheses around next sexp(s) (`insert-parentheses').
  1148.  
  1149. `M-)'
  1150.      Move past next close parenthesis and re-indent
  1151.      (`move-over-close-and-reindent').
  1152.  
  1153.    The commands `M-(' (`insert-parentheses') and `M-)'
  1154. (`move-over-close-and-reindent') are designed to facilitate a style of
  1155. editing which keeps parentheses balanced at all times.  `M-(' inserts a
  1156. pair of parentheses, either together as in `()', or, if given an
  1157. argument, around the next several sexps, and leaves point after the open
  1158. parenthesis.  Instead of typing `( F O O )', you can type `M-( F O O',
  1159. which has the same effect except for leaving the cursor before the
  1160. close parenthesis.  Then you would type `M-)', which moves past the
  1161. close parenthesis, deleting any indentation preceding it (in this
  1162. example there is none), and indenting with LFD after it.
  1163.  
  1164.