summaryrefslogtreecommitdiff
path: root/chess-engine.el
diff options
context:
space:
mode:
authorMario Lang <mlang@delysid.org>2004-01-23 15:42:33 +0000
committerMario Lang <mlang@delysid.org>2004-01-23 15:42:33 +0000
commit9775676bfe5a4d5d88359ef1ba6bcc20d50b4d3d (patch)
tree6b900eb79c8beaac823e8fc5e1bda0e95ebf6520 /chess-engine.el
parent08de9931cdae798ceeb7b4cf8230f31c5c722352 (diff)
dont barf on unbound chess-module-regexp-alist, and add some docstrings
Diffstat (limited to 'chess-engine.el')
-rw-r--r--chess-engine.el25
1 files changed, 18 insertions, 7 deletions
diff --git a/chess-engine.el b/chess-engine.el
index 57f1d19..f11787e 100644
--- a/chess-engine.el
+++ b/chess-engine.el
@@ -72,6 +72,8 @@
(failed-start . "Failed to start chess engine process")))
(defsubst chess-engine-convert-algebraic (move &optional trust-check)
+ "Convert algebraic move to a ply in reference to the engine position.
+If conversion fails, this function fired an 'illegal event."
(or (chess-algebraic-to-ply (chess-engine-position nil) move trust-check)
(chess-engine-command nil 'illegal)))
@@ -294,7 +296,8 @@
(setq chess-engine-regexp-alist
(copy-alist
(symbol-value
- (intern-soft (concat (symbol-name module) "-regexp-alist"))))
+ (let ((sym (intern-soft (concat (symbol-name module) "-regexp-alist"))))
+ (when (boundp sym) sym))))
chess-engine-response-handler
(or response-handler 'chess-engine-default-handler))
(let ((proc chess-engine-process))
@@ -317,15 +320,19 @@
;; 'wall-clock
(defun chess-engine-set-option (engine option value)
+ "Set ENGINE OPTION to VALUE by invoking its handler with the 'set-option
+event."
(chess-with-current-buffer engine
(chess-engine-command engine 'set-option option value)))
(defun chess-engine-set-response-handler (engine &optional response-handler)
+ "Set a new RESPONSE-HANDLER for ENGINE."
(chess-with-current-buffer engine
(setq chess-engine-response-handler
(or response-handler 'chess-engine-default-handler))))
(defun chess-engine-response-handler (engine)
+ "Return the function currently defined as the response-handler for ENGINE."
(chess-with-current-buffer engine
chess-engine-response-handler))
@@ -343,6 +350,7 @@
(chess-game-run-hooks chess-module-game 'orient)))
(defun chess-engine-position (engine)
+ "Return the current position of the game associated with ENGINE."
(chess-with-current-buffer engine
(chess-game-pos chess-module-game)))
@@ -360,7 +368,10 @@
'((engine-not-running . "The engine you were using is no longer running")))
(defun chess-engine-send (engine string)
- "Send the given STRING to ENGINE."
+ "Send the given STRING to ENGINE.
+If `chess-engine-process' is a valid process object, use `process-send-string'
+to submit the data. Otherwise, the 'send event is triggered and the engine
+event handler can take care of the data."
(chess-with-current-buffer engine
(let ((proc chess-engine-process))
(if proc
@@ -424,11 +435,11 @@
(line-end-position) t)
(setq result (funcall (cdar triggers))))
(progn
- (if (eq result 'once)
- (if last-trigger
- (setcdr last-trigger (cdr triggers))
- (setq chess-engine-regexp-alist
- (cdr triggers))))
+ (when (eq result 'once)
+ (if last-trigger
+ (setcdr last-trigger (cdr triggers))
+ (setq chess-engine-regexp-alist
+ (cdr triggers))))
(setq triggers nil))
(setq last-trigger triggers
triggers (cdr triggers)))))