emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BABEL] Tangling to a hierarchy of files?
@ 2011-01-19  4:02 Christopher Maier
  2011-01-19  6:45 ` Charles C. Berry
  0 siblings, 1 reply; 15+ messages in thread
From: Christopher Maier @ 2011-01-19  4:02 UTC (permalink / raw)
  To: emacs-orgmode

I've been experimenting with literate programming using Org mode recently and am
really enjoying it.  I am trying to figure out the best way to create a nested
hierarchy of tangled files from a single Org file, and am not sure the best way
to go about it.

I know that, for example, this block, when tangled, will produce a file
"foo.clj" in the same directory as my Org file... so far so good.

#+begin_src clojure :tangle foo.clj
  (ns foo)
  
  (defn my-inc [x]
    (+ x 1))
#+end_src

However, I would like to be able to do something like this:

#+begin_src clojure :tangle src/foo.clj
  (ns foo)
  
  (defn my-inc [x]
    (+ x 1))
#+end_src

(I'm trying to automatically generate a Leiningen project for Clojure, if that
helps any.)

If I tangle an Org file that contains a block like this, and I haven't already
created a "src" directory, then I get an error ("Opening output file: No such
file or directory...").

I could create a shell script block in my file that will create whatever
directory hierarchy I need, but it looks like I'd have to manually execute that
prior to tangling my source code.  I've seen some examples on the mailing list
using Emacs Lisp code blocks to set up a custom org-babel-pre-tangle-hook, but
it still seems that there's a manual execution step required.

Is there a better (maybe already built-in?) way to achieve this?  Ideally, I'd
eventually like to set things up so that I could invoke a single function that
would create the file hierarchy, tangle the files, generate documentation, and
then run tests and other build-related stuff.  Is that possible without leaving
Org?

Thanks in advance for any help.

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19  4:02 [BABEL] Tangling to a hierarchy of files? Christopher Maier
@ 2011-01-19  6:45 ` Charles C. Berry
  2011-01-19  7:22   ` Eric Schulte
  0 siblings, 1 reply; 15+ messages in thread
From: Charles C. Berry @ 2011-01-19  6:45 UTC (permalink / raw)
  To: Christopher Maier; +Cc: emacs-orgmode

On Wed, 19 Jan 2011, Christopher Maier wrote:

> I've been experimenting with literate programming using Org mode recently and am
> really enjoying it.  I am trying to figure out the best way to create a nested
> hierarchy of tangled files from a single Org file, and am not sure the best way
> to go about it.
>
> I know that, for example, this block, when tangled, will produce a file
> "foo.clj" in the same directory as my Org file... so far so good.
>
> #+begin_src clojure :tangle foo.clj
>  (ns foo)
>
>  (defn my-inc [x]
>    (+ x 1))
> #+end_src
>
> However, I would like to be able to do something like this:
>
> #+begin_src clojure :tangle src/foo.clj
>  (ns foo)
>
>  (defn my-inc [x]
>    (+ x 1))
> #+end_src
>
> (I'm trying to automatically generate a Leiningen project for Clojure, if that
> helps any.)
>
> If I tangle an Org file that contains a block like this, and I haven't already
> created a "src" directory, then I get an error ("Opening output file: No such
> file or directory...").
>
> I could create a shell script block in my file that will create whatever
> directory hierarchy I need, but it looks like I'd have to manually execute that
> prior to tangling my source code.  I've seen some examples on the mailing list
> using Emacs Lisp code blocks to set up a custom org-babel-pre-tangle-hook, but
> it still seems that there's a manual execution step required.


Maybe a file that starts something like this would work for you:


,----
| # -*- eval: (make-directory "src" ".") -*-
| #+Title: Evaluates code on startup
| 
| * contents
`----

On opening, a 'src' directory is created if it doesn't already exist.

