diff options
| author | Fabián Ezequiel Gallina | 2012-12-31 16:27:20 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-12-31 16:27:20 -0300 |
| commit | df4758b82ea93b13bb659fb0084a951b3bd19190 (patch) | |
| tree | 1270df5a5d3cbf2eddb4f6550878ab5ad96169a6 /lisp/progmodes/python.el | |
| parent | bdcad781aaa4ea4b5e63e6118bddab964acf77e4 (diff) | |
| download | emacs-df4758b82ea93b13bb659fb0084a951b3bd19190.tar.gz emacs-df4758b82ea93b13bb659fb0084a951b3bd19190.zip | |
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.") | |||
| 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 | |||
| 895 | indicated by the variable `python-indent-levels' to set the | 901 | indicated by the variable `python-indent-levels' to set the |
| 896 | current indentation. | 902 | current indentation. |
| 897 | 903 | ||
| 898 | When the variable `last-command' is equal to | 904 | When the variable `last-command' is equal to one of the symbols |
| 899 | `indent-for-tab-command' or FORCE-TOGGLE is non-nil it cycles | 905 | inside `python-indent-trigger-commands' or FORCE-TOGGLE is |
| 900 | levels indicated in the variable `python-indent-levels' by | 906 | non-nil it cycles levels indicated in the variable |
| 901 | setting the current level in the variable | 907 | `python-indent-levels' by setting the current level in the |
| 902 | `python-indent-current-level'. | 908 | variable `python-indent-current-level'. |
| 903 | 909 | ||
| 904 | When the variable `last-command' is not equal to | 910 | When the variable `last-command' is not equal to one of the |
| 905 | `indent-for-tab-command' and FORCE-TOGGLE is nil it calculates | 911 | symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE |
| 906 | possible indentation levels and saves it in the variable | 912 | is nil it calculates possible indentation levels and saves it in |
| 907 | `python-indent-levels'. Afterwards it sets the variable | 913 | the variable `python-indent-levels'. Afterwards it sets the |
| 908 | `python-indent-current-level' correctly so offset is equal | 914 | variable `python-indent-current-level' correctly so offset is |
| 909 | to (`nth' `python-indent-current-level' `python-indent-levels')" | 915 | equal 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. |