diff options
author | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2015-01-30 00:41:52 -0300 |
---|---|---|
committer | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2015-01-30 00:41:52 -0300 |
commit | 6c8231ee8ce527b779df81249c0e597b9a04a17f (patch) | |
tree | a0c617a1700e2b501d00cb9900b400c6f1aa19ae | |
parent | 41c3b9241cd78a1eaeb159572b6f4e546b1f8d7b (diff) | |
download | emacs-6c8231ee8ce527b779df81249c0e597b9a04a17f.tar.gz |
python.el: Handle tabs in python-indent-dedent-line.
Fixes: debbugs:19730
* lisp/progmodes/python.el (python-indent-dedent-line): Fixes for
indentation with tabs. Thanks to <dale@codefu.org>.
* test/automated/python-tests.el
(python-indent-dedent-line-backspace-2)
(python-indent-dedent-line-backspace-3): New tests.
-rw-r--r-- | lisp/ChangeLog | 7 | ||||
-rw-r--r-- | lisp/progmodes/python.el | 4 | ||||
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/automated/python-tests.el | 49 |
4 files changed, 63 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20686014bf3..51d47a791ad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,12 @@ 2015-01-30 Fabián Ezequiel Gallina <fgallina@gnu.org> + python.el: Handle tabs in python-indent-dedent-line. + + * progmodes/python.el (python-indent-dedent-line): Fixes for + indentation with tabs. Thanks to <dale@codefu.org> (Bug#19730). + +2015-01-30 Fabián Ezequiel Gallina <fgallina@gnu.org> + * progmodes/python.el (python-indent-context): Respect user indentation after comment. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5842be7cf64..0d314d669eb 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1067,9 +1067,7 @@ indentation levels from right to left." (interactive "*") (when (and (not (bolp)) (not (python-syntax-comment-or-string-p)) - (= (+ (line-beginning-position) - (current-indentation)) - (point))) + (= (current-indentation) (current-column))) (python-indent-line t) t)) diff --git a/test/ChangeLog b/test/ChangeLog index 72e1b854fd9..f33cf84cf98 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,5 +1,11 @@ 2015-01-30 Fabián Ezequiel Gallina <fgallina@gnu.org> + * automated/python-tests.el + (python-indent-dedent-line-backspace-2) + (python-indent-dedent-line-backspace-3): New tests. + +2015-01-30 Fabián Ezequiel Gallina <fgallina@gnu.org> + * automated/python-tests.el (python-indent-pep8-1) (python-indent-pep8-2, python-indent-pep8-3) (python-indent-after-comment-2): Fix tests. diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 4972731d0d2..42c26fc3482 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -2127,6 +2127,55 @@ if True: (call-interactively #'python-indent-dedent-line-backspace) (should (zerop (current-indentation))))) +(ert-deftest python-indent-dedent-line-backspace-2 () + "Check de-indentation with tabs. Bug#19730." + (let ((tab-width 8)) + (python-tests-with-temp-buffer + " +if x: +\tabcdefg +" + (python-tests-look-at "abcdefg") + (goto-char (line-end-position)) + (call-interactively #'python-indent-dedent-line-backspace) + (should + (string= (buffer-substring-no-properties + (line-beginning-position) (line-end-position)) + "\tabcdef"))))) + +(ert-deftest python-indent-dedent-line-backspace-3 () + "Paranoid check of de-indentation with tabs. Bug#19730." + (let ((tab-width 8)) + (python-tests-with-temp-buffer + " +if x: +\tif y: +\t abcdefg +" + (python-tests-look-at "abcdefg") + (goto-char (line-end-position)) + (call-interactively #'python-indent-dedent-line-backspace) + (should + (string= (buffer-substring-no-properties + (line-beginning-position) (line-end-position)) + "\t abcdef")) + (back-to-indentation) + (call-interactively #'python-indent-dedent-line-backspace) + (should + (string= (buffer-substring-no-properties + (line-beginning-position) (line-end-position)) + "\tabcdef")) + (call-interactively #'python-indent-dedent-line-backspace) + (should + (string= (buffer-substring-no-properties + (line-beginning-position) (line-end-position)) + " abcdef")) + (call-interactively #'python-indent-dedent-line-backspace) + (should + (string= (buffer-substring-no-properties + (line-beginning-position) (line-end-position)) + "abcdef"))))) + ;;; Shell integration |