emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Deactivate babel source block
@ 2013-10-06  9:41 Michael Bach
  2013-10-06 15:09 ` Eric Schulte
  2013-10-06 15:09 ` Eric Schulte
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Bach @ 2013-10-06  9:41 UTC (permalink / raw)
  To: emacs-orgmode

Dear org-mode Users and Developers,


I am looking for a nice way to deactivate a babel source block with
point being anywhere on it. Imagine e.g. C-c C-v C-w to say "I want to
toggle execution/tangling for this block".

Background: I have the .emacs setup in a literate org-mode file where I
am testing new emacs packages.  Now many blocks represent specific
features that I want to be activated / deactivated.  This should ideally
behave like the other source code functions (i.e. C-c C-v family).

My naive approach as elisp noob was:
#+begin_src emacs-lisp
  (defun my-org-babel-deactivate ()
    (interactive)
    (org-edit-special)
    (mark-whole-buffer)
    (comment-region)
    (org-edit-src-exit))
#+end_src

Apart from it not working (Wrong number of arguments), this would have
been a dirty one in any case.  Now I thought there must be a better way
by setting/un-setting the respective header arguments in an automated
way.  Is this already possible with org-mode version 8.2?

Best Regards,
Michael

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

* Re: Deactivate babel source block
  2013-10-06  9:41 Deactivate babel source block Michael Bach
@ 2013-10-06 15:09 ` Eric Schulte
  2013-10-06 15:09 ` Eric Schulte
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Schulte @ 2013-10-06 15:09 UTC (permalink / raw)
  To: phaebz; +Cc: emacs-orgmode

You want to set the :eval and :tangle header arguments, this can be done
with `org-babel-insert-header-arg' bound to "C-c C-v j".  I've just
updated this function so that it now takes two optional arguments
specifying the header argument and value.

So the following could now be something like the following.

    (defun my-org-babel-deactivate ()
      (interactive)
      (org-babel-insert-header-arg "eval" "never")
      (org-babel-insert-header-arg "tangle" "no"))

Hope this helps,

Michael Bach <phaebz@gmail.com> writes:

> Dear org-mode Users and Developers,
>
>
> I am looking for a nice way to deactivate a babel source block with
> point being anywhere on it. Imagine e.g. C-c C-v C-w to say "I want to
> toggle execution/tangling for this block".
>
> Background: I have the .emacs setup in a literate org-mode file where I
> am testing new emacs packages.  Now many blocks represent specific
> features that I want to be activated / deactivated.  This should ideally
> behave like the other source code functions (i.e. C-c C-v family).
>
> My naive approach as elisp noob was:
> #+begin_src emacs-lisp
>   (defun my-org-babel-deactivate ()
>     (interactive)
>     (org-edit-special)
>     (mark-whole-buffer)
>     (comment-region)
>     (org-edit-src-exit))
> #+end_src
>
> Apart from it not working (Wrong number of arguments), this would have
> been a dirty one in any case.  Now I thought there must be a better way
> by setting/un-setting the respective header arguments in an automated
> way.  Is this already possible with org-mode version 8.2?
>
> Best Regards,
> Michael
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Re: Deactivate babel source block
  2013-10-06  9:41 Deactivate babel source block Michael Bach
  2013-10-06 15:09 ` Eric Schulte
@ 2013-10-06 15:09 ` Eric Schulte
  2013-10-06 15:23   ` Michael Bach
  2013-10-07  8:31   ` Rainer M Krug
  1 sibling, 2 replies; 7+ messages in thread
From: Eric Schulte @ 2013-10-06 15:09 UTC (permalink / raw)
  To: phaebz; +Cc: emacs-orgmode

You want to set the :eval and :tangle header arguments, this can be done
with `org-babel-insert-header-arg' bound to "C-c C-v j".  I've just
updated this function so that it now takes two optional arguments
specifying the header argument and value.

So your function could now be something like the following.

    (defun my-org-babel-deactivate ()
      (interactive)
      (org-babel-insert-header-arg "eval" "never")
      (org-babel-insert-header-arg "tangle" "no"))

Hope this helps,

Michael Bach <phaebz@gmail.com> writes:

> Dear org-mode Users and Developers,
>
>
> I am looking for a nice way to deactivate a babel source block with
> point being anywhere on it. Imagine e.g. C-c C-v C-w to say "I want to
> toggle execution/tangling for this block".
>
> Background: I have the .emacs setup in a literate org-mode file where I
> am testing new emacs packages.  Now many blocks represent specific
> features that I want to be activated / deactivated.  This should ideally
> behave like the other source code functions (i.e. C-c C-v family).
>
> My naive approach as elisp noob was:
> #+begin_src emacs-lisp
>   (defun my-org-babel-deactivate ()
>     (interactive)
>     (org-edit-special)
>     (mark-whole-buffer)
>     (comment-region)
>     (org-edit-src-exit))
> #+end_src
>
> Apart from it not working (Wrong number of arguments), this would have
> been a dirty one in any case.  Now I thought there must be a better way
> by setting/un-setting the respective header arguments in an automated
> way.  Is this already possible with org-mode version 8.2?
>
> Best Regards,
> Michael
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Re: Deactivate babel source block
  2013-10-06 15:09 ` Eric Schulte
@ 2013-10-06 15:23   ` Michael Bach
  2013-10-07  8:31   ` Rainer M Krug
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Bach @ 2013-10-06 15:23 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On 10/6/13 5:09 PM, Eric Schulte wrote:
> You want to set the :eval and :tangle header arguments, this can be done
> with `org-babel-insert-header-arg' bound to "C-c C-v j".  I've just
> updated this function so that it now takes two optional arguments
> specifying the header argument and value.
> 
> So your function could now be something like the following.
> 
>     (defun my-org-babel-deactivate ()
>       (interactive)
>       (org-babel-insert-header-arg "eval" "never")
>       (org-babel-insert-header-arg "tangle" "no"))
> 
> Hope this helps,
> 

Thanks for implementing this so quickly - I am currently on 8.2 release
branch, but am looking forward to it!

Michael

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

* Re: Deactivate babel source block
  2013-10-06 15:09 ` Eric Schulte
  2013-10-06 15:23   ` Michael Bach
@ 2013-10-07  8:31   ` Rainer M Krug
  2013-10-09  9:57     ` Eric S Fraga
  1 sibling, 1 reply; 7+ messages in thread
From: Rainer M Krug @ 2013-10-07  8:31 UTC (permalink / raw)
  To: emacs-orgmode

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

> You want to set the :eval and :tangle header arguments, this can be done
> with `org-babel-insert-header-arg' bound to "C-c C-v j".  I've just
> updated this function so that it now takes two optional arguments
> specifying the header argument and value.
>
> So your function could now be something like the following.
>
>     (defun my-org-babel-deactivate ()
>       (interactive)
>       (org-babel-insert-header-arg "eval" "never")
>       (org-babel-insert-header-arg "tangle" "no"))

Correct me if I am wrong, but I seem to remember that source blocks
under a commented heading are not tangled?

But I just tried it now, and it doesn't seem to be the case anymore -
code blocks under commented header are still tangled - has this feature
been removed or was it never there?

Rainer

>
> Hope this helps,
>
> Michael Bach <phaebz@gmail.com> writes:
>
>> Dear org-mode Users and Developers,
>>
>>
>> I am looking for a nice way to deactivate a babel source block with
>> point being anywhere on it. Imagine e.g. C-c C-v C-w to say "I want to
>> toggle execution/tangling for this block".
>>
>> Background: I have the .emacs setup in a literate org-mode file where I
>> am testing new emacs packages.  Now many blocks represent specific
>> features that I want to be activated / deactivated.  This should ideally
>> behave like the other source code functions (i.e. C-c C-v family).
>>
>> My naive approach as elisp noob was:
>> #+begin_src emacs-lisp
>>   (defun my-org-babel-deactivate ()
>>     (interactive)
>>     (org-edit-special)
>>     (mark-whole-buffer)
>>     (comment-region)
>>     (org-edit-src-exit))
>> #+end_src
>>
>> Apart from it not working (Wrong number of arguments), this would have
>> been a dirty one in any case.  Now I thought there must be a better way
>> by setting/un-setting the respective header arguments in an automated
>> way.  Is this already possible with org-mode version 8.2?
>>
>> Best Regards,
>> Michael
>>
>>
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

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

* Re: Deactivate babel source block
  2013-10-07  8:31   ` Rainer M Krug
