From: "Eric Schulte" <schulte.eric@gmail.com>
To: Bill Harris <bill_harris@facilitatedsystems.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>, Noorul Islam <noorul@noorul.com>
Subject: Re: File-level execute permissions?
Date: Mon, 27 Sep 2010 07:46:14 -0600 [thread overview]
Message-ID: <87iq1r1eqh.fsf@gmail.com> (raw)
In-Reply-To: <877hi94d2w.fsf@moenchweiler.bach> (Bill Harris's message of "Sat, 25 Sep 2010 16:29:11 -0700")
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 <bill_harris@facilitatedsystems.com> writes:
> Noorul Islam <noorul@noorul.com> 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
next prev parent reply other threads:[~2010-09-27 13:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-24 13:11 File-level execute permissions? Bill Harris
2010-09-25 5:40 ` Noorul Islam
2010-09-25 23:29 ` Bill Harris
2010-09-27 13:46 ` Eric Schulte [this message]
2010-09-28 1:08 ` Bill Harris
2010-09-28 17:40 ` Eric Schulte
2010-09-29 2:36 ` Bill Harris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iq1r1eqh.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=bill_harris@facilitatedsystems.com \
--cc=emacs-orgmode@gnu.org \
--cc=noorul@noorul.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.