This module implements prolog:complete_input/4, which is used notably by
the command line editor library(edit) to perform context aware TAB
completion. It is a seperate library such that other input scenarios can
reuse this code.
prolog:complete_input(+BeforeCursor:string, +AfterCursor:string, -Delete:atom, -Completions:list) is semidet[multifile]- Compute auto completions for the input line
BeforeCursor+AfterCursor. Implemented completions
- Files<br>
- Text starting
'<prefix> (single quotes) is completed as a
file. If there is a single matching file a terminating `'` is
added.
- If the start of the line is
[<prefix> and text can be
a non-quoted atom, look for Prolog files with this name.
Directories can be inserted as / (unquoted), as long as
each segment is a valid atom. If a single .pl file
is found it is closed with ], without the extension.
- Text starting
library(<prefix> is completed as a
library file using the same rules as [<prefix>, but
looking in all library directories instead of the current
directory.
- Atoms
<prefix> is used to complete atoms that can be written
without quotes (excluding symbol atoms such as -->) and
are permanent, i.e., have references from clauses records,
flags, foreign code, etc.
- Variables
<Prefix> is completed as an atom if it is a valid variable
name. It is completed with other atoms from the query being
edited using the same search as Emacs dabbrev (Dynamic
Abbreviation). $<Prefix> expands to saved toplevel
variables.
- Arguments:
-
| Delete | - is an atom or string representing the text that is
replaced by the completion |
| Completions | - is a list of elements of this shape:
- Atom
- Used for a plain completion without comment
- Atom - Comment
- Used for a completion with comment. This will be
used for predicates.
|
- identifier_prefix(-Prefix, -Type) is semidet[private]
- identifier_prefix_r(-Prefix, -Type) is semidet[private]
file_prefix(-Prefix, -Type)// is semidet[private]- True when the part before the cursor looks like a file name.
- finish_file_name(+Matches, -Completions) is det[private]
- Add closing quote for a unique file name.
complete_library(+Prefix:atom, +Close:atom, -Completions:list) is semidet[private]- Complete to a library entry on "library(Prefix".