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

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

[elpa] externals/kiwix 43e0547 083/192: Merge branch 'release/v0.6.0'


From: Stefan Monnier
Subject: [elpa] externals/kiwix 43e0547 083/192: Merge branch 'release/v0.6.0'
Date: Sat, 19 Dec 2020 00:41:38 -0500 (EST)

branch: externals/kiwix
commit 43e05477ad4633bbc2582f7491071e186f3986cd
Merge: 6fb8354 9d16244
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    Merge branch 'release/v0.6.0'
---
 README.org |  1 +
 kiwix.el   | 32 +++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/README.org b/README.org
index a7824e5..f1e4799 100644
--- a/README.org
+++ b/README.org
@@ -84,3 +84,4 @@ The =(library)= can be =wikipedia_en=, =wikipedia_zh=, 
=wiktionary_en=, or =en=,
 - [[wiki:Operations%20Research][Operations Research]] :: query contains space.
 - [[wiki:Operations%20research][Operations research]] :: the second word is 
not capitalized.
 - [[wiki:%E4%B8%AD%E5%9B%BD][中国]] :: non-english query
+- [[wiki:meta-circular%20interpreter][meta-circular interpreter]] :: only 
capitalize the first word.
diff --git a/kiwix.el b/kiwix.el
index 3adc442..d5211b7 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -122,7 +122,9 @@
   (cdr (assoc abbr kiwix-libraries-abbrev-alist)))
 
 (defcustom kiwix-default-library "wikipedia_en_all"
-  "The default kiwix library when library fragment in link not specified.")
+  "The default kiwix library when library fragment in link not specified."
+  :type 'string
+  :group 'kiwix)
 
 ;; add default key-value pair to libraries alist.
 (dolist
@@ -134,6 +136,11 @@
   (push cons kiwix-libraries-abbrev-alist)
   )
 
+(defcustom kiwix-your-language-library "zh"
+  "Specify the library for your navtive language."
+  :type 'string
+  :group 'kiwix)
+
 ;; test
 ;; (kiwix-get-library-fullname "wikipedia_en")
 ;; (kiwix-get-library-fullname "default")
@@ -239,19 +246,23 @@ 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 kiwix-org-get-library ()
+  "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.
+      (kiwix-get-library-fullname (or (match-string 1 link)
+                                      "default"))
+    ;; validate query is non-English
+    (kiwix-get-library-fullname kiwix-your-language-library)
+    )
+  )
+
 (defun org-wiki-link-open (link)
   "Open LINK in external wiki program."
   ;; The regexp: (library):query
   ;; - query : should not exclude space
   (when (string-match "\\(?:(\\(.*\\)):\\)?\\([^]\n\t\r]*\\)"  link) ; 
(library):query
-    (let* (
-           (library (if (string-match-p "[a-zA-Z\ ]+" (match-string 2 link)) ; 
validate query is English
-                        ;; convert between libraries full name and abbrev.
-                        (kiwix-get-library-fullname (or (match-string 1 link)
-                                                        "default"))
-                      ;; validate query is non-English
-                      (kiwix-get-library-fullname "zh")
-                      ))
+    (let* ((library (kiwix-org-get-library))
            (query (match-string 2 link))
            (url (concat
                  kiwix-server-url
@@ -271,8 +282,7 @@ for query string and library interactively."
 (defun org-wiki-link-export (link description format)
   "Export the wiki LINK with DESCRIPTION for FORMAT from Org files."
   (when (string-match "\\(?:(\\(.*\\)):\\)?\\([^] \n\t\r]*\\)" link)
-    (let* ((library (or (match-string 1 link)
-                        (kiwix-get-library-fullname "default")))
+    (let* ((library (kiwix-org-get-library))
            (query (url-encode-url (or (match-string 2 link) description)))
            ;; "http://en.wikipedia.org/wiki/Linux";
            ;;         --



reply via email to

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