mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-25 23:10:47 -08:00
bind-keys fixes related to
GitHub-reference: https://github.com/jwiegley/use-package/issues/482
This commit is contained in:
parent
3850281f88
commit
a4d2e77961
2 changed files with 39 additions and 14 deletions
|
|
@ -219,14 +219,7 @@ Accepts keyword arguments:
|
|||
|
||||
The rest of the arguments are conses of keybinding string and a
|
||||
function symbol (unquoted)."
|
||||
;; jww (2016-02-26): This is a hack; this whole function needs to be
|
||||
;; rewritten to normalize arguments the way that use-package.el does.
|
||||
(if (and (eq (car args) :package)
|
||||
(not (eq (car (cdr (cdr args))) :map))
|
||||
(not keymap))
|
||||
(setq args (cons :map (cons 'global-map args))))
|
||||
|
||||
(let ((map keymap)
|
||||
(let (map
|
||||
doc
|
||||
prefix-map
|
||||
prefix
|
||||
|
|
@ -237,11 +230,14 @@ function symbol (unquoted)."
|
|||
;; Process any initial keyword arguments
|
||||
(let ((cont t))
|
||||
(while (and cont args)
|
||||
(if (cond ((eq :map (car args))
|
||||
(if (cond ((and (eq :map (car args))
|
||||
(not prefix-map))
|
||||
(setq map (cadr args)))
|
||||
((eq :prefix-docstring (car args))
|
||||
(setq doc (cadr args)))
|
||||
((eq :prefix-map (car args))
|
||||
((and (eq :prefix-map (car args))
|
||||
(not (memq map '(global-map
|
||||
override-global-map))))
|
||||
(setq prefix-map (cadr args)))
|
||||
((eq :prefix (car args))
|
||||
(setq prefix (cadr args)))
|
||||
|
|
@ -261,6 +257,8 @@ function symbol (unquoted)."
|
|||
(when (and menu-name (not prefix))
|
||||
(error "If :menu-name is supplied, :prefix must be too"))
|
||||
|
||||
(unless map (setq map keymap))
|
||||
|
||||
;; Process key binding arguments
|
||||
(let (first next)
|
||||
(while args
|
||||
|
|
@ -275,12 +273,13 @@ function symbol (unquoted)."
|
|||
|
||||
(cl-flet
|
||||
((wrap (map bindings)
|
||||
(if (and map pkg (not (memq map '(global-map override-global-map))))
|
||||
(if (and map pkg (not (memq map '(global-map
|
||||
override-global-map))))
|
||||
`((if (boundp ',map)
|
||||
(progn ,@bindings)
|
||||
,(macroexp-progn bindings)
|
||||
(eval-after-load
|
||||
,(if (symbolp pkg) `',pkg pkg)
|
||||
'(progn ,@bindings))))
|
||||
',(macroexp-progn bindings))))
|
||||
bindings)))
|
||||
|
||||
(append
|
||||
|
|
|
|||
|
|
@ -1638,7 +1638,7 @@
|
|||
(bind-key "f" #'w3m-lnum-print-this-url w3m-y-prefix-map nil)
|
||||
(bind-key "t" #'w3m-print-this-url w3m-y-prefix-map nil)))))
|
||||
|
||||
(ert-deftest use-package-test/482 ()
|
||||
(ert-deftest use-package-test/482-1 ()
|
||||
(match-expansion
|
||||
(use-package simple
|
||||
:bind-keymap ("C-t " . my/transpose-map)
|
||||
|
|
@ -1654,6 +1654,32 @@
|
|||
(bind-keys :package simple :map my/transpose-map
|
||||
("w" . transpose-words)))))
|
||||
|
||||
(ert-deftest use-package-test/482-2 ()
|
||||
(match-expansion
|
||||
(use-package simple
|
||||
:bind (:prefix-map my/transpose-map
|
||||
:prefix "C-t"
|
||||
("w" . transpose-words)))
|
||||
`(progn
|
||||
(unless (fboundp 'transpose-words)
|
||||
(autoload #'transpose-words "simple" nil t))
|
||||
(bind-keys :package simple
|
||||
:prefix-map my/transpose-map
|
||||
:prefix "C-t"
|
||||
("w" . transpose-words)))))
|
||||
|
||||
(ert-deftest use-package-test/482-3 ()
|
||||
(match-expansion
|
||||
(bind-keys :package simple
|
||||
:prefix-map my/transpose-map
|
||||
:prefix "C-t"
|
||||
("w" . transpose-words))
|
||||
`(progn
|
||||
(defvar my/transpose-map)
|
||||
(define-prefix-command 'my/transpose-map)
|
||||
(bind-key "C-t" 'my/transpose-map nil nil)
|
||||
(bind-key "w" #'transpose-words my/transpose-map nil))))
|
||||
|
||||
(ert-deftest use-package-test/538 ()
|
||||
(match-expansion
|
||||
(use-package mu4e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue