aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2008-10-13 19:12:48 +0000
committerAlan Mackenzie2008-10-13 19:12:48 +0000
commita85fd6da690a32bc36d1248a2413c3e5703ac375 (patch)
treedaddaa6172be8765e52fdcd4f8add171b2d39d9b
parent17abdd47835413e73cddfe1ace7bd644324316f5 (diff)
downloademacs-a85fd6da690a32bc36d1248a2413c3e5703ac375.tar.gz
emacs-a85fd6da690a32bc36d1248a2413c3e5703ac375.zip
Amend several doc strings and comments.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/progmodes/cc-engine.el85
2 files changed, 60 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0e32539c85a..361f7f7279d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -11,6 +11,8 @@
11 * progmodes/cc-cmds.el (c-indent-region): (c-indent-region): Fix 11 * progmodes/cc-cmds.el (c-indent-region): (c-indent-region): Fix
12 previous patch so that the function works on one-line macros. 12 previous patch so that the function works on one-line macros.
13 13
14 * progmodes/cc-engine.el: Amend several doc strings and comments.
15
142008-10-13 Dan Nicolaescu <dann@ics.uci.edu> 162008-10-13 Dan Nicolaescu <dann@ics.uci.edu>
15 17
16 * vc-hooks.el (vc-stay-local): Add a new choice and default to it. 18 * vc-hooks.el (vc-stay-local): Add a new choice and default to it.
@@ -221,8 +223,6 @@
221 223
2222008-10-07 Alan Mackenzie <acm@muc.de> 2242008-10-07 Alan Mackenzie <acm@muc.de>
223 225
224 * progmodes/cc-engine.el: Amend several doc strings and comments.
225
226 * progmodes/cc-cmds.el (c-indent-line-or-region): Fix so that 226 * progmodes/cc-cmds.el (c-indent-line-or-region): Fix so that
227 indenting a macro followed by blank lines doesn't backslash the 227 indenting a macro followed by blank lines doesn't backslash the
228 following non-blank line into the macro. 228 following non-blank line into the macro.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 817b161ff87..43052386408 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -529,6 +529,10 @@ the previous one if already at the beginning of one. Only
529statements/declarations on the same level are considered, i.e. don't 529statements/declarations on the same level are considered, i.e. don't
530move into or out of sexps (not even normal expression parentheses). 530move into or out of sexps (not even normal expression parentheses).
531 531
532If point is already at the earliest statment within braces or parens,
533this function doesn't move back into any whitespace preceding it; it
534returns 'same in this case.
535
532Stop at statement continuation tokens like \"else\", \"catch\", 536Stop at statement continuation tokens like \"else\", \"catch\",
533\"finally\" and the \"while\" in \"do ... while\" if the start point 537\"finally\" and the \"while\" in \"do ... while\" if the start point
534is within the continuation. If starting at such a token, move to the 538is within the continuation. If starting at such a token, move to the
@@ -548,12 +552,16 @@ of the content in the macro, i.e. the expression of an \"#if\" or the
548start of the definition in a \"#define\". Also stop at start of 552start of the definition in a \"#define\". Also stop at start of
549macros before leaving them. 553macros before leaving them.
550 554
551Return 'label if stopped at a label, 'same if stopped at the beginning 555Return:
552of the current statement, 'up if stepped to a containing statement, 556'label if stopped at a label;
553'previous if stepped to a preceding statement, 'beginning if stepped 557'same if stopped at the beginning of the current statement;
554from a statement continuation clause to its start clause, or 'macro if 558'up if stepped to a containing statement;
555stepped to a macro start. Note that 'same and not 'label is returned 559'previous if stepped to a preceding statement;
556if stopped at the same label without crossing the colon character. 560'beginning if stepped from a statement continuation clause to
561 its start clause; or
562'macro if stepped to a macro start.
563Note that 'same and not 'label is returned if stopped at the same
564label without crossing the colon character.
557 565
558LIM may be given to limit the search. If the search hits the limit, 566LIM may be given to limit the search. If the search hits the limit,
559point will be left at the closest following token, or at the start 567point will be left at the closest following token, or at the start
@@ -2509,7 +2517,7 @@ comment at the start of cc-engine.el for more info."
2509 ;; Move to the beginning of the current token. Do not move if not 2517 ;; Move to the beginning of the current token. Do not move if not
2510 ;; in the middle of one. BACK-LIMIT may be used to bound the 2518 ;; in the middle of one. BACK-LIMIT may be used to bound the
2511 ;; backward search; if given it's assumed to be at the boundary 2519 ;; backward search; if given it's assumed to be at the boundary
2512 ;; between two tokens. Return non-nil if the point is move, nil 2520 ;; between two tokens. Return non-nil if the point is moved, nil
2513 ;; otherwise. 2521 ;; otherwise.
2514 ;; 2522 ;;
2515 ;; This function might do hidden buffer changes. 2523 ;; This function might do hidden buffer changes.
@@ -3319,7 +3327,7 @@ literal next to point is returned. \"Next to\" means there's only
3319spaces and tabs between point and the literal. The search for such a 3327spaces and tabs between point and the literal. The search for such a
3320literal is done first in forward direction. If NOT-IN-DELIMITER is 3328literal is done first in forward direction. If NOT-IN-DELIMITER is
3321non-nil, the case when point is inside a starting delimiter won't be 3329non-nil, the case when point is inside a starting delimiter won't be
3322recognized. This only has effect for comments, which have starting 3330recognized. This only has effect for comments which have starting
3323delimiters with more than one character. 3331delimiters with more than one character.
3324 3332
3325Note that this function might do hidden buffer changes. See the 3333Note that this function might do hidden buffer changes. See the
@@ -3429,9 +3437,10 @@ comment at the start of cc-engine.el for more info."
3429 3437
3430(defun c-literal-type (range) 3438(defun c-literal-type (range)
3431 "Convenience function that given the result of `c-literal-limits', 3439 "Convenience function that given the result of `c-literal-limits',
3432returns nil or the type of literal that the range surrounds. It's 3440returns nil or the type of literal that the range surrounds, one
3433much faster than using `c-in-literal' and is intended to be used when 3441of the symbols 'c, 'c++ or 'string. It's much faster than using
3434you need both the type of a literal and its limits. 3442`c-in-literal' and is intended to be used when you need both the
3443type of a literal and its limits.
3435 3444
3436Note that this function might do hidden buffer changes. See the 3445Note that this function might do hidden buffer changes. See the
3437comment at the start of cc-engine.el for more info." 3446comment at the start of cc-engine.el for more info."
@@ -3581,8 +3590,17 @@ comment at the start of cc-engine.el for more info."
3581 3590
3582(defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun) 3591(defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun)
3583 ;; Call CFD-FUN for each possible spot for a declaration, cast or 3592 ;; Call CFD-FUN for each possible spot for a declaration, cast or
3584 ;; label from the point to CFD-LIMIT. Such a spot is: 3593 ;; label from the point to CFD-LIMIT.
3594 ;;
3595 ;; CFD-FUN is called with point at the start of the spot. It's
3596 ;; passed two arguments: The first is the end position of the token
3597 ;; preceding the spot, or 0 for the implicit match at bob. The
3598 ;; second is a flag that is t when the match is inside a macro. If
3599 ;; CFD-FUN adds `c-decl-end' properties somewhere below the current
3600 ;; spot, it should return non-nil to ensure that the next search
3601 ;; will find them.
3585 ;; 3602 ;;
3603 ;; Such a spot is:
3586 ;; o The first token after bob. 3604 ;; o The first token after bob.
3587 ;; o The first token after the end of submatch 1 in 3605 ;; o The first token after the end of submatch 1 in
3588 ;; `c-decl-prefix-or-start-re' when that submatch matches. 3606 ;; `c-decl-prefix-or-start-re' when that submatch matches.
@@ -3602,14 +3620,6 @@ comment at the start of cc-engine.el for more info."
3602 ;; outside it. It's to avoid this work that the CFD-DECL-RE and 3620 ;; outside it. It's to avoid this work that the CFD-DECL-RE and
3603 ;; CFD-FACE-CHECKLIST checks exist. 3621 ;; CFD-FACE-CHECKLIST checks exist.
3604 ;; 3622 ;;
3605 ;; CFD-FUN is called with point at the start of the spot. It's
3606 ;; passed two arguments: The first is the end position of the token
3607 ;; preceding the spot, or 0 for the implicit match at bob. The
3608 ;; second is a flag that is t when the match is inside a macro. If
3609 ;; CFD-FUN adds `c-decl-end' properties somewhere below the current
3610 ;; spot, it should return non-nil to ensure that the next search
3611 ;; will find them.
3612 ;;
3613 ;; The spots are visited approximately in order from top to bottom. 3623 ;; The spots are visited approximately in order from top to bottom.
3614 ;; It's however the positions where `c-decl-prefix-or-start-re' 3624 ;; It's however the positions where `c-decl-prefix-or-start-re'
3615 ;; matches and where `c-decl-end' properties are found that are in 3625 ;; matches and where `c-decl-end' properties are found that are in
@@ -5139,7 +5149,8 @@ comment at the start of cc-engine.el for more info."
5139 ;; inside a function declaration arglist). 5149 ;; inside a function declaration arglist).
5140 ;; '<> In an angle bracket arglist. 5150 ;; '<> In an angle bracket arglist.
5141 ;; 'arglist Some other type of arglist. 5151 ;; 'arglist Some other type of arglist.
5142 ;; nil Some other context or unknown context. 5152 ;; nil Some other context or unknown context. Includes
5153 ;; within the parens of an if, for, ... construct.
5143 ;; 5154 ;;
5144 ;; LAST-CAST-END is the first token after the closing paren of a 5155 ;; LAST-CAST-END is the first token after the closing paren of a
5145 ;; preceding cast, or nil if none is known. If 5156 ;; preceding cast, or nil if none is known. If
@@ -5487,6 +5498,7 @@ comment at the start of cc-engine.el for more info."
5487 at-decl-or-cast 5498 at-decl-or-cast
5488 (catch 'at-decl-or-cast 5499 (catch 'at-decl-or-cast
5489 5500
5501 ;; CASE 1
5490 (when (> paren-depth 0) 5502 (when (> paren-depth 0)
5491 ;; Encountered something inside parens that isn't matched by 5503 ;; Encountered something inside parens that isn't matched by
5492 ;; the `c-type-decl-*' regexps, so it's not a type decl 5504 ;; the `c-type-decl-*' regexps, so it's not a type decl
@@ -5510,6 +5522,7 @@ comment at the start of cc-engine.el for more info."
5510 (if got-identifier 5522 (if got-identifier
5511 (progn 5523 (progn
5512 5524
5525 ;; CASE 2
5513 (when (and (or at-type maybe-typeless) 5526 (when (and (or at-type maybe-typeless)
5514 (not (or got-prefix got-parens))) 5527 (not (or got-prefix got-parens)))
5515 ;; Got another identifier directly after the type, so it's a 5528 ;; Got another identifier directly after the type, so it's a
@@ -5536,6 +5549,7 @@ comment at the start of cc-engine.el for more info."
5536 (if backup-at-type 5549 (if backup-at-type
5537 (progn 5550 (progn
5538 5551
5552 ;; CASE 3
5539 (when (= (point) start) 5553 (when (= (point) start)
5540 ;; Got a plain list of identifiers. If a colon follows it's 5554 ;; Got a plain list of identifiers. If a colon follows it's
5541 ;; a valid label. Otherwise the last one probably is the 5555 ;; a valid label. Otherwise the last one probably is the
@@ -5548,6 +5562,7 @@ comment at the start of cc-engine.el for more info."
5548 (setq backup-if-not-cast t) 5562 (setq backup-if-not-cast t)
5549 (throw 'at-decl-or-cast t))) 5563 (throw 'at-decl-or-cast t)))
5550 5564
5565 ;; CASE 4
5551 (when (and got-suffix 5566 (when (and got-suffix
5552 (not got-prefix) 5567 (not got-prefix)
5553 (not got-parens)) 5568 (not got-parens))
@@ -5558,6 +5573,7 @@ comment at the start of cc-engine.el for more info."
5558 (setq backup-if-not-cast t) 5573 (setq backup-if-not-cast t)
5559 (throw 'at-decl-or-cast t))) 5574 (throw 'at-decl-or-cast t)))
5560 5575
5576 ;; CASE 5
5561 (when (eq at-type t) 5577 (when (eq at-type t)
5562 ;; If the type is known we know that there can't be any 5578 ;; If the type is known we know that there can't be any
5563 ;; identifier somewhere else, and it's only in declarations in 5579 ;; identifier somewhere else, and it's only in declarations in
@@ -5567,6 +5583,7 @@ comment at the start of cc-engine.el for more info."
5567 5583
5568 (when (= (point) start) 5584 (when (= (point) start)
5569 ;; Only got a single identifier (parsed as a type so far). 5585 ;; Only got a single identifier (parsed as a type so far).
5586 ;; CASE 6
5570 (if (and 5587 (if (and
5571 ;; Check that the identifier isn't at the start of an 5588 ;; Check that the identifier isn't at the start of an
5572 ;; expression. 5589 ;; expression.
@@ -5587,6 +5604,7 @@ comment at the start of cc-engine.el for more info."
5587 ;; constants in C++. 5604 ;; constants in C++.
5588 (memq at-type '(known found))))) 5605 (memq at-type '(known found)))))
5589 (throw 'at-decl-or-cast t) 5606 (throw 'at-decl-or-cast t)
5607 ;; CASE 7
5590 ;; Can't be a valid declaration or cast, but if we've found a 5608 ;; Can't be a valid declaration or cast, but if we've found a
5591 ;; specifier it can't be anything else either, so treat it as 5609 ;; specifier it can't be anything else either, so treat it as
5592 ;; an invalid/unfinished declaration or cast. 5610 ;; an invalid/unfinished declaration or cast.
@@ -5620,7 +5638,7 @@ comment at the start of cc-engine.el for more info."
5620 (c-fdoc-shift-type-backward) 5638 (c-fdoc-shift-type-backward)
5621 5639
5622 ;; Still no identifier. 5640 ;; Still no identifier.
5623 5641 ;; CASE 8
5624 (when (and got-prefix (or got-parens got-suffix)) 5642 (when (and got-prefix (or got-parens got-suffix))
5625 ;; Require `got-prefix' together with either `got-parens' or 5643 ;; Require `got-prefix' together with either `got-parens' or
5626 ;; `got-suffix' to recognize it as an abstract declarator: 5644 ;; `got-suffix' to recognize it as an abstract declarator:
@@ -5633,6 +5651,7 @@ comment at the start of cc-engine.el for more info."
5633 ;; the point when the fontification was invoked. 5651 ;; the point when the fontification was invoked.
5634 (throw 'at-decl-or-cast t)) 5652 (throw 'at-decl-or-cast t))
5635 5653
5654 ;; CASE 9
5636 (when (and at-type 5655 (when (and at-type
5637 (not got-prefix) 5656 (not got-prefix)
5638 (not got-parens) 5657 (not got-parens)
@@ -5643,11 +5662,13 @@ comment at the start of cc-engine.el for more info."
5643 ;; instantiation expression). 5662 ;; instantiation expression).
5644 (throw 'at-decl-or-cast nil)))) 5663 (throw 'at-decl-or-cast nil))))
5645 5664
5665 ;; CASE 10
5646 (when at-decl-or-cast 5666 (when at-decl-or-cast
5647 ;; By now we've located the type in the declaration that we know 5667 ;; By now we've located the type in the declaration that we know
5648 ;; we're in. 5668 ;; we're in.
5649 (throw 'at-decl-or-cast t)) 5669 (throw 'at-decl-or-cast t))
5650 5670
5671 ;; CASE 11
5651 (when (and got-identifier 5672 (when (and got-identifier
5652 (not context) 5673 (not context)
5653 (looking-at c-after-suffixed-type-decl-key) 5674 (looking-at c-after-suffixed-type-decl-key)
@@ -5666,6 +5687,7 @@ comment at the start of cc-engine.el for more info."
5666 ;; A declaration according to `c-after-suffixed-type-decl-key'. 5687 ;; A declaration according to `c-after-suffixed-type-decl-key'.
5667 (throw 'at-decl-or-cast t)) 5688 (throw 'at-decl-or-cast t))
5668 5689
5690 ;; CASE 12
5669 (when (and (or got-prefix (not got-parens)) 5691 (when (and (or got-prefix (not got-parens))
5670 (memq at-type '(t known))) 5692 (memq at-type '(t known)))
5671 ;; It's a declaration if a known type precedes it and it can't be a 5693 ;; It's a declaration if a known type precedes it and it can't be a
@@ -5696,11 +5718,13 @@ comment at the start of cc-engine.el for more info."
5696 ;; Below are tests that only should be applied when we're certain to 5718 ;; Below are tests that only should be applied when we're certain to
5697 ;; not have parsed halfway through an expression. 5719 ;; not have parsed halfway through an expression.
5698 5720
5721 ;; CASE 14
5699 (when (memq at-type '(t known)) 5722 (when (memq at-type '(t known))
5700 ;; The expression starts with a known type so treat it as a 5723 ;; The expression starts with a known type so treat it as a
5701 ;; declaration. 5724 ;; declaration.
5702 (throw 'at-decl-or-cast t)) 5725 (throw 'at-decl-or-cast t))
5703 5726
5727 ;; CASE 15
5704 (when (and (c-major-mode-is 'c++-mode) 5728 (when (and (c-major-mode-is 'c++-mode)
5705 ;; In C++ we check if the identifier is a known type, since 5729 ;; In C++ we check if the identifier is a known type, since
5706 ;; (con|de)structors use the class name as identifier. 5730 ;; (con|de)structors use the class name as identifier.
@@ -5734,6 +5758,7 @@ comment at the start of cc-engine.el for more info."
5734 5758
5735 (if got-identifier 5759 (if got-identifier
5736 (progn 5760 (progn
5761 ;; CASE 16
5737 (when (and got-prefix-before-parens 5762 (when (and got-prefix-before-parens
5738 at-type 5763 at-type
5739 (or at-decl-end (looking-at "=[^=]")) 5764 (or at-decl-end (looking-at "=[^=]"))
@@ -5746,6 +5771,7 @@ comment at the start of cc-engine.el for more info."
5746 ;; be a function call. 5771 ;; be a function call.
5747 (throw 'at-decl-or-cast t)) 5772 (throw 'at-decl-or-cast t))
5748 5773
5774 ;; CASE 17
5749 (when (and (or got-suffix-after-parens 5775 (when (and (or got-suffix-after-parens
5750 (looking-at "=[^=]")) 5776 (looking-at "=[^=]"))
5751 (eq at-type 'found) 5777 (eq at-type 'found)
@@ -5756,6 +5782,7 @@ comment at the start of cc-engine.el for more info."
5756 ;; somewhere else (if it's a known type we won't get here). 5782 ;; somewhere else (if it's a known type we won't get here).
5757 (throw 'at-decl-or-cast t))) 5783 (throw 'at-decl-or-cast t)))
5758 5784
5785 ;; CASE 18
5759 (when (and context 5786 (when (and context
5760 (or got-prefix 5787 (or got-prefix
5761 (and (eq context 'decl) 5788 (and (eq context 'decl)
@@ -6245,10 +6272,14 @@ comment at the start of cc-engine.el for more info."
6245 (looking-at c-opt-asm-stmt-key)))) 6272 (looking-at c-opt-asm-stmt-key))))
6246 6273
6247(defun c-at-toplevel-p () 6274(defun c-at-toplevel-p ()
6248 "Return a determination as to whether point is at the `top-level'. 6275 "Return a determination as to whether point is \"at the top level\".
6249Being at the top-level means that point is either outside any 6276Informally, \"at the top level\" is anywhere where you can write
6250enclosing block (such function definition), or only inside a class, 6277a function.
6251namespace or other block that contains another declaration level. 6278
6279More precisely, being at the top-level means that point is either
6280outside any enclosing block (such as a function definition), or
6281directly inside a class, namespace or other block that contains
6282another declaration level.
6252 6283
6253If point is not at the top-level (e.g. it is inside a method 6284If point is not at the top-level (e.g. it is inside a method
6254definition), then nil is returned. Otherwise, if point is at a 6285definition), then nil is returned. Otherwise, if point is at a
@@ -8178,7 +8209,7 @@ comment at the start of cc-engine.el for more info."
8178 ;; member init list continuation, or a template argument 8209 ;; member init list continuation, or a template argument
8179 ;; list continuation. 8210 ;; list continuation.
8180 ((save-excursion 8211 ((save-excursion
8181 ;; Note: We use the fact that lim always is after any 8212 ;; Note: We use the fact that lim is always after any
8182 ;; preceding brace sexp. 8213 ;; preceding brace sexp.
8183 (if c-recognize-<>-arglists 8214 (if c-recognize-<>-arglists
8184 (while (and 8215 (while (and