]> git.eshelyaron.com Git - dict.git/commitdiff
ADDED: (sweep-find-file-at-point): new function
authorEshel Yaron <me@eshelyaron.com>
Sun, 11 Sep 2022 20:19:50 +0000 (23:19 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 11 Sep 2022 20:19:50 +0000 (23:19 +0300)
(sweep-mode): add sweep-file-at-point to file-name-at-point-functions
buffer locally.

sweep.el
sweep.pl

index 16aa103c50c1faf9cafb4a83640cf74cd086fe31..677a94898759e302c8710c1623c87928b7f44e80 100644 (file)
--- a/sweep.el
+++ b/sweep.el
@@ -1213,6 +1213,15 @@ Interactively, a prefix arg means to prompt for BUFFER."
       (when (sweep-true-p sol)
         (cdr sol)))))
 
+(defun sweep-find-file-at-point (point)
+  "Find file specificed by the Prolog file spec at POINT.
+
+Interactively, POINT is set to the current point."
+  (interactive "d" sweep-mode sweep-top-level-mode)
+  (if-let ((file (sweep-file-at-point point)))
+      (find-file file)
+    (user-error "No file specification found at point!")))
+
 (defun sweep-identifier-at-point (&optional point)
   (let* ((p (or point (point)))
          (beg (save-mark-and-excursion
@@ -1297,6 +1306,7 @@ Interactively, a prefix arg means to prompt for BUFFER."
   (sweep-colourise-buffer)
   (sweep--set-buffer-module)
   (add-hook 'xref-backend-functions #'sweep--xref-backend nil t)
+  (add-hook 'file-name-at-point-functions #'sweep-file-at-point nil t)
   (add-hook 'completion-at-point-functions #'sweep-completion-at-point-function nil t))
 
 ;;;; Testing:
index d5d451fef20b10277680c53dff22412b821eeed5..56a25be01cf6a6dc06494edba622c865c32ba1c2 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -161,7 +161,6 @@ sweep_handle_file_at_point(Point, file(File), Beg, Len) :-
 sweep_handle_file_at_point(_, _, _, _).
 
 
-
 sweep_identifier_at_point([Contents0, Path, Point], Identifier) :-
     setup_call_cleanup(( new_memory_file(H),
                          insert_memory_file(H, 0, Contents0),