emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] feature request: debug messages
@ 2013-07-03 19:58 Andreas Leha
  2013-07-03 22:55 ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-03 19:58 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I would love to see messages like 'entering block foo...' and
'...leaving block foo' printed to my R console.  This would be very
handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
and some lengthy ones.

I know that
(1) I could implement that myself at in the source blocks.  But I would
    love if orgmode did that for me
(2) Such messages are already printed to the emacs *Messages* buffer.
    But that buffer might not be visible and I can not switch to it,
    without interrupting the evaluation.  Anyway it would be much nicer
    to see that output together with the other output, that my code
    generates.


In essence it would be very helpful, if there was a variable
org-babel-print-debug-messages (or org-babel-debug-level...) which if
non-nil would cause that messages to be printed.  Or is there somewhere
already?

Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-03 19:58 [babel] feature request: debug messages Andreas Leha
@ 2013-07-03 22:55 ` Eric Schulte
  2013-07-04  6:42   ` Andreas Leha
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Schulte @ 2013-07-03 22:55 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

Hi Andreas,

This should be easy to turn on or off using the newly introduced
:prologue and :epilogue header arguments.  See the manual and the
following example.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: r-debug.org --]
[-- Type: text/x-org, Size: 739 bytes --]

#+Title: debug messages
#+Property: session *R*
#+Property: prologue (format "print(\"entering %s\")" (get-current-name))

An elisp block to simplify the =:prologue= definition.
#+begin_src emacs-lisp
  (defun get-current-name ()
    (save-excursion
      (goto-char org-babel-current-src-block-location)
      (while (and (forward-line -1)
                  (looking-at org-babel-multi-line-header-regexp)))
      (when (looking-at org-babel-src-name-w-name-regexp)
        (org-no-properties (match-string 3)))))
#+end_src

Two blocks with simple assignments.

#+name: block-1
#+begin_src R
  x <- 2 + 2
#+end_src

#+name: block-2
#+begin_src R
  y <- x + x
#+end_src

Execute the whole buffer =C-c C-v b= to see the prologue in action.

[-- Attachment #3: Type: text/plain, Size: 1037 bytes --]


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

> Hi all,
>
> I would love to see messages like 'entering block foo...' and
> '...leaving block foo' printed to my R console.  This would be very
> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
> and some lengthy ones.
>
> I know that
> (1) I could implement that myself at in the source blocks.  But I would
>     love if orgmode did that for me
> (2) Such messages are already printed to the emacs *Messages* buffer.
>     But that buffer might not be visible and I can not switch to it,
>     without interrupting the evaluation.  Anyway it would be much nicer
>     to see that output together with the other output, that my code
>     generates.
>
>
> In essence it would be very helpful, if there was a variable
> org-babel-print-debug-messages (or org-babel-debug-level...) which if
> non-nil would cause that messages to be printed.  Or is there somewhere
> already?
>
> Regards,
> Andreas
>
>
>
>

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

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

* Re: [babel] feature request: debug messages
  2013-07-03 22:55 ` Eric Schulte
@ 2013-07-04  6:42   ` Andreas Leha
  2013-07-04 14:48     ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-04  6:42 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,


Eric Schulte <schulte.eric@gmail.com> writes:

> Hi Andreas,
>
> This should be easy to turn on or off using the newly introduced
> :prologue and :epilogue header arguments.  See the manual and the
> following example.
>
> #+Title: debug messages
> #+Property: session *R*
> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>
> An elisp block to simplify the =:prologue= definition.
> #+begin_src emacs-lisp
>   (defun get-current-name ()
>     (save-excursion
>       (goto-char org-babel-current-src-block-location)
>       (while (and (forward-line -1)
>                   (looking-at org-babel-multi-line-header-regexp)))
>       (when (looking-at org-babel-src-name-w-name-regexp)
>         (org-no-properties (match-string 3)))))
> #+end_src
>
> Two blocks with simple assignments.
>
> #+name: block-1
> #+begin_src R
>   x <- 2 + 2
> #+end_src
>
> #+name: block-2
> #+begin_src R
>   y <- x + x
> #+end_src
>
> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi all,
>>
>> I would love to see messages like 'entering block foo...' and
>> '...leaving block foo' printed to my R console.  This would be very
>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>> and some lengthy ones.
>>
>> I know that
>> (1) I could implement that myself at in the source blocks.  But I would
>>     love if orgmode did that for me
>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>     But that buffer might not be visible and I can not switch to it,
>>     without interrupting the evaluation.  Anyway it would be much nicer
>>     to see that output together with the other output, that my code
>>     generates.
>>
>>
>> In essence it would be very helpful, if there was a variable
>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>> non-nil would cause that messages to be printed.  Or is there somewhere
>> already?
>>
>> Regards,
>> Andreas
>>
>>
>>
>>


thanks for the quick answer!  The :prologue and :epilogue header
arguments have indeed slipped my attention and they look really
interesting!  I see, that they are documented, but somehow, they seem to
not get their headline and TOC entry?

I have three problems with your example, though:
1) It does not run
2) It does not work
3) It won't be usable for 'my' epilogue, correct?
;-)

1)
It does not run, because org tries to do the prologue also on the
emacs-lisp block defining the function of the prologue.  So, I get
"format: Symbol's function definition is void: get-current-name"
I changed the #+property line to
#+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
which solved that problem.

2)
But still it does not work: This is what I get in my *R* buffer:
--8<---------------cut here---------------start------------->8---

R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
Tippen Sie 'license()' or 'licence()' für Details dazu.

R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
Tippen Sie 'contributors()' für mehr Information und 'citation()',
um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.

Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
Tippen Sie 'q()', um R zu verlassen.

[1] "C"
filehash: Simple key-value database (2.2-1 2012-03-12)
tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
  LaTeX found in the PATH using the command: pdflatex
  XeLaTeX found in the PATH using the command: xelatex
  LuaLaTeX found in the PATH using the command: lualatex
> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>
> > 
> > 
--8<---------------cut here---------------end--------------->8---

I tried it with
- Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
- ess-version : 13.05-1 [<unknown>]
- emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
--8<---------------cut here---------------start------------->8---
(add-to-list 'load-path
                  "~/local/emacs/org-mode-install/lisp")
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))

(add-to-list 'load-path "~/local/emacs/ess/lisp")
(require 'ess-site)

(setq org-babel-load-languages '((emacs-lisp . t)
				 (R . t)
				 (sh . t)))
--8<---------------cut here---------------end--------------->8---

What am I missing?  (BTW: If I put a print("sth") into the R blocks
myself, I see that printed)


3)
Even if it did run, I guess putting sth similar for 'leaving code block
foo' into the epilogue would spoil the return value of my src blocks,
correct?
Is there some work-around?



Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-04  6:42   ` Andreas Leha
@ 2013-07-04 14:48     ` Eric Schulte
  2013-07-06 16:00       ` Andreas Leha
  2013-07-20 15:11       ` Andreas Leha
  0 siblings, 2 replies; 16+ messages in thread
From: Eric Schulte @ 2013-07-04 14:48 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3175 bytes --]

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

