lisp/ox-latex.el: Add `org-latex-listings-src-omit-language'

* lisp/ox-latex.el (org-latex-listings-src-omit-language): New
customization that controls whether language= should be included in
the parameters of the lstlisting environmet generated by a src block.

(org-latex-src-block--listings): Do not add language parameter when
`org-latex-listings-src-omit-language' is non-nil.

* etc/ORG-NEWS (New =org-latex-listings-src-omit-language= variable
for LaTeX export): Document the new defcustom.
This commit is contained in:
Pedro A. Aranda Gutierrez 2022-12-14 07:22:23 +01:00 committed by Ihor Radchenko
parent 0c467b6b89
commit 322b2fd226
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 35 additions and 2 deletions

View File

@ -12,6 +12,21 @@ See the end of the file for license conditions.
Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** New options
*** New ~org-latex-listings-src-omit-language~ customization for LaTeX export
The ~org-latex-listings-src-omit-language~ customization variable
allows you to omit the =language= parameter in the exported
=lstlisting= environment. This is necessary when the =listings=
backend delegates listing generation to another package like
=fancyvrb= using the following setup in the document header:
#+BEGIN_src org
,#+LATEX_HEADER: \RequirePackage{fancyvrb}
,#+LATEX_HEADER: \DefineVerbatimEnvironment{verbatim}{Verbatim}{...whatever...}
,#+LATEX_HEADER: \DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
#+END_src
* Version 9.6
** Important announcements and breaking changes
@ -432,6 +447,7 @@ following properties: ~:hook~, ~:prepare-finalize~,
~:before-finalize~, ~:after-finalize~. These nullary functions run
prior to their global counterparts for the selected template.
** New options
*** A new option for custom setting ~org-refile-use-outline-path~ to show document title in refile targets
@ -747,7 +763,6 @@ following snippet to allow multiple different ID formats in Org files.
org-attach-id-uuid-folder-format
org-attach-id-ts-folder-format))
#+end_src
* Version 9.5
** Important announcements and breaking changes

View File

@ -1021,6 +1021,23 @@ in this list - but it does not hurt if it is present."
(symbol :tag "Major mode ")
(string :tag "Listings language"))))
(defcustom org-latex-listings-src-omit-language nil
"Discard src block language parameter in listings.
Set this option to t to omit the \"language=\" in the parameters to
\"lstlisting\" environments when exporting an src block.
This is necessary, for example, when the \"fancyvrb\" package is used
instead of \"listings\":
#+LATEX_HEADER: \\RequirePackage{fancyvrb}
#+LATEX_HEADER: \\DefineVerbatimEnvironment{verbatim}{Verbatim}{...}
#+LATEX_HEADER: \\DefineVerbatimEnvironment{lstlisting}{Verbatim}{...}"
:group 'org-export-latex
:package-version '(Org . "9.7")
:type 'boolean
:safe #'booleanp)
(defcustom org-latex-listings-options nil
"Association list of options for the latex listings package.
@ -3593,7 +3610,8 @@ and FLOAT are extracted from SRC-BLOCK and INFO in `org-latex-src-block'."
((string= "multicolumn" float) '(("float" "*")))
((and float (not (assoc "float" lst-opt)))
`(("float" ,(plist-get info :latex-default-figure-position)))))
`(("language" ,lst-lang))
(unless org-latex-listings-src-omit-language
`(("language" ,lst-lang)))
(when label
`(("label" ,(org-latex--label src-block info))))
(when caption-str