all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: John Wiegley <johnw@gnu.org>
Cc: telenieko@telenieko.com, 72818-done@debbugs.gnu.org
Subject: bug#72818: 29.4; Cannot hook with use-package if variable is not `-hook'$
Date: Sat, 31 Aug 2024 13:08:24 +0300	[thread overview]
Message-ID: <86v7zhatt3.fsf@gnu.org> (raw)
In-Reply-To: <m2cylvktoi.fsf@gnu.org> (message from John Wiegley on Mon, 26 Aug 2024 11:47:25 -0700)

> From: John Wiegley <johnw@gnu.org>
> Cc: Marc Fargas <telenieko@telenieko.com>,  72818@debbugs.gnu.org
> Date: Mon, 26 Aug 2024 11:47:25 -0700
> 
> >>>>> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Maybe I'm missing something, but how can use-package configure
> > abnormal hooks?  It doesn't know which arguments to pass to them,
> > right?
> >
> > John, am I missing something?
> 
> I think the behavior should be that if the variable name exists at the time
> the use-package macro is encountered, it should use it directly. Only if the
> named hook variable has no ‘symbol-value’ — at that time — should it try
> appending the name ‘-hook‘ to find a place to append the function.
> 
> I.e., the definition could be:
> 
> (defun use-package-handler/:hook (name _keyword args rest state)
>   "Generate use-package custom keyword code."
>   (use-package-concat
>    (use-package-process-keywords name rest state)
>    (cl-mapcan
>     #'(lambda (def)
>         (let ((syms (car def))
>               (fun (cdr def)))
>           (when fun
>             (mapcar
>              #'(lambda (sym)
>                  (if (boundp sym)
>                      `(add-hook (quote ,sym) (function ,fun))
>                    `(add-hook
>                      (quote ,(intern
>                               (concat (symbol-name sym)
>                                       use-package-hook-name-suffix)))
>                      (function ,fun))))
>              (use-package-hook-handler-normalize-mode-symbols syms)))))
>     (use-package-normalize-commands args))))

Thanks, installed on the emacs-30 release branch, and closing the bug.





  reply	other threads:[~2024-08-31 10:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 10:53 bug#72818: 29.4; Cannot hook with use-package if variable is not `-hook'$ Marc Fargas
2024-08-26 11:15 ` Rudolf Schlatte
2024-08-26 11:34 ` Eli Zaretskii
2024-08-26 18:47   ` John Wiegley
2024-08-31 10:08     ` Eli Zaretskii [this message]
2024-09-10  8:27       ` Marc Fargas

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=86v7zhatt3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=72818-done@debbugs.gnu.org \
    --cc=johnw@gnu.org \
    --cc=telenieko@telenieko.com \
    /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.