changeset 25059:d6081fb56cda

(custom-save-variables, custom-save-faces): Sort the entries to make custom-file more readable.
author Markus Rost <rost@math.uni-bielefeld.de>
date Sun, 25 Jul 1999 14:29:22 +0000
parents af119d40c92d
children 82d83822ab69
files lisp/cus-edit.el
diffstat 1 files changed, 58 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/cus-edit.el	Sun Jul 25 05:50:42 1999 +0000
+++ b/lisp/cus-edit.el	Sun Jul 25 14:29:22 1999 +0000
@@ -3122,31 +3122,40 @@
   "Save all customized variables in `custom-file'."
   (save-excursion
     (custom-save-delete 'custom-set-variables)
-    (let ((standard-output (current-buffer)))
+    (let ((standard-output (current-buffer))
+	  (saved-list (make-list 1 0))
+	  sort-fold-case)
+      ;; First create a sorted list of saved variables.
+      (mapatoms
+       (lambda (symbol)
+	 (if (get symbol 'saved-value)
+	     (nconc saved-list (list symbol)))))
+      (setq saved-list (sort (cdr saved-list) 'string<))
       (unless (bolp)
 	(princ "\n"))
       (princ "(custom-set-variables")
-      (mapatoms (lambda (symbol)
-		  (let ((value (get symbol 'saved-value))
-			(requests (get symbol 'custom-requests))
-			(now (not (or (get symbol 'standard-value)
-				      (and (not (boundp symbol))
-					   (not (get symbol 'force-value)))))))
-		    (when value
-		      (princ "\n '(")
-		      (princ symbol)
-		      (princ " ")
-		      (prin1 (car value))
-		      (cond (requests
-			     (if now
-				 (princ " t ")
-			       (princ " nil "))
-			     (prin1 requests)
-			     (princ ")"))
-			    (now
-			     (princ " t)"))
-			    (t
-			     (princ ")")))))))
+      (mapcar
+       (lambda (symbol)
+	 (let ((value (get symbol 'saved-value))
+	       (requests (get symbol 'custom-requests))
+	       (now (not (or (get symbol 'standard-value)
+			     (and (not (boundp symbol))
+				  (not (get symbol 'force-value)))))))
+	   (princ "\n '(")
+	   (princ symbol)
+	   (princ " ")
+	   (prin1 (car value))
+	   (cond (requests
+		  (if now
+		      (princ " t ")
+		    (princ " nil "))
+		  (prin1 requests)
+		  (princ ")"))
+		 (now
+		  (princ " t)"))
+		 (t
+		  (princ ")")))))
+       saved-list)
       (princ ")")
       (unless (looking-at "\n")
 	(princ "\n")))))
@@ -3155,34 +3164,36 @@
   "Save all customized faces in `custom-file'."
   (save-excursion
     (custom-save-delete 'custom-set-faces)
-    (let ((standard-output (current-buffer)))
+    (let ((standard-output (current-buffer))
+	  (saved-list (make-list 1 0))
+	  sort-fold-case)
+      ;; First create a sorted list of saved faces.
+      (mapatoms
+       (lambda (symbol)
+	 (if (get symbol 'saved-face)
+	     (nconc saved-list (list symbol)))))
+      (setq saved-list (sort (cdr saved-list) 'string<))
+      ;; The default face must be first, since it affects the others.
+      (if (memq 'default saved-list)
+	  (setq saved-list (cons 'default (delq 'default saved-list))))
       (unless (bolp)
 	(princ "\n"))
       (princ "(custom-set-faces")
-      (let ((value (get 'default 'saved-face)))
-	;; The default face must be first, since it affects the others.
-	(when value
-	  (princ "\n '(default ")
-	  (prin1 value)
-	  (if (or (get 'default 'face-defface-spec)
-		  (and (not (custom-facep 'default))
-		       (not (get 'default 'force-face))))
-	      (princ ")")
-	    (princ " t)"))))
-      (mapatoms (lambda (symbol)
-		  (let ((value (get symbol 'saved-face)))
-		    (when (and (not (eq symbol 'default))
-			       ;; Don't print default face here.
-			       value)
-		      (princ "\n '(")
-		      (princ symbol)
-		      (princ " ")
-		      (prin1 value)
-		      (if (or (get symbol 'face-defface-spec)
-			      (and (not (custom-facep symbol))
-				   (not (get symbol 'force-face))))
-			  (princ ")")
-			(princ " t)"))))))
+      (mapcar
+       (lambda (symbol)
+	 (let ((value (get symbol 'saved-face)))
+	   (unless (eq symbol 'default))
+	   ;; Don't print default face here.
+	   (princ "\n '(")
+	   (princ symbol)
+	   (princ " ")
+	   (prin1 value)
+	   (if (or (get symbol 'face-defface-spec)
+		   (and (not (custom-facep symbol))
+			(not (get symbol 'force-face))))
+	       (princ ")")
+	     (princ " t)"))))
+       saved-list)
       (princ ")")
       (unless (looking-at "\n")
 	(princ "\n")))))