[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles fec8dfd7b5 088/225: Simplify undo/redo checks
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles fec8dfd7b5 088/225: Simplify undo/redo checks |
Date: |
Wed, 12 Jan 2022 08:58:57 -0500 (EST) |
branch: elpa/evil-goggles
commit fec8dfd7b565dcd8083ada5c9d3371999b9f0aa8
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Simplify undo/redo checks
---
evil-goggles.el | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/evil-goggles.el b/evil-goggles.el
index 8d9bc6faf4..71ea46bbbe 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -245,25 +245,29 @@ ARG are the arguments of the original function."
(advice-remove 'primitive-undo 'evil-goggles--primitive-undo-advice)))
(defun evil-goggles--primitive-undo-advice (orig-fun n list)
- (let* ((ulist (cl-remove-if #'null (mapcar #'evil-goggles--undo-elt list)))
- (ulist-len (length ulist))
- (single-text-block-was-removed
- (and (eq 1 ulist-len) (eq 'text-removed (caar ulist))))
- (single-text-block-was-inserted
- (and (eq 1 ulist-len) (eq 'text-added (caar ulist))))
- (uelt (car ulist))
- (beg (nth 1 uelt))
- (end (nth 2 uelt)))
+ (let ((undo-item (evil-goggles--get-undo-item list)))
;; show hint on the text which will be removed before undo/redo removes it
- (when (and single-text-block-was-inserted (evil-goggles--show-p beg end))
- (evil-goggles--show beg end 'evil-goggles-undo-redo-remove-face))
+ (pcase undo-item
+ (`(text-added ,beg ,end)
+ (when (evil-goggles--show-p beg end)
+ (evil-goggles--show beg end 'evil-goggles-undo-redo-remove-face))))
+ ;; call the undo/redo function
(funcall orig-fun n list)
;; show hint on the text which will be added after undo/redo addes it
- (when (and single-text-block-was-removed (evil-goggles--show-p beg end))
- (evil-goggles--show beg end 'evil-goggles-undo-redo-add-face))))
+ (pcase undo-item
+ (`(text-removed ,beg ,end)
+ (when (evil-goggles--show-p beg end)
+ (evil-goggles--show beg end 'evil-goggles-undo-redo-add-face))))))
+
+(defun evil-goggles--get-undo-item (list)
+ "Process LIST and return the first item if it's only one, or nil."
+ (let* ((processed-list
+ (cl-remove-if #'null (mapcar #'evil-goggles--undo-elt list))))
+ (when (eq 1 (length processed-list))
+ (car processed-list))))
(defun evil-goggles--undo-elt (elt)
(pcase elt
- [nongnu] elpa/evil-goggles 253613ce66 039/225: Fix check of evil-last-paste, (continued)
- [nongnu] elpa/evil-goggles 253613ce66 039/225: Fix check of evil-last-paste, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 788c73d505 041/225: Make lighter configurable, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 97498ef1ba 050/225: Clarify package should be on Melpa, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles bf6f836609 056/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 10512f5b3b 054/225: Check evil-mode is on with bound-and-true-p, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ae77a5c6f0 067/225: Replace the boilerplate in evil-goggles-faces.el with a macro, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 0f6254f548 070/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 902270eea8 084/225: Show a vertical visual hint for vertical text objects., ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 879114abea 085/225: Don't show the overlay when evil-mc is displaying multiple fake cursors, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 0c713e7462 086/225: Add experimental support for undo/redo, off by default, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles fec8dfd7b5 088/225: Simplify undo/redo checks,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles fd85719817 089/225: Improve doc strings, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 0585f4d657 097/225: Try to avoid Travis seg-faults by running emacs in batch mode, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 142e0a9f2b 105/225: Remove unused option, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ee7fafb858 107/225: Remove debugs, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 5404dcfaf8 106/225: Don't quote inherited faces so face-background works, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 13fd7e348c 110/225: Disable pulsing by default, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 49c1318098 113/225: Update README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 6bf281c788 117/225: Simplify macro, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 9f4a9dec5a 122/225: Fix comment, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 04b93b8564 157/225: Use alternative pulse duration calculation, ELPA Syncer, 2022/01/12