emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] automatically add debugging output
@ 2012-11-04  0:20 Andreas Leha
  2012-11-04  0:52 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Leha @ 2012-11-04  0:20 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

is it possible to have babel add debugging lines during execution?

Consider this example with an enabled debug property:
#+PROPERTY: session *R*
#+PROPERTY: debug yes

* Some code blocks
#+name: codeA
#+begin_src R
  sum(1)
#+end_src

#+name: codeB
#+begin_src R
  sum(2)
#+end_src

When executing the subtree with C-c C-v s, for example, I'd like babel to
automatically add some print() statements, so that executed is
,----
| print("entering codeA")
| sum(1)
| print("leaving codeA")
|
| print("entering codeB")
| sum(2)
| print("leaving codeB")
`----

As there is a print statement in most languages, this should be possible
quite universal for any language.



Also handy would be the insertion of breakpoints
(maybe #+PROPERTY: interactive-debug yes)
In R that would lead to the execution of:
,----
| browser()
| sum(1)
|
| browser()
| sum(2)
`----


Are these things possible?
(Or better question:  How are these things possible?)


Regards,
Andreas

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [babel] automatically add debugging output
  2012-11-04  0:20 [babel] automatically add debugging output Andreas Leha
@ 2012-11-04  0:52 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2012-11-04  0:52 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi all,
>
> is it possible to have babel add debugging lines during execution?
>
> Consider this example with an enabled debug property:
> #+PROPERTY: session *R*
> #+PROPERTY: debug yes
>
> * Some code blocks
> #+name: codeA
> #+begin_src R
>   sum(1)
> #+end_src
>
> #+name: codeB
> #+begin_src R
>   sum(2)
> #+end_src
>
> When executing the subtree with C-c C-v s, for example, I'd like babel to
> automatically add some print() statements, so that executed is
> ,----
> | print("entering codeA")
> | sum(1)
> | print("leaving codeA")
> |
> | print("entering codeB")
> | sum(2)
> | print("leaving codeB")
> `----
>
> As there is a print statement in most languages, this should be possible
> quite universal for any language.
>
>
>
> Also handy would be the insertion of breakpoints
> (maybe #+PROPERTY: interactive-debug yes)
> In R that would lead to the execution of:
> ,----
> | browser()
> | sum(1)
> |
> | browser()
> | sum(2)
> `----
>
>
> Are these things possible?

Certainly, I'd pick a language you care about (I'm guessing python), and
take a shot at an implementation for that language.  If this proves
useful then these header arguments can be ported to other languages as
there is demand and developer time supply.

> 
> (Or better question: How are these things possible?)
>

Take a look at the ob-python.el.  Find where
`org-babel-expand-body:generic' is called, you will want to replace
these calls with `org-babel-expand-body:python' and then write this new
function s.t. it calls `org-babel-expand-body:generic' and does the
optional debug wrapping if the debug param is present.

As you said this should be fairly straightforward.  If you do plan to
add this feature please be prepared to write some documentation too. :)

Thanks!

>
>
> Regards,
> Andreas
>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-04  0:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-04  0:20 [babel] automatically add debugging output Andreas Leha
2012-11-04  0:52 ` Eric Schulte

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).