branch: elpa/hyperdrive
commit 761efabd23749f3c06c6e070387fc155820520d6
Author: Joseph Turner <[email protected]>
Commit: Joseph Turner <[email protected]>
Add: (h/gateway-installed-predicate) Customizable option
With this option, we have a clearer level of abstraction and can check
whether the gateway is installed in top-level commands like h/start.
In practice, users might customize h/gateway-installed-predicate if
they are connecting to a gateway instance over a network, such as
https://hyper.hypha.coop/
---
hyperdrive-lib.el | 11 +++++++++++
hyperdrive-vars.el | 5 +++++
2 files changed, 16 insertions(+)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 23517a3b8a..7b0ed796c0 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1492,6 +1492,17 @@ This does not mean that the gateway is responsive, only
that the
process is running."
(process-live-p h/gateway-process))
+(defun h/gateway-installed-p ()
+ "Return non-nil if the gateway program is installed.
+Calls function set in option
+`hyperdrive-gateway-installed-predicate'."
+ (funcall h/gateway-installed-predicate))
+
+(defun h/gateway-installed-p-default ()
+ "Return non-nil if the gateway program is installed."
+ (and-let* ((hyper-gateway-ushin-path (hyperdrive--hyper-gateway-ushin-path)))
+ (file-executable-p hyper-gateway-ushin-path)))
+
(defun h//gateway-ready-p ()
"Return non-nil if the gateway is running and accessible.
Times out after 2 seconds."
diff --git a/hyperdrive-vars.el b/hyperdrive-vars.el
index 1680d39cd0..4c0f421a2d 100644
--- a/hyperdrive-vars.el
+++ b/hyperdrive-vars.el
@@ -429,6 +429,11 @@ gateway process."
"Predicate function which returns non-nil if the gateway process is live."
:type 'function)
+(declare-function h/gateway-installed-p-default "hyperdrive-lib")
+(defcustom h/gateway-installed-predicate #'h/gateway-installed-p-default
+ "Predicate function which returns non-nil if the gateway process is
installed."
+ :type 'function)
+
(defcustom h/gateway-ready-hook
'( h/check-gateway-version
h/announce-gateway-ready