unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* overriding a feature in c-ts-mode
@ 2024-09-16  3:57 Noel Errenil
  0 siblings, 0 replies; only message in thread
From: Noel Errenil @ 2024-09-16  3:57 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-16  3:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16  3:57 overriding a feature in c-ts-mode Noel Errenil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).