[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 56/255: some utility functions
From: |
Eric Schulte |
Subject: |
[elpa] 56/255: some utility functions |
Date: |
Sun, 16 Mar 2014 01:02:19 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 02a9567ed0e5fbf4fec42ae4536af71f01361617
Author: Eric Schulte <address@hidden>
Date: Mon May 21 19:30:39 2012 -0400
some utility functions
---
sgf2el.el | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/sgf2el.el b/sgf2el.el
index d3e0917..d11c7d6 100644
--- a/sgf2el.el
+++ b/sgf2el.el
@@ -5,7 +5,7 @@
;; Author: Eric Schulte <address@hidden>
;; Created: 2012-05-15
;; Version: 0.1
-;; Keywords: game go
+;; Keywords: game go sgf
;; This file is not (yet) part of GNU Emacs.
;; However, it is distributed under the same license.
@@ -82,6 +82,34 @@
(car val) val)))))
(replace-match rep nil 'literal)))))))
+(defun sgf2el (&optional sgf-buffer)
+ "Convert the content of SGF-BUFFER to emacs-lisp in a new buffer."
+ (interactive)
+ (let* ((sgf-buffer (or sgf-buffer (current-buffer)))
+ (buffer (generate-new-buffer (concat (buffer-name sgf-buffer) "-el")))
+ (sgf-str (with-current-buffer sgf-buffer (buffer-string))))
+ (with-current-buffer buffer
+ (insert sgf-str)
+ (sgf2el-region)
+ (emacs-lisp-mode))
+ (pop-to-buffer buffer)))
+
+(defmacro sgf2el-set-to-var (var &optional buffer)
+ "Assign the value of the board in BUFFER to VAR."
+ `(let ((buffer ,(or buffer (current-buffer))))
+ (setq ,var (save-excursion (goto-char (point-min)) (read buffer)))))
+
+(defun sgf2el-normalize (&optional buffer)
+ "Cleanup the formatting of the elisp sgf data in BUFFER."
+ (interactive)
+ (let ((buffer (or buffer (current-buffer))) temp)
+ (sgf2el-set-to-var temp buffer)
+ (with-current-buffer buffer
+ (save-excursion
+ (delete-region (point-min) (point-max))
+ (insert (pp temp))))
+ (length temp)))
+
;;; Specific property converters
(defun process-date (date-args)
@@ -117,3 +145,5 @@
label-args))
(add-to-list 'sgf2el-special-properties (cons :LB #'process-label))
(add-to-list 'sgf2el-special-properties (cons :LW #'process-label))
+
+(provide 'sgf2el)
- [elpa] 49/255: removed debug stuffs, (continued)
- [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, 2014/03/15
- [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 <=
- [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
- [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