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

Overrides keybindings of CIDER #61

Closed
NightMachinery opened this issue Apr 23, 2018 · 8 comments
Closed

Overrides keybindings of CIDER #61

NightMachinery opened this issue Apr 23, 2018 · 8 comments

Comments

@NightMachinery
Copy link

NightMachinery commented Apr 23, 2018

See clojure-emacs/cider#2275
They say it's evil-snipe's issue.
In short, when CIDER's debugger (it's similar to edebug, but for Clojure) is activated, it should get the 's' key, not evil-snipe.

@hlissner
Copy link
Owner

hlissner commented Apr 23, 2018

I'm not familiar with CIDER's debugger, but you can prevent evil-snipe from being enabled in certain major modes by adding it to evil-snipe-disabled-modes, or by adding turn-off-evil-snipe-mode to the appropriate hook. e.g.

;; NOTE: I'm guessing the major mode and hook names
(push 'cider-debug-mode evil-snipe-disabled-modes)
;; or
(add-hook 'cider-debug-mode-hook #'turn-off-evil-snipe-mode)

If you tell me what the appropriate major-mode is, I'll be happy to add it to evil-snipe-disabled-modes's default.

@NightMachinery
Copy link
Author

@hlissner Here is the fix (there is no major mode for the debugger):

(add-hook 'cider--debug-mode-hook (lambda ()
                                      (if (bound-and-true-p cider--debug-mode)
                                          (turn-off-evil-snipe-mode)
                                        (turn-on-evil-snipe-mode))))

Can you add it to evil-snipe? Or is the 'cider--debug-mode-hook problematic when CIDER is not loaded?

@hlissner
Copy link
Owner

hlissner commented May 2, 2018

It isn't problematic, but I am hesitant to use this solution, because this is really an issue with evil not prioritizing minor mode maps correctly (a known issue). Could you try this:

(add-hook 'cider-mode-hook #'evil-normalize-keymaps)
(add-hook 'cider--debug-mode-hook #'evil-normalize-keymaps)

And let me know if that changes your situation?

@NightMachinery
Copy link
Author

NightMachinery commented May 4, 2018

@hlissner No, it didn't work. If you think the issue is with evil, can you file a bug report? I didn't have a good experience with evil maintainers.

@hlissner
Copy link
Owner

hlissner commented May 4, 2018

A bug report already exists (juggling keymaps is a general -- and difficult -- problem), but I'm not entirely confident that it is entirely to blame either. It could also be the load-order in Spacemacs, loading cider before evil-snipe, for whatever reason.

That said, this isn't the first time evil-snipe has encroached into other plugins (like magit, mu4e, and org-agenda) and I'm looking for a reasonable way around it.

On another note: in a buffer with cider--debug-mode active, could you report to me the value of minor-mode-alist?

@hlissner hlissner added the bug label May 4, 2018
@NightMachinery
Copy link
Author

NightMachinery commented May 4, 2018 via email

@hlissner
Copy link
Owner

hlissner commented May 4, 2018

Could you show me minor-mode-alist with your workaround disabled? I need to see if evil-snipe has higher precedence than cider--debug-mode.

@hlissner
Copy link
Owner

hlissner commented Jun 7, 2021

Sorry for the tremendously late response. Looking back, I realize this is an issue inherent to how evil (and minor-mode) keymap precedence works. That is, evil-snipe-mode and cider--debug-mode are both minor modes, but evil-snipe is using evil's keybinding system to bind keys only in normal/visual states, which evil will prioritize over cider's non-evil keymaps.

With that said, this conflict is neither evil-snipe's nor cider's responsibility to resolve. At best, it may be evil's, but this is more a case of "this is how evil works", rather than a bug.

Besides the solution you came up with, the only other possible solution that comes to mind is:

(evil-define-minor-mode-key 'normal 'cider--debug-mode
  "s" #'cider-debug-mode-send-reply)

As there is no decent solution to this issue I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants