From 5471d1ae03b6b8f3ed75b6d7738142df08c3cb90 Mon Sep 17 00:00:00 2001 From: 45mg <45mg@no.mail> Date: Wed, 4 Dec 2024 13:15:34 +0000 Subject: [PATCH] feat(commands): add meow-pop-or-unpop-to-mark Since `meow-search` allows us to search in the other direction using `-` (`negative-argument`), we should have similar behavior for the command that pops the mark: `-` will unpop the mark. --- meow-command.el | 18 +++++++++++++++++- meow-var.el | 9 +++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/meow-command.el b/meow-command.el index e6d3539..3eb312a 100644 --- a/meow-command.el +++ b/meow-command.el @@ -1562,10 +1562,26 @@ To search backward, use \\[negative-argument]." Before jump, a mark of current location will be created." (interactive) (meow--cancel-selection) - (unless (member last-command '(meow-pop-to-mark-command meow-unpop-to-mark-command)) + (unless (member last-command '(meow-pop-to-mark-command meow-unpop-to-mark-command meow-pop-or-unpop-to-mark)) (setq mark-ring (append mark-ring (list (point-marker))))) (pop-to-mark-command)) +(defun meow-pop-or-unpop-to-mark (arg) + "Call `meow-pop-to-mark' or `meow-unpop-to-mark', depending on ARG. + +With a negative prefix ARG, call `meow-unpop-to-mark'. Otherwise, call +`meow-pop-to-mark.' + +See also `meow-pop-or-unpop-to-mark-repeat-unpop'." + (interactive "p") + (if (or (and meow-pop-or-unpop-to-mark-repeat-unpop + (eq last-command 'meow-unpop-to-mark)) + (< arg 0)) + (progn + (setq this-command 'meow-unpop-to-mark) + (meow-unpop-to-mark)) + (meow-pop-to-mark))) + (defun meow-pop-to-global-mark () "Alternative command to `pop-global-mark'. diff --git a/meow-var.el b/meow-var.el index f58db9d..d6f198f 100644 --- a/meow-var.el +++ b/meow-var.el @@ -200,6 +200,15 @@ the `word', `symbol' and `sexp' things, respectively.") :group 'meow :type 'boolean) +(defcustom meow-pop-or-unpop-to-mark-repeat-unpop nil + "Non-nil means that calling `meow-pop-or-unpop-to-mark' +after calling it with a negative argument unpops the mark again. + +This variable is meant to be similar to `set-mark-command-repeat-pop'." + :group 'meow + :type 'boolean) + + (defcustom meow-keypad-describe-delay 0.5 "The delay in seconds before popup keybinding descriptions appear."