1 ;;; mixi-gnus.el --- Gnus 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 Gnus.
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-gnus-setup "mixi-gnus")
30 ;; (add-hook 'gnus-startup-hook 'mixi-gnus-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 (defun message-mixi-p ()
41 "Say whether the current buffer contains a mixi message."
42 (and (not message-this-is-news)
45 (message-narrow-to-headers)
46 (or (message-fetch-field "mixi-to")
47 (string-match mixi-to-regexp (message-fetch-field "to")))))))
49 (defun message-send-via-mixi (arg)
50 "Send the current message via mixi."
51 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp"))
52 (case-fold-search nil)
53 (mailbuf (current-buffer)))
54 ;; Avoid matching with message-mail-p.
55 (with-current-buffer mailbuf
56 (goto-char (point-min))
57 (unless (search-forward "\nMixi-To: " nil t)
58 (when (search-forward "\nTo: " nil t)
59 (replace-match "\nMixi-To: "))))
64 ;; Avoid copying text props (except hard newlines).
65 (insert (with-current-buffer mailbuf
66 (mml-buffer-substring-no-properties-except-hard-newlines
67 (point-min) (point-max))))
68 (mixi-send-mail (message-fetch-field "mixi-to")
69 (message-fetch-field "subject")
70 (buffer-substring (message-goto-body)
74 (push 'mixi message-sent-message-via)))
76 (defun mixi-gnus-setup ()
77 (let ((method '(mixi message-mixi-p message-send-via-mixi)))
78 (unless (member method message-send-method-alist)
79 (setq message-send-method-alist
80 (cons method message-send-method-alist)))))
84 ;;; mixi-gnus.el ends here