Created
August 29, 2018 20:14
-
-
Save alexhrescale/c1ed0035c65b7f0c3ab43762a3005419 to your computer and use it in GitHub Desktop.
convenience emacs methods to execute in shell buffer and capture output into comments
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
(setq copy-output-marker " # <EOF__>") | |
(defun execute-with-marker () | |
(interactive) | |
(kill-ring-save | |
(line-beginning-position) | |
(line-end-position)) | |
(end-of-line) | |
(setq my-comint-originator-buffer (buffer-name)) | |
(other-window 1) | |
(end-of-buffer) | |
(yank) | |
(insert copy-output-marker) | |
(comint-send-input) | |
(other-window 1)) | |
(defun retrieve-ouput-from-marker () | |
(interactive) | |
(let ((current-buffer (buffer-name))) | |
(switch-to-buffer "*shell*") | |
(end-of-buffer) | |
(previous-line) | |
(end-of-line) | |
(let ((end (point))) | |
(search-backward copy-output-marker) | |
(end-of-line) | |
(kill-ring-save | |
(point) end)) | |
(end-of-buffer) | |
(switch-to-buffer current-buffer) | |
(yank) | |
(exchange-point-and-mark) | |
(comment-dwim nil) | |
(deactivate-mark))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment