(defconst py-blank-or-comment-re "[ \t]*\\($\\|#\\)"
"Regexp matching blank or comment lines.")
+(defconst py-outdent-re
+ (concat "\\(" (mapconcat 'identity
+ '("else:"
+ "except\\s +.*:"
+ "finally:"
+ "elif\\s +.*:")
+ "\\|")
+ "\\)")
+ "Regexp matching clauses to be outdented one level.")
\f
;;;###autoload
(let (this-indent)
(if (and (not arg)
(save-excursion
- (forward-word -1)
- (looking-at "\\(else\\|except\\|finally\\elif\\):"))
+ (back-to-indentation)
+ (looking-at py-outdent-re))
(= (setq this-indent (py-compute-indentation))
(save-excursion
(forward-line -1)
(let* ((ci (current-indentation))
(move-to-indentation-p (<= (current-column) ci))
(need (py-compute-indentation)))
+ ;; watch for outdents
+ (if (save-excursion
+ (back-to-indentation)
+ (looking-at py-outdent-re))
+ (setq need (- need py-indent-offset)))
(if (/= ci need)
(save-excursion
(beginning-of-line)