[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/activities 322de07933 35/50: activities--age: rewrite,
From: |
ELPA Syncer |
Subject: |
[elpa] externals/activities 322de07933 35/50: activities--age: rewrite, note future core replacement |
Date: |
Wed, 25 Dec 2024 03:57:20 -0500 (EST) |
branch: externals/activities
commit 322de0793398d046b075b263c18cac3bd22053b0
Author: J.D. Smith <jdtsmith@gmail.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
activities--age: rewrite, note future core replacement
---
activities.el | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/activities.el b/activities.el
index c28343df12..7d07def195 100644
--- a/activities.el
+++ b/activities.el
@@ -875,23 +875,30 @@ activity's name is NAME."
(?w "week" "weeks" ,(* 60 60 24 7))
(?d "day" "days" ,(* 60 60 24))
(?h "hour" "hours" ,(* 60 60))
- (?m "minute" "minutes" 60)
- (?s "second" "seconds" 1))
+ (?m "min" "mins" 60)
+ (?s "sec" "secs" 1))
"Age specification. See `magit--age-spec', which this duplicates.")
-(defun activities--age (age &optional abbreviate)
- "Summarize AGE and possibly ABBREVIATE.
-Adapted from `magit--age'."
- (cl-labels ((fn (age spec)
- (pcase-let ((`(,char ,unit ,units ,weight) (car spec)))
- (let ((cnt (round (/ age weight 1.0))))
- (if (or (not (cdr spec))
- (>= (/ age weight) 1))
- (list cnt (cond (abbreviate char)
- ((= cnt 1) unit)
- (t units)))
- (fn age (cdr spec)))))))
- (fn age activities--age-spec)))
+(defun activities--age (age &optional abbrev)
+ "Summarize AGE.
+Abbreviate the units if ABBREV is non-nil. Based on
+`magit--age'."
+ ;; TODO: replace this if seconds-to-string adds READABLE support
+ (let ((half t)
+ (age-spec activities--age-spec)
+ age-unit cnt)
+ (if (= (round age (if half 0.5 1.)) 0)
+ (format "0%s" (if abbrev "s" " seconds"))
+ (while (and (setq age-unit (pop age-spec)) age-spec
+ (< (/ age (nth 3 age-unit)) 1)))
+ (setq cnt (round (/ (float age) (nth 3 age-unit)) (if half 0.5 1.)))
+ (concat (let ((c (if half (/ cnt 2) cnt)))
+ (and (> c 0) (number-to-string c)))
+ (and half (= (mod cnt 2) 1) "½")
+ (or abbrev " ")
+ (cond (abbrev (car age-unit))
+ ((<= cnt (if half 2 1)) (nth 1 age-unit))
+ (t (nth 2 age-unit)))))))
(defun activities--oldest-age (activities)
"Return the age in seconds of the oldest activity in ACTIVITIES."
@@ -966,8 +973,7 @@ which see, with DEFAULT."
collect (+ (* blend-frac (+ cn
(* (- co cn) (/ age max-age))))
(* (- 1. blend-frac)
cd)))))
(age-annotation (propertize
- (format "%15s" (apply #'format "[%d %s]"
- (activities--age
age)))
+ (format "%10s" (activities--age age))
'face `(:foreground ,age-color :weight
bold)))
(dirty-annotation (if dirtyp (propertize "*" 'face 'bold) "
")))
(concat (propertize " " 'display
- [elpa] externals/activities 9e12e5882a 13/50: handle missing last state and add `*' for modified state buffer list, (continued)
- [elpa] externals/activities 9e12e5882a 13/50: handle missing last state and add `*' for modified state buffer list, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 744fd23282 18/50: annotate: separate active flag (@) from modified flag (*), ELPA Syncer, 2024/12/25
- [elpa] externals/activities 09e469df96 20/50: completing-read: sort completion using new completion-table, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 455e3ebf8f 22/50: Make activities--annotate privately named, ELPA Syncer, 2024/12/25
- [elpa] externals/activities e392e233d3 21/50: annotate: "zero files" is plural, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 8683bb4662 24/50: Factor out buffer-and-files comparison functions, ELPA Syncer, 2024/12/25
- [elpa] externals/activities e774617fb1 25/50: save: retain last timestamp when buffer and files have not changed, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 0a3309ae51 27/50: Inline activities--completion-table, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 6d9b69485a 32/50: inline annotation-function and eliminate vc-annotate, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 67cb87f413 33/50: mapcar-window-state-leafs: improve varnames and docstring, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 322de07933 35/50: activities--age: rewrite, note future core replacement,
ELPA Syncer <=
- [elpa] externals/activities 425b6199ca 37/50: activities-annotation-colors: simplify doc and use ALPHA, ELPA Syncer, 2024/12/25
- [elpa] externals/activities d648a9e3a9 42/50: README: rename section as Completion, ELPA Syncer, 2024/12/25
- [elpa] externals/activities b69373eda6 43/50: README: simplify Completion description, ELPA Syncer, 2024/12/25
- [elpa] externals/activities b75e6f4ab6 44/50: oldest-age: find oldest age of last OR default state, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 9b792abceb 01/50: Initial annotation support for activities-completing-read, ELPA Syncer, 2024/12/25
- [elpa] externals/activities b07a5370de 02/50: Correct the file count, ELPA Syncer, 2024/12/25
- [elpa] externals/activities e829cf9fa2 03/50: re-org: move oldest-age up, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 1e14be5c59 06/50: simplify annotation-function using pcase-let*, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 61461aec1d 05/50: docs: fix typo in oldest-age, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 05d8dbcdc1 07/50: Use struct-slot-value instead of rolling our own function, ELPA Syncer, 2024/12/25