emacs-devel
[Top][All Lists]
Advanced

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

Re: The current state of the comment-cache branch


From: Alan Mackenzie
Subject: Re: The current state of the comment-cache branch
Date: Sat, 24 Dec 2016 11:36:20 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Elias.

On Sat, Dec 24, 2016 at 07:11:30PM +0800, Elias Mårtenson wrote:
> On 24 Dec 2016 5:44 pm, "Alan Mackenzie" <address@hidden> wrote:


>> This slowdown in Paul's config.h no longer happens, because of a
>> workaround put into syntax.c, I can't remember exactly what or when.
>> However, just last week, there was yet one more bug reported to CC
>> Mode about indentation, whose cause was a paren in C0 inside a
>> comment.  I would like these bug reports to cease.  As you said back
>> in March, Emacs should be able to handle these, as they are valid C.


> I'm sorry for raising a question which may have an obvious answer, but as I
> I have been following this thread I have become somewhat concerned with
> confused as to the underlying cause of this issue.

> Could you or someone else explain why an open paren in column 0 can affect
> the parsing of syntax in cc-mode at all? After all, such parens have no
> special syntactic nor semantic meaning in C nor C++.

It is a convention established in Emacs around ?40 years ago, that such
an open paren signalled the start of a defun.  This sped Emacs up
enormously, since the alternative was searching back to the beginning of
the buffer to check whether the paren was at the top level.

Currently, the only piece of low-level code which uses this convention is
back_comment in .../src/syntax.c.  This scans backward over a comment to
its beginning.  Scanning backwards is difficult, because you can't really
tell whether a string quote is contained within a comment, or a comment
marker might be contained within a string, ....  back_comment is
heuristic, and sort of works OK.  But it uses the open defun convention
to speed itself up.

When this convention is disabled (by setting
open-paren-in-column-0-is-defun-start to nil), Emacs runs s-l-o-w-l-y,
particularly in CC Mode (hence my concern).

The comment-cache branch solves these problems by NOT scanning comments
backwards.  Instead, it scans them forwards, storing the state of the
scanning at a particular point in a text property at that point.

I know that's not a brilliant answer.  Maybe the section in the emacs
manual might explain it better.  It's on page "Left Margin Paren".

> Regards,
> Elias

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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