Created
April 6, 2018 09:51
-
-
Save TeMPOraL/8715c9dd9837e0b601d1cdce0592536e to your computer and use it in GitHub Desktop.
Redirect a stream to Emacs buffer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Remember to set `slime-enable-evaluate-in-emacs' to t in Emacs. | |
;;; Also remember that it basically allows your Lisp to execute any code in your Emacs. | |
(defmacro with-output-to-emacs-buffer ((stream buffer-name) &body body) | |
`(let ((results (with-output-to-string (,stream) | |
,@body))) | |
(swank:eval-in-emacs `(with-current-buffer (get-buffer-create ,,buffer-name) | |
(erase-buffer) | |
(insert ,results))))) | |
;;; Use example: | |
(with-output-to-emacs-buffer (*standard-output* "Your Buffer Name") (some-call-that-prints-to-stdout)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment