]> git.eshelyaron.com Git - sweep.git/commitdiff
ADDED: Highlighting and tooltip info for macros
authorEshel Yaron <me@eshelyaron.com>
Fri, 26 May 2023 07:51:57 +0000 (10:51 +0300)
committerEshel Yaron <me@eshelyaron.com>
Fri, 26 May 2023 07:51:57 +0000 (10:51 +0300)
* sweep.pl (sweep_color_normalized_/4): Handle 'macro(String)' terms.
* sweeprolog.el (sweeprolog-macro): New face.
(sweeprolog-analyze-fragment-to-faces)
(sweeprolog-analyze-fragment-help-echo): Handle 'macro' fragments.

sweep.pl
sweeprolog.el

index 154b50ab1da02a815e7442972a6f7a41f697ec9e..c8a154c943d4c284e0d6b53d198dddc32581cb33 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -550,6 +550,8 @@ sweep_color_normalized_(_, type_error, [Kind0|_], ["type_error"|Kind]) :-
     !,
     Kind0 =.. [Kind1|_],
     atom_string(Kind1, Kind).
+sweep_color_normalized_(_, macro, [String|_], ["macro"|String]) :-
+    !.
 sweep_color_normalized_(_, Nom0, _, Nom) :-
     atom_string(Nom0, Nom).
 
index 39f5c90b9b1c0326f0b88a7c10d08553433626cc..a2d80421177400e8216dc2743c626fad6396b26d 100644 (file)
@@ -1581,7 +1581,7 @@ resulting list even when found in the current clause."
 
 (sweeprolog-defface
   expanded
-  (:inherit font-lock-function-name-face)
+  (:inherit font-lock-preprocessor-face)
   (:foreground "blue" :underline t)
   (:foreground "cyan" :underline t)
   "Expanded predicate calls.")
@@ -2010,6 +2010,13 @@ resulting list even when found in the current clause."
   (:box t)
   "Holes.")
 
+(sweeprolog-defface
+  macro
+  (:inherit font-lock-preprocessor-face)
+  (:foreground "blue" :underline t)
+  (:foreground "cyan" :underline t)
+  "Macros.")
+
 ;;;; Font-lock
 
 (defun sweeprolog-analyze-start-font-lock (beg end)
@@ -2115,6 +2122,10 @@ resulting list even when found in the current clause."
      (list (list beg end (sweeprolog-local-face))))
     (`("goal" "constraint" . ,_)
      (list (list beg end (sweeprolog-constraint-face))))
+    (`("macro" . ,_)
+     (list (list beg end (sweeprolog-macro-face))))
+    ("expanded"
+     (list (list beg end (sweeprolog-expanded-face))))
     ("instantiation_error"
      (list (list beg end (sweeprolog-instantiation-error-face))))
     (`("type_error" . ,_)
@@ -2421,6 +2432,9 @@ resulting list even when found in the current clause."
                           functor arity))
     ("not_callable" "Call to a non-callable term")))
 
+(defun sweeprolog--help-echo-for-macro (expansion)
+  (format "Macro indicator, expands to (%s)" expansion))
+
 (defun sweeprolog-analyze-fragment-help-echo (beg end arg)
   (when-let
       (help-echo
@@ -2464,6 +2478,8 @@ resulting list even when found in the current clause."
          ("chars" "Chars")
          (`("module" . ,module)
           (sweeprolog--help-echo-for-module module))
+         (`("macro" . ,expansion)
+          (sweeprolog--help-echo-for-macro expansion))
          ("neck" "Neck")
          (`("hook" . ,_) "Hook")
          ("hook" "Hook")