4

Here is an example to let me explain what I would like to achieve:

#+NAME: heavy_computation
#+BEGIN_SRC shell :results table
echo -e "A\t32\nB\t17"
#+END_SRC

#+BEGIN_SRC python :var data=heavy_computation
return sum([i[1] for i in data])
#+END_SRC

The second code block uses the results of the first one. When running the second code block the result is correctly displayed:

#+RESULTS:
: 49

However I would also like to see the results of the first code block, without having to run it independently. Therefore, under the first code block, I would like to see:

#+RESULTS: heavy_computation
| A | 32 |
| B | 17 |

How can I achieve that? My question looks similar to this question but as far as I understood, the anwser seemed specific to Lisp.

0

You can use a function like the one at https://github.com/jkitchin/scimax/blob/master/scimax-ob.el#L94 to achieve this. That will unfortunately run every block above the current point.

Otherwise, you can put the cursor in the first block, run it, then put the cursor in the second block and run it.

I think there are speed commands for src blocks, so if I have my cursor at the beginning of the first block, on the #, I can press e to execute the block, then n to jump to the next block, and e to execute that one. This works for me, but I am having difficulty finding where that is configured at the moment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.