diff options
| author | Chong Yidong | 2008-11-01 23:39:36 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-11-01 23:39:36 +0000 |
| commit | e722aa81f9fbdcb018d99244d3f89e3718d88b5a (patch) | |
| tree | 98999f1c3acd5e069bf517ac85cc62a7800b9e66 | |
| parent | e2346dea8e7743f76b82b74ab43b96848215891a (diff) | |
| download | emacs-e722aa81f9fbdcb018d99244d3f89e3718d88b5a.tar.gz emacs-e722aa81f9fbdcb018d99244d3f89e3718d88b5a.zip | |
(Program Modes): Link to Program Indent node.
(Left Margin Paren): Explain consequences of changing
open-paren-in-column-0-is-defun-start more concisely.
(Which Function, Program Indent, Info Lookup): Minor edits.
(Basic Indent): If region is active, TAB indents the region.
(Multi-line Indent): If region is active, TAB indents the region. Note
that indent-region is useful when Transient Mark mode is off.
(Matching): The delimiter at the cursor is highlighted---the character
changes color.
(Symbol Completion): Link to Completion node.
| -rw-r--r-- | doc/emacs/programs.texi | 305 |
1 files changed, 148 insertions, 157 deletions
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 2b8cbf895fa..c48d564b589 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi | |||
| @@ -55,8 +55,9 @@ Highlight program syntax (@pxref{Font Lock}). | |||
| 55 | @xref{Major Modes}. A programming language major mode typically | 55 | @xref{Major Modes}. A programming language major mode typically |
| 56 | specifies the syntax of expressions, the customary rules for | 56 | specifies the syntax of expressions, the customary rules for |
| 57 | indentation, how to do syntax highlighting for the language, and how | 57 | indentation, how to do syntax highlighting for the language, and how |
| 58 | to find the beginning of a function definition. It often customizes | 58 | to find the beginning or end of a function definition. It often |
| 59 | or provides facilities for compiling and debugging programs as well. | 59 | customizes or provides facilities for compiling and debugging programs |
| 60 | as well. | ||
| 60 | 61 | ||
| 61 | Ideally, Emacs should provide a major mode for each programming | 62 | Ideally, Emacs should provide a major mode for each programming |
| 62 | language that you might want to edit; if it doesn't have a mode for | 63 | language that you might want to edit; if it doesn't have a mode for |
| @@ -85,28 +86,28 @@ and you can select it by typing @kbd{M-x @var{l}-mode @key{RET}}. | |||
| 85 | @cindex PostScript mode | 86 | @cindex PostScript mode |
| 86 | @cindex Conf mode | 87 | @cindex Conf mode |
| 87 | @cindex DNS mode | 88 | @cindex DNS mode |
| 88 | The existing programming language major modes include Lisp, Scheme (a | 89 | The existing programming language major modes include Lisp, Scheme |
| 89 | variant of Lisp) and the Scheme-based DSSSL expression language, Ada, | 90 | (a variant of Lisp) and the Scheme-based DSSSL expression language, |
| 90 | ASM, AWK, C, C++, Delphi (Object Pascal), Fortran (free format and fixed | 91 | Ada, ASM, AWK, C, C++, Delphi (Object Pascal), Fortran, Icon, IDL |
| 91 | format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s | 92 | (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s companion for font |
| 92 | companion for font creation), Modula2, Objective-C, Octave, Pascal, | 93 | creation), Modula2, Objective-C, Octave, Pascal, Perl, Pike, |
| 93 | Perl, Pike, PostScript, Prolog, Python, Simula, Tcl, and VHDL. An | 94 | PostScript, Prolog, Python, Simula, Tcl, and VHDL. An alternative |
| 94 | alternative mode for Perl is called CPerl mode. Modes are available for | 95 | mode for Perl is called CPerl mode. Modes are available for the |
| 95 | the scripting languages of the common GNU and Unix shells, VMS DCL, and | 96 | scripting languages of the common GNU and Unix shells, VMS DCL, and |
| 96 | MS-DOS/MS-Windows @samp{BAT} files. There are also major modes for | 97 | MS-DOS/MS-Windows @samp{BAT} files. There are also major modes for |
| 97 | editing makefiles, DNS master files, and various sorts of configuration | 98 | editing makefiles, DNS master files, and various sorts of |
| 98 | files. | 99 | configuration files. |
| 99 | 100 | ||
| 100 | @kindex DEL @r{(programming modes)} | 101 | @kindex DEL @r{(programming modes)} |
| 101 | @findex c-electric-backspace | 102 | @findex c-electric-backspace |
| 102 | In most programming languages, indentation should vary from line to | 103 | In most programming languages, indentation should vary from line to |
| 103 | line to illustrate the structure of the program. So the major modes | 104 | line to illustrate the structure of the program. So the major modes |
| 104 | for programming languages arrange for @key{TAB} to update the | 105 | for programming languages arrange for @key{TAB} to update the |
| 105 | indentation of the current line. They also rebind @key{DEL} to treat | 106 | indentation of the current line (@pxref{Program Indent}). They also |
| 106 | a tab as if it were the equivalent number of spaces; this lets you | 107 | rebind @key{DEL} to treat a tab as if it were the equivalent number of |
| 107 | delete one column of indentation without worrying whether the | 108 | spaces; this lets you delete one column of indentation without |
| 108 | whitespace consists of spaces or tabs. Use @kbd{C-b C-d} to delete a | 109 | worrying whether the whitespace consists of spaces or tabs. Use |
| 109 | tab character before point, in these modes. | 110 | @kbd{C-b C-d} to delete a tab character before point, in these modes. |
| 110 | 111 | ||
| 111 | Separate manuals are available for the modes for Ada (@pxref{Top, , Ada | 112 | Separate manuals are available for the modes for Ada (@pxref{Top, , Ada |
| 112 | Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL/Pike/AWK | 113 | Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL/Pike/AWK |
| @@ -120,7 +121,6 @@ mode, see | |||
| 120 | @ref{Fortran}. | 121 | @ref{Fortran}. |
| 121 | @end ifnottex | 122 | @end ifnottex |
| 122 | 123 | ||
| 123 | |||
| 124 | @cindex mode hook | 124 | @cindex mode hook |
| 125 | @vindex c-mode-hook | 125 | @vindex c-mode-hook |
| 126 | @vindex lisp-mode-hook | 126 | @vindex lisp-mode-hook |
| @@ -138,9 +138,9 @@ place to set up customizations for that major mode. @xref{Hooks}. | |||
| 138 | @node Defuns | 138 | @node Defuns |
| 139 | @section Top-Level Definitions, or Defuns | 139 | @section Top-Level Definitions, or Defuns |
| 140 | 140 | ||
| 141 | In Emacs, a major definition at the top level in the buffer, | 141 | In Emacs, a major definition at the top level in the buffer, such as |
| 142 | something like a function, is called a @dfn{defun}. The name comes | 142 | a function, is called a @dfn{defun}. The name comes from Lisp, but in |
| 143 | from Lisp, but in Emacs we use it for all languages. | 143 | Emacs we use it for all languages. |
| 144 | 144 | ||
| 145 | @menu | 145 | @menu |
| 146 | * Left Margin Paren:: An open-paren or similar opening delimiter | 146 | * Left Margin Paren:: An open-paren or similar opening delimiter |
| @@ -155,18 +155,22 @@ from Lisp, but in Emacs we use it for all languages. | |||
| 155 | 155 | ||
| 156 | @cindex open-parenthesis in leftmost column | 156 | @cindex open-parenthesis in leftmost column |
| 157 | @cindex ( in leftmost column | 157 | @cindex ( in leftmost column |
| 158 | Emacs assumes by default that any opening delimiter found at the | 158 | Many programming-language modes assume by default that any opening |
| 159 | left margin is the start of a top-level definition, or defun. | 159 | delimiter found at the left margin is the start of a top-level |
| 160 | Therefore, @strong{don't put an opening delimiter at the left margin | 160 | definition, or defun. Therefore, @strong{don't put an opening |
| 161 | unless it should have that significance}. For instance, never put an | 161 | delimiter at the left margin unless it should have that significance}. |
| 162 | open-parenthesis at the left margin in a Lisp file unless it is the | 162 | For instance, never put an open-parenthesis at the left margin in a |
| 163 | start of a top-level list. | 163 | Lisp file unless it is the start of a top-level list. |
| 164 | |||
| 165 | The convention speeds up many Emacs operations, which would | ||
| 166 | otherwise have to scan back to the beginning of the buffer to analyze | ||
| 167 | the syntax of the code. | ||
| 164 | 168 | ||
| 165 | If you don't follow this convention, not only will you have trouble | 169 | If you don't follow this convention, not only will you have trouble |
| 166 | when you explicitly use the commands for motion by defuns; other | 170 | when you explicitly use the commands for motion by defuns; other |
| 167 | features that use them will also give you trouble. This includes | 171 | features that use them will also give you trouble. This includes the |
| 168 | the indentation commands (@pxref{Program Indent}) and Font Lock | 172 | indentation commands (@pxref{Program Indent}) and Font Lock mode |
| 169 | mode (@pxref{Font Lock}). | 173 | (@pxref{Font Lock}). |
| 170 | 174 | ||
| 171 | The most likely problem case is when you want an opening delimiter | 175 | The most likely problem case is when you want an opening delimiter |
| 172 | at the start of a line inside a string. To avoid trouble, put an | 176 | at the start of a line inside a string. To avoid trouble, put an |
| @@ -185,8 +189,8 @@ delimiter from starting a defun. Here's an example: | |||
| 185 | highlights confusing opening delimiters (those that ought to be | 189 | highlights confusing opening delimiters (those that ought to be |
| 186 | quoted) in bold red. | 190 | quoted) in bold red. |
| 187 | 191 | ||
| 188 | If you need to override this convention, you can so by setting this | 192 | If you need to override this convention, you can do so by setting |
| 189 | user option: | 193 | this user option: |
| 190 | 194 | ||
| 191 | @defvar open-paren-in-column-0-is-defun-start | 195 | @defvar open-paren-in-column-0-is-defun-start |
| 192 | If this user option is set to @code{t} (the default), opening | 196 | If this user option is set to @code{t} (the default), opening |
| @@ -195,25 +199,14 @@ parentheses or braces at column zero always start defuns. When it's | |||
| 195 | outermost level. | 199 | outermost level. |
| 196 | @end defvar | 200 | @end defvar |
| 197 | 201 | ||
| 198 | Usually, you shouldn't need to set | 202 | Usually, you should leave this option at its default value of |
| 199 | @code{open-paren-in-column-0-is-defun-start} to @code{nil}. However, | 203 | @code{t}. If your buffer contains parentheses or braces in column |
| 200 | if your buffer contains parentheses or braces in column zero which | 204 | zero which don't start defuns, and it is somehow impractical to remove |
| 201 | don't start defuns and this confuses Emacs, it sometimes helps to set | 205 | these parentheses or braces, it might be helpful to set the option to |
| 202 | the option to @code{nil}. Be aware, though, that this will make | 206 | @code{nil}. Be aware that this might make scrolling and display in |
| 203 | scrolling and display in large buffers quite sluggish, and that | 207 | large buffers quite sluggish. Furthermore, the parentheses and braces |
| 204 | parentheses and braces must be correctly matched throughout the buffer | 208 | must be correctly matched throughout the buffer for it to work |
| 205 | for it to work properly. | 209 | properly. |
| 206 | |||
| 207 | In the earliest days, the original Emacs found defuns by moving | ||
| 208 | upward a level of parentheses or braces until there were no more | ||
| 209 | levels to go up. This always required scanning all the way back to | ||
| 210 | the beginning of the buffer, even for a small function. To speed up | ||
| 211 | the operation, we changed Emacs to assume that any opening delimiter | ||
| 212 | at the left margin is the start of a defun. This heuristic is nearly | ||
| 213 | always right, and avoids the need to scan back to the beginning of the | ||
| 214 | buffer. However, now that modern computers are so powerful, this | ||
| 215 | scanning is rarely slow enough to annoy, so we've provided a way to | ||
| 216 | disable the heuristic. | ||
| 217 | 210 | ||
| 218 | @node Moving by Defuns | 211 | @node Moving by Defuns |
| 219 | @subsection Moving by Defuns | 212 | @subsection Moving by Defuns |
| @@ -339,21 +332,22 @@ buffer. | |||
| 339 | @findex which-function-mode | 332 | @findex which-function-mode |
| 340 | @vindex which-func-modes | 333 | @vindex which-func-modes |
| 341 | To either enable or disable Which Function mode, use the command | 334 | To either enable or disable Which Function mode, use the command |
| 342 | @kbd{M-x which-function-mode}. This command is global; it applies to | 335 | @kbd{M-x which-function-mode}. This command applies to all buffers, |
| 343 | all buffers, both existing ones and those yet to be created. However, | 336 | both existing ones and those yet to be created. However, it takes |
| 344 | it takes effect only in certain major modes, those listed in the value | 337 | effect only in certain major modes, those listed in the value of |
| 345 | of @code{which-func-modes}. If the value is @code{t}, then Which | 338 | @code{which-func-modes}. If the value of @code{which-func-modes} is |
| 346 | Function mode applies to all major modes that know how to support | 339 | @code{t} rather than a list of modes, then Which Function mode applies |
| 347 | it---in other words, all the major modes that support Imenu. | 340 | to all major modes that know how to support it---in other words, all |
| 341 | the major modes that support Imenu. | ||
| 348 | 342 | ||
| 349 | @node Program Indent | 343 | @node Program Indent |
| 350 | @section Indentation for Programs | 344 | @section Indentation for Programs |
| 351 | @cindex indentation for programs | 345 | @cindex indentation for programs |
| 352 | 346 | ||
| 353 | The best way to keep a program properly indented is to use Emacs to | 347 | The best way to keep a program properly indented is to use Emacs to |
| 354 | reindent it as you change it. Emacs has commands to indent properly | 348 | reindent it as you change it. Emacs has commands to indent either a |
| 355 | either a single line, a specified number of lines, or all of the lines | 349 | single line, a specified number of lines, or all of the lines inside a |
| 356 | inside a single parenthetical grouping. | 350 | single parenthetical grouping. |
| 357 | 351 | ||
| 358 | @menu | 352 | @menu |
| 359 | * Basic Indent:: Indenting a single line. | 353 | * Basic Indent:: Indenting a single line. |
| @@ -373,7 +367,6 @@ This program reformats a Lisp object with indentation chosen to look nice. | |||
| 373 | The basic indentation commands indent a single line according to the | 367 | The basic indentation commands indent a single line according to the |
| 374 | usual conventions of the language you are editing. | 368 | usual conventions of the language you are editing. |
| 375 | 369 | ||
| 376 | @need 1000 | ||
| 377 | @table @kbd | 370 | @table @kbd |
| 378 | @item @key{TAB} | 371 | @item @key{TAB} |
| 379 | Adjust indentation of current line. | 372 | Adjust indentation of current line. |
| @@ -386,18 +379,18 @@ Insert a newline, then adjust indentation of following line | |||
| 386 | @findex c-indent-command | 379 | @findex c-indent-command |
| 387 | @findex indent-line-function | 380 | @findex indent-line-function |
| 388 | @findex indent-for-tab-command | 381 | @findex indent-for-tab-command |
| 389 | The basic indentation command is @key{TAB}, which gives the current line | 382 | The basic indentation command is @key{TAB}. In any |
| 390 | the correct indentation as determined from the previous lines. The | 383 | programming-language major mode, @key{TAB} gives the current line the |
| 391 | function that @key{TAB} runs depends on the major mode; it is | 384 | correct indentation as determined from the previous lines. It does |
| 392 | @code{lisp-indent-line} | 385 | this by inserting or deleting whitespace at the beginning of the |
| 393 | in Lisp mode, @code{c-indent-command} in C mode, etc. These functions | 386 | current line. If point was inside the whitespace at the beginning of |
| 394 | understand the syntax and conventions of different languages, but they all do | 387 | the line, @key{TAB} puts it at the end of that whitespace; otherwise, |
| 395 | conceptually the same job: @key{TAB} in any programming-language major mode | 388 | @key{TAB} keeps point fixed with respect to the characters around it. |
| 396 | inserts or deletes whitespace at the beginning of the current line, | 389 | If the region is active (@pxref{Mark}), @key{TAB} indents every line |
| 397 | independent of where point is in the line. If point was inside the | 390 | within the region instead of just the current line. The function that |
| 398 | whitespace at the beginning of the line, @key{TAB} puts it at the end of | 391 | @key{TAB} runs depends on the major mode; for instance, it is |
| 399 | that whitespace; otherwise, @key{TAB} keeps point fixed with respect to | 392 | @code{c-indent-line-or-region} in C mode. Each function is aware of |
| 400 | the characters around it. | 393 | the syntax and conventions for its particular language. |
| 401 | 394 | ||
| 402 | Use @kbd{C-q @key{TAB}} to insert a tab character at point. | 395 | Use @kbd{C-q @key{TAB}} to insert a tab character at point. |
| 403 | 396 | ||
| @@ -406,40 +399,43 @@ the characters around it. | |||
| 406 | When entering lines of new code, use @kbd{C-j} | 399 | When entering lines of new code, use @kbd{C-j} |
| 407 | (@code{newline-and-indent}), which inserts a newline and then adjusts | 400 | (@code{newline-and-indent}), which inserts a newline and then adjusts |
| 408 | indentation after it. (It also deletes any trailing whitespace which | 401 | indentation after it. (It also deletes any trailing whitespace which |
| 409 | remains before the new newline.) Thus, @kbd{C-j} at the end of a line | 402 | remains before the new newline.) For instance, @kbd{C-j} at the end |
| 410 | creates a blank line with appropriate indentation. In programming | 403 | of a line creates a blank line with appropriate indentation. In |
| 411 | language modes, it is equivalent to @key{RET} @key{TAB}. | 404 | programming language modes, it is equivalent to @key{RET} @key{TAB}. |
| 412 | 405 | ||
| 413 | @key{TAB} indents a line that starts within a parenthetical grouping | 406 | When Emacs indents a line that starts within a parenthetical |
| 414 | under the preceding line within the grouping, or the text after the | 407 | grouping, it usually places the start of the line under the preceding |
| 415 | parenthesis. Therefore, if you manually give one of these lines a | 408 | line within the group, or under the text after the parenthesis. If |
| 416 | nonstandard indentation, the lines below will tend to follow it. This | 409 | you manually give one of these lines a nonstandard indentation, the |
| 417 | behavior is convenient in cases where you have overridden the standard | 410 | lines below will tend to follow it. This behavior is convenient in |
| 418 | result of @key{TAB} because you find it unaesthetic for a particular | 411 | cases where you have overridden the standard result of @key{TAB} |
| 419 | line. | 412 | indentation (e.g., for aesthetic purposes). |
| 420 | 413 | ||
| 421 | In some modes, an open-parenthesis, open-brace or other opening | 414 | Many programming-language modes assume that an open-parenthesis, |
| 422 | delimiter at the left margin is assumed by Emacs (including the | 415 | open-brace or other opening delimiter at the left margin is the start |
| 423 | indentation routines) to be the start of a function. This speeds up | 416 | of a function. This assumption speeds up indentation commands. If |
| 424 | indentation commands. If you will be editing text which contains | 417 | the text you are editing contains opening delimiters in column zero |
| 425 | opening delimiters in column zero that aren't the beginning of a | 418 | that aren't the beginning of a functions---even if these delimiters |
| 426 | functions, even inside strings or comments, you must set | 419 | occur inside strings or comments---then you must set |
| 427 | @code{open-paren-in-column-0-is-defun-start}. @xref{Left Margin | 420 | @code{open-paren-in-column-0-is-defun-start}. @xref{Left Margin |
| 428 | Paren}, for more information on this. | 421 | Paren}. |
| 429 | 422 | ||
| 430 | Normally, lines are indented with tabs and spaces. If you want Emacs | 423 | Normally, Emacs indents lines using an ``optimal'' mix of tab and |
| 431 | to use spaces only, set @code{indent-tabs-mode} (@pxref{Just Spaces}). | 424 | space characters. If you want Emacs to use spaces only, set |
| 425 | @code{indent-tabs-mode} (@pxref{Just Spaces}). | ||
| 432 | 426 | ||
| 433 | @node Multi-line Indent | 427 | @node Multi-line Indent |
| 434 | @subsection Indenting Several Lines | 428 | @subsection Indenting Several Lines |
| 435 | 429 | ||
| 436 | When you wish to reindent several lines of code which have been | 430 | Sometimes, you may want to reindent several lines of code at a time. |
| 437 | altered or moved to a different level in the parenthesis structure, | 431 | One way to do this is to use the mark; when the mark is active and the |
| 438 | you have several commands available. | 432 | region is non-empty, @key{TAB} indents every line within the region. |
| 433 | In addition, Emacs provides several other commands for indenting large | ||
| 434 | chunks of code: | ||
| 439 | 435 | ||
| 440 | @table @kbd | 436 | @table @kbd |
| 441 | @item C-M-q | 437 | @item C-M-q |
| 442 | Reindent all the lines within one parenthetical grouping (@code{indent-pp-sexp}). | 438 | Reindent all the lines within one parenthetical grouping. |
| 443 | @item C-M-\ | 439 | @item C-M-\ |
| 444 | Reindent all lines in the region (@code{indent-region}). | 440 | Reindent all lines in the region (@code{indent-region}). |
| 445 | @item C-u @key{TAB} | 441 | @item C-u @key{TAB} |
| @@ -452,38 +448,38 @@ lines that start inside comments and strings. | |||
| 452 | 448 | ||
| 453 | @kindex C-M-q | 449 | @kindex C-M-q |
| 454 | @findex indent-pp-sexp | 450 | @findex indent-pp-sexp |
| 455 | You can reindent the contents of a single parenthetical grouping by | 451 | To reindent the contents of a single parenthetical grouping, |
| 456 | positioning point before the beginning of it and typing @kbd{C-M-q} | 452 | position point before the beginning of the grouping and type |
| 457 | (@code{indent-pp-sexp} in Lisp mode, @code{c-indent-exp} in C mode; also | 453 | @kbd{C-M-q}. This changes the relative indentation within the |
| 458 | bound to other suitable commands in other modes). The indentation of | 454 | grouping, without affecting its overall indentation (i.e., the |
| 459 | the line where the grouping starts is not changed; therefore this | 455 | indentation of the line where the grouping starts). The function that |
| 460 | changes only the relative indentation within the grouping, not its | 456 | @kbd{C-M-q} runs depends on the major mode; it is |
| 461 | overall indentation. To correct that as well, type @key{TAB} first. | 457 | @code{indent-pp-sexp} in Lisp mode, @code{c-indent-exp} in C mode, |
| 462 | 458 | etc. To correct the overall indentation as well, type @key{TAB} | |
| 463 | Another way to specify the range to be reindented is with the | 459 | first. |
| 464 | region. The command @kbd{C-M-\} (@code{indent-region}) applies | 460 | |
| 465 | @key{TAB} to every line whose first character is between point and | 461 | @kbd{C-M-\} (@code{indent-region}) applies @key{TAB} to the region. |
| 466 | mark. | 462 | This is useful when Transient Mark mode is disabled (@pxref{Persistent |
| 463 | Mark}), because in that case @key{TAB} does not act on the region. | ||
| 467 | 464 | ||
| 468 | @kindex C-u TAB | 465 | @kindex C-u TAB |
| 469 | If you like the relative indentation within a grouping, but not the | 466 | If you like the relative indentation within a grouping but not the |
| 470 | indentation of its first line, you can type @kbd{C-u @key{TAB}} to | 467 | indentation of its first line, move point to that first line and type |
| 471 | reindent the whole grouping as a rigid unit. (This works in Lisp | 468 | @kbd{C-u @key{TAB}}. In Lisp, C, and some other major modes, |
| 472 | modes and C and related modes.) @key{TAB} with a numeric argument | 469 | @key{TAB} with a numeric argument reindents the current line as usual, |
| 473 | reindents the current line as usual, then reindents by the same amount | 470 | then reindents by the same amount all the lines in the parenthetical |
| 474 | all the lines in the parenthetical grouping starting on the current | 471 | grouping starting on the current line. It is clever, though, and does |
| 475 | line. It is clever, though, and does not alter lines that start | 472 | not alter lines that start inside strings. Neither does it alter C |
| 476 | inside strings. Neither does it alter C preprocessor lines when in C | 473 | preprocessor lines when in C mode, but it does reindent any |
| 477 | mode, but it does reindent any continuation lines that may be attached | 474 | continuation lines that may be attached to them. |
| 478 | to them. | ||
| 479 | 475 | ||
| 480 | @findex indent-code-rigidly | 476 | @findex indent-code-rigidly |
| 481 | You can also perform this operation on the region, using the command | 477 | The command @kbd{M-x indent-code-rigidly} rigidly shifts all the |
| 482 | @kbd{M-x indent-code-rigidly}. It rigidly shifts all the lines in the | 478 | lines in the region sideways, like @code{indent-rigidly} does |
| 483 | region sideways, like @code{indent-rigidly} does (@pxref{Indentation | 479 | (@pxref{Indentation Commands}). It doesn't alter the indentation of |
| 484 | Commands}). It doesn't alter the indentation of lines that start | 480 | lines that start inside a string, unless the region also starts inside |
| 485 | inside a string, unless the region also starts inside that string. | 481 | that string. The prefix arg specifies the number of columns to |
| 486 | The prefix arg specifies the number of columns to indent. | 482 | indent. |
| 487 | 483 | ||
| 488 | @node Lisp Indent | 484 | @node Lisp Indent |
| 489 | @subsection Customizing Lisp Indentation | 485 | @subsection Customizing Lisp Indentation |
| @@ -852,12 +848,10 @@ lots of time when there is no match. The default is 25600. | |||
| 852 | @cindex highlighting matching parentheses | 848 | @cindex highlighting matching parentheses |
| 853 | @findex show-paren-mode | 849 | @findex show-paren-mode |
| 854 | Show Paren mode provides a more powerful kind of automatic matching. | 850 | Show Paren mode provides a more powerful kind of automatic matching. |
| 855 | Whenever point is after a closing delimiter, that delimiter and its | 851 | Whenever point is before an opening delimiter or after a closing |
| 856 | matching opening delimiter are both highlighted; otherwise, if point | 852 | delimiter, both that delimiter and its opposite delimiter are |
| 857 | is before an opening delimiter, the matching closing delimiter is | 853 | highlighted. Use the command @kbd{M-x show-paren-mode} to enable or |
| 858 | highlighted. (There is no need to highlight the opening delimiter in | 854 | disable this mode. |
| 859 | that case, because the cursor appears on top of that character.) Use | ||
| 860 | the command @kbd{M-x show-paren-mode} to enable or disable this mode. | ||
| 861 | 855 | ||
| 862 | Show Paren mode uses the faces @code{show-paren-match} and | 856 | Show Paren mode uses the faces @code{show-paren-match} and |
| 863 | @code{show-paren-mismatch} to highlight parentheses; you can customize | 857 | @code{show-paren-mismatch} to highlight parentheses; you can customize |
| @@ -883,8 +877,7 @@ also do spell checking on comments with Flyspell Prog mode | |||
| 883 | @cindex indentation for comments | 877 | @cindex indentation for comments |
| 884 | @cindex alignment for comments | 878 | @cindex alignment for comments |
| 885 | 879 | ||
| 886 | The comment commands in this table insert, kill and align comments. | 880 | The commands in this table insert, kill and align comments: |
| 887 | They are described in this section and following sections. | ||
| 888 | 881 | ||
| 889 | @table @asis | 882 | @table @asis |
| 890 | @item @kbd{M-;} | 883 | @item @kbd{M-;} |
| @@ -943,14 +936,14 @@ programmed so that when it receives a prefix argument it calls | |||
| 943 | @code{comment-kill}. However, @code{comment-kill} is a valid command | 936 | @code{comment-kill}. However, @code{comment-kill} is a valid command |
| 944 | in its own right, and you can bind it directly to a key if you wish. | 937 | in its own right, and you can bind it directly to a key if you wish. |
| 945 | 938 | ||
| 946 | When a region is active, @kbd{M-;} does either adds or removes | 939 | When a region is active, @kbd{M-;} either adds or removes comment |
| 947 | comment delimiters on each line of the region. @xref{Mark}. If every | 940 | delimiters on each line of the region. @xref{Mark}. If every line in |
| 948 | line in the region is a comment, it removes comment delimiters from | 941 | the region is a comment, it removes comment delimiters from each; |
| 949 | each; otherwise, it adds comment delimiters to each. You can also use | 942 | otherwise, it adds comment delimiters to each. You can also use the |
| 950 | the commands @code{comment-region} and @code{uncomment-region} to do | 943 | commands @code{comment-region} and @code{uncomment-region} to do these |
| 951 | these jobs (@pxref{Multi-Line Comments}). A prefix argument used in | 944 | jobs (@pxref{Multi-Line Comments}). A prefix argument used in these |
| 952 | these circumstances specifies how many comment delimiters to add or | 945 | circumstances specifies how many comment delimiters to add or how many |
| 953 | how many to delete. | 946 | to delete. |
| 954 | 947 | ||
| 955 | Some major modes have special rules for aligning certain kinds of | 948 | Some major modes have special rules for aligning certain kinds of |
| 956 | comments in certain contexts. For example, in Lisp code, comments which | 949 | comments in certain contexts. For example, in Lisp code, comments which |
| @@ -970,13 +963,12 @@ and by not changing the indentation of a triple-semicolon comment at all. | |||
| 970 | (1+ x)) ; This line adds one. | 963 | (1+ x)) ; This line adds one. |
| 971 | @end example | 964 | @end example |
| 972 | 965 | ||
| 973 | For C-like modes, you can configure the exact effect of @kbd{M-;} | 966 | For C-like modes, you can configure the exact effect of @kbd{M-;} by |
| 974 | more flexibly than for most buffers by setting the variables | 967 | setting the variables @code{c-indent-comment-alist} and |
| 975 | @code{c-indent-comment-alist} and | ||
| 976 | @code{c-indent-comments-syntactically-p}. For example, on a line | 968 | @code{c-indent-comments-syntactically-p}. For example, on a line |
| 977 | ending in a closing brace, @kbd{M-;} puts the comment one space after | 969 | ending in a closing brace, @kbd{M-;} puts the comment one space after |
| 978 | the brace rather than at @code{comment-column}. For full details see | 970 | the brace rather than at @code{comment-column}. For full details see |
| 979 | @ref{Comment Commands,,, ccmode, The CC Mode Manual}. | 971 | @ref{Comment Commands,,, ccmode, The CC Mode Manual}. |
| 980 | 972 | ||
| 981 | @node Multi-Line Comments | 973 | @node Multi-Line Comments |
| 982 | @subsection Multiple Lines of Comments | 974 | @subsection Multiple Lines of Comments |
| @@ -1109,14 +1101,13 @@ use in your program. | |||
| 1109 | @findex info-lookup-symbol | 1101 | @findex info-lookup-symbol |
| 1110 | @findex info-lookup-file | 1102 | @findex info-lookup-file |
| 1111 | @kindex C-h S | 1103 | @kindex C-h S |
| 1112 | For many major modes, that apply to languages that have | 1104 | For major modes that apply to languages which have documentation in |
| 1113 | documentation in Info, you can use @kbd{C-h S} | 1105 | Info, you can use @kbd{C-h S} (@code{info-lookup-symbol}) to view the |
| 1114 | (@code{info-lookup-symbol}) to view the Info documentation for a | 1106 | Info documentation for a symbol used in the program. You specify the |
| 1115 | symbol used in the program. You specify the symbol with the | 1107 | symbol with the minibuffer; the default is the symbol appearing in the |
| 1116 | minibuffer; the default is the symbol appearing in the buffer at | 1108 | buffer at point. For example, in C mode this looks for the symbol in |
| 1117 | point. For example, in C mode this looks for the symbol in the C | 1109 | the C Library Manual. The command only works if the appropriate |
| 1118 | Library Manual. The command only works if the appropriate manual's | 1110 | manual's Info files are installed. |
| 1119 | Info files are installed. | ||
| 1120 | 1111 | ||
| 1121 | The major mode determines where to look for documentation for the | 1112 | The major mode determines where to look for documentation for the |
| 1122 | symbol---which Info files to look in, and which indices to search. | 1113 | symbol---which Info files to look in, and which indices to search. |
| @@ -1321,9 +1312,9 @@ for more information. | |||
| 1321 | @section Completion for Symbol Names | 1312 | @section Completion for Symbol Names |
| 1322 | @cindex completion (symbol names) | 1313 | @cindex completion (symbol names) |
| 1323 | 1314 | ||
| 1324 | In Emacs, completion is something you normally do in the minibuffer. | 1315 | In Emacs, completion is something you normally do in the minibuffer |
| 1325 | But one kind of completion is available in all buffers: completion for | 1316 | (@pxref{Completion}). But one kind of completion is available in all |
| 1326 | symbol names. | 1317 | buffers: completion for symbol names. |
| 1327 | 1318 | ||
| 1328 | @kindex M-TAB | 1319 | @kindex M-TAB |
| 1329 | The character @kbd{M-@key{TAB}} runs a command to complete the | 1320 | The character @kbd{M-@key{TAB}} runs a command to complete the |