emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Multiple (identical) RESULTS blocks of one code block?


From: John Kitchin
Subject: Re: [O] Multiple (identical) RESULTS blocks of one code block?
Date: Mon, 09 Mar 2015 09:01:40 -0400

I don't believe this is possible out of the box. The first RESULTS block
from the beginning of the buffer will be updated, and not the others.

You might be able to use a hook function to do this, something like:

#+BEGIN_SRC emacs-lisp
(defun update-results () (interactive)
  ;; get name of src block
  (let ((name (org-element-property :name (org-element-at-point)))
        (results))
    (when name
      (org-element-map (org-element-parse-buffer) 'fixed-width
        (lambda (object)
          (if results
              ;; replace value in block
              (setf
               (buffer-substring
                (org-element-property :begin  object)
                (org-element-property :end  object))
               results)
            ;; set results
            (setq results
                  (buffer-substring
                   (org-element-property :begin  object)
                   (org-element-property :end  object)))))))))
#+END_SRC


#+BEGIN_SRC emacs-lisp
(add-hook 'org-babel-after-execute-hook 'update-results)
#+END_SRC

This worked on a small test example, but I did not test it
thoroughly. your mileage might vary ;)


Rainer M Krug writes:

> Hi
>
> Consider the following:
>
> --8<---------------cut here---------------start------------->8---
> * The calculation
> #+NAME: testcode :exports both
> #+begin_src R  :session test
> runif(10)
> #+end_src
>
>
> * summary of the results
> First time
> #+RESULTS: testcode :exports both
> |  0.772744940361008 |
> |  0.170518629485741 |
> | 0.0833237133920193 |
> |  0.149035625392571 |
> |  0.698798568220809 |
> |  0.627075897762552 |
> |  0.177144371205941 |
> | 0.0476319056469947 |
> |  0.289851602632552 |
> | 0.0296813279855996 |
>
> * and another
> testthingy
> #+RESULTS: testcode :exports both
>
> --8<---------------cut here---------------end--------------->8---
>
> If I update the calculation, the first results block is updated, but
> not the second one. I would like to have two RESULTS blocks which
> are both updated when the code block is evaluated.
>
> Is this possible?
>
> Thanks,
>
> Rainer

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]