From: Eshel Yaron Date: Sat, 27 Aug 2022 09:07:14 +0000 (+0300) Subject: Add module descriptions to sweep-find-module annotation function X-Git-Tag: v0.2.0~96 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4b4b28f15af817b2473fb7b053b210a580d47cba;p=dict.git Add module descriptions to sweep-find-module annotation function --- diff --git a/sweep.el b/sweep.el index 7691637..88f6c99 100644 --- a/sweep.el +++ b/sweep.el @@ -95,14 +95,16 @@ module name, F is a functor name and N is its arity." (sweep-open-query "user" "sweep" "sweep_modules_collection" nil) (let ((sol (sweep-next-solution))) (sweep-close-query) - (when (eq '! (car sol)) + (when (or (eq (car sol) '!) + (eq (car sol) t)) (cdr sol)))) (defun sweep-module-path (mod) (sweep-open-query "user" "sweep" "sweep_module_path" mod) (let ((sol (sweep-next-solution))) (sweep-close-query) - (when (eq '! (car sol)) + (when (or (eq (car sol) '!) + (eq (car sol) t)) (cdr sol)))) (defun sweep-read-module-name () @@ -111,8 +113,13 @@ module name, F is a functor name and N is its arity." (completion-extra-properties (list :annotation-function (lambda (key) - (concat (make-string (- 32 (length key)) ? ) - (cdr (assoc-string key col))))))) + (let* ((val (cdr (assoc-string key col))) + (pat (car val)) + (des (cdr val))) + (concat (make-string (- 32 (length key)) ? ) + (if des + (concat pat (make-string (- 64 (length pat)) ? ) des) + pat))))))) (completing-read "Module: " col))) (defun sweep-find-module (mod) diff --git a/sweep.pl b/sweep.pl index 5e90a74..57f20cf 100644 --- a/sweep.pl +++ b/sweep.pl @@ -170,9 +170,16 @@ sweep_module_path_(Module, Path) :- sweep_modules_collection([], Modules) :- - findall([M|P], ( module_property(M0, file(P0)), atom_string(M0, M), atom_string(P0, P) ), Modules0, Tail), - setof([M|P], M0^P0^N^('$autoload':library_index(N, M0, P0), string_concat(P0, ".pl", P), atom_string(M0, M) ), Tail), - list_to_set(Modules0, Modules). + findall([M|P], ( module_property(M, file(P0)), atom_string(P0, P) ), Modules0, Tail), + setof([M|P], P0^N^('$autoload':library_index(N, M, P0), string_concat(P0, ".pl", P) ), Tail), + list_to_set(Modules0, Modules1), + maplist(sweep_module_description, Modules1, Modules). + +sweep_module_description([M0|P], [M|[P|D]]) :- + pldoc_process:doc_comment(M0:module(D0), _, _, _), + atom_string(M0, M), + atom_string(D0, D). +sweep_module_description([M0|P], [M|[P]]) :- atom_string(M0, M). sweep_predicate_location(MFN, [Path|Line]) :- term_string(M:F/N, MFN),