dfcddf2c6d1acc66955cc9070e6e28be2db17a74
[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 (eval-after-load "mailcrypt"
41 '(setq mc-modes-alist
42 (append
43 (quote
44 ((wl-draft-mode (encrypt . mc-encrypt-message)
45 (sign . mc-sign-message))
46 (wl-summary-mode (decrypt . mc-wl-decrypt-message)
47 (verify . mc-wl-verify-signature))))
48 mc-modes-alist)))
49 (add-hook 'wl-summary-mode-hook
50 ;; Set keybindings for
51 ;; PGP-Inline
52 '(lambda ()
53 (local-set-key "k" '(lambda ()
54 (interactive)
55 (save-window-excursion
56 (wl-summary-jump-to-current-message)
57 (gpcf-decrypt-mail))))
58 (local-set-key "0" 'mc-wl-verify-signature)
59 (local-set-key "X" '(lambda ()
60 ; checks for mail remotely using rsync.
61 (interactive)
62 (shell-command
63 (concat (expand-file-name "~/software/mail/getmail.sh") " > /dev/null 2>&1"))
64 (wl-summary-incorporate)
65 ))
66 ))
67 (defun gpcf-decrypt-mail ()
68 "Decrypts mail in MIME preview buffer. Works with both PGP/MIME
69 and PGP-Inline"
70 (interactive)
71 (save-excursion
72 (beginning-of-buffer)
73 (cond
74 ;; PGP/MIME
75 ((search-forward "<application/pgp-encrypted" nil t)
76 (let ((id "") (mess ""))
77 (save-window-excursion
78 (mime-preview-extract-current-entity)
79 (when (string-match "-[0-9]+" (buffer-name))
80 (setq id (substring (buffer-name) (match-beginning 0) (match-end 0)))
81 ))
82 (search-forward "]")
83 (save-window-excursion
84 (switch-to-buffer (concat "*Preview- *WL:Message*" id "*"))
85 (let ((temp-point (point)))
86 (end-of-buffer)
87 (setq mess (buffer-substring temp-point (point)))
88 (kill-buffer))
89 )
90 (let ((temp-point (point)) (inhibit-read-only t))
91 (search-backward "This part is encrypted" nil t)
92 (delete-region (point) temp-point)
93 (insert mess)
94 )))
95 ;;; PGP/INLINE
96 ((search-forward "-----BEGIN PGP MESSAGE-----" nil t)
97 (let ((inhibit-read-only t))
98 (mc-decrypt)))
99 (t (error "No GPG encrypted message found in this file."))))
100 )
101
102 (autoload 'sm-add-emacs-name "silly-mail" nil t)
103 (defun gpcf-setup-mail ()
104 "This function prepares the draft mode.
105 It add headers and defines keyboard shortcuts. Before the
106 message is sent, it adds the user's signature."
107 (if (string= "*draft*" (buffer-name))
108 (progn
109 (setq enc-color (face-remap-add-relative 'mode-line :background "dark red"))
110 (set-input-method "TeX")
111 (sm-add-emacs-name) ;; add silly headers
112 (sm-add-microsoft)
113 (sm-put-header "X-PGP-Key" "http://gpcf.eu/key.asc")
114 (local-set-key (kbd "C-c e") '(lambda ()
115 (interactive)
116 (mime-edit-set-encrypt t)
117 (mime-edit-set-sign t)
118 (message
119 "This message will be signed and encrypted")
120 (face-remap-remove-relative enc-color)
121 ))
122 (local-set-key (kbd "C-c s") 'ispell-message)
123 (local-set-key (kbd "C-c c") '(lambda ()
124 ;;; save email to queue and send it using SSH.
125 (interactive)
126 (wl-draft-send-and-exit)
127 (call-process-shell-command
128 (concat (expand-file-name "~/software/mail/sendmail.sh") "&")
129 nil 0)
130 ))
131 (delete-other-windows))
132 (mail-signature) ;; add signature
133 ))
134
135 (add-hook 'mime-edit-mode-hook 'gpcf-setup-mail)
136 ; single window mode.
137 (setq wl-stay-folder-window nil
138 wl-draft-use-frame nil
139 wl-summary-move-order 'unread
140 )
141 ;; Prevent wl from splitting large messages
142 (setq mime-edit-split-message nil)
143
144 ;; my E-Mail addresses:
145 (setq wl-user-mail-address-list '("gabriel@gpcf.eu"
146 "gpcf@gpcf.eu"))
147 (setq wl-summary-showto-folder-regexp ".*sent.*")
148
149 ;; AUTO-REFILE rules
150 (load "~/.emacs.d/files/refile-rules.el")