Hi,

attached is a patch to silence the setopt-local warnings for org-latex-default-packages-alist and org-latex-packages-alist.

This warning has been annoying when jointly editing the Emacs-Conf presentation with Roger.

I think you have already seen it, but I don't want to interfere in the "big refactoring". It would be nice it is was applied sooner than later.
/PA
--
Pedro A. Aranda
ox-latex & ox-beamer maintainer

Sagen's Paradeiser! (ORF: Als Radiohören gefährlich war) => write BE!
IA: onomatopeya del rebuzno
2nd year of the New Koprocracy
From d0c274221db15f53881ee1a797c76b446a982058 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <[email protected]>
Date: Wed, 25 Nov 2026 07:40:34 +0100
Subject: [PATCH 8/8] org.el: setopt-local compatible LaTeX packages list
 setter

* lisp/org.el (org-set-packages-alist): Add optional buffer-local
parameter. When it is set, use 'set-local', else use
'set-default-toplevel-value'.

An initial try at silencing setopt-local warnings when using Local
Variables to set the value of 'org-latex-default-packages-alist' or
'org-latex-packages-alist'.
---
 lisp/org.el | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index b4cdde700..8148527f6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1489,13 +1489,19 @@ (defcustom org-agenda-text-search-extra-files nil
 	      (const :tag "Agenda Archives" agenda-archives)
 	      (repeat :inline t (file))))
 
-(defun org-set-packages-alist (var val)
-  "Set the packages alist and make sure it has 3 elements per entry."
-  (set-default-toplevel-value var (mapcar (lambda (x)
-		                            (if (and (consp x) (= (length x) 2))
-			                        (list (car x) (nth 1 x) t)
-		                              x))
-		                          val)))
+(defun org-set-packages-alist (var val &optional buffer-local)
+  "Set the packages alist and make sure it has at least 3 elements per entry.
+Minimum will be:
+(ARGS PACKAGE t)
+which will make packages be used in snippets too."
+  (let ((set-function (if buffer-local
+                          #'set-local #'set-default-toplevel-value)))
+    (funcall set-function var
+             (mapcar (lambda (x)
+		       (if (and (consp x) (= (length x) 2))
+			   (list (car x) (nth 1 x) t)
+		         x))
+		     val))))
 
 (defun org-get-packages-alist (var)
   "Get the packages alist and make sure it has 3 elements per entry."
-- 
2.53.0

Reply via email to