7.6.1 Inserting Terms with Holes

Use the command C-c RET to add a term to the buffer at point while keeping it syntactically correct. You don’t need to give the entire term at once, only its functor and arity. Sweep automatically inserts holes for the arguments (if any), which you can incrementally fill one after the other.

C-c RET

Insert a Prolog term with a given functor and arity at point, using holes for arguments (sweeprolog-insert-term-with-holes).

The main command for inserting terms with holes is sweeprolog-insert-term-with-holes. This command, bound by default to C-c C-m (or C-c RET) in Sweep Prolog mode buffers, prompts for a functor and an arity and inserts a corresponding term with holes in place of the term’s arguments. It leaves point right after the first hole, sets the mark to its start and activates the region such that the hole is marked. Call sweeprolog-insert-term-with-holes again to replace the active region, which now covers the first hole, with another term, that may again contain further holes. That way you can incrementally write a Prolog term, including whole clauses, by working down the syntactic structure of the term and maintaining its correctness all the while. Without a prefix argument, sweeprolog-insert-term-with-holes prompts for the functor and the arity to use. A non-negative prefix argument, such as C-2 C-c C-m or C-u C-c C-m, is taken to be the inserted term’s arity and in this case sweeprolog-insert-term-with-holes only prompts for the functor to insert. A negative prefix argument, C-- C-c C-m, inserts only a single hole without prompting for a functor. To further help with keeping the buffer syntactically correct, this command adds a comma (,) before or after the inserted term when needed according to the surrounding tokens. If you call it at the end of a term that doesn’t have a closing fullstop, it adds the fullstop after the inserted term.