From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vitalie Spinu Newsgroups: gmane.emacs.bugs Subject: bug#22983: syntax-ppss returns wrong result. Date: Sun, 20 Mar 2016 00:00:45 +0100 Message-ID: <87zitucbtu.fsf@gmail.com> References: <20160311151512.GD2888@acm.fritz.box> <44b4fa9e-ec8e-98a4-d8ad-e799fffa7959@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1458428480 6436 80.91.229.3 (19 Mar 2016 23:01:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2016 23:01:20 +0000 (UTC) Cc: Alan Mackenzie , 22983@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 20 00:01:10 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ahPrp-0004fg-MX for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Mar 2016 00:01:09 +0100 Original-Received: from localhost ([::1]:50811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahPro-0006Xn-Th for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Mar 2016 19:01:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahPrl-0006XT-Bj for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 19:01:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahPri-0007gR-5Z for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 19:01:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahPri-0007gN-1w for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 19:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ahPrh-0006XB-RY for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 19:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vitalie Spinu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Mar 2016 23:01: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.145842845325096 (code B ref 22983); Sat, 19 Mar 2016 23:01:01 +0000 Original-Received: (at 22983) by debbugs.gnu.org; 19 Mar 2016 23:00:53 +0000 Original-Received: from localhost ([127.0.0.1]:54000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahPrZ-0006Wi-9j for submit@debbugs.gnu.org; Sat, 19 Mar 2016 19:00:53 -0400 Original-Received: from mail-wm0-f49.google.com ([74.125.82.49]:33496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahPrY-0006WW-JX for 22983@debbugs.gnu.org; Sat, 19 Mar 2016 19:00:52 -0400 Original-Received: by mail-wm0-f49.google.com with SMTP id l68so111202271wml.0 for <22983@debbugs.gnu.org>; Sat, 19 Mar 2016 16:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=tyr18GbRLwJ/y1a8oyKCd4fFZq/2AFN2LXLRa19nXdc=; b=zz2mxEcgNEP5DmJ672ktnqdkPm43yheq2ehLqfhWbHG7fuxgKdD2UFft+jN5cVFC9o sSUlGwuK+GismsnCy+AYRcsYe9aILD6natRJSUe16/NtZfFGQIdlvqG6jZpYCApIWy6v FvSh9F6nISruyJTAa2JHlmoI3N48UArR6LWqJ6z+4DKofNcCeuzl6fnJwbS6ELhFzhfA ln5XwjarkM7mTp7+3WFutbfKa+1eWAhXSUYK6GH/evBmJFtR5hqXoMnuN+j37sQ9vuEC CxEC0j5fVvw1WKDCoOqEPkj4Z6RVamEl1BbpwlJZZL5GArBOzmEnF3S5OYjLpas0mLYn dNdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=tyr18GbRLwJ/y1a8oyKCd4fFZq/2AFN2LXLRa19nXdc=; b=TzJH8UqZuznOV7ovkQpUS/dGy5Ua6RcO7e59PNb0x97kSuuZ8UjefDmYSKv1DplZAW e6qTIjbyZjhvI/jS1x7IN/s1YazCjUo/psnNyuXzC4rRTNpncwx86cLkKauWPImx/q/A JnhJ+XiB3FUu0VEoPq1bGJE9QG1Gf8g/Rqce5XwsCOIutg+AFnGqgseVxf931+FOKXA6 Wo8HsGxBsu4f/+UU/zhRXij2zFvcqgZCoyIIsU/28uzGv4tkRCpLCkm3PHXaEno+UFg2 6iqBzYqjYC2qOFbIsQ2NMiH2YpsQlSpXZ8Dyt8LiJzlnTHSeQfjexAGDLIXIGD5fHuvW tJFw== X-Gm-Message-State: AD7BkJKAmopf0aW0l7erc7y2JKW93XbIQwXINY7tlZpKJwkZSzeRS6JePGjNRo1q3qQ8cQ== X-Received: by 10.28.97.10 with SMTP id v10mr1344707wmb.62.1458428446820; Sat, 19 Mar 2016 16:00:46 -0700 (PDT) Original-Received: from localhost ([143.176.214.220]) by smtp.gmail.com with ESMTPSA id ka4sm18320239wjc.47.2016.03.19.16.00.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Mar 2016 16:00:45 -0700 (PDT) In-Reply-To: <44b4fa9e-ec8e-98a4-d8ad-e799fffa7959@yandex.ru> (Dmitry Gutov's message of "Fri, 18 Mar 2016 02:49:34 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.91 (gnu/linux) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115105 Archived-At: Thanks for this. This is a step in right direction IMHO. One side note. `parsep-ppss` has a condition-case for args-out-of-range which could be easily optimized out. You already know that you are calling parse-partial-sexp with out of range arguments if narrowing is in place. The current error check obfuscates the logic and makes debugging harder. Would it be possible for you to have a look once you are on it? Not a big deal though. Thanks, Vitalie >> On Fri, Mar 18 2016 02:49, Dmitry Gutov wrote: > On 03/11/2016 05:15 PM, Alan Mackenzie wrote: > This patch should make ppss-0 and ppss-1 match: > diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el > index e20a210..c1b9d84 100644 > --- a/lisp/emacs-lisp/syntax.el > +++ b/lisp/emacs-lisp/syntax.el > @@ -371,6 +371,11 @@ syntax-ppss-max-span > We try to make sure that cache entries are at least this far apart > from each other, to avoid keeping too much useless info.") > +(defvar syntax-ppss-dont-widen nil > + "If non-nil, `syntax-ppss' will work on the non-widened buffer. > +The code that uses this should create local bindings for > +`syntax-ppss-cache' and `syntax-ppss-last' too.") > + > (defvar syntax-begin-function nil > "Function to move back outside of any comment/string/paren. > This function should move the cursor back to some syntactically safe > @@ -423,12 +428,21 @@ syntax-ppss > in the returned list (counting from 0) cannot be relied upon. > Point is at POS when this function returns. > +IF `syntax-ppss-dont-widen' is nil, the buffer is temporarily > +widened. > + > It is necessary to call `syntax-ppss-flush-cache' explicitly if > this function is called while `before-change-functions' is > temporarily let-bound, or if the buffer is modified without > running the hook." > ;; Default values. > (unless pos (setq pos (point))) > + (save-restriction > + (unless syntax-ppss-dont-widen > + (widen)) > + (syntax-pps--at pos))) > + > +(defun syntax-ppss--at (pos) > (syntax-propertize pos) > ;; > (let ((old-ppss (cdr syntax-ppss-last))