emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e7e55e5: C++ Mode: Fontify correctly declarators wi


From: Alan Mackenzie
Subject: [Emacs-diffs] master e7e55e5: C++ Mode: Fontify correctly declarators with identifier preceded by &
Date: Thu, 3 Oct 2019 08:53:24 -0400 (EDT)

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

    C++ Mode: Fontify correctly declarators with identifier preceded by &
    
    The problem was bar in the following being spuriously recognised as a
    function, and foo as a type, as though the & were a *: Foo foo (&bar);.
    
    * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): New variable
    got-function-name-prefix, which is set when an operator like * (but not &)
    precedes the putative identifer in parentheses.  Test this variable when
    deciding whether or not to "move the type backwards" to the previous
    identifier.
    
    * lisp/progmodes/cc-langs.el (c-type-decl-operator-prefix-key): New lang 
const
    and var.
---
 lisp/progmodes/cc-engine.el | 8 +++++++-
 lisp/progmodes/cc-langs.el  | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 6d7d322..d1cca11 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9544,6 +9544,9 @@ This function might do hidden buffer changes."
          ;; True if there's a prefix match outside the outermost
          ;; paren pair that surrounds the declarator.
          got-prefix-before-parens
+         ;; True if there's a prefix, such as "*" which might precede the
+         ;; identifier in a function declaration.
+         got-function-name-prefix
          ;; True if there's a suffix match outside the outermost
          ;; paren pair that surrounds the declarator.  The value is
          ;; the position of the first suffix match.
@@ -9605,6 +9608,9 @@ This function might do hidden buffer changes."
            (unless got-prefix-before-parens
              (setq got-prefix-before-parens (= paren-depth 0)))
            (setq got-prefix t)
+           (when (save-match-data
+                   (looking-at c-type-decl-operator-prefix-key))
+             (setq got-function-name-prefix t))
            (goto-char (match-end 1)))
          (c-forward-syntactic-ws)))
 
@@ -9773,7 +9779,7 @@ This function might do hidden buffer changes."
                 (throw 'at-decl-or-cast t))
 
               (when (and got-parens
-                         (not got-prefix)
+                         (not got-function-name-prefix)
                          ;; (not got-suffix-after-parens)
                          (or backup-at-type
                              maybe-typeless
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 6ba14a8..d092094 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -3423,7 +3423,7 @@ Identifier syntax is in effect when this is matched \(see
   'dont-doc)
 
 (c-lang-defconst c-type-decl-operator-prefix-key
-  "Regexp matching any declarator operator which isn't a keyword
+  "Regexp matching any declarator operator which isn't a keyword,
 that might precede the identifier in a declaration, e.g. the
 \"*\" in \"char *argv\".  The end of the first submatch is taken
 as the end of the operator.  Identifier syntax is in effect when



reply via email to

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