[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive 549d24ef9e 1/3: Tidy: (hyperdrive--format-host)
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive 549d24ef9e 1/3: Tidy: (hyperdrive--format-host) Use cl-flet for conciseness |
Date: |
Fri, 8 Sep 2023 03:59:54 -0400 (EDT) |
branch: elpa/hyperdrive
commit 549d24ef9e1ee4fb4108fcfdf57cb84b647568a0
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>
Tidy: (hyperdrive--format-host) Use cl-flet for conciseness
---
hyperdrive-lib.el | 66 +++++++++++++++++++------------------------------------
1 file changed, 23 insertions(+), 43 deletions(-)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 5019a5a305..ed363e24e1 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -878,49 +878,29 @@ When WITH-FACES is nil, don't add face text properties."
(pcase-let* (((cl-struct hyperdrive petname public-key domains seed
(metadata (map name)))
hyperdrive))
- (cl-loop for f in format
- when (pcase f
- ;; TODO: Generalize this logic for conciseness.
- ((and 'petname (guard petname))
- (concat (when with-label
- "petname:")
- (if with-faces
- (propertize petname 'face 'hyperdrive-petname)
- petname)))
- ((and 'nickname (guard name))
- (concat (when with-label
- "nickname:")
- (if with-faces
- (propertize name 'face 'hyperdrive-nickname)
- name)))
- ((and 'domain (guard (car domains)))
- ;; TODO: Handle the unlikely case that a drive has
multiple domains.
- (concat (when with-label
- "domain:")
- (if with-faces
- (propertize (car domains) 'face
'hyperdrive-domain)
- (car domains))))
- ((and 'seed (guard seed))
- (concat (when with-label
- "seed:")
- (if with-faces
- (propertize seed 'face 'hyperdrive-seed)
- seed)))
- ((and 'short-key (guard public-key))
- ;; TODO: Consider adding a help-echo with the full key.
- (concat (when with-label
- "public-key:")
- (if with-faces
- (propertize (concat (substring public-key 0
6) "…")
- 'face 'hyperdrive-public-key)
- (concat (substring public-key 0 6) "…"))))
- ((and 'public-key (guard public-key))
- (concat (when with-label
- "public-key:")
- (if with-faces
- (propertize public-key 'face
'hyperdrive-public-key)
- public-key))))
- return it)))
+ (cl-flet ((fmt (string label face)
+ (concat (when with-label
+ label)
+ (if with-faces
+ (propertize string 'face face)
+ string))))
+ (cl-loop for f in format
+ when (pcase f
+ ((and 'petname (guard petname))
+ (fmt petname "petname:" 'hyperdrive-petname))
+ ((and 'nickname (guard name))
+ (fmt name "nickname:" 'hyperdrive-nickname))
+ ((and 'domain (guard (car domains)))
+ ;; TODO: Handle the unlikely case that a drive has
multiple domains.
+ (fmt (car domains) "domain:" 'hyperdrive-domain))
+ ((and 'seed (guard seed))
+ (fmt seed "seed:" 'hyperdrive-seed))
+ ((and 'short-key (guard public-key))
+ ;; TODO: Consider adding a help-echo with the full key.
+ (fmt (concat (substring public-key 0 6) "…")
"public-key:" 'hyperdrive-public-key))
+ ((and 'public-key (guard public-key))
+ (fmt public-key "public-key:" 'hyperdrive-public-key)))
+ return it))))
;;;; Reading from the user