branch: externals/kiwix
commit 86dbead6c0017beefd92a0b64a0bb5f5d12c5b16
Author: stardiviner <[email protected]>
Commit: stardiviner <[email protected]>
add a helper function to detect kiwix profile directory accessible.
Fix kiwix profile directory not accessible issue.
---
kiwix.el | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/kiwix.el b/kiwix.el
index 2d3e544..6335208 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -60,20 +60,29 @@
:type 'string
:group 'kiwix)
+;;;###autoload
+(defun kiwix-dir-detect ()
+ "Detect Kiwix profile directory exist."
+ (let ((kiwix-dir (concat (getenv "HOME") "/.www.kiwix.org/kiwix")))
+ (unless (not (file-accessible-directory-p kiwix-dir))
+ (warn "ERROR: Kiwix profile directory \".www.kiwix.org/kiwix\" is not
accessible."))))
+
(defcustom kiwix-default-data-profile-name
- (car (directory-files
- (concat
- (getenv "HOME") "/.www.kiwix.org/kiwix")
- nil
- ".*\\.default"
- ))
+ (when (kiwix-dir-detect)
+ (car (directory-files
+ (concat
+ (getenv "HOME") "/.www.kiwix.org/kiwix")
+ nil
+ ".*\\.default"
+ )))
"Specify the default Kiwix data profile path."
:type 'string
:group 'kiwix)
(defcustom kiwix-default-data-path
- (concat
- (getenv "HOME") "/.www.kiwix.org/kiwix/" kiwix-default-data-profile-name)
+ (when (kiwix-dir-detect)
+ (concat
+ (getenv "HOME") "/.www.kiwix.org/kiwix/" kiwix-default-data-profile-name))
"Specify the default Kiwix data path."
:type 'string
:group 'kiwix)
@@ -90,10 +99,11 @@
:group 'kiwix)
(defvar kiwix-libraries
- (mapcar #'(lambda (var)
- (replace-regexp-in-string "\.zim" "" var))
- (directory-files
- (concat kiwix-default-data-path "/data/content/") nil ".*\.zim"))
+ (when (kiwix-dir-detect)
+ (mapcar #'(lambda (var)
+ (replace-regexp-in-string "\.zim" "" var))
+ (directory-files
+ (concat kiwix-default-data-path "/data/content/") nil ".*\.zim")))
"A list of Kiwix libraries.")
;; - examples: