l3kn / org-fc

Spaced Repetition System for Emacs org-mode
https://www.leonrische.me/fc/index.html
GNU General Public License v3.0
254 stars 31 forks source link

`org-fc-keymap-hint` and the evil suggestions don't work as expected #76

Open alexsieusahai opened 2 years ago

alexsieusahai commented 2 years ago

Currently using spacemacs with the most up to date develop branch.

My user-config looks like this (wrt org-fc):

  (use-package hydra)
  (require 'org-fc-hydra)
  (setq org-fc-directories '($ORG_LOC))
  (require 'org-fc-keymap-hint)

  (evil-define-minor-mode-key '(normal insert emacs) 'org-fc-review-flip-mode
    (kbd "RET") 'org-fc-review-flip
    (kbd "n") 'org-fc-review-flip
    (kbd "s") 'org-fc-review-suspend-card
    (kbd "q") 'org-fc-review-quit)

  (evil-define-minor-mode-key '(normal insert emacs) 'org-fc-review-rate-mode
    (kbd "1") 'org-fc-review-rate-again
    (kbd "2") 'org-fc-review-rate-hard
    (kbd "3") 'org-fc-review-rate-good
    (kbd "4") 'org-fc-review-rate-easy
    (kbd "s") 'org-fc-review-suspend-card
    (kbd "q") 'org-fc-review-quit)

I could be totally missing something (I wouldn't doubt it) but the keybinds displayed are the default ones, not the rebinds. If you need more info or something, or don't have time to fix this (which is totally understandable), definitely let me know, thanks!

l3kn commented 2 years ago

It looks like the keymap hints only uses bindings from the org-fc-...-mode-maps of the different modes. There seems to be a way to get the keymaps created by evil-define-minor-mode-key, so one solution would be to check whether evil is installed and whether there are keymaps defined for org-fc modes, then use these instead of the default emacs ones for the keymap hints.

As a workaround you can overwrite the org-fc-...-mode-maps with your evil bindings.

I'll see if I can find some way to make this work duplicate key definitions.

alexsieusahai commented 2 years ago

Thanks for responding so fast! This suffices for me; much appreciated! Something else that's worth noting is p is also evil-mc-paste-after, which also happens when you use the config specified in your README for evil. Again, not a big deal, but I thought it was worth reporting.

l3kn commented 2 years ago

If defining the keys twice is ok for you, I'll keep the keymap-hint code as it is. Would you mind posting the code you're using to do so? Then I can add a note to the documentation and also provide an example of these duplicate bindings.

Regarding the p binding:

Do you mean the README at https://www.leonrische.me/fc/use_with_evil-mode.html ? I don't see any bindings for p there. In my personal workflow I don't mind overwriting keys that are already bound by evil because I use the org-fc-edit-mode to make changes. I've heard of some users who regularly write into cards during review, so the documentation could also include a set of key bindings that are prefixed to avoid duplication.

alexsieusahai commented 2 years ago

Ah my bad, it's a default binding for org-rate; just redefining everything in the source suffices, though. In particular, in fc-rate, after flipping a normal card for instance, there's a keybind to edit bound to p. If I use that default, then it'll go to fc-edit, and also invoke evil's paste function, which will probably break the card (depending on what's in your clipboard). Again not a huge deal, as redefining it to a key that's not occupied by evil isn't an issue.

Possibly not intended behavior however?

I personally just added a little bit onto that evil minor mode in the README to get around this for a much more pleasurable out of the box experience. I also directly modify the keybinds at 'org-fc-review-rate-map to display the correct keybinds.

  (evil-define-minor-mode-key '(normal insert emacs) 'org-fc-review-rate-mode
    (kbd "1") 'org-fc-review-rate-again
    (kbd "2") 'org-fc-review-rate-hard
    (kbd "3") 'org-fc-review-rate-good
    (kbd "4") 'org-fc-review-rate-easy
    (kbd "s") 'org-fc-review-suspend-card
    (kbd "e") 'org-fc-review-edit
    (kbd "q") 'org-fc-review-quit)