> Hi Eric,
>
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> Hi Andreas,
>>
>> This should be easy to turn on or off using the newly introduced
>> :prologue and :epilogue header arguments.  See the manual and the
>> following example.
>>
>> #+Title: debug messages
>> #+Property: session *R*
>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>
>> An elisp block to simplify the =:prologue= definition.
>> #+begin_src emacs-lisp
>>   (defun get-current-name ()
>>     (save-excursion
>>       (goto-char org-babel-current-src-block-location)
>>       (while (and (forward-line -1)
>>                   (looking-at org-babel-multi-line-header-regexp)))
>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>         (org-no-properties (match-string 3)))))
>> #+end_src
>>
>> Two blocks with simple assignments.
>>
>> #+name: block-1
>> #+begin_src R
>>   x <- 2 + 2
>> #+end_src
>>
>> #+name: block-2
>> #+begin_src R
>>   y <- x + x
>> #+end_src
>>
>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi all,
>>>
>>> I would love to see messages like 'entering block foo...' and
>>> '...leaving block foo' printed to my R console.  This would be very
>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>> and some lengthy ones.
>>>
>>> I know that
>>> (1) I could implement that myself at in the source blocks.  But I would
>>>     love if orgmode did that for me
>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>     But that buffer might not be visible and I can not switch to it,
>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>     to see that output together with the other output, that my code
>>>     generates.
>>>
>>>
>>> In essence it would be very helpful, if there was a variable
>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>> already?
>>>
>>> Regards,
>>> Andreas
>>>
>>>
>>>
>>>
>
>
> thanks for the quick answer!  The :prologue and :epilogue header
> arguments have indeed slipped my attention and they look really
> interesting!  I see, that they are documented, but somehow, they seem to
> not get their headline and TOC entry?
>
> I have three problems with your example, though:
> 1) It does not run
> 2) It does not work
> 3) It won't be usable for 'my' epilogue, correct?
> ;-)
>

Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
when working through the example I sent, but then I forgot to commit
that support to Org-mode.  I've just pushed up that commit, and
re-worked my example file to avoid the issue of prologue being applied
to the emacs-lisp code block (using the very nice and also new
language-specific PROPERTY header arguments).

Finally, I don't use epilogues in the example because (as the last thing
evaluated) they would override the code block results.

Hopefully the following:
1. will run
2. will work
3. will be usable

Cheers,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: r-debug.org --]
[-- Type: text/x-org, Size: 807 bytes --]

#+Title: debug messages
#+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))

An elisp block to simplify the =:prologue= definition.
#+begin_src emacs-lisp :results silent
  (defun get-current-name ()
    (save-excursion
      (goto-char org-babel-current-src-block-location)
      (while (and (forward-line -1)
                  (looking-at org-babel-multi-line-header-regexp)))
      (when (looking-at org-babel-src-name-w-name-regexp)
        (org-no-properties (match-string 3)))))
#+end_src

Two blocks with simple assignments.

#+name: block-1
#+begin_src R
  x <- 2 + 2
#+end_src

#+RESULTS: block-1
: 4

#+name: block-2
#+begin_src R
  y <- x + x
#+end_src

#+RESULTS: block-2
: 8

Execute the whole buffer =C-c C-v b= to see the prologue in action.

[-- Attachment #3: Type: text/plain, Size: 2812 bytes --]


>
> 1)
> It does not run, because org tries to do the prologue also on the
> emacs-lisp block defining the function of the prologue.  So, I get
> "format: Symbol's function definition is void: get-current-name"
> I changed the #+property line to
> #+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
> which solved that problem.
>
> 2)
> But still it does not work: This is what I get in my *R* buffer:
> --8<---------------cut here---------------start------------->8---
>
> R version 3.0.1 (2013-05-16) -- "Good Sport"
> Copyright (C) 2013 The R Foundation for Statistical Computing
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
> Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
> Tippen Sie 'license()' or 'licence()' für Details dazu.
>
> R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
> Tippen Sie 'contributors()' für mehr Information und 'citation()',
> um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
>
> Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
> 'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
> Tippen Sie 'q()', um R zu verlassen.
>
> [1] "C"
> filehash: Simple key-value database (2.2-1 2012-03-12)
> tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
>   LaTeX found in the PATH using the command: pdflatex
>   XeLaTeX found in the PATH using the command: xelatex
>   LuaLaTeX found in the PATH using the command: lualatex
>> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>>
>> > 
>> > 
> --8<---------------cut here---------------end--------------->8---
>
> I tried it with
> - Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
> - ess-version : 13.05-1 [<unknown>]
> - emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
> --8<---------------cut here---------------start------------->8---
> (add-to-list 'load-path
>                   "~/local/emacs/org-mode-install/lisp")
> (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
>
> (add-to-list 'load-path "~/local/emacs/ess/lisp")
> (require 'ess-site)
>
> (setq org-babel-load-languages '((emacs-lisp . t)
> 				 (R . t)
> 				 (sh . t)))
> --8<---------------cut here---------------end--------------->8---
>
> What am I missing?  (BTW: If I put a print("sth") into the R blocks
> myself, I see that printed)
>
>
> 3)
> Even if it did run, I guess putting sth similar for 'leaving code block
> foo' into the epilogue would spoil the return value of my src blocks,
> correct?
> Is there some work-around?
>
>
>
> Regards,
> Andreas
>
>
>

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

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

* Re: [babel] feature request: debug messages
  2013-07-04 14:48     ` Eric Schulte
@ 2013-07-06 16:00       ` Andreas Leha
  2013-07-07 17:08         ` Eric Schulte
  2013-07-20 15:11       ` Andreas Leha
  1 sibling, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-06 16:00 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric Schulte <schulte.eric@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Eric,
>>
>>
>> Eric Schulte <schulte.eric@gmail.com> writes:
>>
>>> Hi Andreas,
>>>
>>> This should be easy to turn on or off using the newly introduced
>>> :prologue and :epilogue header arguments.  See the manual and the
>>> following example.
>>>
>>> #+Title: debug messages
>>> #+Property: session *R*
>>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>>
>>> An elisp block to simplify the =:prologue= definition.
>>> #+begin_src emacs-lisp
>>>   (defun get-current-name ()
>>>     (save-excursion
>>>       (goto-char org-babel-current-src-block-location)
>>>       (while (and (forward-line -1)
>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>         (org-no-properties (match-string 3)))))
>>> #+end_src
>>>
>>> Two blocks with simple assignments.
>>>
>>> #+name: block-1
>>> #+begin_src R
>>>   x <- 2 + 2
>>> #+end_src
>>>
>>> #+name: block-2
>>> #+begin_src R
>>>   y <- x + x
>>> #+end_src
>>>
>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi all,
>>>>
>>>> I would love to see messages like 'entering block foo...' and
>>>> '...leaving block foo' printed to my R console.  This would be very
>>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>>> and some lengthy ones.
>>>>
>>>> I know that
>>>> (1) I could implement that myself at in the source blocks.  But I would
>>>>     love if orgmode did that for me
>>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>>     But that buffer might not be visible and I can not switch to it,
>>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>>     to see that output together with the other output, that my code
>>>>     generates.
>>>>
>>>>
>>>> In essence it would be very helpful, if there was a variable
>>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>>> already?
>>>>
>>>> Regards,
>>>> Andreas
>>>>
>>>>
>>>>
>>>>
>>
>>
>> thanks for the quick answer!  The :prologue and :epilogue header
>> arguments have indeed slipped my attention and they look really
>> interesting!  I see, that they are documented, but somehow, they seem to
>> not get their headline and TOC entry?
>>
>> I have three problems with your example, though:
>> 1) It does not run
>> 2) It does not work
>> 3) It won't be usable for 'my' epilogue, correct?
>> ;-)
>>
>
> Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
> when working through the example I sent, but then I forgot to commit
> that support to Org-mode.  I've just pushed up that commit, and

Indeed, that fixed it, now it works.

> re-worked my example file to avoid the issue of prologue being applied
> to the emacs-lisp code block (using the very nice and also new
> language-specific PROPERTY header arguments).

Thanks.  So, I did the right thing here.

>
> Finally, I don't use epilogues in the example because (as the last thing
> evaluated) they would override the code block results.

Ok.  As I thought.  No "leaving code block" message, then.


>
> Hopefully the following:
> 1. will run
> 2. will work
> 3. will be usable

Yes.
Yes.
Yes.

I still believe, that there is a bug in the manual, where :epilogue
and :prologue are described.

Tanks a lot for your help and that really nice feature!

