comparison lisp/cus-edit.el @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 74fd4e045ea6
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
53 (require 'wid-edit) 53 (require 'wid-edit)
54 (require 'easymenu) 54 (require 'easymenu)
55 55
56 (require 'cus-load) 56 (require 'cus-load)
57 (require 'cus-start) 57 (require 'cus-start)
58 (require 'cus-file)
58 59
59 ;; Huh? This looks dirty! 60 ;; Huh? This looks dirty!
60 (put 'custom-define-hook 'custom-type 'hook) 61 (put 'custom-define-hook 'custom-type 'hook)
61 (put 'custom-define-hook 'standard-value '(nil)) 62 (put 'custom-define-hook 'standard-value '(nil))
62 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable) 63 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable)
2223 2224
2224 (defun custom-variable-reset-saved (widget) 2225 (defun custom-variable-reset-saved (widget)
2225 "Restore the saved value for the variable being edited by WIDGET." 2226 "Restore the saved value for the variable being edited by WIDGET."
2226 (let* ((symbol (widget-value widget)) 2227 (let* ((symbol (widget-value widget))
2227 (set (or (get symbol 'custom-set) 'set-default)) 2228 (set (or (get symbol 'custom-set) 'set-default))
2228 (comment-widget (widget-get widget :comment-widget))
2229 (value (get symbol 'saved-value)) 2229 (value (get symbol 'saved-value))
2230 (comment (get symbol 'saved-variable-comment))) 2230 (comment (get symbol 'saved-variable-comment)))
2231 (cond ((or value comment) 2231 (cond ((or value comment)
2232 (put symbol 'variable-comment comment) 2232 (put symbol 'variable-comment comment)
2233 (condition-case nil 2233 (condition-case nil
2242 (custom-redraw widget))) 2242 (custom-redraw widget)))
2243 2243
2244 (defun custom-variable-reset-standard (widget) 2244 (defun custom-variable-reset-standard (widget)
2245 "Restore the standard setting for the variable being edited by WIDGET." 2245 "Restore the standard setting for the variable being edited by WIDGET."
2246 (let* ((symbol (widget-value widget)) 2246 (let* ((symbol (widget-value widget))
2247 (set (or (get symbol 'custom-set) 'set-default)) 2247 (set (or (get symbol 'custom-set) 'set-default)))
2248 (comment-widget (widget-get widget :comment-widget)))
2249 (if (get symbol 'standard-value) 2248 (if (get symbol 'standard-value)
2250 (funcall set symbol (eval (car (get symbol 'standard-value)))) 2249 (funcall set symbol (eval (car (get symbol 'standard-value))))
2251 (signal 'error (list "No standard setting known for variable" symbol))) 2250 (signal 'error (list "No standard setting known for variable" symbol)))
2252 (put symbol 'variable-comment nil) 2251 (put symbol 'variable-comment nil)
2253 (put symbol 'customized-value nil) 2252 (put symbol 'customized-value nil)
3237 magics nil) 3236 magics nil)
3238 (setq magics (cdr magics))))) 3237 (setq magics (cdr magics)))))
3239 (widget-put widget :custom-state found))) 3238 (widget-put widget :custom-state found)))
3240 (custom-magic-reset widget)) 3239 (custom-magic-reset widget))
3241 3240
3242 ;;; The `custom-save-all' Function.
3243 ;;;###autoload
3244 (defcustom custom-file "~/.emacs"
3245 "File used for storing customization information.
3246 If you change this from the default \"~/.emacs\" you need to
3247 explicitly load that file for the settings to take effect."
3248 :type 'file
3249 :group 'customize)
3250
3251 (defun custom-save-delete (symbol) 3241 (defun custom-save-delete (symbol)
3252 "Delete the call to SYMBOL form in `custom-file'. 3242 "Delete the call to SYMBOL form in `custom-file'.
3253 Leave point at the location of the call, or after the last expression." 3243 Leave point at the location of the call, or after the last expression."
3254 (let ((find-file-hooks nil) 3244 (let ((find-file-hooks nil)
3255 (auto-mode-alist nil)) 3245 (auto-mode-alist nil))
3592 (make-local-hook 'widget-edit-functions) 3582 (make-local-hook 'widget-edit-functions)
3593 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t) 3583 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t)
3594 (run-hooks 'custom-mode-hook)) 3584 (run-hooks 'custom-mode-hook))
3595 3585
3596 3586
3587 ;;;###autoload
3588 (defun custom-migrate-custom-file (new-custom-file-name)
3589 "Migrate custom file from home directory."
3590 (mapc 'custom-save-delete
3591 '(custom-load-themes custom-reset-variables
3592 custom-set-variables
3593 custom-set-faces
3594 custom-reset-faces))
3595 (with-current-buffer (find-file-noselect custom-file)
3596 (save-buffer))
3597 (setq custom-file new-custom-file-name)
3598 (custom-save-all))
3599
3597 ;;; The End. 3600 ;;; The End.
3598 3601
3599 (provide 'cus-edit) 3602 (provide 'cus-edit)
3600 3603
3601 ;; cus-edit.el ends here 3604 ;; cus-edit.el ends here