emacs-diffs
[Top][All Lists]
Advanced

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

master c9cf673d505: CC Mode: Fontify function names after long stretches


From: Alan Mackenzie
Subject: master c9cf673d505: CC Mode: Fontify function names after long stretches of macros.
Date: Fri, 12 May 2023 06:35:56 -0400 (EDT)

branch: master
commit c9cf673d505b2dd9a666fed50d7f3b2f7dff163f
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    CC Mode: Fontify function names after long stretches of macros.
    
    This fixes bug#63322.
    
    * lisp/progmodes/cc-engine.el (c-find-decl-spots): When a
    search back over syntactic whitespace hits its limit, set
    cfd-match-pos and cfd-continue-pos to cfd-start-pos.
    
    * lisp/progmodes/cc-mode.el (c-fl-decl-start): Remove an
    unneeded (and harmful) condition on (point)'s position in the
    main loop.
---
 lisp/progmodes/cc-engine.el | 21 +++++++++++++++------
 lisp/progmodes/cc-mode.el   |  2 --
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 8b34daf03c2..d21e082d0b6 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6244,6 +6244,9 @@ comment at the start of cc-engine.el for more info."
   ;; prefix".  The declaration prefix is the earlier of `cfd-prop-match' and
   ;; `cfd-re-match'.  `cfd-match-pos' is set to the decl prefix.
   ;;
+  ;; The variables which this macro should set for `c-find-decl-spots' are
+  ;; `cfd-match-pos' and `cfd-continue-pos'.
+  ;;
   ;; This macro might do hidden buffer changes.
 
   '(progn
@@ -6586,11 +6589,17 @@ comment at the start of cc-engine.el for more info."
        ;; and so we can continue the search from this point.  If we
        ;; didn't hit `c-find-decl-syntactic-pos' then we're now in
        ;; the right spot to begin searching anyway.
-       (if (and (eq (point) c-find-decl-syntactic-pos)
-                c-find-decl-match-pos)
-           (setq cfd-match-pos c-find-decl-match-pos
-                 cfd-continue-pos syntactic-pos)
-
+       (cond
+        ((and (eq (point) c-find-decl-syntactic-pos)
+              c-find-decl-match-pos)
+         (setq cfd-match-pos c-find-decl-match-pos
+               cfd-continue-pos syntactic-pos))
+        ((save-excursion (c-beginning-of-macro))
+         ;; The `c-backward-syntactic-ws' ~40 lines up failed to find non
+         ;; syntactic-ws and hit its limit, leaving us in a macro.
+         (setq cfd-match-pos cfd-start-pos
+               cfd-continue-pos cfd-start-pos))
+        (t
          (setq c-find-decl-syntactic-pos syntactic-pos)
 
          (when (if (bobp)
@@ -6608,7 +6617,7 @@ comment at the start of cc-engine.el for more info."
            (c-find-decl-prefix-search)) ; sets cfd-continue-pos
 
          (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos)
-                                          cfd-match-pos))))) ; end of `cond'
+                                          cfd-match-pos)))))) ; end of `cond'
 
       ;; Advance `cfd-continue-pos' if it's before the start position.
       ;; The closest continue position that might have effect at or
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 330202bb5f9..11a1d3fe6c2 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2444,8 +2444,6 @@ with // and /*, not more generic line and block comments."
                           (setq pseudo (c-cheap-inside-bracelist-p 
(c-parse-state)))))))
               (goto-char pseudo))
             t)
-          (or (> (point) bod-lim)
-              (eq bod-lim (point-min)))
           ;; Move forward to the start of the next declaration.
           (progn (c-forward-syntactic-ws)
                  ;; Have we got stuck in a comment at EOB?



reply via email to

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