From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Lele Gaifax <lele@metapensiero.it>
Cc: 29305@debbugs.gnu.org
Subject: bug#29305: 26.0.90; Wrong electrified indentation with Python multiline string
Date: Sun, 19 Nov 2017 09:27:46 -0500 [thread overview]
Message-ID: <878tf21gyl.fsf@users.sourceforge.net> (raw)
In-Reply-To: <878tf7x4wc.fsf@metapensiero.it> (Lele Gaifax's message of "Wed, 15 Nov 2017 10:33:39 +0100")
[-- Attachment #1: Type: text/plain, Size: 419 bytes --]
severity 29305 minor
tags 29305 + patch
quit
Lele Gaifax <lele@metapensiero.it> writes:
> In python-mode, when I'm inside a triple-quoted string or immediately after
> it and insert (say) a comma, current line indentation should not change.
>
> I tried to play with python-indent-post-self-insert-function, but could not
> figure out how to recognize when I'm within or close to a multiline string.
How about this:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1116 bytes --]
From d48c6f6d25911b2d128c72eec9ff5b3f457a3545 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 19 Nov 2017 09:00:43 -0500
Subject: [PATCH] Disable eletric indent for python strings (Bug#29305)
* lisp/progmodes/python.el (python-indent-post-self-insert-function):
Do nothing when in string syntax or indent context.
---
lisp/progmodes/python.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d4226e5ce7..093dd0ae65 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -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
--
2.11.0
next prev parent reply other threads:[~2017-11-19 14:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 9:33 bug#29305: 26.0.90; Wrong electrified indentation with Python multiline string Lele Gaifax
2017-11-19 14:27 ` Noam Postavsky [this message]
2017-11-21 9:15 ` Lele Gaifax
2017-11-21 13:52 ` Noam Postavsky
2017-11-21 14:22 ` Lele Gaifax
2017-12-02 14:54 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878tf21gyl.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=29305@debbugs.gnu.org \
--cc=lele@metapensiero.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.