From: Tomas Hlavaty <tom@logand.com>
To: Marco Antoniotti <marcoxa@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Waiting for 'compile' to finish
Date: Fri, 10 Jan 2025 10:25:42 +0100 [thread overview]
Message-ID: <87a5bzc961.fsf@neko.mail-host-address-is-not-set> (raw)
In-Reply-To: <CAKmY7cWwJ-pNH6FcLE2z9z32O8Eombj7n6VH3LSfjGG=n=LQtg@mail.gmail.com>
On Thu 09 Jan 2025 at 22:38, Marco Antoniotti <marcoxa@gmail.com> wrote:
> Thanks... and how exactly do I do that?
> On Thu, Jan 9, 2025 at 10:36 PM Tomas Hlavaty <tom@logand.com> wrote:
>> On Thu 09 Jan 2025 at 21:00, Marco Antoniotti <marcoxa@gmail.com> wrote:
>> > I meant "programmatically", as in: checking if the process/thread is
>> alive
>> > or not.
>> poll it in idle timer
for timer see (describe-function 'run-with-idle-timer)
the nice thing about polling is that it works universally
without having to know implementation details
and without having a hook for the right event
thus if you don't know and cannot dig deeper => poll
but I found even better solution in my .emacs using
set-process-sentinel, something like this:
(set-process-sentinel
(get-buffer-process (get-buffer eepitch-buffer-name))
(lambda (_process event)
(when (equal "finished\n" event)
(run-with-idle-timer 1 nil after))))
so you can watch the process without polling and call your callback when
you need.
this is what I do to pull emails:
(defun background-repl (code command exit after)
(eepitch code)
(eepitch-kill)
(eepitch code)
(set-process-sentinel
(get-buffer-process (get-buffer eepitch-buffer-name))
(lambda (_process event)
(when (equal "finished\n" event)
(run-with-idle-timer 1 nil after))))
(mapc 'eepitch-line (ensure-list command))
(mapc 'eepitch-line (ensure-list exit)))
usage:
(background-repl
'(shell "**nm")
"notmuch new"
"exit"
(lambda () (notmuch-search "tag:inbox")))
next prev parent reply other threads:[~2025-01-10 9:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 19:44 Waiting for 'compile' to finish Marco Antoniotti
2025-01-09 19:50 ` Tomas Hlavaty
2025-01-09 20:00 ` Marco Antoniotti
2025-01-09 20:18 ` Bruno Barbier
2025-01-09 21:05 ` Marco Antoniotti
2025-01-09 21:23 ` Bruno Barbier
2025-01-09 21:25 ` Marco Antoniotti
2025-01-09 22:02 ` Bruno Barbier
2025-01-09 21:36 ` Tomas Hlavaty
2025-01-09 21:38 ` Marco Antoniotti
2025-01-10 9:25 ` Tomas Hlavaty [this message]
2025-01-10 14:06 ` Stefan Monnier via Users list for the GNU Emacs text editor
2025-01-09 23:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5bzc961.fsf@neko.mail-host-address-is-not-set \
--to=tom@logand.com \
--cc=help-gnu-emacs@gnu.org \
--cc=marcoxa@gmail.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.