diff options
| author | Fabián Ezequiel Gallina | 2014-09-01 19:51:46 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2014-09-01 19:51:46 -0300 |
| commit | 0e4c8f1856c46900f9530977e5ac9f83ca13bbfd (patch) | |
| tree | 529ec7bc3cad3c868e1662d3e8ff6e83c29323ce | |
| parent | ad5c82a8cc3f78172dc872c7fe3c6e774f50fe15 (diff) | |
| download | emacs-0e4c8f1856c46900f9530977e5ac9f83ca13bbfd.tar.gz emacs-0e4c8f1856c46900f9530977e5ac9f83ca13bbfd.zip | |
* lisp/progmodes/python.el (python-indent-post-self-insert-function):
Avoid electric colon at beginning-of-defun.
* test/automated/python-tests.el:
(python-indent-electric-colon-1): New test. (Bug#18228)
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 8 | ||||
| -rw-r--r-- | test/ChangeLog | 5 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 14 |
4 files changed, 31 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 939553608ba..70e5ade2eee 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-09-01 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/python.el (python-indent-post-self-insert-function): | ||
| 4 | Avoid electric colon at beginning-of-defun. (Bug#18228) | ||
| 5 | |||
| 1 | 2014-09-01 Glenn Morris <rgm@gnu.org> | 6 | 2014-09-01 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * tutorial.el (tutorial--display-changes): | 8 | * tutorial.el (tutorial--display-changes): |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a51cff8529e..740dfee5870 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1155,9 +1155,15 @@ the line will be re-indented automatically if needed." | |||
| 1155 | ((and (eq ?: last-command-event) | 1155 | ((and (eq ?: last-command-event) |
| 1156 | (memq ?: electric-indent-chars) | 1156 | (memq ?: electric-indent-chars) |
| 1157 | (not current-prefix-arg) | 1157 | (not current-prefix-arg) |
| 1158 | ;; Trigger electric colon only at end of line | ||
| 1158 | (eolp) | 1159 | (eolp) |
| 1160 | ;; Avoid re-indenting on extra colon | ||
| 1159 | (not (equal ?: (char-before (1- (point))))) | 1161 | (not (equal ?: (char-before (1- (point))))) |
| 1160 | (not (python-syntax-comment-or-string-p))) | 1162 | (not (python-syntax-comment-or-string-p)) |
| 1163 | ;; Never re-indent at beginning of defun | ||
| 1164 | (not (save-excursion | ||
| 1165 | (python-nav-beginning-of-statement) | ||
| 1166 | (python-info-looking-at-beginning-of-defun)))) | ||
| 1161 | (python-indent-line))))) | 1167 | (python-indent-line))))) |
| 1162 | 1168 | ||
| 1163 | 1169 | ||
diff --git a/test/ChangeLog b/test/ChangeLog index 90b30a4dd66..dcab604dbb1 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-09-01 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 2 | |||
| 3 | * automated/python-tests.el: | ||
| 4 | (python-indent-electric-colon-1): New test. (Bug#18228) | ||
| 5 | |||
| 1 | 2014-08-18 Glenn Morris <rgm@gnu.org> | 6 | 2014-08-18 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * automated/python-tests.el (python-shell-calculate-exec-path-2): | 8 | * automated/python-tests.el (python-shell-calculate-exec-path-2): |
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 47dfa4b64ed..39195fd7086 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -711,6 +711,20 @@ if a: | |||
| 711 | (should (= (python-indent-calculate-indentation) 0)) | 711 | (should (= (python-indent-calculate-indentation) 0)) |
| 712 | (should (equal (python-indent-calculate-levels) '(0))))) | 712 | (should (equal (python-indent-calculate-levels) '(0))))) |
| 713 | 713 | ||
| 714 | (ert-deftest python-indent-electric-colon-1 () | ||
| 715 | "Test indentation case from Bug#18228." | ||
| 716 | (python-tests-with-temp-buffer | ||
| 717 | " | ||
| 718 | def a(): | ||
| 719 | pass | ||
| 720 | |||
| 721 | def b() | ||
| 722 | " | ||
| 723 | (python-tests-look-at "def b()") | ||
| 724 | (goto-char (line-end-position)) | ||
| 725 | (python-tests-self-insert ":") | ||
| 726 | (should (= (current-indentation) 0)))) | ||
| 727 | |||
| 714 | 728 | ||
| 715 | ;;; Navigation | 729 | ;;; Navigation |
| 716 | 730 | ||