From: Eshel Yaron Date: Tue, 28 Nov 2023 20:38:44 +0000 (+0100) Subject: Provide documentation for predicate at point in top-levels X-Git-Tag: V9.1.21-sweep-0.27.3~8 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dca64656566cdefbe2084c0a1f1e9cd8866e1e57;p=sweep.git Provide documentation for predicate at point in top-levels --- diff --git a/sweep.pl b/sweep.pl index 47a2a97..9db524d 100644 --- 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). diff --git a/sweeprolog.el b/sweeprolog.el index 6236414..cbd99fa 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -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)))