diff options
| author | Lars Magne Ingebrigtsen | 2012-04-10 06:43:35 +0200 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2012-04-10 06:43:35 +0200 |
| commit | b245988452013d8cf83f0d45eb10ff6265f21db7 (patch) | |
| tree | ecf27132f34dd6e83c7cef2d73115395f9589f58 | |
| parent | ec3e5f739a282667021905a3f62effcc8b0d6d80 (diff) | |
| download | emacs-b245988452013d8cf83f0d45eb10ff6265f21db7.tar.gz emacs-b245988452013d8cf83f0d45eb10ff6265f21db7.zip | |
Make erc use auth-source to look up channel keys
* lisp/erc/erc-join.el (erc-server-join-channel): New function to look up
the channel password via auth-source.
(erc-autojoin-channels): Use it.
(erc-autojoin-after-ident): Ditto.
(erc-autojoin-channels-alist): Mention auth-source.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/erc/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/erc/erc-join.el | 27 |
3 files changed, 37 insertions, 2 deletions
| @@ -39,6 +39,10 @@ been adding them there, put them somewhere else, eg site-lisp. | |||
| 39 | * Editing Changes in Emacs 24.2 | 39 | * Editing Changes in Emacs 24.2 |
| 40 | 40 | ||
| 41 | * Changes in Specialized Modes and Packages in Emacs 24.2 | 41 | * Changes in Specialized Modes and Packages in Emacs 24.2 |
| 42 | |||
| 43 | ** erc will look up server/channel names via auth-source and use the | ||
| 44 | channel keys found, if any. | ||
| 45 | |||
| 42 | 46 | ||
| 43 | * New Modes and Packages in Emacs 24.2 | 47 | * New Modes and Packages in Emacs 24.2 |
| 44 | 48 | ||
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index 9f858ba96e5..649ab7f3fc2 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-04-10 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * erc-join.el (erc-server-join-channel): New function to look up | ||
| 4 | the channel password via auth-source. | ||
| 5 | (erc-autojoin-channels): Use it. | ||
| 6 | (erc-autojoin-after-ident): Ditto. | ||
| 7 | (erc-autojoin-channels-alist): Mention auth-source. | ||
| 8 | |||
| 1 | 2012-04-10 Deniz Dogan <deniz@dogan.se> (tiny change) | 9 | 2012-04-10 Deniz Dogan <deniz@dogan.se> (tiny change) |
| 2 | 10 | ||
| 3 | * erc.el (erc-display-prompt): Adds the field text property to the | 11 | * erc.el (erc-display-prompt): Adds the field text property to the |
diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el index da894ba5977..85d1edf6427 100644 --- a/lisp/erc/erc-join.el +++ b/lisp/erc/erc-join.el | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | ;;; Code: | 32 | ;;; Code: |
| 33 | 33 | ||
| 34 | (require 'erc) | 34 | (require 'erc) |
| 35 | (require 'auth-source) | ||
| 35 | (eval-when-compile (require 'cl)) | 36 | (eval-when-compile (require 'cl)) |
| 36 | 37 | ||
| 37 | (defgroup erc-autojoin nil | 38 | (defgroup erc-autojoin nil |
| @@ -56,6 +57,13 @@ Every element in the alist has the form (SERVER . CHANNELS). | |||
| 56 | SERVER is a regexp matching the server, and channels is the | 57 | SERVER is a regexp matching the server, and channels is the |
| 57 | list of channels to join. | 58 | list of channels to join. |
| 58 | 59 | ||
| 60 | If the channel(s) require channel keys for joining, the passwords | ||
| 61 | are found via auth-source. For instance, if you use ~/.authinfo | ||
| 62 | as your auth-source backend, then put something like the | ||
| 63 | following in that file: | ||
| 64 | |||
| 65 | machine irc.example.net login \"#fsf\" password sEcReT | ||
| 66 | |||
| 59 | Customize this variable to set the value for your first connect. | 67 | Customize this variable to set the value for your first connect. |
| 60 | Once you are connected and join and part channels, this alist | 68 | Once you are connected and join and part channels, this alist |
| 61 | keeps track of what channels you are on, and will join them | 69 | keeps track of what channels you are on, and will join them |
| @@ -131,7 +139,7 @@ This function is run from `erc-nickserv-identified-hook'." | |||
| 131 | (when (string-match (car l) server) | 139 | (when (string-match (car l) server) |
| 132 | (dolist (chan (cdr l)) | 140 | (dolist (chan (cdr l)) |
| 133 | (unless (erc-member-ignore-case chan joined) | 141 | (unless (erc-member-ignore-case chan joined) |
| 134 | (erc-server-send (concat "join " chan)))))))) | 142 | (erc-server-join-channel server chan))))))) |
| 135 | nil) | 143 | nil) |
| 136 | 144 | ||
| 137 | (defun erc-autojoin-channels (server nick) | 145 | (defun erc-autojoin-channels (server nick) |
| @@ -148,10 +156,25 @@ This function is run from `erc-nickserv-identified-hook'." | |||
| 148 | (dolist (l erc-autojoin-channels-alist) | 156 | (dolist (l erc-autojoin-channels-alist) |
| 149 | (when (string-match (car l) server) | 157 | (when (string-match (car l) server) |
| 150 | (dolist (chan (cdr l)) | 158 | (dolist (chan (cdr l)) |
| 151 | (erc-server-send (concat "join " chan)))))) | 159 | (erc-server-join-channel server chan))))) |
| 152 | ;; Return nil to avoid stomping on any other hook funcs. | 160 | ;; Return nil to avoid stomping on any other hook funcs. |
| 153 | nil) | 161 | nil) |
| 154 | 162 | ||
| 163 | (defun erc-server-join-channel (server channel) | ||
| 164 | (let* ((secret (plist-get (nth 0 (auth-source-search | ||
| 165 | :max 1 | ||
| 166 | :host server | ||
| 167 | :port "irc" | ||
| 168 | :user channel)) | ||
| 169 | :secret)) | ||
| 170 | (password (if (functionp secret) | ||
| 171 | (funcall secret) | ||
| 172 | secret))) | ||
| 173 | (erc-server-send (concat "join " channel | ||
| 174 | (if password | ||
| 175 | (concat " " password) | ||
| 176 | ""))))) | ||
| 177 | |||
| 155 | (defun erc-autojoin-add (proc parsed) | 178 | (defun erc-autojoin-add (proc parsed) |
| 156 | "Add the channel being joined to `erc-autojoin-channels-alist'." | 179 | "Add the channel being joined to `erc-autojoin-channels-alist'." |
| 157 | (let* ((chnl (erc-response.contents parsed)) | 180 | (let* ((chnl (erc-response.contents parsed)) |