[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles 636b263361 215/225: Make async overlay cleanu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles 636b263361 215/225: Make async overlay cleanup more robust, without using pre-command-hook |
Date: |
Wed, 12 Jan 2022 08:59:10 -0500 (EST) |
branch: elpa/evil-goggles
commit 636b263361d872bdd1e03ab0612de5313d90e85a
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Make async overlay cleanup more robust, without using pre-command-hook
The overlay is cleaned-up correctly even if evil-goggles--vanish is
interrupted mid-flight, for example by the user pressing C-g.
---
README.md | 1 +
evil-goggles.el | 22 +++++++++++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 31b4e90865..e4421e9f78 100644
--- a/README.md
+++ b/README.md
@@ -178,6 +178,7 @@ evil-goggles-record-macro-face
## NEWS - Recent Significant Changes
+- [Jul 01, 2018] Make async hint cleanup more robust
- [Jun 01, 2018] Refactor code to not use :around advice-s, which was a source
of edge-case-issues
- [Feb 05, 2018] Show hint on start/stop macro recording
- [Dec 02, 2017] Pulsing hints is no longer experimental
diff --git a/evil-goggles.el b/evil-goggles.el
index 6d05c180d2..c60f802daf 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -321,13 +321,17 @@ which take BEG and END as their first and second
arguments."
(defvar evil-goggles--async-ov nil)
(defun evil-goggles--vanish (&rest _)
- "Remove the async overlay and cancel the timer."
- (when (timerp evil-goggles--timer)
- (cancel-timer evil-goggles--timer)
- (setq evil-goggles--timer nil))
- (when evil-goggles--async-ov
- (delete-overlay evil-goggles--async-ov)
- (setq evil-goggles--async-ov nil)))
+ "Remove the async overlay, cancel the timer, unregister from
‘pre-command-hook’."
+ ;; user's C-g during this function execution should not result in
+ ;; this function getting removed from pre-command-hook/run-at-time
+ (with-local-quit
+ (when (overlayp evil-goggles--async-ov)
+ (delete-overlay evil-goggles--async-ov)
+ (setq evil-goggles--async-ov nil)
+ (when (timerp evil-goggles--timer)
+ (cancel-timer evil-goggles--timer)
+ (setq evil-goggles--timer nil)
+ (remove-hook 'pre-command-hook 'evil-goggles--vanish)))))
(defun evil-goggles--show-async-hint (beg end)
"Show blocking hint from BEG to END."
@@ -337,6 +341,8 @@ which take BEG and END as their first and second arguments."
(unwind-protect
;; show the overlay
(evil-goggles--show-or-pulse-overlay ov face dur)
+ ;; any command by the user should prematurely cleanup the overlay
+ (add-hook 'pre-command-hook #'evil-goggles--vanish)
;; remove the overlay with a timer
(setq
evil-goggles--async-ov ov
@@ -575,7 +581,6 @@ Argument YANK-HANDLER is the yank hanler."
:require 'evil-goggles
(if evil-goggles-mode
(progn
- (add-hook 'pre-command-hook #'evil-goggles--vanish)
;; add advice
(dolist (command-cfg evil-goggles--commands)
(let ((cmd (car command-cfg))
@@ -585,7 +590,6 @@ Argument YANK-HANDLER is the yank hanler."
(when (symbol-value switch)
(advice-add cmd (if after :after :before) advice)))))
;; remove advice
- (remove-hook 'pre-command-hook 'evil-goggles--vanish)
(dolist (command-cfg evil-goggles--commands)
(let ((cmd (car command-cfg))
(advice (plist-get (cdr command-cfg) :advice)))
- [nongnu] elpa/evil-goggles 5bd77428e3 142/225: Cleanup internal API for showing a vertical hint once, (continued)
- [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
- [nongnu] elpa/evil-goggles 674a1be5aa 188/225: Merge branch 'hint-only-when-command-is-interactive'. Close #18, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 946598059f 204/225: Fix compilation warnings, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles b756edf31e 182/225: Show hint on u/redo after inserting text with "O", ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 6d2ce52faa 200/225: Add hint for `m`, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 8aa26e9671 205/225: CI: run package-lint, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 77a8bb1785 207/225: Update README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 87722a5b46 210/225: Add hint for `D`, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d7876e6566 218/225: Drop unnecessary helper macro, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 636b263361 215/225: Make async overlay cleanup more robust, without using pre-command-hook,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles 12cfb80230 104/225: Use separate config, face and advice for nerd-commenter and commentary. Refs #13, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 75d124851f 156/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d4b3d873dc 155/225: Update CI setup to run evil's tests unaltered, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 761abb7b2f 145/225: Hint duration should be configured via three variables, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles f282263af4 120/225: Show visual hint after shift left/right, not before #7, ELPA Syncer, 2022/01/12
- [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