Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key combinations don't work with evil bindings #13

Open
gab-dev opened this issue Mar 17, 2022 · 2 comments
Open

Key combinations don't work with evil bindings #13

gab-dev opened this issue Mar 17, 2022 · 2 comments
Labels

Comments

@gab-dev
Copy link

gab-dev commented Mar 17, 2022

Hello, I'm using Emacs 27.2, evil 1.14.0 and I'm using elfeed with elfeed-org and elfeed-goodies.
In elfeed-dashboard when I try to use something like
#+KEYMAP: be | elfeed-dashboard-query "+unread +blog +emacs"
I get the following error:
Wrong type argument: keymapp, evil-backward-word-begin

What I've tried so far has been to disable global evil-mode and use the local-mode as hook only for the modes where I really need it. The only problem with that is that I want evil-mode active on org-mode so:
(add-hook 'org-mode-hook 'evil-local-mode)
but elfeed-dashboard also rely on org-mode so I have this:
(add-hook 'elfeed-dashboard-mode '(lambda () (evil-local-mode -1)))
This setup works with single key bindings but not with multiple ones.

I've also tried something like this but no luck :(
(add-hook 'org-mode-hook '(lambda () (if (not (eq major-mode 'elfeed-dashboard-mode)) (evil-local-mode) )))

Is there any workaround for this issue?
Thanks

@EFLS
Copy link

EFLS commented Mar 17, 2022

I don't think you need to disable evil, rather turn it to emacs state with something like (evil-set-initial-state 'elfeed-dashboard-mode 'emacs)

You can then use the keybindings you have configured in the dashboard itself.

Later, when editing the dashboard file with elfeed-dashboard-edit, you'll be in Org-mode rather than Elfeed-dashboard-mode, and your Evil bindings should work.

@gab-dev
Copy link
Author

gab-dev commented Mar 19, 2022

I've tried your solution but it works only with one key binding.

My dirty solution so far has been to manually disable evil-local-mode inside elfeed-dashboard--get-keymap

(defun elfeed-dashboard--get-keymap (key)
    "Return the right keymap depending on the number of chars in the KEY.
     Assumes a max KEY length of 2."
    (evil-local-mode -1) ; <--- MY FIX
    (if (> (length key) 2)
	(user-error "Key exceeds a max length of 2: %s" key))
    (if (eq (length key) 1)
	elfeed-dashboard-mode-map
      ;; 2 letter key
      (let* ((prefix-key (substring key 0 1))
	     (binding (local-key-binding (kbd prefix-key))))
	(unless binding
	  (define-key elfeed-dashboard-mode-map (kbd prefix-key) (make-sparse-keymap)))
	(key-binding (kbd prefix-key))))
    )

@manojm321 manojm321 added the evil label Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants