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

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

[nongnu] elpa/hyperdrive aa29fa3652 06/14: Add: (hyperdrive-history-view


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive aa29fa3652 06/14: Add: (hyperdrive-history-view-file) View file from history mode
Date: Wed, 6 Sep 2023 04:00:03 -0400 (EDT)

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

    Add: (hyperdrive-history-view-file) View file from history mode
---
 hyperdrive-history.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/hyperdrive-history.el b/hyperdrive-history.el
index 08372a033f..27a04e2d38 100644
--- a/hyperdrive-history.el
+++ b/hyperdrive-history.el
@@ -119,6 +119,7 @@ and ENTRY's version are nil."
   :parent  hyperdrive-ewoc-mode-map
   :doc "Local keymap for `hyperdrive-history-mode' buffers."
   "RET" #'hyperdrive-history-find-file
+  "v"   #'hyperdrive-history-view-file
   "="   #'hyperdrive-history-diff
   "w"   #'hyperdrive-history-copy-url
   "d"   #'hyperdrive-history-download-file)
@@ -263,6 +264,28 @@ buffer."
      ;; TODO: Design options
      (hyperdrive-message "File not known to exist. What do you want to do?"))))
 
+(declare-function hyperdrive-view-file "hyperdrive")
+(defun hyperdrive-history-view-file (range-entry)
+  "Open hyperdrive entry in RANGE-ENTRY at point in `view-mode'.
+When entry does not exist or is not known to exist, does nothing
+and returns nil.
+
+Interactively, visit entry at point in `hyperdrive-history'
+buffer."
+  (declare (modes hyperdrive-history-mode))
+  (interactive (list (hyperdrive-history-range-entry-at-point)))
+  (pcase-exhaustive (hyperdrive-range-entry-exists-p range-entry)
+    ('t
+     ;; Known to exist: open it.
+     (hyperdrive-view-file (cdr range-entry)))
+    ('nil
+     ;; Known to not exist: warn user.
+     (hyperdrive-user-error "File does not exist!"))
+    ('unknown
+     ;; Not known to exist: prompt user
+     ;; TODO: Design options
+     (hyperdrive-message "File not known to exist. What do you want to do?"))))
+
 (declare-function hyperdrive-copy-url "hyperdrive")
 
 (defun hyperdrive-history-copy-url (range-entry)



reply via email to

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