From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: proper use of add-function Date: Tue, 22 May 2018 17:29:17 -0700 Message-ID: <87wovvw6xu.fsf@ericabrahamsen.net> References: <87efi3xppf.fsf@ericabrahamsen.net> <87a7srgtco.fsf@web.de> <87603fxnxi.fsf@ericabrahamsen.net> <874lizgs4g.fsf@web.de> <871se3xmfk.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1527035482 19366 195.159.176.226 (23 May 2018 00:31:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 May 2018 00:31:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Help Gnu Emacs mailing list To: Noam Postavsky Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 23 02:31:18 2018 Return-path: Envelope-to: geh-help-gnu-emacs@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 1fLHgU-0004ur-4s for geh-help-gnu-emacs@m.gmane.org; Wed, 23 May 2018 02:31:18 +0200 Original-Received: from localhost ([::1]:58573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHib-00038A-5U for geh-help-gnu-emacs@m.gmane.org; Tue, 22 May 2018 20:33:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHhS-00035O-VD for help-gnu-emacs@gnu.org; Tue, 22 May 2018 20:32:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLHhN-0000Vj-Vv for help-gnu-emacs@gnu.org; Tue, 22 May 2018 20:32:18 -0400 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:42211) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fLHhN-0000TQ-Ps for help-gnu-emacs@gnu.org; Tue, 22 May 2018 20:32:13 -0400 Original-Received: from localhost (97-113-251-151.tukw.qwest.net [97.113.251.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 12D29C1D68; Wed, 23 May 2018 00:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1527035526; bh=/ikVDKjyo9Y8N8age3rLgPgta+5LN1QgtLx7GqGv6Jo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=w7sqWXBkg3C/3eLjr57pLYlX25h5nFK9M4afZdl2o3ZT+Lc6LjKOTu5HNGk2LIJTi Za5A7PJcSolK4/K0onkpAusJpIu5xlFj+Zxz4xinuNKgcAc4eZASTJmTRwq30aomrf 9v0GsnNOahe6I/eaD2xbDNsKKIJnfS2py++l1MBM= In-Reply-To: (Noam Postavsky's message of "Tue, 22 May 2018 20:19:14 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 50.56.99.223 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116828 Archived-At: On 05/22/18 20:19 PM, Noam Postavsky wrote: > On 22 May 2018 at 20:09, Eric Abrahamsen wrote: >> Michael Heerdegen writes: >> >>> Eric Abrahamsen writes: >>> >>>> Okay, I see what you and Noam are saying, and in fact what the docstring >>>> is saying. It's just pretty weird that `add-function' works on >>>> variables, and `advice-add' works on functions. > > Yeah, this isn't the first time I've seen confusion over this (e.g., > Bug#30241). The docstring is clear enough when you already know what > it says, but I've just added an extra note that should help guide > people toward advice-add. > > [1: e3f00f5637]: 2018-05-22 20:08:01 -0400 > Clarify when to use advice-add vs add-function > https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e3f00f5637a2790923a9c4c1d4b7dbf65027d8ce Thanks for doing that. That was definitely a "makes sense when you already understand it" situation. >>> Actually `add-function' works for "places" (including >>> `symbol-function'), so it's the more general and more low-level tool. >>> `advice-add' is higher-level and specialized on function names. >> >> I guess that's why I kept trying to make this work -- I thought the >> `symbol-function' place would allow me to apply my advice to >> 'canonically-space-region. Why doesn't that work? > > (add-function > :filter-args > (symbol-function 'canonically-space-region) > #'my-canonical-space-region) > > This seems to work for me (although advice-add is preferable for > reasons listed in the manual). Right, I get that now. I was only stuck on `add-function' because I was under the impression that it would get me buffer-local behavior, which I understand now it won't. Thanks, Eric