>
> Is there a better (maybe already built-in?) way to achieve this?  Ideally, I'd
> eventually like to set things up so that I could invoke a single function that
> would create the file hierarchy, tangle the files, generate documentation, and
> then run tests and other build-related stuff.  Is that possible without leaving
> Org?

An emacs-lisp src block to do all those things, perhaps?

HTH,

Chuck

>
> Thanks in advance for any help.
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

Charles C. Berry                            Dept of Family/Preventive Medicine
cberry@tajo.ucsd.edu			    UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19  6:45 ` Charles C. Berry
@ 2011-01-19  7:22   ` Eric Schulte
  2011-01-19 10:05     ` Rainer M Krug
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Schulte @ 2011-01-19  7:22 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: Christopher Maier, emacs-orgmode

"Charles C. Berry" <cberry@tajo.ucsd.edu> writes:

> On Wed, 19 Jan 2011, Christopher Maier wrote:
>
>> I've been experimenting with literate programming using Org mode recently and am
>> really enjoying it.  I am trying to figure out the best way to create a nested
>> hierarchy of tangled files from a single Org file, and am not sure the best way
>> to go about it.
>>
>> I know that, for example, this block, when tangled, will produce a file
>> "foo.clj" in the same directory as my Org file... so far so good.
>>
>> #+begin_src clojure :tangle foo.clj
>>  (ns foo)
>>
>>  (defn my-inc [x]
>>    (+ x 1))
>> #+end_src
>>
>> However, I would like to be able to do something like this:
>>
>> #+begin_src clojure :tangle src/foo.clj
>>  (ns foo)
>>
>>  (defn my-inc [x]
>>    (+ x 1))
>> #+end_src
>>

In addition to the solution Charles posted, it is possible to put
arbitrary elisp forms into header arguments, so the following
alternative to your block above will create the directory (if it doesn't
already exist) whenever the block is tangled or evaluated.

#+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" "."))
  (ns foo)
  
  (defn my-inc [x]
    (+ x 1))
#+end_src

Cheers -- Eric

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19  7:22   ` Eric Schulte
@ 2011-01-19 10:05     ` Rainer M Krug
  2011-01-19 11:59       ` Chris Maier
  0 siblings, 1 reply; 15+ messages in thread
From: Rainer M Krug @ 2011-01-19 10:05 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Christopher Maier, Charles C. Berry

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/19/2011 08:22 AM, Eric Schulte wrote:
> "Charles C. Berry" <cberry@tajo.ucsd.edu> writes:
> 
>> On Wed, 19 Jan 2011, Christopher Maier wrote:
>>
>>> I've been experimenting with literate programming using Org mode recently and am
>>> really enjoying it.  I am trying to figure out the best way to create a nested
>>> hierarchy of tangled files from a single Org file, and am not sure the best way
>>> to go about it.
>>>
>>> I know that, for example, this block, when tangled, will produce a file
>>> "foo.clj" in the same directory as my Org file... so far so good.
>>>
>>> #+begin_src clojure :tangle foo.clj
>>>  (ns foo)
>>>
>>>  (defn my-inc [x]
>>>    (+ x 1))
>>> #+end_src
>>>
>>> However, I would like to be able to do something like this:
>>>
>>> #+begin_src clojure :tangle src/foo.clj
>>>  (ns foo)
>>>
>>>  (defn my-inc [x]
>>>    (+ x 1))
>>> #+end_src
>>>
> 
> In addition to the solution Charles posted, it is possible to put
> arbitrary elisp forms into header arguments, so the following
> alternative to your block above will create the directory (if it doesn't
> already exist) whenever the block is tangled or evaluated.
> 
> #+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" "."))
>   (ns foo)
>   
>   (defn my-inc [x]
>     (+ x 1))
> #+end_src

Would it be possible, to include this into tangling, i.e. if the folder
in which the source file should be created does not exist, create it?

I remember vaguely a discussion along these lines some time ago, but I
don't remember the outcome?

Rainer

