Pregunta

Most of what I do with Emacs is in perl, and for that cperl-mode is mostly excellent; the one major annoyance is that a simple my $whatever introduction is given the property font-lock-keyword-face, which nixes the advantage of having keywords pop. I'm new to elisp, and so have been trying to play around with adding or removing keywords from font-lock. While both EmacsWiki and GNU give the syntax, the regex is driving me crazy. I got the following not to whine in my init:

(font-lock-remove-keywords 'cperl-mode '(("\\<\\(my\\)")))

And it does nothing. The \\<\\(my\\) bit works in scratch with re-builder so I think I have a syntax issue here. How do I add and remove keywords?

¿Fue útil?

Solución

The font-lock-remove-keywords function is designed to remove an existing font-lock rule, which, in font-lock jargon is a font-lock keyword.

If you apply it to something that is not an exact match of an existing font-lock rule, then it does nothing.

It is not designed to remove language keywords.

They best way to do this is to look at the variable font-lock-keywords and remove the rule that you don't like using font-lock-remove-keywords and then add a modified version of the rule using font-lock-add-keywords.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top