elfeed-dashboard icon indicating copy to clipboard operation
elfeed-dashboard copied to clipboard

Key combinations don't work with evil bindings

Open gab-dev opened this issue 3 years ago • 2 comments
trafficstars

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

gab-dev avatar Mar 17 '22 06:03 gab-dev

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.

EFLS avatar Mar 17 '22 15:03 EFLS

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))))
    )

gab-dev avatar Mar 19 '22 07:03 gab-dev