From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uFCwABB+52M2fwAAbAwnHQ (envelope-from ) for ; Sat, 11 Feb 2023 12:37:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4HOwABB+52PvVAAA9RJhRA (envelope-from ) for ; Sat, 11 Feb 2023 12:37:52 +0100 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 8FFE511107 for ; Sat, 11 Feb 2023 12:37:50 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQoBV-0003K3-PR; Sat, 11 Feb 2023 06:36:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQoBU-0003JP-8n for emacs-orgmode@gnu.org; Sat, 11 Feb 2023 06:36:48 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQoBR-00009n-GW for emacs-orgmode@gnu.org; Sat, 11 Feb 2023 06:36:47 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6D3132406DE for ; Sat, 11 Feb 2023 12:36:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1676115401; bh=fWrvRxsbPxqjPIdlWlKirwsvdLCLc+fivxGZKq4b6tA=; h=From:To:Cc:Subject:Date:From; b=TJf0ZQRvLMAqvCo6qOmdNwZpVbeo3WNLzWV3qGN+J0Jar2pyNHxKQcpTmUAhg4630 dFZPs8Vww29Iwx4Fvv9ZNZlWzJx1wb1pKYfCUYV4UzcGm6XPBUg5ymmayZzmEETp+b uKAYNdw4Qf/+KVDXS2HGi+Kn8orbO8iwRqUloOfvpXf2E0s+O2OeZlUHw3y7iTp3pI 950CzFyxhve0Nbv29e2XfNNZih59b+5/1/7ZUMpmHnmV7nKiqbW2htJihghS2MIb+D Fer6KaK8i7y7rKE/gshVuX3d5Md8GN2z2nE8CucbKUDtyc+qQ40JmjK4PCra6iZEPs N5bp7WC2Nh1SA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDT8J6fT5z6tmK; Sat, 11 Feb 2023 12:36:32 +0100 (CET) From: Ihor Radchenko To: Timothy Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Introduce "export features" In-Reply-To: <875yc95rxp.fsf@tec.tecosaur.net> References: <875yc95rxp.fsf@tec.tecosaur.net> Date: Sat, 11 Feb 2023 11:37:04 +0000 Message-ID: <87lel4bfhb.fsf@localhost> 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=yantar92@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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=TJf0ZQRv; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1676115471; a=rsa-sha256; cv=none; b=egEU0JXK3NPTAfBaxGmZ/XgHq/kQN4TuTM07rEOIydLQQPVtW7WGRIfcH06lukwhOC7ulf VnW95qrX/GaTX5jHfkLRR76cdovh+OBz942mFLyj0MIwWzTwDqwHcjnFituh27Rh0vz+Or OdkZtGWf4HIfvlYE65j1FwHaXbXxUvyN0eclAzpCZg3hLo39hzdDTR6U6qYhv+VNZTuhQu obX8AvG9cjWi9qKIiKZja4iCZ09yzm5nfFKNsC+Hkbj9KYjgkAl+SgMP74j+16aHiTNS0Z ErqC88RpsqmRq1VPWI3MYLo9hDbsoQSo/0gAKZx6CFn4a3ZeoJ3iCic8p4j16Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676115471; 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=mMv5eqK62A/lSKBUUXJr5bB/H2ppWW9UhUGogHyTMjw=; b=D4IBiaQlHlaqFdIDhP7LNUWX3broKn0TJaMc2N7VeS5n5S21c5MvR8jYomviA77T34xXrM N56y5DRwTGlr+xCb4C8t7dCBTy2e1nJcgcS+yCXJe/uH44QJEoTTIhb4XF4F1bmheuaZLz q5QYIa6ocFqkWG51vqTmjgiOlk/2oPBaSx9BkBuiGRqFAVStXOvRPrsg953Lu8o8C2QyV3 RjTuzj5SJLJ/rh0w8oG+7EcPzX1fLK/zjqWUXB1e8X5/zRVavHAcR+qHSGZxY8a4AbaS/S 60JT5A1TAQzqZuGO1CYxoGYVpK0sDR770Dp3Kx/bkHRN7ALlZok5U/POHHrR6g== X-Migadu-Queue-Id: 8FFE511107 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=TJf0ZQRv; 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"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -7.37 X-Spam-Score: -7.37 X-TUID: ZOmFk1LZSpfI Timothy writes: > =E2=80=9Cexport features=E2=80=9D allow for the specification of qualitie= s of the org buffer > being exported that imply certain =E2=80=9Cfeatures=E2=80=9D, and how tho= se features may be > implemented in a particular export. > > This is done by augmenting the backend struct with two new fields: > `feature-conditions' and `feature-implementations'. > > The feature conditions are resolved during the annotation of `info', in t= he Org > buffer after `#+include' expansion and the removal of comments. > > The feature implementations are expanded by the backend itself, in the ca= se of > `ox-latex' this currently means during preamble construction. I am in favour of this. Some comments on the code are below. > + `(("^[ \t]*#\\+print_bibliography:" . bibliography) This will also match bibliography statements, which are not keywords. For example, inside quote blocks. > + :group 'org-export-general > + :type '(alist :key-type > + (choice (regexp :tag "Feature test regexp") > + (variable :tag "Feature variable") > + (function :tag "Feature test function")) > + :value-type > + (choice (symbol :tag "Feature symbol") > + (repeat symbol :tag "Feature symbols")))) :package-version is missing in this defcustom. It should be added. > +(defun org-export-detect-features (info) > + "Detect features from `org-export-conditional-features' in INFO." > + (let (case-fold-search) This unconditionally sets case-sensitive search. Thus, for example, #+PRINT_BIBLIOGRAPHY (as opposed to #+print_bibliography) will not be recognized as 'bibliography feature. > + (delete-dups > + (mapcan > + (lambda (construct-feature) This lambda could be a private function instead. A function would be byte-compiled. > (defcustom org-latex-default-packages-alist > '(("AUTO" "inputenc" t ("pdflatex")) > ("T1" "fontenc" t ("pdflatex")) > - ("" "graphicx" t) You need to update :package-version upon changing the defcustom value. > +;;;; Generated preamble > + > +(defcustom org-latex-conditional-features defcustom :keywords are missing here. Please, add. > + (,(lambda (info) > + (org-element-map (plist-get info :parse-tree) > + 'link > + (lambda (link) > + (and (member (org-element-property :type link) > + '("http" "https" "ftp" "file")) > + (file-name-extension (org-element-property :path link)) > + (equal (downcase (file-name-extension > + (org-element-property :path link))) > + "svg"))) > + info t)) > + . svg) This is a duplicate of an entry in `org-export-conditional-features'. Is it intentional? > +(defcustom org-latex-feature-implementations :package-version is missing. > + "Alist describing how export features should be supported in the pream= ble. > + > +Implementation alist has the feature symbol as the car, with the > +cdr forming a plist with the following keys: > +- :snippet, which is either, > + - A string, which should be included in the preamble verbatim. > + - A variable, the value of which should be included in the preamble. > + - A function, which is called with two arguments =E2=80=94 the export = info, > + and the list of feature flags. The returned value is included in > + the preamble. > +- :requires, a feature or list of features which are needed. > +- :when, a feature or list of features which imply this feature. > +- :prevents, a feature or list of features that should be masked. > +- :order, for when inclusion order matters. Feature implementations > + with a lower order appear first. The default is 0." > + :group 'org-export-general What is this group? > + :type '(plist :key-type > + (choice (const :snippet) > + (const :requires) > + (const :when) > + (const :prevents) > + (const :order) > + (const :trigger)) > + :value-type > + (choice (string :tag "Verbatim content") > + (variable :tag "Content variable") > + (function :tag "Generating function")))) The docstring and :type are rather generic wrt backend. Can they be abstracted away? > -(defun org-latex-guess-inputenc (header) > +(defun org-latex-guess-inputenc (info) It is a breaking change. Can we make something to not break existing third-party code? > -(defun org-latex-guess-babel-language (header info) > +(defun org-latex-guess-babel-language (info) Again, backwards-incompatible. > -(defun org-latex-guess-polyglossia-language (header info) > +(defun org-latex-guess-polyglossia-language (info) backwards-incompatible > + (concat > + ;; Time-stamp. > + (and (plist-get info :time-stamp-file) > + (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) May it also be a feature? > + ;; LaTeX compiler. > + (org-latex--insert-compiler info) And this. > +(defun org-export-update-features (backend &rest feature-property-value-= lists) > + "For BACKEND's export spec, set all FEATURE-PROPERTY-VALUE-LISTS. what about (defun org-export-update-features (backend &rest feature-settings) "Update FEATURE-SETTINGS for BACKEND. > +Specifically, for each (FEATURE . PROPERTY-VALUE-LIST) entry of > +FEATURE-PROPERTY-VALUE-LISTS, each :PROPERTY VALUE pair of > +PROPERTY-VALUE-PAIRS is set to VALUE within the backend's feature > +implementation plist. The sole exception to this is the > +:condition property, the value of which is set in the backend's > +feature condition plist instead. This patch is not what how it looks at the end, right? One of the following patches completely amends the docstring. Could you please restructure the patches in a way that is easier to review? Without significant changes in implementations. I am not sure if all the above comments will apply to the final patchset. Also, you will need to add ORG-NEWS entry and document the new feature system in "13.17 Advanced Export Configuration" and "A.4 Adding Export Back-ends" sections of the manual. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at