[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 357432877c 033/158: Implement annotation/affixat
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 357432877c 033/158: Implement annotation/affixation function |
Date: |
Wed, 19 Jan 2022 18:57:42 -0500 (EST) |
branch: externals/dtache
commit 357432877c685c25e9583c9e4e6f2f5585805ecd
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Implement annotation/affixation function
In order to provide annotations to all users dtache this patch
implements an annotation/affixation function which will provide
annotations for dtache-open-session.
---
dtache.el | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 79 insertions(+), 12 deletions(-)
diff --git a/dtache.el b/dtache.el
index 2ae7b82de1..e31c565795 100644
--- a/dtache.el
+++ b/dtache.el
@@ -79,6 +79,59 @@
"Hooks to run when compiling a session.")
(defvar dtache-metadata-annotators-alist nil
"An alist of annotators for metadata.")
+(defvar dtache-annotation-format
+ `((:width 3 :function dtache--active-str :face dtache-active-face)
+ (:width 3 :function dtache--status-str :face dtache-failure-face)
+ (:width 10 :function dtache--session-host :face dtache-host-face)
+ (:width 40 :function dtache--working-dir-str :face dtache-working-dir-face)
+ (:width 30 :function dtache--metadata-str :face dtache-metadata-face)
+ (:width 10 :function dtache--duration-str :face dtache-duration-face)
+ (:width 8 :function dtache--size-str :face dtache-size-face)
+ (:width 12 :function dtache--creation-str :face dtache-creation-face))
+ "The format of the annotations.")
+
+;;;;; Faces
+
+(defgroup dtache-faces nil
+ "Faces used by `dtache'."
+ :group 'dtache
+ :group 'faces)
+
+(defface dtache-metadata-face
+ '((t :inherit font-lock-builtin-face))
+ "Face used to highlight metadata in `dtache'.")
+
+(defface dtache-failure-face
+ '((t :inherit error))
+ "Face used to highlight failure in `dtache'.")
+
+(defface dtache-active-face
+ '((t :inherit success))
+ "Face used to highlight active in `dtache'.")
+
+(defface dtache-duration-face
+ '((t :inherit font-lock-builtin-face))
+ "Face used to highlight duration in `dtache'.")
+
+(defface dtache-size-face
+ '((t :inherit font-lock-function-name-face))
+ "Face used to highlight size in `dtache'.")
+
+(defface dtache-creation-face
+ '((t :inherit font-lock-comment-face))
+ "Face used to highlight date in `dtache'.")
+
+(defface dtache-working-dir-face
+ '((t :inherit font-lock-variable-name-face))
+ "Face used to highlight working directory in `dtache'.")
+
+(defface dtache-host-face
+ '((t :inherit font-lock-constant-face))
+ "Face used to highlight host in `dtache'.")
+
+(defface dtache-identifier-face
+ '((t :inherit font-lock-comment-face))
+ "Face used to highlight identifier in `dtache'.")
;;;;; Private
@@ -373,6 +426,17 @@ Sessions running on current host or localhost are
updated."
(dtache--session-short-id it))))
(prog1 s (put-text-property 0 1 'dtache--data it s))))
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-update-session (session)
"Update SESSION."
@@ -487,20 +551,23 @@ Sessions running on current host or localhost are
updated."
(defun dtache-completing-read (sessions)
"Select a session from SESSIONS through `completing-read'."
(let* ((candidates (dtache-session-candidates sessions))
- (metadata '(metadata
+ (metadata `(metadata
(category . dtache)
(cycle-sort-function . identity)
- (display-sort-function . identity)))
- (coll (lambda (string predicate action)
- (if (eq action 'metadata)
- metadata
- (complete-with-action action candidates string predicate))))
- (cand (minibuffer-with-setup-hook
- (lambda ()
- (add-hook 'after-change-functions 'dtache--eat-cookie nil
t))
- (completing-read "Select session: " coll nil t nil
- 'dtache-session-history))))
- (get-text-property 0 'dtache--data (car (member cand candidates)))))
+ (display-sort-function . identity)
+ (annotation-function . ,(lambda (s)
+ (dtache-session-annotation (cdr
(assoc s candidates)))))
+ (affixation-function .
+ ,(lambda (cands)
+ (seq-map (lambda (s)
+ `(,s nil
,(dtache-session-annotation (cdr (assoc s candidates)))))
+ cands)))))
+ (collection (lambda (string predicate action)
+ (if (eq action 'metadata)
+ metadata
+ (complete-with-action action candidates string
predicate))))
+ (cand (completing-read "Select session: " collection nil t nil
'dtache-session-history)))
+ (cdr (assoc cand candidates))))
(defun dtache-setup-notification (session)
"Setup notification for SESSION."
- [elpa] externals/dtache 9b9d58e6b5 011/158: Add flycheck-mode to .dir-locals, (continued)
- [elpa] externals/dtache 9b9d58e6b5 011/158: Add flycheck-mode to .dir-locals, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 9194f78dec 005/158: Update credits section, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 34b481d354 008/158: Add some more information to the README, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 91baa9ecfa 031/158: Update dtache-message detection, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache eaf141725f 044/158: Add compile section to tips and tricks in README, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache eb997e0b4e 023/158: Correct some spelling mistakes, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 082139f1c3 045/158: Add instructions on how to customize annotations, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache f6c9710c1b 017/158: Merge develop branch into master, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 99fd5c5b5c 025/158: Make sure to erase the output buffer, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b2eabec6c7 041/158: Improve dtache actions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 357432877c 033/158: Implement annotation/affixation function,
ELPA Syncer <=
- [elpa] externals/dtache ecc7563302 048/158: Update LICENSE, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2958d21869 035/158: Remove marginalia from dtache, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache afb2684f38 027/158: Improve dtache-env command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c29079e0c0 047/158: Remove dtache-session-history, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache db230154e4 016/158: Merge develop branch into master, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2a38a9b538 030/158: Robustify against failures in configuration, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 115de6c1a2 022/158: Add default value for dtache-max-command-length, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 09d378e50a 024/158: Fix read-only problematic, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 4e99fc9daa 049/158: Deprecate dtache-list-sessions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache cb1762ffc2 052/158: Add presentation about dtache version 0.2, ELPA Syncer, 2022/01/19