From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: How can I write this function better? Date: Thu, 16 Mar 2017 09:30:52 +0100 Message-ID: <87y3w5k4hv.fsf@zigzag.favinet> References: <87zigprm7q.fsf@cocaine.ninja> <87o9x2oodq.fsf@rdorte.org> Reply-To: help-gnu-emacs@gnu.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1489653697 20314 195.159.176.226 (16 Mar 2017 08:41:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 16 Mar 2017 08:41:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cc: Patrick To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 16 09:41:33 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coQyR-0004Rx-Gq for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Mar 2017 09:41:31 +0100 Original-Received: from localhost ([::1]:41639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coQyU-0007Q8-F3 for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Mar 2017 04:41:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coQy3-0007Q0-RN for help-gnu-emacs@gnu.org; Thu, 16 Mar 2017 04:41:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coQy0-0007dt-MU for help-gnu-emacs@gnu.org; Thu, 16 Mar 2017 04:41:07 -0400 Original-Received: from mail.agora-net.com ([67.59.132.6]:50339) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1coQy0-0007dV-IC for help-gnu-emacs@gnu.org; Thu, 16 Mar 2017 04:41:04 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.82) (envelope-from ) id 1coQxx-000458-0E; Thu, 16 Mar 2017 04:41:01 -0400 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1coQoM-0006Ls-N2; Thu, 16 Mar 2017 09:31:06 +0100 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: <87o9x2oodq.fsf@rdorte.org> (Patrick's message of "Wed, 15 Mar 2017 10:55:29 +0100") X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ttn@gnuvola.org X-SA-Exim-Scanned: No (on mail.agora-net.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 67.59.132.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112578 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Patrick () Wed, 15 Mar 2017 10:55:29 +0100 Note how you can define the process and then add properties or set a sentinel `later' in the function, took me some time to figure this out. But I still don't know if that's always the case (feedback very welcome). Generally, if you have: (let ((proc (start-process ...))) OTHER-CODE (set-process-sentinel proc FUNC)) FUNC will not be run (due to =E2=80=98proc=E2=80=99 not accepting output) u= nless OTHER-CODE does (directly or indirectly) =E2=80=98sit-for=E2=80=99, =E2=80= =98sleep-for=E2=80=99, or =E2=80=98accept-process-output=E2=80=99, or waits for terminal input (e.= g., w/ =E2=80=98read-string=E2=80=99). See: (info "(elisp) Output from Process= es") and =E2=80=98git grep -n -H -e set-process-\\\(sentinel\\\|filter\\\)=E2=80= =99 output (Emacs source) for theory and practice, respectively. Assigning the process sentinel (or filter) need not even occur in the same block. Indeed, any "later" point in time is fine (although there is such a thing as "too late to be useful" :-D). I use this one-process-multiple-filter-set-"later" approach in gnugo.el, for example. =2D-=20 Thien-Thi Nguyen ----------------------------------------------- (defun responsep (query) (pcase (context query) (`(technical ,ml) (correctp ml)) ...)) 748E A0E8 1CB8 A748 9BFA =2D-------------------------------------- 6CE4 6703 2224 4C80 7502 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAljKTUQACgkQZwMiJEyAdQIowgCfRBrkiQnpOXab1PUUSabHy242 h6sAoJP46nMrV+YEEuweTT6d71hqh9w2 =BnUF -----END PGP SIGNATURE----- --=-=-=--