From: Eshel Yaron Date: Sun, 25 Sep 2022 11:48:44 +0000 (+0300) Subject: ENHANCED: also update highlighting between sub terms X-Git-Tag: v0.4.0~8 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=04964e36b45ae6c0e6703aadf73b58db89a5b72f;p=sweep.git ENHANCED: also update highlighting between sub terms --- diff --git a/sweep.el b/sweep.el index 9cb6b1a..8297f52 100644 --- a/sweep.el +++ b/sweep.el @@ -911,20 +911,6 @@ module name, F is a functor name and N is its arity." (:weight bold) "Dict separators.") -(sweep-defface - type-error - (:inherit font-lock-warning-face) - (:foreground "orange") - (:foreground "orange") - "Type errors.") - -(sweep-defface - instantiation-error - (:inherit font-lock-warning-face) - (:foreground "orange") - (:foreground "orange") - "Instantiation errors.") - (sweep-defface file (:inherit button) @@ -1040,17 +1026,66 @@ module name, F is a functor name and N is its arity." (sweep-defface error (:inherit font-lock-warning-face) - (:foreground "orange") - (:foreground "orange") + (:background "orange") + (:background "orange") "Unspecified errors.") +(sweep-defface + type-error + (:inherit font-lock-warning-face) + (:background "orange") + (:background "orange") + "Type errors.") + +(sweep-defface + instantiation-error + (:inherit font-lock-warning-face) + (:background "orange") + (:background "orange") + "Instantiation errors.") + (sweep-defface syntax-error (:inherit error) - (:foreground "orange") - (:foreground "orange") + (:background "orange") + (:background "orange") "Syntax errors.") +(sweep-defface + around-syntax-error + (:inherit default) + (:inherit default) + (:inherit default) + "Text around a syntax error.") + +(sweep-defface + clause + (:inherit default) + (:inherit default) + (:inherit default) + "Predicate clauses.") + +(sweep-defface + grammar-rule + (:inherit default) + (:inherit default) + (:inherit default) + "DCG grammar rules.") + +(sweep-defface + term + (:inherit default) + (:inherit default) + (:inherit default) + "Top terms.") + +(sweep-defface + directive + (:inherit default) + (:inherit default) + (:inherit default) + "Directives.") + (sweep-defface structured-comment (:inherit font-lock-doc-face) @@ -1083,7 +1118,11 @@ module name, F is a functor name and N is its arity." (`("goal",(rx "imported(") . ,_) (sweep-imported-face)) (`("goal",(rx "global(") . ,_) (sweep-global-face)) (`("goal",(rx "local(") . ,_) (sweep-local-face)) - (`("syntax_error" ,_message ,_eb ,_ee) (sweep-syntax-error-face)) + (`("syntax_error" ,_message ,eb ,ee) + (with-silent-modifications + (put-text-property eb ee 'font-lock-face + (sweep-around-syntax-error-face))) + (sweep-syntax-error-face)) ("unused_import" (sweep-unused-import-face)) ("undefined_import" (sweep-undefined-import-face)) ("html_attribute" (sweep-html-attribute-face)) @@ -1120,6 +1159,10 @@ module name, F is a functor name and N is its arity." ("file_no_depend" (sweep-file-no-depend-face)) ("nofile" (sweep-no-file-face)) ("op_type" (sweep-op-type-face)) + ("directive" (sweep-directive-face)) + ("clause" (sweep-clause-face)) + ("term" (sweep-term-face)) + ("grammar_rule" (sweep-grammar-rule-face)) ("method" (sweep-method-face)) ("class" (sweep-class-face)))) diff --git a/sweep.pl b/sweep.pl index 3556a75..a161694 100644 --- a/sweep.pl +++ b/sweep.pl @@ -126,9 +126,14 @@ sweep_colourise_buffer_(Path0, Contents, []) :- asserta(sweep_source_time(Path, Time), Ref1), xref_source(Path, []), seek(Contents, 0, bof, _), + retractall(sweep_current_comment(_, _, _)), prolog_colourise_stream(Contents, Path, - sweep_handle_query_color(1)), + sweep_handle_color(1)), + forall(sweep_current_comment(Kind, Start, Len), + ( atom_string(Kind, String), + user:sweep_funcall("sweep--colourise", [Start,Len,"comment"|String], _) + )), erase(Ref0), erase(Ref1). @@ -311,10 +316,15 @@ sweep_colourise_some_terms_(Path0, Offset, Contents, []) :- set_stream(Contents, file_name(Path)), seek(Contents, 0, bof, _), findall(Op, xref_op(Path, Op), Ops), + retractall(sweep_current_comment(_, _, _)), prolog_colourise_stream(Contents, Path, - sweep_handle_query_color(Offset), - [operators(Ops)]). + sweep_handle_color(Offset), + [operators(Ops)]), + forall(sweep_current_comment(Kind, Start, Len), + ( atom_string(Kind, String), + user:sweep_funcall("sweep--colourise", [Start,Len,"comment"|String], _) + )). sweep_documentation([Path, Functor, Arity], Docs) :- atom_string(P, Path), @@ -589,6 +599,12 @@ sweep_pack_info(pack(Name0, _, Desc0, Version0, URLS0), [Name, Desc, Version, UR sweep_pack_install(PackName, []) :- atom_string(Pack, PackName), pack_install(Pack, [silent(true), upgrade(true), interactive(false)]). +sweep_handle_color(Offset, comment(Kind), Beg, Len) :- + !, + Start is Beg + Offset, + asserta(sweep_current_comment(Kind, Start, Len)). +sweep_handle_color(Offset, Col, Beg, Len) :- + sweep_handle_query_color(Offset, Col, Beg, Len). sweep_colourise_query([String|Offset], _) :- prolog_colourise_query(String, module(sweep), sweep_handle_query_color(Offset)).