From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: File-level execute permissions? Date: Mon, 27 Sep 2010 07:46:14 -0600 Message-ID: <87iq1r1eqh.fsf@gmail.com> References: <87zkv74778.fsf@moenchweiler.bach> <877hi94d2w.fsf@moenchweiler.bach> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=37491 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0E2G-0007mL-T1 for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 09:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0E2A-0003Vn-0z for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 09:46:28 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:61099) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0E29-0003Vg-US for emacs-orgmode@gnu.org; Mon, 27 Sep 2010 09:46:21 -0400 Received: by iwn33 with SMTP id 33so7828162iwn.0 for ; Mon, 27 Sep 2010 06:46:21 -0700 (PDT) In-Reply-To: <877hi94d2w.fsf@moenchweiler.bach> (Bill Harris's message of "Sat, 25 Sep 2010 16:29:11 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bill Harris Cc: emacs-orgmode , Noorul Islam Hi Bill, The `org-confirm-babel-evaluate' variable can be set to a function which can query the user to confirm code block evaluation. The following code does two things. 1) it creates and maintains a list of the files that the user has said are safe for evaluation (this list will need to be rebuilt every time you re-start Emacs) 2) it shows the language and body of the code block to the user when querying for evaluation --8<---------------cut here---------------start------------->8--- (setq babel-safe-files '()) (defun my-babel-confirmation (lang body) (let ((file (buffer-file-name))) (if (member file babel-safe-files) nil (if (y-or-n-p (format (concat "#+begin_src %s\n%s#+end_src\n" "Evaluate this code block " "(and all others in this file) " "on your system? ") lang body)) (prog1 nil (setq babel-safe-files (cons file babel-safe-files))) t)))) (setq org-confirm-babel-evaluate #'my-babel-confirmation) --8<---------------cut here---------------end--------------->8--- This above can be added to your configuration to get close to the functionality you describe. I agree that the default confirmation should show the code block in question when asking if it should be evaluated. I'll add this to our development task list. Note: the above requires that you pull down the latest version of Org-mode. Best -- Eric Bill Harris writes: > Noorul Islam writes: > >> How about setting `org-confirm-babel-evaluate' to nil > > Noorul, > > Thank you for the suggestion. Setting that to nil, according to the > documentation, prevents _any_ confirmation requests in any file, at > least as best as I can tell. I don't really want that. > > What I want is to have to confirm once at the first code block in an org > file and then have the rest go without confirmation. Since I don't see > the code blocks anyway when I get asked for confirmation, I'm not sure > there's a lot of benefit to a confirmation request on each block, but I > do want a reminder that there is one or more code blocks in a file > before I blithely execute the entire thing. > > Bill