:type '(list string)
:group 'sweep)
-
-(defvar sweep-prolog-server-port 12345)
+(defvar sweep-prolog-server-port nil)
;;;###autoload
(defun sweep-module-compile ()
(defun sweep-start-prolog-server ()
(sweep-open-query "user"
- "sweep"
- "sweep_start_prolog_server"
- sweep-prolog-server-port)
+ "prolog_server"
+ "prolog_server"
+ nil t)
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- sol))
+ (when (sweep-true-p sol)
+ (setq sweep-prolog-server-port (cdr sol)))))
(defun sweep-init ()
- (setq sweep-prolog-server-port (+ (random 10000)
- sweep-prolog-server-port))
(apply #'sweep-initialize
(cons (expand-file-name "bin/swipl" (file-name-directory
load-file-name))
(defvar sweep-predicate-completion-collection nil)
+(defvar-local sweep-buffer-module nil)
+
(defun sweep-local-predicates-collection (&optional prefix)
- (sweep-open-query "user" "sweep" "sweep_local_predicate_completion" prefix)
+ (sweep-open-query "user" "sweep" "sweep_local_predicate_completion"
+ (cons sweep-buffer-module
+ prefix))
(let ((sol (sweep-next-solution)))
(sweep-close-query)
(when (sweep-true-p sol)
(put-text-property beg end 'font-lock-face
(pcase g
(`("recursion" . ,_) sweep-recursion-face)
- (`("meta" . ,_) sweep-meta-face)
- (`("built_in" . ,_) sweep-built-in-face)
+ (`("meta" . ,_) sweep-meta-face)
+ (`("built_in" . ,_) sweep-built-in-face)
(`("undefined" . ,_) sweep-undefined-face)
(_ sweep-goal-face))))
("unused_import" (put-text-property beg end 'font-lock-face sweep-unused-import-face))
(add-hook 'post-self-insert-hook #'sweep-top-level--post-self-insert-function nil t)
(setq sweep-top-level-timer (run-with-idle-timer 0.2 t #'sweep-colourise-query (current-buffer)))
(add-hook 'completion-at-point-functions #'sweep-completion-at-point-function nil t)
+ (setq sweep-buffer-module "user")
(add-hook 'kill-buffer-hook
(lambda ()
(when (timerp sweep-top-level-timer)
sweep_predicates_collection/2,
sweep_modules_collection/2,
sweep_packs_collection/2,
- sweep_start_prolog_server/2,
sweep_pack_install/2,
sweep_module_path/2
]).
predicate_property(M:H, line_count(Line)),
predicate_property(M:H, file(Path0)), atom_string(Path0, Path).
-sweep_local_predicate_completion(Sub, Preds) :-
+sweep_local_predicate_completion([Mod|Sub], Preds) :-
+ atom_string(M, Mod),
findall(F/N,
- current_predicate(F/N),
+ @(current_predicate(F/N), M),
Preds0),
- list_to_set(Preds0, Preds1),
- convlist(sweep_predicate_completion_annotated(Sub), Preds1, Preds).
+ convlist(sweep_predicate_completion_annotated(Sub, M), Preds0, Preds).
-sweep_predicate_completion_annotated(Sub, F/N, [S|A]) :-
+sweep_predicate_completion_annotated(Sub, M, F/N, [S|A]) :-
format(string(S), '~W/~w', [F, [quoted(true), character_escapes(true)], N]),
sub_string(S, _, _, _, Sub),
+ \+ sub_string(S, _, _, _, "$"),
pi_head(F/N, Head),
- findall(P, predicate_property(Head, P), Ps0),
+ findall(P, @(predicate_property(Head, P), M), Ps0),
sweep_predicate_completion_op_annotation(F, Ps0, Ps),
phrase(sweep_head_annotation(Ps), A).
Tail),
list_to_set(Preds0, Preds1),
maplist(sweep_predicate_description, Preds1, Preds2),
+ include(sweep_predicate_non_hidden, Preds2, Preds3),
( Sub == []
- -> Preds = Preds2
- ; include(sweep_predicate_matches(Sub), Preds2, Preds)
+ -> Preds = Preds3
+ ; include(sweep_predicate_matches(Sub), Preds3, Preds)
).
sweep_predicate_matches(Sub, [String|_]) :-
sub_string(String, _, _, _, Sub).
+sweep_predicate_non_hidden([String|_]) :-
+ \+ sub_string(String, 0, _, _, "$").
sweep_predicate_description(M:F/N, [S|T]) :-
sweep_predicate_description_(M, F, N, T), format(string(S), '~w:~w/~w', [M, F, N]).
atom_string(Pack, PackName), pack_install(Pack, [silent(true), upgrade(true), interactive(false)]).
-sweep_start_prolog_server(Port, []) :-
- prolog_server(Port, []).
-
sweep_colourise_query([String|Offset], _) :-
prolog_colourise_query(String, module(sweep), sweep_handle_query_color(Offset)).