[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/vcomplete b579e91c03 3/5: Allow calling 'vcomplete-current
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/vcomplete b579e91c03 3/5: Allow calling 'vcomplete-current-completion' everywhere without args |
Date: |
Fri, 11 Nov 2022 08:59:39 -0500 (EST) |
branch: elpa/vcomplete
commit b579e91c03b753921dff53a2d30f547ff18531aa
Author: Daniel Semyonov <daniel@dsemy.com>
Commit: Daniel Semyonov <daniel@dsemy.com>
Allow calling 'vcomplete-current-completion' everywhere without args
* vcomplete.el (vcomplete-current-completion): Allow calling from
anywhere without and without arguments (in which case point is used).
* vcomplete.texi (Completion commands): Update description.
---
vcomplete.el | 46 +++++++++++++++++++++++-----------------------
vcomplete.texi | 13 ++++++++-----
2 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/vcomplete.el b/vcomplete.el
index 52c35171f5..33796dffef 100644
--- a/vcomplete.el
+++ b/vcomplete.el
@@ -168,29 +168,29 @@ This function only searches the frames specified in
`vcomplete-search-range'."
"The `*Completions*' buffer is set to an incorrect mode"))
,@body))))
-(defun vcomplete-current-completion (pos)
- "Get the completion candidate at POS.
+(defun vcomplete-current-completion (&optional pos)
+ "Get the completion candidate at point in the `*Completions*' window.
+When POS is non-nil, use it instead of point.
The completion candidate is returned as a list of the form:
- (COMPLETION-STRING . (BEGINNING . END))
-If no completion is found, return nil.
-An error is thrown when the current buffer
-isn't a completion list buffer."
- (unless (derived-mode-p 'completion-list-mode)
- (error "Not in a valid completion list buffer"))
- ;; Modified from code in `choose-completion'.
- (let (beg end noop)
- (cond
- ((and (not (eobp)) (get-text-property pos 'mouse-face))
- (setq end pos beg (1+ pos)))
- ((and (not (bobp))
- (get-text-property (1- pos) 'mouse-face))
- (setq end (1- pos) beg pos))
- (t (setq noop t)))
- (unless noop
- (setq beg (previous-single-property-change beg 'mouse-face))
- (setq end (or (next-single-property-change end 'mouse-face)
- (point-max)))
- `(,(buffer-substring-no-properties beg end) . (,beg . ,end)))))
+ (COMPLETION-STRING . (BEG . END))
+Where BEG and END are the beginning and end positions of the
+completion string in the `*Completions*' buffer.
+If no completion is found, return nil."
+ (vcomplete-with-completions-window
+ ;; Modified from code in `choose-completion'.
+ (let ((pos (or pos (point))) beg end noop)
+ (cond
+ ((and (not (eobp)) (get-text-property pos 'mouse-face))
+ (setq end pos beg (1+ pos)))
+ ((and (not (bobp))
+ (get-text-property (1- pos) 'mouse-face))
+ (setq end (1- pos) beg pos))
+ (t (setq noop t)))
+ (unless noop
+ (setq beg (previous-single-property-change beg 'mouse-face))
+ (setq end (or (next-single-property-change end 'mouse-face)
+ (point-max)))
+ `(,(buffer-substring-no-properties beg end) . (,beg . ,end))))))
(if (boundp 'completions-highlight-face)
(defun vcomplete--move-n-completions (n)
@@ -203,7 +203,7 @@ isn't a completion list buffer."
(defun vcomplete--highlight-completion-at-point ()
"Highlight the completion at point in the `*Completions*' buffer."
- (let ((cur (vcomplete-current-completion (point))))
+ (let ((cur (vcomplete-current-completion)))
(when vcomplete--last-completion-overlay
(delete-overlay vcomplete--last-completion-overlay))
(when-let ((pos (cdr cur)))
diff --git a/vcomplete.texi b/vcomplete.texi
index f11afc2341..f9068fbbd3 100644
--- a/vcomplete.texi
+++ b/vcomplete.texi
@@ -237,13 +237,16 @@ should be available whenever completion is initiated when
@code{vcomplete-mode} is enabled.
@end defvar
-@defun vcomplete-current-completion pos
-Get the completion candidate at POS in the *Completions* buffer.
-The completion candidate is returned as a list of the form:
+@defun vcomplete-current-completion &optional pos
+Get the completion candidate at point in the `*Completions*'
+window. When POS is non-nil, use it instead of point. The completion
+candidate is returned as a list of the form:
@example
-(COMPLETION-STRING . (BEGINNING . END))
+(COMPLETION-STRING . (BEG . END))
@end example
-If no completion is found, this function returns nil.
+Where BEG and END are the beginning and end positions of the
+completion string in the `*Completions*' buffer. If no completion is
+found, return nil.
@end defun
@defmac vcomplete-with-completions-window body...
- [nongnu] elpa/vcomplete updated (42a3fded4a -> 93ae3db40d), ELPA Syncer, 2022/11/11
- [nongnu] elpa/vcomplete d9c97a5889 2/5: Integrate built-in completion enhancements of Emacs 29, ELPA Syncer, 2022/11/11
- [nongnu] elpa/vcomplete b579e91c03 3/5: Allow calling 'vcomplete-current-completion' everywhere without args,
ELPA Syncer <=
- [nongnu] elpa/vcomplete b7d4b7286f 4/5: ; Document last commit in NEWS, ELPA Syncer, 2022/11/11
- [nongnu] elpa/vcomplete bcdfcfb686 1/5: Restore original {pre, suf}fix in the minibuffer when choosing completion, ELPA Syncer, 2022/11/11
- [nongnu] elpa/vcomplete 93ae3db40d 5/5: ; Bump version to 2.0, ELPA Syncer, 2022/11/11