From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Specifying the tangle filename based on the source filename? Date: Sun, 28 Jan 2018 14:54:44 +0100 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_68FD9560-4C15-475E-AE3E-3AD2AC4C5B80" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efnR5-0004C7-Sv for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 08:55:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efnR2-0003Z0-Rm for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 08:55:55 -0500 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:38470) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efnR2-0003YT-Iu for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 08:55:52 -0500 Received: by mail-wm0-x22a.google.com with SMTP id 141so28786110wme.3 for ; Sun, 28 Jan 2018 05:55:52 -0800 (PST) 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: emacs-orgmode@gnu.org Cc: Diego Zamboni --Apple-Mail=_68FD9560-4C15-475E-AE3E-3AD2AC4C5B80 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, 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: #+PROPERTY: header-args:emacs-lisp :tangle init.el 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. Thanks for any help, =E2=80=94Diego --Apple-Mail=_68FD9560-4C15-475E-AE3E-3AD2AC4C5B80 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hi,

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:

#+PROPERTY: header-args:emacs-lisp :tangle = init.el

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.

Thanks for any = help,
=E2=80=94Diego

= --Apple-Mail=_68FD9560-4C15-475E-AE3E-3AD2AC4C5B80-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jack Henahan Subject: Re: Specifying the tangle filename based on the source filename? Date: Sun, 28 Jan 2018 13:13:50 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efrSq-0006vc-2q for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 13:14:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efrSm-00070T-Ts for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 13:14:00 -0500 Received: from ms11p00im-qufv17100601.me.com ([17.58.37.33]:51445) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efrSm-0006zi-NC for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 13:13:56 -0500 Received: from process-dkim-sign-daemon.ms11p00im-qufv17100601.me.com by ms11p00im-qufv17100601.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0P3A0060005JPS00@ms11p00im-qufv17100601.me.com> for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 18:13:54 +0000 (GMT) Received: from icloud.com ([127.0.0.1]) by ms11p00im-qufv17100601.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0P3A0094U2N2P110@ms11p00im-qufv17100601.me.com> for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 18:13:54 +0000 (GMT) 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: emacs-orgmode@gnu.org I do something similar, and I use a snippet like this #+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))) (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-th= is-file)) "el") the-lib-directory)) (:noweb . "yes")))))) (add-hook 'org-mode-hook 'the-org-lib-hook) #+end_src `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 org/whatever.org * Configuring Whatever Features ** Requirements :noexport: #+begin_src emacs-lisp ;; -*- lexical-binding: t; -*- ;;; whatever.el --- Whatever functionality =20=20=20=20=20 (require 'whatever) #+end_src ** Some Subfeature Explain how we use the feature #+begin_src emacs-lisp (my-configuration 'stuff) #+end_src ** Provides :noexport: #+begin_src emacs-lisp (provide 'whatever) ;;; whatever.el ends here #+end_src 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. Diego Zamboni writes: > Hi, > > I=E2=80=99ve been converting many of my configuration files to org-mode t= o better document them (examples: > https://github.com/zzamboni/dot_emacs/blob/master/init.org, https://githu= b.com/zzamboni/dot_elvish/blob/master/rc.org). Usually I > have a line like the following at the top of each org file: > > #+PROPERTY: header-args:emacs-lisp :tangle init.el > > So that all the code blocks in the file are, by default, tangled to the c= orresponding config file. I was wondering if it might be > possible to avoid hardcoding the output file (=E2=80=9Cinit.el=E2=80=9D i= n this example) and instead derive it from the source filename (=E2=80=9Cin= it.org=E2=80=9D in > this case). I=E2=80=99ve looked a bit through the manual and although I f= ound the {{{input-file}}} macro, I couldn=E2=80=99t get it to work. > > Thanks for any help, > =E2=80=94Diego 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Rettke Subject: Re: Specifying the tangle filename based on the source filename? Date: Sun, 28 Jan 2018 14:47:11 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c1ce126e38b9c0563dc3bb8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eftr9-0006sW-Cv for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 15:47:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eftr8-0007S5-AO for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 15:47:15 -0500 Received: from mail-lf0-x235.google.com ([2a00:1450:4010:c07::235]:33438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eftr8-0007RZ-36 for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 15:47:14 -0500 Received: by mail-lf0-x235.google.com with SMTP id t139so7079513lff.0 for ; Sun, 28 Jan 2018 12:47:13 -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: Diego Zamboni Cc: Org-mode --94eb2c1ce126e38b9c0563dc3bb8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jan 28, 2018 at 7:54 AM, Diego Zamboni wrote: > Hi, > > I=E2=80=99ve been converting many of my configuration files to org-mode t= o better > document them (examples: https://github.com/zzamboni/dot_emacs/blob/ > master/init.org, https://github.com/zzamboni/dot_elvish/blob/master/rc.or= g). > Usually I have a line like the following at the top of each org file: > > #+PROPERTY: header-args:emacs-lisp :tangle init.el > > 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 avo= id > hardcoding the output file (=E2=80=9Cinit.el=E2=80=9D in this example) an= d 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 macro, I couldn=E2=80=99t get= it to > work. > > #+PROPERTY: header-args :tangle (concat (file-name-sans-extension (buffer-file-name)) ".el") #+NAME: org_gcr_2018-01-25_mara_5AA14ABD-5F82-4515-893A-B2370B6F4321 #+BEGIN_SRC emacs-lisp (message "Text") #+END_SRC --94eb2c1ce126e38b9c0563dc3bb8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Jan 28, 2018 at 7:54 AM, Diego Z= amboni <diego@zzamboni.org> wrote:
Hi,
I=E2=80=99ve been converting many of my configuration file= s to org-mode to better document them (examples:=C2=A0https:/= /github.com/zzamboni/dot_emacs/blob/master/init.org,=C2=A0https://github.com/zzamboni/dot_elvish/blob/master/rc= .org). Usually I have a line like the following at the top of each org = file:

#+PROPERTY: header-args:emacs-lisp :tan= gle init.el

So that all the code blocks in t= he file are, by default, tangled to the corresponding config file. I was wo= ndering 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 macro, I couldn=E2=80=99t get it to work.

--94eb2c1ce126e38b9c0563dc3bb8-- 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 22:07:46 +0100 Message-ID: <37438715-6FE1-4014-9FF1-159A10567636@zzamboni.org> References: Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_03C6B9D0-30E7-4D22-8C66-A97AD9E01101" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efuCN-0003WC-T0 for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 16:09:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efuCK-0002Ds-2t for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 16:09:11 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:39826) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efuCJ-0002DJ-OZ for emacs-orgmode@gnu.org; Sun, 28 Jan 2018 16:09:08 -0500 Received: by mail-wm0-x231.google.com with SMTP id b21so30116659wme.4 for ; Sun, 28 Jan 2018 13:09:07 -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: Grant Rettke Cc: Diego Zamboni , Org-mode --Apple-Mail=_03C6B9D0-30E7-4D22-8C66-A97AD9E01101 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Ah, this is exactly what I was looking for. Thanks! =E2=80=94Diego > On 28 Jan 2018, at 21:47, Grant Rettke = wrote: >=20 > On Sun, Jan 28, 2018 at 7:54 AM, Diego Zamboni > wrote: > 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 macro, I couldn=E2=80=99t = get it to work. >=20 > #+PROPERTY: header-args :tangle (concat (file-name-sans-extension = (buffer-file-name)) ".el") >=20 > #+NAME: org_gcr_2018-01-25_mara_5AA14ABD-5F82-4515-893A-B2370B6F4321 > #+BEGIN_SRC emacs-lisp > (message "Text") > #+END_SRC > =20 >=20 --Apple-Mail=_03C6B9D0-30E7-4D22-8C66-A97AD9E01101 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Ah, = this is exactly what I was looking for. Thanks!

=E2=80=94Diego


On Sun, Jan 28, 2018 at = 7:54 AM, Diego Zamboni <diego@zzamboni.org> wrote:
Hi,

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.orghttps://github.com/zzamboni/dot_elvish/blob/master/rc.org). Usually I have a line like = the following at the top of each org file:

#+PROPERTY: = header-args:emacs-lisp :tangle init.el

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=99= ve looked a bit through the manual and although I found the macro, I = couldn=E2=80=99t get it to work.

#+PROPERTY: = header-args :tangle (concat (file-name-sans-extension = (buffer-file-name)) ".el")

#+NAME: = org_gcr_2018-01-25_mara_5AA14ABD-5F82-4515-893A-B2370B6F4321
#+BEGIN_SRC emacs-lisp
(message = "Text")
#+END_SRC
 


= --Apple-Mail=_03C6B9D0-30E7-4D22-8C66-A97AD9E01101--