From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 mNICM8SyeGLpwQAAbAwnHQ (envelope-from ) for ; Mon, 09 May 2022 08:20:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id KAcmMsSyeGIQGwEAG6o9tA (envelope-from ) for ; Mon, 09 May 2022 08:20:52 +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 19E2238E12 for ; Mon, 9 May 2022 08:20:52 +0200 (CEST) Received: from localhost ([::1]:49056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnwlG-0006Xl-99 for larch@yhetil.org; Mon, 09 May 2022 02:20:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnwke-0006Xb-Bo for emacs-orgmode@gnu.org; Mon, 09 May 2022 02:20:12 -0400 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:44855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnwkc-000726-F6 for emacs-orgmode@gnu.org; Mon, 09 May 2022 02:20:12 -0400 Received: by mail-qk1-x72f.google.com with SMTP id n8so9638087qke.11 for ; Sun, 08 May 2022 23:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=vphPoctRRz+adWhueJSdaFtwz8goHlcU6P06+0bpz74=; b=SVkk0l+a3KY3ZEBE9fDZUY/QJO+0ldyGDAq+RXSTW+uBUG9+hr7/jPBFUUt0KPjIG/ xGBipsmwHgeMnjwxjHP87cnVEwCgWY4pEosmCx/HORfz41Vd/RZHk/UKGX2y5Mm0Jt7I P0pEUGNc+mfxC7CpZQ16jTwQPTpicCbbtpXpqmlH16jfy5RiZ3WP9s6W1/5XjIxKI8YG 8OzIp6x2fcOECQocU5ScJyypa2tvQQ2TJjSYJx5a7Okx1o7jbGsmXgZBtVyg2sDnpwy6 PuDRv/X1vAu84DP9tIhsOgA+tM8hSqRSTgbHt9h+VQqp4yUAct09Q62rF+T5VJngCkR4 YifQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=vphPoctRRz+adWhueJSdaFtwz8goHlcU6P06+0bpz74=; b=nlj04Ytta9NNepz2XRRLwa4csWLYg6KRAvGmUM4Z46qJeJYtFTjsBap42+rTJFEvcH 7VH211shbNPN4x2ncQ/imf2tPT4RjDeqQzJ4dUflpbExsuPjF7kdxyQnTYR2ItAPM3Uf quFHTCOOHDpJ0jMWFAkOv/CJ+xaolKu27L0qkSPiRXH955zy4nD1EW9x1YDbJmUl28VD 9PFJnJJZOJfL4O1j6/UkIW3QrgxmILA8ROTlgwjrzxOkmqPkWEiyFrf2Hncnr/Sc8/y+ I90PwmcgRwwjBIXOKT1e6GocsnEE072E4m+jlq6L7+0N++7eMl+rbtggfZzEObGvKyv2 5moQ== X-Gm-Message-State: AOAM532qCY7sPReZvzhUHZt7hcIAtMIDbMLITtA5swofEGexzhUHDp0m AY8oZr7KbYDc5awgRM6P6VLPxh4TN7AqZvz1 X-Google-Smtp-Source: ABdhPJzJlgtX9y+KPwlI6JRkkuwrl6pMZPQagESc5vpPWYyJe7w02arLta2yyZyexI6FNIVp8auQqQ== X-Received: by 2002:a05:620a:448b:b0:6a0:3266:f6ef with SMTP id x11-20020a05620a448b00b006a03266f6efmr11024711qkp.427.1652077209336; Sun, 08 May 2022 23:20:09 -0700 (PDT) Received: from localhost (22.b2.a86c.ip4.static.sl-reverse.com. [108.168.178.34]) by smtp.gmail.com with ESMTPSA id d16-20020ac86150000000b002f39b99f6a5sm7452013qtm.63.2022.05.08.23.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:20:08 -0700 (PDT) From: Ihor Radchenko To: Timothy Cc: Daniel Fleischer , emacs-orgmode@gnu.org, Nicolas Goaziou Subject: Re: [PATCH] (v2) New LaTeX code export option: engraved In-Reply-To: <87levcm2bx.fsf@gmail.com> References: <87wnf1z1w8.fsf@gmail.com> <87sfpogyag.fsf@localhost> <87v8ukyo94.fsf@gmail.com> <87sfpoyn0l.fsf@gmail.com> <875ymhzzvq.fsf@localhost> <87o809n7hw.fsf@gmail.com> <87mtftmxox.fsf@gmail.com> <87levcm2bx.fsf@gmail.com> Date: Mon, 09 May 2022 14:20:44 +0800 Message-ID: <874k1zqlab.fsf@localhost> 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::72f; envelope-from=yantar92@gmail.com; helo=mail-qk1-x72f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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=1652077252; 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=vphPoctRRz+adWhueJSdaFtwz8goHlcU6P06+0bpz74=; b=RU8uWtLjrx/wO8huOszgPjxSfLyH855vl/YQuhWPHH34x7rVq+Dw/GEgMi+FbtmgtkEloQ mduuYFia78dtAguZMAmO1gPSZUqUwH5A3jGgcbbYMdZ4Y+Wk1omOIpgRo1Y6DAAPAENXCo JU24b0dELCp93oA+UZ84oj2nxjlfG3RRc6wGv7x5dJavp28ECh5rOKNBNB7QnnmPP1p0aS RndFg4+XHmYXuRFXWCYyCGG8ARr5KeCc1pgTkQElcG/9ZEICQvZlyPBBs1RDbed3yNYSuv otkg7A1wCYfdzyHqu5JhwUjjgEhhB9sj0+FIoEwZpKMPF3ulNYa2ov5H/h0KYQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652077252; a=rsa-sha256; cv=none; b=Fr8kIS8cpSqJ2aCIhHXsMstyV9izb5Jjo7w+HP4KGYTgDPaUXiqDESRkcEKjPrFtvMEHgg y3hwBH5OjA9zh7Ye4D90uVbFEvD80c9a+dLCZq7lDczCSC2WyKOK0w/oZ7JI5FmlXtCXLA uiSt/GsosGbOBUSyr38ubYch7p/p2WqcdItmJNtq6ydi3tupxrTMt2fPDUNNae/2hZwTjm 7MN5bx1g2fJ2vdfM88qkH1ooUAYQ6JxLNjA+BFiRzqFXs6pKR28QeT53b4OJPiZZ12F/sh RyKnvfHBIbQ/oj2GUFhACEgRqkCoq257RGC37uYI6TaE4JbWDfW2Ow79Zncxzg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SVkk0l+a; dmarc=pass (policy=none) header.from=gmail.com; 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: -4.00 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SVkk0l+a; dmarc=pass (policy=none) header.from=gmail.com; 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: 19E2238E12 X-Spam-Score: -4.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: yqFwjz6fBO8K Timothy writes: > I have a new set of patches (attached), which make use of a major new fea= ture in > engrave-faces v0.3: engraved themes. Thanks! > Glad to hear you=E2=80=99ve been able to have a look over the patches. Wi= th the feedback > I=E2=80=99ve received here so far, if no issues come up in the next few d= ays I=E2=80=99m > inclined to merge this, add documentation, and see what feedback pops > up. Before merging, could you also try to implement tests at least for engraved feature? If I recall correctly, we do not currently have backend-specific tests. But it would certainly help if we did. You might as well write a small "nucleus" test for ox-latex. Also, unless I miss something, there is no support for coderefs in the patchset. Is it intentional? > +(defun org-latex-src-block--verbatim > ... > + (let ((caption-str (org-latex--caption/label-string src-block info)) > +(defun org-latex-src-block--custom > ... > + (let ((caption-str (org-latex--caption/label-string src-block info)) > + (formatted-src (org-export-format-code-default src-block info))) It appears that the code for caption-str is duplicated. It could be also factored out. > + (format-spec custom-env > + `((?s . ,formatted-src) > + (?c . ,caption) > + (?f . ,float) > + (?l . ,(org-latex--label src-block info)) > + (?o . ,(or (plist-get attributes :options) ""))))))) I do not see a definition of `format-spec' function. There is only `spec' above in the code. Can you double check? Either I am missing something or something fishy is going on. > + (let ((code (org-element-property :value inline-src-block)) > + (lang (org-element-property :language inline-src-block))) > + (pcase (plist-get info :latex-listings) > + ('nil (org-latex--text-markup code 'code info)) > + ('minted (org-latex-inline-src-block--minted info code lang)) > + (_ (org-latex-inline-src-block--listings info code lang))))) Please use `nil and `minted. Using ' may create issues in older Emacs. > +% In case engrave-faces-latex-gen-preamble has not been run. > +\\providecolor{EfD}{HTML}{f7f7f7} > +\\providecolor{EFD}{HTML}{28292e} What is the difference between EfD and EFD? EfD is also not documented. > +FVEXTRA-SETUP sets fvextra's defaults according to > +`org-latex-engraved-options', and LISTINGS-SETUP creates the > +listings environment and defines \\listoflistings." It is unclear what listings environment does given that we use engraved package. Can you provide a bit more details in the docstring on what the user will get if [LISTINGS-SETUP] is present. It may catch users by surprise that deleting this will make captions disappear. > @@ -1756,6 +1929,17 @@ (defun org-latex-template (contents info) > (let ((template (plist-get info :latex-hyperref-template))) > (and (stringp template) > (format-spec template spec))) > + ;; engrave-faces-latex preamble > + (when (eq org-latex-listings 'engraved) > + (let ((src-p (org-element-map (plist-get info :parse-tree) > + '(src-block inline-src-block) #'identity > + info t)) > + (fixedw-p > + (org-element-map (plist-get info :parse-tree) > + '(example-block fixed-width) #'identity > + info t))) > + (when (or src-p fixedw-p) > + (org-latex-generate-engraved-preamble info src-p)))) Why not just (org-element-map (plist-get info :parse-tree) '(src-block inline-src-block example-block fixed-wi= dth) #'identity info t) ? > (pcase (plist-get info :latex-listings) > ('nil (org-latex--text-markup code 'code info)) > ('minted (org-latex-inline-src-block--minted info code lang)) > + ('engraved (org-latex-inline-src-block--engraved info code lang)) > (_ (org-latex-inline-src-block--listings info code lang))))) Same comment about ` in pcase. =20=20 > (defun org-latex-inline-src-block--listings (info code lang) > "Transcode an inline src block's content from Org to LaTeX, using lstl= istings. > INFO, CODE, and LANG are provided by `org-latex-inline-src-block'." > @@ -2323,6 +2513,7 @@ (defun org-latex-keyword (keyword _contents info) > (cl-case (plist-get info :latex-listings) > ((nil) "\\listoffigures") > (minted "\\listoflistings") > + (engraved "\\listoflistings") > (otherwise "\\lstlistoflistings"))))))))) What will happen if there is no [LISTINGS-SETUP]? > +(defcustom org-latex-engraved-theme nil > + "The theme that should be used for engraved code, when non-nil. > +This can be set to any theme defined in `engrave-faces-themes' or > +loadable by Emacs. When set to t, the current Emacs theme is > +used." > + :group 'org-export-latex > + :type 'symbol) Docstring does not explain what happens when set to nil. Also, does :type 'symbol allow t and nil? > - (engrave-faces-latex-gen-preamble) > + (engrave-faces-latex-gen-preamble > + (when engraved-theme (intern engraved-theme))) Will it work when engraved-theme is t? > - (engraved-theme (plist-get info :latex-engraved-theme))) > + (engraved-theme (plist-get info :latex-engraved-theme)) > + (engraved-themes > + (cl-delete-duplicates > + (org-element-map > + (plist-get info :parse-tree) > + '(src-block inline-src-block) > + (lambda (src) > + (plist-get > + (org-export-read-attribute :attr_latex src) > + :engraved-theme)) > + info))) What about example-block and fixed-width? I may be missing something, but earlier in the patchset you had conditionals of the type (or src-p fixedw-p). So, does engrave-faces do anything with fixedw-type elements? > + (gen-theme-spec > + (lambda (theme) > + (if (eq engrave-faces-latex-output-style 'preset) > + (engrave-faces-latex-gen-preamble (when theme (intern th= eme))) > + (engrave-faces-latex-gen-preamble-line > + 'default > + (alist-get 'default > + (if theme > + (engrave-faces-get-theme (intern theme)) > + engrave-faces-current-preset-style))))))) This appears to be not guarded by (require 'engrave-faces-latex nil t). > -(defun org-latex-src--engrave-code (content lang) > - "Engrave CONTENT to LaTeX in a LANG-mode buffer, and give the result." > +(defun org-latex-src--engrave-code (content lang &optional theme options= inline) > + "Engrave CONTENT to LaTeX in a LANG-mode buffer, and give the result. > +When THEME is non-nil, it will be used." You did not document the remaining two arguments. (this makes me ask a question whether you checked compile warnings). Also, consider running M-x checkdoc on ox-latex.el. > - (insert content) > + (insert (string-trim-right content "\n")) As a theoretical possibility, what will happen if content has something like "%\n"? Best, Ihor