Hessu
Hessu

Reputation: 59

How to write a regex that allows a comment at the end of line without turning off font-lock for the line in an Emacs major mode

I'm trying to write a regex for a font-lock command. I want the font-lock to apply to all characters following '!', until the end of line or a comment, starting with '#', but the font-lock is turned off for the whole line after I enter any characters following '#'.

Currently I have this:

("!.*[^#+?]" . font-lock-custom-face)

! this works as expected #
! but here the font-lock # breaks

In the latter example, the comment is colored, but the line before it is not.

This works fine for a line without a comment, but the font-lock only 'ignores' the '#' sign, not the characters following it. How could I make the comment longer than just the '#' character, without breaking the font-lock on the part of the line preceding the comment?

Upvotes: 0

Views: 50

Answers (0)

Related Questions