emacs-diffs
[Top][All Lists]
Advanced

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

master 6403ede201 1/2: Ensure that cus-load doesn't add things twice


From: Lars Ingebrigtsen
Subject: master 6403ede201 1/2: Ensure that cus-load doesn't add things twice
Date: Sat, 24 Sep 2022 06:44:59 -0400 (EDT)

branch: master
commit 6403ede2016d0d16a487d759ef45745c3d4ac24b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Ensure that cus-load doesn't add things twice
    
    * lisp/cus-dep.el (custom-make-dependencies): Use it.
    
    * lisp/custom.el (custom--add-custom-loads): New function.
---
 lisp/cus-dep.el | 5 +----
 lisp/custom.el  | 7 +++++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index 163a2da1f1..3f18202aff 100644
--- a/lisp/cus-dep.el
+++ b/lisp/cus-dep.el
@@ -175,10 +175,7 @@ Usage: emacs -batch -l ./cus-dep.el -f 
custom-make-dependencies DIRS"
                                    (prin1 (sort found #'string<))))
                            alist))))))
     (dolist (e (sort alist (lambda (e1 e2) (string< (car e1) (car e2)))))
-      ;; Don't overwrite elements added by packages.
-      (insert "(put '" (car e)
-              " 'custom-loads (append '" (cdr e)
-              " (get '" (car e) " 'custom-loads)))\n")))
+      (insert "(custom--add-custom-loads '" (car e) " '" (cdr e) ")\n")))
   (insert "\
 
 ;; The remainder of this file is for handling :version.
diff --git a/lisp/custom.el b/lisp/custom.el
index 352b5b0e16..604b1a3ff4 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1707,6 +1707,13 @@ If a choice with the same tag already exists, no action 
is taken."
       (put variable 'custom-type
            (append choices (list choice))))))
 
+(defun custom--add-custom-loads (symbol loads)
+  ;; Don't overwrite existing `custom-loads'.
+  (dolist (load (get symbol 'custom-loads))
+    (unless (memq load loads)
+      (push load loads)))
+  (put symbol 'custom-loads loads))
+
 (provide 'custom)
 
 ;;; custom.el ends here



reply via email to

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