[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kiwix 80c0899 144/192: Follow previous commit which can
From: |
Stefan Monnier |
Subject: |
[elpa] externals/kiwix 80c0899 144/192: Follow previous commit which can use the select library to construct API URL |
Date: |
Sat, 19 Dec 2020 00:41:49 -0500 (EST) |
branch: externals/kiwix
commit 80c0899bc79cfb5a29715b187d497060c0169450
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
Follow previous commit which can use the select library to construct API URL
---
kiwix.el | 67 ++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 38 insertions(+), 29 deletions(-)
diff --git a/kiwix.el b/kiwix.el
index 5bf1731..e3de033 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -110,6 +110,10 @@
(concat kiwix-default-data-path "/data/library/") nil ".*\.zim")))
"A list of Kiwix libraries.")
+(defvar kiwix--selected-library nil
+ "Global variable of currently select library used in anonymous function.
+Like in function `kiwix-ajax-search-hints'.")
+
;; - examples:
;; - "wikipedia_en_all" - "wikipedia_en_all_2016-02"
;; - "wikipedia_zh_all" - "wikipedia_zh_all_2015-17"
@@ -192,11 +196,12 @@
:error (function* (lambda (&rest args &key error-thrown
&allow-other-keys)
(setq kiwix-server-available? nil)))))
-(defun kiwix-ajax-search-hints (input)
+(defun kiwix-ajax-search-hints (input &optional selected-library)
"Instantly AJAX request to get available Kiwix entry keywords
list and return a list result."
- (let* ((library (or kiwix-default-library
- (kiwix--get-library-name kiwix-default-library)))
+ (let* ((library (or selected-library
+ (kiwix--get-library-name (or kiwix--selected-library
+ kiwix-default-library))))
(ajax-api (format "%s/suggest?content=%s&term="
kiwix-server-url
library))
@@ -222,32 +227,36 @@ for query string and library interactively."
(interactive "P")
(kiwix-ping-server)
(if kiwix-server-available?
- (let* ((library (if (or kiwix-search-interactively interactively)
- (kiwix-select-library)
- (kiwix--get-library-name kiwix-default-library)))
- (query (ivy-read "Kiwix related entries: "
- 'kiwix-ajax-search-hints
- :predicate nil
- :require-match nil
- :initial-input (if mark-active
- (buffer-substring
- (region-beginning)
(region-end))
- (thing-at-point 'symbol))
- :preselect nil
- :def nil
- :history nil
- :keymap nil
- :update-fn 'auto
- :sort t
- :dynamic-collection t
- :caller 'ivy-done)))
- (message (format "library: %s, query: %s" library query))
- (if (or (null library)
- (string-empty-p library)
- (null query)
- (string-empty-p query))
- (error "Your query is invalid")
- (kiwix-query query library)))
+ (progn
+ (setq kiwix--selected-library (if (or kiwix-search-interactively
interactively)
+ (kiwix-select-library)
+ (kiwix--get-library-name
kiwix-default-library)))
+ (let* ((library kiwix--selected-library)
+ (query (ivy-read "Kiwix related entries: "
+ `(lambda (input)
+ (apply 'kiwix-ajax-search-hints
+ input `(,kiwix--selected-library)))
+ :predicate nil
+ :require-match nil
+ :initial-input (if mark-active
+ (buffer-substring
+ (region-beginning)
(region-end))
+ (thing-at-point 'symbol))
+ :preselect nil
+ :def nil
+ :history nil
+ :keymap nil
+ :update-fn 'auto
+ :sort t
+ :dynamic-collection t
+ :caller 'ivy-done)))
+ (message (format "library: %s, query: %s" library query))
+ (if (or (null library)
+ (string-empty-p library)
+ (null query)
+ (string-empty-p query))
+ (error "Your query is invalid")
+ (kiwix-query query library))))
(warn "kiwix-serve is not available, please start it at first."))
(setq kiwix-server-available? nil))
- [elpa] externals/kiwix 15a5c3c 124/192: make kiwix-serve server port customize option, (continued)
- [elpa] externals/kiwix 15a5c3c 124/192: make kiwix-serve server port customize option, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 7786e70 126/192: improve README: add Kiwix installation, kiwix-serve Docker setup., Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix e8bfe4e 127/192: update package description, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 2cec30b 132/192: add kiwix/kiwix-serve Docker image into installation section of README, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix c5b8f69 133/192: add a gender ping of kiwix-serve before query, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix d2ae338 130/192: fix org-link-set-parameters void function when package.el initialize., Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 04347e6 137/192: turn a request part into a separate function, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix f587833 135/192: make available testing before every query, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 6c4d80a 136/192: fix `request' :error sentinel., Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 5221eda 142/192: silent request result, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 80c0899 144/192: Follow previous commit which can use the select library to construct API URL,
Stefan Monnier <=
- [elpa] externals/kiwix 82140a5 145/192: Make Ivy optional, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 9ee19a0 146/192: silent request flashing echo-area messages flashing., Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix ce554ec 147/192: add async search completion keywords candidates screenshot in README, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 013449c 151/192: update image link for GitHub Org Mode link path support., Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 1fdcfcc 153/192: add screenshot for kiwix open URL with EWW, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 648916d 154/192: add option to set Kiwix default completing-read framework, default is Ivy., Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix eee7cbd 157/192: auto pull download Docker image if it is not available, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix ba929ec 159/192: update Docker run container command, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 2d31741 160/192: auto launch server if ping not available, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 8cc16b1 161/192: no need to select library when use Docker container, Stefan Monnier, 2020/12/19