From: Fabián Ezequiel Gallina Date: Fri, 30 Jan 2015 03:41:52 +0000 (-0300) Subject: python.el: Handle tabs in python-indent-dedent-line. X-Git-Tag: emacs-24.4.90~20 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6c8231e;p=emacs.git 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 . * test/automated/python-tests.el (python-indent-dedent-line-backspace-2) (python-indent-dedent-line-backspace-3): New tests. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20686014bf3..51d47a791ad 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2015-01-30 Fabián Ezequiel Gallina + + python.el: Handle tabs in python-indent-dedent-line. + + * progmodes/python.el (python-indent-dedent-line): Fixes for + indentation with tabs. Thanks to (Bug#19730). + 2015-01-30 Fabián Ezequiel Gallina * progmodes/python.el (python-indent-context): Respect user 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,3 +1,9 @@ +2015-01-30 Fabián Ezequiel Gallina + + * 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 * automated/python-tests.el (python-indent-pep8-1) 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