]> granicus.if.org Git - python/commitdiff
(py-statement-closes-block-p, py-compute-indentation): Outdent one
authorBarry Warsaw <barry@python.org>
Wed, 31 Jul 1996 20:42:59 +0000 (20:42 +0000)
committerBarry Warsaw <barry@python.org>
Wed, 31 Jul 1996 20:42:59 +0000 (20:42 +0000)
level after a return, raise, break, or continue statement.

Misc/python-mode.el

index af1c24d53957fc780d2676015c634959127901c0..ebcc7916c6ebf1e853b3cfdc577f15aee3c9510a 100644 (file)
@@ -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