[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/mct a24e2dc108 2/2: Comment on sample code for sorting
From: |
ELPA Syncer |
Subject: |
[elpa] externals/mct a24e2dc108 2/2: Comment on sample code for sorting completions |
Date: |
Mon, 7 Feb 2022 00:57:33 -0500 (EST) |
branch: externals/mct
commit a24e2dc10837c4edf34c5fbc2fb80fef960a36f0
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Comment on sample code for sorting completions
---
README.org | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.org b/README.org
index 0fceae7382..3c4b201e5e 100644
--- a/README.org
+++ b/README.org
@@ -1091,6 +1091,7 @@ Starting with Emacs 29 (current development target), the
user option
accepts a custom function. Consider any of the following examples:
#+begin_src emacs-lisp
+;; Some sorting functions...
(defun my-sort-by-alpha-length (elems)
"Sort ELEMS first alphabetically, then by length."
(sort elems (lambda (c1 c2)
@@ -1110,6 +1111,9 @@ Use `mct-sort-sort-by-alpha-length' if no history is
available."
(pcase (mct--completion-category)
('nil (my-sort-by-alpha-length elems))
(_ (my-sort-by-history elems))))
+
+;; Specify the sorting function.
+(setq completions-sort #'my-sort-by-history)
#+end_src
[[#h:1f42c4e6-53c1-4e8a-81ef-deab70822fa4][Known completion categories]].