From c5b4c7a028f2bf15d99753efc6f43b6e0b8d9e5e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 1 Nov 2024 16:55:51 +0100 Subject: emacs: Highlight ‘__func__’ and ‘__FUNCTION__’ in C MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/emacs/modules/mm-treesit.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el index 75e679f..ed8a299 100644 --- a/.config/emacs/modules/mm-treesit.el +++ b/.config/emacs/modules/mm-treesit.el @@ -137,4 +137,22 @@ This alist is used to configure `auto-mode-alist'.") ;; https://github.com/tree-sitter/tree-sitter-c/issues/236 (append keywords '("constexpr")))) -(provide 'mm-treesit) + +;;; Highlight Predefined Variables + +(with-eval-after-load 'treesit + (defvar mm-c-font-lock-rules + (treesit-font-lock-rules + :language 'c + :feature 'constant + :override t + `(((identifier) @font-lock-constant-face + (:match ,(rx bos (or "__func__" "__FUNCTION__") eos) + @font-lock-constant-face)))))) + +(add-hook 'c-ts-mode-hook + (defun mm-c-apply-font-lock-extras () + (setq treesit-font-lock-settings + (append treesit-font-lock-settings mm-c-font-lock-rules)))) + +(provide 'mm-treesit) \ No newline at end of file -- cgit v1.2.3