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