[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/vcomplete 12def7b143 19/91: Highlight the completion at po
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/vcomplete 12def7b143 19/91: Highlight the completion at point in the completion list buffer |
Date: |
Tue, 24 May 2022 15:59:06 -0400 (EDT) |
branch: elpa/vcomplete
commit 12def7b143950332d10bd324b4b4320736799b84
Author: Daniel Semyonov <cmstr@dsemy.com>
Commit: Daniel Semyonov <cmstr@dsemy.com>
Highlight the completion at point in the completion list buffer
This is different from previous behavior since the completion at point
is highlighted even when navigated to manually.
Note that this doesn't work when completing in-region, although this
doesn't really matter since switching buffers exits
'completion-in-region-mode'.
* vcomplete.el (vcomplete-next-completion, vcomplete-prev-completion):
Don't set 'this-command' to 'vcomplete--no-update'.
(vcomplete--last-string): New variable to hold the last pending
completion string.
(vcomplete--last-string-in-minibuffer): New function which sets
'vcomplete--last-string' (when completing in a minibuffer).
(vcomplete--last-string-in-region): New function which sets
'vcomplete--last-string' (when completing in-region).
(vcomplete--update-in-minibuffer, vcomplete--update-in-region): Modify
to update when the current completion string is different to
'vcomplete--last-string'.
(vcomplete--reset-vars): Add steps to reset 'vcomplete--last-string'
and remove 'vcomplete--highlight-completion-at-point' from the local
'post-command-hook'.
(vcomplete--setup-completions): New function which sets up the
completion list buffer for highlighting at point.
(vcomplete--setup-current): Rename from 'vcomplete--setup'.
Restructure and add steps to add the "last-string" functions added to
the local 'pre-command-hook'.
(vcomplete-mode): Rename references to 'vcomplete--setup' and
add steps to add/remove 'vcomplete--setup-completions' to
'completions-list-mode-hook'.
---
README | 7 ++---
vcomplete.el | 91 ++++++++++++++++++++++++++++++++++++++++------------------
vcomplete.texi | 20 ++++++++-----
3 files changed, 79 insertions(+), 39 deletions(-)
diff --git a/README b/README
index bbd37d51dd..a243f997a7 100644
--- a/README
+++ b/README
@@ -1,8 +1,7 @@
Vcomplete - Visual completions
Vcomplete provides a minor mode enhancing the default completion
-list buffer, providing visual aids for selecting completions and
-performing other actions.
+list buffer, providing visual aids for selecting completions.
Installation:
@@ -44,8 +43,8 @@ When vcomplete-mode is active:
- 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.
-- The current completion is highlighted in the completion list
- buffer.
+- The currently selected completion is highlighted in the completion
+ list buffer.
C-n moves point to the next completion.
diff --git a/vcomplete.el b/vcomplete.el
index 9078c5d55d..f61903139f 100644
--- a/vcomplete.el
+++ b/vcomplete.el
@@ -27,8 +27,7 @@
;;; Commentary:
;; Vcomplete provides a minor mode enhancing the default completion
-;; list buffer, providing visual aids for selecting completions and
-;; performing other actions.
+;; list buffer, providing visual aids for selecting completions.
;;
;; Usage:
;;
@@ -48,8 +47,8 @@
;; - 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.
-;; - The current completion is highlighted in the completion list
-;; buffer.
+;; - The currently selected completion is highlighted in the
+;; completion list buffer.
;;
;; C-n moves point to the next completion.
;;
@@ -155,15 +154,13 @@ If no completion is found, return nil."
"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))
- (setq this-command 'vcomplete--no-update))
+ (vcomplete--move-n-completions (or n 1)))
(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)))
- (setq this-command 'vcomplete--no-update))
+ (vcomplete--move-n-completions (- (or n 1))))
(defun vcomplete-choose-completion ()
"Choose the completion at point in the ‘*Completions*’ buffer."
@@ -182,45 +179,81 @@ With prefix argument N, move N items (negative N means
move forward)."
;;;; Visual completion mode:
+(defvar vcomplete--last-string nil
+ "Last pending completion string.")
+
+(defun vcomplete--last-string-in-minibuffer-1 ()
+ "Return the minibuffer substring after the prompt."
+ (buffer-substring-no-properties (minibuffer-prompt-end)
+ (point-max)))
+
+(defun vcomplete--last-string-in-minibuffer ()
+ "Set ‘vcomplete--last-string’ in a minibuffer."
+ (setq vcomplete--last-string (vcomplete--last-string-in-minibuffer-1)))
+
+(defun vcomplete--last-string-in-region-1 ()
+ "Return a substring according to the markers in
‘completion-in-region--data’."
+ (when completion-in-region--data
+ (buffer-substring-no-properties
+ (car completion-in-region--data)
+ (cadr completion-in-region--data))))
+
+(defun vcomplete--last-string-in-region ()
+ "Set ‘vcomplete--last-string’ in-region."
+ (setq vcomplete--last-string
+ (vcomplete--last-string-in-region-1)))
+
(defun vcomplete--update-in-minibuffer ()
"Update the completion list when completing in a minibuffer."
(while-no-input
(redisplay)
- (unless (eq this-command 'vcomplete--no-update)
+ (unless (string= (vcomplete--last-string-in-minibuffer-1)
+ vcomplete--last-string)
(minibuffer-completion-help))))
(defun vcomplete--update-in-region ()
"Update the completion list when completing in-region."
(while-no-input
(redisplay)
- (unless (or (eq this-command 'vcomplete--no-update)
- (eq this-command 'completion-at-point)
- (null completion-in-region-mode))
+ (unless (string= (vcomplete--last-string-in-region-1)
+ vcomplete--last-string)
(completion-help-at-point))))
(defun vcomplete--reset-vars ()
"Reset variables used by Vcomplete to their default values."
- (setq vcomplete--last-completion-overlay nil)
+ (setq vcomplete--last-completion-overlay nil
+ vcomplete--last-string nil)
+ (remove-hook 'pre-command-hook #'vcomplete--last-string-in-minibuffer t)
+ (remove-hook 'pre-command-hook #'vcomplete--last-string-in-region t)
(remove-hook 'post-command-hook #'vcomplete--update-in-region t)
- (remove-hook 'post-command-hook #'vcomplete--update-in-minibuffer t))
+ (remove-hook 'post-command-hook #'vcomplete--update-in-minibuffer t)
+ (remove-hook 'post-command-hook #'vcomplete--highlight-completion-at-point
t))
+
+(defun vcomplete--setup-completions ()
+ "Setup ‘vcomplete-mode’ for the ‘*Completions*’ buffer."
+ (add-hook 'post-command-hook
+ #'vcomplete--highlight-completion-at-point nil t))
-(defun vcomplete--setup ()
- "Setup ‘vcomplete-mode’."
+(defun vcomplete--setup-current ()
+ "Setup ‘vcomplete-mode’ for the current buffer."
+ (vcomplete--reset-vars)
(if (minibufferp)
(progn
(when (and vcomplete-auto-update minibuffer-completion-table)
+ (add-hook 'pre-command-hook
+ #'vcomplete--last-string-in-minibuffer nil t)
(add-hook 'post-command-hook
#'vcomplete--update-in-minibuffer 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)))
- (when vcomplete-auto-update
- (add-hook 'post-command-hook
- #'vcomplete--update-in-region nil t))
- (setcdr map vcomplete-command-map))
- (vcomplete--reset-vars))))
+ (when-let ((map (assq #'completion-in-region-mode
+ minor-mode-overriding-map-alist)))
+ (when vcomplete-auto-update
+ (add-hook 'pre-command-hook
+ #'vcomplete--last-string-in-region nil t)
+ (add-hook 'post-command-hook
+ #'vcomplete--update-in-region nil t))
+ (setcdr map vcomplete-command-map))))
;;;###autoload
(define-minor-mode vcomplete-mode
@@ -235,13 +268,15 @@ completion:
(if vcomplete-mode
(progn
(vcomplete--reset-vars)
- (add-hook 'minibuffer-setup-hook #'vcomplete--setup)
+ (add-hook 'completion-list-mode-hook #'vcomplete--setup-completions)
+ (add-hook 'minibuffer-setup-hook #'vcomplete--setup-current)
(add-hook 'minibuffer-exit-hook #'vcomplete--reset-vars)
- (add-hook 'completion-in-region-mode-hook #'vcomplete--setup))
+ (add-hook 'completion-in-region-mode-hook #'vcomplete--setup-current))
(vcomplete--reset-vars)
- (remove-hook 'minibuffer-setup-hook #'vcomplete--setup)
+ (remove-hook 'completion-list-mode-hook #'vcomplete--setup-completions)
+ (remove-hook 'minibuffer-setup-hook #'vcomplete--setup-current)
(remove-hook 'minibuffer-exit-hook #'vcomplete--reset-vars)
- (remove-hook 'completion-in-region-mode-hook #'vcomplete--setup)))
+ (remove-hook 'completion-in-region-mode-hook #'vcomplete--setup-current)))
(provide 'vcomplete)
diff --git a/vcomplete.texi b/vcomplete.texi
index fe3d8eb6be..d8078b7dcc 100644
--- a/vcomplete.texi
+++ b/vcomplete.texi
@@ -42,8 +42,7 @@ General Public License for more details.
@top Vcomplete User Manual
Vcomplete provides a minor mode enhancing the default completion list
-buffer, providing visual aids for selecting completions and performing
-other actions.
+buffer, providing visual aids for selecting completions.
@noindent
This manual is for Vcomplete version 0.1.
@@ -80,10 +79,10 @@ Customization
@chapter Introduction
Vcomplete provides a minor mode enhancing the default completion list
-buffer, providing visual aids for selecting completions and performing
-other actions. It's designed to build upon the default completion
-system, instead of replacing it. As such, it works both when
-completing in a minibuffer and in normal buffers.
+buffer, providing visual aids for selecting completions. It's designed
+to build upon the default completion system, instead of replacing
+it. As such, it works both when completing in a minibuffer and in
+normal buffers.
@node Installation
@chapter Installation
@@ -136,7 +135,14 @@ be enabled:
You can also add @code{(vcomplete-mode)} to your init file, instead.
@end table
-The following commands assume completion is in progress.
+When @code{vcomplete-mode} is enabled, the @code{*Completions*} buffer
+appears and updates automatically (by default), and the completion at
+point is highlighted. Note that the completion at point isn't
+highlighted when completing in-region, however switching to the
+@code{*Completions*} buffer stops completion in this case (this is
+default Emacs behavior).
+
+The following commands are available when completion is in progress:
@kindex C-n
@cindex vcomplete-next-completion
- [nongnu] elpa/vcomplete 9aa2d01fb9 52/91: ; Improvements to the manual, (continued)
- [nongnu] elpa/vcomplete 9aa2d01fb9 52/91: ; Improvements to the manual, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete aa4bdbf080 11/91: * vcomplete.el (vcomplete-mode): Ensure variables are reset, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 556a6c2cff 08/91: ; Document recent changes in the NEWS file, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 8a921cf088 48/91: ; Optimize require's in vcomplete-embark.el, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete cbdde2fc09 61/91: Define a face for highlighting completions, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 0bbc9b391b 69/91: ; Improve docstrings and comments, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 18164dd260 71/91: ; Another small change to 'vcomplete-mode's docstring, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 6a3b02df46 76/91: * vcomplete.el (vcomplete-with-completions-buffer): Allow debugging body, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete dce24e895d 18/91: Replaced current completion variables with a function, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 36ae2920e4 17/91: * vcomplete.el (vcomplete-kill-buffer): Remove to simplify the package, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 12def7b143 19/91: Highlight the completion at point in the completion list buffer,
ELPA Syncer <=
- [nongnu] elpa/vcomplete a7eb3b9365 25/91: ; Fixes and improvements to the Info node, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 6bc410d948 27/91: Handle cases where 'vcomplete-mode' starts before loading Embark, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete e37470eb13 05/91: ; Fix indentation, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 39f0aead10 13/91: Fix 'vcomplete--update-in-region' added to 'post-command-hook' globally, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete b6fd11b7c4 31/91: ; Update mail address, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 369a9fb9c4 03/91: ; Ignore Emacs' backup files, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete b1fa61dffd 16/91: Change the way the current completion is highlighted, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 14429ac79d 20/91: Exits 'completion-in-region-mode' when completions aren't visible, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 29423a4aa1 37/91: ; Documentation improvements, ELPA Syncer, 2022/05/24
- [nongnu] elpa/vcomplete 8441803b7a 38/91: Split 'vcomplete--setup-current' into two functions, ELPA Syncer, 2022/05/24