> 
> Cheers -- Eric
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      Rainer@krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk02t20ACgkQoYgNqgF2egqJcwCeMaM/k5MeTsZ07crbr0CfpCMB
zrkAniGC6QejbjMsksxnD7I/QS3em0Xh
=+yMc
-----END PGP SIGNATURE-----

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 10:05     ` Rainer M Krug
@ 2011-01-19 11:59       ` Chris Maier
  2011-01-19 12:06         ` Rainer M Krug
                           ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Chris Maier @ 2011-01-19 11:59 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode, Charles C. Berry

On Wed, Jan 19, 2011 at 5:05 AM, Rainer M Krug <r.m.krug@gmail.com> wrote:
> On 01/19/2011 08:22 AM, Eric Schulte wrote:
>>
>> In addition to the solution Charles posted, it is possible to put
>> arbitrary elisp forms into header arguments, so the following
>> alternative to your block above will create the directory (if it doesn't
>> already exist) whenever the block is tangled or evaluated.
>>
>> #+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" "."))
>>   (ns foo)
>>
>>   (defn my-inc [x]
>>     (+ x 1))
>> #+end_src

This will do what I'm looking for, thanks!

Is there a place where this and the eval-on-startup trick Charles
posted are documented?  If so, I missed it, and these are both really
useful to know.

> Would it be possible, to include this into tangling, i.e. if the folder
> in which the source file should be created does not exist, create it?
>
> I remember vaguely a discussion along these lines some time ago, but I
> don't remember the outcome?

This would be a great feature to have.  Eric's embedded Lisp code
trick will do the job, but I can imagine that it would get cumbersome
for more complex projects.

Thanks for all the help, everyone!

Chris

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 11:59       ` Chris Maier
@ 2011-01-19 12:06         ` Rainer M Krug
  2011-01-19 16:20         ` Charles C. Berry
  2011-01-19 17:41         ` Eric Schulte
  2 siblings, 0 replies; 15+ messages in thread
From: Rainer M Krug @ 2011-01-19 12:06 UTC (permalink / raw)
  To: Chris Maier; +Cc: emacs-orgmode, Charles C. Berry

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/19/2011 12:59 PM, Chris Maier wrote:
> On Wed, Jan 19, 2011 at 5:05 AM, Rainer M Krug <r.m.krug@gmail.com> wrote:
>> On 01/19/2011 08:22 AM, Eric Schulte wrote:
>>>
>>> In addition to the solution Charles posted, it is possible to put
>>> arbitrary elisp forms into header arguments, so the following
>>> alternative to your block above will create the directory (if it doesn't
>>> already exist) whenever the block is tangled or evaluated.
>>>
>>> #+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" "."))
>>>   (ns foo)
>>>
>>>   (defn my-inc [x]
>>>     (+ x 1))
>>> #+end_src
> 
> This will do what I'm looking for, thanks!
> 
> Is there a place where this and the eval-on-startup trick Charles
> posted are documented?  If so, I missed it, and these are both really
> useful to know.
> 
>> Would it be possible, to include this into tangling, i.e. if the folder
>> in which the source file should be created does not exist, create it?
>>
>> I remember vaguely a discussion along these lines some time ago, but I
>> don't remember the outcome?
> 
> This would be a great feature to have.  Eric's embedded Lisp code
> trick will do the job, but I can imagine that it would get cumbersome
> for more complex projects.

Exactly - you effectively have to specify the same path twice - very
error prone.


Cheers,

Rainer

> 
> Thanks for all the help, everyone!
> 
> Chris


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      Rainer@krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0209kACgkQoYgNqgF2egpTuACeKw3OUQSA5x7ugyJe4syt0PkP
pPgAnj77qMjWHKputXIn836nEclfsjg6
=mkG3
-----END PGP SIGNATURE-----

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 11:59       ` Chris Maier
  2011-01-19 12:06         ` Rainer M Krug
@ 2011-01-19 16:20         ` Charles C. Berry
  2011-01-19 16:27           ` Chris Maier
  2011-01-19 17:41         ` Eric Schulte
  2 siblings, 1 reply; 15+ messages in thread
