-
Notifications
You must be signed in to change notification settings - Fork 15
/
mime-partial.el
90 lines (74 loc) · 3.12 KB
/
mime-partial.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;;; mime-partial.el --- Grabbing all MIME "message/partial"s. -*- lexical-binding: t -*-
;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
;; Author: OKABE Yasuo @ Kyoto University
;; MORIOKA Tomohiko <[email protected]>
;; Keywords: message/partial, MIME, multimedia, mail, news
;; This file is part of SEMI (Suite of Emacs MIME Interfaces).
;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(require 'mime-view)
(require 'mime-play)
(defun mime-combine-message/partial-pieces-automatically (entity situation)
"Internal method for mime-view to combine message/partial messages
automatically."
(interactive)
(let* ((id (cdr (assoc "id" situation)))
(target (cdr (assq 'major-mode situation)))
(subject-buf (eval (cdr (assq 'summary-buffer-exp situation))))
(mother (current-buffer))
subject-id
(root-dir (expand-file-name
(concat "m-prts-" (user-login-name))
temporary-file-directory))
(request-partial-message-method
(cdr (assq 'request-partial-message-method situation)))
full-file)
(setq root-dir (concat root-dir "/" (replace-as-filename id)))
(setq full-file (concat root-dir "/FULL"))
(if (null target)
(error "%s is not supported. Sorry." target))
;; if you can't parse the subject line, try simple decoding method
(if (or (file-exists-p full-file)
(not (y-or-n-p "Merge partials?")))
(mime-store-message/partial-piece entity situation)
(setq subject-id (mime-entity-read-field entity 'Subject))
(if (string-match "[0-9\n]+" subject-id)
(setq subject-id (substring subject-id 0 (match-beginning 0))))
;; Do not use `with-current-buffer'. Inner save-excursion(),
;; the current buffer may be accessed.
(save-excursion
(set-buffer subject-buf)
(while (search-backward subject-id nil t))
(catch 'tag
(while t
(let* ((message
;; request message at the cursor in Subject buffer.
(save-window-excursion
(funcall request-partial-message-method)))
(situation (mime-entity-situation message))
(the-id (cdr (assoc "id" situation))))
(when (string= the-id id)
(with-current-buffer mother
(mime-store-message/partial-piece message situation))
(if (file-exists-p full-file)
(throw 'tag nil)))
(if (not (progn
(end-of-line)
(search-forward subject-id nil t)))
(error "not found")))))))))
;;; @ end
;;;
(provide 'mime-partial)
(run-hooks 'mime-partial-load-hook)
;;; mime-partial.el ends here