* progress indicator for code blocks?
@ 2014-08-30 13:02 John Kitchin
2014-08-31 12:03 ` John Kitchin
0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2014-08-30 13:02 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
I am using org-mode in a class, and some students wondered if it was
possible for there to be a progress bar of some kind while a code block
is running. Right now Emacs just appears to lock up and there is no
indication anything is happening, especially the first time we run a
python block.
I found make-progress-reporter and tried something like this::
#+BEGIN_SRC emacs-lisp
(defadvice org-babel-execute-src-block (around progress nil activate)
(let ((pr (make-progress-reporter "Running")))
ad-do-it
(progress-reporter-done pr)))
#+END_SRC
but there is no way to update it, so it doesn't quite do anything
useful.
What I would really like is an hourglass or some spinning thing. Does
anyone know how to get that (in a cross-platform way)?
--
-----------------------------------
John Kitchin
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: progress indicator for code blocks?
2014-08-30 13:02 progress indicator for code blocks? John Kitchin
@ 2014-08-31 12:03 ` John Kitchin
2014-09-02 9:18 ` Rainer M Krug
0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2014-08-31 12:03 UTC (permalink / raw)
To: emacs-orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
I am currently using this bit of advice to change the color of code
blocks while they are being executed so there is a visual hint something
is happening.
;; give us some hint we are running
(defadvice org-babel-execute-src-block (around progress nil activate)
(set-face-attribute
'org-block-background nil :background "LightSteelBlue")
(message "Running your code block")
ad-do-it
(set-face-attribute 'org-block-background nil :background "gray")
(message "Done with code block"))
> Hi all,
> I am using org-mode in a class, and some students wondered if it was
> possible for there to be a progress bar of some kind while a code block
> is running. Right now Emacs just appears to lock up and there is no
> indication anything is happening, especially the first time we run a
> python block.
>
> I found make-progress-reporter and tried something like this::
>
> #+BEGIN_SRC emacs-lisp
> (defadvice org-babel-execute-src-block (around progress nil activate)
> (let ((pr (make-progress-reporter "Running")))
> ad-do-it
> (progress-reporter-done pr)))
> #+END_SRC
>
> but there is no way to update it, so it doesn't quite do anything
> useful.
>
> What I would really like is an hourglass or some spinning thing. Does
> anyone know how to get that (in a cross-platform way)?
--
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: progress indicator for code blocks?
2014-08-31 12:03 ` John Kitchin
@ 2014-09-02 9:18 ` Rainer M Krug
2014-09-02 14:19 ` John Kitchin
0 siblings, 1 reply; 5+ messages in thread
From: Rainer M Krug @ 2014-09-02 9:18 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]
Thanks for this snippet - I think something along these lines should be
included into org out-of-the-box.
There are many cases where I simply use C-g to go back to emacs while
the evaluation is still running - would your snippet still work?
Rainer
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> I am currently using this bit of advice to change the color of code
> blocks while they are being executed so there is a visual hint something
> is happening.
>
> ;; give us some hint we are running
> (defadvice org-babel-execute-src-block (around progress nil activate)
> (set-face-attribute
> 'org-block-background nil :background "LightSteelBlue")
> (message "Running your code block")
> ad-do-it
> (set-face-attribute 'org-block-background nil :background "gray")
> (message "Done with code block"))
>
>
>> Hi all,
>> I am using org-mode in a class, and some students wondered if it was
>> possible for there to be a progress bar of some kind while a code block
>> is running. Right now Emacs just appears to lock up and there is no
>> indication anything is happening, especially the first time we run a
>> python block.
>>
>> I found make-progress-reporter and tried something like this::
>>
>> #+BEGIN_SRC emacs-lisp
>> (defadvice org-babel-execute-src-block (around progress nil activate)
>> (let ((pr (make-progress-reporter "Running")))
>> ad-do-it
>> (progress-reporter-done pr)))
>> #+END_SRC
>>
>> but there is no way to update it, so it doesn't quite do anything
>> useful.
>>
>> What I would really like is an hourglass or some spinning thing. Does
>> anyone know how to get that (in a cross-platform way)?
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: progress indicator for code blocks?
2014-09-02 9:18 ` Rainer M Krug
@ 2014-09-02 14:19 ` John Kitchin
2014-09-03 4:55 ` Nick Dokos
0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2014-09-02 14:19 UTC (permalink / raw)
To: Rainer M Krug; +Cc: emacs-orgmode
No, it does not seem to work for me. C-g kills the current evaluation
for me.
Rainer M Krug <Rainer@krugs.de> writes:
> Thanks for this snippet - I think something along these lines should be
> included into org out-of-the-box.
>
> There are many cases where I simply use C-g to go back to emacs while
> the evaluation is still running - would your snippet still work?
>
> Rainer
>
>
> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>>
>> I am currently using this bit of advice to change the color of code
>> blocks while they are being executed so there is a visual hint something
>> is happening.
>>
>> ;; give us some hint we are running
>> (defadvice org-babel-execute-src-block (around progress nil activate)
>> (set-face-attribute
>> 'org-block-background nil :background "LightSteelBlue")
>> (message "Running your code block")
>> ad-do-it
>> (set-face-attribute 'org-block-background nil :background "gray")
>> (message "Done with code block"))
>>
>>
>>> Hi all,
>>> I am using org-mode in a class, and some students wondered if it was
>>> possible for there to be a progress bar of some kind while a code block
>>> is running. Right now Emacs just appears to lock up and there is no
>>> indication anything is happening, especially the first time we run a
>>> python block.
>>>
>>> I found make-progress-reporter and tried something like this::
>>>
>>> #+BEGIN_SRC emacs-lisp
>>> (defadvice org-babel-execute-src-block (around progress nil activate)
>>> (let ((pr (make-progress-reporter "Running")))
>>> ad-do-it
>>> (progress-reporter-done pr)))
>>> #+END_SRC
>>>
>>> but there is no way to update it, so it doesn't quite do anything
>>> useful.
>>>
>>> What I would really like is an hourglass or some spinning thing. Does
>>> anyone know how to get that (in a cross-platform way)?
--
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: progress indicator for code blocks?
2014-09-02 14:19 ` John Kitchin
@ 2014-09-03 4:55 ` Nick Dokos
0 siblings, 0 replies; 5+ messages in thread
From: Nick Dokos @ 2014-09-03 4:55 UTC (permalink / raw)
To: emacs-orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> No, it does not seem to work for me. C-g kills the current evaluation
> for me.
>
> Rainer M Krug <Rainer@krugs.de> writes:
>
>> Thanks for this snippet - I think something along these lines should be
>> included into org out-of-the-box.
>>
>> There are many cases where I simply use C-g to go back to emacs while
>> the evaluation is still running - would your snippet still work?
>>
>> Rainer
>>
>>
>> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>>
>>> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>>>
>>> I am currently using this bit of advice to change the color of code
>>> blocks while they are being executed so there is a visual hint something
>>> is happening.
>>>
>>> ;; give us some hint we are running
>>> (defadvice org-babel-execute-src-block (around progress nil activate)
>>> (set-face-attribute
>>> 'org-block-background nil :background "LightSteelBlue")
>>> (message "Running your code block")
>>> ad-do-it
>>> (set-face-attribute 'org-block-background nil :background "gray")
>>> (message "Done with code block"))
>>>
>>>
>>>> Hi all,
>>>> I am using org-mode in a class, and some students wondered if it was
>>>> possible for there to be a progress bar of some kind while a code block
>>>> is running. Right now Emacs just appears to lock up and there is no
>>>> indication anything is happening, especially the first time we run a
>>>> python block.
>>>>
>>>> I found make-progress-reporter and tried something like this::
>>>>
>>>> #+BEGIN_SRC emacs-lisp
>>>> (defadvice org-babel-execute-src-block (around progress nil activate)
>>>> (let ((pr (make-progress-reporter "Running")))
>>>> ad-do-it
>>>> (progress-reporter-done pr)))
>>>> #+END_SRC
>>>>
>>>> but there is no way to update it, so it doesn't quite do anything
>>>> useful.
>>>>
>>>> What I would really like is an hourglass or some spinning thing. Does
>>>> anyone know how to get that (in a cross-platform way)?
Until emacs becomes multi-threaded, this will be a difficult thing
to do. You can create two asynchronous processes, one to do the
computation and the other to do the spinning: you wait on the first one
and when it finishes, you kill the second, e.g.
#+BEGIN_SRC emacs-lisp
(defvar gq nil)
(defun foo ()
(let* ((p (start-process "computation" "foo" "sleep" "10"))
(sentinel (lambda (p event) (delete-process gq))))
(setq gq (start-process "spinner" "bar" "spin-the-bottle"))
(set-process-sentinel p sentinel))
)
(foo)
#+END_SRC
where spin-the-bottle is a program that pops up a spinner[fn:1].
Or you can use coroutines: the computation "thread" yields every second
(or half-second or whatever) to the spinner "thread" which advances the
spinner (e.g. with progress-reporter-update) and yields control
back to the computation "thread". There is even a coroutine.el but
I have no idea how to use it or how well it works.
The first one works better if the computation is done externally (if
it's done by a lisp function, then you'll have to write a script that
starts another emacs instance to call the function). The second one
might work better if the computation is done by a lisp function.
In any case, things get complicated very quickly, so most people don't
bother.
Footnotes:
[fn:1] Here's my poor-man's "spinner":
--8<---------------cut here---------------start------------->8---
#!/usr/bin/env python
import gtk
import sys
text = 'Spinning'
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO, gtk.BUTTONS_NONE,
text)
dialog.run()
dialog.destroy()
--8<---------------cut here---------------end--------------->8---
--
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-03 4:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-30 13:02 progress indicator for code blocks? John Kitchin
2014-08-31 12:03 ` John Kitchin
2014-09-02 9:18 ` Rainer M Krug
2014-09-02 14:19 ` John Kitchin
2014-09-03 4:55 ` Nick Dokos
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.