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

>>>>> Eli Zaretskii <eliz@gnu.org> writes:

>> From: Marc Fargas <telenieko@telenieko.com>
>>
>> -- Variable: after-make-frame-functions
>> An abnormal hook run by ‘make-frame’ after it created the frame.
>> Each function in ‘after-make-frame-functions’ receives one
>> argument, the frame just created.
>> 
>> This hook cannot be configured with `use-package' :hook keyword as it
>> does not end in `-hook'.

> 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))))

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





  reply	other threads:[~2024-08-26 18:47 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 [this message]
2024-08-31 10:08     ` Eli Zaretskii
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=m2cylvktoi.fsf@gnu.org \
    --to=johnw@gnu.org \
    --cc=72818@debbugs.gnu.org \
    --cc=eliz@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.