Function: advice--interactive-form-1

advice--interactive-form-1 is a byte-compiled function defined in nadvice.el.gz.

Signature

(advice--interactive-form-1 FUNCTION)

Documentation

Like interactive-form but preserves the static context if needed.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/nadvice.el.gz
(defun advice--interactive-form-1 (function)
  "Like `interactive-form' but preserves the static context if needed."
  (let ((if (interactive-form function)))
    (if (not (and if (interpreted-function-p function)))
        if
      (cl-assert (eq 'interactive (car if)))
      (let ((form (cadr if)))
        (if (macroexp-const-p form)     ;Common case: a string.
            if
          ;; The interactive is expected to be run in the static context
          ;; that the function captured.
          (let ((ctx (aref function 2)))
            `(interactive
              ,(let* ((f (if (eq 'function (car-safe form)) (cadr form) form)))
                 ;; If the form jut returns a function, preserve the fact that
                 ;; it just returns a function, which is an info we use in
                 ;; `advice--make-interactive-form'.
                 (if (eq 'lambda (car-safe f))
                     (eval form ctx)
                   `(eval ',form ',ctx))))))))))