7.21 Managing Dependencies

It is considered good practice to explicitly list the dependencies of your SWI-Prolog source files on predicates defined in other files by using autoload/2 and use_module/2 directives, rather than relying on implicit autoloads. To find all implicitly autoloaded predicates in the current sweeprolog-mode buffer and make the dependencies on them explicit, use the command sweeprolog-update-dependencies bound to C-c C-u.

C-c C-u

Add explicit dependencies for implicitly autoloaded predicates in the current buffer (sweeprolog-update-dependencies).

User Option: sweeprolog-dependency-directive

Determines which Prolog directive to use in sweeprolog-update-dependencies when adding new directives. The value of this user option is one of the symbols use-module, autoload or infer. If it is use-module, sweeprolog-update-dependencies adds use_module/2 directives, a value of autoload means to add autoload/2 directives, and infer says to infer which directive to use based on the existing dependency directives in the buffer, if any. Defaults to infer.

User Option: sweeprolog-note-implicit-autoloads

Whether Flymake should complain about implicitly autoloaded predicates in Sweep Prolog mode buffers.

The command sweeprolog-update-dependencies, bound to C-c C-u, analyzes the current buffer and adds or updates autoload/2 and use_module/2 directives as needed.

When this command adds a new directive, rather than updating an existing one, it can use either autoload/2 or use_module/2 to declare the new dependency based on the value of the user option sweeprolog-dependency-directive. If you set this option is to use-module, new dependencies use the use_module/2 directive. If it’s autoload, new dependencies use autoload/2. If it’s infer, as it is by default, new dependencies use autoload/2 unless the buffer already contains dependency directives and they are all use_module/2 directives, in which case they also use use_module/2.

By default, when Flymake integration is enabled (see Examining Diagnostics), Sweep highlights calls to implicitly autoloaded predicates and reports them as Flymake diagnostics. To inhibit Flymake from diagnosing implicit autoloads, customize the user option sweeprolog-note-implicit-autoloads to nil.