manojm321 / elfeed-dashboard

A frontend for elfeed
GNU General Public License v3.0
81 stars 9 forks source link

Key combinations don't work with evil bindings #13

Open gab-dev opened 2 years ago

gab-dev commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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