[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [QUESTION] How to use :filter in `make-process'?
From: |
Stefan Monnier |
Subject: |
Re: [QUESTION] How to use :filter in `make-process'? |
Date: |
Tue, 03 Mar 2020 09:39:04 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (let ((op-fn (lambda () (message "call the fn"))))
> (make-process
> :name "sleep command test"
> :command (list "sleep" "3")
> :filter `(lambda (proc event)
> (message "event catched!")
^^^^^^^
caught ;-)
> (funcall ,op-fn))
> :buffer "*sleep test*"))
More importantly, the ,op-fn is incorrect, it should be ',op-fn
otherwise the value contained in op-fn will be re-interpreted as an
expression (which will sometimes be harmless but sometimes not,
depending on how the function value ends up represented).
Of course, the better solution is to use `lexical-binding` so you can
just write:
(let ((op-fn (lambda () (message "call the fn"))))
(make-process
:name "sleep command test"
:command (list "sleep" "3")
:filter (lambda (proc event)
(message "event catched!")
(funcall op-fn))
:buffer "*sleep test*"))
-- Stefan