all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Shakthi Kannan <shakthimaan@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Scripting with org-mode
Date: Mon, 30 Nov 2015 14:15:38 -0500	[thread overview]
Message-ID: <m2two3qox1.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <CABG-yt2dC9Nc+p0FRFO8gJWe6+wGZvFjBNacX6Q_gQjAa3=s4Q@mail.gmail.com>

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

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

  parent reply	other threads:[~2015-11-30 19:15 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 [this message]
2015-11-30 20:22   ` Nick Dokos
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

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

  git send-email \
    --in-reply-to=m2two3qox1.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=shakthimaan@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.