#+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
" 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)