diff options
author | Julien Danjou <julien@danjou.info> | 2010-10-23 12:35:22 -0700 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2010-10-23 12:35:22 -0700 |
commit | 6bb55f7cb0258425ff49bd65533aeb16a58afb67 (patch) | |
tree | 19198e97271f452f4a6f83ccae20a9ed6ae38d9e /lisp/erc | |
parent | 0d0d9424a23a1fd11c96b7aa5bba80c88758ddfa (diff) | |
download | emacs-6bb55f7cb0258425ff49bd65533aeb16a58afb67.tar.gz |
* lisp/erc/erc-backend.el (erc-process-sentinel): Check that buffer is alive
before setting it as current buffer.
Diffstat (limited to 'lisp/erc')
-rw-r--r-- | lisp/erc/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/erc/erc-backend.el | 49 |
2 files changed, 30 insertions, 24 deletions
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index 4568b598a3b..4143893008f 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog @@ -1,3 +1,8 @@ +2010-10-23 Julien Danjou <julien@danjou.info> + + * erc-backend.el (erc-process-sentinel): Check that buffer is alive + before setting it as current buffer. + 2010-10-12 Juanma Barranquero <lekktu@gmail.com> * erc-xdcc.el (erc-xdcc-help-text): Fix typo in docstring. diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 8b533b4c255..92b1c761a30 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -652,30 +652,31 @@ Conditionally try to reconnect and take appropriate action." (defun erc-process-sentinel (cproc event) "Sentinel function for ERC process." - (with-current-buffer (process-buffer cproc) - (erc-log (format - "SENTINEL: proc: %S status: %S event: %S (quitting: %S)" - cproc (process-status cproc) event erc-server-quitting)) - (if (string-match "^open" event) - ;; newly opened connection (no wait) - (erc-login) - ;; assume event is 'failed - (let ((buf (process-buffer cproc))) - (erc-with-all-buffers-of-server cproc nil - (setq erc-server-connected nil)) - (when erc-server-ping-handler - (progn (erc-cancel-timer erc-server-ping-handler) - (setq erc-server-ping-handler nil))) - (run-hook-with-args 'erc-disconnected-hook - (erc-current-nick) (system-name) "") - ;; Remove the prompt - (goto-char (or (marker-position erc-input-marker) (point-max))) - (forward-line 0) - (erc-remove-text-properties-region (point) (point-max)) - (delete-region (point) (point-max)) - ;; Decide what to do with the buffer - ;; Restart if disconnected - (erc-process-sentinel-1 event buf))))) + (let ((buf (process-buffer cproc))) + (when (buffer-live-p buf) + (with-current-buffer buf + (erc-log (format + "SENTINEL: proc: %S status: %S event: %S (quitting: %S)" + cproc (process-status cproc) event erc-server-quitting)) + (if (string-match "^open" event) + ;; newly opened connection (no wait) + (erc-login) + ;; assume event is 'failed + (erc-with-all-buffers-of-server cproc nil + (setq erc-server-connected nil)) + (when erc-server-ping-handler + (progn (erc-cancel-timer erc-server-ping-handler) + (setq erc-server-ping-handler nil))) + (run-hook-with-args 'erc-disconnected-hook + (erc-current-nick) (system-name) "") + ;; Remove the prompt + (goto-char (or (marker-position erc-input-marker) (point-max))) + (forward-line 0) + (erc-remove-text-properties-region (point) (point-max)) + (delete-region (point) (point-max)) + ;; Decide what to do with the buffer + ;; Restart if disconnected + (erc-process-sentinel-1 event buf)))))) ;;;; Sending messages |