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.
Eshel Yaron [Tue, 15 Nov 2022 21:45:02 +0000 (23:45 +0200)]
Start the top-level TCP server just-in-time
* sweeprolog.el (sweeprolog-init): do not start TCP server
unconditionally
(sweeprolog-top-level): start it here instead, on demand.
* sweep.pl (sweep_top_level_server/2): wait for TCP server thread to
start before returning control to Emacs.
* README.org (The Prolog Top-Level): add implementation note.
Eshel Yaron [Mon, 14 Nov 2022 16:19:31 +0000 (18:19 +0200)]
ADDED: minor mode for automatic whitespace insertion
* sweep.pl (sweep_context_callable/2): only consider the context to be
callable if a neck is present up the tree, i.e. not in the head.
* sweeprolog.el (sweeprolog-context-callable-p): new function,
extracted from (sweeprolog-predicate-completion-at-point)
(sweeprolog-electric-layout-post-self-insert-function): new function.
(sweeprolog-electric-layout-mode): new minor mode.
Eshel Yaron [Sat, 12 Nov 2022 20:38:54 +0000 (22:38 +0200)]
ENHANCED: revise predicate completion at point
Completion at point now detects whether predicate completion is
appropriate, by parsing Prolog code back from point to determine the
context of point. If predicate completion is not appropriate,
fallback to atom completion.
Eshel Yaron [Fri, 11 Nov 2022 10:39:58 +0000 (12:39 +0200)]
ADDED: user option specifying where to define new predicates
* sweeprolog.el (sweeprolog-default-new-predicate-location)
(sweeprolog-new-predicate-location-above-current): new functions.
(sweeprolog-new-predicate-location-function): new user option.
(sweeprolog-maybe-define-predicate): use it.