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.
Eshel Yaron [Tue, 4 Oct 2022 09:33:08 +0000 (12:33 +0300)]
ADDED: new command for signaling Prolog top-level threads
* sweep.pl: sweep_thread_signal/2: new predicate.
* sweeprolog.el:
- sweeprolog-signal-thread: new function, Elisp interface for
sweep_thread_signal/2.
- sweeprolog-top-level-thread-id: new buffer-local variable in
sweeprolog-top-level buffers.
- sweeprolog-top-level-signal: new command.
- sweeprolog-top-level-mode: signal top-level thread with
thread_exit/1 when buffer is killed.
Eshel Yaron [Mon, 3 Oct 2022 15:55:36 +0000 (18:55 +0300)]
ADDED: sweep Top-level Menu for listing Prolog top-levels
* sweep.pl
- sweep_top_level_threads/2: new predicate for querying
currently active Prolog top-level threads
* sweeprolog.el
- sweeprolog-top-level-menu--entries: new function, exposing
sweep_top_level_threads/2 to Elisp.
- sweeprolog-top-level-menu-mode: new major mode derived from
tabulated-list-mode
- sweeprolog-top-level-menu-go-to: new command, switches to the
top-level buffer of the Top-level Menu entry at point
- sweeprolog-top-level-menu-kill: new command, kills the top-level
buffer of the Top-level Menu entry at point
- sweeprolog-top-level-menu-new: new command, creates a new top-level
from the Top-level Menu
- sweeprolog-list-top-levels: new command, opens the Top-level Menu