This is the official manual for the latest Org-mode release.

Table of Contents

Next: , Previous: wrap, Up: Specific header arguments


14.8.2.27 :post

The :post header argument is for post-processing results from ‘src’ block evaluation. When :post has any value, Org binds the results to *this* variable for easy passing to var header argument specifications. That makes results available to other ‘src’ code blocks, or for even direct Emacs Lisp code execution.

The following two examples illustrate :post header argument in action. The first one shows how to attach #+ATTR_LATEX: line using :post.

     #+name: attr_wrap
     #+begin_src sh :var data="" :var width="\\textwidth" :results output
       echo "#+ATTR_LATEX: :width $width"
       echo "$data"
     #+end_src
     
     #+header: :file /tmp/it.png
     #+begin_src dot :post attr_wrap(width="5cm", data=*this*) :results drawer
       digraph{
               a -> b;
               b -> c;
               c -> a;
       }
     #+end_src
     
     #+RESULTS:
     :RESULTS:
     #+ATTR_LATEX :width 5cm
     [[file:/tmp/it.png]]
     :END:

The second example shows use of :colnames in :post to pass data between ‘src’ code blocks.

     #+name: round-tbl
     #+begin_src emacs-lisp :var tbl="" fmt="%.3f"
       (mapcar (lambda (row)
                 (mapcar (lambda (cell)
                           (if (numberp cell)
                               (format fmt cell)
                             cell))
                         row))
               tbl)
     #+end_src
     
     #+begin_src R :colnames yes :post round-tbl[:colnames yes](*this*)
     set.seed(42)
     data.frame(foo=rnorm(1))
     #+end_src
     
     #+RESULTS:
     |   foo |
     |-------|
     | 1.371 |