From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: Bug: Feature Request: add 'org-babel-before-execute-hook' [8.3.4 (8.3.4-99-ga8e4a3-elpa @ /Users/macbookair/.emacs.d/elpa/org-20160704/)] Date: Fri, 8 Jul 2016 09:09:55 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLYLs-0001hQ-Sn for emacs-orgmode@gnu.org; Fri, 08 Jul 2016 12:10:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLYLm-0002op-Mx for emacs-orgmode@gnu.org; Fri, 08 Jul 2016 12:10:03 -0400 Received: from iport-acv5-out.ucsd.edu ([132.239.0.10]:13645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLYLm-0002ob-E2 for emacs-orgmode@gnu.org; Fri, 08 Jul 2016 12:09:58 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jiajie Chen Cc: emacs-orgmode@gnu.org 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