From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: [QUESTION] How to use :filter in `make-process'? Date: Tue, 03 Mar 2020 09:39:04 -0500 Message-ID: References: <87r1y97u8v.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="33686"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:AzSymVPfFvfsY+AS3gVf/qhaLCE= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 03 15:40:25 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 1j98ie-0008gc-SK for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Mar 2020 15:40:24 +0100 Original-Received: from localhost ([::1]:48210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j98id-0000Bs-Up for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Mar 2020 09:40:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37837) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j98iK-0000BX-Nd for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 09:40:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j98iJ-0005yE-QY for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 09:40:04 -0500 Original-Received: from ciao.gmane.io ([159.69.161.202]:41414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j98iJ-0005xw-KM for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 09:40:03 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1j98iI-0008IT-Fv for help-gnu-emacs@gnu.org; Tue, 03 Mar 2020 15:40:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 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:122517 Archived-At: > (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