bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#17045: 24.3.50; feature request: rcirc-reconnect


From: Leo Liu
Subject: bug#17045: 24.3.50; feature request: rcirc-reconnect
Date: Tue, 08 Apr 2014 16:33:18 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (CentOS 6.5)

On 2014-03-20 10:33 +0800, Sam Steingold wrote:
> It is not nice to have to do M-x rcirc whenever the connection dies.
> Would it be possible to incorporate something similar to
> http://www.emacswiki.org/emacs/rcircReconnect
> Please?
>
> In GNU Emacs 24.3.50.1 (x86_64-apple-darwin13.1.0, NS apple-appkit-1265.19)
>  of 2014-03-18 on sds-MacBook-Pro.local
> Windowing system distributor `Apple', version 10.3.1265
> Configured using:
>  `configure --with-ns'

Hi Sam,

Would something like this suit your needs? Thanks for testing. - Leo

=== modified file 'lisp/net/rcirc.el'
--- lisp/net/rcirc.el   2014-04-08 03:32:37 +0000
+++ lisp/net/rcirc.el   2014-04-08 08:27:11 +0000
@@ -521,6 +521,7 @@
 (defvar rcirc-user-authenticated nil)
 (defvar rcirc-user-disconnect nil)
 (defvar rcirc-connecting nil)
+(defvar rcirc-connection-info nil)
 (defvar rcirc-process nil)
 
 ;;;###autoload
@@ -549,22 +550,23 @@
       (set-process-sentinel process 'rcirc-sentinel)
       (set-process-filter process 'rcirc-filter)
 
-      (set (make-local-variable 'rcirc-process) process)
-      (set (make-local-variable 'rcirc-server) server)
-      (set (make-local-variable 'rcirc-server-name) server) ; Update when we 
get 001 response.
-      (set (make-local-variable 'rcirc-buffer-alist) nil)
-      (set (make-local-variable 'rcirc-nick-table)
-           (make-hash-table :test 'equal))
-      (set (make-local-variable 'rcirc-nick) nick)
-      (set (make-local-variable 'rcirc-process-output) nil)
-      (set (make-local-variable 'rcirc-startup-channels) startup-channels)
-      (set (make-local-variable 'rcirc-last-server-message-time)
-           (current-time))
-
-      (set (make-local-variable 'rcirc-timeout-timer) nil)
-      (set (make-local-variable 'rcirc-user-disconnect) nil)
-      (set (make-local-variable 'rcirc-user-authenticated) nil)
-      (set (make-local-variable 'rcirc-connecting) t)
+      (setq-local rcirc-connection-info
+                 (list server port nick user-name full-name startup-channels
+                       password encryption))
+      (setq-local rcirc-process process)
+      (setq-local rcirc-server server)
+      (setq-local rcirc-server-name server) ; Update when we get 001 response.
+      (setq-local rcirc-buffer-alist nil)
+      (setq-local rcirc-nick-table (make-hash-table :test 'equal))
+      (setq-local rcirc-nick nick)
+      (setq-local rcirc-process-output nil)
+      (setq-local rcirc-startup-channels startup-channels)
+      (setq-local rcirc-last-server-message-time (current-time))
+
+      (setq-local rcirc-timeout-timer nil)
+      (setq-local rcirc-user-disconnect nil)
+      (setq-local rcirc-user-authenticated nil)
+      (setq-local rcirc-connecting t)
 
       (add-hook 'auto-save-hook 'rcirc-log-write)
 
@@ -782,11 +784,11 @@
 (defun rcirc-buffer-process (&optional buffer)
   "Return the process associated with channel BUFFER.
 With no argument or nil as argument, use the current buffer."
-  (or (get-buffer-process (if buffer
-                             (with-current-buffer buffer
-                               rcirc-server-buffer)
-                           rcirc-server-buffer))
-      rcirc-process))
+  (let ((buffer (or buffer (if (buffer-live-p rcirc-server-buffer)
+                              rcirc-server-buffer
+                            (error "Server buffer deleted")))))
+    (or (with-current-buffer buffer rcirc-process)
+       rcirc-process)))
 
 (defun rcirc-server-name (process)
   "Return PROCESS server name, given by the 001 response."
@@ -2210,6 +2212,17 @@
                                         reason
                                       rcirc-id-string))))
 
+(defun-rcirc-command reconnect (_)
+  "Reconnect to current server."
+  (interactive "i")
+  (with-rcirc-server-buffer
+    (unless (or rcirc-connecting (process-live-p process))
+      (let ((conn-info (copy-sequence rcirc-connection-info)))
+       (setf (nth 5 conn-info)
+             (cl-remove-if-not #'rcirc-channel-p
+                               (mapcar #'car rcirc-buffer-alist)))
+       (apply #'rcirc-connect conn-info)))))
+
 (defun-rcirc-command nick (nick)
   "Change nick to NICK."
   (interactive "i")






reply via email to

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