branch: externals/kiwix commit edd84586be5ad1d530dfdde4544cc23131badf1d Author: stardiviner <numbch...@gmail.com> Commit: stardiviner <numbch...@gmail.com>
Make external library elquery optional --- kiwix.el | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/kiwix.el b/kiwix.el index 5761f02..d715180 100644 --- a/kiwix.el +++ b/kiwix.el @@ -7,7 +7,7 @@ ;; Homepage: https://github.com/stardiviner/kiwix.el ;; Created: 23th July 2016 ;; Version: 1.1.0 -;; Package-Requires: ((emacs "24.4") (request "0.3.0") (elquery "0.1.0")) +;; Package-Requires: ((emacs "24.4") (request "0.3.0")) ;; Copyright (C) 2019-2020 Free Software Foundation, Inc. @@ -61,7 +61,6 @@ (require 'subr-x) (require 'thingatpt) (require 'json) -(require 'elquery) (declare-function helm "helm") (declare-function helm-build-async-source "helm") @@ -156,21 +155,25 @@ Set it to ‘t’ will use Emacs built-in ‘completing-read’." :type "GET" :sync t :parser (lambda () - (let ((html (elquery-read-string (buffer-substring-no-properties (point-min) (point-max))))) - (setq kiwix-libraries - (mapcar - ;; remove "/" from "/<zim_library_name>" - (lambda (slash_library) - (substring slash_library 1 nil)) - ;; extract plist values. list of "/<zim_library_name>" - (mapcar 'cadr - ;; extract nodes properties in plist - (mapcar #'elquery-props - ;; return a list of elquery nodes - (elquery-children - ;; return the <div class="book__list"> - (car (elquery-$ ".book__list" html))))))) - (elquery-children (first (elquery-$ ".book__list" html))))) + (if (not (featurep 'elquery)) + (print "PLACEHOLDER: use libxml by default") + (require 'elquery) + (let ((html (elquery-read-string + (buffer-substring-no-properties (point-min) (point-max))))) + (setq kiwix-libraries + (mapcar + ;; remove "/" from "/<zim_library_name>" + (lambda (slash_library) + (substring slash_library 1 nil)) + ;; extract plist values. list of "/<zim_library_name>" + (mapcar 'cadr + ;; extract nodes properties in plist + (mapcar #'elquery-props + ;; return a list of elquery nodes + (elquery-children + ;; return the <div class="book__list"> + (car (elquery-$ ".book__list" html))))))) + (elquery-children (first (elquery-$ ".book__list" html)))))) :error (cl-function (lambda (&rest args &key error-thrown &allow-other-keys) (message "Function kiwix-get-libraries error.")))