From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: babel completion notification Date: Mon, 17 Mar 2014 19:07:47 -0600 Message-ID: <87eh20wbz0.fsf@gmail.com> References: <87iorcwn6g.fsf@gmail.com> <87lhw8wkhz.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPiXY-0002iR-UA for emacs-orgmode@gnu.org; Mon, 17 Mar 2014 21:10:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPiXT-0006Jg-Ri for emacs-orgmode@gnu.org; Mon, 17 Mar 2014 21:10:00 -0400 Received: from mail-pb0-x231.google.com ([2607:f8b0:400e:c01::231]:34037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPiXT-0006Il-KT for emacs-orgmode@gnu.org; Mon, 17 Mar 2014 21:09:55 -0400 Received: by mail-pb0-f49.google.com with SMTP id jt11so6422721pbb.22 for ; Mon, 17 Mar 2014 18:09:54 -0700 (PDT) In-Reply-To: <87lhw8wkhz.fsf@alphaville.bos.redhat.com> (Nick Dokos's message of "Mon, 17 Mar 2014 18:03:36 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nick Dokos Cc: emacs-orgmode@gnu.org Nick Dokos writes: > Ken Mankoff writes: > >> Hi Eric, >> >> On 2014-03-17 at 17:05, Eric Schulte wrote: >>> Ken Mankoff 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