From 6023baf8b65ad12f66a6f5e1b2109ad7185a2404 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 23 Apr 2019 10:25:46 -0400 Subject: [PATCH] Add make-process-fn function --- emacs/init.org | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/emacs/init.org b/emacs/init.org index afdca16..8c5b588 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -272,6 +272,23 @@ Some utilities for calling out to other processes. (kill-buffer buf))))) #+END_SRC +A function to call a process passing some string as stdin and returning the process output: +#+BEGIN_SRC emacs-lisp + (defun make-process-fn (program &rest args) + "Returns a function that, when called, call `program` with arguments `args`, + passing the function argument as stdin" + (lambda (&optional input) + (let ((infile + (when input + (let ((tmp-file (make-temp-file "make-process-input"))) + (with-temp-file tmp-file + (insert input) + tmp-file))))) + (with-temp-buffer + (apply #'call-process program infile t nil args) + (buffer-substring-no-properties (point-min) (point-max)))))) +#+END_SRC + * Customization File I don't want anything to write to my init.el, so save customizations in a separate file: #+BEGIN_SRC emacs-lisp