I am working with the C-source code of Emacs using the built-in c-mode
, and would like Emacs to automatically highlight functions and variables within comments with a different color: In the following example, how can I make pos-visible-in-window-p
a different color?
/* See the doc-string for `pos-visible-in-window-p'. */
(font-lock-add-keywords 'c-mode '(("`\\([a-z-]+\\)'" 1 'font-lock-function-name-face prepend)))
. This does not check if`foo'
is in a comment, though. – Constantine Feb 6 '16 at 21:24c-font-lock-doc-comments
might be appropriate. However, the method used byc-mode
to achieve its highlighting is quite complex. – lawlist Feb 6 '16 at 21:39emacs-lisp-mode
highlights functions and variables within comments, and find that I really miss that visual behavior when working inc-mode
. The answer of @Constantine is essentially a textbook example fromfont-lock
class 101. I'm most interested in a spiffy modification of the syntactic functions used byc-mode
to achieve the desired effect. I am already familiar with the find features for functions and variables. – lawlist Feb 6 '16 at 22:51gtkdoc
,autodoc
, andjavadoc
) would be enough -- it would be nice to leave the logic ofc-font-lock-doc-comments
alone). Also, I just realized that one could modifybug-reference-mode
to achieve something similar. (That way we could easily have clickable buttons that call 'describe-function` ordescribe-variable
.) – Constantine Feb 7 '16 at 0:08