From: Eshel Yaron Date: Sun, 4 Sep 2022 19:57:31 +0000 (+0300) Subject: ENHANCED: set per buffer module name in sweep-mode X-Git-Tag: v0.2.0~40 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d226bbb70c7260d1bb1d6f8165daa913e864cd10;p=dict.git ENHANCED: set per buffer module name in sweep-mode --- diff --git a/sweep.el b/sweep.el index bf3aff1..16ce920 100644 --- a/sweep.el +++ b/sweep.el @@ -262,6 +262,14 @@ module name, F is a functor name and N is its arity." pat))))))) (completing-read sweep-read-module-prompt col))) + +(defun sweep--set-buffer-module () + (sweep-open-query "user" "sweep" "sweep_path_module" (buffer-file-name)) + (let ((sol (sweep-next-solution))) + (sweep-close-query) + (when (sweep-true-p sol) + (setq sweep-buffer-module (cdr sol))))) + ;;;###autoload (defun sweep-find-module (mod) "Jump to the source file of the Prolog module MOD." @@ -970,7 +978,8 @@ Interactively, a prefix arg means to prompt for BUFFER." nil nil (font-lock-fontify-region-function . sweep-colourise-some-terms))) - (sweep-colourise-buffer)) + (sweep-colourise-buffer) + (sweep--set-buffer-module)) ;;;; Testing: diff --git a/sweep.pl b/sweep.pl index 3d65efa..c24bae8 100644 --- a/sweep.pl +++ b/sweep.pl @@ -35,6 +35,7 @@ sweep_colourise_some_terms/2, sweep_documentation/2, sweep_expand_file_name/2, + sweep_path_module/2, sweep_predicate_location/2, sweep_predicates_collection/2, sweep_modules_collection/2, @@ -350,3 +351,9 @@ sweep_expand_file_name_(Dir, Spec, Exp) :- relative_to(Dir), solutions(all), extensions(['', '.pl'])]). + +sweep_path_module([], "user") :- !. +sweep_path_module(Path0, Module) :- + atom_string(Path, Path0), + xref_module(Path, Module0), + atom_string(Module0, Module).