c536e88f799fdd091c64e40d4993d45f511c5459
[dotfiles.git] / .wl
1 ;; mode: -*-emacs-lisp-*-
2 ;
3 (load "silly-mail" nil t)
4 (setq wl-stay-folder-window t
5 wl-local-domain "gpcf.eu"
6 wl-message-id-domain "aubergine.gpcf.eu"
7 wl-from (concat user-full-name " <" user-mail-address ">")
8 ;; here starts all the maildir stuff
9 elmo-maildir-folder-path "~/Maildir"
10 wl-fcc ".sent"
11 wl-trash-folder ".trash"
12 wl-queue-folder ".queue"
13 signature-file-name "~/.signature"
14 signature-insert-at-eof t
15 signature-delete-blank-lines-at-eof t
16 wl-draft-send-mail-function 'wl-draft-send-mail-with-sendmail
17 sendmail-program (expand-file-name "~/software/mail/savemail.py")
18 default-mime-charset 'utf8
19 wl-fcc-force-as-read t
20 wl-interactive-send nil
21 wl-summary-width 120
22 mime-pgp-decrypt-when-preview t
23 )
24 (add-hook 'mime-view-mode-hook
25 '(lambda () (local-set-key (kbd "ä") 'wl-next-message)
26 (local-set-key (kbd "ö") 'wl-prev-message))
27 )
28 (setq mime-edit-insert-user-agent-field nil)
29
30 (setq wl-generate-mailer-string-function
31 ; set X-Mailer string
32 (function
33 (lambda ()
34 (format "GNU Emacs Version 24.3, %s, GNU/Linux" (product-string-1 'wl-version)))))
35
36 (setq wl-demo-display-logo nil)
37 (mc-install-read-mode)
38
39
40 (defun mc-wl-verify-signature ()
41 (interactive)
42 (save-window-excursion
43 (wl-summary-jump-to-current-message)
44 (mc-verify)))
45
46 (eval-after-load "mailcrypt"
47 '(setq mc-modes-alist
48 (append
49 (quote
50 ((wl-draft-mode (encrypt . mc-encrypt-message)
51 (sign . mc-sign-message))
52 (wl-summary-mode (decrypt . mc-wl-decrypt-message)
53 (verify . mc-wl-verify-signature))))
54 mc-modes-alist)))
55 (add-hook 'wl-summary-mode-hook
56 ;; Set keybindings for
57 ;; PGP-Inline
58 '(lambda ()
59 (local-set-key "k" '(lambda ()
60 (interactive)
61 (save-window-excursion
62 (wl-summary-jump-to-current-message)
63 (gpcf-decrypt-mail))))
64 (local-set-key "0" 'mc-wl-verify-signature)
65 (local-set-key (kbd "ä") 'wl-next-message)
66 (local-set-key (kbd "ö") 'wl-prev-message)
67 (local-set-key (kbd "<return>") '(lambda () (interactive) (wl-summary-redisplay)
68 (wl-summary-jump-to-current-message)
69 (delete-other-windows)) )
70 (local-set-key "X" '(lambda ()
71 ; checks for mail remotely using rsync.
72 (interactive)
73 (shell-command
74 (concat (expand-file-name "~/software/mail/getmail.sh") " > /dev/null 2>&1"))
75 (wl-summary-incorporate)
76 ))
77 ))
78 (defun gpcf-decrypt-mail ()
79 "Decrypts mail in MIME preview buffer. Works with both PGP/MIME
80 and PGP-Inline. OBSOLETE FOR PGP/MIME, USE (setq mime-pgp-decrypt-when-preview t) instead."
81 (interactive)
82 (save-excursion
83 (beginning-of-buffer)
84 (cond
85 ;; PGP/MIME
86 ((search-forward "<application/pgp-encrypted" nil t)
87 (let ((id "") (mess ""))
88 (save-window-excursion
89 (mime-preview-extract-current-entity)
90 (when (string-match "-[0-9]+" (buffer-name))
91 (setq id (substring (buffer-name) (match-beginning 0) (match-end 0)))
92 ))
93 (search-forward "]")
94 (save-window-excursion
95 (switch-to-buffer (concat "*Preview- *WL:Message*" id "*"))
96 (let ((temp-point (point)))
97 (end-of-buffer)
98 (setq mess (buffer-substring temp-point (point)))
99 (kill-buffer))
100 )
101 (let ((temp-point (point)) (inhibit-read-only t))
102 (search-backward "This part is encrypted" nil t)
103 (delete-region (point) temp-point)
104 (insert mess)
105 )))
106 ;;; PGP/INLINE
107 ((search-forward "-----BEGIN PGP MESSAGE-----" nil t)
108 (let ((inhibit-read-only t))
109 (mc-decrypt)))
110 (t (error "No GPG encrypted message found in this file."))))
111 )
112
113
114 (defun gpcf-setup-mail ()
115 "This function prepares the draft mode.
116 It add headers and defines keyboard shortcuts. Before the
117 message is sent, it adds the user's signature."
118 (if (string-match-p "\\*draft\\*.*" (buffer-name))
119 (progn
120 (setq enc-color (face-remap-add-relative 'mode-line :background "dark red"))
121 (set-input-method "TeX")
122 (auto-fill-mode)
123 (setq default-justification 'full)
124 (sm-add-microsoft)
125 (sm-add-emacs-name)
126 (sm-put-header "X-PGP-Key" "http://en.gpcf.eu/key.asc")
127 (local-set-key (kbd "C-c e") '(lambda ()
128 (interactive)
129 (mime-edit-set-encrypt t)
130 (mime-edit-set-sign t)
131 (message
132 "This message will be signed and encrypted")
133 (face-remap-remove-relative enc-color)
134 ))
135 (local-set-key (kbd "C-c s") 'ispell-message)
136 (local-set-key (kbd "C-c c") '(lambda ()
137 ;;; save email to queue and send it using SSH.
138 (interactive)
139 (wl-draft-send-and-exit)
140 (call-process-shell-command
141 (concat (expand-file-name "~/software/mail/sendmail.sh") "&")
142 nil 0)
143 ))
144 (delete-other-windows))
145 (mail-signature) ;; add signature
146 ))
147
148 (add-hook 'mime-edit-mode-hook 'gpcf-setup-mail)
149 ; single window mode.
150 (setq wl-stay-folder-window nil
151 wl-draft-use-frame nil
152 wl-summary-move-order 'new
153 )
154 ;; Prevent wl from splitting large messages
155 (setq mime-edit-split-message nil)
156
157 ;; my E-Mail addresses:
158 (setq wl-user-mail-address-list '("gabriel@gpcf.eu"
159 "gpcf@gpcf.eu"))
160 (setq wl-summary-showto-folder-regexp ".*sent.*")
161
162 ;; AUTO-REFILE rules
163 (load "~/.emacs.d/files/refile-rules.el")
164 (defadvice mime-preview-quit (after mime-preview-quit activate)
165 (delete-other-windows)
166 )
167 (defun wl-delete-other-windows ()
168 (wl-summary-jump-to-current-message)
169 (delete-other-windows)
170 )
171 (defadvice wl-summary-next (after wl-summary-next activate)
172 (wl-delete-other-windows)
173 )
174 (defadvice wl-summary-prev (after wl-summary-prev activate)
175 (wl-delete-other-windows)
176 )
177 (defun wl-next-message ()
178 (interactive)
179 (if (string= (buffer-name) "Summary")
180 (wl-summary-next)
181 (progn
182 (mime-preview-quit)
183 (wl-summary-next))))
184 (defun wl-prev-message ()
185 (interactive)
186 (if (string= (buffer-name) "Summary")
187 (wl-summary-prev)
188 (progn
189 (mime-preview-quit)
190 (wl-summary-prev))))
191