(mime-article/grab-message/partials): Unused local variable `mother'
[elisp/semi.git] / mime-partial.el
1 ;;; mime-partial.el --- Grabbing all MIME "message/partial"s.
2
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
4
5 ;; Author: OKABE Yasuo @ Kyoto University
6 ;;         MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Version:
8 ;;      $Id: mime-partial.el,v 0.4 1997-03-15 20:29:25 morioka Exp $ 
9 ;; Keywords: message/partial, MIME, multimedia, mail, news
10
11 ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Code:
29
30 (require 'mime-view)
31 (require 'mime-play)
32
33 (defvar mime-partial/preview-article-method-alist nil)
34    
35 ;; display Article at the cursor in Subject buffer.
36 (defun mime-partial/preview-article (target)
37   (save-window-excursion
38     (let ((f (assq target mime-partial/preview-article-method-alist)))
39       (if f
40           (funcall (cdr f))
41         (error "Fatal. Unsupported mode")
42         ))))
43
44 (defun mime-article/grab-message/partials (beg end cal)
45   (interactive)
46   (let* ((id (cdr (assoc "id" cal)))
47          (target (cdr (assq 'major-mode cal)))
48          (article-buffer (buffer-name (current-buffer)))
49          (subject-buf (eval (cdr (assq 'summary-buffer-exp cal))))
50          subject-id
51          (root-dir (expand-file-name
52                     (concat "m-prts-" (user-login-name)) mime-temp-directory))
53          full-file)
54     (setq root-dir (concat root-dir "/" (replace-as-filename id)))
55     (setq full-file (concat root-dir "/FULL"))
56     
57     (if (null target)
58         (error "%s is not supported. Sorry." target)
59       )
60     
61     ;; if you can't parse the subject line, try simple decoding method
62     (if (or (file-exists-p full-file)
63             (not (y-or-n-p "Merge partials?"))
64             )
65         (mime-article/decode-message/partial beg end cal)
66       (let (cinfo the-id parameters)
67         (setq subject-id (std11-field-body "Subject"))
68         (if (string-match "[0-9\n]+" subject-id)
69             (setq subject-id (substring subject-id 0 (match-beginning 0)))
70           )
71         (save-excursion
72           (set-buffer subject-buf)
73           (while (search-backward subject-id nil t))
74           (catch 'tag
75             (while t
76               (mime-partial/preview-article target)
77               (set-buffer article-buffer)
78               (set-buffer mime::article/preview-buffer)
79               (setq cinfo
80                     (mime::preview-content-info/content-info
81                      (car mime::preview/content-list)))
82               (setq parameters (mime::content-info/parameters cinfo))
83               (setq the-id (cdr (assoc "id" parameters)))
84               (if (equal the-id id)
85                   (progn
86                     (set-buffer article-buffer)
87                     (mime-article/decode-message/partial
88                      (point-min)(point-max) parameters)
89                     (if (file-exists-p full-file)
90                         (throw 'tag nil)
91                       )
92                     ))
93               (if (not (progn
94                          (set-buffer subject-buf)
95                          (end-of-line)
96                          (search-forward subject-id nil t)
97                          ))
98                   (error "not found")
99                 )
100               )
101             ))))))
102
103
104 ;;; @ end
105 ;;;
106
107 (provide 'mime-partial)
108
109 (run-hooks 'mime-partial-load-hook)
110
111 ;;; mime-partial.el ends here