[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-27 884b68c: CC Mode: Fontify foo in "const auto foo :" correctly
From: |
Alan Mackenzie |
Subject: |
emacs-27 884b68c: CC Mode: Fontify foo in "const auto foo :" correctly |
Date: |
Sun, 23 Feb 2020 06:02:33 -0500 (EST) |
branch: emacs-27
commit 884b68ca2c63c98d3fa90ca5f11b47286d2fb85c
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>
CC Mode: Fontify foo in "const auto foo :" correctly
* lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): While attempting
to
find a declaration's identifier, recast the latest found id. as that
identifier when there is no other type identifier and the result of the most
recent c-forward-type call is 'maybe or 'found. In the latter case, remove
the id. from the found types list, too.
---
lisp/progmodes/cc-engine.el | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 0c338fa..447942e 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9275,9 +9275,10 @@ This function might do hidden buffer changes."
;;
;; The third element of the return value is non-nil when the declaration
;; parsed might be an expression. The fourth element is the position of
- ;; the start of the type identifier. The fifth element is t if either
- ;; CONTEXT was 'top, or the declaration is detected to be treated as top
- ;; level (e.g. with the keyword "extern").
+ ;; the start of the type identifier, or the same as the first element when
+ ;; there is no type identifier. The fifth element is t if either CONTEXT
+ ;; was 'top, or the declaration is detected to be treated as top level
+ ;; (e.g. with the keyword "extern").
;;
;; If a cast is parsed:
;;
@@ -9680,7 +9681,26 @@ This function might do hidden buffer changes."
(setq got-identifier (c-forward-name))
(setq name-start pos))
(when (looking-at "[0-9]")
- (setq got-number t))) ; We've probably got an arithmetic expression.
+ (setq got-number t)) ; We probably have an arithmetic expression.
+ (and maybe-typeless
+ (or (eq at-type 'maybe)
+ (when (eq at-type 'found)
+ ;; Remove the ostensible type from the found types list.
+ (when type-start
+ (c-unfind-type
+ (buffer-substring-no-properties
+ type-start
+ (save-excursion
+ (goto-char type-start)
+ (c-end-of-token)
+ (point)))))
+ t))
+ ;; The token which we assumed to be a type is actually the
+ ;; identifier, and we have no explicit type.
+ (setq at-type nil
+ name-start type-start
+ id-start type-start
+ got-identifier t)))
;; Skip over type decl suffix operators and trailing noise macros.
(while
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-27 884b68c: CC Mode: Fontify foo in "const auto foo :" correctly,
Alan Mackenzie <=