diff options
author | Daniel MartÃn <mardani29@yahoo.es> | 2023-01-03 22:08:13 +0100 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2023-01-04 00:04:32 -0700 |
commit | c786afcbb9f5c4edf845beae08bdaa11d168a42f (patch) | |
tree | 7d95e9dd42b6c176b61411ab6648a1259afe03c3 /lisp/progmodes/c-ts-mode.el | |
parent | 0d98fac6bbc19c7728d42d6196adf4d392ba3132 (diff) | |
download | emacs-c786afcbb9f5c4edf845beae08bdaa11d168a42f.tar.gz emacs-c786afcbb9f5c4edf845beae08bdaa11d168a42f.tar.bz2 emacs-c786afcbb9f5c4edf845beae08bdaa11d168a42f.zip |
Fontify C++ function definitions in c-ts-mode (bug#60529)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--declarator-identifier):
Teach the code how to extract the declarator of a node of type
"qualified_identifier".
(c-ts-mode--fontify-declarator): Consider the case where the
identifier in a function declarator is buried inside
"qualifier_identifier" nodes.
Diffstat (limited to 'lisp/progmodes/c-ts-mode.el')
-rw-r--r-- | lisp/progmodes/c-ts-mode.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 1f2a195bf64..ffc15e681f7 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -430,6 +430,9 @@ MODE is either `c' or `cpp'." ((or "function_declarator" "array_declarator" "init_declarator") (c-ts-mode--declarator-identifier (treesit-node-child-by-field-name node "declarator"))) + ("qualified_identifier" + (c-ts-mode--declarator-identifier + (treesit-node-child-by-field-name node "name"))) ;; Terminal case. ((or "identifier" "field_identifier") node))) @@ -439,7 +442,14 @@ MODE is either `c' or `cpp'." For NODE, OVERRIDE, START, END, and ARGS, see `treesit-font-lock-rules'." (let* ((identifier (c-ts-mode--declarator-identifier node)) - (face (pcase (treesit-node-type (treesit-node-parent identifier)) + (qualified-root + (treesit-parent-while (treesit-node-parent identifier) + (lambda (node) + (equal (treesit-node-type node) + "qualified_identifier")))) + (face (pcase (treesit-node-type (treesit-node-parent + (or qualified-root + identifier))) ("function_declarator" 'font-lock-function-name-face) (_ 'font-lock-variable-name-face)))) (treesit-fontify-with-override |