commit b1a6206556d8f9d4a7522d5218094b7325ff8507 parent 83b54f219e50049ad7b61230cb8b5afd7467b9c9 Author: Wojciech Siewierski <wojciech@siewierski.eu> Date: Fri, 10 Mar 2023 12:38:38 +0100 Use a marker to save the pre-execution point position reliably Diffstat:
| M | kmacro-x-mc.el | | | 22 | ++++++++-------------- |
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/kmacro-x-mc.el b/kmacro-x-mc.el @@ -228,20 +228,14 @@ CURSOR is internally an overlay." (when defining-kbd-macro (end-kbd-macro)) (run-hooks 'kmacro-x-mc-pre-apply-hook) - (dolist (ov kmacro-x-mc-cursors) - (unless (kmacro-x-mc--main-cursor-p ov) - (kmacro-x-mc--apply-cursor ov))) - ;; Push the original point to the `mark-ring', so it's easy to - ;; return there if needed. Calculated from the original cursor's - ;; overlay boundaries which should be correct even with the text - ;; before it shifting around. Note, this is the position from - ;; before the macro was recorded, not from right after it got - ;; recorded but before it got replayed. The latter would be - ;; a little more troublesome to calculate. Definitely possible but - ;; for now I don't see any benefit in one over the other. - (push-mark (let ((ov kmacro-x-mc-main-cursor)) - (+ (overlay-start ov) - (car (overlay-get ov 'offsets))))) + (let ((marker (point-marker))) + (dolist (ov kmacro-x-mc-cursors) + (unless (kmacro-x-mc--main-cursor-p ov) + (kmacro-x-mc--apply-cursor ov))) + ;; Push the original point to the `mark-ring', so it's easy to + ;; return there if needed. + (push-mark marker) + (set-marker marker nil)) (run-hooks 'kmacro-x-mc-post-apply-hook) (kmacro-x-mc-mode 0))