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: Brittleness of called-interactively-p Date: Sun, 12 Jul 2015 10:00:54 +0500 Message-ID: <871tgeufzt.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436677267 29094 80.91.229.3 (12 Jul 2015 05:01:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Jul 2015 05:01:07 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 12 07:01:07 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 1ZE9Ny-00046p-Ix for ged-emacs-devel@m.gmane.org; Sun, 12 Jul 2015 07:01:06 +0200 Original-Received: from localhost ([::1]:49747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZE9Nx-0006rj-W1 for ged-emacs-devel@m.gmane.org; Sun, 12 Jul 2015 01:01:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZE9Nt-0006oM-SB for emacs-devel@gnu.org; Sun, 12 Jul 2015 01:01:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZE9Nq-0000PQ-Hf for emacs-devel@gnu.org; Sun, 12 Jul 2015 01:01:01 -0400 Original-Received: from mail-lb0-x236.google.com ([2a00:1450:4010:c04::236]:33066) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZE9Nq-0000Ng-9S for emacs-devel@gnu.org; Sun, 12 Jul 2015 01:00:58 -0400 Original-Received: by lbbyj8 with SMTP id yj8so24729443lbb.0 for ; Sat, 11 Jul 2015 22:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=HEmfSZDPle77tg/3hHnC6UARPtdDT+4fe1fNJQYYmaA=; b=IO7BSlB3l4xdk1oYmwZ3HRzrOzJqPXkJs8EvDU3HQpZGObAqdvTJxv7u68NphZtnCL BD65gp/8e/YlDIIdONWPi2C3hHcWyk5l99vK6PCI6EIauS/d8RNpztmQMFmrdaXC0SVk Nq+BH4KafBfK0nAhmRlwl9zKciT1KePiQJ/fk6abs+6czi1WGLa+hF3+T3qvXXSxKlJc oXSkoJ2L13jZ5h4JBbRUdEX7vzEtaJ4hCHAaZpUj/huILgu/LoegKhUkNpUH8vYL5HFm Lr2B1SWkNObutKl9I4pjQSak1/5jPSS3RnQr35VXEsJPNoHC2trPUiBK91lrMxglO/1/ PHHQ== X-Received: by 10.152.3.135 with SMTP id c7mr25460060lac.109.1436677255754; Sat, 11 Jul 2015 22:00:55 -0700 (PDT) Original-Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id su8sm3669925lbc.41.2015.07.11.22.00.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jul 2015 22:00:55 -0700 (PDT) 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:c04::236 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:187813 Archived-At: Hello, The documentation string of called-interactively-p states this: > This function is very brittle, it may fail to return the intended result > when the code is debugged, advised, or instrumented in some form. Some > macros and special forms (such as `condition-case') may also sometimes > wrap their bodies in a `lambda', so any call to `called-interactively-p' > from those bodies will indicate whether that lambda (rather than the > surrounding function) was called interactively. 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. The called-interactively-p function would simply return this value. Of course, this will change the meaning of called-interactively-p inside the usual functions without interactive form, but previously it didn't make sense to check called-interactively-p inside such functions anyway, so the change shouldn't cause problems with existing code. This will allow using called-interactively-p in those cases when changing of function signature is undesirable for some reasons. For example, when interactivity of call is insignificant for function interface and you don't want to compromise the cleanness of function signature for such a little reason. Or inside advices, when overriding function signature is undesirable for compatibility reasons. And it even makes provision for some new uses, e.g. inside function hooks. Sorry if this idea has already been discussed here.