unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@gnu.org>
To: help-gnu-emacs@gnu.org
Cc: Patrick <pma@rdorte.org>
Subject: Re: How can I write this function better?
Date: Thu, 16 Mar 2017 09:30:52 +0100	[thread overview]
Message-ID: <87y3w5k4hv.fsf@zigzag.favinet> (raw)
In-Reply-To: <87o9x2oodq.fsf@rdorte.org> (Patrick's message of "Wed, 15 Mar 2017 10:55:29 +0100")

[-- Attachment #1: Type: text/plain, Size: 1412 bytes --]


() Patrick <pma@rdorte.org>
() 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 ‘proc’ not accepting output) unless
OTHER-CODE does (directly or indirectly) ‘sit-for’, ‘sleep-for’,
or ‘accept-process-output’, or waits for terminal input (e.g.,
w/ ‘read-string’).  See: (info "(elisp) Output from Processes")
and ‘git grep -n -H -e set-process-\\\(sentinel\\\|filter\\\)’
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.

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (query)
   (pcase (context query)
     (`(technical ,ml) (correctp ml))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

      reply	other threads:[~2017-03-16  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-13 19:49 How can I write this function better? user
2017-03-14 12:44 ` Marcin Borkowski
2017-03-14 17:48 ` John Mastro
2017-03-15  9:55   ` Patrick
2017-03-16  8:30     ` Thien-Thi Nguyen [this message]

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=87y3w5k4hv.fsf@zigzag.favinet \
    --to=ttn@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pma@rdorte.org \
    /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).