Initial Commit
[packages] / xemacs-packages / mew / mew / mew-os2.el
1 ;;
2 ;;  mew-os2.el
3 ;;     --- OS/2 specific settings & external/internal MIME methods.
4 ;;
5 ;; Author:  OKUNISHI Fujikazu <fuji0924@mbox.kyoto-inet.or.jp>
6 ;;          Kazu Yamamoto <Kazu@Mew.org>
7 ;; Created: Dec 18, 1996
8 ;; Revised: Aug 30, 1999
9
10
11 ;;; Code
12 (defconst mew-os2-version "mew-os2.el v0.28")
13
14 (defvar mew-os2-load-hook nil
15  "*Hook called after mew-os2 has been loaded.")
16
17 \f
18 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 ;; coding-system
20
21 (setq mew-cs-text-for-write 'mew-cs-text-crlf)
22 (cond
23  ((featurep 'mew-mule2) ;; 2.3@19.x
24     (if (not (boundp '*ctext*dos))
25       (make-coding-system
26        '*ctext* 2               ;; xxx
27        ?X "Coding-system used in X as Compound Text Encoding."
28        t        ;; xxx '*ctext*unix, '*ctext*dos, '*ctext*mac, too
29         (list lc-ascii lc-ltn1 lc-invalid lc-invalid
30           nil 'ascii-eol 'ascii-cntl)))
31     (setq mew-cs-scan     '*ctext*dos)
32     (setq mew-cs-virtual  mew-cs-scan) ;; remove ^M
33     ;; for *.cmd (by NAKAGAWA Takayuki)
34     (require 'os2-process)
35     )
36  ((featurep 'mew-mule3) ;; MULE 3.0
37   ))
38
39
40 \f
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42 ;; OS/2 & shell specific variables
43
44 ;; os2-process.el
45 ;;(setq mew-prog-shell (file-name-nondirectory os2-process-comspec-cmd))
46 ;;(setq mew-prog-shell-arg "/c")
47
48 ;(setq mew-prog-utime ;; NOT fullpath
49 ;  (file-name-nondirectory
50 ;    (os2-process-openp "utime" exec-path os2-process-exec-suffixes t)))
51 (setq mew-prog-uncompface "uncompface.exe")
52
53 (setq mew-prog-mime-encode "mewencode.exe")
54 (setq mew-prog-mime-decode "mewdecode.exe")
55
56 ;; nsclient: "http://www.t3.rim.or.jp/~homy/"
57 (defvar mew-ext-prog-url "nsclient.exe")
58
59 (autoload 'browse-url-at-mouse "browse-url" nil t)
60 (autoload 'browse-url-interactive-arg "browse-url" nil t)
61
62 (defun browse-url-nsclient (url)
63   (interactive (browse-url-interactive-arg "Netscape URL: "))
64   (x-set-selection 'PRIMARY url)
65   (start-process "nsclient" nil "nsclient.exe" url))
66
67 ;;(add-hook 'mew-init-hook (function (lambda ()
68 ;;  (define-key mew-message-mode-map [mouse-2] 'browse-url-at-mouse))))
69
70 ;;(setq browse-url-browser-function (function browse-url-nsclient))
71
72 \f
73 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
74 ;; 'mew-summary-x-face (C-cC-x)
75 ;;  rexX-Face
76 ;;    => http://web.kyoto-inet.or.jp/people/fuji0924/os2mew.html
77
78 ;;(setq mew-x-face-filter (list mew-prog-uncompface "icon2xbm")) ;; rexX-Face/icon2xbm.cmd
79 ;;(setq mew-x-face-prog "d:/tool/pmview/pmview.exe")  ;; PMview, GBM/2
80 ;;(setq mew-x-face-args '("/Wpos=\(,,,,For\)"))
81
82 \f
83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
84 ;; misc
85
86 (setq mew-touch-folder-p t)
87 ;; Perl
88 (setenv "PERL_BADLANG" "0")
89 (setenv "PERL_BADFREE" "0")
90
91 ;; Archive interface for OS/2 imcat
92 (defvar mew-os2/archive-prefix "archived")
93 (defvar mew-os2/archive-suffix ".zip")
94
95 (defconst mew-os2/archive
96   (concat mew-os2/archive-prefix mew-os2/archive-suffix))
97
98 (defun mew-os2/archive-exist-p (fld)
99   (file-exists-p (mew-expand-folder fld mew-os2/archive)))
100
101 \f
102 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 ;; MIME methods
104
105 (defvar mew-os2/mime-method "mew-mime.cmd")
106 (defvar mew-prog-plain '(mew-mime-text/plain () nil))
107 (defvar mew-prog-enriched '(mew-mime-text/enriched () nil))
108 ;;(defvar mew-prog-html '(mew-mime-text/html () nil))
109 ;; Netscape/nsclient: "x:/foo/bar.html" => "file:///x|/foo/bar.html"
110 (defvar mew-prog-html (list mew-os2/mime-method (list "text/html") t))
111 (defvar mew-prog-text '(mew-mime-text/plain () nil))
112 (defvar mew-prog-audio
113   (list mew-prog-shell (list mew-prog-shell-arg "cat - > /dev/audio") nil))
114 (defvar mew-prog-audio2
115   (list mew-prog-shell (list mew-prog-shell-arg "cat < /dev/audio") nil))
116 (defvar mew-prog-gif (if (and window-system mew-xemacs-p
117                               (valid-image-instantiator-format-p 'gif))
118                          '(mew-mime-image/gif () nil)
119                        (list mew-os2/mime-method (list "image/gif") t)))
120 (defvar mew-prog-jpeg (if (and window-system mew-xemacs-p
121                                (valid-image-instantiator-format-p 'jpeg))
122                           '(mew-mime-image/jpeg () nil)
123                         (list mew-os2/mime-method (list "image/jpeg") t)))
124 (defvar mew-prog-xwd (list mew-os2/mime-method (list "image/x-xwd") t))
125 (defvar mew-prog-xbm
126   (if (fboundp 'bitmap-insert-xbm-buffer)  ;; bitmap-mule/bitmap.el
127       '(mew-mime-image/x-xbm-for-mule () nil)
128     (if (and window-system mew-xemacs-p
129              (valid-image-instantiator-format-p 'xbm)) ;; XEmacs
130         '(mew-mime-image/xbm () nil)
131       (list mew-os2/mime-method (list "image/x-xbm") t))))
132
133 (defvar mew-prog-bmp (list mew-os2/mime-method (list "image/x-bmp") t))
134 (defvar mew-prog-image (list mew-os2/mime-method (list "image/oth") t))
135 (defvar mew-prog-mpeg (list mew-os2/mime-method (list "video/mpeg") t))
136 (defvar mew-prog-rfc822 '(mew-mime-message/rfc822 () nil))
137 (defvar mew-prog-external-body '(mew-mime-external-body () nil))
138 (defvar mew-prog-delivery-status '(mew-mime-text/plain () nil))
139 (defvar mew-prog-postscript (list mew-os2/mime-method (list "application/postscript") t))
140 (defvar mew-prog-pgp-keys '(mew-mime-pgp-keys () nil))
141 (defvar mew-prog-octet-stream '(mew-mime-application/octet-stream () nil))
142
143 \f
144 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
145 ;; other MIME Content-Types & methods
146
147 ;; Audio
148 (defvar mew-prog-wav
149   (list mew-os2/mime-method (list "audio/x-wav") t))
150 (defvar mew-prog-aiff
151   (list mew-os2/mime-method (list "audio/x-aiff") t))
152 (defvar mew-prog-midi
153   (list mew-os2/mime-method (list "audio/x-midi") t))
154
155 ;; Image
156 (defvar mew-prog-os2-bmp
157   (list mew-os2/mime-method (list "image/x-os2-bmp") t))
158 (defvar mew-prog-tiff
159   (list mew-os2/mime-method (list "image/tiff") t))
160 (defvar mew-prog-pic
161   (list mew-os2/mime-method (list "image/x-pic") t))
162 (defvar mew-prog-pcx
163   (list mew-os2/mime-method (list "image/x-pcx") t))
164 (defvar mew-prog-prm
165   (list mew-os2/mime-method (list "image/x-prm") t))
166 (defvar mew-prog-pgm
167   (list mew-os2/mime-method (list "image/x-pgm") t))
168 (defvar mew-prog-xpm
169   (list mew-os2/mime-method (list "image/x-xpm") t))
170 (defvar mew-prog-png (if (and window-system mew-xemacs-p
171                               (valid-image-instantiator-format-p 'png))
172                          '(mew-mime-image/png () nil)
173                        (list mew-os2/mime-method (list "image/png") t)))
174 (defvar mew-prog-meta
175   (list mew-os2/mime-method (list "image/x-os2-meta") t))
176
177 ;; Movie
178 (defvar mew-prog-msvideo
179   (list mew-os2/mime-method (list "video/x-msvideo") t))
180 (defvar mew-prog-qt
181   (list mew-os2/mime-method (list "video/quicktime") t))
182
183 ;; misc
184 (defvar mew-prog-pdf
185   (list mew-os2/mime-method (list "application/pdf") t))
186 (defvar mew-prog-mac
187   (list mew-os2/mime-method (list "application/mac-binhex40") t))
188 (defvar mew-prog-view
189   (list mew-os2/mime-method (list "application/x-os2-inf") t))
190 (defvar mew-prog-viewhelp
191   (list mew-os2/mime-method (list "application/x-os2-hlp") t))
192 (defvar mew-prog-caesar-table
193   (if (fboundp 'mew-mime-text/x-rot13-47)
194       '(mew-mime-text/x-rot13-47 () nil)
195     '(mew-mime-text/plain () nil)))
196
197
198 (setq mew-mime-content-type (append '(
199  ;; Audio
200    ("audio/x-wav"
201     "\\.wav$"
202     mew-b64
203     mew-prog-wav
204     mew-icon-audio
205     )
206    ("audio/x-aiff"
207     "\\.aif?f$"
208     mew-b64
209     mew-prog-aiff
210     mew-icon-audio
211     )
212    ("audio/x-midi"
213     "\\.midi?$"
214     mew-b64
215     mew-prog-midi
216     mew-icon-audio
217     )
218  ;; Image
219    ("image/x-os2-bmp"
220     "\\.bmp$"
221     mew-b64
222     mew-prog-os2-bmp
223     mew-icon-image
224     )
225    ("image/tiff"
226     "\\.tif?f$"
227     mew-b64
228     mew-prog-tiff
229     mew-icon-image
230     )
231    ("image/x-tiff"
232     "\\.tif?f$"
233     mew-b64
234     mew-prog-tiff
235     mew-icon-image
236     )
237    ("image/x-pic"
238     "\\.pic$"
239     mew-b64
240     mew-prog-pic
241     mew-icon-image
242     )
243    ("image/x-pcx"
244     "\\.pcx$"
245     mew-b64
246     mew-prog-pcx
247     mew-icon-image
248     )
249    ("image/x-prm"
250     "\\.prm$"
251     mew-b64
252     mew-prog-prm
253     mew-icon-image
254     )
255    ("image/x-pgm"
256     "\\.pgm$"
257     mew-b64
258     mew-prog-pgm
259     mew-icon-image
260     )
261    ("image/x-xpm"
262     "\\.xpm$"
263     mew-b64
264     mew-prog-xpm
265     mew-icon-image
266     )
267    ("image/x-os2-meta"
268     "\\.meta?$"
269     mew-b64
270     mew-prog-meta
271     mew-icon-image
272     )
273  ;; Movie
274    ("video/x-msvideo"
275     "\\.avi$"
276     mew-b64
277     mew-prog-msvideo
278     mew-icon-video
279     )
280    ("video/quicktime"
281     "\\.mov$"
282     mew-b64
283     mew-prog-qt
284     mew-icon-video
285     )
286  ;; misc (binary file)
287    ("application/octet-stream"
288     "\\.exe$\\|\\.com$\\|\\.cmd$\\|\\.tar\\.?b?z?2?$\\|\\.bz2?$\\|\\.lzh$\\|\\.zip$\\|\\.arj$\\|\\.zoo$\\|\\.rar$\\|\\.img$"
289     mew-b64
290     mew-prog-octet-stream
291     mew-icon-application/octet-stream
292     )
293    ("application/mac-binhex40"
294     "\\.hqx$"
295     mew-b64
296     mew-prog-mac
297     mew-icon-application/octet-stream
298     )
299    ("application/x-os2-inf"
300     "\\.inf$"
301     mew-b64
302     mew-prog-view
303     mew-icon-application/octet-stream
304     )
305    ("application/x-os2-hlp"
306     "\\.hlp$"
307     mew-b64
308     mew-prog-viewhelp
309     mew-icon-application/octet-stream
310     )
311    ("text/x-rot13-47"
312     "\\.rot$"
313     nil
314     mew-prog-caesar-table
315     mew-icon-text
316    )
317  ) mew-mime-content-type ))
318
319
320 (setq mew-mime-content-type-list (append
321   '(
322     "application/mac-hexbin40"
323     "application/x-os2-inf"
324     "application/x-os2-hlp"
325     "image/x-os2-bmp" "image/tiff" "image/x-tiff"
326     "image/x-pcx" "image/x-pic" "image/x-xpm"
327     "image/x-prm" "image/x-pgm" "image/x-os2-meta"
328     "audio/x-wav" "audio/x-aiff" "audio/x-midi"
329     "video/x-msvideo" "video/quicktime"
330     )
331     mew-mime-content-type-list))
332
333 \f
334 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
335 ;; internal method for image/x-xbm. -- 'bitmap-mule/bitmap.el' required.
336 ;;
337 (defun mew-mime-image/x-xbm-for-mule (begin end &optional params execute)
338   (if (> end begin)
339       (save-excursion
340         (set-buffer (mew-buffer-message))
341         (mew-elet
342          (insert-buffer-substring (mew-current-get 'cache) begin end)
343          (if (or mew-end-of-message-string mew-end-of-part-string) ;; xxx
344              (goto-char (point-max)) ;; necessary?
345            (setq last-point (point-max))
346            (bitmap-insert-xbm-buffer (mew-buffer-message))
347            (delete-region (point-min) last-point)))
348         (set-buffer-modified-p nil) ;; xxx
349         )))
350 \f
351 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
352 ;; fasten mew-folder-list() w/ REXX
353 (defvar mew-prog-rxfolders "RxFolders")
354
355 ;(if (os2-process-openp mew-prog-rxfolders exec-path '(".exe" ".cmd" "") t)
356 ;    (setq mew-folder-list-function 'mew-os2/folders-list))
357
358
359 (defun mew-os2/folders-list (prefix)
360   (let (folder folders-list
361         (path (cond
362                ((string= "+" prefix) mew-mail-path)
363                ((string= "=" prefix) mew-news-path))))
364     (mew-set-buffer-tmp)
365     (call-process mew-prog-rxfolders nil t nil path)
366     (goto-char (point-min))
367     (while (re-search-forward ".+$" nil t)
368       (setq folder (concat prefix (mew-match 0)))
369       (setq folders-list (cons folder folders-list)))
370     folders-list))
371
372 \f
373 ;;; End
374 (provide 'mew-os2)
375 (run-hooks 'mew-os2-load-hook)
376
377 ;;; Copyright Notice:
378
379 ;; Copyright (C) 1997, 1998, 1999 Mew developing team.
380 ;; All rights reserved.
381
382 ;; Redistribution and use in source and binary forms, with or without
383 ;; modification, are permitted provided that the following conditions
384 ;; are met:
385 ;; 
386 ;; 1. Redistributions of source code must retain the above copyright
387 ;;    notice, this list of conditions and the following disclaimer.
388 ;; 2. Redistributions in binary form must reproduce the above copyright
389 ;;    notice, this list of conditions and the following disclaimer in the
390 ;;    documentation and/or other materials provided with the distribution.
391 ;; 3. Neither the name of the team nor the names of its contributors
392 ;;    may be used to endorse or promote products derived from this software
393 ;;    without specific prior written permission.
394 ;; 
395 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
396 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
397 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
398 ;; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
399 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
400 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
401 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
402 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
403 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
404 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
405 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
406
407 ;; mew-os2.el ends here