2

Here is the code with two things I tried as the ":filter" in ": my-pass-it-on-filter":

(defun my-pass-it-on-sentinel (proc _msg)
  "Process entire output of PROC line-wise."
  (when (and (eq (process-status proc) 'exit)
             (zerop (process-exit-status proc))
             (buffer-live-p (process-buffer proc)))
    (with-current-buffer (process-buffer proc)
      (mapc #'(lambda (x) x) (split-string (buffer-string) "\n" t))
      (kill-buffer))))

(defun my-pass-it-on-filter (filePath proc str)
  "Process each line produced by PROC in STR."
  (when (buffer-live-p (process-buffer proc))
    (with-current-buffer (process-buffer proc)
      (insert str)
      (goto-char (point-min))
      (while (progn (skip-chars-forward "^\n")
                    (not (eobp)))
        ((lambda (line) (progn ((message ">>> %s" line)) (ignore-errors line))) (delete-and-extract-region (point-min) (point)))
        (delete-char 1)))))
(make-process :name "my-proc2"
              :buffer " *my-proc2*"
              :command '("sh" "-c" "echo 1 && sleep 5 && echo 2")
              :connection-type 'pipe
              ;; :filter #'(funcall 'my-pass-it-on-filter "/tmp/mytmp")
              :filter #'(apply-partially 'my-pass-it-on-filter "/tmp/mytmp")
              :sentinel #'my-pass-it-on-sentinel)
Drew
  • 75,699
  • 9
  • 109
  • 225
codygman
  • 153
  • 6
  • 1
    This was also asked and answered on `help-gnu-emacs@gnu.org`. Mentioning that in case there is followup there that readers here might be interested in. – Drew Oct 09 '18 at 18:56

1 Answers1

3

You almost have it: drop the quote from the apply-partially form so that it reads:

:filter (apply-partially 'my-pass-it-on-filter "/tmp/mytmp") 

The point is that apply-partially returns the function you want.

While we are here, the message form has an extra sets of parens around it.

Fran Burstall
  • 3,665
  • 10
  • 18