From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OOH0I4ylK2K2xQAAgWs5BA (envelope-from ) for ; Fri, 11 Mar 2022 20:39:56 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id mC65IIylK2IuvgAAauVa8A (envelope-from ) for ; Fri, 11 Mar 2022 20:39:56 +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 3881017B2B for ; Fri, 11 Mar 2022 20:39:56 +0100 (CET) Received: from localhost ([::1]:36794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSl7C-0007y1-Iy for larch@yhetil.org; Fri, 11 Mar 2022 14:39:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSl5m-0007xp-Nt for emacs-orgmode@gnu.org; Fri, 11 Mar 2022 14:38:26 -0500 Received: from ciao.gmane.io ([116.202.254.214]:57648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSl5c-00079B-ES for emacs-orgmode@gnu.org; Fri, 11 Mar 2022 14:38:17 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nSl5a-0008c0-U0 for emacs-orgmode@gnu.org; Fri, 11 Mar 2022 20:38:14 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Nick Dokos Subject: Re: Export (to `LaTeX`) =?utf-8?Q?`~=E2=9F=A8code_snippet?= =?utf-8?Q?=E2=9F=A9~`?= into =?utf-8?Q?`=5Clstinline+=E2=9F=A8code_snippe?= =?utf-8?Q?t=E2=9F=A9+`?= (just as does =?utf-8?Q?`src=5F=E2=9F=A8language?= =?utf-8?Q?=E2=9F=A9{=E2=9F=A8code_snippet=E2=9F=A9}`=29?= Date: Fri, 11 Mar 2022 14:38:06 -0500 Message-ID: <87mthwp9ep.fsf@alphaville.usersys.redhat.com> References: <87zglwbl97.fsf@example.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cancel-Lock: sha1:KRg4h1g7A6kJJrx4qZ1cR70WVAQ= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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=1647027596; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=K5yT7/AwRdv/LG+/AQU18U2qP6kWhWTTeBPQFAkBhqw=; b=tPNsUNmxDtprfvw2N/AHbGO4N536KUIgfYgTzood5OE96bOpBjPXzWfm9HfAvWI1dHeO9r htg8zugmYL1mQlfpoD3oztUI9Nyvs8jku5hjMHdKEmWMY3/KgdSLveC8spE3TuGnXohBuP /w0KDklIPihn3gSiY5vfaMpa8+Sekl/V3DJbHl2x+F+frOJFG68xlDlCVq9HeVHagYwTFW Zi4fMreOiCojuRBFLg/n4WwwH966+0Q9DGLB/u9LTCZf2l9hbkkIBTGLM/unEtF50JlXrx W+kWFM8xgey8oXjLXq0e61c6H1bVg2cWGhejV610ZmCIiCiKQE5LcSalpIMhlg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1647027596; a=rsa-sha256; cv=none; b=AwpDjid5yN5mpFky6OHehdgBLkUuczIdiLDYnlX/ovEIL6NN1oJ/rN0G67Ke6EQWpLfX8Y iQQLxQCUun98L+R5OBEbZn5is6uML3GnG2wt15mTASRXGTc7uhx6zmPmhZeTMY5Dx2xSZw OVN1b2rWDk1ta/yWdE8pf/U5JYSWGJLx5taAXoLEiltGFbwRosAM7gNSQnJBqtmiqy9wck xWzRxhWMX+52pFRB6Hj4pAKvBsy2MoI5DDOvK7en5418bBFsugb7A/RhA+T8CcBcUdq+W4 yLssKZB5eaxq3+5DZ0469nnq5xPumuJc1vtvN03GEtMmWkvN1Jc8gh8w0ThSig== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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.51 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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: 3881017B2B X-Spam-Score: 2.51 X-Migadu-Scanner: scn1.migadu.com X-TUID: 1XdcUe1cd3P4 Hi Denis, Denis Bitouzé writes: > Hi, > > here is a feature request about the LaTeX export (another one: the > previous mine, https://list.orgmode.org/87zgmda67z.fsf@example.com/, > sadly didn't get any answer). > > With `(setq org-latex-listings t)`, `src_⟨language⟩{⟨code snippet⟩}` is > exported from `org-mode` to `LaTeX` into > `\lstinline[language=⟨language⟩]~⟨code snippet⟩~` (here, `~` could be > almost any token): so far, so good. > > But one could expect to get the same export with the usual `org-mode` > syntax for code snippets: `~⟨code snippet⟩~` (this supposes the ⟨language⟩ > to be declared globally), as in the following example: > > #+OPTIONS: toc:nil title:nil > > #+LaTeX_HEADER: \usepackage{xcolor} > #+LaTeX_HEADER: \usepackage{listings} > #+LaTeX_HEADER: \lstset{language=[auto]lisp,basicstyle=\ttfamily,keywordstyle=\color{red}} > > #+PROPERTY: header-args :padline no :exports both :noweb yes :eval always > > src_lisp{defun} is fun! > > ~defun~ is fun! > > > For this, it is possible to redefine the `org-latex-code` function: > > ;; Inspired by https://emacs.stackexchange.com/q/70720/5267 > (defun org-latex-code (code _contents info) > "Transcode a CODE object from Org to LaTeX. > CONTENTS is nil. INFO is a plist used as a communication > channel." > (format "\\lstinline+%s+" > (org-element-property :value code))) > > but, IMHO, this should be the default. > > WDYT? I have no opinion on whether it should be the default or not, but I wanted to point out a possibility that might have not occurred to you: it is possible to define what's called a "derived" exporter, an exporter that shares most of its code with the exporter that it is derived from and only overrides one or two functions where you need a change. See the doc string of the function `org-export-define-derived-backend' for some details. There are also many examples where this feature is used (a simple one is in the doc string itself), but there are examples in the Org mode code itself, e.g the beamer exporter (ox-beamer.el) is derived from the LaTex one (ox-latex.el), as is the koma-letter exporter (ox-koma-letter.el), and the markdown exporter (ox-md.el) is derived from the HTML exporter in ox-html.el. Deriving a new back end from the LaTeX exporter and redefining one or two functions (like `org-latex-code' above) is IMO the best way forward. You get an exporter that works as you want and the defaults are left as-is (developers are wary about changing defaults: that brings out a lot of complaints of the "it was working fine yesterday but you broke it" variety). And you can publish your derived mode on e.g Gitlab/Github/whatever and make it available in MELPA for others to try out. HTH. -- Nick "There are only two hard problems in computer science: cache invalidation, naming things, and off-by-one errors." -Martin Fowler