mickeynp / combobulate

Structured Editing and Navigation in Emacs with Tree-Sitter
GNU General Public License v3.0
945 stars 54 forks source link

Suggestion: would it be possible to "move point back" after cancelling expand region? #13

Closed realcomplex closed 1 year ago

realcomplex commented 1 year ago

I'm trying to use combobulate to replace the expand-region package, and mostly this is working very well. Still there are one or two things on my wish-list.

However, I want to make it clear that I already appreciate the package a lot as it stands, and don't take any additional features as a given. If you think that these suggestions will only lead to feature-creep and aren't aligned with the goals of combobulate, I have the fullest respect for that.

With that said, a general annoyance with using combobulate to expand the region (i.e. combobulate-mark-node-dwim, bound to M-h) is how "irreversible" it feels, especially compared to expand-region.el. Once you expand the region, there is no way to "go back" or shrink the region, and even if you just deactivate the region to potentially start from scratch, the point has been moved. This means you have to pop the mark (C-u C-SPC) one or several (!) times to get back to where you started.

One concrete feature that would nicely address the latter problem would be to ensure that the point is returned to where it was before expanding the region when a keyboard-quit (C-g) is detected immediately after combobulate-mark-node-dwim. As far as my skills go this wouldn't be trivial to implement, and I imagine one might have to enter some kind of minor mode with its own keymap upon combobulate-mark-node-dwim in order to "catch" the keyboard-quit, but I'm by no means an expert and maybe I'm missing something.

Another cool feature would be the ability to "shrink" the region, but this would again entail keeping track of some kind of state in terms of where the point was located before the region was expanded. If you rather prefer to keep the operations of combobulate as pure and state-less as possible, I understand.

Thanks for the great package, it's really useful!

mickeynp commented 1 year ago

Feature suggestions are always welcome. I like the idea of undoing/redoing and snapping back. I'll see about adding it soon!

mickeynp commented 1 year ago

Can you give the development branch a shot? Typing M-h now engages the choice UI so you can cycle through matches or C-g to quit out and return point.

realcomplex commented 1 year ago

Just tested, and this is great actually! What an improvement; this makes it much more user-friendly. Thanks for the incredibly quick response! Feel free to close.

mickeynp commented 1 year ago

Glad you like it!