branch: elpa/sweeprolog
commit ed2733e7216466ff4f9d86029786c3480c8ed986
Author: Eshel Yaron <m...@eshelyaron.com>
Commit: Eshel Yaron <m...@eshelyaron.com>

    Use 'process-lines-handling-status'.
    
    * sweeprolog.el (sweeprolog--ensure-module): Use
    'process-lines-handling-status' instead of 'split-string'-based
    approach.
---
 sweeprolog.el | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/sweeprolog.el b/sweeprolog.el
index 693befcb0c..7a11bfcd25 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -745,21 +745,19 @@ pack completion candidates."
                      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"))))))
+      (let* ((success nil)
+             (lines (process-lines-handling-status
+                     (or sweeprolog-swipl-path "swipl")
+                     (lambda (status)
+                       (setq success (= status 0)))
+                     "-q" "-g" "write_sweep_module_location"
+                     "-t" "halt"
+                     sweep-pl)))
+        (if (and success lines)
+            (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)

Reply via email to