From 414fd7021adab560b064bdb55e156527b3c698ed Mon Sep 17 00:00:00 2001 From: Per Abrahamsen Date: Thu, 7 Feb 2002 17:32:18 +0000 Subject: [PATCH] 2002-02-05 Per Abrahamsen * cus-edit.el (customize-mark-to-save): New function. * menu-bar.el (menu-bar-options-save): Rewrote. --- lisp/ChangeLog | 6 ++++++ lisp/cus-edit.el | 32 +++++++++++++++++++++++++++++++- lisp/menu-bar.el | 39 ++++++++++++++++++++++++--------------- 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 64d044d9e1b..468c08704ea 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2002-02-05 Per Abrahamsen + + * cus-edit.el (customize-mark-to-save): New function. + * menu-bar.el (menu-bar-options-save): Rewrote. + 2002-02-06 Kim F. Storm * 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,Bm(Bk * cus-start.el (x-use-underline-position-properties): diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index ca11e484f84..a5cb2071eb9 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -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 ;; 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 diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 634c7f53cff..10314e193fb 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -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 -- 2.39.2