Function: custom-add-choice
custom-add-choice is a byte-compiled function defined in custom.el.gz.
Signature
(custom-add-choice VARIABLE CHOICE)
Documentation
Add CHOICE to the custom type of VARIABLE.
If a choice with the same tag already exists, no action is taken.
Probably introduced at or before Emacs version 28.1.
Source Code
;; Defined in /usr/src/emacs/lisp/custom.el.gz
(defun custom-add-choice (variable choice)
"Add CHOICE to the custom type of VARIABLE.
If a choice with the same tag already exists, no action is taken."
(let ((choices (get variable 'custom-type)))
(unless (eq (car choices) 'choice)
(error "Not a choice type: %s" choices))
(unless (seq-find (lambda (elem)
(equal (caddr (member :tag elem))
(caddr (member :tag choice))))
(cdr choices))
;; Put the new choice at the end.
(put variable 'custom-type
(append choices (list choice))))))