Mercurial > emacs
changeset 43167:6dab4dad0093
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.
author | Per Abrahamsen <abraham@dina.kvl.dk> |
---|---|
date | Thu, 07 Feb 2002 17:32:18 +0000 |
parents | aa31e3865857 |
children | 3d510ec26d69 |
files | lisp/ChangeLog lisp/cus-edit.el lisp/menu-bar.el |
diffstat | 3 files changed, 61 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Thu Feb 07 15:57:55 2002 +0000 +++ b/lisp/ChangeLog Thu Feb 07 17:32:18 2002 +0000 @@ -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,Bm(Bk <Pavel@Janik.cz> * cus-start.el (x-use-underline-position-properties):
--- a/lisp/cus-edit.el Thu Feb 07 15:57:55 2002 +0000 +++ b/lisp/cus-edit.el Thu Feb 07 17:32:18 2002 +0000 @@ -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 @@ (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
--- a/lisp/menu-bar.el Thu Feb 07 15:57:55 2002 +0000 +++ b/lisp/menu-bar.el Thu Feb 07 17:32:18 2002 +0000 @@ -545,21 +545,30 @@ (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