greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, and more.

Home Page:https://www.racket-mode.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

usaoc opened this issue · comments

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.

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.

  • Manually: If point is after the thing, I C-SPACE, and move before the thing. Or vice versa.
  • With something like the expand-region package: Point is always before the start of the thing, mark always after.
  • Other 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. 🤷

I'm open to other ideas.

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.

That's reasonable. Will do....