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