Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to keep output when using hy-shell--redirect-send #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions hy-shell.el
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
(or (re-search-backward comint-prompt-regexp nil t)
(error "No prompt found or `comint-prompt-regexp' not set properly")))))

(defun hy-shell--redirect-send-1 (text)
(defun hy-shell--redirect-send-1 (text &optional keep-output)
"Internal implementation of `comint-redirect-send-command-to-process'.
Expected to be called within a Hy interpreter process buffer."
Expand All @@ -192,19 +192,19 @@ Expected to be called within a Hy interpreter process buffer."
(process (hy-shell--current-process))
(timeout hy-shell--redirect-timeout))
;; Setup local vars for the filter, temporarily overwrite comint filters
(comint-redirect-setup output-buffer buffer comint-prompt-regexp)
(comint-redirect-setup output-buffer buffer comint-prompt-regexp keep-output)
(add-function :around (process-filter process) #'comint-redirect-filter)

(process-send-string buffer (s-concat text "\n"))
(while (and (null comint-redirect-completed)
(accept-process-output process timeout)))))

(defun hy-shell--redirect-send (text)
(defun hy-shell--redirect-send (text &optional keep-output)
"Send TEXT to Hy interpreter, capturing and removing the output."
(with-current-buffer (get-buffer-create hy-shell--redirect-output-buffer)
(erase-buffer)
(hy-shell--with
(hy-shell--redirect-send-1 text))
(hy-shell--redirect-send-1 text keep-output))
(s-chomp (buffer-substring-no-properties (point-min) (point-max)))))

(defun hy-shell--redirect-send-internal (text)
Expand Down