summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-fonts.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2022-09-26 19:16:33 +0000
committerAlan Mackenzie <acm@muc.de>2022-09-26 19:20:54 +0000
commit07e6bbb9bc68f76773e9bdf8846d64d83f50b0ea (patch)
treea7c935a05740386446ba0880a99938822e86b3ec /lisp/progmodes/cc-fonts.el
parentbb83fb5f62aa4b27a5598f4a0a9b22efdd94cf14 (diff)
downloademacs-07e6bbb9bc68f76773e9bdf8846d64d83f50b0ea.tar.gz
CC Mode: Handle C++20 concepts
* lisp/progmodes/cc-align.el (c-lineup-topmost-intro-cont): Amend so as not to indent lines following a requires line. * lisp/progmodes/cc-engine.el (c-forward-primary-expression) (c-forward-c++-requires-clause): New functions. (c-forward-declarator): Skip forward over any trailing requires clause. (c-forward-decl-or-cast-1): Skip requires clauses before and after the type. Amend the second element of the return list to include information on two consecutive identifiers in <...>. (c-looking-at-or-maybe-in-bracelist): Don't recognize braces in requires expressions as brace lists. (c-guess-basic-syntax): CASE 5D.7: New case to handle the continuation of a "concept foo = " line. * lisp/progmodes/cc-fonts.el (c-basic-matchers-before): Add a new clause to handle the declaration of a concept. (c-get-fontification-context): Treat the arglist of a requires construct as a declaration arglist. * lisp/progmodes/cc-langs.el (c-equals-nontype-decl-kwds/key) (c-fun-name-substitute-kwds/key, c-pre-concept-<>-kwds/key): New c-lang-consts/vars. (c-constant-key): New c-lang-var. (c-type-decl-suffix-key): Include "requires" in the keywords matched. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Fix an off by one error. Use equal rather than eq to compare two syntax contexts.
Diffstat (limited to 'lisp/progmodes/cc-fonts.el')
-rw-r--r--lisp/progmodes/cc-fonts.el39
1 files changed, 30 insertions, 9 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 5d80eb58e38..753ae480878 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -887,6 +887,23 @@ casts and declarations are fontified. Used on level 2 and higher."
,@(when (c-major-mode-is 'c++-mode)
'(c-font-lock-c++-modules))
+ ;; The next regexp is highlighted with narrowing. This is so that the
+ ;; final "context" bit of the regexp, "\\(?:[^=]\\|$\\)", which cannot
+ ;; match anything non-empty at LIMIT, will match "$" instead.
+ ,@(when (c-lang-const c-equals-nontype-decl-kwds)
+ `((,(byte-compile
+ `(lambda (limit)
+ (save-restriction
+ (narrow-to-region (point-min) limit)
+ ,(c-make-font-lock-search-form
+ (concat (c-lang-const c-equals-nontype-decl-key) ;no \\(
+ (c-lang-const c-simple-ws) "+\\("
+ (c-lang-const c-symbol-key) "\\)"
+ (c-lang-const c-simple-ws) "*"
+ "=\\(?:[^=]\\|$\\)")
+ `((,(+ 1 (c-lang-const c-simple-ws-depth))
+ font-lock-type-face t)))))))))
+
;; Fontify the special declarations in Objective-C.
,@(when (c-major-mode-is 'objc-mode)
`(;; Fontify class names in the beginning of message expressions.
@@ -1278,15 +1295,19 @@ casts and declarations are fontified. Used on level 2 and higher."
(or (memq type '(c-decl-arg-start c-decl-type-start))
(and
(progn (c-backward-syntactic-ws) t)
- (c-back-over-compound-identifier)
- (progn
- (c-backward-syntactic-ws)
- (or (bobp)
- (progn
- (setq type (c-get-char-property (1- (point))
- 'c-type))
- (memq type '(c-decl-arg-start
- c-decl-type-start))))))))))
+ (or
+ (and
+ (c-back-over-compound-identifier)
+ (progn
+ (c-backward-syntactic-ws)
+ (or (bobp)
+ (progn
+ (setq type (c-get-char-property (1- (point))
+ 'c-type))
+ (memq type '(c-decl-arg-start
+ c-decl-type-start))))))
+ (and (zerop (c-backward-token-2))
+ (looking-at c-fun-name-substitute-key))))))))
(cons 'decl nil))
(t (cons 'arglist t)))))