emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/rcirc-update 1181c60 8/8: Check if server buffer is live


From: Philip Kaludercic
Subject: feature/rcirc-update 1181c60 8/8: Check if server buffer is live
Date: Tue, 15 Jun 2021 12:46:43 -0400 (EDT)

branch: feature/rcirc-update
commit 1181c606b3ff76488c068ce057cd7596e6c49cea
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    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 36a46dd..dfa80bb 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]