comparison lisp/cus-edit.el @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 576fb035e263
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
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))
3352 (unless (looking-at "\n") 3342 (unless (looking-at "\n")
3353 (princ "\n"))))) 3343 (princ "\n")))))
3354 3344
3355 (defun custom-save-resets (property setter special) 3345 (defun custom-save-resets (property setter special)
3356 (let (started-writing ignored-special) 3346 (let (started-writing ignored-special)
3347 (setq ignored-special ignored-special) ;; suppress byte-compiler warning
3357 ;; (custom-save-delete setter) Done by caller 3348 ;; (custom-save-delete setter) Done by caller
3358 (let ((standard-output (current-buffer)) 3349 (let ((standard-output (current-buffer))
3359 (mapper `(lambda (object) 3350 (mapper `(lambda (object)
3360 (let ((spec (car-safe (get object (quote ,property))))) 3351 (let ((spec (car-safe (get object (quote ,property)))))
3361 (when (and (not (memq object ignored-special)) 3352 (when (and (not (memq object ignored-special))
3375 (princ ")"))))))) 3366 (princ ")")))))))
3376 (mapc mapper special) 3367 (mapc mapper special)
3377 (setq ignored-special special) 3368 (setq ignored-special special)
3378 (mapatoms mapper) 3369 (mapatoms mapper)
3379 (when started-writing 3370 (when started-writing
3380 (princ ")\n"))))) 3371 (princ ")\n"))))
3372 )
3381 3373
3382 3374
3383 (defun custom-save-loaded-themes () 3375 (defun custom-save-loaded-themes ()
3384 (let ((themes (reverse (get 'user 'theme-loads-themes))) 3376 (let ((themes (reverse (get 'user 'theme-loads-themes)))
3385 (standard-output (current-buffer))) 3377 (standard-output (current-buffer)))
3592 (make-local-hook 'widget-edit-functions) 3584 (make-local-hook 'widget-edit-functions)
3593 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t) 3585 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t)
3594 (run-hooks 'custom-mode-hook)) 3586 (run-hooks 'custom-mode-hook))
3595 3587
3596 3588
3589 ;;;###autoload
3590 (defun custom-migrate-custom-file (new-custom-file-name)
3591 "Migrate custom file from home directory."
3592 (mapc 'custom-save-delete
3593 '(custom-load-themes custom-reset-variables
3594 custom-set-variables
3595 custom-set-faces
3596 custom-reset-faces))
3597 (with-current-buffer (find-file-noselect custom-file)
3598 (save-buffer))
3599 (setq custom-file new-custom-file-name)
3600 (custom-save-all))
3601
3597 ;;; The End. 3602 ;;; The End.
3598 3603
3599 (provide 'cus-edit) 3604 (provide 'cus-edit)
3600 3605
3601 ;; cus-edit.el ends here 3606 ;; cus-edit.el ends here