emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110170: * progmodes/python.el (pytho


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110170: * progmodes/python.el (python-indent-line): More consistent cursor
Date: Sun, 23 Sep 2012 15:21:33 -0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110170
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-23 15:21:33 -0300
message:
  * progmodes/python.el (python-indent-line): More consistent cursor
  movement behavior.
modified:
  lisp/ChangeLog
  lisp/progmodes/python.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-23 14:50:02 +0000
+++ b/lisp/ChangeLog    2012-09-23 18:21:33 +0000
@@ -1,3 +1,8 @@
+2012-09-23  Fabián Ezequiel Gallina  <address@hidden>
+
+       * progmodes/python.el (python-indent-line): More consistent cursor
+       movement behavior.
+
 2012-09-23  Stefan Merten  <address@hidden>
 
        * textmodes/rst.el: Fix compiler warning.

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2012-09-07 14:53:15 +0000
+++ b/lisp/progmodes/python.el  2012-09-23 18:21:33 +0000
@@ -897,16 +897,27 @@
 `python-indent-levels'.  Afterwards it sets the variable
 `python-indent-current-level' correctly so offset is equal
 to (`nth' `python-indent-current-level' `python-indent-levels')"
-  (if (or (and (eq this-command 'indent-for-tab-command)
-               (eq last-command this-command))
-          force-toggle)
-      (if (not (equal python-indent-levels '(0)))
-          (python-indent-toggle-levels)
-        (python-indent-calculate-levels))
-    (python-indent-calculate-levels))
-  (beginning-of-line)
-  (delete-horizontal-space)
-  (indent-to (nth python-indent-current-level python-indent-levels))
+  (or
+   (and (or (and (eq this-command 'indent-for-tab-command)
+                 (eq last-command this-command))
+            force-toggle)
+        (not (equal python-indent-levels '(0)))
+        (or (python-indent-toggle-levels) t))
+   (python-indent-calculate-levels))
+  (let* ((starting-pos (point-marker))
+         (indent-ending-position
+          (+ (line-beginning-position) (current-indentation)))
+         (follow-indentation-p
+          (or (bolp)
+              (and (<= (line-beginning-position) starting-pos)
+                   (>= indent-ending-position starting-pos))))
+         (next-indent (nth python-indent-current-level python-indent-levels)))
+    (unless (= next-indent (current-indentation))
+      (beginning-of-line)
+      (delete-horizontal-space)
+      (indent-to next-indent)
+      (goto-char starting-pos))
+    (and follow-indentation-p (back-to-indentation)))
   (python-info-closing-block-message))
 
 (defun python-indent-line-function ()


reply via email to

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