From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.help Subject: Re: proper use of add-function Date: Tue, 22 May 2018 20:19:14 -0400 Message-ID: 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; charset="UTF-8" X-Trace: blaine.gmane.org 1527035719 3812 195.159.176.226 (23 May 2018 00:35:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 May 2018 00:35:19 +0000 (UTC) Cc: Help Gnu Emacs mailing list To: Eric Abrahamsen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 23 02:35:14 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 1fLHkI-0000ta-62 for geh-help-gnu-emacs@m.gmane.org; Wed, 23 May 2018 02:35:14 +0200 Original-Received: from localhost ([::1]:58593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHmP-0006IJ-9Z for geh-help-gnu-emacs@m.gmane.org; Tue, 22 May 2018 20:37:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLHUq-0001DL-Gs for help-gnu-emacs@gnu.org; Tue, 22 May 2018 20:19:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLHUp-0001tH-FC for help-gnu-emacs@gnu.org; Tue, 22 May 2018 20:19:16 -0400 Original-Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]:44589) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLHUp-0001sx-9x for help-gnu-emacs@gnu.org; Tue, 22 May 2018 20:19:15 -0400 Original-Received: by mail-ot0-x236.google.com with SMTP id g7-v6so23145445otj.11 for ; Tue, 22 May 2018 17:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=74XB76QcJz+e7k+FL6c/4eYLvIQTJXv/1fNtUFNHIp8=; b=fYRhW6is5uqsmRn+yGYVUyBeKjJKSh54BvHI9eNZXomTsAk334eJ09StxmZtjEBR4E SCWJGG3UHE8z4yL/wWgy34mhwYN8z/ky08rwq2iDbFbyyg3NszyQNoQnKDzvtrZhBq2A Nw9TGxFLNhpSuIcQJ/ECdD1J3lY5iYFq94go1YOL7XbGYHRLCutciMy7WyTowSFI7AMW jNZR8pZFXo03saEMYDQ2Ip14a03bAVtjEKFoY5LDmFEoaXQc1Niea50Db7DZu68+gCiq 5GgAoYNnz5mnaNFLUFf8IiTj4ijtzoSfE/jcUxrXaFOyYgtxyOsec/wwcgfAGBtHrDWS ehCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=74XB76QcJz+e7k+FL6c/4eYLvIQTJXv/1fNtUFNHIp8=; b=MU2FtchSVGF6OTsQeXRk8yaHegKisKj6q6qIOUq+KY4eY4rLUa7FSr6UPkpyNcbQtO 9VPtEVmuZJmqhc/x5j1N6vRNClC8g37BUhohbYZIlE2VKlbsA7SJVtCiSw+/tPb0ypsP hEXrHb6JnGZkveHRyAAmFKZyWoa5LZ87O6NMOJTYlZA5+2gHDKm7KGxpcnKFNIKYSjQ2 I4FB4woaB4K+xsnkc/nrg+RhyPtFqP7fOTVvyDL22+SnRD0VxyUux+yuSfopIyk0wche /AGX2JHxLeq1vR9ZE6yNMF+wDdb2AbfU6qg/+Wf696adMtBg8+zQwhJSavUpGm8rVBZS 585w== X-Gm-Message-State: ALKqPwfZU7HH9Qx41QvZ8456b9GDf7bqCSKKF0/OCYLdg1JwiftDOfaV Md9Q16cpLFDLJNpGRH7IdS2RGJnAmhTN/CR/yyg= X-Google-Smtp-Source: AB8JxZovM7b7xO2ZwAVUaPKSEInwrV6uKGSU8dUrJKTLYf9wGVXzZBtMO0ltr0/LtV/hQlM3nWCFNQE4ZPypKB2ya3Q= X-Received: by 2002:a9d:501a:: with SMTP id a26-v6mr450728oth.82.1527034754673; Tue, 22 May 2018 17:19:14 -0700 (PDT) Original-Received: by 2002:a4a:587:0:0:0:0:0 with HTTP; Tue, 22 May 2018 17:19:14 -0700 (PDT) In-Reply-To: <871se3xmfk.fsf@ericabrahamsen.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::236 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:116829 Archived-At: 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 >> 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).