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
23 ;; mu4e has to be installed manually,
24 ;; and make sure it's in load-path
29 "The list of Lisp packages required by the aminb layer.")
31 (defun aminb/post-init-counsel
()
36 (spacemacs/set-leader-keys-for-major-mode
'eshell-mode
37 "," 'counsel-esh-history
)
38 (add-hook 'eshell-mode-hook
39 '(lambda () (define-key eshell-mode-map
40 (kbd "M-l") 'counsel-esh-history
)))
43 (defun aminb/init-creamsody-theme
())
45 (defun aminb/init-crux
()
48 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
49 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region
)
52 (defun aminb/init-writeroom-mode
()
53 (use-package writeroom-mode
; Distraction-free editing
55 :config
(setq writeroom-width
82)
56 :bind
(("C-c W" . writeroom-mode
)
57 ("s-?" . writeroom-toggle-mode-line
))))
59 (defun aminb/init-znc
()
63 (spacemacs/set-leader-keys
67 ;; Set the erc nick completion postfix to ", "
68 (setq erc-pcomplete-nick-postfix
", ")
70 ;; Restore channel buffers from logs
71 (setq erc-log-insert-log-on-open t
)
73 (defun vbe:znc-add-server
(server port user networks
)
74 "Add a server to the list of ZNC servers.
75 We use SSL inconditionaly. Moreover, we don't store the password
76 but put nil instead. At least, we tweak the username to contain
77 the network name later, this will be separated again."
78 (add-to-list 'znc-servers
82 (mapcar (function (lambda (slug) (list slug
83 (format "%s/%s" user slug
)
87 (defun vbe:znc-erc-ssl-connector
(&rest R
)
88 "Connect to ERC using SSL and retrieve password with `auth-source-search'.
89 Moreover, handle multiple networks by sending the password with
90 the appropriate network slug that we extract from the nick."
91 (let* ((user (nth 0 (split-string (plist-get R
:nick
) "/")))
92 (slug (nth 1 (split-string (plist-get R
:nick
) "/")))
93 (found (nth 0 (auth-source-search :host
(plist-get R
:server
)
95 :require
'(:user
:secret
)
98 (let ((password (let ((secret (plist-get found
:secret
)))
99 (if (functionp secret
)
102 (plist-put R
:password
(format "%s/%s:%s" user slug password
))
103 (plist-put R
:nick user
)
104 (apply 'erc-tls R
)))))
105 (setq znc-erc-ssl-connector
'vbe
:znc-erc-ssl-connector
)
108 (vbe:znc-add-server
"nix.aminb.org" 6669 "amin"
111 ;; https://www.emacswiki.org/emacs/ErcBar
112 ;; Display a bar before unread messages
113 (eval-after-load 'erc-track
115 (defun erc-bar-move-back (n)
116 "Moves back n message lines. Ignores wrapping, and server messages."
117 (interactive "nHow many lines ? ")
118 (re-search-backward "^.*<.*>" nil t n
))
120 (defun erc-bar-update-overlay ()
121 "Update the overlay for current buffer, based on the content of
122 erc-modified-channels-alist. Should be executed on window change."
124 (let* ((info (assq (current-buffer) erc-modified-channels-alist
))
126 (if (and info
(> count erc-bar-threshold
))
129 (when (erc-bar-move-back count
)
130 (let ((inhibit-field-text-motion t
))
131 (move-overlay erc-bar-overlay
132 (line-beginning-position)
135 (delete-overlay erc-bar-overlay
))))
137 (defvar erc-bar-threshold
1
138 "Display bar when there are more than erc-bar-threshold unread messages.")
139 (defvar erc-bar-overlay nil
140 "Overlay used to set bar")
141 (setq erc-bar-overlay
(make-overlay 0 0))
142 (overlay-put erc-bar-overlay
'face
'(:underline
"purple"))
143 ;;put the hook before erc-modified-channels-update
144 (defadvice erc-track-mode
(after erc-bar-setup-hook
145 (&rest args
) activate
)
146 ;;remove and add, so we know it's in the first place
147 (remove-hook 'window-configuration-change-hook
'erc-bar-update-overlay
)
148 (add-hook 'window-configuration-change-hook
'erc-bar-update-overlay
))
149 (add-hook 'erc-send-completed-hook
(lambda (str)
150 (erc-bar-update-overlay)))))
154 (defun aminb/post-init-mu4e
()
155 (setq maildir
"~/mail")
160 (setq mu4e-maildir maildir
161 mu4e-get-mail-command
"true"
162 mu4e-update-interval
300
163 mu4e-view-show-addresses t
164 mu4e-headers-include-related t
165 mu4e-enable-notifications t
166 mu4e-enable-mode-line t
167 mu4e-compose-signature-auto-include t
168 mu4e-compose-signature
172 message-kill-buffer-on-exit t
; don't keep message buffers around
173 mu4e-attachment-dir
"~/dls"
174 mu4e-sent-folder
"/amin/Sent"
175 mu4e-drafts-folder
"/amin/Drafts"
176 mu4e-trash-folder
"/amin/Trash"
177 user-full-name
"Amin Bandali"
178 user-mail-address
"amin@aminb.org"
179 mu4e-view-html-plaintext-ratio-heuristic most-positive-fixnum
180 mu4e-context-policy
'pick-first
182 (list (make-mu4e-context
184 :enter-func
(lambda () (mu4e-message "Switch to the Personal context"))
185 :match-func
(lambda (msg)
187 (s-prefix?
"/amin/" (mu4e-message-field msg
:maildir
))))
188 :vars
'((user-mail-address .
"amin@aminb.org")
189 (mu4e-sent-folder .
"/amin/Sent")
190 (mu4e-drafts-folder .
"/amin/Drafts")
191 (mu4e-trash-folder .
"/amin/Trash")
192 (mu4e-sent-messages-behavior . sent
)
193 (smtpmail-default-smtp-server .
"nix.aminb.org")
194 (smtpmail-smtp-server .
"nix.aminb.org")
195 (smtpmail-stream-type . starttls
)
196 (smtpmail-smtp-service .
587)))
199 :enter-func
(lambda () (mu4e-message "Switch to the BB context"))
200 :match-func
(lambda (msg)
202 (s-prefix?
"/gmail/" (mu4e-message-field msg
:maildir
))))
203 :vars
'((user-mail-address .
"amin.bandali@gmail.com")
204 (mu4e-sent-folder .
"/gmail/Sent")
205 (mu4e-drafts-folder .
"/gmail/Drafts")
206 (mu4e-trash-folder .
"/gmail/Trash")
207 (mu4e-sent-messages-behavior . delete
)
208 (mu4e-compose-signature . nil
)
209 (smtpmail-default-smtp-server .
"smtp.gmail.com")
210 (smtpmail-smtp-server .
"smtp.gmail.com")
211 (smtpmail-stream-type . starttls
)
212 (smtpmail-smtp-service .
587)))
215 :enter-func
(lambda () (mu4e-message "Switch to the GNU context"))
216 :match-func
(lambda (msg)
218 (s-prefix?
"/gnu/" (mu4e-message-field msg
:maildir
))))
219 :vars
'((user-mail-address .
"aminb@gnu.org")
220 (mu4e-sent-folder .
"/gnu/Sent")
221 (mu4e-drafts-folder .
"/gnu/Drafts")
222 (mu4e-trash-folder .
"/gnu/Trash")
223 (mu4e-sent-messages-behavior . sent
)
224 (smtpmail-default-smtp-server .
"fencepost.gnu.org")
225 (smtpmail-smtp-server .
"fencepost.gnu.org")
226 (smtpmail-stream-type . starttls
)
227 (smtpmail-smtp-service .
587)))))
228 (with-eval-after-load 'mu4e-alert
229 ;; Enable Desktop notifications
230 (mu4e-alert-set-default-style 'notifications
))))
232 (use-package gnus-dired
233 ;; A special version of the gnus-dired-mail-buffers function
234 ;; that understands mu4e buffers as well.
235 ;; Usage: mark the file(s) in dired and press C-c RET C-a,
236 ;; then will be asked whether to attach them to an existing
237 ;; message, or create a new one.
241 ;; make the `gnus-dired-mail-buffers' function also work on
242 ;; message-mode derived modes, such as mu4e-compose-mode
243 (defun gnus-dired-mail-buffers ()
244 "Return a list of active message buffers."
247 (dolist (buffer (buffer-list t
))
249 (when (and (derived-mode-p 'message-mode
)
250 (null message-sent-message-via
))
251 (push (buffer-name buffer
) buffers
))))
253 (setq gnus-dired-mail-mode
'mu4e-user-agent
)
254 (add-hook 'dired-mode-hook
'turn-on-gnus-dired-mode
))
257 ;; Exclude the files in maildir from recents
261 (add-to-list 'recentf-exclude
(expand-file-name maildir
)))
263 (spacemacs/set-leader-keys
267 (defun aminb/init-smtpmail
()
268 (use-package smtpmail
271 (setq smtpmail-default-smtp-server
"nix.aminb.org"
272 smtpmail-local-domain
"aminb.org"
273 smtpmail-smtp-server
"nix.aminb.org"
274 smtpmail-stream-type
'starttls
275 smtpmail-smtp-service
587
276 send-mail-function
'smtpmail-send-it
)))
278 ;;; packages.el ends here