1

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?

Drew
  • 29,895
  • 7
  • 74
  • 104
SamsonWang
  • 13
  • 5

1 Answers1

1

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)
Rorschach
  • 31,301
  • 5
  • 78
  • 129