From ab386d244c0cf1b7fe274e2cec80a180e9b88b14 Mon Sep 17 00:00:00 2001 From: Amin Bandali Date: Sun, 11 Dec 2016 16:51:42 -0500 Subject: [spacemacs] Use znc.el for irc (wraps around erc) kudos to vincentbernat and rrix https://github.com/vincentbernat/dot.emacs/blob/master/znc.conf.el http://doc.rix.si/cce/cce-irc.html --- spacemacs/.emacs.d/private/aminb/layers.el | 14 ++++++++ spacemacs/.emacs.d/private/aminb/packages.el | 48 +++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 spacemacs/.emacs.d/private/aminb/layers.el (limited to 'spacemacs/.emacs.d/private') 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 +;; 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 -- cgit v1.2.3-60-g2f50