From 14b5328514b738b8acbde5d588b263a9c34fa52a Mon Sep 17 00:00:00 2001 From: ueno Date: Fri, 12 Aug 2005 20:20:10 +0000 Subject: [PATCH] * riece-ruby.el (riece-ruby-filter): Pass timestamp of output event to output-handler. --- lisp/ChangeLog | 5 +++++ lisp/riece-rdcc.el | 4 ++-- lisp/riece-ruby.el | 28 ++++++++++++++++++++-------- lisp/test/test-riece-ruby.el | 4 ++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f6cb330..dba7b89 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2005-08-12 Daiki Ueno + * riece-ruby.el (riece-ruby-filter): Pass timestamp of output + event to output-handler. + +2005-08-12 Daiki Ueno + * riece-button.el (riece-user-button-popup-menu): Simplified menu item titles. diff --git a/lisp/riece-rdcc.el b/lisp/riece-rdcc.el index f977f36..cd51ab0 100644 --- a/lisp/riece-rdcc.el +++ b/lisp/riece-rdcc.el @@ -107,7 +107,7 @@ end (defvar jka-compr-compression-info-list) (defvar jam-zcat-filename-list) -(defun riece-rdcc-output-handler (name output) +(defun riece-rdcc-output-handler (name output time) (if (string-match "\\([0-9]+\\) \\([0-9]+\\)" output) (let ((address (match-string 1 output)) (port (match-string 2 output))) @@ -121,7 +121,7 @@ end (riece-ruby-property name 'riece-rdcc-request-size))))) (riece-ruby-set-output-handler name #'riece-rdcc-output-handler-2)) -(defun riece-rdcc-output-handler-2 (name output) +(defun riece-rdcc-output-handler-2 (name output time) (message "Sending %s...(%s/%d)" (riece-ruby-property name 'riece-rdcc-request-file) (string-to-number output) diff --git a/lisp/riece-ruby.el b/lisp/riece-ruby.el index e11ec90..aa7a838 100644 --- a/lisp/riece-ruby.el +++ b/lisp/riece-ruby.el @@ -215,7 +215,8 @@ Use `riece-ruby-set-property' to set this variable.") (cdr (car riece-ruby-status-alist))))) (if (looking-at "# output \\([^ ]*\\) \\(.*\\)\r") (riece-ruby-run-output-handler (match-string 1) - (match-string 2)) + (match-string 2) + (current-time)) (if (looking-at "# exit \\(.*\\)\r") (riece-ruby-run-exit-handler (match-string 1)))))))) (forward-line)) @@ -226,18 +227,24 @@ Use `riece-ruby-set-property' to set this variable.") (when entry (setq riece-ruby-exit-handler-alist (delq entry riece-ruby-exit-handler-alist)) - (riece-funcall-ignore-errors name (cdr entry) (car entry)) + (riece-funcall-ignore-errors (if (symbolp (cdr entry)) + (symbol-name (cdr entry)) + (format "%s-exit-handler" name)) + (cdr entry) (car entry)) (riece-ruby-clear name)))) -(defun riece-ruby-run-output-handler (name output) +(defun riece-ruby-run-output-handler (name output time) (let ((handler-entry (assoc name riece-ruby-output-handler-alist)) (entry (assoc name riece-ruby-output-queue-alist))) (if handler-entry - (riece-funcall-ignore-errors name (cdr handler-entry) name output) + (riece-funcall-ignore-errors (if (symbolp (cdr handler-entry)) + (symbol-name (cdr handler-entry)) + (format "%s-output-handler" name)) + (cdr handler-entry) name output time) (if entry (setcdr entry (cons output (cdr entry))) (setq riece-ruby-output-queue-alist - (cons (list name output) + (cons (list name (cons output time)) riece-ruby-output-queue-alist)))))) (defun riece-ruby-sentinel (process status) @@ -336,8 +343,9 @@ is specified. Otherwise, it should be called explicitly." "Set an output-handler HANDLER for the program distinguished by NAME. An output-handler is called when the program sends any output by using `output' method in the Ruby program. -An output-handler is called with two argument. The first argument is -the same as NAME. The second argument is output string." +An output-handler is called with three argument. The first argument +is the same as NAME. The second argument is the output string. The +third argument is the timestamp of the output event." (let ((entry (assoc name riece-ruby-output-handler-alist)) queue-entry pointer) (if handler @@ -347,7 +355,11 @@ the same as NAME. The second argument is output string." riece-ruby-output-queue-alist (delq queue-entry riece-ruby-output-queue-alist)) (while pointer - (riece-funcall-ignore-errors name handler name (car pointer)) + (riece-funcall-ignore-errors (if (symbolp handler) + (symbol-name handler) + (format "%s-output-handler" name)) + handler name (car (car pointer)) + (cdr (car pointer))) (setq pointer (cdr pointer)))) (if entry (setcdr entry handler) diff --git a/lisp/test/test-riece-ruby.el b/lisp/test/test-riece-ruby.el index 7b41b8f..ca99573 100644 --- a/lisp/test/test-riece-ruby.el +++ b/lisp/test/test-riece-ruby.el @@ -78,7 +78,7 @@ (let ((name (riece-ruby-execute "output(1 << 32)"))) (riece-ruby-set-output-handler name - (lambda (name output) + (lambda (name output time) (setq test-riece-ruby-output-handler-1 output))) (sleep-for 1) (lunit-assert-2 @@ -91,7 +91,7 @@ (sleep-for 1) (riece-ruby-set-output-handler name - (lambda (name output) + (lambda (name output time) (setq test-riece-ruby-output-handler-2 output))) (lunit-assert-2 case -- 1.7.10.4