[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu 61a20a5036 1/2: corfu--teardown: Handle dead buff
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/corfu 61a20a5036 1/2: corfu--teardown: Handle dead buffer during teardown |
|
Date: |
Wed, 3 Jan 2024 09:57:38 -0500 (EST) |
branch: externals/corfu
commit 61a20a50369de2cae77d649269d3c047fbbc27ec
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
corfu--teardown: Handle dead buffer during teardown
---
corfu.el | 19 ++++++++++---------
extensions/corfu-echo.el | 2 +-
extensions/corfu-popupinfo.el | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/corfu.el b/corfu.el
index 62ae4581a6..dbdf6f1ee6 100644
--- a/corfu.el
+++ b/corfu.el
@@ -893,8 +893,7 @@ See `completion-in-region' for the arguments BEG, END,
TABLE, PRED."
;; Ensure that the tear-down runs in the correct buffer, if
still alive.
(unless completion-in-region-mode
(remove-hook 'completion-in-region-mode-hook sym)
- (with-current-buffer (if (buffer-live-p buf) buf
(current-buffer))
- (corfu--teardown)))))
+ (corfu--teardown buf))))
(add-hook 'completion-in-region-mode-hook sym)))
(defun corfu--in-region (&rest args)
@@ -1165,15 +1164,17 @@ AUTO is non-nil when initializing auto completion."
;; 4) No candidates & auto completing or initialized => Quit.
((or auto corfu--input) (corfu-quit)))))
-(cl-defgeneric corfu--teardown ()
- "Tear-down Corfu."
+(cl-defgeneric corfu--teardown (buffer)
+ "Tear-down Corfu in BUFFER, which might be dead at this point."
(corfu--popup-hide)
- (remove-hook 'window-selection-change-functions #'corfu--window-change
'local)
- (remove-hook 'window-buffer-change-functions #'corfu--window-change 'local)
- (remove-hook 'pre-command-hook #'corfu--prepare 'local)
- (remove-hook 'post-command-hook #'corfu--post-command)
(when corfu--preview-ov (delete-overlay corfu--preview-ov))
- (accept-change-group corfu--change-group)
+ (remove-hook 'post-command-hook #'corfu--post-command)
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (remove-hook 'window-selection-change-functions #'corfu--window-change
'local)
+ (remove-hook 'window-buffer-change-functions #'corfu--window-change
'local)
+ (remove-hook 'pre-command-hook #'corfu--prepare 'local)
+ (accept-change-group corfu--change-group)))
(cl-loop for (k . v) in corfu--initial-state do (set k v)))
(defun corfu-sort-length-alpha (list)
diff --git a/extensions/corfu-echo.el b/extensions/corfu-echo.el
index edc7f8f301..d93d819699 100644
--- a/extensions/corfu-echo.el
+++ b/extensions/corfu-echo.el
@@ -97,7 +97,7 @@ subsequent delay."
(corfu-echo--show (funcall fun cand))))))
(corfu-echo--cancel)))
-(cl-defmethod corfu--teardown :before (&context (corfu-echo-mode (eql t)))
+(cl-defmethod corfu--teardown :before (_buf &context (corfu-echo-mode (eql t)))
(corfu-echo--cancel))
(cl-defmethod corfu--prepare :before (&context (corfu-echo-mode (eql t)))
diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el
index ea4ce66547..2b8b2d60d6 100644
--- a/extensions/corfu-popupinfo.el
+++ b/extensions/corfu-popupinfo.el
@@ -505,7 +505,7 @@ not be displayed until this command is called again, even if
(corfu-popupinfo--hide))))
(corfu-popupinfo--hide))))
-(cl-defmethod corfu--teardown :before (&context (corfu-popupinfo-mode (eql t)))
+(cl-defmethod corfu--teardown :before (_buf &context (corfu-popupinfo-mode
(eql t)))
(corfu-popupinfo--hide)
(cl-loop for (k . v) in corfu-popupinfo--initial-state do (set k v))
(cl-callf2 assq-delete-all #'corfu-popupinfo-mode
minor-mode-overriding-map-alist))