emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master b02a063: C++ Mode: Fontify correctly uniform initia


From: Alan Mackenzie
Subject: [Emacs-diffs] master b02a063: C++ Mode: Fontify correctly uniform initialisation with inner parentheses.
Date: Tue, 16 Jan 2018 17:07:46 -0500 (EST)

branch: master
commit b02a06317b04b56d54f73a7d97568a0bc150a18b
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    C++ Mode: Fontify correctly uniform initialisation with inner parentheses.
    
    E.g.: someStruct x ( (nullptr != y) ? 3 : 4 )
    Also fontify declarations of function pointers correctly.
    
    * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): While testing for 
a
    typeless declaration, additionally test the variable `got-prefix' to
    recognize a function pointer in parentheses.  Allow 
c-fdoc-shift-type-backward
    to be invoked when we have nested parens.
---
 lisp/progmodes/cc-engine.el | 57 ++++++++++++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index e997260..5a0088d 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8605,6 +8605,7 @@ comment at the start of cc-engine.el for more info."
                 ;; construct here in C, since we want to recognize this as a
                 ;; typeless function declaration.
                 (not (and (c-major-mode-is 'c-mode)
+                          (not got-prefix)
                           (or (eq context 'top) make-top)
                           (eq (char-after) ?\)))))
            (if (eq (char-after) ?\))
@@ -8634,31 +8635,39 @@ comment at the start of cc-engine.el for more info."
            ;; (con|de)structors in C++ and `c-typeless-decl-kwds'
            ;; style declarations.  That isn't applicable in an
            ;; arglist context, though.
-           (when (and (= paren-depth 1)
-                         (not got-prefix-before-parens)
-                         (not (eq at-type t))
-                         (or backup-at-type
-                             maybe-typeless
-                             backup-maybe-typeless
-                             (when c-recognize-typeless-decls
-                               (and (memq context '(nil top))
-                                    ;; Deal with C++11's "copy-initialization"
-                                    ;; where we have <type>(<constant>), by
-                                    ;; contrasting with a typeless
-                                    ;; <name>(<type><parameter>, ...).
-                                    (save-excursion
-                                      (goto-char after-paren-pos)
-                                      (c-forward-syntactic-ws)
-                                      (or (c-forward-type)
-                                          ;; Recognize a top-level typeless
-                                          ;; function declaration in C.
-                                          (and (c-major-mode-is 'c-mode)
-                                               (or (eq context 'top) make-top)
-                                               (eq (char-after) ?\))))))))
-                         (setq pos (c-up-list-forward (point)))
-                         (eq (char-before pos) ?\)))
+           (when (and (> paren-depth 0)
+                      (not got-prefix-before-parens)
+                      (not (eq at-type t))
+                      (or backup-at-type
+                          maybe-typeless
+                          backup-maybe-typeless
+                          (when c-recognize-typeless-decls
+                            (and (memq context '(nil top))
+                                 ;; Deal with C++11's "copy-initialization"
+                                 ;; where we have <type>(<constant>), by
+                                 ;; contrasting with a typeless
+                                 ;; <name>(<type><parameter>, ...).
+                                 (save-excursion
+                                   (goto-char after-paren-pos)
+                                   (c-forward-syntactic-ws)
+                                   (or (c-forward-type)
+                                       ;; Recognize a top-level typeless
+                                       ;; function declaration in C.
+                                       (and (c-major-mode-is 'c-mode)
+                                            (or (eq context 'top) make-top)
+                                            (eq (char-after) ?\))))))))
+                      (let ((pd paren-depth))
+                        (setq pos (point))
+                        (catch 'pd
+                          (while (> pd 0)
+                            (setq pos (c-up-list-forward pos))
+                            (when (or (null pos)
+                                      (not (eq (char-before pos) ?\))))
+                              (throw 'pd nil))
+                            (goto-char pos)
+                            (setq pd (1- pd)))
+                          t)))
                 (c-fdoc-shift-type-backward)
-                (goto-char pos)
                 t)))
 
        (c-forward-syntactic-ws))



reply via email to

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