set_stream(user_input, newline(detect)),
set_stream(user_output, newline(dos)),
set_stream(user_error, newline(dos)),
+ thread_self(Self),
+ thread_property(Self, id(Id)),
+ thread_at_exit(retractall(sweep_top_level_thread_buffer(Id, _))),
call_cleanup(prolog,
( close(InStream, [force(true)]),
- close(OutStream, [force(true)]),
- thread_self(Self),
- thread_property(Self, id(Id)),
- retractall(sweep_top_level_thread_buffer(Id, _))
+ close(OutStream, [force(true)])
)).
sweep_top_level_client(InStream, OutStream, _) :-
close(InStream),
(sweeprolog-close-query)
(unless (sweeprolog-true-p sol)
(error "Failed to create new top-level!")))
- (make-comint-in-buffer "sweeprolog-top-level"
- buf
- (cons "localhost"
- sweeprolog-prolog-server-port))
+ (with-current-buffer buf
+ (make-comint-in-buffer "sweeprolog-top-level"
+ buf
+ (cons "localhost"
+ sweeprolog-prolog-server-port))
+ (unless comint-last-prompt
+ (accept-process-output (get-buffer-process (current-buffer)) 1))
+ (sweeprolog-top-level--populate-thread-id))
(pop-to-buffer buf sweeprolog-top-level-display-action)))
(defun sweeprolog-top-level--post-self-insert-function ()
(buffer-local-value 'major-mode b))))
(read-string "Signal goal: ?- ")))
(sweeprolog-signal-thread (buffer-local-value 'sweeprolog-top-level-thread-id
- buffer)
+ (get-buffer buffer))
goal))
;;;###autoload
(length s)))
comint-delimiter-argument-list '(?,)
comment-start "%")
- (add-hook 'comint-exec-hook #'sweeprolog-top-level--populate-thread-id nil t)
(add-hook 'post-self-insert-hook #'sweeprolog-top-level--post-self-insert-function nil t)
(setq sweeprolog-buffer-module "user")
(add-hook 'completion-at-point-functions #'sweeprolog-completion-at-point-function nil t)