Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-19 Thread Leo Alekseyev
On Mon, Mar 5, 2012 at 10:24 AM, Eric Schulte eric.schu...@gmx.com wrote:
 Andreas Leha andreas.l...@med.uni-goettingen.de writes:

 Eric Schulte eric.schu...@gmx.com writes:

 Leo Alekseyev dnqu...@gmail.com writes:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there 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-info
  target-file)
(setq target-file
  (read-from-minibuffer Tangle to:  (buffer-file-name)
#+end_src



Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-19 Thread Eric Schulte
Leo Alekseyev dnqu...@gmail.com writes:

 On Mon, Mar 5, 2012 at 10:24 AM, Eric Schulte eric.schu...@gmx.com wrote:
 Andreas Leha andreas.l...@med.uni-goettingen.de writes:

 Eric Schulte eric.schu...@gmx.com writes:

 Leo Alekseyev dnqu...@gmail.com writes:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there 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-info
 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,

From bfacabb33acb4d2dbcfd87b10e3488e43cf5d84a Mon Sep 17 00:00:00 2001
From: Eric Schulte eric.schu...@gmx.com
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



-- 
Eric Schulte
http://cs.unm.edu/~eschulte/


Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-06 Thread Andreas Leha
Eric Schulte eric.schu...@gmx.com writes:

 Andreas Leha andreas.l...@med.uni-goettingen.de writes:

 Eric Schulte eric.schu...@gmx.com writes:

 Leo Alekseyev dnqu...@gmail.com writes:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there 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,

 I did not know this either.  Thanks for the hint!

 Shouldn't this be mentioned in the manual (14.4)?

 I have two questions/issues about this:
 (1) Can I get noweb-references to be expanded by this?  Or how would I
 tangle one block with noweb references expanded?

 There was a conflict between the narrowing to a single code block caused
 by the prefix argument, and the code which searches for replacements to
 noweb elements.  I've just pushed up a fix so noweb elements should now
 expand as normal.

 
 (2) I am asked for a filename.  But the header argument :tangle somefile
 is overruling my input, which is un-expected.


 This is now fixed as well.


Hi Eric,

thanks for both fixes!  Tangling of single source blocks is a really
nice feature now!

Regards,
Andreas




Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-05 Thread Eric Schulte
Andreas Leha andreas.l...@med.uni-goettingen.de writes:

 Eric Schulte eric.schu...@gmx.com writes:

 Leo Alekseyev dnqu...@gmail.com writes:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there 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,

 I did not know this either.  Thanks for the hint!

 Shouldn't this be mentioned in the manual (14.4)?

 I have two questions/issues about this:
 (1) Can I get noweb-references to be expanded by this?  Or how would I
 tangle one block with noweb references expanded?

There was a conflict between the narrowing to a single code block caused
by the prefix argument, and the code which searches for replacements to
noweb elements.  I've just pushed up a fix so noweb elements should now
expand as normal.

 
 (2) I am asked for a filename.  But the header argument :tangle somefile
 is overruling my input, which is un-expected.


This is now fixed as well.

Thanks,


 Regards,
 Andreas



-- 
Eric Schulte
http://cs.unm.edu/~eschulte/



Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-04 Thread Sylvain Rousseau
Under Gnome, I'm using this at the beginning of a sh source block:

 echo -e #! /bin/bash\n/usr/bin/gksudo -p -m Password  /tmp/gksudo-stdout
 chmod +x /tmp/gksudo-stdout
 SUDO_ASKPASS=/tmp/gksudo-stdout sudo -A -s


Sylvain.


Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-03 Thread Nick Dokos
Leo Alekseyev dnqu...@gmail.com wrote:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there a
 quick way to export _just_ that one source block to a temp file so
 that I could run it as root manually?
 

You could set up sudo so that it does not require a password and prefix each
command that needs to be run as root with sudo:

--8---cut here---start-8---

* foo

#+BEGIN_SRC sh
sudo id

#+END_SRC

#+RESULTS:
: uid=0(root) gid=0(root) groups=0(root)
--8---cut here---end---8---

Not sure how sudo would interact with babel if you had to type in a password.

Nick



Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-03 Thread Eric Schulte
Leo Alekseyev dnqu...@gmail.com writes:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there 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



-- 
Eric Schulte
http://cs.unm.edu/~eschulte/



Re: [O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-03 Thread Andreas Leha
Eric Schulte eric.schu...@gmx.com writes:

 Leo Alekseyev dnqu...@gmail.com writes:

 I was wondering if there was an easy way to execute some shell
 commands contained in a src block as root.  Alternatively, is there 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,

I did not know this either.  Thanks for the hint!

Shouldn't this be mentioned in the manual (14.4)?

I have two questions/issues about this:
(1) Can I get noweb-references to be expanded by this?  Or how would I
tangle one block with noweb references expanded?
(2) I am asked for a filename.  But the header argument :tangle somefile
is overruling my input, which is un-expected.

Regards,
Andreas




[O] Is it possible to run shell script src blocks as root or to export individual blocks?

2012-03-02 Thread Leo Alekseyev
I was wondering if there was an easy way to execute some shell
commands contained in a src block as root.  Alternatively, is there a
quick way to export _just_ that one source block to a temp file so
that I could run it as root manually?