From 7b0cd304edc8a150c57d2e2320492be59d0a6d5a Mon Sep 17 00:00:00 2001 From: JSDurand Date: Wed, 26 Jan 2022 17:40:15 +0800 Subject: 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. --- completion-conf.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'completion-conf.el') 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 () -- cgit v1.2.3-18-g5258