From 66deea724bf232b683d6371a6c9fd102a6369a29 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Tue, 21 Oct 2014 17:40:32 +0100 Subject: [PATCH] manage messages split into multiple chunks buffer content until we find at least one newline character. Technically this doesn't handle multiple messages ending in an incomplete one; as proof of concept it'll do. --- squeeze.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/squeeze.el b/squeeze.el index 1e34449..1858614 100644 --- a/squeeze.el +++ b/squeeze.el @@ -39,15 +39,20 @@ (defvar squeeze-control-inhibit-display nil) -(defun squeeze-update-state (string) - (let (done-something) - (dolist (line (split-string string "\n")) - (when (squeeze-update-state-from-line line) - (setq done-something t))) - (when done-something - (unless squeeze-control-inhibit-display - (squeeze-control-display-players)))) - string) +(lexical-let ((buffer "")) + (defun squeeze-update-state (string) + (if (cl-position ?\n string) + (let (done-something) + (setq string (concat buffer string)) + (dolist (line (split-string string "\n")) + (when (squeeze-update-state-from-line line) + (setq done-something t))) + (when done-something + (unless squeeze-control-inhibit-display + (squeeze-control-display-players))) + (setq buffer "")) + (setq buffer (concat buffer string))) + string)) (defconst squeeze-player-line-regexp "^\\(\\(?:[0-9a-f]\\{2\\}%3A\\)\\{5\\}[0-9a-f]\\{2\\}\\) ") -- 2.39.5