Skip to content

Commit

Permalink
Echo extraneous output after prompt has been received
Browse files Browse the repository at this point in the history
When the REPL spits out more stdout when no command is (ostensibly) in
progress, echo that output before the prompt.

Example case:

λ> forkIO (do threadDelay (1000*1000); putStrLn "yo")
ThreadId 37

yo
λ>

The "yo" is usually just lost in the ether. It also doesn't disturb
your prompt if you're typing in it.

@hvr @cmears might be interested.
  • Loading branch information
chrisdone committed Apr 6, 2014
1 parent 277e8e8 commit c2e7dbf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 15 additions & 0 deletions haskell-interactive-mode.el
Expand Up @@ -138,6 +138,11 @@ Key bindings:
"Face for the result."
:group 'haskell-interactive)

(defface haskell-interactive-face-garbage
'((t :inherit 'font-lock-string-face))
"Face for trailing garbage after a command has completed."
:group 'haskell-interactive)

(defun haskell-interactive-mode-newline-indent ()
"Make newline and indent."
(interactive)
Expand Down Expand Up @@ -461,6 +466,16 @@ SESSION, otherwise operate on the current buffer.
'read-only t
'rear-nonsticky t)))))))

(defun haskell-interactive-mode-insert-garbage (session message)
"Echo a read only piece of text before the prompt."
(with-current-buffer (haskell-session-interactive-buffer session)
(save-excursion
(haskell-interactive-mode-goto-end-point)
(insert (propertize message
'face 'haskell-interactive-face-garbage
'read-only t
'rear-nonsticky t)))))

(defun haskell-interactive-mode-insert (session message)
"Echo a read only piece of text before the prompt."
(with-current-buffer (haskell-session-interactive-buffer session)
Expand Down
8 changes: 5 additions & 3 deletions haskell-process.el
Expand Up @@ -1065,10 +1065,12 @@ If I break, you can:
(haskell-process-log (format "<- %S\n" response))
(let ((session (haskell-process-project-by-proc proc)))
(when session
(when (haskell-process-cmd (haskell-session-process session))
(haskell-process-collect session
(if (haskell-process-cmd (haskell-session-process session))
(haskell-process-collect session
response
(haskell-session-process session))))))
(haskell-session-process session))
(haskell-interactive-mode-insert-garbage session
response)))))

(defun haskell-process-log (msg)
"Write MSG to the process log (if enabled)."
Expand Down

0 comments on commit c2e7dbf

Please sign in to comment.