From 441302c63cbf336fc148e6006c96b8c975b553bf Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Fri, 28 Feb 2025 12:07:31 +0100 Subject: [PATCH] Make 'completion-preview-sort-function' a defcustom * lisp/completion-preview.el (completion-preview-sort-function): Define and document it as a user option. * etc/NEWS: Announce. (cherry picked from commit 8b9194ae03214dd5169bd84f7d83bbe660dd9f90) --- lisp/completion-preview.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 68a898921a6..6ace3f736d1 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -236,8 +236,20 @@ affect the background color, for example with `hl-line-mode'." (const :tag "Disable" nil)) :version "31.1") -(defvar completion-preview-sort-function #'minibuffer--sort-by-length-alpha - "Sort function to use for choosing a completion candidate to preview.") +(defcustom completion-preview-sort-function #'minibuffer--sort-by-length-alpha + "Sort function to use for choosing a completion candidate to preview. + +Completion Preview mode calls the function that this option specifies to +sort completion candidates. The function takes one argument, the list +of candidates, and returns the list sorted. + +The default sort function sorts first by length, then alphabetically. +To disable sorting, set this option to `identity'. + +If the completion table that produces the candidates already specifies a +sort function, it takes precedence over this option." + :type 'function + :version "31.1") (defface completion-preview '((t :inherit shadow)) -- 2.39.5