Function: advice--called-interactively-skip
advice--called-interactively-skip is a byte-compiled function defined
in nadvice.el.gz.
Signature
(advice--called-interactively-skip ORIGI FRAME1 FRAME2)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/nadvice.el.gz
(defun advice--called-interactively-skip (origi frame1 frame2)
(let* ((i origi)
(get-next-frame
(lambda ()
(setq frame1 frame2)
(setq frame2 (backtrace-frame i #'called-interactively-p))
;; (message "Advice Frame %d = %S" i frame2)
(setq i (1+ i)))))
;; FIXME: Adjust this for the new :filter advices, since they use `funcall'
;; rather than `apply'.
;; FIXME: Somehow this doesn't work on (advice-add :before
;; 'call-interactively #'ignore), see bug#3984.
(when (and (eq (nth 1 frame2) 'apply)
(progn
(funcall get-next-frame)
(advice--p (indirect-function (nth 1 frame2)))))
(funcall get-next-frame)
;; If we now have the symbol, this was the head advice and
;; we're done.
(while (advice--p (nth 1 frame1))
;; This was an inner advice called from some earlier advice.
;; The stack frames look different depending on the particular
;; kind of the earlier advice.
(let ((inneradvice (nth 1 frame1)))
(if (and (eq (nth 1 frame2) 'apply)
(progn
(funcall get-next-frame)
(advice--p (indirect-function
(nth 1 frame2)))))
;; The earlier advice was something like a before/after
;; advice where the "next" code is called directly by the
;; advice--p object.
(funcall get-next-frame)
;; It's apparently an around advice, where the "next" is
;; called by the body of the advice in any way it sees fit,
;; so we need to skip the frames of that body.
(while
(progn
(funcall get-next-frame)
(and frame2
(not (and (eq (nth 1 frame2) 'apply)
(eq (nth 3 frame2) inneradvice))))))
(funcall get-next-frame)
(funcall get-next-frame))))
(- i origi 1))))