|Subject:||New Package for GNU ELPA|
|Date:||Sun, 22 May 2016 12:45:35 -0400|
|User-agent:||Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)|
I'd like to offer my new package, hook-helpers (https://savannah.nongnu.org/projects/hook-helpers-el/), to GNU ELPA. I've already filled out copyright paperwork for Emacs.
Often times, I see people define a function to be used once in a hook. If
they don’t do this, then it will be an anonymous function. If the anonymous
function is modified, then the function can’t be removed. With a function
outside of the
add-hook call, it looks messy.
define-hook-helper macro is a solution to this. Think of it as an
add-hook, but one that can be called many times without risking
redundant hook functions. It gives a cleaner look and feel to Emacs
configuration files, and could even be used in actual libraries.
The purpose of this package is to build upon add-hook and remove-hook. When you have something like the following:
(defun my/after-init-hook () (set-scroll-bar-mode nil))
You’ve got to remember to actually add this to the after-init-hook variable. Alternatively, you can use a lambda function:
(add-hook 'after-init-hook (lambda () (set-scroll-bar-mode nil)))
But then if you want to modify the function, it’s permanently stuck on the after-init-hook variable, and you have to deal with it. It’s not a problem for after-init-hook, which is used once, but would be a problem for a mode hook, like text-mode-hook.
Instead, hook-helpers can do the following:
(define-hook-helper after-init (set-scroll-bar-mode nil))
Which handles everything for you.
-- Ian Dunn
|[Prev in Thread]||Current Thread||[Next in Thread]|