Function: custom-theme-set-variables

custom-theme-set-variables is a byte-compiled function defined in custom.el.gz.

Signature

(custom-theme-set-variables THEME &rest ARGS)

Documentation

Initialize variables for theme THEME according to settings in ARGS.

Each of the arguments in ARGS should be a list of this form:

  (SYMBOL EXP [NOW [REQUEST [COMMENT]]])

SYMBOL is the variable name, and EXP is an expression which evaluates to the customized value. EXP will also be stored, without evaluating it, in SYMBOL's saved-value property, so that it can be restored via the Customize interface. It is also added to the alist in SYMBOL's theme-value property (by calling custom-push-theme).

NOW, if present and non-nil, means to install the variable's value directly now, even if its defcustom declaration has not been executed. This is for internal use only.

REQUEST is a list of features to require (which are loaded prior to evaluating EXP).

COMMENT is a comment string about SYMBOL.

View in manual

Probably introduced at or before Emacs version 31.1.

Source Code

;; Defined in /usr/src/emacs/lisp/custom.el.gz
(defun custom-theme-set-variables (theme &rest args)
  "Initialize variables for theme THEME according to settings in ARGS.
Each of the arguments in ARGS should be a list of this form:

  (SYMBOL EXP [NOW [REQUEST [COMMENT]]])

SYMBOL is the variable name, and EXP is an expression which
evaluates to the customized value.  EXP will also be stored,
without evaluating it, in SYMBOL's `saved-value' property, so
that it can be restored via the Customize interface.  It is also
added to the alist in SYMBOL's `theme-value' property (by
calling `custom-push-theme').

NOW, if present and non-nil, means to install the variable's
value directly now, even if its `defcustom' declaration has not
been executed.  This is for internal use only.

REQUEST is a list of features to `require' (which are loaded
prior to evaluating EXP).

COMMENT is a comment string about SYMBOL."
  (custom-check-theme theme)
  ;; Process all the needed autoloads before anything else, so that the
  ;; subsequent code has all the info it needs (e.g. which var corresponds
  ;; to a minor mode), regardless of the ordering of the variables.
  (dolist (entry args)
    (let* ((symbol (indirect-variable (nth 0 entry))))
      (unless (or (get symbol 'standard-value)
                  (memq (get symbol 'custom-autoload) '(nil noset)))
        ;; This symbol needs to be autoloaded, even just for a `set'.
        (custom-load-symbol symbol))))
  (setq args (custom--sort-vars args))
  (dolist (entry args)
    (unless (listp entry)
      (error "Incompatible Custom theme spec"))
    (let* ((symbol (indirect-variable (nth 0 entry)))
	   (value (nth 1 entry)))
      (custom-push-theme 'theme-value symbol theme 'set value)
      (when (custom--should-apply-setting theme)
	;; Now set the variable.
	(let* ((now (nth 2 entry))
	       (requests (nth 3 entry))
	       (comment (nth 4 entry))
	       set)
	  (when requests
	    (put symbol 'custom-requests requests)
            ;; Load any libraries that the setting has specified as
            ;; being required, but don't error out if the package has
            ;; been removed.
            (mapc (lambda (lib) (require lib nil t)) requests))
          (setq set (or (get symbol 'custom-set) #'custom-set-default))
	  (put symbol 'saved-value (list value))
	  (put symbol 'saved-variable-comment comment)
	  ;; Allow for errors in the case where the setter has
	  ;; changed between versions, say, but let the user know.
	  (condition-case data
	      (cond (now
		     ;; Rogue variable, set it now.
		     (put symbol 'force-value t)
		     (funcall set symbol (eval value)))
		    ((default-boundp symbol)
		     ;; Something already set this, overwrite it.
		     (funcall set symbol (eval value))))
	    (error
	     (message "Error setting %s: %s" symbol data)))
	  (and (or now (default-boundp symbol))
	       (put symbol 'variable-comment comment)))))))