748 |
|
|
749 |
;;;###autoload |
;;;###autoload |
750 |
(defun customize-set-value (var val &optional comment) |
(defun customize-set-value (var val &optional comment) |
751 |
"Set VARIABLE to VALUE. VALUE is a Lisp object. |
"Set VARIABLE to VALUE, and return VALUE. VALUE is a Lisp object. |
752 |
|
|
753 |
If VARIABLE has a `variable-interactive' property, that is used as if |
If VARIABLE has a `variable-interactive' property, that is used as if |
754 |
it were the arg to `interactive' (which see) to interactively read the value. |
it were the arg to `interactive' (which see) to interactively read the value. |
761 |
"Set %s to value: " |
"Set %s to value: " |
762 |
current-prefix-arg)) |
current-prefix-arg)) |
763 |
|
|
|
(set var val) |
|
764 |
(cond ((string= comment "") |
(cond ((string= comment "") |
765 |
(put var 'variable-comment nil)) |
(put var 'variable-comment nil)) |
766 |
(comment |
(comment |
767 |
(put var 'variable-comment comment)))) |
(put var 'variable-comment comment))) |
768 |
|
(set var val)) |
769 |
|
|
770 |
;;;###autoload |
;;;###autoload |
771 |
(defun customize-set-variable (variable value &optional comment) |
(defun customize-set-variable (variable value &optional comment) |
772 |
"Set the default for VARIABLE to VALUE. VALUE is a Lisp object. |
"Set the default for VARIABLE to VALUE, and return VALUE. |
773 |
|
VALUE is a Lisp object. |
774 |
|
|
775 |
If VARIABLE has a `custom-set' property, that is used for setting |
If VARIABLE has a `custom-set' property, that is used for setting |
776 |
VARIABLE, otherwise `set-default' is used. |
VARIABLE, otherwise `set-default' is used. |
788 |
(interactive (custom-prompt-variable "Set variable: " |
(interactive (custom-prompt-variable "Set variable: " |
789 |
"Set customized value for %s to: " |
"Set customized value for %s to: " |
790 |
current-prefix-arg)) |
current-prefix-arg)) |
791 |
|
(custom-load-symbol variable) |
792 |
(funcall (or (get variable 'custom-set) 'set-default) variable value) |
(funcall (or (get variable 'custom-set) 'set-default) variable value) |
793 |
(put variable 'customized-value (list (custom-quote value))) |
(put variable 'customized-value (list (custom-quote value))) |
794 |
(cond ((string= comment "") |
(cond ((string= comment "") |
796 |
(put variable 'customized-variable-comment nil)) |
(put variable 'customized-variable-comment nil)) |
797 |
(comment |
(comment |
798 |
(put variable 'variable-comment comment) |
(put variable 'variable-comment comment) |
799 |
(put variable 'customized-variable-comment comment)))) |
(put variable 'customized-variable-comment comment))) |
800 |
|
value) |
801 |
|
|
802 |
;;;###autoload |
;;;###autoload |
803 |
(defun customize-save-variable (var value &optional comment) |
(defun customize-save-variable (var value &optional comment) |
804 |
"Set the default for VARIABLE to VALUE, and save it for future sessions. |
"Set the default for VARIABLE to VALUE, and save it for future sessions. |
805 |
|
Return VALUE. |
806 |
|
|
807 |
If VARIABLE has a `custom-set' property, that is used for setting |
If VARIABLE has a `custom-set' property, that is used for setting |
808 |
VARIABLE, otherwise `set-default' is used. |
VARIABLE, otherwise `set-default' is used. |
809 |
|
|
828 |
(comment |
(comment |
829 |
(put var 'variable-comment comment) |
(put var 'variable-comment comment) |
830 |
(put var 'saved-variable-comment comment))) |
(put var 'saved-variable-comment comment))) |
831 |
(custom-save-all)) |
(custom-save-all) |
832 |
|
value) |
833 |
|
|
834 |
;;;###autoload |
;;;###autoload |
835 |
(defun customize () |
(defun customize () |
1821 |
(defvar custom-load-recursion nil |
(defvar custom-load-recursion nil |
1822 |
"Hack to avoid recursive dependencies.") |
"Hack to avoid recursive dependencies.") |
1823 |
|
|
1824 |
|
;;;###autoload |
1825 |
(defun custom-load-symbol (symbol) |
(defun custom-load-symbol (symbol) |
1826 |
"Load all dependencies for SYMBOL." |
"Load all dependencies for SYMBOL." |
1827 |
(unless custom-load-recursion |
(unless custom-load-recursion |
3757 |
"Mark SYMBOL for later saving. |
"Mark SYMBOL for later saving. |
3758 |
|
|
3759 |
If the default value of SYMBOL is different from the standard value, |
If the default value of SYMBOL is different from the standard value, |
3760 |
set the 'saved-value' property to a list whose car evaluates to the |
set the `saved-value' property to a list whose car evaluates to the |
3761 |
default value. Otherwise, set it til nil. |
default value. Otherwise, set it til nil. |
3762 |
|
|
3763 |
To actually save the value, call 'custom-save-all'. |
To actually save the value, call `custom-save-all'. |
3764 |
|
|
3765 |
Return non-nil iff the 'saved-value' property actually changed." |
Return non-nil iff the `saved-value' property actually changed." |
3766 |
(let* ((get (or (get symbol 'custom-get) 'default-value)) |
(let* ((get (or (get symbol 'custom-get) 'default-value)) |
3767 |
(value (funcall get symbol)) |
(value (funcall get symbol)) |
3768 |
(saved (get symbol 'saved-value)) |
(saved (get symbol 'saved-value)) |
3769 |
(standard (get symbol 'standard-value)) |
(standard (get symbol 'standard-value)) |
3770 |
(comment (get symbol 'customized-variable-comment))) |
(comment (get symbol 'customized-variable-comment))) |
3771 |
;; Save default value iff different from standard value. |
;; Save default value iff different from standard value. |
3772 |
(if (and standard |
(if (or (null standard) |
3773 |
(not (condition-case nil |
(not (equal value (condition-case nil |
3774 |
(equal value (eval (car standard))) |
(eval (car standard)) |
3775 |
(error nil)))) |
(error nil))))) |
3776 |
(put symbol 'saved-value (list (custom-quote value))) |
(put symbol 'saved-value (list (custom-quote value))) |
3777 |
(put symbol 'saved-value nil)) |
(put symbol 'saved-value nil)) |
3778 |
;; Clear customized information (set, but not saved). |
;; Clear customized information (set, but not saved). |
3782 |
(put symbol 'saved-variable-comment comment)) |
(put symbol 'saved-variable-comment comment)) |
3783 |
(not (equal saved (get symbol 'saved-value))))) |
(not (equal saved (get symbol 'saved-value))))) |
3784 |
|
|
3785 |
|
;;;###autoload |
3786 |
|
(defun customize-mark-as-set (symbol) |
3787 |
|
"Mark current value of SYMBOL as being set from customize. |
3788 |
|
|
3789 |
|
If the default value of SYMBOL is different from the saved value if any, |
3790 |
|
or else if it is different from the standard value, set the |
3791 |
|
`customized-value' property to a list whose car evaluates to the |
3792 |
|
default value. Otherwise, set it til nil. |
3793 |
|
|
3794 |
|
Return non-nil iff the `customized-value' property actually changed." |
3795 |
|
(let* ((get (or (get symbol 'custom-get) 'default-value)) |
3796 |
|
(value (funcall get symbol)) |
3797 |
|
(customized (get symbol 'customized-value)) |
3798 |
|
(old (or (get symbol 'saved-value) (get symbol 'standard-value)))) |
3799 |
|
;; Mark default value as set iff different from old value. |
3800 |
|
(if (or (null old) |
3801 |
|
(not (equal value (condition-case nil |
3802 |
|
(eval (car old)) |
3803 |
|
(error nil))))) |
3804 |
|
(put symbol 'customized-value (list (custom-quote value))) |
3805 |
|
(put symbol 'customized-value nil)) |
3806 |
|
;; Changed? |
3807 |
|
(not (equal customized (get symbol 'customized-value))))) |
3808 |
|
|
3809 |
;;; The Customize Menu. |
;;; The Customize Menu. |
3810 |
|
|
3811 |
;;; Menu support |
;;; Menu support |