[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/activities 542f4e4a65 16/50: annotate: compare file tru
From: |
ELPA Syncer |
Subject: |
[elpa] externals/activities 542f4e4a65 16/50: annotate: compare file truenames and buffers correctly |
Date: |
Wed, 25 Dec 2024 03:57:18 -0500 (EST) |
branch: externals/activities
commit 542f4e4a65cdd52e4285698c2936fb0092c9c249
Author: J.D. Smith <jdtsmith@gmail.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
annotate: compare file truenames and buffers correctly
The buffer names can differ when symbolic links or buffers with
repeated names (e.g. the same file from multiple directories) are
included in active activities' window states. Rather than compare
buffer names alone, compare (true) filename or, if the buffer has no
associated file, the buffer name, to test for state modification.
---
activities.el | 75 +++++++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 35 deletions(-)
diff --git a/activities.el b/activities.el
index 7133475f46..e464f83041 100644
--- a/activities.el
+++ b/activities.el
@@ -863,42 +863,47 @@ OLDEST-POSSIBLE is the oldest age in the
`vc-annotate-color-map'."
(dolist (type '(last default))
(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))))))))
+ (buffers-and-files
+ (activities--map-window-state-leafs
+ (activities-activity-state-window-state state)
+ (lambda (leaf)
+ (let ((rec (map-nested-elt (cdr leaf) '(parameters
activities-buffer))))
+ (cons (activities-buffer-name rec)
(activities-buffer-filename rec)))))))
(setf (alist-get type data)
- (list (length (delq nil files))
- (and time (float-time (time-since time))) buffers)))))
- (pcase-let* ((`(,num-last-files ,last-age ,last-buffers) (map-elt data
'last))
- (`(,num-default-files ,default-age ,default-buffers)
(map-elt data 'default))
- (age (if last-age (min last-age default-age) default-age))
- (num-buffers (length (or last-buffers default-buffers)))
- (num-files (or num-last-files num-default-files))
- (dirtyp (when last-buffers
- (or (/= (length last-buffers) (length
default-buffers))
- (not (seq-set-equal-p last-buffers
default-buffers)))))
- (annotation (format "%s bufs %s files "
- (propertize (format "%2d" num-buffers)
'face 'success)
- (propertize (format "%2d" num-files)
'face 'warning)))
- (age-color (or (cdr (vc-annotate-compcar
- (* (/ age max-age) oldest-possible)
- vc-annotate-color-map))
- vc-annotate-very-old-color))
- (age-annotation (propertize
- (format "%15s" (apply #'format "[%d %s]"
(activities--age age)))
- 'face `(:foreground ,age-color
- :background
,vc-annotate-background)))
- (dirty-annotation (propertize (if dirtyp "*" " ") 'face
'bold)))
- (concat (propertize " " 'display
- `(space :align-to
- (- right ,(+ (length annotation) (length
age-annotation) 1))))
- annotation age-annotation dirty-annotation))))))
+ (list (and time (float-time (time-since time)))
buffers-and-files)))))
+ (cl-labels ((file-or-buffer (cell)
+ "Given (buffer . file), return the true filename or (if
none) buffer."
+ (if (cdr cell) (file-truename (cdr cell)) (car cell)))
+ (buffers-and-files-differ-p (bf1 bf2)
+ "Return t if BF1 and BF2 are not the same set of files or
buffers."
+ (not (seq-set-equal-p (mapcar #'file-or-buffer bf1)
+ (mapcar #'file-or-buffer bf2)))))
+ (pcase-let* ((`(,last-age ,last-buffers-and-files) (map-elt data
'last)) ;possibly nil
+ (`(,default-age ,default-buffers-and-files) (map-elt
data 'default))
+ (age (if last-age (min last-age default-age)
default-age))
+ (buffers-and-files (if last-age
+ last-buffers-and-files
+ default-buffers-and-files))
+ (num-buffers (length buffers-and-files))
+ (num-files (seq-count #'stringp (mapcar #'cdr
buffers-and-files)))
+ (dirtyp (when last-buffers-and-files
+ (buffers-and-files-differ-p
last-buffers-and-files
+
default-buffers-and-files)))
+ (activep (activities-activity-active-p activity))
+ (annotation (format "%s bufs %s files "
+ (propertize (format "%2d"
num-buffers) 'face 'success)
+ (propertize (format "%2d" num-files)
'face 'warning)))
+ (age-color (or (cdr (vc-annotate-compcar
+ (* (/ age max-age) oldest-possible)
+ vc-annotate-color-map))
+ vc-annotate-very-old-color))
+ (age-annotation (propertize
+ (format "%15s" (apply #'format "[%d %s]"
+ (activities--age
age)))
+ 'face `(:foreground ,age-color
+ `(space :align-to (- right ,(+ 1 (length
annotation)
+ (length
age-annotation)))))
+ annotation age-annotation dirty-annotation)))))))
(cl-defun activities-completing-read
(&key (activities activities-activities)
- [elpa] externals/activities updated (59caef88e6 -> 31ec5154dd), ELPA Syncer, 2024/12/25
- [elpa] externals/activities 2fc364df30 09/50: map-window-state-leafs: remove additional unused pcase branch, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 16981be880 10/50: annotate: remove extra indentation-preserving space in function call, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 0ce4fefe10 08/50: map-window-state-leafs: omit unused pcase branch, ELPA Syncer, 2024/12/25
- [elpa] externals/activities d855ed0a45 11/50: annotate: rename vars and simplify age padding, ELPA Syncer, 2024/12/25
- [elpa] externals/activities c2c24484bf 15/50: annotate: make variable names more explicit, ELPA Syncer, 2024/12/25
- [elpa] externals/activities 542f4e4a65 16/50: annotate: compare file truenames and buffers correctly,
ELPA Syncer <=
- [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