From: Philip Kaludercic Date: Tue, 7 Sep 2021 08:33:51 +0000 (+0200) Subject: Allow /reconnect while connecting X-Git-Tag: emacs-28.0.90~948^2~19 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4a0c0e5606f13ac023a44b2c75f86df055e4864d;p=emacs.git Allow /reconnect while connecting * rcirc.el (reconnect): Kill previous process and start a new one --- diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 1637041bb17..5236f96b09f 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."