aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2014-07-01 00:54:11 -0300
committerFabián Ezequiel Gallina2014-07-01 00:54:11 -0300
commit3acd6262d993cb445a3656808ce544cf68754f89 (patch)
tree0a7216ec13d284e4976944b34cd0cad0ab257085 /lisp
parent64c11219d16ae5f971d51f1fb19405b0e24f9269 (diff)
downloademacs-3acd6262d993cb445a3656808ce544cf68754f89.tar.gz
emacs-3acd6262d993cb445a3656808ce544cf68754f89.zip
* lisp/progmodes/python.el (python-indent-post-self-insert-function):
Enhancements to electric indentation behavior inside parens. * test/automated/python-tests.el (python-tests-self-insert): New function. (python-triple-quote-pairing): Use it. (python-util-forward-comment-1): New test. (Bug#17658)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/python.el28
2 files changed, 26 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c01480ef857..4d186b585dd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12014-07-01 Fabián Ezequiel Gallina <fgallina@gnu.org>
2
3 * progmodes/python.el (python-indent-post-self-insert-function):
4 Enhancements to electric indentation behavior inside
5 parens. (Bug#17658)
6
12014-07-01 Stefan Monnier <monnier@iro.umontreal.ca> 72014-07-01 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * ps-def.el (ps-generate-postscript-with-faces1): Don't mess with 9 * ps-def.el (ps-generate-postscript-with-faces1): Don't mess with
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f99a580b376..2301db8ecf6 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1097,16 +1097,28 @@ the line will be re-indented automatically if needed."
1097 (when (and electric-indent-mode 1097 (when (and electric-indent-mode
1098 (eq (char-before) last-command-event)) 1098 (eq (char-before) last-command-event))
1099 (cond 1099 (cond
1100 ((and (not (bolp)) 1100 ;; Electric indent inside parens
1101 (memq (char-after) '(?\) ?\] ?\}))) 1101 ((and
1102 (not (bolp))
1103 (let ((paren-start (python-syntax-context 'paren)))
1104 ;; Check that point is inside parens.
1105 (when paren-start
1106 (not
1107 ;; Filter the case where input is happening in the same
1108 ;; line where the open paren is.
1109 (= (line-number-at-pos)
1110 (line-number-at-pos paren-start)))))
1111 ;; When content has been added before the closing paren or a
1112 ;; comma has been inserted, it's ok to do the trick.
1113 (or
1114 (memq (char-after) '(?\) ?\] ?\}))
1115 (eq (char-before) ?,)))
1102 (save-excursion 1116 (save-excursion
1103 (goto-char (line-beginning-position)) 1117 (goto-char (line-beginning-position))
1104 ;; If after going to the beginning of line the point 1118 (let ((indentation (python-indent-calculate-indentation)))
1105 ;; is still inside a paren it's ok to do the trick 1119 (when (< (current-indentation) indentation)
1106 (when (python-syntax-context 'paren) 1120 (indent-line-to indentation)))))
1107 (let ((indentation (python-indent-calculate-indentation))) 1121 ;; Electric colon
1108 (when (< (current-indentation) indentation)
1109 (indent-line-to indentation))))))
1110 ((and (eq ?: last-command-event) 1122 ((and (eq ?: last-command-event)
1111 (memq ?: electric-indent-chars) 1123 (memq ?: electric-indent-chars)
1112 (not current-prefix-arg) 1124 (not current-prefix-arg)