branch: elpa/hyperdrive
commit 188438e59df651e562d2dace1c95cc15623e968e
Author: Joseph Turner <jos...@ushin.org>
Commit: Joseph Turner <jos...@ushin.org>

    Change: (h/mark-as-safe) Allow marking as 'unknown
---
 hyperdrive-lib.el |  5 ++++-
 hyperdrive.el     | 20 ++++++++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 113dccca43..51c7737bd6 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -94,7 +94,10 @@ Passes ARGS to `format-message'."
   ;; TODO: Consider adding gv-setters for etc slot keys
   (etc nil :documentation "Alist of extra data.
 - disk-usage :: Number of bytes occupied locally by the drive.
-- safep :: Whether or not to treat this hyperdrive as safe."))
+- safep :: Whether or not to treat this hyperdrive as safe.
+  + t :: safe
+  + nil :: unsafe
+  + \\+`unknown' (or unset) :: unknown"))
 
 (defun h/url (hyperdrive)
   "Return a \"hyper://\"-prefixed URL from a HYPERDRIVE struct.
diff --git a/hyperdrive.el b/hyperdrive.el
index e2269e1a1f..8e4345cfca 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -161,15 +161,18 @@ Interactively, prompt for hyperdrive and action."
                  (pcase (read-answer
                          (format "Mark hyperdrive `%s' as: (currently: %s) "
                                  (h//format-hyperdrive hyperdrive)
-                                 (if safep
-                                     (propertize "safe" 'face 'success)
-                                   (propertize "unsafe" 'face 'error)))
+                                 (pcase-exhaustive safep
+                                   ('t (propertize "safe" 'face 'success))
+                                   ('nil (propertize "unsafe" 'face 'error))
+                                   ('unknown (propertize "unknown" 'face 
'warning))))
                          '(("safe" ?S "mark as safe")
-                           ("unsafe" ?u "mark as unsafe")
+                           ("unsafe" ?U "mark as unsafe")
+                           ("unknown" ?u "ask again later")
                            ("info" ?i "show Info manual section about safety")
                            ("quit" ?q "quit")))
                    ((or ?S "safe") t)
-                   ((or ?u "unsafe") nil)
+                   ((or ?U "unsafe") nil)
+                   ((or ?u "unknown") 'unknown)
                    ((or ?i "info") :info)
                    (_ :quit))))
      (list hyperdrive mark-safe-p)))
@@ -180,9 +183,10 @@ Interactively, prompt for hyperdrive and action."
        (h/persist hyperdrive)
        (message "Marked hyperdrive `%s' as %s."
                 (h//format-hyperdrive hyperdrive)
-                (if safep
-                    (propertize "safe" 'face 'success)
-                  (propertize "unsafe" 'face 'error))))))
+                (pcase-exhaustive safep
+                  ('t (propertize "safe" 'face 'success))
+                  ('nil (propertize "unsafe" 'face 'error))
+                  ('unknown (propertize "unknown" 'face 'warning)))))))
 
 (defun h/forget-file (entry)
   "Delete local copy of the file or directory contents of ENTRY.

Reply via email to