From 487fbd4a6503b2267128391fd8cbcb6c1eb100a1 Mon Sep 17 00:00:00 2001 From: 45mg <45mm.cartridge421@slmail.me> Date: Sat, 4 May 2024 09:54:08 +0000 Subject: [PATCH] meow--select: don't spam mark-ring For example, without this change, calling `meow-next-word` repeatedly on a selection created by `meow-mark-word` will repeatedly push the position at the beginning of the selection onto the mark-ring. This can quickly overflow the mark-ring, and it makes `pop-to-mark-command` a lot more annoying to use. --- meow-command.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/meow-command.el b/meow-command.el index ec56b82..81c8e66 100644 --- a/meow-command.el +++ b/meow-command.el @@ -64,7 +64,8 @@ The direction of selection is MARK -> POS." (meow--cancel-selection)) (let ((sel-type (car selection)) (mark (cadr selection)) - (pos (caddr selection))) + (pos (caddr selection)) + to-push) (if meow--selection (unless (equal meow--selection (car meow--selection-history)) (push meow--selection meow--selection-history)) @@ -73,7 +74,11 @@ The direction of selection is MARK -> POS." meow--selection-history)) (goto-char (if backward mark pos)) (when sel-type - (push-mark (if backward pos mark) t t) + (setq to-push (if backward pos mark)) + ;; set the mark; push it to the mark ring only if we're moving it + (if (eq to-push (mark t)) + (set-mark to-push) + (push-mark to-push t t)) (setq meow--selection selection)))) (defun meow--select-without-history (selection)