how to highlight elisp macro argument?

156 Views Asked by At

when I use "use-package" macro in emacs lisp, I found that the argument is highlighted. macro argument is highlighted

but argument of my own macro is not highlighted by emacs.

mine not highlighted

How to write a macro with highlighted arguments?

1

There are 1 best solutions below

0
Rorschach On BEST ANSWER

use-package uses font-lock-add-keywords to mark the argument with font-lock-constant-face. Replacing "use-package" with "test_macro" in the the code would colorize your argument similarly

(defconst my-font-lock-keywords
  '(("(\\(test_macro\\)\\_>[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
     (1 font-lock-keyword-face)
     (2 font-lock-constant-face nil t))))

(font-lock-add-keywords 'emacs-lisp-mode my-font-lock-keywords)