From: Eshel Yaron Date: Tue, 4 Oct 2022 09:42:48 +0000 (+0300) Subject: FIXED: top-level buffer to thread synchronization X-Git-Tag: v0.5.0~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c0d818905667f7f66922f41322f61cdf572a59bd;p=dict.git FIXED: top-level buffer to thread synchronization --- diff --git a/sweep.pl b/sweep.pl index 4a1d376..fd2dc02 100644 --- a/sweep.pl +++ b/sweep.pl @@ -829,12 +829,12 @@ sweep_top_level_client(InStream, OutStream, ip(127,0,0,1)) :- 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), diff --git a/sweeprolog.el b/sweeprolog.el index bd9a9b7..51e7522 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -1521,10 +1521,14 @@ Interactively, a prefix arg means to prompt for BUFFER." (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 () @@ -1578,7 +1582,7 @@ Interactively, a prefix arg means to prompt for BUFFER." (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 @@ -1593,7 +1597,6 @@ Interactively, a prefix arg means to prompt for BUFFER." (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)