]> git.eshelyaron.com Git - emacs.git/commitdiff
2002-02-05 Per Abrahamsen <abraham@dina.kvl.dk>
authorPer Abrahamsen <abraham@dina.kvl.dk>
Thu, 7 Feb 2002 17:32:18 +0000 (17:32 +0000)
committerPer Abrahamsen <abraham@dina.kvl.dk>
Thu, 7 Feb 2002 17:32:18 +0000 (17:32 +0000)
* cus-edit.el (customize-mark-to-save): New function.
* menu-bar.el (menu-bar-options-save): Rewrote.

lisp/ChangeLog
lisp/cus-edit.el
lisp/menu-bar.el

index 64d044d9e1ba9c11647044cc13a46cefd1e7f802..468c08704eaac3790a3b61d938f6342a8720ddbe 100644 (file)
@@ -1,3 +1,8 @@
+2002-02-05  Per Abrahamsen  <abraham@dina.kvl.dk>
+
+       * cus-edit.el (customize-mark-to-save): New function.
+       * menu-bar.el (menu-bar-options-save): Rewrote.
+
 2002-02-06  Kim F. Storm  <storm@cua.dk>
 
        * help.el (where-is): Report remapped commands.
@@ -84,6 +89,7 @@
        * gud.el (gud-refresh): Call recenter only after we are sure we
        are in the right window.
 
+>>>>>>> 1.3415
 2002-02-05  Pavel Jan\e,Bm\e(Bk  <Pavel@Janik.cz>
 
        * cus-start.el (x-use-underline-position-properties):
index ca11e484f844f4afe647e235caaf51b76ac7a9a3..a5cb2071eb9e93c934d215cc97916b545063d36a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages
 ;;
-;; Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: help, faces
@@ -3745,6 +3745,36 @@ or (if there were none) at the end of the buffer."
       (let ((file-precious-flag t))
        (save-buffer)))))
 
+;;;###autoload
+(defun customize-mark-to-save (symbol)
+  "Mark SYMBOL for later saving.
+
+If the default value of SYMBOL is different from the standard value, 
+set the 'saved-value' property to a list whose car evaluates to the
+default value. Otherwise, set it til nil.
+
+To actually save the value, call 'custom-save-all'.
+
+Return non-nil iff the 'saved-value' property actually changed."
+  (let* ((get (or (get symbol 'custom-get) 'default-value))
+        (value (funcall get symbol))
+        (saved (get symbol 'saved-value))
+        (standard (get symbol 'standard-value))
+        (comment (get symbol 'customized-variable-comment)))
+    ;; Save default value iff different from standard value.
+    (if (and standard 
+            (not (condition-case nil
+                     (equal value (eval (car standard)))
+                   (error nil))))
+       (put symbol 'saved-value (list (custom-quote value)))
+      (put symbol 'saved-value nil))
+    ;; Clear customized information (set, but not saved).
+    (put symbol 'customized-value nil)
+    ;; Save any comment that might have been set.
+    (when comment
+      (put symbol 'saved-variable-comment comment))
+    (not (equal saved (get symbol 'saved-value)))))
+
 ;;; The Customize Menu.
 
 ;;; Menu support
index 634c7f53cff523e0d9d525fdc3036ceefce1b27a..10314e193fbf8e11e08d1a7f8e8ad8ec852b6f52 100644 (file)
@@ -545,21 +545,30 @@ Do the same for the keys of the same name."
 (defun menu-bar-options-save ()
   "Save current values of Options menu items using Custom."
   (interactive)
-  (dolist (elt '(debug-on-quit debug-on-error auto-compression-mode
-                case-fold-search truncate-lines show-paren-mode
-                transient-mark-mode global-font-lock-mode
-                current-language-environment default-input-method
-                default-frame-alist display-time-mode))
-    (if (default-value elt)
-       (customize-save-variable elt (default-value elt))))
-  (if (memq 'turn-on-auto-fill text-mode-hook)
-      (customize-save-variable 'text-mode-hook
-                              (default-value 'text-mode-hook)))
-  (if (featurep 'saveplace)
-      (customize-save-variable 'save-place (default-value 'save-place)))
-  (if (featurep 'uniquify)
-      (customize-save-variable 'uniquify-buffer-name-style
-                              (default-value 'uniquify-buffer-name-style))))
+  (let ((need-save nil))
+    (dolist (elt '(debug-on-quit debug-on-error auto-compression-mode
+                  case-fold-search truncate-lines show-paren-mode
+                  transient-mark-mode global-font-lock-mode
+                  current-language-environment default-input-method
+                  default-frame-alist display-time-mode))
+      (when (customize-mark-to-save elt)
+       (setq need-save t)))
+    ;; We only want to save text-mode-hook after adding or removing auto fill.
+    (and (or (memq 'turn-on-auto-fill text-mode-hook) ;Added.
+            ;; If it is already saved, it is safe to save.
+            (get 'text-mode-hook 'saved-value)) ;Maybe removed.
+        (customize-mark-to-save 'text-mode-hook)
+        (setq need-save t))
+    ;; Avoid loading extra libraries.
+    (and (featurep 'saveplace)
+        (customize-mark-to-save 'save-place)
+        (setq need-save t))
+    (and(featurep 'uniquify)
+       (customize-mark-to-save 'uniquify-buffer-name-style)
+       (setq need-save t))
+    ;; Save if we changed anything.
+    (when need-save
+      (custom-save-all))))
 
 (define-key menu-bar-options-menu [save]
   '(menu-item "Save Options" menu-bar-options-save