From: Dave Barker <kzar@kzar.co.uk>
To: emacs-devel@gnu.org
Subject: Re: PATCH: Add the ability to give rcirc servers an alias name
Date: Sun, 8 Nov 2015 17:45:59 +0000 [thread overview]
Message-ID: <CAH+bdfSgTPXCb4ZYrYK_ux+tB7g64KbUh5XAg1_M_GoKtkRScQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+bdfTLGAjHoOKLCEmLU6pE6mHn5pc5=R-439u_Cm6vi50a5g@mail.gmail.com>
[-- 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
next prev parent reply other threads:[~2015-11-08 17:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH+bdfSgTPXCb4ZYrYK_ux+tB7g64KbUh5XAg1_M_GoKtkRScQ@mail.gmail.com \
--to=kzar@kzar.co.uk \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.