1 ;;; packages.el --- mu4e Layer packages File for Spacemacs
3 ;; Copyright (c) 2012-2014 Sylvain Benner
4 ;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
5 ;; Copyright (c) 2015 Amin Bandali
7 ;; Authors: Amin Bandali <me@aminb.org>
8 ;; Sylvain Benner <sylvain.benner@gmail.com>
9 ;; URL: https://github.com/aminb/dotfiles
11 ;; This file is not part of GNU Emacs; nor that of spacemacs.
17 ;; mu4e is not in any repos, so it's commented
21 "List of all packages to install and/or initialize. Built-in packages
22 which require an initialization must be listed explicitly in the list.")
24 (defvar mu4e-excluded-packages
'()
25 "List of packages to exclude.")
27 (defun get-string-from-file (filePath)
28 "Return filePath's file content."
30 (insert-file-contents filePath
)
32 ;; thanks to “Pascal J Bourguignon” and “TheFlyingDutchman
33 ;; 〔zzbba…@aol.com〕”. 2010-09-02
35 (defun get-passwd-file (name)
36 "Return name's passwd file content"
37 (get-string-from-file (concat "/home/amin/.passwd/" name
)))
42 ;; path to our Maildir directory
43 (setq mu4e-maildir
"/home/amin/.mail")
46 mu4e-get-mail-command
"mbsync -aq" ;; or fetchmail, or ...
47 mu4e-update-interval
300 ;; update every 5 minutes
48 mu4e-sent-folder
"/aminb/Sent"
49 mu4e-drafts-folder
"/aminb/Drafts"
50 mu4e-trash-folder
"/aminb/Trash"
51 user-mail-address
(get-passwd-file "aminb-mail")
52 mu4e-compose-signature
56 smtpmail-default-smtp-server
"mail.aminb.org"
57 smtpmail-local-domain
"aminb.org"
58 smtpmail-smtp-server
"mail.aminb.org"
59 smtpmail-stream-type
'ssl
60 smtpmail-smtp-service
465)
62 (defvar my-mu4e-account-alist
64 (mu4e-sent-folder "/aminb/Sent")
65 (mu4e-drafts-folder "/aminb/Drafts")
66 (mu4e-trash-folder "/aminb/Trash")
67 (user-mail-address (get-passwd-file "aminb-mail"))
68 (user-full-name "Amin Bandali")
69 (smtpmail-default-smtp-server "mail.aminb.org")
70 (smtpmail-local-domain "aminb.org")
71 (smtpmail-smtp-user (get-passwd-file "aminb-user"))
72 (smtpmail-smtp-server "mail.aminb.org")
73 (smtpmail-stream-type ssl
)
74 (smtpmail-smtp-service 465))
75 (user-mail-address (get-passwd-file "gmail-mail"))
77 (mu4e-sent-folder "/gmail/[Gmail].Sent Mail")
78 (mu4e-drafts-folder "/gmail/Drafts")
79 (mu4e-trash-folder "/gmail/Trash")
80 (user-full-name "Amin Bandali")
81 (smtpmail-default-smtp-server "smtp.gmail.com")
82 (smtpmail-local-domain "gmail.com")
83 (smtpmail-smtp-user (get-passwd-file "gmail-mail"))
84 (smtpmail-smtp-server "smtp.gmail.com")
85 (smtpmail-stream-type ssl
)
86 (smtpmail-smtp-service 465))))
88 (defun my-mu4e-set-account ()
89 "Set the account for composing a message."
91 (if mu4e-compose-parent-message
92 (let ((maildir (mu4e-message-field mu4e-compose-parent-message
:maildir
)))
93 (string-match "/\\(.*?\\)/" maildir
)
94 (match-string 1 maildir
))
95 (completing-read (format "Compose with account: (%s) "
96 (mapconcat #'(lambda (var) (car var
))
97 my-mu4e-account-alist
"/"))
98 (mapcar #'(lambda (var) (car var
)) my-mu4e-account-alist
)
99 nil t nil nil
(caar my-mu4e-account-alist
))))
100 (account-vars (cdr (assoc account my-mu4e-account-alist
))))
102 (mapc #'(lambda (var)
103 (set (car var
) (cadr var
)))
105 (error "No email account found"))))
107 (add-hook 'mu4e-compose-pre-hook
'my-mu4e-set-account
)
110 ;; Shortcut for mu4e.
111 (global-set-key (kbd "C-c m") 'mu4e
)
112 (evil-leader/set-key
"am" 'mu4e
)
115 ;; A special version of the gnus-dired-mail-buffers function
116 ;; that understands mu4e buffers as well
117 (require 'gnus-dired
)
118 ;; make the `gnus-dired-mail-buffers' function also work on
119 ;; message-mode derived modes, such as mu4e-compose-mode
120 (defun gnus-dired-mail-buffers ()
121 "Return a list of active message buffers."
124 (dolist (buffer (buffer-list t
))
126 (when (and (derived-mode-p 'message-mode
)
127 (null message-sent-message-via
))
128 (push (buffer-name buffer
) buffers
))))
131 (setq gnus-dired-mail-mode
'mu4e-user-agent
)
132 (add-hook 'dired-mode-hook
'turn-on-gnus-dired-mode
)
134 (require 'mu4e-contrib
)
135 (setq mu4e-html2text-command
'mu4e-shr2text
136 mu4e-view-html-plaintext-ratio-heuristic
10
137 mu4e-view-prefer-html t
)
139 ;; For each package, define a function mu4e/init-<package-mu4e>
141 ;; (defun mu4e/init-my-package ()
142 ;; "Initialize my package"
145 ;; Often the body of an initialize function uses `use-package'
146 ;; For more info on `use-package', see readme:
147 ;; https://github.com/jwiegley/use-package