I use code blocks in org-mode a lot. I usually code in Python, and in Python I usually write code that prints output which I want to see. So I almost always want the code blocks to return the output, and not the value of the last function. I have set my default header args like this:
|(:exports . both)||(:results . replace output)||(:session . none)||(:cache . no)||(:noweb . no)||(:hlines . no)||(:tangle . no)|
However, I would prefer that emacs-lisp blocks use value for the
results. I know I can get that by putting
:results value in the
code block header, but that annoys me. I learned today from
http://orgmode.org/worg/org-contrib/babel/header-args.html that you
can make language specific default headers!
This code in my init file sets emacs-lisp specific default headers:
(setq org-babel-default-header-args:emacs-lisp (cons '(:results . "value") (assq-delete-all :results org-babel-default-header-args)))
That way I do not have type
:results value at the top of every elisp
block. Of course, if I want the output I could specify
output in the block.
|(:results . value)||(:exports . both)||(:session . none)||(:cache . no)||(:noweb . no)||(:hlines . no)||(:tangle . no)|
On a related note, I find I write so many blocks of python and elisp I added these templates:
;; add <p for python expansion (add-to-list 'org-structure-template-alist '("p" "#+BEGIN_SRC python\n?\n#+END_SRC" "<src lang=\"python\">\n?\n</src>")) ;; add <el for emacs-lisp expansion (add-to-list 'org-structure-template-alist '("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC" "<src lang=\"emacs-lisp\">\n?\n</src>"))
I probably could have also coded the :results header into those too. They add a tidbit of convenience so I do not have to type python or emacs-lisp after expanding a source block with <s.
Copyright (C) 2014 by John Kitchin. See the License for information about copying.
Org-mode version = 8.2.5g