]> git.eshelyaron.com Git - dict.git/commitdiff
* (sweeprolog--ensure-module): detect and report missing sweep.pl
authorEshel Yaron <me@eshelyaron.com>
Sat, 3 Dec 2022 18:13:20 +0000 (20:13 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 3 Dec 2022 18:13:20 +0000 (20:13 +0200)
sweeprolog.el

index df231b9d7d94b97920655330581436d524cb6482..514dd3acbbc96c6d2cc7b6dd763d18e0947b84a9 100644 (file)
@@ -538,23 +538,26 @@ non-terminals)."
 (defun sweeprolog--ensure-module ()
   "Locate and load `sweep-module', unless already loaded."
   (unless (featurep 'sweep-module)
-    (if-let ((lines (save-match-data
-                      (split-string
-                       (with-output-to-string
-                         (with-current-buffer standard-output
-                           (call-process
-                            (or sweeprolog-swipl-path "swipl")
-                            nil '(t nil) nil
-                            "-q" "-g" "write_sweep_module_location"
-                            "-t" "halt"
-                            (expand-file-name
-                             "sweep.pl"
-                             sweeprolog--directory))))
-                       "\n" t))))
-        (mapc #'sweeprolog--load-module lines)
-      (error (concat "Failed to locate `sweep-module'. "
-                     "Make sure SWI-Prolog is installed "
-                     "and up to date")))))
+    (let ((sweep-pl (expand-file-name
+                     "sweep.pl"
+                     sweeprolog--directory)))
+      (unless (file-readable-p sweep-pl)
+        (error "Missing file `sweep.pl' in `sweeprolog' directory"))
+      (if-let ((lines (save-match-data
+                        (split-string
+                         (with-output-to-string
+                           (with-current-buffer standard-output
+                             (call-process
+                              (or sweeprolog-swipl-path "swipl")
+                              nil '(t nil) nil
+                              "-q" "-g" "write_sweep_module_location"
+                              "-t" "halt"
+                              sweep-pl)))
+                         "\n" t))))
+          (mapc #'sweeprolog--load-module lines)
+        (error (concat "Failed to locate `sweep-module'. "
+                       "Make sure SWI-Prolog is installed "
+                       "and up to date"))))))
 
 (defun sweeprolog-ensure-initialized ()
   (sweeprolog--ensure-module)