Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply font lock to quoted symbols in elisp

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?

like image 556
Zameer Manji Avatar asked Dec 17 '12 04:12

Zameer Manji


1 Answers

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.

like image 101
Lindydancer Avatar answered Sep 28 '22 00:09

Lindydancer