comparison man/cc-mode.texi @ 69139:85cd04b9bd25

(Hungry WS Deletion): Rename c-hungry-backspace to c-hungry-delete-backwards, at the request of RMS. Leave the old name as an alias. (Movement Commands): Correct the definition of c-beginning-of-defun, to include the function header within the defun. (Comment Commands): State that C-u M-; kills any existing comment. (Electric Keys): Add a justification for electric indentation. (Hungry WS Deletion): Clear up the names and complications of the BACKSPACE and DELETE keys. Correct two typos.
author Alan Mackenzie <acm@muc.de>
date Fri, 24 Feb 2006 12:20:45 +0000
parents dc2d5a6655a3
children 11b616eddda4 8976b9f5eda1 8a1ee48a8386
comparison
equal deleted inserted replaced
69138:955661fbe891 69139:85cd04b9bd25
206 206
207 @page 207 @page
208 @vskip 0pt plus 1filll 208 @vskip 0pt plus 1filll
209 @insertcopying 209 @insertcopying
210 210
211 This manual was generated from $Revision: 1.34 $ of $RCSfile: cc-mode.texi,v $, which can be 211 This manual was generated from $Revision: 1.35 $ of $RCSfile: cc-mode.texi,v $, which can be
212 downloaded from 212 downloaded from
213 @url{http://cvs.sf.net/viewcvs.py/cc-mode/cc-mode/cc-mode.texi}. 213 @url{http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/man/cc-mode.texi}.
214 @end titlepage 214 @end titlepage
215 215
216 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 216 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
217 @comment The Top node contains the master menu for the Info file. 217 @comment The Top node contains the master menu for the Info file.
218 @comment This appears only in the Info file, not the printed manual. 218 @comment This appears only in the Info file, not the printed manual.
445 customizations - whether in hooks, in styles, in both, or in neither, 445 customizations - whether in hooks, in styles, in both, or in neither,
446 depending on your needs. It describes the @ccmode{} style system and 446 depending on your needs. It describes the @ccmode{} style system and
447 lists the standard styles that @ccmode{} supplies. 447 lists the standard styles that @ccmode{} supplies.
448 448
449 @item 449 @item
450 The next few chapters, describe in detail how to customize the various 450 The next few chapters describe in detail how to customize the various
451 features of @ccmode{}. 451 features of @ccmode{}.
452 452
453 @item 453 @item
454 Finally, there is a sample @file{.emacs} fragment, which might help you 454 Finally, there is a sample @file{.emacs} fragment, which might help you
455 in creating your own customization. 455 in creating your own customization.
523 Normally, when you type ``punctuation'' characters such as @samp{;} or 523 Normally, when you type ``punctuation'' characters such as @samp{;} or
524 @samp{@{}, @ccmode{} instantly reindents the current line. This can 524 @samp{@{}, @ccmode{} instantly reindents the current line. This can
525 be disconcerting until you get used to it. To disable @dfn{electric 525 be disconcerting until you get used to it. To disable @dfn{electric
526 indentation} in the current buffer, type @kbd{C-c C-l}. Type the same 526 indentation} in the current buffer, type @kbd{C-c C-l}. Type the same
527 thing to enable it again. To have electric indentation disabled by 527 thing to enable it again. To have electric indentation disabled by
528 default, put the following into your @file{.emacs} mode@footnote{There 528 default, put the following into your @file{.emacs} file@footnote{There
529 is no ``easy customization'' facility for making this change.}: 529 is no ``easy customization'' facility for making this change.}:
530 530
531 @example 531 @example
532 (setq-default c-electric-flag nil) 532 (setq-default c-electric-flag nil)
533 @end example 533 @end example
834 @end ifclear 834 @end ifclear
835 @ifset XEMACS 835 @ifset XEMACS
836 (@pxref{Comments,,, xemacs, XEmacs User's Manual}) 836 (@pxref{Comments,,, xemacs, XEmacs User's Manual})
837 @end ifset 837 @end ifset
838 and the variables below. Finally, position the point after the 838 and the variables below. Finally, position the point after the
839 comment starter. This is a standard Emacs command, but @ccmode{} 839 comment starter. @kbd{C-u M-;} kills any comment on the current line,
840 enhances it a bit with two variables: 840 together with any whitespace before it. This is a standard Emacs
841 command, but @ccmode{} enhances it a bit with two variables:
841 842
842 @defopt c-indent-comment-alist 843 @defopt c-indent-comment-alist
843 @vindex indent-comment-alist (c-) 844 @vindex indent-comment-alist (c-)
844 @vindex comment-column 845 @vindex comment-column
845 This style variable allows you to vary the column that @kbd{M-;} puts 846 This style variable allows you to vary the column that @kbd{M-;} puts
885 @findex c-end-of-defun 886 @findex c-end-of-defun
886 @findex beginning-of-defun (c-) 887 @findex beginning-of-defun (c-)
887 @findex end-of-defun (c-) 888 @findex end-of-defun (c-)
888 @findex beginning-of-defun 889 @findex beginning-of-defun
889 @findex end-of-defun 890 @findex end-of-defun
890 Move to the start or end of the current top-level definition, this 891 Move to the start or end of the current top-level definition. This is
891 being the outermost brace pair which encloses point. These functions 892 the outermost brace pair which encloses point, together with the
892 are analogous to the Emacs built-in commands @code{beginning-of-defun} 893 function header or similar preamble which precedes the opening brace.
893 and @code{end-of-defun}, except they eliminate the constraint that the 894 These functions are analogous to the Emacs built-in commands
894 top-level opening brace of the defun must be in column zero. See 895 @code{beginning-of-defun} and @code{end-of-defun}, except they
895 @ref{Defuns,,,@emacsman{}, @emacsmantitle{}}, for more information. 896 eliminate the constraint that the top-level opening brace of the defun
897 must be in column zero. See @ref{Defuns,,,@emacsman{},
898 @emacsmantitle{}}, for more information.
896 899
897 Depending on the coding style you're using, you might prefer these two 900 Depending on the coding style you're using, you might prefer these two
898 commands to the standard Emacs ones. If so, consider binding them to 901 commands to the standard Emacs ones. If so, consider binding them to
899 @kbd{C-M-a} and @kbd{C-M-e}. @xref{Sample .emacs File}. This 902 @kbd{C-M-a} and @kbd{C-M-e}. @xref{Sample .emacs File}. This
900 customization won't affect the special bindings for these key 903 customization won't affect the special bindings for these key
1218 @cindex electric characters 1221 @cindex electric characters
1219 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1222 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1220 1223
1221 Most punctuation keys provide @dfn{electric} behavior - as well as 1224 Most punctuation keys provide @dfn{electric} behavior - as well as
1222 inserting themselves they perform some other action, such as 1225 inserting themselves they perform some other action, such as
1223 reindenting the line. A few keywords, such as @code{else}, also 1226 reindenting the line. This reindentation saves you from having to
1224 trigger electric action. 1227 reindent a line manually after typing, say, a @samp{@}}. A few
1228 keywords, such as @code{else}, also trigger electric action.
1225 1229
1226 You can inhibit the electric behaviour described here by disabling 1230 You can inhibit the electric behaviour described here by disabling
1227 electric minor mode (@pxref{Minor Modes}.) 1231 electric minor mode (@pxref{Minor Modes}).
1228 1232
1229 Common to all of them is that they only behave electrically when used 1233 Common to all these keys is that they only behave electrically when
1230 in normal code (as contrasted with getting typed in a string literal 1234 used in normal code (as contrasted with getting typed in a string
1231 or comment). Those which cause re-indentation do so only when 1235 literal or comment). Those which cause re-indentation do so only when
1232 @code{c-syntactic-indentation} has a non-@code{nil} value (which it 1236 @code{c-syntactic-indentation} has a non-@code{nil} value (which it
1233 does by default). 1237 does by default).
1234 1238
1235 These keys and keywords are: 1239 These keys and keywords are:
1236 @c ACM, 2004/8/24: c-electric-pound doesn't check c-s-i: this is more 1240 @c ACM, 2004/8/24: c-electric-pound doesn't check c-s-i: this is more
1451 @comment node-name, next, previous, up 1455 @comment node-name, next, previous, up
1452 @section Hungry Deletion of Whitespace 1456 @section Hungry Deletion of Whitespace
1453 @cindex hungry-deletion 1457 @cindex hungry-deletion
1454 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1458 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1455 1459
1456 @kindex C-d
1457
1458 If you want to delete an entire block of whitespace at point, you can 1460 If you want to delete an entire block of whitespace at point, you can
1459 use @dfn{hungry deletion}. This deletes all the contiguous whitespace 1461 use @dfn{hungry deletion}. This deletes all the contiguous whitespace
1460 either before point or after point in a single operation. 1462 either before point or after point in a single operation.
1461 ``Whitespace'' here includes tabs and newlines, but not comments or 1463 ``Whitespace'' here includes tabs and newlines, but not comments or
1462 preprocessor commands. Hungry deletion can markedly cut down on the 1464 preprocessor commands. Hungry deletion can markedly cut down on the
1466 1468
1467 Hungry deletion is a simple feature that some people find extremely 1469 Hungry deletion is a simple feature that some people find extremely
1468 useful. In fact, you might find yourself wanting it in @strong{all} 1470 useful. In fact, you might find yourself wanting it in @strong{all}
1469 your editing modes! 1471 your editing modes!
1470 1472
1473 Loosely speaking, in what follows, @dfn{@key{DEL}} means ``the
1474 backspace key'' and @dfn{@key{DELETE}} means ``the forward delete
1475 key''. This is discussed in more detail below.
1476
1471 There are two different ways you can use hungry deletion: 1477 There are two different ways you can use hungry deletion:
1472 1478
1473 @table @asis 1479 @table @asis
1474 @item Using @dfn{Hungry Delete Mode} with @kbd{@key{DEL}} and @kbd{C-d} 1480 @item Using @dfn{Hungry Delete Mode} with @kbd{@key{DEL}} and @kbd{C-d}
1475 Here you toggle Hungry Delete minor mode with @kbd{M-x 1481 Here you toggle Hungry Delete minor mode with @kbd{M-x
1476 c-toggle-hungry-state}@footnote{Prior to @ccmode{} 5.31, this command 1482 c-toggle-hungry-state}@footnote{Prior to @ccmode{} 5.31, this command
1477 was bound to @kbd{C-c C-d}. @kbd{C-c C-d} is now the default binding 1483 was bound to @kbd{C-c C-d}. @kbd{C-c C-d} is now the default binding
1478 for @code{c-hungry-delete-forward}.} (@pxref{Minor Modes}.) This 1484 for @code{c-hungry-delete-forward}.} (@pxref{Minor Modes}.) This
1479 makes @kbd{@key{DEL}} and @kbd{C-d} do forward and backwards hungry 1485 makes @kbd{@key{DEL}} and @kbd{C-d} do backwards and forward hungry
1480 deletion. 1486 deletion.
1481 1487
1482 @table @asis 1488 @table @asis
1483 @item @kbd{@key{DEL}} (@code{c-electric-backspace}) 1489 @item @kbd{@key{DEL}} (@code{c-electric-backspace})
1484 @kindex DEL 1490 @kindex DEL
1522 default value is @code{delete-char}. 1528 default value is @code{delete-char}.
1523 @end table 1529 @end table
1524 1530
1525 @item Using Distinct Bindings 1531 @item Using Distinct Bindings
1526 The other (newer and recommended) way to use hungry deletion is to 1532 The other (newer and recommended) way to use hungry deletion is to
1527 perform @code{c-hungry-backspace} and @code{c-hungry-delete-forward} 1533 perform @code{c-hungry-delete-backwards} and
1528 directly through their key sequences rather than using the minor mode 1534 @code{c-hungry-delete-forward} directly through their key sequences
1529 toggling. 1535 rather than using the minor mode toggling.
1530 1536
1531 @table @asis 1537 @table @asis
1532 @item @kbd{C-c C-@key{Backspace}}, @kbd{C-c DEL}, or @kbd{C-c @key{Backspace}} (@code{c-hungry-backspace}) 1538 @item @kbd{C-c C-@key{DEL}}, or @kbd{C-c @key{DEL}} (@code{c-hungry-delete-backwards})@footnote{This command was formerly known as @code{c-hungry-backspace}.}
1533 @kindex C-c C-<backspace> 1539 @kindex C-c C-<backspace>
1540 @kindex C-c <backspace>
1541 @kindex C-c C-DEL
1534 @kindex C-c DEL 1542 @kindex C-c DEL
1535 @kindex C-c <backspace> 1543 @findex c-hungry-delete-backwards
1536 @findex c-hungry-backspace 1544 @findex hungry-delete-backwards (c-)
1537 @findex hungry-backspace (c-)
1538 Delete any amount of whitespace in the backwards direction (regardless 1545 Delete any amount of whitespace in the backwards direction (regardless
1539 whether hungry-delete mode is enabled or not). This command is bound 1546 whether hungry-delete mode is enabled or not). This command is bound
1540 to both @kbd{C-c C-@key{Backspace}} and @kbd{C-c @key{Backspace}}, 1547 to both @kbd{C-c C-@key{DEL}} and @kbd{C-c @key{DEL}}, since the more
1541 since the more natural one, @kbd{C-c C-@key{Backspace}}, is sometimes 1548 natural one, @kbd{C-c C-@key{DEL}}, is sometimes difficult to type at
1542 difficult to type at a character terminal. 1549 a character terminal.
1543 1550
1544 @item @kbd{C-c C-@key{Delete}}, @kbd{C-c C-d}, or @kbd{C-c @key{Delete}} (@code{c-hungry-delete-forward}) 1551 @item @kbd{C-c C-d}, @kbd{C-c C-@key{DELETE}}, or @kbd{C-c @key{DELETE}} (@code{c-hungry-delete-forward})
1545 @kindex C-c C-<delete>
1546 @kindex C-c C-d 1552 @kindex C-c C-d
1547 @kindex C-c <delete> 1553 @kindex C-c C-<DELETE>
1554 @kindex C-c <DELETE>
1548 @findex c-hungry-delete-forward 1555 @findex c-hungry-delete-forward
1549 @findex hungry-delete-forward (c-) 1556 @findex hungry-delete-forward (c-)
1550 Delete any amount of whitespace in the forward direction (regardless 1557 Delete any amount of whitespace in the forward direction (regardless
1551 whether hungry-delete mode is enabled or not). This command is bound 1558 whether hungry-delete mode is enabled or not). This command is bound
1552 to both @kbd{C-c C-@key{Delete}} and @kbd{C-c @key{Delete}} for the 1559 to both @kbd{C-c C-@key{DELETE}} and @kbd{C-c @key{DELETE}} for the
1553 same reason as for @key{Backspace} above. 1560 same reason as for @key{DEL} above.
1554 @end table 1561 @end table
1555 @end table 1562 @end table
1556 1563
1557 @kindex <delete> 1564 @kindex <delete>
1558 @kindex <backspace> 1565 @kindex <backspace>
1559 1566
1560 When we talk about @kbd{DEL}, @kbd{C-d}, @key{Backspace} and 1567 When we talk about @kbd{@key{DEL}}, and @kbd{@key{DELETE}} above, we
1561 @key{Delete} above, we actually do so without connecting them to the 1568 actually do so without connecting them to the physical keys commonly
1562 physical keys commonly known as @key{Backspace} and @key{Delete}. The 1569 known as @key{Backspace} and @key{Delete}. The default bindings to
1563 default bindings to those two keys depends on the flavor of (X)Emacs 1570 those two keys depends on the flavor of (X)Emacs you are using.
1564 you are using.
1565 1571
1566 @findex c-electric-delete 1572 @findex c-electric-delete
1567 @findex electric-delete (c-) 1573 @findex electric-delete (c-)
1568 @findex c-hungry-delete 1574 @findex c-hungry-delete
1569 @findex hungry-delete (c-) 1575 @findex hungry-delete (c-)
1570 @vindex delete-key-deletes-forward 1576 @vindex delete-key-deletes-forward
1571
1572 In XEmacs 20.3 and beyond, the @key{Backspace} key is bound to 1577 In XEmacs 20.3 and beyond, the @key{Backspace} key is bound to
1573 @code{c-electric-backspace} and the @key{Delete} key is bound to 1578 @code{c-electric-backspace} and the @key{Delete} key is bound to
1574 @code{c-electric-delete}. You control the direction it deletes in by 1579 @code{c-electric-delete}. You control the direction it deletes in by
1575 setting the variable @code{delete-key-deletes-forward}, a standard 1580 setting the variable @code{delete-key-deletes-forward}, a standard
1576 XEmacs variable. When this variable is non-@code{nil}, 1581 XEmacs variable.
1577 @code{c-electric-delete} will do forward deletion with 1582 @c This variable is encapsulated by XEmacs's (defsubst delete-forward-p ...).
1578 @code{c-electric-delete-forward}, otherwise it does backward deletion 1583 When this variable is non-@code{nil}, @code{c-electric-delete} will do
1579 with @code{c-electric-backspace}. Similarly, @kbd{C-c @key{Delete}} 1584 forward deletion with @code{c-electric-delete-forward}, otherwise it
1580 and @kbd{C-c C-@key{Delete}} are bound to @code{c-hungry-delete} which 1585 does backward deletion with @code{c-electric-backspace}. Similarly,
1581 is controlled in the same way by @code{delete-key-deletes-forward}. 1586 @kbd{C-c @key{Delete}} and @kbd{C-c C-@key{Delete}} are bound to
1587 @code{c-hungry-delete} which is controlled in the same way by
1588 @code{delete-key-deletes-forward}.
1582 1589
1583 @findex normal-erase-is-backspace-mode 1590 @findex normal-erase-is-backspace-mode
1584 1591
1585 Emacs 21 and later automatically binds @key{Backspace} and 1592 Emacs 21 and later automatically binds @key{Backspace} and
1586 @key{Delete} to @kbd{DEL} and @kbd{C-d} according to your environment, 1593 @key{Delete} to @kbd{DEL} and @kbd{C-d} according to your environment,