mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-18 10:16:51 +00:00
Shell output catching a la gud-gdb.
* progmodes/python.el (python-shell-fetch-lines-in-progress) (python-shell-fetch-lines-string, python-shell-fetched-lines): New Vars. (python-shell-fetch-lines-filter): New function. (python-shell-send-string-no-output): Use them.
This commit is contained in:
parent
07f133bf5d
commit
0478776bb7
@ -1,3 +1,12 @@
|
|||||||
|
2012-10-01 Fabián Ezequiel Gallina <fgallina@cuca>
|
||||||
|
|
||||||
|
Shell output catching a la gud-gdb.
|
||||||
|
* progmodes/python.el (python-shell-fetch-lines-in-progress)
|
||||||
|
(python-shell-fetch-lines-string, python-shell-fetched-lines): New
|
||||||
|
Vars.
|
||||||
|
(python-shell-fetch-lines-filter): New function.
|
||||||
|
(python-shell-send-string-no-output): Use them.
|
||||||
|
|
||||||
2012-09-30 Tomohiro Matsuyama <tomo@cx4a.org>
|
2012-09-30 Tomohiro Matsuyama <tomo@cx4a.org>
|
||||||
|
|
||||||
* profiler.el (profiler-sampling-interval): Rename from
|
* profiler.el (profiler-sampling-interval): Rename from
|
||||||
|
@ -1867,31 +1867,45 @@ When MSG is non-nil messages the first line of STRING."
|
|||||||
(string-match "\n[ \t].*\n?$" string))
|
(string-match "\n[ \t].*\n?$" string))
|
||||||
(comint-send-string process "\n")))))
|
(comint-send-string process "\n")))))
|
||||||
|
|
||||||
|
;; Shell output catching stolen from gud-gdb
|
||||||
|
(defvar python-shell-fetch-lines-in-progress nil)
|
||||||
|
(defvar python-shell-fetch-lines-string nil)
|
||||||
|
(defvar python-shell-fetched-lines nil)
|
||||||
|
|
||||||
|
(defun python-shell-fetch-lines-filter (string)
|
||||||
|
"Filter used to read the list of lines output by a command.
|
||||||
|
STRING is the output to filter."
|
||||||
|
(setq string (concat python-shell-fetch-lines-string string))
|
||||||
|
(while (string-match "\n" string)
|
||||||
|
(push (substring string 0 (match-beginning 0))
|
||||||
|
python-shell-fetched-lines)
|
||||||
|
(setq string (substring string (match-end 0))))
|
||||||
|
(if (equal (string-match comint-prompt-regexp string) 0)
|
||||||
|
(progn
|
||||||
|
(setq python-shell-fetch-lines-in-progress nil)
|
||||||
|
string)
|
||||||
|
(progn
|
||||||
|
(setq python-shell-fetch-lines-string string)
|
||||||
|
"")))
|
||||||
|
|
||||||
(defun python-shell-send-string-no-output (string &optional process msg)
|
(defun python-shell-send-string-no-output (string &optional process msg)
|
||||||
"Send STRING to PROCESS and inhibit output.
|
"Send STRING to PROCESS and inhibit output.
|
||||||
When MSG is non-nil messages the first line of STRING. Return
|
When MSG is non-nil messages the first line of STRING. Return
|
||||||
the output."
|
the output."
|
||||||
(let* ((output-buffer "")
|
(let ((process (or process (python-shell-get-or-create-process)))
|
||||||
(process (or process (python-shell-get-or-create-process)))
|
|
||||||
(comint-preoutput-filter-functions
|
(comint-preoutput-filter-functions
|
||||||
(append comint-preoutput-filter-functions
|
'(python-shell-fetch-lines-filter))
|
||||||
'(ansi-color-filter-apply
|
(python-shell-fetch-lines-in-progress t)
|
||||||
(lambda (string)
|
|
||||||
(setq output-buffer (concat output-buffer string))
|
|
||||||
""))))
|
|
||||||
(inhibit-quit t))
|
(inhibit-quit t))
|
||||||
(or
|
(or
|
||||||
(with-local-quit
|
(with-local-quit
|
||||||
(python-shell-send-string string process msg)
|
(python-shell-send-string string process msg)
|
||||||
(accept-process-output process)
|
(while python-shell-fetch-lines-in-progress
|
||||||
(replace-regexp-in-string
|
(accept-process-output process))
|
||||||
(if (> (length python-shell-prompt-output-regexp) 0)
|
(prog1
|
||||||
(format "\n*%s$\\|^%s\\|\n$"
|
(mapconcat #'identity
|
||||||
python-shell-prompt-regexp
|
(reverse python-shell-fetched-lines) "\n")
|
||||||
(or python-shell-prompt-output-regexp ""))
|
(setq python-shell-fetched-lines nil)))
|
||||||
(format "\n*$\\|^%s\\|\n$"
|
|
||||||
python-shell-prompt-regexp))
|
|
||||||
"" output-buffer))
|
|
||||||
(with-current-buffer (process-buffer process)
|
(with-current-buffer (process-buffer process)
|
||||||
(comint-interrupt-subjob)))))
|
(comint-interrupt-subjob)))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user