Extract subsumed goals when extracting goal to predicate
Extend 'sweeprolog-extract-region-to-predicate' with the ability to
replace other goals in the current buffer that are subsumed by the
extracted goal with calls to the predicate this command creates.
'sweeprolog-extract-region-to-predicate' now does this when it is
called with a prefix argument. Also make
'sweeprolog-insert-term-dwim' propagate the prefix argument to
functions in 'sweeprolog-insert-term-functions'.
* sweeprolog.el (sweeprolog-insert-term-dwim): Add ARG argument and
pass it to functions listed...
(sweeprolog-insert-term-functions): ...here. Adjust docstring.
(sweeprolog-maybe-insert-next-clause)
(sweeprolog-maybe-define-predicate)
(sweeprolog-maybe-extract-region-to-predicate): Adjust accordingly.
(sweeprolog-default-new-predicate-location): Go to end of line in case
there's a comment on the last line of the current predicate
definition.
(sweeprolog-query-replace-term-include-match-function): New variable.
(sweeprolog-query-replace-term): Use it.
(sweeprolog-extract-region-to-predicate): Add ALL argument. When
non-nil, suggest replacing all goals in the buffer that are subsumbed
by the extracted goal with calls to the newly defined predicate.