]> git.eshelyaron.com Git - emacs.git/commitdiff
python.el: Handle tabs in python-indent-dedent-line.
authorFabián Ezequiel Gallina <fgallina@gnu.org>
Fri, 30 Jan 2015 03:41:52 +0000 (00:41 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Fri, 30 Jan 2015 03:41:52 +0000 (00:41 -0300)
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.

lisp/ChangeLog
lisp/progmodes/python.el
test/ChangeLog
test/automated/python-tests.el

index 20686014bf316930bb4f74dda1fbd6cd9e34ae1d..51d47a791ad9157ec8438b593da66aefbcb0fdc3 100644 (file)
@@ -1,3 +1,10 @@
+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
index 5842be7cf64dce720dd675fd0b1322d11bdda896..0d314d669eb8e86b9d6488da57d7ad94301ad651 100644 (file)
@@ -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))
 
index 72e1b854fd9527cd9bdd2ba4eceaa3aa2bc59524..f33cf84cf98c41ae708007a7faf0cacf97b98a33 100644 (file)
@@ -1,3 +1,9 @@
+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)
index 4972731d0d26ed9027378e19be976581cf46d751..42c26fc3482f2dd59eb106ab9e917d6c7a6d9f40 100644 (file)
@@ -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")))))
+
 \f
 ;;; Shell integration