Function: sesman-grouped-links
sesman-grouped-links is a byte-compiled function defined in sesman.el.
Signature
(sesman-grouped-links SYSTEM SESSION &optional CURRENT-FIRST AS-STRING)
Documentation
Retrieve all links for SYSTEM's SESSION from the global sesman-links-alist.
Return an alist of the form
((buffer buffers..)
(directory directories...)
(project projects...)).
When CURRENT-FIRST is non-nil, a cons of two lists as above is returned with car containing links relevant in current context and cdr all other links. If AS-STRING is non-nil, return an equivalent string representation.
Source Code
;; Defined in ~/.emacs.d/elpa/sesman-20240417.1723/sesman.el
(defun sesman-grouped-links (system session &optional current-first as-string)
"Retrieve all links for SYSTEM's SESSION from the global `sesman-links-alist'.
Return an alist of the form
((buffer buffers..)
(directory directories...)
(project projects...)).
When `CURRENT-FIRST' is non-nil, a cons of two lists as above is returned with
car containing links relevant in current context and cdr all other links. If
AS-STRING is non-nil, return an equivalent string representation."
(let* ((system (or system (sesman--system)))
(session (or session (sesman-current-session system)))
(ses-name (car session))
(links (thread-last sesman-links-alist
(seq-filter (sesman--link-lookup-fn system ses-name))
(sesman--sort-links system)
(reverse)))
(out (mapcar (lambda (x) (list x))
(sesman-context-types system)))
(out-rel (when current-first
(copy-alist out))))
(mapc (lambda (link)
(let* ((type (sesman--lnk-context-type link))
(entry (if (and current-first
(sesman-relevant-link-p link))
(assoc type out-rel)
(assoc type out))))
(when entry
(setcdr entry (cons link (cdr entry))))))
links)
(let ((out (delq nil (mapcar (lambda (el) (and (cdr el) el)) out)))
(out-rel (delq nil (mapcar (lambda (el) (and (cdr el) el)) out-rel))))
(if as-string
(let ((fmt-fn (lambda (typed-links)
(let* ((type (car typed-links)))
(mapconcat (lambda (lnk)
(let ((val (sesman--abbrev-path-maybe
(sesman--lnk-value lnk))))
(sesman--format-context type val 'italic)))
(cdr typed-links)
", ")))))
(if out-rel
(concat (mapconcat fmt-fn out-rel ", ")
(when out " | ")
(mapconcat fmt-fn out ", "))
(mapconcat fmt-fn out ", ")))
(if current-first
(cons out-rel out)
out)))))