[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 98/255: *trackers* are multiple subordinate back-ends
From: |
Eric Schulte |
Subject: |
[elpa] 98/255: *trackers* are multiple subordinate back-ends |
Date: |
Sun, 16 Mar 2014 01:02:27 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 16db958b4837116b67fe9a616de449dae3b389eb
Author: Eric Schulte <address@hidden>
Date: Sat May 26 16:36:32 2012 -0600
*trackers* are multiple subordinate back-ends
---
go-board.el | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/go-board.el b/go-board.el
index a91ea17..b13b273 100644
--- a/go-board.el
+++ b/go-board.el
@@ -33,6 +33,7 @@
(defvar *size* nil "Holds the board size.")
(defvar *turn* nil "Holds the color of the current turn.")
(defvar *back-end* nil "Holds the primary back-end connected to a board.")
+(defvar *trackers* nil "Holds a list of back-ends which should track the
game.")
(defvar black-piece "X")
(defvar white-piece "O")
@@ -196,22 +197,31 @@
comment)))
(goto-char (point-min))))
-(defun go-board-display (back-end)
+(defun go-board-display (back-end &rest trackers)
(let ((buffer (generate-new-buffer "*GO*")))
(with-current-buffer buffer
(go-board-mode)
- (when (go<-name back-end)
- (rename-buffer (ear-muffs (go<-name back-end)) 'unique))
+ (let ((name (go<-name back-end)))
+ (when name
+ (rename-buffer (ear-muffs name) 'unique)
+ (mapcar (lambda (tr) (go->name tr name)) trackers)))
(set (make-local-variable '*back-end*) back-end)
(set (make-local-variable '*turn*) :B)
(set (make-local-variable '*size*) (go<-size back-end))
+ (mapcar (lambda (tr) (go->size tr *size*)) trackers)
(set (make-local-variable '*history*)
(list (board-to-pieces (make-board *size*))))
+ (set (make-local-variable '*trackers*) trackers)
(update-display (current-buffer)))
(pop-to-buffer buffer)))
;;; User input
+(defmacro with-backends (sym &rest body)
+ (declare (indent 1))
+ `(prog1 (let ((,sym *back-end*)) ,@body)
+ (mapcar (lambda (tr) (let ((,sym tr)) ,@body)) *trackers*)))
+
(defvar go-board-actions '(move resign undo comment)
"List of actions which may be taken on an GO board.")
@@ -243,18 +253,18 @@
(mapcar #'number-to-string
(range 1 *size*))))))))
(move (cons *turn* (cons :pos pos))))
- (message "move:%S" move)
- (go->move *back-end* move)
+ (with-backends back
+ (go->move back move))
(apply-turn-to-board (list move))
(setf *turn* (other-color *turn*))))
(defun go-board-act-resign ()
(interactive)
- (go->reset *back-end*))
+ (with-backends back (go->reset back)))
(defun go-board-act-undo (&optional num)
(interactive "p")
- (go->undo *back-end*)
+ (with-backends back (go->undo back))
(pop *history*)
(update-display (current-buffer))
(setf *turn* (other-color *turn*)))
- [elpa] 87/255: removed old variable, (continued)
- [elpa] 87/255: removed old variable, Eric Schulte, 2014/03/15
- [elpa] 83/255: starting to transition to generic board interface, Eric Schulte, 2014/03/15
- [elpa] 85/255: working with new set less some state-leak issues, Eric Schulte, 2014/03/15
- [elpa] 90/255: moving around major mode and key bindings, Eric Schulte, 2014/03/15
- [elpa] 91/255: adding properties to the board string, Eric Schulte, 2014/03/15
- [elpa] 86/255: playing gnugo, Eric Schulte, 2014/03/15
- [elpa] 94/255: remove old variable from tests, Eric Schulte, 2014/03/15
- [elpa] 92/255: worked around stupid bug in mapconcat, Eric Schulte, 2014/03/15
- [elpa] 93/255: able to play against gnugo, Eric Schulte, 2014/03/15
- [elpa] 95/255: renaming files for go- prefix, Eric Schulte, 2014/03/15
- [elpa] 98/255: *trackers* are multiple subordinate back-ends,
Eric Schulte <=
- [elpa] 89/255: tweaks, Eric Schulte, 2014/03/15
- [elpa] 102/255: simpler name for main go-board function, Eric Schulte, 2014/03/15
- [elpa] 100/255: automated playing with gnugo, Eric Schulte, 2014/03/15
- [elpa] 99/255: single function to play gnugo, Eric Schulte, 2014/03/15
- [elpa] 101/255: now with colors, Eric Schulte, 2014/03/15
- [elpa] 106/255: sgf: go-labels shouldn't increment the index, Eric Schulte, 2014/03/15
- [elpa] 107/255: can now feed moves from gnugo through to sgf, Eric Schulte, 2014/03/15
- [elpa] 105/255: fleshing out the sgf interface, Eric Schulte, 2014/03/15
- [elpa] 103/255: some setter methods for the sgf backend, Eric Schulte, 2014/03/15
- [elpa] 108/255: renaming go-sgf.el to sgf.el, Eric Schulte, 2014/03/15