diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 5b29a284c..a319fa830 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1021,6 +1021,16 @@ 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 + "Set this option to t to omit the +\"language=\" +in the parameters to \\begin{lstlisting} when exporting a src block" + :group 'org-export-latex + :version "30.0" + :package-version '(Org . "9.7") + :type 'boolean + ) + (defcustom org-latex-listings-options nil "Association list of options for the latex listings package. @@ -3593,12 +3603,13 @@ 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)) - (if label - `(("label" ,(org-latex--label src-block info))) - '(("label" " "))) - (if caption-str `(("caption" ,caption-str)) '(("caption" " "))) - `(("captionpos" ,(if caption-above-p "t" "b"))) + (unless org-latex-listings-src-omit-language + `(("language" ,lst-lang))) + (when label ; label= w/o label makes little sense + `(("label" ,(org-latex--label src-block info)))) + (when caption-str ; caption= w/o caption makes little sense + `(("caption" ,caption-str)) + `(("captionpos" ,(if caption-above-p "t" "b")))) ; as does captionpos w/o caption (cond ((assoc "numbers" lst-opt) nil) ((not num-start) '(("numbers" "none"))) (t `(("firstnumber" ,(number-to-string (1+ num-start)))