unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: stardiviner <numbchild@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: [QUESTION] How to use :filter in `make-process'?
Date: Tue, 03 Mar 2020 23:08:24 +0800	[thread overview]
Message-ID: <87o8td79xz.fsf@gmail.com> (raw)
In-Reply-To: <jwvzhcx5wut.fsf-monnier+emacs@gnu.org>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> (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*"))
>
Use lexical-binding in your example, it does not work. report error:

: error in process sentinel: Symbol’s value as variable is void: op-fn [2 times]

>
> -- Stefan


- -- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5ecugUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsPRXAgAzjfJp3dgJ7fKBf0C6flThJXqEhiL
TXrDnJ2mFehQzZO21lmMoGjy2Td6nxuGHJO7VdryhsE0b6hwaVVqbTD1TC+nvbtO
dBZ8ZiSWnbYYgLraLtOU+oFQ6ZTa+gN6ADpbm+44xMk3mL41xjgg5Nx+a4U8+poG
EDLZZNpbuQF9BjL9Bzvkb14lTMV0rOZKuRfo8+Q5VDu92rbQbk1Fkr4dDOgdc5eV
BsPXtkc+zw4PZ8Vcx+GNy52PcthAX2A0Div+TK7sfRm1FIERdQiIk1PuwEub8dT8
Z5WhZSYMjvhwFwRISm7N2K7Fj0qIwLnT/DAiWn/c0uovdNId42jivO9qYA==
=cLpZ
-----END PGP SIGNATURE-----



  reply	other threads:[~2020-03-03 15:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03  7:49 [QUESTION] How to use :filter in `make-process'? stardiviner
2020-03-03  8:19 ` Joost Kremers
2020-03-03 16:18   ` [SOLVED] " stardiviner
2020-03-03 16:51     ` Stefan Monnier
2020-03-03 17:33       ` stardiviner
2020-03-03 14:39 ` Stefan Monnier
2020-03-03 15:08   ` stardiviner [this message]
2020-03-03 15:25     ` Michael Heerdegen
2020-03-03 17:34       ` stardiviner
2020-03-03 16:49     ` Stefan Monnier
2020-03-03 17:35       ` stardiviner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8td79xz.fsf@gmail.com \
    --to=numbchild@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).