diff options
| author | Andrea Corallo | 2020-10-04 19:45:05 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-10-04 19:45:05 +0200 |
| commit | 44ef24342fd8a2ac876212124ebf38673acda35a (patch) | |
| tree | 793dc4ba4197559b4bc65339d713c0807a7b2ca9 /lisp/progmodes/python.el | |
| parent | afb765ab3cab7b6582d0def543b23603cd076445 (diff) | |
| parent | d8665e6d3473403c90a0831e83439a013d0012d3 (diff) | |
| download | emacs-44ef24342fd8a2ac876212124ebf38673acda35a.tar.gz emacs-44ef24342fd8a2ac876212124ebf38673acda35a.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 95b6a037bb3..76baa4469c7 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2078,7 +2078,7 @@ virtualenv." | |||
| 2078 | :group 'python) | 2078 | :group 'python) |
| 2079 | 2079 | ||
| 2080 | (defcustom python-shell-setup-codes nil | 2080 | (defcustom python-shell-setup-codes nil |
| 2081 | "List of code run by `python-shell-send-setup-codes'." | 2081 | "List of code run by `python-shell-send-setup-code'." |
| 2082 | :type '(repeat symbol) | 2082 | :type '(repeat symbol) |
| 2083 | :group 'python) | 2083 | :group 'python) |
| 2084 | 2084 | ||
| @@ -2378,9 +2378,11 @@ regexps: `python-shell-prompt-regexp', | |||
| 2378 | 2378 | ||
| 2379 | (defun python-shell-prompt-set-calculated-regexps () | 2379 | (defun python-shell-prompt-set-calculated-regexps () |
| 2380 | "Detect and set input and output prompt regexps. | 2380 | "Detect and set input and output prompt regexps. |
| 2381 | Build and set the values for `python-shell-input-prompt-regexp' | 2381 | Build and set the values for |
| 2382 | and `python-shell-output-prompt-regexp' using the values from | 2382 | `python-shell--prompt-calculated-input-regexp' and |
| 2383 | `python-shell-prompt-regexp', `python-shell-prompt-block-regexp', | 2383 | `python-shell--prompt-calculated-output-regexp' using the values |
| 2384 | from `python-shell-prompt-regexp', | ||
| 2385 | `python-shell-prompt-block-regexp', | ||
| 2384 | `python-shell-prompt-pdb-regexp', | 2386 | `python-shell-prompt-pdb-regexp', |
| 2385 | `python-shell-prompt-output-regexp', | 2387 | `python-shell-prompt-output-regexp', |
| 2386 | `python-shell-prompt-input-regexps', | 2388 | `python-shell-prompt-input-regexps', |
| @@ -2442,7 +2444,7 @@ of `python-shell-buffer-name'." | |||
| 2442 | 2444 | ||
| 2443 | (defun python-shell-internal-get-process-name () | 2445 | (defun python-shell-internal-get-process-name () |
| 2444 | "Calculate the appropriate process name for Internal Python process. | 2446 | "Calculate the appropriate process name for Internal Python process. |
| 2445 | The name is calculated from `python-shell-global-buffer-name' and | 2447 | The name is calculated from `python-shell-buffer-name' and |
| 2446 | the `buffer-name'." | 2448 | the `buffer-name'." |
| 2447 | (format "%s[%s]" python-shell-internal-buffer-name (buffer-name))) | 2449 | (format "%s[%s]" python-shell-internal-buffer-name (buffer-name))) |
| 2448 | 2450 | ||
| @@ -3074,7 +3076,7 @@ Returns the output. See `python-shell-send-string-no-output'." | |||
| 3074 | (define-obsolete-function-alias | 3076 | (define-obsolete-function-alias |
| 3075 | 'python-send-string 'python-shell-internal-send-string "24.3") | 3077 | 'python-send-string 'python-shell-internal-send-string "24.3") |
| 3076 | 3078 | ||
| 3077 | (defun python-shell-buffer-substring (start end &optional nomain) | 3079 | (defun python-shell-buffer-substring (start end &optional nomain no-cookie) |
| 3078 | "Send buffer substring from START to END formatted for shell. | 3080 | "Send buffer substring from START to END formatted for shell. |
| 3079 | This is a wrapper over `buffer-substring' that takes care of | 3081 | This is a wrapper over `buffer-substring' that takes care of |
| 3080 | different transformations for the code sent to be evaluated in | 3082 | different transformations for the code sent to be evaluated in |
| @@ -3100,12 +3102,13 @@ the python shell: | |||
| 3100 | (goto-char start) | 3102 | (goto-char start) |
| 3101 | (python-util-forward-comment 1) | 3103 | (python-util-forward-comment 1) |
| 3102 | (current-indentation)))) | 3104 | (current-indentation)))) |
| 3103 | (fillstr (when (not starts-at-point-min-p) | 3105 | (fillstr (and (not no-cookie) |
| 3104 | (concat | 3106 | (not starts-at-point-min-p) |
| 3105 | (format "# -*- coding: %s -*-\n" encoding) | 3107 | (concat |
| 3106 | (make-string | 3108 | (format "# -*- coding: %s -*-\n" encoding) |
| 3107 | ;; Subtract 2 because of the coding cookie. | 3109 | (make-string |
| 3108 | (- (line-number-at-pos start) 2) ?\n))))) | 3110 | ;; Subtract 2 because of the coding cookie. |
| 3111 | (- (line-number-at-pos start) 2) ?\n))))) | ||
| 3109 | (with-temp-buffer | 3112 | (with-temp-buffer |
| 3110 | (python-mode) | 3113 | (python-mode) |
| 3111 | (when fillstr | 3114 | (when fillstr |
| @@ -3144,7 +3147,8 @@ the python shell: | |||
| 3144 | (line-beginning-position) (line-end-position)))) | 3147 | (line-beginning-position) (line-end-position)))) |
| 3145 | (buffer-substring-no-properties (point-min) (point-max))))) | 3148 | (buffer-substring-no-properties (point-min) (point-max))))) |
| 3146 | 3149 | ||
| 3147 | (defun python-shell-send-region (start end &optional send-main msg) | 3150 | (defun python-shell-send-region (start end &optional send-main msg |
| 3151 | no-cookie) | ||
| 3148 | "Send the region delimited by START and END to inferior Python process. | 3152 | "Send the region delimited by START and END to inferior Python process. |
| 3149 | When optional argument SEND-MAIN is non-nil, allow execution of | 3153 | When optional argument SEND-MAIN is non-nil, allow execution of |
| 3150 | code inside blocks delimited by \"if __name__== \\='__main__\\=':\". | 3154 | code inside blocks delimited by \"if __name__== \\='__main__\\=':\". |
| @@ -3154,7 +3158,8 @@ non-nil, forces display of a user-friendly message if there's no | |||
| 3154 | process running; defaults to t when called interactively." | 3158 | process running; defaults to t when called interactively." |
| 3155 | (interactive | 3159 | (interactive |
| 3156 | (list (region-beginning) (region-end) current-prefix-arg t)) | 3160 | (list (region-beginning) (region-end) current-prefix-arg t)) |
| 3157 | (let* ((string (python-shell-buffer-substring start end (not send-main))) | 3161 | (let* ((string (python-shell-buffer-substring start end (not send-main) |
| 3162 | no-cookie)) | ||
| 3158 | (process (python-shell-get-process-or-error msg)) | 3163 | (process (python-shell-get-process-or-error msg)) |
| 3159 | (original-string (buffer-substring-no-properties start end)) | 3164 | (original-string (buffer-substring-no-properties start end)) |
| 3160 | (_ (string-match "\\`\n*\\(.*\\)" original-string))) | 3165 | (_ (string-match "\\`\n*\\(.*\\)" original-string))) |
| @@ -3178,7 +3183,7 @@ interactively." | |||
| 3178 | (python-shell-send-region | 3183 | (python-shell-send-region |
| 3179 | (save-excursion (python-nav-beginning-of-statement)) | 3184 | (save-excursion (python-nav-beginning-of-statement)) |
| 3180 | (save-excursion (python-nav-end-of-statement)) | 3185 | (save-excursion (python-nav-end-of-statement)) |
| 3181 | send-main msg))) | 3186 | send-main msg t))) |
| 3182 | 3187 | ||
| 3183 | (defun python-shell-send-buffer (&optional send-main msg) | 3188 | (defun python-shell-send-buffer (&optional send-main msg) |
| 3184 | "Send the entire buffer to inferior Python process. | 3189 | "Send the entire buffer to inferior Python process. |
| @@ -3200,27 +3205,29 @@ optional argument MSG is non-nil, forces display of a | |||
| 3200 | user-friendly message if there's no process running; defaults to | 3205 | user-friendly message if there's no process running; defaults to |
| 3201 | t when called interactively." | 3206 | t when called interactively." |
| 3202 | (interactive (list current-prefix-arg t)) | 3207 | (interactive (list current-prefix-arg t)) |
| 3203 | (save-excursion | 3208 | (let ((starting-pos (point))) |
| 3204 | (python-shell-send-region | 3209 | (save-excursion |
| 3205 | (progn | 3210 | (python-shell-send-region |
| 3206 | (end-of-line 1) | 3211 | (progn |
| 3207 | (while (and (or (python-nav-beginning-of-defun) | 3212 | (end-of-line 1) |
| 3208 | (beginning-of-line 1)) | 3213 | (while (and (or (python-nav-beginning-of-defun) |
| 3209 | (> (current-indentation) 0))) | 3214 | (beginning-of-line 1)) |
| 3210 | (when (not arg) | 3215 | (> (current-indentation) 0))) |
| 3211 | (while (and | 3216 | (when (not arg) |
| 3212 | (eq (forward-line -1) 0) | 3217 | (while (and |
| 3213 | (if (looking-at (python-rx decorator)) | 3218 | (eq (forward-line -1) 0) |
| 3214 | t | 3219 | (if (looking-at (python-rx decorator)) |
| 3215 | (forward-line 1) | 3220 | t |
| 3216 | nil)))) | 3221 | (forward-line 1) |
| 3217 | (point-marker)) | 3222 | nil)))) |
| 3218 | (progn | 3223 | (point-marker)) |
| 3219 | (or (python-nav-end-of-defun) | 3224 | (progn |
| 3220 | (end-of-line 1)) | 3225 | (goto-char starting-pos) |
| 3221 | (point-marker)) | 3226 | (or (python-nav-end-of-defun) |
| 3222 | nil ;; noop | 3227 | (end-of-line 1)) |
| 3223 | msg))) | 3228 | (point-marker)) |
| 3229 | nil ;; noop | ||
| 3230 | msg)))) | ||
| 3224 | 3231 | ||
| 3225 | (defun python-shell-send-file (file-name &optional process temp-file-name | 3232 | (defun python-shell-send-file (file-name &optional process temp-file-name |
| 3226 | delete msg) | 3233 | delete msg) |
| @@ -4712,7 +4719,7 @@ customize how labels are formatted." | |||
| 4712 | (defun python-imenu-create-flat-index (&optional alist prefix) | 4719 | (defun python-imenu-create-flat-index (&optional alist prefix) |
| 4713 | "Return flat outline of the current Python buffer for Imenu. | 4720 | "Return flat outline of the current Python buffer for Imenu. |
| 4714 | Optional argument ALIST is the tree to be flattened; when nil | 4721 | Optional argument ALIST is the tree to be flattened; when nil |
| 4715 | `python-imenu-build-index' is used with | 4722 | `python-imenu-create-index' is used with |
| 4716 | `python-imenu-format-parent-item-jump-label-function' | 4723 | `python-imenu-format-parent-item-jump-label-function' |
| 4717 | `python-imenu-format-parent-item-label-function' | 4724 | `python-imenu-format-parent-item-label-function' |
| 4718 | `python-imenu-format-item-label-function' set to | 4725 | `python-imenu-format-item-label-function' set to |