]> git.eshelyaron.com Git - sweep.git/commitdiff
ADDED: new command sweeprolog-xref-project-source-files
authorEshel Yaron <me@eshelyaron.com>
Thu, 10 Nov 2022 18:14:26 +0000 (20:14 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 10 Nov 2022 18:14:26 +0000 (20:14 +0200)
sweeprolog.el

index 6d8b2074cfa99218a02156840809fb682de85ae7..03db2c6917857bc2f0d1018405b16f2462cd3e67 100644 (file)
@@ -367,6 +367,7 @@ clause."
     (define-key map "P" #'sweeprolog-pack-install)
     (define-key map "R" #'sweeprolog-restart)
     (define-key map "T" #'sweeprolog-list-top-levels)
+    (define-key map "X" #'sweeprolog-xref-project-source-files)
     (define-key map "e" #'sweeprolog-view-messages)
     (define-key map "h" sweeprolog-help-prefix-map)
     (define-key map "l" #'sweeprolog-load-buffer)
@@ -412,6 +413,10 @@ clause."
     [ "Describe Predicate"  sweeprolog-describe-predicate t ]
     [ "Describe Prolog module" sweeprolog-describe-module t ]
     "--"
+    [ "Xref files in current project"
+      sweeprolog-xref-project-source-files
+      (project-current) ]
+    "--"
     [ "Reset sweep"            sweeprolog-restart         t ]
     [ "View sweep messages"    sweeprolog-view-messages   t ]))
 
@@ -692,8 +697,30 @@ FLAG and VALUE are specified as strings and read as Prolog terms."
   "Return a list of prediacte completion candidates matchitng PREFIX."
   (sweeprolog--query-once "sweep" "sweep_predicates_collection" prefix))
 
+;;;###autoload
+(defun sweeprolog-xref-project-source-files (&optional project)
+  "Update cross reference data for all Prolog files in PROJECT.
+
+If PROJECT is nil, update data for the current project.
+
+If called interactively with a prefix argument, prompt for
+PROJECT."
+  (interactive (list (or (and current-prefix-arg
+                              (let ((default-directory
+                                     (project-prompt-project-dir)))
+                                (project-current)))
+                         (or (project-current)
+                             (user-error "No current project")))))
+  (when-let ((proj (or project (project-current))))
+    (mapc (lambda (path)
+            (sweeprolog--query-once "sweep" "sweep_xref_source" path))
+          (seq-filter (lambda (path)
+                        (string= "pl" (file-name-extension path)))
+                      (project-files proj)))))
+
 (defun sweeprolog-predicate-references (mfn)
   "Find source locations where the predicate MFN is called."
+  (sweeprolog-xref-project-source-files)
   (sweeprolog--query-once "sweep" "sweep_predicate_references" mfn))
 
 (defun sweeprolog--mfn-to-functor-arity (mfn)