emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <cberry@tajo.ucsd.edu>
To: Christopher Maier <christopher.maier@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BABEL] Tangling to a hierarchy of files?
Date: Tue, 18 Jan 2011 22:45:42 -0800	[thread overview]
Message-ID: <Pine.LNX.4.64.1101182216260.14809@tajo.ucsd.edu> (raw)
In-Reply-To: <loom.20110119T044416-421@post.gmane.org>

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

  reply	other threads:[~2011-01-19  6:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19  4:02 [BABEL] Tangling to a hierarchy of files? Christopher Maier
2011-01-19  6:45 ` Charles C. Berry [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1101182216260.14809@tajo.ucsd.edu \
    --to=cberry@tajo.ucsd.edu \
    --cc=christopher.maier@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).