Cheers,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-06 16:00       ` Andreas Leha
@ 2013-07-07 17:08         ` Eric Schulte
  2013-07-07 19:24           ` Andreas Leha
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Schulte @ 2013-07-07 17:08 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

>>
>> Hopefully the following:
>> 1. will run
>> 2. will work
>> 3. will be usable
>
> Yes.
> Yes.
> Yes.
>

Great^3

>
> I still believe, that there is a bug in the manual, where :epilogue
> and :prologue are described.
>

Could you elaborate?

>
> Tanks a lot for your help and that really nice feature!
>

Happy to help,

>
> Cheers,
> Andreas
>
>

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

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

* Re: [babel] feature request: debug messages
  2013-07-07 17:08         ` Eric Schulte
@ 2013-07-07 19:24           ` Andreas Leha
  2013-07-08  2:03             ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-07 19:24 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric Schulte <schulte.eric@gmail.com> writes:

[...]

>>
>> I still believe, that there is a bug in the manual, where :epilogue
>> and :prologue are described.
>>
>
> Could you elaborate?
>


In my build I get the sections on :epilogue and :prologue unnumbered.
They are also not present present in the TOC.

I guess it should be:
14.8.2.25 :post
14.8.2.26 :prologue
14.8.2.27 :epilogue

Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-07 19:24           ` Andreas Leha
@ 2013-07-08  2:03             ` Eric Schulte
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Schulte @ 2013-07-08  2:03 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

>
> In my build I get the sections on :epilogue and :prologue unnumbered.
> They are also not present present in the TOC.
>
> I guess it should be:
> 14.8.2.25 :post
> 14.8.2.26 :prologue
> 14.8.2.27 :epilogue
>

Oh, I had to open the HTML version of the documentation to see what you
mean, but you're right; I forgot to add subsection lines for these
header arguments.

This should be fixed now, thanks for the report!

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

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

* Re: [babel] feature request: debug messages
  2013-07-04 14:48     ` Eric Schulte
  2013-07-06 16:00       ` Andreas Leha
@ 2013-07-20 15:11       ` Andreas Leha
  2013-07-20 15:24         ` Andreas Leha
  1 sibling, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-20 15:11 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,


Eric Schulte <schulte.eric@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Eric,
>>
>>
>> Eric Schulte <schulte.eric@gmail.com> writes:
>>
>>> Hi Andreas,
>>>
>>> This should be easy to turn on or off using the newly introduced
>>> :prologue and :epilogue header arguments.  See the manual and the
>>> following example.
>>>
>>> #+Title: debug messages
>>> #+Property: session *R*
>>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>>
>>> An elisp block to simplify the =:prologue= definition.
>>> #+begin_src emacs-lisp
>>>   (defun get-current-name ()
>>>     (save-excursion
>>>       (goto-char org-babel-current-src-block-location)
>>>       (while (and (forward-line -1)
>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>         (org-no-properties (match-string 3)))))
>>> #+end_src
>>>
>>> Two blocks with simple assignments.
>>>
>>> #+name: block-1
>>> #+begin_src R
>>>   x <- 2 + 2
>>> #+end_src
>>>
>>> #+name: block-2
>>> #+begin_src R
>>>   y <- x + x
>>> #+end_src
>>>
>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi all,
>>>>
>>>> I would love to see messages like 'entering block foo...' and
>>>> '...leaving block foo' printed to my R console.  This would be very
>>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>>> and some lengthy ones.
>>>>
>>>> I know that
>>>> (1) I could implement that myself at in the source blocks.  But I would
>>>>     love if orgmode did that for me
>>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>>     But that buffer might not be visible and I can not switch to it,
>>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>>     to see that output together with the other output, that my code
>>>>     generates.
>>>>
>>>>
>>>> In essence it would be very helpful, if there was a variable
>>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>>> already?
>>>>
>>>> Regards,
>>>> Andreas
>>>>
>>>>
>>>>
>>>>
>>
>>
>> thanks for the quick answer!  The :prologue and :epilogue header
>> arguments have indeed slipped my attention and they look really
>> interesting!  I see, that they are documented, but somehow, they seem to
>> not get their headline and TOC entry?
>>
>> I have three problems with your example, though:
>> 1) It does not run
>> 2) It does not work
>> 3) It won't be usable for 'my' epilogue, correct?
>> ;-)
>>
>
> Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
> when working through the example I sent, but then I forgot to commit
> that support to Org-mode.  I've just pushed up that commit, and
> re-worked my example file to avoid the issue of prologue being applied
> to the emacs-lisp code block (using the very nice and also new
> language-specific PROPERTY header arguments).
>
> Finally, I don't use epilogues in the example because (as the last thing
> evaluated) they would override the code block results.
>
> Hopefully the following:
> 1. will run
> 2. will work
> 3. will be usable
>
> Cheers,
>
> #+Title: debug messages
> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>
> An elisp block to simplify the =:prologue= definition.
> #+begin_src emacs-lisp :results silent
>   (defun get-current-name ()
>     (save-excursion
>       (goto-char org-babel-current-src-block-location)
>       (while (and (forward-line -1)
>                   (looking-at org-babel-multi-line-header-regexp)))
>       (when (looking-at org-babel-src-name-w-name-regexp)
>         (org-no-properties (match-string 3)))))
> #+end_src
>
> Two blocks with simple assignments.
>
> #+name: block-1
> #+begin_src R
>   x <- 2 + 2
> #+end_src
>
> #+RESULTS: block-1
> : 4
> #+name: block-2
> #+begin_src R
>   y <- x + x
> #+end_src
>
> #+RESULTS: block-2
> : 8
>
> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>
>>
>> 1)
>> It does not run, because org tries to do the prologue also on the
>> emacs-lisp block defining the function of the prologue.  So, I get
>> "format: Symbol's function definition is void: get-current-name"
>> I changed the #+property line to
>> #+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
>> which solved that problem.
>>
>> 2)
>> But still it does not work: This is what I get in my *R* buffer:
>> --8<---------------cut here---------------start------------->8---
>>
>> R version 3.0.1 (2013-05-16) -- "Good Sport"
>> Copyright (C) 2013 The R Foundation for Statistical Computing
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>> R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
>> Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
>> Tippen Sie 'license()' or 'licence()' für Details dazu.
>>
>> R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
>> Tippen Sie 'contributors()' für mehr Information und 'citation()',
>> um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
>>
>> Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
>> 'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
>> Tippen Sie 'q()', um R zu verlassen.
>>
>> [1] "C"
>> filehash: Simple key-value database (2.2-1 2012-03-12)
>> tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
>>   LaTeX found in the PATH using the command: pdflatex
>>   XeLaTeX found in the PATH using the command: xelatex
>>   LuaLaTeX found in the PATH using the command: lualatex
>>> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>>>
>>> > 
>>> > 
>> --8<---------------cut here---------------end--------------->8---
>>
>> I tried it with
>> - Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
>> - ess-version : 13.05-1 [<unknown>]
>> - emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
>> --8<---------------cut here---------------start------------->8---
>> (add-to-list 'load-path
>>                   "~/local/emacs/org-mode-install/lisp")
>> (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
>>
>> (add-to-list 'load-path "~/local/emacs/ess/lisp")
>> (require 'ess-site)
>>
>> (setq org-babel-load-languages '((emacs-lisp . t)
>> 				 (R . t)
>> 				 (sh . t)))
>> --8<---------------cut here---------------end--------------->8---
>>
>> What am I missing?  (BTW: If I put a print("sth") into the R blocks
>> myself, I see that printed)
>>
>>
>> 3)
>> Even if it did run, I guess putting sth similar for 'leaving code block
>> foo' into the epilogue would spoil the return value of my src blocks,
>> correct?
>> Is there some work-around?
>>
>>
>>
>> Regards,
>> Andreas
>>
>>
>>


Could that awesome setup be extended to work on #+call lines as well?
That would be really helpful.

The get-current-name does not work for #+call lines:

--8<---------------cut here---------------start------------->8---
#+Title: debug messages
#+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))

An elisp block to simplify the =:prologue= definition.
#+begin_src emacs-lisp :results silent
  (defun get-current-name ()
    (save-excursion
      (goto-char org-babel-current-src-block-location)
      (while (and (forward-line -1)
                  (looking-at org-babel-multi-line-header-regexp)))
      (when (looking-at org-babel-src-name-w-name-regexp)
        (org-no-properties (match-string 3)))))
#+end_src

Two blocks with simple assignments.

#+name: block-1
#+begin_src R
  x <- 2 + 2
#+end_src

#+results: block-1
: 4



#+name: block-2
#+begin_src R
  y <- x + x
#+end_src

#+results: block-2
: 8

#+call: block-1()

#+results:
: 4


Execute the whole buffer =C-c C-v b= to see the prologue in action.
--8<---------------cut here---------------end--------------->8---

Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-20 15:11       ` Andreas Leha
@ 2013-07-20 15:24         ` Andreas Leha
  2013-07-20 15:33           ` Andreas Leha
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-20 15:24 UTC (permalink / raw)
  To: emacs-orgmode

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

