[Top][All Lists]

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

Re: New Package for GNU ELPA

From: Ian Dunn
Subject: Re: New Package for GNU ELPA
Date: Fri, 27 May 2016 21:16:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

John Wiegley <address@hidden> writes:

>>>>>> Kaushal Modi <address@hidden> writes:
>> IMO the standard add-hook and remove-hook don't seem to need syntactic
>> sugar. The macros in the package lack many things that the default
>> add-hook/remove-hook do and also it is more verbose.
>> It's not too difficult to define a foo function and add that to a hook using
>> the standard way. And ALWAYS explicitly defining a function first is a good
>> rule of thumb. It applies to hooks and advices both.
> I like this package. First, it's not being suggested for core, or as an
> alternative to standard methods. Second, just because you *can* do something
> in a manual way, is no reason to argue against convenience. I would both
> welcome this addition, and start using it.
> As a bonus, it could be implemented as a macro that does actually generates a
> new function and adds that function symbol to the hook, in such a way that if
> you change the body and re-evaluate with C-M-x, it removes the old function,
> and adds the changed one. Then it would be identical to what "best practices"
> say one should do when adding a hook, but with a clearer declaration of
> intent: "I want the following FORMS to happen when the hook is run".

  I appreciate the feedback from both of you.  John, you've succinctly
stated my goal with this package, and I appreciate your support.  It's
not a replacement for add-hook/remove-hook, because Kaushal, as you put
it, you can't beat the simplicity and brevity of the two.

  My intention was something similar to `define-advice', except for
hooks.  I wanted something that would clean up functions that were only
ever added to a hook, wrapping them inside a nice macro and tucking them
away where we don't have to see them.

> PS: "define-mode-hook-helper text" and "define-hook-helper text-mode" seem to 
> do
> the exact same thing.  The macro user is not saving any time by using
> define-mode-hook-helper; they still need to type "-mode" but at a different
> place. I don't understand the point of that.

  I'm not sure why that's never occurred to me.  Thanks for pointing that out.

  One of the glaring flaws that almost everyone has pointed out is that
there is no way to add the new function to multiple hooks.  With my most
recent push, I added `define-hook-function', which is mostly just
`defun', but with the "hooks" keyword that allows a user to specify one
or more hook to which the function will be added.  It doesn't address
every concern, as people are different and have different ways of doing
things, but this does give people the ability to define a function, find
it with `C-h f', and specify as many hooks as they want.

Ian Dunn

reply via email to

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