From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Brittleness of called-interactively-p Date: Sun, 12 Jul 2015 19:26:36 -0400 Message-ID: References: <871tgeufzt.fsf@gmail.com> <87r3odtngi.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436743624 11243 80.91.229.3 (12 Jul 2015 23:27:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Jul 2015 23:27:04 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitri Paduchikh Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 13 01:26:55 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZEQe6-0005zq-6j for ged-emacs-devel@m.gmane.org; Mon, 13 Jul 2015 01:26:54 +0200 Original-Received: from localhost ([::1]:52271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEQe5-0007FD-6I for ged-emacs-devel@m.gmane.org; Sun, 12 Jul 2015 19:26:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEQe1-0007F7-3h for emacs-devel@gnu.org; Sun, 12 Jul 2015 19:26:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEQdx-00013r-C2 for emacs-devel@gnu.org; Sun, 12 Jul 2015 19:26:49 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:36057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEQdx-00012f-6g for emacs-devel@gnu.org; Sun, 12 Jul 2015 19:26:45 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t6CNQfK0032554; Sun, 12 Jul 2015 19:26:42 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 7CD3DAE0DF; Sun, 12 Jul 2015 19:26:36 -0400 (EDT) In-Reply-To: <87r3odtngi.fsf@gmail.com> (Dmitri Paduchikh's message of "Sun, 12 Jul 2015 20:17:17 +0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5365=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5365> : inlines <3367> : streams <1470696> : uri <1983556> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187841 Archived-At: >>> I would like to make a suggestion. All these problems can be resolved by >>> introducing a special (dynamically bound) variable. Each call -- not only >>> interactive -- to an interactive function would rebind it to the value >>> providing all the necessary information about interactiveness of this call. SM> That's pretty much what we do. > No. Currently, called-interactively-p "returns t if the containing function > was called by `call-interactively'." I argue that functions not having > interactive form should not have effect on return value. You might be able to exploit this "ignore non-interactive functions" to make the current code more robust, indeed. It might be reasonably easy, e.g. replace (memq (nth 1 frame) '(interactive-p 'byte-code)) with something like (not (commandp (nth 1 frame)). But note that the situation for advised functions is still tricky: the outer advice is called with funcall-interactively (and it interactive) but inner advices and the original function are always called with `apply' or `funcall' rather than with funcall-interactively, so called-interactively-p still has to work harder to try and figure out that "the inner function is actually, conceptually, called interactively, even though technically it's not". Stefan