From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lixin Chin Subject: [PATCH] ox-latex.el: Wrap 'minted' src blocks in a 'listing', environment Date: Tue, 31 Jan 2017 14:28:16 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------80DF63E96374EE6793DE6E51" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYRvY-0004KZ-97 for emacs-orgmode@gnu.org; Tue, 31 Jan 2017 01:28:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYRvT-0005Vr-DU for emacs-orgmode@gnu.org; Tue, 31 Jan 2017 01:28:28 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYRvT-0005Vl-4J for emacs-orgmode@gnu.org; Tue, 31 Jan 2017 01:28:23 -0500 Received: by mail-pf0-x242.google.com with SMTP id y143so26204615pfb.1 for ; Mon, 30 Jan 2017 22:28:22 -0800 (PST) Received: from [130.95.197.213] ([130.95.197.213]) by smtp.gmail.com with ESMTPSA id z127sm22495564pgz.29.2017.01.30.22.28.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 22:28:20 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------80DF63E96374EE6793DE6E51 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi everyone, Included is a patch to make the 'minted' source code syntax highlighting package behave the same as the 'listings' source code syntax package when exporting an org-mode document to LaTeX. Previously, 'minted' would only get exported to a floating environment if '#+ATTR_LATEX: :float multicolumn' was provided, whereas the org-mode documentation implies that it should be floated if any caption is provided. Regards, Lixin Chin * lisp/ox-latex.el (org-latex-src-block): Make source highlighting using the 'minted' syntax highlighting package behave the same as using the 'listings' syntax highlighting package. The source block should be floating if a caption is provided, or if ':float t' is provided in an '#+ATTR_LATEX:' block. Previously, the source block would only be floating if ':float multicolumn' was provided. This now matches the org-mode documentation for source blocks. --- lisp/ox-latex.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index d05991233..3cea81650 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1301,7 +1301,7 @@ For non-floats, see `org-latex--wrap-label'." (and (eq type 'src-block) (not (plist-get attr :float)) (memq (plist-get info :latex-listings) - '(nil minted))))) + '(nil))))) (short (org-export-get-caption element t)) (caption-from-attr-latex (plist-get attr :caption))) (cond @@ -2880,13 +2880,19 @@ contextual information." (float-env (cond ((string= "multicolumn" float) - (format "\\begin{listing*}\n%s%%s\n%s\\end{listing*}" + (format "\\begin{listing*}[%s]\n%s%%s\n%s\\end{listing*}" + (plist-get info :latex-default-figure-position) (if caption-above-p caption-str "") (if caption-above-p "" caption-str))) (caption - (concat (if caption-above-p caption-str "") - "%s" - (if caption-above-p "" (concat "\n" caption-str)))) + (format "\\begin{listing}[%s]\n%s%%s\n%s\\end{listing}" + (plist-get info :latex-default-figure-position) + (if caption-above-p caption-str "") + (if caption-above-p "" caption-str))) + ((string= "t" float) + (concat (format "\\begin{listing}[%s]\n" + (plist-get info :latex-default-figure-position)) + "%s\n\\end{listing}")) (t "%s"))) (options (plist-get info :latex-minted-options)) (body -- 2.11.0 --------------80DF63E96374EE6793DE6E51 Content-Type: text/plain; charset=UTF-8; name="0001-ox-latex.el-Wrap-minted-src-blocks-in-a-listing-envi.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0="0001-ox-latex.el-Wrap-minted-src-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