> ;; Add font lock for both macros. > (font-lock-add-keywords > 'emacs-lisp-mode > '(("(\\(define-hook-helper\\)\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?" > (1 font-lock-keyword-face) > (2 font-lock-constant-face nil t)) > ("(\\(define-mode-hook-helper\\)\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?" > (1 font-lock-keyword-face) > (2 font-lock-constant-face nil t)))) Is there a reason why these two macros aren't highlighted properly by default? I don't think other packages do this. On 2016-05-22 12:45, Ian Dunn wrote: > > 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. > > The |define-hook-helper| macro is a solution to this. Think of it as an anaphoric |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. > > > >