From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: 1) (elisp) `Advising Named Functions', 2) search filtering example Date: Mon, 17 Oct 2016 08:40:36 -0700 (PDT) Message-ID: References: <5a44a850-e4fc-4c9f-a266-c74766810ba1@default> <1807679d-1125-4afe-81b7-b8d8e78aa2c6@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1476718912 31123 195.159.176.226 (17 Oct 2016 15:41:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Oct 2016 15:41:52 +0000 (UTC) To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 17 17:41:48 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwA2s-0007Vx-MO for ged-emacs-devel@m.gmane.org; Mon, 17 Oct 2016 17:41:46 +0200 Original-Received: from localhost ([::1]:33962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwA2u-0003V9-P6 for ged-emacs-devel@m.gmane.org; Mon, 17 Oct 2016 11:41:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwA1t-0002xV-1d for emacs-devel@gnu.org; Mon, 17 Oct 2016 11:40:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwA1o-0008BZ-40 for emacs-devel@gnu.org; Mon, 17 Oct 2016 11:40:45 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:17588) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwA1n-0008AU-RV for emacs-devel@gnu.org; Mon, 17 Oct 2016 11:40:40 -0400 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u9HFecVU016329 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2016 15:40:38 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u9HFecNE003436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2016 15:40:38 GMT Original-Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u9HFecV5030005; Mon, 17 Oct 2016 15:40:38 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:208363 Archived-At: > > You're right. I did have the impression that add-function was > > considered to be okay, just like add-hook is. >=20 > It is. >=20 > > the important distinction is between the thing being added to, not the > > function used to do the adding. >=20 > That's right. For `foo-predicate` and `foo-bar-function`, modifying the > variable is the raison d'=C3=AAtre of that variable, so it's not harmful: > programmers know that by design this value may change. But advising such a variable also advises its function value. Applying macro `add-function' to `isearch-filter-predicate' advises the value - the function itself. It does not just point the variable to a different value (function). This is a bit different from just saying that because the variable has a function value users will expect the variable value to be changeable. To be clear, I don't think I have a problem with a policy change that says that advising is now OK also for Emacs itself. But I think the policy should be recognized if this is the case, and the doc should reflect it. =20 > On the contrary (symbol-function ) is the value associated to > a function name and programmers usually expect that function to be > defined at somewhere in a file (in a single place) and the value is > expected (by the programmer and by other chunks of code which call it) > to be faithful to the file's code. If you advise either `isearch-filter-predicate' (as a place) or its value (e.g. `isearch-filter-visible') then `(symbol-function isearch-filter-predicate)' returns an advice (an object that satisfies "internal" predicate `advice--p'). The doc commands pretty much DTRT (but see bug #14734). But the function that is the value of an advised function variable such as `isearch-filter-predicate' _is advised_, and its `symbol-function' reflects that. (In fact, to retrieve the name of the function that is advised, you need to do some digging (e.g., use "internal" and undocumented function `advice--cd*r').