File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -290,6 +290,15 @@ Currently-active file is at the head of the list.")
290290(defconst py-blank-or-comment-re " [ \t ]*\\ ($\\ |#\\ )"
291291 " Regexp matching blank or comment lines." )
292292
293+ (defconst py-outdent-re
294+ (concat " \\ (" (mapconcat 'identity
295+ '(" else:"
296+ " except\\ s +.*:"
297+ " finally:"
298+ " elif\\ s +.*:" )
299+ " \\ |" )
300+ " \\ )" )
301+ " Regexp matching clauses to be outdented one level." )
293302
294303
295304;;;### autoload
@@ -374,8 +383,8 @@ argument is provided, that many colons are inserted non-electrically."
374383 (let (this-indent)
375384 (if (and (not arg)
376385 (save-excursion
377- (forward-word -1 )
378- (looking-at " \\ (else \\ |except \\ |finally \\ elif \\ ): " ))
386+ (back-to-indentation )
387+ (looking-at py-outdent-re ))
379388 (= (setq this-indent (py-compute-indentation))
380389 (save-excursion
381390 (forward-line -1 )
@@ -604,6 +613,11 @@ needed so that only a single column position is deleted."
604613 (let* ((ci (current-indentation ))
605614 (move-to-indentation-p (<= (current-column ) ci))
606615 (need (py-compute-indentation)))
616+ ; ; watch for outdents
617+ (if (save-excursion
618+ (back-to-indentation )
619+ (looking-at py-outdent-re))
620+ (setq need (- need py-indent-offset)))
607621 (if (/= ci need)
608622 (save-excursion
609623 (beginning-of-line )
You can’t perform that action at this time.
0 commit comments