[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 65/255: cleanup and straightening
From: |
Eric Schulte |
Subject: |
[elpa] 65/255: cleanup and straightening |
Date: |
Sun, 16 Mar 2014 01:02:20 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit d5ee4b31248540f78245a93023b05f2ee967955d
Author: Eric Schulte <address@hidden>
Date: Tue May 22 11:09:49 2012 -0400
cleanup and straightening
---
sgf-board.el | 47 +++++++++++++++++------------------------------
sgf2el.el | 12 ++++++++++++
2 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/sgf-board.el b/sgf-board.el
index caf6360..10d50a4 100644
--- a/sgf-board.el
+++ b/sgf-board.el
@@ -26,20 +26,16 @@
;; Boston, MA 02110-1301, USA.
;;; Code:
+(require 'sgf2el)
(eval-when-compile (require 'cl))
;;; Visualization
-;; - make buffer to show a board, and notes, etc...
-;; - keep an index into the sgf file
-;; - write functions for building boards from sgf files (forwards and
backwards)
-;; - sgf movement keys
(defvar sgf-board nil "Holds the board local to a GO buffer.")
(defvar sgf-sgf nil "Holds the sgf data structure local to a GO buffer.")
(defvar sgf-index nil "Index into the sgf local to a GO buffer.")
-(set-default 'sgf-index '(0))
(defun make-board (size) (make-vector (* size size) nil))
@@ -109,15 +105,6 @@
(dolist (piece pieces board)
(setf (aref board (cdr piece)) (car piece)))))
-(defun clean-comment (comment)
- (let ((replacements '(("\\(" . "(")
- ("\\)" . ")")
- ("\\[" . "[")
- ("\\]" . "]"))))
- (dolist (pair replacements comment)
- (setq comment (replace-regexp-in-string
- (regexp-quote (car pair)) (cdr pair) comment)))))
-
(defun update-display ()
(unless sgf-sgf (error "sgf: buffer has not associated sgf data"))
(delete-region (point-min) (point-max))
@@ -130,7 +117,7 @@
(when comment
(insert (make-string (+ 6 (* 2 (board-size sgf-board))) ?=)
"\n\n")
- (insert (clean-comment comment))))
+ (insert comment)))
(goto-char (point-min)))
(defun display-sgf (game)
@@ -159,21 +146,7 @@
(defun display-sgf-file (path)
(interactive "f")
- (display-sgf (read-from-file path)))
-
-(defun sgf-ref (sgf index)
- (let ((part sgf))
- (while (car index)
- (setq part (nth (car index) part))
- (setq index (cdr index)))
- part))
-
-(defun set-sgf-ref (sgf index new)
- (eval `(setf ,(reduce (lambda (acc el) (list 'nth el acc))
- index :initial-value 'sgf)
- ',new)))
-
-(defsetf sgf-ref set-sgf-ref)
+ (display-sgf (sgf2el-file-to-el path)))
(defun get-create-pieces ()
(if (aget (sgf-ref sgf-sgf sgf-index) :pieces)
@@ -234,6 +207,20 @@
;;; Board manipulation functions
+(defun sgf-ref (sgf index)
+ (let ((part sgf))
+ (while (car index)
+ (setq part (nth (car index) part))
+ (setq index (cdr index)))
+ part))
+
+(defun set-sgf-ref (sgf index new)
+ (eval `(setf ,(reduce (lambda (acc el) (list 'nth el acc))
+ index :initial-value 'sgf)
+ ',new)))
+
+(defsetf sgf-ref set-sgf-ref)
+
(defun move-type (move)
(cond
((member (car move) '(:B :W)) :move)
diff --git a/sgf2el.el b/sgf2el.el
index ed62e21..d1bb832 100644
--- a/sgf2el.el
+++ b/sgf2el.el
@@ -170,4 +170,16 @@
(add-to-list 'sgf2el-special-properties (cons :LB #'process-label))
(add-to-list 'sgf2el-special-properties (cons :LW #'process-label))
+(defun process-comment (comments)
+ (let ((replacements '(("\\(" . "(")
+ ("\\)" . ")")
+ ("\\[" . "[")
+ ("\\]" . "]"))))
+ (mapcar (lambda (comment)
+ (dolist (pair replacements comment)
+ (setq comment (replace-regexp-in-string
+ (regexp-quote (car pair)) (cdr pair) comment))))
+ comments)))
+(add-to-list 'sgf2el-special-properties (cons :C #'process-comment))
+
(provide 'sgf2el)
- [elpa] 62/255: automatically normalize elisp sgf buffers, (continued)
- [elpa] 62/255: automatically normalize elisp sgf buffers, Eric Schulte, 2014/03/15
- [elpa] 58/255: able to load and play through games w/sgf2el, Eric Schulte, 2014/03/15
- [elpa] 60/255: passing first five tests, Eric Schulte, 2014/03/15
- [elpa] 64/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 67/255: support for converting *very* large files, Eric Schulte, 2014/03/15
- [elpa] 63/255: consistently passing first 7 tests, Eric Schulte, 2014/03/15
- [elpa] 73/255: indentation, Eric Schulte, 2014/03/15
- [elpa] 66/255: parsing weird comments, Eric Schulte, 2014/03/15
- [elpa] 72/255: tweak header, Eric Schulte, 2014/03/15
- [elpa] 68/255: misc, Eric Schulte, 2014/03/15
- [elpa] 65/255: cleanup and straightening,
Eric Schulte <=
- [elpa] 71/255: other new files, Eric Schulte, 2014/03/15
- [elpa] 69/255: better names for dynamic local variables, Eric Schulte, 2014/03/15
- [elpa] 70/255: bringing in some files from my old go-mode, Eric Schulte, 2014/03/15
- [elpa] 74/255: sending sgf commands to gnugo, Eric Schulte, 2014/03/15
- [elpa] 76/255: sgf-play -> sgf-trans, Eric Schulte, 2014/03/15
- [elpa] 75/255: stubbing out board interaction functions, Eric Schulte, 2014/03/15
- [elpa] 78/255: stubbing out generic trans functions, Eric Schulte, 2014/03/15
- [elpa] 79/255: communicating with gnugo through gtp generics, Eric Schulte, 2014/03/15
- [elpa] 77/255: saner requirement dependency graph, Eric Schulte, 2014/03/15
- [elpa] 81/255: normalization, Eric Schulte, 2014/03/15