aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2013-03-25 22:55:11 -0300
committerFabián Ezequiel Gallina2013-03-25 22:55:11 -0300
commitc9886b39eb33e444662f79d9eb649603fda6839a (patch)
tree13de29bfea76378d701f2a3b0a9bb9de75f73584 /lisp/progmodes/python.el
parent4430bd53998ea752ce99b1c25384cf7cfabcef88 (diff)
downloademacs-c9886b39eb33e444662f79d9eb649603fda6839a.tar.gz
emacs-c9886b39eb33e444662f79d9eb649603fda6839a.zip
Un-indent after "pass" and "return" statements
* lisp/progmodes/python.el (python-indent-block-enders): New var. (python-indent-calculate-indentation): Use it. * test/automated/python-tests.el (python-indent-block-enders): New test. (python-info-current-defun-2): Fix test. Fixes: debbugs:13888
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index c2739ce80a1..266d193cdda 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -628,6 +628,12 @@ It makes underscores and dots word constituent chars.")
628These make `python-indent-calculate-indentation' subtract the value of 628These make `python-indent-calculate-indentation' subtract the value of
629`python-indent-offset'.") 629`python-indent-offset'.")
630 630
631(defvar python-indent-block-enders '("return" "pass")
632 "List of words that mark the end of a block.
633These make `python-indent-calculate-indentation' subtract the
634value of `python-indent-offset' when `python-indent-context' is
635AFTER-LINE.")
636
631(defun python-indent-guess-indent-offset () 637(defun python-indent-guess-indent-offset ()
632 "Guess and set `python-indent-offset' for the current buffer." 638 "Guess and set `python-indent-offset' for the current buffer."
633 (interactive) 639 (interactive)
@@ -753,9 +759,13 @@ START is the buffer position where the sexp starts."
753 (save-excursion 759 (save-excursion
754 (goto-char context-start) 760 (goto-char context-start)
755 (current-indentation)) 761 (current-indentation))
756 (if (progn 762 (if (or (save-excursion
757 (back-to-indentation) 763 (back-to-indentation)
758 (looking-at (regexp-opt python-indent-dedenters))) 764 (looking-at (regexp-opt python-indent-dedenters)))
765 (save-excursion
766 (python-util-forward-comment -1)
767 (python-nav-beginning-of-statement)
768 (member (current-word) python-indent-block-enders)))
759 python-indent-offset 769 python-indent-offset
760 0))) 770 0)))
761 ;; When inside of a string, do nothing. just use the current 771 ;; When inside of a string, do nothing. just use the current