emacs-devel
[Top][All Lists]
Advanced

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

Re: Bug #25608 and the comment-cache branch


From: Stefan Monnier
Subject: Re: Bug #25608 and the comment-cache branch
Date: Sun, 05 Feb 2017 21:08:15 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>> > The "alternative patch" didn't scan comments correctly all the time
>> > when I looked at it, just as the current back_comment doesn't.

Of course, there's an alternative way to look at this reality: your
comment-cache changes the behavior in some cases where the AP patch doesn't.
You claim that the new behavior is "correct" and the other one "wrong",
but AFAIK these are borderline cases where both interpretations can be
correct or wrong depending on what narrowing was used for.

So while I don't claim that comment cache's behavior is *wrong*, it
might break existing code.

> In the following test case (same as in my other post) the "alternative
> patch" doesn't work.  Narrow the buffer with point-min at the indicated
> position.  Put point at EOL.  Try M-: (forward-comment -1).  This fails.

>     char foo[] = "asdf asdf" "asdf"; /* "asdf" */ /*  */  /*   '"'"  */
>                       ^

For example here, your intention for narrowing is clear, but Emacs
currently doesn't keep track of the fact that the user put this
narrowing (rather than some code like mmm-mode), so while in this case
your comment-cache is probably right, in other cases it might give the
wrong answer.  E.g. maybe in a case such as

     char foo[] = "for (x = 0; x < n; x++) /* Loop header */\n";
                   ^                                        ^

where the user narrows to the string, then goes to EOL and does
M-: (forward-comment -1)

Really your comment-cache (just like the existing code) currently can't
do much better, because to do better we need to fix the narrowing
problem.

So really, the problem to be solved is the problem of narrowing.
Once that one is solved, AP and comment-cache should both be able to
behave correctly in both cases (in the case of AP, this will happen
without any changes to AP itself, because the fix will be in
syntax-ppss).


        Stefan




reply via email to

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