diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 9c5c71db882..339f2403c26 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2483,6 +2483,12 @@ With argument MSG show activation/deactivation message." | |||
| 2483 | (python-shell-font-lock-turn-off msg)) | 2483 | (python-shell-font-lock-turn-off msg)) |
| 2484 | python-shell-font-lock-enable)) | 2484 | python-shell-font-lock-enable)) |
| 2485 | 2485 | ||
| 2486 | ;; Used to hold user interactive overrides to | ||
| 2487 | ;; `python-shell-interpreter' and `python-shell-interpreter-args' that | ||
| 2488 | ;; will be made buffer-local by `inferior-python-mode': | ||
| 2489 | (defvar python-shell--interpreter) | ||
| 2490 | (defvar python-shell--interpreter-args) | ||
| 2491 | |||
| 2486 | (define-derived-mode inferior-python-mode comint-mode "Inferior Python" | 2492 | (define-derived-mode inferior-python-mode comint-mode "Inferior Python" |
| 2487 | "Major mode for Python inferior process. | 2493 | "Major mode for Python inferior process. |
| 2488 | Runs a Python interpreter as a subprocess of Emacs, with Python | 2494 | Runs a Python interpreter as a subprocess of Emacs, with Python |
| @@ -2508,15 +2514,16 @@ initialization of the interpreter via `python-shell-setup-codes' | |||
| 2508 | variable. | 2514 | variable. |
| 2509 | 2515 | ||
| 2510 | \(Type \\[describe-mode] in the process buffer for a list of commands.)" | 2516 | \(Type \\[describe-mode] in the process buffer for a list of commands.)" |
| 2511 | (let ((interpreter python-shell-interpreter) | 2517 | (when python-shell--parent-buffer |
| 2512 | (args python-shell-interpreter-args)) | 2518 | (python-util-clone-local-variables python-shell--parent-buffer)) |
| 2513 | (when python-shell--parent-buffer | 2519 | ;; Users can interactively override default values for |
| 2514 | (python-util-clone-local-variables python-shell--parent-buffer)) | 2520 | ;; `python-shell-interpreter' and `python-shell-interpreter-args' |
| 2515 | ;; Users can override default values for these vars when calling | 2521 | ;; when calling `run-python'. This ensures values let-bound in |
| 2516 | ;; `run-python'. This ensures new values let-bound in | 2522 | ;; `python-shell-make-comint' are locally set if needed. |
| 2517 | ;; `python-shell-make-comint' are locally set. | 2523 | (set (make-local-variable 'python-shell-interpreter) |
| 2518 | (set (make-local-variable 'python-shell-interpreter) interpreter) | 2524 | (or python-shell--interpreter python-shell-interpreter)) |
| 2519 | (set (make-local-variable 'python-shell-interpreter-args) args)) | 2525 | (set (make-local-variable 'python-shell-interpreter-args) |
| 2526 | (or python-shell--interpreter-args python-shell-interpreter-args)) | ||
| 2520 | (set (make-local-variable 'python-shell--prompt-calculated-input-regexp) nil) | 2527 | (set (make-local-variable 'python-shell--prompt-calculated-input-regexp) nil) |
| 2521 | (set (make-local-variable 'python-shell--prompt-calculated-output-regexp) nil) | 2528 | (set (make-local-variable 'python-shell--prompt-calculated-output-regexp) nil) |
| 2522 | (python-shell-prompt-set-calculated-regexps) | 2529 | (python-shell-prompt-set-calculated-regexps) |
| @@ -2566,13 +2573,13 @@ killed." | |||
| 2566 | interpreter nil args)) | 2573 | interpreter nil args)) |
| 2567 | (python-shell--parent-buffer (current-buffer)) | 2574 | (python-shell--parent-buffer (current-buffer)) |
| 2568 | (process (get-buffer-process buffer)) | 2575 | (process (get-buffer-process buffer)) |
| 2569 | ;; As the user may have overridden default values for | 2576 | ;; Users can override the interpreter and args |
| 2570 | ;; these vars on `run-python', let-binding them allows | 2577 | ;; interactively when calling `run-python', let-binding |
| 2571 | ;; to have the new right values in all setup code | 2578 | ;; these allows to have the new right values in all |
| 2572 | ;; that's is done in `inferior-python-mode', which is | 2579 | ;; setup code that is done in `inferior-python-mode', |
| 2573 | ;; important, especially for prompt detection. | 2580 | ;; which is important, especially for prompt detection. |
| 2574 | (python-shell-interpreter interpreter) | 2581 | (python-shell--interpreter interpreter) |
| 2575 | (python-shell-interpreter-args | 2582 | (python-shell--interpreter-args |
| 2576 | (mapconcat #'identity args " "))) | 2583 | (mapconcat #'identity args " "))) |
| 2577 | (with-current-buffer buffer | 2584 | (with-current-buffer buffer |
| 2578 | (inferior-python-mode)) | 2585 | (inferior-python-mode)) |