From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 +DDsF/QAdmJ1bwAAbAwnHQ (envelope-from ) for ; Sat, 07 May 2022 07:17:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id sBndF/QAdmLHvgAAauVa8A (envelope-from ) for ; Sat, 07 May 2022 07:17:40 +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 D171E156B for ; Sat, 7 May 2022 07:17:39 +0200 (CEST) Received: from localhost ([::1]:37454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnCp0-0003J0-BG for larch@yhetil.org; Sat, 07 May 2022 01:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnCnG-0003HX-UB for emacs-orgmode@gnu.org; Sat, 07 May 2022 01:15:51 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]:39161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnCnD-00073B-SG for emacs-orgmode@gnu.org; Sat, 07 May 2022 01:15:49 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-deb9295679so9295812fac.6 for ; Fri, 06 May 2022 22:15:47 -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; bh=xnKiXZpLvF7zVOxZPC0XmFwGcnTudI+EBlCjK2HhLBA=; b=JitUkHHYfjQb1Pj/GQySA7SNK+C+l5tPMdsvl8Eo/slrCyoEl6ieHcOnRJta5hdmpa anJCC9yEEKU99v8e3x3/lzf2Bmr6b6ipT8M5UUXdlhyG2Sj3U4vSdMRoMoO3nstgPoAr lSehhl6c5m8BGu/ime80bDxbFVQeRBSSOtoMXc9BRQy3OMwQCrYq7iriHWKrs+hj3Umf BwY98Zi+raNzayQGPUz8SXBeIcU+N0UZzl1CIPpoXDW6Afc0uBomJeuWMCp46a6OjcjT tCalu1+y7gfq0RlDuNzI/5ywq8GLIln5JmGDkuw7HhJnjRFKvbLvpHb7NfJSPy8ItGeh kWiw== 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; bh=xnKiXZpLvF7zVOxZPC0XmFwGcnTudI+EBlCjK2HhLBA=; b=hkJiOdr/l92aAg3Q2CazlwqZBm7jJo073CE5s0YJ6lP7v548pcEnxAHvFLRWo4zD/g rqM49BPc5rJosTxLF/fqABA6KBzr97EU/5hohPCb4uwwQpvX5W4na3YMm3eTSIsCp59u +GnxZTCGQzc3aNu6oEVXp7ZRLTZfo0k8s50pVxOnpDa0paAuRj4pB0ch5/CaFono8rtG AuemS9M9MpFyjCqniYW5veyCB9IcsAdc5TJBzEnR/zpR2ZxJRBsEm9qxH38pn7nRMRv7 FwBmbp0jartvxjDhiI3LH4M/x4++vmbMQYHunfa+RYm/l0ppTfHmdvAsEz2bPQKG76IW VXvw== X-Gm-Message-State: AOAM5324MlRQuheo0levNERJsAYOMXcpRoXNPNwRpfnRJQ2oang47x8b YEJi2x7E/LgWFCy7DMqqaPw= X-Google-Smtp-Source: ABdhPJzf0h0woSH2S0hchu8Xz/qy748wFaPmiGwBh+jgcaVWQx3J+Rdd3XD0ucz8pNQnWY5kgPgpxw== X-Received: by 2002:a05:6870:ac0e:b0:ed:9a7d:4881 with SMTP id kw14-20020a056870ac0e00b000ed9a7d4881mr2791190oab.178.1651900545663; Fri, 06 May 2022 22:15:45 -0700 (PDT) Received: from localhost ([104.223.98.2]) by smtp.gmail.com with ESMTPSA id v9-20020acade09000000b00325cda1ffa8sm2387950oig.39.2022.05.06.22.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 22:15:44 -0700 (PDT) From: Ihor Radchenko To: Timothy Cc: emacs-orgmode@gnu.org, Daniel Fleischer , Nicolas Goaziou Subject: Re: [PATCH] New LaTeX code export option: engraved In-Reply-To: <87sfpoyn0l.fsf@gmail.com> References: <87wnf1z1w8.fsf@gmail.com> <87sfpogyag.fsf@localhost> <87v8ukyo94.fsf@gmail.com> <87sfpoyn0l.fsf@gmail.com> Date: Sat, 07 May 2022 13:16:09 +0800 Message-ID: <875ymhzzvq.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=yantar92@gmail.com; helo=mail-oa1-x36.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=1651900660; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xnKiXZpLvF7zVOxZPC0XmFwGcnTudI+EBlCjK2HhLBA=; b=mcJaowniID0TD4wWKhgjHQY4S71pwzoXk2uxnijQPxgB26n8aIHGvLE1DqI8qAhDr3YkSw 3dCOGmG8b3J4npkVEs7OvvFnZndS8vNPvskrAawjgI51ox95Tc6bK1veE4l25vQHpZRKa+ qikI6j2GAq6Ddnp5cBmTVIx61SQHr88XIdCoaq48mXm9RXNu8LOtutrPToUcQezah8kGvF 8bmbLTiKwo1MKE5OEeMHYRsAdvsNmTZIhfoe0jqjfpJHmU6SvyrTICpHRv+RhF3q35xEJS uwnu08NaTKBpU3VxAmmmgz/2+AUU2+y9sz2GgJTybBdkGPiB5mGxN+bINK5lcg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651900660; a=rsa-sha256; cv=none; b=pcf6giDZ6aow9fxDJHYkM/AfaMvOD0uLGf6WYqj3U+gyR86QjuBpEutxIZ2Eyc9RrHqv/+ gn4i0WqZ43QkqNMweSEe92dFN7OdfbEK6CLnaj84DcSDrZKNI+YukubwU/Y6DqerQXeqb/ fMLWM+nh4DJFjA7JHaPi98e6useUB00RXSGkMImMU1c30e5agOx5BBvhNvS536miix/qwv +IJrp+6yg30pfFwlLoJceqX1Xay+EUv0iS1SkRzCKArnpsE9tiB79zh+e73kDGaIuqkfJa lTGX+CWSc7qPNG3fto50yjyh+WKBW80LsL7NKZ5/Dr/uNJeSJ9rqeYTrrMKrSA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JitUkHHY; 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: -2.00 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JitUkHHY; 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: D171E156B X-Spam-Score: -2.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: mCcTj24Zo/db Timothy writes: Thanks for the updated patch! See some more comments below. > +The first two options provide basic syntax > +highlighting (listings), or none at all (verbatim). > ... > -Alternatively, > +There are two options for more comprehensive fontification. The > +first can be set with, Maybe "The other two options"? Also, using first/second here is a bit confusing because: (1) they are actually 3/4 in the above list; (2) engraved is listed last. > +The second more comprehensive option can be used with, *can be set with > -causes source code to be exported using the minted package as > -opposed to listings. If you want to use minted, you need to add > -the minted package to `org-latex-packages-alist', for example > +which causes source code to be exported using the minted package > +as opposed to listings. If you want to use minted, you need to > +add the minted package to `org-latex-packages-alist', for example > using customize, or with I feel slightly confused about using the word "package" here. Which one refers to LaTeX package and which one to Emacs? I would state "Emacs package" explicitly to highlight contrast with "LaTeX package". > +(defcustom org-latex-engraved-preamble > + "\\usepackage{fvextra} > + > +[FVEXTRA-SETUP] > + > +\\renewcommand\\theFancyVerbLine{\\footnotesize\\color{black!40!white}\\arabic{FancyVerbLine}} I'd like to see a comment on what it does. > +\\usepackage{xcolor} > + > +\\providecolor{codebackground}{HTML}{f7f7f7} > +\\providecolor{codeborder}{HTML}{f0f0f0} > +\\providecolor{EFD}{HTML}{28292e} > + > +% TODO have code boxes keep line vertical alignment > +\\usepackage[breakable,xparse]{tcolorbox} > +\\DeclareTColorBox[]{Code}{o}% Same request to provide a comment. Also, what it that % TODO doing there? It is confusing. Also, it is unclear what the [breakable,xparse] options to tcolorbox are doing there and what will happen if the user removes them. Further, I am wondering what is going to happen if the user happens to have tcolorbox without options loaded via org-latex-packages-alist. > +There is quite a lot of flexibility in what this preamble can be, as long as it: > +- Loads the fvextra package. > +- Loads the package xcolor (if it is not already loader elsewhere). > +- Defines a \"Code\" environment (note the capital C), which can be > + later used to wrap \"Verbatim\" environments (provided by fvextra). The last point is not very clear. What kind of environment? > +(defun org-latex-generate-engraved-preamble (info syntax-colours-p) > + "Generate the preamble to setup engraved code. > +The result is constructed from `org-latex-engraved-preamble' and > +`org-latex-engraved-options'." This is relying on (:latex-engraved-options nil nil org-latex-engraved-options) (:latex-engraved-preamble nil nil org-latex-engraved-preamble) If it changes any time in future (e.g. to allow per-file settings), the docstring may be overlooked. > + (let ((src-p (org-element-map (plist-get info :parse-tree) > + '(src-block inline-src-block) #'identity)) > + (fixedw-p > + (org-element-map (plist-get info :parse-tree) > + '(example-block fixed-width) #'identity))) I'd use FIRST-MATCH argument for org-element-map. It will be slightly faster on large buffers. > - (downcase org-lang))) > + (downcase lang))) I am not sure if this belongs to this patch. Please double check. > + (mapcar 'length > + (org-split-string (car code-info) > + "\n"))))) I am not sure how well it will work with e.g. Chinese characters in comments. Best, Ihor