From unknown Fri Aug 15 14:47:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19915: 25.0.50; defadvice for `org-store-link' makes code fail because of `org-called-interactively-p' 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: To: 19915@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.142454969930979 (code B ref -1); Sat, 21 Feb 2015 20:15:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 Feb 2015 20:14:59 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 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 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 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 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 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 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 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 MIME-Version: 1.0 Message-ID: <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> Date: Sat, 21 Feb 2015 12:14:44 -0800 (PST) From: Drew Adams X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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' From unknown Fri Aug 15 14:47:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19915: 25.0.50; defadvice for `org-store-link' makes code fail because of `org-called-interactively-p' Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Feb 2015 20:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19915 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 19915@debbugs.gnu.org Received: via spool by 19915-submit@debbugs.gnu.org id=B19915.142455064232556 (code B ref 19915); Sat, 21 Feb 2015 20:31:02 +0000 Received: (at 19915) by debbugs.gnu.org; 21 Feb 2015 20:30:42 +0000 Received: from localhost ([127.0.0.1]:50396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YPGhA-0008Sw-T4 for submit@debbugs.gnu.org; Sat, 21 Feb 2015 15:30:39 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:18876) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YPGh1-0008Sd-2g for 19915@debbugs.gnu.org; Sat, 21 Feb 2015 15:30:28 -0500 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t1LKUP66024812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for <19915@debbugs.gnu.org>; Sat, 21 Feb 2015 20:30:26 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id t1LKUOm4011938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for <19915@debbugs.gnu.org>; Sat, 21 Feb 2015 20:30:25 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t1LKUOaG022460 for <19915@debbugs.gnu.org>; Sat, 21 Feb 2015 20:30:24 GMT MIME-Version: 1.0 Message-ID: <806cb9a1-9089-45a5-bcf1-5e1563fc4793@default> Date: Sat, 21 Feb 2015 12:30:23 -0800 (PST) From: Drew Adams References: <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> In-Reply-To: <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) And yes, `advice-add' does not have the same problem. But it is a shame to limit users to recent Emacs versions just because Org uses `called-interactively' instead of adding an argument that indicates whether the command is called interactively (as Emacs recommends). From unknown Fri Aug 15 14:47:08 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Drew Adams Subject: bug#19915: closed (Re: bug#19915: 25.0.50; defadvice for `org-store-link' makes code fail because of `org-called-interactively-p') Message-ID: References: <87po6qoom4.fsf@nicolasgoaziou.fr> <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> X-Gnu-PR-Message: they-closed 19915 X-Gnu-PR-Package: org-mode Reply-To: 19915@debbugs.gnu.org Date: Wed, 03 Jan 2018 17:10:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1514999403-22595-1" This is a multi-part message in MIME format... ------------=_1514999403-22595-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #19915: 25.0.50; defadvice for `org-store-link' makes code fail because of = `org-called-interactively-p' which was filed against the org-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 19915@debbugs.gnu.org. --=20 19915: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D19915 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1514999403-22595-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 19915-done) by debbugs.gnu.org; 3 Jan 2018 17:10:00 +0000 Received: from localhost ([127.0.0.1]:34564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWmYB-0005s7-UM for submit@debbugs.gnu.org; Wed, 03 Jan 2018 12:10:00 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:56531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWmYA-0005ry-08 for 19915-done@debbugs.gnu.org; Wed, 03 Jan 2018 12:09:58 -0500 Received: from saiph.selenimh (000043010000000000000469.ipv6.commingeshautdebit.fr [IPv6:2a03:a0a0:0:4301::469]) (Authenticated sender: mail@nicolasgoaziou.fr) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id A3018A80CD; Wed, 3 Jan 2018 18:09:56 +0100 (CET) Received: from ngz by saiph.selenimh with local (Exim 4.89) (envelope-from ) id 1eWmY7-00035C-W4; Wed, 03 Jan 2018 18:09:56 +0100 From: Nicolas Goaziou To: Drew Adams Subject: Re: bug#19915: 25.0.50; defadvice for `org-store-link' makes code fail because of `org-called-interactively-p' In-Reply-To: <806cb9a1-9089-45a5-bcf1-5e1563fc4793@default> (Drew Adams's message of "Sat, 21 Feb 2015 12:30:23 -0800 (PST)") References: <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> <806cb9a1-9089-45a5-bcf1-5e1563fc4793@default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Date: Wed, 03 Jan 2018 18:09:55 +0100 Message-ID: <87po6qoom4.fsf@nicolasgoaziou.fr> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 19915-done Cc: 19915-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hello, Drew Adams writes: > And yes, `advice-add' does not have the same problem. > > But it is a shame to limit users to recent Emacs versions > just because Org uses `called-interactively' instead of > adding an argument that indicates whether the command is > called interactively (as Emacs recommends). I removed call to `called-interactively-p' in `org-store-link' (in development version). Thank you. Regards, -- Nicolas Goaziou 0x80A93738 ------------=_1514999403-22595-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 21 Feb 2015 20:14:59 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 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 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 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 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 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 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 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 MIME-Version: 1.0 Message-ID: <66d452bd-fa38-40e7-b16e-8fe4756d5fab@default> Date: Sat, 21 Feb 2015 12:14:44 -0800 (PST) From: Drew Adams To: bug-gnu-emacs@gnu.org Subject: 25.0.50; defadvice for `org-store-link' makes code fail because of `org-called-interactively-p' X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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' ------------=_1514999403-22595-1--