[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles f79c03ba62 108/225: Experimental: add support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles f79c03ba62 108/225: Experimental: add support for pulsing, new option`evil-goggles-pulse' |
Date: |
Wed, 12 Jan 2022 08:59:00 -0500 (EST) |
branch: elpa/evil-goggles
commit f79c03ba6274ba61d1301b793122dab6fff8da53
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Experimental: add support for pulsing, new option`evil-goggles-pulse'
---
evil-goggles.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 46 insertions(+), 6 deletions(-)
diff --git a/evil-goggles.el b/evil-goggles.el
index af16dfae37..4a112e8cf5 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -44,11 +44,24 @@
:type 'number
:group 'evil-goggles)
+(defcustom evil-goggles-pulse (display-graphic-p)
+ "If t, the overlay hint will pulse rather than appear and disapper.
+
+Default is t for graphic displays, nil otherwise"
+ :type 'boolean
+ :group 'evil-goggles)
+
(defface evil-goggles-default-face
'((t (:inherit region)))
- "Evil-goggles generic face."
+ "Evil-goggles default face."
:group 'evil-goggles)
+(defface evil-goggles--pulse-face nil
+ "Temporary face used when pulsing.
+
+This is needed because the pulse package expects to receive a face, it
+can't work with input such as (backgound . \"red\")."
+ :group 'evil-goggles)
(defun evil-goggles--show (beg end face)
"Show overlay in region from BEG to END with FACE.
@@ -59,25 +72,52 @@ otherwise - a region."
(evil-goggles--show-block beg end face)
(evil-goggles--show-region beg end face)))
+(autoload 'pulse-momentary-highlight-overlay "pulse")
+
(defun evil-goggles--show-region (beg end face)
- "Show overlay in region from BEG to END with FACE."
- (let ((ov (evil-goggles--make-overlay beg end 'face face)))
+ "Show overlay in region from BEG to END with FACE.
+
+The overlay will either pulse if variable `evil-goggles-pulse' is t or
+appear and disappear."
+ (let ((ov (evil-goggles--make-overlay beg end))
+ (bg (evil-goggles--face-background face)))
(unwind-protect
- (sit-for evil-goggles-duration)
+ (progn
+ (if evil-goggles-pulse
+ (evil-goggles--pulse-overlay ov bg) ;; pulse the overlay
+ (overlay-put ov 'face `(:background ,bg))) ;; just put the
background color on the overlay
+ (sit-for evil-goggles-duration))
(delete-overlay ov))))
+(defun evil-goggles--pulse-overlay (ov background)
+ "Pulse the overlay OV with the BACKGROUND color."
+ (let* ((pulse-delay 0.03)
+ (pulse-iterations (round 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)))
+
(defun evil-goggles--show-block (beg end face)
"Show overlay in blcok from BEG to END with FACE."
- (let ((ovs))
+ (let ((ovs)
+ (overlay-face `(:background ,(evil-goggles--face-background face))))
(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 face)))
+ (add-to-list 'ovs
+ (evil-goggles--make-overlay
line-beg line-end 'face overlay-face)))
beg end nil)
(sit-for evil-goggles-duration))
(mapcar 'delete-overlay ovs))))
+(defun evil-goggles--face-background (face)
+ "Return the background of FACE or use a fallback.
+
+If the given FACE doesn't have a background, then fallback to the
+background of 'evil-goggles-default-face, then 'region."
+ (face-background face nil '(evil-goggles-default-face region)))
+
(defun evil-goggles--make-overlay (beg end &rest properties)
"Make overlay in region from BEG to END with PROPERTIES."
(let ((ov (make-overlay beg end)))
- [nongnu] elpa/evil-goggles 9927490983 042/225: Update README.md, (continued)
- [nongnu] elpa/evil-goggles 9927490983 042/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 08da44cf83 057/225: Add the evil-goggles face, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ef1cad8f3a 064/225: Re-add paste and fill-and-move, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 179c3002f2 071/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 904fc39728 072/225: Add doc for evil-goggles-use-diff-faces, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles e65aa39749 083/225: Add support for block paste, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 685e3714a5 090/225: Handle a specific u/redo case when the list has 2 connecting items, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 1e9ebe5e4c 095/225: Extend support for u/redo after some text is changed., ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 221a5ed8ea 098/225: Add support for Emacs 24 by not relying on funcall-interactively, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles aaa93841f9 103/225: Update evil-goggles.el, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles f79c03ba62 108/225: Experimental: add support for pulsing, new option`evil-goggles-pulse',
ELPA Syncer <=
- [nongnu] elpa/evil-goggles 9fa3d448ca 112/225: Update "Recent Significant Changes" section in README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 219d93e125 118/225: Add support for displaying the hint after the operation, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles c5c49d7965 127/225: Use different duration for before/after hints, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 5c313522cf 128/225: Don't call deprecated functions, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 03cb67fc4c 125/225: Remove duplicated line, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 70ed667698 131/225: Fix compile warnings, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ea0102bcf5 133/225: Use "post" hint when commenting, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 3f6dd85657 151/225: Update README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 5bd77428e3 142/225: Cleanup internal API for showing a vertical hint once, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles c515477fd4 160/225: Clarify docs for evil-goggles-async-duration and evil-goggles-blocking-duration, ELPA Syncer, 2022/01/12