branch: elpa/vcomplete commit 24c4552d2f4df8a407a53aceffd6684b760de184 Author: Daniel Semyonov <dan...@dsemy.com> Commit: Daniel Semyonov <dan...@dsemy.com>
Use a user option to control which commands cause auto updates * vcomplete.el (vcomplete-no-update-commands): New user option. (vcomplete--move-n-completions, vcomplete-choose-completion): Don't set 'this-command' to 'vcomplete-noop'. (vcomplete--update-in-minibuffer, vcomplete--update-in-region): Compare 'this-command' to each element of 'vcomplete-no-update-commands'. --- vcomplete.el | 20 +++++++++++++++----- vcomplete.texi | 9 ++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/vcomplete.el b/vcomplete.el index 4277f08b65..59ea5df700 100644 --- a/vcomplete.el +++ b/vcomplete.el @@ -87,6 +87,19 @@ Otherwise, operate according to `completion-auto-help'." :risky t :package-version '(vcomplete . 0.1)) +(defcustom vcomplete-no-update-commands + '(vcomplete-next-completion + vcomplete-prev-completion + vcomplete-choose-completion + minibuffer-complete-and-exit + minibuffer-force-complete-and-exit + completion-at-point) + "List of commands which shouldn't cause the `*Completions*' buffer to update." + :link '(info-link "(Vcomplete)Completion commands") + :type '(hook :tag "Commands") + :risky t + :package-version '(vcomplete . 1.1)) + ;;;; Completion commands: (defmacro vcomplete-with-completions-buffer (&rest body) @@ -144,7 +157,6 @@ If no completion is found, return nil." (defun vcomplete--move-n-completions (n) "Move N completions in the `*Completions*' buffer." - (setq this-command 'vcomplete-noop) (vcomplete-with-completions-buffer (next-completion n) (set-window-point window (point)) @@ -165,7 +177,6 @@ With prefix argument N, move N items (negative N means move forward)." (defun vcomplete-choose-completion () "Choose the completion at point in the `*Completions*' buffer." (interactive) - (setq this-command 'vcomplete-noop) (when-let ((buf (get-buffer "*Completions*"))) (switch-to-completions) (choose-completion))) @@ -184,15 +195,14 @@ With prefix argument N, move N items (negative N means move forward)." "Update the completion list when completing in a minibuffer." (while-no-input (redisplay) - (unless (eq this-command 'vcomplete-noop) + (unless (memq this-command vcomplete-no-update-commands) (minibuffer-completion-help)))) (defun vcomplete--update-in-region (&rest _args) "Update the completion list when completing in-region." (while-no-input (redisplay) - (unless (or (eq this-command 'vcomplete-noop) - (eq this-command 'completion-at-point)) + (unless (memq this-command vcomplete-no-update-commands) (completion-help-at-point)))) ;; This function is required (in the local `post-command-hook') since diff --git a/vcomplete.texi b/vcomplete.texi index b21124040b..7b7c8bc1a0 100644 --- a/vcomplete.texi +++ b/vcomplete.texi @@ -206,9 +206,12 @@ package. Consider disabling them or this option on slow computers. Completion commands are used to perform actions while completing. They are normal commands (interactive functions) which are bound to a key -sequence in @code{vcomplete-command-map}. Completion commands which -shouldn't cause the @code{*Completions*} buffer to update should set -@code{this-command} to @code{vcomplete-noop}. +sequence in @code{vcomplete-command-map}. + +@defopt vcomplete-no-update-commands +List of commands which shouldn't cause the @code{*Completions*} buffer +to update. +@end defopt @defvar vcomplete-command-map Key map which holds key bindings to completion commands. This key map