emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: PATCH: don't emit empty attributes for lstlistings in LaTeX listings backend
Date: Sun, 11 Dec 2022 08:17:00 +0100	[thread overview]
Message-ID: <CAO48Bk_6bqKgp1MgnZaARYku2+St6R1D4Bziq5NzMWNEWqfitw@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 447 bytes --]

Hi,

attached is a small patch for the Latex export backend that suppresses
emitting empty labels and captions when exporting src blocks using
'listings. This cleans up the emitted LaTeX.

BR,/PA
-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet

[-- Attachment #1.2: Type: text/html, Size: 732 bytes --]

[-- Attachment #2: org-nolabels.diff --]
[-- Type: text/x-patch, Size: 1173 bytes --]

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5b29a284c..1291aff95 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3594,11 +3594,11 @@ 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= 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)))

             reply	other threads:[~2022-12-11  7:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11  7:17 Pedro Andres Aranda Gutierrez [this message]
2022-12-11  9:50 ` PATCH: don't emit empty attributes for lstlistings in LaTeX listings backend Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO48Bk_6bqKgp1MgnZaARYku2+St6R1D4Bziq5NzMWNEWqfitw@mail.gmail.com \
    --to=paaguti@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).