branch: elpa/evil-goggles
commit 219d93e125fa838e66fb7586963f8597e60a0a87
Author: Evgeni Kolev <[email protected]>
Commit: Evgeni Kolev <[email protected]>
Add support for displaying the hint after the operation
---
evil-goggles.el | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/evil-goggles.el b/evil-goggles.el
index 9b916476da..d28e432d43 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -156,16 +156,41 @@ overlay must not be displayed.")
"Show goggles overlay from BEG to END if the conditions are met.
OVERLAY-FACE is the face to use for the overlay.
-The goggles overlay will be displayed briefly before BODY is executed.
+The goggles overlay will be displayed before BODY is executed.
BODY will be executed but an overlay will not be allowed to be
displayed while its running."
(declare (indent defun) (debug t))
`(if (evil-goggles--show-p ,beg ,end)
- (let* ((evil-goggles--on t))
+ (let ((evil-goggles--on t))
(evil-goggles--show ,beg ,end ,overlay-face)
,@body)
,@body))
+(defmacro evil-goggles--with-after-goggles (beg end overlay-face &rest body)
+ "Add an overlay from BEG to END, make it visible with OVERLAY-FACE after
BODY."
+ (declare (indent defun) (debug t))
+ `(if (evil-goggles--show-p ,beg ,end)
+ (let ((evil-goggles--on t)
+ (ov (evil-goggles--make-overlay ,beg ,end 'insert-behind-hooks
'(evil-goggles--overlay-insert-behind-hook)))
+ (bg (evil-goggles--face-background ,overlay-face)))
+ (unwind-protect
+ (progn
+ (if evil-goggles-pulse
+ (evil-goggles--pulse-overlay ov bg) ;; pulse the overlay
+ (overlay-put ov 'face ,overlay-face)) ;; just put the face on
the overlay
+ ,@body
+ (sit-for evil-goggles-duration))
+ (delete-overlay ov)))
+ ,@body))
+
+(defun evil-goggles--overlay-insert-behind-hook (o afterp beg end &optional
len)
+ (when afterp
+ (if (zerop len)
+ (progn
+ (setq len (- end beg))
+ (move-overlay o (overlay-start o) (+ len (overlay-end o))))
+ (move-overlay o (overlay-start o) (- (overlay-end o) len) ))))
+
(defun evil-goggles--funcall-interactively (f &rest args)
"Call F with ARGS interactively.