]> git.eshelyaron.com Git - sweep.git/commitdiff
Use 'process-lines-handling-status'.
authorEshel Yaron <me@eshelyaron.com>
Thu, 17 Aug 2023 21:33:46 +0000 (23:33 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 17 Aug 2023 21:33:46 +0000 (23:33 +0200)
* sweeprolog.el (sweeprolog--ensure-module): Use
'process-lines-handling-status' instead of 'split-string'-based
approach.

sweeprolog.el

index 693befcb0ca449de495eaa68179ed6a1ba6be928..7a11bfcd25779dffc489c8579aabdcddd91909d9 100644 (file)
@@ -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)