aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2023-05-12 10:33:15 +0000
committerAlan Mackenzie2023-05-12 10:33:15 +0000
commitc9cf673d505b2dd9a666fed50d7f3b2f7dff163f (patch)
tree9f79ccace85edcb41315bffadf66bc79e6f16f19
parent6234c3e0411a1d70bed2c85bbfb438d4479be51b (diff)
downloademacs-c9cf673d505b2dd9a666fed50d7f3b2f7dff163f.tar.gz
emacs-c9cf673d505b2dd9a666fed50d7f3b2f7dff163f.zip
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.
-rw-r--r--lisp/progmodes/cc-engine.el21
-rw-r--r--lisp/progmodes/cc-mode.el2
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."
6244 ;; prefix". The declaration prefix is the earlier of `cfd-prop-match' and 6244 ;; prefix". The declaration prefix is the earlier of `cfd-prop-match' and
6245 ;; `cfd-re-match'. `cfd-match-pos' is set to the decl prefix. 6245 ;; `cfd-re-match'. `cfd-match-pos' is set to the decl prefix.
6246 ;; 6246 ;;
6247 ;; The variables which this macro should set for `c-find-decl-spots' are
6248 ;; `cfd-match-pos' and `cfd-continue-pos'.
6249 ;;
6247 ;; This macro might do hidden buffer changes. 6250 ;; This macro might do hidden buffer changes.
6248 6251
6249 '(progn 6252 '(progn
@@ -6586,11 +6589,17 @@ comment at the start of cc-engine.el for more info."
6586 ;; and so we can continue the search from this point. If we 6589 ;; and so we can continue the search from this point. If we
6587 ;; didn't hit `c-find-decl-syntactic-pos' then we're now in 6590 ;; didn't hit `c-find-decl-syntactic-pos' then we're now in
6588 ;; the right spot to begin searching anyway. 6591 ;; the right spot to begin searching anyway.
6589 (if (and (eq (point) c-find-decl-syntactic-pos) 6592 (cond
6590 c-find-decl-match-pos) 6593 ((and (eq (point) c-find-decl-syntactic-pos)
6591 (setq cfd-match-pos c-find-decl-match-pos 6594 c-find-decl-match-pos)
6592 cfd-continue-pos syntactic-pos) 6595 (setq cfd-match-pos c-find-decl-match-pos
6593 6596 cfd-continue-pos syntactic-pos))
6597 ((save-excursion (c-beginning-of-macro))
6598 ;; The `c-backward-syntactic-ws' ~40 lines up failed to find non
6599 ;; syntactic-ws and hit its limit, leaving us in a macro.
6600 (setq cfd-match-pos cfd-start-pos
6601 cfd-continue-pos cfd-start-pos))
6602 (t
6594 (setq c-find-decl-syntactic-pos syntactic-pos) 6603 (setq c-find-decl-syntactic-pos syntactic-pos)
6595 6604
6596 (when (if (bobp) 6605 (when (if (bobp)
@@ -6608,7 +6617,7 @@ comment at the start of cc-engine.el for more info."
6608 (c-find-decl-prefix-search)) ; sets cfd-continue-pos 6617 (c-find-decl-prefix-search)) ; sets cfd-continue-pos
6609 6618
6610 (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos) 6619 (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos)
6611 cfd-match-pos))))) ; end of `cond' 6620 cfd-match-pos)))))) ; end of `cond'
6612 6621
6613 ;; Advance `cfd-continue-pos' if it's before the start position. 6622 ;; Advance `cfd-continue-pos' if it's before the start position.
6614 ;; The closest continue position that might have effect at or 6623 ;; 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."
2444 (setq pseudo (c-cheap-inside-bracelist-p (c-parse-state))))))) 2444 (setq pseudo (c-cheap-inside-bracelist-p (c-parse-state)))))))
2445 (goto-char pseudo)) 2445 (goto-char pseudo))
2446 t) 2446 t)
2447 (or (> (point) bod-lim)
2448 (eq bod-lim (point-min)))
2449 ;; Move forward to the start of the next declaration. 2447 ;; Move forward to the start of the next declaration.
2450 (progn (c-forward-syntactic-ws) 2448 (progn (c-forward-syntactic-ws)
2451 ;; Have we got stuck in a comment at EOB? 2449 ;; Have we got stuck in a comment at EOB?