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

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

[nongnu] elpa/vcomplete 452cf29801 04/91: Optionally update the '*Comple


From: ELPA Syncer
Subject: [nongnu] elpa/vcomplete 452cf29801 04/91: Optionally update the '*Completions*' buffer automatically
Date: Tue, 24 May 2022 15:59:05 -0400 (EDT)

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

    Optionally update the '*Completions*' buffer automatically
    
    * vcomplete.el (vcomplete-auto-update): Rename from
    'vcomplete-auto-help'.
    (vcomplete-next-completion, vcomplete-prev-completion): Set
    'this-command' to 'vcomplete--no-update' as the last step.
    (vcomplete--update): New function which updates the '*Completions*'
    buffer.
    (vcomplete--setup): Add appropriate hooks when 'vcomplete-auto-update'
    is non-nil (only for minibuffer completion currently).
---
 README         |  4 ++--
 vcomplete.el   | 47 +++++++++++++++++++++++++++++++----------------
 vcomplete.texi | 10 ++++++----
 3 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/README b/README
index 5ee1ac7387..bbd37d51dd 100644
--- a/README
+++ b/README
@@ -39,8 +39,8 @@ For use-package users:
   (vcomplete-mode))
 
 When vcomplete-mode is active:
-- The completion list buffer opens automatically (see
-  ‘vcomplete-auto-help’).
+- The completion list buffer opens and updates automatically (see
+  ‘vcomplete-auto-update’).
 - The completion list buffer can be controlled through the
   minibuffer (during minibuffer completion) or the current buffer
   (during in-buffer completion), if it's visible.
diff --git a/vcomplete.el b/vcomplete.el
index bc1d66bf82..2880b9e261 100644
--- a/vcomplete.el
+++ b/vcomplete.el
@@ -43,8 +43,8 @@
 ;;   (vcomplete-mode))
 ;;
 ;; When vcomplete-mode is active:
-;; - The completion list buffer opens automatically (see
-;;   ‘vcomplete-auto-help’).
+;; - The completion list buffer opens and updates automatically (see
+;;   ‘vcomplete-auto-update’).
 ;; - The completion list buffer can be controlled through the
 ;;   minibuffer (during minibuffer completion) or the current buffer
 ;;   (during in-buffer completion), if it's visible.
@@ -79,12 +79,13 @@
   :group 'convenience
   :prefix "vcomplete-")
 
-(defcustom vcomplete-auto-help t
-  "Whether the ‘*Completions*’ buffer should open automatically.
-Non-nil means automatically open.
+(defcustom vcomplete-auto-update t
+  "Whether the ‘*Completions*’ buffer should open and update automatically.
+Non-nil means automatically open and update.
 Otherwise, operate according to ‘completion-auto-help’."
-  :type '(radio (const :tag "Automatically open" t)
-                (const :tag "According to ‘completion-auto-help’" nil))
+  :type '(radio
+          (const :tag "Automatically open and update" t)
+          (const :tag "Operate according to ‘completion-auto-help’" nil))
   :package-version '(vcomplete . 0.1))
 
 ;;;; Completion commands:
@@ -138,13 +139,15 @@ The completion selected is marked with an overlay."
   "Move to the next item in the ‘*Completions*’ buffer.
 With prefix argument N, move N items (negative N means move backward)."
   (interactive "p")
-  (vcomplete--move-n-completions (or n 1)))
+  (vcomplete--move-n-completions (or n 1))
+  (setq this-command 'vcomplete--no-update))
 
 (defun vcomplete-prev-completion (&optional n)
   "Move to the previous item in the ‘*Completions*’ buffer.
 With prefix argument N, move N items (negative N means move forward)."
   (interactive "p")
-  (vcomplete--move-n-completions (- (or n 1))))
+  (vcomplete--move-n-completions (- (or n 1)))
+  (setq this-command 'vcomplete--no-update))
 
 (defun vcomplete-choose-completion ()
   "Choose the completion at point in the ‘*Completions*’ buffer."
@@ -171,15 +174,27 @@ With prefix argument N, move N items (negative N means 
move forward)."
     map)
   "Key map for ‘vcomplete-mode’ commands.")
 
+(defun vcomplete--update()
+  "Update the ‘*Completions*’ buffer when completing in the minibuffer."
+  (while-no-input
+    (redisplay)
+    (unless (eq this-command 'vcomplete--no-update)
+      (minibuffer-completion-help))))
+
 (defun vcomplete--setup ()
   "Setup ‘vcomplete-mode’."
-  (when-let ((map (assq #'completion-in-region-mode
-                        minor-mode-overriding-map-alist)))
-    (setcdr map vcomplete-command-map))
-  (when (minibufferp)
-    (minibuffer-completion-help)
-    (use-local-map (make-composed-keymap vcomplete-command-map
-                                         (current-local-map)))))
+  (if (minibufferp)
+      (progn
+        (when (and vcomplete-auto-update minibuffer-completion-table)
+          (add-hook 'post-command-hook
+                    #'vcomplete--update nil t))
+        (use-local-map (make-composed-keymap vcomplete-command-map
+                                             (current-local-map))))
+    (if completion-in-region-mode
+        (when-let ((map (assq #'completion-in-region-mode
+                              minor-mode-overriding-map-alist)))
+          (setcdr map vcomplete-command-map))
+      (remove-hook 'post-command-hook #'vcomplete--update t))))
 
 ;;;; Visual completion mode:
 
diff --git a/vcomplete.texi b/vcomplete.texi
index 11ac2128a9..cb24cd1200 100644
--- a/vcomplete.texi
+++ b/vcomplete.texi
@@ -191,9 +191,10 @@ be done through the customize interface:
 @item @kbd{M-x customize-group RET vcomplete RET}
 @end table
 
-@defopt vcomplete-auto-help
-Whether the @code{*Completions*} buffer should open automatically.
-Non-nil means automatically open. Otherwise, operate according to
+@defopt vcomplete-auto-update
+Whether the @code{*Completions*} buffer should open and update
+automatically.  Non-nil means automatically open and
+update. Otherwise, operate according to
 @code{completion-auto-help}. By default, @code{t} is used.
 @end defopt
 
@@ -210,7 +211,8 @@ functions) which are bound to a key sequence in
 @code{vcomplete-command-map}.  @code{vcomplete-next-completion},
 @code{vcomplete-prev-completion}, @code{vcomplete-choose-completion}
 and @code{vcomplete-kill-buffer} are implemented as completion
-commands.
+commands. Completion commands can inhibit updating the completion list
+buffer by setting @code{this-command} to @code{vcomplete--no-update}.
 
 @defvar vcomplete-command-map
 Key map which holds key bindings to completion commands. This key map



reply via email to

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