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

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

[nongnu] elpa/hyperdrive b403a9c7a3 044/102: Add: (hyperdrive-buffer-nam


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive b403a9c7a3 044/102: Add: (hyperdrive-buffer-name-format)
Date: Wed, 29 Nov 2023 04:00:51 -0500 (EST)

branch: elpa/hyperdrive
commit b403a9c7a33466d4fcc2b2ccde2ca42d6fa519ab
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add: (hyperdrive-buffer-name-format)
---
 hyperdrive-lib.el  | 35 ++++++++++++++++++++++++++--
 hyperdrive-vars.el | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 78c7f21a4a..d8a7675d5d 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1369,8 +1369,39 @@ Affected by option `hyperdrive-reuse-buffers', which 
see."
   (lambda (buffer) (hyperdrive--buffer-visiting-entry-p buffer entry)))
 
 (defun hyperdrive--entry-buffer-name (entry)
-  "Return buffer name for ENTRY."
-  (hyperdrive-entry-description entry :format-path 'name))
+  "Return buffer name for ENTRY.
+Formatted according to `hyperdrive-buffer-name-format', which
+see."
+  (pcase-let* (((cl-struct hyperdrive-entry hyperdrive name path version) 
entry)
+               ((cl-struct hyperdrive domains public-key petname seed
+                           (metadata (map ('name nickname))))
+                hyperdrive))
+    (format-spec hyperdrive-buffer-name-format
+                 ;; TODO(deprecate-28): Use lambdas in each specifier.
+                 `((?n . ,name)
+                   (?p . ,path)
+                   (?v . ,(if version
+                              (format hyperdrive-entry-version-format version)
+                            ""))
+                   (?D . ,(if domains
+                              (format hyperdrive-entry-domains-format
+                                      (string-join domains ","))
+                            ""))
+                   (?H . ,(hyperdrive--format-host
+                           hyperdrive :with-label t :with-faces nil))
+                   (?k . ,(format hyperdrive-entry-public-key-short-format
+                                  (concat (substring public-key 0 6) "…")))
+                   (?K . ,(format hyperdrive-entry-public-key-full-format
+                                  public-key))
+                   (?N . ,(if nickname
+                              (format hyperdrive-entry-nickname-format 
nickname)
+                            ""))
+                   (?P . ,(if petname
+                              (format hyperdrive-entry-petname-format petname)
+                            ""))
+                   (?S . ,(if seed
+                              (format hyperdrive-entry-seed-format seed)
+                            ""))))))
 
 (defun hyperdrive--entry-directory-p (entry)
   "Return non-nil if ENTRY is a directory."
diff --git a/hyperdrive-vars.el b/hyperdrive-vars.el
index b5efc769ba..f5a5bb27b7 100644
--- a/hyperdrive-vars.el
+++ b/hyperdrive-vars.el
@@ -165,6 +165,73 @@ an existing buffer at the same version, or make a new 
buffer."
   :type '(choice (const :tag "Use an existing buffer at any version" 
any-version)
                  (const :tag "Use an existing buffer at the same version" 
same-version)))
 
+;;;;;; Entry formatting
+
+(defgroup hyperdrive-entry-format nil
+  "Formatting of entries for buffer names, etc."
+  :group 'hyperdrive)
+
+(defcustom hyperdrive-buffer-name-format "[%H] %n%v"
+  "Format string for buffer names.
+Specifiers:
+
+%n  Entry name
+%p  Entry path
+%v  Entry version (see `hyperdrive-entry-version-format')
+
+%H Hyperdrive default host format (see
+   `hyperdrive-default-host-format')
+
+%D  Hyperdrive domains
+%k  Hyperdrive public key (short)
+%K  Hyperdrive public key (full)
+%N  Hyperdrive nickname
+%P  Hyperdrive petname
+%S  Hyperdrive seed"
+  :type 'string)
+
+(defcustom hyperdrive-entry-version-format " (version:%s)"
+  "Format string for entry version.
+\"%s\" is replaced with the entry version.  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
+(defcustom hyperdrive-entry-domains-format "domains:%s"
+  "Format string for entry domains.
+\"%s\" is replaced with the entry domains.  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
+(defcustom hyperdrive-entry-nickname-format "nickname:%s"
+  "Format string for entry nickname.
+\"%s\" is replaced with the entry nickname  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
+(defcustom hyperdrive-entry-petname-format "petname:%s"
+  "Format string for entry petname.
+\"%s\" is replaced with the entry petname  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
+(defcustom hyperdrive-entry-public-key-full-format "public-key:%s"
+  "Format string for entry full public-key.
+\"%s\" is replaced with the entry's full public-key.  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
+(defcustom hyperdrive-entry-public-key-short-format "public-key:%s"
+  "Format string for entry public-key (short format).
+\"%s\" is replaced with the entry's short public-key.  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
+(defcustom hyperdrive-entry-seed-format "seed:%s"
+  "Format string for entry seed.
+\"%s\" is replaced with the entry seed  Used in
+`hyperdrive-buffer-name-format', which see."
+  :type 'string)
+
 ;;;;; Faces
 
 (defgroup hyperdrive-faces nil



reply via email to

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