[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive b2afbfaa60 046/102: Change: Replace -entry-desc
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/hyperdrive b2afbfaa60 046/102: Change: Replace -entry-description with --format-entry, etc. |
|
Date: |
Wed, 29 Nov 2023 04:00:52 -0500 (EST) |
branch: elpa/hyperdrive
commit b2afbfaa6042eaf055970e5f5f7ea1661357096d
Author: Adam Porter <adam@alphapapa.net>
Commit: Joseph Turner <joseph@ushin.org>
Change: Replace -entry-description with --format-entry, etc.
---
hyperdrive-diff.el | 10 ++++---
hyperdrive-dir.el | 6 ++--
hyperdrive-history.el | 2 +-
hyperdrive-lib.el | 81 ++++++++++++++++++++-------------------------------
hyperdrive-org.el | 4 +--
hyperdrive-vars.el | 15 ++++++++--
hyperdrive.el | 21 ++++++-------
7 files changed, 68 insertions(+), 71 deletions(-)
diff --git a/hyperdrive-diff.el b/hyperdrive-diff.el
index ed4954b916..05c2440ba8 100644
--- a/hyperdrive-diff.el
+++ b/hyperdrive-diff.el
@@ -71,9 +71,11 @@ This function is intended to diff files, not directories."
(unless (or old-response new-response)
(hyperdrive-error "Files non-existent"))
(let ((old-buffer (generate-new-buffer
- (hyperdrive-entry-description
old-entry)))
+ (hyperdrive--format-entry
+ old-entry
hyperdrive-buffer-name-format)))
(new-buffer (generate-new-buffer
- (hyperdrive-entry-description
new-entry)))
+ (hyperdrive--format-entry
+ new-entry
hyperdrive-buffer-name-format)))
;; TODO: Improve diff buffer name.
(diff-buffer (get-buffer-create
"*hyperdrive-diff*")))
(when old-response
@@ -119,8 +121,8 @@ This function is intended to diff files, not directories."
(insert (format "No difference between entries:
%s
%s"
- (hyperdrive-entry-description (car
hyperdrive-diff-entries))
- (hyperdrive-entry-description (cdr
hyperdrive-diff-entries)))))
+ (hyperdrive--format-entry (car
hyperdrive-diff-entries))
+ (hyperdrive--format-entry (cdr
hyperdrive-diff-entries)))))
(goto-char (point-max))
(forward-line -1)
(delete-region (point) (point-max)))))
diff --git a/hyperdrive-dir.el b/hyperdrive-dir.el
index 4074f3a008..706f699e0a 100644
--- a/hyperdrive-dir.el
+++ b/hyperdrive-dir.el
@@ -63,7 +63,8 @@ If THEN, call it in the directory buffer with no arguments."
;; of this function (e.g. so it will be available if
;; the user loads a non-directory file directly).
(hyperdrive-fill-metadata hyperdrive)
- (hyperdrive-dir-column-headers (hyperdrive-entry-description
directory-entry))))
+ (hyperdrive-dir-column-headers
+ (hyperdrive--format-entry directory-entry))))
(num-entries (length entries)) (num-filled 0)
;; (debug-start-time (current-time))
(metadata-queue) (ewoc) (prev-entry) (prev-point))
@@ -344,7 +345,8 @@ DIRECTORY-SORT should be a valid value of
(dolist (entry (hyperdrive-sort-entries entries))
(ewoc-enter-last hyperdrive-ewoc entry))
(ewoc-set-hf hyperdrive-ewoc
- (hyperdrive-dir-column-headers
(hyperdrive-entry-description hyperdrive-current-entry))
+ (hyperdrive-dir-column-headers
+ (hyperdrive--format-entry hyperdrive-current-entry))
""))))
;;;; Imenu support
diff --git a/hyperdrive-history.el b/hyperdrive-history.el
index 4ff74e2ee9..8231acd2f2 100644
--- a/hyperdrive-history.el
+++ b/hyperdrive-history.el
@@ -179,7 +179,7 @@ prefix argument \\[universal-argument], prompt for ENTRY."
:version (car range))))
;; Display in reverse chronological order
(nreverse (hyperdrive-entry-version-ranges-no-gaps
entry))))
- (main-header (hyperdrive-entry-description entry :with-version
nil))
+ (main-header (hyperdrive--format-entry entry "[%H] %p"))
(header (concat main-header "\n"
(format "%7s %19s %6s %s"
(propertize "Exists" 'face
'hyperdrive-column-header)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index e0f7486246..d1fdbc0774 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -557,7 +557,8 @@ echo area when the request for the file is made."
;; alert the user that the entry no longer exists.
(progn
(switch-to-buffer buffer)
- (hyperdrive-message "Entry no longer exists! %s"
(hyperdrive-entry-description entry)))
+ (hyperdrive-message "Entry no longer exists! %s"
+ (hyperdrive--format-entry
entry)))
;; Make and switch to new buffer.
(switch-to-buffer (hyperdrive--get-buffer-create
entry))))
(t
@@ -916,28 +917,6 @@ Call ELSE if request fails."
(hyperdrive--write (hyperdrive-entry-url entry)
:body body :then then :else else :queue queue))
-(cl-defun hyperdrive-entry-description (entry &key (format-path 'path)
(with-version t))
- "Return description for ENTRY.
-When ENTRY has a non-nil VERSION slot, include it. Returned
-string looks like:
-
- FORMAT-PATH [HOST] (version:VERSION)
-
-When FORMAT-PATH is `path', use full path to entry. When
-FORMAT-PATH is `name', use only last part of path, as in
-`file-name-non-directory'.
-
-When WITH-VERSION or ENTRY's version is nil, omit (version:VERSION)."
- (pcase-let* (((cl-struct hyperdrive-entry hyperdrive version path name)
entry)
- (handle (hyperdrive--format-host hyperdrive :with-label t)))
- (propertize (concat (format "[%s] " handle)
- (pcase format-path
- ('path path)
- ('name name))
- (when (and version with-version)
- (format " (version:%s)" version)))
- 'help-echo (hyperdrive-entry-url entry))))
-
(cl-defun hyperdrive--format-entry-url
(entry &key (host-format '(public-key domain))
(with-path t) (with-protocol t) (with-help-echo t)
@@ -1371,7 +1350,7 @@ Affected by option `hyperdrive-reuse-buffers', which see."
;; TODO: This function is a workaround for bug#65797
(lambda (buffer) (hyperdrive--buffer-visiting-entry-p buffer entry)))
-(defun hyperdrive--format-entry (entry format)
+(cl-defun hyperdrive--format-entry (entry &optional (format
hyperdrive-default-entry-format))
"Return ENTRY formatted according to FORMAT.
FORMAT may be a format string like the value of
`hyperdrive-buffer-name-format', which see."
@@ -1379,32 +1358,34 @@ FORMAT may be a format string like the value of
((cl-struct hyperdrive domains public-key petname seed
(metadata (map ('name nickname))))
hyperdrive))
- (format-spec 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)
- ""))))))
+ (propertize
+ (format-spec 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)
+ ""))))
+ 'help-echo (hyperdrive-entry-url entry))))
(defun hyperdrive--entry-directory-p (entry)
"Return non-nil if ENTRY is a directory."
diff --git a/hyperdrive-org.el b/hyperdrive-org.el
index 235a729b20..dcf3130c69 100644
--- a/hyperdrive-org.el
+++ b/hyperdrive-org.el
@@ -64,10 +64,10 @@ which see."
(let ((entry (hyperdrive-dir--entry-at-point)))
`((type . "hyper://")
(link . ,(hyperdrive-entry-url entry))
- (description . ,(hyperdrive-entry-description
entry)))))
+ (description . ,(hyperdrive--format-entry entry)))))
(_ `((type . "hyper://")
(link . ,(hyperdrive-entry-url
hyperdrive-current-entry))
- (description . ,(hyperdrive-entry-description
hyperdrive-current-entry)))))))
+ (description . ,(hyperdrive--format-entry
hyperdrive-current-entry)))))))
(org-link-store-props :type type :link link :description description)
t)))
diff --git a/hyperdrive-vars.el b/hyperdrive-vars.el
index f5a5bb27b7..b90a36b6b5 100644
--- a/hyperdrive-vars.el
+++ b/hyperdrive-vars.el
@@ -171,8 +171,8 @@ an existing buffer at the same version, or make a new
buffer."
"Formatting of entries for buffer names, etc."
:group 'hyperdrive)
-(defcustom hyperdrive-buffer-name-format "[%H] %n%v"
- "Format string for buffer names.
+(defcustom hyperdrive-default-entry-format "[%H] %p%v"
+ "Format string for displaying entries.
Specifiers:
%n Entry name
@@ -190,6 +190,17 @@ Specifiers:
%S Hyperdrive seed"
:type 'string)
+(defvar hyperdrive-default-entry-format-without-version "[%H] %p"
+ "Format string for displaying entries without displaying the version.
+The format of the following specifiers can be configured using
+`hyperdrive-entry-format-alist', which see.")
+
+(defcustom hyperdrive-buffer-name-format "[%H] %n%v"
+ "Format string for buffer names.
+Specifiers are as in `hyperdrive-default-entry-format', which
+see."
+ :type 'string)
+
(defcustom hyperdrive-entry-version-format " (version:%s)"
"Format string for entry version.
\"%s\" is replaced with the entry version. Used in
diff --git a/hyperdrive.el b/hyperdrive.el
index 02b3eb6ddb..b19133bfe6 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -361,7 +361,7 @@ directory. Otherwise, or with universal prefix argument
(declare (indent defun))
(interactive
(let* ((entry (hyperdrive--context-entry :latest-version t))
- (description (hyperdrive-entry-description entry))
+ (description (hyperdrive--format-entry entry))
(buffer (current-buffer)))
(when (and (hyperdrive--entry-directory-p entry)
(or (eq entry hyperdrive-current-entry)
@@ -450,11 +450,11 @@ use, see `hyperdrive-write'."
current-prefix-arg))
(unless (or overwritep (not (hyperdrive-entry-at nil entry)))
(unless (y-or-n-p
- (format "File %s exists; overwrite?" (hyperdrive-entry-description
entry)))
+ (format "File %s exists; overwrite?" (hyperdrive--format-entry
entry)))
(hyperdrive-user-error "Canceled"))
(when-let ((buffers (match-buffers (hyperdrive--buffer-for-entry entry))))
(unless (y-or-n-p
- (format "A buffer is visiting %s; proceed?"
(hyperdrive-entry-description entry)))
+ (format "A buffer is visiting %s; proceed?"
(hyperdrive--format-entry entry)))
(hyperdrive-user-error "Aborted"))
;; TODO: In BUFFERS, when user attempts to modify the buffer,
;; offer warning like "FILE has been modified in hyperdrive; are
@@ -557,7 +557,7 @@ it to `hyperdrive-open'."
(if-let ((previous-entry (hyperdrive-entry-previous entry)))
(hyperdrive-open previous-entry)
(hyperdrive-message (substitute-command-keys "%s does not exist at version
%s. Try \\[hyperdrive-history]")
- (hyperdrive-entry-description entry :with-version nil)
+ (hyperdrive--format-entry entry "[%H] %p")
(1- (car (hyperdrive-entry-version-range entry))))))
(defun hyperdrive-open-next-version (entry)
@@ -591,11 +591,12 @@ Nil VERSION means open the entry at its hyperdrive's
latest version."
(list entry (hyperdrive-read-version
:hyperdrive (hyperdrive-entry-hyperdrive entry)
:prompt (format "Open «%s» at version (leave
blank for latest version)"
- (hyperdrive-entry-description
entry :with-version nil))))))
+ (hyperdrive--format-entry
entry))))))
(if-let ((latest-entry (hyperdrive-entry-at version entry)))
(hyperdrive-open latest-entry)
(hyperdrive-message (substitute-command-keys "%s does not exist at version
%s. Try \\[hyperdrive-history]")
- (hyperdrive-entry-description entry :with-version nil)
+ (hyperdrive--format-entry
+ entry hyperdrive-default-entry-format-without-version)
version)))
;;;; Bookmark support
@@ -609,7 +610,7 @@ Works in `hyperdrive-mode' and `hyperdrive-dir-mode'
buffers."
(let ((bookmark (bookmark-make-record-default 'no-file)))
(setf (alist-get 'handler bookmark) #'hyperdrive-bookmark-handler
(alist-get 'location bookmark) (hyperdrive-entry-url
hyperdrive-current-entry))
- (cons (format "hyperdrive: %s" (hyperdrive-entry-description
hyperdrive-current-entry)) bookmark)))
+ (cons (format "hyperdrive: %s" (hyperdrive--format-entry
hyperdrive-current-entry)) bookmark)))
;;;###autoload
(defun hyperdrive-bookmark-handler (bookmark)
@@ -799,14 +800,14 @@ The return value of this function is the retrieval
buffer."
(if (< emacs-major-version 28)
(read-multiple-choice
(format "Hyperdrive file %s modified; kill anyway?"
- (hyperdrive-entry-description hyperdrive-current-entry))
+ (hyperdrive--format-entry hyperdrive-current-entry))
'((?y "yes" "kill buffer without saving")
(?n "no" "exit without doing anything")
(?s "save and then kill" "save the buffer and then kill it")))
(with-suppressed-warnings ((free-vars use-short-answers))
(compat-call read-multiple-choice
(format "Hyperdrive file %s modified; kill anyway?"
- (hyperdrive-entry-description
hyperdrive-current-entry))
+ (hyperdrive--format-entry
hyperdrive-current-entry))
'((?y "yes" "kill buffer without saving")
(?n "no" "exit without doing anything")
(?s "save and then kill" "save the buffer and
then kill it"))
@@ -962,7 +963,7 @@ The return value of this function is the retrieval buffer."
:active hyperdrive-current-entry
:label (if-let* ((entry hyperdrive-current-entry))
(format "Current: «%s»"
- (hyperdrive-entry-description entry))
+ (hyperdrive--format-entry entry))
"Current")
("Current Drive"
:active hyperdrive-current-entry
- [nongnu] elpa/hyperdrive b682fc8058 052/102: Change: (--entry-version-range-key) Don't pass :with-help-echo, (continued)
- [nongnu] elpa/hyperdrive b682fc8058 052/102: Change: (--entry-version-range-key) Don't pass :with-help-echo, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 299e100c03 026/102: Comment: Add TODO, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive b1cc39978b 091/102: Comment: Remove TODO, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 600c921605 081/102: Tidy: Rename "naming" to "format", ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 9c0cf70040 094/102: Fix: (h//format) Don't use lambdas in format-spec yet, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive fe986e53ee 079/102: Chore: Rebuild texi manual, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 89fb114bdd 093/102: Fix: Autoload for markdown-mode links, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive ab2fb6e8ea 009/102: Change: (-menu-hyperdrive) Place mirror commands in separate column, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive b403a9c7a3 044/102: Add: (hyperdrive-buffer-name-format), ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 60d37a34ec 029/102: Change: (-mirror-set-filter) Wording of formatted nil value, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive b2afbfaa60 046/102: Change: Replace -entry-description with --format-entry, etc.,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 214a060f75 001/102: Fix: (-mirror-read-predicate) Require match for predicate type, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 9d8de7ed67 006/102: Change: (-menu-set-nickname) No longer explicitly refresh transient, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 74b0eb400f 032/102: Fix/Docs: Reword as suggested by makeinfo, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 1f3eeca9dc 013/102: Change (-menu-hyperdrive) Add suffix for copying URL, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive e9b6b9f059 011/102: Add/Change: Improve transient support for mirroring, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 307b33362a 045/102: Change: (--format-entry) replaces --entry-buffer-name, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 780bd3d8e0 004/102: Fix/Change: (-menu-hyperdrive) Use new display-only child syntax, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive 1f7dfa3580 039/102: Fix: (hyperdrive-mirror-set-target) Validate target path, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive f52b33cef4 057/102: Tidy: Docstring, ELPA Syncer, 2023/11/29
- [nongnu] elpa/hyperdrive ccaffb946d 021/102: Change: (hyperdrive-menu-hyperdrive) Remove adhoc mirror command, ELPA Syncer, 2023/11/29