Eshel Yaron [Thu, 12 Jan 2023 11:27:17 +0000 (13:27 +0200)]
ADDED: command for sending a goal to top-level from any buffer
* sweeprolog.el (sweeprolog-top-level): extract buffer setup logic to...
(sweeprolog-top-level-buffer): new function.
(sweeprolog-top-level-send-string): new function, used by...
(sweeprolog-top-level-send-goal): new command, reads a goal from the
minibuffer and sends it to a Prolog top-level buffer.
(sweeprolog-mode-map): bind it to C-c C-q.
(sweeprolog-menu): add "Send Goal to Top-level" entry.
* README.org ("Sending Goals to the Top-level"): new manual section.
Eshel Yaron [Thu, 12 Jan 2023 11:22:21 +0000 (13:22 +0200)]
Support completion when reading a goal from the minibuffer
* sweeprolog.el (sweeprolog-read-goal-map): new keymap, derived from
sweeprolog-read-term-map.
(sweeprolog-goals-at-point): new function, similar to
sweeprolog-terms-at-point but only returns goal terms.
(sweeprolog-read-goal): use them.
Eshel Yaron [Sat, 7 Jan 2023 06:20:01 +0000 (08:20 +0200)]
ENHANCED: use terms at point as "future history" for term-search
* sweep.pl (sweep_terms_at_point/2): new predicate.
* sweeprolog.el (sweeprolog-terms-at-point): new function.
(sweeprolog-read-term): use it for setting the future history.
(sweeprolog-read-goal): new function.
(sweeprolog-term-search): use it for reading a goal when called with
prefix argument.
Eshel Yaron [Fri, 6 Jan 2023 07:16:33 +0000 (09:16 +0200)]
ENHANCED: Support refining term searches with arbitrary goals
* sweep.pl (sweep_term_search/2): extend with an extra goal argument.
* sweeprolog.el (sweeprolog-read-term): new function, similar to
read--expression but for Prolog terms rather than Elisp expressions.
(sweeprolog-term-search): use it, and prompt for goal with prefix arg.
Eshel Yaron [Tue, 3 Jan 2023 22:22:34 +0000 (00:22 +0200)]
ADDED: command for finding terms subsumed by a given term
* sweep.pl (sweep_term_search/2): new predicate.
* sweeprolog.el (sweeprolog-term-search-in-buffer): new function.
(sweeprolog-term-search): new command.
* README.org ("Term Search"): new manual section.
Eshel Yaron [Sun, 1 Jan 2023 12:32:01 +0000 (14:32 +0200)]
ADDED: user option to control predicate documentation composition
* sweeprolog.el
(sweeprolog-insert-pldoc-for-predicate): remove in favor of...
(sweeprolog-insert-predicate-documentation): new function.
(sweeprolog-format-term-with-holes): new utility
function, used by...
(sweeprolog-read-predicate-documentation-with-holes)
(sweeprolog-read-predicate-documentation-default-function): new
functions, used for...
(sweeprolog-read-predicate-documentation-function): new user option,
used by...
(sweeprolog-read-predicate-documentation): new function, used by...
(sweeprolog-document-predicate-at-point): refactor.
Eshel Yaron [Sat, 31 Dec 2022 11:10:17 +0000 (13:10 +0200)]
Avoid excessive analysis in presence of unbalanced quotes
* sweeprolog.el (sweeprolog-analyze-fragment-fullstop): new function,
adds a dedicated text property to fullstops.
(sweeprolog-analyze-region-fragment-hook): add it.
(sweeprolog-at-fullstop-p)
(sweeprolog-end-of-last-fullstop, sweeprolog-end-of-next-fullstop):
new functions.
(sweeprolog-end-of-top-term): use them for restricting to region
between last fullstop and next fullstop.
Eshel Yaron [Thu, 22 Dec 2022 14:51:47 +0000 (16:51 +0200)]
ADDED: New command sweeprolog-insert-term-with-holes
* sweep.pl (sweep_format_term/2, sweep_current_functors/2): new
predicates.
* sweeprolog.el (sweeprolog-read-functor-history): new variable,
history list for...
(sweeprolog-read-functor): new function.
(sweeprolog-forward-hole-repeat-mode): rename to...
(sweeprolog-forward-hole-repeat-map): corrected name for keymap.
(sweeprolog-analyze-end-font-lock): don't rely on
sweeprolog--next-hole to move point.
(sweeprolog-at-hole-p, sweeprolog-beginning-of-hole)
(sweeprolog-end-of-hole): new functions, used by...
(sweeprolog--previous-hole, sweeprolog--next-hole): revise.
(sweeprolog--precedence-at-point): new function, used by...
(sweeprolog-insert-term-with-holes): new command.
(sweeprolog-mode-map): bind it to C-c C-m
* sweeprolog-tests: test it.
* README.org ("Filling Holes"): move to top and rename to...
("Holes"): document sweeprolog-insert-term-with-holes.
Eshel Yaron [Wed, 21 Dec 2022 17:51:48 +0000 (19:51 +0200)]
ENHANCED: highlight holes in incomplete terms
* sweeprolog.el (sweeprolog-predicate-completion-at-point): fontify
holes when inserting them.
(sweeprolog-analyze-start-font-lock): reset font-lock-face in analyzed
region.
(sweeprolog-analyze-fragment-to-faces): fix syntax error handling,
don't highlight holes as it is done by...
(sweeprolog-analyze-end-font-lock): new function, highlights holes in
analyzed region when sweeprolog-highlight-holes is non-nil.
(sweeprolog-analyze-region-end-hook): add it.
(sweeprolog--hole): fix text property used for setting stickiness.
Eshel Yaron [Fri, 16 Dec 2022 22:02:33 +0000 (00:02 +0200)]
Use indent-to instead manually indenting with spaces
* sweeprolog.el (sweeprolog-indent-line): use indent-to.
(sweeprolog-indent-offset): tweak docstring.
(sweeprolog-indent-line-after-prefix): use it instead of hard-coded
offset.
(sweeprolog-export-predicate): don't override indent-tabs-mode.
Eshel Yaron [Sun, 4 Dec 2022 17:09:30 +0000 (19:09 +0200)]
Use built-in file_autoload_directives/3 to update deps
* sweep.pl (sweep_file_missing_dependencies/2): new predicate.
* sweeprolog.el (sweeprolog-update-dependencies): use it.
* sweeprolog-tests.el: add another test case for
sweeprolog-update-dependencies.
Eshel Yaron [Sat, 3 Dec 2022 16:09:18 +0000 (18:09 +0200)]
ADDED: ability to pass command line args directly to swipl
* sweeprolog.el (sweeprolog-handle-command-line-args): new function,
sets up command line argument handling using...
(sweeprolog-command-line-function): new function.
Eshel Yaron [Fri, 2 Dec 2022 11:41:32 +0000 (13:41 +0200)]
ADDED: minor mode for moving to the next hole with TAB
* sweeprolog.el (sweeprolog-forward-hole-on-tab-mode): new minor mode,
binding TAB to...
(sweeprolog-indent-or-forward-hole): new command.
* README.org ("Filling Holes"): rephrase and mention new minor mode.
Eshel Yaron [Fri, 2 Dec 2022 09:47:58 +0000 (11:47 +0200)]
ENHANCED: indentation after infix operators
* sweeprolog.el (sweeprolog-indent-line-after-infix): adhere to last line
indentation even if non-standard, handle DCG RHS contexts and SSU
guards.
* sweeprolog-tests.el: add more tests for indentation.
Eshel Yaron [Sun, 27 Nov 2022 19:08:14 +0000 (21:08 +0200)]
ENHANCED: use argument names for holes in predicate completion
* sweep.pl (predicate_argument_names/2): new predicate.
(sweep_format_predicate/2): use it, and revise into...
(sweep_format_predicate/4): new predicate.
(sweep_predicate_completion_candidates): use it.
Eshel Yaron [Sat, 26 Nov 2022 14:10:04 +0000 (16:10 +0200)]
ADDED: make flymake optionally complain about implicit autoloads
* sweeprolog.el (sweeprolog-note-implicit-autoloads): new user-option.
(sweeprolog-analyze-fragment-flymake): use it.
* README.org ("Managing Dependencies"): mention it.
Eshel Yaron [Fri, 25 Nov 2022 21:01:40 +0000 (23:01 +0200)]
Adjust arity of predicates according to completion context
* sweep.pl (sweep_context_callable): track required arity adjustment.
(sweep_predicate_completion_candidates): take arity difference as
argument, adjust and filter candidates according to it.
* sweeprolog.el (sweeprolog-predicate-completion-at-point): use it.
* sweeprolog-tests.el: test it.
Eshel Yaron [Wed, 23 Nov 2022 19:25:39 +0000 (21:25 +0200)]
ADDED: PlUnit tests block skeleton and command for inserting it
* sweeprolog.el (sweeprolog-format-string-as-atom): new function.
(sweeprolog-module-header-skeleton): use define-skeleton, making it a
command instead of a defconst.
(sweeprolog-plunit-testset-skeleton): new skeleton and command.
* sweeprolog-tests: test it.
* README.org ("Writing Tests"): new section.
("Using templates for creating new modules"): rename to "Creating New
Modules".
Eshel Yaron [Tue, 22 Nov 2022 18:14:46 +0000 (20:14 +0200)]
Handle module-qualification in next-clause insertion
* sweeprolog.el (sweeprolog-definition-at-point): also return module
name when the head term is qualified.
(sweeprolog-maybe-insert-next-clause): pass module name to...
(sweeprolog-insert-clause): new argument module.
* sweeprolog-tests.el: add a couple of relevant test cases.
Eshel Yaron [Tue, 22 Nov 2022 10:59:41 +0000 (12:59 +0200)]
FIXED: sweeprolog-beginning-of-next-top-term: other possible loop
* sweeprolog.el (sweeprolog-beginning-of-next-top-term): don't loop
when called in the last term of the buffer
* sweeprolog-tests.el (beginning-of-next-top-term-at-last-clause): new
test case
Eshel Yaron [Sun, 20 Nov 2022 19:31:11 +0000 (21:31 +0200)]
Support DCG and SSU rules in sweeprolog-insert-next-clause
* sweeprolog.el (sweeprolog-definition-at-point): also return kind of
neck.
(sweeprolog-maybe-insert-next-clause): pass it to...
(sweeprolog-insert-next-clause): new argument NECK used instead of
hardcoded ":-", use "Body" for clause body instead of "_".
(sweeprolog-identifier-at-point): handle raw meta goals.
* sweeprolog-tests.el: add tests for sweeprolog-insert-term-dwim
inserting clauses with different neck kinds.
Eshel Yaron [Sat, 19 Nov 2022 16:38:32 +0000 (18:38 +0200)]
FIXED: exporting predicates in presence of exported operators
* sweep.pl (sweep_exportable_predicates/2): new predicate.
* sweeprolog.el (sweeprolog--module-term)
(sweeprolog--exportable-predicates)
(sweeprolog-analyze-start-exportable)
(sweeprolog-analyze-fragment-exportable): no longer used, deleted.
(sweeprolog-exportable-predicates): new function.
(sweeprolog-read-exportable-predicate): use it.
(sweeprolog-export-predicate): handle exported operators.
Eshel Yaron [Tue, 15 Nov 2022 22:43:51 +0000 (00:43 +0200)]
Don't highlight syntax error at the end of the buffer
* sweeprolog.el (sweeprolog--analyze-point): new buffer local
variable.
(sweeprolog-analyze-buffer, sweeprolog-analyze-some-terms): let-bind
it.
(sweeprolog-analyze-fragment-to-faces): check it before applying
sweeprolog-syntax-error-face.