help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

overriding a feature in c-ts-mode


From: Noel Errenil
Subject: overriding a feature in c-ts-mode
Date: Mon, 16 Sep 2024 13:57:37 +1000

Dear Emacs Community,

I'm trying to highlight variables of all uppercase letters in
font-lock-constant-face but I just can't seem to get my head around
it.  At the moment I have the following configuration in my init.el:

(defun my-customize-c-ts-mode-font-lock ()
  (setq-local
   treesit-font-lock-settings
   (append treesit-font-lock-settings
           (treesit-font-lock-rules
            :language 'c
            :override t
            :feature 'variable
            '((identifier) @font-lock-constant-face
              (:match "[A-Z0-9_]+" @font-lock-constant-face)))))

  (treesit-font-lock-recompute-features))

(add-hook 'c-ts-mode-hook #'my-customize-c-ts-mode-font-lock)

(setq treesit-font-lock-level 4)

The effect I'd like to have is to highlight a variable like `MY_VAR'
in the constant face instead of the variable face.  How can I do this
correctly?

Best,
Erre



reply via email to

[Prev in Thread] Current Thread [Next in Thread]