]> git.eshelyaron.com Git - dict.git/commitdiff
FIXED: stale predicate locations in loaded modified buffers
authorEshel Yaron <me@eshelyaron.com>
Thu, 8 Dec 2022 20:10:04 +0000 (22:10 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 8 Dec 2022 20:26:02 +0000 (22:26 +0200)
* sweep.pl (sweep_predicate_location_/2,3): prefer xref over loaded
predicate properties.
* sweeprolog.el (sweeprolog-predicate-location): first analyze buffer
if modified to update xref data.

sweep.pl
sweeprolog.el

index 4c0c12ea1dc020607b49e38e0cbf49b574294a22..95f1f2d01b47521fb93729b3eb5a33ae4fa4467c 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -353,23 +353,15 @@ sweep_predicate_apropos(Query0, Matches) :-
             Tail).
 
 sweep_predicate_location_(H, Path, Line) :-
-    predicate_property(H, file(Path0)),
-    predicate_property(H, line_count(Line)),
+    xref_defined(Path0, H, How),
+    xref_definition_line(How, Line),
     !,
     atom_string(Path0, Path).
 sweep_predicate_location_(H, Path, Line) :-
-    (   xref_defined(Path0, H, How),
-        xref_definition_line(How, Line)
-    ->  true
-    ;   xref_defined(Path0, H, _), Line = []
-    ),
+    predicate_property(H, file(Path0)),
+    predicate_property(H, line_count(Line)),
     atom_string(Path0, Path).
 
-sweep_predicate_location_(M, H, Path, Line) :-
-    predicate_property(M:H, file(Path0)),
-    predicate_property(M:H, line_count(Line)),
-    !,
-    atom_string(Path0, Path).
 sweep_predicate_location_(M, H, Path, Line) :-
     (   xref_defined(Path0, M:H, How),
         xref_definition_line(How, Line)
@@ -377,9 +369,12 @@ sweep_predicate_location_(M, H, Path, Line) :-
     ;   xref_defined(Path0, H, How),
         xref_definition_line(How, Line),
         xref_module(Path0, M)
-    ->  true
-    ;   xref_defined(Path0, M:H, _), Line = []
     ),
+    !,
+    atom_string(Path0, Path).
+sweep_predicate_location_(M, H, Path, Line) :-
+    predicate_property(M:H, file(Path0)),
+    predicate_property(M:H, line_count(Line)),
     atom_string(Path0, Path).
 
 
index 3fd1765650836ad1462e30d9a4d28c1c3c7ae054..742b42a15ff95a54bc98bed11ef43773de037085 100644 (file)
@@ -853,6 +853,7 @@ PROJECT (only on Emacs 28 or later)."
 For native built-in predicates, the behavior of this function
 depends on the value of the user option
 `sweeprolog-swipl-sources', which see."
+  (sweeprolog-analyze-buffer)
   (or (sweeprolog--query-once "sweep" "sweep_predicate_location" mfn)
       (sweeprolog-native-predicate-location mfn)))