aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
diff options
context:
space:
mode:
authorSam Steingold2014-05-09 13:04:46 -0400
committerSam Steingold2014-05-09 13:04:46 -0400
commitf36f0bca381402745550aed8ccfd8e447efb1dd8 (patch)
treed56e024d6f35509bb2fbaa9ee3f757d5e2da52b0 /lisp/net
parent8e45f27f7e5bc74eb5ce035dff6ab22fb0f9dd20 (diff)
downloademacs-f36f0bca381402745550aed8ccfd8e447efb1dd8.tar.gz
emacs-f36f0bca381402745550aed8ccfd8e447efb1dd8.zip
Optionally auto-reconnect depending on `rcirc-reconnect-delay'.
* net/rcirc.el (rcirc-reconnect-delay): New user option. (rcirc-sentinel): Auto-reconnect to the server if `rcirc-reconnect-delay' is non-0 (but not more often than its value in case the host is off-line).
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/rcirc.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 5a75617c485..346c885fda4 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -658,6 +658,15 @@ is non-nil."
658 "Hook functions called when the process sentinel is called. 658 "Hook functions called when the process sentinel is called.
659Functions are called with PROCESS and SENTINEL arguments.") 659Functions are called with PROCESS and SENTINEL arguments.")
660 660
661(defcustom rcirc-reconnect-delay 0
662 "*The minimum interval in seconds between reconnect attempts.
663When 0, do not auto-reconnect."
664 :type 'integer
665 :group 'rcirc)
666
667(defvar rcirc-last-connect-time nil
668 "The last time the buffer was connected.")
669
661(defun rcirc-sentinel (process sentinel) 670(defun rcirc-sentinel (process sentinel)
662 "Called when PROCESS receives SENTINEL." 671 "Called when PROCESS receives SENTINEL."
663 (let ((sentinel (replace-regexp-in-string "\n" "" sentinel))) 672 (let ((sentinel (replace-regexp-in-string "\n" "" sentinel)))
@@ -671,6 +680,14 @@ Functions are called with PROCESS and SENTINEL arguments.")
671 sentinel 680 sentinel
672 (process-status process)) (not rcirc-target)) 681 (process-status process)) (not rcirc-target))
673 (rcirc-disconnect-buffer))) 682 (rcirc-disconnect-buffer)))
683 (when (and (string= sentinel "deleted")
684 (< 0 rcirc-reconnect-delay))
685 (let ((now (current-time)))
686 (when (or (null rcirc-last-connect-time)
687 (< rcirc-reconnect-delay
688 (float-time (time-subtract now rcirc-last-connect-time))))
689 (setq sds-rcirc-sentinel-last now)
690 (rcirc-cmd-reconnect nil))))
674 (run-hook-with-args 'rcirc-sentinel-functions process sentinel)))) 691 (run-hook-with-args 'rcirc-sentinel-functions process sentinel))))
675 692
676(defun rcirc-disconnect-buffer (&optional buffer) 693(defun rcirc-disconnect-buffer (&optional buffer)
@@ -1007,6 +1024,7 @@ This number is independent of the number of lines in the buffer.")
1007 (setq-local fill-paragraph-function 'rcirc-fill-paragraph) 1024 (setq-local fill-paragraph-function 'rcirc-fill-paragraph)
1008 (setq-local rcirc-recent-quit-alist nil) 1025 (setq-local rcirc-recent-quit-alist nil)
1009 (setq-local rcirc-current-line 0) 1026 (setq-local rcirc-current-line 0)
1027 (setq-local rcirc-last-connect-time (current-time))
1010 1028
1011 (use-hard-newlines t) 1029 (use-hard-newlines t)
1012 (setq-local rcirc-short-buffer-name nil) 1030 (setq-local rcirc-short-buffer-name nil)