eschulte pushed a commit to branch go in repository elpa. commit 64fd6d02fc83150c9b6552854cf0a841c10b8fe2 Author: Eric Schulte <eric.schu...@gmx.com> Date: Sun May 27 16:34:09 2012 -0600
uniform gnugo prefix --- gnugo.el | 38 +++++++++++++++++--------------------- go-board.el | 2 +- go-tests.el | 4 ++-- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/gnugo.el b/gnugo.el index a04f8c3..ab4e0f0 100644 --- a/gnugo.el +++ b/gnugo.el @@ -1,4 +1,4 @@ -;;; go-gnugo.el --- functions for interaction with a gnugo process using gtp +;;; gnugo.el --- gnugo GO back-end ;; Copyright (C) 2008 2012 Eric Schulte <eric.schu...@gmx.com> @@ -25,53 +25,49 @@ ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. -;;; Comments: - -;; Interaction with gnugo - ;;; CODE: (require 'go-util) (require 'gtp) (require 'comint) -(defun go-gnugo-gtp-commands () +(defun gnugo-gtp-commands () "Return a list of the gnugo GTP commands." (split-string (substring (shell-command-to-string - (format "echo list_commands | %s --mode gtp" go-gnugo-program)) + (format "echo list_commands | %s --mode gtp" gnugo-program)) 2 -2) "\n")) -(defvar go-gnugo-program "gnugo" +(defvar gnugo-program "gnugo" "path to gnugo executable") -(defvar go-gnugo-process-name "gnugo" +(defvar gnugo-process-name "gnugo" "name for the gnugo process") -(defun go-gnugo-start-process (&rest options) +(defun gnugo-start-process (&rest options) (let ((buffer (apply 'make-comint - go-gnugo-process-name - go-gnugo-program nil + gnugo-process-name + gnugo-program nil "--mode" "gtp" "--quiet" options))) (with-current-buffer buffer (comint-mode)) buffer)) -(defun go-gnugo-command-to-string (gnugo command) +(defun gnugo-command-to-string (gnugo command) "Send command to gnugo process and return gnugo's results as a string" (interactive "sgnugo command: ") - (go-gnugo-input-command gnugo command) - (go-gnugo-last-output gnugo)) + (gnugo-input-command gnugo command) + (gnugo-last-output gnugo)) -(defun go-gnugo-input-command (gnugo command) +(defun gnugo-input-command (gnugo command) "Pass COMMAND to the gnugo process running in the buffer of GNUGO." (with-current-buffer (buffer gnugo) (goto-char (process-mark (get-buffer-process (current-buffer)))) (insert command) (comint-send-input)) - (go-gnugo-wait-for-output gnugo)) + (gnugo-wait-for-output gnugo)) -(defun go-gnugo-wait-for-output (gnugo) +(defun gnugo-wait-for-output (gnugo) (with-current-buffer (buffer gnugo) (while (progn (goto-char comint-last-input-end) @@ -80,7 +76,7 @@ (error (match-string 1))) (accept-process-output (get-buffer-process (current-buffer)))))) -(defun go-gnugo-last-output (gnugo) +(defun gnugo-last-output (gnugo) (with-current-buffer (buffer gnugo) (comint-show-output) (org-babel-clean-text-properties @@ -92,6 +88,6 @@ ((buffer :initarg :buffer :accessor buffer :initform nil))) (defmethod gtp-command ((gnugo gnugo) command) - (go-gnugo-command-to-string gnugo command)) + (gnugo-command-to-string gnugo command)) -(provide 'go-gnugo) +(provide 'gnugo) diff --git a/go-board.el b/go-board.el index ba5b072..d0eb59c 100644 --- a/go-board.el +++ b/go-board.el @@ -336,7 +336,7 @@ (let ((*autoplay* t)) (go-board (make-instance 'gnugo - :buffer (apply #'go-gnugo-start-process + :buffer (apply #'gnugo-start-process (when level (list "--level" (number-to-string level)))))))) diff --git a/go-tests.el b/go-tests.el index 159d9c3..d5b7bd9 100644 --- a/go-tests.el +++ b/go-tests.el @@ -30,7 +30,7 @@ (require 'sgf2el) (require 'go-board) (require 'gtp) -(require 'go-gnugo) +(require 'gnugo) (require 'sgf) (require 'ert) @@ -168,7 +168,7 @@ (unwind-protect (progn (setf *gnugo* (make-instance 'gnugo)) - (setf (buffer *gnugo*) (go-gnugo-start-process)) + (setf (buffer *gnugo*) (gnugo-start-process)) ,@body) (let ((kill-buffer-query-functions nil)) (should (kill-buffer (buffer *gnugo*)))))))