[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ilist 5ba04b79bd 03/24: * ilist.el (ilist-string): Add
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ilist 5ba04b79bd 03/24: * ilist.el (ilist-string): Add support for sorting. |
Date: |
Tue, 28 Dec 2021 16:58:13 -0500 (EST) |
branch: externals/ilist
commit 5ba04b79bd68b55b08e6fe0607203cf96c64fb7b
Author: JSDurand <mmemmew@gmail.com>
Commit: JSDurand <mmemmew@gmail.com>
* ilist.el (ilist-string): Add support for sorting.
---
ilist.el | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/ilist.el b/ilist.el
index 8abe9d1245..4223a27615 100644
--- a/ilist.el
+++ b/ilist.el
@@ -32,7 +32,7 @@
;;; Code:
-;;; dependency
+;;; dependencies
(require 'text-property-search)
@@ -262,7 +262,7 @@ columns."
;;; produce the string
-(defun ilist-string (ls columns groups &optional discard-empty-p)
+(defun ilist-string (ls columns groups &optional discard-empty-p sorter)
"Display list LS as the returned string.
COLUMNS will be passed to `ilist-define-column'.
@@ -282,12 +282,23 @@ higher priority over those that occur later.
The display of each group is done by `ilist-display'.
If DISCARD-EMPTY-P is non-nil, then empty groups will not be
-displayed."
+displayed.
+
+If SORTER is non-nil, it should be a function with two arguments,
+X and Y, and should return non-nil if X should come before Y."
(declare (pure t) (side-effect-free t))
- (let ((ls (copy-tree ls))
- (temp-groups (copy-tree groups))
- column-widths temp-group group-results group-strs
- all-cols all-cols-indices header title-sep)
+ ;; normalize SORTER
+ (cond
+ ((null sorter))
+ ((not (functionp sorter))
+ (user-error "SORTER should be a function, but got %S"
+ sorter)))
+ ;; we sort the list at the beginning
+ (let* ((ls (copy-tree ls))
+ (ls (cond ((null sorter) ls) ((sort ls sorter))))
+ (temp-groups (copy-tree groups))
+ column-widths temp-group group-results group-strs
+ all-cols all-cols-indices header title-sep)
;; If we want to operate on the displayed list, then we should
;; store the original list, and the indices of each displayed
;; element. But we re-order the elements while preparing the
- [elpa] branch externals/ilist created (now b2bf67c5d8), ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 3265864faf 01/24: Initial working version, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist d03de0ea64 02/24: README, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 5ba04b79bd 03/24: * ilist.el (ilist-string): Add support for sorting.,
ELPA Syncer <=
- [elpa] externals/ilist 457f0b0d87 06/24: no trailing whitespaces if demanded, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 4fb5695fe1 09/24: Add manuals and update README, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 95bcbf4b00 12/24: ilist: leave new lines when hiding groups, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 8b5d5f382f 22/24: Update docs, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist f021d7d8ab 20/24: fix: account for an invisible beginning, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 282f60c93a 21/24: I forgot to byte-compile again. Silly me!, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist c3f0e61360 13/24: fix missing parameter, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist b2bf67c5d8 24/24: Add changelog, and update documentation, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist ed18678569 05/24: new: get group and marks, ELPA Syncer, 2021/12/28
- [elpa] externals/ilist 5362c106a8 04/24: more functionalities, ELPA Syncer, 2021/12/28