From 1181c606b3ff76488c068ce057cd7596e6c49cea Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Tue, 15 Jun 2021 18:16:58 +0200 Subject: [PATCH] Check if server buffer is live * rcirc.el (with-rcirc-server-buffer): Use live-buffer-p (rcirc-buffer-nick): Use with-rcirc-server-buffer (rcirc-switch-to-server-buffer): Use with-rcirc-server-buffer --- lisp/net/rcirc.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 36a46dd208a..dfa80bb4089 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -681,8 +681,10 @@ that are joined after authentication." (defmacro with-rcirc-server-buffer (&rest body) "Evaluate BODY in the server buffer of the current channel." (declare (indent 0) (debug t)) - `(with-current-buffer rcirc-server-buffer - ,@body)) + `(if (buffer-live-p rcirc-server-buffer) + (with-current-buffer rcirc-server-buffer + ,@body) + (user-error "Server buffer was killed"))) (define-obsolete-function-alias 'rcirc-float-time 'float-time "26.1") @@ -1037,7 +1039,7 @@ With no argument or nil as argument, use the current buffer." "Return the nick associated with BUFFER. With no argument or nil as argument, use the current buffer." (with-current-buffer (or buffer (current-buffer)) - (with-current-buffer rcirc-server-buffer + (with-rcirc-server-buffer (or rcirc-nick rcirc-default-nick)))) (defvar rcirc-max-message-length 420 @@ -2132,9 +2134,7 @@ This function does not alter the INPUT string." (defun rcirc-switch-to-server-buffer () "Switch to the server buffer associated with current channel buffer." (interactive) - (unless (buffer-live-p rcirc-server-buffer) - (error "No such buffer")) - (switch-to-buffer rcirc-server-buffer)) + (switch-to-buffer (with-rcirc-server-buffer (current-buffer)))) (defun rcirc-jump-to-first-unread-line () "Move the point to the first unread line in this buffer." -- 2.39.2