From da0c6ab9535fa1985bb57fd686632fa36a6ddef8 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 1 Nov 2023 12:33:22 +0100 Subject: [PATCH] * completion-preview.el (completion-preview-predicate): Rename --- completion-preview.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/completion-preview.el b/completion-preview.el index 3d18c65..767d61f 100644 --- a/completion-preview.el +++ b/completion-preview.el @@ -67,8 +67,12 @@ after each command, and only displays the completion preview when all of the functions return non-nil." :type 'hook) -(defvar completion-preview-predicate #'always - "Completion predicate to use for completion preview.") +(defvar completion-preview-default-predicate #'always + "Completion predicate to use for completion preview by default. + +If a member of `completion-at-point-functions' returns a non-nil +`:predicate' completion property, then that predicate overrides +the default value that you specify in this option.") (defvar completion-preview-sort-function #'completion-preview--sort-by-length-alpha "Sort function to use for choosing a completion candidate to preview.") @@ -119,14 +123,14 @@ Compatibility definition for `minibuffer--sort-by-length-alpha'." #'completion--capf-wrapper 'all))) (pcase res (`(,_ ,beg ,end ,table . ,plist) - (let* ((string (buffer-substring beg end)) - (md (completion-metadata string table completion-preview-predicate)) + (let* ((pred (or (plist-get plist :predicate) + completion-preview-default-predicate)) + (string (buffer-substring beg end)) + (md (completion-metadata string table pred)) (sort-fn (or (completion-metadata-get md 'cycle-sort-function) (completion-metadata-get md 'display-sort-function) completion-preview-sort-function)) - (all (completion-all-completions string table - (or (plist-get plist :predicate) - completion-preview-predicate) + (all (completion-all-completions string table pred (- (point) beg) md)) (last (last all)) (base (or (cdr last) 0)) -- 2.39.2