From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Is it possible to run shell script src blocks as root or to export individual blocks? Date: Mon, 19 Mar 2012 10:46:04 -0400 Message-ID: <87fwd4abtf.fsf@gmx.com> References: <87pqctkahb.fsf@gmx.com> <87ty25hbz6.fsf@med.uni-goettingen.de> <87wr6zax0z.fsf@gmx.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9dqp-0001ya-RR for emacs-orgmode@gnu.org; Mon, 19 Mar 2012 10:46:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9dqj-0004ir-5B for emacs-orgmode@gnu.org; Mon, 19 Mar 2012 10:46:23 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:34382 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1S9dqi-0004ih-V7 for emacs-orgmode@gnu.org; Mon, 19 Mar 2012 10:46:17 -0400 In-Reply-To: (Leo Alekseyev's message of "Mon, 19 Mar 2012 04:42:14 -0400") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Leo Alekseyev Cc: Andreas Leha , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Leo Alekseyev writes: > On Mon, Mar 5, 2012 at 10:24 AM, Eric Schulte wrot= e: >> Andreas Leha writes: >> >>> Eric Schulte writes: >>> >>>> Leo Alekseyev writes: >>>> >>>>> I was wondering if there was an easy way to execute some shell >>>>> commands contained in a src block as root. =C2=A0Alternatively, is th= ere a >>>>> quick way to export _just_ that one source block to a temp file so >>>>> that I could run it as root manually? >>>>> >>>> >>>> Just call org-babel-tangle with a prefix argument and it only tangles >>>> the current block > > Hi all, > > I just pulled a fresh version of org, and this tangling an individual > block only works if there's a :tangle header argument present. I > don't think this is the intended behavior! The problem, it seems, is > that when :tangle is not present, the (or ...) in the code below > always evaluates to true. > > #+begin_src emacs-lisp > (unless (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-inf= o)))) > target-file) > (setq target-file > (read-from-minibuffer "Tangle to: " (buffer-file-name))))) > #+end_src Thanks for raising this issue. I can not apply patches to the git repository until the recent git issues are sorted, so I am attaching the patch to this email so that you can apply it locally if you like. I will push this up once our git repository is back in working order. Best, --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Bring-back-prompt-for-single-block-tangling.patch >From bfacabb33acb4d2dbcfd87b10e3488e43cf5d84a Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 19 Mar 2012 10:44:43 -0400 Subject: [PATCH 2/2] Bring back prompt for single-block tangling. * lisp/ob-tangle.el (org-babel-tangle): Bring back prompt for single-block tangling. --- lisp/ob-tangle.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 5e498ab..b57d89d 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -186,7 +186,10 @@ exported source code blocks by language." (unless (org-babel-where-is-src-block-head) (error "Point is not currently inside of a code block")) (save-match-data - (unless (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info)))) + (unless (or (not (string= + (cdr (assoc :tangle + (nth 2 (org-babel-get-src-block-info)))) + "no")) target-file) (setq target-file (read-from-minibuffer "Tangle to: " (buffer-file-name))))) -- 1.7.9.4 --=-=-= Content-Type: text/plain -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--