unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Ihor Radchenko <yantar92@posteo.net>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: RE: [External] : Re: Use of advice   [was: Is it valid to call isearch-filter-predicate outside isearch?]
Date: Wed, 7 Jun 2023 02:01:01 +0000	[thread overview]
Message-ID: <SJ0PR10MB548836535DBA91A122F33BDCF353A@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87edmo17v7.fsf@web.de>

> if you use named advices,
> debugging and analyzing can be simple.

Yes. Naming advice is pretty essential if you
want some flexibility - being able to add &
remove bits etc.

> In the Elisp sources, instead of modifying
> the function binding of a variable ... the
> bound function could maybe just be changed
> to handle all situations.  Then the code
> would not have to change the variable at all.

Not sure what you have in mind there.

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.

> ... 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.

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.

> 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.)

> Anyway, I think we (at least I) still learn about the consequences of
> having this tool.  The "see what is going on" part would maybe be
> facilitated if the *Help* pages would show a combined overview showing
> which types of advices are applied in which order and at which depth
> around an advised function (at least in not trivial cases).

+1 to that.  I expect more needs to be done
wrt the debugger as well, to make what's
going on clearer.



  reply	other threads:[~2023-06-07  2:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-03 15:22 Use of advice [was: Is it valid to call isearch-filter-predicate outside isearch?] Drew Adams
2023-06-06 23:36 ` Michael Heerdegen
2023-06-07  2:01   ` Drew Adams [this message]
2023-06-07  2:53     ` [External] : " Michael Heerdegen
2023-06-07 14:44       ` Drew Adams
2023-06-08  1:30         ` Michael Heerdegen
2023-06-07 11:53     ` Ihor Radchenko
2023-06-07 11:49   ` Ihor Radchenko
2023-06-07 14:47     ` [External] : " Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=SJ0PR10MB548836535DBA91A122F33BDCF353A@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=yantar92@posteo.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).