emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Scripting with org-mode
Date: Mon, 30 Nov 2015 15:22:04 -0500	[thread overview]
Message-ID: <87fuzngrv7.fsf@alphaville.usersys.redhat.com> (raw)
In-Reply-To: m2two3qox1.fsf@andrew.cmu.edu

John Kitchin <jkitchin@andrew.cmu.edu> 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	other threads:[~2015-11-30 20:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30 16:43 Scripting with org-mode Shakthi Kannan
2015-11-30 18:48 ` briangpowell .
2015-11-30 19:15 ` John Kitchin
2015-11-30 20:22   ` Nick Dokos [this message]
2015-11-30 20:36     ` John Kitchin
2015-12-01  1:03     ` Shakthi Kannan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fuzngrv7.fsf@alphaville.usersys.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).