[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 52/255: more condensed collecting of games w/alternatives
From: |
Eric Schulte |
Subject: |
[elpa] 52/255: more condensed collecting of games w/alternatives |
Date: |
Sun, 16 Mar 2014 01:02:18 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 010efd72dba44e9418e1930ab4ef875dfc3bd7e0
Author: Eric Schulte <address@hidden>
Date: Sun May 20 13:19:39 2012 -0400
more condensed collecting of games w/alternatives
---
sgf.el | 38 +++++++++++++++++++++++---------------
1 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/sgf.el b/sgf.el
index 66b9185..c7e8395 100644
--- a/sgf.el
+++ b/sgf.el
@@ -162,18 +162,19 @@
(defun parse-trees (str)
(let (cont-p)
- (parse-many parse-tree-part-re str
- (let ((m-end (match-end 0)))
- (setq cont-p (string= "(" (substring str (1- m-end) m-end)))
- (collect (parse-nodes (match-string 1 str)))
- (setq start
- (if cont-p
- (let* ((start (1- m-end))
- (end (closing-paren str start)))
- (unless end (error "sgf: parsing w/o end at %d" start))
- (collect (parse-trees (substring str start end)))
- (1+ end))
- m-end))))))
+ (flet ((my-collect (el) (setq res (append el res))))
+ (parse-many parse-tree-part-re str
+ (let ((m-end (match-end 0)))
+ (setq cont-p (string= "(" (substring str (1- m-end) m-end)))
+ (my-collect (parse-nodes (match-string 1 str)))
+ (setq start
+ (if cont-p
+ (let* ((start (1- m-end))
+ (end (closing-paren str start)))
+ (unless end (error "sgf: parsing w/o end at %d" start))
+ (my-collect (nreverse (parse-trees (substring str start
end))))
+ (1+ end))
+ m-end)))))))
(defun read-from-buffer (buffer)
(process (parse-trees (with-current-buffer buffer (buffer-string)))))
@@ -314,6 +315,15 @@
(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 local-sgf (error "sgf: buffer has not associated sgf data"))
(delete-region (point-min) (point-max))
@@ -326,9 +336,7 @@
(when comment
(insert (make-string (+ 6 (* 2 (board-size local-board))) ?=)
"\n\n")
- (let ((beg (point)))
- (insert comment)
- (fill-region beg (point)))))
+ (insert (clean-comment comment))))
(goto-char (point-min)))
(defun display-sgf (game)
- [elpa] 26/255: improvements, considering labels and moves, (continued)
- [elpa] 26/255: improvements, considering labels and moves, Eric Schulte, 2014/03/15
- [elpa] 40/255: parsing empty properties, Eric Schulte, 2014/03/15
- [elpa] 42/255: more work with tree parsing, Eric Schulte, 2014/03/15
- [elpa] 46/255: TODO: try using load-read-function and try loading these files w/read, Eric Schulte, 2014/03/15
- [elpa] 45/255: looking at a new method of parsing trees, Eric Schulte, 2014/03/15
- [elpa] 44/255: indentation, Eric Schulte, 2014/03/15
- [elpa] 43/255: paren matching, Eric Schulte, 2014/03/15
- [elpa] 49/255: removed debug stuffs, Eric Schulte, 2014/03/15
- [elpa] 47/255: parsing of sgf files with alternative paths working, Eric Schulte, 2014/03/15
- [elpa] 48/255: all tests are passing, Eric Schulte, 2014/03/15
- [elpa] 52/255: more condensed collecting of games w/alternatives,
Eric Schulte <=
- [elpa] 51/255: parsing large complex files, Eric Schulte, 2014/03/15
- [elpa] 39/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 50/255: whitespace, Eric Schulte, 2014/03/15
- [elpa] 41/255: simplified parse-tree, but not done, Eric Schulte, 2014/03/15
- [elpa] 53/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 54/255: more parsing/syntax tweaks, Eric Schulte, 2014/03/15
- [elpa] 56/255: some utility functions, Eric Schulte, 2014/03/15
- [elpa] 55/255: new approach to parsing sgf files into elisp, Eric Schulte, 2014/03/15
- [elpa] 61/255: passing first 6 tests, Eric Schulte, 2014/03/15
- [elpa] 59/255: passing first two tests, Eric Schulte, 2014/03/15