From: Eshel Yaron Date: Thu, 1 Jun 2023 11:23:11 +0000 (+0300) Subject: ADDED: highlighting and tooltip info for declaration options X-Git-Tag: V9.1.10-sweep-0.18.4~9 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0dc3a896f0cbe0b45ee599f59753628659f0ec2f;p=sweep.git ADDED: highlighting and tooltip info for declaration options * sweep.pl (sweep_color_normalized_/4): Handle 'decl_option/1' fragments. * 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. --- diff --git a/sweep.pl b/sweep.pl index 5dfc17d..31aa759 100644 --- a/sweep.pl +++ b/sweep.pl @@ -554,6 +554,9 @@ sweep_color_normalized_(_, type_error, [Kind0|_], ["type_error"|Kind]) :- atom_string(Kind1, Kind). sweep_color_normalized_(_, macro, [String|_], ["macro"|String]) :- !. +sweep_color_normalized_(_, decl_option, [Opt0|_], ["decl_option"|Opt]) :- + !, + term_string(Opt0, Opt). sweep_color_normalized_(_, Nom0, _, Nom) :- atom_string(Nom0, Nom). diff --git a/sweeprolog.el b/sweeprolog.el index 2ac0550..8b57c8b 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -2027,6 +2027,13 @@ resulting list even when found in the current clause." (:foreground "cyan" :underline t) "Macros.") +(sweeprolog-defface + declaration-option + (:weight bold) + (:weight bold) + (:weight bold) + "Declaration options.") + ;;;; Font-lock (defun sweeprolog-analyze-start-font-lock (beg end) @@ -2305,7 +2312,9 @@ resulting list even when found in the current clause." ("method" (list (list beg end nil) (list beg end (sweeprolog-method-face)))) ("class" - (list (list beg end (sweeprolog-class-face)))))) + (list (list beg end (sweeprolog-class-face)))) + (`("decl_option" . ,_) + (list (list beg end (sweeprolog-declaration-option-face)))))) (defun sweeprolog-analyze-fragment-font-lock (beg end arg) (when-let ((face-fragments (sweeprolog-analyze-fragment-to-faces @@ -2445,6 +2454,18 @@ resulting list even when found in the current clause." (defun sweeprolog--help-echo-for-macro (expansion) (format "Macro indicator, expands to (%s)" expansion)) +(defun sweeprolog--help-echo-for-declaration-option (option) + (pcase option + ("incremental" + (concat + "Incremental declaration " + "(tables that depend on this predicate are updated it changes)")) + ("volatile" + (concat + "Volatile declaration " + "(predicate excluded from saved program)")) + (_ (format "%s predicate property declaration" option)))) + (defun sweeprolog-analyze-fragment-help-echo (beg end arg) (when-let (help-echo @@ -2510,7 +2531,9 @@ resulting list even when found in the current clause." ("rational" "Rational") ("dict_function" "Dict function") ("dict_return_op" "Dict return operator") - ("func_dot" "Dict function dot"))) + ("func_dot" "Dict function dot") + (`("decl_option" . ,option) + (sweeprolog--help-echo-for-declaration-option option)))) (with-silent-modifications (put-text-property beg end 'help-echo help-echo))))