From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uE1NGytJMGNlKQAAbAwnHQ (envelope-from ) for ; Sun, 25 Sep 2022 14:27:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cL5RGytJMGP/5AAA9RJhRA (envelope-from ) for ; Sun, 25 Sep 2022 14:27:23 +0200 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 53BA02CE36 for ; Sun, 25 Sep 2022 14:27:22 +0200 (CEST) Received: from localhost ([::1]:59066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQjB-0007m7-EG for larch@yhetil.org; Sun, 25 Sep 2022 08:27:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocQOf-0002Kj-CY for emacs-orgmode@gnu.org; Sun, 25 Sep 2022 08:06:09 -0400 Received: from mout02.posteo.de ([185.67.36.66]:38339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocQOc-0002cS-Lr for emacs-orgmode@gnu.org; Sun, 25 Sep 2022 08:06:09 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 9C6DB240105 for ; Sun, 25 Sep 2022 14:06:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1664107564; bh=Z/yDdT2/c0UNuEybBkyTny5whclPPt/6/abRjERGRHo=; h=From:To:Cc:Subject:Date:From; b=A9ZtqBorgcFbPnv1gszknRWOHZinyxhZhgWeDGpUnqpYNLwfN+AaXJvRmvSMms8io UTpup/+vof/DhgL/Qg1wGdtJyEm3AFLzQIzWw5Wn1G84RooU2LmlJ0llNqqGywT0Tp GeIlB5Q97LRzz35I8TjhIxJTvekr8Vwx1Wb7eS1h4k+hULnnkaNIhN8z/PBIg8pZBJ MoP5Iwjj9AEzL3nmf9gCtBvg7L/CyPE2/z01EcYfhOb2i8ftYpaf71yHg8CjbzA6YA BUY08/vKIh8R1edONz7FyXIaaWVfI2XbDCTWstu0aF3q9fA83bTox9fxLcp5j4fRmq CqQR6vY5yU25Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Mb4NW1LSxz6tm9; Sun, 25 Sep 2022 14:06:02 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: Ihor Radchenko Cc: orgmode Subject: Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section References: <87o7vcsw8m.fsf@posteo.net> <87czbqyy5i.fsf@localhost> <87sfkmdkxa.fsf@posteo.net> <878rmdxg17.fsf@localhost> <878rmcvlcz.fsf@posteo.net> <87czbna4e4.fsf@localhost> <87h70wbzd3.fsf@posteo.net> <875yhct9eh.fsf@localhost> Date: Sun, 25 Sep 2022 12:06:00 +0000 In-Reply-To: <875yhct9eh.fsf@localhost> (Ihor Radchenko's message of "Sun, 25 Sep 2022 11:33:58 +0800") Message-ID: <87a66nmzfb.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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.29 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664108842; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=hzZFnQZWoXcPCSD8QVzRdrL0Aurtl1hoqg+CKcY95r0=; b=UhWYu/Cwwemz4RnAzH3CAIQ99GGsO7Zdp0TWQRyZQHP5Mz349PgtWb6TBmDBBuLt8Vqs9e lIa5BjmrlWvzJ6w60WNDDdgC3iKYa3FiouuUtB6PewY+wfHgb4IROMVoSD0+TNE4czRRHH 00mz6aV0wQWdCWWXP3lh7DVQkWmeH6ByiPwWttpNezuBy+3gcj1QvBRXdTh/5KFXFhgYsH ARsJZPsB2Ldr+mNR0hpV6Hr+VdZOGKkc8/Eh5TIrgB03r/GdPUxkrHCj44SH57QONX17Kz 7be6VhKMN1/QTKki8WFJQ8z5UiAwT0jjlrMPe4I7ILb+w3jpHPj8h9S1OG2XIg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664108842; a=rsa-sha256; cv=none; b=ASr8sPJ8/ZRFKrEvlB+4WeAzwXmozHij4u14YWJTooLUPowiaY9Ef+Lj5WOAYzZghLecqC Y7laGp19LobHfabtf878Icxo6hJ+vZWX8G8GFTozifbTV/n3ug8tAOPnZORVJA45+ZT1Uk ImnnKE/MDXEIAXntcu+7J247DJWbiTYwlbfjQ7yHrALx8VdwoKTAxkLDWGmnKyQDpXw9td qoxZYWFA/b2c5V4L0vvJRPISnhu6V8v7OmPwfCXq8fbYs3xKgLiN0UwolofbvDcDWh+kTU T6RnjBZ/2Jw8n4i/1IX0Pkn3aymeki+MB28DxDe3a6HnIjRpWCUZFpwbs47V8g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=A9ZtqBor; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.55 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=A9ZtqBor; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 53BA02CE36 X-Spam-Score: -2.55 X-Migadu-Scanner: scn1.migadu.com X-TUID: CnsCSwdRFUgA Ihor Radchenko writes: >>> #+ATTR_BACKEND: :export_template "can also work on non-headings" >>> Paragraph. >> >> In this case I would not see it necessary, IMHO. For simple things (of >> the begin/end style) there are the special blocks. And for more complex >> pre- and/or post- code we have export blocks and export snippets. Since >> there is no heading involved here, there would be no danger of the >> pre-code leaving with the content of the previous header. > > I do not insist on this. I just see supporting this easier (it will work > automatically) compared to explicitly limiting :export_template to > headings/inlinetasks. > > Also, some people prefer to have such option (Pedro Andres Aranda > Gutierrez in off-list reply to > https://orgmode.org/list/87fsgmyyhw.fsf@localhost) Well, it's evident that your idea of the export_template attribute is very productive and can be consistently extended to more situations. One scenario where I think it would be very useful is also in tables and figures, but in this case to insert arbitrary code *inside* the table, figure, etc. environments. This is something that gets asked on the list from time to time and the solutions provided are usually a bit tricky. Going back to the earlier :ATTR_BACKEND: issue as a property for headings, I've been doing some testing and scribbled down a possible function[1] whose code is almost entirely stolen from org-export-read-attribute, with some modifications. Evaluated at the headline, it returns the value of the ATTR_BACKEND property as a plist. And then that plist could be easily manipulated on each backend to format export_template conveniently. For example: * headline :PROPERTIES: :ATTR_LaTeX: :export_template \begin{myenv}\n%s\n\end{myenv} :ATTR_LaTeX+: blah blah blah :END: =3D=3D> (:export_template "\\begin{myenv}\\n%s\\n\\end{myenv} blah blah bla= h") I don't know if that would be the way to go... Best regards, Juan Manuel [1] (defun possible-function (attribute) "TODO" (let* ((prepare-value (lambda (str) (save-match-data (cond ((member str '(nil "" "nil")) nil) ((string-match "^\"\\(\"+\\)?\"$" str) (or (match-string 1 str) "")) (t str))))) (attributes (let ((value (org-entry-get nil attribute))) (when value (let ((s value) result) (while (string-match "\\(?:^\\|[ \t]+\\)\\(:[-a-zA-Z0-9_]+\\)\\([ \t]+\\|$\\)" s) (let ((value (substring s 0 (match-beginning 0)))) (push (funcall prepare-value value) result)) (push (intern (match-string 1 s)) result) (setq s (substring s (match-end 0)))) ;; Ignore any string before first property with `cdr'. (cdr (nreverse (cons (funcall prepare-value s) result)))))))) attributes)) --=20 -- ------------------------------------------------------ Juan Manuel Mac=C3=ADas=20 https://juanmanuelmacias.com https://lunotipia.juanmanuelmacias.com https://gnutas.juanmanuelmacias.com