all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>,
	"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 14:44:33 +0000	[thread overview]
Message-ID: <SJ0PR10MB54886B308C995172B68F1F3DF353A@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87ttvkoue6.fsf@web.de>

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

Are you talking about an advice name or the name
of a predicate-valued variable?

For the latter, we could adopt suffix `-predicate'
conventionally.  A predicate in Lisp is a Boolean
function.  (It's not just a Boolean value.)

However, just as with other functions, predicates
can have different signatures.  So that suffix
would correspond to an "abnormal" hook, i.e., one
whose value could accept args.
____

I'll also pointed out that predicates are
_particularly_ useful use cases for advice, as
the ways you can combine the advice include the
usual logical combinations (AND, OR, NOT).

IOW, knowing that the function being advised, as
well as the intended result of advising, are to
be _predicates_ means you can use such general
logical combinations as ways of advising them.

That's what my Isearch dynamic filtering code
does: it lets you combine predicates easily
(interactively) using AND, OR, and NOT, among
other possibilities.

And there are two versions of ORing and
complementing:

1. Just add a predicate, ORing/complementing
   the current predicate.

2. Replace the last-added predicate (advice)
   by its disjunction with a new predicate
   or by its complement.

https://www.emacswiki.org/emacs/DynamicIsearchFiltering#FilteringCommandsAvailableDuringSearch

Advising an arbitrary function doesn't allow such
combining possibilities.  But at least you still
have some other general operations: add advice,
remove advice, replace advice, list/show/describe
current advice, save current advised definition
(to reuse later), keep or not for subsequent
commands, reset to original predicate.



  reply	other threads:[~2023-06-07 14:44 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   ` [External] : " Drew Adams
2023-06-07  2:53     ` Michael Heerdegen
2023-06-07 14:44       ` Drew Adams [this message]
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

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

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