Did you know ... Search Documentation:
messages.pl
PublicShow source
Source translate_message(+Term)// is det
Translate a message Term into message lines. The produced lines is a list of
nl
Emit a newline
Fmt - Args
Emit the result of format(Fmt, Args)
Fmt
Emit the result of format(Fmt)
ansi(Class, Fmt, Args)
Use ansi_format/3 for color output.
url(Location)
Emit a source location as a hyperlink. Location is File:Line:Column, File:Line, File or a URL.
url(Location, Label)
As above, but print Label rather than Location. Label is plain text, Fmt-Args or ansi(Class, Fmt, Args), the latter combining a hyperlink with a style class.
flush
Used only as last element of the list. Simply flush the output instead of producing a final newline.
at_same_line
Start the messages at the same line (instead of using ~N)
eol
End the decorated part of the last line. See print_message_lines/3.

The elements begin(Class, Ctx) and end(Ctx) that decorate the message as a whole are added by print_message_lines/3.

Use predicate_reference//1,2 to refer to a predicate rather than formatting the predicate indicator by hand.

deprecated
- Use code for message translation should call translate_message//1.
Source translate_message(+Term)// is det
Translate a message term into message lines. This version may be called from user and library definitions for message translation.
Source term_message(+Term)//
Deal with the formal argument of error(Format, ImplDefined) exception terms. The ImplDefined argument is handled by swi_location//2.
Source swi_location(+Term)// is det
Print location information for error(Formal, ImplDefined) from the ImplDefined term.
Source predicate_indicator(+Spec, -QPI) is semidet
QPI is the fully qualified predicate indicator Module:Name/Arity or, for a non-terminal, Module:Name//Arity for Spec. Spec is one of
  • A callable term (a head), optionally module qualified
  • A predicate indicator, optionally module qualified

The module is kept here. Whether or not it is printed is left to predicate_reference//2, which uses user_predicate_indicator/2.

See also
- pi_head/2 of library(prolog_code) for the general version. This one is in the boot files and thus cannot use it.
Source predicate_reference(+Spec)// is det
Source predicate_reference(+Spec, +Options)// is det
Emit a reference to a predicate. Spec is a (possibly qualified) head or predicate indicator. The reference is printed using the style class code and, if the location of the predicate is known and the output is a terminal that supports it, it is a hyperlink to the definition. Options:
module(+Which)
One of auto (default), hide or show. Using auto, the module qualification is removed if hidden_module/1 holds for it.
link(+Bool)
If false, do not try to create a hyperlink. Default true.
style(+Class)
Style class for the reference. Default code.
tag(+Bool)
If true, add a tag that indicates the kind of predicate. See predicate_kind/2. Default false. Only sensible if the reference is the only thing on the line.

If Spec cannot be interpreted as a predicate it is printed using the code class and ~p, i.e., we never fail on a malformed message.

Source predicate_location(+Spec, -Location) is semidet
Location is File:Line for the definition of the predicate Spec. Also deals with predicates defined in C. Note that predicates that are not loaded but can be autoloaded are located from the autoload index, i.e., printing a message never loads a library.
Source predicate_definition(+Spec, +Message)// is det
Emit "Message at File:Line" on a new line if the location of Spec is known and nothing at all if it is not.
Source predicate_kind(+Spec, -Kind) is semidet
Classify a predicate for the benefit of the user who has to pick one from a list of candidates. Fails if Spec is not a predicate. Kind is one of
  • iso
  • built_in
  • foreign
  • library(Name)
  • module(Module)
  • user
  • undefined
Source print_message(+Kind, +Term)
Print an error message using a term as generated by the exception system.
Source print_message_lines(+Stream, +PrefixOrKind, +Lines)
Quintus compatibility predicate to print message lines using a prefix.

If PrefixOrKind is kind(Kind), the message as a whole may be decorated. To this end the lines are wrapped in begin(Class, Ctx) and end(Ctx), where Class is derived from Kind using msg_color_class/2. Ctx is a variable that is bound by whoever implements prolog:message_line_element/2 for begin/2 (normally library(ansi_term)) and remains unbound if the decoration is not available, e.g., because Stream is not a terminal.

The elements that need Ctx are rewritten by prefix_nl/4 to carry it. See there for the details.

Source link_label(+Label, -Format, -Args) is det
Decompose the label of an url/2 message element. See url/2 in print_message_lines/3. Note that a plain label is text rather than a format: it typically holds a file name, which may contain ~.
Source message_to_string(+Term, -String)
Translate an error term into a string