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

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

[elpa] externals/dtache 9a2f4a4d43 057/158: Introduce caching variable f


From: ELPA Syncer
Subject: [elpa] externals/dtache 9a2f4a4d43 057/158: Introduce caching variable for candidates
Date: Wed, 19 Jan 2022 18:57:55 -0500 (EST)

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

    Introduce caching variable for candidates
    
    Store candidates in a variable so that they can be accessed without
    having to re-generate the list of candidates.
---
 dtache.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/dtache.el b/dtache.el
index 1167110031..848f1a5a9c 100644
--- a/dtache.el
+++ b/dtache.el
@@ -157,6 +157,8 @@
   "Mode of operation for dtach.")
 (defvar dtache--sessions nil
   "A list of sessions.")
+(defvar dtache--session-candidates nil
+  "An alist of session candidates.")
 (defconst dtache--dtach-eof-message "\\[EOF - dtach terminating\\]\^M"
   "Message printed when `dtach' finishes.")
 (defconst dtache--dtach-detached-message "\\[detached\\]\^M"
@@ -424,15 +426,16 @@ Optionally make the path LOCAL to host."
 
 (defun dtache-session-candidates (sessions)
   "Return an alist of SESSIONS candidates."
-  (thread-last sessions
-               (seq-map (lambda (it)
-                          `(,(dtache--session-truncate-command it)
-                            . ,it)))
-               (dtache--session-deduplicate)
-               (seq-map (lambda (it)
-                          ;; Max width is the ... padding + width of identifier
-                          (setcar it (truncate-string-to-width (car it) (+ 3 6 
dtache-max-command-length) 0 ?\s))
-                          it))))
+  (setq dtache--session-candidates
+        (thread-last sessions
+                     (seq-map (lambda (it)
+                                `(,(dtache--session-truncate-command it)
+                                  . ,it)))
+                     (dtache--session-deduplicate)
+                     (seq-map (lambda (it)
+                                ;; Max width is the ... padding + width of 
identifier
+                                (setcar it (truncate-string-to-width (car it) 
(+ 3 6 dtache-max-command-length) 0 ?\s))
+                                it)))))
 
 (defun dtache--session-deduplicate (sessions)
   "Make car of SESSIONS unique by adding an identifier to it."



reply via email to

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