branch: elpa/hyperdrive
commit 583b1c5160d0b4fa5b69e6d0da0d96f8fc43942e
Author: Joseph Turner <[email protected]>
Commit: Joseph Turner <[email protected]>

    Change: (h/start) Check installed/installing in command
    
    Move logic for checking if the gateway is installed/installing from
    the default start function into the top-level command.
---
 hyperdrive-lib.el | 42 +++++++++++++++++-------------------------
 hyperdrive.el     | 24 +++++++++++++++++-------
 2 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index b2c6549970..b38db5671e 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1419,31 +1419,23 @@ Then calls THEN if given."
 (defun h//gateway-start-default ()
   "Start the gateway as an Emacs subprocess.
 Default function; see variable `h/gateway-start-function'."
-  (let ((hyper-gateway-ushin-path (h//hyper-gateway-ushin-path))
-        (gateway-installed-p (h/gateway-installed-p)))
-    (cond (h/gateway-process
-           ;; Process variable is non-nil: gateway might be starting but not 
yet
-           ;; "live", which was checked in `h/start'.  This probably should 
never
-           ;; happen, but if it were to, this distinct message might help us
-           ;; understand what's going on.
-           (h/error "Gateway appears to be starting"))
-          ((and (not gateway-installed-p) hyperdrive-install-in-progress-p)
-           (h/error "Gateway installation in-progress"))
-          ((not gateway-installed-p)
-           (error "Hyperdrive: %s"
-                  (substitute-command-keys
-                   "Gateway not installed; try \\[hyperdrive-install]")))
-          (hyperdrive-install-in-progress-p
-           (h/message
-            "Gateway installation in-progress; starting old gateway anyway."))
-          (t (h/message "Starting gateway.")))
-    (setf h/gateway-process
-          (make-process
-           :name "hyper-gateway-ushin"
-           :buffer " *hyperdrive-start*"
-           :command (cons hyper-gateway-ushin-path
-                          (split-string-and-unquote h/gateway-command-args))
-           :connection-type 'pipe))))
+  (when h/gateway-process
+    ;; TODO: `h/gateway-process' appears to be non-nil but not live when
+    ;; make-process receives a bad command line program, like "ls"
+    ;; instead of "hyper-gateway-ushin".
+
+    ;; Process variable is non-nil: gateway might be starting but not yet
+    ;; "live", which was checked in `h/start'.  This probably should never
+    ;; happen, but if it were to, this distinct message might help us
+    ;; understand what's going on.
+    (h/error "Gateway appears to be starting"))
+  (setf h/gateway-process
+        (make-process
+         :name "hyper-gateway-ushin"
+         :buffer " *hyperdrive-start*"
+         :command (cons (h//hyper-gateway-ushin-path)
+                        (split-string-and-unquote h/gateway-command-args))
+         :connection-type 'pipe)))
 
 (defun h/announce-gateway-ready ()
   "Announce that the gateway is ready."
diff --git a/hyperdrive.el b/hyperdrive.el
index 4f12a63867..33947b9ec1 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -99,13 +99,23 @@
 Calls function set in option `hyperdrive-gateway-start-function',
 which see."
   (interactive)
-  (cond ((and (h//gateway-ready-p) (h/gateway-live-p))
-         (h/message "Gateway already running."))
-        ((h//gateway-ready-p)
-         (h/message "Gateway already running outside of Emacs."))
-        ((h/gateway-live-p)
-         (h/message "Gateway already starting."))
-        (t (funcall h/gateway-start-function)))
+  (let ((gateway-installed-p (h/gateway-installed-p)))
+    (cond ((and (h//gateway-ready-p) (h/gateway-live-p))
+           (h/message "Gateway already running."))
+          ((h//gateway-ready-p)
+           (h/message "Gateway already running outside of Emacs."))
+          ((h/gateway-live-p)
+           (h/message "Gateway already starting."))
+          ((and (not gateway-installed-p) h/install-in-progress-p)
+           (h/user-error "Gateway installation in-progress"))
+          ((not gateway-installed-p)
+           (h/user-error "Gateway not installed; try \\[hyperdrive-install]"))
+          (t
+           (h/message
+            (if hyperdrive-install-in-progress-p
+                "Gateway installation in-progress; starting old gateway 
anyway."
+              "Starting gateway."))
+           (funcall h/gateway-start-function))))
   (h//gateway-wait-for-ready))
 
 ;;;###autoload

Reply via email to