emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 6c8231e: python.el: Handle tabs in python-indent-


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] emacs-24 6c8231e: python.el: Handle tabs in python-indent-dedent-line.
Date: Fri, 30 Jan 2015 03:42:11 +0000

branch: emacs-24
commit 6c8231ee8ce527b779df81249c0e597b9a04a17f
Author: Fabián Ezequiel Gallina <address@hidden>
Commit: Fabián Ezequiel Gallina <address@hidden>

    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 <address@hidden>.
    
    * test/automated/python-tests.el
    (python-indent-dedent-line-backspace-2)
    (python-indent-dedent-line-backspace-3): New tests.
---
 lisp/ChangeLog                 |    7 +++++
 lisp/progmodes/python.el       |    4 +--
 test/ChangeLog                 |    6 +++++
 test/automated/python-tests.el |   49 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2068601..51d47a7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
 2015-01-30  Fabián Ezequiel Gallina  <address@hidden>
 
+       python.el: Handle tabs in python-indent-dedent-line.
+
+       * progmodes/python.el (python-indent-dedent-line): Fixes for
+       indentation with tabs.  Thanks to <address@hidden> (Bug#19730).
+
+2015-01-30  Fabián Ezequiel Gallina  <address@hidden>
+
        * progmodes/python.el (python-indent-context): Respect user
        indentation after comment.
 
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5842be7..0d314d6 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 72e1b85..f33cf84 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,11 @@
 2015-01-30  Fabián Ezequiel Gallina  <address@hidden>
 
+       * 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  <address@hidden>
+
        * 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 4972731..42c26fc 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
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]