]> git.eshelyaron.com Git - sweep.git/commitdiff
ADDED: highlighting and tooltip info for declaration options
authorEshel Yaron <me@eshelyaron.com>
Thu, 1 Jun 2023 11:23:11 +0000 (14:23 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 1 Jun 2023 11:23:11 +0000 (14:23 +0300)
* 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.

sweep.pl
sweeprolog.el

index 5dfc17d0e5d38d5b685788d0ad6a69bbfad6b98f..31aa7594a0c6ce7c606ef165c08e91f9ce79937e 100644 (file)
--- 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).
 
index 2ac05503e4484d2d2ffc66130dc332c8075875ff..8b57c8bde15fd87032806723f78dd54e53bc5588 100644 (file)
@@ -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))))