summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1996-07-31 20:42:59 (GMT)
committerBarry Warsaw <barry@python.org>1996-07-31 20:42:59 (GMT)
commitf831d81999e826e9bf444138c2e193ff1c9e801e (patch)
tree8337c6599d32583a78bd5fcec2515f098cc5adbd
parent32aa1a72b256cc8c4262bc9863eef9452fc1305c (diff)
downloadcpython-f831d81999e826e9bf444138c2e193ff1c9e801e.zip
cpython-f831d81999e826e9bf444138c2e193ff1c9e801e.tar.gz
cpython-f831d81999e826e9bf444138c2e193ff1c9e801e.tar.bz2
(py-statement-closes-block-p, py-compute-indentation): Outdent one
level after a return, raise, break, or continue statement.
-rw-r--r--Misc/python-mode.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index af1c24d..ebcc791 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -911,9 +911,13 @@ the new line indented."
;; string. this handles triple quoted, multi-line spanning
;; strings.
(py-goto-initial-line)
- (if (py-statement-opens-block-p)
- (+ (current-indentation) py-indent-offset)
- (current-indentation)))))))
+ (+ (current-indentation)
+ (if (py-statement-opens-block-p)
+ py-indent-offset
+ (if (py-statement-closes-block-p)
+ (- py-indent-offset)
+ 0)))
+ )))))
(defun py-guess-indent-offset (&optional global)
"Guess a good value for, and change, `py-indent-offset'.
@@ -1906,6 +1910,16 @@ local bindings to py-newline-and-indent."))
(setq searching nil)))
answer)))
+(defun py-statement-closes-block-p ()
+ ;; true iff the current statement `closes' a block == the line
+ ;; starts with `return', `raise', `break' or `continue'. doesn't
+ ;; catch embedded statements
+ (let ((here (point)))
+ (back-to-indentation)
+ (prog1
+ (looking-at "\\(return\\|raise\\|break\\|continue\\)\\>")
+ (goto-char here))))
+
;; go to point right beyond final line of block begun by the current
;; line. This is the same as where py-goto-beyond-final-line goes
;; unless we're on colon line, in which case we go to the end of the