[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/activities 310f6d11ff 40/50: sort-by-active-age: reform
From: |
ELPA Syncer |
Subject: |
[elpa] externals/activities 310f6d11ff 40/50: sort-by-active-age: reformulate using pcase |
Date: |
Wed, 25 Dec 2024 03:57:21 -0500 (EST) |
branch: externals/activities
commit 310f6d11ff6697d0376221e4ed13bb13de40f7a5
Author: J.D. Smith <jdtsmith@gmail.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
sort-by-active-age: reformulate using pcase
---
activities.el | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/activities.el b/activities.el
index 0213b366ef..c7bc7b556b 100644
--- a/activities.el
+++ b/activities.el
@@ -911,20 +911,18 @@ Abbreviate the units if ABBREV is non-nil."
maximize (float-time (time-since (map-elt etc 'time))))))
(defun activities-sort-by-active-age (names)
- "Return the list activity NAMES sorted active first, then by age."
- (sort names
- (lambda (a b)
- (let* ((activity-a (map-elt activities-activities a))
- (state-a (or (activities-activity-last activity-a)
- (activities-activity-default activity-a)))
- (time-a (map-elt (activities-activity-state-etc state-a)
'time))
- (activep-a (activities-activity-active-p activity-a))
- (activity-b (map-elt activities-activities b))
- (state-b (or (activities-activity-last activity-b)
- (activities-activity-default activity-b)))
- (time-b (map-elt (activities-activity-state-etc state-b)
'time))
- (activep-b (activities-activity-active-p activity-b)))
- (or (and activep-a (not activep-b)) (time-less-p time-b time-a))))))
+ "Return the list of activity NAMES sorted active first, then by age."
+ (cl-labels ((time-active-p (name)
+ (pcase-let* ((activity (map-elt activities-activities name))
+ (active-p (activities-activity-active-p activity))
+ ((cl-struct activities-activity last default)
activity)
+ (state (or last default))
+ (time (map-elt (activities-activity-state-etc
state) 'time)))
+ (cons time active-p))))
+ (sort names (pcase-lambda ((app time-active-p `(,time-a . ,activep-a))
+ (app time-active-p `(,time-b . ,activep-b)))
+ (or (and activep-a (not activep-b))
+ (time-less-p time-b time-a))))))
(cl-defun activities-completing-read
(&key (activities activities-activities)
- [elpa] externals/activities ea95275d88 19/50: Handle plurals correctly in annotation bufs/files, (continued)
- [elpa] externals/activities ea95275d88 19/50: Handle plurals correctly in annotation bufs/files, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 9e46784287 23/50: Remove debug message, ELPA Syncer, 2024/12/25
- [elpa] externals/activities bcf09497de 26/50: README: improve annotation/sorting docs, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 0e7151b6bd 28/50: buffer-and-files-differ: improve docstring, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 8c5efa1855 29/50: buffers-and-files: better var name, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 93e1fbbad0 30/50: map-window-state-leafs -> mapcar-window-state-leafs, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 3dd100d0e0 31/50: cl-labels file-or-buffer: improve docstring, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 29e89be859 34/50: buffers-and-files: fix docstring typo, ELPA Syncer, 2024/12/25
- [elpa] externals/activities c31498588e 36/50: improve custom activities-sort-function -> activities-sort-by, ELPA Syncer, 2024/12/25
- [elpa] externals/activities fad6543d48 39/50: age: mention related bug report and magit--age in comment, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 310f6d11ff 40/50: sort-by-active-age: reformulate using pcase,
ELPA Syncer <=
- [elpa] externals/activities d4b0ae717f 45/50: sort-by: use function-item for custom, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 793c50cbba 47/50: sort-by-active-age: fix sort logic, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 31ec5154dd 50/50: Merge: Completion annotations, ELPA Syncer, 2024/12/25
- [elpa] externals/activities e131d560d9 48/50: README: mention new completion interface in Changelog, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 1f9f578860 41/50: activities-completing-read: use cl-labels for clarity, ELPA Syncer, 2024/12/25
- [elpa] externals/activities c59ab9e9d7 38/50: activities--buffers-and-files-differ-p: rename args for clarity, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 2beae7a329 46/50: completing-read: make sort-by always set to a sort function, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 61d13b3a0f 49/50: Docs: (README.org) Tidy, ELPA Syncer, 2024/12/25