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 this program; if not, you can either send email to this
22 ;; program's maintainer or write to: The Free Software Foundation,
23 ;; Inc.; 51 Franklin Street, Fifth Floor, 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>.
39 ;; Functions and variables which should be defined in the other module
42 (defvar mail-header-separator)
43 (defvar wl-mime-charset)
44 (defvar wl-draft-send-confirm-with-preview)
45 (defvar wl-draft-send-mail-function)
46 (autoload 'std11-field-body "std11")
47 (autoload 'eword-decode-string "eword-decode")
48 (autoload 'wl-draft-set-sent-message "wl-draft")
49 (autoload 'wl-draft-write-sendlog "wl-draft")
50 (autoload 'decode-mime-charset-string "mcharset"))
52 (defsubst mixi-wl-get-recipients-from-buffer ()
53 (or (std11-field-body "mixi-to")
54 (std11-field-body "to")))
56 (defun wl-draft-send-mail-with-mixi ()
57 "Send the prepared message buffer with mixi."
58 (let* ((case-fold-search t)
59 (default-case-fold-search t)
60 (recipients (mixi-wl-get-recipients-from-buffer)))
61 (let ((delimline (save-excursion
62 (goto-char (point-min))
64 (concat "^" (regexp-quote mail-header-separator)
67 (id (std11-field-body "message-id")))
68 (shimbun-mixi-send-mail recipients
70 (std11-field-body "subject"))
71 (decode-mime-charset-string
72 (buffer-substring (1+ delimline)
75 (wl-draft-set-sent-message 'mail 'sent)
76 (wl-draft-write-sendlog 'ok 'mixi nil (list recipients) id))))
78 (defun mixi-wl-setup-draft-buffer ()
79 (when (string-match shimbun-mixi-to-regexp
80 (mixi-wl-get-recipients-from-buffer))
81 (make-local-variable 'wl-draft-send-confirm-with-preview)
82 (setq wl-draft-send-confirm-with-preview nil)
83 (make-local-variable 'wl-draft-send-mail-function)
84 (setq wl-draft-send-mail-function 'wl-draft-send-mail-with-mixi)))
86 (defun mixi-wl-setup ()
87 (add-hook 'wl-draft-send-hook 'mixi-wl-setup-draft-buffer))
91 ;;; mixi-wl.el ends here