emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dtache 471a2f57c7 058/158: Update dtache-session-annota


From: ELPA Syncer
Subject: [elpa] externals/dtache 471a2f57c7 058/158: Update dtache-session-annotation
Date: Wed, 19 Jan 2022 18:57:56 -0500 (EST)

branch: externals/dtache
commit 471a2f57c712c369c20586301751c82fc5d5764f
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Update dtache-session-annotation
    
    Make the function more reusable by adding an initial association step
    to match the session based on an item. This change makes the function
    reusable in consult-dtache.
---
 dtache.el | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/dtache.el b/dtache.el
index 848f1a5a9c..db7628bf12 100644
--- a/dtache.el
+++ b/dtache.el
@@ -452,17 +452,18 @@ Optionally make the path LOCAL to host."
         (setcar session (format "%s%s" (car session) (make-string 
identifier-width ?\s)))))
     (seq-reverse reverse-sessions)))
 
-(defun dtache-session-annotation (session)
-  "Return annotation string for SESSION."
-  (mapconcat
-   #'identity
-   (cl-loop for annotation in dtache-annotation-format
-            collect (let ((str (funcall (plist-get annotation :function) 
session)))
-                      (truncate-string-to-width
-                       (propertize str 'face (plist-get annotation :face))
-                       (plist-get annotation :width)
-                       0 ?\s)))
-   "   "))
+(defun dtache-session-annotation (item)
+  "Associate ITEM to a session and return ts annotation."
+  (let ((session (cdr (assoc item dtache--session-candidates))))
+    (mapconcat
+     #'identity
+     (cl-loop for annotation in dtache-annotation-format
+              collect (let ((str (funcall (plist-get annotation :function) 
session)))
+                        (truncate-string-to-width
+                         (propertize str 'face (plist-get annotation :face))
+                         (plist-get annotation :width)
+                         0 ?\s)))
+     "   ")))
 
 (defun dtache-update-session (session)
   "Update SESSION."
@@ -623,12 +624,11 @@ Optionally make the path LOCAL to host."
                      (category . dtache)
                      (cycle-sort-function . identity)
                      (display-sort-function . identity)
-                     (annotation-function . ,(lambda (s)
-                                               (dtache-session-annotation (cdr 
(assoc s candidates)))))
+                     (annotation-function . dtache-session-annotation)
                      (affixation-function .
                                           ,(lambda (cands)
                                              (seq-map (lambda (s)
-                                                        `(,s nil 
,(dtache-session-annotation (cdr (assoc s candidates)))))
+                                                        `(,s nil 
,(dtache-session-annotation s)))
                                                       cands)))))
          (collection (lambda (string predicate action)
                        (if (eq action 'metadata)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]