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 permission_error(Action, Type, Object)//[private]
Translate permission errors. Most follow te pattern "No permission to Action Type Object", but some are a bit different.
Source tabling_existence_error(+Ball, +Context)//[private]
Called on invalid shift/1 calls. Track those that result from tabling errors.
Source dwim_predicates(+PI, -Dwims)[private]
Find related predicate indicators.
Source swi_location(+Term)// is det
Print location information for error(Formal, ImplDefined) from the ImplDefined term.
Source swi_extra(+Term)// is det[private]
Extract information from the second argument of an error(Formal, ImplDefined) that is printed after the core of the message.
See also
- swi_location//1 uses the same term to insert context before the core of the message.
Source prolog_message(+Term)//[private]
Source user_predicate_indicator(+QPI, -PI) is det[private]
Remove the module qualification from QPI if it does not add information for the user. This is the single module hiding policy of this file. See also predicate_reference//2.
 out_of_c_stack[private]
The thread's C-stack limit was exceeded. Give some advice on how to resolve this.
Source extra_line// is det[private]
End the answer and, if toplevel_extra_white_line is true, add an empty line. The ~N cannot be replaced by nl because the answer is not always left at a non-empty line. The eol element paints the remainder of the line if the message has a background colour, which ~N cannot do as it is written using format/3.

Note that eol ends the last line of the answer. The empty line that separates the answer from the next query is not part of the answer and keeps the default background.

Source user_version_messages(+Terms)//[private]
Helper for the welcome message to print information registered using version/1.
 user_version_message(+Term)[private]
Source predicate_list(+Specs)// is det[private]
Emit a list of predicates, one per line, each tagged with its kind. See predicate_reference//2.
Source goal_style(+Port, -Style) is det[private]
Style is the colour class used for the goal of a frame that is being reported for Port. It is a term goal(Port, Parity), which allows themes to decorate the goal depending on the port, on the parity of the step count (striping, which separates the steps of a trace visually) or both. See also '$answer_class'/1, which does the same for the answers of the interactive toplevel.
Source predicate_goal(+Goal, +Port)// is det[private]
Emit Goal, linking it to the definition of its predicate. Used if we have no frame, i.e., for the messages of library(prolog_trace).
Source frame_location(+Frame, -Location) is semidet[private]
Location is File:Line for the call site of Frame, i.e., the place in the clause of the parent frame from which Frame was called. This is the position the user is at while tracing. If we cannot find it, fall back to the clause that runs in Frame and finally to the file that defines the predicate.

Resolving the call site uses library(prolog_stack), which has to run the decompiler and read the source file. This is affordable for an interactive tracer, but we only do it if the location can actually be used, i.e., if hyperlinks are rendered. See goal_links/0.

Source goal_links is semidet[private]
True when goals printed by the debugger should be linked to their source location. Controlled by the flag debugger_goal_links, which is one of true, false or auto. Using auto (default) we create the links if the console can render them.
Source message_lang(-Lang) is multi[private]
True when Lang is a language id preferred for messages. Starts with the most specific language (e.g., nl_BE) and ends with en.
Source current_message_lang(-Lang) is det[private]
Get the current language for messages.
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 dcg_indicator(+Module, +PI, -QPI) is det[private]
Qualify PI with Module and use the // notation if the predicate is a non-terminal.
Source predicate_head(+Spec, -QHead) is semidet[private]
QHead is the module qualified head for Spec, accepting the same input as predicate_indicator/2. Unqualified specs are qualified using user.
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 pref_option(?Option, +Options, +Default) is semidet[private]
Get an option from the option list of predicate_reference//2. Fails if Options holds a value for Option that does not unify. Note that this deliberately does not use library(option): boot/messages.pl must be able to print a message before the libraries are available.
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 library_file(+File) is semidet[private]
Source library_name(+File, -Name) is det[private]
True if File is in one of the library directories and, if so, Name is how the file is referred to as library(Name).
Source predicate_reference_tag(+QPI, +Options)// is det[private]
Source predicate_kind_tag(+Kind)// is det[private]
Emit the kind of the predicate as a short tag.
Source print_message(+Kind, +Term)
Print an error message using a term as generated by the exception system.
Source print_system_message(+Term, +Kind, +Lines)[private]
Print the message if the user did not intecept the message. The first is used for errors and warnings that can be related to source-location. Note that syntax errors have their own source-location and should therefore not be handled this way.
Source msg_context(+Prefix0, -Prefix) is det[private]
Add contextual information to a message. This uses the Prolog flag message_context. Recognised context terms are:
  • time
  • time(Format)
  • thread

In addition, the hook message_prefix_hook/2 is called that allows for additional context information.

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 msg_color_class(+Kind, -Class) is det[private]
Colour class used to decorate an entire message of the given Kind. Defaults to Kind itself, which is mapped to message(Kind) (see level_attrs/2).
Source insert_prefix(+Lines, +Prefix, ?Ctx, -PrefixedLines) is det[private]
Add Prefix to the start of each line of Lines. If the first element is at_same_line the message continues the line and no initial prefix is added. Ctx is the message context; see prefix_nl/4 and print_message_lines/3.
Source prefix_nl(+Lines, +Prefix, ?Ctx, -Lines) is det[private]
Insert Prefix after each nl and make the message context Ctx available to the elements that need it:
  • nl, flush and eol become nl(Ctx), flush(Ctx) and eol(Ctx). Their handler writes the sequence that paints the remainder of the line before ending it if the message has a background colour.
  • ansi(Attrs, Fmt, Args) becomes ansi(Attrs, Fmt, Args, Ctx). Its handler re-installs the decoration of the message as a whole after writing the element, as the element ends with a full reset. The same applies to an ansi/3 element used as the label of an url/2 element.

The last line of a message is ended implicitly: if Lines does not end in nl or flush an nl is added. This one does not paint: what follows the message is not part of it. A message that wants its last line painted ends it using eol.

Source print_message_lines(+Stream, +Lines)[private]
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 safe_format(+Stream, +Format, +Args) is det[private]
Source message_to_string(+Term, -String)
Translate an error term into a string
Source print_once(Message, Level)[private]
True for messages that must be printed only once.
Source must_print(+Level, +Message)[private]
True if the message must be printed.