 argument is provided, that many colons are inserted non-electrically."
   (interactive "P")
   (self-insert-command (prefix-numeric-value arg))
-  (let (this-indent)
-    (if (and (not arg)
-	     (save-excursion
-	       (back-to-indentation)
-	       (looking-at py-outdent-re))
-	     (= (setq this-indent (py-compute-indentation))
-		(save-excursion
-		  (forward-line -1)
-		  (py-compute-indentation)))
-	     )
-	(save-excursion
-	  (beginning-of-line)
-	  (delete-horizontal-space)
-	  (indent-to (- this-indent py-indent-offset)))
+  (save-excursion
+    (let ((here (point))
+	  (outdent 0)
+	  (indent (py-compute-indentation)))
+      (if (and (not arg)
+	       (progn
+		 (back-to-indentation)
+		 (looking-at py-outdent-re))
+	       (prog2
+		   (backward-to-indentation 1)
+		   (not (looking-at py-no-outdent-re))
+		 (goto-char here))
+	       (= indent (progn
+			   (forward-line -1)
+			   (py-compute-indentation)))
+	       )
+	  (setq outdent py-indent-offset))
+      (goto-char here)
+      (beginning-of-line)
+      (delete-horizontal-space)
+      (indent-to (- indent outdent))
       )))
 
 
(defconst py-outdent-re
  (concat "\\(" (mapconcat 'identity
			   '("else:"
			     "except\\s +.*:"
			     "finally:"
			     "elif\\s +.*:")
			   "\\|")
	  "\\)")
  "Regexp matching clauses to be outdented one level.")



  (let* ((ci (current-indentation))
	 (move-to-indentation-p (<= (current-column) ci))
	 (need (py-compute-indentation)))
    ;; see if we need to outdent
    (if (save-excursion
	  (and (progn (back-to-indentation)
		      (looking-at py-outdent-re))
	       (progn (backward-to-indentation 1)
		      (not (looking-at py-no-outdent-re)))))
	(setq need (- need py-indent-offset)))
    (if (/= ci need)
	(save-excursion
