emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Is it possible to run shell script src blocks as root or to export individual blocks?
@ 2012-03-03  4:40 Leo Alekseyev
  2012-03-03  8:55 ` Nick Dokos
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Leo Alekseyev @ 2012-03-03  4:40 UTC (permalink / raw)
  To: Emacs orgmode

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?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-03  4:40 Is it possible to run shell script src blocks as root or to export individual blocks? Leo Alekseyev
@ 2012-03-03  8:55 ` Nick Dokos
  2012-03-03  9:19 ` org-babel-execute-src-block deletes its src block Daimrod
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Nick Dokos @ 2012-03-03  8:55 UTC (permalink / raw)
  To: Leo Alekseyev; +Cc: nicholas.dokos, Emacs orgmode

Leo Alekseyev <dnquark@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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* org-babel-execute-src-block deletes its src block.
  2012-03-03  4:40 Is it possible to run shell script src blocks as root or to export individual blocks? Leo Alekseyev
  2012-03-03  8:55 ` Nick Dokos
@ 2012-03-03  9:19 ` Daimrod
  2012-03-03  9:42   ` Nick Dokos
  2012-03-03 14:25 ` Is it possible to run shell script src blocks as root or to export individual blocks? Eric Schulte
  2012-03-04 17:29 ` Sylvain Rousseau
  3 siblings, 1 reply; 14+ messages in thread
From: Daimrod @ 2012-03-03  9:19 UTC (permalink / raw)
  To: emacs-orgmode


Hi, I've recently switched from Org 7.4 to the master branch on the git
repository, and I've encountered this weird situation.

  #+name: foo
  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp

If I evaluate this block I get:

  #+name: foo
=42
=emacs-lisp

Though it works as expected if I remove the name:

  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp
=>
  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp

  #+RESULTS:
  : 42

I've tried to figure out what was the problem and it lies in the regexp
org-babel-src-name-w-name-regexp.

So far I've found those workarounds:

No spaces after the ':'

  #+name:foo
  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp
=>
  #+name:foo
  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp

  #+RESULTS: foo
  : 42

Add parentheses after the name.

  #+name: foo()
  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp
=>
  #+name: foo()
  #+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp

  #+RESULTS: foo
  : 42

No spaces before the src block

  #+name: foo
#+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp
=>
  #+name: foo
#+begin_src emacs-lisp 
    (defun foo ()
      42)
    (foo)
  #+end_src emacs-lisp

#+RESULTS: foo
: 42

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org-babel-execute-src-block deletes its src block.
  2012-03-03  9:19 ` org-babel-execute-src-block deletes its src block Daimrod
@ 2012-03-03  9:42   ` Nick Dokos
  2012-03-03  9:54     ` Daimrod
  2012-03-03 14:46     ` Eric Schulte
  0 siblings, 2 replies; 14+ messages in thread
From: Nick Dokos @ 2012-03-03  9:42 UTC (permalink / raw)
  To: Daimrod; +Cc: nicholas.dokos, emacs-orgmode

Daimrod <daimrod@gmail.com> wrote:

> 
> Hi, I've recently switched from Org 7.4 to the master branch on the git
> repository, and I've encountered this weird situation.
> 
>   #+name: foo
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> 
> If I evaluate this block I get:
> 
>   #+name: foo
> =42
> =emacs-lisp
> 
> Though it works as expected if I remove the name:
> 
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> =>
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> 
>   #+RESULTS:
>   : 42
> 
> I've tried to figure out what was the problem and it lies in the regexp
> org-babel-src-name-w-name-regexp.
> 
> So far I've found those workarounds:
> 
> No spaces after the ':'
> 
>   #+name:foo
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> =>
>   #+name:foo
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
>   #+RESULTS: foo
>   : 42
> 
> Add parentheses after the name.
> 
>   #+name: foo()
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> =>
>   #+name: foo()
>   #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> 
>   #+RESULTS: foo
>   : 42
> 
> No spaces before the src block
> 
>   #+name: foo
> #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> =>
>   #+name: foo
> #+begin_src emacs-lisp 
>     (defun foo ()
>       42)
>     (foo)
>   #+end_src emacs-lisp
> 
> #+RESULTS: foo
> : 42

