From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#22983: syntax-ppss returns wrong result. Date: Sun, 13 Mar 2016 21:49:30 -0400 Message-ID: References: <20160311151512.GD2888@acm.fritz.box> <20160311212410.GG2888@acm.fritz.box> <73903215-f94b-e194-7bfe-0d6350c95769@yandex.ru> <20160311221540.GH2888@acm.fritz.box> <2c301ec9-041d-9172-d628-479062314b23@yandex.ru> <20160313185755.GG1871@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1457920224 24389 80.91.229.3 (14 Mar 2016 01:50:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Mar 2016 01:50:24 +0000 (UTC) Cc: 22983@debbugs.gnu.org, Dmitry Gutov To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 14 02:50:13 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 1afHe7-0002Mo-QT for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Mar 2016 02:50:11 +0100 Original-Received: from localhost ([::1]:38546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afHe7-0003Zj-3h for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Mar 2016 21:50:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afHe2-0003XP-P4 for bug-gnu-emacs@gnu.org; Sun, 13 Mar 2016 21:50:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afHdy-0002t0-Oc for bug-gnu-emacs@gnu.org; Sun, 13 Mar 2016 21:50:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afHdy-0002st-Kb for bug-gnu-emacs@gnu.org; Sun, 13 Mar 2016 21:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1afHdy-00047k-Cr for bug-gnu-emacs@gnu.org; Sun, 13 Mar 2016 21:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Mar 2016 01:50: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.145792017515814 (code B ref 22983); Mon, 14 Mar 2016 01:50:02 +0000 Original-Received: (at 22983) by debbugs.gnu.org; 14 Mar 2016 01:49:35 +0000 Original-Received: from localhost ([127.0.0.1]:47269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1afHdW-000470-SS for submit@debbugs.gnu.org; Sun, 13 Mar 2016 21:49:35 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:38189) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1afHdU-00046s-Qi for 22983@debbugs.gnu.org; Sun, 13 Mar 2016 21:49:33 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id u2E1ntpC031503; Sun, 13 Mar 2016 21:49:56 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id C94B366162; Sun, 13 Mar 2016 21:49:30 -0400 (EDT) In-Reply-To: <20160313185755.GG1871@acm.fritz.box> (Alan Mackenzie's message of "Sun, 13 Mar 2016 18:57:55 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5609=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5609> : inlines <4491> : streams <1602534> : uri <2165323> 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:114875 Archived-At: > That's pure sophistry. The semantics needed are quite clear: For your use case, yes. It's quite clear *in your mind*. There are other use cases. Worse yet: Elisp doesn't generally know if the narrowing was setup by the user or by some Elisp caller up the stack. So even if we were to pretend that the use-case is clear when the narrowing is set by the user, we'd still have to figure out if that's the case. > Lets define them as I said in the previous paragraph. Or can you > conceive of a use case where one would want narrowing to invert strings > and non-strings, leaving comments totally random? There's the case where some Elisp code does (save-restriction (narrow-to-region beg end (with-syntax-table ...))) to parse a sub-part of your buffer in a different way. Of course this completely breaks syntax-ppss and friends. I need to do exactly that in sm-c-mode (when parsing the C code inside CPP directives, since those directives are marked as comments), for example and had to use (let ((syntax-propertize-function nil) (syntax-ppss-cache nil) (syntax-ppss-last nil)) ...) to deal with it. It would be easy/natural to add a binding of syntax-ppss-dont-widen in there (and/or literal-cache-dont-widen for that matter). > Do you have any views on how the bug should be resolved? Look up some past discussions of how to number lines in a narrowed buffer (same basic issue), where we discussed this. We basically need to add information about which kind of narrowing is in effect. IIRC one way suggested was to have 2 narrowing states at the same time: the current one, plus a new one which is a kind of "hard narrowing" (the current narrowing would have to be "narrower" than the "hard narrowing"), with corresponding new kind of "widen". Stefan