emacs-diffs
[Top][All Lists]
Advanced

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

master 95f987cbd5: Don't make a custom-save-icons section if there's not


From: Lars Ingebrigtsen
Subject: master 95f987cbd5: Don't make a custom-save-icons section if there's nothing to save
Date: Sun, 31 Jul 2022 12:17:29 -0400 (EDT)

branch: master
commit 95f987cbd5eb54e9a497fefe1fe34f6c06801e2f
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Don't make a custom-save-icons section if there's nothing to save
    
    * lisp/cus-edit.el (custom-save-icons): Only make an entry when
    there's something to save (bug#56860).  Also autoload.
---
 lisp/cus-edit.el | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 1012d08ab5..edc09f3199 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -5543,6 +5543,7 @@ See `define-icon' for details."
   (pcase-dolist (`(,icon ,spec) specs)
     (custom-push-theme 'theme-icon icon theme 'set spec)))
 
+;;;###autoload
 (defun custom-set-icons (&rest args)
   "Install user customizations of icon specs specified in ARGS.
 These settings are registered as theme `user'.
@@ -5556,27 +5557,28 @@ This stores EXP (without evaluating it) as the saved 
spec for SYMBOL."
 ;;;###autoload
 (defun custom-save-icons ()
   "Save all customized icons in `custom-file'."
-  (save-excursion
-    (custom-save-delete 'custom-set-icons)
-    (let ((values nil))
-      (mapatoms
-       (lambda (symbol)
-         (let ((value (car-safe (get symbol 'theme-icon))))
-          (when (eq (car value) 'user)
-             (push (list symbol (cadr value)) values)))))
-      (ensure-empty-lines)
-      (insert "(custom-set-icons
+  (let ((values nil))
+    (mapatoms
+     (lambda (symbol)
+       (let ((value (car-safe (get symbol 'theme-icon))))
+        (when (eq (car value) 'user)
+           (push (list symbol (cadr value)) values)))))
+    (save-excursion
+      (custom-save-delete 'custom-set-icons)
+      (when values
+        (ensure-empty-lines)
+        (insert "(custom-set-icons
  ;; custom-set-icons was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.\n")
-      (dolist (value (sort values (lambda (s1 s2)
-                                    (string< (car s1) (car s2)))))
-       (unless (bolp)
-         (insert "\n"))
-        (insert "  '")
-        (prin1 value (current-buffer)))
-      (insert ")\n"))))
+        (dolist (value (sort values (lambda (s1 s2)
+                                      (string< (car s1) (car s2)))))
+         (unless (bolp)
+           (insert "\n"))
+          (insert "  '")
+          (prin1 value (current-buffer)))
+        (insert ")\n")))))
 
 (provide 'cus-edit)
 



reply via email to

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