]> git.eshelyaron.com Git - emacs.git/commitdiff
Disable electric indent for python strings (Bug#29305)
authorNoam Postavsky <npostavs@gmail.com>
Sun, 19 Nov 2017 14:00:43 +0000 (09:00 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Sat, 2 Dec 2017 14:35:40 +0000 (09:35 -0500)
* lisp/progmodes/python.el (python-indent-post-self-insert-function):
Do nothing when point or beginning of line is in string.

lisp/progmodes/python.el

index d4226e5ce7b8da2a4fd863306a8734883c2b61df..9e09bfc5941e32a5b9dd71933293d4e9535f8eef 100644 (file)
@@ -1257,7 +1257,11 @@ This function is intended to be added to `post-self-insert-hook.'
 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))
+             (save-excursion
+               (beginning-of-line)
+               (not (python-syntax-context 'string (syntax-ppss)))))
     (cond
      ;; Electric indent inside parens
      ((and