[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles 2b922512fb 199/225: Refactor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles 2b922512fb 199/225: Refactor |
Date: |
Wed, 12 Jan 2022 08:59:08 -0500 (EST) |
branch: elpa/evil-goggles
commit 2b922512fb31af8cd192fc909b2ebd730b1f3592
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Refactor
---
evil-goggles.el | 49 +++++++++++++++++++++++--------------------------
1 file changed, 23 insertions(+), 26 deletions(-)
diff --git a/evil-goggles.el b/evil-goggles.el
index d95b0ecba1..efb1b2de6c 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -131,9 +131,6 @@ background of 'evil-goggles-default-face, then 'region."
(defvar evil-goggles--force-block nil
"When non-nil, force the hint about to be shown to be a block.")
-(defvar evil-goggles--hint-on-empty-lines nil
- "When nil, the default, function `evil-goggles--show-p' will not return t
for whitespace-only regions.")
-
(defun evil-goggles--show-p (beg end)
"Return t if the overlay should be displayed in region BEG to END."
(and (not evil-inhibit-operator-value)
@@ -149,10 +146,7 @@ background of 'evil-goggles-default-face, then 'region."
(not (evil-insert-state-p))
;; don't show overlay when evil-mc has active cursors
(not (and (fboundp 'evil-mc-has-cursors-p) (evil-mc-has-cursors-p)))
- ;; don't show hint when the region has nothing but whitespace, but skip
this check if `evil-goggles--hint-on-empty-lines' is t
- (if evil-goggles--hint-on-empty-lines
- t
- (not (null (string-match-p "[^ \t\n]" (buffer-substring-no-properties
beg end)))))))
+ (not (null (string-match-p "[^ \t\n]" (buffer-substring-no-properties
beg end))))))
(defun evil-goggles--overlay-insert-behind-hook (ov afterp beg end &optional
len)
"Function which grows/shriks the overlay OV when its text changes.
@@ -308,9 +302,9 @@ OFF-BY-DEFAULT if non-nil will set the switch to `nil'"
(plist-get (alist-get command evil-goggles--commands) :face)
'evil-goggles-default-face))
-(defun evil-goggles--show-blocking-hint (beg end face)
- "Show blocking hint from BEG to END with face FACE."
- (let ((dur (or evil-goggles-blocking-duration evil-goggles-duration)))
+(defun evil-goggles--show-blocking-hint (beg end)
+ (let ((dur (or evil-goggles-blocking-duration evil-goggles-duration))
+ (face (evil-goggles--get-face this-command)))
(if (or (eq evil-this-type 'block) evil-goggles--force-block)
(evil-goggles--show-block-overlay beg end face dur)
(evil-goggles--show-overlay beg end face dur))))
@@ -318,7 +312,7 @@ OFF-BY-DEFAULT if non-nil will set the switch to `nil'"
(defun evil-goggles--generic-blocking-advice (beg end &rest _)
(when (and (called-interactively-p 'interactive)
(evil-goggles--show-p beg end))
- (evil-goggles--show-blocking-hint beg end (evil-goggles--get-face
this-command))))
+ (evil-goggles--show-blocking-hint beg end)))
;;; generic async advice
@@ -334,26 +328,29 @@ OFF-BY-DEFAULT if non-nil will set the switch to `nil'"
(delete-overlay evil-goggles--async-ov)
(setq evil-goggles--async-ov nil)))
+(defun evil-goggles--show-async-hint (beg end)
+ (let ((ov (evil-goggles--make-overlay beg end 'insert-behind-hooks
'(evil-goggles--overlay-insert-behind-hook)))
+ (dur (or evil-goggles-async-duration evil-goggles-duration))
+ (face (evil-goggles--get-face this-command)))
+ (unwind-protect
+ ;; show the overlay
+ (evil-goggles--show-or-pulse-overlay ov 'evil-goggles-default-face dur)
+ ;; remove the overlay with a timer
+ (setq
+ evil-goggles--async-ov ov
+ evil-goggles--timer (run-at-time dur
+ nil
+ #'evil-goggles--vanish)))))
+
(defun evil-goggles--generic-async-advice (beg end &rest _)
(when (and (called-interactively-p 'interactive)
(evil-goggles--show-p beg end))
- (let ((ov (evil-goggles--make-overlay beg end 'insert-behind-hooks
'(evil-goggles--overlay-insert-behind-hook)))
- (dur (or evil-goggles-async-duration evil-goggles-duration))
- (face (evil-goggles--get-face this-command)))
- (unwind-protect
- ;; show the overlay
- (evil-goggles--show-or-pulse-overlay ov 'evil-goggles-default-face
dur)
- ;; remove the overlay with a timer
- (setq
- evil-goggles--async-ov ov
- evil-goggles--timer (run-at-time dur
- nil
- #'evil-goggles--vanish))))))
+ (evil-goggles--show-async-hint beg end)))
(defun evil-goggles--generic-async-advice-1 (_ beg end &rest _)
- (when (called-interactively-p 'interactive)
- (cl-letf (((symbol-function 'called-interactively-p) (lambda (_) t)))
- (funcall 'evil-goggles--generic-async-advice beg end))))
+ (when (and (called-interactively-p 'interactive)
+ (evil-goggles--show-p beg end))
+ (evil-goggles--show-async-hint beg end)))
;;; delete
- [nongnu] elpa/evil-goggles 2932d91a6c 129/225: Remove deprecated functions, (continued)
- [nongnu] elpa/evil-goggles 2932d91a6c 129/225: Remove deprecated functions, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d3802c500f 141/225: Rename function with-no-hint => with-disabled-hint, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 888f064624 130/225: Add docstrings, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 7f30cbd73c 139/225: Fix default values, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 838aacbe33 176/225: evil-goggles--show-p: check for a single char *and* single line, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 5780bcf8cb 186/225: Show hint only when the command is called interactively #18, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 4bfc8df8b3 191/225: Remove deprecated macros, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles bb974e38d2 193/225: Add hints for `J`, `gq` and `=`, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 42051e2cb3 197/225: Keep configuration per command in a variable, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 1c72501a6f 196/225: Reduce configuration options - drop `substitute`, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 2b922512fb 199/225: Refactor,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles dac6c45aa1 214/225: Add hint for `Y', when `evil-want-Y-yank-to-eol' is t, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles bf1be3be24 018/225: Don't show overlay on whitespaces-only regions, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 36fb70d6a1 044/225: Rename option `evil-goggles-show-for` to `evil-goggles-duration`, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles c6935dc53d 099/225: Don't bundle evil-tests.el. Fix #15, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 88cb3ffa38 100/225: Fetch evil-tests.el from evil's repo. Comment out parts of it with sed. Refs #15, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 2d2011180f 111/225: Mention experimental pulse option in README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles e9b0ed0484 137/225: Tweak defaults, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ca6b5f7bfe 138/225: Rename APIs pre/post to blocking/async, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles df26adb069 153/225: Use async hints for paste, undo/redo, set mark, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 692f276434 158/225: Indentation, ELPA Syncer, 2022/01/12