]> git.eshelyaron.com Git - sweep.git/commitdiff
Provide documentation for predicate at point in top-levels
authorEshel Yaron <me@eshelyaron.com>
Tue, 28 Nov 2023 20:38:44 +0000 (21:38 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 28 Nov 2023 20:38:44 +0000 (21:38 +0100)
sweep.pl
sweeprolog.el

index 47a2a97a2a52f52527e1725f6a892ce446d8339f..9db524d806833281894893ddd6ebfe1195c0de44 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -236,9 +236,12 @@ sweep_handle_fragment_(Offset, Col, Beg, Len) :-
     user:sweep_funcall("sweeprolog-analyze-fragment", [Start,Len|Nom], _).
 
 sweep_short_documentation([ClauseString,Point,FileName0], [PIString,Doc,ArgSpan]) :-
-    atom_string(FileName, FileName0),
-    xref_source(FileName),
-    sweep_module_path_(Mod, FileName),
+    (   FileName0 == []
+    ->  Mod = user
+    ;   atom_string(FileName, FileName0),
+        xref_source(FileName),
+        sweep_module_path_(Mod, FileName)
+    ),
     term_string(Clause, ClauseString, [subterm_positions(Pos), module(Mod), syntax_errors(quiet)]),
     callable(Clause),
     sweep_short_documentation_clause(Pos, Clause, Point, FileName, Mod, PIString, Doc, ArgSpan).
@@ -276,6 +279,9 @@ sweep_short_documentation_clause_((Head --> Body), _Pos, [HeadPos, BodyPos], Poi
 sweep_short_documentation_clause_((:- Directive), _Pos, [Pos], Point, FileName, Mod, PIString, Doc, ArgSpan) :-
     !,
     sweep_short_documentation_body(Pos, Directive, 0, Point, FileName, Mod, PIString, Doc, ArgSpan).
+sweep_short_documentation_clause_((?- Directive), _Pos, [Pos], Point, FileName, Mod, PIString, Doc, ArgSpan) :-
+    !,
+    sweep_short_documentation_body(Pos, Directive, 0, Point, FileName, Mod, PIString, Doc, ArgSpan).
 sweep_short_documentation_clause_(Head, Pos, _, Point, FileName, Mod, PIString, Doc, ArgSpan) :-
     sweep_short_documentation_head(Pos, Head, 0, Point, FileName, Mod, PIString, Doc, ArgSpan).
 
index 62364147fb5e66c526c459aa668d5c41f08a849b..cbd99fadaf23021e2082e989a9f0c09d97a30894 100644 (file)
@@ -3661,6 +3661,9 @@ GOAL.  Otherwise, GOAL is set to a default value specified by
   (add-hook 'after-change-functions #'sweeprolog-colourise-query nil t)
   (add-hook 'xref-backend-functions #'sweeprolog--xref-backend nil t)
   (add-hook 'comint-input-filter-functions #'sweeprolog--fill-query-holes nil t)
+  (when (fboundp 'eldoc-documentation-default)
+    (setq-local eldoc-documentation-strategy #'eldoc-documentation-default))
+  (add-hook 'eldoc-documentation-functions #'sweeprolog-predicate-modes-doc nil t)
   (unless (member 'sweeprolog-hole yank-excluded-properties)
     (setq-local yank-excluded-properties
                 (cons 'sweeprolog-hole yank-excluded-properties)))