unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: John Wiegley <jwiegley@gmail.com>,
	Philipp Stephani <p.stephani2@gmail.com>,
	22983@debbugs.gnu.org
Subject: bug#22983: syntax-ppss returns wrong result.
Date: Sat, 9 Sep 2017 10:20:27 +0000	[thread overview]
Message-ID: <20170909102027.GB5194@ACM> (raw)
In-Reply-To: <69e034d3-7a52-cc81-dc56-e5308ad5dce0@yandex.ru>

Hello, Dmitry.

On Sat, Sep 09, 2017 at 12:44:02 +0300, Dmitry Gutov wrote:
> Hi Alan,

> On 9/7/17 11:45 PM, Alan Mackenzie wrote:

> > The solution I propose is to introduce a second cache into syntax-ppss,
> > and this cache would be used whenever (not (eq (point-min) 1)).
> > Whenever point-min changes, and isn't 1, this second cached would be
> > calculated again from scratch.

> Thanks for writing this up. I think it's a good step, and since it 
> follow the current wording of the docstring, it should be highly 
> compatible with the existing code.

Thanks.

> > This proposal has these advantages:

> > (i) It would make the function deliver what its unchanged doc string
> > says.  This is important, given that syntax-ppss has been very widely
> > used within Emacs, and likely by external packages too; these will
> > typically have assumed the advertised behaviour of the function, without
> > having tested it in narrowed buffers.

> It will also continue to function as expected in mmm-mode, AFAICT, 
> without the need for an "escape hatch" we discussed before.

> > (i) In the case which currently works, namely a non-narrowed buffer,
> > there would be only a minute slow-down (basically, there would be extra
> > code to check point-min and select the cache to use).

> > (ii) The cache for use in a narrowed buffer might well be sufficiently
> > fast in normal use.  If it is not, it could be enhanced readily.

> And since the API doesn't change, and the observable behavior doesn't 
> either (in the vast majority of cases; probably all except the broken 
> ones), we can refine this solution easily, or even swap it for something 
> else, with little cost.

Yes.  I now have a provisional implementation of this new strategy,
which works on the test case for xdisp.c with which I opened the bug.
It seems to be working, generally.  I need to test it more thoroughly.

In the implementation, I have left the function `syntax-ppss' untouched
except for adding a function call to set up the cache right at the
start.  I have refactored syntax-ppss-flush-cache, extracting a function
which is called directly from the cache-selecting code.  Other than
that, there is one new function (which switches the current cache in
use) and a few new variables to keep track of the caches.

> > I think Dmitry also proposed a method of solution some months ago,
> > though I don't remember in detail what it was.  Dmitry, do you still
> > think your solution would work?  If so, please elaborate on it.

> There is a simple patch at 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22983#47, but I after some 
> consideration, I now prefer your proposed approach. We've also had some 
> grander ideas about enhancing things further, but those can be added 
> later, after we finally decide.

Yes, I agree.

> I do want to know what Stefan thinks of this subject now, though.

Yes.

> Caveats:

> - This solves the dependency on point-min, but does nothing about the 
> dependency on the current syntax-table (which can change). I'm not 
> necessarily suggesting we try to solve that now, though.

I had some ideas on this back in the spring (about having "indirect
variables") which could be used quickly to "swap out" the current
syntax-table text properties, and (more importantly) quickly swap them
back in.  But that's for another day.

> - Before this change is pushed to master, or shortly after, I'd like to 
> know that it actually fixed the problem Philipp experienced with 
> python-mode, so we can revert 4fbd330. If it was caused by e.g. 
> syntax-table changing, we've not improved much.

I am naturally interested in this, too.  If my patch doesn't fix this
bug, at least it will have removed a layer of fog inhibiting its
investigation.

> All the best,
> Dmitry.

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2017-09-09 10:20 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 15:15 bug#22983: syntax-ppss returns wrong result Alan Mackenzie
2016-03-11 20:31 ` Dmitry Gutov
2016-03-11 21:24   ` Alan Mackenzie
2016-03-11 21:35     ` Dmitry Gutov
2016-03-11 22:15       ` Alan Mackenzie
2016-03-11 22:38         ` Dmitry Gutov
2016-03-13 17:37           ` Stefan Monnier
2016-03-13 18:57             ` Alan Mackenzie
2016-03-14  0:47               ` Dmitry Gutov
2016-03-14  1:04                 ` Drew Adams
2016-04-03 22:55                   ` John Wiegley
2016-03-14  1:49               ` Stefan Monnier
2016-03-13 17:32     ` Stefan Monnier
2016-03-13 18:52 ` Andreas Röhler
2016-03-13 18:56   ` Dmitry Gutov
2016-03-18  0:49 ` Dmitry Gutov
2016-03-19 12:27   ` Alan Mackenzie
2016-03-19 18:47     ` Dmitry Gutov
2016-03-27  0:51       ` John Wiegley
2016-03-27  1:14         ` Dmitry Gutov
2016-04-03 22:58           ` John Wiegley
2016-04-03 23:15             ` Dmitry Gutov
2017-09-02 13:12               ` Eli Zaretskii
2017-09-02 17:40                 ` Alan Mackenzie
2017-09-02 17:53                   ` Eli Zaretskii
2017-09-03 20:44                   ` John Wiegley
2017-09-04 23:34                   ` Dmitry Gutov
2017-09-05  6:57                     ` Andreas Röhler
2017-09-05 12:28                     ` John Wiegley
2017-09-07 20:45                       ` Alan Mackenzie
2017-09-08 16:04                         ` Andreas Röhler
2017-09-10 18:26                           ` Alan Mackenzie
2017-09-09  9:44                         ` Dmitry Gutov
2017-09-09 10:20                           ` Alan Mackenzie [this message]
2017-09-09 12:18                             ` Dmitry Gutov
2017-09-10 11:42                               ` Alan Mackenzie
2017-09-10 11:36                           ` bug#22983: [ Patch ] " Alan Mackenzie
2017-09-10 22:53                             ` Stefan Monnier
2017-09-10 23:36                               ` Dmitry Gutov
2017-09-11 11:10                                 ` Stefan Monnier
2017-09-12  0:11                                   ` Dmitry Gutov
2017-09-12 22:12                                     ` Richard Stallman
2017-09-11 19:42                               ` Alan Mackenzie
2017-09-11 20:20                                 ` Stefan Monnier
2017-09-11  0:11                             ` Dmitry Gutov
2017-09-11 20:12                               ` Alan Mackenzie
2017-09-12  0:24                                 ` Dmitry Gutov
2017-09-17 10:29                                   ` Alan Mackenzie
2017-09-17 23:43                                     ` Dmitry Gutov
2017-09-18 19:08                                       ` Alan Mackenzie
2017-09-19  0:02                                         ` Dmitry Gutov
2017-09-19 20:47                                           ` Alan Mackenzie
2017-09-22 14:09                                             ` Dmitry Gutov
2017-09-24 11:26                                               ` Alan Mackenzie
2017-09-25 23:53                                                 ` Dmitry Gutov
2017-10-01 16:36                                                   ` Alan Mackenzie
2017-10-04 20:07                                                 ` Johan Bockgård
2017-09-17 11:12                             ` Philipp Stephani
2017-09-19 20:50                               ` Alan Mackenzie
2017-09-07 17:56                     ` Alan Mackenzie
2017-09-07 20:36                       ` Dmitry Gutov
2016-03-19 23:16     ` Vitalie Spinu
2016-03-19 23:00   ` Vitalie Spinu
2016-03-19 23:20     ` Dmitry Gutov
     [not found] ` <mailman.7307.1457709188.843.bug-gnu-emacs@gnu.org>
2017-10-01 16:31   ` Alan Mackenzie

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=20170909102027.GB5194@ACM \
    --to=acm@muc.de \
    --cc=22983@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=jwiegley@gmail.com \
    --cc=p.stephani2@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).