emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Scripting with org-mode


From: John Kitchin
Subject: Re: [O] Scripting with org-mode
Date: Mon, 30 Nov 2015 15:36:24 -0500

of course there is a simpler way ;)

John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803

On Mon, Nov 30, 2015 at 3:22 PM, Nick Dokos <address@hidden> wrote:
John Kitchin <address@hidden> writes:

> I think one of these will do what you want:
>
> ** Rerun all src blocks
>
> #+BEGIN_SRC emacs-lisp
> (defun run-blocks ()
>   (interactive)
>   (save-excursion
>     (org-element-map (org-element-parse-buffer) 'src-block
>       (lambda (src-block)
>         (goto-char (org-element-property :begin src-block))
>         (org-babel-execute-src-block)))))
>
>
> #+END_SRC
>
> #+RESULTS:
> : run-blocks
>
>
> #+BEGIN_SRC emacs-lisp
> (defun run-blocks-2 ()
>   (interactive)
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward "^#\\+BEGIN_SRC" nil t)
>       (org-babel-execute-src-block))))
> #+END_SRC
> #+RESULTS:
>
>
>
>
>
> Shakthi Kannan writes:
>
>> Hi,
>>
>> Is there a way to execute all the org-mode code blocks in a file, and
>> send the output to stdout?
>>
>> For example, I have the following org file:
>>
>> === BEGIN ===
>>
>> * Greeting
>>
>> #+BEGIN_SRC sh :results output
>>   echo "Hello $USER! Today is `date`"
>> #+END_SRC
>>
>> * Current directory
>>
>> #+BEGIN_SRC sh :results output
>>   pwd
>> #+END_SRC
>>
>> === END ===
>>
>> I could go to each code block, and type C-c C-c to produce an output.
>> But, I just want to be able to execute the entire file, and produce
>> one single output.
>>
>> Is this possible?
>>


IIUC, org-babel-execute-buffer is exactly what the OP
needs.

--
Nick




reply via email to

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