[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 472586b9d4: Eliminate global variable, better wi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 472586b9d4: Eliminate global variable, better window handling |
Date: |
Mon, 21 Feb 2022 11:57:25 -0500 (EST) |
branch: externals/embark
commit 472586b9d40976efe9827399deff3954f1570c71
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Eliminate global variable, better window handling
---
avy-embark-collect.el | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/avy-embark-collect.el b/avy-embark-collect.el
index 37a29dccdd..fbfd46a263 100644
--- a/avy-embark-collect.el
+++ b/avy-embark-collect.el
@@ -33,9 +33,6 @@
(require 'embark)
(eval-when-compile (require 'subr-x))
-(defvar avy-embark-collect--initial-window nil
- "Window that was selected before jumping.")
-
(defun avy-embark-collect--candidates ()
"Collect all visible Embark collect candidates."
(let (candidates)
@@ -53,23 +50,25 @@
(push (cons (point) wnd) candidates))))))
(nreverse candidates)))
-(defun avy-embark-collect--window-restore ()
- "Return to window selected before jumping."
- (select-window avy-embark-collect--initial-window))
-
(defun avy-embark-collect--act (pt)
"Act on the completion at PT."
- (goto-char pt)
- (cl-letf (((alist-get :always embark-post-action-hooks)
- (append (alist-get :always embark-post-action-hooks)
- '(avy-embark-collect--window-restore))))
- (embark-act)))
+ (unwind-protect
+ (save-excursion
+ (goto-char pt)
+ (embark-act))
+ (select-window (cdr (ring-ref avy-ring 0)))
+ t))
+
+(defun avy-embark-collect--choose (pt)
+ "Choose on the completion at PT."
+ (unwind-protect (push-button pt)
+ (select-window (cdr (ring-ref avy-ring 0)))
+ t))
(defun avy-embark-collect--jump (action dispatch-alist)
"Jump to a visible Embark Collect candidate and perform ACTION.
Other actions are listed in the DISPATCH-ALIST."
(interactive)
- (setq avy-embark-collect--initial-window (selected-window))
(avy-with avy-embark-collect-choose
(let ((avy-action action)
(avy-dispatch-alist dispatch-alist))
@@ -79,7 +78,7 @@ Other actions are listed in the DISPATCH-ALIST."
(defun avy-embark-collect-choose ()
"Choose an Embark Collect candidate."
(interactive)
- (avy-embark-collect--jump #'push-button
+ (avy-embark-collect--jump #'avy-embark-collect--choose
'((?e . avy-embark-collect--act)
(?p . avy-action-goto))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/embark 472586b9d4: Eliminate global variable, better window handling,
ELPA Syncer <=