diff options
| author | Augusto Stoffel | 2021-09-15 10:02:34 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-09-15 10:02:34 +0200 |
| commit | 6cfc312d7196d7c7c70e7030b344891ecea8c4f1 (patch) | |
| tree | 48babcaac9618a459b4676a93ee8f485c33569eb /lisp/progmodes/python.el | |
| parent | 3c2753a3b8e69e32524d1e1342be6ffc41aa1ec3 (diff) | |
| download | emacs-6cfc312d7196d7c7c70e7030b344891ecea8c4f1.tar.gz emacs-6cfc312d7196d7c7c70e7030b344891ecea8c4f1.zip | |
Python shell: rearrange printing of newline before output
* progmodes/python.el (python-shell-output-filter-in-progress)
(python-shell-output-filter-buffer): Move defvars to avoid compiler
warnings.
(python-shell-eval-setup-code): Don't print a newline in
__PYTHON_EL_eval.
(python-shell-send-string): Insert newline before output when
applicable (bug#50514).
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d9fc5c50091..fae350dea24 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2189,6 +2189,9 @@ virtualenv." | |||
| 2189 | :type '(alist regexp) | 2189 | :type '(alist regexp) |
| 2190 | :group 'python) | 2190 | :group 'python) |
| 2191 | 2191 | ||
| 2192 | (defvar python-shell-output-filter-in-progress nil) | ||
| 2193 | (defvar python-shell-output-filter-buffer nil) | ||
| 2194 | |||
| 2192 | (defmacro python-shell--add-to-path-with-priority (pathvar paths) | 2195 | (defmacro python-shell--add-to-path-with-priority (pathvar paths) |
| 2193 | "Modify PATHVAR and ensure PATHS are added only once at beginning." | 2196 | "Modify PATHVAR and ensure PATHS are added only once at beginning." |
| 2194 | `(dolist (path (reverse ,paths)) | 2197 | `(dolist (path (reverse ,paths)) |
| @@ -2821,7 +2824,6 @@ def __PYTHON_EL_eval(source, filename): | |||
| 2821 | from __builtin__ import compile, eval, globals | 2824 | from __builtin__ import compile, eval, globals |
| 2822 | else: | 2825 | else: |
| 2823 | from builtins import compile, eval, globals | 2826 | from builtins import compile, eval, globals |
| 2824 | sys.stdout.write('\\n') | ||
| 2825 | try: | 2827 | try: |
| 2826 | p, e = ast.parse(source, filename), None | 2828 | p, e = ast.parse(source, filename), None |
| 2827 | except SyntaxError: | 2829 | except SyntaxError: |
| @@ -3162,6 +3164,11 @@ t when called interactively." | |||
| 3162 | (python-shell--encode-string string) | 3164 | (python-shell--encode-string string) |
| 3163 | (python-shell--encode-string (or (buffer-file-name) | 3165 | (python-shell--encode-string (or (buffer-file-name) |
| 3164 | "<string>"))))) | 3166 | "<string>"))))) |
| 3167 | (unless python-shell-output-filter-in-progress | ||
| 3168 | (with-current-buffer (process-buffer process) | ||
| 3169 | (save-excursion | ||
| 3170 | (goto-char (process-mark process)) | ||
| 3171 | (insert-before-markers "\n")))) | ||
| 3165 | (if (or (null (process-tty-name process)) | 3172 | (if (or (null (process-tty-name process)) |
| 3166 | (<= (string-bytes code) | 3173 | (<= (string-bytes code) |
| 3167 | (or (bound-and-true-p comint-max-line-length) | 3174 | (or (bound-and-true-p comint-max-line-length) |
| @@ -3172,9 +3179,6 @@ t when called interactively." | |||
| 3172 | (file-name (or (buffer-file-name) temp-file-name))) | 3179 | (file-name (or (buffer-file-name) temp-file-name))) |
| 3173 | (python-shell-send-file file-name process temp-file-name t))))) | 3180 | (python-shell-send-file file-name process temp-file-name t))))) |
| 3174 | 3181 | ||
| 3175 | (defvar python-shell-output-filter-in-progress nil) | ||
| 3176 | (defvar python-shell-output-filter-buffer nil) | ||
| 3177 | |||
| 3178 | (defun python-shell-output-filter (string) | 3182 | (defun python-shell-output-filter (string) |
| 3179 | "Filter used in `python-shell-send-string-no-output' to grab output. | 3183 | "Filter used in `python-shell-send-string-no-output' to grab output. |
| 3180 | STRING is the output received to this point from the process. | 3184 | STRING is the output received to this point from the process. |