unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* What is the correct way of passing a function with a default argument to a function?
@ 2018-10-09 17:02 Cody Goodman
  2018-10-09 18:15 ` Philipp Stephani
  0 siblings, 1 reply; 2+ messages in thread
From: Cody Goodman @ 2018-10-09 17:02 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1911 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: What is the correct way of passing a function with a default argument to a function?
  2018-10-09 17:02 What is the correct way of passing a function with a default argument to a function? Cody Goodman
@ 2018-10-09 18:15 ` Philipp Stephani
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Stephani @ 2018-10-09 18:15 UTC (permalink / raw)
  To: Cody Goodman; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 291 bytes --]

Cody Goodman <codygman.consulting@gmail.com> schrieb am Di., 9. Okt. 2018
um 19:04 Uhr:

>
>               :filter #'(apply-partially 'my-pass-it-on-filter
> "/tmp/mytmp")
>
>
This should work if you leave out the quoting, i.e.

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

[-- Attachment #2: Type: text/html, Size: 709 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-09 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09 17:02 What is the correct way of passing a function with a default argument to a function? Cody Goodman
2018-10-09 18:15 ` Philipp Stephani

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).