[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kiwix 5f64044 175/192: support detect whether query is
From: |
Stefan Monnier |
Subject: |
[elpa] externals/kiwix 5f64044 175/192: support detect whether query is chinese |
Date: |
Sat, 19 Dec 2020 00:41:55 -0500 (EST) |
branch: externals/kiwix
commit 5f6404486e1f1292469a1cca186e2d457992497a
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
support detect whether query is chinese
---
kiwix.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/kiwix.el b/kiwix.el
index 4794e78..c5da69b 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -339,11 +339,17 @@ for query string and library interactively."
;; - group 2: link? (match everything but ], space, tab, carriage return,
linefeed by using [^] \n\t\r]*)
;; for open wiki search query with local application database.
+(defun chinese-string-p (string)
+ "Return t if STRING is a Chinese string."
+ (if (string-match (format "\\cC\\{%s\\}" (length string)) string)
+ t
+ nil))
+
(defun kiwix-org-get-library (link)
"Get library from Org-mode `LINK'."
(if (string-match-p "[a-zA-Z\ ]+" (match-string 2 link)) ; validate query is
English
;; convert between libraries full name and abbrev.
- (or (match-string 1 link) (kiwix-select-library))
+ (or (match-string 1 link) (kiwix-select-library "en"))
;; validate query is non-English
(kiwix-select-library "zh")))
@@ -354,7 +360,7 @@ for query string and library interactively."
;; - query : should not exclude space
(when (string-match "\\(?:(\\(.*\\)):\\)?\\([^]\n\t\r]*\\)" link) ;
(library):query
(let* ((library (kiwix-org-get-library link))
- (query (match-string 2 link))
+ (query (if (chinese-string-p link) link (match-string 2 link)))
(url (concat
kiwix-server-url
library "/A/"
- [elpa] externals/kiwix 7e18994 158/192: add a custom option for kiwix default libraries path, (continued)
- [elpa] externals/kiwix 7e18994 158/192: add a custom option for kiwix default libraries path, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 4243689 156/192: check whether Docker image "kiwix/kiwix-serve" is available, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix d7c4778 162/192: select library require matched in candidates, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 5b5b117 163/192: improve the kiwix-query URL to use the search API, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix f4a1e2d 164/192: rename function* -> cl-function, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix cf6fc32 165/192: add :status-code handler, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 3fe879f 168/192: refresh libraries before selecting library, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 716c5f6 169/192: Docker container launch command use library.xml index file, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix cd95bc9 171/192: update README: using libraries index file "library.xml", Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 9db0a13 172/192: display screenshots at beginning, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 5f64044 175/192: support detect whether query is chinese,
Stefan Monnier <=
- [elpa] externals/kiwix 6c6c443 176/192: fix Org link open function, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 7fda411 184/192: fix org-link-set-parameters functions not available when Org not loaded, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 5bd84a6 187/192: select kiwix library when completing org link, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix d92a371 189/192: Fix some byte-compile warnings, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 905a413 192/192: Fix #4 add GNU license info in package source code file, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 2d33910 072/192: Merge tag 'v0.5.0' into develop, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix bf128fb 087/192: Merge branch 'hotfix/void-function_org-link-set-parameters', Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix f3a2d8f 091/192: Merge branch 'release/0.6.1', Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix f84b449 070/192: autoload Org-mode link adding, Stefan Monnier, 2020/12/19
- [elpa] externals/kiwix 3485131 071/192: Merge branch 'develop', Stefan Monnier, 2020/12/19