erc-commit
[Top][All Lists]
Advanced

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

[Erc-commit] [commit][emacs22] Add /RECONNECT command


From: mwolson
Subject: [Erc-commit] [commit][emacs22] Add /RECONNECT command
Date: Sun, 14 Oct 2007 00:48:36 -0400

commit 7bc088a743aa51e23d97367b53397d9acb850577
Author: Michael Olson <address@hidden>
Date:   Wed Dec 27 00:37:43 2006 +0000

    Add /RECONNECT command
    
    2006-12-27  Michael Olson  <address@hidden>
    
        * erc.el (erc-cmd-RECONNECT): New command which is an alias to
        erc-server-reconnect.
    
        * erc-backend.el (erc-server-reconnect): New function that
        reestablishes the current IRC connection.
        (erc-process-sentinel-1): Use it.
        (erc-server-reconnect-p): Move higher.
    
        * erc.texi (Getting Started): Update for /RECONNECT command.
    git-archimport-id: address@hidden/erc--main--0--patch-72

diff --git a/ChangeLog b/ChangeLog
index 2c8c8b2..c030889 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-12-27  Michael Olson  <address@hidden>
+
+       * erc.el (erc-cmd-RECONNECT): New command which is an alias to
+       erc-server-reconnect.
+
+       * erc-backend.el (erc-server-reconnect): New function that
+       reestablishes the current IRC connection.
+       (erc-process-sentinel-1): Use it.
+       (erc-server-reconnect-p): Move higher.
+
+       * erc.texi (Getting Started): Update for /RECONNECT command.
+
 2006-12-26  Michael Olson  <address@hidden>
 
        * erc.el (erc-open): Restore old point correctly, or at least get
diff --git a/erc-backend.el b/erc-backend.el
index 086335f..67cc21a 100644
--- a/erc-backend.el
+++ b/erc-backend.el
@@ -500,6 +500,17 @@ We will store server variables in the buffer given by 
BUFFER."
       (erc-display-message nil nil buffer "Opening connection..\n")
     (erc-login)))
 
+(defun erc-server-reconnect ()
+"Reestablish the current IRC connection.
+Make sure you are in an ERC buffer when running this."
+  (let ((server (erc-server-buffer)))
+    (unless (and server
+                 (buffer-live-p server))
+      (error "Couldn't switch to server buffer"))
+    (with-current-buffer server
+      (erc-open erc-session-server erc-session-port erc-server-current-nick
+                erc-session-user-full-name t erc-session-password))))
+
 (defun erc-server-filter-function (process string)
   "The process filter for the ERC server."
   (with-current-buffer (process-buffer process)
@@ -529,6 +540,16 @@ We will store server variables in the buffer given by 
BUFFER."
                                (match-end 0))))
             (erc-parse-server-response process line)))))))
 
+(defun erc-server-reconnect-p (event)
+  "Return non-nil if ERC should attempt to reconnect automatically.
+EVENT is the message received from the closed connection process."
+  (and erc-server-auto-reconnect
+       (not erc-server-banned)
+       (or erc-server-timed-out
+           (not (string-match "^deleted" event)))
+       ;; open-network-stream-nowait error for connection refused
+       (not (string-match "^failed with code 111" event))))
+
 (defun erc-process-sentinel-1 (event)
   "Called when `erc-process-sentinel' has decided that we're disconnecting.
 Determine whether user has quit or whether erc has been terminated.
@@ -550,24 +571,11 @@ Conditionally try to reconnect and take appropriate 
action."
     (setq erc-server-last-sent-time 0)
     (setq erc-server-lines-sent 0)
     (if (erc-server-reconnect-p event)
-        ;; Yuck, this should perhaps funcall
-        ;; erc-server-reconnect-function with no args
-        (erc-open erc-session-server erc-session-port erc-server-current-nick
-                  erc-session-user-full-name t erc-session-password)
+        (erc-server-reconnect)
       ;; terminate, do not reconnect
       (erc-display-message nil 'error (current-buffer)
                            'terminated ?e event))))
 
-(defun erc-server-reconnect-p (event)
-  "Return non-nil if ERC should attempt to reconnect automatically.
-EVENT is the message received from the closed connection process."
-  (and erc-server-auto-reconnect
-       (not erc-server-banned)
-       (or erc-server-timed-out
-           (not (string-match "^deleted" event)))
-       ;; open-network-stream-nowait error for connection refused
-       (not (string-match "^failed with code 111" event))))
-
 (defun erc-process-sentinel (cproc event)
   "Sentinel function for ERC process."
   (with-current-buffer (process-buffer cproc)
diff --git a/erc.el b/erc.el
index 8be1a71..77d2faa 100644
--- a/erc.el
+++ b/erc.el
@@ -3195,6 +3195,8 @@ the message given by REASON."
 (defalias 'erc-cmd-GQ 'erc-cmd-GQUIT)
 (put 'erc-cmd-GQUIT 'do-not-parse-args t)
 
+(defalias 'erc-cmd-RECONNECT 'erc-server-reconnect)
+
 (defun erc-cmd-SERVER (server)
   "Connect to SERVER, leaving existing connection intact."
   (erc-log (format "cmd: SERVER: %s" server))
diff --git a/erc.texi b/erc.texi
index 2a28e5b..1c203cd 100644
--- a/erc.texi
+++ b/erc.texi
@@ -279,6 +279,11 @@ itself.  An example follows.
 Once ERC is loaded, the command @kbd{M-x erc} will start ERC and
 prompt for the server to connect to.
 
+If the connection goes away at some point, ERC will try to reconnect
+automatically.  If it fails to reconnect, and you want to try to
+manually reestablish the connection at some later point, switch to an
+ERC buffer and run the /RECONNECT command.
+
 @c PRE5_2: Sample session, including:
 @c - connect to Freenode
 @c - /join #emacs




reply via email to

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