Make called-interactively-p work for edebug or advised code.
* lisp/subr.el (called-interactively-p-functions): New var. (internal--called-interactively-p--get-frame): New macro. (called-interactively-p, interactive-p): Rewrite in Lisp. * lisp/emacs-lisp/nadvice.el (advice--called-interactively-skip): New fun. (called-interactively-p-functions): Use it. * lisp/emacs-lisp/edebug.el (edebug--called-interactively-skip): New fun. (called-interactively-p-functions): Use it. * lisp/allout.el (allout-called-interactively-p): Don't assume called-interactively-p is a subr. * src/eval.c (Finteractive_p, Fcalled_interactively_p, interactive_p): Remove. (syms_of_eval): Remove corresponding defsubr. * src/bytecode.c (exec_byte_code): `interactive-p' is now a Lisp function. * test/automated/advice-tests.el (advice-tests--data): Remove. (advice-tests): Move the tests directly here instead. Add called-interactively-p tests.
This commit is contained in:
parent
b0636be7f9
commit
23ba2705e2
10 changed files with 336 additions and 186 deletions
|
@ -4268,6 +4268,21 @@ With prefix argument, make it a temporary breakpoint."
|
|||
|
||||
;;; Finalize Loading
|
||||
|
||||
;; When edebugging a function, some of the sub-expressions are
|
||||
;; wrapped in (edebug-enter (lambda () ..)), so we need to teach
|
||||
;; called-interactively-p that calls within the inner lambda should refer to
|
||||
;; the outside function.
|
||||
(add-hook 'called-interactively-p-functions
|
||||
#'edebug--called-interactively-skip)
|
||||
(defun edebug--called-interactively-skip (i frame1 frame2)
|
||||
(when (and (eq (car-safe (nth 1 frame1)) 'lambda)
|
||||
(eq (nth 1 (nth 1 frame1)) '())
|
||||
(eq (nth 1 frame2) 'edebug-enter))
|
||||
;; `edebug-enter' calls itself on its first invocation.
|
||||
(if (eq (nth 1 (internal--called-interactively-p--get-frame i))
|
||||
'edebug-enter)
|
||||
2 1)))
|
||||
|
||||
;; Finally, hook edebug into the rest of Emacs.
|
||||
;; There are probably some other things that could go here.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue