Last active
October 10, 2017 19:45
-
-
Save wasamasa/b89a54f56f3ef86d20cd6b8d85e2a5d8 to your computer and use it in GitHub Desktop.
Emacs buffer filtering
This file contains hidden or 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
(defun my-filter-current-buffer (program &rest args) | |
(let* ((stdout-buffer (generate-new-buffer " stdout")) | |
(ret (apply 'call-process-region (point-min) (point-max) program | |
nil (list stdout-buffer) nil args))) | |
(when (zerop ret) | |
(let ((output (with-current-buffer stdout-buffer | |
(buffer-string)))) | |
(erase-buffer) | |
(insert output))) | |
(kill-buffer stdout-buffer))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment