On Fri, 8 Jul 2016, Jiajie Chen wrote:
[snip]
Now there exists 'org-babel-after-execute-hook'. I want to implement
this functionality: Check whether the path specified in `:file' exists
in file system and throw an error if that does not exists. If there is
`org-babel-before-execute-hook', we can do that instead of using
advice. I love symmetry :)
Not a bug, of course.
You can check on things like file existence in a number of ways.
First, you can put emacs-lisp in header args, for example:
This evaluates when there is a file called "elisp" in the default
directory:
#+header: :eval (or (file-exists-p "elisp") "no")
#+BEGIN_SRC emacs-lisp :eval (file-exists-p "elisp")
"got it!"
#+END_SRC
and this does not (when there is no 'eeeelisp'):
#+header: :eval (or (file-exists-p "eeeelisp") "no")
#+BEGIN_SRC emacs-lisp
"got it!"
#+END_SRC
I've illustrated here with `:eval', but `:file' will also take such an
elisp snippet.
Alternatively, you can define a function for `org-confirm-babel-evaluate'
that will block evaluation.
Chuck