[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles 6d3247db6c 173/225: Enable pulsing by default
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles 6d3247db6c 173/225: Enable pulsing by default on graphical displays |
Date: |
Wed, 12 Jan 2022 08:59:06 -0500 (EST) |
branch: elpa/evil-goggles
commit 6d3247db6c05b7550e80f05238111f415a7ab569
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Enable pulsing by default on graphical displays
Pulsing is enabled if `display-graphic-p` return t.
---
evil-goggles.el | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/evil-goggles.el b/evil-goggles.el
index e80e6f695b..b75322bad8 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -46,7 +46,6 @@
;;; Code:
(require 'evil)
-(require 'cl-lib)
(defcustom evil-goggles-duration 0.200
"Time in floating seconds the goggles hint should last.
@@ -77,10 +76,20 @@ If nil, the value of `evil-goggles-duration' will be used."
:type 'number
:group 'evil-goggles)
-(defcustom evil-goggles-pulse nil
- "If t, the hint will pulse, rather than just appear and disapper."
- :type 'boolean
- :group 'evil-goggles)
+(defcustom evil-goggles-pulse #'display-graphic-p
+ "Controls whether to pulse the hint or just appear and disapper.
+
+If t, the hint will pulse always.
+If nil, the hint will never pulse.
+This variable can also hold a custom function which should return t or nil.
+
+The default is to pulse if the display is graphical, otherwise not."
+ :group 'evil-goggles
+ :type '(choice
+ (const :tag "Always" nil)
+ (const :tag "Never" t)
+ (function :tag "If graphical display" #'display-graphic-p)
+ (function :tag "Custom function")))
(defface evil-goggles-default-face
'((t (:inherit region)))
@@ -96,6 +105,12 @@ can't work with input such as (backgound . \"red\")."
(autoload 'pulse-momentary-highlight-overlay "pulse")
+(defun evil-goggles--pulse-p ()
+ "Return whether to pulse or not, depending on variable `evil-goggles-pulse'."
+ (if (functionp evil-goggles-pulse)
+ (funcall evil-goggles-pulse)
+ evil-goggles-pulse))
+
(defun evil-goggles--pulse-overlay (ov background dur)
"Pulse the overlay OV with the BACKGROUND color for DUR duration.
@@ -180,8 +195,8 @@ non-nil, else for `evil-goggles-duration' seconds."
"Show or pulse overlay OV with face FACE.
DUR is used only when pulsing.
-The overlay is pulsed if variable `evil-goggles-pulse' is t and the
-FACE is appropriate for pulsing, i.e. it has a background."
+The decision to pulse or not is made by function
+`evil-goggles--should-blink-or-pulse'."
(pcase (evil-goggles--should-blink-or-pulse face)
(`(blink ,blink-face)
(overlay-put ov 'face blink-face))
@@ -194,7 +209,7 @@ FACE is appropriate for pulsing, i.e. it has a background."
The decision is made based on the value of `evil-goggles-pulse'.
If the FACE has no background, pulsing is not supported, hence the
-decision is to blink. If the face has no foreground and/or background,
+decision is to blink. If the face has no foreground and/or background,
this function tries to make the most appropriate decision whether to
pulse or not, and whether to use the given FACE or use the fallback
face `evil-goggles-default-face'.
@@ -204,10 +219,10 @@ This function returns a list - either ('blink face) or
('pulse bg)."
(bg (face-background face nil t)))
(cond
;; pulse enabled and the face has a bg - pulse with the given face's bg
- ((and evil-goggles-pulse bg)
+ ((and (evil-goggles--pulse-p) bg)
`(pulse ,bg))
;; pulse enabled and the face has no bg or fg - pulse with the default
face's bg
- ((and evil-goggles-pulse (null bg) (null fg))
+ ((and (evil-goggles--pulse-p) (null bg) (null fg))
`(pulse ,(face-background 'evil-goggles-default-face nil t)))
;; pulse disabled or face has fg only - show the hint with given face
((and (null bg) (null fg))
@@ -271,7 +286,7 @@ hint, i.e. it will be displayed for
`evil-goggles-blocking-duration'
rather than `evil-goggles-async-duration'"
(if (or blocking force-vertical-hint)
(let ((evil-goggles--force-block blocking))
- ;; use blocking hint for blocks, async hint doesn't support blocks
+ ;; use blocking hint for vertial blocks, async hint doesn't support
vertial blocks
(evil-goggles--with-blocking-hint beg end face))
(evil-goggles--with-async-hint beg end face)))
- [nongnu] elpa/evil-goggles be3acc9142 152/225: Merge branch 'per-action-duration', (continued)
- [nongnu] elpa/evil-goggles be3acc9142 152/225: Merge branch 'per-action-duration', ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 787b8dcabd 159/225: Fix macro indentation, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 52e77e9a3a 146/225: Simplify customization: remove duration options for each advised command, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 9a1ddbda3e 164/225: Add helper function on inherit from diff-refine-* faces, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles b611a140a2 162/225: Highlight the whole line when pasting a whole line, not just the text, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 690dd7aba3 165/225: Pulse only if the face defines a background, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d1683b3353 167/225: Pulse if the face inherits a background, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d4b0ea224d 169/225: Add tests covering the decision whether to pulse or not, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles b620c7512c 170/225: Update README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 2670fdf664 172/225: Revert `evaporate` overlay property, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 6d3247db6c 173/225: Enable pulsing by default on graphical displays,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles e2cccdf0c0 174/225: Tweak Makefile, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles a1a62d2b56 175/225: Fix failing CI by using latest evil-tests.el, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 1fd103dc13 177/225: evil-goggles--show-p: allow the "whitespace-only" check to be skipped, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles aad4b44727 181/225: evil-goggles--show-hint: fix value of evil-goggles--force-block, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles deab4966d7 183/225: README: reverse NEWS, newest on top, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles a7340dbb49 185/225: Run travis tests on Emacs 25.3, set `load-prefer-newer` to t in tests, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 89fcaebb6e 187/225: Add hint for `c`, `C` and `S` actions #18, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 57f45c2582 189/225: Temporarily disable change hint until #19 is resolved, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles c0afde5d66 202/225: Remove depracated variable, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 2e5452b6a5 216/225: Revert "evil-goggles--show-p: no need to check evil-inhibit-operator-value", ELPA Syncer, 2022/01/12