emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103260: Proper fix for CC mode Bug#7


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103260: Proper fix for CC mode Bug#7722.
Date: Sun, 13 Feb 2011 15:25:15 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103260
author: Alan Mackenzie <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2011-02-13 15:25:15 -0500
message:
  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.
modified:
  lisp/ChangeLog
  lisp/progmodes/cc-engine.el
  lisp/progmodes/cc-fonts.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-02-13 20:04:33 +0000
+++ b/lisp/ChangeLog    2011-02-13 20:25:15 +0000
@@ -1,3 +1,12 @@
+2011-02-13  Alan Mackenzie  <address@hidden>
+
+       * 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  <address@hidden>
 
        * vc/log-view.el: New command log-view-toggle-entry-display for

=== modified file 'lisp/progmodes/cc-engine.el'
--- a/lisp/progmodes/cc-engine.el       2011-01-31 23:54:50 +0000
+++ b/lisp/progmodes/cc-engine.el       2011-02-13 20:25:15 +0000
@@ -5371,8 +5371,6 @@
 ;; cc-mode requires cc-fonts.
 (declare-function c-fontify-recorded-types-and-refs "cc-fonts" ())
 
-(defvar c-forward-<>-arglist-recur-depth)
-
 (defun c-forward-<>-arglist (all-types)
   ;; 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
@@ -5398,8 +5396,7 @@
        ;; If `c-record-type-identifiers' is set then activate
        ;; recording of any found types that constitute an argument in
        ;; the arglist.
-       (c-record-found-types (if c-record-type-identifiers t))
-       (c-forward-<>-arglist-recur--depth 0))
+       (c-record-found-types (if c-record-type-identifiers t)))
     (if (catch 'angle-bracket-arglist-escape
          (setq c-record-found-types
                (c-forward-<>-arglist-recur all-types)))
@@ -5416,14 +5413,6 @@
       nil)))
 
 (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'.
   ;;
   ;; This function might do hidden buffer changes.
@@ -5455,9 +5444,11 @@
            (goto-char start)
            nil))
 
-      (forward-char)
+      (forward-char) ; Forward over the opening '<'.
 
       (unless (looking-at c-<-op-cont-regexp)
+       ;; go forward one non-alphanumeric character (group) per iteration of
+       ;; this loop.
        (while (and
                (progn
                  (c-forward-syntactic-ws)
@@ -5486,7 +5477,7 @@
                            (c-forward-type)
                            (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
                  ;; that "<>" is matched by "<" rather than "[^>:-]>".
@@ -5522,37 +5513,35 @@
                  ;; Either an operator starting with '<' or a nested arglist.
                  (setq pos (point))
                  (let (id-start id-end subres keyword-match)
-                   (if (if (looking-at c-<-op-cont-regexp)
-                           (setq tmp (match-end 0))
-                         (setq tmp pos)
-                         (backward-char)
-                         (not
-                          (and
-
-                           (save-excursion
-                             ;; There's always an identifier before an angle
-                             ;; bracket arglist, or a keyword in
-                             ;; `c-<>-type-kwds' or `c-<>-arglist-kwds'.
-                             (c-backward-syntactic-ws)
-                             (setq id-end (point))
-                             (c-simple-skip-symbol-backward)
-                             (when (or (setq keyword-match
-                                             (looking-at c-opt-<>-sexp-key))
-                                       (not (looking-at c-keywords-regexp)))
-                               (setq id-start (point))))
-
-                           (setq subres
-                                 (let ((c-promote-possible-types t)
-                                       (c-record-found-types t))
-                                   (c-forward-<>-arglist-recur
-                                    (and keyword-match
-                                         (c-keyword-member
-                                          (c-keyword-sym (match-string 1))
-                                          'c-<>-type-kwds)))))
-                           )))
-
-                       ;; It was not an angle bracket arglist.
-                       (goto-char tmp)
+                  (cond
+                    ;; The '<' begins a multi-char operator.
+                    ((looking-at c-<-op-cont-regexp)
+                     (setq tmp (match-end 0))
+                     (goto-char (match-end 0)))
+                    ;; We're at a nested <.....>
+                    ((progn
+                       (setq tmp pos)
+                       (backward-char) ; to the '<'
+                       (and
+                        (save-excursion
+                          ;; There's always an identifier before an angle
+                          ;; bracket arglist, or a keyword in `c-<>-type-kwds'
+                          ;; or `c-<>-arglist-kwds'.
+                          (c-backward-syntactic-ws)
+                          (setq id-end (point))
+                          (c-simple-skip-symbol-backward)
+                          (when (or (setq keyword-match
+                                          (looking-at c-opt-<>-sexp-key))
+                                    (not (looking-at c-keywords-regexp)))
+                            (setq id-start (point))))
+                        (setq subres
+                              (let ((c-promote-possible-types t)
+                                    (c-record-found-types t))
+                                (c-forward-<>-arglist-recur
+                                 (and keyword-match
+                                      (c-keyword-member
+                                       (c-keyword-sym (match-string 1))
+                                       'c-<>-type-kwds)))))))
 
                      ;; It was an angle bracket arglist.
                      (setq c-record-found-types subres)
@@ -5567,8 +5556,13 @@
                                   (c-forward-syntactic-ws)
                                   (looking-at c-opt-identifier-concat-key)))
                            (c-record-ref-id (cons id-start id-end))
-                         (c-record-type-id (cons id-start id-end))))))
-                 t)
+                        (c-record-type-id (cons id-start id-end)))))
+
+                   ;; At a "less than" operator.
+                   (t
+                    (forward-char)
+                    )))
+                t)                    ; carry on looping.
 
                 ((and (not c-restricted-<>-arglists)
                       (or (and (eq (char-before) ?&)

=== modified file 'lisp/progmodes/cc-fonts.el'
--- a/lisp/progmodes/cc-fonts.el        2011-01-25 04:08:28 +0000
+++ b/lisp/progmodes/cc-fonts.el        2011-02-13 20:25:15 +0000
@@ -1082,7 +1082,7 @@
             (boundp 'parse-sexp-lookup-properties))))
 
       ;; 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
       ;; a common situation while the first line is being written:
       ;;
@@ -1094,9 +1094,9 @@
       ;; "some_other_variable" as an identifier, and the latter will not
       ;; 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-region
-       (point-min)
-       (if (<= limit (c-point 'bonl))
+      (if (<= limit (c-point 'bonl))
+         (narrow-to-region
+          (point-min)
           (save-excursion
             ;; Narrow after any operator chars following the limit though,
             ;; since those characters can be useful in recognizing a
@@ -1104,8 +1104,7 @@
             ;; after the header).
             (goto-char limit)
             (skip-chars-forward c-nonsymbol-chars)
-            (point))
-        limit))
+            (point))))
 
       (c-find-decl-spots
        limit


reply via email to

[Prev in Thread] Current Thread [Next in Thread]