From: Charles C. Berry @ 2011-01-19 16:20 UTC (permalink / raw)
  To: Chris Maier; +Cc: emacs-orgmode, Rainer M Krug

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1703 bytes --]

On Wed, 19 Jan 2011, Chris Maier wrote:

> On Wed, Jan 19, 2011 at 5:05 AM, Rainer M Krug <r.m.krug@gmail.com> wrote:
>> On 01/19/2011 08:22 AM, Eric Schulte wrote:
>>>
>>> In addition to the solution Charles posted, it is possible to put
>>> arbitrary elisp forms into header arguments, so the following
>>> alternative to your block above will create the directory (if it doesn't
>>> already exist) whenever the block is tangled or evaluated.
>>>
>>> #+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" "."))
>>>   (ns foo)
>>>
>>>   (defn my-inc [x]
>>>     (+ x 1))
>>> #+end_src
>
> This will do what I'm looking for, thanks!
>
> Is there a place where this and the eval-on-startup trick Charles
> posted are documented?  If so, I missed it, and these are both really
> useful to know.


C-h i, then navigate to

(emacs)Top > Customization > Variables > File Variables > Specifying File 
Variables

'eval' is a special kind of file variable.

Chuck

>
>> Would it be possible, to include this into tangling, i.e. if the folder
>> in which the source file should be created does not exist, create it?
>>
>> I remember vaguely a discussion along these lines some time ago, but I
>> don't remember the outcome?
>
> This would be a great feature to have.  Eric's embedded Lisp code
> trick will do the job, but I can imagine that it would get cumbersome
> for more complex projects.
>
> Thanks for all the help, everyone!
>
> Chris
>

Charles C. Berry                            Dept of Family/Preventive Medicine
cberry@tajo.ucsd.edu			    UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901


[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 16:20         ` Charles C. Berry
@ 2011-01-19 16:27           ` Chris Maier
  0 siblings, 0 replies; 15+ messages in thread
From: Chris Maier @ 2011-01-19 16:27 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode, Rainer M Krug

On Wed, Jan 19, 2011 at 11:20 AM, Charles C. Berry <cberry@tajo.ucsd.edu> wrote:
> On Wed, 19 Jan 2011, Chris Maier wrote:
>> Is there a place where this and the eval-on-startup trick Charles
>> posted are documented?  If so, I missed it, and these are both really
>> useful to know.
>
>
> C-h i, then navigate to
>
> (emacs)Top > Customization > Variables > File Variables > Specifying File
> Variables
>
> 'eval' is a special kind of file variable.

Ah, it's for Emacs in general instead of Org mode... thanks for the
tip, Charles.

No matter how much you know about Emacs, it seems there's always
something new to learn :)

Chris

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 11:59       ` Chris Maier
  2011-01-19 12:06         ` Rainer M Krug
  2011-01-19 16:20         ` Charles C. Berry
@ 2011-01-19 17:41         ` Eric Schulte
  2011-01-19 18:18           ` Chris Maier
  2011-01-20  9:09           ` Christopher Witte
  2 siblings, 2 replies; 15+ messages in thread
From: Eric Schulte @ 2011-01-19 17:41 UTC (permalink / raw)
  To: Chris Maier; +Cc: emacs-orgmode, Charles C. Berry, Rainer M Krug

Chris Maier <christopher.maier@gmail.com> writes:

