From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Berry, Charles" Subject: Re: Babel eval w/ C-c C-c but not (org-babel-execute-buffer) Date: Thu, 10 Oct 2019 17:21:49 +0000 Message-ID: <635C173F-5C04-4361-BC63-CA93DE277FA0@ucsd.edu> References: <87o8yyj2oe.fsf@gmail.com> <877e5d3zmu.fsf@gmail.com> <31702816-69D2-450B-88A0-D6F7375C014C@ucsd.edu> <87r23k3612.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:49031) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIc98-0004P3-8j for emacs-orgmode@gnu.org; Thu, 10 Oct 2019 13:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIc96-0006Dg-RP for emacs-orgmode@gnu.org; Thu, 10 Oct 2019 13:22:38 -0400 Received: from mx0b-00395d01.pphosted.com ([148.163.137.170]:48720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iIc96-0006DO-9s for emacs-orgmode@gnu.org; Thu, 10 Oct 2019 13:22:36 -0400 In-Reply-To: <87r23k3612.fsf@gmail.com> Content-Language: en-US Content-ID: <93DE29204831E340BE3683949DD21664@AD.UCSD.EDU> 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: Ken Mankoff Cc: "emacs-orgmode@gnu.org" , John Kitchin > On Oct 10, 2019, at 9:43 AM, Ken Mankoff wrote: >=20 > Hi Charles, >=20 > On 2019-10-10 at 18:22 +02, Berry, Charles wrote... >> If the language mode you use supports of evaluation of the src edit >> buffer (e.g. ESS[R], Python), you can issue >>=20 >> C-c C-v v C-c C-b >>=20 >> for ESS[R] or >>=20 >> C-c C-v v C-c C-c >>=20 >> for Python (I think) >>=20 >> The commands will expand :var args and noweb declarations, then >> execute the corresponding 'send-buffer' command regardless of :eval. >=20 > This could work in theory, but doesn't for bash on my system. And (I thin= k) with this method tables of output are not then injected back into the Or= g buffer that can be exported as part of the document. I think in R such tables are injected with :exports results/both. But if you need bash, I guess not. >=20 >> Why not use something like this >>=20 >> :eval (ok2run) >>=20 >> where `ok2run' consults a property to decide whether to eval the block? >=20 > I need to think about this some more... Can you describe more how you pic= ture this working? Try this: #+begin_src org ,#+begin_src emacs-lisp=20 (defun ok2run (&optional eval-arg) "Use EVAL-ARG as the argument for `:eval'. If none is supplied consult a variable `buffer-eval-arg' if such exists a property called `eval-arg' or default to `yes'." (let ((eval-arg (or eval-arg (bound-and-true-p buffer-eval-arg) (org-entry-get (point) "eval-arg" t) "yes"))) eval-arg)) ,#+end_src #+end_src #+begin_src org ,#+PROPERTY: header-args :eval (ok2run) :exports results ,* use default ,#+name: use-default ,#+begin_src emacs-lisp "unboundp" ,#+end_src ,* explicit no ,#+name: explicit-no ,#+begin_src emacs-lisp :eval (ok2run "no")=20 "explicit-no" ,#+end_src ,* never export in this subtree :PROPERTIES: :eval-arg: never-export :END: ,#+name: never-export ,#+begin_src emacs-lisp=20 "never-export" ,#+end_src #+end_src This will give fairly fine grained control over what and when to eval.=20 > Off the top of my head, I am picturing a top-level property setting :eval= (ok2run) and then blocks I want to always run have :eval yes and blocks I = want to run interactively only have a new property, ":eval-on-c-c" set to "= t". The, (ok2run) checks for eval-on-c-c as a header arg and returns 't' if= it exists and 'nil' if it does not? >=20 >=20 > While your suggestions do work for some cases, they feel like work-around= s for a missing feature. Perhaps, `org-confirm-babel-evaluate' is that feature. I think with a bit o= f effort it could do what I proposed above for `ok2run'. > Isn't the feature I'm proposing a logical enhancement? Why would someone = C-c C-c (or C-u C-u C-c C-c) on a code block if they didn't want it to run?= Shouldn't an explicit request override a local header or top-level-documen= t flag that says "don't eval"? Maybe it is logical.=20 But I am a terrible typist and sometimes end up typing things or in places = I did not intend.=20 I have disabled a number of commands to prevent me from accidentally wrecki= ng my work. =20 So if I mark a block with `:eval no', I want to be sure errant keystrokes d= o not override that setting. Chuck=