@ 2013-10-09  9:57     ` Eric S Fraga
  2013-10-09 16:28       ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2013-10-09  9:57 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode

Rainer M Krug <Rainer@krugs.de> writes:

[...]

> Correct me if I am wrong, but I seem to remember that source blocks
> under a commented heading are not tangled?
>
> But I just tried it now, and it doesn't seem to be the case anymore -
> code blocks under commented header are still tangled - has this feature
> been removed or was it never there?

It was there; we had a discussion about this early this year.  There is
a commit log entry indicating that this was implemented:

,----
| commit 8e0b4529f780de4e442d26a7ba4aedd892c78c5b
| Author: Bastien Guerry <bzg@altern.org>
| Date:   Thu Feb 28 10:25:21 2013 +0100
| 
|     ob-tangle.el (org-babel-tangle-collect-blocks): Don't collect blocks in commented out headings
|     
|     * ob-tangle.el (org-babel-tangle-collect-blocks): Don't
|     collect blocks in commented out headings.
|     
|     Thansk to the various people who requested this.
`----

but I also found recently that code blocks in commented sections are
indeed tangled.

I have no idea what has happened to the code since.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.2.1-66-gf871fb

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

* Re: Deactivate babel source block
  2013-10-09  9:57     ` Eric S Fraga
@ 2013-10-09 16:28       ` Eric Schulte
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Schulte @ 2013-10-09 16:28 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Rainer M Krug <Rainer@krugs.de> writes:
>
> [...]
>
>> Correct me if I am wrong, but I seem to remember that source blocks
>> under a commented heading are not tangled?
>>
>> But I just tried it now, and it doesn't seem to be the case anymore -
>> code blocks under commented header are still tangled - has this feature
>> been removed or was it never there?
>
> It was there; we had a discussion about this early this year.  There is
> a commit log entry indicating that this was implemented:
>
> ,----
> | commit 8e0b4529f780de4e442d26a7ba4aedd892c78c5b
> | Author: Bastien Guerry <bzg@altern.org>
> | Date:   Thu Feb 28 10:25:21 2013 +0100
> | 
> |     ob-tangle.el (org-babel-tangle-collect-blocks): Don't collect blocks in commented out headings
> |     
> |     * ob-tangle.el (org-babel-tangle-collect-blocks): Don't
> |     collect blocks in commented out headings.
> |     
> |     Thansk to the various people who requested this.
> `----
>
> but I also found recently that code blocks in commented sections are
> indeed tangled.
>
> I have no idea what has happened to the code since.

It looks like commit 17131cb broke the heading handling of
`org-babel-tangle-collect-blocks' by removing the application of an
anonymous lambda function.

I just pushed up a fix which reapplies this function, and tangles the
following file correctly (i.e., does not tangle the commented heading).

Thanks for pointing this out.

Cheers,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

end of thread, other threads:[~2013-10-09 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-06  9:41 Deactivate babel source block Michael Bach
2013-10-06 15:09 ` Eric Schulte
2013-10-06 15:09 ` Eric Schulte
2013-10-06 15:23   ` Michael Bach
2013-10-07  8:31   ` Rainer M Krug
2013-10-09  9:57     ` Eric S Fraga
2013-10-09 16:28       ` Eric Schulte

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).