Hi Tassilo and all,

>>>>> Tassilo Horn <[email protected]> writes:
>> I did notice, BTW, that this function uses `add-to-list`, the doc
>> string of which warns against using it in Lisp code.

> Yes, you should definitely not use it on lexical local variables.  With
> AUCTeX 13, we switched to lexical-binding, and now that doesn't work
> anymore.

According to the output of "git grep add-to-list", there are still some
usage of `add-to-list' on lexical scope variables, and I made the
attached patch. Does this look reasonable?

What is strange to me is that those wrong usages of `add-to-list' don't
cause error in a way the former polyglossia.el troubled Joost.
Customizing `TeX-view-program-list' and `TeX-view-program-selection' in
custom buffer proceeds smoothly and `TeX-add-to-alist' runs without
error for me, even without the patch.

Regards,
Ikumi Keita

diff --git a/tex.el b/tex.el
index 8469dd05..3c9b1c1c 100644
--- a/tex.el
+++ b/tex.el
@@ -1365,7 +1365,7 @@ restarting Emacs."
                      ,(let (list)
                         ;; Build the list of available predicates.
                         (mapc (lambda (spec)
-                                (add-to-list 'list `(const ,(car spec))))
+                                (push `(const ,(car spec)) list))
                               (append TeX-view-predicate-list
                                       TeX-view-predicate-list-builtin))
                         ;; Sort the list alphabetically.
@@ -1421,7 +1421,7 @@ are evaluated positively is chosen."
                 ;; Offer list of defined predicates.
                 ,(let (list)
                    (mapc (lambda (spec)
-                           (add-to-list 'list `(const ,(car spec))))
+                           (push `(const ,(car spec)) list))
                          (append TeX-view-predicate-list
                                  TeX-view-predicate-list-builtin))
                    (setq list (sort list
@@ -1437,8 +1437,7 @@ are evaluated positively is chosen."
                 (group (choice :tag "Viewer"
                                ,@(let (list)
                                    (mapc (lambda (spec)
-                                           (add-to-list 'list
-                                                        `(const ,(car spec))))
+                                           (push `(const ,(car spec)) list))
                                          (append TeX-view-program-list
                                                  TeX-view-program-list-builtin))
                                    (sort list
@@ -4713,9 +4712,8 @@ element to ALIST-VAR."
             (set alist-var (delete old-element (symbol-value alist-var)))
             ;; Append to `old-element' the values of the current element of
             ;; NEW-ALIST.
-            (mapc (lambda (elt) (add-to-list 'old-element elt t))
-                  (cdr new-element))
-            (set alist-var (add-to-list alist-var old-element t)))
+            (setq old-element (append old-element (cdr new-element)))
+            (add-to-list alist-var old-element t))
         (add-to-list alist-var new-element t)))
     ;; Next element of NEW-ALIST.
     (setq new-alist (cdr new-alist))))

Reply via email to