1 ;;; packages.el --- aminb layer packages file for Spacemacs.
3 ;; Copyright (c) 2016 Amin Bandali
5 ;; Author: Amin Bandali <amin@aminb.org>
6 ;; URL: https://github.com/aminb/dotfiles
8 ;; This file is not part of GNU Emacs.
14 ;; This file is a collection of my settings and customizations on top of
19 (defconst aminb-packages
20 '(crux writeroom-mode znc
)
21 "The list of Lisp packages required by the aminb layer.")
23 (defun aminb/init-crux
()
26 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
27 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region
)
30 (defun aminb/init-writeroom-mode
()
31 (use-package writeroom-mode
; Distraction-free editing
33 :config
(setq writeroom-width
82)
34 :bind
(("C-c W" . writeroom-mode
)
35 ("s-?" . writeroom-toggle-mode-line
))))
37 (defun aminb/init-znc
()
41 (spacemacs/set-leader-keys
45 (defun vbe:znc-add-server
(server port user networks
)
46 "Add a server to the list of ZNC servers.
47 We use SSL inconditionaly. Moreover, we don't store the password
48 but put nil instead. At least, we tweak the username to contain
49 the network name later, this will be separated again."
50 (add-to-list 'znc-servers
54 (mapcar (function (lambda (slug) (list slug
55 (format "%s/%s" user slug
)
59 (defun vbe:znc-erc-ssl-connector
(&rest R
)
60 "Connect to ERC using SSL and retrieve password with `auth-source-search'.
61 Moreover, handle multiple networks by sending the password with
62 the appropriate network slug that we extract from the nick."
63 (let* ((user (nth 0 (split-string (plist-get R
:nick
) "/")))
64 (slug (nth 1 (split-string (plist-get R
:nick
) "/")))
65 (found (nth 0 (auth-source-search :host
(plist-get R
:server
)
67 :require
'(:user
:secret
)
70 (let ((password (let ((secret (plist-get found
:secret
)))
71 (if (functionp secret
)
74 (plist-put R
:password
(format "%s/%s:%s" user slug password
))
75 (plist-put R
:nick user
)
76 (apply 'erc-tls R
)))))
77 (setq znc-erc-ssl-connector
'vbe
:znc-erc-ssl-connector
)
80 (vbe:znc-add-server
"nix.aminb.org" 6669 "amin"
84 ;;; packages.el ends here