[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64901: 29.1; use-package fails to require bind-key at runtime in com
From: |
John Wiegley |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) |
>>>>> 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
- bug#64901: 29.1; use-package fails to require bind-key at runtime in compiled files,
John Wiegley <=