4
|
1 ;;; tm-view.el --- interactive MIME viewer for GNU Emacs
|
|
2
|
98
|
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
|
4
|
4
|
|
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
6 ;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el)
|
136
|
7 ;; Version: $Revision: 1.4 $
|
4
|
8 ;; Keywords: mail, news, MIME, multimedia
|
|
9
|
|
10 ;; This file is part of tm (Tools for MIME).
|
|
11
|
|
12 ;; This program is free software; you can redistribute it and/or
|
|
13 ;; modify it under the terms of the GNU General Public License as
|
|
14 ;; published by the Free Software Foundation; either version 2, or (at
|
|
15 ;; your option) any later version.
|
|
16
|
|
17 ;; This program is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
25 ;; Boston, MA 02111-1307, USA.
|
|
26
|
|
27 ;;; Code:
|
|
28
|
|
29 (require 'tl-str)
|
|
30 (require 'tl-list)
|
|
31 (require 'tl-atype)
|
|
32 (require 'tl-misc)
|
|
33 (require 'std11)
|
|
34 (require 'mel)
|
|
35 (require 'tm-ew-d)
|
|
36 (require 'tm-def)
|
|
37 (require 'tm-parse)
|
|
38 (require 'tm-text)
|
|
39
|
|
40
|
|
41 ;;; @ version
|
|
42 ;;;
|
|
43
|
|
44 (defconst mime-viewer/RCS-ID
|
136
|
45 "$Id: tm-view.el,v 1.4 1997/04/24 04:00:14 steve Exp $")
|
4
|
46
|
|
47 (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID))
|
|
48 (defconst mime/viewer-version mime-viewer/version)
|
|
49
|
|
50
|
|
51 ;;; @ variables
|
|
52 ;;;
|
|
53
|
|
54 (defvar mime/content-decoding-condition
|
|
55 '(((type . "text/plain")
|
|
56 (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)
|
|
57 (mode "play" "print")
|
|
58 )
|
|
59 ((type . "text/html")
|
|
60 (method "tm-html" nil 'file 'type 'encoding 'mode 'name)
|
|
61 (mode . "play")
|
|
62 )
|
|
63 ((type . "text/x-rot13-47")
|
|
64 (method . mime-article/decode-caesar)
|
|
65 (mode . "play")
|
|
66 )
|
|
67 ((type . "audio/basic")
|
|
68 (method "tm-au" nil 'file 'type 'encoding 'mode 'name)
|
|
69 (mode . "play")
|
|
70 )
|
|
71
|
|
72 ((type . "image/jpeg")
|
|
73 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
74 (mode "play" "print")
|
|
75 )
|
|
76 ((type . "image/gif")
|
|
77 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
78 (mode "play" "print")
|
|
79 )
|
|
80 ((type . "image/tiff")
|
|
81 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
82 (mode "play" "print")
|
|
83 )
|
|
84 ((type . "image/x-tiff")
|
|
85 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
86 (mode "play" "print")
|
|
87 )
|
|
88 ((type . "image/x-xbm")
|
|
89 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
90 (mode "play" "print")
|
|
91 )
|
|
92 ((type . "image/x-pic")
|
|
93 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
94 (mode "play" "print")
|
|
95 )
|
|
96 ((type . "image/x-mag")
|
|
97 (method "tm-image" nil 'file 'type 'encoding 'mode 'name)
|
|
98 (mode "play" "print")
|
|
99 )
|
|
100
|
|
101 ((type . "video/mpeg")
|
|
102 (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name)
|
|
103 (mode . "play")
|
|
104 )
|
|
105
|
|
106 ((type . "application/postscript")
|
|
107 (method "tm-ps" nil 'file 'type 'encoding 'mode 'name)
|
|
108 (mode "play" "print")
|
|
109 )
|
|
110 ((type . "application/octet-stream")
|
|
111 (method "tm-file" nil 'file 'type 'encoding 'mode 'name)
|
|
112 (mode "play" "print")
|
|
113 )
|
|
114
|
|
115 ;;((type . "message/external-body")
|
|
116 ;; (method "xterm" nil
|
|
117 ;; "-e" "showexternal"
|
|
118 ;; 'file '"access-type" '"name" '"site" '"directory"))
|
|
119 ((type . "message/rfc822")
|
|
120 (method . mime-article/view-message/rfc822)
|
|
121 (mode . "play")
|
|
122 )
|
|
123 ((type . "message/partial")
|
|
124 (method . mime-article/decode-message/partial)
|
|
125 (mode . "play")
|
|
126 )
|
|
127
|
|
128 ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file)
|
|
129 (mode . "play")
|
|
130 )
|
|
131 ((method "tm-file" nil 'file 'type 'encoding 'mode 'name)
|
|
132 (mode . "extract")
|
|
133 )
|
|
134 ))
|
|
135
|
|
136 (defvar mime-viewer/childrens-header-showing-Content-Type-list
|
|
137 '("message/rfc822" "message/news"))
|
|
138
|
|
139 (defvar mime-viewer/default-showing-Content-Type-list
|
|
140 '("text/plain" nil "text/richtext" "text/enriched"
|
|
141 "text/x-latex" "application/x-latex"
|
|
142 "message/delivery-status"
|
|
143 "application/pgp" "text/x-pgp"
|
|
144 "application/octet-stream"
|
|
145 "application/x-selection" "application/x-comment"))
|
|
146
|
|
147 (defvar mime-viewer/content-button-ignored-ctype-list
|
|
148 '("application/x-selection"))
|
|
149
|
|
150 (defvar mime-viewer/content-button-visible-ctype-list
|
|
151 '("application/pgp"))
|
|
152
|
|
153 (defvar mime-viewer/uuencode-encoding-name-list '("x-uue" "x-uuencode"))
|
|
154
|
|
155 (defvar mime-viewer/ignored-field-list
|
|
156 '(".*Received" ".*Path" ".*Id" "References"
|
|
157 "Replied" "Errors-To"
|
|
158 "Lines" "Sender" ".*Host" "Xref"
|
|
159 "Content-Type" "Precedence"
|
|
160 "Status" "X-VM-.*")
|
|
161 "All fields that match this list will be hidden in MIME preview buffer.
|
|
162 Each elements are regexp of field-name. [tm-view.el]")
|
|
163
|
|
164 (defvar mime-viewer/ignored-field-regexp
|
|
165 (concat "^"
|
|
166 (apply (function regexp-or) mime-viewer/ignored-field-list)
|
|
167 ":"))
|
|
168
|
|
169 (defvar mime-viewer/visible-field-list
|
|
170 '("Dnas.*" "Message-Id")
|
|
171 "All fields that match this list will be displayed in MIME preview buffer.
|
|
172 Each elements are regexp of field-name. [tm-view.el]")
|
|
173
|
|
174 (defvar mime-viewer/visible-field-regexp
|
|
175 (concat "^"
|
|
176 (apply (function regexp-or) mime-viewer/visible-field-list)
|
|
177 ":"))
|
|
178
|
|
179 (defvar mime-viewer/redisplay nil)
|
|
180
|
136
|
181 (defun mime-viewer/get-key-for-fun (symb)
|
|
182 (let ((key (where-is-internal symb))
|
|
183 )
|
|
184 (if key
|
|
185 (key-description (car key))
|
|
186 "v")))
|
|
187
|
|
188 (defun mime-viewer/announcement-for-message/partial ()
|
|
189 (let ((key (mime-viewer/get-key-for-fun 'mime-viewer/play-content)))
|
|
190 (if (and (>= emacs-major-version 19) window-system)
|
|
191 (concat
|
|
192 "\
|
4
|
193 \[[ This is message/partial style split message. ]]
|
136
|
194 \[[ Please press `"
|
|
195 key
|
|
196 "' in this buffer ]]
|
|
197 \[[ or click here by mouse button-2. ]]")
|
|
198 (concat
|
|
199 "\
|
4
|
200 \[[ This is message/partial style split message. ]]
|
136
|
201 \[[ Please press `"
|
|
202 key
|
|
203 "' in this buffer. ]]")
|
|
204 )))
|
4
|
205
|
|
206 ;;; @@ predicate functions
|
|
207 ;;;
|
|
208
|
|
209 (defun mime-viewer/header-visible-p (rcnum cinfo &optional ctype)
|
|
210 (or (null rcnum)
|
|
211 (progn
|
|
212 (setq ctype
|
|
213 (mime::content-info/type
|
|
214 (mime-article/rcnum-to-cinfo (cdr rcnum) cinfo)
|
|
215 ))
|
|
216 (member ctype mime-viewer/childrens-header-showing-Content-Type-list)
|
|
217 )))
|
|
218
|
|
219 (defun mime-viewer/body-visible-p (rcnum cinfo &optional ctype)
|
|
220 (let (ccinfo)
|
|
221 (or ctype
|
|
222 (setq ctype
|
|
223 (mime::content-info/type
|
|
224 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
|
|
225 ))
|
|
226 )
|
|
227 (and (member ctype mime-viewer/default-showing-Content-Type-list)
|
|
228 (if (string-equal ctype "application/octet-stream")
|
|
229 (progn
|
|
230 (or ccinfo
|
|
231 (setq ccinfo (mime-article/rcnum-to-cinfo rcnum cinfo))
|
|
232 )
|
|
233 (member (mime::content-info/encoding ccinfo)
|
|
234 '(nil "7bit" "8bit"))
|
|
235 )
|
|
236 t))
|
|
237 ))
|
|
238
|
|
239
|
|
240 ;;; @@ content button
|
|
241 ;;;
|
|
242
|
|
243 (defun mime-preview/insert-content-button
|
|
244 (rcnum cinfo ctype params subj encoding)
|
|
245 (save-restriction
|
|
246 (narrow-to-region (point)(point))
|
|
247 (let ((access-type (assoc "access-type" params))
|
|
248 (charset (assoc "charset" params))
|
|
249 (num (or (assoc-value "x-part-number" params)
|
|
250 (if (consp rcnum)
|
|
251 (mapconcat (function
|
|
252 (lambda (num)
|
|
253 (format "%s" (1+ num))
|
|
254 ))
|
|
255 (reverse rcnum) ".")
|
|
256 "0"))
|
|
257 ))
|
|
258 (cond (access-type
|
|
259 (let ((server (assoc "server" params)))
|
|
260 (setq access-type (cdr access-type))
|
|
261 (if server
|
|
262 (insert (format "[%s %s ([%s] %s)]\n" num subj
|
|
263 access-type (cdr server)))
|
|
264 (let ((site (assoc-value "site" params))
|
|
265 (dir (assoc-value "directory" params))
|
|
266 )
|
|
267 (insert (format "[%s %s ([%s] %s:%s)]\n" num subj
|
|
268 access-type site dir))
|
|
269 )))
|
|
270 )
|
|
271 (t
|
|
272 (insert (concat "[" num " " subj))
|
|
273 (let ((rest
|
|
274 (if (setq charset (cdr charset))
|
|
275 (if encoding
|
|
276 (format " <%s; %s (%s)>]\n"
|
|
277 ctype charset encoding)
|
|
278 (format " <%s; %s>]\n" ctype charset)
|
|
279 )
|
|
280 (format " <%s>]\n" ctype)
|
|
281 )))
|
|
282 (if (>= (+ (current-column)(length rest))(window-width))
|
|
283 (setq rest (concat "\n\t" rest))
|
|
284 )
|
|
285 (insert rest)
|
|
286 ))))
|
|
287 (tm:add-button (point-min)(1- (point-max))
|
|
288 (function mime-viewer/play-content))
|
|
289 ))
|
|
290
|
|
291 (defun mime-preview/default-content-button-function
|
|
292 (rcnum cinfo ctype params subj encoding)
|
|
293 (if (and (consp rcnum)
|
|
294 (not (member
|
|
295 ctype
|
|
296 mime-viewer/content-button-ignored-ctype-list)))
|
|
297 (mime-preview/insert-content-button
|
|
298 rcnum cinfo ctype params subj encoding)
|
|
299 ))
|
|
300
|
|
301 (defvar mime-preview/content-button-function
|
|
302 (function mime-preview/default-content-button-function))
|
|
303
|
|
304
|
|
305 ;;; @@ content header filter
|
|
306 ;;;
|
|
307
|
|
308 (defun mime-preview/cut-header ()
|
|
309 (goto-char (point-min))
|
|
310 (while (and
|
|
311 (re-search-forward mime-viewer/ignored-field-regexp nil t)
|
|
312 (let* ((beg (match-beginning 0))
|
|
313 (end (match-end 0))
|
|
314 (name (buffer-substring beg end))
|
|
315 )
|
|
316 (if (not (string-match mime-viewer/visible-field-regexp name))
|
|
317 (delete-region
|
|
318 beg
|
|
319 (save-excursion
|
|
320 (and
|
|
321 (re-search-forward "^\\([^ \t]\\|$\\)" nil t)
|
|
322 (match-beginning 0)
|
|
323 )))
|
|
324 )
|
|
325 t)))
|
|
326 )
|
|
327
|
|
328 (defun mime-viewer/default-content-header-filter ()
|
|
329 (mime-preview/cut-header)
|
|
330 (mime/decode-message-header)
|
|
331 )
|
|
332
|
|
333 (defvar mime-viewer/content-header-filter-alist nil)
|
|
334
|
|
335
|
|
336 ;;; @@ content filter
|
|
337 ;;;
|
|
338
|
|
339 (defvar mime-viewer/content-filter-alist
|
|
340 '(("text/enriched" . mime-preview/filter-for-text/enriched)
|
|
341 ("text/richtext" . mime-preview/filter-for-text/richtext)
|
|
342 (t . mime-preview/filter-for-text/plain)
|
|
343 ))
|
|
344
|
|
345
|
|
346 ;;; @@ content separator
|
|
347 ;;;
|
|
348
|
|
349 (defun mime-preview/default-content-separator (rcnum cinfo ctype params subj)
|
|
350 (if (and (not (mime-viewer/header-visible-p rcnum cinfo ctype))
|
|
351 (not (mime-viewer/body-visible-p rcnum cinfo ctype))
|
|
352 )
|
|
353 (progn
|
|
354 (goto-char (point-max))
|
|
355 (insert "\n")
|
|
356 )))
|
|
357
|
|
358
|
|
359 ;;; @@ buffer local variables
|
|
360 ;;;
|
|
361
|
|
362 ;; for XEmacs
|
|
363 (defvar mime::article/preview-buffer nil)
|
|
364 (defvar mime::article/code-converter nil)
|
|
365 (defvar mime::preview/article-buffer nil)
|
|
366
|
|
367 (make-variable-buffer-local 'mime::article/content-info)
|
|
368 (make-variable-buffer-local 'mime::article/preview-buffer)
|
|
369 (make-variable-buffer-local 'mime::article/code-converter)
|
|
370
|
|
371 (make-variable-buffer-local 'mime::preview/mother-buffer)
|
|
372 (make-variable-buffer-local 'mime::preview/content-list)
|
|
373 (make-variable-buffer-local 'mime::preview/article-buffer)
|
|
374 (make-variable-buffer-local 'mime::preview/original-major-mode)
|
|
375 (make-variable-buffer-local 'mime::preview/original-window-configuration)
|
|
376
|
|
377
|
|
378 ;;; @@ quitting method
|
|
379 ;;;
|
|
380
|
|
381 (defvar mime-viewer/quitting-method-alist
|
|
382 '((mime/show-message-mode
|
|
383 . mime-viewer/quitting-method-for-mime/show-message-mode)))
|
|
384
|
|
385 (defvar mime-viewer/over-to-previous-method-alist nil)
|
|
386 (defvar mime-viewer/over-to-next-method-alist nil)
|
|
387
|
|
388 (defvar mime-viewer/show-summary-method nil)
|
|
389
|
|
390
|
|
391 ;;; @@ following method
|
|
392 ;;;
|
|
393
|
|
394 (defvar mime-viewer/following-method-alist nil)
|
|
395
|
74
|
396 (defvar mime-viewer/following-required-fields-list
|
|
397 '("From"))
|
|
398
|
4
|
399
|
|
400 ;;; @@ X-Face
|
|
401 ;;;
|
|
402
|
|
403 ;; hack from Gnus 5.0.4.
|
|
404
|
|
405 (defvar mime-viewer/x-face-to-pbm-command
|
|
406 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm")
|
|
407
|
|
408 (defvar mime-viewer/x-face-command
|
|
409 (concat mime-viewer/x-face-to-pbm-command
|
|
410 " | xv -quit -")
|
|
411 "String to be executed to display an X-Face field.
|
|
412 The command will be executed in a sub-shell asynchronously.
|
|
413 The compressed face will be piped to this command.")
|
|
414
|
|
415 (defun mime-viewer/x-face-function ()
|
|
416 "Function to display X-Face field. You can redefine to customize."
|
|
417 ;; 1995/10/12 (c.f. tm-eng:130)
|
|
418 ;; fixed by Eric Ding <ericding@San-Jose.ate.slb.com>
|
|
419 (save-restriction
|
|
420 (narrow-to-region (point-min) (re-search-forward "^$" nil t))
|
|
421 ;; end
|
|
422 (goto-char (point-min))
|
|
423 (if (re-search-forward "^X-Face:[ \t]*" nil t)
|
|
424 (let ((beg (match-end 0))
|
|
425 (end (std11-field-end))
|
|
426 )
|
|
427 (call-process-region beg end "sh" nil 0 nil
|
|
428 "-c" mime-viewer/x-face-command)
|
|
429 ))))
|
|
430
|
|
431
|
|
432 ;;; @@ utility
|
|
433 ;;;
|
|
434
|
|
435 (defun mime-preview/get-original-major-mode ()
|
|
436 (if mime::preview/mother-buffer
|
|
437 (save-excursion
|
|
438 (set-buffer mime::preview/mother-buffer)
|
|
439 (mime-preview/get-original-major-mode)
|
|
440 )
|
|
441 mime::preview/original-major-mode))
|
|
442
|
|
443
|
|
444 ;;; @ data structures
|
|
445 ;;;
|
|
446
|
|
447 ;;; @@ preview-content-info
|
|
448 ;;;
|
|
449
|
|
450 (define-structure mime::preview-content-info
|
|
451 point-min point-max buffer content-info)
|
|
452
|
|
453
|
|
454 ;;; @ buffer setup
|
|
455 ;;;
|
|
456
|
|
457 (defun mime-viewer/setup-buffer (&optional ctl encoding ibuf obuf)
|
|
458 (if ibuf
|
|
459 (progn
|
|
460 (get-buffer ibuf)
|
|
461 (set-buffer ibuf)
|
|
462 ))
|
|
463 (or mime-viewer/redisplay
|
|
464 (setq mime::article/content-info (mime/parse-message ctl encoding))
|
|
465 )
|
|
466 (let ((ret (mime-viewer/make-preview-buffer obuf)))
|
|
467 (setq mime::article/preview-buffer (car ret))
|
|
468 ret))
|
|
469
|
|
470 (defun mime-viewer/make-preview-buffer (&optional obuf)
|
|
471 (let* ((cinfo mime::article/content-info)
|
|
472 (pcl (mime/flatten-content-info cinfo))
|
|
473 (dest (make-list (length pcl) nil))
|
|
474 (the-buf (current-buffer))
|
|
475 (mode major-mode)
|
|
476 )
|
|
477 (or obuf
|
|
478 (setq obuf (concat "*Preview-" (buffer-name the-buf) "*")))
|
|
479 (set-buffer (get-buffer-create obuf))
|
|
480 (setq buffer-read-only nil)
|
|
481 (widen)
|
|
482 (erase-buffer)
|
|
483 (setq mime::preview/article-buffer the-buf)
|
|
484 (setq mime::preview/original-major-mode mode)
|
|
485 (setq major-mode 'mime/viewer-mode)
|
|
486 (setq mode-name "MIME-View")
|
|
487 (let ((drest dest))
|
|
488 (while pcl
|
|
489 (setcar drest
|
|
490 (mime-preview/display-content (car pcl) cinfo the-buf obuf))
|
|
491 (setq pcl (cdr pcl)
|
|
492 drest (cdr drest))
|
|
493 ))
|
|
494 (set-buffer-modified-p nil)
|
|
495 (setq buffer-read-only t)
|
|
496 (set-buffer the-buf)
|
|
497 (list obuf dest)
|
|
498 ))
|
|
499
|
|
500 (defun mime-preview/display-content (content cinfo ibuf obuf)
|
|
501 (let* ((beg (mime::content-info/point-min content))
|
|
502 (end (mime::content-info/point-max content))
|
|
503 (ctype (mime::content-info/type content))
|
|
504 (params (mime::content-info/parameters content))
|
|
505 (encoding (mime::content-info/encoding content))
|
|
506 (rcnum (mime::content-info/rcnum content))
|
|
507 he e nb ne subj)
|
|
508 (set-buffer ibuf)
|
|
509 (goto-char beg)
|
|
510 (setq he (if (re-search-forward "^$" nil t)
|
|
511 (1+ (match-end 0))
|
|
512 end))
|
|
513 (if (> he end)
|
|
514 (setq he end)
|
|
515 )
|
|
516 (save-restriction
|
|
517 (narrow-to-region beg end)
|
|
518 (setq subj
|
|
519 (mime-eword/decode-string
|
|
520 (mime-article/get-subject params encoding)))
|
|
521 )
|
|
522 (set-buffer obuf)
|
|
523 (setq nb (point))
|
|
524 (narrow-to-region nb nb)
|
|
525 (funcall mime-preview/content-button-function
|
|
526 rcnum cinfo ctype params subj encoding)
|
|
527 (if (mime-viewer/header-visible-p rcnum cinfo ctype)
|
|
528 (mime-preview/display-header beg he)
|
|
529 )
|
|
530 (if (and (null rcnum)
|
|
531 (member
|
|
532 ctype mime-viewer/content-button-visible-ctype-list))
|
|
533 (save-excursion
|
|
534 (goto-char (point-max))
|
|
535 (mime-preview/insert-content-button
|
|
536 rcnum cinfo ctype params subj encoding)
|
|
537 ))
|
|
538 (cond ((mime-viewer/body-visible-p rcnum cinfo ctype)
|
|
539 (mime-preview/display-body he end
|
|
540 rcnum cinfo ctype params subj encoding)
|
|
541 )
|
|
542 ((equal ctype "message/partial")
|
|
543 (mime-preview/display-message/partial)
|
|
544 )
|
|
545 ((and (null rcnum)
|
|
546 (null (mime::content-info/children cinfo))
|
|
547 )
|
|
548 (goto-char (point-max))
|
|
549 (mime-preview/insert-content-button
|
|
550 rcnum cinfo ctype params subj encoding)
|
|
551 ))
|
|
552 (mime-preview/default-content-separator rcnum cinfo ctype params subj)
|
|
553 (prog1
|
|
554 (progn
|
|
555 (setq ne (point-max))
|
|
556 (widen)
|
|
557 (mime::preview-content-info/create nb (1- ne) ibuf content)
|
|
558 )
|
|
559 (goto-char ne)
|
|
560 )))
|
|
561
|
|
562 (defun mime-preview/display-header (beg end)
|
|
563 (save-restriction
|
|
564 (narrow-to-region (point)(point))
|
|
565 (insert-buffer-substring mime::preview/article-buffer beg end)
|
|
566 (let ((f (cdr (assq mime::preview/original-major-mode
|
|
567 mime-viewer/content-header-filter-alist))))
|
|
568 (if (functionp f)
|
|
569 (funcall f)
|
|
570 (mime-viewer/default-content-header-filter)
|
|
571 ))
|
|
572 (run-hooks 'mime-viewer/content-header-filter-hook)
|
|
573 ))
|
|
574
|
|
575 (defun mime-preview/display-body (beg end
|
|
576 rcnum cinfo ctype params subj encoding)
|
|
577 (save-restriction
|
|
578 (narrow-to-region (point-max)(point-max))
|
|
579 (insert-buffer-substring mime::preview/article-buffer beg end)
|
|
580 (let ((f (cdr (or (assoc ctype mime-viewer/content-filter-alist)
|
|
581 (assq t mime-viewer/content-filter-alist)))))
|
|
582 (and (functionp f)
|
|
583 (funcall f ctype params encoding)
|
|
584 )
|
|
585 )))
|
|
586
|
|
587 (defun mime-preview/display-message/partial ()
|
|
588 (save-restriction
|
|
589 (goto-char (point-max))
|
|
590 (if (not (search-backward "\n\n" nil t))
|
|
591 (insert "\n")
|
|
592 )
|
|
593 (let ((be (point-max)))
|
|
594 (narrow-to-region be be)
|
136
|
595 (insert (mime-viewer/announcement-for-message/partial))
|
4
|
596 (tm:add-button (point-min)(point-max)
|
|
597 (function mime-viewer/play-content))
|
|
598 )))
|
|
599
|
|
600 (defun mime-article/get-uu-filename (param &optional encoding)
|
|
601 (if (member (or encoding
|
|
602 (cdr (assq 'encoding param))
|
|
603 )
|
|
604 mime-viewer/uuencode-encoding-name-list)
|
|
605 (save-excursion
|
|
606 (or (if (re-search-forward "^begin [0-9]+ " nil t)
|
|
607 (if (looking-at ".+$")
|
|
608 (buffer-substring (match-beginning 0)(match-end 0))
|
|
609 ))
|
|
610 ""))
|
|
611 ))
|
|
612
|
|
613 (defun mime-article/get-subject (param &optional encoding)
|
|
614 (or (std11-find-field-body '("Content-Description" "Subject"))
|
|
615 (let (ret)
|
|
616 (if (or (and (setq ret (mime/Content-Disposition))
|
|
617 (setq ret (assoc "filename" (cdr ret)))
|
|
618 )
|
|
619 (setq ret (assoc "name" param))
|
|
620 (setq ret (assoc "x-name" param))
|
|
621 )
|
|
622 (std11-strip-quoted-string (cdr ret))
|
|
623 ))
|
|
624 (mime-article/get-uu-filename param encoding)
|
|
625 ""))
|
|
626
|
|
627
|
|
628 ;;; @ content information
|
|
629 ;;;
|
|
630
|
|
631 (defun mime-article/point-content-number (p &optional cinfo)
|
|
632 (or cinfo
|
|
633 (setq cinfo mime::article/content-info)
|
|
634 )
|
|
635 (let ((b (mime::content-info/point-min cinfo))
|
|
636 (e (mime::content-info/point-max cinfo))
|
|
637 (c (mime::content-info/children cinfo))
|
|
638 )
|
|
639 (if (and (<= b p)(<= p e))
|
|
640 (or (let (co ret (sn 0))
|
|
641 (catch 'tag
|
|
642 (while c
|
|
643 (setq co (car c))
|
|
644 (setq ret (mime-article/point-content-number p co))
|
|
645 (cond ((eq ret t) (throw 'tag (list sn)))
|
|
646 (ret (throw 'tag (cons sn ret)))
|
|
647 )
|
|
648 (setq c (cdr c))
|
|
649 (setq sn (1+ sn))
|
|
650 )))
|
|
651 t))))
|
|
652
|
|
653 (defun mime-article/rcnum-to-cinfo (rcnum &optional cinfo)
|
|
654 (or cinfo
|
|
655 (setq cinfo mime::article/content-info)
|
|
656 )
|
|
657 (find-if (function
|
|
658 (lambda (ci)
|
|
659 (equal (mime::content-info/rcnum ci) rcnum)
|
|
660 ))
|
|
661 (mime/flatten-content-info cinfo)
|
|
662 ))
|
|
663
|
|
664 (defun mime-article/cnum-to-cinfo (cn &optional cinfo)
|
|
665 (or cinfo
|
|
666 (setq cinfo mime::article/content-info)
|
|
667 )
|
|
668 (if (eq cn t)
|
|
669 cinfo
|
|
670 (let ((sn (car cn)))
|
|
671 (if (null sn)
|
|
672 cinfo
|
|
673 (let ((rc (nth sn (mime::content-info/children cinfo))))
|
|
674 (if rc
|
|
675 (mime-article/cnum-to-cinfo (cdr cn) rc)
|
|
676 ))
|
|
677 ))))
|
|
678
|
|
679 (defun mime/flatten-content-info (&optional cinfo)
|
|
680 (or cinfo
|
|
681 (setq cinfo mime::article/content-info)
|
|
682 )
|
|
683 (let ((dest (list cinfo))
|
|
684 (rcl (mime::content-info/children cinfo))
|
|
685 )
|
|
686 (while rcl
|
|
687 (setq dest (nconc dest (mime/flatten-content-info (car rcl))))
|
|
688 (setq rcl (cdr rcl))
|
|
689 )
|
|
690 dest))
|
|
691
|
|
692 (defun mime-preview/point-pcinfo (p &optional pcl)
|
|
693 (or pcl
|
|
694 (setq pcl mime::preview/content-list)
|
|
695 )
|
|
696 (catch 'tag
|
|
697 (let ((r pcl) cell)
|
|
698 (while r
|
|
699 (setq cell (car r))
|
|
700 (if (and (<= (mime::preview-content-info/point-min cell) p)
|
|
701 (<= p (mime::preview-content-info/point-max cell))
|
|
702 )
|
|
703 (throw 'tag cell)
|
|
704 )
|
|
705 (setq r (cdr r))
|
|
706 ))
|
|
707 (car (last pcl))
|
|
708 ))
|
|
709
|
|
710
|
|
711 ;;; @ MIME viewer mode
|
|
712 ;;;
|
|
713
|
|
714 (defconst mime-viewer/menu-title "MIME-View")
|
|
715 (defconst mime-viewer/menu-list
|
|
716 '((up "Move to upper content" mime-viewer/up-content)
|
|
717 (previous "Move to previous content" mime-viewer/previous-content)
|
|
718 (next "Move to next content" mime-viewer/next-content)
|
|
719 (scroll-down "Scroll to previous content" mime-viewer/scroll-down-content)
|
|
720 (scroll-up "Scroll to next content" mime-viewer/scroll-up-content)
|
|
721 (play "Play Content" mime-viewer/play-content)
|
|
722 (extract "Extract Content" mime-viewer/extract-content)
|
|
723 (print "Print" mime-viewer/print-content)
|
|
724 (x-face "Show X Face" mime-viewer/display-x-face)
|
|
725 )
|
|
726 "Menu for MIME Viewer")
|
|
727
|
|
728 (if running-xemacs
|
|
729 (progn
|
|
730 (defvar mime-viewer/xemacs-popup-menu
|
|
731 (cons mime-viewer/menu-title
|
|
732 (mapcar (function
|
|
733 (lambda (item)
|
|
734 (vector (nth 1 item)(nth 2 item) t)
|
|
735 ))
|
|
736 mime-viewer/menu-list)))
|
|
737 (defun mime-viewer/xemacs-popup-menu (event)
|
|
738 "Popup the menu in the MIME Viewer buffer"
|
|
739 (interactive "e")
|
|
740 (select-window (event-window event))
|
|
741 (set-buffer (event-buffer event))
|
|
742 (popup-menu 'mime-viewer/xemacs-popup-menu))
|
|
743 ))
|
|
744
|
|
745 (defun mime-viewer/define-keymap (&optional mother)
|
|
746 (let ((mime/viewer-mode-map (if mother
|
|
747 (copy-keymap mother)
|
108
|
748 (make-keymap)
|
|
749 )))
|
|
750 (or mother
|
|
751 (suppress-keymap mime/viewer-mode-map))
|
4
|
752 (define-key mime/viewer-mode-map
|
|
753 "u" (function mime-viewer/up-content))
|
|
754 (define-key mime/viewer-mode-map
|
|
755 "p" (function mime-viewer/previous-content))
|
|
756 (define-key mime/viewer-mode-map
|
|
757 "n" (function mime-viewer/next-content))
|
|
758 (define-key mime/viewer-mode-map
|
98
|
759 "\e\t" (function mime-viewer/previous-content))
|
|
760 (define-key mime/viewer-mode-map
|
|
761 "\t" (function mime-viewer/next-content))
|
|
762 (define-key mime/viewer-mode-map
|
4
|
763 " " (function mime-viewer/scroll-up-content))
|
|
764 (define-key mime/viewer-mode-map
|
|
765 "\M- " (function mime-viewer/scroll-down-content))
|
|
766 (define-key mime/viewer-mode-map
|
|
767 "\177" (function mime-viewer/scroll-down-content))
|
|
768 (define-key mime/viewer-mode-map
|
|
769 "\C-m" (function mime-viewer/next-line-content))
|
|
770 (define-key mime/viewer-mode-map
|
|
771 "\C-\M-m" (function mime-viewer/previous-line-content))
|
|
772 (define-key mime/viewer-mode-map
|
|
773 "v" (function mime-viewer/play-content))
|
|
774 (define-key mime/viewer-mode-map
|
98
|
775 "e" (function mime-viewer/extract-content))
|
4
|
776 (define-key mime/viewer-mode-map
|
|
777 "\C-c\C-p" (function mime-viewer/print-content))
|
|
778 (define-key mime/viewer-mode-map
|
|
779 "x" (function mime-viewer/display-x-face))
|
|
780 (define-key mime/viewer-mode-map
|
|
781 "a" (function mime-viewer/follow-content))
|
|
782 (define-key mime/viewer-mode-map
|
|
783 "q" (function mime-viewer/quit))
|
|
784 (define-key mime/viewer-mode-map
|
|
785 "h" (function mime-viewer/show-summary))
|
|
786 (define-key mime/viewer-mode-map
|
|
787 "\C-c\C-x" (function mime-viewer/kill-buffer))
|
|
788 (define-key mime/viewer-mode-map
|
|
789 "<" (function beginning-of-buffer))
|
|
790 (define-key mime/viewer-mode-map
|
|
791 ">" (function end-of-buffer))
|
|
792 (define-key mime/viewer-mode-map
|
|
793 "?" (function describe-mode))
|
|
794 (if mouse-button-2
|
|
795 (define-key mime/viewer-mode-map
|
|
796 mouse-button-2 (function tm:button-dispatcher))
|
|
797 )
|
|
798 (cond (running-xemacs
|
|
799 (define-key mime/viewer-mode-map
|
|
800 mouse-button-3 (function mime-viewer/xemacs-popup-menu))
|
|
801 )
|
|
802 ((>= emacs-major-version 19)
|
|
803 (define-key mime/viewer-mode-map [menu-bar mime-view]
|
|
804 (cons mime-viewer/menu-title
|
|
805 (make-sparse-keymap mime-viewer/menu-title)))
|
|
806 (mapcar (function
|
|
807 (lambda (item)
|
|
808 (define-key mime/viewer-mode-map
|
|
809 (vector 'menu-bar 'mime-view (car item))
|
|
810 (cons (nth 1 item)(nth 2 item))
|
|
811 )
|
|
812 ))
|
|
813 (reverse mime-viewer/menu-list)
|
|
814 )
|
|
815 ))
|
|
816 (use-local-map mime/viewer-mode-map)
|
|
817 (run-hooks 'mime-viewer/define-keymap-hook)
|
|
818 ))
|
|
819
|
|
820 (defun mime/viewer-mode (&optional mother ctl encoding ibuf obuf
|
|
821 mother-keymap)
|
|
822 "Major mode for viewing MIME message.
|
|
823
|
|
824 Here is a list of the standard keys for mime/viewer-mode.
|
|
825
|
|
826 key feature
|
|
827 --- -------
|
|
828
|
|
829 u Move to upper content
|
98
|
830 p or M-TAB Move to previous content
|
|
831 n or TAB Move to next content
|
4
|
832 SPC Scroll up or move to next content
|
98
|
833 M-SPC or DEL Scroll down or move to previous content
|
4
|
834 RET Move to next line
|
|
835 M-RET Move to previous line
|
|
836 v Decode current content as `play mode'
|
|
837 e Decode current content as `extract mode'
|
|
838 C-c C-p Decode current content as `print mode'
|
|
839 a Followup to current content.
|
|
840 x Display X-Face
|
|
841 q Quit
|
|
842 button-2 Move to point under the mouse cursor
|
|
843 and decode current content as `play mode'
|
|
844 "
|
|
845 (interactive)
|
|
846 (let ((buf (get-buffer mime/output-buffer-name)))
|
|
847 (if buf
|
|
848 (save-excursion
|
|
849 (set-buffer buf)
|
|
850 (erase-buffer)
|
|
851 )))
|
|
852 (let ((ret (mime-viewer/setup-buffer ctl encoding ibuf obuf))
|
|
853 (win-conf (current-window-configuration))
|
|
854 )
|
|
855 (prog1
|
|
856 (switch-to-buffer (car ret))
|
|
857 (setq mime::preview/original-window-configuration win-conf)
|
|
858 (if mother
|
|
859 (progn
|
|
860 (setq mime::preview/mother-buffer mother)
|
|
861 ))
|
|
862 (mime-viewer/define-keymap mother-keymap)
|
|
863 (setq mime::preview/content-list (nth 1 ret))
|
|
864 (goto-char
|
|
865 (let ((ce (mime::preview-content-info/point-max
|
|
866 (car mime::preview/content-list)
|
|
867 ))
|
|
868 e)
|
|
869 (goto-char (point-min))
|
|
870 (search-forward "\n\n" nil t)
|
|
871 (setq e (match-end 0))
|
|
872 (if (<= e ce)
|
|
873 e
|
|
874 ce)))
|
|
875 (run-hooks 'mime/viewer-mode-hook)
|
|
876 )))
|
|
877
|
|
878 (defun mime-preview/point-content-number (point)
|
|
879 (save-window-excursion
|
|
880 (let ((pc (mime-preview/point-pcinfo (point)))
|
|
881 cinfo)
|
|
882 (switch-to-buffer (mime::preview-content-info/buffer pc))
|
|
883 (setq cinfo (mime::preview-content-info/content-info pc))
|
|
884 (mime-article/point-content-number (mime::content-info/point-min cinfo))
|
|
885 )))
|
|
886
|
|
887 (defun mime-preview/cinfo-to-pcinfo (cinfo)
|
|
888 (let ((rpcl mime::preview/content-list) cell)
|
|
889 (catch 'tag
|
|
890 (while rpcl
|
|
891 (setq cell (car rpcl))
|
|
892 (if (eq cinfo (mime::preview-content-info/content-info cell))
|
|
893 (throw 'tag cell)
|
|
894 )
|
|
895 (setq rpcl (cdr rpcl))
|
|
896 ))))
|
|
897
|
|
898 (autoload 'mime-preview/decode-content "tm-play")
|
|
899
|
|
900 (defvar mime-viewer/decoding-mode "play" "MIME body decoding mode")
|
|
901
|
|
902 (defun mime-viewer/play-content ()
|
|
903 (interactive)
|
|
904 (let ((mime-viewer/decoding-mode "play"))
|
|
905 (mime-preview/decode-content)
|
|
906 ))
|
|
907
|
|
908 (defun mime-viewer/extract-content ()
|
|
909 (interactive)
|
|
910 (let ((mime-viewer/decoding-mode "extract"))
|
|
911 (mime-preview/decode-content)
|
|
912 ))
|
|
913
|
|
914 (defun mime-viewer/print-content ()
|
|
915 (interactive)
|
|
916 (let ((mime-viewer/decoding-mode "print"))
|
|
917 (mime-preview/decode-content)
|
|
918 ))
|
|
919
|
|
920 (defun mime-viewer/follow-content ()
|
|
921 (interactive)
|
|
922 (let ((root-cinfo
|
|
923 (mime::preview-content-info/content-info
|
|
924 (car mime::preview/content-list)))
|
|
925 pc p-beg p-end cinfo rcnum)
|
|
926 (let ((rest mime::preview/content-list)
|
|
927 b e cell len rc)
|
|
928 (if (catch 'tag
|
|
929 (while (setq cell (car rest))
|
|
930 (setq b (mime::preview-content-info/point-min cell)
|
|
931 e (mime::preview-content-info/point-max cell))
|
|
932 (setq rest (cdr rest))
|
|
933 (if (and (<= b (point))(<= (point) e))
|
|
934 (throw 'tag cell)
|
|
935 )
|
|
936 ))
|
|
937 (progn
|
|
938 (setq pc cell
|
|
939 cinfo (mime::preview-content-info/content-info pc)
|
|
940 rcnum (mime::content-info/rcnum cinfo))
|
|
941 (setq len (length rcnum))
|
|
942 (setq p-beg (mime::preview-content-info/point-min pc)
|
|
943 p-end (mime::preview-content-info/point-max pc))
|
|
944 (while (and (setq cell (car rest))
|
|
945 (progn
|
|
946 (setq rc
|
|
947 (mime::content-info/rcnum
|
|
948 (mime::preview-content-info/content-info
|
|
949 cell)))
|
|
950 (equal rcnum
|
|
951 (nthcdr (- (length rc) len) rc))
|
|
952 ))
|
|
953 (setq p-end (mime::preview-content-info/point-max cell))
|
|
954 (setq rest (cdr rest))
|
|
955 ))))
|
|
956 (if pc
|
|
957 (let* ((mode (mime-preview/get-original-major-mode))
|
|
958 (new-name (format "%s-%s" (buffer-name) (reverse rcnum)))
|
|
959 new-buf
|
|
960 (the-buf (current-buffer))
|
|
961 (a-buf mime::preview/article-buffer)
|
|
962 (hb (mime::content-info/point-min cinfo))
|
|
963 (he (mime::content-info/point-max cinfo))
|
|
964 fields from to cc reply-to subj mid f)
|
|
965 (save-excursion
|
|
966 (set-buffer (setq new-buf (get-buffer-create new-name)))
|
|
967 (erase-buffer)
|
|
968 (insert-buffer-substring the-buf p-beg p-end)
|
|
969 (goto-char (point-min))
|
|
970 (if (mime-viewer/header-visible-p rcnum root-cinfo)
|
|
971 (delete-region (goto-char (point-min))
|
|
972 (if (re-search-forward "^$" nil t)
|
|
973 (match-end 0)
|
|
974 (point-min)))
|
|
975 )
|
|
976 (goto-char (point-min))
|
|
977 (insert "\n")
|
|
978 (goto-char (point-min))
|
|
979 (let ((rcnum (mime::content-info/rcnum cinfo)) ci str)
|
|
980 (while (progn
|
|
981 (setq str
|
|
982 (save-excursion
|
|
983 (set-buffer a-buf)
|
|
984 (setq ci (mime-article/rcnum-to-cinfo rcnum))
|
|
985 (save-restriction
|
|
986 (narrow-to-region
|
|
987 (mime::content-info/point-min ci)
|
|
988 (mime::content-info/point-max ci)
|
|
989 )
|
|
990 (std11-header-string-except
|
|
991 (concat "^"
|
|
992 (apply (function regexp-or) fields)
|
|
993 ":") ""))))
|
|
994 (if (string-equal (mime::content-info/type ci)
|
|
995 "message/rfc822")
|
|
996 nil
|
|
997 (if str
|
|
998 (insert str)
|
|
999 )
|
|
1000 rcnum))
|
|
1001 (setq fields (std11-collect-field-names)
|
|
1002 rcnum (cdr rcnum))
|
|
1003 )
|
|
1004 )
|
74
|
1005 (let ((rest mime-viewer/following-required-fields-list))
|
|
1006 (while rest
|
|
1007 (let ((field-name (car rest)))
|
|
1008 (or (std11-field-body field-name)
|
|
1009 (insert
|
|
1010 (format
|
|
1011 (concat field-name
|
|
1012 ": "
|
|
1013 (save-excursion
|
|
1014 (set-buffer the-buf)
|
|
1015 (set-buffer mime::preview/mother-buffer)
|
|
1016 (set-buffer mime::preview/article-buffer)
|
|
1017 (std11-field-body field-name)
|
|
1018 )
|
|
1019 "\n")))
|
|
1020 ))
|
|
1021 (setq rest (cdr rest))
|
|
1022 ))
|
4
|
1023 (mime/decode-message-header)
|
|
1024 )
|
98
|
1025 (let ((f (cdr (assq mode mime-viewer/following-method-alist))))
|
|
1026 (if (functionp f)
|
|
1027 (funcall f new-buf)
|
|
1028 (message
|
|
1029 (format
|
|
1030 "Sorry, following method for %s is not implemented yet."
|
|
1031 mode))
|
|
1032 ))
|
4
|
1033 ))))
|
|
1034
|
|
1035 (defun mime-viewer/display-x-face ()
|
|
1036 (interactive)
|
|
1037 (save-window-excursion
|
|
1038 (set-buffer mime::preview/article-buffer)
|
|
1039 (mime-viewer/x-face-function)
|
|
1040 ))
|
|
1041
|
|
1042 (defun mime-viewer/up-content ()
|
|
1043 (interactive)
|
|
1044 (let* ((pc (mime-preview/point-pcinfo (point)))
|
|
1045 (cinfo (mime::preview-content-info/content-info pc))
|
|
1046 (rcnum (mime::content-info/rcnum cinfo))
|
|
1047 )
|
|
1048 (if rcnum
|
|
1049 (let ((r (save-excursion
|
|
1050 (set-buffer (mime::preview-content-info/buffer pc))
|
|
1051 (mime-article/rcnum-to-cinfo (cdr rcnum))
|
|
1052 ))
|
|
1053 (rpcl mime::preview/content-list)
|
|
1054 cell)
|
|
1055 (while (and
|
|
1056 (setq cell (car rpcl))
|
|
1057 (not (eq r (mime::preview-content-info/content-info cell)))
|
|
1058 )
|
|
1059 (setq rpcl (cdr rpcl))
|
|
1060 )
|
|
1061 (goto-char (mime::preview-content-info/point-min cell))
|
|
1062 )
|
|
1063 (mime-viewer/quit)
|
|
1064 )))
|
|
1065
|
|
1066 (defun mime-viewer/previous-content ()
|
|
1067 (interactive)
|
|
1068 (let* ((pcl mime::preview/content-list)
|
|
1069 (p (point))
|
|
1070 (i (- (length pcl) 1))
|
|
1071 beg)
|
|
1072 (catch 'tag
|
74
|
1073 (while (> i 0)
|
4
|
1074 (setq beg (mime::preview-content-info/point-min (nth i pcl)))
|
|
1075 (if (> p beg)
|
|
1076 (throw 'tag (goto-char beg))
|
|
1077 )
|
|
1078 (setq i (- i 1))
|
|
1079 )
|
|
1080 (let ((f (assq mime::preview/original-major-mode
|
|
1081 mime-viewer/over-to-previous-method-alist)))
|
|
1082 (if f
|
|
1083 (funcall (cdr f))
|
|
1084 ))
|
|
1085 )
|
|
1086 ))
|
|
1087
|
|
1088 (defun mime-viewer/next-content ()
|
|
1089 (interactive)
|
|
1090 (let ((pcl mime::preview/content-list)
|
|
1091 (p (point))
|
|
1092 beg)
|
|
1093 (catch 'tag
|
|
1094 (while pcl
|
|
1095 (setq beg (mime::preview-content-info/point-min (car pcl)))
|
|
1096 (if (< p beg)
|
|
1097 (throw 'tag (goto-char beg))
|
|
1098 )
|
|
1099 (setq pcl (cdr pcl))
|
|
1100 )
|
|
1101 (let ((f (assq mime::preview/original-major-mode
|
|
1102 mime-viewer/over-to-next-method-alist)))
|
|
1103 (if f
|
|
1104 (funcall (cdr f))
|
|
1105 ))
|
|
1106 )
|
|
1107 ))
|
|
1108
|
|
1109 (defun mime-viewer/scroll-up-content (&optional h)
|
|
1110 (interactive)
|
|
1111 (or h
|
|
1112 (setq h (- (window-height) 1))
|
|
1113 )
|
|
1114 (if (= (point) (point-max))
|
|
1115 (let ((f (assq mime::preview/original-major-mode
|
|
1116 mime-viewer/over-to-next-method-alist)))
|
|
1117 (if f
|
|
1118 (funcall (cdr f))
|
|
1119 ))
|
|
1120 (let ((pcl mime::preview/content-list)
|
|
1121 (p (point))
|
|
1122 np beg)
|
|
1123 (setq np
|
|
1124 (or (catch 'tag
|
|
1125 (while pcl
|
|
1126 (setq beg (mime::preview-content-info/point-min (car pcl)))
|
|
1127 (if (< p beg)
|
|
1128 (throw 'tag beg)
|
|
1129 )
|
|
1130 (setq pcl (cdr pcl))
|
|
1131 ))
|
|
1132 (point-max)))
|
|
1133 (forward-line h)
|
|
1134 (if (> (point) np)
|
|
1135 (goto-char np)
|
|
1136 )
|
|
1137 ;;(show-subtree)
|
|
1138 ))
|
|
1139 )
|
|
1140
|
|
1141 (defun mime-viewer/scroll-down-content (&optional h)
|
|
1142 (interactive)
|
|
1143 (or h
|
|
1144 (setq h (- (window-height) 1))
|
|
1145 )
|
|
1146 (if (= (point) (point-min))
|
|
1147 (let ((f (assq mime::preview/original-major-mode
|
|
1148 mime-viewer/over-to-previous-method-alist)))
|
|
1149 (if f
|
|
1150 (funcall (cdr f))
|
|
1151 ))
|
|
1152 (let ((pcl mime::preview/content-list)
|
|
1153 (p (point))
|
|
1154 pp beg)
|
|
1155 (setq pp
|
|
1156 (or (let ((i (- (length pcl) 1)))
|
|
1157 (catch 'tag
|
|
1158 (while (> i 0)
|
|
1159 (setq beg (mime::preview-content-info/point-min
|
|
1160 (nth i pcl)))
|
|
1161 (if (> p beg)
|
|
1162 (throw 'tag beg)
|
|
1163 )
|
|
1164 (setq i (- i 1))
|
|
1165 )))
|
|
1166 (point-min)))
|
|
1167 (forward-line (- h))
|
|
1168 (if (< (point) pp)
|
|
1169 (goto-char pp)
|
|
1170 )))
|
|
1171 )
|
|
1172
|
|
1173 (defun mime-viewer/next-line-content ()
|
|
1174 (interactive)
|
|
1175 (mime-viewer/scroll-up-content 1)
|
|
1176 )
|
|
1177
|
|
1178 (defun mime-viewer/previous-line-content ()
|
|
1179 (interactive)
|
|
1180 (mime-viewer/scroll-down-content 1)
|
|
1181 )
|
|
1182
|
|
1183 (defun mime-viewer/quit ()
|
|
1184 (interactive)
|
|
1185 (let ((r (save-excursion
|
|
1186 (set-buffer (mime::preview-content-info/buffer
|
|
1187 (mime-preview/point-pcinfo (point))))
|
|
1188 (assq major-mode mime-viewer/quitting-method-alist)
|
|
1189 )))
|
|
1190 (if r
|
|
1191 (funcall (cdr r))
|
|
1192 )))
|
|
1193
|
|
1194 (defun mime-viewer/show-summary ()
|
|
1195 (interactive)
|
|
1196 (let ((r (save-excursion
|
|
1197 (set-buffer
|
|
1198 (mime::preview-content-info/buffer
|
|
1199 (mime-preview/point-pcinfo (point)))
|
|
1200 )
|
|
1201 (assq major-mode mime-viewer/show-summary-method)
|
|
1202 )))
|
|
1203 (if r
|
|
1204 (funcall (cdr r))
|
|
1205 )))
|
|
1206
|
|
1207 (defun mime-viewer/kill-buffer ()
|
|
1208 (interactive)
|
|
1209 (kill-buffer (current-buffer))
|
|
1210 )
|
|
1211
|
|
1212
|
|
1213 ;;; @ end
|
|
1214 ;;;
|
|
1215
|
|
1216 (provide 'tm-view)
|
|
1217
|
|
1218 (run-hooks 'tm-view-load-hook)
|
|
1219
|
|
1220 ;;; tm-view.el ends here
|