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

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

[elpa] 156/255: chunking responses from IGS server into full lines


From: Eric Schulte
Subject: [elpa] 156/255: chunking responses from IGS server into full lines
Date: Sun, 16 Mar 2014 01:02:39 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 9cc13dcae2b5512df6408c696d1eaf8fa7fadc3b
Author: Eric Schulte <address@hidden>
Date:   Sun Jun 3 14:36:13 2012 -0600

    chunking responses from IGS server into full lines
---
 back-ends/igs.el |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/back-ends/igs.el b/back-ends/igs.el
index b3ec70c..37e22e1 100644
--- a/back-ends/igs.el
+++ b/back-ends/igs.el
@@ -110,6 +110,9 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
 (defvar *igs-current-game* nil
   "Number of the current IGS game (may change frequently).")
 
+(defvar *igs-partial-line* nil
+  "Holds partial lines of input from an IGS process.")
+
 (defmacro igs-w-proc (proc &rest body)
   (declare (indent 1))
   `(with-current-buffer (process-buffer proc) ,@body))
@@ -146,8 +149,15 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
        (goto-char (process-mark proc))
         (insert string)
         (set-marker (process-mark proc) (point))
-        (mapc (lambda (s) (igs-filter-process proc s))
-              (split-string string "[\n\r]")))
+        (let ((lines (split-string (if *igs-partial-line*
+                                       (concat *igs-partial-line* string)
+                                     string)
+                                   "[\n\r]")))
+          (if (string-match "[\n\r]$" (car (last lines)))
+              (setf *igs-partial-line* nil)
+            (setf *igs-partial-line* (car (last lines)))
+            (setf lines (butlast lines)))
+          (mapc (lambda (s) (igs-filter-process proc s)) lines)))
       (when moving (goto-char (process-mark proc))))))
 
 (defun igs-connect ()
@@ -169,6 +179,7 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
         (set (make-local-variable '*igs-ready*) nil)
         (set (make-local-variable '*igs-games*) nil)
         (set (make-local-variable '*igs-current-game*) nil)
+        (set (make-local-variable '*igs-partial-line*) nil)
         (set (make-local-variable '*igs-time-last-sent*) (current-time))
         (let ((proc (get-buffer-process (current-buffer))))
           (wait "^Login:")
@@ -197,8 +208,7 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
 
 (defun igs-game-list (igs)
   (let (games)
-    (with-current-buffer (buffer igs)
-      (setq games *igs-games*))
+    (with-igs igs (setq games *igs-games*))
     (let* ((my-games (copy-seq games))
            (list-buf (get-buffer-create "*igs-game-list*")))
       (with-current-buffer (pop-to-buffer list-buf)
@@ -357,9 +367,11 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
 
 (defmethod go-name ((igs igs))
   (with-igs igs (let ((game (igs-current-game)))
-                  (format "%s vs %s"
+                  (format "%s(%s) vs %s(%s)"
                           (aget game :white-name)
-                          (aget game :black-name)))))
+                          (aget game :white-rank)
+                          (aget game :black-name)
+                          (aget game :black-rank)))))
 
 (defmethod set-go-name ((igs igs) name)
   (signal 'unsupported-back-end-command (list igs :set-name name)))



reply via email to

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