Hi, it seems like Cider has some kind of feature to aid in selecting/marking text. I'm using evil. How can I disable it?
it's hard to describe because it feels like it's a bug, where if I try to select a region of some sort and then move my cursor around, the current selection just does a bunch of arbitrary things
Yeah so it seems to happen whenever there's an unbalanced paren...
Doesn't seem like much to go off of. Maybe it's a function that's being advised?
It's reproducible with my config, I can try using vanilla emacs. All I have to do is have an unmatched parens somewhere and it'll start doing the funky selection/unselect behavior
I see! Is there a reason why you want selection to behave normally before you've balanced your parens? For me, having unmatched parens is a broken state that I'll want to fix before I do anything else, but maybe selecting regions is part of your workflow to balance them again?
yes, because I use evil, I still haven't migrated my workflow to use any of the structural editing packages since evil is "good enough". I'm trying to just focus on learning Clojure first before having to also learn new editing keybindings
I believe Common Lisp doesn't behave this way, it's only with Cider it seems
So yes, any idea what's causing this? Is it indeed Cider adding some kind of advice?
Or is it that Paredit or some structural package is getting enabled automatically without me realizing it?
Ok, so I wasn't able to replicate with just Cider and vanilla emacs
I would highly recommend using something like paredit even when beginning to learn, because it helps a lot - but I can also see why it may feel overly restrictive in the beginning. I promise, it's actually just your highly opinionated future best friend, though! 🙌
You can check what other modes are enabled with C-h m (or the evil equivalent) to double-check, but I believe CIDER doesn't come with any structural editing out of the box and those packages (like Paredit) need to be installed and enabled explicitly.
It would be interesting to check if you still experience the same behaviour if you kill the CIDER session and disable cider-mode!
> Ok, so I wasn't able to replicate with just Cider and vanilla emacs Interesting!
Yeah, something else is causing this. I guess I should try installing evil next. Ugh this is annoying
When experiencing the issue, what modes do you have enabled?
I have a 2000 line init file
Only God knows
You can check in the buffer by pressing C-h m. It will only show you the modes that are currently enabled, not unrelated modes from your config.
Also, I don't disagree with you about Paredit, I'm actually wanting to ween off of evil
It's hard though, it's been over a decade
In addition to any hooks its parent mode 'prog-mode' might have run,
this mode runs the hook 'clojure-mode-hook', as the final or
penultimate step during initialization.
Global minor modes enabled: Age-Encryption All-The-Icons-Completion
Auto-Encryption Beframe Blink-Cursor Column-Number
Dirvish-Override-Dired Doom-Modeline Electric-Indent Evil-Commentary
Evil-Goggles Evil Evil-Snipe-Override File-Name-Shadow
Global-Auto-Revert Global-Eldoc Global-Evil-Collection-Unimpaired
Global-Evil-Surround Global-Font-Lock Global-Hl-Line Joe/Evil-Space
Magit-Auto-Revert Marginalia Pixel-Scroll-Precision Recentf Save-Place
Savehist Show-Paren Transient-Mark Undelete-Frame
Undo-Fu-Session-Global Vertico Which-Key WinnerActually, I get the same behavior if i'm in emacs mode (pressing C-z while in evil mode)
So if I do a mark and then move the cursor down eventually I get the same odd behavior
here's another interesting thing. It only happens if I jack in to cider. If I just open a clj and unbalance a paren, I don't get this behavior.
I could ping Batsov but I don't want to bother him
> here's another interesting thing. It only happens if I jack in to cider. If I just open a clj and unbalance a paren, I don't get this behavior. That's pretty curious! Does the list of enabled modes change from before you jack in, to after?
That's a good idea, let me see if there's a difference
┬─[joe@flowjoe-f37:/tmp]─[03:53:21 PM] ╰─>$ diff -u a.txt b.txt
Nope
> Nope Ah, dang!
I don't know anything about evil packages, but from skimming the repo's README, I could imagine that evil-surround might affect your selections based on the programming language you're in. But if it changes when jacking in, that seems less likely. Still, it's worth disabling that mode manually and seeing if it resolves the issue
I'm not sure it has anything to do with evil now because it happens in emacs mode as well
But it does seem like it's some random package causing this
It says it's a global minor mode, right? So I could imagine it doesn't get disabled automatically when entering Emacs mode. Is it still enabled when you enter Emacs mode?
It should be getting disabled. Surround isn't about selections though. It's about adding delimiters around text objects. I could check
But yeah, seems like i'd have to go through a process of elimination
So you don't get this behavior I'm describing then?
Where I select lines and as I move up or down, if there are unbalanced parens, my selection gets all screwed up, deselecting and selecting other random things
It does seem to be related to some kind of package conflict, cause I couldn't replicate with vanilla emacs + clojure-mode + cider
> But yeah, seems like i'd have to go through a process of elimination Yeah, this is usually the most surefire way of finding the culprit! Definitely not the fastest, but when all else fails, this is my goto for those hard-to-debug, weird behaviour issues
> So you don't get this behavior I'm describing then? No, this has never happened to me:/ I use a pretty plain vanilla setup, though
Thanks for the help @sophie.bosio
Sure thing! Hope it works out! 🙌
If the issue is fixed, then great! If not, it's worth checking out what other modes you have enabled with C-h m (or the evil equivalent) and disabling them one by one to find the culprit. Sometimes I've been surprised by weird behaviour stemming from a sneaky global minor mode that's activated way up in my config, like in a hook somewhere.
I haven't encountered this with Cider. You should probably check which commands are actually being executed when you use those key bindings.
I haven't bound anything. I'm just doing normal movement inside a clj buffer. Both emacs mode and evil visual mode have the same problem. I'll start visual mode, start moving my cursor and after moving around for a bit, my selection just does something weird and selects something completely different
Put another way, when I describe the keys I'm pressing, it's just showing what I have bound. I guess emacs maybe has a way to get a full stack trace per key press, I can investigate that
I have a pretty vanilla setup, and I would just doubt that cider is doing anything interesting there, as I use C-SPC + movement commands very frequently in clojure and have not noticed any weird behavior.
(the only janky behavior I had with the default cider settings were the tooltips, so I have that disabled)
It feels like something about Cider is trying to auto-select matching parens
I'm trying to search for vars that I can toggle but I haven't found anything yet
Let me try vanilla emacs with only cider
I never get tired of repeating: folks, please learn how to use the built-in profiler. It is a life-saver and it's great for diagnosing such issues. The only annoying thing I ever had with it is that it doesn't automatically expand all the nodes, forcing you to go one by one. So I wrote this helper:
(defun profiler-report-expand-all ()
"Expand all entries in the profiler report recursively."
(interactive)
(thread-last
(buffer-list)
(seq-filter
(lambda (b)
(string-match-p
"\\*\\(CPU\\|Memory\\)-Profiler-Report.*\\*"
(buffer-name b))))
(seq-do
(lambda (b)
(with-current-buffer b
(goto-char (point-min))
(while (not (eobp))
(profiler-report-expand-entry)
(profiler-report-next-entry))
(goto-char (point-min)))))))
I run it on the profiler-report-mode-hook with a timer, like this:
(add-hook! 'profiler-report-mode-hook
(run-with-timer
0.1 nil
#'profiler-report-expand-all))And right when I tried profiling.. the issue went away... so weird...