From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yBr+AFzuwl8jBQAA0tVLHw (envelope-from ) for ; Sun, 29 Nov 2020 00:42:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mLplOFvuwl+REAAA1q6Kng (envelope-from ) for ; Sun, 29 Nov 2020 00:42:03 +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 37E8394011A for ; Sun, 29 Nov 2020 00:42:03 +0000 (UTC) Received: from localhost ([::1]:51644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjAmu-0007gI-T9 for larch@yhetil.org; Sat, 28 Nov 2020 19:42:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjAm2-0007g7-MI for emacs-orgmode@gnu.org; Sat, 28 Nov 2020 19:41:07 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:12665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjAlw-0002Mv-Fx for emacs-orgmode@gnu.org; Sat, 28 Nov 2020 19:41:06 -0500 Date: Sun, 29 Nov 2020 00:40:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1606610457; bh=dHoM0+ohNnM4nOXBFtlt/lzUb6YtRPUaMNtVv0pKP3c=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=nM5fGsYBCKDV76Ttx8/1jeuzhOdpCyvw8cBzCKRnMYScGKfqEVPdWGb1iKa0/m/ZM ty3LJRNfsT9SSB07B36S4+v5UP/fb4e65os/Sqb5nNt9MPPCXBevDbe0sEYe/iZhKP Yna0Cp6/0QkpmTKbpkFnGm28wa4PjoRgSJlVO/gg= To: Tom Gillespie From: mooss Cc: "emacs-orgmode@gnu.org" Subject: Re: Multiple named code blocks Message-ID: In-Reply-To: References: <2PnBr0V8kH99j60xzpYf0HgMQZZtQ_FTnrNNhbHxzgTnxuJqv3y_tSGDNcv4Pqzvlfy4RLgmUbw83UIRiJXTgV9-_fDlwJOaCIon3zJo_-E=@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.136; envelope-from=mooss@protonmail.com; helo=mail-40136.protonmail.ch 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_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: , Reply-To: mooss Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.97 X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.com header.s=protonmail header.b=nM5fGsYB; dmarc=pass (policy=quarantine) header.from=protonmail.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-TUID: Cu7XdHewDntG Hi Tom, The downsides you mention are making perfect sense, especially the cd and rm examples, I did not thought about that and I agree that this would be a dangerous default. Another possibility would be to shield this behaviour behind a header argument, for example by adding a "dimension" to the "noweb" argument. What I mean by "dimension" is that to my knowledge, the header- arg "noweb" only has a, let's say, "when" dimension that can take one value among "yes" "no" and "no-export", whereas "results" can have several dimensions, hence the validity of ":results drawer replace" as a header-arg. This new dimension could be called the "duplicated" dimension and take values among "contatenate", "first" or "last". With this scheme, one could use the header-arg ":noweb yes concatenate" to always expand noweb inclusions and handle multiple code blocks via concatenation. I can see a couple of potential problems with this approach: 1. It might be better to avoid adding header-args left and right to keep complexity in check and this feature is arguably quite niche. 2. This would solidify the idea that multiple code blocks sharing the same name is good practice in org documents, which it is not, as you explained. Yet another option would be to not rely on the names but on another header-arg like "addto" that instruct the noweb resolver to concatenate the current block to another named code block. Reusing the previous example, #+name: Before foo #+begin_src perl my $value =3D 'Inside foo call'; #+end_src Would become: #+begin_src perl :addto "Before foo" my $value =3D 'Inside foo call'; #+end_src Yet another approach would be to add a "directive" (that's probably not the= right terminology), like so: #+addto: Before foo #+begin_src perl my $value =3D 'Inside foo call'; #+end_src The last two approaches would solve problem 2) but not problem 1). There would also be the problem of what to do when a code block is "added to" before its definition, what should be done ? Throwing an error, appending or prepending ? Personally I would prefer the last approach, even though the prepending problem remains to be solved, because the other approaches are polluting the header arguments and look out of place there. In any case, I think that a mechanism to concatenate to an existing code block is a valuable feature for a literate programming system. On another note, that is a bit embarrassing but I'm not too sure about how I am supposed to respond to this email list, I just clicked on "Reply all" in my webmail client and this results in a mail specifically addressed to you Tom and a CC to the list. That is also what is suggested by the "Reply instructions:" section of the list, but I just want to be sure that I am not disrespecting a rule or custom that escapes me. Best regards, F=C3=A9lix