emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What is the correct way of passing a function with a default argument to


From: Cody Goodman
Subject: What is the correct way of passing a function with a default argument to a function?
Date: Tue, 9 Oct 2018 12:02:44 -0500

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)


Thanks,

Cody

reply via email to

[Prev in Thread] Current Thread [Next in Thread]