7.2 Semantic Highlighting

Sweep Prolog mode highlights Prolog code through the standard Emacs font-lock system (see (emacs)Font Lock). Sweep Prolog mode highlights different tokens in Prolog code according to their semantics, determined through static analysis that Sweep performs on demand. When you first open a buffer in Sweep Prolog mode, its entire contents are analyzed to collect and cache cross reference data, and Sweep highlight all of the code in the buffer accordingly. In contrast, while you edit and move around the buffer, Sweep uses a faster, local analysis for updating the semantic highlighting in response to changes in the buffer.

C-c C-c

Analyze the current buffer and update cross-references (sweeprolog-analyze-buffer).

User Option: sweeprolog-analyze-buffer-on-idle

Whether to analyze sweeprolog-mode buffers on idle. Defaults to t.

User Option: sweeprolog-analyze-buffer-max-size

Maximum number of characters in a Sweep Prolog mode buffer to analyze on idle. Larger buffers are not analyzed on idle. Defaults to 100,000 characters.

User Option: sweeprolog-analyze-buffer-min-interval

Minimum number of idle seconds to wait before analyzing a sweeprolog-mode buffer. Defaults to 1.5.

At any point in a sweeprolog-mode buffer, you can use the command C-c C-c (M-x sweeprolog-analyze-buffer) to update the cross reference cache and highlight the buffer accordingly. When Sweep’s Flymake integration is enabled, this command also updates the diagnostics for the current buffer (see Examining Diagnostics). This may be useful, for example, after defining a new predicate.

If the user option sweeprolog-analyze-buffer-on-idle is set to non-nil (as it is by default), Sweep also updates semantic highlighting in the buffer whenever Emacs is idle for a reasonable amount of time, unless the buffer is larger than the value of the sweeprolog-analyze-buffer-max-size user option. You can specify a minimum idle time for Sweep to wait before updating reanalyzing the buffer highlighting is controlled by customizing the user option sweeprolog-analyze-buffer-min-interval.

To view and customize the various faces that Sweep defines and uses for semantic highlighting, type M-x customize-group RET sweeprolog-faces RET. See (emacs)Faces, for more information about text faces in Emacs.