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)
  • 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 9 at 18:56
up vote 3 down vote accepted

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.

  • Thanks, that worked! Now on to my other issues :) – Codygman Oct 10 at 4:03

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.