Bug confirmed (but I didn't try all your workarounds, just the no spaces
before the #+begin_src and no space after the colon in the #+name).

I take it it was working on 7.4?

Nick

PS. One side note: the syntax of code blocks is

     #+NAME: <name>
     #+BEGIN_SRC <language> <switches> <header arguments>
       <body>
     #+END_SRC

so no emacs-lisp on the #+end_src line.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org-babel-execute-src-block deletes its src block.
  2012-03-03  9:42   ` Nick Dokos
@ 2012-03-03  9:54     ` Daimrod
  2012-03-03 14:46     ` Eric Schulte
  1 sibling, 0 replies; 14+ messages in thread
From: Daimrod @ 2012-03-03  9:54 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> writes:

> Daimrod <daimrod@gmail.com> wrote:
>
>> 
>> Hi, I've recently switched from Org 7.4 to the master branch on the git
>> repository, and I've encountered this weird situation.
>> 
>>   #+name: foo
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>> If I evaluate this block I get:
>> 
>>   #+name: foo
>> =42
>> =emacs-lisp
>> 
>> Though it works as expected if I remove the name:
>> 
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>>   #+RESULTS:
>>   : 42
>> 
>> I've tried to figure out what was the problem and it lies in the regexp
>> org-babel-src-name-w-name-regexp.
>> 
>> So far I've found those workarounds:
>> 
>> No spaces after the ':'
>> 
>>   #+name:foo
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+name:foo
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>>   #+RESULTS: foo
>>   : 42
>> 
>> Add parentheses after the name.
>> 
>>   #+name: foo()
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+name: foo()
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>>   #+RESULTS: foo
>>   : 42
>> 
>> No spaces before the src block
>> 
>>   #+name: foo
>> #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+name: foo
>> #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>> #+RESULTS: foo
>> : 42
>
> Bug confirmed (but I didn't try all your workarounds, just the no spaces
> before the #+begin_src and no space after the colon in the #+name).
>
> I take it it was working on 7.4?
>

Yes.

> Nick
>
> PS. One side note: the syntax of code blocks is
>
>      #+NAME: <name>
>      #+BEGIN_SRC <language> <switches> <header arguments>
>        <body>
>      #+END_SRC
>
> so no emacs-lisp on the #+end_src line.

Indeed, I don't know why I've pasted it like this, normally I don't do
it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-03  4:40 Is it possible to run shell script src blocks as root or to export individual blocks? Leo Alekseyev
  2012-03-03  8:55 ` Nick Dokos
  2012-03-03  9:19 ` org-babel-execute-src-block deletes its src block Daimrod
@ 2012-03-03 14:25 ` Eric Schulte
  2012-03-03 16:43   ` Andreas Leha
  2012-03-04 17:29 ` Sylvain Rousseau
  3 siblings, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2012-03-03 14:25 UTC (permalink / raw)
  To: Leo Alekseyev; +Cc: Emacs orgmode

Leo Alekseyev <dnquark@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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org-babel-execute-src-block deletes its src block.
  2012-03-03  9:42   ` Nick Dokos
  2012-03-03  9:54     ` Daimrod
@ 2012-03-03 14:46     ` Eric Schulte
  2012-03-03 15:11       ` Daimrod
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2012-03-03 14:46 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Daimrod, emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> writes:

> Daimrod <daimrod@gmail.com> wrote:
>
>> 
>> Hi, I've recently switched from Org 7.4 to the master branch on the git
>> repository, and I've encountered this weird situation.
>> 
>>   #+name: foo
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>> If I evaluate this block I get:
>> 
>>   #+name: foo
>> =42
>> =emacs-lisp
>> 
>> Though it works as expected if I remove the name:
>> 
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>>   #+RESULTS:
>>   : 42
>> 
>> I've tried to figure out what was the problem and it lies in the regexp
>> org-babel-src-name-w-name-regexp.
>> 
>> So far I've found those workarounds:
>> 
>> No spaces after the ':'
>> 
>>   #+name:foo
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+name:foo
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>>   #+RESULTS: foo
>>   : 42
>> 
>> Add parentheses after the name.
>> 
>>   #+name: foo()
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+name: foo()
>>   #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>>   #+RESULTS: foo
>>   : 42
>> 
>> No spaces before the src block
>> 
>>   #+name: foo
>> #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> =>
>>   #+name: foo
>> #+begin_src emacs-lisp 
>>     (defun foo ()
>>       42)
>>     (foo)
>>   #+end_src emacs-lisp
>> 
>> #+RESULTS: foo
>> : 42
>
> Bug confirmed (but I didn't try all your workarounds, just the no spaces
> before the #+begin_src and no space after the colon in the #+name).
>

This was caused by a commit of mine yesterday, I've just pushed up a fix
and a protecting test case.

Thanks for catching,

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: org-babel-execute-src-block deletes its src block.
  2012-03-03 14:46     ` Eric Schulte
@ 2012-03-03 15:11       ` Daimrod
  0 siblings, 0 replies; 14+ messages in thread
From: Daimrod @ 2012-03-03 15:11 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

> Nick Dokos <nicholas.dokos@hp.com> writes:
>
>> Daimrod <daimrod@gmail.com> wrote:
>>
>>> 
>>> Hi, I've recently switched from Org 7.4 to the master branch on the git
>>> repository, and I've encountered this weird situation.
>>> 
>>>   #+name: foo
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> 
>>> If I evaluate this block I get:
>>> 
>>>   #+name: foo
>>> =42
>>> =emacs-lisp
>>> 
>>> Though it works as expected if I remove the name:
>>> 
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> =>
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> 
>>>   #+RESULTS:
>>>   : 42
>>> 
>>> I've tried to figure out what was the problem and it lies in the regexp
>>> org-babel-src-name-w-name-regexp.
>>> 
>>> So far I've found those workarounds:
>>> 
>>> No spaces after the ':'
>>> 
>>>   #+name:foo
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> =>
>>>   #+name:foo
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>>   #+RESULTS: foo
>>>   : 42
>>> 
>>> Add parentheses after the name.
>>> 
>>>   #+name: foo()
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> =>
>>>   #+name: foo()
>>>   #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> 
>>>   #+RESULTS: foo
>>>   : 42
>>> 
>>> No spaces before the src block
>>> 
>>>   #+name: foo
>>> #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> =>
>>>   #+name: foo
>>> #+begin_src emacs-lisp 
>>>     (defun foo ()
>>>       42)
>>>     (foo)
>>>   #+end_src emacs-lisp
>>> 
>>> #+RESULTS: foo
>>> : 42
>>
>> Bug confirmed (but I didn't try all your workarounds, just the no spaces
>> before the #+begin_src and no space after the colon in the #+name).
>>
>
> This was caused by a commit of mine yesterday, I've just pushed up a fix
> and a protecting test case.
>
> Thanks for catching,

Works nicely.

By the way, org-babel is awesome, thanks for your efforts!

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-03 14:25 ` Is it possible to run shell script src blocks as root or to export individual blocks? Eric Schulte
@ 2012-03-03 16:43   ` Andreas Leha
  2012-03-05 15:24     ` Eric Schulte
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Leha @ 2012-03-03 16:43 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

> Leo Alekseyev <dnquark@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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-03  4:40 Is it possible to run shell script src blocks as root or to export individual blocks? Leo Alekseyev
                   ` (2 preceding siblings ...)
  2012-03-03 14:25 ` Is it possible to run shell script src blocks as root or to export individual blocks? Eric Schulte
@ 2012-03-04 17:29 ` Sylvain Rousseau
  3 siblings, 0 replies; 14+ messages in thread
From: Sylvain Rousseau @ 2012-03-04 17:29 UTC (permalink / raw)
  To: Leo Alekseyev; +Cc: Emacs orgmode

[-- Attachment #1: Type: text/plain, Size: 231 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 286 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-03 16:43   ` Andreas Leha
@ 2012-03-05 15:24     ` Eric Schulte
  2012-03-06  9:11       ` Andreas Leha
  2012-03-19  8:42       ` Leo Alekseyev
  0 siblings, 2 replies; 14+ messages in thread
From: Eric Schulte @ 2012-03-05 15:24 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Eric Schulte <eric.schulte@gmx.com> writes:
>
>> Leo Alekseyev <dnquark@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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-05 15:24     ` Eric Schulte
@ 2012-03-06  9:11       ` Andreas Leha
  2012-03-19  8:42       ` Leo Alekseyev
  1 sibling, 0 replies; 14+ messages in thread
From: Andreas Leha @ 2012-03-06  9:11 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Eric Schulte <eric.schulte@gmx.com> writes:
>>
>>> Leo Alekseyev <dnquark@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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-05 15:24     ` Eric Schulte
  2012-03-06  9:11       ` Andreas Leha
@ 2012-03-19  8:42       ` Leo Alekseyev
  2012-03-19 14:46         ` Eric Schulte
  1 sibling, 1 reply; 14+ messages in thread
From: Leo Alekseyev @ 2012-03-19  8:42 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Andreas Leha, emacs-orgmode

On Mon, Mar 5, 2012 at 10:24 AM, Eric Schulte <eric.schulte@gmx.com> wrote:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Eric Schulte <eric.schulte@gmx.com> writes:
>>
>>> Leo Alekseyev <dnquark@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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Is it possible to run shell script src blocks as root or to export individual blocks?
  2012-03-19  8:42       ` Leo Alekseyev
@ 2012-03-19 14:46         ` Eric Schulte
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Schulte @ 2012-03-19 14:46 UTC (permalink / raw)
  To: Leo Alekseyev; +Cc: Andreas Leha, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1536 bytes --]

Leo Alekseyev <dnquark@gmail.com> writes:

> On Mon, Mar 5, 2012 at 10:24 AM, Eric Schulte <eric.schulte@gmx.com> wrote:
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Eric Schulte <eric.schulte@gmx.com> writes:
>>>
>>>> Leo Alekseyev <dnquark@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,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Bring-back-prompt-for-single-block-tangling.patch --]
[-- Type: text/x-patch, Size: 1033 bytes --]

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


[-- Attachment #3: Type: text/plain, Size: 48 bytes --]



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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-03-19 14:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-03  4:40 Is it possible to run shell script src blocks as root or to export individual blocks? Leo Alekseyev
2012-03-03  8:55 ` Nick Dokos
2012-03-03  9:19 ` org-babel-execute-src-block deletes its src block Daimrod
2012-03-03  9:42   ` Nick Dokos
2012-03-03  9:54     ` Daimrod
2012-03-03 14:46     ` Eric Schulte
2012-03-03 15:11       ` Daimrod
2012-03-03 14:25 ` Is it possible to run shell script src blocks as root or to export individual blocks? Eric Schulte
2012-03-03 16:43   ` Andreas Leha
2012-03-05 15:24     ` Eric Schulte
2012-03-06  9:11       ` Andreas Leha
2012-03-19  8:42       ` Leo Alekseyev
2012-03-19 14:46         ` Eric Schulte
2012-03-04 17:29 ` Sylvain Rousseau

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).