> On Wed, Jan 19, 2011 at 5:05 AM, Rainer M Krug <r.m.krug@gmail.com> wrote:
>> On 01/19/2011 08:22 AM, Eric Schulte wrote:
>>>
>>> In addition to the solution Charles posted, it is possible to put
>>> arbitrary elisp forms into header arguments, so the following
>>> alternative to your block above will create the directory (if it doesn't
>>> already exist) whenever the block is tangled or evaluated.
>>>
>>> #+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" "."))
>>>   (ns foo)
>>>
>>>   (defn my-inc [x]
>>>     (+ x 1))
>>> #+end_src
>
> This will do what I'm looking for, thanks!
>
> Is there a place where this and the eval-on-startup trick Charles
> posted are documented?  If so, I missed it, and these are both really
> useful to know.
>

We don't currently have a good place in which to collect such tricks,
probably the closest is a file called scraps.org which I use for
stubbing out examples when responding to mailing list questions or doing
development.  Each subheading is a short self-contained example.  I do
plan on transforming this at some point into either a page on Worg
"Babel Tricks" or into a "Babel a Day" series or some such.  The page is
available at the following (notice this dir. trick is at the top)
https://github.com/eschulte/babel-dev/raw/master/scraps.org

If anyone would like to take on the task of transferring this
information into a page on Worg that would be much appreciated!  Maybe a
programmatic solution would be best, since I imagine this file will
continue to grow, or maybe I should just move this file to Worg
directly, if the Worg maintainers don't mind a steady trickle of small
commits...

>
>> Would it be possible, to include this into tangling, i.e. if the folder
>> in which the source file should be created does not exist, create it?
>>
>> I remember vaguely a discussion along these lines some time ago, but I
>> don't remember the outcome?
>
> This would be a great feature to have.  Eric's embedded Lisp code
> trick will do the job, but I can imagine that it would get cumbersome
> for more complex projects.
>

This issue has come up recently -- also raised (I believe) by a
Clojurian most likely wanted to create a lein directory layout.

The reason that I push back against this, is that I often times
accidentally use a tangle path in which the directory does not exist and
the error notification serves as a useful warning that I either
mis-typed the directory or need to create it.

I would suggest either using the pre-tangle hook, or using my trick
above, which could be made more graceful with the following function
defined...

#+begin_src emacs-lisp
  (defun mkdir-p (file &optional dir)
    "Create any parent directories of FILE if missing and return FILE."
    (make-directory (file-name-directory file) (or dir ".")) file)
#+end_src

However given that there seems to be some wide support for this maybe a
customization variable should be introduce,
e.g. org-babel-tangle-mkdirs-p or somesuch...

Cheers -- Eric

>
> Thanks for all the help, everyone!
>
> Chris

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 17:41         ` Eric Schulte
@ 2011-01-19 18:18           ` Chris Maier
  2011-01-20  3:37             ` Eric Schulte
  2011-01-20  9:09           ` Christopher Witte
  1 sibling, 1 reply; 15+ messages in thread
From: Chris Maier @ 2011-01-19 18:18 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Charles C. Berry, Rainer M Krug

On Wed, Jan 19, 2011 at 12:41 PM, Eric Schulte <schulte.eric@gmail.com> wrote:
> Chris Maier <christopher.maier@gmail.com> writes:
>>
>> Is there a place where this and the eval-on-startup trick Charles
>> posted are documented?  If so, I missed it, and these are both really
>> useful to know.
>>
>
> We don't currently have a good place in which to collect such tricks,
> probably the closest is a file called scraps.org which I use for
> stubbing out examples when responding to mailing list questions or doing
> development.  Each subheading is a short self-contained example.  I do
> plan on transforming this at some point into either a page on Worg
> "Babel Tricks" or into a "Babel a Day" series or some such.  The page is
> available at the following (notice this dir. trick is at the top)
> https://github.com/eschulte/babel-dev/raw/master/scraps.org

Thanks for the link.

