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

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

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
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Mon, Nov 30, 2015 at 3:22 PM, Nick Dokos <ndokos@gmail.com> wrote:

> 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
>
>
>

[-- Attachment #2: Type: text/html, Size: 3083 bytes --]

  reply	other threads:[~2015-11-30 20:36 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
2015-11-30 20:36     ` John Kitchin [this message]
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=CAJ51ETokyPYCDkgPJDLHS7KpY7TKWhpUSQSMkh-q0NHxEXx_2w@mail.gmail.com \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@gmail.com \
    /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).