Function: bytecomp--custom-declare
bytecomp--custom-declare is a byte-compiled function defined in
bytecomp.el.gz.
Signature
(bytecomp--custom-declare FORM)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun bytecomp--custom-declare (form)
(when (>= (length form) 4)
(let* ((name-arg (nth 1 form))
(name (and (eq (car-safe name-arg) 'quote)
(symbolp (nth 1 name-arg))
(nth 1 name-arg)))
(keyword-args (nthcdr 4 form))
(fun (car form))
(bytecomp--cus-function fun)
(bytecomp--cus-name name))
;; Check :type
(when (memq fun '(custom-declare-variable define-widget))
(let ((type-tag (memq :type keyword-args)))
(if (null type-tag)
;; :type only mandatory for `defcustom'
(when (eq fun 'custom-declare-variable)
(bytecomp--cus-warn form "missing :type keyword parameter"))
(let ((dup-type (memq :type (cdr type-tag))))
(when dup-type
(bytecomp--cus-warn
dup-type "duplicated :type keyword argument")))
(let ((type-arg (cadr type-tag)))
(when (or (null type-arg)
(eq (car-safe type-arg) 'quote))
(bytecomp--check-cus-type (cadr type-arg)))))))
(when (eq fun 'custom-declare-face)
(let ((face-arg (nth 2 form)))
(when (and (eq (car-safe face-arg) 'quote)
(consp (cdr face-arg))
(null (cddr face-arg)))
(bytecomp--check-cus-face-spec (nth 1 face-arg)))))
;; Check :group
(when (cond
((memq fun '(custom-declare-variable custom-declare-face))
(not byte-compile-current-group))
((eq fun 'custom-declare-group)
(not (eq name 'emacs))))
(unless (plist-get keyword-args :group)
(bytecomp--cus-warn form "fails to specify containing group")))
;; Update current group
(when (and name
byte-compile-current-file ; only when compiling a whole file
(eq fun 'custom-declare-group))
(setq byte-compile-current-group name))
;; Check :local
(when-let* ((val (and (eq fun 'custom-declare-variable)
(plist-get keyword-args :local)))
(_ (not (member val '(t 'permanent 'permanent-only)))))
(bytecomp--cus-warn form ":local keyword does not accept %S" val))))
(byte-compile-normal-call form))