In SWI-Prolog, one often refers to source file paths using file
specifications, special Prolog terms that act as path aliases, such
as library(lists)
which refers to a file lists.pl in any
of the Prolog library directories.
Resolve file specification at point and visit the specified file
(sweeprolog-find-file-at-point
).
Return the file name specified by the Prolog file specification at point.
You can follow file specifications that occur in Sweep Prolog mode
buffers with C-c C-o (or M-x sweeprolog-find-file-at-point
RET) whenever point is over a valid file specification. For
example, consider a Prolog file buffer with the common directive
use_module/1
:
:- use_module(library(lists)).
With point anywhere inside library(lists)
, type C-c C-o
to open the lists.pl file in the Prolog library.
Sweep also extends Emacs’s file-name-at-point-functions
hook
with the function sweeprolog-file-at-point
that returns the
resolved Prolog file specification at point, if any. Emacs uses this
hook to populate the “future history” of minibuffer prompts that
read file names, such as the one you get when you type C-x C-f
(find-file
). In particular this means that if point is in a
Prolog file specification, you can type M-n after C-x C-f
to populate the minibuffer with the corresponding file name. You can
then go ahead and visit the file by typing RET, or you can
edit the minibuffer contents and visit a nearby file instead.
For more information about file specifications in SWI-Prolog, see
absolute_file_name/3
in the SWI-Prolog manual.