From: Julien Danjou <julien@danjou.info>
To: emacs-devel@gnu.org
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH] erc: check that buffer is alive in sentinel
Date: Sat, 23 Oct 2010 14:43:00 +0200 [thread overview]
Message-ID: <1287837780-14235-1-git-send-email-julien@danjou.info> (raw)
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/erc/ChangeLog | 5 ++++
lisp/erc/erc-backend.el | 49 ++++++++++++++++++++++++-----------------------
2 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index 81bdf54..3443e3b 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-14 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 9a237d4..65d8ce1 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -653,30 +653,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
--
1.7.2.3
next reply other threads:[~2010-10-23 12:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-23 12:43 Julien Danjou [this message]
2010-10-23 19:34 ` [PATCH] erc: check that buffer is alive in sentinel Glenn Morris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287837780-14235-1-git-send-email-julien@danjou.info \
--to=julien@danjou.info \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.