emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sweeprolog 22f7108f65 1/2: Workaround issue with Xwidgets


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog 22f7108f65 1/2: Workaround issue with Xwidgets and XPCE in older SWI-Prolog
Date: Mon, 14 Aug 2023 16:01:10 -0400 (EDT)

branch: elpa/sweeprolog
commit 22f7108f6543663d55f5281746acf4fdbfbcd17a
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    Workaround issue with Xwidgets and XPCE in older SWI-Prolog
    
    * sweeprolog.el (sweeprolog-init-args): Disable XPCE if Emacs is built
    with Xwidgets and SWI-Prolog version is earlier then 9.1.14.
    
    * README.org (Prolog Initialization and Cleanup): Reword
    'sweeprolog-init-args' documentation.
---
 README.org    | 31 ++++++++++++++++++-------------
 sweeprolog.el | 37 ++++++++++++++++++++++++++++---------
 2 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/README.org b/README.org
index d48badc631..09ef6b1bcd 100644
--- a/README.org
+++ b/README.org
@@ -268,27 +268,32 @@ its customization options in Sweep:
 #+FINDEX: sweeprolog-restart
 - Command: sweeprolog-restart :: Restart the embedded Prolog runtime.
 
-In Sweep, Prolog initialization is done via
-the C-implemented =sweeprolog-initialize= Elisp function defined in
-=sweep-module=.  =sweeprolog-initialize= takes one or more arguments, which
-must all be strings, and initializes the embedded Prolog as if it were
-invoked externally in a command line with the given strings as command
-line arguments, where the first argument to =sweeprolog-initialize=
-corresponds to =argv[0]=.
+In Sweep, Prolog initialization is done via the C-implemented
+~sweeprolog-initialize~ Elisp function defined in ~sweep-module~.
+~sweeprolog-initialize~ takes one or more string arguments and
+initializes the embedded Prolog as if it were invoked externally in a
+command line with the given strings as command line arguments, where
+the first argument to ~sweeprolog-initialize~ corresponds to
+~argv[0]~.
 
 Sweep loads and initializes Prolog on-demand at the first invocation
-of a command that requires the embedded Prolog.  The arguments used to
-initialize Prolog are then determined by the value of the user-option
-~sweeprolog-init-args~ which the user is free to extend with e.g.:
+of a command that requires the embedded Prolog.  The user option
+~sweeprolog-init-args~ says which arguments to pass to Prolog
+initialization.  Its value is a list of strings that you can extend if
+you want to pass specific command line flags SWI-Prolog.  For example,
+to limit the embedded Prolog stack to 512 MB, add the following to
+your Emacs configuration:
 
 #+begin_src emacs-lisp
-  (add-to-list 'sweeprolog-init-args "--stack-limit=512m")
+  (with-eval-after-load 'sweeprolog
+    (push "--stack-limit=512m" sweeprolog-init-args))
 #+end_src
 
 #+CINDEX: sweep Prolog flag
 The default value of ~sweeprolog-init-args~ is set to load the Prolog
-helper library =sweep.pl= and to create a boolean Prolog flag Sweep, set
-to ~true~, which indicates to SWI-Prolog that it is running under Sweep.
+helper library =sweep.pl= and to create a boolean Prolog flag called
+~sweep~ with value ~true~.  You can check for this flag in Prolog code
+to detect at runtime that you're running under Sweep.
 
 #+CINDEX: command line arguments
 It is also possible to specify initialization arguments to SWI-Prolog
diff --git a/sweeprolog.el b/sweeprolog.el
index 579e0bc48b..1a445235d8 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -284,16 +284,35 @@ inserted to the input history in 
`sweeprolog-top-level-mode' buffers."
                          " regardless of the value of this option.")
                         "sweeprolog version 0.7.2")
 
-(defcustom sweeprolog-init-args (list "-q"
-                                      "--no-signals"
-                                      "-g"
-                                      
"create_prolog_flag(sweep,true,[access(read_only),type(boolean)])"
-                                      "-l"
-                                      (expand-file-name
-                                       "sweep.pl"
-                                       sweeprolog--directory))
+(defcustom sweeprolog-init-args
+  (append
+   (when (and (featurep 'xwidget-internal)
+              (when-let (swipl (or sweeprolog-swipl-path
+                                   (executable-find "swipl")))
+                (<= 90114               ; first SWI-Prolog version to
+                                        ; hide XPCE private symbols
+                    (string-to-number
+                     (with-output-to-string
+                       (with-current-buffer standard-output
+                         (call-process swipl
+                                       nil '(t nil) nil
+                                       "-g"
+                                       "current_prolog_flag(version, V), 
writeln(V)"
+                                       "-t" "halt")))))))
+     ;; Disable XPCE if Emacs has been built with Xwidgets to
+     ;; workaround a potential crash due to symbol collision
+     ;; (see https://github.com/SWI-Prolog/swipl-devel/issues/1188).
+     '("--pce=false"))
+   (list "-q"
+         "--no-signals"
+         "-g"
+         "create_prolog_flag(sweep,true,[access(read_only),type(boolean)])"
+         "-l"
+         (expand-file-name
+          "sweep.pl"
+          sweeprolog--directory)))
   "List of strings used as initialization arguments for Prolog."
-  :package-version '((sweeprolog "0.5.2"))
+  :package-version '((sweeprolog "0.22.2"))
   :type '(repeat string)
   :group 'sweeprolog)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]