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

    Change: (h/start) Move default start logic to default start function
    
    h/install-in-progress-p, h//hyper-gateway-ushin-path, and
    h/gateway-process are specific to the default method of running
    hyper-gateway-ushin as an Emacs subprocess, so they should be checked
    in the default start function.
    
    This commit also changes the behavior when the gateway is being
    installed and there exists an old copy of the gateway in the PATH.
    Previously an error was signaled, preventing the old gateway from
    starting.  Now, the old gateway is started and a message appears,
    "Gateway installation in-progress; starting old gateway anyway."
---
 hyperdrive-lib.el | 38 +++++++++++++++++++++++++-------------
 hyperdrive.el     | 16 +---------------
 2 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index bff2371d7d..2aa0dc6320 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1420,19 +1420,31 @@ Then calls THEN if given."
   "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)))
-    (if (not hyper-gateway-ushin-path)
-        ;; Gateway appears to not be installed: suggest to install it.
-        (h/message "Gateway not installed; try \\[hyperdrive-install]")
-
-      ;; Gateway is installed: start it.
-      (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))
-      (h/message "Starting gateway..."))))
+    (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 hyper-gateway-ushin-path)
+                hyperdrive-install-in-progress-p)
+           (h/error "Gateway installation in-progress"))
+          ((not hyper-gateway-ushin-path)
+           (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))))
 
 (defun h/announce-gateway-ready ()
   "Announce that the gateway is ready."
diff --git a/hyperdrive.el b/hyperdrive.el
index 8166239fe3..705f68921d 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -99,26 +99,12 @@
 Calls function set in option `hyperdrive-gateway-start-function',
 which see."
   (interactive)
-  (cond (h/install-in-progress-p
-         ;; Skip `h//gateway-wait-for-ready'.
-         (h/error "Gateway installation in-progress"))
-        ((and (h//gateway-ready-p)
-              (h/gateway-live-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."))
-        (h/gateway-process
-         ;; Process variable is non-nil: gateway might be starting but not yet
-         ;; "live".  This probably should never happen, but if it were to, this
-         ;; distinct message might help us understand what's going on.
-         (h/message "Gateway appears to be starting."))
-        ((not (h//hyper-gateway-ushin-path))
-         ;; Gateway appears to not be installed: suggest to install it.
-         (error "Hyperdrive: %s"
-                (substitute-command-keys
-                 "Gateway not installed; try \\[hyperdrive-install]")))
         (t (funcall h/gateway-start-function)))
   (h//gateway-wait-for-ready))
 

Reply via email to