[Top][All Lists]

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

How do you check if the current point is in a comment or a string? (Was

From: Clément Pit--Claudel
Subject: How do you check if the current point is in a comment or a string? (Was Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.])
Date: Wed, 9 Mar 2016 12:06:57 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/09/2016 05:49 AM, Alan Mackenzie wrote:
> (ii) No account is taken of possibly starting a parse-partial-sexp from
>   after the first character of a two character comment starter or ender.
>   OK, this is really a problem with the parser state not recording this
>   situation (which we could correct), but failing that, syntax-ppss
>   should check for this.  We did talk about this (in connection with a
>   CC Mode bug) a few years ago.

I keep running into this, actually. There are plenty of examples out there of 
people checking whether the face at point is font-lock-comment-face or 
font-lock-string-face or font-lock-doc-face to know whether the current point 
is in a comment or string. Using (nth 8 (syntax-ppss)) instead mostly works, 
except that it's nil in comment openers (e.g. in ;; in ELisp) and closers.

Am I missing something?


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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