auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. b326502954199d5f4339f


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. b326502954199d5f4339f09e82dfd1dcb32ca1d6
Date: Sun, 10 Jan 2021 01:01:18 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  b326502954199d5f4339f09e82dfd1dcb32ca1d6 (commit)
      from  b465e383472725d6885b811f97985cc38f5226cd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b326502954199d5f4339f09e82dfd1dcb32ca1d6
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Sat Jan 9 17:55:08 2021 +0900

    Don't use `add-to-list' on lexical vars
    
    * tex.el (TeX-view-program-list, TeX-view-program-selection):
    (TeX-add-to-alist):
    Don't use `add-to-list' on lexical scope variables.
    * tests/tex/utility.el (TeX-adding-to-alist): New test.
    (): Enable lexical binding.  Update copyright year.

diff --git a/tests/tex/utility.el b/tests/tex/utility.el
index 92442ba..ac0a8aa 100644
--- a/tests/tex/utility.el
+++ b/tests/tex/utility.el
@@ -1,6 +1,6 @@
-;;; utility.el --- tests for AUCTeX utility functions
+;;; utility.el --- tests for AUCTeX utility functions -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017, 2021 Free Software Foundation, Inc.
 
 ;; This file is part of AUCTeX.
 
@@ -28,4 +28,31 @@
   (should (TeX-delete-duplicate-strings '("nil")))
   (should (TeX-delete-dups-by-car '(("nil" . 1)))))
 
+;; `TeX-add-to-alist' needs dynamic scope variable as its first
+;; argument.
+(defvar TeX-dummy-alist nil)
+
+(ert-deftest TeX-adding-to-alist ()
+  "Check whether `TeX-add-to-alist' works as expected."
+  (TeX-add-to-alist 'TeX-dummy-alist '((a 1)))
+  (should (equal TeX-dummy-alist '((a 1))))
+
+  (TeX-add-to-alist 'TeX-dummy-alist '((b 2 3)))
+  (should (equal TeX-dummy-alist '((a 1) (b 2 3))))
+
+  ;; Append new value(s) of the same key. The target cons is moved to
+  ;; the last of the alist.
+  (TeX-add-to-alist 'TeX-dummy-alist '((a 4)))
+  (should (equal TeX-dummy-alist '((b 2 3) (a 1 4))))
+
+  ;; Adding the same value again should not create duplicated
+  ;; elements.
+  (TeX-add-to-alist 'TeX-dummy-alist '((a 1)))
+  (should (equal TeX-dummy-alist '((b 2 3) (a 1 4))))
+
+  ;; A value which is the same as the key should be included in the
+  ;; result.
+  (TeX-add-to-alist 'TeX-dummy-alist '((a a)))
+  (should (equal TeX-dummy-alist '((b 2 3) (a 1 4 a)))))
+
 ;;; utility.el ends here
diff --git a/tex.el b/tex.el
index 8469dd0..915702f 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))))
+                                (cl-pushnew `(const ,(car spec)) list :test 
#'equal))
                               (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))))
+                           (cl-pushnew `(const ,(car spec)) list :test 
#'equal))
                          (append TeX-view-predicate-list
                                  TeX-view-predicate-list-builtin))
                    (setq list (sort list
@@ -1437,8 +1437,8 @@ are evaluated positively is chosen."
                 (group (choice :tag "Viewer"
                                ,@(let (list)
                                    (mapc (lambda (spec)
-                                           (add-to-list 'list
-                                                        `(const ,(car spec))))
+                                           (cl-pushnew `(const ,(car spec))
+                                                       list :test #'equal))
                                          (append TeX-view-program-list
                                                  
TeX-view-program-list-builtin))
                                    (sort list
@@ -4713,9 +4713,11 @@ 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))
+            (mapc (lambda (elt)
+                    (unless (member elt (cdr old-element))
+                      (setq old-element (append old-element (list elt)))))
                   (cdr new-element))
-            (set alist-var (add-to-list alist-var old-element t)))
+            (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))))

-----------------------------------------------------------------------

Summary of changes:
 tests/tex/utility.el | 31 +++++++++++++++++++++++++++++--
 tex.el               | 14 ++++++++------
 2 files changed, 37 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]