[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Re: Save Options vs. default-input-method
From: |
Per Abrahamsen |
Subject: |
[PATCH] Re: Save Options vs. default-input-method |
Date: |
Tue, 05 Feb 2002 17:38:02 +0100 |
User-agent: |
Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.1 (i686-pc-linux-gnu) |
Richard Stallman <address@hidden> writes:
> I can't find any customize-save-all in the sources, and I don't see
> any function which is like customize-save-variable but without setting
> the value.
I meant custom-save-all. And it wasn't really correct, as
customize-save-variable performs three tasks, it set the variable, it
marks the variable for saving, and it saves all variables and faces
marked for saving.
> I don't think customize-save-variable should be changed, the Options
> menu is simply abusing it. It is not intended for such use.
>
> What use is it intended for?
Setting a single variable permanently. The original use was a
function that would prompt the user for his mail address if not
specified, and save it permanently.
It is inefficient for saving multiple variables, since each call to
customize-save-variable also calls custom-save-all, which delete all
face and variable customization from custom-file, and then recreates
it. That function should only be called once, after all the relevant
options had been marked for saving.
> I think this change in
> customize-save-variable would be logical, and make it both more useful
> and more natural.
A new function 'mark-variable-for-saving' function would be better, as
the old function already is used with its current semantics.
> But I think you are right that it is not the proper method to use for
> this purpose, for the following reason:
>
> The other would be to fix menu-bar-options-save to do what I suspect
> it is intended to do, i.e. just save the current values of the options
> in the options menu.
That issue is really orthogonal, customize-save-variable is only used
for saving the specified items.
> I think it is clear that it should only save the menu bar options,
> so that is the best solution.
OK. I'd still prefer to set them with customize-set-variable, because
then if you later customize it, it will have the state "set, but not
saved", rather than "changed outside customize". And it will be
listed by the 'customize-customized' command.
In any case, here is the patch. OK to commit?
2002-02-05 Per Abrahamsen <address@hidden>
* cus-edit.el (mark-variable-for-saving): New function.
* menu-bar.el (menu-bar-options-save): Rewrote.
Index: lisp/cus-edit.el
===================================================================
RCS file: /cvsroot/emacs//emacs/lisp/cus-edit.el,v
retrieving revision 1.142
diff -c -r1.142 cus-edit.el
*** lisp/cus-edit.el 2 Feb 2002 15:52:36 -0000 1.142
--- lisp/cus-edit.el 5 Feb 2002 16:25:30 -0000
***************
*** 1,6 ****
;;; cus-edit.el --- tools for customizing Emacs and Lisp packages
;;
! ;; Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
;;
;; Author: Per Abrahamsen <address@hidden>
;; Keywords: help, faces
--- 1,6 ----
;;; cus-edit.el --- tools for customizing Emacs and Lisp packages
;;
! ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation,
Inc.
;;
;; Author: Per Abrahamsen <address@hidden>
;; Keywords: help, faces
***************
*** 3744,3749 ****
--- 3744,3779 ----
(set-buffer (find-file-noselect (custom-file))))
(let ((file-precious-flag t))
(save-buffer)))))
+
+ ;;;###autoload
+ (defun mark-variable-for-saving (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.
Index: lisp/menu-bar.el
===================================================================
RCS file: /cvsroot/emacs//emacs/lisp/menu-bar.el,v
retrieving revision 1.194
diff -c -r1.194 menu-bar.el
*** lisp/menu-bar.el 3 Feb 2002 11:28:28 -0000 1.194
--- lisp/menu-bar.el 5 Feb 2002 16:25:34 -0000
***************
*** 545,565 ****
(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))))
(define-key menu-bar-options-menu [save]
'(menu-item "Save Options" menu-bar-options-save
--- 545,574 ----
(defun menu-bar-options-save ()
"Save current values of Options menu items using Custom."
(interactive)
! (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 (mark-variable-for-saving 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.
! (mark-variable-for-saving 'text-mode-hook)
! (setq need-save t))
! ;; Avoid loading extra libraries.
! (and (featurep 'saveplace)
! (mark-variable-for-saving 'save-place)
! (setq need-save t))
! (and(featurep 'uniquify)
! (mark-variable-for-saving '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
- Re: Save Options vs. default-input-method, Pavel Janík, 2002/02/02
- Re: Save Options vs. default-input-method, Richard Stallman, 2002/02/04
- Re: Save Options vs. default-input-method, Pavel Janík, 2002/02/04
- Re: Save Options vs. default-input-method, Per Abrahamsen, 2002/02/04
- Re: Save Options vs. default-input-method, Richard Stallman, 2002/02/05
- [PATCH] Re: Save Options vs. default-input-method,
Per Abrahamsen <=
- [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, Per Abrahamsen, 2002/02/05
- Re: [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, Richard Stallman, 2002/02/07
- Re: [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, Per Abrahamsen, 2002/02/07
- Re: [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, Richard Stallman, 2002/02/08
- Re: [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, Per Abrahamsen, 2002/02/09
- Re: [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, Richard Stallman, 2002/02/10
- Re: [PATCH] text-mode-hook-identify should be part of the standard value for text-mode-hook, ShengHuo ZHU, 2002/02/13
- Re: [PATCH] Re: Save Options vs. default-input-method, Per Abrahamsen, 2002/02/05
- Re: [PATCH] Re: Save Options vs. default-input-method, Richard Stallman, 2002/02/07
- Re: [PATCH] Re: Save Options vs. default-input-method, Per Abrahamsen, 2002/02/07