diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-14 23:17:48 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-14 23:17:48 +0000 |
| commit | 4f7271d9ea4f82eb316b05a54bac9030d1127c8e (patch) | |
| tree | 2bc9aca9e184f57a83ee74a68c97aca261cbc7c2 | |
| parent | db5b94f367aebaeb019b46b2e2feb9f366d5d964 (diff) | |
*** no comment ***
| -rw-r--r-- | chess-display.el | 8 | ||||
| -rw-r--r-- | chess-engine.el | 3 | ||||
| -rw-r--r-- | chess-none.el | 5 | ||||
| -rw-r--r-- | chess-pgn.el | 29 | ||||
| -rw-r--r-- | chess.el | 4 |
5 files changed, 30 insertions, 19 deletions
diff --git a/chess-display.el b/chess-display.el index 768ed72..76a2fa6 100644 --- a/chess-display.el +++ b/chess-display.el @@ -82,7 +82,8 @@ makes moves, or any other changes to the underlying game." (setq buffer (current-buffer)) (chess-display-mode read-only) (if (null (setq buffer (funcall handler 'initialize))) - (kill-buffer buffer) + (ignore + (kill-buffer buffer)) (add-hook 'kill-buffer-hook 'chess-display-quit nil t) (setq chess-display-style style chess-display-perspective perspective @@ -193,10 +194,11 @@ This is the function to call to cause a display to view a game. It will also update all of the listening engines and other displays to also view the same game." (chess-with-current-buffer display - (setq chess-display-index (or index (chess-game-index game))) (chess-game-set-tags chess-display-game (chess-game-tags game)) ;; this call triggers `setup-game' for us - (chess-game-set-plies chess-display-game (chess-game-plies game)))) + (let ((chess-game-inhibit-events t)) + (chess-game-set-plies chess-display-game (chess-game-plies game))) + (chess-display-set-index nil (or index (chess-game-index game))))) (defun chess-display-detach-game (display) "Set the display game. diff --git a/chess-engine.el b/chess-engine.el index ed80570..eb492f1 100644 --- a/chess-engine.el +++ b/chess-engine.el @@ -267,7 +267,8 @@ (setq buffer (current-buffer)) (let ((proc (apply handler 'initialize handler-ctor-args))) (if (null proc) ; must be a process or t - (kill-buffer buffer) + (ignore + (kill-buffer buffer)) (add-hook 'kill-buffer-hook 'chess-engine-on-kill nil t) (setq chess-engine-regexp-alist (symbol-value regexp-alist) chess-engine-event-handler handler diff --git a/chess-none.el b/chess-none.el index 5494cf1..104d524 100644 --- a/chess-none.el +++ b/chess-none.el @@ -12,9 +12,10 @@ This is only useful when two humans are playing each other, in which case this engine will do the job of accepting undos, handling resignations, etc." (cond + ((eq event 'initialize) t) + ((memq event '(resign abort)) - (chess-engine-set-position nil) - t) + (chess-engine-set-position nil)) ((eq event 'undo) (chess-game-undo chess-engine-game (car args))))) diff --git a/chess-pgn.el b/chess-pgn.el index 874e467..c9954ee 100644 --- a/chess-pgn.el +++ b/chess-pgn.el @@ -222,6 +222,18 @@ If INDENTED is non-nil, indent the move texts." (push "application/x-chess-pgn" mm-inlined-types) (push "application/x-chess-pgn" mm-automatic-display))) +(defun chess-pgn-index () + "Return the move index associated with point." + (save-excursion + (if (re-search-backward chess-pgn-move-regexp nil t) + (let* ((index (string-to-int (match-string 2))) + (first-move (match-string 3)) + (second-move (match-string 14)) + (ply (1+ (* 2 (1- index))))) + (if (and second-move (> (length second-move) 0)) + (setq ply (1+ ply))) + ply)))) + (defun chess-pgn-show-position () (interactive) ;; load a database to represent this file if not already up @@ -250,29 +262,24 @@ If INDENTED is non-nil, indent the move texts." ;; now find what position we're at in the game (save-excursion - (when (and chess-pgn-current-game - (re-search-backward chess-pgn-move-regexp nil t)) - (let* ((index (string-to-int (match-string 2))) - (first-move (match-string 3)) - (second-move (match-string 14)) - (ply (1+ (* 2 (1- index))))) - (if (and second-move (> (length second-move) 0)) - (setq ply (1+ ply))) + (when chess-pgn-current-game + (let ((index (chess-pgn-index))) (if (or (and (or (null chess-pgn-display) (not (buffer-live-p chess-pgn-display))) - (setq chess-pgn-display (chess-create-display))) + (let ((chess-game-inhibit-events t)) + (setq chess-pgn-display (chess-create-display)))) (/= (chess-game-data chess-pgn-current-game 'database-index) (chess-game-data (chess-display-game chess-pgn-display) 'database-index))) (progn (chess-display-disable-popup chess-pgn-display) (chess-display-set-game chess-pgn-display - chess-pgn-current-game ply) + chess-pgn-current-game index) (chess-game-set-tag (chess-display-game chess-pgn-display) 'database-index (chess-game-data chess-pgn-current-game 'database-index))) - (chess-display-set-index chess-pgn-display ply)))))) + (chess-display-set-index chess-pgn-display index)))))) (defun chess-pgn-mouse-show-position (event) (interactive "e") @@ -124,8 +124,8 @@ available." (defun chess--create-engine (module game response-handler ctor-args) (if (require module nil t) - (let ((engine (chess-engine-create game module - response-handler ctor-args))) + (let ((engine (apply 'chess-engine-create game module + response-handler ctor-args))) (when engine ;; for the sake of engines which are ready to play now, and ;; which don't need connect/accept negotiation (most |
