all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: RE: 1) (elisp) `Advising Named Functions', 2) search filtering example
Date: Mon, 17 Oct 2016 08:40:36 -0700 (PDT)	[thread overview]
Message-ID: <cc8cf156-a31d-4889-918a-df56728c1b26@default> (raw)
In-Reply-To: <jwvd1izc9ru.fsf-monnier+gmane.emacs.devel@gnu.org>

> > You're right. I did have the impression that add-function was
> > considered to be okay, just like add-hook is.
> 
> It is.
> 
> > the important distinction is between the thing being added to, not the
> > function used to do the adding.
> 
> That's right.  For `foo-predicate` and `foo-bar-function`, modifying the
> variable is the raison d'être 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.
 
> On the contrary (symbol-function <foo>) 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').



  reply	other threads:[~2016-10-17 15:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-17  5:25 1) (elisp) `Advising Named Functions', 2) search filtering example Drew Adams
2016-10-17 12:20 ` Noam Postavsky
2016-10-17 14:02   ` Drew Adams
2016-10-17 14:37     ` Noam Postavsky
2016-10-17 14:52       ` Stefan Monnier
2016-10-17 15:40         ` Drew Adams [this message]
2016-10-17 15:51           ` Stefan Monnier
2016-10-17 17:05             ` Drew Adams
2016-10-17 17:47               ` Stefan Monnier
2016-10-17 15:40       ` Drew Adams
2016-10-17 16:16         ` Noam Postavsky
2016-10-17 17:05           ` Drew Adams
2016-10-17 17:53             ` Stefan Monnier
2016-10-17 18:41               ` Drew Adams
2016-10-17 19:25                 ` Stefan Monnier
2016-10-18 19:47                   ` Richard Stallman
2016-10-19  6:15                     ` Eli Zaretskii
2016-10-19 20:00                       ` Richard Stallman
2016-10-19 20:18                         ` Stefan Monnier
2016-10-20  7:17                           ` Eli Zaretskii
2016-10-20  7:06                         ` Eli Zaretskii
2016-10-20 18:06                           ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc8cf156-a31d-4889-918a-df56728c1b26@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.