In Emacs I would like quoted symbols in emacs lisp such as: 'blah
and display them in a different color. How can I use font-lock
mode to do this?
Try:
(font-lock-add-keywords 'emacs-lisp-mode
'(("'[-a-zA-Z_][-a-zA-Z0-9_]*\\>" 0 'font-lock-constant-face)))
Or (if you don't want the quote colored):
(font-lock-add-keywords 'emacs-lisp-mode
'(("'\\([-a-zA-Z_][-a-zA-Z0-9_]*\\)\\>" 1 'font-lock-constant-face)))
This will not color things in comments or strings, as they are colored in earlier, and font-lock (by default) doesn't re-color things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With