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

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

[nongnu] elpa/vcomplete 0170c083a3 26/91: Eliminate delay after Embark a


From: ELPA Syncer
Subject: [nongnu] elpa/vcomplete 0170c083a3 26/91: Eliminate delay after Embark action from minibuffer when auto updates are on
Date: Tue, 24 May 2022 15:59:07 -0400 (EDT)

branch: elpa/vcomplete
commit 0170c083a32c6d628536254b3660f7edd2a0be82
Author: Daniel Semyonov <cmstr@dsemy.com>
Commit: Daniel Semyonov <cmstr@dsemy.com>

    Eliminate delay after Embark action from minibuffer when auto updates are on
    
    * vcomplete.el (vcomplete-embark--eliminate-delay): New function which
    is used as an advice around 'embark-act' and 'embark-default-action'
    to eliminate the aforementioned delay.
    (vcomplete-embark--advise-commands): New function which performs the
    advising. Add to 'vcomplete-mode-hook' after loading Embark.
---
 vcomplete.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/vcomplete.el b/vcomplete.el
index 47000b5d7a..4da1801540 100644
--- a/vcomplete.el
+++ b/vcomplete.el
@@ -278,6 +278,18 @@ completion:
 (declare-function embark-target-completion-at-point "ext:embark")
 (declare-function embark-completions-buffer-candidates "ext:embark")
 
+(defun vcomplete-embark--eliminate-delay (fun &rest args)
+  "Call FUN with ‘minibuffer-message-timeout’ locally set to ‘0’."
+  (let ((minibuffer-message-timeout 0))
+    (apply fun args)))
+
+(defun vcomplete-embark--advise-commands ()
+  "Advise Embark commands with ‘vcomplete-embark--eliminate-delay’."
+  (dolist (cmd '(embark-act embark-default-action))
+    (if vcomplete-mode
+        (advice-add cmd :around #'vcomplete-embark--eliminate-delay)
+      (advice-remove cmd #'vcomplete-embark--eliminate-delay))))
+
 (defun vcomplete-embark-current-completion (&optional relative)
   "Call ‘embark-target-completion-at-point’ in the ‘*Completions*’ buffer."
   (when (and vcomplete-mode
@@ -293,6 +305,8 @@ completion:
       (embark-completions-buffer-candidates))))
 
 (with-eval-after-load 'embark
+  (add-hook 'vcomplete-mode-hook
+            #'vcomplete-embark--advise-commands)
   (add-hook 'embark-target-finders
             #'vcomplete-embark-current-completion)
   (add-hook 'embark-candidate-collectors



reply via email to

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