From 18bf82b5d10c40696a92011165aa7e0c0ff20e6b Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 5 Aug 2021 15:47:40 +0800 Subject: fix: poor man' live upadting * completion-conf.el (durand-minibuffer-respect-inhibit-advice) (minibuffer-message): Make sure this respects the value of `inhibit-message'. (durand-completion-display-after-change): Previously this will add a message at the end of the minibuffer after completing, so that the input becomes invalid. Now this problem is fixed. --- completion-conf.el | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'completion-conf.el') diff --git a/completion-conf.el b/completion-conf.el index fdf0e10..35248c6 100644 --- a/completion-conf.el +++ b/completion-conf.el @@ -91,18 +91,42 @@ minibuffer as usual." (remove-hook 'minibuffer-setup-hook 'durand-headlong-minibuffer-setup-hook) (remove-hook 'minibuffer-exit-hook 'durand-headlong-minibuffer-exit-hook)) +;; Make sure `minibuffer-message' respects `inhibit-message'. + +(defun durand-minibuffer-respect-inhibit-advice (fn &rest args) + (cond (inhibit-message) + (t (apply fn args)))) + +(advice-add 'minibuffer-message :around 'durand-minibuffer-respect-inhibit-advice) + ;;;###autoload -(fset - 'durand-completion-display-after-change - (make-byte-code - #x080 - (unibyte-string 192 32 135) - (vector #'minibuffer-completion-help) - 2 +(defun durand-completion-display-after-change (&rest args) "Call `minibuffer-completion-help' with no input. \(fn &rest ARGS)" - nil)) + (cond + ((minibufferp) + (let ((while-no-input-ignore-events '(selection-request))) + (while-no-input + (condition-case nil + (save-excursion + (goto-char (point-max)) + (save-match-data + (let ((inhibit-message t)) + (minibuffer-completion-help)))) + (quit (abort-recursive-edit)))))))) + +;; (fset +;; 'durand-completion-display-after-change +;; (make-byte-code +;; #x080 +;; (unibyte-string 192 32 135) +;; (vector #'minibuffer-completion-help) +;; 2 +;; "Call `minibuffer-completion-help' with no input. + +;; \(fn &rest ARGS)" +;; nil)) ;;;###autoload (fset -- cgit v1.2.3-18-g5258