From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Re: Feature request: Maintaining multiple init files with one org file Date: Mon, 30 Jul 2018 21:25:02 +0200 Message-ID: References: <87va8ziuem.fsf@ntnu.no> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001849ba05723c6b5a" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkDn1-0003Ik-SY for emacs-orgmode@gnu.org; Mon, 30 Jul 2018 15:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkDmz-0001CI-SE for emacs-orgmode@gnu.org; Mon, 30 Jul 2018 15:25:07 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:40948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkDmz-0001AV-FK for emacs-orgmode@gnu.org; Mon, 30 Jul 2018 15:25:05 -0400 Received: by mail-wm0-x235.google.com with SMTP id y9-v6so543162wma.5 for ; Mon, 30 Jul 2018 12:25:04 -0700 (PDT) In-Reply-To: <87va8ziuem.fsf@ntnu.no> 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: Sven Bretfeld Cc: Org-mode --0000000000001849ba05723c6b5a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Sven, Personally, I do not like the idea of having to generate the config files on every host - I prefer to tangle once, on my main machine, and then distribute (via git) both the org source and the tangled result to all my machines. This results in much lower maintenance effort - otherwise I would need to login to each machine, open Emacs there, and tangle the file (or automate the process, but still, more work than doing it once). This means that the logic still needs to be present in the resulting file, but it doesn't mean the org source needs to be less readable. What I do is use noweb mode selectively, to indicate the corresponding sections. I use this for the OS-specific configuration in my Emacs file: https://github.com/zzamboni/dot-emacs/blob/master/init.org#system-specific-= configuration . In short, the top-level block includes the necessary logic, plus the corresponding sections in noweb-style references (the :noweb no-export makes it so that the tags get expanded only when tangling and not when exporting, which makes my rendered config files more readable, see the links below): #+begin_src emacs-lisp :noweb no-export (cond ((eq system-type 'darwin) <> ) ((eq system-type 'windows-nt) <> ) ((eq system-type 'gnu/linux) <> )) #+end_src Then, each subsection sets the corresponding section-level properties, so that they don't have to be specified in each block - then all the blocks within that section will be automatically inserted in the corresponding "section" of the cond statement above. For example: ** Mac :PROPERTIES: :header-args:emacs-lisp: :tangle no :noweb-ref Mac settings :END: First, we set the key modifiers correctly to my preferences: Make Command (=E2=8C=98) act as Meta, Option as Alt, right-Option as Super #+begin_src emacs-lisp (customize-set-variable 'mac-command-modifier 'meta) (customize-set-variable 'mac-option-modifier 'alt) (customize-set-variable 'mac-right-option-modifier 'super) #+end_src You can see the real file here: https://github.com/zzamboni/dot-emacs/blob/master/init.org#system-specific-= configuration, or in a nicer rendering in my blog: https://zzamboni.org/post/my-emacs-configuration-with-commentary/#system-sp= ecific-configuration Hope this helps - not exactly what you asked, but maybe a useful alternative? Best, --Diego On Sat, Jul 28, 2018 at 11:25 AM, Sven Bretfeld wrote: > Hi > > I don't know how you guys maintain init files for different hosts. I > have one org-file with the header: > > #+PROPERTY: header-args :tangle ~/.emacs > > The file is synced to all my machines and produces the local init files > on each. Most configurations are shared, but some are host-specific > (e.g. font size). > > Sadly export filtering does not work with the tangle function. It would > be nice to be able to do something like: > > ,---- > | * Default Frame > | ** Office Computer :OFFICE: > | #+begin_src emacs-lisp > | (setq default-frame-alist '( > | (font . "-PfEd-DejaVu Sans Mono-normal-normal-normal-*- > 26-*-*-*-m-0-iso10646-1") > | (width . 102) > | (height . 41)) > | #+end_src > | > | ** Computer at home :HOME: > | #+begin_src emacs-lisp > | (setq default-frame-alist '( > | (font . "-PfEd-DejaVu Sans Mono-normal-normal-normal-*- > 18-*-*-*-m-0-iso10646-1") > | (width . 150) > | (height . 50)) > | #+end_src > | > | ** Laptop :LAPTOP: > | #+begin_src emacs-lisp > | (setq default-frame-alist '( > | (font . "-PfEd-DejaVu Sans Mono-normal-normal-normal-*- > 12-*-*-*-m-0-iso10646-1") > | (width . 80) > | (height . 30)) > | #+end_src > `---- > > It should be clear what this is about. On the office computer you would > prepare the file headers to exclude the tags HOME and LAPTOP from being > tangled and, after saving/tangling the file, you would have a nice init > file suiting this computer. At home the same by excluding the other tags > etc. > > This would save a lot of work and you would have a tidy way to maintain > all your init files without (if (string-equal (system-name) clauses. > > If the noexport tag worked, it would also save a lot of time and mess > when debugging your init file in case of an error. > > I don't actually understand why the developers decided not to implement > export filtering in the tangling operations. I know about the COMMENT > keyword, but the above example should make clear that this solution is > far from handy. > > Maybe there is another way that escaped me so far? > > All best, > > Sven > > > --0000000000001849ba05723c6b5a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Sven,

Personally, I do not like the = idea of having to generate the config files on every host - I prefer to tan= gle once, on my main machine, and then distribute (via git) both the org so= urce and the tangled result to all my machines. This results in much lower = maintenance effort - otherwise I would need to login to each machine, open = Emacs there, and tangle the file (or automate the process, but still, more = work than doing it once). This means that the logic still needs to be prese= nt in the resulting file, but it doesn't mean the org source needs to b= e less readable. What I do is use noweb mode selectively, to indicate the c= orresponding sections. I use this for the OS-specific configuration in my E= macs file:=C2=A0https://github.com/zzamboni/dot-e= macs/blob/master/init.org#system-specific-configuration.

=
In short, the top-level block includes the necessary logic, plus= the corresponding sections in noweb-style references (the :noweb no-export= makes it so that the tags get expanded only when tangling and not when exp= orting, which makes my rendered config files more readable, see the links b= elow):

#+begin_src emacs-lisp :noweb no-expor= t
=C2=A0 (cond ((eq system-type 'darwin)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<<Mac settings>><= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ((eq system-type 'windows-nt)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<<Windows settings>&g= t;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ((eq system-type 'gnu/linux)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<<Linux settings>&g= t;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0))
#+end_src

Then, ea= ch subsection sets the corresponding section-level properties, so that they= don't have to be specified in each block - then all the blocks within = that section will be automatically inserted in the corresponding "sect= ion" of the cond statement above. For example:

** Mac
:PROPERTIES:
:header-arg= s:emacs-lisp: :tangle no :noweb-ref Mac settings
:END:=

First, we set the key modif= iers correctly to my preferences: Make Command (=E2=8C=98) act as Meta, Opt= ion as Alt, right-Option as Super

#+begin_src emacs-lisp
=C2=A0 (customize-set-var= iable 'mac-command-modifier 'meta)
=C2=A0 (cus= tomize-set-variable 'mac-option-modifier 'alt)
=C2=A0 (customize-set-variable 'mac-right-option-modifier 'super)<= /div>
#+end_src

=

Hope this helps - not= exactly what you asked, but maybe a useful alternative?

Best,
--Diego


On Sat, Jul 28, 2018 at 11:= 25 AM, Sven Bretfeld <sven.bretfeld@ntnu.no> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">Hi

I don't know how you guys maintain init files for different hosts. I have one org-file with the header:

#+PROPERTY: header-args :tangle ~/.emacs

The file is synced to all my machines and produces the local init files
on each. Most configurations are shared, but some are host-specific
(e.g. font size).

Sadly export filtering does not work with the tangle function. It would
be nice to be able to do something like:

,----
| * Default Frame
| ** Office Computer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :OFFICE:
| #+begin_src emacs-lisp
| (setq default-frame-alist '(
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(font . "-PfEd-DejaVu Sans Mono-nor= mal-normal-normal-*-26-*-*-*-m-0-iso10646-1")
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(width . 102)
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(height . 41))
| #+end_src
|
| ** Computer at home=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:HOME:
| #+begin_src emacs-lisp
| (setq default-frame-alist '(
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(font . "-PfEd-DejaVu Sans Mono-nor= mal-normal-normal-*-18-*-*-*-m-0-iso10646-1")
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(width . 150)
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(height . 50))
| #+end_src
|
| ** Laptop=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:LAPTO= P:
| #+begin_src emacs-lisp
| (setq default-frame-alist '(
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(font . "-PfEd-DejaVu Sans Mono-nor= mal-normal-normal-*-12-*-*-*-m-0-iso10646-1")
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(width . 80)
|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(height . 30))
| #+end_src
`----

It should be clear what this is about. On the office computer you would
prepare the file headers to exclude the tags HOME and LAPTOP from being
tangled and, after saving/tangling the file, you would have a nice init
file suiting this computer. At home the same by excluding the other tags etc.

This would save a lot of work and you would have a tidy way to maintain
all your init files without (if (string-equal (system-name) clauses.

If the noexport tag worked, it would also save a lot of time and mess
when debugging your init file in case of an error.

I don't actually understand why the developers decided not to implement=
export filtering in the tangling operations. I know about the COMMENT
keyword, but the above example should make clear that this solution is
far from handy.

Maybe there is another way that escaped me so far?

All best,

Sven



--0000000000001849ba05723c6b5a--