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

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

[nongnu] elpa/hyperdrive 5bad8e2762 040/123: Add: (hyperdrive-menu-hyper


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive 5bad8e2762 040/123: Add: (hyperdrive-menu-hyperdrive) Transient for modifying hyperdrive
Date: Fri, 6 Oct 2023 01:01:01 -0400 (EDT)

branch: elpa/hyperdrive
commit 5bad8e276223c76296bca0e0236fac8bf535d252
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>

    Add: (hyperdrive-menu-hyperdrive) Transient for modifying hyperdrive
---
 hyperdrive-menu.el | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/hyperdrive-menu.el b/hyperdrive-menu.el
index a6093643b4..a47c319c63 100644
--- a/hyperdrive-menu.el
+++ b/hyperdrive-menu.el
@@ -49,6 +49,38 @@
 
 (declare-function hyperdrive-dir--entry-at-point "hyperdrive-dir")
 
+(transient-define-prefix hyperdrive-menu-hyperdrive (hyperdrive)
+  "Show menu for editing HYPERDRIVE."
+  [ :description
+    (lambda ()
+      (let ((hyperdrive (oref transient--prefix scope)))
+        (concat (propertize "Drive: " 'face 'transient-heading)
+                (hyperdrive--format-hyperdrive hyperdrive :formats 
'(public-key seed domain))
+                (format "  latest:%s" (hyperdrive-latest-version 
hyperdrive)))))
+    ("n" "set nickname" hyperdrive-menu-hyperdrive-set-nickname
+     :if (lambda ()
+           (hyperdrive-writablep (oref transient--prefix scope)))
+     :description (lambda ()
+                    (format "Nickname: %s"
+                            ;; TODO: Hyperdrive-metadata accessor (and maybe 
gv setter).
+                            (pcase (alist-get 'name
+                                              (hyperdrive-metadata
+                                               (oref transient--prefix scope)))
+                              ('nil (propertize "none"
+                                                'face 
'transient-inactive-value))
+                              (it (propertize it
+                                              'face 'transient-value))))))]
+  (interactive (list (hyperdrive-complete-hyperdrive :force-prompt 
current-prefix-arg)))
+  (transient-setup 'hyperdrive-menu-hyperdrive nil nil :scope hyperdrive))
+
+(transient-define-suffix hyperdrive-menu-hyperdrive-set-nickname (nickname)
+  ;; TODO: Offer current nickname as default value; note that
+  ;; transient--prefix and transient-current-prefix are both nil here.
+  (interactive (list (hyperdrive-read-name :prompt "New nickname")))
+  (hyperdrive-set-nickname nickname (oref transient-current-prefix scope)
+                           :then (lambda (hyperdrive)
+                                   (hyperdrive-menu-hyperdrive hyperdrive))))
+
 (transient-define-suffix hyperdrive-menu-up ()
   ;; :transient 'transient--do-call
   (interactive)



reply via email to

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