1

I'm running a distribution of spacemacs and am currently working in clojure's cider debugger, and an issue I've run into is that several of the cider--debug-mode keybindings are shadowed by evil-mode. I've tried a few things with my configuration so far, including adding a hook on the cider--debug-mode which defines a keybinding to allow me to use the keys for their intended purpose again, which didn't work, and I've also simply called (evil-mode) in the lambda as well since just calling the function with no args will toggle the mode. However I've continued to experience the shadowed keybinds regardless. When I manually disable evil-mode before beginning debugging it works as intended, so it seems to me almost as if the hook isn't running properly.

Why might that be?

2 Answers 2

4

No (evil-mode) called non-interactively does not toggle. It unconditionally switches evil-mode on. You have to call (evil-mode -1) in your program to switch evil-mode off.

See the doc of define-minor-mode:

The toggle command takes one optional (prefix) argument. If called interactively with no argument it toggles the mode on or off. A positive prefix argument enables the mode, any other prefix argument disables it. From Lisp, an argument of toggle toggles the mode, whereas an omitted or nil argument enables the mode. This makes it easy to enable the minor mode in a major mode hook, for example. If doc is nil, the macro supplies a default documentation string explaining the above.

1
  • 1
    This gave me an almost-correct solution. I used (add-hook 'cider--debug-mode-hook '(lambda () (if (bound-and-true-p cider--debug-mode) (evil-mode -1) (evil-mode 1)))) and it seemed to work.
    – Suskeyhose
    Commented Jan 27, 2018 at 7:33
2

Here's an actual solution to the problem you've encountered:

(defun my-cider-debug-setup ()
  (evil-make-overriding-map cider--debug-mode-map 'normal)
  (evil-normalize-keymaps))

(add-hook 'cider--debug-mode-hook 'my-cider-debug-setup)

It will make debug keys work with CIDER while not disabling Evil.

4
  • Could you also elaborate wrt the question ("Why might that be?")?
    – Drew
    Commented Jan 26, 2018 at 15:33
  • That has been answered thoroughly in the other solution.
    – wasamasa
    Commented Jan 26, 2018 at 17:33
  • Unfortunately when I added this to my configuration it seemed to have no effect whatsoever. One odd things I noticed however was that it seemed that I either couldn't evaluate the function, or that M-x was unable to find it. In any case I tried to inline it as a lambda and it still didn't work properly.
    – Suskeyhose
    Commented Jan 27, 2018 at 6:21
  • I'm on a stable version of CIDER, so who knows, maybe they changed things meanwhile.
    – wasamasa
    Commented Jan 27, 2018 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.