[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-exchange 1e3ba07be4 18/46: Merge pull request #5 from
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-exchange 1e3ba07be4 18/46: Merge pull request #5 from fbergroth/remove-transpose-regions |
Date: |
Thu, 6 Jan 2022 03:59:51 -0500 (EST) |
branch: elpa/evil-exchange
commit 1e3ba07be4cac67cd7e54e9169b1dcbd0b44d5de
Merge: d35ebe9a7d 0539868f46
Author: Dewdrops <v_v_4474@126.com>
Commit: Dewdrops <v_v_4474@126.com>
Merge pull request #5 from fbergroth/remove-transpose-regions
Drop use of `transpose-regions`
---
evil-exchange.el | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/evil-exchange.el b/evil-exchange.el
index 843dbb611b..4f334a6a9e 100644
--- a/evil-exchange.el
+++ b/evil-exchange.el
@@ -104,27 +104,32 @@
(cond
;; exchange block region
((and (eq orig-type 'block) (eq type 'block))
- (let ((orig-rect (delete-extract-rectangle orig-beg orig-end))
- (curr-rect (delete-extract-rectangle beg-marker end-marker)))
- (save-excursion
- (goto-char orig-beg)
- (insert-rectangle curr-rect)
- (goto-char beg-marker)
- (insert-rectangle orig-rect)))
- (setq evil-exchange-position nil)
- (evil-exchange-remove-overlays))
+ (evil-exchange--do-swap beg-marker end-marker
+ orig-beg orig-end
+ #'delete-extract-rectangle
#'insert-rectangle))
;; signal error if regions incompatible
((or (eq orig-type 'block) (eq type 'block))
(error "Can't exchange block region with non-block region."))
;; exchange normal region
(t
- (transpose-regions orig-beg orig-end beg end)
- (setq evil-exchange-position nil)
- (evil-exchange-remove-overlays))))))
+ (evil-exchange--do-swap beg-marker end-marker
+ orig-beg orig-end
+ #'delete-and-extract-region #'insert))))))
;; place cursor on beginning of line
(when (and (evil-called-interactively-p) (eq type 'line))
(evil-first-non-blank)))
+(defun evil-exchange--do-swap (curr-beg curr-end orig-beg orig-end extract-fn
insert-fn)
+ (let ((orig-text (funcall extract-fn orig-beg orig-end))
+ (curr-text (funcall extract-fn curr-beg curr-end)))
+ (save-excursion
+ (goto-char orig-beg)
+ (funcall insert-fn curr-text)
+ (goto-char curr-beg)
+ (funcall insert-fn orig-text)))
+ (setq evil-exchange-position nil)
+ (evil-exchange-remove-overlays))
+
;;;###autoload
(defun evil-exchange-cancel ()
"Cancel current pending exchange."
- [nongnu] elpa/evil-exchange 25b3eda13b 12/46: doc fix, (continued)
- [nongnu] elpa/evil-exchange 25b3eda13b 12/46: doc fix, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange d862e1c321 32/46: Add support for lispyville, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange cbd31e6a73 34/46: remove [Experimental] label for cx bindings, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 0739b4ca7c 42/46: Don't do exchange when buffer is dead., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange ac50f21b29 46/46: fix README english mistake. (#7), ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 72bf29c9fa 01/46: initial commit, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange ee17ab47fe 02/46: improve doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange ba64a66e26 11/46: correct autoloads, try to fix #2, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 3efefb1bd7 07/46: Add a Bitdeli badge to README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 37fd36065d 10/46: Merge https://github.com/Dewdrops/evil-exchange, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 1e3ba07be4 18/46: Merge pull request #5 from fbergroth/remove-transpose-regions,
ELPA Syncer <=
- [nongnu] elpa/evil-exchange 7cd34aea03 13/46: use non-advancable marker to mark the end of the region to exchange, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 7f1436b781 14/46: highlight the area marked to exchange, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange d35ebe9a7d 16/46: doc improvement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 5b0c4ab07c 20/46: add vim-compatible key bindings, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 2ae6e0a203 24/46: ignore tags, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 22d9b6ce1b 19/46: bump version and rename internal function, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 51c830b65d 21/46: better error message, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 328370e898 23/46: vim compatible bindings, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 47c017cc9a 22/46: Fix weird behaviour for adjacent areas, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange e7e3d679b9 27/46: implement exchange across buffers, ELPA Syncer, 2022/01/06