From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Maier Subject: Re: [BABEL] Tangling to a hierarchy of files? Date: Wed, 19 Jan 2011 13:18:45 -0500 Message-ID: References: <87tyh5icir.fsf@gmail.com> <4D36B76D.9020502@gmail.com> <87vd1k3i62.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=53881 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfccL-00046W-V5 for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 13:18:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfccK-0002L0-Kn for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 13:18:49 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:50406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfccK-0002KX-Ek for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 13:18:48 -0500 Received: by pwj8 with SMTP id 8so289731pwj.0 for ; Wed, 19 Jan 2011 10:18:47 -0800 (PST) In-Reply-To: <87vd1k3i62.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org, "Charles C. Berry" , Rainer M Krug On Wed, Jan 19, 2011 at 12:41 PM, Eric Schulte wro= te: > Chris Maier writes: >> >> Is there a place where this and the eval-on-startup trick Charles >> posted are documented? =A0If 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. =A0Each subheading is a short self-contained example. =A0I d= o > 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. =A0The page i= s > 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. =A0Eric'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 > =A0(defun mkdir-p (file &optional dir) > =A0 =A0"Create any parent directories of FILE if missing and return FILE.= " > =A0 =A0(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