emacs-devel
[Top][All Lists]
Advanced

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

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


From: Clément Pit--Claudel
Subject: Re: 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: Thu, 10 Mar 2016 12:21:53 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/10/2016 10:20 AM, Stefan Monnier wrote:
>> Thanks for the clarification. What's the recommended way to check if the
>> point is in a comment, then? I'm thinking for example of adjusting
>> fill-nobreak-predicate, or similar things.
> 
> The recommended way is
> 
>    (nth 8 (syntax-ppss))
> 
> Whether "/<point>*" is inside the comment or not is very debatable, and
> luckily it rarely matters.  So if/when it matters and syntax-ppss's
> answer isn't the one we need, then we can discuss the better replacement
> for that specific case, but the specifics will matter then.

Cool, thanks Stefan, As long as this behaviour is consistent with the rest of 
Emacs, that's fine by me.

Here's one case where it matters: in tuareg-mode (for OCaml), with the 
following code:

  (<point>* comment *)

The call to (prettify-symbols-default-compose-p (point) (1+ (point)) nil) 
returns t.
On the other hand, the same call with the point as follows returns nil:

  (*<point> comment *)

This makes it unreliable to prettify * to × in tuareg mode.
I'll report a bug for prettify-symbols-mode.

Clément.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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