"Charles C. Berry" <cbe...@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

_______________________________________________
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

Reply via email to