diff options
| author | Joakim Verona | 2012-12-30 00:03:52 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-12-30 00:03:52 +0100 |
| commit | ea2da3d8fbf19765a9bd82292bfc73918f74048d (patch) | |
| tree | b350dbdaa6601f4384a3fbde01eeaea297d4f047 /lisp/progmodes/python.el | |
| parent | 16b9f224223b3e9eb0c4b313e4257dacbd3ebe34 (diff) | |
| parent | eff2eb5812e964024c3aa20197b21f12d37155dd (diff) | |
| download | emacs-ea2da3d8fbf19765a9bd82292bfc73918f74048d.tar.gz emacs-ea2da3d8fbf19765a9bd82292bfc73918f74048d.zip | |
auto upstream
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 67388c0339b..54a657a2593 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -204,7 +204,6 @@ | |||
| 204 | 204 | ||
| 205 | (require 'ansi-color) | 205 | (require 'ansi-color) |
| 206 | (require 'comint) | 206 | (require 'comint) |
| 207 | (eval-when-compile (require 'cl-lib)) | ||
| 208 | 207 | ||
| 209 | ;; Avoid compiler warnings | 208 | ;; Avoid compiler warnings |
| 210 | (defvar view-return-to-alist) | 209 | (defvar view-return-to-alist) |
| @@ -529,7 +528,7 @@ is used to limit the scan." | |||
| 529 | (while (and (< i 3) | 528 | (while (and (< i 3) |
| 530 | (or (not limit) (< (+ point i) limit)) | 529 | (or (not limit) (< (+ point i) limit)) |
| 531 | (eq (char-after (+ point i)) quote-char)) | 530 | (eq (char-after (+ point i)) quote-char)) |
| 532 | (cl-incf i)) | 531 | (setq i (1+ i))) |
| 533 | i)) | 532 | i)) |
| 534 | 533 | ||
| 535 | (defun python-syntax-stringify () | 534 | (defun python-syntax-stringify () |
| @@ -608,6 +607,12 @@ It makes underscores and dots word constituent chars.") | |||
| 608 | :group 'python | 607 | :group 'python |
| 609 | :safe 'booleanp) | 608 | :safe 'booleanp) |
| 610 | 609 | ||
| 610 | (defcustom python-indent-trigger-commands | ||
| 611 | '(indent-for-tab-command yas-expand yas/expand) | ||
| 612 | "Commands that might trigger a `python-indent-line' call." | ||
| 613 | :type '(repeat symbol) | ||
| 614 | :group 'python) | ||
| 615 | |||
| 611 | (define-obsolete-variable-alias | 616 | (define-obsolete-variable-alias |
| 612 | 'python-indent 'python-indent-offset "24.3") | 617 | 'python-indent 'python-indent-offset "24.3") |
| 613 | 618 | ||
| @@ -906,20 +911,21 @@ Uses the offset calculated in | |||
| 906 | indicated by the variable `python-indent-levels' to set the | 911 | indicated by the variable `python-indent-levels' to set the |
| 907 | current indentation. | 912 | current indentation. |
| 908 | 913 | ||
| 909 | When the variable `last-command' is equal to | 914 | When the variable `last-command' is equal to one of the symbols |
| 910 | `indent-for-tab-command' or FORCE-TOGGLE is non-nil it cycles | 915 | inside `python-indent-trigger-commands' or FORCE-TOGGLE is |
| 911 | levels indicated in the variable `python-indent-levels' by | 916 | non-nil it cycles levels indicated in the variable |
| 912 | setting the current level in the variable | 917 | `python-indent-levels' by setting the current level in the |
| 913 | `python-indent-current-level'. | 918 | variable `python-indent-current-level'. |
| 914 | 919 | ||
| 915 | When the variable `last-command' is not equal to | 920 | When the variable `last-command' is not equal to one of the |
| 916 | `indent-for-tab-command' and FORCE-TOGGLE is nil it calculates | 921 | symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE |
| 917 | possible indentation levels and saves it in the variable | 922 | is nil it calculates possible indentation levels and saves it in |
| 918 | `python-indent-levels'. Afterwards it sets the variable | 923 | the variable `python-indent-levels'. Afterwards it sets the |
| 919 | `python-indent-current-level' correctly so offset is equal | 924 | variable `python-indent-current-level' correctly so offset is |
| 920 | to (`nth' `python-indent-current-level' `python-indent-levels')" | 925 | equal to (`nth' `python-indent-current-level' |
| 926 | `python-indent-levels')" | ||
| 921 | (or | 927 | (or |
| 922 | (and (or (and (eq this-command 'indent-for-tab-command) | 928 | (and (or (and (memq this-command python-indent-trigger-commands) |
| 923 | (eq last-command this-command)) | 929 | (eq last-command this-command)) |
| 924 | force-toggle) | 930 | force-toggle) |
| 925 | (not (equal python-indent-levels '(0))) | 931 | (not (equal python-indent-levels '(0))) |
| @@ -2009,7 +2015,14 @@ Returns the output. See `python-shell-send-string-no-output'." | |||
| 2009 | (defun python-shell-send-region (start end) | 2015 | (defun python-shell-send-region (start end) |
| 2010 | "Send the region delimited by START and END to inferior Python process." | 2016 | "Send the region delimited by START and END to inferior Python process." |
| 2011 | (interactive "r") | 2017 | (interactive "r") |
| 2012 | (python-shell-send-string (buffer-substring start end) nil t)) | 2018 | (python-shell-send-string |
| 2019 | (concat | ||
| 2020 | (let ((line-num (line-number-at-pos start))) | ||
| 2021 | ;; When sending a region, add blank lines for non sent code so | ||
| 2022 | ;; backtraces remain correct. | ||
| 2023 | (make-string (1- line-num) ?\n)) | ||
| 2024 | (buffer-substring start end)) | ||
| 2025 | nil t)) | ||
| 2013 | 2026 | ||
| 2014 | (defun python-shell-send-buffer (&optional arg) | 2027 | (defun python-shell-send-buffer (&optional arg) |
| 2015 | "Send the entire buffer to inferior Python process. | 2028 | "Send the entire buffer to inferior Python process. |
| @@ -2487,12 +2500,12 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." | |||
| 2487 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." | 2500 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." |
| 2488 | (let* ((marker (point-marker)) | 2501 | (let* ((marker (point-marker)) |
| 2489 | (str-start-pos | 2502 | (str-start-pos |
| 2490 | (let ((m (make-marker))) | 2503 | (set-marker |
| 2491 | (setf (marker-position m) | 2504 | (make-marker) |
| 2492 | (or (python-syntax-context 'string) | 2505 | (or (python-syntax-context 'string) |
| 2493 | (and (equal (string-to-syntax "|") | 2506 | (and (equal (string-to-syntax "|") |
| 2494 | (syntax-after (point))) | 2507 | (syntax-after (point))) |
| 2495 | (point)))) m)) | 2508 | (point))))) |
| 2496 | (num-quotes (python-syntax-count-quotes | 2509 | (num-quotes (python-syntax-count-quotes |
| 2497 | (char-after str-start-pos) str-start-pos)) | 2510 | (char-after str-start-pos) str-start-pos)) |
| 2498 | (str-end-pos | 2511 | (str-end-pos |