term_string(Goal, Goal0),
thread_signal(ThreadId, Goal).
-sweep_local_predicate_export_comment([Path0,F0,A],Comm) :-
+sweep_local_predicate_export_comment([Path0,F0,A,I0],Comm) :-
atom_string(Path, Path0),
atom_string(F, F0),
- doc_comment(_:F/A, Path:_, _Summary, Comment),
+ atom_string(I, I0),
+ compound_name_arguments(PI, I, [F,A]),
+ doc_comment(_:PI, Path:_, _Summary, Comment),
comment_modes(Comment, Modes),
- pi_head(F/A, Head),
+ compound_name_arity(Head, F, A),
member(ModeAndDet, Modes),
strip_det(ModeAndDet, Head),
Head =.. [_|Args],
]),
sub_string(Syn0, 6, _, 1, Comm).
+strip_det(//(Mode) is _, Mode) :- !.
strip_det(Mode is _, Mode) :- !.
strip_det(//(Mode), Mode) :- !.
strip_det(Mode, Mode).
findall(D,
( xref_defined(Path, D0, _),
\+ xref_exported(Path, D0),
- pi_head(D1, D0),
+ \+ D0 = _:_,
+ pi_head(F/A, D0),
+ ( xref_defined(Path, D0, dcg)
+ -> B is A - 2, D1 = F//B
+ ; D1 = F/A
+ ),
term_string(D1, D)
),
Preds).
(sweeprolog-close-query)
res))
-(defun sweeprolog-local-predicate-export-comment (fun ari)
+(defun sweeprolog-local-predicate-export-comment (fun ari ind)
(sweeprolog--query-once "sweep" "sweep_local_predicate_export_comment"
- (list (buffer-file-name) fun ari)))
+ (list (buffer-file-name) fun ari ind)))
(defun sweeprolog-exportable-predicates ()
"Return a list of exportable predicates from the current buffer."
predicate to export providing completion candidates based on the
non-exported predicates defined in the current buffer."
(interactive (or (and (not current-prefix-arg)
- (when-let ((def (sweeprolog-definition-at-point))
- (fun (cadr def))
- (ari (caddr def)))
- (list (concat fun "/" (number-to-string ari))
- (sweeprolog-local-predicate-export-comment fun ari))))
+ (when-let ((def (sweeprolog-definition-at-point))
+ (fun (nth 1 def))
+ (ari (nth 2 def))
+ (neck (nth 4 def))
+ (ind "/"))
+ (unless (nth 5 def)
+ (when (string= neck "-->")
+ (setq ari (- ari 2)
+ ind "//"))
+ (list (concat fun ind (number-to-string ari))
+ (sweeprolog-local-predicate-export-comment fun ari ind)))))
(list
(sweeprolog-read-exportable-predicate)
(read-string "Export comment: ")))