summaryrefslogtreecommitdiff
path: root/completion-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-01-26 17:40:15 +0800
committerJSDurand <mmemmew@gmail.com>2022-01-26 17:40:15 +0800
commit7b0cd304edc8a150c57d2e2320492be59d0a6d5a (patch)
tree4c8da021de99ef15f8289c7fe5821ec178f30a59 /completion-conf.el
parent4ed65865faa604b475f8051f9e4a06554c1bcb76 (diff)
clear up after preview
* completion-conf.el (durand-preview-exit-hook) (durand-open-completion-list-with-buffer-preview): I forgot to clear the mess after the preview is over. The result of this experiment is far from usable yet, of course.
Diffstat (limited to 'completion-conf.el')
-rw-r--r--completion-conf.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/completion-conf.el b/completion-conf.el
index c40294e..b4d2c03 100644
--- a/completion-conf.el
+++ b/completion-conf.el
@@ -212,11 +212,21 @@ candidates."
group-fun))
((list str grou-fun)))))
+(defun durand-preview-exit-hook ()
+ "Clear things up."
+ (let (bf)
+ (cond
+ ((setq bf (get-buffer "*Completions*"))
+ (with-current-buffer bf
+ (remove-hook 'post-command-hook
+ #'durand-preview-in-completion-list))))))
+
(defun durand-open-completion-list-with-buffer-preview ()
"Open the completion list buffer and propertize the candidates."
(interactive)
(advice-add #'completion--insert :filter-args
#'durand-propertize-buffer-for-completion-list)
+ (add-hook 'minibuffer-exit-hook #'durand-preview-exit-hook)
(let ((minibuffer-allow-text-properties t))
(minibuffer-completion-help))
(advice-remove #'completion--insert
@@ -226,7 +236,7 @@ candidates."
(cond
((derived-mode-p 'completion-list-mode)
(add-hook 'post-command-hook
- #'durand-preview-in-completion-list))
+ #'durand-preview-in-completion-list nil t))
((user-error "Something is wrong!"))))
;; (defun durand-quit-completion-list-with-buffer-preview ()