From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id VMa9FLwt5WBPKwAAgWs5BA (envelope-from ) for ; Wed, 07 Jul 2021 06:29:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id IIHWD7wt5WAdBwAAbx9fmQ (envelope-from ) for ; Wed, 07 Jul 2021 04:29:48 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6CEC318F16 for ; Wed, 7 Jul 2021 06:29:47 +0200 (CEST) Received: from localhost ([::1]:33450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0zBx-0006rN-5J for larch@yhetil.org; Wed, 07 Jul 2021 00:29:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0zBL-0006n4-NU for emacs-orgmode@gnu.org; Wed, 07 Jul 2021 00:29:07 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:35726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0zBJ-0003qk-Js for emacs-orgmode@gnu.org; Wed, 07 Jul 2021 00:29:07 -0400 Received: by mail-pl1-x631.google.com with SMTP id b5so367384plg.2 for ; Tue, 06 Jul 2021 21:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=8Yp+mAWfoYvX22/zOQEZTLxZFY8kjYqsKQt0BiQAA9A=; b=cx1OgPguwViTuqoExv1EGCjgCMJvUbL9nn9oCofjUist88wZH+6D7s/WN85YTvay/z bV3pxRXXGAbT4exmIypNGRvS+DtyW3HlNLNmHoetShHIbOmunGbQXlC26SAqcp3mY4UI 63bjSGqdwUhz/Md0DrhDhiF80GBjSubocm/kxhK0He1l7SNttJ2yqc1svOTrqsNkucq3 XTxcCMXB0S/2CRPeZ2U3CkmIQwIABI9x1INyunCKdyqG8am11+tYBycowq5T8BzVW94Y VxH9vI6eU6dYIMYWzY8bPGaw2s2SX/LChpaa392+3rOlHVCN6tamKAn6CvOF2LRLP/gt t9YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=8Yp+mAWfoYvX22/zOQEZTLxZFY8kjYqsKQt0BiQAA9A=; b=DGwOhuUXuhqc7EuT1Ofzz/E7SxDp0WLK7/5+a9TsPWQfM+xx7Ho06hMvVsN9n138v8 aU8Iizvp2+Cijk2cGBDKvn/9OQ3WDojoLcS4voRtSeBgFO6y+9ypwm8uKvbI84NTjVXL 2/pxB0HuKf9T+PSUuGbQFSihmdEgoh17PfBhKOZEdH3lXRuHQFGXgfbsrnFEF2j3kAki vT0cY7ims5nKgQa0d8X4yMRycAugF4tc8GvuNXm0W1mITyOGuNeqWfcA2NCUJRlyNuOw oV6YcYfaWd6d/lJMTc2G6IgDJigI8k/DwrwgT0IXyDlKZf8pEPZgbJRwmwv/QkV8lBvK nuig== X-Gm-Message-State: AOAM533rdvOkLCig0+mSF6WcToHS3NIc/gnhvczjOrf5OiarBxZWibc/ fZ09DzvYe6hVDpL1aBG3n5iEIUz1FVs= X-Google-Smtp-Source: ABdhPJyndx+X5F4enlWV9URb+wC6Wgnj/dx/sAIMMeI5jhQXRYmyq3qkKzptgUuOw8sqzJ/z+s4Feg== X-Received: by 2002:a17:902:778f:b029:128:b3e1:15f8 with SMTP id o15-20020a170902778fb0290128b3e115f8mr19793145pll.14.1625632143775; Tue, 06 Jul 2021 21:29:03 -0700 (PDT) Received: from tim-desktop (220-235-14-30.dyn.iinet.net.au. [220.235.14.30]) by smtp.gmail.com with ESMTPSA id cs1sm4465855pjb.56.2021.07.06.21.29.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 21:29:03 -0700 (PDT) References: <-0ZoEP_lzUvrnWSq9TwiYHNJ0Spa94xjiTOF0TU8np0pYgHEPx-62_dr5xBMd3VUu7frSRXxiAFje99v2jeaJg==@protonmail.internalid> <3xziDF9qTEWTCnFZdoXRlffWkusi5xR4Rcrp-7A0mXpDHI11TIQoxfgNAoygPMIK52EZ7hZfRpb8YnTDQ4RosA==@protonmail.internalid> <4139848.ejJDZkT8p0@bl4ckspoons> User-agent: mu4e 1.5.13; emacs 28.0.50 From: Tim Cross To: emacs-orgmode@gnu.org Subject: Re: [PATCH] Allow tangling to a list of files Date: Wed, 07 Jul 2021 14:09:52 +1000 In-reply-to: Message-ID: <8735sqn3w4.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=theophilusx@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625632187; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=8Yp+mAWfoYvX22/zOQEZTLxZFY8kjYqsKQt0BiQAA9A=; b=M3EfEKsWMlQ15fGcmQQzY3RKPQm29ZGyrE/8vu0MctMfF95hL3JOnMZQAiv27Zo+dCFHdW ZgsrslqYkht+RkqFtJPXmdpda9E4I0Wjx/N6e6uAfV5OGVnPzhWTgC90olsx4uVrasTXiL lLb3MXXP7+RBlN6sRKAxwv7r1oTQ1PMAMtB8YcWkjaDTerBMoGNqjXl+LGFexg+9wVsqXB y/6azCIK8eaGwQ2yketKsACGSkaVYpTVR4Vd8IF33GzXV8q5MDUKIWbjcWdbdFR2Feue5a 6m/AzAbiG1Y9Vb9WYmYMnKr01Jaod7U1p8zMPXCs2yTY/x2C2sv4K3ZS0XIGkg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625632187; a=rsa-sha256; cv=none; b=c6sqseFRzzTaA+4xy8GgmCA4niXcBGNApymZmVyiO1pQH97w7xWNjP62y7WEIs7gRutmFn qecYGpIy6D/6WSbFsQJsgjKpU+mIFjdp5ypdwBMoGyS2o0ot0ihePMEwg+YLKXjq3ZXdqF CV6OUFI7wxolDqoGMEiqU1bASALKOrAmic4s1dPhTE3eByj47abHcQVjb1siCwRxd+G2b7 MhczM8MWyKQDK7W4tcrH6xD6isY1TKTi5MnlDzKh6mC/HqxQytrRB8+LLdz+RqbjX9QaSt kkGy9vWBW5R2J8oh0CR3Exp6jcvUYVJOcI5ZEmle3IESjQeVTJR0X+P/d4Kxog== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=cx1OgPgu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.11 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=cx1OgPgu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 6CEC318F16 X-Spam-Score: -3.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: iiDXcSMrg3Rq Vladimir Lomov writes: > [[PGP Signed Part:Undecided]] > Hello Jacopo. > ** Jacopo De Simoi [2021-07-06 11:24:40 -0400]: > >> Dear Vladimir,=20 > >> thanks for your reply. > >> Let me show you two examples; they are both WIP and incomplete, but you'= ll get=20 >> the gist.=20 > >> - Example 1 > >> https://gist.github.com/85c9b9c9ab151c5fd35bd761ef6ef569 > >> This is my literate config for .zshrc; as you can see different blocks a= re >> tangled to different set of files; hence the output files differ (as some >> blocks are present and other are not)=20 > > I couldn't find in Org manual how tangling should work if there are sever= al > source code blocks with the same file name for ':tangle'. The Org manual > section "15.8 Extracting Source Code" is a bit obscure. There are these t= wo > sentences > > When Org tangles code blocks, it expands, merges, and transforms > them. Then Org recomposes them into one or more separate files, as > configured through the options. > > The second sentence assumes that it might be possible to tangle to more t= han > one file but possible options for ':tangle' don't give certain answer: > > yes=E2=80=99 > > Export the code block to source file. The file name for the source > file is derived from the name of the Org file, and the file extens= ion > is derived from the source code language identifier. > Example: =E2=80=98:tangle yes=E2=80=99. > > FILENAME > > Export the code block to source file whose file name is derived fr= om > any string passed to the =E2=80=98tangle=E2=80=99 header argument.= Org derives the > file name as being relative to the directory of the Org file=E2=80= =99s > location. Example: =E2=80=98:tangle FILENAME=E2=80=99. > > If I understand first choice correctly then the only source block ("the c= ode > block") will be tangled (exported) to a source file. What Org will do if = there > are several source blocks? Concatenate them or write to a file only last = one? > (I didn't test that). > > The same applies to 'FILENAME' case: what Org will do if there are several > source code blocks with the same 'FILENAME' for ':tangle'. > > I would say that you use here undocumented feature and you workflow could= be > broken if in some future Org version developers decide to implement only > documented features. > As it stands at the moment, if the :tangle keyword is followed by a filename, that block will be tangled into that file. If there is more than one block with the same filename, the blocks will all be concatenated into the same file. If you have multiple source blocks, but with different filenames for the blocks, multiple files will be created when you tangle the file - one file for each unique filename given to the :tangle argument in each block. I use this to generate my emacs config. I have both an early-init.el and an init.el. These files are created from multiple source blocks where some blocks have :tangle early-init.el and some have :tangle init.el. (actually, I have changed that now. I tangle to tangle-early-init.el and tangle-init.el. I then have a simple 'install.sh' script which first moves the old early-init.el and init.el to new files with a timestamp added to the name i.e. init.el-20210722 and then it installs the new init files, renaming them to early-init.el and init.el). I'm not sure this is an undocumented feature. The manual just says that the code will be tangled into the file specified with the :tangle keyword. Nothing states the filename can only appear once or you cannot have different filenames for different blocks. If you don't specify a filename i.e. :tangle yes, the block will be tangled into a file with the same name as the org file and the extension appropriate to the language in the source block. For example, if my org file is called emacs-config.org and I just have :tangle yes, I will get the source tangled into emacs-config.el. Same will happen if I just have the keyword :tangle. When I don't want a source block added to a file, I just add :tangle no to the block header. This is a handy way of removing something from a config file. I find it useful when trying to track down problems with my emacs init as I can quickly remove lots of stuff, generate a new config and see if the issue persists. I find this easier than commenting and uncommenting multiple lines in my init file. I also find it useful when I run into a problem with something (possibly due to a package update) as my source blocks are all broken up into specific bits of configuration which are as far as possible completely independent of each other. For example, a while ago, I had problems with one of the magit add on packages I use after it was updated. I changed the header to :tangle no, generated a new init file and waited until a new version of the package was released. This happened a few days later and I just changed the header back to :tangle init.el and generated the new config and all was back to normal. --=20 Tim Cross