unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Ryan <rct@thompsonclan.org>
Cc: 3984@debbugs.gnu.org
Subject: bug#3984: Fix for #3984
Date: Fri, 13 Sep 2013 17:02:38 -0400	[thread overview]
Message-ID: <jwv61u4o3x2.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <5233670E.4030703@thompsonclan.org> (Ryan's message of "Fri, 13 Sep 2013 12:27:10 -0700")

>> Looking at the code in trunk, I see that there is a special hook for
>> functions to decide which stack frames to skip over when looking for
>> call-interactively. I still think they should relax the test for
>> equality to "equal indirect-functions" instead of exactly the symbol
>> call-interactively.

The code does check "equal modulo indirect-functions" in some cases, but
indeed not all.  I don't think that replacing the equality check against
`call-interactively' with a check modulo indirect-functions would solve
your problem, tho (that only helps when calling though an alias of
call-interactively, but here the relevant stack frame will be a call to
the #<subr call-interactively> which is not
equal-modulo-indirect-functions to call-interactively since
call-interactively has been redefined to a different functions by the
advice).

You can probably use called-interactively-p-functions to detect the
#<subr call-interactively> and skip the frames between it and the
corresponding call to `call-interactively'.

But if you find a cute patch against the current code which makes it
work for you in a cleanish way, do send it here, to see if it can
be included.

> Actually, I just noticed that in trunk, nadvice.el adds a function to
> "called-interactively-p-functions" to skip advice-related stack frames, but
> this works only for advice on the interactive function, not advice defined
> on call-interactively itself.

Indeed.  It doesn't even work for all advices (more specifically it
doesn't work for :around advices, which means it doesn't work for
advices defined via `defadvice' since these all turn into one
big :around "new advice").

> Furthermore, from my limited testing it appears that the structure of
> the call stack for advised functions has changes significantly in
> trunk, making my code obsolete.

Indeed, the implementation of advices has been completely changed.

> The whole thing looks like a work in progress right now.

There's no planned change to it, so I consider it "ready modulo
bug-reports".  AFAIK it works "at least as well as before" (it works
better than before in the sense that Edebugging a function with calls
to called-interactively-p should now work correctly).

`called-interactively-p' is a big ugly hack and only works sometimes.
It can break in all kinds of cases (e.g. it currently won't work in
byte-compiled lexical-binding code within a `catch', or
a `condition-case', or the unwind part of an `unwind-protect').  Also,
the functions called (non-interactively, obviously) by your
`call-interactively' advice will probably think that they're called
interactively (hopefully your advice doesn't call many functions, and
hopefully none of them cares whether it's called interactively or not).


        Stefan





  reply	other threads:[~2013-09-13 21:02 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-30 22:37 bug#3984: 23.0.96; defadvice of call-interactively defeats interactive-p Drew Adams
2009-07-31  1:58 ` Stefan Monnier
2009-07-31 14:19   ` Drew Adams
2009-07-31 19:31     ` Stefan Monnier
2009-07-31 20:04       ` Drew Adams
2011-10-10  6:00 ` Kai Tetzlaff
2011-10-11 14:26   ` Drew Adams
2011-10-11 15:46     ` Stefan Monnier
2011-10-11 16:05       ` Drew Adams
2013-09-10 20:29 ` Christopher Wellons
2013-09-11  0:29   ` Stefan Monnier
2013-09-13  8:56 ` bug#3984: Fix for #3984 Ryan
2013-09-13 13:18   ` Stefan Monnier
2013-09-13 18:30     ` Ryan
2013-09-13 19:27       ` Ryan
2013-09-13 21:02         ` Stefan Monnier [this message]
2013-09-17  3:18           ` Ryan
2013-09-17 13:10             ` Stefan Monnier
2013-09-17 17:22               ` bug#3984: Ryan
2013-09-18  1:46                 ` bug#3984: Stefan Monnier
2013-09-18 23:30                   ` bug#3984: Ryan
2013-09-19  0:47                     ` bug#3984: Ryan
2013-09-19  3:38                       ` bug#3984: Stefan Monnier
2013-09-19  8:06                         ` bug#3984: Ryan
2013-09-19 19:23                           ` bug#3984: Ryan
2013-09-19 20:59                             ` bug#3984: Stefan Monnier
2013-09-19 21:59                             ` bug#3984: Ryan
2013-09-20  4:23                               ` bug#3984: Ryan
2013-09-20  4:58                                 ` bug#3984: Fix case where call-interactively is advised Ryan
2013-09-20  5:03                                   ` bug#3984: Ryan
2013-09-20 14:35                                 ` bug#3984: Stefan Monnier
2013-09-20 16:54                                   ` bug#3984: Ryan
2013-09-20 16:56                                     ` bug#3984: Ryan
2013-09-20 14:54                               ` bug#3984: Stefan Monnier
2013-09-20 16:50                                 ` bug#3984: Ryan
2013-09-20 19:59                                   ` bug#3984: Stefan Monnier
2013-09-13 10:24 ` bug#3984: bug#123: Potential fix Ryan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv61u4o3x2.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=3984@debbugs.gnu.org \
    --cc=rct@thompsonclan.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).