unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Bug #25608 and the comment-cache branch
Date: Mon, 13 Feb 2017 18:09:19 +0000	[thread overview]
Message-ID: <20170213180919.GA2377@acm> (raw)
In-Reply-To: <jwvr333pbu5.fsf-monnier+emacs@gnu.org>

Hello, Stefan.

On Sun, Feb 12, 2017 at 12:49:29 -0500, Stefan Monnier wrote:
> > I also have an attachment to it because it works, and would save me
>                                                  ^^^
>                                                for you

> > demoralizing work debugging bugs caused by open parens in column zero in
> > comments.

> Is that really the only reason?  It seems like an amazingly complicated
> way to go about it.

comment-cache is a gross simplification of syntax.c, scanning comments
only in the forward direction and totally eliminating
open-paren-in-column-0-is-defun-start from syntax.c.  To achieve this
simplification took a lot of work.

> Let's see some alternatives:
> - set open-paren-in-column-0-is-defun-start to nil.

Too slow.

> - add a font-lock rule which highlights open-paren-in-column-0 inside
>   comments in bright red.

Totally irrelevant to what's required.  By the way, did you ever get
around to looking at that bug which noted that mechanism no longer
working?

> - use my syntax-ppss-based patch.

Doesn't work all the time, in particular in narrowed buffers.

> > Bug #22983 is a flaw.

> Great!  We're trying to have a reasoned argument; I tell you that using
> this term to describe this problem is not helping and you insist on
> using it.  From where I stand, this qualifies as provocation.

Of all the words in English which mean "imperfection", that's one of the
milder ones.  Would you prefer I used "defect" or "fault" or something
else?  #22983 _is_ a flaw/defect/fault/whatever else you want to call
it.  In particular, syntax-ppss gives out different results for a buffer
position depending on its internal state.

If that word would provoke you into actually fixing #22983, after all
this time, I would use it again for that purpose.

> > Also the cache invalidation in syntax-ppss is less than rigorous.

> Yup, syntax-ppss's implementation is not perfect.  That can be improved.

> > For example, the cache isn't invalidated when syntax-table text
> > properties are applied or removed.

> This is not a correct characterization of the most common
> cache-invalidation problem with syntax-ppss: there's a correlation
> between the problem and syntax-table text properties, but that's all: it
> also affects all other properties, but it doesn't affect all changes to
> the syntax-table text properties.

syntax-ppss is a cache of the syntax-table text property.  Not
invalidating the cache when a syntax-table text property is changed is
an imperfection.  Will it be fixed?

By contrast, there are no known bugs in the cacheing in comment-cache.

> >> BTW, your comment-cache doesn't fix that "flaw" and hence won't help any
> >> of those users of syntax-ppss which can't be changed to use your
> >> comment-cache.
> > That's incoherent.  comment-cache was never intended to help those other
> > uses, though it appears it could do so for most of them.

> It's only incoherent if you refuse to see the larger picture.

The larger picture is that comment-cache can work alongside syntax-ppss
pefectly happily without any contention.

> > Can't be done, as I keep telling you.  comment-cache is solely for
> > handling literals.

> Then it's useless, AFAIC:
> - we need syntax-ppss's data for lots of things.
> - your code can't replace all those uses.
> - so we're stuck with syntax-ppss, no matter how much you think it sucks.
> - then we might as well use it in back_comment instead of your code,
>   since it's there and is cheap.

But it doesn't work properly.  comment-cache is also cheap, having
already been written and debugged.

> > The question of "widening" is not difficult.  Narrowing a buffer should
> > not change the syntax of the characters in it.  Doing so leads to
> > inconsistencies.

> I can agree with that.  But currently that's not how Emacs behaves, so
> it's an incompatible change (which I'm quite willing to make, BTW), and
> needs to come with some way to recover the other behavior when that one
> is needed.

> > If I understand correctly, the problem is that multiple-major-mode modes
> > are trying to use narrowing to get a null syntactic context.

> That's the typical example, but not the only one.

> > They are trying this because we don't provide anything better.
> > We should provide something better.

> Agreed.

> > I suggested such a something last spring ("islands").  If each buffer
> > position has an unambiguous syntactic context the question of
> > "widening" simply evaporates.

> I think this is too specialized to a particular application (multiple
> major modes).  We also need to accommodate other cases.

Could you identify these other cases?

> For that we need to provide something equivalent to

>     (save-restriction
>       (narrow-to-region BEG END)
>       ...)

> but where syntax-ppss and friends will know that we shouldn't widen past
> BEG/END ....

I thorougly dislike the conceptualization of handling syntax as
"widening".  Both the Lisp and C parts of Emacs use narrowing and
widening "all the time", and if we try to express semantics in terms of
"widening" and "narrowing" we're going to create confusion.

