Closed kamoii closed 1 month ago
Hey, in the second operation, the secondary selection did not include the tailing "!". That's why the "?" was inserted before it.
@DogLooksGood
I was thinking that it might be more intuitive if the grabbed region were expanded to include the !
when one is added at the end. What do you think?
Well, I think there's no good way to force it. When we append at each line, we are actually recording a macro which can contain any operation. The secondary selection is a built-in thing in Emacs, its overlay simply won't expand.
@DogLooksGood How about before applying the macro, place a marker at the end of the grabbed region, and after applying, if the position of the marker is beyond the end of the grabbed region, extending the grabbed region. There are still some edge cases, but I believe this approach would work well for most scenarios, including the case mentioned.
You can do grab during the recording, I guess there will be a lot edge cases. I think the best way to achieve what you said, is to tweak how secondary selection was created.
@DogLooksGood Thanks for your advice. Didn't know secondary-selection is just an overlay. Following code solves my issue.
(eval-after-load 'mouse
;; Re-define `mouse-secondary-overlay` to make it rear-advance
(setq mouse-secondary-overlay
(let ((ol (make-overlay (point-min) (point-min) nil nil t)))
(delete-overlay ol)
(overlay-put ol 'face 'secondary-selection)
ol)))
After selecting multiple lines with
line
and usinggrab
, if you then performline
+append
+ some input, the content added to the last line of the grabbed region extends beyond the grabbed region. The following video demonstrates adding ! to the end after selecting two lines withline
twice. If you add another ?, it gets inserted before the ! at the end of the second line.Kooha-2024-03-31-03-58-43.webm
Is this behavior intentional, or is it a bug?