[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog face064afa 062/166: ADDED: custom font-lock-fon
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog face064afa 062/166: ADDED: custom font-lock-fontify-region-function for sweep-mode |
Date: |
Fri, 30 Sep 2022 04:59:26 -0400 (EDT) |
branch: elpa/sweeprolog
commit face064afaaf5206fc5cb289c5c6ca5dabf3ebd3
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
ADDED: custom font-lock-fontify-region-function for sweep-mode
---
sweep.el | 39 +++++++++++++++++++++++++++++++++++----
sweep.pl | 21 +++++++++++++++++++++
2 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/sweep.el b/sweep.el
index 46ea566ba4..bf3aff17bb 100644
--- a/sweep.el
+++ b/sweep.el
@@ -548,8 +548,8 @@ module name, F is a functor name and N is its arity."
(defun sweep--colourise (args)
"ARGS is a list of the form (BEG LEN . SEM)."
- (let* ((beg (car args))
- (end (+ beg (cadr args)))
+ (let* ((beg (max (point-min) (car args)))
+ (end (min (point-max) (+ beg (cadr args))))
(arg (cddr args)))
(with-silent-modifications
(pcase arg
@@ -558,6 +558,7 @@ module name, F is a functor name and N is its arity."
(pcase h
(`("unreferenced" . ,_)
sweep-head-unreferenced-face)
(`("exported" . ,_) sweep-head-exported-face)
+ (`("hook" . ,_) sweep-head-hook-face)
(`(,(rx (seq "local(")) . ,_)
sweep-head-local-face)
(other (message "unknown head color term %S"
other) sweep-head-local-face))))
(`("goal" . ,g)
@@ -567,17 +568,22 @@ module name, F is a functor name and N is its arity."
(`("meta" . ,_) sweep-meta-face)
(`("built_in" . ,_) sweep-built-in-face)
(`("undefined" . ,_) sweep-undefined-face)
+ (`(,(rx (seq "dynamic ")) . ,_)
sweep-dynamic-face)
+ (`(,(rx (seq "extern(")) . ,_) sweep-extern-face)
(`(,(rx (seq "autoload(")) . ,_)
sweep-autoload-face)
(`(,(rx (seq "imported(")) . ,_)
sweep-imported-face)
(`(,(rx (seq "local(")) . ,_) sweep-local-face)
(other (message "unknown goal color term %S"
other) sweep-goal-face))))
- (`("syntax_error" ,message ,eb ,ee)
+ (`("syntax_error" ,_message ,_eb ,_ee)
(put-text-property beg end 'font-lock-face sweep-syntax-error-face))
("unused_import" (put-text-property beg end 'font-lock-face
sweep-unused-import-face))
("undefined_import" (put-text-property beg end 'font-lock-face
sweep-undefined-import-face))
("dict_tag" (put-text-property beg end 'font-lock-face
sweep-dict-tag-face))
("dict_key" (put-text-property beg end 'font-lock-face
sweep-dict-key-face))
("dict_sep" (put-text-property beg end 'font-lock-face
sweep-dict-sep-face))
+ ("flag_name" (put-text-property beg end 'font-lock-face
sweep-flag-name-face))
+ ("no_flag_name" (put-text-property beg end 'font-lock-face
sweep-flag-name-face))
+ ("ext_quant" (put-text-property beg end 'font-lock-face
sweep-ext-quant-face))
("atom" (put-text-property beg end 'font-lock-face
sweep-atom-face))
("float" (put-text-property beg end 'font-lock-face
sweep-float-face))
("int" (put-text-property beg end 'font-lock-face
sweep-int-face))
@@ -640,6 +646,29 @@ module name, F is a functor name and N is its arity."
(sweep-close-query)
sol))))
+(defun sweep-colourise-some-terms (beg0 end0 &optional _verbose)
+ (let* ((beg (save-mark-and-excursion
+ (goto-char beg0)
+ (sweep-beginning-of-top-term)
+ (point)))
+ (end (save-mark-and-excursion
+ (goto-char end0)
+ (sweep-end-of-top-term)
+ (point)))
+ (contents (buffer-substring-no-properties beg end)))
+ (with-silent-modifications
+ (font-lock-unfontify-region beg end))
+ (sweep-open-query "user"
+ "sweep"
+ "sweep_colourise_some_terms"
+ (list contents
+ (buffer-file-name)
+ beg))
+ (let ((sol (sweep-next-solution)))
+ (sweep-close-query)
+ (when (sweep-true-p sol)
+ `(jit-lock-bounds ,beg . ,end)))))
+
(defun sweep-colourise-query (buffer)
(when (buffer-live-p buffer)
(with-current-buffer buffer
@@ -939,7 +968,9 @@ Interactively, a prefix arg means to prompt for BUFFER."
nil
nil
nil
- nil)))
+ nil
+ (font-lock-fontify-region-function .
sweep-colourise-some-terms)))
+ (sweep-colourise-buffer))
;;;; Testing:
diff --git a/sweep.pl b/sweep.pl
index 0a475effb9..3d65efa01d 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -32,6 +32,7 @@
:- module(sweep,
[ sweep_colourise_buffer/2,
+ sweep_colourise_some_terms/2,
sweep_documentation/2,
sweep_expand_file_name/2,
sweep_predicate_location/2,
@@ -85,6 +86,7 @@ sweep_colourise_buffer([String|Path], Colors) :-
( close(Contents),
free_memory_file(H)
)).
+
sweep_colourise_buffer_(Path0, Contents, []) :-
atom_string(Path, Path0),
set_stream(Contents, encoding(utf8)),
@@ -100,6 +102,25 @@ sweep_colourise_buffer_(Path0, Contents, []) :-
erase(Ref0),
erase(Ref1).
+sweep_colourise_some_terms([String,Path,Offset], Colors) :-
+ setup_call_cleanup(( new_memory_file(H),
+ insert_memory_file(H, 0, String),
+ open_memory_file(H, read, Contents, [encoding(utf8)])
+ ),
+ sweep_colourise_some_terms_(Path, Offset, Contents,
Colors),
+ ( close(Contents),
+ free_memory_file(H)
+ )).
+
+sweep_colourise_some_terms_(Path0, Offset, Contents, []) :-
+ atom_string(Path, Path0),
+ set_stream(Contents, encoding(utf8)),
+ set_stream(Contents, file_name(Path)),
+ seek(Contents, 0, bof, _),
+ prolog_colourise_stream(Contents,
+ Path,
+ sweep_handle_query_color(Offset)).
+
sweep_documentation([Path, Functor, Arity], Docs) :-
atom_string(P, Path),
atom_string(F, Functor),
- [nongnu] elpa/sweeprolog 6b9e2a7833 139/166: Tweak README to prevent a hosting platform from failing to render it, (continued)
- [nongnu] elpa/sweeprolog 6b9e2a7833 139/166: Tweak README to prevent a hosting platform from failing to render it, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 79bf5b78b8 042/166: Run `make check` with libswipl preloaded, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 97440dda21 043/166: DOC: update the manual to reflect the latest GMP deconflication, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 9466ce0d59 046/166: ADDED: completion-at-point function in sweep-top-level-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 6e9ac379e6 047/166: DOC: Expand top-level documentation section, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4ecc8ec55f 050/166: Add BSD license, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a26ca14c81 053/166: ENHANCED: show more relevant candidates in top-level completion, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7fa11fdcdd 055/166: FIXED: hide predicates starting with '$' in sweep-find-predicate, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog e70b4aef2f 057/166: ADDED: sweep-file-name-handler, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 10516034be 061/166: ADDED: sweep-indent-line, an indent-line-function for sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog face064afa 062/166: ADDED: custom font-lock-fontify-region-function for sweep-mode,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog 6363ddef3a 073/166: ADDED: implemented all xref backend callback functions, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 8dc9359dca 082/166: ADDED: sweep-set-prolog-flag for setting Prolog flags, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 0f86b23be9 080/166: ENHANCED: emit Prolog messages with color coding, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1f4b1a6dcc 079/166: MODIFIED: use executable-find to locate the swipl executable..., ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog f772a136e4 081/166: DOC: fix typos, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 75ec7290be 096/166: ADDED: sweep-load-buffer, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 3717572348 091/166: FIXED: handle more missing color terms, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1744b29cc2 092/166: FIXED: off by one in sweep-colourise-some-terms, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 16d1a380ab 122/166: FIXED: (sweep-beginning-of-top-term): possible infinite loop, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog f887a4b3f0 085/166: ENHANCED: provide caller predicate in xref-find-references, ELPA Syncer, 2022/09/30