Function: custom-variable-set
custom-variable-set is a byte-compiled function defined in
cus-edit.el.gz.
Signature
(custom-variable-set WIDGET)
Documentation
Set the current value for the variable being edited by WIDGET.
Source Code
;; Defined in /usr/src/emacs/lisp/cus-edit.el.gz
(defun custom-variable-set (widget)
"Set the current value for the variable being edited by WIDGET."
(let* ((form (widget-get widget :custom-form))
(state (widget-get widget :custom-state))
(child (car (widget-get widget :children)))
(symbol (widget-value widget))
(set (or (get symbol 'custom-set) 'set-default))
(comment-widget (widget-get widget :comment-widget))
(comment (widget-value comment-widget))
val)
(cond ((eq state 'hidden)
(user-error "Cannot set hidden variable"))
((setq val (widget-apply child :validate))
(goto-char (widget-get val :from))
(error "%s" (widget-get val :error)))
((memq form '(lisp mismatch))
(when (equal comment "")
(setq comment nil)
;; Make the comment invisible by hand if it's empty
(custom-comment-hide comment-widget))
(setq val (widget-value child))
(unless (equal (eval val) (custom-variable-current-value widget))
(custom-variable-backup-value widget))
(custom-push-theme 'theme-value symbol 'user
'set (custom-quote val))
(funcall set symbol (eval val))
(put symbol 'customized-value (list val))
(put symbol 'variable-comment comment)
(put symbol 'customized-variable-comment comment))
(t
(when (equal comment "")
(setq comment nil)
;; Make the comment invisible by hand if it's empty
(custom-comment-hide comment-widget))
(setq val (widget-value child))
(unless (equal val (custom-variable-current-value widget))
(custom-variable-backup-value widget))
(custom-push-theme 'theme-value symbol 'user
'set (custom-quote val))
(funcall set symbol val)
(put symbol 'customized-value (list (custom-quote val)))
(put symbol 'variable-comment comment)
(put symbol 'customized-variable-comment comment)))
(custom-variable-state-set widget)
(custom-redraw-magic widget)))