From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Re: Specifying the tangle filename based on the source filename? Date: Sun, 28 Jan 2018 21:15:03 +0100 Message-ID: References: Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eftNI-0004Z8-2S for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 15:16:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eftND-0007fS-H5 for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 15:16:24 -0500 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:53918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eftND-0007ck-43 for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 15:16:19 -0500 Received: by mail-wm0-x22c.google.com with SMTP id t74so10391735wme.3 for ; Sun, 28 Jan 2018 12:16:18 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jack Henahan Cc: Diego Zamboni , emacs-orgmode@gnu.org Hi Jack, This is very useful. At the moment I=E2=80=99m still keeping my org = files next to their generated files instead of a single tree, but your = code makes me think it should be possible to set up a save hook to set = the header-args variable for each file. I=E2=80=99m already using a save = hook to run org-babel-tangle when I save an org file, so it shouldn=E2=80=99= t be too difficult to add this. I=E2=80=99ll give it a try. Thanks for the pointer! Best, =E2=80=94Diego > On 28 Jan 2018, at 19:13, Jack Henahan wrote: >=20 > I do something similar, and I use a snippet like this >=20 > #+begin_src emacs-lisp > (defun the-in-the-org-lib-p () > (and (f-this-file) > (f-child-of? (f-this-file) the-org-lib-directory))) >=20 > (defun the-org-lib-hook () > (if (the-in-the-org-lib-p) > (progn > (setq-local org-babel-default-header-args:emacs-lisp > `((:tangle . ,(f-expand (f-swap-ext (f-filename = (f-this-file)) "el") the-lib-directory)) > (:noweb . "yes")))))) >=20 > (add-hook 'org-mode-hook 'the-org-lib-hook) > #+end_src >=20 > `the-org-lib-directory' points to where all my Org config sources are, > while `the-lib-directory' points to where the tangled files go. My Org > files then have a structure like >=20 > org/whatever.org >=20 > * Configuring Whatever Features > ** Requirements :noexport: > #+begin_src emacs-lisp > ;; -*- lexical-binding: t; -*- > ;;; whatever.el --- Whatever functionality >=20 > (require 'whatever) > #+end_src > ** Some Subfeature > Explain how we use the feature > #+begin_src emacs-lisp > (my-configuration 'stuff) > #+end_src >=20 > ** Provides :noexport: > #+begin_src emacs-lisp > (provide 'whatever) >=20 > ;;; whatever.el ends here > #+end_src >=20 > I have some additional configuration to tangle my lib files on save, = and > to regenerate the top-level documentation so that (in theory) the = README > is always up to date with the configuration. The :noexport: tags = remove > the noise of require and provides when I export. >=20 > Diego Zamboni writes: >=20 >> Hi, >>=20 >> I=E2=80=99ve been converting many of my configuration files to = org-mode to better document them (examples: >> https://github.com/zzamboni/dot_emacs/blob/master/init.org, = https://github.com/zzamboni/dot_elvish/blob/master/rc.org). Usually I >> have a line like the following at the top of each org file: >>=20 >> #+PROPERTY: header-args:emacs-lisp :tangle init.el >>=20 >> So that all the code blocks in the file are, by default, tangled to = the corresponding config file. I was wondering if it might be >> possible to avoid hardcoding the output file (=E2=80=9Cinit.el=E2=80=9D= in this example) and instead derive it from the source filename = (=E2=80=9Cinit.org=E2=80=9D in >> this case). I=E2=80=99ve looked a bit through the manual and although = I found the {{{input-file}}} macro, I couldn=E2=80=99t get it to work. >>=20 >> Thanks for any help, >> =E2=80=94Diego >=20