X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-filter.el;h=6c5f44cc587f6c47db970190ce5b54837f52a578;hp=64e917d9f7907deb9999173697d5ff2a692748b0;hb=2f2db64d1382fb55b259d09e8bb31de623c7832a;hpb=4e7b6b2f4e23e9dfd7ed2dbbcedba6a27a45c8d4 diff --git a/lisp/riece-filter.el b/lisp/riece-filter.el index 64e917d..6c5f44c 100644 --- a/lisp/riece-filter.el +++ b/lisp/riece-filter.el @@ -28,14 +28,10 @@ (require 'riece-misc) (require 'riece-server) ;riece-close-server (require 'riece-identity) -(require 'riece-display) (defun riece-handle-numeric-reply (prefix number name string) (let ((base-number (* (/ number 100) 100)) function) - (condition-case nil - (require (intern (format "riece-%03d" base-number))) - (error)) (setq function (intern-soft (format "riece-handle-%03d-message" number))) (unless (and function (symbol-function function)) @@ -49,16 +45,7 @@ (riece-decode-coding-string string)) (error (if riece-debug - (message "Error occurred in `%S': %S" function error))))))) - -(defun riece-default-handle-numeric-reply - (client-prefix prefix number name string) - (riece-insert - (list riece-dialogue-buffer riece-others-buffer) - (concat client-prefix - (riece-concat-server-name - (mapconcat #'identity (riece-split-parameters string) " ")) - "\n"))) + (message "Error in `%S': %S" function error))))))) (defun riece-handle-message (prefix message string) (if (and prefix @@ -75,19 +62,19 @@ (run-hook-with-args-until-success hook prefix string) (error (if riece-debug - (message "Error occurred in `%S': %S" hook error)) + (message "Error in `%S': %S" hook error)) nil)) (if function (condition-case error (funcall function prefix string) (error (if riece-debug - (message "Error occurred in `%S': %S" function error))))) + (message "Error in `%S': %S" function error))))) (condition-case error (run-hook-with-args-until-success after-hook prefix string) (error (if riece-debug - (message "Error occurred in `%S': %S" after-hook error))))))) + (message "Error in `%S': %S" after-hook error))))))) (defun riece-filter (process input) (save-excursion @@ -100,29 +87,27 @@ (goto-char (prog1 riece-read-point (setq riece-read-point (point)))) (beginning-of-line) - (catch 'contiguous - (while (not (eobp)) - (save-excursion - (if (looking-at - ":\\([^ ]+\\) +\\([0-5][0-9][0-9]\\) +\\([^ ]+\\) +\\(.*\\)\r\n") - (riece-handle-numeric-reply - (match-string 1) ;prefix - (string-to-number (match-string 2)) ;number - (match-string 3) ;name - (match-string 4)) ;reply string - (if (looking-at "\\(:\\([^ ]+\\) +\\)?\\([^ ]+\\) +\\(.*\\)\r\n") - (riece-handle-message - (match-string 2) ;optional prefix - (match-string 3) ;command - (match-string 4)) ;params & trailing - (if (looking-at ".*\r\n") - (if riece-debug - (message "Weird message from server: %s" - (buffer-substring (point) (progn - (end-of-line) - (point))))) - (throw 'contiguous nil))))) - (forward-line))))) + (while (and (not (eobp)) + (looking-at ".*\r\n")) ;the input line is not finished + (save-excursion + (if (looking-at + ":\\([^ ]+\\) +\\([0-5][0-9][0-9]\\) +\\([^ ]+\\) +\\(.*\\)\r\n") + (riece-handle-numeric-reply + (match-string 1) ;prefix + (string-to-number (match-string 2)) ;number + (match-string 3) ;name + (match-string 4)) ;reply string + (if (looking-at "\\(:\\([^ ]+\\) +\\)?\\([^ ]+\\) +\\(.*\\)\r\n") + (riece-handle-message + (match-string 2) ;optional prefix + (match-string 3) ;command + (match-string 4)) ;params & trailing + (if riece-debug + (message "Weird message from server: %s" + (buffer-substring (point) (progn + (end-of-line) + (point)))))))) + (forward-line)))) (eval-when-compile (autoload 'riece-exit "riece")) @@ -156,7 +141,10 @@ (riece-part-channel (car channels))) (setq channels (cdr channels)))) (riece-redisplay-buffers) - (riece-close-server-process process)))) + (riece-close-server-process process) + ;; If no server process is available, exit. + (unless riece-server-process-alist + (riece-exit))))) (provide 'riece-filter)