From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#56135: 29.0.50; python.el - forward-sexp regression over triple-quoted strings Date: Thu, 23 Jun 2022 08:49:31 +0200 Message-ID: <87fsjv27t0.fsf@gmail.com> References: <875yktgpiz.fsf@gmail.com> <877d58juup.fsf@gmail.com> <87y1xotlna.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4322"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 56135@debbugs.gnu.org, Stefan Monnier To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 23 08:50:52 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4Gfz-0000wh-Ho for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jun 2022 08:50:51 +0200 Original-Received: from localhost ([::1]:51204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4Gfy-0005NX-3k for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jun 2022 02:50:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4GfC-0005MH-U6 for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2022 02:50:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4GfC-0005eG-Ks for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2022 02:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o4GfC-0004Vc-FV for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2022 02:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jun 2022 06:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56135 X-GNU-PR-Package: emacs Original-Received: via spool by 56135-submit@debbugs.gnu.org id=B56135.165596698117287 (code B ref 56135); Thu, 23 Jun 2022 06:50:02 +0000 Original-Received: (at 56135) by debbugs.gnu.org; 23 Jun 2022 06:49:41 +0000 Original-Received: from localhost ([127.0.0.1]:37069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4Ger-0004Uj-8T for submit@debbugs.gnu.org; Thu, 23 Jun 2022 02:49:41 -0400 Original-Received: from mail-wr1-f51.google.com ([209.85.221.51]:40467) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4Geo-0004UT-PQ for 56135@debbugs.gnu.org; Thu, 23 Jun 2022 02:49:40 -0400 Original-Received: by mail-wr1-f51.google.com with SMTP id w17so26477217wrg.7 for <56135@debbugs.gnu.org>; Wed, 22 Jun 2022 23:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=4u4djkCGrvtt7yXVNhyULhDMUgI4N66Qv1OF6av6L0s=; b=h4FrVk18d0SE1RdUo9XjR9mjqFQJ2DT/5dqS+hAbh9yhl1v9i2mPUcJqQbNCyOx90Y C10qQDJpmVOwqPtv5KGcQNz44iOlkhxV48o+xewE3qc74EC2ZAl1kADOoRuNUsckWFS6 ut9bT9kb8vThfUe1fTw/JnwGyFWKE62OjKpLkHn5sVWFQ/v668rdXTOBT0Zy19hhwnyM PBlez1BpY8f1EBoMQycTwE91FCm7XHd0LcuYLlU9jLqpJ/cnKe8aTXIocu3dyHLAe0Al WXrYBxHvbJEACYS6M47Tvq29DTLS20YqZQcd4F/8dtIGYxFDtDJjF3wWbcY3WCd4QJBB VGeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=4u4djkCGrvtt7yXVNhyULhDMUgI4N66Qv1OF6av6L0s=; b=gIazW2Djjwt82Ihtx8VFCW6zCQo+jhu4aWNlAdnPxaL9RpCTUZdDsrFr27BNigLk2H agAkxE+IyrvWOpb+EKKrhOnsRK75WSntTHWIQQLv26h4trs93PYKyiacYddJuVTCUQiG iBHg05rt8VpYSs9IyR0asEahMSo8zId6Uwy2xnh9lWkVW2GbSrHC8oY7kGg7WQ1xbyTg J1fd1XQmJXa4rvvoxyWVqBKzz6kErNv1uaur37l5nxK77U7UmPeS6j6I5XucsCO0XpYb cHnC4+wqDGmtfQO1t+t5OBPH8z+t7Ipwws/12DilJZMXjCW69Gic9OEAl3lzKejb/l+n w2AA== X-Gm-Message-State: AJIora9FKipHhj/8J5cb1I6sYPPxwjN9DDNln76UTsqY5ntAjsNeY/GK +ShfTf3qPzWul4ua0hDEsC0= X-Google-Smtp-Source: AGRyM1sGolw77AdKscD4oCVFZAfgBiWNgxfImlVDppS80nqoUDli2i3p+1Se6Ly6rMNvKq21F3G7dQ== X-Received: by 2002:a5d:4e47:0:b0:21a:39fd:5bb5 with SMTP id r7-20020a5d4e47000000b0021a39fd5bb5mr6608301wrt.712.1655966972677; Wed, 22 Jun 2022 23:49:32 -0700 (PDT) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c511300b0039c7dbafa7asm1970022wms.19.2022.06.22.23.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jun 2022 23:49:32 -0700 (PDT) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Wed, 22 Jun 2022 23:19:40 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235065 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > On Wed, Jun 22, 2022 at 10:48 PM K=C3=A9vin Le Gouguec wrote: > > K=C3=A9vin Le Gouguec writes: > > > Jo=C3=A3o T=C3=A1vora writes: > > > >> Why are you setting python-forward-sexp-function to nil? > > > > [wall of text follows] > > ( > Hadn't realized we had taken this off-list. FWIW if you found all > my verbiage informative, don't hesitate to (tell me to) forward it > back on the bug tracker. > ) > > Ups. That was my mistake. Wondering what to do now. Should we re-send = to the=20 > tracker. Or let future generations wonder about the missing great wall o= f text. =F0=9F=98=81 I'll forward it in a separate message, in case someone finds o= ther points to bounce off of. > Anyway, I did find your wall of text informative, particularly this point. > >> Wondering what the best way forward would be. Maybe a third suggested >> value for python-forward-sexp-function, which would handle triple-quotes >> but not add those "implicit paired delimiters"? > > Yes, I think this makes sense. Let's see what other think, but a patch > that extracts only that bit from the current functionality and puts it in= =20 > a third value would be a good idea, I think. Mm. I've stepped through python-nav--forward-sexp with Edebug, and there wasn't any obvious "triple-quote handler" to extract. IIUC * being on either end of a triple-quote block satisfies python-info-{beginning,end}-of-statement-p, so 'context' becomes 'statement-{start,end}, * (then we dance a little gigue to compute next-sexp-{context,pos}, which we do not end up using in this scenario,) * eventually we call python-nav-{end,beginning}-of-statement. So the "magic" happens in those functions IIUC. E.g. in python-nav-end-of-statement we either=20 * skip the whole cond form because the initial (goto-char (line-end-position)) took us at EOL after a single-line string, or=E2=80= =A6 * go down the (setq string-start (python-syntax-context 'string)) path for multiline strings, or=E2=80=A6 * =E2=80=A6 oh! Mm, well, here's a bug maybe? Consider: """string 1""" def foo(): """string 2 (multiline). """ print("""string 3""") ^ So *with python-forward-sexp-function set to its default value* (python-nav-forward-sexp), with point on the ^ mark (at the beginning of """string 3"""), * before commit 0646c68, C-M-f moved to the end of """string 3""", * now it just moves over one pair of quotes. (Feel like I should note that single-line triple-quoted strings have their uses FWIW, since they let one write single and double quotes into the string without the need to backslash-escape them) I see that the new commentary in python-syntax-stringify addresses this, I guess? > ;; FIXME: This makes sexp-movement a bit suboptimal since """a"= "" > ;; is now treated as 3 strings. So AFAICT while the change meant to improve the situation with electric-pair-mode (which I'm grateful for, since I'm a happy user of that minor mode), it did make sexp-movement a bit more "janky" (meaning "hard to predict and rely on", no offense meant), *regardless* of whether users (un)set (python-)forward-sexp-function =F0=9F=98=95