greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
682 stars 93 forks source link

Wrapping a region with pairs should not move to end of region #686

Closed usaoc closed 11 months ago

usaoc commented 11 months ago

I’m not sure if this is intentional, but it seems unnatural to me that wrapping a region with pairs can cause the point to move. In racket-hash-lang-mode, if you mark a region and insert an opening delimiter, the region will be wrapped, as in Smartparens. Unlike in Smartparens, though, the point seems to always move to the end of region. I think the Smartparens behavior makes more sense (keep the point at where it was). Again, I’m not sure if this is intentional, so I’m opening this as a question.

greghendershott commented 11 months ago

Because I feel like this little feature is a necessary evil and detour (as opposed to me wanting to go down the entire long road of an ideal auto-pair package), I didn't think about this too long.

But my (small) thinking was:

Point and mark can be set in various ways.

Given this variety, it seemed like point wasn't necessarily a precious value to preserve. Instead, better just to move it consistently somewhere. For which, I arbitrarily chose the end. :shrug:

I'm open to other ideas.

usaoc commented 11 months ago

Yes, most, if not all, of the times I use wrapping with C-M-SPC (in #lang racket, that is), so preserving the point is important to me. The workflow is like this: suppose I’m looking at an expression,

|(some s-exp)

I may think that this expression deserves some further processing, so I’ll C-M-SPC, (, and insert more things. Moving the point to the end doesn’t seem useful if you use wrapping like this—you’ll have to C-M-b C-M-d anyway. Preserving the point is arguably the most natural option.

greghendershott commented 11 months ago

That's reasonable. Will do....