summaryrefslogtreecommitdiffstats
path: root/spacemacs/.emacs.d/private
diff options
context:
space:
mode:
Diffstat (limited to 'spacemacs/.emacs.d/private')
-rw-r--r--spacemacs/.emacs.d/private/aminb/layers.el14
-rw-r--r--spacemacs/.emacs.d/private/aminb/packages.el48
2 files changed, 61 insertions, 1 deletions
diff --git a/spacemacs/.emacs.d/private/aminb/layers.el b/spacemacs/.emacs.d/private/aminb/layers.el
new file mode 100644
index 0000000..a7cbc32
--- /dev/null
+++ b/spacemacs/.emacs.d/private/aminb/layers.el
@@ -0,0 +1,14 @@
+;;; layers.el --- aminb layer layers file for Spacemacs.
+;;
+;; Copyright (c) 2016 Amin Bandali
+;;
+;; Author: Amin Bandali <amin@aminb.org>
+;; URL: https://github.com/aminb/dotfiles
+;;
+;; This file is not part of GNU Emacs.
+;;
+;;; License: GPLv3
+
+;; Prerequisites
+
+(configuration-layer/declare-layer 'erc)
diff --git a/spacemacs/.emacs.d/private/aminb/packages.el b/spacemacs/.emacs.d/private/aminb/packages.el
index fb9862b..919b271 100644
--- a/spacemacs/.emacs.d/private/aminb/packages.el
+++ b/spacemacs/.emacs.d/private/aminb/packages.el
@@ -17,7 +17,7 @@
;;; Code:
(defconst aminb-packages
- '(crux writeroom-mode)
+ '(crux writeroom-mode znc)
"The list of Lisp packages required by the aminb layer.")
(defun aminb/init-crux ()
@@ -34,5 +34,51 @@
:bind (("C-c W" . writeroom-mode)
("s-?" . writeroom-toggle-mode-line))))
+(defun aminb/init-znc ()
+ (use-package znc
+ :defer t
+ :init
+ (spacemacs/set-leader-keys
+ "aiz" 'znc-erc)
+ :config
+ (progn
+ (defun vbe:znc-add-server (server port user networks)
+ "Add a server to the list of ZNC servers.
+We use SSL inconditionaly. Moreover, we don't store the password
+but put nil instead. At least, we tweak the username to contain
+the network name later, this will be separated again."
+ (add-to-list 'znc-servers
+ (list server
+ port
+ t ; SSL enabled
+ (mapcar (function (lambda (slug) (list slug
+ (format "%s/%s" user slug)
+ nil)))
+ networks))))
+
+ (defun vbe:znc-erc-ssl-connector (&rest R)
+ "Connect to ERC using SSL and retrieve password with `auth-source-search'.
+Moreover, handle multiple networks by sending the password with
+the appropriate network slug that we extract from the nick."
+ (let* ((user (nth 0 (split-string (plist-get R :nick) "/")))
+ (slug (nth 1 (split-string (plist-get R :nick) "/")))
+ (found (nth 0 (auth-source-search :host (plist-get R :server)
+ :user user
+ :require '(:user :secret)
+ :max 1))))
+ (if found
+ (let ((password (let ((secret (plist-get found :secret)))
+ (if (functionp secret)
+ (funcall secret)
+ secret))))
+ (plist-put R :password (format "%s/%s:%s" user slug password))
+ (plist-put R :nick user)
+ (apply 'erc-tls R)))))
+ (setq znc-erc-ssl-connector 'vbe:znc-erc-ssl-connector)
+
+ ;; Define networks
+ (vbe:znc-add-server "nix.aminb.org" 6669 "amin"
+ '(freenode mozilla))
+ )))
;;; packages.el ends here