]> git.eshelyaron.com Git - dict.git/commitdiff
FIXED: disregard stderr when invoking write_sweep_module_location
authorEshel Yaron <me@eshelyaron.com>
Sat, 15 Oct 2022 06:26:41 +0000 (09:26 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 15 Oct 2022 10:38:20 +0000 (13:38 +0300)
sweep.pl
sweeprolog.el

index c697323efbc0ed93a0aa83dcb644e5a7d39e388a..3a9667b9908db88d4ac3591bc37b4c426a2631ab 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -782,6 +782,11 @@ write_sweep_module_location :-
     absolute_file_name(foreign('sweep-module'),
                        Path,
                        [file_type(executable), access(read)]),
+    (   current_prolog_flag(executable_format, elf)
+    ->  current_prolog_flag(libswipl, Libpath),
+        writeln(Libpath)
+    ;   true
+    ),
     writeln(Path).
 
 sweep_top_level_server(_, Port) :-
index 2d023de0dad3cd052786e3f43e1e6f218091094e..190498143cc0631974f22d8d6773139e90ba75ef 100644 (file)
@@ -217,57 +217,23 @@ clause."
 (defun sweeprolog--ensure-module ()
   "Locate and load `sweep-module', unless already loaded."
   (unless (featurep 'sweep-module)
-    (when-let ((exec-format (car
-                             (save-match-data
-                               (split-string
-                                (shell-command-to-string
-                                 (concat
-                                  (shell-quote-argument
-                                   (or sweeprolog-swipl-path (executable-find "swipl")))
-                                  " -q"
-                                  " -g 'current_prolog_flag(executable_format, X), writeln(X)'"
-                                  " -t halt"))
-                                "\n"
-                                t)))))
-      (when (string= exec-format "elf")
-        (let ((libswipl-path (or sweeprolog-libswipl-path
-                                 (car
-                                  (save-match-data
-                                    (split-string
-                                     (shell-command-to-string
-                                      (concat
-                                       (shell-quote-argument
-                                        (or sweeprolog-swipl-path (executable-find "swipl")))
-                                       " -q"
-                                       " -g 'current_prolog_flag(libswipl, X), writeln(X)'"
-                                       " -t halt"))
-                                     "\n"))))))
-          (condition-case _
-              (load libswipl-path)
-            (file-error (user-error
-                         (concat "Failed to load `libswipl'. "
-                                 "Make sure SWI-Prolog is installed "
-                                 "and up to date")))))))
-    (let ((sweep-module-path (car
-                              (save-match-data
-                                (split-string
-                                 (shell-command-to-string
-                                  (concat
-                                   (shell-quote-argument
-                                    (or sweeprolog-swipl-path (executable-find "swipl")))
-                                   " -g write_sweep_module_location"
-                                   " -t halt "
-                                   (shell-quote-argument
-                                    (expand-file-name
-                                     "sweep.pl"
-                                     (file-name-directory load-file-name)))))
-                                 "\n")))))
-      (condition-case _
-          (load sweep-module-path)
-        (file-error (user-error
-                     (concat "Failed to locate `sweep-module'. "
-                             "Make sure SWI-Prolog is installed "
-                             "and up to date")))))))
+    (if-let ((paths (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"
+                             (file-name-directory load-file-name)))))
+                       "\n" t))))
+        (mapc #'load paths)
+      (error (concat "Failed to locate `sweep-module'. "
+                     "Make sure SWI-Prolog is installed "
+                     "and up to date")))))
 
 (defface sweeprolog-debug-prefix-face
   '((default :inherit shadow))