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

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

[elpa] externals/kiwix 57b07c1 3/6: To enable stopping local server, ke


From: Stefan Monnier
Subject: [elpa] externals/kiwix 57b07c1 3/6: To enable stopping local server, keep a reference to server process
Date: Thu, 7 Oct 2021 08:33:51 -0400 (EDT)

branch: externals/kiwix
commit 57b07c1d80a8a2825794f349741158bd26cbabe6
Author: Matt Beshara <m@mfa.pw>
Commit: Matt Beshara <m@mfa.pw>

    To enable stopping local server, keep a reference to server process
---
 kiwix.el | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/kiwix.el b/kiwix.el
index a97f43c..70eacc4 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -216,6 +216,8 @@ Set it to ‘t’ will use Emacs built-in ‘completing-read’."
   "Specify kiwix-mode keybinding prefix before loading."
   :type 'kbd)
 
+(defvar kiwix--server-process nil
+  "Local server process launched by ‘kiwix-launch-server’.")
 
 ;; launch Kiwix server
 ;;;###autoload
@@ -236,13 +238,21 @@ Set it to ‘t’ will use Emacs built-in ‘completing-read’."
                       "-p" (format "%s:80" kiwix-server-port)
                       "kiwix/kiwix-serve"
                       "--library" "library.xml"))
-      ('kiwix-serve-local (start-process
-                           "kiwix-server"
-                           " *kiwix server*"
-                           kiwix-server-command
-                           "--port" (number-to-string kiwix-server-port)
-                           "--daemon"
-                           "--library" (concat library-path "library.xml"))))))
+      ('kiwix-serve-local
+       (setq kiwix--server-process
+             (start-process
+              "kiwix-server"
+              " *kiwix server*"
+              kiwix-server-command
+              "--port" (number-to-string kiwix-server-port)
+              "--library" (concat kiwix-zim-dir "library.xml")))))))
+
+(defun kiwix-stop-local-server ()
+  "Stops a Kiwix server started by ‘kiwix-launch-server’."
+  (interactive)
+  (when kiwix--server-process
+    (kill-process kiwix--server-process)
+    (setq kiwix--server-process nil)))
 
 (defun kiwix-capitalize-first (string)
   "Only capitalize the first word of STRING."



reply via email to

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