emacs-diffs
[Top][All Lists]
Advanced

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

feature/rcirc-update 4a0c0e5: Allow /reconnect while connecting


From: Philip Kaludercic
Subject: feature/rcirc-update 4a0c0e5: Allow /reconnect while connecting
Date: Tue, 7 Sep 2021 04:33:59 -0400 (EDT)

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

    Allow /reconnect while connecting
    
    * rcirc.el (reconnect): Kill previous process and start a new one
---
 lisp/net/rcirc.el | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 1637041..5236f96 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -2572,17 +2572,22 @@ to `rcirc-default-part-reason'."
   "Reconnect to current server."
   (interactive "i")
   (with-rcirc-server-buffer
-    (cond
-     (rcirc-connecting (message "Already connecting"))
-     ((process-live-p process) (message "Server process is alive"))
-     (t (let ((conn-info rcirc-connection-info))
-         (setf (nth 5 conn-info)
-               (cl-remove-if-not #'rcirc-channel-p
-                                 (mapcar #'car rcirc-buffer-alist)))
-          (dolist (buf (nth 5 conn-info))
-            (with-current-buffer (cdr (assoc buf rcirc-buffer-alist))
-              (setq rcirc-reconncting t)))
-         (apply #'rcirc-connect conn-info))))))
+    (catch 'exit
+      (cond
+       (rcirc-connecting
+        (when (process-live-p process)
+          (kill-process process))
+        (setq rcirc-connecting nil))
+       ((process-live-p process)
+        (throw 'exit (message "Server process is alive"))))
+      (let ((conn-info rcirc-connection-info))
+       (setf (nth 5 conn-info)
+             (cl-remove-if-not #'rcirc-channel-p
+                               (mapcar #'car rcirc-buffer-alist)))
+        (dolist (buf (nth 5 conn-info))
+          (with-current-buffer (cdr (assoc buf rcirc-buffer-alist))
+            (setq rcirc-reconncting t)))
+       (apply #'rcirc-connect conn-info)))))
 
 (rcirc-define-command nick (nick)
   "Change nick to NICK."



reply via email to

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