bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23438: 24.5; ERC autojoin should use erc-autojoin-domain-only search


From: Jim Crossley
Subject: bug#23438: 24.5; ERC autojoin should use erc-autojoin-domain-only searching channel keys
Date: Wed, 4 May 2016 11:10:38 -0400

Here ya go, thanks!

- Jim

master ef554176256a318ce0bc4d3d3790a66e8ddd1fc0
Author:     Jim Crossley <address@hidden>
AuthorDate: Wed May 4 11:04:28 2016 -0400
Commit:     Jim Crossley <address@hidden>
CommitDate: Wed May 4 11:04:28 2016 -0400

Parent:     3d8b29b * lisp/vc/ediff-util.el: Use lexical-binding.
Merged:     master
Containing: master
Follows:    emacs-24.5-rc3-fixed (9210)

Use the domain name for auth-source-search

For the same reason we might use the domain name to query
erc-autojoin-channels-alist, we should use it for auth-source-search.
Otherwise, we'd need to include a line for every possible server to
which chat.freenode.net might redirect us in ~/.authinfo.gpg

1 file changed, 12 insertions(+), 9 deletions(-)
lisp/erc/erc-join.el | 21 ++++++++++++---------

modified   lisp/erc/erc-join.el
@@ -166,10 +166,17 @@ This function is run from `erc-nickserv-identified-hook'."
   ;; Return nil to avoid stomping on any other hook funcs.
   nil)
 
+(defun erc-server-name (server)
+  "Use the server's domain name if option set"
+  (if (and erc-autojoin-domain-only
+   (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server))
+      (match-string 1 server)
+    server))
+
 (defun erc-server-join-channel (server channel)
   (let* ((secret (plist-get (nth 0 (auth-source-search
     :max 1
-    :host server
+    :host (erc-server-name server)
     :port "irc"
     :user channel))
     :secret))
@@ -186,11 +193,9 @@ This function is run from `erc-nickserv-identified-hook'."
   (let* ((chnl (erc-response.contents parsed))
  (nick (car (erc-parse-user (erc-response.sender parsed))))
  (server (with-current-buffer (process-buffer proc)
-   (or erc-server-announced-name erc-session-server))))
+   (erc-server-name
+    (or erc-server-announced-name erc-session-server)))))
     (when (erc-current-nick-p nick)
-      (when (and erc-autojoin-domain-only
- (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server))
- (setq server (match-string 1 server)))
       (let ((elem (assoc server erc-autojoin-channels-alist)))
  (if elem
     (unless (member chnl (cdr elem))
@@ -209,11 +214,9 @@ This function is run from `erc-nickserv-identified-hook'."
   (let* ((chnl (car (erc-response.command-args parsed)))
  (nick (car (erc-parse-user (erc-response.sender parsed))))
  (server (with-current-buffer (process-buffer proc)
-   (or erc-server-announced-name erc-session-server))))
+   (erc-server-name
+    (or erc-server-announced-name erc-session-server)))))
     (when (erc-current-nick-p nick)
-      (when (and erc-autojoin-domain-only
- (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server))
- (setq server (match-string 1 server)))
       (let ((elem (assoc server erc-autojoin-channels-alist)))
  (when elem
   (setcdr elem (delete chnl (cdr elem)))


On Tue, May 3, 2016 at 6:38 PM, Lars Ingebrigtsen <address@hidden> wrote:
Jim Crossley <address@hidden> writes:

> It's impossible to know what round-robin server you'll actually connect
> to when connecting to chat.freenode.net, for example. Therefore, it's
> impossible to include the correct host lines for channel keys in the
> auth-source files. It would be far better to search for the channel keys
> using the same name used to query erc-autojoin-channels-alist when
> erc-autojoin-domain-only is non-nil. I have a patch that works, but I'm
> not sure where to submit it.

Submit it here, please.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no


reply via email to

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