* bug#17045: 24.3.50; feature request: rcirc-reconnect
@ 2014-03-20 2:33 Sam Steingold
2014-04-08 8:33 ` Leo Liu
0 siblings, 1 reply; 12+ messages in thread
From: Sam Steingold @ 2014-03-20 2:33 UTC (permalink / raw
To: 17045
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'
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ https://www.facebook.com/TheIslamicThreat
http://camera.org http://americancensorship.org http://ffii.org
Yellow wine is called "white" because it is made out of green grapes.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-03-20 2:33 bug#17045: 24.3.50; feature request: rcirc-reconnect Sam Steingold
@ 2014-04-08 8:33 ` Leo Liu
2014-04-08 9:33 ` Daimrod
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Leo Liu @ 2014-04-08 8:33 UTC (permalink / raw
To: Sam Steingold; +Cc: 17045
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")
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-08 8:33 ` Leo Liu
@ 2014-04-08 9:33 ` Daimrod
2014-04-08 11:52 ` Leo Liu
2014-04-09 21:22 ` Sam Steingold
2014-05-07 17:57 ` Sam Steingold
2 siblings, 1 reply; 12+ messages in thread
From: Daimrod @ 2014-04-08 9:33 UTC (permalink / raw
To: Leo Liu; +Cc: 17045, Sam Steingold
[-- Attachment #1: Type: text/plain, Size: 863 bytes --]
Leo Liu <sdl.web@gmail.com> writes:
> 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
It would be nice if a hook was run with the old and the new process as
arguments.
For example, shoes-off[1] would need it to update the process plist and
its inner structures.
1: https://github.com/nicferrier/shoes-off
--
Daimrod/Greg
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-08 9:33 ` Daimrod
@ 2014-04-08 11:52 ` Leo Liu
2014-04-08 14:03 ` Daimrod
0 siblings, 1 reply; 12+ messages in thread
From: Leo Liu @ 2014-04-08 11:52 UTC (permalink / raw
To: Daimrod; +Cc: 17045, Sam Steingold
On 2014-04-08 17:33 +0800, Daimrod wrote:
> It would be nice if a hook was run with the old and the new process as
> arguments.
>
> For example, shoes-off[1] would need it to update the process plist and
> its inner structures.
>
> 1: https://github.com/nicferrier/shoes-off
Please give more details about what it does and the requirements to
support it. I probably won't have time to try 3rd party code.
Thanks,
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-08 11:52 ` Leo Liu
@ 2014-04-08 14:03 ` Daimrod
2014-04-09 21:17 ` Sam Steingold
0 siblings, 1 reply; 12+ messages in thread
From: Daimrod @ 2014-04-08 14:03 UTC (permalink / raw
To: Leo Liu; +Cc: 17045, Sam Steingold
[-- Attachment #1: Type: text/plain, Size: 1379 bytes --]
Leo Liu <sdl.web@gmail.com> writes:
> On 2014-04-08 17:33 +0800, Daimrod wrote:
>> It would be nice if a hook was run with the old and the new process as
>> arguments.
>>
>> For example, shoes-off[1] would need it to update the process plist and
>> its inner structures.
>>
>> 1: https://github.com/nicferrier/shoes-off
>
> Please give more details about what it does and the requirements to
> support it. I probably won't have time to try 3rd party code.
Shoes-off is an IRC bouncer built on top of RCIRC. So basically, it uses
RCIRC to connect to IRC servers and listen on a specific port for
clients. When a clients connect, it is as if it was connected to the IRC
servers. To do that, shoes-off "binds" RCIRC processes to a client
connection and it uses process-plist to store this kind of information.
However, when a RCIRC connection is restarted, AFAIK it just means that
a new connection is established. So, from shoes-off's POV, the previous
RCIRC process is dead, hence it can not continue to forward the messages
between the RCIRC connection and the client.
That's why I would like a way to be notified when a RCIRC process is
replaced so that shoes-off can update the connections information. But
to do that, I would probably need more that just a notification, I would
need the old and the new process.
Best,
--
Daimrod/Greg
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-08 14:03 ` Daimrod
@ 2014-04-09 21:17 ` Sam Steingold
2014-04-10 0:47 ` Daimrod
0 siblings, 1 reply; 12+ messages in thread
From: Sam Steingold @ 2014-04-09 21:17 UTC (permalink / raw
To: Daimrod; +Cc: 17045, Leo Liu
> * Daimrod <qnvzebq@tznvy.pbz> [2014-04-08 23:03:45 +0900]:
>
> That's why I would like a way to be notified when a RCIRC process is
> replaced so that shoes-off can update the connections information.
would rcirc-reconnect-hook be enough?
> But to do that, I would probably need more that just a notification, I
> would need the old and the new process.
I am afraid the old process is dead and discarded by this time.
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://palestinefacts.org
http://islamexposedonline.com http://truepeace.org http://dhimmi.com
Murphy's Law was probably named after the wrong guy.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-08 8:33 ` Leo Liu
2014-04-08 9:33 ` Daimrod
@ 2014-04-09 21:22 ` Sam Steingold
2014-05-07 17:57 ` Sam Steingold
2 siblings, 0 replies; 12+ messages in thread
From: Sam Steingold @ 2014-04-09 21:22 UTC (permalink / raw
To: Leo Liu; +Cc: 17045
Hi Leo,
> * Leo Liu <fqy.jro@tznvy.pbz> [2014-04-08 16:33:18 +0800]:
>
> Would something like this suit your needs? Thanks for testing. - Leo
looks good, except that you might want to avoid mixing functional
changes with cosmetic ones (setq-local & rcirc-buffer-process).
thanks!
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://honestreporting.com http://palestinefacts.org
http://memri.org https://www.facebook.com/TheIslamicThreat http://truepeace.org
If Microsoft wrote poetry, it would have patented dactyl and anapest.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-09 21:17 ` Sam Steingold
@ 2014-04-10 0:47 ` Daimrod
2014-04-10 4:41 ` Leo Liu
0 siblings, 1 reply; 12+ messages in thread
From: Daimrod @ 2014-04-10 0:47 UTC (permalink / raw
To: Sam Steingold; +Cc: 17045, Leo Liu
Sam Steingold <sds@gnu.org> writes:
>> * Daimrod <qnvzebq@tznvy.pbz> [2014-04-08 23:03:45 +0900]:
>>
>> That's why I would like a way to be notified when a RCIRC process is
>> replaced so that shoes-off can update the connections information.
>
> would rcirc-reconnect-hook be enough?
>
>> But to do that, I would probably need more that just a notification, I
>> would need the old and the new process.
>
> I am afraid the old process is dead and discarded by this time.
Hmm, does the new process use the same buffer or does it create a new
one?
I'm trying to find a way to identify which RCIRC process is replaced.
Simply checking which connection is dead is probably not enough in case
more than one conections dropped at the same time.
--
Daimrod/Greg
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-10 0:47 ` Daimrod
@ 2014-04-10 4:41 ` Leo Liu
2014-04-10 5:07 ` Daimrod
0 siblings, 1 reply; 12+ messages in thread
From: Leo Liu @ 2014-04-10 4:41 UTC (permalink / raw
To: Daimrod; +Cc: 17045, Sam Steingold
On 2014-04-10 08:47 +0800, Daimrod wrote:
> Hmm, does the new process use the same buffer or does it create a new
> one?
>
> I'm trying to find a way to identify which RCIRC process is replaced.
> Simply checking which connection is dead is probably not enough in case
> more than one conections dropped at the same time.
When users kick off /reconnect it will find the connection info in the
server buffer and fire off rcirc-connect which will reuse the buffer if
I am not mistaken.
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-10 4:41 ` Leo Liu
@ 2014-04-10 5:07 ` Daimrod
0 siblings, 0 replies; 12+ messages in thread
From: Daimrod @ 2014-04-10 5:07 UTC (permalink / raw
To: Leo Liu; +Cc: 17045, Sam Steingold
[-- Attachment #1: Type: text/plain, Size: 605 bytes --]
Leo Liu <sdl.web@gmail.com> writes:
> On 2014-04-10 08:47 +0800, Daimrod wrote:
>> Hmm, does the new process use the same buffer or does it create a new
>> one?
>>
>> I'm trying to find a way to identify which RCIRC process is replaced.
>> Simply checking which connection is dead is probably not enough in case
>> more than one conections dropped at the same time.
>
> When users kick off /reconnect it will find the connection info in the
> server buffer and fire off rcirc-connect which will reuse the buffer if
> I am not mistaken.
Ok, then it's doable.
Best,
--
Daimrod/Greg
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-04-08 8:33 ` Leo Liu
2014-04-08 9:33 ` Daimrod
2014-04-09 21:22 ` Sam Steingold
@ 2014-05-07 17:57 ` Sam Steingold
2014-05-08 1:58 ` Leo Liu
2 siblings, 1 reply; 12+ messages in thread
From: Sam Steingold @ 2014-05-07 17:57 UTC (permalink / raw
To: Leo Liu; +Cc: 17045
Hi Leo,
> * Leo Liu <fqy.jro@tznvy.pbz> [2014-04-08 16:33:18 +0800]:
>
> 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
>
> Would something like this suit your needs? Thanks for testing. - Leo
This indeed enables me to auto-reconnect like this:
--8<---------------cut here---------------start------------->8---
(defvar sds-rcirc-sentinel-last (current-time) "last reconnect attempt time")
(defun sds-rcirc-sentinel (process sentinel)
(let* ((now (current-time))
(delay (float-time (time-subtract (current-time)
sds-rcirc-sentinel-last))))
(message "%s sds-rcirc-sentinel: %s %s %s (last: %s, %s ago)"
(format-time-string "%F %R") process
(process-status process) sentinel
(format-time-string "%F %R" sds-rcirc-sentinel-last)
(sds-difftime-to-string delay))
(when (and (string= sentinel "deleted")
(< 60 delay)) ; do not try to reconnect more than once a minute
(setq sds-rcirc-sentinel-last now)
(rcirc-cmd-reconnect nil))))
(add-hook 'rcirc-sentinel-functions 'sds-rcirc-sentinel)
--8<---------------cut here---------------end--------------->8---
However, I would much prefer to enable auto-reconnect by a simple
(custom-set-variables '(rcirc-reconnect-interval 60))
where rcirc-reconnect-interval = 0 means the current behavior (no
auto-reconnect).
Do you mind if I commit something based on the above or would you like
to implement it yourself?
Thanks a lot for your help!
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://think-israel.org http://mideasttruth.com
http://pmw.org.il http://honestreporting.com
There is an exception to every rule, including this one.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#17045: 24.3.50; feature request: rcirc-reconnect
2014-05-07 17:57 ` Sam Steingold
@ 2014-05-08 1:58 ` Leo Liu
0 siblings, 0 replies; 12+ messages in thread
From: Leo Liu @ 2014-05-08 1:58 UTC (permalink / raw
To: Sam Steingold; +Cc: 17045
On 2014-05-07 13:57 -0400, Sam Steingold wrote:
> Do you mind if I commit something based on the above?
Not at all. Please make the change and thanks ;)
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-05-08 1:58 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-20 2:33 bug#17045: 24.3.50; feature request: rcirc-reconnect Sam Steingold
2014-04-08 8:33 ` Leo Liu
2014-04-08 9:33 ` Daimrod
2014-04-08 11:52 ` Leo Liu
2014-04-08 14:03 ` Daimrod
2014-04-09 21:17 ` Sam Steingold
2014-04-10 0:47 ` Daimrod
2014-04-10 4:41 ` Leo Liu
2014-04-10 5:07 ` Daimrod
2014-04-09 21:22 ` Sam Steingold
2014-05-07 17:57 ` Sam Steingold
2014-05-08 1:58 ` Leo Liu
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.