From: bg66 Date: Tue, 9 Jan 2007 03:18:11 +0000 (+0000) Subject: * mixi-gnus.el: New file. X-Git-Tag: mixi-el-1_0_0~125 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=872ea3f9f91416b4a534d6a311379ead87394f39;p=elisp%2Fmixi.git * mixi-gnus.el: New file. * sb-mixi.el (shimbun-mixi-send-mail): Rename from `shimbun-mixi-send-mail-wrapper'. --- diff --git a/ChangeLog b/ChangeLog index 1954e9c..fd362d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-01-09 OHASHI Akira + + * mixi-gnus.el: New file. + + * sb-mixi.el (shimbun-mixi-send-mail): Rename from + `shimbun-mixi-send-mail-wrapper'. + 2007-01-08 OHASHI Akira * mixi.el (mixi-backend): Rename from `mixi-retrieve-function' and diff --git a/mixi-gnus.el b/mixi-gnus.el new file mode 100644 index 0000000..2397ddc --- /dev/null +++ b/mixi-gnus.el @@ -0,0 +1,86 @@ +;;; mixi-gnus.el --- Gnus integration for mixi + +;; Copyright (C) 2007 OHASHI Akira + +;; Author: OHASHI Akira +;; Keywords: news + +;; This file is *NOT* a part of Gnus. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, you can either send email to this +;; program's maintainer or write to: The Free Software Foundation, +;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; To use, add the following lines to your ~/.emacs: +;; +;; (autoload 'mixi-gnus-setup "mixi-gnus") +;; (add-hook 'gnus-startup-hook 'mixi-gnus-setup) + +;; If you have bug reports and/or suggestions for improvement, please +;; send them via . + +;;; Code: + +(require 'sb-mixi) +(require 'message) + +(defun message-mixi-p () + "Say whether the current buffer contains a mixi message." + (and (not message-this-is-news) + (or message-this-is-mail + (save-excursion + (save-restriction + (message-narrow-to-headers) + (or (message-fetch-field "mixi") + (string-match shimbun-mixi-to-regexp + (message-fetch-field "to")))))))) + +(defun message-send-via-mixi (arg) + "Send the current message via mixi." + (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp")) + (case-fold-search nil) + (mailbuf (current-buffer))) + ;; Avoid matching with message-mail-p. + (with-current-buffer mailbuf + (goto-char (point-min)) + (when (search-forward "\nTo: " nil t) + (replace-match "\nMixi: "))) + (unwind-protect + (save-excursion + (set-buffer tembuf) + (erase-buffer) + ;; Avoid copying text props (except hard newlines). + (insert (with-current-buffer mailbuf + (mml-buffer-substring-no-properties-except-hard-newlines + (point-min) (point-max)))) + (shimbun-mixi-send-mail (message-fetch-field "mixi") + (message-fetch-field "subject") + (buffer-substring (message-goto-body) + (point-max)))) + (kill-buffer tembuf)) + (set-buffer mailbuf) + (push 'mixi message-sent-message-via))) + +(defun mixi-gnus-setup () + (let ((method '(mixi message-mixi-p message-send-via-mixi))) + (unless (member method message-send-method-alist) + (setq message-send-method-alist + (cons '(mixi message-mixi-p message-send-via-mixi) + message-send-method-alist))))) + +(provide 'mixi-gnus) + +;;; mixi-gnus.el ends here diff --git a/sb-mixi.el b/sb-mixi.el index 25ce539..2201024 100644 --- a/sb-mixi.el +++ b/sb-mixi.el @@ -289,7 +289,7 @@ of mixi object." (defconst shimbun-mixi-to-regexp "^mixi;\\([a-z]+\\);?\\([a-z0-9]+\\)?;?\\([0-9]+\\)?;?\\([0-9]+\\)?") -(defun shimbun-mixi-send-mail-wrapper (to title content) +(defun shimbun-mixi-send-mail (to title content) (when (string-match shimbun-mixi-to-regexp to) (let ((method (match-string 1 to))) (cond ((string= method "comment")