From: Dmitry Gutov Date: Sat, 4 Feb 2023 20:46:41 +0000 (+0200) Subject: c-ts-mode: Highlight name in parameter declarations X-Git-Tag: emacs-29.0.90~516 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=69380a88e92;p=emacs.git c-ts-mode: Highlight name in parameter declarations * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Uncomment parameter declaration highlighting (bug#61275). (c-ts-mode--fontify-declarator): Check that identifier was found. Some declarations can miss identifier name. --- diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 390f67a8e8c..2a164af26ea 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -440,11 +440,10 @@ MODE is either `c' or `cpp'." declarator: (_) @c-ts-mode--fontify-declarator) (function_definition - declarator: (_) @c-ts-mode--fontify-declarator)) + declarator: (_) @c-ts-mode--fontify-declarator) - ;; Should we highlight identifiers in the parameter list? - ;; (parameter_declaration - ;; declarator: (_) @c-ts-mode--fontify-declarator)) + (parameter_declaration + declarator: (_) @c-ts-mode--fontify-declarator)) :language mode :feature 'assignment @@ -552,9 +551,10 @@ For NODE, OVERRIDE, START, END, and ARGS, see identifier))) ("function_declarator" 'font-lock-function-name-face) (_ 'font-lock-variable-name-face)))) - (treesit-fontify-with-override - (treesit-node-start identifier) (treesit-node-end identifier) - face override start end))) + (when identifier + (treesit-fontify-with-override + (treesit-node-start identifier) (treesit-node-end identifier) + face override start end)))) (defun c-ts-mode--fontify-variable (node override start end &rest _) "Fontify an identifier node if it is a variable.