unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: "Elias Mårtenson" <lokedhs@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: The current state of the comment-cache branch
Date: Sat, 24 Dec 2016 11:36:20 +0000	[thread overview]
Message-ID: <20161224113620.GF2212@acm.fritz.box> (raw)
In-Reply-To: <CADtN0W+bJfHP0-0F6m7k1zgzi_-efF4bsic=n7bCbBZNo3Oa_Q@mail.gmail.com>

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" <acm@muc.de> 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	other threads:[~2016-12-24 11:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-23 21:50 The current state of the comment-cache branch Alan Mackenzie
2016-12-24  1:32 ` Stefan Monnier
2016-12-24  9:07   ` Alan Mackenzie
2016-12-24  1:33 ` Stefan Monnier
2016-12-24  8:40   ` Alan Mackenzie
2016-12-24 20:56   ` Stephen Leake
2016-12-25 15:47     ` Stefan Monnier
2016-12-25 20:41     ` Richard Stallman
2016-12-24  8:02 ` Eli Zaretskii
2016-12-24  8:30   ` Alan Mackenzie
2016-12-24  8:55     ` Eli Zaretskii
2016-12-24  9:42       ` Alan Mackenzie
2016-12-24 11:11         ` Elias Mårtenson
2016-12-24 11:36           ` Alan Mackenzie [this message]
2016-12-24 12:00             ` Eli Zaretskii
2016-12-24 21:48               ` Andreas Röhler
     [not found]             ` <CADtN0W+7zHzuoWFrzs6MuonUM74D_dC+yh10rSk+r0nuxgeTBg@mail.gmail.com>
     [not found]               ` <CADtN0WJYXRg=oEBxn3UPjF6RFJG62nG4GpUFaphdkj9Egde_4Q@mail.gmail.com>
2016-12-24 12:21                 ` Elias Mårtenson
2016-12-27 17:55                   ` Alan Mackenzie
2016-12-28 15:36                     ` Eli Zaretskii
2016-12-28 16:42                       ` Alan Mackenzie
2016-12-28 16:45                       ` Nikolaus Rath
2016-12-28 17:09                         ` Eli Zaretskii
2016-12-28 23:58                           ` Nikolaus Rath
2016-12-29  3:43                             ` Eli Zaretskii
2016-12-29 16:56                               ` Nikolaus Rath
2016-12-29 17:46                                 ` Eli Zaretskii
2016-12-29 19:44                                   ` Alan Mackenzie
2016-12-30 10:29                                     ` Andreas Röhler
2017-01-03 17:39                                       ` Stefan Monnier
2017-01-20 18:58                                         ` Andreas Röhler
2017-01-20 21:48                                           ` Stefan Monnier
2017-01-21  9:06                                             ` Andreas Röhler
2017-01-22  4:28                                               ` Stefan Monnier
2016-12-28 17:15                         ` Stefan Monnier
2016-12-29  1:38                           ` Richard Stallman
2016-12-29  2:15                             ` Stefan Monnier
2016-12-24 12:27         ` Eli Zaretskii
2016-12-24 22:19           ` Paul Eggert
2016-12-25 16:07           ` Stefan Monnier
2016-12-25 16:30             ` Eli Zaretskii
2016-12-28  8:37             ` Alan Mackenzie
2016-12-28 17:02               ` Stefan Monnier
2016-12-28 17:10               ` Stefan Monnier
2016-12-27 16:40           ` Alan Mackenzie
2016-12-28 15:35             ` Eli Zaretskii
2016-12-28 16:35               ` Alan Mackenzie
2016-12-24 18:54 ` Richard Stallman
2016-12-27 16:11   ` Alan Mackenzie
2016-12-28  1:40     ` Dmitry Gutov
2016-12-28  7:54       ` Alan Mackenzie
2016-12-29  1:13         ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161224113620.GF2212@acm.fritz.box \
    --to=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lokedhs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).