mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
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.
This commit is contained in:
parent
d4eb88c7ab
commit
abfc152b45
3 changed files with 55 additions and 53 deletions
|
|
@ -1,3 +1,12 @@
|
||||||
|
2011-02-13 Alan Mackenzie <acm@muc.de>
|
||||||
|
|
||||||
|
* progmodes/cc-fonts.el (c-font-lock-declarations): Remove a
|
||||||
|
narrow-to-region call that cuts context off the end (Bug#7722).
|
||||||
|
|
||||||
|
* progmodes/cc-engine.el (c-forward-<>-arglist-recur): Refactor
|
||||||
|
nested if-forms with a simple cond.
|
||||||
|
(c-forward-<>-arglist): Revert 2011-01-31 change.
|
||||||
|
|
||||||
2011-02-13 Chong Yidong <cyd@stupidchicken.com>
|
2011-02-13 Chong Yidong <cyd@stupidchicken.com>
|
||||||
|
|
||||||
* vc/log-view.el: New command log-view-toggle-entry-display for
|
* vc/log-view.el: New command log-view-toggle-entry-display for
|
||||||
|
|
|
||||||
|
|
@ -5371,8 +5371,6 @@ comment at the start of cc-engine.el for more info."
|
||||||
;; cc-mode requires cc-fonts.
|
;; cc-mode requires cc-fonts.
|
||||||
(declare-function c-fontify-recorded-types-and-refs "cc-fonts" ())
|
(declare-function c-fontify-recorded-types-and-refs "cc-fonts" ())
|
||||||
|
|
||||||
(defvar c-forward-<>-arglist-recur-depth)
|
|
||||||
|
|
||||||
(defun c-forward-<>-arglist (all-types)
|
(defun c-forward-<>-arglist (all-types)
|
||||||
;; The point is assumed to be at a "<". Try to treat it as the open
|
;; The point is assumed to be at a "<". Try to treat it as the open
|
||||||
;; paren of an angle bracket arglist and move forward to the
|
;; 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."
|
||||||
;; If `c-record-type-identifiers' is set then activate
|
;; If `c-record-type-identifiers' is set then activate
|
||||||
;; recording of any found types that constitute an argument in
|
;; recording of any found types that constitute an argument in
|
||||||
;; the arglist.
|
;; the arglist.
|
||||||
(c-record-found-types (if c-record-type-identifiers t))
|
(c-record-found-types (if c-record-type-identifiers t)))
|
||||||
(c-forward-<>-arglist-recur--depth 0))
|
|
||||||
(if (catch 'angle-bracket-arglist-escape
|
(if (catch 'angle-bracket-arglist-escape
|
||||||
(setq c-record-found-types
|
(setq c-record-found-types
|
||||||
(c-forward-<>-arglist-recur all-types)))
|
(c-forward-<>-arglist-recur all-types)))
|
||||||
|
|
@ -5416,14 +5413,6 @@ comment at the start of cc-engine.el for more info."
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(defun c-forward-<>-arglist-recur (all-types)
|
(defun c-forward-<>-arglist-recur (all-types)
|
||||||
|
|
||||||
;; Temporary workaround for Bug#7722.
|
|
||||||
(when (boundp 'c-forward-<>-arglist-recur--depth)
|
|
||||||
(if (> c-forward-<>-arglist-recur--depth 200)
|
|
||||||
(error "Max recursion depth reached in <> arglist")
|
|
||||||
(setq c-forward-<>-arglist-recur--depth
|
|
||||||
(1+ c-forward-<>-arglist-recur--depth))))
|
|
||||||
|
|
||||||
;; Recursive part of `c-forward-<>-arglist'.
|
;; Recursive part of `c-forward-<>-arglist'.
|
||||||
;;
|
;;
|
||||||
;; This function might do hidden buffer changes.
|
;; This function might do hidden buffer changes.
|
||||||
|
|
@ -5455,9 +5444,11 @@ comment at the start of cc-engine.el for more info."
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
(forward-char)
|
(forward-char) ; Forward over the opening '<'.
|
||||||
|
|
||||||
(unless (looking-at c-<-op-cont-regexp)
|
(unless (looking-at c-<-op-cont-regexp)
|
||||||
|
;; go forward one non-alphanumeric character (group) per iteration of
|
||||||
|
;; this loop.
|
||||||
(while (and
|
(while (and
|
||||||
(progn
|
(progn
|
||||||
(c-forward-syntactic-ws)
|
(c-forward-syntactic-ws)
|
||||||
|
|
@ -5486,7 +5477,7 @@ comment at the start of cc-engine.el for more info."
|
||||||
(c-forward-type)
|
(c-forward-type)
|
||||||
(c-forward-syntactic-ws))))))
|
(c-forward-syntactic-ws))))))
|
||||||
|
|
||||||
(setq pos (point))
|
(setq pos (point)) ; e.g. first token inside the '<'
|
||||||
|
|
||||||
;; Note: These regexps exploit the match order in \| so
|
;; Note: These regexps exploit the match order in \| so
|
||||||
;; that "<>" is matched by "<" rather than "[^>:-]>".
|
;; that "<>" is matched by "<" rather than "[^>:-]>".
|
||||||
|
|
@ -5522,37 +5513,35 @@ comment at the start of cc-engine.el for more info."
|
||||||
;; Either an operator starting with '<' or a nested arglist.
|
;; Either an operator starting with '<' or a nested arglist.
|
||||||
(setq pos (point))
|
(setq pos (point))
|
||||||
(let (id-start id-end subres keyword-match)
|
(let (id-start id-end subres keyword-match)
|
||||||
(if (if (looking-at c-<-op-cont-regexp)
|
(cond
|
||||||
(setq tmp (match-end 0))
|
;; The '<' begins a multi-char operator.
|
||||||
(setq tmp pos)
|
((looking-at c-<-op-cont-regexp)
|
||||||
(backward-char)
|
(setq tmp (match-end 0))
|
||||||
(not
|
(goto-char (match-end 0)))
|
||||||
(and
|
;; We're at a nested <.....>
|
||||||
|
((progn
|
||||||
(save-excursion
|
(setq tmp pos)
|
||||||
;; There's always an identifier before an angle
|
(backward-char) ; to the '<'
|
||||||
;; bracket arglist, or a keyword in
|
(and
|
||||||
;; `c-<>-type-kwds' or `c-<>-arglist-kwds'.
|
(save-excursion
|
||||||
(c-backward-syntactic-ws)
|
;; There's always an identifier before an angle
|
||||||
(setq id-end (point))
|
;; bracket arglist, or a keyword in `c-<>-type-kwds'
|
||||||
(c-simple-skip-symbol-backward)
|
;; or `c-<>-arglist-kwds'.
|
||||||
(when (or (setq keyword-match
|
(c-backward-syntactic-ws)
|
||||||
(looking-at c-opt-<>-sexp-key))
|
(setq id-end (point))
|
||||||
(not (looking-at c-keywords-regexp)))
|
(c-simple-skip-symbol-backward)
|
||||||
(setq id-start (point))))
|
(when (or (setq keyword-match
|
||||||
|
(looking-at c-opt-<>-sexp-key))
|
||||||
(setq subres
|
(not (looking-at c-keywords-regexp)))
|
||||||
(let ((c-promote-possible-types t)
|
(setq id-start (point))))
|
||||||
(c-record-found-types t))
|
(setq subres
|
||||||
(c-forward-<>-arglist-recur
|
(let ((c-promote-possible-types t)
|
||||||
(and keyword-match
|
(c-record-found-types t))
|
||||||
(c-keyword-member
|
(c-forward-<>-arglist-recur
|
||||||
(c-keyword-sym (match-string 1))
|
(and keyword-match
|
||||||
'c-<>-type-kwds)))))
|
(c-keyword-member
|
||||||
)))
|
(c-keyword-sym (match-string 1))
|
||||||
|
'c-<>-type-kwds)))))))
|
||||||
;; It was not an angle bracket arglist.
|
|
||||||
(goto-char tmp)
|
|
||||||
|
|
||||||
;; It was an angle bracket arglist.
|
;; It was an angle bracket arglist.
|
||||||
(setq c-record-found-types subres)
|
(setq c-record-found-types subres)
|
||||||
|
|
@ -5567,8 +5556,13 @@ comment at the start of cc-engine.el for more info."
|
||||||
(c-forward-syntactic-ws)
|
(c-forward-syntactic-ws)
|
||||||
(looking-at c-opt-identifier-concat-key)))
|
(looking-at c-opt-identifier-concat-key)))
|
||||||
(c-record-ref-id (cons id-start id-end))
|
(c-record-ref-id (cons id-start id-end))
|
||||||
(c-record-type-id (cons id-start id-end))))))
|
(c-record-type-id (cons id-start id-end)))))
|
||||||
t)
|
|
||||||
|
;; At a "less than" operator.
|
||||||
|
(t
|
||||||
|
(forward-char)
|
||||||
|
)))
|
||||||
|
t) ; carry on looping.
|
||||||
|
|
||||||
((and (not c-restricted-<>-arglists)
|
((and (not c-restricted-<>-arglists)
|
||||||
(or (and (eq (char-before) ?&)
|
(or (and (eq (char-before) ?&)
|
||||||
|
|
|
||||||
|
|
@ -1082,7 +1082,7 @@ casts and declarations are fontified. Used on level 2 and higher."
|
||||||
(boundp 'parse-sexp-lookup-properties))))
|
(boundp 'parse-sexp-lookup-properties))))
|
||||||
|
|
||||||
;; Below we fontify a whole declaration even when it crosses the limit,
|
;; Below we fontify a whole declaration even when it crosses the limit,
|
||||||
;; to avoid gaps when lazy-lock fontifies the file a screenful at a
|
;; to avoid gaps when jit/lazy-lock fontifies the file a block at a
|
||||||
;; time. That is however annoying during editing, e.g. the following is
|
;; time. That is however annoying during editing, e.g. the following is
|
||||||
;; a common situation while the first line is being written:
|
;; a common situation while the first line is being written:
|
||||||
;;
|
;;
|
||||||
|
|
@ -1094,9 +1094,9 @@ casts and declarations are fontified. Used on level 2 and higher."
|
||||||
;; "some_other_variable" as an identifier, and the latter will not
|
;; "some_other_variable" as an identifier, and the latter will not
|
||||||
;; correct itself until the second line is changed. To avoid that we
|
;; correct itself until the second line is changed. To avoid that we
|
||||||
;; narrow to the limit if the region to fontify is a single line.
|
;; narrow to the limit if the region to fontify is a single line.
|
||||||
(narrow-to-region
|
(if (<= limit (c-point 'bonl))
|
||||||
(point-min)
|
(narrow-to-region
|
||||||
(if (<= limit (c-point 'bonl))
|
(point-min)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
;; Narrow after any operator chars following the limit though,
|
;; Narrow after any operator chars following the limit though,
|
||||||
;; since those characters can be useful in recognizing a
|
;; since those characters can be useful in recognizing a
|
||||||
|
|
@ -1104,8 +1104,7 @@ casts and declarations are fontified. Used on level 2 and higher."
|
||||||
;; after the header).
|
;; after the header).
|
||||||
(goto-char limit)
|
(goto-char limit)
|
||||||
(skip-chars-forward c-nonsymbol-chars)
|
(skip-chars-forward c-nonsymbol-chars)
|
||||||
(point))
|
(point))))
|
||||||
limit))
|
|
||||||
|
|
||||||
(c-find-decl-spots
|
(c-find-decl-spots
|
||||||
limit
|
limit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue