From: Eshel Yaron Date: Sat, 15 Oct 2022 06:26:41 +0000 (+0300) Subject: FIXED: disregard stderr when invoking write_sweep_module_location X-Git-Tag: V8.5.18-sweep-0.6.2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7587649505febea7df232d8d70f11db8b438ff23;p=sweep.git FIXED: disregard stderr when invoking write_sweep_module_location --- diff --git a/sweep.pl b/sweep.pl index c697323..3a9667b 100644 --- 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) :- diff --git a/sweeprolog.el b/sweeprolog.el index 2d023de..1904981 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -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))