From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: stardiviner Newsgroups: gmane.emacs.help Subject: Re: [QUESTION] How to use :filter in `make-process'? Date: Tue, 03 Mar 2020 23:08:24 +0800 Message-ID: <87o8td79xz.fsf@gmail.com> References: <87r1y97u8v.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="37835"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.3.8; emacs 27.0.50 Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 03 16:11:06 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j99CL-0009kY-PY for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Mar 2020 16:11:05 +0100 Original-Received: from localhost ([::1]:48754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j99CK-0003fy-SL for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Mar 2020 10:11:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43074) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j99AG-0008Ig-4k for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 10:08:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j99AE-0002G3-SY for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 10:08:55 -0500 Original-Received: from [183.249.128.110] (port=13246 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j99AE-00027M-Dk for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 10:08:54 -0500 Original-Received: by dark.localdomain (Postfix, from userid 1000) id 7EB492418B0; Tue, 3 Mar 2020 23:08:28 +0800 (CST) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 183.249.128.110 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122518 Archived-At: =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Stefan Monnier 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=E2=80=99s value as variable is void: op= -fn [2 times] > > -- Stefan =2D --=20 [ 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 =20=20=20=20=20=20 =2D----BEGIN PGP SIGNATURE----- iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5ecugUHG51bWJjaGls ZEBnbWFpbC5jb20ACgkQG13xyVromsPRXAgAzjfJp3dgJ7fKBf0C6flThJXqEhiL TXrDnJ2mFehQzZO21lmMoGjy2Td6nxuGHJO7VdryhsE0b6hwaVVqbTD1TC+nvbtO dBZ8ZiSWnbYYgLraLtOU+oFQ6ZTa+gN6ADpbm+44xMk3mL41xjgg5Nx+a4U8+poG EDLZZNpbuQF9BjL9Bzvkb14lTMV0rOZKuRfo8+Q5VDu92rbQbk1Fkr4dDOgdc5eV BsPXtkc+zw4PZ8Vcx+GNy52PcthAX2A0Div+TK7sfRm1FIERdQiIk1PuwEub8dT8 Z5WhZSYMjvhwFwRISm7N2K7Fj0qIwLnT/DAiWn/c0uovdNId42jivO9qYA=3D=3D =3DcLpZ =2D----END PGP SIGNATURE-----