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
22 ;; mu4e has to be installed manually,
23 ;; and make sure it's in load-path
25 (mu4e-contrib :location site
)
29 "The list of Lisp packages required by the aminb layer.")
31 (defun aminb/init-creamsody-theme
())
33 (defun aminb/init-crux
()
36 :bind
(("C-c d" . crux-duplicate-current-line-or-region
)
37 ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region
)
40 (defun aminb/init-writeroom-mode
()
41 (use-package writeroom-mode
; Distraction-free editing
43 :config
(setq writeroom-width
82)
44 :bind
(("C-c W" . writeroom-mode
)
45 ("s-?" . writeroom-toggle-mode-line
))))
47 (defun aminb/init-znc
()
51 (spacemacs/set-leader-keys
55 ;; Set the erc nick completion postfix to ", "
56 (setq erc-pcomplete-nick-postfix
", ")
58 ;; Restore channel buffers from logs
59 (setq erc-log-insert-log-on-open t
)
61 (defun vbe:znc-add-server
(server port user networks
)
62 "Add a server to the list of ZNC servers.
63 We use SSL inconditionaly. Moreover, we don't store the password
64 but put nil instead. At least, we tweak the username to contain
65 the network name later, this will be separated again."
66 (add-to-list 'znc-servers
70 (mapcar (function (lambda (slug) (list slug
71 (format "%s/%s" user slug
)
75 (defun vbe:znc-erc-ssl-connector
(&rest R
)
76 "Connect to ERC using SSL and retrieve password with `auth-source-search'.
77 Moreover, handle multiple networks by sending the password with
78 the appropriate network slug that we extract from the nick."
79 (let* ((user (nth 0 (split-string (plist-get R
:nick
) "/")))
80 (slug (nth 1 (split-string (plist-get R
:nick
) "/")))
81 (found (nth 0 (auth-source-search :host
(plist-get R
:server
)
83 :require
'(:user
:secret
)
86 (let ((password (let ((secret (plist-get found
:secret
)))
87 (if (functionp secret
)
90 (plist-put R
:password
(format "%s/%s:%s" user slug password
))
91 (plist-put R
:nick user
)
92 (apply 'erc-tls R
)))))
93 (setq znc-erc-ssl-connector
'vbe
:znc-erc-ssl-connector
)
96 (vbe:znc-add-server
"nix.aminb.org" 6669 "amin"
99 ;; https://www.emacswiki.org/emacs/ErcBar
100 ;; Display a bar before unread messages
101 (eval-after-load 'erc-track
103 (defun erc-bar-move-back (n)
104 "Moves back n message lines. Ignores wrapping, and server messages."
105 (interactive "nHow many lines ? ")
106 (re-search-backward "^.*<.*>" nil t n
))
108 (defun erc-bar-update-overlay ()
109 "Update the overlay for current buffer, based on the content of
110 erc-modified-channels-alist. Should be executed on window change."
112 (let* ((info (assq (current-buffer) erc-modified-channels-alist
))
114 (if (and info
(> count erc-bar-threshold
))
117 (when (erc-bar-move-back count
)
118 (let ((inhibit-field-text-motion t
))
119 (move-overlay erc-bar-overlay
120 (line-beginning-position)
123 (delete-overlay erc-bar-overlay
))))
125 (defvar erc-bar-threshold
1
126 "Display bar when there are more than erc-bar-threshold unread messages.")
127 (defvar erc-bar-overlay nil
128 "Overlay used to set bar")
129 (setq erc-bar-overlay
(make-overlay 0 0))
130 (overlay-put erc-bar-overlay
'face
'(:underline
"purple"))
131 ;;put the hook before erc-modified-channels-update
132 (defadvice erc-track-mode
(after erc-bar-setup-hook
133 (&rest args
) activate
)
134 ;;remove and add, so we know it's in the first place
135 (remove-hook 'window-configuration-change-hook
'erc-bar-update-overlay
)
136 (add-hook 'window-configuration-change-hook
'erc-bar-update-overlay
))
137 (add-hook 'erc-send-completed-hook
(lambda (str)
138 (erc-bar-update-overlay)))))
142 (defun aminb/post-init-mu4e
()
143 (setq maildir
"~/mail")
148 (setq mu4e-maildir maildir
149 mu4e-get-mail-command
"true"
150 mu4e-update-interval
300
151 mu4e-view-show-addresses t
152 mu4e-headers-include-related t
153 mu4e-enable-notifications t
154 mu4e-enable-mode-line t
155 mu4e-compose-signature-auto-include t
156 mu4e-compose-signature
160 message-kill-buffer-on-exit t
; don't keep message buffers around
161 mu4e-attachment-dir
"~/dls"
162 mu4e-sent-folder
"/amin/Sent"
163 mu4e-drafts-folder
"/amin/Drafts"
164 mu4e-trash-folder
"/amin/Trash"
165 user-full-name
"Amin Bandali"
166 user-mail-address
"amin@aminb.org"
167 mu4e-context-policy
'pick-first
169 (list (make-mu4e-context
171 :enter-func
(lambda () (mu4e-message "Switch to the Personal context"))
172 :match-func
(lambda (msg)
174 (s-prefix?
"/amin/" (mu4e-message-field msg
:maildir
))))
175 :vars
'((user-mail-address .
"amin@aminb.org")
176 (mu4e-sent-folder .
"/amin/Sent")
177 (mu4e-drafts-folder .
"/amin/Drafts")
178 (mu4e-trash-folder .
"/amin/Trash")
179 (mu4e-sent-messages-behavior . sent
)
180 (smtpmail-default-smtp-server .
"nix.aminb.org")
181 (smtpmail-smtp-server .
"nix.aminb.org")
182 (smtpmail-stream-type . starttls
)
183 (smtpmail-smtp-service .
587)))
186 :enter-func
(lambda () (mu4e-message "Switch to the BB context"))
187 :match-func
(lambda (msg)
189 (s-prefix?
"/gmail/" (mu4e-message-field msg
:maildir
))))
190 :vars
'((user-mail-address .
"amin.bandali@gmail.com")
191 (mu4e-sent-folder .
"/gmail/Sent")
192 (mu4e-drafts-folder .
"/gmail/Drafts")
193 (mu4e-trash-folder .
"/gmail/Trash")
194 (mu4e-sent-messages-behavior . delete
)
195 (mu4e-compose-signature . nil
)
196 (smtpmail-default-smtp-server .
"smtp.gmail.com")
197 (smtpmail-smtp-server .
"smtp.gmail.com")
198 (smtpmail-stream-type . starttls
)
199 (smtpmail-smtp-service .
587)))
202 :enter-func
(lambda () (mu4e-message "Switch to the GNU context"))
203 :match-func
(lambda (msg)
205 (s-prefix?
"/gnu/" (mu4e-message-field msg
:maildir
))))
206 :vars
'((user-mail-address .
"aminb@gnu.org")
207 (mu4e-sent-folder .
"/gnu/Sent")
208 (mu4e-drafts-folder .
"/gnu/Drafts")
209 (mu4e-trash-folder .
"/gnu/Trash")
210 (mu4e-sent-messages-behavior . sent
)
211 (smtpmail-default-smtp-server .
"fencepost.gnu.org")
212 (smtpmail-smtp-server .
"fencepost.gnu.org")
213 (smtpmail-stream-type . starttls
)
214 (smtpmail-smtp-service .
587)))))
215 (with-eval-after-load 'mu4e-alert
216 ;; Enable Desktop notifications
217 (mu4e-alert-set-default-style 'notifications
))))
219 (use-package gnus-dired
220 ;; A special version of the gnus-dired-mail-buffers function
221 ;; that understands mu4e buffers as well
225 ;; make the `gnus-dired-mail-buffers' function also work on
226 ;; message-mode derived modes, such as mu4e-compose-mode
227 (defun gnus-dired-mail-buffers ()
228 "Return a list of active message buffers."
231 (dolist (buffer (buffer-list t
))
233 (when (and (derived-mode-p 'message-mode
)
234 (null message-sent-message-via
))
235 (push (buffer-name buffer
) buffers
))))
237 (setq gnus-dired-mail-mode
'mu4e-user-agent
)
238 (add-hook 'dired-mode-hook
'turn-on-gnus-dired-mode
))
241 ;; Exclude the files in maildir from recents
245 (add-to-list 'recentf-exclude
(expand-file-name maildir
)))
247 (spacemacs/set-leader-keys
251 (defun aminb/init-mu4e-contrib
()
252 (use-package mu4e-contrib
255 (setq mu4e-html2text-command
'mu4e-shr2text
256 mu4e-view-html-plaintext-ratio-heuristic
10
257 mu4e-view-prefer-html t
)))
259 (defun aminb/init-smtpmail
()
260 (use-package smtpmail
263 (setq smtpmail-default-smtp-server
"nix.aminb.org"
264 smtpmail-local-domain
"aminb.org"
265 smtpmail-smtp-server
"nix.aminb.org"
266 smtpmail-stream-type
'starttls
267 smtpmail-smtp-service
587
268 send-mail-function
'smtpmail-send-it
)))
270 ;;; packages.el ends here