aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el42
1 files changed, 28 insertions, 14 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 98ba437d4ef..89b85e10351 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -597,6 +597,12 @@ It makes underscores and dots word constituent chars.")
597 :group 'python 597 :group 'python
598 :safe 'booleanp) 598 :safe 'booleanp)
599 599
600(defcustom python-indent-trigger-commands
601 '(indent-for-tab-command yas-expand yas/expand)
602 "Commands that might trigger a `python-indent-line' call."
603 :type '(repeat symbol)
604 :group 'python)
605
600(define-obsolete-variable-alias 606(define-obsolete-variable-alias
601 'python-indent 'python-indent-offset "24.3") 607 'python-indent 'python-indent-offset "24.3")
602 608
@@ -895,20 +901,21 @@ Uses the offset calculated in
895indicated by the variable `python-indent-levels' to set the 901indicated by the variable `python-indent-levels' to set the
896current indentation. 902current indentation.
897 903
898When the variable `last-command' is equal to 904When the variable `last-command' is equal to one of the symbols
899`indent-for-tab-command' or FORCE-TOGGLE is non-nil it cycles 905inside `python-indent-trigger-commands' or FORCE-TOGGLE is
900levels indicated in the variable `python-indent-levels' by 906non-nil it cycles levels indicated in the variable
901setting the current level in the variable 907`python-indent-levels' by setting the current level in the
902`python-indent-current-level'. 908variable `python-indent-current-level'.
903 909
904When the variable `last-command' is not equal to 910When the variable `last-command' is not equal to one of the
905`indent-for-tab-command' and FORCE-TOGGLE is nil it calculates 911symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE
906possible indentation levels and saves it in the variable 912is nil it calculates possible indentation levels and saves it in
907`python-indent-levels'. Afterwards it sets the variable 913the variable `python-indent-levels'. Afterwards it sets the
908`python-indent-current-level' correctly so offset is equal 914variable `python-indent-current-level' correctly so offset is
909to (`nth' `python-indent-current-level' `python-indent-levels')" 915equal to (`nth' `python-indent-current-level'
916`python-indent-levels')"
910 (or 917 (or
911 (and (or (and (eq this-command 'indent-for-tab-command) 918 (and (or (and (memq this-command python-indent-trigger-commands)
912 (eq last-command this-command)) 919 (eq last-command this-command))
913 force-toggle) 920 force-toggle)
914 (not (equal python-indent-levels '(0))) 921 (not (equal python-indent-levels '(0)))
@@ -1998,7 +2005,14 @@ Returns the output. See `python-shell-send-string-no-output'."
1998(defun python-shell-send-region (start end) 2005(defun python-shell-send-region (start end)
1999 "Send the region delimited by START and END to inferior Python process." 2006 "Send the region delimited by START and END to inferior Python process."
2000 (interactive "r") 2007 (interactive "r")
2001 (python-shell-send-string (buffer-substring start end) nil t)) 2008 (python-shell-send-string
2009 (concat
2010 (let ((line-num (line-number-at-pos start)))
2011 ;; When sending a region, add blank lines for non sent code so
2012 ;; backtraces remain correct.
2013 (make-string (1- line-num) ?\n))
2014 (buffer-substring start end))
2015 nil t))
2002 2016
2003(defun python-shell-send-buffer (&optional arg) 2017(defun python-shell-send-buffer (&optional arg)
2004 "Send the entire buffer to inferior Python process. 2018 "Send the entire buffer to inferior Python process.