From: ueno Date: Sun, 26 Sep 2004 13:53:02 +0000 (+0000) Subject: Undo the last change. X-Git-Tag: riece-1_0_4~8 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=b5c4b3c66a239d72d50875cc3f44140f06b3fb46;p=elisp%2Friece.git Undo the last change. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 881c1b9..03cbb2e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -4,7 +4,10 @@ (riece-flush-send-queue): New function. (riece-process-send-string): Use it. (riece-reset-process-buffer): Reset riece-send-queue, - riece-send-size. + riece-send-size, and riece-last-send-time. + (riece-seconds-to-time): New function. + (riece-time-less-p): New function. + (riece-time-since): New function. * riece-options.el (riece-max-send-size): New user option. (riece-send-delay): New user option. * riece-globals.el (riece-send-queue): New variable. diff --git a/lisp/riece-globals.el b/lisp/riece-globals.el index a910ea1..4741b89 100644 --- a/lisp/riece-globals.el +++ b/lisp/riece-globals.el @@ -114,6 +114,9 @@ Local to the server buffers.") (defvar riece-send-size nil "Size of the last send. Local to the server buffers.") +(defvar riece-last-send-time nil + "Timestamp of the last send. +Local to the server buffers.") (defvar riece-obarray nil "Namespace of the IRC world. Local to the server buffers.") diff --git a/lisp/riece-server.el b/lisp/riece-server.el index e0ffa28..b38c925 100644 --- a/lisp/riece-server.el +++ b/lisp/riece-server.el @@ -105,11 +105,35 @@ the `riece-server-keyword-map' variable." (put 'riece-with-server-buffer 'lisp-indent-function 1) (put 'riece-with-server-buffer 'edebug-form-spec '(form body)) -(defun riece-flush-send-queue (process reset) +;; stolen (and renamed) from time-date.el. +(defun riece-seconds-to-time (seconds) + "Convert SECONDS (a floating point number) to a time value." + (list (floor seconds 65536) + (floor (mod seconds 65536)) + (floor (* (- seconds (ffloor seconds)) 1000000)))) + +;; stolen (and renamed) from time-date.el. +(defun riece-time-less-p (t1 t2) + "Say whether time value T1 is less than time value T2." + (or (< (car t1) (car t2)) + (and (= (car t1) (car t2)) + (< (nth 1 t1) (nth 1 t2))))) + +;; stolen (and renamed) from time-date.el. +(defun riece-time-since (time) + "Return the time elapsed since TIME." + (let* ((current (current-time)) + (rest (when (< (nth 1 current) (nth 1 time)) + (expt 2 16)))) + (list (- (+ (car current) (if rest -1 0)) (car time)) + (- (+ (or rest 0) (nth 1 current)) (nth 1 time))))) + +(defun riece-flush-send-queue (process) (with-current-buffer (process-buffer process) (let ((length 0) string) - (if reset + (if (riece-time-less-p (riece-seconds-to-time riece-send-delay) + (riece-time-since riece-last-send-time)) (setq riece-send-size 0)) (while (and riece-send-queue (<= riece-send-size riece-max-send-size)) @@ -118,17 +142,18 @@ the `riece-server-keyword-map' variable." (if (> length riece-max-send-size) (message "Long message (%d > %d)" length riece-max-send-size) (setq riece-send-size (+ riece-send-size length)) - (if (<= riece-send-size riece-max-send-size) - (process-send-string process string))) + (when (<= riece-send-size riece-max-send-size) + (process-send-string process string) + (setq riece-last-send-time (current-time)))) (setq riece-send-queue (cdr riece-send-queue))) (if riece-send-queue (riece-run-at-time riece-send-delay nil - #'riece-flush-send-queue process t))))) + #'riece-flush-send-queue process))))) (defun riece-process-send-string (process string) (with-current-buffer (process-buffer process) (setq riece-send-queue (nconc riece-send-queue (list string)))) - (riece-flush-send-queue process nil)) + (riece-flush-send-queue process)) (defun riece-current-server-name () (or riece-overriding-server-name @@ -203,6 +228,8 @@ the `riece-server-keyword-map' variable." (make-local-variable 'riece-send-queue) (make-local-variable 'riece-send-size) (setq riece-send-size 0) + (make-local-variable 'riece-last-send-time) + (setq riece-last-send-time '(0 0 0)) (make-local-variable 'riece-obarray) (setq riece-obarray (make-vector riece-obarray-size 0)) (make-local-variable 'riece-coding-system)