~ubuntu-branches/ubuntu/trusty/semi/trusty

« back to all changes in this revision

Viewing changes to mime-partial.el

  • Committer: Bazaar Package Importer
  • Author(s): Tatsuya Kinoshita
  • Date: 2004-05-23 00:54:01 UTC
  • Revision ID: james.westby@ubuntu.com-20040523005401-0216ggl5q8ibm9ni
Tags: upstream-1.14.6+0.20040418
ImportĀ upstreamĀ versionĀ 1.14.6+0.20040418

Show diffs side-by-side

added added

removed removed

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