> Hi Eric,
>
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi Eric,
>>>
>>>
>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>
>>>> Hi Andreas,
>>>>
>>>> This should be easy to turn on or off using the newly introduced
>>>> :prologue and :epilogue header arguments.  See the manual and the
>>>> following example.
>>>>
>>>> #+Title: debug messages
>>>> #+Property: session *R*
>>>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>>>
>>>> An elisp block to simplify the =:prologue= definition.
>>>> #+begin_src emacs-lisp
>>>>   (defun get-current-name ()
>>>>     (save-excursion
>>>>       (goto-char org-babel-current-src-block-location)
>>>>       (while (and (forward-line -1)
>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>         (org-no-properties (match-string 3)))))
>>>> #+end_src
>>>>
>>>> Two blocks with simple assignments.
>>>>
>>>> #+name: block-1
>>>> #+begin_src R
>>>>   x <- 2 + 2
>>>> #+end_src
>>>>
>>>> #+name: block-2
>>>> #+begin_src R
>>>>   y <- x + x
>>>> #+end_src
>>>>
>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>
>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I would love to see messages like 'entering block foo...' and
>>>>> '...leaving block foo' printed to my R console.  This would be very
>>>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>>>> and some lengthy ones.
>>>>>
>>>>> I know that
>>>>> (1) I could implement that myself at in the source blocks.  But I would
>>>>>     love if orgmode did that for me
>>>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>>>     But that buffer might not be visible and I can not switch to it,
>>>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>>>     to see that output together with the other output, that my code
>>>>>     generates.
>>>>>
>>>>>
>>>>> In essence it would be very helpful, if there was a variable
>>>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>>>> already?
>>>>>
>>>>> Regards,
>>>>> Andreas
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>> thanks for the quick answer!  The :prologue and :epilogue header
>>> arguments have indeed slipped my attention and they look really
>>> interesting!  I see, that they are documented, but somehow, they seem to
>>> not get their headline and TOC entry?
>>>
>>> I have three problems with your example, though:
>>> 1) It does not run
>>> 2) It does not work
>>> 3) It won't be usable for 'my' epilogue, correct?
>>> ;-)
>>>
>>
>> Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
>> when working through the example I sent, but then I forgot to commit
>> that support to Org-mode.  I've just pushed up that commit, and
>> re-worked my example file to avoid the issue of prologue being applied
>> to the emacs-lisp code block (using the very nice and also new
>> language-specific PROPERTY header arguments).
>>
>> Finally, I don't use epilogues in the example because (as the last thing
>> evaluated) they would override the code block results.
>>
>> Hopefully the following:
>> 1. will run
>> 2. will work
>> 3. will be usable
>>
>> Cheers,
>>
>> #+Title: debug messages
>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>
>> An elisp block to simplify the =:prologue= definition.
>> #+begin_src emacs-lisp :results silent
>>   (defun get-current-name ()
>>     (save-excursion
>>       (goto-char org-babel-current-src-block-location)
>>       (while (and (forward-line -1)
>>                   (looking-at org-babel-multi-line-header-regexp)))
>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>         (org-no-properties (match-string 3)))))
>> #+end_src
>>
>> Two blocks with simple assignments.
>>
>> #+name: block-1
>> #+begin_src R
>>   x <- 2 + 2
>> #+end_src
>>
>> #+RESULTS: block-1
>> : 4
>> #+name: block-2
>> #+begin_src R
>>   y <- x + x
>> #+end_src
>>
>> #+RESULTS: block-2
>> : 8
>>
>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>
>>>
>>> 1)
>>> It does not run, because org tries to do the prologue also on the
>>> emacs-lisp block defining the function of the prologue.  So, I get
>>> "format: Symbol's function definition is void: get-current-name"
>>> I changed the #+property line to
>>> #+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
>>> which solved that problem.
>>>
>>> 2)
>>> But still it does not work: This is what I get in my *R* buffer:
>>> --8<---------------cut here---------------start------------->8---
>>>
>>> R version 3.0.1 (2013-05-16) -- "Good Sport"
>>> Copyright (C) 2013 The R Foundation for Statistical Computing
>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>
>>> R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
>>> Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
>>> Tippen Sie 'license()' or 'licence()' für Details dazu.
>>>
>>> R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
>>> Tippen Sie 'contributors()' für mehr Information und 'citation()',
>>> um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
>>>
>>> Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
>>> 'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
>>> Tippen Sie 'q()', um R zu verlassen.
>>>
>>> [1] "C"
>>> filehash: Simple key-value database (2.2-1 2012-03-12)
>>> tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
>>>   LaTeX found in the PATH using the command: pdflatex
>>>   XeLaTeX found in the PATH using the command: xelatex
>>>   LuaLaTeX found in the PATH using the command: lualatex
>>>> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>>>>
>>>> > 
>>>> > 
>>> --8<---------------cut here---------------end--------------->8---
>>>
>>> I tried it with
>>> - Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
>>> - ess-version : 13.05-1 [<unknown>]
>>> - emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
>>> --8<---------------cut here---------------start------------->8---
>>> (add-to-list 'load-path
>>>                   "~/local/emacs/org-mode-install/lisp")
>>> (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
>>>
>>> (add-to-list 'load-path "~/local/emacs/ess/lisp")
>>> (require 'ess-site)
>>>
>>> (setq org-babel-load-languages '((emacs-lisp . t)
>>> 				 (R . t)
>>> 				 (sh . t)))
>>> --8<---------------cut here---------------end--------------->8---
>>>
>>> What am I missing?  (BTW: If I put a print("sth") into the R blocks
>>> myself, I see that printed)
>>>
>>>
>>> 3)
>>> Even if it did run, I guess putting sth similar for 'leaving code block
>>> foo' into the epilogue would spoil the return value of my src blocks,
>>> correct?
>>> Is there some work-around?
>>>
>>>
>>>
>>> Regards,
>>> Andreas
>>>
>>>
>>>
>
>
> Could that awesome setup be extended to work on #+call lines as well?
> That would be really helpful.
>
> The get-current-name does not work for #+call lines:
>
> #+Title: debug messages
> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>
> An elisp block to simplify the =:prologue= definition.
> #+begin_src emacs-lisp :results silent
>   (defun get-current-name ()
>     (save-excursion
>       (goto-char org-babel-current-src-block-location)
>       (while (and (forward-line -1)
>                   (looking-at org-babel-multi-line-header-regexp)))
>       (when (looking-at org-babel-src-name-w-name-regexp)
>         (org-no-properties (match-string 3)))))
> #+end_src
>
> Two blocks with simple assignments.
>
> #+name: block-1
> #+begin_src R
>   x <- 2 + 2
> #+end_src
>
> #+results: block-1
> : 4
>
>
>
> #+name: block-2
> #+begin_src R
>   y <- x + x
> #+end_src
>
> #+results: block-2
> : 8
>
> #+call: block-1()
>
> #+results:
> : 4
>
>
> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>
> Regards,
> Andreas


Just as an add-on.  It does work with *named* #+call lines.

Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-20 15:24         ` Andreas Leha
@ 2013-07-20 15:33           ` Andreas Leha
  2013-07-23 22:12             ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-20 15:33 UTC (permalink / raw)
  To: emacs-orgmode

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

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Eric,
>>
>>
>> Eric Schulte <schulte.eric@gmail.com> writes:
>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi Eric,
>>>>
>>>>
>>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>>
>>>>> Hi Andreas,
>>>>>
>>>>> This should be easy to turn on or off using the newly introduced
>>>>> :prologue and :epilogue header arguments.  See the manual and the
>>>>> following example.
>>>>>
>>>>> #+Title: debug messages
>>>>> #+Property: session *R*
>>>>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>>>>
>>>>> An elisp block to simplify the =:prologue= definition.
>>>>> #+begin_src emacs-lisp
>>>>>   (defun get-current-name ()
>>>>>     (save-excursion
>>>>>       (goto-char org-babel-current-src-block-location)
>>>>>       (while (and (forward-line -1)
>>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>>         (org-no-properties (match-string 3)))))
>>>>> #+end_src
>>>>>
>>>>> Two blocks with simple assignments.
>>>>>
>>>>> #+name: block-1
>>>>> #+begin_src R
>>>>>   x <- 2 + 2
>>>>> #+end_src
>>>>>
>>>>> #+name: block-2
>>>>> #+begin_src R
>>>>>   y <- x + x
>>>>> #+end_src
>>>>>
>>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>>
>>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I would love to see messages like 'entering block foo...' and
>>>>>> '...leaving block foo' printed to my R console.  This would be very
>>>>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>>>>> and some lengthy ones.
>>>>>>
>>>>>> I know that
>>>>>> (1) I could implement that myself at in the source blocks.  But I would
>>>>>>     love if orgmode did that for me
>>>>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>>>>     But that buffer might not be visible and I can not switch to it,
>>>>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>>>>     to see that output together with the other output, that my code
>>>>>>     generates.
>>>>>>
>>>>>>
>>>>>> In essence it would be very helpful, if there was a variable
>>>>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>>>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>>>>> already?
>>>>>>
>>>>>> Regards,
>>>>>> Andreas
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>> thanks for the quick answer!  The :prologue and :epilogue header
>>>> arguments have indeed slipped my attention and they look really
>>>> interesting!  I see, that they are documented, but somehow, they seem to
>>>> not get their headline and TOC entry?
>>>>
>>>> I have three problems with your example, though:
>>>> 1) It does not run
>>>> 2) It does not work
>>>> 3) It won't be usable for 'my' epilogue, correct?
>>>> ;-)
>>>>
>>>
>>> Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
>>> when working through the example I sent, but then I forgot to commit
>>> that support to Org-mode.  I've just pushed up that commit, and
>>> re-worked my example file to avoid the issue of prologue being applied
>>> to the emacs-lisp code block (using the very nice and also new
>>> language-specific PROPERTY header arguments).
>>>
>>> Finally, I don't use epilogues in the example because (as the last thing
>>> evaluated) they would override the code block results.
>>>
>>> Hopefully the following:
>>> 1. will run
>>> 2. will work
>>> 3. will be usable
>>>
>>> Cheers,
>>>
>>> #+Title: debug messages
>>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>>
>>> An elisp block to simplify the =:prologue= definition.
>>> #+begin_src emacs-lisp :results silent
>>>   (defun get-current-name ()
>>>     (save-excursion
>>>       (goto-char org-babel-current-src-block-location)
>>>       (while (and (forward-line -1)
>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>         (org-no-properties (match-string 3)))))
>>> #+end_src
>>>
>>> Two blocks with simple assignments.
>>>
>>> #+name: block-1
>>> #+begin_src R
>>>   x <- 2 + 2
>>> #+end_src
>>>
>>> #+RESULTS: block-1
>>> : 4
>>> #+name: block-2
>>> #+begin_src R
>>>   y <- x + x
>>> #+end_src
>>>
>>> #+RESULTS: block-2
>>> : 8
>>>
>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>
>>>>
>>>> 1)
>>>> It does not run, because org tries to do the prologue also on the
>>>> emacs-lisp block defining the function of the prologue.  So, I get
>>>> "format: Symbol's function definition is void: get-current-name"
>>>> I changed the #+property line to
>>>> #+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
>>>> which solved that problem.
>>>>
>>>> 2)
>>>> But still it does not work: This is what I get in my *R* buffer:
>>>> --8<---------------cut here---------------start------------->8---
>>>>
>>>> R version 3.0.1 (2013-05-16) -- "Good Sport"
>>>> Copyright (C) 2013 The R Foundation for Statistical Computing
>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>>
>>>> R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
>>>> Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
>>>> Tippen Sie 'license()' or 'licence()' für Details dazu.
>>>>
>>>> R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
>>>> Tippen Sie 'contributors()' für mehr Information und 'citation()',
>>>> um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
>>>>
>>>> Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
>>>> 'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
>>>> Tippen Sie 'q()', um R zu verlassen.
>>>>
>>>> [1] "C"
>>>> filehash: Simple key-value database (2.2-1 2012-03-12)
>>>> tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
>>>>   LaTeX found in the PATH using the command: pdflatex
>>>>   XeLaTeX found in the PATH using the command: xelatex
>>>>   LuaLaTeX found in the PATH using the command: lualatex
>>>>> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>>>>>
>>>>> > 
>>>>> > 
>>>> --8<---------------cut here---------------end--------------->8---
>>>>
>>>> I tried it with
>>>> - Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
>>>> - ess-version : 13.05-1 [<unknown>]
>>>> - emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
>>>> --8<---------------cut here---------------start------------->8---
>>>> (add-to-list 'load-path
>>>>                   "~/local/emacs/org-mode-install/lisp")
>>>> (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
>>>>
>>>> (add-to-list 'load-path "~/local/emacs/ess/lisp")
>>>> (require 'ess-site)
>>>>
>>>> (setq org-babel-load-languages '((emacs-lisp . t)
>>>> 				 (R . t)
>>>> 				 (sh . t)))
>>>> --8<---------------cut here---------------end--------------->8---
>>>>
>>>> What am I missing?  (BTW: If I put a print("sth") into the R blocks
>>>> myself, I see that printed)
>>>>
>>>>
>>>> 3)
>>>> Even if it did run, I guess putting sth similar for 'leaving code block
>>>> foo' into the epilogue would spoil the return value of my src blocks,
>>>> correct?
>>>> Is there some work-around?
>>>>
>>>>
>>>>
>>>> Regards,
>>>> Andreas
>>>>
>>>>
>>>>
>>
>>
>> Could that awesome setup be extended to work on #+call lines as well?
>> That would be really helpful.
>>
>> The get-current-name does not work for #+call lines:
>>
>> #+Title: debug messages
>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>
>> An elisp block to simplify the =:prologue= definition.
>> #+begin_src emacs-lisp :results silent
>>   (defun get-current-name ()
>>     (save-excursion
>>       (goto-char org-babel-current-src-block-location)
>>       (while (and (forward-line -1)
>>                   (looking-at org-babel-multi-line-header-regexp)))
>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>         (org-no-properties (match-string 3)))))
>> #+end_src
>>
>> Two blocks with simple assignments.
>>
>> #+name: block-1
>> #+begin_src R
>>   x <- 2 + 2
>> #+end_src
>>
>> #+results: block-1
>> : 4
>>
>>
>>
>> #+name: block-2
>> #+begin_src R
>>   y <- x + x
>> #+end_src
>>
>> #+results: block-2
>> : 8
>>
>> #+call: block-1()
>>
>> #+results:
>> : 4
>>
>>
>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>
>> Regards,
>> Andreas
>
>
> Just as an add-on.  It does work with *named* #+call lines.
>
> Regards,
> Andreas


