From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#22983: syntax-ppss returns wrong result. Date: Sat, 9 Sep 2017 12:44:02 +0300 Message-ID: <69e034d3-7a52-cc81-dc56-e5308ad5dce0@yandex.ru> References: <20160319122759.GA2644@acm.fritz.box> <9f36a39b-ea9f-2f61-5400-68de18526ab1@yandex.ru> <9fc66395-045c-1984-f530-033c2ff706f6@yandex.ru> <83h8wlz1kf.fsf@gnu.org> <20170902174027.GB4267@ACM> <20170907204502.GC4488@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1504950317 18642 195.159.176.226 (9 Sep 2017 09:45:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 9 Sep 2017 09:45:17 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Thunderbird/56.0 Cc: 22983@debbugs.gnu.org, Philipp Stephani To: Alan Mackenzie , John Wiegley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 09 11:45:08 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 1dqcJz-0004B7-Ci for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Sep 2017 11:45:04 +0200 Original-Received: from localhost ([::1]:48827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqcK6-0007bk-Lu for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Sep 2017 05:45:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqcK1-0007bO-Kn for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 05:45:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqcJy-0006hD-HG for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 05:45:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqcJy-0006h4-CH for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 05:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dqcJx-0006W3-UU for bug-gnu-emacs@gnu.org; Sat, 09 Sep 2017 05:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Sep 2017 09:45:01 +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.150495025924986 (code B ref 22983); Sat, 09 Sep 2017 09:45:01 +0000 Original-Received: (at 22983) by debbugs.gnu.org; 9 Sep 2017 09:44:19 +0000 Original-Received: from localhost ([127.0.0.1]:56864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqcJH-0006Uv-Gc for submit@debbugs.gnu.org; Sat, 09 Sep 2017 05:44:19 -0400 Original-Received: from mail-lf0-f47.google.com ([209.85.215.47]:38356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqcJF-0006Uj-HY for 22983@debbugs.gnu.org; Sat, 09 Sep 2017 05:44:18 -0400 Original-Received: by mail-lf0-f47.google.com with SMTP id q132so9773043lfe.5 for <22983@debbugs.gnu.org>; Sat, 09 Sep 2017 02:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=arN5LHxeH7xz0J03mqmrQxhwkZU7cPZaExLMa3gfX/8=; b=vhuIOP62kgMnTf2rVULRmm5G0lYGm5hnHDL7mi9IDQZRP8KccZKwqoUZR+YmwOmyXR kMGuv7yOVwQ/NLgWPyTP7+9Gw5M5JaYUlM0R4MYmclSM6VQgRqZZhdvHvoyu5LGCImG9 a00Wq3x68NWhza0VVEOw0NWewWEWKglqp1mvCJo1NkwbFhUGHOr3BYk6NdYXNKktsE+6 2SDOaXeDUlATur3ON1h499kkrXQHXBLRqucN9ufgY7fgMPH7ge8++lfVTgX3BjZKaRCB YBPDp46bYyCrbCkiqvJp6mdTRtLYxUXlmbFo9WoE+hoFJlGswJRCOc/6ZnK63locnYVA YmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=arN5LHxeH7xz0J03mqmrQxhwkZU7cPZaExLMa3gfX/8=; b=uButH6rKTkTe4baEfsUMidCfKfD0NtTTDxhcwaOZ7GWxazdJmlCyeQJfJ5QsYqMmO/ 6t5llM7dGAkDmLSIu52Zin2hkfEf0Ma2ld3gRC/llVC31InwuriSwYVs43R9PITfcsvX cgng1HmOcVruM0B03Yxp+QbQ/Ww4bDSe8He0jtW7aclnvFRXvzB+sf+hCPxYfBB0occS P7AzgpUzYcDl4+XKu08w+sw+lfcVvSjZGugbF9IsVTEmPCT90TuXJK59qZa8e6P8ou/y SRVeB6clOdtCKay2IaXwRF9ZlASF75ViQEwglQ8yv+xuJRUBTA4JJEvrD1eihwebttDw oWCg== X-Gm-Message-State: AHPjjUjmOBLyUD2pSloYkYrleUYFgJ73qlQlFQWZzJqtuDkm5+ol/zl7 PjN2nWEmfbuoFw== X-Google-Smtp-Source: AOwi7QDGduZTyxQIF0/uGjTNtrture/xv8RO2pTgkJSU3ESQJluRJZSPhkE7HCPQsjqVf7ezqC3AZQ== X-Received: by 10.46.25.198 with SMTP id 67mr2405225ljz.67.1504950251284; Sat, 09 Sep 2017 02:44:11 -0700 (PDT) Original-Received: from [192.168.1.174] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id 26sm649295lfx.50.2017.09.09.02.44.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Sep 2017 02:44:09 -0700 (PDT) In-Reply-To: <20170907204502.GC4488@ACM> Content-Language: en-US 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:136699 Archived-At: 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. > 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. > 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. I do want to know what Stefan thinks of this subject now, though. 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. - 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. All the best, Dmitry.