From: ueno Date: Sat, 19 Feb 2005 06:59:10 +0000 (+0000) Subject: * riece-debug.el (riece-funcall-ignore-errors): New function. X-Git-Tag: riece-1_0_8~32 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e73817ff1c5852dae78de4e04d402ee8b402625;p=elisp%2Friece.git * riece-debug.el (riece-funcall-ignore-errors): New function. * riece-signal.el (riece-emit-signal): Use riece-funcall-ignore-errors. * riece-filter.el (riece-handle-numeric-reply): Use riece-funcall-ignore-errors. (riece-handle-message): Ditto. * riece-ctcp.el (riece-handle-ctcp-request): Use riece-funcall-ignore-errors. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dd78f3c..136d2af 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2005-02-19 Daiki Ueno + + * riece-debug.el (riece-funcall-ignore-errors): New function. + * riece-signal.el (riece-emit-signal): Use riece-funcall-ignore-errors. + * riece-filter.el (riece-handle-numeric-reply): Use + riece-funcall-ignore-errors. + (riece-handle-message): Ditto. + * riece-ctcp.el (riece-handle-ctcp-request): Use + riece-funcall-ignore-errors. + 2005-02-18 Steve Youngs * riece-ctcp.el (riece-handle-ctcp-time-request): New. diff --git a/lisp/riece-ctcp.el b/lisp/riece-ctcp.el index d7ffe6b..9bb7de3 100644 --- a/lisp/riece-ctcp.el +++ b/lisp/riece-ctcp.el @@ -77,8 +77,9 @@ (run-hook-with-args-until-success hook prefix (car targets) message)) (if function - (riece-ignore-errors (symbol-name function) - (funcall function prefix (car targets) message))) + (riece--funcall-ignore-errors (symbol-name function) + function prefix (car targets) + message)) (riece-ignore-errors (symbol-name after-hook) (run-hook-with-args-until-success after-hook prefix (car targets) message)))) @@ -222,8 +223,9 @@ (run-hook-with-args-until-success hook prefix (car targets) message)) (if function - (riece-ignore-errors (symbol-name function) - (funcall function prefix (car targets) message))) + (riece-funcall-ignore-errors + (symbol-name function) + function prefix (car targets) message)) (riece-ignore-errors (symbol-name after-hook) (run-hook-with-args-until-success after-hook prefix (car targets) message)))) diff --git a/lisp/riece-debug.el b/lisp/riece-debug.el index 6c1b051..d3132ce 100644 --- a/lisp/riece-debug.el +++ b/lisp/riece-debug.el @@ -27,12 +27,14 @@ (require 'riece-globals) (defun riece-debug-reset-standard-output () + "Reset `riece-temp-buffer' to be used as `standard-output'." (save-excursion (set-buffer riece-temp-buffer) (buffer-disable-undo) (erase-buffer))) (defmacro riece-debug-with-backtrace (&rest body) + "Execute BODY and send a backtrace to `riece-temp-buffer'." `(unwind-protect (progn ,@body) (riece-debug-reset-standard-output) @@ -43,6 +45,10 @@ (put 'riece-debug-with-backtrace 'edebug-form-spec '(form body)) (defmacro riece-ignore-errors (location &rest body) + "Execute BODY; if an error occurs, return nil. +Otherwise, return result of last FORM. +If `riece-debug' is non-nil and an error occurred, it sends a +backtrace to standard-output." `(condition-case error (if riece-debug (riece-debug-with-backtrace ,@body) @@ -60,6 +66,14 @@ (put 'riece-ignore-errors 'lisp-indent-function 1) (put 'riece-ignore-errors 'edebug-form-spec '(form body)) +(defun riece-funcall-ignore-errors (location function &rest args) + "Call FUNCTION with ARGS; if an error occurs, return nil. +Otherwise, return result of the function. +If `riece-debug' is non-nil and an error occurred, it sends a +backtrace to standard-output." + (riece-ignore-errors location + (apply function args))) + (provide 'riece-debug) ;;; riece-debug.el ends here diff --git a/lisp/riece-filter.el b/lisp/riece-filter.el index 39edd49..e02b4d4 100644 --- a/lisp/riece-filter.el +++ b/lisp/riece-filter.el @@ -41,9 +41,9 @@ (format "riece-handle-default-%03d-message" base-number)))) (if (and function (symbol-function function)) - (riece-ignore-errors (symbol-name function) - (funcall function prefix number name - (riece-decode-coding-string string)))))) + (riece-funcall-ignore-errors (symbol-name function) + function prefix number name + (riece-decode-coding-string string))))) (defun riece-handle-message (prefix message string) (if (and prefix @@ -59,8 +59,8 @@ (unless (riece-ignore-errors (symbol-name hook) (run-hook-with-args-until-success hook prefix string)) (if function - (riece-ignore-errors (symbol-name function) - (funcall function prefix string))) + (riece-funcall-ignore-errors (symbol-name function) + function prefix string)) (riece-ignore-errors (symbol-name after-hook) (run-hook-with-args-until-success after-hook prefix string))))) diff --git a/lisp/riece-signal.el b/lisp/riece-signal.el index 844c3cc..e972580 100644 --- a/lisp/riece-signal.el +++ b/lisp/riece-signal.el @@ -104,14 +104,15 @@ This function is for internal use only." (setq signal (riece-make-signal signal-name args) slots (symbol-value symbol)) (while slots - (riece-ignore-errors (format "slot function for \"%S\"" - signal-name) - (if (or (null (riece-slot-filter (car slots))) - (riece-ignore-errors (format "signal filter for \"%S\"" - signal-name) - (funcall (riece-slot-filter (car slots)) signal))) - (funcall (riece-slot-function (car slots)) - signal (riece-slot-handback (car slots))))) + (if (or (null (riece-slot-filter (car slots))) + (riece-ignore-errors (format "signal filter for \"%S\"" + signal-name) + (funcall (riece-slot-filter (car slots)) signal))) + (riece-funcall-ignore-errors (format "slot function for \"%S\"" + signal-name) + (riece-slot-function (car slots)) + signal + (riece-slot-handback (car slots)))) (setq slots (cdr slots)))))) (provide 'riece-signal)