Sorry for continuously answering my own post.

There is another problem with that solution:  I can not edit a source
code buffer with C-'
,----
| save-excursion: Wrong type argument: integer-or-marker-p, nil
`----

Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-20 15:33           ` Andreas Leha
@ 2013-07-23 22:12             ` Eric Schulte
  2013-07-25  8:14               ` Andreas Leha
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Schulte @ 2013-07-23 22:12 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

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

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi Eric,
>>>
>>>
>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>
>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>
>>>>> Hi Eric,
>>>>>
>>>>>
>>>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>>>
>>>>>> Hi Andreas,
>>>>>>
>>>>>> This should be easy to turn on or off using the newly introduced
>>>>>> :prologue and :epilogue header arguments.  See the manual and the
>>>>>> following example.
>>>>>>
>>>>>> #+Title: debug messages
>>>>>> #+Property: session *R*
>>>>>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>>>>>
>>>>>> An elisp block to simplify the =:prologue= definition.
>>>>>> #+begin_src emacs-lisp
>>>>>>   (defun get-current-name ()
>>>>>>     (save-excursion
>>>>>>       (goto-char org-babel-current-src-block-location)
>>>>>>       (while (and (forward-line -1)
>>>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>>>         (org-no-properties (match-string 3)))))
>>>>>> #+end_src
>>>>>>
>>>>>> Two blocks with simple assignments.
>>>>>>
>>>>>> #+name: block-1
>>>>>> #+begin_src R
>>>>>>   x <- 2 + 2
>>>>>> #+end_src
>>>>>>
>>>>>> #+name: block-2
>>>>>> #+begin_src R
>>>>>>   y <- x + x
>>>>>> #+end_src
>>>>>>
>>>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>>>
>>>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I would love to see messages like 'entering block foo...' and
>>>>>>> '...leaving block foo' printed to my R console.  This would be very
>>>>>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>>>>>> and some lengthy ones.
>>>>>>>
>>>>>>> I know that
>>>>>>> (1) I could implement that myself at in the source blocks.  But I would
>>>>>>>     love if orgmode did that for me
>>>>>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>>>>>     But that buffer might not be visible and I can not switch to it,
>>>>>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>>>>>     to see that output together with the other output, that my code
>>>>>>>     generates.
>>>>>>>
>>>>>>>
>>>>>>> In essence it would be very helpful, if there was a variable
>>>>>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>>>>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>>>>>> already?
>>>>>>>
>>>>>>> Regards,
>>>>>>> Andreas
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>> thanks for the quick answer!  The :prologue and :epilogue header
>>>>> arguments have indeed slipped my attention and they look really
>>>>> interesting!  I see, that they are documented, but somehow, they seem to
>>>>> not get their headline and TOC entry?
>>>>>
>>>>> I have three problems with your example, though:
>>>>> 1) It does not run
>>>>> 2) It does not work
>>>>> 3) It won't be usable for 'my' epilogue, correct?
>>>>> ;-)
>>>>>
>>>>
>>>> Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
>>>> when working through the example I sent, but then I forgot to commit
>>>> that support to Org-mode.  I've just pushed up that commit, and
>>>> re-worked my example file to avoid the issue of prologue being applied
>>>> to the emacs-lisp code block (using the very nice and also new
>>>> language-specific PROPERTY header arguments).
>>>>
>>>> Finally, I don't use epilogues in the example because (as the last thing
>>>> evaluated) they would override the code block results.
>>>>
>>>> Hopefully the following:
>>>> 1. will run
>>>> 2. will work
>>>> 3. will be usable
>>>>
>>>> Cheers,
>>>>
>>>> #+Title: debug messages
>>>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>>>
>>>> An elisp block to simplify the =:prologue= definition.
>>>> #+begin_src emacs-lisp :results silent
>>>>   (defun get-current-name ()
>>>>     (save-excursion
>>>>       (goto-char org-babel-current-src-block-location)
>>>>       (while (and (forward-line -1)
>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>         (org-no-properties (match-string 3)))))
>>>> #+end_src
>>>>
>>>> Two blocks with simple assignments.
>>>>
>>>> #+name: block-1
>>>> #+begin_src R
>>>>   x <- 2 + 2
>>>> #+end_src
>>>>
>>>> #+RESULTS: block-1
>>>> : 4
>>>> #+name: block-2
>>>> #+begin_src R
>>>>   y <- x + x
>>>> #+end_src
>>>>
>>>> #+RESULTS: block-2
>>>> : 8
>>>>
>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>
>>>>>
>>>>> 1)
>>>>> It does not run, because org tries to do the prologue also on the
>>>>> emacs-lisp block defining the function of the prologue.  So, I get
>>>>> "format: Symbol's function definition is void: get-current-name"
>>>>> I changed the #+property line to
>>>>> #+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
>>>>> which solved that problem.
>>>>>
>>>>> 2)
>>>>> But still it does not work: This is what I get in my *R* buffer:
>>>>> --8<---------------cut here---------------start------------->8---
>>>>>
>>>>> R version 3.0.1 (2013-05-16) -- "Good Sport"
>>>>> Copyright (C) 2013 The R Foundation for Statistical Computing
>>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>>>
>>>>> R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
>>>>> Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
>>>>> Tippen Sie 'license()' or 'licence()' für Details dazu.
>>>>>
>>>>> R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
>>>>> Tippen Sie 'contributors()' für mehr Information und 'citation()',
>>>>> um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
>>>>>
>>>>> Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
>>>>> 'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
>>>>> Tippen Sie 'q()', um R zu verlassen.
>>>>>
>>>>> [1] "C"
>>>>> filehash: Simple key-value database (2.2-1 2012-03-12)
>>>>> tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
>>>>>   LaTeX found in the PATH using the command: pdflatex
>>>>>   XeLaTeX found in the PATH using the command: xelatex
>>>>>   LuaLaTeX found in the PATH using the command: lualatex
>>>>>> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>>>>>>
>>>>>> > 
>>>>>> > 
>>>>> --8<---------------cut here---------------end--------------->8---
>>>>>
>>>>> I tried it with
>>>>> - Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
>>>>> - ess-version : 13.05-1 [<unknown>]
>>>>> - emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
>>>>> --8<---------------cut here---------------start------------->8---
>>>>> (add-to-list 'load-path
>>>>>                   "~/local/emacs/org-mode-install/lisp")
>>>>> (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
>>>>>
>>>>> (add-to-list 'load-path "~/local/emacs/ess/lisp")
>>>>> (require 'ess-site)
>>>>>
>>>>> (setq org-babel-load-languages '((emacs-lisp . t)
>>>>> 				 (R . t)
>>>>> 				 (sh . t)))
>>>>> --8<---------------cut here---------------end--------------->8---
>>>>>
>>>>> What am I missing?  (BTW: If I put a print("sth") into the R blocks
>>>>> myself, I see that printed)
>>>>>
>>>>>
>>>>> 3)
>>>>> Even if it did run, I guess putting sth similar for 'leaving code block
>>>>> foo' into the epilogue would spoil the return value of my src blocks,
>>>>> correct?
>>>>> Is there some work-around?
>>>>>
>>>>>
>>>>>
>>>>> Regards,
>>>>> Andreas
>>>>>
>>>>>
>>>>>
>>>
>>>
>>> Could that awesome setup be extended to work on #+call lines as well?
>>> That would be really helpful.
>>>
>>> The get-current-name does not work for #+call lines:
>>>
>>> #+Title: debug messages
>>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>>
>>> An elisp block to simplify the =:prologue= definition.
>>> #+begin_src emacs-lisp :results silent
>>>   (defun get-current-name ()
>>>     (save-excursion
>>>       (goto-char org-babel-current-src-block-location)
>>>       (while (and (forward-line -1)
>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>         (org-no-properties (match-string 3)))))
>>> #+end_src
>>>
>>> Two blocks with simple assignments.
>>>
>>> #+name: block-1
>>> #+begin_src R
>>>   x <- 2 + 2
>>> #+end_src
>>>
>>> #+results: block-1
>>> : 4
>>>
>>>
>>>
>>> #+name: block-2
>>> #+begin_src R
>>>   y <- x + x
>>> #+end_src
>>>
>>> #+results: block-2
>>> : 8
>>>
>>> #+call: block-1()
>>>
>>> #+results:
>>> : 4
>>>
>>>
>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>
>>> Regards,
>>> Andreas
>>
>>
>> Just as an add-on.  It does work with *named* #+call lines.
>>
>> Regards,
>> Andreas
>
>
> Sorry for continuously answering my own post.
>
> There is another problem with that solution:  I can not edit a source
> code buffer with C-'
> ,----
> | save-excursion: Wrong type argument: integer-or-marker-p, nil
> `----
>
> Regards,
> Andreas
>
>

This version should
- not throw an error when no code block is being executed, and
- always return a string (even if there is no name)

  #+begin_src emacs-lisp :results silent
    (defun get-current-name ()
      (or (when org-babel-current-src-block-location
            (save-excursion
              (goto-char org-babel-current-src-block-location)
              (while (and (forward-line -1)
                          (looking-at org-babel-multi-line-header-regexp)))
              (when (looking-at org-babel-src-name-w-name-regexp)
                (org-no-properties (match-string 3)))))
          ""))
  #+end_src

Hopefully this helps,

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

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

* Re: [babel] feature request: debug messages
  2013-07-23 22:12             ` Eric Schulte
@ 2013-07-25  8:14               ` Andreas Leha
  2013-07-25 13:37                 ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-25  8:14 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi Eric,
>>>>
>>>>
>>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>>
>>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>>
>>>>>> Hi Eric,
>>>>>>
>>>>>>
>>>>>> Eric Schulte <schulte.eric@gmail.com> writes:
>>>>>>
>>>>>>> Hi Andreas,
>>>>>>>
>>>>>>> This should be easy to turn on or off using the newly introduced
>>>>>>> :prologue and :epilogue header arguments.  See the manual and the
>>>>>>> following example.
>>>>>>>
>>>>>>> #+Title: debug messages
>>>>>>> #+Property: session *R*
>>>>>>> #+Property: prologue (format "print(\"entering %s\")" (get-current-name))
>>>>>>>
>>>>>>> An elisp block to simplify the =:prologue= definition.
>>>>>>> #+begin_src emacs-lisp
>>>>>>>   (defun get-current-name ()
>>>>>>>     (save-excursion
>>>>>>>       (goto-char org-babel-current-src-block-location)
>>>>>>>       (while (and (forward-line -1)
>>>>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>>>>         (org-no-properties (match-string 3)))))
>>>>>>> #+end_src
>>>>>>>
>>>>>>> Two blocks with simple assignments.
>>>>>>>
>>>>>>> #+name: block-1
>>>>>>> #+begin_src R
>>>>>>>   x <- 2 + 2
>>>>>>> #+end_src
>>>>>>>
>>>>>>> #+name: block-2
>>>>>>> #+begin_src R
>>>>>>>   y <- x + x
>>>>>>> #+end_src
>>>>>>>
>>>>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>>>>
>>>>>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> I would love to see messages like 'entering block foo...' and
>>>>>>>> '...leaving block foo' printed to my R console.  This would be very
>>>>>>>> handy when I evaluate a subtree (C-c C-v s) with a lot of #+call lines
>>>>>>>> and some lengthy ones.
>>>>>>>>
>>>>>>>> I know that
>>>>>>>> (1) I could implement that myself at in the source blocks.  But I would
>>>>>>>>     love if orgmode did that for me
>>>>>>>> (2) Such messages are already printed to the emacs *Messages* buffer.
>>>>>>>>     But that buffer might not be visible and I can not switch to it,
>>>>>>>>     without interrupting the evaluation.  Anyway it would be much nicer
>>>>>>>>     to see that output together with the other output, that my code
>>>>>>>>     generates.
>>>>>>>>
>>>>>>>>
>>>>>>>> In essence it would be very helpful, if there was a variable
>>>>>>>> org-babel-print-debug-messages (or org-babel-debug-level...) which if
>>>>>>>> non-nil would cause that messages to be printed.  Or is there somewhere
>>>>>>>> already?
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Andreas
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>> thanks for the quick answer!  The :prologue and :epilogue header
>>>>>> arguments have indeed slipped my attention and they look really
>>>>>> interesting!  I see, that they are documented, but somehow, they seem to
>>>>>> not get their headline and TOC entry?
>>>>>>
>>>>>> I have three problems with your example, though:
>>>>>> 1) It does not run
>>>>>> 2) It does not work
>>>>>> 3) It won't be usable for 'my' epilogue, correct?
>>>>>> ;-)
>>>>>>
>>>>>
>>>>> Ah! My fault.  I had to add prologue and epilogue support to ob-R.el
>>>>> when working through the example I sent, but then I forgot to commit
>>>>> that support to Org-mode.  I've just pushed up that commit, and
>>>>> re-worked my example file to avoid the issue of prologue being applied
>>>>> to the emacs-lisp code block (using the very nice and also new
>>>>> language-specific PROPERTY header arguments).
>>>>>
>>>>> Finally, I don't use epilogues in the example because (as the last thing
>>>>> evaluated) they would override the code block results.
>>>>>
>>>>> Hopefully the following:
>>>>> 1. will run
>>>>> 2. will work
>>>>> 3. will be usable
>>>>>
>>>>> Cheers,
>>>>>
>>>>> #+Title: debug messages
>>>>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>>>>
>>>>> An elisp block to simplify the =:prologue= definition.
>>>>> #+begin_src emacs-lisp :results silent
>>>>>   (defun get-current-name ()
>>>>>     (save-excursion
>>>>>       (goto-char org-babel-current-src-block-location)
>>>>>       (while (and (forward-line -1)
>>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>>         (org-no-properties (match-string 3)))))
>>>>> #+end_src
>>>>>
>>>>> Two blocks with simple assignments.
>>>>>
>>>>> #+name: block-1
>>>>> #+begin_src R
>>>>>   x <- 2 + 2
>>>>> #+end_src
>>>>>
>>>>> #+RESULTS: block-1
>>>>> : 4
>>>>> #+name: block-2
>>>>> #+begin_src R
>>>>>   y <- x + x
>>>>> #+end_src
>>>>>
>>>>> #+RESULTS: block-2
>>>>> : 8
>>>>>
>>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>>
>>>>>>
>>>>>> 1)
>>>>>> It does not run, because org tries to do the prologue also on the
>>>>>> emacs-lisp block defining the function of the prologue.  So, I get
>>>>>> "format: Symbol's function definition is void: get-current-name"
>>>>>> I changed the #+property line to
>>>>>> #+Property: header-args:R :prologue (format "print(\"entering %s\")" (get-current-name))
>>>>>> which solved that problem.
>>>>>>
>>>>>> 2)
>>>>>> But still it does not work: This is what I get in my *R* buffer:
>>>>>> --8<---------------cut here---------------start------------->8---
>>>>>>
>>>>>> R version 3.0.1 (2013-05-16) -- "Good Sport"
>>>>>> Copyright (C) 2013 The R Foundation for Statistical Computing
>>>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>>>>
>>>>>> R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
>>>>>> Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
>>>>>> Tippen Sie 'license()' or 'licence()' für Details dazu.
>>>>>>
>>>>>> R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
>>>>>> Tippen Sie 'contributors()' für mehr Information und 'citation()',
>>>>>> um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
>>>>>>
>>>>>> Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
>>>>>> 'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
>>>>>> Tippen Sie 'q()', um R zu verlassen.
>>>>>>
>>>>>> [1] "C"
>>>>>> filehash: Simple key-value database (2.2-1 2012-03-12)
>>>>>> tikzDevice: R Graphics Output in LaTeX Format (v0.6.2-92-0ad2792)
>>>>>>   LaTeX found in the PATH using the command: pdflatex
>>>>>>   XeLaTeX found in the PATH using the command: xelatex
>>>>>>   LuaLaTeX found in the PATH using the command: lualatex
>>>>>>> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
>>>>>>>
>>>>>>> > 
>>>>>>> > 
>>>>>> --8<---------------cut here---------------end--------------->8---
>>>>>>
>>>>>> I tried it with
>>>>>> - Org-mode version 8.0.4 (release_8.0.4-294-g62f20c)
>>>>>> - ess-version : 13.05-1 [<unknown>]
>>>>>> - emacs -Q -l ~/.emacs.minimal.ess.org, whith that content:
>>>>>> --8<---------------cut here---------------start------------->8---
>>>>>> (add-to-list 'load-path
>>>>>>                   "~/local/emacs/org-mode-install/lisp")
>>>>>> (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
>>>>>>
>>>>>> (add-to-list 'load-path "~/local/emacs/ess/lisp")
>>>>>> (require 'ess-site)
>>>>>>
>>>>>> (setq org-babel-load-languages '((emacs-lisp . t)
>>>>>> 				 (R . t)
>>>>>> 				 (sh . t)))
>>>>>> --8<---------------cut here---------------end--------------->8---
>>>>>>
>>>>>> What am I missing?  (BTW: If I put a print("sth") into the R blocks
>>>>>> myself, I see that printed)
>>>>>>
>>>>>>
>>>>>> 3)
>>>>>> Even if it did run, I guess putting sth similar for 'leaving code block
>>>>>> foo' into the epilogue would spoil the return value of my src blocks,
>>>>>> correct?
>>>>>> Is there some work-around?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Andreas
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>> Could that awesome setup be extended to work on #+call lines as well?
>>>> That would be really helpful.
>>>>
>>>> The get-current-name does not work for #+call lines:
>>>>
>>>> #+Title: debug messages
>>>> #+Property: header-args:R :session *R* :prologue (format "print(\"entering %s\")" (get-current-name))
>>>>
>>>> An elisp block to simplify the =:prologue= definition.
>>>> #+begin_src emacs-lisp :results silent
>>>>   (defun get-current-name ()
>>>>     (save-excursion
>>>>       (goto-char org-babel-current-src-block-location)
>>>>       (while (and (forward-line -1)
>>>>                   (looking-at org-babel-multi-line-header-regexp)))
>>>>       (when (looking-at org-babel-src-name-w-name-regexp)
>>>>         (org-no-properties (match-string 3)))))
>>>> #+end_src
>>>>
>>>> Two blocks with simple assignments.
>>>>
>>>> #+name: block-1
>>>> #+begin_src R
>>>>   x <- 2 + 2
>>>> #+end_src
>>>>
>>>> #+results: block-1
>>>> : 4
>>>>
>>>>
>>>>
>>>> #+name: block-2
>>>> #+begin_src R
>>>>   y <- x + x
>>>> #+end_src
>>>>
>>>> #+results: block-2
>>>> : 8
>>>>
>>>> #+call: block-1()
>>>>
>>>> #+results:
>>>> : 4
>>>>
>>>>
>>>> Execute the whole buffer =C-c C-v b= to see the prologue in action.
>>>>
>>>> Regards,
>>>> Andreas
>>>
>>>
>>> Just as an add-on.  It does work with *named* #+call lines.
>>>
>>> Regards,
>>> Andreas
>>
>>
>> Sorry for continuously answering my own post.
>>
>> There is another problem with that solution:  I can not edit a source
>> code buffer with C-'
>> ,----
>> | save-excursion: Wrong type argument: integer-or-marker-p, nil
>> `----
>>
>> Regards,
>> Andreas
>>
>>
>
> This version should
> - not throw an error when no code block is being executed, and
> - always return a string (even if there is no name)
>
>   #+begin_src emacs-lisp :results silent
>     (defun get-current-name ()
>       (or (when org-babel-current-src-block-location
>             (save-excursion
>               (goto-char org-babel-current-src-block-location)
>               (while (and (forward-line -1)
>                           (looking-at org-babel-multi-line-header-regexp)))
>               (when (looking-at org-babel-src-name-w-name-regexp)
>                 (org-no-properties (match-string 3)))))
>           ""))
>   #+end_src
>
> Hopefully this helps,


This helps a lot.  Thanks!  Now, I will this into all my org files.

Cheers,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-25  8:14               ` Andreas Leha
@ 2013-07-25 13:37                 ` Eric Schulte
  2013-07-25 15:18                   ` Andreas Leha
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Schulte @ 2013-07-25 13:37 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

>
> This helps a lot.  Thanks!

Happy this worked out.

> Now, I will this into all my org files.
>

Check out the library of babel of things that you want to have globally
available.

Best,

>
> Cheers,
> Andreas
>
>
>
>

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

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

* Re: [babel] feature request: debug messages
  2013-07-25 13:37                 ` Eric Schulte
@ 2013-07-25 15:18                   ` Andreas Leha
  2013-07-25 16:07                     ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Andreas Leha @ 2013-07-25 15:18 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric Schulte <schulte.eric@gmail.com> writes:

>>
>> This helps a lot.  Thanks!
>
> Happy this worked out.
>
>> Now, I will this into all my org files.
>>
>
> Check out the library of babel of things that you want to have globally
> available.

Thanks for the hint.  If I put it there, I still have to #+call it from
every org file, correct?

Regards,
Andreas

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

* Re: [babel] feature request: debug messages
  2013-07-25 15:18                   ` Andreas Leha
@ 2013-07-25 16:07                     ` Eric Schulte
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Schulte @ 2013-07-25 16:07 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

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

> Hi Eric,
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>>>
>>> This helps a lot.  Thanks!
>>
>> Happy this worked out.
>>
>>> Now, I will this into all my org files.
>>>
>>
>> Check out the library of babel of things that you want to have globally
>> available.
>
> Thanks for the hint.  If I put it there, I still have to #+call it from
> every org file, correct?
>

Sorry, ignore the library of babel, you can just add that function
definition to your .emacs.

Best,

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

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

end of thread, other threads:[~2013-07-25 16:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 19:58 [babel] feature request: debug messages Andreas Leha
2013-07-03 22:55 ` Eric Schulte
2013-07-04  6:42   ` Andreas Leha
2013-07-04 14:48     ` Eric Schulte
2013-07-06 16:00       ` Andreas Leha
2013-07-07 17:08         ` Eric Schulte
2013-07-07 19:24           ` Andreas Leha
2013-07-08  2:03             ` Eric Schulte
2013-07-20 15:11       ` Andreas Leha
2013-07-20 15:24         ` Andreas Leha
2013-07-20 15:33           ` Andreas Leha
2013-07-23 22:12             ` Eric Schulte
2013-07-25  8:14               ` Andreas Leha
2013-07-25 13:37                 ` Eric Schulte
2013-07-25 15:18                   ` Andreas Leha
2013-07-25 16:07                     ` 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).