From 35a15e183ced5cb9529d7e35433dcb26db548897 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 10 Jul 2023 12:03:38 +1000 Subject: Add some more wikis and wiki-open-url --- wiki-engine.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'wiki-engine.el') diff --git a/wiki-engine.el b/wiki-engine.el index a201c72..fb6fcba 100644 --- a/wiki-engine.el +++ b/wiki-engine.el @@ -90,13 +90,20 @@ The site name is passed as a symbol WIKI-SITE." (defun-wiki-fetchers) (defun wiki-open-url (url) - "Open the wiki corresponding to URL. + "Open the raw wiki corresponding to the URL of a html wiki page. -If URL points to html title, open the corresponding raw title. -If URL points to a raw title, open directly. -If URL points to a host, assume it is mediawiki try to open main page." +If URL points to html title, open the corresponding raw title." (interactive "sURL: ") - + (when-let + ((found-site + (seq-find + (lambda (site-pair) + (when-let ((base-url (plist-get (cdr site-pair) :base-url))) + (string-prefix-p base-url url))) + wiki-sites))) + (pcase-let ((`(,site-id . ,site-info) found-site)) + (funcall (wiki-site-fetcher site-id) + (string-remove-prefix (plist-get site-info :base-url) url)))) ) (provide 'wiki-engine) -- cgit v1.2.3