From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: [patch] ox-latex.el to allow customization of verbatim environments (e.g., to use fancyvrb) Date: Sun, 14 Apr 2013 11:48:08 -0600 Message-ID: <87mwt1dmw7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:55172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URR2n-0005Mj-49 for emacs-orgmode@gnu.org; Sun, 14 Apr 2013 13:48:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URR2l-0000Tr-Na for emacs-orgmode@gnu.org; Sun, 14 Apr 2013 13:48:49 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:55622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URR2l-0000Tg-Dr for emacs-orgmode@gnu.org; Sun, 14 Apr 2013 13:48:47 -0400 Received: by mail-pa0-f41.google.com with SMTP id kx1so2208476pab.28 for ; Sun, 14 Apr 2013 10:48:46 -0700 (PDT) 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode Mailing List --=-=-= Content-Type: text/plain Please see the attached patch, I'd love for this to be applied. Cheers, --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0003-customizable-verbatim-export-for-LaTeX-fancyvrb.patch >From 04358f2eecf99e43f79956f0d3bc66aa0ab4b95d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 14 Apr 2013 11:43:30 -0600 Subject: [PATCH 3/3] customizable verbatim export for LaTeX (fancyvrb) This patch allows custom export of verbatim environments to LaTeX. Allowing the usage of packages such as fancyvrb. * lisp/ox-latex.el (org-latex-verbatim-env): New defcustom allowing customization of verbatim export for latex. (org-latex-example-block): Use new defcustom verbatim environment. (org-latex-fixed-width): Use new defcustom verbatim environment. (org-latex-quote-section): Use new defcustom verbatim environment. (org-latex-src-block): Use new defcustom verbatim environment. (org-latex-table): Use new defcustom verbatim environment. --- lisp/ox-latex.el | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 5975ce2..91747c3 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -957,6 +957,14 @@ log of a latex-run." (string :tag "Regexp") (string :tag "Message")))) +(defcustom org-latex-verbatim-env + "verbatim" + "Environment to use for verbatim markup in latex export. +To use the fancyvrb package set this variable to \"Verbatim\"." + :group 'org-export-latex + :version "24.4" + :package-version '(Org . "8.0") + :type 'string) ;;; Internal Functions @@ -1320,8 +1328,10 @@ information." (when (org-string-nw-p (org-element-property :value example-block)) (org-latex--wrap-label example-block - (format "\\begin{verbatim}\n%s\\end{verbatim}" - (org-export-format-code-default example-block info))))) + (format "\\begin{%s}\n%s\\end{%s}" + org-latex-verbatim-env + (org-export-format-code-default example-block info) + org-latex-verbatim-env)))) ;;;; Export Block @@ -1349,9 +1359,11 @@ CONTENTS is nil. INFO is a plist holding contextual information." CONTENTS is nil. INFO is a plist holding contextual information." (org-latex--wrap-label fixed-width - (format "\\begin{verbatim}\n%s\\end{verbatim}" + (format "\\begin{%s}\n%s\\end{%s}" + org-latex-verbatim-env (org-remove-indentation - (org-element-property :value fixed-width))))) + (org-element-property :value fixed-width)) + org-latex-verbatim-env))) ;;;; Footnote Reference @@ -2098,8 +2110,8 @@ holding contextual information." CONTENTS is nil. INFO is a plist holding contextual information." (let ((value (org-remove-indentation (org-element-property :value quote-section)))) - (when value (format "\\begin{verbatim}\n%s\\end{verbatim}" value)))) - + (when value (format "\\begin{%s}\n%s\\end{%s}" + org-latex-verbatim-env value org-latex-verbatim-env)))) ;;;; Radio Target @@ -2171,8 +2183,10 @@ contextual information." caption-str)))) (format (or float-env "%s") - (concat (format "\\begin{verbatim}\n%s\\end{verbatim}" - (org-export-format-code-default src-block info)))))) + (concat (format "\\begin{%s}\n%s\\end{%s}" + org-latex-verbatim-env + (org-export-format-code-default src-block info) + org-latex-verbatim-env))))) ;; Case 2. Custom environment. (custom-env (format "\\begin{%s}\n%s\\end{%s}\n" custom-env @@ -2377,10 +2391,12 @@ contextual information." (cond ;; Case 1: Verbatim table. ((string= type "verbatim") - (format "\\begin{verbatim}\n%s\n\\end{verbatim}" + (format "\\begin{%s}\n%s\n\\end{%s}" + org-latex-verbatim-env ;; Re-create table, without affiliated keywords. (org-trim (org-element-interpret-data - `(table nil ,@(org-element-contents table)))))) + `(table nil ,@(org-element-contents table)))) + org-latex-verbatim-env)) ;; Case 2: Matrix. ((or (string= type "math") (string= type "inline-math")) (org-latex--math-table table info)) @@ -2741,8 +2757,8 @@ holding contextual information." "Transcode a VERBATIM object from Org to LaTeX. CONTENTS is nil. INFO is a plist used as a communication channel." - (org-latex--text-markup (org-element-property :value verbatim) 'verbatim)) - + (org-latex--text-markup (org-element-property :value verbatim) + org-latex-verbatim-env)) ;;;; Verse Block -- 1.8.2.1 --=-=-= Content-Type: text/plain -- Eric Schulte http://cs.unm.edu/~eschulte --=-=-=--