[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached f943404ee6 04/10: Add unique narrow criteria
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached f943404ee6 04/10: Add unique narrow criteria |
Date: |
Thu, 27 Oct 2022 02:57:37 -0400 (EDT) |
branch: externals/detached
commit f943404ee6945f45820010cb9767ce63932b94cb
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Add unique narrow criteria
This criteria makes it convenient to only show the most recent session
if multiple sessions have the same string identifier. The identifier
function is customizable in case the user has other ideas of what is a
unique session.
---
CHANGELOG.org | 1 +
detached-list.el | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index dfccbb8586..5372f0c51a 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -15,6 +15,7 @@
- Add command for initializing a session directory
- Add integration with =nano-modeline=
- Add =detached-describe-session= command
+- Add unique narrow criteria
* Version 0.9.1 (2022-09-22)
diff --git a/detached-list.el b/detached-list.el
index 9daed31d26..444e346707 100644
--- a/detached-list.el
+++ b/detached-list.el
@@ -69,6 +69,12 @@ detached list implements."
:group 'detached
:type '(alist :key-type string))
+(defcustom detached-list-session-identifier-function
+ #'detached-list-session-identifier
+ "The function to use for identifying a session."
+ :group 'detached
+ :type 'sexp)
+
;;;; Private
(defvar detached-list--marked-sessions nil
@@ -98,6 +104,14 @@ detached list implements."
(propertize annotation 'face
'detached-annotation-face)))))
(string-join (seq-remove #'null strs) "\n")))))
+(defun detached-list-session-identifier (session)
+ "Return a string identifier for SESSION."
+ (string-join
+ `(,(detached--session-command session)
+ ,(detached--host-str session)
+ ,(detached--session-directory session))
+ ", "))
+
;;;; Commands
(defun detached-list-initialize-session-directory (&optional all)
@@ -237,6 +251,24 @@ Optionally SUPPRESS-OUTPUT."
(bury-buffer buffer))
(detached-open-session session)))
+(defun detached-list-narrow-unique ()
+ "Narrow to unique sessions."
+ (interactive)
+ (when detached-list-session-identifier-function
+ (detached-list-narrow-sessions
+ `(,@detached-list--narrow-criteria
+ ("Unique" .
+ ,(lambda (sessions)
+ (thread-last sessions
+ (seq-group-by
detached-list-session-identifier-function)
+ (seq-map (lambda (it)
+ (pcase-let ((`(,_identifier .
,duplicate-sessions) it))
+ (car duplicate-sessions))))
+ (seq-sort-by
+ (lambda (it)
+ (plist-get (detached--session-time it) :start))
+ #'>))))))))
+
(defun detached-list-narrow-after-time (time-threshold)
"Narrow to session's created after TIME-THRESHOLD."
(interactive
@@ -759,6 +791,7 @@ If prefix-argument is provided unmark instead of mark."
(define-key map (kbd "n o") #'detached-list-narrow-origin)
(define-key map (kbd "n r") #'detached-list-narrow-remote)
(define-key map (kbd "n s") #'detached-list-narrow-success)
+ (define-key map (kbd "n u") #'detached-list-narrow-unique)
(define-key map (kbd "n +") #'detached-list-narrow-after-time)
(define-key map (kbd "n -") #'detached-list-narrow-before-time)
(define-key map (kbd "n /") #'detached-list-narrow-output-regexp)
- [elpa] externals/detached updated (7796d2e6f2 -> d0dc9d0f92), ELPA Syncer, 2022/10/27
- [elpa] externals/detached 413cd86120 01/10: Remove validation of session when copying command, ELPA Syncer, 2022/10/27
- [elpa] externals/detached 30bd263210 06/10: Add criteria working/session-directory, ELPA Syncer, 2022/10/27
- [elpa] externals/detached 7b058ef99e 09/10: Update command string in detached-list-mode, ELPA Syncer, 2022/10/27
- [elpa] externals/detached 6aea11b5e8 03/10: Update detached-list diff sessions command, ELPA Syncer, 2022/10/27
- [elpa] externals/detached f943404ee6 04/10: Add unique narrow criteria,
ELPA Syncer <=
- [elpa] externals/detached 66bc2811fb 08/10: Add possibility to toggle initial-mode when rerun, ELPA Syncer, 2022/10/27
- [elpa] externals/detached acac8bd3eb 02/10: Update to correct order of criteria, ELPA Syncer, 2022/10/27
- [elpa] externals/detached 655b3b03e9 07/10: Update detached-list narrow bindings, ELPA Syncer, 2022/10/27
- [elpa] externals/detached a3a7cd963c 05/10: Remove regexp suffix for some criteria, ELPA Syncer, 2022/10/27
- [elpa] externals/detached d0dc9d0f92 10/10: Merge status and state in detached-list, ELPA Syncer, 2022/10/27