From 72deef2fbf72ade7f795135020d922fa8e4c8171 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 3 Dec 2022 20:13:20 +0200 Subject: [PATCH] * (sweeprolog--ensure-module): detect and report missing sweep.pl --- sweeprolog.el | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index df231b9..514dd3a 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -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) -- 2.39.2