Eshel Yaron [Thu, 17 Aug 2023 21:39:58 +0000 (23:39 +0200)]
Use 'without-restriction'.
* sweeprolog.el (sweeprolog-analyze-buffer)
(sweeprolog--buffer-string)
(sweeprolog-export-predicate): Use 'without-restriction' instead of
'save-restriction' and 'widen'.
Eshel Yaron [Tue, 8 Aug 2023 18:29:35 +0000 (21:29 +0300)]
Fix feedback in 'sweeprolog-set-prolog-flag'
Similarly to the previous fix for 'sweeprolog-pack-install', this
makes 'sweeprolog-set-prolog-flag' actually report its result, instead
of reporting failure even when successful.
* sweep.pl (sweep_set_prolog_flag/2): Bind the output argument to
non-nil on success.
Eshel Yaron [Mon, 7 Aug 2023 15:48:48 +0000 (18:48 +0300)]
Fix feedback in 'sweeprolog-pack-install'
Have 'sweeprolog-pack-install' actually report its result, instead of
reporting failure even when successful.
* sweep.pl (sweep_pack_install/2): Bind the output argument to non-nil
on success.
* sweeprolog.el (sweeprolog-pack-description-max-width): New user
option.
(sweeprolog-read-pack-name): Use display text properties for alignment
instead of repeated spaces.
This command has been documented since Sweep version 0.6.0 but its
implementation was unintentionally committed. This fixes that.
* sweeprolog.el (sweeprolog-submit-bug-report): New command.
(sweeprolog-menu): Add entry for 'sweeprolog-submit-bug-report'.
* README.org (Setting up Sweep for local development): Capitalize.
(Submitting patches and bug reports): Update.
When a keymap is autoloaded (and the definition is copied over to the
-autoloads.el file), and the function are sharp-quoted, Emacs can
complain about undefined symbols, especially in combination with
'package-quickstart'.
Refactor and enhance 'completion-at-point' support
Replace 'sweeprolog-completion-at-point-functions' with a single
function 'sweeprolog-completion-at-point' that implements a much more
refined context-sensitive decision tree to determine what kind of
completion to perform.
Eshel Yaron [Tue, 27 Jun 2023 18:36:45 +0000 (21:36 +0300)]
Add grouping and affixation functions for module completion
This adds a 'group-function' and an 'affixation-function' to
'sweeprolog-module-completion-table', for Emacs 28+
The affixation API allows us to compute the appropriate padding to
insert before annotations in a cleaner way. Modules are group
according to their classes.
* sweep.pl (sweep_module_class/2): New predicate.
* sweeprolog.el (sweeprolog-module-minibuffer-annotation-1):
Extract helper function from...
(sweeprolog-module-minibuffer-annotation): ...here. Adapt.
(sweeprolog-module-minibuffer-affixation)
(sweeprolog-module-minibuffer-group): New functions.
(sweeprolog-module-completion-table): Use them.
* sweeprolog.el (sweeprolog-module-completion-table)
(sweeprolog-module-p, sweeprolog-module-minibuffer-annotation)
(sweeprolog-module-annotation): New functions.
(sweeprolog-modules-collection)
(sweeprolog-read-module-name): Adapt.
(sweeprolog-find-module): Improve feedback for modules that are not
backed by files.
Eshel Yaron [Fri, 23 Jun 2023 08:59:18 +0000 (11:59 +0300)]
MODIFIED: Replace "faces styles" with a theme emulating PceEmacs
This adds a custom theme called 'sweeprolog-pce' that mimics the
highlighting of SWI-Prolog's built-in editor, PceEmacs. It obsoletes
the "faces styles" feature that Sweep provided thus far. For backward
compatibility, The user option 'sweeprolog-faces-style' is retained
and mostly still respected.
Thanks to Stefan Monnier for suggesting this approach for simplifying
Sweep's code and making it more conformant with Emacs conventions.
* sweeprolog-pce-theme.el: New file.
* sweeprolog.el: Remove 'sweeprolog-defface' macro its
'sweeprolog-*-face' functions, use plain face definitions and refer to
them directly by their names instead. Also extend
'custom-theme-load-path' to include the new sweeprolog-pce-theme.el.
* README.org (Semantic Highlighting): Replace "Available Styles"
subsection with new subsection "PceEmacs Theme".
Eshel Yaron [Sun, 18 Jun 2023 19:32:33 +0000 (22:32 +0300)]
ADDED: Persistent history for Sweep top-levels
This adds a new user option that controls the value of
'comint-input-ring-file-name' in Sweep top-level buffers.
* sweeprolog.el (sweeprolog-top-level-persistent-history): New user
option.
(sweeprolog-top-level-sentinel)
(sweeprolog-top-level-setup-history): New functions.
(sweeprolog-top-level-setup-buffer): Call
'sweeprolog-top-level-setup-history' when creating a new top-level
buffer.
Eshel Yaron [Wed, 14 Jun 2023 07:37:02 +0000 (10:37 +0300)]
FIXED: Correctly recognize DCG grammar rules in 'C-c C-d'
* sweeprolog.el (sweeprolog-beginning-of-predicate-at-point): Also
return the module and neck operator of the predicate at point.
(sweeprolog-insert-predicate-documentation)
(sweeprolog-read-predicate-documentation-function)
(sweeprolog-read-predicate-documentation-with-holes)
(sweeprolog-read-predicate-documentation-default-function)
(sweeprolog-read-predicate-documentation)
(sweeprolog-document-predicate-at-point): Adapt to support DCGs and
non-local predicates.
Eshel Yaron [Tue, 13 Jun 2023 15:54:50 +0000 (18:54 +0300)]
Simplify 'sweeprolog-beginning-of-top-term'
Extract the core of 'sweeprolog-beginning-of-top-term' to
'sweeprolog-beginning-of-top-term-once' and make it leave point at the
very beginning of the top term, rather than at the following
character.
* sweeprolog.el (sweeprolog-beginning-of-top-term-once): New function.
(sweeprolog-beginning-of-top-term): Use it.
(sweeprolog-local-variables-collection)
(sweeprolog-analyze-term)
(sweeprolog-analyze-some-terms)
(sweeprolog-beginning-of-predicate-at-point)
(sweeprolog-terms-at-point): Adapt.
Eshel Yaron [Sun, 11 Jun 2023 18:05:13 +0000 (21:05 +0300)]
ENHANCED: Guess argument names for DCG grammar rules
* sweeprolog.el (sweeprolog-predicate-completion-at-point)
(sweeprolog-insert-clause): Support guessing argument names from
documentation also for DCG grammar rules.
Allow finding modules and predicates in another window with prefix
argument. Also improve prompt for 'sweeprolog-find-predicate'.
* sweeprolog.el (sweeprolog-read-predicate-prompt): Remove trailing
colon and space.
(sweeprolog-predicate-visible-p-function): New user option.
(sweeprolog-read-predicate): Use it, and format PROMPT with predicate
at point as the default argument.
(sweeprolog-find-module)
(sweeprolog-find-predicate): Add optional argument OTHER-WINDOW.
(sweeprolog-describe-predicate): Adapt PROMPT argument passed to
'sweeprolog-read-predicate'.
Eshel Yaron [Thu, 8 Jun 2023 17:46:45 +0000 (20:46 +0300)]
ENHANCED: Improve DCG support
Take into account DCG grammar rules and ensure they're supported all
around. Crucially, allow 'sweeprolog-describe-predicate' to display
documentation for DCG grammar rules.
Eshel Yaron [Thu, 8 Jun 2023 17:33:55 +0000 (20:33 +0300)]
Give a better name to 'sweeprolog--mfn-to-functor-arity'
* sweeprolog.el (sweeprolog--pi-to-functor-arity): New function,
renamed from 'sweeprolog--mfn-to-functor-arity'.
(sweeprolog-native-predicate-location): Use it.
* sweeprolog.el (sweeprolog-declaration-option): New face, used in...
(sweeprolog-analyze-fragment-to-faces): ...for 'decl_option' frags.
(sweeprolog--help-echo-for-declaration-option): New function.
(sweeprolog-analyze-fragment-help-echo): Use it.
Eshel Yaron [Tue, 30 May 2023 19:29:34 +0000 (22:29 +0300)]
ADDED: command for inserting example usage comments
* sweeprolog.el (sweeprolog-top-level-example-mode): New minor mode.
(sweeprolog-make-example-usage-comment): New command.
(sweeprolog-mode-map): Bind it.
* README.org (Example Usage Comments): New section.
Eshel Yaron [Fri, 26 May 2023 07:56:15 +0000 (10:56 +0300)]
ADDED: New command for expanding macros
* sweep.pl (sweep_expand_macro/2): New predicate.
* sweeprolog.el (sweeprolog-expand-macro-at-pos): New function.
(sweeprolog-expand-macro-at-point): New command.
(sweeprolog-context-menu-functions): Add...
(sweeprolog-context-menu-for-macro): New function.
* README.org (Macro Expansion): New section.
Eshel Yaron [Fri, 26 May 2023 07:18:38 +0000 (10:18 +0300)]
FIXED: tokenizing adjacent operators
Make Sweep's Prolog tokenization functions more careful in their
handling of unrelated adjacent operators. This fixes an issue that
affects term-based movement commands and other commands that rely on
'sweeprolog--forward-sexp' and friends.
* sweeprolog.el (sweeprolog-next-token-boundaries)
(sweeprolog-last-token-boundaries): Fix handling of
adjacent (distinct) operators.
* sweeprolog-tests.el
(forward-sexp-with-adjacent-operators): New test case.
Eshel Yaron [Wed, 24 May 2023 07:11:44 +0000 (10:11 +0300)]
Use 'nil' for some 'defface's instead of ':inherit default'
Change 'defface's that only specify inheritance from 'default' to
empty (nil) definitions, such that the appearance of text these with
faces can be determined by other faces applied to the same text. This
is important, for example, when using Sweep in Org mode source blocks.
Eshel Yaron [Sat, 20 May 2023 14:52:17 +0000 (17:52 +0300)]
ENHANCED: faster completion-at-point for predicates
Filter predicate completion candidates according to the text near
point before formatting and computing argument names. This makes
completion-at-point for predicates much faster when there are lots of
known predicates.
* sweeprolog.el (sweeprolog-predicate-completion-at-point): Pass
(partial) functor at point to...
* sweep.pl (sweep_predicate_completion_candidates/2): Filter
predicates based on new Sub argument.
Eshel Yaron [Thu, 16 Feb 2023 12:34:45 +0000 (14:34 +0200)]
ADDED: mode line indication for loaded buffers
* sweep.pl (sweep_source_file_load_time/2): new predicate.
(sweep_load_buffer/2): also update source modification time based.
* sweeprolog.el (sweeprolog-buffer-load-time)
(sweeprolog-buffer-loaded-since-last-modification-p): new functions.
(sweeprolog-load-buffer): use it.
(sweeprolog-mode): add mode line indication if buffer is loaded.