>>> Would it be possible, to include this into tangling, i.e. if the folder
>>> in which the source file should be created does not exist, create it?
>>>
>>> I remember vaguely a discussion along these lines some time ago, but I
>>> don't remember the outcome?
>>
>> This would be a great feature to have.  Eric's embedded Lisp code
>> trick will do the job, but I can imagine that it would get cumbersome
>> for more complex projects.
>>
>
> This issue has come up recently -- also raised (I believe) by a
> Clojurian most likely wanted to create a lein directory layout.
>
> The reason that I push back against this, is that I often times
> accidentally use a tangle path in which the directory does not exist and
> the error notification serves as a useful warning that I either
> mis-typed the directory or need to create it.
>
> I would suggest either using the pre-tangle hook, or using my trick
> above, which could be made more graceful with the following function
> defined...
>
> #+begin_src emacs-lisp
>  (defun mkdir-p (file &optional dir)
>    "Create any parent directories of FILE if missing and return FILE."
>    (make-directory (file-name-directory file) (or dir ".")) file)
> #+end_src
>
> However given that there seems to be some wide support for this maybe a
> customization variable should be introduce,
> e.g. org-babel-tangle-mkdirs-p or somesuch...
>
> Cheers -- Eric

A customization variable would be fantastic.  Could it be done such
that it could be applied (or not applied, according to taste) to a
sub-tree of your Org file?  That way you could have it disabled on
whatever code you might be currently working on so you still see the
error messages if you mistype.  Then, when you're satisfied with all
your tangle paths, you could flip the switch on that sub-tree and have
Org do everything for you.

Chris

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 18:18           ` Chris Maier
@ 2011-01-20  3:37             ` Eric Schulte
  2011-01-20 10:06               ` Rainer M Krug
  2011-01-21  2:11               ` Chris Maier
  0 siblings, 2 replies; 15+ messages in thread
From: Eric Schulte @ 2011-01-20  3:37 UTC (permalink / raw)
  To: Chris Maier; +Cc: emacs-orgmode, Charles C. Berry, Rainer M Krug

>
> A customization variable would be fantastic.  Could it be done such
> that it could be applied (or not applied, according to taste) to a
> sub-tree of your Org file?  That way you could have it disabled on
> whatever code you might be currently working on so you still see the
> error messages if you mistype.  Then, when you're satisfied with all
> your tangle paths, you could flip the switch on that sub-tree and have
> Org do everything for you.
>

