A small refinement in the attached patch.

On 21/04/2026 20:41, Ihor Radchenko wrote:
"Pedro A. Aranda" <[email protected]> writes:

attached is a patch for the reported and confirmed bug.

Thanks!
Applied onto main, after adjusting the commit message.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=2bc1124e6
Fixed.


--
Sagen's Paradeiser! (ORF: Als Radiohören gefährlich war) => write BE!

2nd year of the New Koprocracy
From 2b8b9b8d949be6ef2c6fad8df53b0974252fa834 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <[email protected]>
Date: Thu, 23 Apr 2026 07:54:22 +0200
Subject: [PATCH] ox-latex.el: Prepare (org-latex--mk-options) for the future

ox-latex.el: (org-latex--mk-options) add an optional parameter
KEEP-NIL to return an empty string when STR is nil unless you need it
to be nil.

This function comes from the feature branch and there the empty string
is used in most LaTeX commands when STR is nil.
---
 lisp/ox-latex.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index a54ac5a3b..5ba35a0ba 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2018,13 +2018,13 @@ The default behaviour is to typeset with the Roman font family."
 
 
 ;;; Template
-(defun org-latex--mk-options (str)
+(defun org-latex--mk-options (str &optional keep-nil)
   "Make STR be enclosed in [ ] or return an empty string if nil or empty.
 
 If STR is nil or an empty string, return STR.
 If STR is a traditional LATEX_CLASS_OPTIONS enclosed in [ ], return it as is.
 If the square brackets are missing, return STR enclosed in square brackets."
-  (if (or (not str) (length= str 0)) str
+  (if (or (null str) (equal str "")) (if keep-nil str "")
     (save-match-data  ; just in case it is used in a search/replace context
       (let ((str (concat "[" str "]"))) ; make sure it is enclosed in []
         (replace-regexp-in-string  ; remove excess [ at the beginning
@@ -2044,7 +2044,8 @@ specified in `org-latex-default-packages-alist' or
   (let* ((class (plist-get info :latex-class))
 	 (class-template
 	  (or template
-	      (let* ((class-options (org-latex--mk-options (plist-get info :latex-class-options)))
+              ;; Don't make `class-options' an empty string for (not class-options) below.
+	      (let* ((class-options (org-latex--mk-options (plist-get info :latex-class-options) t))
 		     (header (nth 1 (assoc class (plist-get info :latex-classes)))))
 		(and (stringp header)
 	             (mapconcat #'org-element-normalize-string
-- 
2.43.0

Reply via email to