[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult 9c4c75daeb 1/2: consult-completion-in-region: R
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult 9c4c75daeb 1/2: consult-completion-in-region: Remove :completion-styles override |
Date: |
Sun, 25 Feb 2024 06:57:36 -0500 (EST) |
branch: externals/consult
commit 9c4c75daeb99ad36feb350236be3ba310582adec
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
consult-completion-in-region: Remove :completion-styles override
---
consult.el | 79 ++++++++++++++++++++++----------------------------------------
1 file changed, 28 insertions(+), 51 deletions(-)
diff --git a/consult.el b/consult.el
index 593c3d6c94..d66bcf7729 100644
--- a/consult.el
+++ b/consult.el
@@ -3011,58 +3011,35 @@ of functions and in `consult-completion-in-region'."
(defun consult-completion-in-region (start end collection &optional predicate)
"Use minibuffer completion as the UI for `completion-at-point'.
-The function is called with 4 arguments: START END COLLECTION PREDICATE.
-The arguments and expected return value are as specified for
-`completion-in-region'. Use as a value for `completion-in-region-function'.
-
-The function can be configured via `consult-customize'.
-
- (consult-customize consult-completion-in-region
- :completion-styles (basic)
- :cycle-threshold 3)
-
-These configuration options are supported:
-
- * :cycle-threshold - Cycling threshold (def: `completion-cycle-threshold')
- * :completion-styles - Use completion styles (def: `completion-styles')
- * :require-match - Require matches when completing (def: nil)
- * :prompt - The prompt string shown in the minibuffer"
+The function is called with 4 arguments: START END COLLECTION
+PREDICATE. The arguments and expected return value are as
+specified for `completion-in-region'. Use this function as a
+value for `completion-in-region-function'."
(barf-if-buffer-read-only)
- (cl-letf* ((config (consult--customize-get #'consult-completion-in-region))
- ;; Overwrite both the local and global value of
- ;; `completion-styles', such that the `completing-read' minibuffer
- ;; sees the overwritten value in any case. This is necessary if
- ;; `completion-styles' is buffer-local. Be aware that the
override
- ;; also affects recursive editing sessions.
- (cs (or (plist-get config :completion-styles) completion-styles))
- (completion-styles cs)
- ((default-value 'completion-styles) cs)
- (initial (buffer-substring-no-properties start end))
- (metadata (completion-metadata initial collection predicate))
- ;; TODO: `minibuffer-completing-file-name' is mostly deprecated,
- ;; but still in use. Packages should instead use the completion
- ;; metadata.
- (minibuffer-completing-file-name
- (eq 'file (completion-metadata-get metadata 'category)))
- (threshold (or (plist-get config :cycle-threshold)
- (completion--cycle-threshold metadata)))
- (all (completion-all-completions initial collection predicate
(length initial)))
- ;; Wrap all annotation functions to ensure that they are executed
- ;; in the original buffer.
- (exit-fun (plist-get completion-extra-properties :exit-function))
- (ann-fun (plist-get completion-extra-properties
:annotation-function))
- (aff-fun (plist-get completion-extra-properties
:affixation-function))
- (docsig-fun (plist-get completion-extra-properties
:company-docsig))
- (completion-extra-properties
- `(,@(and ann-fun (list :annotation-function (consult--in-buffer
ann-fun)))
- ,@(and aff-fun (list :affixation-function (consult--in-buffer
aff-fun)))
- ;; Provide `:annotation-function' if `:company-docsig' is
specified.
- ,@(and docsig-fun (not ann-fun) (not aff-fun)
- (list :annotation-function
- (consult--in-buffer
- (lambda (cand)
- (concat (propertize " " 'display '(space
:align-to center))
- (funcall docsig-fun cand)))))))))
+ (let* ((initial (buffer-substring-no-properties start end))
+ (metadata (completion-metadata initial collection predicate))
+ ;; TODO: `minibuffer-completing-file-name' is mostly deprecated, but
+ ;; still in use. Packages should instead use the completion metadata.
+ (minibuffer-completing-file-name
+ (eq 'file (completion-metadata-get metadata 'category)))
+ (threshold (completion--cycle-threshold metadata))
+ (all (completion-all-completions initial collection predicate (length
initial)))
+ ;; Wrap all annotation functions to ensure that they are executed
+ ;; in the original buffer.
+ (exit-fun (plist-get completion-extra-properties :exit-function))
+ (ann-fun (plist-get completion-extra-properties :annotation-function))
+ (aff-fun (plist-get completion-extra-properties :affixation-function))
+ (docsig-fun (plist-get completion-extra-properties :company-docsig))
+ (completion-extra-properties
+ `(,@(and ann-fun (list :annotation-function (consult--in-buffer
ann-fun)))
+ ,@(and aff-fun (list :affixation-function (consult--in-buffer
aff-fun)))
+ ;; Provide `:annotation-function' if `:company-docsig' is
specified.
+ ,@(and docsig-fun (not ann-fun) (not aff-fun)
+ (list :annotation-function
+ (consult--in-buffer
+ (lambda (cand)
+ (concat (propertize " " 'display '(space :align-to
center))
+ (funcall docsig-fun cand)))))))))
;; error if `threshold' is t or the improper list `all' is too short
(if (and threshold
(or (not (consp (ignore-errors (nthcdr threshold all))))