47b48b1a02ffbf6a82004a66c8b3433ff6f7ad90
1 ;;; extensions.el --- irc Layer extensions File for Spacemacs
3 ;; Copyright (c) 2012-2014 Sylvain Benner
4 ;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
6 ;; Author: Sylvain Benner <sylvain.benner@gmail.com>
7 ;; URL: https://github.com/syl20bnr/spacemacs
9 ;; This file is not part of GNU Emacs.
11 ;; vbe* functions for reading passwords from authinfo by Vincent Bernat
15 (setq irc-pre-extensions
17 ;; pre extension names go here
20 (setq irc-post-extensions
22 ;; post extension names go here
26 ;; For each extension, define a function irc/init-<extension-name>
28 (defun irc/init-znc
()
31 :load-path
"private/ZNC.el"
32 :commands
(znc-erc znc-all
)
34 :init
(evil-leader/set-key
39 (defun vbe:znc-add-server
(server port user networks
)
40 "Add a server to the list of ZNC servers.
41 We use SSL inconditionaly. Moreover, we don't store the password
42 but put nil instead. At least, we tweak the username to contain
43 the network name later, this will be separated again."
44 (add-to-list 'znc-servers
48 (mapcar (function (lambda (slug) (list slug
49 (format "%s/%s" user slug
)
53 (defun vbe:znc-erc-ssl-connector
(&rest R
)
54 "Connect to ERC using SSL and retrieve password with `auth-source-search'.
55 Moreover, handle multiple networks by sending the password with
56 the appropriate network slug that we extract from the nick."
57 (let* ((user (nth 0 (split-string (plist-get R
:nick
) "/")))
58 (slug (nth 1 (split-string (plist-get R
:nick
) "/")))
59 (found (nth 0 (auth-source-search :host
(plist-get R
:server
)
61 :require
'(:user
:secret
)
64 (let ((password (let ((secret (plist-get found
:secret
)))
65 (if (functionp secret
)
68 (plist-put R
:password
(format "%s/%s:%s" user slug password
))
69 (plist-put R
:nick user
)
70 (apply 'erc-tls R
)))))
71 (setq znc-erc-ssl-connector
'vbe
:znc-erc-ssl-connector
)
74 (vbe:znc-add-server
"aminb.org" 6697 "aminb"
80 ;; Often the body of an initialize function uses `use-package'
81 ;; For more info on `use-package', see readme:
82 ;; https://github.com/jwiegley/use-package