> .... and that BEG should be taken as "the (temporary) beginning of the
> buffer".  Let's call it `with-region-as-subbuffer`.  Most likely, this
> new functionality should also make it possible to temporarily provide
> a different syntax-table.  Such things are used in various
> circumstances where the author simply wants to reuse Emacs's syntax.c
> code to avoid writing some ad-hoc parsing.

> IOW, we need to provide something on top of which we can build this
> `with-region-as-subbuffer` macro as well as your islands.

Introducing the new syntactic symbols "island start/end" would cater for
with-region-as-subbuffer admirably, without having to resort to
confusing narrowing.  Every buffer position would continue to have its
unique (global) syntactic context.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2017-02-13 18:09 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 20:24 Bug #25608 and the comment-cache branch Alan Mackenzie
2017-02-02 20:47 ` Eli Zaretskii
2017-02-02 21:51   ` Alan Mackenzie
2017-02-02 22:15     ` Dmitry Gutov
2017-02-03  7:41     ` Eli Zaretskii
2017-02-03 17:29       ` Alan Mackenzie
2017-02-03 22:08         ` Dmitry Gutov
2017-02-04 10:24           ` Alan Mackenzie
2017-02-06  2:09             ` Dmitry Gutov
2017-02-06 19:24               ` Alan Mackenzie
2017-02-07  1:42                 ` Dmitry Gutov
2017-02-07 19:21                   ` Alan Mackenzie
2017-02-14 15:28                     ` Dmitry Gutov
2017-02-14 16:38                       ` Stefan Monnier
2017-02-22  2:25                         ` Dmitry Gutov
2017-02-22  3:53                           ` Stefan Monnier
2017-02-23 14:23                             ` Dmitry Gutov
2017-02-23 14:48                               ` Stefan Monnier
2017-02-24  7:46                                 ` Tom Tromey
2017-02-14 21:14                       ` Alan Mackenzie
2017-02-16 14:10                         ` Stefan Monnier
2017-02-18 10:44                           ` Alan Mackenzie
2017-02-18 13:49                             ` Stefan Monnier
2017-02-12  2:53               ` John Wiegley
2017-02-12  8:20                 ` Elias Mårtenson
2017-02-12 10:47                 ` Alan Mackenzie
2017-02-12 11:14                 ` martin rudalics
2017-02-12 15:05                   ` Andreas Röhler
2017-02-12 15:39                   ` Eli Zaretskii
2017-02-05 22:00       ` Alan Mackenzie
2017-02-06  1:12         ` Stefan Monnier
2017-02-06 18:37           ` Alan Mackenzie
2017-02-08 17:20         ` Eli Zaretskii
2017-02-11 23:25           ` Alan Mackenzie
2017-02-12  0:55             ` Stefan Monnier
2017-02-12 12:05               ` Alan Mackenzie
2017-02-12 13:13                 ` Juanma Barranquero
2017-02-12 15:57                 ` Dmitry Gutov
2017-02-12 17:29                   ` Alan Mackenzie
2017-02-12 20:35                     ` Dmitry Gutov
2017-02-13  1:47                     ` zhanghj
2017-02-13  5:50                       ` Stefan Monnier
2017-02-13  6:45                         ` zhanghj
2017-02-13  7:24                           ` Stefan Monnier
2017-02-13  7:59                             ` zhanghj
2017-02-13  9:25                               ` Stefan Monnier
2017-02-13 16:14                           ` Drew Adams
2017-02-13  7:05                         ` zhanghj
2017-02-13  7:16                         ` zhanghj
2017-02-13 14:57                           ` Dmitry Gutov
2017-02-12 17:49                 ` Stefan Monnier
2017-02-13 18:09                   ` Alan Mackenzie [this message]
2017-02-13 19:34                     ` Eli Zaretskii
2017-02-13 21:21                     ` Stefan Monnier
2017-02-02 22:14 ` Dmitry Gutov
2017-02-03 16:44   ` Alan Mackenzie
2017-02-03 21:53     ` Dmitry Gutov
2017-02-04 11:02       ` Alan Mackenzie
2017-02-06  1:28         ` Dmitry Gutov
2017-02-06 19:37           ` Alan Mackenzie
2017-02-06  2:08         ` Stefan Monnier
2017-02-06 20:01           ` Alan Mackenzie
2017-02-06 22:33             ` Stefan Monnier
2017-02-07 21:24               ` Alan Mackenzie
2017-02-08 12:54                 ` Stefan Monnier
2017-02-07 15:29             ` Eli Zaretskii
2017-02-07 21:09               ` Alan Mackenzie
2017-02-08 17:28                 ` Eli Zaretskii
2017-02-02 23:57 ` Stefan Monnier
2017-02-03 16:19   ` Alan Mackenzie
2017-02-04  9:06     ` Andreas Röhler
2017-02-04 18:18     ` Stefan Monnier
2017-02-04 18:28       ` Alan Mackenzie
2017-02-03  7:49 ` Yuri Khan
2017-02-03 18:30   ` Andreas Röhler

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=20170213180919.GA2377@acm \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).