GNU bug report logs - #79106
[PATCH] Add new optional keywords to use-package

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sun, 27 Jul 2025 20:20:01 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: "Elijah G." <eg642616 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Philip Kaludercic <philipk <at> posteo.net>
Cc: karthikchikmagalur <at> gmail.com, 79106 <at> debbugs.gnu.org, shipmints <at> gmail.com, johnw <at> newartisans.com
Subject: bug#79106: [PATCH] Add new optional keywords to use-package
Date: Thu, 07 Aug 2025 09:44:46 -0600
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Philip Kaludercic <philipk <at> posteo.net>
>> Cc: Elijah Gabe Pérez <eg642616 <at> gmail.com>,
>>   karthikchikmagalur <at> gmail.com,
>>   johnw <at> newartisans.com, 79106 <at> debbugs.gnu.org, shipmints <at> gmail.com
>> Date: Thu, 07 Aug 2025 14:26:53 +0000
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> > Suggestion 1: allow many hooks to be specified in a list
>> >> >
>> >> > :hook+ (foo-mode . (bar baz quux))
>> >> >
>> >> > adds functions bar, baz and quux to foo-mode-hook.  (To
>> >> > disambiguate
>> >> > between a list of hook functions and a lambda, you can look at
>> >> > the car
>> >> > of the list maybe?)
>> >> 
>> >> It is not possible because (foo-mode . (bar baz quux)) is
>> >> expanded as
>> >> (foo-mode bar baz quux), and this can be misinterpreted by :hook+
>> >> as a
>> >> list of hooks.
>> >> 
>> >> The only workaround i found is making a kind of separator
>> >> (:multi),
>> >> which tells :hook+ the cdr is a list of functions, not part of a
>> >> list of
>> >> hooks.
>> >> 
>> >> I know that :multi can look weird (even i was thinking in rename
>> >> it [1]
>> >> or use a better separator), but it was the only solution i found
>> >> and
>> >> worked.
>> >> 
>> >> > Suggestion 2: allow many hooks to be added to.  (:hook already
>> >> > does
>> >> > this)
>> >> >
>> >> > :hook+ ((foo-mode cor-mode) . (bar baz quux))
>> >> >
>> >> > Adds the three functions to both foo-mode-hook and
>> >> > cor-mode-hook.
>> >> 
>> >> Similar problem as previous.
>> >> 
>> >> > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified
>> >> > with
>> >> > the functions,
>> >> > in the same order as add-hook.
>> >> >
>> >> > :hook+ (foo-mode . ((bar 90 t)
>> >> >                     baz
>> >> >                     (quux -30)
>> >> >                     (cor nil t))
>> >> >
>> >> > will install 
>> >> > - bar at depth 90, to be run buffer-locally when foo-mode-hook
>> >> > runs
>> >> > - baz without special accommodations, and
>> >> > - quux at depth -30.
>> >> > - cor buffer-locally with default depth
>> >> 
>> >> I like this, i think i can implement only the "local" part.
>> >> But of course, only part of :multi.
>> >> 
>> >> If i can get rid of `:multi` i can implement this, but it will
>> >> look
>> >> somewhat ugly:
>> >> 
>> >>   :hook+ (foo-mode . '((bar 90 t)))
>> >
>> > So what is the outcome of this discussion?  Are you working on an
>> > updated patch, or should I install the last one you posted?
>> 
>> I believe there was a reasonable doubt whether we need some of the
>> keywords at all from the initial patch.  So my vote would be to hold
>> back from that option for now, and figure out what would make sense
>> to
>> add to the core.
>
> Figure out how?
>
> AFAIU, the latest round of comments just brought up an issue with
> :hook+, and the rest didn't cause any objections?  Why not install
> them?

AFAIU, the keywords are considered useless and perhaps unnecessary, and
actually, they are, most of them can be useless and redundant or
confusing, but to remember, most of these keywords are ideas and
concepts that people asked for in use-package and could not be
implemented due to lack of time or had to be eliminated.

Based on the comments here and in emacs-devel, the only keyword i think
should be in core would be :hook+.

And this is based on a recent comment in use-package bug tracker on github:

---
  I myself have a wrapper around use-package for various reasons and
  I'll be adding support for this as I don't like having things like:

    :config
    ;; TODO: neo/use-package could support dept in :hook
    (add-hook 'after-init-hook 'neo/desktop-restore 99) ; :hook doesn't support depth

  but if it were supported by use-package it could benefit more people.
---

Currently, I'm trying to rewrite :hook+ to make it more familar to
add-hook (and see if it's possible to merge it with :hook).

So, I'll be sending a better patch when I have something.

-- 
- E.G via GNU Emacs Android port.




This bug report was last modified 17 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.