1 ;;; mixi-wl.el --- Wanderlust integration for mixi
3 ;; Copyright (C) 2007 OHASHI Akira
5 ;; Author: OHASHI Akira <bg66@koka-in.org>
8 ;; This file is *NOT* a part of Wanderlust.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
27 ;; To use, add the following lines to your ~/.emacs:
29 ;; (autoload 'mixi-wl-setup "mixi-wl")
30 ;; (add-hook 'wl-init-hook 'mixi-wl-setup)
32 ;; If you have bug reports and/or suggestions for improvement, please
33 ;; send them via <URL:http://mixi.jp/view_community.pl?id=1596390>.
40 (defsubst mixi-wl-get-recipients-from-buffer ()
41 (or (std11-field-body "mixi-to")
42 (std11-field-body "to")))
44 (defun wl-draft-send-mail-with-mixi ()
45 "Send the prepared message buffer with mixi."
46 (let* ((case-fold-search t)
47 (default-case-fold-search t)
48 (recipients (mixi-wl-get-recipients-from-buffer)))
49 (let ((delimline (save-excursion
50 (goto-char (point-min))
52 (concat "^" (regexp-quote mail-header-separator)
55 (id (std11-field-body "message-id")))
56 (mixi-send-mail recipients
57 (eword-decode-string (or (std11-field-body "subject")
59 (decode-mime-charset-string
60 (buffer-substring (1+ delimline) (point-max))
62 (wl-draft-set-sent-message 'mail 'sent)
63 (wl-draft-write-sendlog 'ok 'mixi nil (list recipients) id))))
65 (defun mixi-wl-setup-draft-buffer ()
66 (let ((recipients (mixi-wl-get-recipients-from-buffer)))
68 (string-match mixi-to-regexp recipients))
69 (make-local-variable 'wl-draft-send-confirm-with-preview)
70 (setq wl-draft-send-confirm-with-preview nil)
71 (make-local-variable 'wl-draft-send-mail-function)
72 (setq wl-draft-send-mail-function 'wl-draft-send-mail-with-mixi))))
74 (defun mixi-wl-setup ()
75 (add-hook 'wl-draft-send-hook 'mixi-wl-setup-draft-buffer))
79 ;;; mixi-wl.el ends here