emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Re: Use of advice [was: Is it valid to call isearch-fil


From: Michael Heerdegen
Subject: Re: [External] : Re: Use of advice [was: Is it valid to call isearch-filter-predicate outside isearch?]
Date: Wed, 07 Jun 2023 04:53:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Drew Adams <drew.adams@oracle.com> writes:

> In the application I spoke of, the value (of
> `isearch-filter-predicate') gets advised.
> And advised, and advised,..., accumulating
> advice to tweak/refine the behavior.  And any
> added advice can get also get removed.
>
> A user does this interactively.  Any given state
> of the variable can be saved and restored, so if
> something (you or something else) changes the
> variable value for some reason you can easily
> get back to a previous state if you want.
>
> This particular interactive use of advice isn't
> about the Elisp sources using advice.  So I guess
> it's not quite the same thing you're talking about.

Yes, I think in such situations it's ok to use advices.  It's not really
possible to avoid them.

> > ... advised variables are more like hooks: you
> > add and remove functions, but you don't set it.
>
> Coming back to the example I referred to, yes,
> that's why I used advice.  But with hooks you
> have only the order of the hook functions to
> fiddle with.  With advice you have greater
> flexibility.

Exactly.  Advising is only a bit less transparent for that reason.

> Wrt "you don't set it": You _can_ replace the
> original effect completely, which is essentially
> setting it.  (And both a variable setting and a
> replacement advice can be reversed/restored,
> with some foresight.)
>
> Advice lets you do pretty much anything to the
> behavior.  But again, yes, to be able to
> add/subtract etc. easily you really want to
> use _named_ advice.

If you speak of :override: yes... but these can also get effected by
other advices, and different :override advices of different depths
concur.  That's what I wanted to mention.

> > Dunno if it would be worth it that variables which are considered to be
> > modified by advising should have a special suffix (like "-hook" for
> > hooks).  Or maybe we already more or less have it: "...-function".
> > `setq'ing such variables in the Emacs sources is probably not user
> > friendly.
>
> By "considered to be" I guess you mean
> "intended" or "expected" to be.  I guess you're
> talking about a variable that's expected to be
> used a bit like a hook.
>
> That's the case, BTW, for variables such as
> `isearch-filter-predicate'.  (OK, it uses suffix
> `-predicate' instead of `-function' or `-hook'.
> But the idea's the same.)

Yes, we have a few.  But `-predicate' is irrelevant for naming - not all
such places will be predicate functions.  And you can't tell from the
name that the variable should be advised and not set.


Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]