emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 457738f: Correctly analyze brace arguments in tem


From: Alan Mackenzie
Subject: [Emacs-diffs] emacs-25 457738f: Correctly analyze brace arguments in templated C++ function declarations.
Date: Fri, 08 Jan 2016 22:42:49 +0000

branch: emacs-25
commit 457738ffba806a638ca3597741ecd103241790be
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    Correctly analyze brace arguments in templated C++ function declarations.
    
    * lisp/progmodes/cc-defs.el (c-go-list-forward, c-go-list-backward): add
    POS and LIMIT parameters, like the other c-go-list-* functions have.
    
    * lisp/progmodes/cc-engine.el (c-restore-<>-properties): Check backwards
    for a ?\( rather than a ?<.  (c-looking-at-inexpr-block): Handle names
    followed by template specifiers.
---
 lisp/progmodes/cc-defs.el   |   46 +++++++++++++++++++++++++++---------------
 lisp/progmodes/cc-engine.el |    9 ++++++-
 2 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 77e949c..000995c 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -654,23 +654,35 @@ right side of it."
 ;; Wrappers for common scan-lists cases, mainly because it's almost
 ;; impossible to get a feel for how that function works.
 
-(defmacro c-go-list-forward ()
-  "Move backward across one balanced group of parentheses.
-
-Return POINT when we succeed, NIL when we fail.  In the latter case, leave
-point unmoved."
-  `(c-safe (let ((endpos (scan-lists (point) 1 0)))
-            (goto-char endpos)
-            endpos)))
-
-(defmacro c-go-list-backward ()
-  "Move backward across one balanced group of parentheses.
-
-Return POINT when we succeed, NIL when we fail.  In the latter case, leave
-point unmoved."
-  `(c-safe (let ((endpos (scan-lists (point) -1 0)))
-            (goto-char endpos)
-            endpos)))
+(defmacro c-go-list-forward (&optional pos limit)
+  "Move forward across one balanced group of parentheses starting at POS or
+point.  Return POINT when we succeed, NIL when we fail.  In the latter case,
+leave point unmoved.
+
+A LIMIT for the search may be given.  The start position is assumed to be
+before it."
+  (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 0)) 
(point))))
+    (if limit
+       `(save-restriction
+          (if ,limit
+              (narrow-to-region (point-min) ,limit))
+          ,res)
+      res)))
+
+(defmacro c-go-list-backward (&optional pos limit)
+  "Move backward across one balanced group of parentheses starting at POS or
+point.  Return POINT when we succeed, NIL when we fail.  In the latter case,
+leave point unmoved.
+
+A LIMIT for the search may be given.  The start position is assumed to be
+after it."
+  (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 0)) 
(point))))
+    (if limit
+       `(save-restriction
+          (if ,limit
+              (narrow-to-region ,limit (point-max)))
+          ,res)
+      res)))
 
 (defmacro c-up-list-forward (&optional pos limit)
   "Return the first position after the list sexp containing POS,
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3301d41..98699df 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -5688,8 +5688,8 @@ comment at the start of cc-engine.el for more info."
        (c-backward-token-2)
        (setq c-restricted-<>-arglists
             (and (not (looking-at c-opt-<>-sexp-key))
-                 (progn (c-backward-syntactic-ws) ; to < or ,
-                        (and (memq (char-before) '(?< ?,))
+                 (progn (c-backward-syntactic-ws) ; to ( or ,
+                        (and (memq (char-before) '(?\( ?,)) ; what about <?
                              (not (eq (c-get-char-property (point) 'c-type)
                                       'c-decl-arg-start)))))))
       (or (c-forward-<>-arglist nil)
@@ -9106,6 +9106,11 @@ comment at the start of cc-engine.el for more info."
            (goto-char containing-sexp)
            (if (or (save-excursion
                      (c-backward-syntactic-ws lim)
+                     (while (and (eq (char-before) ?>)
+                                 (c-get-char-property (1- (point))
+                                                      'syntax-table)
+                                 (c-go-list-backward nil lim))
+                       (c-backward-syntactic-ws lim))
                      (and (> (point) (or lim (point-min)))
                           (c-on-identifier)))
                    (and c-special-brace-lists



reply via email to

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