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)))))))

      ;; 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))))

  (byte-compile-normal-call form))