From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitri Paduchikh Newsgroups: gmane.emacs.devel Subject: Re: Brittleness of called-interactively-p Date: Fri, 07 Aug 2015 18:35:20 +0500 Message-ID: <87fv3v43xj.fsf@gmail.com> References: <871tgeufzt.fsf@gmail.com> <87r3odtngi.fsf@gmail.com> <87380st7c1.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438954559 6550 80.91.229.3 (7 Aug 2015 13:35:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2015 13:35:59 +0000 (UTC) Cc: Richard Stallman , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 07 15:35:54 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 1ZNhoQ-0004I9-Db for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 15:35:54 +0200 Original-Received: from localhost ([::1]:49213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNhoP-0000wY-JG for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 09:35:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNho2-0000wM-82 for emacs-devel@gnu.org; Fri, 07 Aug 2015 09:35:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNho0-0004xj-S4 for emacs-devel@gnu.org; Fri, 07 Aug 2015 09:35:30 -0400 Original-Received: from mail-la0-x234.google.com ([2a00:1450:4010:c03::234]:35072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNhnv-0004wD-K9; Fri, 07 Aug 2015 09:35:23 -0400 Original-Received: by labkb6 with SMTP id kb6so46008393lab.2; Fri, 07 Aug 2015 06:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=NOtRaAiv/qXFHyDtv6fTYH1nErBxeKKJQJcI9/H1rXw=; b=vPgBq+dhMvvOzRSr0TgFcjUZ84NX1E+8Wb8YqPWAGYaWAqvaIXC09hmrv0kOGAv8zK iU0MVo/BObp60oeU7jP5Nm+P9nMUal7YCNExaro0GhqCfEAIV22h9e6Ws9bQvCFQfDSD qr78jUewkBcHWMT/W57aQCGKjN5IMZnuapthu/GpSFg3WuMqThfcYbHWvdGxCYtbS4F0 rdsOSX0f0Fh60SdaK8yKSpnUrMvOmvLItHGBtIPgE/YtsYKMe6DpYKeo0g23KUkACwLV MjS5WUU6HjQhjoXSuUrc/AkH0FiIbpfgNOnnkYydYderZaOCXjBcVRkZDZ7xcw3eDN20 32XQ== X-Received: by 10.112.105.104 with SMTP id gl8mr7513295lbb.81.1438954521934; Fri, 07 Aug 2015 06:35:21 -0700 (PDT) Original-Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id o7sm2178452lbp.9.2015.08.07.06.35.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2015 06:35:20 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Thu, 06 Aug 2015 18:33:32 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::234 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:188539 Archived-At: Stefan Monnier writes: >> These calls are internal to the advice mechanism and, of course, they >> cannot be considered conceptually interactive. SM> If the original function uses called-interactively-p and the "whole SM> advised function" is called interactively, then called-interactively-p SM> should return t, yet this call is inside an interactive function which SM> is called non-interactively. Exactly, see above. I thought that may be it is better to associate interactive form with function symbol rather than with function itself. This would solve issues with calls that are internal to advice system. When advised, the original function becomes non-interactive automatically. There can be other issues with such approach though. The most obvious one is that it is not longer possible to use interactive lambdas. Personally I think that they are not so necessary and are better to be avoided when defining key bindings because symbols look better in help output. Also there is problem with idiom like this: (call-interactively (lambda (b e) (interactive "r") ...)) But note that conceptually this is not a interactive call of command. It is about reusing the feature of interactive calls to obtain values for arguments. So it probably can be replaced with something like (call-with-interactive-args "r" (lambda (b e) ...)) >> It is not clear for me whether this approach will help to solve the current >> problem of macros wrapping fragments of code in lambdas. SM> BTW, the real solution, which is simple and reliable is to not use SM> called-interactively-p at all, and use an argument instead: SM> (defun foo (bar &optional called-interactively) SM> (interactive (list toto t)) Yes, indeed, and this method is described in the doc string of called-interactively-p. This means however that one odd argument is added to the function interface which plays only technical role. And also advices which need this information will have to modify the argument list of the original function if it does not provide it already. RMS had an idea to make sort of separate argument for this purpose which does not belong to function interface. My comment above was directed to him. As you can see I was confused, since in theory it can work with macros and lambdas no worse than your recommendation of using special argument. I have not ideas about this approach, so do not comment it further. I will be away for next ten days, and so won't be able to participate in the discussion in the case you or somebody else is interested.