Function: custom-dynamic-cons-value-create

custom-dynamic-cons-value-create is a byte-compiled function defined in cus-edit.el.gz.

Signature

(custom-dynamic-cons-value-create WIDGET)

Documentation

Select an appropriate 2nd type for the cons WIDGET and create WIDGET.

The appropriate types are:
- A symbol, if the value to represent is a minor-mode.
- A boolean, if the value to represent is either the unibyte value or the
  subdirs value.
- A widget type suitable for editing a variable, in case of specifying a
  variable's value.
- A sexp widget, if none of the above happens.

Source Code

;; Defined in /usr/src/emacs/lisp/cus-edit.el.gz
(defun custom-dynamic-cons-value-create (widget)
  "Select an appropriate 2nd type for the cons WIDGET and create WIDGET.

The appropriate types are:
- A symbol, if the value to represent is a minor-mode.
- A boolean, if the value to represent is either the unibyte value or the
  subdirs value.
- A widget type suitable for editing a variable, in case of specifying a
  variable's value.
- A sexp widget, if none of the above happens."
  (let* ((args (widget-get widget :args))
         (value (widget-get widget :value))
         (val (car value)))
    (cond
     ((eq val 'mode) (setf (nth 1 args)
                           `(symbol :keymap ,custom-dirlocals-field-map
                                    :tag "Minor mode")))
     ((eq val 'unibyte) (setf (nth 1 args) '(boolean)))
     ((eq val 'subdirs) (setf (nth 1 args) '(boolean)))
     ((custom-variable-p val)
      (let ((w (widget-convert (custom-variable-type val))))
        (when (custom--editable-field-p w)
          (widget-put w :keymap custom-dirlocals-field-map))
        (setf (nth 1 args) w)))
     (t (setf (nth 1 args) `(sexp :keymap ,custom-dirlocals-field-map))))
    (widget-put (nth 0 args) :keymap custom-dirlocals-field-map)
    (widget-group-value-create widget)))