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

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

[elpa] externals/kiwix 4bdf16b 188/192: smarter `kiwix-org-get-library'


From: Stefan Monnier
Subject: [elpa] externals/kiwix 4bdf16b 188/192: smarter `kiwix-org-get-library' detect existing library in link
Date: Sat, 19 Dec 2020 00:41:58 -0500 (EST)

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

    smarter `kiwix-org-get-library' detect existing library in link
---
 org-kiwix.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/org-kiwix.el b/org-kiwix.el
index 4076051..34bf511 100644
--- a/org-kiwix.el
+++ b/org-kiwix.el
@@ -1,6 +1,6 @@
 ;;; org-kiwix.el --- Org Mode link support -*- lexical-binding: t; -*-
 
-;;; Time-stamp: <2020-05-12 21:23:23 stardiviner>
+;;; Time-stamp: <2020-07-11 17:39:13 stardiviner>
 
 ;;; Commentary:
 
@@ -37,13 +37,17 @@
 
 (defun kiwix-org-get-library (link)
   "Get library from Org-mode `LINK'."
-  (cond
-   ((chinese-string-p link)
-    (kiwix-select-library "zh"))
-   ((string-match-p "[a-zA-Z\ ]+" link)
-    ;; convert between libraries full name and abbrev.
-    (kiwix-select-library "en"))
-   (t (kiwix-select-library))))
+  (let ((library (catch 'args-out-of-range
+                   (when (string-match "(\\([^)].*\\)):\\(.*\\)" link)
+                     (match-string 1 link)))))
+    (or library
+        (cond
+         ((chinese-string-p link)
+          (kiwix-select-library "zh"))
+         ((string-match-p "[a-zA-Z\ ]+" link)
+          ;; convert between libraries full name and abbrev.
+          (kiwix-select-library "en"))
+         (t (kiwix-select-library))))))
 
 ;;;###autoload
 (defun org-wikipedia-open-link (link)



reply via email to

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