summaryrefslogtreecommitdiff
path: root/chess-engine.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-09 23:51:30 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-09 23:51:30 +0000
commit23808aea3686317c1673d32b10783329cf0bc310 (patch)
tree5efce99df084d9ac57c8830a97e8d53654908665 /chess-engine.el
parentcdcddcb50f516cae6dbe2cd8f484cd16f59dd0bd (diff)
*** no comment ***
Diffstat (limited to 'chess-engine.el')
-rw-r--r--chess-engine.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/chess-engine.el b/chess-engine.el
index 07d7bd6..77cca30 100644
--- a/chess-engine.el
+++ b/chess-engine.el
@@ -139,17 +139,19 @@
(defun chess-engine-on-kill ()
"Function called when the buffer is killed."
- (chess-engine-detach-game nil))
+ (chess-engine-command (current-buffer) 'shutdown))
(defun chess-engine-destroy (engine)
(let ((buf (or engine (current-buffer))))
(when (buffer-live-p buf)
(chess-engine-command engine 'destroy)
+ (remove-hook 'kill-buffer-hook 'chess-engine-on-kill t)
(kill-buffer buf))))
(defun chess-engine-command (engine event &rest args)
(chess-with-current-buffer engine
- (apply chess-engine-event-handler event args)))
+ (apply 'chess-engine-event-handler
+ (chess-engine-game nil) engine event args)))
;; 'ponder
;; 'search-depth
@@ -217,16 +219,18 @@
(if proc
(if (memq (process-status proc) '(run open))
(process-send-string proc string)
- (error "The engine you were using is no longer running"))
+ (message "The engine you were using is no longer running")
+ (chess-engine-command nil 'destroy))
(chess-engine-command nil 'send string)))))
(defun chess-engine-submit (engine string)
"Submit the given STRING, so ENGINE sees it in its input stream."
(chess-with-current-buffer engine
(let ((proc chess-engine-process))
- (if (and (processp proc)
- (not (memq (process-status proc) '(run open))))
- (error "The engine you were using is no longer running"))
+ (when (and (processp proc)
+ (not (memq (process-status proc) '(run open))))
+ (message "The engine you were using is no longer running")
+ (chess-engine-command nil 'destroy))
(chess-engine-filter nil string))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -243,8 +247,10 @@
(apply chess-engine-event-handler event args)))
(cond
((eq event 'shutdown)
- (ignore-errors
- (chess-engine-destroy engine))))))
+ (chess-engine-destroy engine))
+
+ ((eq event 'destroy)
+ (chess-engine-detach-game engine)))))
(defun chess-engine-filter (proc string)
"Filter for receiving text for an engine from an outside source."