[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles 287491d0a0 124/225: Add WIP support for per-a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles 287491d0a0 124/225: Add WIP support for per-action durations |
Date: |
Wed, 12 Jan 2022 08:59:01 -0500 (EST) |
branch: elpa/evil-goggles
commit 287491d0a0fc626912b0201dc1556da0ffbbb478
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Add WIP support for per-action durations
---
evil-goggles.el | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 69 insertions(+), 2 deletions(-)
diff --git a/evil-goggles.el b/evil-goggles.el
index bf8a99da33..414b46c485 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -89,10 +89,11 @@ otherwise it will just appear and disappear."
(sit-for evil-goggles-duration))
(delete-overlay ov))))
-(defun evil-goggles--pulse-overlay (ov background)
+;; TODO dur should not be optional
+(defun evil-goggles--pulse-overlay (ov background &optional dur)
"Pulse the overlay OV with the BACKGROUND color."
(let* ((pulse-delay 0.03)
- (pulse-iterations (round evil-goggles-duration pulse-delay)))
+ (pulse-iterations (round (or dur evil-goggles-duration) pulse-delay)))
(ignore pulse-iterations) ;; silence compile warning Unused lexical
variable
(set-face-attribute 'evil-goggles--pulse-face nil :background background)
(pulse-momentary-highlight-overlay ov 'evil-goggles--pulse-face)))
@@ -191,6 +192,72 @@ displayed while its running."
(move-overlay o (overlay-start o) (+ len (overlay-end o))))
(move-overlay o (overlay-start o) (- (overlay-end o) len) ))))
+(defmacro evil-goggles--with-after-goggles2 (beg end face dur &rest body)
+ (declare (indent 4) (debug t))
+ `(evil-goggles--with-hint-on ,beg ,end (progn ,@body)
+ (evil-goggles--show-overlay ,beg ,end ,face ,dur
+ ,@body)))
+
+(defun evil-goggles--show-or-pulse-overlay (ov face dur)
+ (if evil-goggles-pulse
+ (evil-goggles--pulse-overlay ov (evil-goggles--face-background face)
dur) ;; pulse the overlay
+ (overlay-put ov 'face face))) ;; just put the face on the overlay
+
+(defmacro evil-goggles--with-hint-on (beg end body1 &rest body2)
+ (declare (indent 3) (debug t))
+ `(if (and (not evil-goggles--on) (evil-goggles--show-p ,beg ,end))
+ (let ((evil-goggles--on t))
+ ,@body2)
+ ,body1))
+
+(defmacro evil-goggles--with-no-hint (&rest body)
+ (declare (indent 0) (debug t))
+ `(let ((evil-goggles--on t))
+ ,@body))
+
+(defmacro evil-goggles--with-before-goggles2 (beg end face dur &rest body)
+ (declare (indent 4) (debug t))
+ `(evil-goggles--with-hint-on ,beg ,end (progn ,@body)
+ (if (eq evil-this-type 'block)
+ (evil-goggles--show-block-overlay ,beg ,end ,face ,dur)
+ (evil-goggles--show-overlay ,beg ,end ,face ,dur))
+ ,@body))
+
+(defmacro evil-goggles--show-overlay (beg end face dur &rest body)
+ "Show overlay from BEG to END with face FACE for DUR seconds.
+
+If BODY is non-nil, run BODY before removing the overlay. The overlay
+will be adjusted if BODY modifies the text in it."
+ (declare (indent 4) (debug t))
+ `(let ((ov (evil-goggles--make-overlay ,beg ,end 'insert-behind-hooks
'(evil-goggles--overlay-insert-behind-hook))))
+ (unwind-protect
+ (progn
+ (evil-goggles--show-or-pulse-overlay ov ,face ,dur)
+ ,@body
+ (sit-for ,dur))
+ (delete-overlay ov))))
+
+(defun evil-goggles--show-block-overlay (beg end face dur)
+ "Show overlay from BEG to END with face FACE for DUR seconds.
+
+Pulsing the overlay isn't supported.
+Running code while the hint is on isn't supported."
+ ;; NOTE both of the limitation stated above can likely be addressed
+ ;; if needed
+ (let ((ovs)
+ (overlay-face `(:background ,(evil-goggles--face-background face))))
;; TODO drop this var
+ (unwind-protect
+ (progn
+ ;; create multiple overlays, one for each line in the block
+ (evil-apply-on-block (lambda (line-beg line-end)
+ (add-to-list 'ovs
+ (evil-goggles--make-overlay
line-beg line-end 'face overlay-face)))
+ beg end nil)
+ ;; TODO add support for pulsing a vertical block
+ ;; (dolist (ov ovs) (evil-goggles--show-or-pulse-overlay ov face
dur))
+ (sit-for evil-goggles-duration))
+ (mapcar 'delete-overlay ovs))))
+
(defun evil-goggles--funcall-interactively (f &rest args)
"Call F with ARGS interactively.
- [nongnu] elpa/evil-goggles 02d649ccde 101/225: Enable undo/redo by default, it's no longer experimental, (continued)
- [nongnu] elpa/evil-goggles 02d649ccde 101/225: Enable undo/redo by default, it's no longer experimental, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 1ffd97d6b8 102/225: add support for evil-nerd-commenter, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 33ea1247a7 109/225: Add helper to make evil-goggles use magit-diff-* faces, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles e14b865d80 114/225: Don't ignore foreground color when not pulsing. Fix #16, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 856cb548c3 123/225: Define per-action durations, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 8b3889332c 126/225: Use new funcs/macros which support duration per operation, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 90da624f36 115/225: Improve docs, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 92d614e731 119/225: Display the hint after indenting and "replacing with register" #7, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles c7e3f6ff17 116/225: Remove incorrectly commited snippet, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 4777cd7849 121/225: Show hint after indenting, not before #7, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 287491d0a0 124/225: Add WIP support for per-action durations,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles f5e98355f4 135/225: Use one function for `evil-paste-after` and `evil-paste-before` advices, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d705bef9d4 134/225: Fix CI failing, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles f6519214b8 149/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 5db6848df8 154/225: Undo adds should show a blocking hint, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 440324a1ed 161/225: Silence compilation warning for unused lexical variable, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 3dce5937ac 166/225: Pulsing is no longer experimental, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 4d4465fd59 168/225: Improve logic deciding whether to pulse or not, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 3b874c7630 178/225: Set mark advice: show hint on whitespace-only lines, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ca18c944ed 179/225: Show hint on start/stop record macro, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 943382b367 194/225: Add hints for surround, commentary, nerd commenter, ELPA Syncer, 2022/01/12