(and (looking-at-p (rx bol graph))
(not (nth 8 (syntax-ppss)))))
-(defun sweep-identifier-at-point (&optional point)
+(defun sweep-file-at-point (&optional point)
(let* ((p (or point (point)))
(beg (save-mark-and-excursion
(goto-char p)
(unless (sweep-at-beginning-of-top-term-p)
(sweep-beginning-of-top-term))
+ (max (1- (point)) (point-min))))
+ (end (save-mark-and-excursion
+ (goto-char p)
+ (sweep-end-of-top-term)
(point)))
+ (contents (buffer-substring-no-properties beg end)))
+ (sweep-open-query "user"
+ "sweep"
+ "sweep_file_at_point"
+ (list contents
+ (buffer-file-name)
+ (- p beg)))
+ (let ((sol (sweep-next-solution)))
+ (sweep-close-query)
+ (when (sweep-true-p sol)
+ (cdr sol)))))
+
+(defun sweep-identifier-at-point (&optional point)
+ (let* ((p (or point (point)))
+ (beg (save-mark-and-excursion
+ (goto-char p)
+ (unless (sweep-at-beginning-of-top-term-p)
+ (sweep-beginning-of-top-term))
+ (max (1- (point)) (point-min))))
(end (save-mark-and-excursion
(goto-char p)
(sweep-end-of-top-term)
sweep_current_prolog_flags/2,
sweep_set_prolog_flag/2,
sweep_documentation/2,
+ sweep_file_at_point/2,
sweep_identifier_at_point/2,
sweep_expand_file_name/2,
sweep_path_module/2,
erase(Ref1).
+sweep_file_at_point([Contents,Path0,Point], Result) :-
+ atom_string(Path, Path0),
+ with_buffer_stream(Stream,
+ Contents,
+ sweep_file_at_point_(Stream, Path, Point, Result)).
+
+:- dynamic sweep_current_file_at_point/1.
+
+sweep_file_at_point_(Stream, Path, Point, File) :-
+ set_stream(Stream, file_name(Path)),
+ retractall(sweep_current_file_at_point(_)),
+ prolog_colourise_term(Stream, Path,
+ sweep_handle_file_at_point(Point),
+ []),
+ sweep_current_file_at_point(File0),
+ atom_string(File0, File).
+
+sweep_handle_file_at_point(Point, file_no_depend(File), Beg, Len) :-
+ Beg =< Point,
+ Point =< Beg + Len,
+ !,
+ asserta(sweep_current_file_at_point(File)).
+sweep_handle_file_at_point(Point, file(File), Beg, Len) :-
+ Beg =< Point,
+ Point =< Beg + Len,
+ !,
+ asserta(sweep_current_file_at_point(File)).
+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),