]> git.eshelyaron.com Git - completion-preview.git/commitdiff
* completion-preview.el (completion-preview-predicate): Rename
authorEshel Yaron <me@eshelyaron.com>
Wed, 1 Nov 2023 11:33:22 +0000 (12:33 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 1 Nov 2023 11:33:22 +0000 (12:33 +0100)
completion-preview.el

index 3d18c65f4a66e090331a8e1561cbc558b168abbf..767d61f7ce291d48d6af35369510defeb592ecbe 100644 (file)
@@ -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))