You can load a buffer of SWI-Prolog code with the following command:
Use the command
sweeprolog-load-buffer to load the contents of
a Sweep Prolog mode buffer into the embedded SWI-Prolog runtime.
After a buffer is loaded, you can query the predicates it defines from
Elisp (see Querying Prolog) and from the Sweep top-level
(see The Prolog Top-level). In Sweep Prolog mode buffers,
sweeprolog-load-buffer is bound to C-c C-l. By default
this command loads the current buffer if its major mode is
sweeprolog-mode, and prompts for an appropriate buffer
otherwise. To choose a different buffer to load while visiting a
sweeprolog-mode buffer, invoke
with a prefix argument (C-u C-c C-l).
The mode line displays the word ‘Loaded’ next to the ‘Sweep’ major mode indicator if the current buffer has been loaded and hasn’t been modified since. See (emacs)Mode Line, for more information about the mode line.
More relevant information about loading code in SWI-Prolog can be found in Loading Prolog source files in the SWI-Prolog manual.