help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to detect font-lock mode is on?


From: Stefan Monnier
Subject: Re: Best way to detect font-lock mode is on?
Date: Sun, 02 Jan 2011 23:59:14 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Just wanting to know what people would suggest as the best way to detect
> if font-lock mode is enabled. 

Wrong question, I suspect.

> I have two functions I use in a mode to determine if the point is
> currently within a comment or a string. If font-lock mode is enabled,

So IIUC the real question is how to determine if you're within a comment
or string.  The answer is (nth 4 (syntax-ppss)) and (nth
3 (syntax-ppss)) respectively (and (nth 8 (syntax-ppss)) if you want to
check whether you're within either of the two).

> As you can see, I'm using font-lock-defaults to test whether font-lock
> is enabled. Is this the best way to go or is there a more
> reliable/better test to use?

Any reason not to use `font-lock-mode'?


        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]