From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lele Gaifax Newsgroups: gmane.emacs.bugs Subject: bug#29305: 26.0.90; Wrong electrified indentation with Python multiline string Date: Tue, 21 Nov 2017 10:15:12 +0100 Message-ID: <87d14cuh5r.fsf@metapensiero.it> References: <878tf7x4wc.fsf@metapensiero.it> <878tf21gyl.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1511255782 9614 195.159.176.226 (21 Nov 2017 09:16:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 21 Nov 2017 09:16:22 +0000 (UTC) Cc: 29305@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 21 10:16:13 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 1eH4f1-0001aq-Gx for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Nov 2017 10:16:07 +0100 Original-Received: from localhost ([::1]:33248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH4f5-0007d0-IL for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Nov 2017 04:16:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eH4ez-0007cv-8c for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2017 04:16:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eH4ew-00057b-2x for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2017 04:16:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41199) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eH4ev-00057N-VS for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2017 04:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eH4ev-0000WA-N6 for bug-gnu-emacs@gnu.org; Tue, 21 Nov 2017 04:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lele Gaifax Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Nov 2017 09:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29305 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 29305-submit@debbugs.gnu.org id=B29305.15112557241947 (code B ref 29305); Tue, 21 Nov 2017 09:16:01 +0000 Original-Received: (at 29305) by debbugs.gnu.org; 21 Nov 2017 09:15:24 +0000 Original-Received: from localhost ([127.0.0.1]:49880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eH4eK-0000VK-6t for submit@debbugs.gnu.org; Tue, 21 Nov 2017 04:15:24 -0500 Original-Received: from mail.arstecnica.it ([144.76.81.238]:59582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eH4eH-0000V8-Md for 29305@debbugs.gnu.org; Tue, 21 Nov 2017 04:15:22 -0500 Original-Received: from nautilus (assp.arstecnica.it [192.168.1.102]) by mail.arstecnica.it (Postfix) with ESMTPSA id 6676483F0C2; Tue, 21 Nov 2017 09:15:13 +0000 (UTC) Original-Received: from nautilus ([31.44.165.109] helo=nautilus) by assp.arstecnica.it with SMTPS(AES256-GCM-SHA384) (2.3.3); 21 Nov 2017 09:15:12 +0000 In-Reply-To: <878tf21gyl.fsf@users.sourceforge.net> X-Assp-Version: 2.3.3(14029) on assp.arstecnica.it X-Assp-ID: assp.arstecnica.it m1-55713-04241 X-Assp-Session: B0F1C30C (mail 1) X-Assp-Envelope-From: lele@metapensiero.it X-Assp-Intended-For: 29305@debbugs.gnu.org X-Assp-Intended-For: npostavs@users.sourceforge.net X-Assp-Client-TLS: yes X-Assp-Server-TLS: yes 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:140189 Archived-At: Thanks Noam, I tried your suggestion and it seems doing the right thing, I will keep exercising this for a while. > @@ -1257,7 +1257,9 @@ python-indent-post-self-insert-function > If a line renders a paren alone, after adding a char before it, > the line will be re-indented automatically if needed." > (when (and electric-indent-mode > - (eq (char-before) last-command-event)) > + (eq (char-before) last-command-event) > + (not (python-syntax-context 'string)) > + (not (eq (car (python-indent-context)) :inside-string))) > (cond > ;; Electric indent inside parens > ((and I wish to better understand *why* it works though: in particular, I fail to see how it can handle the situation illustrated by my second test case (python-indent-electric-comma-after-multiline-string): a =3D ( '''\ - foo, - bar''' where I'm going to add a comma *after* the multiline string: when I tried to find a solution, I thought I'd need to consider the state *at (beginning-of-line)*, in other words, morphing my experiment on top of your change to something like: (when (and electric-indent-mode (eq (char-before) last-command-event) (not (python-syntax-context 'string)) (save-excursion (beginning-of-line) (not (eq (car (python-indent-context)) :inside-string)))) but your simpler code tells that it is not needed... I will try harder ;-) ciao, lele. --=20 nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.