Skip to content

Commit f0600b4

Browse files
committed
Option to merge undo boundaries
1 parent 758d6f1 commit f0600b4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

move-dup.el

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
;; (move-dup-mode)
5353

5454
;;; Code:
55+
56+
(defgroup move-dup nil
57+
"Move or duplicate text."
58+
:group 'editing
59+
:prefix "move-dup")
60+
61+
(defcustom move-dup-undo-auto-amalgamate t
62+
"Whether a series of move-dup command should only require one undo to undo all."
63+
:type 'boolean
64+
:group 'move-dup)
65+
66+
(defun md-merge-undo-boundaries-maybe ()
67+
(when move-dup-undo-auto-amalgamate
68+
(undo-auto-amalgamate)))
69+
5570
(defun md-ensure-rectangle ()
5671
"Normalizes the selection by making sure it's always a rectangle.
5772
@@ -117,6 +132,7 @@ forward N lines; otherwise backward."
117132

118133
(defun md-move-line-or-region (n)
119134
"Decides whether a line or selection should be moved N lines."
135+
(md-merge-undo-boundaries-maybe)
120136
(if (use-region-p)
121137
(md-move-region n)
122138
(md-move-line n)))
@@ -163,6 +179,7 @@ line or selection."
163179
"Decides whether a line or selection should be duplicated.
164180
165181
DIRECTION must be one of \"up\" or \"down\"."
182+
(md-merge-undo-boundaries-maybe)
166183
(if (use-region-p)
167184
(md-duplicate-region direction)
168185
(md-duplicate-line direction)))

0 commit comments

Comments
 (0)