diff options
author | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2012-12-31 16:27:20 -0300 |
---|---|---|
committer | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2012-12-31 16:27:20 -0300 |
commit | df4758b82ea93b13bb659fb0084a951b3bd19190 (patch) | |
tree | 1270df5a5d3cbf2eddb4f6550878ab5ad96169a6 /lisp/progmodes/python.el | |
parent | bdcad781aaa4ea4b5e63e6118bddab964acf77e4 (diff) | |
download | emacs-df4758b82ea93b13bb659fb0084a951b3bd19190.tar.gz |
Backported revisions 2012-12-29T12:33:33Z!fgallina@gnu.org and 2012-12-29T12:57:49Z!fgallina@gnu.org from trunk.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r-- | lisp/progmodes/python.el | 42 |
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.") :group 'python :safe 'booleanp) +(defcustom python-indent-trigger-commands + '(indent-for-tab-command yas-expand yas/expand) + "Commands that might trigger a `python-indent-line' call." + :type '(repeat symbol) + :group 'python) + (define-obsolete-variable-alias 'python-indent 'python-indent-offset "24.3") @@ -895,20 +901,21 @@ Uses the offset calculated in indicated by the variable `python-indent-levels' to set the current indentation. -When the variable `last-command' is equal to -`indent-for-tab-command' or FORCE-TOGGLE is non-nil it cycles -levels indicated in the variable `python-indent-levels' by -setting the current level in the variable -`python-indent-current-level'. - -When the variable `last-command' is not equal to -`indent-for-tab-command' and FORCE-TOGGLE is nil it calculates -possible indentation levels and saves it in the variable -`python-indent-levels'. Afterwards it sets the variable -`python-indent-current-level' correctly so offset is equal -to (`nth' `python-indent-current-level' `python-indent-levels')" +When the variable `last-command' is equal to one of the symbols +inside `python-indent-trigger-commands' or FORCE-TOGGLE is +non-nil it cycles levels indicated in the variable +`python-indent-levels' by setting the current level in the +variable `python-indent-current-level'. + +When the variable `last-command' is not equal to one of the +symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE +is nil it calculates possible indentation levels and saves it in +the variable `python-indent-levels'. Afterwards it sets the +variable `python-indent-current-level' correctly so offset is +equal to (`nth' `python-indent-current-level' +`python-indent-levels')" (or - (and (or (and (eq this-command 'indent-for-tab-command) + (and (or (and (memq this-command python-indent-trigger-commands) (eq last-command this-command)) force-toggle) (not (equal python-indent-levels '(0))) @@ -1998,7 +2005,14 @@ Returns the output. See `python-shell-send-string-no-output'." (defun python-shell-send-region (start end) "Send the region delimited by START and END to inferior Python process." (interactive "r") - (python-shell-send-string (buffer-substring start end) nil t)) + (python-shell-send-string + (concat + (let ((line-num (line-number-at-pos start))) + ;; When sending a region, add blank lines for non sent code so + ;; backtraces remain correct. + (make-string (1- line-num) ?\n)) + (buffer-substring start end)) + nil t)) (defun python-shell-send-buffer (&optional arg) "Send the entire buffer to inferior Python process. |