Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annotations and sorting for activities-completing-read #83

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6f4ba19
Initial annotation support for activities-completing-read
jdtsmith Apr 20, 2024
963321c
Correct the file count
jdtsmith Apr 20, 2024
dac0937
re-org: move oldest-age up
jdtsmith Apr 20, 2024
650cba7
Find oldest colormap age just once per read
jdtsmith Apr 20, 2024
d9f9819
docs: fix typo in oldest-age
jdtsmith Apr 20, 2024
e083a42
simplify annotation-function using pcase-let*
jdtsmith Apr 21, 2024
113f72f
Use struct-slot-value instead of rolling our own function
jdtsmith Apr 23, 2024
e6e52ac
map-window-state-leafs: omit unused pcase branch
jdtsmith Apr 23, 2024
fb18108
map-window-state-leafs: remove additional unused pcase branch
jdtsmith Apr 23, 2024
2e3b2d3
annotate: remove extra indentation-preserving space in function call
jdtsmith Apr 23, 2024
a4115ac
annotate: rename vars and simplify age padding
jdtsmith Apr 23, 2024
55e10dc
annotate: correct indentation for makem.sh
jdtsmith Apr 23, 2024
2bfabb1
handle missing last state and add `*' for modified state buffer list
jdtsmith Apr 23, 2024
1f2a81c
README: add information about the annotations
jdtsmith Apr 23, 2024
6c26c59
annotate: make variable names more explicit
jdtsmith Apr 23, 2024
061207d
annotate: compare file truenames and buffers correctly
jdtsmith Apr 24, 2024
c3849d9
annotate: indicate active and modified using final flag char
jdtsmith Apr 24, 2024
b67a3f5
annotate: separate active flag (@) from modified flag (*)
jdtsmith Apr 24, 2024
06874ea
Handle plurals correctly in annotation bufs/files
jdtsmith Apr 24, 2024
1c497c6
completing-read: sort completion using new completion-table
jdtsmith Apr 25, 2024
671f6a2
annotate: "zero files" is plural
jdtsmith Apr 25, 2024
743d75b
Make activities--annotate privately named
jdtsmith May 19, 2024
5b62bd2
Remove debug message
jdtsmith May 19, 2024
139b877
Factor out buffer-and-files comparison functions
jdtsmith May 19, 2024
1949ecd
save: retain last timestamp when buffer and files have not changed
jdtsmith May 19, 2024
2f30cff
README: improve annotation/sorting docs
jdtsmith May 19, 2024
0f2c097
Inline activities--completion-table
jdtsmith Jun 15, 2024
2d4ae67
buffer-and-files-differ: improve docstring
jdtsmith Jun 15, 2024
4081f7e
buffers-and-files: better var name
jdtsmith Jun 15, 2024
a998a32
map-window-state-leafs -> mapcar-window-state-leafs
jdtsmith Jun 15, 2024
5af4c43
cl-labels file-or-buffer: improve docstring
jdtsmith Jun 15, 2024
90db238
inline annotation-function and eliminate vc-annotate
jdtsmith Jun 15, 2024
e6dadfe
mapcar-window-state-leafs: improve varnames and docstring
jdtsmith Jun 15, 2024
1335f33
buffers-and-files: fix docstring typo
jdtsmith Jun 15, 2024
4aca4ab
activities--age: rewrite, note future core replacement
jdtsmith Jun 23, 2024
389fa29
improve custom activities-sort-function -> activities-sort-by
jdtsmith Jul 13, 2024
0aafb28
activities-annotation-colors: simplify doc and use ALPHA
jdtsmith Jul 13, 2024
9ec15fe
activities--buffers-and-files-differ-p: rename args for clarity
jdtsmith Jul 13, 2024
205a6b2
age: mention related bug report and magit--age in comment
jdtsmith Jul 13, 2024
47b475c
sort-by-active-age: reformulate using pcase
jdtsmith Jul 13, 2024
b60b7df
activities-completing-read: use cl-labels for clarity
jdtsmith Jul 13, 2024
bf88a40
README: rename section as Completion
jdtsmith Jul 13, 2024
bc2e2a2
README: simplify Completion description
jdtsmith Jul 13, 2024
9ab50c2
oldest-age: find oldest age of last OR default state
jdtsmith Jul 13, 2024
6c56933
sort-by: use function-item for custom
jdtsmith Jul 18, 2024
e1d7fcf
completing-read: make sort-by always set to a sort function
jdtsmith Jul 18, 2024
482bc10
sort-by-active-age: fix sort logic
jdtsmith Jul 18, 2024
dbbda99
README: mention new completion interface in Changelog
jdtsmith Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 31 additions & 30 deletions activities.el
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ Adapted from `magit--age'."
(cl-loop
for type in '(default last)
for state = (cl-struct-slot-value 'activities-activity type act)
if state
for etc = (activities-activity-state-etc state)
maximize (float-time (time-since (map-elt etc 'time))))))

Expand All @@ -858,44 +859,44 @@ OLDEST-POSSIBLE is the oldest age in the `vc-annotate-color-map'."
(when-let ((activity (map-elt activities-activities name)))
(let (data)
(dolist (type '(last default))
(let* ((state (cl-struct-slot-value 'activities-activity type activity))
(time (map-elt (activities-activity-state-etc state) 'time))
(window-state (activities-activity-state-window-state state))
(buffers (window-state-buffers window-state))
(files (activities--map-window-state-leafs
window-state
(lambda (leaf)
(bookmark-get-filename
(activities-buffer-bookmark
(map-nested-elt (cdr leaf)
'(parameters activities-buffer))))))))
(setf (alist-get type data)
(list (length buffers)
(length (delq nil files))
(float-time (time-since time))))))
(pcase-let* ((`(,last-bufs ,last-files ,last-time) (map-elt data 'last))
(`(,default-bufs ,default-files ,default-time) (map-elt data 'default))
(age (min last-time default-time))
(ann (format "%s:%s|%s %s:%s|%s "
(propertize "buffers" 'face 'bold)
(propertize (format "%2d" last-bufs) 'face 'success)
(propertize (format "%-2d" default-bufs) 'face 'warning)
(propertize "files" 'face 'bold)
(propertize (format "%2d" last-files) 'face 'success)
(propertize (format "%-2d" default-files) 'face 'warning)))
(when-let ((state (cl-struct-slot-value 'activities-activity type activity)))
(let* ((time (map-elt (activities-activity-state-etc state) 'time))
(window-state (activities-activity-state-window-state state))
(buffers (window-state-buffers window-state))
(files (activities--map-window-state-leafs
window-state
(lambda (leaf)
(bookmark-get-filename
(activities-buffer-bookmark
(map-nested-elt (cdr leaf)
'(parameters activities-buffer))))))))
(setf (alist-get type data)
(list (length (delq nil files))
alphapapa marked this conversation as resolved.
Show resolved Hide resolved
(and time (float-time (time-since time))) buffers)))))
(pcase-let* ((`(,last-file-cnt ,last-age ,last-bufs) (map-elt data 'last))
jdtsmith marked this conversation as resolved.
Show resolved Hide resolved
(`(,default-file-cnt ,default-age ,default-bufs) (map-elt data 'default))
(age (if last-age (min last-age default-age) default-age))
(buf-cnt (length (or last-bufs default-bufs)))
(file-cnt (or last-file-cnt default-file-cnt))
(dirty (and last-bufs
jdtsmith marked this conversation as resolved.
Show resolved Hide resolved
(or (/= (length last-bufs) (length default-bufs))
(not (seq-set-equal-p last-bufs default-bufs)))))
(ann (format "%s bufs %s files "
(propertize (format "%2d" buf-cnt) 'face 'success)
(propertize (format "%2d" file-cnt) 'face 'warning)))
jdtsmith marked this conversation as resolved.
Show resolved Hide resolved
(age-color (or (cdr (vc-annotate-compcar
(* (/ age max-age) oldest-possible)
vc-annotate-color-map))
vc-annotate-very-old-color))
(age-ann (propertize
(format "%15s" (apply #'format "[%d %s]"
(activities--age age)))
(format "%15s" (apply #'format "[%d %s]" (activities--age age)))
'face `( :foreground ,age-color
:background ,vc-annotate-background))))
:background ,vc-annotate-background)))
(dirty-ann (propertize (if dirty "*" " ") 'face 'bold)))
(concat (propertize " " 'display
`( space :align-to
(- right ,(+ (length ann) (length age-ann)))))
ann age-ann))))))
(- right ,(+ (length ann) (length age-ann) 1))))
ann age-ann dirty-ann))))))

(cl-defun activities-completing-read
(&key (activities activities-activities)
Expand Down