This has now been added as a new :mkdirp code block header argument, so
it can be set on the block, subtree, file, language, or global level
(see http://orgmode.org/manual/Using-header-arguments.html).

#+begin_src language :mkdirp yes :tangle nested/directories/target.ext
  code body
#+end_src

Cheers -- Eric

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-19 17:41         ` Eric Schulte
  2011-01-19 18:18           ` Chris Maier
@ 2011-01-20  9:09           ` Christopher Witte
  2011-01-20 16:11             ` Eric Schulte
  1 sibling, 1 reply; 15+ messages in thread
From: Christopher Witte @ 2011-01-20  9:09 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Charles C. Berry, Chris Maier, emacs-orgmode, Rainer M Krug


[-- Attachment #1.1: Type: text/plain, Size: 462 bytes --]

 On 19 January 2011 18:41, Eric Schulte <schulte.eric@gmail.com> wrote:

> The reason that I push back against this, is that I often times
> accidentally use a tangle path in which the directory does not exist and
> the error notification serves as a useful warning that I either
> mis-typed the directory or need to create it.
>

Why not make the function prompt the user if they want to create the
directory? That way you get the best of both worlds.


Chris.

[-- Attachment #1.2: Type: text/html, Size: 740 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-20  3:37             ` Eric Schulte
@ 2011-01-20 10:06               ` Rainer M Krug
  2011-01-21  2:11               ` Chris Maier
  1 sibling, 0 replies; 15+ messages in thread
From: Rainer M Krug @ 2011-01-20 10:06 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Chris Maier, Charles C. Berry

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/20/2011 04:37 AM, Eric Schulte wrote:
>>
>> A customization variable would be fantastic.  Could it be done such
>> that it could be applied (or not applied, according to taste) to a
>> sub-tree of your Org file?  That way you could have it disabled on
>> whatever code you might be currently working on so you still see the
>> error messages if you mistype.  Then, when you're satisfied with all
>> your tangle paths, you could flip the switch on that sub-tree and have
>> Org do everything for you.
>>
> 
> This has now been added as a new :mkdirp code block header argument, so
> it can be set on the block, subtree, file, language, or global level
> (see http://orgmode.org/manual/Using-header-arguments.html).
> 
> #+begin_src language :mkdirp yes :tangle nested/directories/target.ext
>   code body
> #+end_src

Sounds perfect for me - thanks.

Rainer

> 
> Cheers -- Eric


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:        +33 - (0)9 53 10 27 44
Cell:       +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:      Rainer@krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk04CRcACgkQoYgNqgF2ego39ACaAhYz3GYfAKBODtY8KDJmYIdZ
jpQAn0pQNxcCwnzUtQo6m1lugmSIXaDE
=Fxrd
-----END PGP SIGNATURE-----

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-20  9:09           ` Christopher Witte
@ 2011-01-20 16:11             ` Eric Schulte
  0 siblings, 0 replies; 15+ messages in thread
From: Eric Schulte @ 2011-01-20 16:11 UTC (permalink / raw)
  To: Christopher Witte
  Cc: Charles C. Berry, Chris Maier, emacs-orgmode, Rainer M Krug

Christopher Witte <chris@witte.net.au> writes:

>  On 19 January 2011 18:41, Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The reason that I push back against this, is that I often times
>> accidentally use a tangle path in which the directory does not exist and
>> the error notification serves as a useful warning that I either
>> mis-typed the directory or need to create it.
>>
>
> Why not make the function prompt the user if they want to create the
> directory? That way you get the best of both worlds.
>

This would be a departure from all existing header arguments none of
which will require a prompt.  In fact the only time that evaluating a
code block can lead to a prompt is through the confirmation construct
which is allowed to be special because it is a security concern.

That said if you do want more complex behavior like prompting you should
be able to add this sort of thing to the `org-babel-pre-tangle-hook'.

Best -- Eric

>
>
> Chris.

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

* Re: [BABEL] Tangling to a hierarchy of files?
  2011-01-20  3:37             ` Eric Schulte
  2011-01-20 10:06               ` Rainer M Krug
@ 2011-01-21  2:11               ` Chris Maier
  1 sibling, 0 replies; 15+ messages in thread
From: Chris Maier @ 2011-01-21  2:11 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Charles C. Berry, Rainer M Krug

On Wed, Jan 19, 2011 at 10:37 PM, Eric Schulte <schulte.eric@gmail.com> wrote:
>
> This has now been added as a new :mkdirp code block header argument, so
> it can be set on the block, subtree, file, language, or global level
> (see http://orgmode.org/manual/Using-header-arguments.html).
>
> #+begin_src language :mkdirp yes :tangle nested/directories/target.ext
>  code body
> #+end_src
>
> Cheers -- Eric
>

Just got around to incorporating this into my Emacs setup... works
like a charm.  Thanks for this, Eric!

Chris

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

end of thread, other threads:[~2011-01-21  2:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19  4:02 [BABEL] Tangling to a hierarchy of files? Christopher Maier
2011-01-19  6:45 ` Charles C. Berry
2011-01-19  7:22   ` Eric Schulte
2011-01-19 10:05     ` Rainer M Krug
2011-01-19 11:59       ` Chris Maier
2011-01-19 12:06         ` Rainer M Krug
2011-01-19 16:20         ` Charles C. Berry
2011-01-19 16:27           ` Chris Maier
2011-01-19 17:41         ` Eric Schulte
2011-01-19 18:18           ` Chris Maier
2011-01-20  3:37             ` Eric Schulte
2011-01-20 10:06               ` Rainer M Krug
2011-01-21  2:11               ` Chris Maier
2011-01-20  9:09           ` Christopher Witte
2011-01-20 16:11             ` 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).