get_time(Time),
asserta(sweep_open(Path, Contents), Ref0),
asserta(sweep_source_time(Path, Time), Ref1),
- xref_source(Path, []),
+ xref_source(Path, [comments(store)]),
seek(Contents, 0, bof, _),
retractall(sweep_current_comment(_, _, _)),
prolog_colourise_stream(Contents,
sweep_handle_identifier_at_point_goal(_Path, _M0, imported(Path), Goal) :-
!,
pi_head(PI, Goal),
+ xref_source(Path, [comments(store)]),
xref_module(Path, M),
asserta(sweep_current_identifier_at_point(M:PI)).
sweep_handle_identifier_at_point_goal(_Path, _M0, Extern, Goal) :-
user:sweep_funcall("sweeprolog--colourise", [Start,Len,"comment"|String], _)
)).
-sweep_documentation([Path, Functor, Arity], Docs) :-
- atom_string(P, Path),
- atom_string(F, Functor),
- PI = F/Arity,
- pi_head(PI, Head),
- ( module_property(M, file(P)),
- \+ predicate_property(M:Head, imported_from(_))
+sweep_documentation(PI0, Docs) :-
+ term_string(PI1, PI0),
+ ( PI1 = M:PI
-> true
- ; module_property(M0, file(P)),
- predicate_property(M0:Head, imported_from(M))
- -> true
- ; M=user
+ ; M=user, PI=PI1
),
findall(Doc, sweep_documentation_(M, PI, Doc), Docs).
:type '(repeat string)
:group 'sweeprolog)
+(defcustom sweeprolog-enable-eldoc t
+ "If non-nil, enable `eldoc' suport in `sweeprolog-mode' buffers."
+ :package-version '((sweeprolog "0.4.7"))
+ :type 'boolean
+ :group 'sweeprolog)
+
(defcustom sweeprolog-enable-cursor-sensor t
"If non-nil, enable `cursor-sensor-mode' in `sweeprolog-mode'.
(sweeprolog-highlight-variable (point) var)
(sweeprolog-highlight-variable old)))))
+
+(defun sweeprolog-predicate-modes-doc (cb)
+ (when-let ((pi (sweeprolog-identifier-at-point)))
+ (sweeprolog-open-query "user"
+ "sweep"
+ "sweep_documentation"
+ pi)
+ (let ((sol (sweeprolog-next-solution)))
+ (sweeprolog-close-query)
+ (when (sweeprolog-true-p sol)
+ (funcall cb (cadr sol) :thing pi :face font-lock-function-name-face)))))
+
(defvar-local sweeprolog--timer nil)
(defvar-local sweeprolog--colourise-buffer-duration 0.2)
nil
nil
(font-lock-fontify-region-function . sweeprolog-colourise-some-terms)))
+ (when sweeprolog-enable-eldoc
+ (setq-local eldoc-documentation-strategy #'eldoc-documentation-default)
+ (add-hook 'eldoc-documentation-functions #'sweeprolog-predicate-modes-doc nil t))
(let ((time (current-time)))
(sweeprolog-colourise-buffer)
(setq sweeprolog--colourise-buffer-duration (float-time (time-since time))))