unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: John Wiegley <johnw@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: contovob@tcd.ie, 64901@debbugs.gnu.org, david@fiander.info
Subject: bug#64901: 29.1; use-package fails to require bind-key at runtime in compiled files
Date: Tue, 01 Aug 2023 14:37:51 -0700	[thread overview]
Message-ID: <m2fs52xx3k.fsf@newartisans.com> (raw)
In-Reply-To: <83mszfi28p.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 29 Jul 2023 10:52:06 +0300")

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

>> I have no further notes to add, but I would like to see that restriction
>> lifted also.

> Any suggestions for how should we go about that?

I would suggest that in the macro ‘bind-key’, we emit ‘(require ’bind-key)’. I
can see now what an oversight this was, since indeed the macro will omit code
that references a variable that may not be in scope after direct compilation:

(defmacro bind-key (key-name command &optional keymap predicate)
  (let ((namevar (make-symbol "name"))
        (keyvar (make-symbol "key"))
        (kmapvar (make-symbol "kmap"))
        (kdescvar (make-symbol "kdesc"))
        (bindingvar (make-symbol "binding")))
    `(let* ((,namevar ,key-name)
            (,keyvar ,(if (stringp key-name) (read-kbd-macro key-name)
                        `(if (vectorp ,namevar) ,namevar
                           (read-kbd-macro ,namevar))))
            (,kmapvar (or (if (and ,keymap (symbolp ,keymap))
                              (symbol-value ,keymap) ,keymap)
                          global-map))
            (,kdescvar (cons (if (stringp ,namevar) ,namevar
                               (key-description ,namevar))
                             (if (symbolp ,keymap) ,keymap (quote ,keymap))))
            (,bindingvar (lookup-key ,kmapvar ,keyvar)))
       (let ((entry (assoc ,kdescvar personal-keybindings))
             (details (list ,command
                            (unless (numberp ,bindingvar)
                              ,bindingvar))))
         (if entry
             (setcdr entry details)
           (add-to-list 'personal-keybindings (cons ,kdescvar details))))
       ,(if predicate
            `(define-key ,kmapvar ,keyvar
               '(menu-item "" nil :filter (lambda (&optional _)
                                            (when ,predicate
                                              ,command))))
          `(define-key ,kmapvar ,keyvar ,command)))))

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





  reply	other threads:[~2023-08-01 21:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27 14:51 bug#64901: 29.1; use-package fails to require bind-key at runtime in compiled files David Fiander
2023-07-27 16:52 ` Eli Zaretskii
2023-07-27 17:03   ` David Fiander
2023-07-27 17:12     ` Eli Zaretskii
2023-07-28  6:56       ` Eli Zaretskii
2023-07-28  9:28         ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-28 12:12           ` Eli Zaretskii
2023-07-28 16:55             ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-28 17:37               ` John Wiegley
2023-07-29  7:52                 ` Eli Zaretskii
2023-08-01 21:37                   ` John Wiegley [this message]
2023-08-03  8:59                     ` Eli Zaretskii
2023-08-03 22:16                       ` John Wiegley
2023-08-04  6:43                         ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2fs52xx3k.fsf@newartisans.com \
    --to=johnw@gnu.org \
    --cc=64901@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=david@fiander.info \
    --cc=eliz@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).