use-package icon indicating copy to clipboard operation
use-package copied to clipboard

":bind (:map" doesn't work with multiple keybindings on "evil-normal-state-map"

Open alienbogart opened this issue 6 years ago • 3 comments

Why this only works for the first keybinding ("gr")?

(use-package evil  
  :init
  :bind (:map evil-normal-state-map
              ("gr" . my/sel-to-end)
              ("gl" . evil-end-of-visual-line))

  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)
  :config

  (general-unbind 'evil-normal-state-map
    :with 'my/quiet-save-buffer-only
    [remap evil-force-normal-state])
  
  (evil-mode +1))

I gives the following warning:

Error (use-package): Failed to parse package evil: use-package: evil wants arguments acceptable to the `bind-keys' macro, or a list of such values

alienbogart avatar Nov 02 '19 06:11 alienbogart

#679

Tooooommy avatar Nov 03 '19 16:11 Tooooommy

It started working for some reason. Maybe because it needed a restart? Anyway, here's the code:

(use-package evil  
  :init
  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)

  ;;;; EVIL ORG MODE ;;;
  (add-hook 'org-mode-hook 'evil-org-mode)
  (require 'evil-org-agenda)
  (evil-org-agenda-set-keys)

  :bind (:map evil-normal-state-map
              ("go"    . cool-moves/open-line-below)
              ("gO"    . cool-moves/open-line-above)
              ("gr"    . my/sel-to-end)
              ("ge"    . end-of-visual-line)
              ("zi"    . outline-show-all)
              ("C-0"   . universal-argument)
              ("C-c o" . hydra-find-file/Body)
              ("C-h"   . hydra-help/body)
              ("C-s"   . evil-search-forward)
              ("M-RET" . my/indent-Buffer)
              ("M-s"   . last-buffer)
              ("gt"    . fix-word-capitalize))

  :bind (:map evil-visual-state-map
              ("gr"    . my/sel-to-end)
              ("ge"    . end-of-visual-line)
              ("zi"    . outline-show-all)
              ("C-0"   . universal-argument)
              ("C-c o" . hydra-find-file/body)
              ("C-h"   . hydra-help/body)
              ("M-RET" . my/indent-buffer))

  :bind (:map evil-insert-state-map
              ("C-u"   . my/backward-kill-line)
              ("C-h"   . backward-delete-char)
              ("C-d"   . delete-char)
              ("C-k"   . kill-visual-lined)
              ("M-d"   . kill-word)
              ("M-f"   . forward-word)
              ("M-b"   . backward-word)
              ("C-a"   . move-beginning-of-line)
              ("C-a"   . move-end-of-line)
              ("C-c o" . hydra-find-file/body)
              ("M-RET" . my/indent-buffer))
  :config
  (general-unbind 'evil-normal-state-map
    :with 'my/quiet-save-buffer-only
    [remap evil-force-normal-state])

  (evil-mode +1))

Should I close the issue?

alienbogart avatar Nov 04 '19 01:11 alienbogart

all you need is moving :config keyword, I think.

(use-package evil  
  :init
  :bind (:map evil-normal-state-map
              ("gr" . my/sel-to-end)
              ("gl" . evil-end-of-visual-line))

  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)
  :config

  (general-unbind 'evil-normal-state-map
    :with 'my/quiet-save-buffer-only
    [remap evil-force-normal-state])
  
  (evil-mode +1))

to

(use-package evil  
  :init
  :bind (:map evil-normal-state-map
              ("gr" . my/sel-to-end)
              ("gl" . evil-end-of-visual-line))
  
  :config
  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)

  (general-unbind 'evil-normal-state-map
    :with 'my/quiet-save-buffer-only
    [remap evil-force-normal-state])
  
  (evil-mode +1))

:bind cannot interpret (setq evil-want-integration t).

conao3 avatar Feb 22 '21 15:02 conao3

OP reports that things are working now, so I'm closing this issue.

skangas avatar Nov 13 '22 19:11 skangas