From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#22983: syntax-ppss returns wrong result. Date: Sat, 9 Sep 2017 10:20:27 +0000 Message-ID: <20170909102027.GB5194@ACM> References: <9fc66395-045c-1984-f530-033c2ff706f6@yandex.ru> <83h8wlz1kf.fsf@gnu.org> <20170902174027.GB4267@ACM> <20170907204502.GC4488@ACM> <69e034d3-7a52-cc81-dc56-e5308ad5dce0@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1504952781 16790 195.159.176.226 (9 Sep 2017 10:26:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 9 Sep 2017 10:26:21 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: John Wiegley , Philipp Stephani , 22983@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 09 12:26:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqcxj-0003a4-9Y for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Sep 2017 12:26:07 +0200 Original-Received: from localhost ([::1]:48906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqcxo-0007YR-Qb for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Sep 2017 06:26:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqcxh-0007Y8-Ru for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 06:26:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqcxe-0002n8-Ms for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 06:26:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqcxe-0002mz-I8 for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 06:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dqcxe-0007Xx-4k for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 06:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Sep 2017 10:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22983 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22983-submit@debbugs.gnu.org id=B22983.150495272928970 (code B ref 22983); Sat, 09 Sep 2017 10:26:02 +0000 Original-Received: (at 22983) by debbugs.gnu.org; 9 Sep 2017 10:25:29 +0000 Original-Received: from localhost ([127.0.0.1]:56889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqcx6-0007XB-Ty for submit@debbugs.gnu.org; Sat, 09 Sep 2017 06:25:29 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:33101 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1dqcx4-0007X2-RD for 22983@debbugs.gnu.org; Sat, 09 Sep 2017 06:25:27 -0400 Original-Received: (qmail 1650 invoked by uid 3782); 9 Sep 2017 10:25:21 -0000 Original-Received: from acm.muc.de (p548C7C7C.dip0.t-ipconnect.de [84.140.124.124]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 09 Sep 2017 12:25:20 +0200 Original-Received: (qmail 6670 invoked by uid 1000); 9 Sep 2017 10:20:27 -0000 Content-Disposition: inline In-Reply-To: <69e034d3-7a52-cc81-dc56-e5308ad5dce0@yandex.ru> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136701 Archived-At: 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).