emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 183/255: explicit connection method for back-end objects


From: Eric Schulte
Subject: [elpa] 183/255: explicit connection method for back-end objects
Date: Sun, 16 Mar 2014 01:02:45 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 8e62bd0d698f76c8d93c5e1568e5bfba9da98c89
Author: Eric Schulte <address@hidden>
Date:   Sun May 19 12:06:42 2013 -0600

    explicit connection method for back-end objects
---
 back-ends/gnugo.el |    5 ++++-
 back-ends/igs.el   |   13 +++++++------
 go-api.el          |    1 +
 go.el              |    1 +
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/back-ends/gnugo.el b/back-ends/gnugo.el
index dd1a676..54f41c4 100644
--- a/back-ends/gnugo.el
+++ b/back-ends/gnugo.el
@@ -85,7 +85,10 @@
 
 ;;; Class and interface
 (defclass gnugo (gtp)
-  ((buffer :initarg :buffer :accessor buffer :initform (gnugo-start-process))))
+  ((buffer :initarg :buffer :accessor buffer)))
+
+(defmethod go-connect ((gnugo gnugo))
+  (setf (buffer gnugo) (gnugo-start-process)))
 
 (defmethod gtp-command ((gnugo gnugo) command)
   (gnugo-command-to-string gnugo command))
diff --git a/back-ends/igs.el b/back-ends/igs.el
index 056c8f2..04c7f5c 100644
--- a/back-ends/igs.el
+++ b/back-ends/igs.el
@@ -162,22 +162,21 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
           (mapc (lambda (s) (igs-filter-process proc s)) lines)))
       (when moving (goto-char (process-mark proc))))))
 
-(defun igs-connect ()
+(defun igs-connect (igs)
   "Open a connection to `igs-server'."
   (interactive)
   (flet ((wait (prompt)
                (while (and (goto-char (or comint-last-input-end (point-min)))
                            (not (re-search-forward prompt nil t)))
                  (accept-process-output proc))))
-    (let ((igs-instance (make-instance 'igs))
-          (buffer (apply 'make-comint
+    (let ((buffer (apply 'make-comint
                          igs-process-name
                          igs-telnet-command nil
                          (list igs-server (number-to-string igs-port)))))
-      (setf (buffer igs-instance) buffer)
+      (setf (buffer igs) buffer)
       (with-current-buffer buffer
         (comint-mode)
-        (set (make-local-variable '*igs-instance*) igs-instance)
+        (set (make-local-variable '*igs-instance*) igs)
         (set (make-local-variable '*igs-ready*) nil)
         (set (make-local-variable '*igs-games*) nil)
         (set (make-local-variable '*igs-current-game*) nil)
@@ -191,7 +190,7 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
           (igs-toggle "client" t)
           (set-process-filter proc 'igs-insertion-filter))
         (igs-games))
-      igs-instance)))
+      buffer)))
 
 (defun igs-toggle (setting value)
   (igs-send (format "toggle %s %s" setting (if value "true" "false"))))
@@ -366,6 +365,8 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
 (defclass igs ()
   ((buffer :initarg :buffer :accessor buffer :initform nil)))
 
+(defmethod go-connect ((igs igs)) (igs-connect igs))
+
 (defmacro with-igs (igs &rest body)
   (declare (indent 1))
   `(with-current-buffer (buffer ,igs) ,@body))
diff --git a/go-api.el b/go-api.el
index 6238fb1..2ea36cd 100644
--- a/go-api.el
+++ b/go-api.el
@@ -68,6 +68,7 @@
   go-player-prisoners         "Access current BACK-END player prisoners.")
 
 ;; sending messages to the back-end
+(defgeneric go-connect (back-end) "Connect to BACK-END.")
 (defgeneric go-undo   (back-end) "Send undo to BACK-END.")
 (defgeneric go-pass   (back-end) "Send pass to BACK-END.")
 (defgeneric go-resign (back-end) "Send resign to BACK-END.")
diff --git a/go.el b/go.el
index 26ecac5..974f2b6 100644
--- a/go.el
+++ b/go.el
@@ -53,6 +53,7 @@
         (size (read (org-icompleting-read
                      "board size: "
                      (mapcar #'number-to-string '(19 13 9))))))
+    (go-connect it)
     (setf (go-size it) size)
     it))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]