aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2011-02-13 15:25:15 -0500
committerChong Yidong2011-02-13 15:25:15 -0500
commitabfc152b45e356fc73c798ed770765c7d2560075 (patch)
tree221a7e73f12cc18dc1b315630de32db3657e3ef1
parentd4eb88c7ab151a7cb7188c3ba03eb326ec1fa6f2 (diff)
downloademacs-abfc152b45e356fc73c798ed770765c7d2560075.tar.gz
emacs-abfc152b45e356fc73c798ed770765c7d2560075.zip
Proper fix for CC mode Bug#7722.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Remove a narrow-to-region call that cuts context off the end (Bug#7722). * lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur): Refactor nested if-forms with a simple cond. (c-forward-<>-arglist): Revert 2011-01-31 change.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/progmodes/cc-engine.el88
-rw-r--r--lisp/progmodes/cc-fonts.el11
3 files changed, 55 insertions, 53 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bf347d2a70f..0d242589f76 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12011-02-13 Alan Mackenzie <acm@muc.de>
2
3 * progmodes/cc-fonts.el (c-font-lock-declarations): Remove a
4 narrow-to-region call that cuts context off the end (Bug#7722).
5
6 * progmodes/cc-engine.el (c-forward-<>-arglist-recur): Refactor
7 nested if-forms with a simple cond.
8 (c-forward-<>-arglist): Revert 2011-01-31 change.
9
12011-02-13 Chong Yidong <cyd@stupidchicken.com> 102011-02-13 Chong Yidong <cyd@stupidchicken.com>
2 11
3 * vc/log-view.el: New command log-view-toggle-entry-display for 12 * vc/log-view.el: New command log-view-toggle-entry-display for
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index f90d29bf009..de1debd6456 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -5371,8 +5371,6 @@ comment at the start of cc-engine.el for more info."
5371;; cc-mode requires cc-fonts. 5371;; cc-mode requires cc-fonts.
5372(declare-function c-fontify-recorded-types-and-refs "cc-fonts" ()) 5372(declare-function c-fontify-recorded-types-and-refs "cc-fonts" ())
5373 5373
5374(defvar c-forward-<>-arglist-recur-depth)
5375
5376(defun c-forward-<>-arglist (all-types) 5374(defun c-forward-<>-arglist (all-types)
5377 ;; The point is assumed to be at a "<". Try to treat it as the open 5375 ;; The point is assumed to be at a "<". Try to treat it as the open
5378 ;; paren of an angle bracket arglist and move forward to the 5376 ;; paren of an angle bracket arglist and move forward to the
@@ -5398,8 +5396,7 @@ comment at the start of cc-engine.el for more info."
5398 ;; If `c-record-type-identifiers' is set then activate 5396 ;; If `c-record-type-identifiers' is set then activate
5399 ;; recording of any found types that constitute an argument in 5397 ;; recording of any found types that constitute an argument in
5400 ;; the arglist. 5398 ;; the arglist.
5401 (c-record-found-types (if c-record-type-identifiers t)) 5399 (c-record-found-types (if c-record-type-identifiers t)))
5402 (c-forward-<>-arglist-recur--depth 0))
5403 (if (catch 'angle-bracket-arglist-escape 5400 (if (catch 'angle-bracket-arglist-escape
5404 (setq c-record-found-types 5401 (setq c-record-found-types
5405 (c-forward-<>-arglist-recur all-types))) 5402 (c-forward-<>-arglist-recur all-types)))
@@ -5416,14 +5413,6 @@ comment at the start of cc-engine.el for more info."
5416 nil))) 5413 nil)))
5417 5414
5418(defun c-forward-<>-arglist-recur (all-types) 5415(defun c-forward-<>-arglist-recur (all-types)
5419
5420 ;; Temporary workaround for Bug#7722.
5421 (when (boundp 'c-forward-<>-arglist-recur--depth)
5422 (if (> c-forward-<>-arglist-recur--depth 200)
5423 (error "Max recursion depth reached in <> arglist")
5424 (setq c-forward-<>-arglist-recur--depth
5425 (1+ c-forward-<>-arglist-recur--depth))))
5426
5427 ;; Recursive part of `c-forward-<>-arglist'. 5416 ;; Recursive part of `c-forward-<>-arglist'.
5428 ;; 5417 ;;
5429 ;; This function might do hidden buffer changes. 5418 ;; This function might do hidden buffer changes.
@@ -5455,9 +5444,11 @@ comment at the start of cc-engine.el for more info."
5455 (goto-char start) 5444 (goto-char start)
5456 nil)) 5445 nil))
5457 5446
5458 (forward-char) 5447 (forward-char) ; Forward over the opening '<'.
5459 5448
5460 (unless (looking-at c-<-op-cont-regexp) 5449 (unless (looking-at c-<-op-cont-regexp)
5450 ;; go forward one non-alphanumeric character (group) per iteration of
5451 ;; this loop.
5461 (while (and 5452 (while (and
5462 (progn 5453 (progn
5463 (c-forward-syntactic-ws) 5454 (c-forward-syntactic-ws)
@@ -5486,7 +5477,7 @@ comment at the start of cc-engine.el for more info."
5486 (c-forward-type) 5477 (c-forward-type)
5487 (c-forward-syntactic-ws)))))) 5478 (c-forward-syntactic-ws))))))
5488 5479
5489 (setq pos (point)) 5480 (setq pos (point)) ; e.g. first token inside the '<'
5490 5481
5491 ;; Note: These regexps exploit the match order in \| so 5482 ;; Note: These regexps exploit the match order in \| so
5492 ;; that "<>" is matched by "<" rather than "[^>:-]>". 5483 ;; that "<>" is matched by "<" rather than "[^>:-]>".
@@ -5522,37 +5513,35 @@ comment at the start of cc-engine.el for more info."
5522 ;; Either an operator starting with '<' or a nested arglist. 5513 ;; Either an operator starting with '<' or a nested arglist.
5523 (setq pos (point)) 5514 (setq pos (point))
5524 (let (id-start id-end subres keyword-match) 5515 (let (id-start id-end subres keyword-match)
5525 (if (if (looking-at c-<-op-cont-regexp) 5516 (cond
5526 (setq tmp (match-end 0)) 5517 ;; The '<' begins a multi-char operator.
5527 (setq tmp pos) 5518 ((looking-at c-<-op-cont-regexp)
5528 (backward-char) 5519 (setq tmp (match-end 0))
5529 (not 5520 (goto-char (match-end 0)))
5530 (and 5521 ;; We're at a nested <.....>
5531 5522 ((progn
5532 (save-excursion 5523 (setq tmp pos)
5533 ;; There's always an identifier before an angle 5524 (backward-char) ; to the '<'
5534 ;; bracket arglist, or a keyword in 5525 (and
5535 ;; `c-<>-type-kwds' or `c-<>-arglist-kwds'. 5526 (save-excursion
5536 (c-backward-syntactic-ws) 5527 ;; There's always an identifier before an angle
5537 (setq id-end (point)) 5528 ;; bracket arglist, or a keyword in `c-<>-type-kwds'
5538 (c-simple-skip-symbol-backward) 5529 ;; or `c-<>-arglist-kwds'.
5539 (when (or (setq keyword-match 5530 (c-backward-syntactic-ws)
5540 (looking-at c-opt-<>-sexp-key)) 5531 (setq id-end (point))
5541 (not (looking-at c-keywords-regexp))) 5532 (c-simple-skip-symbol-backward)
5542 (setq id-start (point)))) 5533 (when (or (setq keyword-match
5543 5534 (looking-at c-opt-<>-sexp-key))
5544 (setq subres 5535 (not (looking-at c-keywords-regexp)))
5545 (let ((c-promote-possible-types t) 5536 (setq id-start (point))))
5546 (c-record-found-types t)) 5537 (setq subres
5547 (c-forward-<>-arglist-recur 5538 (let ((c-promote-possible-types t)
5548 (and keyword-match 5539 (c-record-found-types t))
5549 (c-keyword-member 5540 (c-forward-<>-arglist-recur
5550 (c-keyword-sym (match-string 1)) 5541 (and keyword-match
5551 'c-<>-type-kwds))))) 5542 (c-keyword-member
5552 ))) 5543 (c-keyword-sym (match-string 1))
5553 5544 'c-<>-type-kwds)))))))
5554 ;; It was not an angle bracket arglist.
5555 (goto-char tmp)
5556 5545
5557 ;; It was an angle bracket arglist. 5546 ;; It was an angle bracket arglist.
5558 (setq c-record-found-types subres) 5547 (setq c-record-found-types subres)
@@ -5567,8 +5556,13 @@ comment at the start of cc-engine.el for more info."
5567 (c-forward-syntactic-ws) 5556 (c-forward-syntactic-ws)
5568 (looking-at c-opt-identifier-concat-key))) 5557 (looking-at c-opt-identifier-concat-key)))
5569 (c-record-ref-id (cons id-start id-end)) 5558 (c-record-ref-id (cons id-start id-end))
5570 (c-record-type-id (cons id-start id-end)))))) 5559 (c-record-type-id (cons id-start id-end)))))
5571 t) 5560
5561 ;; At a "less than" operator.
5562 (t
5563 (forward-char)
5564 )))
5565 t) ; carry on looping.
5572 5566
5573 ((and (not c-restricted-<>-arglists) 5567 ((and (not c-restricted-<>-arglists)
5574 (or (and (eq (char-before) ?&) 5568 (or (and (eq (char-before) ?&)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 0d738700cc7..c7bb93f73e7 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1082,7 +1082,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1082 (boundp 'parse-sexp-lookup-properties)))) 1082 (boundp 'parse-sexp-lookup-properties))))
1083 1083
1084 ;; Below we fontify a whole declaration even when it crosses the limit, 1084 ;; Below we fontify a whole declaration even when it crosses the limit,
1085 ;; to avoid gaps when lazy-lock fontifies the file a screenful at a 1085 ;; to avoid gaps when jit/lazy-lock fontifies the file a block at a
1086 ;; time. That is however annoying during editing, e.g. the following is 1086 ;; time. That is however annoying during editing, e.g. the following is
1087 ;; a common situation while the first line is being written: 1087 ;; a common situation while the first line is being written:
1088 ;; 1088 ;;
@@ -1094,9 +1094,9 @@ casts and declarations are fontified. Used on level 2 and higher."
1094 ;; "some_other_variable" as an identifier, and the latter will not 1094 ;; "some_other_variable" as an identifier, and the latter will not
1095 ;; correct itself until the second line is changed. To avoid that we 1095 ;; correct itself until the second line is changed. To avoid that we
1096 ;; narrow to the limit if the region to fontify is a single line. 1096 ;; narrow to the limit if the region to fontify is a single line.
1097 (narrow-to-region 1097 (if (<= limit (c-point 'bonl))
1098 (point-min) 1098 (narrow-to-region
1099 (if (<= limit (c-point 'bonl)) 1099 (point-min)
1100 (save-excursion 1100 (save-excursion
1101 ;; Narrow after any operator chars following the limit though, 1101 ;; Narrow after any operator chars following the limit though,
1102 ;; since those characters can be useful in recognizing a 1102 ;; since those characters can be useful in recognizing a
@@ -1104,8 +1104,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1104 ;; after the header). 1104 ;; after the header).
1105 (goto-char limit) 1105 (goto-char limit)
1106 (skip-chars-forward c-nonsymbol-chars) 1106 (skip-chars-forward c-nonsymbol-chars)
1107 (point)) 1107 (point))))
1108 limit))
1109 1108
1110 (c-find-decl-spots 1109 (c-find-decl-spots
1111 limit 1110 limit