diff options
Diffstat (limited to 'chess-gnuchess.el')
| -rw-r--r-- | chess-gnuchess.el | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/chess-gnuchess.el b/chess-gnuchess.el index ef2e4be..c304a8b 100644 --- a/chess-gnuchess.el +++ b/chess-gnuchess.el @@ -10,23 +10,28 @@ "Interface code for playing against gnuchess. Uses `chess-process'." :group 'chess) -(defcustom chess-gnuchess-command "gnuchess" +(defcustom chess-gnuchess-command (and (require 'executable) + (executable-find "gnuchess")) "The name of the gnuchess program." :type 'string :group 'chess-gnuchess) ;;;###autoload -(defun chess-gnuchess (session process event &rest args) - (chess-process - session process event - (list (list (concat "My move is : \\(" chess-algebraic-regexp "\\)") - (function - (lambda (move) - (chess-game-move chess-process-game move nil))) 1) - '("Illegal move:" (error "Illegal move"))) - (if (file-name-absolute-p chess-gnuchess-command) - chess-gnuchess-command - (executable-find chess-gnuchess-command)))) +(defun chess-gnuchess (session buffer event &rest args) + (if (not (eq event 'initialize)) + (apply 'chess-process session buffer event args) + (chess-process session buffer event + (list (list + (concat "My move is : \\(" + chess-algebraic-regexp "\\)") + (function + (lambda (move) + (chess-session-event + chess-current-session 'move + (chess-algebraic-to-ply + (chess-game-pos chess-process-game) move)))) 1) + '("Illegal move:" (error "Illegal move"))) + chess-gnuchess-command))) (provide 'chess-gnuchess) |
