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

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

[elpa] externals/kiwix c273429 06/18: refactor and remove the variable `


From: Stefan Monnier
Subject: [elpa] externals/kiwix c273429 06/18: refactor and remove the variable `kiwix--selected-library'
Date: Wed, 4 Aug 2021 18:28:09 -0400 (EDT)

branch: externals/kiwix
commit c27342992ea68f958a327bd5355deabd8062f260
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    refactor and remove the variable `kiwix--selected-library'
---
 kiwix.el | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/kiwix.el b/kiwix.el
index dc111d4..5c0dffe 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -149,19 +149,10 @@ Set it to ‘t’ will use Emacs built-in ‘completing-read’."
   "A helper function to refresh available Kiwx libraries."
   (setq kiwix-libraries (kiwix-get-libraries)))
 
-(defvar kiwix--selected-library nil
-  "Global variable of currently select library used in anonymous function.
-Like in function `kiwix-ajax-search-hints'.")
-
 (defun kiwix-select-library (&optional filter)
   "Select Kiwix library name."
   (completing-read "Kiwix library: " kiwix-libraries nil t filter))
 
-(defcustom kiwix-default-library "wikipedia_en_all.zim"
-  "The default kiwix library when library fragment in link not specified."
-  :type 'string
-  :safe #'stringp)
-
 (defcustom kiwix-mode-prefix nil
   "Specify kiwix-mode keybinding prefix before loading."
   :type 'kbd)
@@ -200,7 +191,7 @@ Like in function `kiwix-ajax-search-hints'.")
 
 (defun kiwix-query (query &optional selected-library)
   "Search `QUERY' in `LIBRARY' with Kiwix."
-  (let* ((library (or selected-library (kiwix--get-library-name 
kiwix-default-library)))
+  (let* ((library (or selected-library (kiwix--get-library-name 
selected-library)))
          (url (concat (format "%s:%s" kiwix-server-url (number-to-string 
kiwix-server-port))
                       "/search?content=" library "&pattern=" 
(url-hexify-string query)))
          (browse-url-browser-function kiwix-default-browser-function))
@@ -223,7 +214,7 @@ Like in function `kiwix-ajax-search-hints'.")
        (or (kiwix-docker-check)
            (async-shell-command "docker pull kiwix/kiwix-serve")))
   (let ((inhibit-message t))
-    (request (format "%s:%s" kiwix-server-url (number-to-string 
kiwix-server-port))
+    (request (format "%s:%s" kiwix-server-url kiwix-server-port)
       :type "GET"
       :sync t
       :parser (lambda () (libxml-parse-html-region (point-min) (point-max)))
@@ -238,14 +229,13 @@ Like in function `kiwix-ajax-search-hints'.")
       :status-code '((404 . (lambda (&rest _) (message (format "Endpoint %s 
does not exist." url))))
                      (500 . (lambda (&rest _) (message (format "Error from  
%s." url))))))))
 
-(defun kiwix-ajax-search-hints (input &optional selected-library)
+(defun kiwix--ajax-search-hints (input &optional selected-library)
   "Instantly AJAX request to get available Kiwix entry keywords
 list and return a list result."
   (kiwix-ping-server)
   (when (and input kiwix-server-available?)
     (let* ((library (or selected-library
-                        (kiwix--get-library-name (or kiwix--selected-library
-                                                     kiwix-default-library))))
+                        (kiwix--get-library-name selected-library)))
            (ajax-api (format "%s:%s/suggest?content=%s&term="
                              kiwix-server-url (number-to-string 
kiwix-server-port)
                              library))



reply via email to

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