annotate lisp/tm/tm-image.el @ 96:dbb370e3c29e r20-0final

Import from CVS: tag r20-0final
author cvs
date Mon, 13 Aug 2007 09:12:40 +0200
parents c0c698873ce1
children 0d2f883870bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; tm-image.el --- tm-view filter to display images in XEmacs or MULE buffers
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
3 ;; Copyright (C) 1995,1996 MORIOKA Tomohiko
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4 ;; Copyright (C) 1996 Dan Rich
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
6 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Dan Rich <drich@morpheus.corp.sgi.com>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9 ;; Created: 1995/12/15
96
dbb370e3c29e Import from CVS: tag r20-0final
cvs
parents: 76
diff changeset
10 ;; Version: $Id: tm-image.el,v 1.3 1997/02/08 03:26:13 steve Exp $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
12 ;; Keywords: mail, news, MIME, multimedia, image, picture, X-Face
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
14 ;; This file is part of tm (Tools for MIME).
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
27 ;; along with this program; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32 ;; If you use this program with MULE, please install
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33 ;; etl8x16-bitmap.bdf font included in tl package.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 (require 'tm-view)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 (cond (running-xemacs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
40 (require 'annotations)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
41
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
42 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
43 "image/jpeg"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
44 (if (featurep 'jpeg) ; Use built-in suport if available
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
45 (function mime-preview/filter-for-inline-image)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
46 (function mime-preview/filter-for-image)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
47 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
48
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
49 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
50 "image/gif"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
51 (if (featurep 'gif) ; Use built-in suport if available
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
52 (function mime-preview/filter-for-inline-image)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
53 (function mime-preview/filter-for-image)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
54 ))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
56 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
57 "image/x-xpixmap"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
58 (if (featurep 'xpm) ; Use built-in suport if available
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
59 (function mime-preview/filter-for-inline-image)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
60 (function mime-preview/filter-for-image)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
61 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
62
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
63 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
64 "image/tiff" (function mime-preview/filter-for-image))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
65 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
66 "image/x-tiff" (function mime-preview/filter-for-image))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
68 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
69 "image/x-pic" (function mime-preview/filter-for-image))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
71 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
72 "image/x-mag" (function mime-preview/filter-for-image))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
73
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
74 (defvar tm-image/inline-image-types
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
75 (if (featurep 'gif)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
76 (nconc
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
77 '("image/jpeg" "image/gif" "image/tiff"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
78 "image/x-tiff" "image/x-pic" "image/x-mag"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
79 "image/x-xbm" "image/x-xpixmap")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
80 (if (featurep 'gif)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
81 '("application/postscript")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
82 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
83 )))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (defun bitmap-insert-xbm-file (file)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
86 (let (gl)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
87 (while (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
88 (setq gl (make-glyph file))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
89 (eq (image-instance-type (glyph-image-instance gl))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
90 'text)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
91 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
92 (make-annotation gl (point) 'text)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
95 (defvar mime-viewer/image-converter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
96 '(("image/jpeg" . jpeg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
97 ("image/gif" . gif)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
98 ("image/x-png" . png)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
99 ("image/x-xpixmap" . xpm)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
100 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
101
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
102 (defvar mime-preview/x-face-function
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
103 (function mime-preview/x-face-function-use-highlight-headers))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
104
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 (autoload 'highlight-headers "highlight-headers")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (defun mime-preview/x-face-function-use-highlight-headers ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (highlight-headers (point-min) (re-search-forward "^$" nil t) t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 ((featurep 'mule)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 ;; for MULE 2.* or mule merged EMACS
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (require 'x-face-mule)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
115 (defvar tm-image/inline-image-types '("image/x-mag" "image/x-xbm"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
117 (defvar mime-preview/x-face-function
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
118 (function x-face-decode-message-header))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
121 (defvar mime-viewer/shell-command "/bin/sh")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
122 (defvar mime-viewer/shell-arguments '("-c"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 (defvar mime-viewer/ps-to-gif-command "pstogif")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
126 (defvar mime-viewer/graphic-converter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
127 '(("image/jpeg" . "djpeg -color 256 < %s | ppmtoxpm > %s")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
128 ("image/gif" . "giftopnm < %s | ppmtoxpm > %s")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
129 ("image/tiff" . "tifftopnm < %s | ppmquant 256 | ppmtoxpm > %s")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
130 ("image/x-tiff" . "tifftopnm < %s | ppmquant 256 | ppmtoxpm > %s")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
131 ("image/x-pic" . "pictoppm < %s | ppmquant 256 | ppmtoxpm > %s")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
132 ("image/x-mag" . "magtoppm < %s | ppmtoxpm > %s")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
133 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
134
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
135
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
136 ;;; @ X-Face
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
137 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
138
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
139 (defvar mime-viewer/x-face-to-xbm-command
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
140 (concat mime-viewer/x-face-to-pbm-command " | pbmtoxbm"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
141
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
142 (if mime-preview/x-face-function
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
143 (add-hook 'mime-viewer/content-header-filter-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
144 mime-preview/x-face-function)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
145 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
146
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 ;;; @ content filter for images
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 ;; (for XEmacs 19.12 or later)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 (defun mime-preview/filter-for-image (ctype params encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153 (let* ((mode mime::preview/original-major-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 (m (assq mode mime-viewer/code-converter-alist))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
155 (filter (assoc-value ctype mime-viewer/graphic-converter-alist))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
156 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
157 (if filter
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
158 (let* ((beg (point-min)) (end (point-max))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
159 (orig-file
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
160 (make-temp-name (expand-file-name "tm" mime/tmp-dir)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
161 (xbm-file (concat orig-file ".xbm"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
162 gl annot)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
163 ;;(remove-text-properties beg end '(face nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
164 (mime-decode-region beg end encoding)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
165 (write-region (point-min)(point-max) orig-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
166 (delete-region (point-min)(point-max))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
167 (message "Now translating, please wait...")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
168 (apply (function call-process)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
169 mime-viewer/shell-command nil nil nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
170 (append mime-viewer/shell-arguments
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
171 (list (format filter orig-file xbm-file)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
172 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
173 (setq gl (make-glyph xbm-file))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
174 (setq annot (make-annotation gl (point) 'text))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
175 (unwind-protect
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
176 (delete-file orig-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
177 (condition-case nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
178 (delete-file xbm-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
179 (error nil)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
180 (goto-char (point-max))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
181 (insert "\n")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
182 (message "Translation done.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
183 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
184 (message (format "%s is not supported." ctype))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
185 )))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
186
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
187
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
188 ;;; @ content filter for xbm
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
189 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
190
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
191 (defun mime-preview/filter-for-image/xbm (ctype params encoding)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
192 (let* ((mode mime::preview/original-major-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
193 (m (assq mode mime-viewer/code-converter-alist))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
194 (charset (assoc "charset" params))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
195 (beg (point-min)) (end (point-max))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
196 (xbm-file (make-temp-name (expand-file-name "tm" mime/tmp-dir)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
197 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
198 (remove-text-properties beg end '(face nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
199 (mime-decode-region beg end encoding)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
200 (write-region (point-min)(point-max) xbm-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
201 (delete-region (point-min)(point-max))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
202 (bitmap-insert-xbm-file xbm-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
203 (delete-file xbm-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
204 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
205
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
206 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
207 "image/xbm" (function mime-preview/filter-for-image/xbm))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
208
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
209 (set-alist 'mime-viewer/content-filter-alist
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
210 "image/x-xbm" (function mime-preview/filter-for-image/xbm))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
211
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
212
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
213 ;;; @ content filter for support in-line image types
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
214 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
215 ;; (for XEmacs 19.14 or later)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
216
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
217 (defun mime-preview/filter-for-inline-image (ctype params encoding)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
218 (let* ((mode mime::preview/original-major-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
219 (m (assq mode mime-viewer/code-converter-alist))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 (charset (assoc "charset" params))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 (beg (point-min)) (end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (remove-text-properties beg end '(face nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 (mime-decode-region beg end encoding)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
225 (let ((data (buffer-string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
226 (minor (assoc-value ctype mime-viewer/image-converter-alist))
96
dbb370e3c29e Import from CVS: tag r20-0final
cvs
parents: 76
diff changeset
227 gl e)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (delete-region (point-min)(point-max))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
229 (while (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
230 (setq gl (make-glyph (vector minor :data data)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
231 (eq (image-instance-type (glyph-image-instance gl))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
232 'text)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
233 ))
96
dbb370e3c29e Import from CVS: tag r20-0final
cvs
parents: 76
diff changeset
234 (setq e (make-extent (point) (point)))
dbb370e3c29e Import from CVS: tag r20-0final
cvs
parents: 76
diff changeset
235 (set-extent-end-glyph e gl)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 ;;; @ content filter for Postscript
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 ;; (for XEmacs 19.14 or later)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (defun mime-preview/filter-for-application/postscript (ctype params encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 (let* ((mode mime::preview/original-major-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (m (assq mode mime-viewer/code-converter-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 (beg (point-min)) (end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 (file-base (make-temp-name (expand-file-name "tm" mime/tmp-dir)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 (ps-file (concat file-base ".ps"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (gif-file (concat file-base ".gif"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 (remove-text-properties beg end '(face nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (mime-decode-region beg end encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 (write-region (point-min)(point-max) ps-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (delete-region (point-min)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 (call-process mime-viewer/ps-to-gif-command nil nil nil ps-file)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
258 (let (gl)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
259 (while (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
260 (setq gl (make-glyph (vector 'gif :file gif-file)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
261 (eq (image-instance-type (glyph-image-instance gl))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
262 'text)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
263 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
264 (make-annotation gl (point) 'text)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
265 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 (delete-file ps-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 (delete-file gif-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (set-alist 'mime-viewer/content-filter-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 "application/postscript"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 (function mime-preview/filter-for-application/postscript))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
274
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
275 ;;; @ setting
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
276 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
277
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
278 (mapcar
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
279 (lambda (ctype)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
280 (or (member ctype mime-viewer/default-showing-Content-Type-list)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
281 (setq mime-viewer/default-showing-Content-Type-list
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
282 (cons ctype
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
283 mime-viewer/default-showing-Content-Type-list))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
284 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
285 tm-image/inline-image-types)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 (provide 'tm-image)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 ;;; tm-image.el ends here