all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Clément Pit--Claudel" <clement.pit@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: New Package for GNU ELPA
Date: Sun, 22 May 2016 13:06:26 -0400	[thread overview]
Message-ID: <5741E712.8040306@gmail.com> (raw)
In-Reply-To: <87posef3dc.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 2177 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2016-05-22 17:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-22 16:45 New Package for GNU ELPA Ian Dunn
2016-05-22 17:06 ` Clément Pit--Claudel [this message]
2016-05-22 17:20   ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2016-05-22 17:27 Ian Dunn
2016-05-22 17:51 ` Clément Pit--Claudel
2016-05-22 18:17   ` Ian Dunn
2016-05-24 23:37 Ian Dunn
2016-05-25  0:16 ` Drew Adams
2016-05-27  2:00 Ian Dunn
2016-05-27 10:26 ` Kaushal Modi
2016-05-27 17:19   ` John Wiegley
2016-05-28  1:16     ` Ian Dunn

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=5741E712.8040306@gmail.com \
    --to=clement.pit@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.