[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#29305: 26.0.90; Wrong electrified indentation with Python multiline
From: |
Lele Gaifax |
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@metapensiero.it | -- Fortunato Depero, 1929.