* Waiting for 'compile' to finish
@ 2025-01-09 19:44 Marco Antoniotti
2025-01-09 19:50 ` Tomas Hlavaty
0 siblings, 1 reply; 12+ messages in thread
From: Marco Antoniotti @ 2025-01-09 19:44 UTC (permalink / raw)
To: help-gnu-emacs
Hi
what would be the best way to check that 'compile' is done?
AFAIU, there is no easy to find handle to the asynchronous process running
the compilation.
Thanks
--
Marco Antoniotti
Somewhere over the Rainbow
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
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
0 siblings, 1 reply; 12+ messages in thread
From: Tomas Hlavaty @ 2025-01-09 19:50 UTC (permalink / raw)
To: Marco Antoniotti, help-gnu-emacs
On Thu 09 Jan 2025 at 20:44, Marco Antoniotti <marcoxa@gmail.com> wrote:
> what would be the best way to check that 'compile' is done?
the last line in the buffer says:
Compilation finished at
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
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:36 ` Tomas Hlavaty
0 siblings, 2 replies; 12+ messages in thread
From: Marco Antoniotti @ 2025-01-09 20:00 UTC (permalink / raw)
To: Tomas Hlavaty; +Cc: help-gnu-emacs
That is obvious.
I meant "programmatically", as in: checking if the process/thread is alive
or not.
MA
On Thu, Jan 9, 2025 at 8:50 PM Tomas Hlavaty <tom@logand.com> wrote:
> On Thu 09 Jan 2025 at 20:44, Marco Antoniotti <marcoxa@gmail.com> wrote:
> > what would be the best way to check that 'compile' is done?
>
> the last line in the buffer says:
> Compilation finished at
>
--
Marco Antoniotti
Somewhere over the Rainbow
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
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:36 ` Tomas Hlavaty
1 sibling, 1 reply; 12+ messages in thread
From: Bruno Barbier @ 2025-01-09 20:18 UTC (permalink / raw)
To: Marco Antoniotti, Tomas Hlavaty; +Cc: help-gnu-emacs
Marco Antoniotti <marcoxa@gmail.com> writes:
> That is obvious.
>
> I meant "programmatically", as in: checking if the process/thread is alive
> or not.
You could add an advice around the function defined by the variable
`compilation-exit-message-function'.
Bruno
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 20:18 ` Bruno Barbier
@ 2025-01-09 21:05 ` Marco Antoniotti
2025-01-09 21:23 ` Bruno Barbier
0 siblings, 1 reply; 12+ messages in thread
From: Marco Antoniotti @ 2025-01-09 21:05 UTC (permalink / raw)
To: Bruno Barbier; +Cc: help-gnu-emacs
Thanks, I'll check it out. But where is this documented?
MA
On Thu, Jan 9, 2025 at 9:18 PM Bruno Barbier <brubar.cs@gmail.com> wrote:
> Marco Antoniotti <marcoxa@gmail.com> writes:
>
> > That is obvious.
> >
> > I meant "programmatically", as in: checking if the process/thread is
> alive
> > or not.
>
> You could add an advice around the function defined by the variable
> `compilation-exit-message-function'.
>
>
> Bruno
>
--
Marco Antoniotti
Somewhere over the Rainbow
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 21:05 ` Marco Antoniotti
@ 2025-01-09 21:23 ` Bruno Barbier
2025-01-09 21:25 ` Marco Antoniotti
0 siblings, 1 reply; 12+ messages in thread
From: Bruno Barbier @ 2025-01-09 21:23 UTC (permalink / raw)
To: Marco Antoniotti; +Cc: help-gnu-emacs
Marco Antoniotti <marcoxa@gmail.com> writes:
> Thanks, I'll check it out. But where is this documented?
>
It seems that the only documentation is the variable definition itself:
C-h v compilation-exit-message-function
Bruno
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 21:23 ` Bruno Barbier
@ 2025-01-09 21:25 ` Marco Antoniotti
2025-01-09 22:02 ` Bruno Barbier
0 siblings, 1 reply; 12+ messages in thread
From: Marco Antoniotti @ 2025-01-09 21:25 UTC (permalink / raw)
To: Bruno Barbier; +Cc: help-gnu-emacs
Yep. That much I surmised. It does not seem to be mentioned in the Info
documentation.
All the best
MA
On Thu, Jan 9, 2025 at 10:23 PM Bruno Barbier <brubar.cs@gmail.com> wrote:
> Marco Antoniotti <marcoxa@gmail.com> writes:
>
> > Thanks, I'll check it out. But where is this documented?
> >
>
> It seems that the only documentation is the variable definition itself:
>
> C-h v compilation-exit-message-function
>
>
> Bruno
>
--
Marco Antoniotti
Somewhere over the Rainbow
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 21:25 ` Marco Antoniotti
@ 2025-01-09 22:02 ` Bruno Barbier
0 siblings, 0 replies; 12+ messages in thread
From: Bruno Barbier @ 2025-01-09 22:02 UTC (permalink / raw)
To: Marco Antoniotti; +Cc: help-gnu-emacs
Marco Antoniotti <marcoxa@gmail.com> writes:
> Yep. That much I surmised. It does not seem to be mentioned in the Info
> documentation.
Here is a function that compiles and do something when done using
`compilation-exit-message-function'.
(defun my-compile (cmd on-exit)
"Compile using CMD. Return the buffer.
Call ON-EXIT when done."
(let ((buffer (compile cmd)))
(with-current-buffer buffer
(add-function :around (local 'compilation-exit-message-function)
(lambda (old-fun process-status exit-status msg)
(let ((mm (funcall old-fun process-status exit-status msg)))
(funcall on-exit process-status exit-status msg)
mm))))
buffer))
Here is an example about how to use it.
(defun my-compile-echo-result (process-status exit-status msg)
"An ON-EXIT example that just displays OK or Failed."
(message "Compilation: %s" (if (eq 0 exit-status) "OK." "Failed!")))
;; A compilation that succeeds.
(my-compile "sleep 1; echo ok" #'my-compile-echo-result)
;; A compilation that fails.
(my-compile "sleep 1; oops" #'my-compile-echo-result)
Hoping this may help you,
Bruno
> All the best
>
> MA
>
> On Thu, Jan 9, 2025 at 10:23 PM Bruno Barbier <brubar.cs@gmail.com> wrote:
>
>> Marco Antoniotti <marcoxa@gmail.com> writes:
>>
>> > Thanks, I'll check it out. But where is this documented?
>> >
>>
>> It seems that the only documentation is the variable definition itself:
>>
>> C-h v compilation-exit-message-function
>>
>>
>> Bruno
>>
>
>
> --
> Marco Antoniotti
> Somewhere over the Rainbow
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 20:00 ` Marco Antoniotti
2025-01-09 20:18 ` Bruno Barbier
@ 2025-01-09 21:36 ` Tomas Hlavaty
2025-01-09 21:38 ` Marco Antoniotti
2025-01-09 23:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
1 sibling, 2 replies; 12+ messages in thread
From: Tomas Hlavaty @ 2025-01-09 21:36 UTC (permalink / raw)
To: Marco Antoniotti; +Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 21:36 ` Tomas Hlavaty
@ 2025-01-09 21:38 ` Marco Antoniotti
2025-01-10 9:25 ` Tomas Hlavaty
2025-01-09 23:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 12+ messages in thread
From: Marco Antoniotti @ 2025-01-09 21:38 UTC (permalink / raw)
To: Tomas Hlavaty; +Cc: help-gnu-emacs
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
>
--
Marco Antoniotti
Somewhere over the Rainbow
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 21:38 ` Marco Antoniotti
@ 2025-01-10 9:25 ` Tomas Hlavaty
0 siblings, 0 replies; 12+ messages in thread
From: Tomas Hlavaty @ 2025-01-10 9:25 UTC (permalink / raw)
To: Marco Antoniotti; +Cc: help-gnu-emacs
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")))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Waiting for 'compile' to finish
2025-01-09 21:36 ` Tomas Hlavaty
2025-01-09 21:38 ` Marco Antoniotti
@ 2025-01-09 23:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2025-01-09 23:35 UTC (permalink / raw)
To: help-gnu-emacs
>> I meant "programmatically", as in: checking if the process/thread is alive or not.
> poll it in idle timer
If you can find the process object (which you presumably need in order
to "poll"), then you can just as well use the process's sentinel instead
of polling.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-01-10 9:25 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-01-09 23:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
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.