GNU bug report logs - #29305
26.0.90; Wrong electrified indentation with Python multiline string

Previous Next

Package: emacs;

Reported by: Lele Gaifax <lele <at> metapensiero.it>

Date: Wed, 15 Nov 2017 09:35:02 UTC

Severity: minor

Tags: fixed, patch

Found in version 26.0.90

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lele Gaifax <lele <at> metapensiero.it>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 29305 <at> debbugs.gnu.org
Subject: bug#29305: 26.0.90; Wrong electrified indentation with Python multiline string
Date: Tue, 21 Nov 2017 10:15:12 +0100
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 = (
        '''\
    - 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.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele <at> metapensiero.it  |                 -- Fortunato Depero, 1929.




This bug report was last modified 7 years and 268 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.