lisp/ox-latex.el: Don't emit empty label=, caption=

* lisp/ox-latex.el (org-latex-src-block--listings): Don't emit label=
when label is empty.  Don't emit caption= and captionpos= when caption
is empty.

This is safe to do as long as we do not set "lstlisting" parameters
globally.  See the discussion in
https://orgmode.org/list/87h6xyqqod.fsf@localhost.
This commit is contained in:
Pedro A. Aranda Gutierrez 2022-12-14 07:12:55 +01:00 committed by Ihor Radchenko
parent dd4e06ddc3
commit 0c467b6b89
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 8 additions and 5 deletions

View File

@ -3594,11 +3594,14 @@ and FLOAT are extracted from SRC-BLOCK and INFO in `org-latex-src-block'."
((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")))
(when label
`(("label" ,(org-latex--label src-block info))))
(when caption-str
`(("caption" ,caption-str)))
(when caption-str
;; caption-above-p means captionpos is t(op)
;; else b(ottom)
`(("captionpos" ,(if caption-above-p "t" "b"))))
(cond ((assoc "numbers" lst-opt) nil)
((not num-start) '(("numbers" "none")))
(t `(("firstnumber" ,(number-to-string (1+ num-start)))