emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/mct 92680c1091 05/64: completion--done: Attempt to tear


From: ELPA Syncer
Subject: [elpa] externals/mct 92680c1091 05/64: completion--done: Attempt to teardown completion in region properly
Date: Thu, 30 Dec 2021 23:57:49 -0500 (EST)

branch: externals/mct
commit 92680c1091edb8f069481c138d97fd0b91f77828
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    completion--done: Attempt to teardown completion in region properly
---
 mct.el | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/mct.el b/mct.el
index 91e2a48d4a..c9a50e536f 100644
--- a/mct.el
+++ b/mct.el
@@ -1140,15 +1140,17 @@ Meant to be added to `after-change-functions'."
 
 ;;;;;; Minor mode specification
 
-;; FIXME 2021-12-03: We need a predicate here for when we are active.
-;; It cannot be `completion-in-region-mode'.
 (defun mct--region-setup-completion-in-region ()
   "Set up Mct for `completion-in-region'."
-  ;; NOTE: Ignore the predicate in order to support orderless style.
-  ;; TODO: This override should be guarded by a customizable variable,
-  ;; since it is intrusive. See also `corfu-quit-at-boundary'.
-  (setq completion-in-region-mode--predicate (lambda () t))
-  (mct--region-live-update))
+  (if completion-in-region-mode
+      (progn
+        ;; NOTE: Ignore the predicate in order to support orderless style.
+        ;; TODO: This override should be guarded by a customizable variable,
+        ;; since it is intrusive. See also `corfu-quit-at-boundary'.
+        (setq completion-in-region-mode--predicate (lambda () t))
+        (mct--region-live-update))
+    ;; Teardown
+    (remove-hook 'after-change-functions #'mct--region-live-completions t)))
 
 ;; FIXME 2021-12-03: When using a flex style followed by tab, the
 ;; completion-in-region seems to remain active as the echo area has a
@@ -1178,6 +1180,7 @@ Meant to be added to `after-change-functions'."
   :global t
   (if mct-region-mode
       (progn
+        (advice-add #'completion--done :around #'mct--region-completion-done)
         (add-hook 'completion-list-mode-hook #'mct--setup-completion-list)
         (add-hook 'completion-in-region-mode-hook 
#'mct--region-setup-completion-in-region)
         (advice-add #'display-completion-list :around 
#'mct--display-completion-list-advice)
@@ -1185,6 +1188,7 @@ Meant to be added to `after-change-functions'."
         (let ((map completion-in-region-mode-map))
           (define-key map (kbd "C-n") #'mct-switch-to-completions-top)
           (define-key map (kbd "C-p") #'mct-switch-to-completions-bottom)))
+    (advice-remove #'completion--done #'mct--region-completion-done)
     (remove-hook 'completion-list-mode-hook #'mct--setup-completion-list)
     (remove-hook 'completion-in-region-mode-hook 
#'mct--region-setup-completion-in-region)
     (advice-remove #'display-completion-list 
#'mct--display-completion-list-advice)
@@ -1192,5 +1196,9 @@ Meant to be added to `after-change-functions'."
       (define-key map (kbd "C-n") nil)
       (define-key map (kbd "C-p") nil))))
 
+(defun mct--completion-done (&rest app)
+  (apply app)
+  (completion-in-region-mode -1))
+
 (provide 'mct)
 ;;; mct.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]