This answer is just a slight modification of Lindydancer's answer in the following link: https://emacs.stackexchange.com/a/20228/2287
It has been modified to highlight a double-quoted name -- e.g., ;; Hello "James Bond".
The major-mode is emacs-lisp-mode
.
(defface drobnbobn-face
'((t (:background "black" :foreground "red")))
"Face for `drobnbobn-face'.")
(defvar drobnbobn-face 'drobnbobn-face)
(defun my-highlight-symbol-font-lock-keywords-matcher (limit)
"Search for doubled-quoted things in comments.
Match group 0 is the entire construct, 1 the symbol."
(let (res)
(while
(and (setq res (re-search-forward "\"\\([a-zA-Z0-9\s_-]+\\)\"" limit t))
(not (nth 4 (syntax-ppss))))) ; Continue, unless in a comment
res))
(defun my-highlight-symbol-activate ()
"Highlight double-quoted things in comments."
(font-lock-add-keywords nil
'((my-highlight-symbol-font-lock-keywords-matcher
(1 drobnbobn-face prepend)))))
(add-hook 'emacs-lisp-mode-hook #'my-highlight-symbol-activate)
c-mode
. emacs.stackexchange.com/a/20228/2287 You could surely adapt that example to a specific word or you could define your own way to recognize what needs a special color. – lawlist Mar 6 '16 at 15:48emacs-lisp-mode-common-hook
instead ofc-mode-common-hook
and"James Bond"
instead of ``\([a-zA-Z0-9_-]+\)'`? doesn't work – drobnbobn Mar 6 '16 at 16:35emacs-lisp-mode-hook
instead ofemacs-lisp-mode-common-hook
-- the latter does not exist. I've posted a working answer that you can further modify to suit your needs. – lawlist Mar 6 '16 at 17:50