* babel completion notification
@ 2014-03-17 20:33 Ken Mankoff
2014-03-17 21:05 ` Eric Schulte
0 siblings, 1 reply; 8+ messages in thread
From: Ken Mankoff @ 2014-03-17 20:33 UTC (permalink / raw)
To: Org-mode mailing list
I see from old emails to this list that asynchronous babel does not
exist and is non-trivial to implement. Until asynchronous babel
exists, it would be nice to at least be notified when long-running
tasks complete. Does anyone have advice how to set up a hook on babel
completion so that growl or some other system notification alerts,
perhaps only if the execution took more than x seconds?
Thanks,
-k.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-17 20:33 babel completion notification Ken Mankoff
@ 2014-03-17 21:05 ` Eric Schulte
2014-03-17 21:39 ` Ken Mankoff
0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-03-17 21:05 UTC (permalink / raw)
To: Ken Mankoff; +Cc: Org-mode mailing list
Hi Ken,
Ken Mankoff <mankoff@gmail.com> writes:
> I see from old emails to this list that asynchronous babel does not
> exist and is non-trivial to implement.
Yes, at least my initial attempts to implement this did not succeed (see
line 100 of ob-comint.el), and I haven't had the time to revisit the
issue. In actuality it may not be that much work to provide for
asynchronous evaluation (at least in most cases).
> Until asynchronous babel exists, it would be nice to at least be
> notified when long-running tasks complete. Does anyone have advice how
> to set up a hook on babel completion so that growl or some other
> system notification alerts, perhaps only if the execution took more
> than x seconds?
>
You can use the org-babel-after-execute-hook to run any action after a
code block finishes executing.
Best,
>
> Thanks,
>
> -k.
>
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-17 21:05 ` Eric Schulte
@ 2014-03-17 21:39 ` Ken Mankoff
2014-03-17 22:03 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Ken Mankoff @ 2014-03-17 21:39 UTC (permalink / raw)
To: Eric Schulte; +Cc: Org-mode mailing list
Hi Eric,
On 2014-03-17 at 17:05, Eric Schulte wrote:
> Ken Mankoff <mankoff@gmail.com> writes:
>
>> Until asynchronous babel exists, it would be nice to at least be
>> notified when long-running tasks complete. Does anyone have advice
>> how to set up a hook on babel completion so that growl or some
>> other system notification alerts, perhaps only if the execution
>> took more than x seconds?
>
> You can use the org-babel-after-execute-hook to run any action after a
> code block finishes executing.
Yes, and your reply makes me recall that :post works too, so I can
call a shell command "notifier" (or Growl) like this:
#+BEGIN_SRC python -n :results output :post (shell-command-to-string "notifier 'babel done'")
print "hello, world"
#+END_SRC
#+RESULTS:
Thanks,
-k.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-17 21:39 ` Ken Mankoff
@ 2014-03-17 22:03 ` Nick Dokos
2014-03-18 1:07 ` Eric Schulte
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2014-03-17 22:03 UTC (permalink / raw)
To: emacs-orgmode
Ken Mankoff <mankoff@gmail.com> writes:
> Hi Eric,
>
> On 2014-03-17 at 17:05, Eric Schulte wrote:
>> Ken Mankoff <mankoff@gmail.com> writes:
>>
>>> Until asynchronous babel exists, it would be nice to at least be
>>> notified when long-running tasks complete. Does anyone have advice
>>> how to set up a hook on babel completion so that growl or some
>>> other system notification alerts, perhaps only if the execution
>>> took more than x seconds?
>>
>> You can use the org-babel-after-execute-hook to run any action after a
>> code block finishes executing.
>
> Yes, and your reply makes me recall that :post works too, so I can
> call a shell command "notifier" (or Growl) like this:
>
> #+BEGIN_SRC python -n :results output :post (shell-command-to-string "notifier 'babel done'")
> print "hello, world"
> #+END_SRC
> #+RESULTS:
>
The :post method does not seem to work for me. With:
--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC sh :results output :post (shell-command-to-string "popup.py babel done")
sleep 10
echo DONE
#+END_SRC
--8<---------------cut here---------------end--------------->8---
(popup.py is my homemade notifier) I get the popup immediately and the
results after 10 seconds. The org-babel-after-execute-hook method
worked fine.
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-17 22:03 ` Nick Dokos
@ 2014-03-18 1:07 ` Eric Schulte
2014-03-18 2:44 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-03-18 1:07 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
Nick Dokos <ndokos@gmail.com> writes:
> Ken Mankoff <mankoff@gmail.com> writes:
>
>> Hi Eric,
>>
>> On 2014-03-17 at 17:05, Eric Schulte wrote:
>>> Ken Mankoff <mankoff@gmail.com> writes:
>>>
>>>> Until asynchronous babel exists, it would be nice to at least be
>>>> notified when long-running tasks complete. Does anyone have advice
>>>> how to set up a hook on babel completion so that growl or some
>>>> other system notification alerts, perhaps only if the execution
>>>> took more than x seconds?
>>>
>>> You can use the org-babel-after-execute-hook to run any action after a
>>> code block finishes executing.
>>
>> Yes, and your reply makes me recall that :post works too, so I can
>> call a shell command "notifier" (or Growl) like this:
>>
>> #+BEGIN_SRC python -n :results output :post (shell-command-to-string "notifier 'babel done'")
>> print "hello, world"
>> #+END_SRC
>> #+RESULTS:
>>
>
> The :post method does not seem to work for me. With:
>
> --8<---------------cut here---------------start------------->8---
> #+BEGIN_SRC sh :results output :post (shell-command-to-string "popup.py babel done")
> sleep 10
> echo DONE
> #+END_SRC
> --8<---------------cut here---------------end--------------->8---
>
> (popup.py is my homemade notifier)
Try adding `(lambda () (shell-command-to-string "popup.py babel done"))'
to your `org-babel-after-execute-hook'.
>
> I get the popup immediately and the results after 10 seconds. The
> org-babel-after-execute-hook method worked fine.
>
That is probably because the elisp form in the :post value is executed
at header-argument parse time before the code block is executed. If
instead your use a code block name as your post header argument it will
only be evaluated after the code block finishes.
Best,
>
> Nick
>
>
>
>
>
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-18 1:07 ` Eric Schulte
@ 2014-03-18 2:44 ` Nick Dokos
2014-03-18 14:32 ` Eric Schulte
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2014-03-18 2:44 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <schulte.eric@gmail.com> writes:
> Nick Dokos <ndokos@gmail.com> writes:
>
>> (popup.py is my homemade notifier)
>
> Try adding `(lambda () (shell-command-to-string "popup.py babel done"))'
> to your `org-babel-after-execute-hook'.
>
>>
>> I get the popup immediately and the results after 10 seconds. The
>> org-babel-after-execute-hook method worked fine.
>>
Yes, as I said, the hook worked fine :-), although the function would
have to be munged so that the notification doesn't pop up
indiscriminately after every evaluation.
>
> That is probably because the elisp form in the :post value is executed
> at header-argument parse time before the code block is executed. If
> instead your use a code block name as your post header argument it will
> only be evaluated after the code block finishes.
>
Thanks - that's good to know: the fact that it can be applied
selectively to certain code blocks does make it a much better solution
than the hook.
However, there is a problem:
--8<---------------cut here---------------start------------->8---
#+name: notify
#+BEGIN_SRC emacs-lisp :results none
(shell-command "popup.py DONE")
#+END_SRC
#+name: long-running
#+BEGIN_SRC shell :results output :post notify
sleep 5
echo DONE
#+END_SRC
#+RESULTS: long-running
: nil
--8<---------------cut here---------------end--------------->8---
The result seems to be the result of the notify block, not the
long-running one.
--
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-18 2:44 ` Nick Dokos
@ 2014-03-18 14:32 ` Eric Schulte
2014-03-19 2:00 ` Grant Rettke
0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-03-18 14:32 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
> However, there is a problem:
>
> --8<---------------cut here---------------start------------->8---
> #+name: notify
> #+BEGIN_SRC emacs-lisp :results none
> (shell-command "popup.py DONE")
> #+END_SRC
>
> #+name: long-running
> #+BEGIN_SRC shell :results output :post notify
> sleep 5
> echo DONE
> #+END_SRC
>
> #+RESULTS: long-running
> : nil
> --8<---------------cut here---------------end--------------->8---
>
> The result seems to be the result of the notify block, not the
> long-running one.
Yes, that's how post blocks are supposed to work, they're normally used
to post-process results. You should add a variable to the post block
and have it return that variable, e.g.,
#+name: notify
#+begin_src emacs-lisp :var data=""
(shell-command "popup.py DONE")
data
#+end_src
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: babel completion notification
2014-03-18 14:32 ` Eric Schulte
@ 2014-03-19 2:00 ` Grant Rettke
0 siblings, 0 replies; 8+ messages in thread
From: Grant Rettke @ 2014-03-19 2:00 UTC (permalink / raw)
To: Eric Schulte; +Cc: Nick Dokos, emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]
The other options are prettier and the hook is more flexible; I had only
cared about
tangling though so I set this:
(defadvice org-babel-tangle (before org-babel-tangle-before activate)
(message (concat "org-babel-tangle BEFORE: <"
(format-time-string "%Y-%m-%dT%T%z")
">")))
(defadvice org-babel-tangle (after org-babel-tangle-after activate)
(message (concat "org-babel-tangle AFTER: <"
(format-time-string "%Y-%m-%dT%T%z")
">")))
For some reason couldn't get around advice working here, it was just never
run.
On Tue, Mar 18, 2014 at 9:32 AM, Eric Schulte <schulte.eric@gmail.com>wrote:
> > However, there is a problem:
> >
> > --8<---------------cut here---------------start------------->8---
> > #+name: notify
> > #+BEGIN_SRC emacs-lisp :results none
> > (shell-command "popup.py DONE")
> > #+END_SRC
> >
> > #+name: long-running
> > #+BEGIN_SRC shell :results output :post notify
> > sleep 5
> > echo DONE
> > #+END_SRC
> >
> > #+RESULTS: long-running
> > : nil
> > --8<---------------cut here---------------end--------------->8---
> >
> > The result seems to be the result of the notify block, not the
> > long-running one.
>
> Yes, that's how post blocks are supposed to work, they're normally used
> to post-process results. You should add a variable to the post block
> and have it return that variable, e.g.,
>
> #+name: notify
> #+begin_src emacs-lisp :var data=""
> (shell-command "popup.py DONE")
> data
> #+end_src
>
> --
> Eric Schulte
> https://cs.unm.edu/~eschulte
> PGP: 0x614CA05D
>
>
--
Grant Rettke | ACM, AMA, COG, IEEE
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson
[-- Attachment #2: Type: text/html, Size: 2971 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-03-19 2:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-17 20:33 babel completion notification Ken Mankoff
2014-03-17 21:05 ` Eric Schulte
2014-03-17 21:39 ` Ken Mankoff
2014-03-17 22:03 ` Nick Dokos
2014-03-18 1:07 ` Eric Schulte
2014-03-18 2:44 ` Nick Dokos
2014-03-18 14:32 ` Eric Schulte
2014-03-19 2:00 ` Grant Rettke
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.