Subject: Re: bug#3984

From: Stefan Monnier <[email-masked]>
Date: Fri, 20 Sep 2013 10:35:01 -0400

> After a little more consideration, I think I know what the bug is. The goal
> of "advice--called-interactively-skip" is to skip all the advice-related
> stack frames of the called function, not advice-related stack frames for
> advice on call-interactively.

Oh, right.  How 'bout the patch below?

        Stefan

=== modified file 'lisp/subr.el'
--- lisp/subr.el	2013-09-18 03:50:18 +0000
+++ lisp/subr.el	2013-09-20 14:34:03 +0000
@@ -4246,6 +4246,8 @@
 if those frames don't seem special and otherwise, it should return
 the number of frames to skip (minus 1).")
 
+(defconst internal--call-interactively (symbol-function 'call-interactively))
+
 (defun called-interactively-p (&optional kind)
   "Return t if the containing function was called by `call-interactively'.
 If KIND is `interactive', then only return t if the call was made
@@ -4321,7 +4323,9 @@
         ;; Somehow, I sometimes got `command-execute' rather than
         ;; `call-interactively' on my stacktrace !?
         ;;(`(,_ . (t command-execute . ,_)) t)
-        (`(,_ . (t call-interactively . ,_)) t)))))
+        (`(,_ . (t ,(or `call-interactively
+                        (pred (eq internal--call-interactively))) . ,_))
+         t)))))
 
 (defun interactive-p ()
   "Return t if the containing function was run directly by user input.