clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.55k stars 645 forks source link

Use more basic buffer major mode in special buffers #3220

Open Invertisment opened 2 years ago

Invertisment commented 2 years ago

Hey. I'm an evil-mode user and something that bothers me is that I can't go to cider-inspector and use f{ key to jump to first curly paren.

This happens because cider-inspector (and others derived modes in CIDER) are implemented in a specific way that prevents all evil-mode repeats and jumps. This goes the same for Test-Summary mode and other CIDER modes.

j and k keys work and to use <M-5> I have to move my fingers from home row. I think that pressing Alt+5 Ctrl+N to move five lines down is moving too many fingers.

But what's more interesting is that cider-result is read-only but it isn't implemented using these Emacs's special modes and it allows to jump around. REPL mode doesn't fall into this category because it's allowed to edit the buffer. Main mode allows to edit the buffer too.

Is your feature request related to a problem? Please describe.

The problem with this is that I tried to use add-hook to enable motion-state of evil-mode but when I use it on cider-inspector then it switches the mode back on immediately. This makes it so that I can't apply evil-mode's bindings at all.

Describe the solution you'd like

I would like you to consider implementing these modes (or providing an alternative) that would allow to conditionally not use Emacs's special modes. I really like how basic the result-mode is and I would like that it could be somehow used in here too.

One of the more basic solutions would probably be to allow editing in all of the modes. What are we preventing ourselves from? We already know that we shouldn't edit there. That would break the keys that you defined but it's still something to think about. As one wise man have said: "You can tell a kid not to put a spoon in a blender and turn it on and they'll remember that for the rest of their lives". Source: https://youtu.be/aSEQfqNYNAc?t=201 So... I'm not too happy of what Emacs gives in this mode. It prevents me from doing what I want to do. The function that creates cider-inspect is called derive which means it's an inheritance, as in Java. And it means that as a programmer I can't change what it is.

Describe alternatives you've considered

I tried to do add-hook and I tried to manually enable the motion-state by calling the function from the GUI. The function resets the bindings to what I would want to work with (I think that I'd then bind the keys myself if it would work) but as the mode reloading hook happens it resets the mode and removes my enabled motion-state. Basically this means that if I go into a child element of cider-inspector using then my motion-state is replaced by cider-inspector major mode which is special-mode of Emacs and which doesn't have f{ and 5j evil-mode motion keys.

I know it's a lot to ask but Conjure in Neovim doesn't have much of the functionality that CIDER has and Emacs's "way" is to move my fingers away from the home row (namely click Ctrl and Alt all the time). It's fine to click Ctrl and Alt once in a while but I don't think it's a good way to work.

Additional context I use Spacemacs

bbatsov commented 2 years ago

I don't use evil-mode, so it's hard for me to comment on what's the best course of action here. I'm open to suggestions, as long as they are not going to add complexity or degrade the existing experience.

Invertisment commented 2 years ago

I also tried to change the cider-inspector mode to use cider-mode instead of the special mode (then restarting cider to test it and so on) but I think I didn't know what I was doing and it didn't work. So I'm not even sure how to make it work so that it could bind the keys from the start. i.e. I don't know how to make it work even in the way that would break all modes.