[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-exchange 7f1436b781 14/46: highlight the area marked
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-exchange 7f1436b781 14/46: highlight the area marked to exchange |
Date: |
Thu, 6 Jan 2022 03:59:51 -0500 (EST) |
branch: elpa/evil-exchange
commit 7f1436b7818ca2052a56b3222f4b088224188bd9
Author: Dewdrops <v_v_4474@126.com>
Commit: Dewdrops <v_v_4474@126.com>
highlight the area marked to exchange
---
evil-exchange.el | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/evil-exchange.el b/evil-exchange.el
index d269a1a5f0..04fd826c84 100644
--- a/evil-exchange.el
+++ b/evil-exchange.el
@@ -61,8 +61,25 @@
'sexp)
:group 'evil-exchange)
+(defcustom evil-exchange-highlight-face 'highlight
+ "Face used to highlight marked area."
+ :type 'sexp
+ :group 'evil-exchange)
+
(defvar evil-exchange-position nil "Text position which will be exchanged")
+(defvar evil-exchange-overlays nil "Overlays used to highlight marked area")
+
+
+(defun evil-exchange-highlight (beg end)
+ (let ((o (make-overlay beg end nil t nil)))
+ (overlay-put o 'face evil-exchange-highlight-face)
+ (add-to-list 'evil-exchange-overlays o)))
+
+(defun evil-exchange-remove-overlays ()
+ (mapc 'delete-overlay evil-exchange-overlays)
+ (setq evil-exchange-overlays nil))
+
;;;###autoload
(autoload 'evil-exchange "evil-exchange"
"Exchange two regions with evil motion." t)
@@ -75,7 +92,12 @@
(end-marker (copy-marker end nil)))
(if (null evil-exchange-position)
;; call without evil-exchange-position set: store region
- (setq evil-exchange-position (list beg-marker end-marker type))
+ (progn
+ (setq evil-exchange-position (list beg-marker end-marker type))
+ ;; highlight area marked to exchange
+ (if (eq type 'block)
+ (evil-apply-on-block #'evil-exchange-highlight beg end nil)
+ (evil-exchange-highlight beg end)))
;; secondary call: do exchange
(cl-destructuring-bind
(orig-beg orig-end orig-type) evil-exchange-position
@@ -89,14 +111,16 @@
(insert-rectangle curr-rect)
(goto-char beg-marker)
(insert-rectangle orig-rect)))
- (setq evil-exchange-position nil))
+ (setq evil-exchange-position nil)
+ (evil-exchange-remove-overlays))
;; 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))))))
+ (setq evil-exchange-position nil)
+ (evil-exchange-remove-overlays))))))
;; place cursor on beginning of line
(when (and (evil-called-interactively-p) (eq type 'line))
(evil-first-non-blank)))
@@ -106,6 +130,7 @@
"Cancel current pending exchange."
(interactive)
(setq evil-exchange-position nil)
+ (evil-exchange-remove-overlays)
(message "Exchange cancelled"))
;;;###autoload
- [nongnu] elpa/evil-exchange cbd31e6a73 34/46: remove [Experimental] label for cx bindings, (continued)
- [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, 2022/01/06
- [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 <=
- [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
- [nongnu] elpa/evil-exchange 19b4b6277e 29/46: Merge pull request #8 from Dewdrops/cross-buffer, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-exchange 9d59144066 30/46: improve doc, ELPA Syncer, 2022/01/06