From 1aefaea2ab0d2537e816b5da37eb67658e831859 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 11 Sep 2022 23:19:50 +0300 Subject: [PATCH] ADDED: (sweep-find-file-at-point): new function (sweep-mode): add sweep-file-at-point to file-name-at-point-functions buffer locally. --- sweep.el | 10 ++++++++++ sweep.pl | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sweep.el b/sweep.el index 16aa103..677a948 100644 --- 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: diff --git a/sweep.pl b/sweep.pl index d5d451f..56a25be 100644 --- 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), -- 2.39.2