Function: byte-run--parse-body

byte-run--parse-body is a byte-compiled function defined in byte-run.el.gz.

Signature

(byte-run--parse-body BODY ALLOW-INTERACTIVE)

Documentation

Decompose BODY into (DOCSTRING DECLARE INTERACTIVE BODY-REST WARNINGS).

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/byte-run.el.gz
(defalias 'byte-run--parse-body
  #'(lambda (body allow-interactive)
      "Decompose BODY into (DOCSTRING DECLARE INTERACTIVE BODY-REST WARNINGS)."
      (let* ((top body)
             (docstring nil)
             (declare-form nil)
             (interactive-form nil)
             (warnings nil)
             (warn #'(lambda (msg form)
                       (push (macroexp-warn-and-return msg nil nil t form)
                             warnings))))
        (while
            (and body
                 (let* ((form (car body))
                        (head (car-safe form)))
                   (cond
                    ((or (and (stringp form) (cdr body))
                         (eq head :documentation))
                     (cond
                      (docstring (funcall warn "More than one doc string" top))
                      (declare-form
                       (funcall warn "Doc string after `declare'" declare-form))
                      (interactive-form
                       (funcall warn "Doc string after `interactive'"
                                interactive-form))
                      (t (setq docstring form)))
                     t)
                    ((eq head 'declare)
                     (cond
                      (declare-form
                       (funcall warn "More than one `declare' form" form))
                      (interactive-form
                       (funcall warn "`declare' after `interactive'" form))
                      (t (setq declare-form form)))
                     t)
                    ((eq head 'interactive)
                     (cond
                      ((not allow-interactive)
                       (funcall warn "No `interactive' form allowed here" form))
                      (interactive-form
                       (funcall warn "More than one `interactive' form" form))
                      (t (setq interactive-form form)))
                     t))))
          (setq body (cdr body)))
        (list docstring declare-form interactive-form body warnings))))