emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sweeprolog bcd59aff79 1/2: ENHANCED: consult with library


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog bcd59aff79 1/2: ENHANCED: consult with library index for finding predicate defs
Date: Fri, 20 Jan 2023 14:59:45 -0500 (EST)

branch: elpa/sweeprolog
commit bcd59aff790f40b8777e9929fff1e7fed6e4e06a
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ENHANCED: consult with library index for finding predicate defs
    
    * sweep.pl (sweep_predicate_location_/4): also check library_index/3.
    * sweeprolog-tests.el: add test for finding the source location of a
    predicate in the package clib.
---
 sweep.pl            | 8 ++++++++
 sweeprolog-tests.el | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/sweep.pl b/sweep.pl
index 79c6ffc37c..7cfb80bac8 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -384,6 +384,14 @@ sweep_predicate_location_(M, H, Path, Line) :-
     xref_definition_line(How, Line),
     !,
     atom_string(Path0, Path).
+sweep_predicate_location_(M, H, P, L) :-
+    '$autoload':library_index(H, M, P0),
+    absolute_file_name(P0, P1, [extensions([pl])]),
+    xref_source(P1, [comments(store)]),
+    xref_defined(P1, H, How),
+    xref_definition_line(How, L),
+    !,
+    atom_string(P1, P).
 sweep_predicate_location_(M, H, Path, Line) :-
     predicate_property(M:H, file(Path0)),
     predicate_property(M:H, line_count(Line)),
diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el
index bb2c1a9b35..3076cb99d4 100644
--- a/sweeprolog-tests.el
+++ b/sweeprolog-tests.el
@@ -124,6 +124,10 @@ recursive(Var) :-
     *-> Bar is foo
     )")))))
 
+(ert-deftest predicate-location ()
+  "Test `sweeprolog-predicate-location'."
+  (should (sweeprolog-predicate-location "memory_file:new_memory_file/1")))
+
 (ert-deftest term-search ()
   "Test `sweeprolog-term-search'."
   (let ((temp (make-temp-file "sweeprolog-test"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]