emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Bastien <bzg@gnu.org>, Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: PATCH: include controlling language= in my previous patch
Date: Wed, 14 Dec 2022 07:37:35 +0100	[thread overview]
Message-ID: <CAO48Bk8js2Fjt75QMsQevG4WOqbWMuNYeURT+EutaNafwJCYkA@mail.gmail.com> (raw)
In-Reply-To: <87bko7cyhy.fsf@localhost>


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

Next try... I'm learning a lot :-)

BR,/PA


On Tue, 13 Dec 2022 at 12:51, Ihor Radchenko <yantar92@posteo.net> wrote:

> Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:
>
> > thanks for the patience. I hope to have implemented all suggestions by
> now.
>
> No. You missed several.
>
> 1. :version is not necessary. See 15.1 Common Item Keywords section of
> Elisp manual:
>
> 2. Please also provide changelog entries. See
> https://orgmode.org/worg/org-contribute.html#commit-messages
>
> More comments below.
>
> > +*** New =org-latex-listings-src-omit-language= variable 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
> > +forwards the actual listing generation to another package like
> > +=fancyvrb= using the following setup in the document header:
>
> Please use ~code~ for Elisp symbols and double space between sentences.
> You may refer to etc/Documentation_Standards.org file for details.
>
> > +#+BEGIN_example
> > +#+LATEX_HEADER: \\RequirePackage{fancyvrb}
> > +#+LATEX_HEADER:
> \\DefineVerbatimEnvironment{verbatim}{Verbatim}{...whatever...}
> > +#+LATEX_HEADER:
> \\DefineVerbatimEnvironment{lstlisting}{Verbatim}{...whatever...}
> > +#+END_example
>
> Please quote #+LATEX_HEADER in the example block with commas. (Org will
> do it automatically for you if you edit the example block with C-c ')
>
> > +*** The LaTeX export backend only emits =label= and =caption= when they
> are not empty
> > +
> > +When exporting a SRC block and using the listings backend , =label==
> > +and =caption== parameters for the =lstlisting= environment will be
> > +only generated when they are not empty. Things like
> > +
> > +#+BEGIN_src latex
> > +\begin{lstlisting}[label= ,caption= ,captionpos=b]
> > +\end{lstlisting}
> > +#+END_src
> > +
> > +will no more appear.
>
> This is probably not something people need to take note of. Not necessary.
>
> > Subject: [PATCH 2/4] Allow to suppress language= in SRC blocks
> > Subject: [PATCH 3/4] Refine DOCSTRING for
> org-latex-listings-src-omit-language
>
> 2nd and 3rd patches can be merged into one.
>
> --
> 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

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

[-- Attachment #2: 0003-etc-ORG-NEWS-add-org-latex-listings-src-omit-languag.patch --]
[-- Type: text/x-patch, Size: 1752 bytes --]

From dabdc3026e32ec674e22698de6257d724f60c4af Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda Gutierrez" <paaguti@gmail.com>
Date: Wed, 14 Dec 2022 07:32:31 +0100
Subject: [PATCH 3/3] etc/ORG-NEWS: add org-latex-listings-src-omit-language

* etc/ORG-NEWS: Add information for `org-latex-listings-src-omit-language'
---
 etc/ORG-NEWS | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5d5e726e0..bd78ed9a7 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -432,6 +432,21 @@ following properties: ~:hook~, ~:prepare-finalize~,
 ~:before-finalize~, ~:after-finalize~.  These nullary functions run
 prior to their global counterparts for the selected template.
 
+
+*** New =org-latex-listings-src-omit-language= variable 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
+
 ** New options
 *** A new option for custom setting ~org-refile-use-outline-path~ to show document title in refile targets
 
@@ -747,7 +762,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
-- 
2.25.1


[-- Attachment #3: 0001-lisp-ox-latex.el-don-t-emit-empyt-label-caption.patch --]
[-- Type: text/x-patch, Size: 1633 bytes --]

From 2038bddb662f393d99ceb88c9bf9d2a6898919dc Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda Gutierrez" <paaguti@gmail.com>
Date: Wed, 14 Dec 2022 07:12:55 +0100
Subject: [PATCH 1/3] lisp/ox-latex.el: don't emit empyt label=, caption=

* lisp/ox-latex.el: (org-latex-src-block--listings):
  Don't emit label= if label is empty.
  DOn't emit caption= or captionpos= is caption is empty.
---
 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


[-- Attachment #4: 0002-lisp-ox-latex.el-Add-org-latex-listings-src-omit-lan.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

From af8a3032884e536aa4a398d3c248cb76b689b977 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda Gutierrez" <paaguti@gmail.com>
Date: Wed, 14 Dec 2022 07:22:23 +0100
Subject: [PATCH 2/3] lisp/ox-latex.el: Add
 org-latex-listings-src-omit-language

* lisp/ox-latex.el: Add org-latex-listings-src-omit-language variable
to control whether language= should be included in the parameters
of the lstlisting environmet generated by a SRC block.
---
 lisp/ox-latex.el | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index f03903605..f18c2a068 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1021,6 +1021,24 @@ 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.
+
+This is necessary, for example, when the `fancyvrb' package is used
+instead of `listings' by including the following in the doc header:
+
+#+LATEX_HEADER: \\RequirePackage{fancyvrb}
+#+LATEX_HEADER: \\DefineVerbatimEnvironment{verbatim}{Verbatim}{...}
+#+LATEX_HEADER: \\DefineVerbatimEnvironment{lstlisting}{Verbatim}{...}
+
+{...} is whatever default parameters you need to pass to either environment.
+"
+  :group 'org-export-latex
+  :package-version '(Org . "9.7")
+  :type 'boolean)
+
 (defcustom org-latex-listings-options nil
   "Association list of options for the latex listings package.
 
@@ -3593,7 +3611,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


  reply	other threads:[~2022-12-14  6:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11  8:06 PATCH: include controlling language= in my previous patch Pedro Andres Aranda Gutierrez
2022-12-11 10:05 ` Ihor Radchenko
2022-12-11 11:23   ` Pedro Andres Aranda Gutierrez
2022-12-12 10:11     ` Ihor Radchenko
2022-12-12 12:57       ` Pedro Andres Aranda Gutierrez
2022-12-13  9:24         ` Ihor Radchenko
2022-12-13 11:08           ` Pedro Andres Aranda Gutierrez
2022-12-13 11:51             ` Ihor Radchenko
2022-12-14  6:37               ` Pedro Andres Aranda Gutierrez [this message]
2022-12-14  9:29                 ` Ihor Radchenko
2022-12-18 13:17                   ` Ihor Radchenko
2022-12-18  9:31           ` Bastien Guerry

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=CAO48Bk8js2Fjt75QMsQevG4WOqbWMuNYeURT+EutaNafwJCYkA@mail.gmail.com \
    --to=paaguti@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /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).