kmacro-x

a fork of vifon's kmacro-x
git clone https://git.trogloxene.org/kmacro-x.git
Log | Files | Refs | README | LICENSE

commit eae6121dd6d53ed0d2a9b1f475db5ba6f6f7ea51
parent da859b6b8b31c4fdfd3028996a02e5a70d9fff6b
Author: andsy10 <andsy1016@gmail.com>
Date:   Thu,  8 Oct 2026 00:46:55 +0800

Add commands to remove cursors

Diffstat:
Mkmacro-x-mc.el | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/kmacro-x-mc.el b/kmacro-x-mc.el @@ -343,6 +343,35 @@ If region is active, merely deactivate it instead." ;; `C-g' command anyway. (keyboard-quit))) +(defun kmacro-x-mc--unmark (&optional backwards) + "Remove the outermost fake cursor in `kmacro-x-mc-mode'. + +If BACKWARDS is non-nil, removes the first fake cursor in +`kmacro-x-mc-cursors' (i.e. the outermost one created with +`kmacro-x-mc-mark-previous'). Otherwise removes the last one. + +Used internally by `kmacro-x-mc-unmark-next' and +`kmacro-x-mc-unmark-previous'." + (unless kmacro-x-mc-mode + (user-error "kmacro-x-mc-mode is not active")) + (cancel-kbd-macro-events) + (let ((ov (car (if backwards + kmacro-x-mc-cursors + (last kmacro-x-mc-cursors))))) + (if (kmacro-x-mc--main-cursor-p ov) + (message "No more cursors to remove") + (delete-overlay ov) + (setq kmacro-x-mc-cursors (delq ov kmacro-x-mc-cursors))))) + +(defun kmacro-x-mc-unmark-next () + "Delete next fake cursor." + (interactive) + (kmacro-x-mc--unmark)) + +(defun kmacro-x-mc-unmark-previous () + "Delete previous fake cursor." + (interactive) + (kmacro-x-mc--unmark t)) (defvar kmacro-x-mc-mode-map (let ((map (make-sparse-keymap)))