From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#19915: 25.0.50; defadvice for `org-store-link' makes code fail because of `org-called-interactively-p' Date: Sat, 21 Feb 2015 12:14:44 -0800 (PST) Message-ID: <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1424549736 18699 80.91.229.3 (21 Feb 2015 20:15:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Feb 2015 20:15:36 +0000 (UTC) To: 19915@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 21 21:15:22 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1YPGSQ-0002ut-CV for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Feb 2015 21:15:22 +0100 Original-Received: from localhost ([::1]:37282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPGSP-00041o-Ol for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Feb 2015 15:15:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPGSM-00041j-Fe for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:15:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPGSH-0006u7-FJ for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:15:18 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPGSH-0006tf-BQ for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:15:13 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YPGS6-000849-PV for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Feb 2015 20:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19915 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.142454969930979 (code B ref -1); Sat, 21 Feb 2015 20:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Feb 2015 20:14:59 +0000 Original-Received: from localhost ([127.0.0.1]:50388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YPGS3-00083a-0o for submit@debbugs.gnu.org; Sat, 21 Feb 2015 15:14:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43244) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YPGS1-00083R-8Z for submit@debbugs.gnu.org; Sat, 21 Feb 2015 15:14:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPGRz-0006l2-MM for submit@debbugs.gnu.org; Sat, 21 Feb 2015 15:14:56 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:55134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPGRz-0006ky-J9 for submit@debbugs.gnu.org; Sat, 21 Feb 2015 15:14:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPGRy-0003rg-E2 for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:14:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPGRt-0006kY-6V for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:14:54 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:30750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPGRs-0006kP-Vx for bug-gnu-emacs@gnu.org; Sat, 21 Feb 2015 15:14:49 -0500 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t1LKElAT002663 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 21 Feb 2015 20:14:48 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t1LKEkaT001994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 21 Feb 2015 20:14:47 GMT Original-Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t1LKEjNQ022969 for ; Sat, 21 Feb 2015 20:14:45 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99682 Archived-At: In an attempt to work around bug #19914, I tried advising `org-store-link', as follows: (defadvice org-store-link (before foo activate) "Reset `foo' to nil." (setq foo nil)) ; A defvar'd variable. With that advice, this part of the `org-store-link' code fails: ;; Return the link (if (not (and (or (org-called-interactively-p 'any) executing-kbd-macro) link)) (or agenda-link (and link (org-make-link-string link desc))) (push (list link desc) org-stored-links) (message "Stored: %s" (or desc link)) (when custom-id (setq link (concat "file:" (abbreviate-file-name (buffer-file-name)) "::#" custom-id)) (push (list link desc) org-stored-links)) (car org-stored-links)) The call to `org-called-interactively-p' returns nil, when it should return non-nil (I invoked `org-store-link' interactively). The result is that `org-stored-links' is not updated. If I unadvise the function then there is no such problem. The doc string of `called-interactively-p', which is used by `org-called-interactively-p', says this, which seems relevant here: 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. The Org code should presumably be changed following this part of that doc string: Instead of using this function, it is cleaner and more reliable to give your function an extra optional argument whose `interactive' spec specifies non-nil unconditionally ("p" is a good way to do this), or via (not (or executing-kbd-macro noninteractive)). The Org code uses `org-called-interactively-p' all over the place, it seems. Dunno whether other occurrences are as problematic as this one. In GNU Emacs 25.0.50.1 (i686-pc-mingw32) of 2014-10-20 on LEG570 Bzr revision: 118168 rgm@gnu.org-20141020195941-icp42t8ttcnud09g Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --enable-checking=3Dyes,glyphs CPPFLAGS=3D-DGLYPH_DEBUG=3D1'