Commit 414fd702 authored by Per Abrahamsen's avatar Per Abrahamsen

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.
parent 6833e8ba
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):
......
;;; 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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment