[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sesman 81a2136489 078/100: New SORT argument to sesman-cur
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sesman 81a2136489 078/100: New SORT argument to sesman-current-links |
Date: |
Tue, 28 Dec 2021 14:06:04 -0500 (EST) |
branch: elpa/sesman
commit 81a2136489823c95ebe710640fd65717ff35a550
Author: Vitalie Spinu <spinuvit@gmail.com>
Commit: Vitalie Spinu <spinuvit@gmail.com>
New SORT argument to sesman-current-links
---
sesman.el | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/sesman.el b/sesman.el
index 9e0013627a..f924eaf13f 100644
--- a/sesman.el
+++ b/sesman.el
@@ -121,7 +121,7 @@ Can be either a symbol, or a function returning a symbol.")
(when ses
(list ses))))
((or (equal which '(4)) (eq which 'linked))
- (sesman--linked-sessions system))
+ (sesman--linked-sessions system 'sort))
((or (equal which '(16)) (eq which 'all) (eq which t))
(sesman--all-system-sessions system 'sort))
;; session itself
@@ -200,7 +200,7 @@ Can be either a symbol, or a function returning a symbol.")
(delete-dups
(mapcar (lambda (assoc)
(gethash (car assoc) sesman-sessions-hashmap))
- (sesman-current-links system nil cxt-types)))))
+ (sesman-current-links system nil sort cxt-types)))))
(defun sesman--friendly-sessions (system &optional sort)
(let ((sessions (seq-filter (lambda (ses) (sesman-friendly-session-p system
ses))
@@ -558,7 +558,7 @@ use `sesman-more-recent-p' utility in this method."
(cl-defgeneric sesman-friendly-session-p (_system _session)
"Return non-nil if SESSION is a friendly session in current context.
The \"friendship\" is system dependent but usually means sessions running in
-dependency projects. Unless SYSTEM has defined a method for this generic, there
+dependent projects. Unless SYSTEM has defined a method for this generic, there
are no friendly sessions."
nil)
@@ -577,8 +577,8 @@ Contexts must be sorted from most specific to least
specific."
(defun sesman-sessions (system &optional sort type cxt-types)
"Return a list of sessions registered with SYSTEM.
-When TYPE is either 'all or nil return all sessions registered with system,
when
-'linked, only linked sessions to the current context, when 'friendly return
only
+When TYPE is either 'all or nil return all sessions registered with the SYSTEM,
+when 'linked, only linked to the current context sessions, when 'friendly -
only
friendly sessions. If SORT is non-nil, sessions are sorted in the relevance
order with linked sessions leading the list. CXT-TYPES is a list of context
types to consider for linked sessions."
@@ -591,8 +591,8 @@ types to consider for linked sessions."
((memq type '(all nil))
(if sort
(delete-dups
- (append (sesman--linked-sessions system t cxt-types)
- (sesman--all-system-sessions system t)))
+ (append (sesman--linked-sessions system 'sort cxt-types)
+ (sesman--all-system-sessions system 'sort)))
(sesman--all-system-sessions system)))
(t (error "Invalid session TYPE argument %s" type)))))
@@ -604,9 +604,9 @@ sessions, otherwise only of linked sessions. CXT-TYPES is a
list of context
types to consider. Defaults to the list returned from `sesman-context-types'."
(if sesman-use-friendly-sessions
(delete-dups
- (append (sesman--linked-sessions system cxt-types)
+ (append (sesman--linked-sessions system 'sort cxt-types)
(sesman--friendly-sessions system 'sort)))
- (sesman--linked-sessions system cxt-types)))
+ (sesman--linked-sessions system 'sort cxt-types)))
(defun sesman-has-sessions-p (system)
"Return t if there is at least one session registered with SYSTEM."
@@ -662,7 +662,7 @@ return a list of sessions, otherwise a single session."
(defun sesman-current-session (system &optional cxt-types)
"Get the most relevant current session for the SYSTEM.
CXT-TYPES is a list of context types to consider."
- (or (car (sesman--linked-sessions system cxt-types))
+ (or (car (sesman--linked-sessions system 'sort cxt-types))
(car (sesman--friendly-sessions system 'sort))))
(defun sesman-ensure-session (system &optional cxt-types)
@@ -779,24 +779,25 @@ list, otherwise links are returned in the creation order."
(sesman--sort-links system (seq-filter lfn
sesman-links-alist))))
(seq-filter lfn sesman-links-alist))))
-(defun sesman-current-links (system &optional session-or-name cxt-types)
+(defun sesman-current-links (system &optional session-or-name sort cxt-types)
"Retrieve all active links in current context for SYSTEM and SESSION-OR-NAME.
SESSION-OR-NAME can be either a session or a name of the session. CXT-TYPES is
a
list of context types to consider. Returned links are a subset of
-`sesman-links-alist' sorted in order of relevance."
+`sesman-links-alist' sorted in order of relevance if SORT is non-nil."
;; mapcan is a built-in in 26.1; don't want to require cl-lib for one
function
(let ((ses-name (if (listp session-or-name)
(car session-or-name)
session-or-name)))
(seq-mapcat
(lambda (cxt-type)
- (let ((lfn (sesman--link-lookup-fn system ses-name cxt-type)))
- (sesman--sort-links
- system
- (seq-filter (lambda (l)
- (and (funcall lfn l)
- (sesman-relevant-context-p cxt-type
(sesman--lnk-value l))))
- sesman-links-alist))))
+ (let* ((lfn (sesman--link-lookup-fn system ses-name cxt-type))
+ (links (seq-filter (lambda (l)
+ (and (funcall lfn l)
+ (sesman-relevant-context-p cxt-type
(sesman--lnk-value l))))
+ sesman-links-alist)))
+ (if sort
+ (sesman--sort-links system links)
+ links)))
(or cxt-types (sesman-context-types system)))))
(defun sesman-has-links-p (system &optional cxt-types)
- [nongnu] elpa/sesman e06a40589d 010/100: Move back from cider new-connection branch, (continued)
- [nongnu] elpa/sesman e06a40589d 010/100: Move back from cider new-connection branch, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman ec275e2e10 009/100: Readme, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 8f2784a4ba 001/100: Initial commit, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 7987deb2c4 011/100: Makefile, tests, travis, checkdoc, .dir-locals, .gitignore etc., ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman b839a2379a 005/100: More bulk updates, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 27bd3bf457 020/100: Remove disambiguation defcustom and simplify sesman-ensure-linked-session, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman df5a081689 029/100: Fix a fixme :-), ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 5fc5934b5f 044/100: Extend semantics of 'which' argument in interactive commands, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman b8a1cdd20e 056/100: Add lint target for convenience, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 779c034180 082/100: Update doc of the sesman-project generic, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 81a2136489 078/100: New SORT argument to sesman-current-links,
ELPA Syncer <=
- [nongnu] elpa/sesman 083cf73f3f 079/100: Version 0.3.2, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 1a6c5448cb 081/100: Don't use deleted sesman-connected-p, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 3a08e3e7de 085/100: Bump dev version, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 9c921699ce 090/100: Use elipsis instead of %%s for the common session name, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 90974f9fcf 092/100: Update README: sesman-kill* -> sesman-quit*, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 2a1a9a4ccf 087/100: Promote sesman-expand-path into public API, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman e8bfb0e379 091/100: Convert buffers to strings during formatting, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman fe92090cb6 099/100: Reformulate sesman-unlink docs, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 16fb6eca09 016/100: Fix package-lint issues, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman cdb8e0973a 018/100: Port back from CIDER, ELPA Syncer, 2021/12/28