Hi,

I've (finally) followed the procedure and broken up the patch in two. One
for the labels= ,caption=  and one for the language= control.

FYI, I have already cleared the FSF paperwork for an emacs patch.

Best, /PA

On Mon, 12 Dec 2022 at 11:11, Ihor Radchenko <yanta...@posteo.net> wrote:

> Pedro Andres Aranda Gutierrez <paag...@gmail.com> writes:
>
> > thanks for the patience. I have a comment on the message you refer to...
> If
> > comes from 2014.
> >
> > So I have resorted to my fresh Emacs29, opened it with emacs -Q for a
> clean
> > environment.
> > ...
> > In my most humble opinion, I looks like the global \lstset{} isn't used
> and
> > that the caption/label is set locally. And this makes me believe that
> > label= or caption= are not very useful.
>
> I guess it is after
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6ef33b6dd
>
> If the cited issue is no longer need to be accounted for, your version
> should be fine.
>
> > I'm attaching the patch generated with git diff -p.
> > Mea culpa, I should have RTFM before sending anything :-)
>
> For the final version of the patch, you may better follow
> https://orgmode.org/worg/org-contribute.html#orgbc683f3 to create a
> .patch file. The .patch file will include your authorship. Do not forget
> the changelog entry.
>
> > +(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
> > +  )
>
> Please do not leave handing ")" on separate lines. It is against common
> Elisp style conventions. See D.1 Emacs Lisp Coding Conventions section
> of Elisp manual:
>
>    • Don’t make a habit of putting close-parentheses on lines by
>      themselves; Lisp programmers find this disconcerting.
>
> > +         (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
>
> These comments are not really needed. Actually, it is that `if' that
> deserved explanation. Not putting empty caption/label is intuitive.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>


-- 
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
From 3a4705f454ed5f692ce9d04f81d3ae9bc2efad56 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda Gutierrez" <paag...@gmail.com>
Date: Mon, 12 Dec 2022 13:51:49 +0100
Subject: [PATCH 2/2] Allow to suppress language= in SRC blocks

---
 lisp/ox-latex.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index f03903605..924afb399 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1021,6 +1021,15 @@ 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,7 +3602,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
-- 
2.25.1

From 3bc08d0ccabb2d3f4a0ea09bec5bc6a896c351ac Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda Gutierrez" <paag...@gmail.com>
Date: Mon, 12 Dec 2022 13:49:35 +0100
Subject: [PATCH 1/2] Don't emit empty labels and captions in SRC blocks

---
 lisp/ox-latex.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index a2d60d5db..f03903605 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -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)))
-- 
2.25.1

Reply via email to