use-package
use-package copied to clipboard
keybind with macro issue
I want to rebind backward-up-list
to my function generate by a macro ,but it tell me (error "use-package: web-mode wants arguments acceptable to the
bind-keys' macro, or a list of such values")`
here is my code
(defmacro web-mode-rebind-key(src dst)
`(lambda()
(interactive)
(let ((point (point)))
(unless (ignore-errors (,src) t)
(goto-char point)
(,dst)))))
(use-package web-mode
:mode ("\\.html\\'" "\\.vue\\'")
:custom
(tab-width 2)
:bind (:map web-mode-map
([remap backward-up-list] . (web-mode-rebind-key backward-up-list web-mode-element-parent))))
and if possible ,I want to generate cons
es use macro , so I can omited second backward-up-list
In this case :bind
is probably not the right tool. It accepts a form acceptable to bind-key
, not arbitrary lisp code. It is intended to make the common case easier. In particular, it makes the assumption that the commands bound come from the package itself (in this case web-mode
), because it generates autoloads for them. You want something different: you also want to define new commands as you bind them.
I think it would be better to just do what you want to do in a :config
form. That is plain lisp code that is executed after the package is loaded. You could start by making a single defun
that set up web-mode
exactly as you like, and then calling it in a :config
form. That would be easier to debug.
The answer here is to use :config
, so I'm closing this bug.