Subject: bug#33601: 26; Add macro `with-hook-added'

From: Phil Sainty <[email-masked]>
Date: Tue, 04 Dec 2018 12:13:55 +1300

On 2018-12-04 11:50, Drew Adams wrote:
> The real question is whether such a macro is useful.
> I think it can be.  I gave a couple examples in bug
> #33595.  It was those examples that made me think
> such a macro might be useful.

I certainly think it can be useful.

On a couple of occasions I've used code which does a similar thing
with advice -- adding temporary advice, running a body, and removing
the advice again.

In both cases one could argue for a more persistent hook or advice
which performs its own check to see whether it should do things, but
that might also entail writing a new wrapper to perform the test, so
there's appeal in a with-* approach (particularly for things which are
wanted only very occasionally).

-Phil