]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-cmds.el
Finish fixing a cacheing bug in CC Mode (see 2016-03-09)
[gnu-emacs] / lisp / progmodes / cc-cmds.el
index 32ce8c6a249e5343d62ab54bc748a7b9315babc6..59f2729c43d4ca51183563ecb2bb98779897d89d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-cmds.el --- user level commands for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2016 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -1121,35 +1121,15 @@ numeric argument is supplied, or the point is inside a literal."
                           (looking-at "<<"))
                         (>= (match-end 0) final-pos)))
 
-             ;; It's a >.  Either a C++ >> operator. ......
-             (or (and (c-major-mode-is 'c++-mode)
+             ;; It's a >.  Either a template/generic terminator ...
+             (or (c-get-char-property (1- final-pos) 'syntax-table)
+                 ;; or a C++ >> operator.
+                 (and (c-major-mode-is 'c++-mode)
                       (progn
                         (goto-char (1- final-pos))
                         (c-beginning-of-current-token)
                         (looking-at ">>"))
-                      (>= (match-end 0) final-pos))
-                 ;; ...., or search back for a < which isn't already marked as an
-                 ;; opening template delimiter.
-                 (save-restriction
-                   (widen)
-                   ;; Narrow to avoid `c-forward-<>-arglist' below searching past
-                   ;; our position.
-                   (narrow-to-region (point-min) final-pos)
-                   (goto-char final-pos)
-                   (while
-                       (and
-                        (progn
-                          (c-syntactic-skip-backward "^<;}" nil t)
-                          (eq (char-before) ?<))
-                        (progn
-                          (backward-char)
-                          (looking-at "\\s("))))
-                   (and (eq (char-after) ?<)
-                        (not (looking-at "\\s("))
-                        (progn (c-backward-syntactic-ws)
-                               (c-simple-skip-symbol-backward))
-                        (or (looking-at c-opt-<>-sexp-key)
-                            (not (looking-at c-keywords-regexp)))))))))
+                      (>= (match-end 0) final-pos))))))
 
     (goto-char final-pos)
     (when found-delim
@@ -1157,11 +1137,9 @@ numeric argument is supplied, or the point is inside a literal."
       (when (and (eq (char-before) ?>)
                 (not executing-kbd-macro)
                 blink-paren-function)
-       ;; Currently (2014-10-19), the syntax-table text properties on < and >
-       ;; are only applied in code called during Emacs redisplay.  We thus
-       ;; explicitly cause a redisplay so that these properties have been
-       ;; applied when `blink-paren-function' gets called.
-       (sit-for 0)
+       ;; From now (2016-01-01), the syntax-table text properties on < and >
+       ;; are applied in an after-change function, not during redisplay.  Hence
+       ;; we no longer need to call (sit-for 0) for blink paren to work.
        (funcall blink-paren-function)))))
 
 (defun c-electric-paren (arg)
@@ -1617,12 +1595,12 @@ defun."
       (push-mark))
 
   (c-save-buffer-state
-      (beginning-of-defun-function end-of-defun-function
+      (beginning-of-defun-function
+       end-of-defun-function
        (start (point))
-       (paren-state (copy-tree (c-parse-state))) ; This must not share list
-                                       ; structure with other users of c-state-cache.
+       (paren-state (c-parse-state))
        (orig-point-min (point-min)) (orig-point-max (point-max))
-       lim                         ; Position of { which has been widened to.
+       lim                 ; Position of { which has been widened to.
        where pos case-fold-search)
 
     (save-restriction
@@ -1741,10 +1719,10 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'."
       (push-mark))
 
   (c-save-buffer-state
-      (beginning-of-defun-function end-of-defun-function
+      (beginning-of-defun-function
+       end-of-defun-function
        (start (point))
-       (paren-state (copy-tree (c-parse-state))) ; This must not share list
-                                 ; structure with other users of c-state-cache.
+       (paren-state (c-parse-state))
        (orig-point-min (point-min)) (orig-point-max (point-max))
        lim
        where pos case-fold-search)
@@ -1781,7 +1759,7 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'."
 
       ;; Do we need to move forward from the brace to the semicolon?
       (when (eq arg 0)
-       (if (c-in-function-trailer-p) ; after "}" of struct/enum, etc.
+       (if (c-in-function-trailer-p)   ; after "}" of struct/enum, etc.
            (c-syntactic-re-search-forward ";"))
 
        (setq pos (point))