home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / misc / e1858src.lha / emacs-18.58 / info / emacs-7 < prev    next >
Encoding:
GNU Info File  |  1992-02-21  |  49.0 KB  |  1,177 lines

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