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.
Eshel Yaron [Tue, 25 Oct 2022 06:44:46 +0000 (09:44 +0300)]
ADDED: completion-at-point for variable names
* sweeprolog.el (sweeprolog-local-variables-collection,
sweeprolog-variable-completion-at-point): new
functions. (sweeprolog-mode): add to
completion-at-point-functions. (sweeprolog-mode-syntax-table): update
according to char_type(Char, prolog_symbol).
Eshel Yaron [Sat, 22 Oct 2022 16:10:08 +0000 (19:10 +0300)]
ADDED: context-based command for inserting new clauses or terms
* sweeprolog.el (sweeprolog--forward-hole, sweeprolog--backward-hole):
new functions.
(sweeprolog-forward-hole): new command.
(sweeprolog-end-of-predicate-definition,sweeprolog-insert-clause,
sweeprolog-maybe-insert-next-clause,
sweeprolog-maybe-define-predicate): new functions.
(sweeprolog-insert-term-functions): new hook.
(sweeprolog-insert-term-dwim): new command.
(sweeprolog-mode-map): bind new commands.
* sweeprolog-tests.el (dwim-define-predicate): new test case.
* README.org (Context-Based Term Insertion): new section.
Eshel Yaron [Fri, 21 Oct 2022 08:32:10 +0000 (11:32 +0300)]
ENHANCED: add predicate properties list in help buffers
* sweep.pl (sweep_predicate_properties/2): new predicate.
* sweeprolog.el (sweeprolog--render-predicate-properties): new
function.
(sweeprolog--describe-predicate): use it.
Eshel Yaron [Thu, 20 Oct 2022 19:38:43 +0000 (22:38 +0300)]
ENHANCED: load and initialize sweep-module just-in-time
Instead of loading sweep-module and initializing Prolog as part of
loading sweeprolog.el (subject to the user option
sweeprolog-init-on-load), this commit introduces just-in-time loading
and initialization of Prolog. Suggested by Stefan Monnier.
* sweeprolog.el: (sweeprolog--open-query): new function, wraps
sweeprolog-open-query and initializes Prolog on the first call. Used
in place of sweeprolog-open-query throughout.
(sweeprolog-init-on-load): make variable obsolete.
Eshel Yaron [Wed, 19 Oct 2022 05:38:34 +0000 (08:38 +0300)]
ENHANCED: teach sweep to jump to C code for built-in predicates
* sweeprolog.el:
- sweeprolog-swipl-sources: new user option.
- sweeprolog-native-predicate-location: new function.
- sweeprolog-predicate-location: use it.
- README.org: Built-in Native Predicates: new section.
Eshel Yaron [Mon, 17 Oct 2022 07:56:27 +0000 (10:56 +0300)]
ADDED: new command for showing help for Prolog predicates
* sweep.pl: sweep_predicate_html_documentation/2: new predicate
* sweeprolog.el:
- sweeprolog-read-predicate-history: new variable.
- sweeprolog-read-predicate: use it, and default to the predicate at
point.
- sweeprolog--colour-term-to-faces: quote symbol
- sweeprolog-describe-predicate: new command.
- sweeprolog-help-prefix-map: bind it.
* README.org: Prolog Help: mention it.
Eshel Yaron [Sun, 16 Oct 2022 15:22:08 +0000 (18:22 +0300)]
ADDED: new command for showing help for Prolog modules
* sweep.pl: sweep_module_html_documentation/2: new predicate.
* sweeprolog.el:
- sweeprolog-read-module-history: new variable.
- sweeprolog-read-module-name: use it.
- sweeprolog--describe-module: new function.
- sweeprolog-describe-module: new command.
- sweeprolog-help-prefix-map: new keymap.
- sweeprolog-prefix-map: bind it keymap to `h'.
* README.org: Prolog Help: new section.
Eshel Yaron [Sat, 15 Oct 2022 10:25:39 +0000 (13:25 +0300)]
ADDED: new command for exporting Prolog predicates
* sweep.pl: sweep_local_predicate_export_comment/2: new predicate.
* sweeprolog.el:
- sweeprolog-read-exportable-predicate-prompt: new user option.
- sweeprolog--exportable-predicates: new buffer local variable.
- sweeprolog--colour-term-to-faces: accumulate exportable predicates.
- sweeprolog-colourise-buffer: reset sweeprolog--exportable-predicates.
- sweeprolog-export-predicate: new command.
- sweeprolog-mode-map: bind it.
- sweeprolog-menu: bind it.
- README.org: document it.
Eshel Yaron [Sun, 9 Oct 2022 14:48:13 +0000 (17:48 +0300)]
ADDED: Flymake integration in sweeprolog-mode
* sweeprolog.el:
- sweeprolog-enable-flymake: new user option.
- sweeprolog--diagnostics: new buffer-local variable.
- sweeprolog--diagnostics-report-fn,
sweeprolog--diagnostics-changes-beg,
sweeprolog--diagnostics-changes-end: new buffer-local variables.
- sweeprolog-defface: add docstrings for generated functions.
- sweeprolog--colourise: accumulate diagnostics when
sweeprolog-enable-flymake is non-nil.
- sweeprolog-colourise-buffer, sweeprolog-colourise-some-terms: report
diagnostics when sweeprolog-enable-flymake is non-nil.
- sweeprolog-show-diagnostics: new command in sweeprolog-mode buffers.
- sweeprolog-mode-map: bind it.
- sweeprolog-diagnostic-function: new function.
- sweeprolog-mode: use it when sweeprolog-enable-flymake is non-nil.
* README.org: Examining diagnostics: new section.
* NEWS.org: announce flymake integration.
Eshel Yaron [Sat, 8 Oct 2022 20:38:45 +0000 (23:38 +0300)]
ADDED: new command and user option for updating whitespace
* sweeprolog.el:
- sweeprolog-align-spaces: new command, updates whitespace around
point according to SWI-Prolog conventions.
- sweeprolog-enable-cycle-spacing: new user option, when non-nil
sweeprolog-align-spaces is added to cycle-spacing-actions.
- sweeprolog-mode: use it.
- README.org: document it.
- NEWS.org: announce it.