summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina <fgallina@gnu.org>2012-09-23 15:21:33 -0300
committerFabián Ezequiel Gallina <fgallina@gnu.org>2012-09-23 15:21:33 -0300
commit095bb82357c1fb173a20518104d56fbeb5135f43 (patch)
tree59c0ee00d66426e372abaa352519faba4bbc952e
parentaf0e9f75ea016190896133353f49596754e3dc73 (diff)
downloademacs-095bb82357c1fb173a20518104d56fbeb5135f43.tar.gz
* progmodes/python.el (python-indent-line): More consistent cursor
movement behavior.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/python.el31
2 files changed, 26 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index eb0c75d66d9..420e4d992bd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-23 Fabián Ezequiel Gallina <fgallina@cuca>
+
+ * progmodes/python.el (python-indent-line): More consistent cursor
+ movement behavior.
+
2012-09-23 Stefan Merten <smerten@oekonux.de>
* textmodes/rst.el: Fix compiler warning.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ffc6c1ac885..8b8002b84b7 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -897,16 +897,27 @@ possible indentation levels and saves it in the variable
`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 ()