Skip to content

Instantly share code, notes, and snippets.

@wasamasa
Last active October 10, 2017 19:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wasamasa/b89a54f56f3ef86d20cd6b8d85e2a5d8 to your computer and use it in GitHub Desktop.
Save wasamasa/b89a54f56f3ef86d20cd6b8d85e2a5d8 to your computer and use it in GitHub Desktop.
Emacs buffer filtering
(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