unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* PATCH: Add the ability to give rcirc servers an alias name
@ 2015-11-07 23:00 Dave Barker
  2015-11-08 17:45 ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-11-07 23:00 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1322 bytes --]

Hello all,

First time contributing to Emacs (or at least attempting to), sorry if I'm
doing this wrong somehow.

I wanted the ability to give rcirc servers an alias name, to be displayed
instead of the actual server name. The reason is that I use the ZNC IRC
bouncer to connect to multiple servers and this means, as far as rcirc is
concerned, that I have 4+ servers with the same server name - my ZNC
server's hostname. This breaks rcirc, it won't let you connect to the same
server twice, but even if it did things would quickly get confusing. (Up
until now I've had to add bogus entries in my hosts file to point each IRC
server's hostname to my ZNC server, but that's clearly quite a hack!)

So the attached patch adds an optional :server-alias keyword parameter
to rcirc-server-alist that allows you to specify a friendlier name for a
rcirc server. The name is then used when messages are displayed, and for
buffer naming purposes. If not specified the real server name is used
instead just like before. (For people who are used to GitHub, here's my
feature branch <https://github.com/kzar/emacs/tree/rcirc-server-alias>.)

It would be great to get some feedback on this, the patch is working great
for me but I'm inexperienced with elisp and this is the first time I've had
a look at the rcirc code.

Cheers, Dave.

[-- Attachment #1.2: Type: text/html, Size: 1513 bytes --]

[-- Attachment #2: 0001-Add-ability-to-give-rcirc-servers-an-alias-name.patch --]
[-- Type: text/x-patch, Size: 4607 bytes --]

From cb54e4d668577c2e7d0d53b8bd54c7dcfc87f403 Mon Sep 17 00:00:00 2001
From: Dave Barker <kzar@kzar.co.uk>
Date: Sat, 7 Nov 2015 22:32:51 +0000
Subject: [PATCH] Add ability to give rcirc servers an alias name

---
 lisp/net/rcirc.el | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index d58f3eb..a309a47 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -103,7 +103,12 @@ connected to automatically.
 `:encryption'
 
 VALUE must be `plain' (the default) for unencrypted connections, or `tls'
-for connections using SSL/TLS."
+for connections using SSL/TLS.
+
+`:server-alias'
+
+VALUE must be a string that will be used instead of the server name for
+display purposes. If absent, the real server name will be displayed instead."
   :type '(alist :key-type string
 		:value-type (plist :options
                                    ((:nick string)
@@ -113,7 +118,8 @@ for connections using SSL/TLS."
                                     (:full-name string)
                                     (:channels (repeat string))
                                     (:encryption (choice (const tls)
-                                                         (const plain))))))
+                                                         (const plain)))
+                                    (:server-alias string))))
   :group 'rcirc)
 
 (defcustom rcirc-default-port 6667
@@ -484,17 +490,20 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (channels (plist-get (cdr c) :channels))
               (password (plist-get (cdr c) :password))
               (encryption (plist-get (cdr c) :encryption))
+              (server-alias (plist-get (cdr c) :server-alias))
               contact)
 	  (when server
 	    (let (connected)
 	      (dolist (p (rcirc-process-list))
-		(when (string= server (process-name p))
+		(when (string= (or server-alias server) (process-name p))
 		  (setq connected p)))
 	      (if (not connected)
 		  (condition-case nil
 		      (rcirc-connect server port nick user-name
-				     full-name channels password encryption)
-		    (quit (message "Quit connecting to %s" server)))
+                                     full-name channels password encryption
+                                     server-alias)
+		    (quit (message "Quit connecting to %s"
+                                   (or server-alias server))))
 		(with-current-buffer (process-buffer connected)
                   (setq contact (process-contact
                                  (get-buffer-process (current-buffer)) :host))
@@ -528,9 +537,10 @@ If ARG is non-nil, instead prompt for connection parameters."
 
 ;;;###autoload
 (defun rcirc-connect (server &optional port nick user-name
-                             full-name startup-channels password encryption)
+                             full-name startup-channels password encryption
+                             server-alias)
   (save-excursion
-    (message "Connecting to %s..." server)
+    (message "Connecting to %s..." (or server-alias server))
     (let* ((inhibit-eol-conversion)
            (port-number (if port
 			    (if (stringp port)
@@ -542,7 +552,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	   (full-name (or full-name rcirc-default-full-name))
 	   (startup-channels startup-channels)
            (process (open-network-stream
-                     server nil server port-number
+                     (or server-alias server) nil server port-number
                      :type (or encryption 'plain))))
       ;; set up process
       (set-process-coding-system process 'raw-text 'raw-text)
@@ -557,7 +567,8 @@ If ARG is non-nil, instead prompt for connection parameters."
 			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-server-name
+                  (or server-alias 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)
@@ -584,7 +595,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	(setq rcirc-keepalive-timer
 	      (run-at-time 0 (/ rcirc-timeout-seconds 2) 'rcirc-keepalive)))
 
-      (message "Connecting to %s...done" server)
+      (message "Connecting to %s...done" (or server-alias server))
 
       ;; return process object
       process)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-11-07 23:00 PATCH: Add the ability to give rcirc servers an alias name Dave Barker
@ 2015-11-08 17:45 ` Dave Barker
  2015-11-08 19:22   ` Artur Malabarba
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-11-08 17:45 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1648 bytes --]

Second try, reconnecting to servers now works again and the proper server
names are displayed.

(Also I forgot to mention before, patch applies
to ea88d874a4f3ecbfdb5fa79dcb3ea90927cebec2 )

Cheers, Dave.

On Sat, Nov 7, 2015 at 11:00 PM, Dave Barker <kzar@kzar.co.uk> wrote:

> Hello all,
>
> First time contributing to Emacs (or at least attempting to), sorry if I'm
> doing this wrong somehow.
>
> I wanted the ability to give rcirc servers an alias name, to be displayed
> instead of the actual server name. The reason is that I use the ZNC IRC
> bouncer to connect to multiple servers and this means, as far as rcirc is
> concerned, that I have 4+ servers with the same server name - my ZNC
> server's hostname. This breaks rcirc, it won't let you connect to the same
> server twice, but even if it did things would quickly get confusing. (Up
> until now I've had to add bogus entries in my hosts file to point each IRC
> server's hostname to my ZNC server, but that's clearly quite a hack!)
>
> So the attached patch adds an optional :server-alias keyword parameter
> to rcirc-server-alist that allows you to specify a friendlier name for a
> rcirc server. The name is then used when messages are displayed, and for
> buffer naming purposes. If not specified the real server name is used
> instead just like before. (For people who are used to GitHub, here's my
> feature branch <https://github.com/kzar/emacs/tree/rcirc-server-alias>.)
>
> It would be great to get some feedback on this, the patch is working great
> for me but I'm inexperienced with elisp and this is the first time I've had
> a look at the rcirc code.
>
> Cheers, Dave.
>

[-- Attachment #1.2: Type: text/html, Size: 2145 bytes --]

[-- Attachment #2: 0001-Add-ability-to-give-rcirc-servers-an-alias-name.patch --]
[-- Type: text/x-patch, Size: 5051 bytes --]

From 8e76f8dd43d137b23e3f43f61641ff26b45bb648 Mon Sep 17 00:00:00 2001
From: Dave Barker <kzar@kzar.co.uk>
Date: Sat, 7 Nov 2015 22:32:51 +0000
Subject: [PATCH] Add ability to give rcirc servers an alias name

---
 lisp/net/rcirc.el | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index d58f3eb..89a446f 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -103,7 +103,12 @@ connected to automatically.
 `:encryption'
 
 VALUE must be `plain' (the default) for unencrypted connections, or `tls'
-for connections using SSL/TLS."
+for connections using SSL/TLS.
+
+`:server-alias'
+
+VALUE must be a string that will be used instead of the server name for
+display purposes. If absent, the real server name will be displayed instead."
   :type '(alist :key-type string
 		:value-type (plist :options
                                    ((:nick string)
@@ -113,7 +118,8 @@ for connections using SSL/TLS."
                                     (:full-name string)
                                     (:channels (repeat string))
                                     (:encryption (choice (const tls)
-                                                         (const plain))))))
+                                                         (const plain)))
+                                    (:server-alias string))))
   :group 'rcirc)
 
 (defcustom rcirc-default-port 6667
@@ -484,22 +490,26 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (channels (plist-get (cdr c) :channels))
               (password (plist-get (cdr c) :password))
               (encryption (plist-get (cdr c) :encryption))
+              (server-alias (plist-get (cdr c) :server-alias))
               contact)
 	  (when server
 	    (let (connected)
 	      (dolist (p (rcirc-process-list))
-		(when (string= server (process-name p))
+		(when (string= (or server-alias server) (process-name p))
 		  (setq connected p)))
 	      (if (not connected)
 		  (condition-case nil
 		      (rcirc-connect server port nick user-name
-				     full-name channels password encryption)
-		    (quit (message "Quit connecting to %s" server)))
+                                     full-name channels password encryption
+                                     server-alias)
+		    (quit (message "Quit connecting to %s"
+                                   (or server-alias server))))
 		(with-current-buffer (process-buffer connected)
                   (setq contact (process-contact
-                                 (get-buffer-process (current-buffer)) :host))
+                                 (get-buffer-process (current-buffer)) :name))
                   (setq connected-servers
-                        (cons (if (stringp contact) contact server)
+                        (cons (if (stringp contact)
+                                  contact (or server-alias server))
                               connected-servers))))))))
       (when connected-servers
 	(message "Already connected to %s"
@@ -528,9 +538,10 @@ If ARG is non-nil, instead prompt for connection parameters."
 
 ;;;###autoload
 (defun rcirc-connect (server &optional port nick user-name
-                             full-name startup-channels password encryption)
+                             full-name startup-channels password encryption
+                             server-alias)
   (save-excursion
-    (message "Connecting to %s..." server)
+    (message "Connecting to %s..." (or server-alias server))
     (let* ((inhibit-eol-conversion)
            (port-number (if port
 			    (if (stringp port)
@@ -542,7 +553,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	   (full-name (or full-name rcirc-default-full-name))
 	   (startup-channels startup-channels)
            (process (open-network-stream
-                     server nil server port-number
+                     (or server-alias server) nil server port-number
                      :type (or encryption 'plain))))
       ;; set up process
       (set-process-coding-system process 'raw-text 'raw-text)
@@ -557,7 +568,8 @@ If ARG is non-nil, instead prompt for connection parameters."
 			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-server-name
+                  (or server-alias 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)
@@ -584,7 +596,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	(setq rcirc-keepalive-timer
 	      (run-at-time 0 (/ rcirc-timeout-seconds 2) 'rcirc-keepalive)))
 
-      (message "Connecting to %s...done" server)
+      (message "Connecting to %s...done" (or server-alias server))
 
       ;; return process object
       process)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-11-08 19:22   ` Artur Malabarba
@ 2015-11-08 18:52     ` Ryan Yeske
  2015-11-08 19:01       ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Ryan Yeske @ 2015-11-08 18:52 UTC (permalink / raw)
  To: Artur Malabarba, Dave Barker; +Cc: Leo Liu, emacs-devel

Where is the patch?

On Sun, Nov 8, 2015, at 11:22 AM, Artur Malabarba wrote:
> Dave Barker <kzar@kzar.co.uk> writes:
> 
> > Second try, reconnecting to servers now works again and the proper
> > server names are displayed.
> >
> > (Also I forgot to mention before, patch applies
> > to ea88d874a4f3ecbfdb5fa79dcb3ea90927cebec2 )
> 
> Hi Dave,
> 
> Your patch looks fine to me, but I'm not familiar with rcirc code.
> Therefore. I've CC'd here Leo and Ryan who are listed as rcirc
> maintainers in the file.
> 
> >
> > Cheers, Dave.
> >
> > On Sat, Nov 7, 2015 at 11:00 PM, Dave Barker <kzar@kzar.co.uk> wrote:
> >
> >     Hello all,
> >    
> >     First time contributing to Emacs (or at least attempting to),
> >     sorry if I'm doing this wrong somehow.
> >    
> >     I wanted the ability to give rcirc servers an alias name, to be
> >     displayed instead of the actual server name. The reason is that I
> >     use the ZNC IRC bouncer to connect to multiple servers and this
> >     means, as far as rcirc is concerned, that I have 4+ servers with
> >     the same server name - my ZNC server's hostname. This breaks
> >     rcirc, it won't let you connect to the same server twice, but
> >     even if it did things would quickly get confusing. (Up until now
> >     I've had to add bogus entries in my hosts file to point each IRC
> >     server's hostname to my ZNC server, but that's clearly quite a
> >     hack!)
> >    
> >     So the attached patch adds an optional :server-alias keyword
> >     parameter to rcirc-server-alist that allows you to specify a
> >     friendlier name for a rcirc server. The name is then used when
> >     messages are displayed, and for buffer naming purposes. If not
> >     specified the real server name is used instead just like before.
> >     (For people who are used to GitHub, here's my feature branch.)
> >    
> >     It would be great to get some feedback on this, the patch is
> >     working great for me but I'm inexperienced with elisp and this is
> >     the first time I've had a look at the rcirc code.
> >    
> >     Cheers, Dave.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-11-08 18:52     ` Ryan Yeske
@ 2015-11-08 19:01       ` Dave Barker
  2015-11-18 11:20         ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-11-08 19:01 UTC (permalink / raw)
  To: Ryan Yeske; +Cc: Leo Liu, Artur Malabarba, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 145 bytes --]

Here you go Ryan, it's attached.

Cheers, Dave.



On Sun, Nov 8, 2015 at 6:52 PM, Ryan Yeske <ryan@ryanyeske.com> wrote:

> Where is the patch?

[-- Attachment #1.2: Type: text/html, Size: 502 bytes --]

[-- Attachment #2: 0001-Add-ability-to-give-rcirc-servers-an-alias-name.patch --]
[-- Type: text/x-patch, Size: 5051 bytes --]

From 8e76f8dd43d137b23e3f43f61641ff26b45bb648 Mon Sep 17 00:00:00 2001
From: Dave Barker <kzar@kzar.co.uk>
Date: Sat, 7 Nov 2015 22:32:51 +0000
Subject: [PATCH] Add ability to give rcirc servers an alias name

---
 lisp/net/rcirc.el | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index d58f3eb..89a446f 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -103,7 +103,12 @@ connected to automatically.
 `:encryption'
 
 VALUE must be `plain' (the default) for unencrypted connections, or `tls'
-for connections using SSL/TLS."
+for connections using SSL/TLS.
+
+`:server-alias'
+
+VALUE must be a string that will be used instead of the server name for
+display purposes. If absent, the real server name will be displayed instead."
   :type '(alist :key-type string
 		:value-type (plist :options
                                    ((:nick string)
@@ -113,7 +118,8 @@ for connections using SSL/TLS."
                                     (:full-name string)
                                     (:channels (repeat string))
                                     (:encryption (choice (const tls)
-                                                         (const plain))))))
+                                                         (const plain)))
+                                    (:server-alias string))))
   :group 'rcirc)
 
 (defcustom rcirc-default-port 6667
@@ -484,22 +490,26 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (channels (plist-get (cdr c) :channels))
               (password (plist-get (cdr c) :password))
               (encryption (plist-get (cdr c) :encryption))
+              (server-alias (plist-get (cdr c) :server-alias))
               contact)
 	  (when server
 	    (let (connected)
 	      (dolist (p (rcirc-process-list))
-		(when (string= server (process-name p))
+		(when (string= (or server-alias server) (process-name p))
 		  (setq connected p)))
 	      (if (not connected)
 		  (condition-case nil
 		      (rcirc-connect server port nick user-name
-				     full-name channels password encryption)
-		    (quit (message "Quit connecting to %s" server)))
+                                     full-name channels password encryption
+                                     server-alias)
+		    (quit (message "Quit connecting to %s"
+                                   (or server-alias server))))
 		(with-current-buffer (process-buffer connected)
                   (setq contact (process-contact
-                                 (get-buffer-process (current-buffer)) :host))
+                                 (get-buffer-process (current-buffer)) :name))
                   (setq connected-servers
-                        (cons (if (stringp contact) contact server)
+                        (cons (if (stringp contact)
+                                  contact (or server-alias server))
                               connected-servers))))))))
       (when connected-servers
 	(message "Already connected to %s"
@@ -528,9 +538,10 @@ If ARG is non-nil, instead prompt for connection parameters."
 
 ;;;###autoload
 (defun rcirc-connect (server &optional port nick user-name
-                             full-name startup-channels password encryption)
+                             full-name startup-channels password encryption
+                             server-alias)
   (save-excursion
-    (message "Connecting to %s..." server)
+    (message "Connecting to %s..." (or server-alias server))
     (let* ((inhibit-eol-conversion)
            (port-number (if port
 			    (if (stringp port)
@@ -542,7 +553,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	   (full-name (or full-name rcirc-default-full-name))
 	   (startup-channels startup-channels)
            (process (open-network-stream
-                     server nil server port-number
+                     (or server-alias server) nil server port-number
                      :type (or encryption 'plain))))
       ;; set up process
       (set-process-coding-system process 'raw-text 'raw-text)
@@ -557,7 +568,8 @@ If ARG is non-nil, instead prompt for connection parameters."
 			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-server-name
+                  (or server-alias 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)
@@ -584,7 +596,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	(setq rcirc-keepalive-timer
 	      (run-at-time 0 (/ rcirc-timeout-seconds 2) 'rcirc-keepalive)))
 
-      (message "Connecting to %s...done" server)
+      (message "Connecting to %s...done" (or server-alias server))
 
       ;; return process object
       process)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-11-08 17:45 ` Dave Barker
@ 2015-11-08 19:22   ` Artur Malabarba
  2015-11-08 18:52     ` Ryan Yeske
  0 siblings, 1 reply; 21+ messages in thread
From: Artur Malabarba @ 2015-11-08 19:22 UTC (permalink / raw)
  To: Dave Barker; +Cc: Ryan Yeske, Leo Liu, emacs-devel

Dave Barker <kzar@kzar.co.uk> writes:

> Second try, reconnecting to servers now works again and the proper
> server names are displayed.
>
> (Also I forgot to mention before, patch applies
> to ea88d874a4f3ecbfdb5fa79dcb3ea90927cebec2 )

Hi Dave,

Your patch looks fine to me, but I'm not familiar with rcirc code.
Therefore. I've CC'd here Leo and Ryan who are listed as rcirc
maintainers in the file.

>
> Cheers, Dave.
>
> On Sat, Nov 7, 2015 at 11:00 PM, Dave Barker <kzar@kzar.co.uk> wrote:
>
>     Hello all,
>    
>     First time contributing to Emacs (or at least attempting to),
>     sorry if I'm doing this wrong somehow.
>    
>     I wanted the ability to give rcirc servers an alias name, to be
>     displayed instead of the actual server name. The reason is that I
>     use the ZNC IRC bouncer to connect to multiple servers and this
>     means, as far as rcirc is concerned, that I have 4+ servers with
>     the same server name - my ZNC server's hostname. This breaks
>     rcirc, it won't let you connect to the same server twice, but
>     even if it did things would quickly get confusing. (Up until now
>     I've had to add bogus entries in my hosts file to point each IRC
>     server's hostname to my ZNC server, but that's clearly quite a
>     hack!)
>    
>     So the attached patch adds an optional :server-alias keyword
>     parameter to rcirc-server-alist that allows you to specify a
>     friendlier name for a rcirc server. The name is then used when
>     messages are displayed, and for buffer naming purposes. If not
>     specified the real server name is used instead just like before.
>     (For people who are used to GitHub, here's my feature branch.)
>    
>     It would be great to get some feedback on this, the patch is
>     working great for me but I'm inexperienced with elisp and this is
>     the first time I've had a look at the rcirc code.
>    
>     Cheers, Dave.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-11-08 19:01       ` Dave Barker
@ 2015-11-18 11:20         ` Dave Barker
  2015-12-13 18:23           ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-11-18 11:20 UTC (permalink / raw)
  To: Ryan Yeske; +Cc: Leo Liu, Artur Malabarba, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

Hey Ryan,

Just wondered if you've had a chance to look at my patch yet?

Cheers, Dave.

On Sun, Nov 8, 2015 at 7:01 PM, Dave Barker <kzar@kzar.co.uk> wrote:

> Here you go Ryan, it's attached.
>
> Cheers, Dave.
>
>
>
> On Sun, Nov 8, 2015 at 6:52 PM, Ryan Yeske <ryan@ryanyeske.com> wrote:
>
>> Where is the patch?
>
>

[-- Attachment #2: Type: text/html, Size: 1003 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-11-18 11:20         ` Dave Barker
@ 2015-12-13 18:23           ` Dave Barker
  2015-12-16  6:16             ` Ryan Yeske
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-12-13 18:23 UTC (permalink / raw)
  To: Ryan Yeske; +Cc: Leo Liu, Artur Malabarba, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 171 bytes --]

Any chance someone could look at this for me? I've been using this patch
with great results since I posted it and it would be nice to see it land
upstream.

Cheers, Dave.

[-- Attachment #2: Type: text/html, Size: 220 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-13 18:23           ` Dave Barker
@ 2015-12-16  6:16             ` Ryan Yeske
  2015-12-16 12:29               ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Ryan Yeske @ 2015-12-16  6:16 UTC (permalink / raw)
  To: Dave Barker; +Cc: Leo Liu, Artur Malabarba, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]

Hi Dave,

I got a chance to review this.  It works fine for me here.

I think it might be good to replace the several instances of `(or server-
alias server)' with calls to a new function `rcirc-server-or-alias`.

Also, what about automatically creating this alias when connecting to a
server multiple times, without requiring the user to come up with an
alias?  Like automatically creating the server name `*irc.freenode.net*'
and `*irc.freenode.net<1>'.  This would only happen if disambiguating
aliases were not provided via your new mechanism.

What do you think?

Ryan





On Sun, Dec 13, 2015, at 10:23 AM, Dave Barker wrote:
> Any chance someone could look at this for me? I've been using this
> patch with great results since I posted it and it would be nice to see
> it land upstream.
>
> Cheers, Dave.

[-- Attachment #2: Type: text/html, Size: 1295 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-16  6:16             ` Ryan Yeske
@ 2015-12-16 12:29               ` Dave Barker
  2015-12-17 18:40                 ` Ryan Yeske
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-12-16 12:29 UTC (permalink / raw)
  To: Ryan Yeske; +Cc: Leo Liu, Artur Malabarba, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]

Thanks for taking a look Ryan.

I agree that `(or server-alias server)` shows up quite frequently.

I don't think creating a function server-or-alias would help however as in
all
cases both the `server` and `server-alias` variables are local to the
function
(`rcirc` and `rcirc-connect`), so we would have to pass them through. In
other
words we would be replacing `(or server-alias server)` with something like
`(server-or-alias server server-alias)`! I could let a new local variable
`server-or-alias` in both functions if you think that would look nicer?

As for the automatic server alias, I'm undecided. I think _usually_ the
desired
behaviour is to just warn the user that server X is already connected if
she/he
attempt to connect again. That's certainly how I use rcric, for example I
might
have only lost connection to one of four servers but I would still just call
`rcirc` to reconnect to that one. I'm struggling to think of many use cases
where connecting multiple times is required, and perhaps it's good for those
that the alias needs to be defined manually?

Cheers, Dave.

On Wed, Dec 16, 2015 at 6:16 AM, Ryan Yeske <ryan@ryanyeske.com> wrote:

> Hi Dave,
>
> I got a chance to review this.  It works fine for me here.
>
> I think it might be good to replace the several instances of `(or
> server-alias server)' with calls to a new function `rcirc-server-or-alias`.
>
> Also, what about automatically creating this alias when connecting to a
> server multiple times, without requiring the user to come up with an
> alias?  Like automatically creating the server name `*irc.freenode.net*'
> and `*irc.freenode.net<1>'.  This would only happen if disambiguating
> aliases were not provided via your new mechanism.
>
> What do you think?
>
> Ryan
>
>

[-- Attachment #2: Type: text/html, Size: 2730 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-16 12:29               ` Dave Barker
@ 2015-12-17 18:40                 ` Ryan Yeske
  2015-12-18 10:46                   ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Ryan Yeske @ 2015-12-17 18:40 UTC (permalink / raw)
  To: Dave Barker; +Cc: Leo Liu, Artur Malabarba, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

Thanks for all your patience with this Dave.

I think you are right on both counts.  Creating a helper function
doesn't really work.  And creating multiple connections to one server is
almost never what we would want.

I approve this patch.  What is the next step to getting this merged
into emacs?

Ryan


On Wed, Dec 16, 2015, at 04:29 AM, Dave Barker wrote:

> Thanks for taking a look Ryan.
>
> I agree that `(or server-alias server)` shows up quite frequently.
>
> I don't think creating a function server-or-alias would help however
> as in all cases both the `server` and `server-alias` variables are
> local to the function (`rcirc` and `rcirc-connect`), so we would have
> to pass them through. In other words we would be replacing `(or server-
> alias server)` with something like `(server-or-alias server server-
> alias)`! I could let a new local variable `server-or-alias` in both
> functions if you think that would look nicer?
>
> As for the automatic server alias, I'm undecided. I think _usually_
> the desired behaviour is to just warn the user that server X is
> already connected if she/he attempt to connect again. That's certainly
> how I use rcric, for example I might have only lost connection to one
> of four servers but I would still just call `rcirc` to reconnect to
> that one. I'm struggling to think of many use cases where connecting
> multiple times is required, and perhaps it's good for those that the
> alias needs to be defined manually?
>
> Cheers, Dave.
>
> On Wed, Dec 16, 2015 at 6:16 AM, Ryan Yeske
> <ryan@ryanyeske.com> wrote:
>> __
>> Hi Dave,
>>
>> I got a chance to review this.  It works fine for me here.
>>
>> I think it might be good to replace the several instances of `(or server-
>> alias server)' with calls to a new function `rcirc-server-or-alias`.
>>
>> Also, what about automatically creating this alias when connecting to
>> a server multiple times, without requiring the user to come up with
>> an alias?  Like automatically creating the server name
>> `*irc.freenode.net*' and `*irc.freenode.net<1>'.  This would only
>> happen if disambiguating aliases were not provided via your new
>> mechanism.
>>
>> What do you think?
>>
>>
>> Ryan
>>
>>
>>

[-- Attachment #2: Type: text/html, Size: 3604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-17 18:40                 ` Ryan Yeske
@ 2015-12-18 10:46                   ` Dave Barker
  2015-12-18 13:34                     ` Artur Malabarba
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-12-18 10:46 UTC (permalink / raw)
  To: Ryan Yeske; +Cc: Leo Liu, Artur Malabarba, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 585 bytes --]

I'm not sure, this is the first time I've contributed to the project.
Hopefully someone else knows how we can get this pushed?

(I've attached it again in case it helps.)

Cheers, Dave.


On Thu, Dec 17, 2015 at 6:40 PM, Ryan Yeske <ryan@ryanyeske.com> wrote:

> Thanks for all your patience with this Dave.
>
> I think you are right on both counts.  Creating a helper function doesn't
> really work.  And creating multiple connections to one server is almost
> never what we would want.
>
> I approve this patch.  What is the next step to getting this merged into
> emacs?
>
> Ryan
>

[-- Attachment #1.2: Type: text/html, Size: 1148 bytes --]

[-- Attachment #2: 0001-Add-ability-to-give-rcirc-servers-an-alias-name.patch --]
[-- Type: text/x-patch, Size: 5051 bytes --]

From 8e76f8dd43d137b23e3f43f61641ff26b45bb648 Mon Sep 17 00:00:00 2001
From: Dave Barker <kzar@kzar.co.uk>
Date: Sat, 7 Nov 2015 22:32:51 +0000
Subject: [PATCH] Add ability to give rcirc servers an alias name

---
 lisp/net/rcirc.el | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index d58f3eb..89a446f 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -103,7 +103,12 @@ connected to automatically.
 `:encryption'
 
 VALUE must be `plain' (the default) for unencrypted connections, or `tls'
-for connections using SSL/TLS."
+for connections using SSL/TLS.
+
+`:server-alias'
+
+VALUE must be a string that will be used instead of the server name for
+display purposes. If absent, the real server name will be displayed instead."
   :type '(alist :key-type string
 		:value-type (plist :options
                                    ((:nick string)
@@ -113,7 +118,8 @@ for connections using SSL/TLS."
                                     (:full-name string)
                                     (:channels (repeat string))
                                     (:encryption (choice (const tls)
-                                                         (const plain))))))
+                                                         (const plain)))
+                                    (:server-alias string))))
   :group 'rcirc)
 
 (defcustom rcirc-default-port 6667
@@ -484,22 +490,26 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (channels (plist-get (cdr c) :channels))
               (password (plist-get (cdr c) :password))
               (encryption (plist-get (cdr c) :encryption))
+              (server-alias (plist-get (cdr c) :server-alias))
               contact)
 	  (when server
 	    (let (connected)
 	      (dolist (p (rcirc-process-list))
-		(when (string= server (process-name p))
+		(when (string= (or server-alias server) (process-name p))
 		  (setq connected p)))
 	      (if (not connected)
 		  (condition-case nil
 		      (rcirc-connect server port nick user-name
-				     full-name channels password encryption)
-		    (quit (message "Quit connecting to %s" server)))
+                                     full-name channels password encryption
+                                     server-alias)
+		    (quit (message "Quit connecting to %s"
+                                   (or server-alias server))))
 		(with-current-buffer (process-buffer connected)
                   (setq contact (process-contact
-                                 (get-buffer-process (current-buffer)) :host))
+                                 (get-buffer-process (current-buffer)) :name))
                   (setq connected-servers
-                        (cons (if (stringp contact) contact server)
+                        (cons (if (stringp contact)
+                                  contact (or server-alias server))
                               connected-servers))))))))
       (when connected-servers
 	(message "Already connected to %s"
@@ -528,9 +538,10 @@ If ARG is non-nil, instead prompt for connection parameters."
 
 ;;;###autoload
 (defun rcirc-connect (server &optional port nick user-name
-                             full-name startup-channels password encryption)
+                             full-name startup-channels password encryption
+                             server-alias)
   (save-excursion
-    (message "Connecting to %s..." server)
+    (message "Connecting to %s..." (or server-alias server))
     (let* ((inhibit-eol-conversion)
            (port-number (if port
 			    (if (stringp port)
@@ -542,7 +553,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	   (full-name (or full-name rcirc-default-full-name))
 	   (startup-channels startup-channels)
            (process (open-network-stream
-                     server nil server port-number
+                     (or server-alias server) nil server port-number
                      :type (or encryption 'plain))))
       ;; set up process
       (set-process-coding-system process 'raw-text 'raw-text)
@@ -557,7 +568,8 @@ If ARG is non-nil, instead prompt for connection parameters."
 			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-server-name
+                  (or server-alias 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)
@@ -584,7 +596,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	(setq rcirc-keepalive-timer
 	      (run-at-time 0 (/ rcirc-timeout-seconds 2) 'rcirc-keepalive)))
 
-      (message "Connecting to %s...done" server)
+      (message "Connecting to %s...done" (or server-alias server))
 
       ;; return process object
       process)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-18 10:46                   ` Dave Barker
@ 2015-12-18 13:34                     ` Artur Malabarba
  2015-12-18 14:52                       ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Artur Malabarba @ 2015-12-18 13:34 UTC (permalink / raw)
  To: Dave Barker; +Cc: Ryan Yeske, Leo Liu, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

On 18 Dec 2015 8:46 am, "Dave Barker" <kzar@kzar.co.uk> wrote:
>
> I'm not sure, this is the first time I've contributed to the project.
Hopefully someone else knows how we can get this pushed?

Have you signed the copyright assignment?
Once you do that, we can push this to Emacs.
I'm having trouble finding the time to sit in front of a computer at the
moment, :-) but I can do that by January.

[-- Attachment #2: Type: text/html, Size: 520 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-18 13:34                     ` Artur Malabarba
@ 2015-12-18 14:52                       ` Dave Barker
  2016-01-03 23:11                         ` Artur Malabarba
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2015-12-18 14:52 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: Ryan Yeske, Leo Liu, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

On Fri, Dec 18, 2015 at 1:34 PM, Artur Malabarba <bruce.connor.am@gmail.com>
wrote:

> Have you signed the copyright assignment?
>
Nope, but I've just emailed assign@gnu.org to request the form.

> Once you do that, we can push this to Emacs.
> I'm having trouble finding the time to sit in front of a computer at the
> moment, :-) but I can do that by January.
>
Awesome thanks :)

Cheers, Dave.

[-- Attachment #2: Type: text/html, Size: 1181 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2015-12-18 14:52                       ` Dave Barker
@ 2016-01-03 23:11                         ` Artur Malabarba
  2016-01-07 11:52                           ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Artur Malabarba @ 2016-01-03 23:11 UTC (permalink / raw)
  To: Dave Barker; +Cc: Ryan Yeske, Leo Liu, emacs-devel

2015-12-18 14:52 GMT+00:00 Dave Barker <kzar@kzar.co.uk>:
> On Fri, Dec 18, 2015 at 1:34 PM, Artur Malabarba <bruce.connor.am@gmail.com>
> wrote:
>>
>> Have you signed the copyright assignment?
>
> Nope, but I've just emailed assign@gnu.org to request the form.

Great! Let us know when it's done.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-03 23:11                         ` Artur Malabarba
@ 2016-01-07 11:52                           ` Dave Barker
  2016-01-07 16:12                             ` Eli Zaretskii
  2016-01-08  5:57                             ` Richard Stallman
  0 siblings, 2 replies; 21+ messages in thread
From: Dave Barker @ 2016-01-07 11:52 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: Ryan Yeske, Leo Liu, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

Hey Artur,

I emailed my signed copyright assignment form on the 19th of December.

I don't know how to check that it has been actioned there end, I have not
heard back from them. (I was waiting to see if they would reply after the
holidays.)

Cheers, Dave.

On Sun, Jan 3, 2016 at 11:11 PM, Artur Malabarba <bruce.connor.am@gmail.com>
wrote:

> 2015-12-18 14:52 GMT+00:00 Dave Barker <kzar@kzar.co.uk>:
> > On Fri, Dec 18, 2015 at 1:34 PM, Artur Malabarba <
> bruce.connor.am@gmail.com>
> > wrote:
> >>
> >> Have you signed the copyright assignment?
> >
> > Nope, but I've just emailed assign@gnu.org to request the form.
>
> Great! Let us know when it's done.
>

[-- Attachment #2: Type: text/html, Size: 1249 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-07 11:52                           ` Dave Barker
@ 2016-01-07 16:12                             ` Eli Zaretskii
  2016-01-07 19:23                               ` Artur Malabarba
  2016-01-08  5:57                             ` Richard Stallman
  1 sibling, 1 reply; 21+ messages in thread
From: Eli Zaretskii @ 2016-01-07 16:12 UTC (permalink / raw)
  To: Dave Barker; +Cc: ryan, sdl.web, bruce.connor.am, emacs-devel

> Date: Thu, 7 Jan 2016 11:52:31 +0000
> From: Dave Barker <kzar@kzar.co.uk>
> Cc: Ryan Yeske <ryan@ryanyeske.com>, Leo Liu <sdl.web@gmail.com>,
> 	emacs-devel <emacs-devel@gnu.org>
> 
> I emailed my signed copyright assignment form on the 19th of December.
> 
> I don't know how to check that it has been actioned there end, I have not heard
> back from them. (I was waiting to see if they would reply after the holidays.)

Your assignment is already on file, so we can accept your
contributions.

Thanks.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-07 16:12                             ` Eli Zaretskii
@ 2016-01-07 19:23                               ` Artur Malabarba
  0 siblings, 0 replies; 21+ messages in thread
From: Artur Malabarba @ 2016-01-07 19:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Dave Barker, ryan, Leo Liu, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

On Jan 7, 2016 2:12 PM, "Eli Zaretskii" <eliz@gnu.org> wrote:
> Your assignment is already on file, so we can accept your
> contributions.

Thanks, Eli.

It'll take me a couple of weeks to have access to a real computer, so
anyone's free to push this before me. :-)

[-- Attachment #2: Type: text/html, Size: 398 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-07 11:52                           ` Dave Barker
  2016-01-07 16:12                             ` Eli Zaretskii
@ 2016-01-08  5:57                             ` Richard Stallman
  2016-01-08 11:07                               ` Dave Barker
  1 sibling, 1 reply; 21+ messages in thread
From: Richard Stallman @ 2016-01-08  5:57 UTC (permalink / raw)
  To: Dave Barker; +Cc: ryan, sdl.web, bruce.connor.am, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I emailed my signed copyright assignment form on the 19th of December.

  > I don't know how to check that it has been actioned there end, I have not
  > heard back from them.

Please write to assign@gnu.org.

When they sent you email, did the email say what email address to
contact them at?  It should.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-08  5:57                             ` Richard Stallman
@ 2016-01-08 11:07                               ` Dave Barker
  2016-01-09  3:23                                 ` Richard Stallman
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Barker @ 2016-01-08 11:07 UTC (permalink / raw)
  To: rms; +Cc: Ryan Yeske, Leo Liu, Artur Malabarba, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

Sure, it said to send the assignment to assign@gnu.org. (I originally
missed that and sent it back directly to the assignment administrator who
was helping me, but then I forwarded on to the proper address. I just
never received a reply, perhaps it just got marked as spam my end?)

Thanks for all your work, I'm a big fan.

Cheers, Dave.

On Fri, Jan 8, 2016 at 5:57 AM, Richard Stallman <rms@gnu.org> wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > I emailed my signed copyright assignment form on the 19th of December.
>
>   > I don't know how to check that it has been actioned there end, I have
> not
>   > heard back from them.
>
> Please write to assign@gnu.org.
>
> When they sent you email, did the email say what email address to
> contact them at?  It should.
>
> --
> Dr Richard Stallman
> President, Free Software Foundation (gnu.org, fsf.org)
> Internet Hall-of-Famer (internethalloffame.org)
> Skype: No way! See stallman.org/skype.html.
>
>

[-- Attachment #2: Type: text/html, Size: 2192 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-08 11:07                               ` Dave Barker
@ 2016-01-09  3:23                                 ` Richard Stallman
  2016-01-31 14:05                                   ` Dave Barker
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Stallman @ 2016-01-09  3:23 UTC (permalink / raw)
  To: Dave Barker; +Cc: ryan, sdl.web, bruce.connor.am, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Any time you expect a response from someone and don't get it, I advise
writing again after a suitable time.  For email to assign@gnu.org, I
suggest one week unless it is a holiday in which case two weeks.

If you are waiting for a response to snail mail, I suggest waiting
one additional week if it is from the US, and two additional weeks
if it is from another country.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: PATCH: Add the ability to give rcirc servers an alias name
  2016-01-09  3:23                                 ` Richard Stallman
@ 2016-01-31 14:05                                   ` Dave Barker
  0 siblings, 0 replies; 21+ messages in thread
From: Dave Barker @ 2016-01-31 14:05 UTC (permalink / raw)
  To: rms; +Cc: Ryan Yeske, Leo Liu, Artur Malabarba, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 321 bytes --]

On Sat, Jan 9, 2016 at 3:23 AM, Richard Stallman <rms@gnu.org> wrote:
>
> Any time you expect a response from someone and don't get it, I advise
> writing again after a suitable time.


Any chance someone could push the patch for me? It would be great to see it
finally included. (I've attached it again.)

Cheers, Dave.

[-- Attachment #1.2: Type: text/html, Size: 721 bytes --]

[-- Attachment #2: 0001-Add-ability-to-give-rcirc-servers-an-alias-name.patch --]
[-- Type: text/x-patch, Size: 5051 bytes --]

From 8e76f8dd43d137b23e3f43f61641ff26b45bb648 Mon Sep 17 00:00:00 2001
From: Dave Barker <kzar@kzar.co.uk>
Date: Sat, 7 Nov 2015 22:32:51 +0000
Subject: [PATCH] Add ability to give rcirc servers an alias name

---
 lisp/net/rcirc.el | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index d58f3eb..89a446f 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -103,7 +103,12 @@ connected to automatically.
 `:encryption'
 
 VALUE must be `plain' (the default) for unencrypted connections, or `tls'
-for connections using SSL/TLS."
+for connections using SSL/TLS.
+
+`:server-alias'
+
+VALUE must be a string that will be used instead of the server name for
+display purposes. If absent, the real server name will be displayed instead."
   :type '(alist :key-type string
 		:value-type (plist :options
                                    ((:nick string)
@@ -113,7 +118,8 @@ for connections using SSL/TLS."
                                     (:full-name string)
                                     (:channels (repeat string))
                                     (:encryption (choice (const tls)
-                                                         (const plain))))))
+                                                         (const plain)))
+                                    (:server-alias string))))
   :group 'rcirc)
 
 (defcustom rcirc-default-port 6667
@@ -484,22 +490,26 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (channels (plist-get (cdr c) :channels))
               (password (plist-get (cdr c) :password))
               (encryption (plist-get (cdr c) :encryption))
+              (server-alias (plist-get (cdr c) :server-alias))
               contact)
 	  (when server
 	    (let (connected)
 	      (dolist (p (rcirc-process-list))
-		(when (string= server (process-name p))
+		(when (string= (or server-alias server) (process-name p))
 		  (setq connected p)))
 	      (if (not connected)
 		  (condition-case nil
 		      (rcirc-connect server port nick user-name
-				     full-name channels password encryption)
-		    (quit (message "Quit connecting to %s" server)))
+                                     full-name channels password encryption
+                                     server-alias)
+		    (quit (message "Quit connecting to %s"
+                                   (or server-alias server))))
 		(with-current-buffer (process-buffer connected)
                   (setq contact (process-contact
-                                 (get-buffer-process (current-buffer)) :host))
+                                 (get-buffer-process (current-buffer)) :name))
                   (setq connected-servers
-                        (cons (if (stringp contact) contact server)
+                        (cons (if (stringp contact)
+                                  contact (or server-alias server))
                               connected-servers))))))))
       (when connected-servers
 	(message "Already connected to %s"
@@ -528,9 +538,10 @@ If ARG is non-nil, instead prompt for connection parameters."
 
 ;;;###autoload
 (defun rcirc-connect (server &optional port nick user-name
-                             full-name startup-channels password encryption)
+                             full-name startup-channels password encryption
+                             server-alias)
   (save-excursion
-    (message "Connecting to %s..." server)
+    (message "Connecting to %s..." (or server-alias server))
     (let* ((inhibit-eol-conversion)
            (port-number (if port
 			    (if (stringp port)
@@ -542,7 +553,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	   (full-name (or full-name rcirc-default-full-name))
 	   (startup-channels startup-channels)
            (process (open-network-stream
-                     server nil server port-number
+                     (or server-alias server) nil server port-number
                      :type (or encryption 'plain))))
       ;; set up process
       (set-process-coding-system process 'raw-text 'raw-text)
@@ -557,7 +568,8 @@ If ARG is non-nil, instead prompt for connection parameters."
 			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-server-name
+                  (or server-alias 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)
@@ -584,7 +596,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 	(setq rcirc-keepalive-timer
 	      (run-at-time 0 (/ rcirc-timeout-seconds 2) 'rcirc-keepalive)))
 
-      (message "Connecting to %s...done" server)
+      (message "Connecting to %s...done" (or server-alias server))
 
       ;; return process object
       process)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-01-31 14:05 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-07 23:00 PATCH: Add the ability to give rcirc servers an alias name Dave Barker
2015-11-08 17:45 ` Dave Barker
2015-11-08 19:22   ` Artur Malabarba
2015-11-08 18:52     ` Ryan Yeske
2015-11-08 19:01       ` Dave Barker
2015-11-18 11:20         ` Dave Barker
2015-12-13 18:23           ` Dave Barker
2015-12-16  6:16             ` Ryan Yeske
2015-12-16 12:29               ` Dave Barker
2015-12-17 18:40                 ` Ryan Yeske
2015-12-18 10:46                   ` Dave Barker
2015-12-18 13:34                     ` Artur Malabarba
2015-12-18 14:52                       ` Dave Barker
2016-01-03 23:11                         ` Artur Malabarba
2016-01-07 11:52                           ` Dave Barker
2016-01-07 16:12                             ` Eli Zaretskii
2016-01-07 19:23                               ` Artur Malabarba
2016-01-08  5:57                             ` Richard Stallman
2016-01-08 11:07                               ` Dave Barker
2016-01-09  3:23                                 ` Richard Stallman
2016-01-31 14:05                                   ` Dave Barker

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).