Initial Commit
[packages] / xemacs-packages / mew / mew / mew-win32.el
1 ;;; mew-win32.el --- Settings for Mew on Win32
2
3 ;; Author:  Shuichi Kitaguchi <kit@Mew.org>
4 ;; Created: Dec 05, 1997
5 ;; Revised: Nov 20, 1999
6
7 ;;; Code:
8
9 (defconst mew-win32-version "mew-win32.el 0.33.1")
10 (require 'mew-func)
11 ;;; for NTEmacs User
12 ;;
13 ;; put mw32script.el(in Meadow's archive) into load-path.
14 ;;
15
16 ;;
17 ;;  ~/.emacs settings
18 ;;
19
20 ;;; for PGP/MIME
21 ;;    mew-prog-pgp           ...  executable name for PGP/MIME
22 ;;
23 ;;; example
24 ;;    (setq mew-prog-pgp  "pgp.exe")      ;; PGP
25 ;;    (setq mew-prog-pgp  "gpg.exe")      ;; GNUPG
26
27 ;;; for Windows NT with NTFS
28 ;;(eval-after-load "mew-win32"
29 ;;  '(setq mew-touch-folder-p nil))
30
31 ;;; for PRINTING
32 ;;    mew-w32-prog-print     ...  print command
33 ;;    mew-w32-prog-print-arg ...  print command argument
34 ;;    mew-w32-cs-print       ...  coding-system for printing
35 ;;    define-process-argument-editing  ...  for argument-editing
36 ;;
37 ;;; example
38 ;;   (setq mew-w32-prog-print     "notepad.exe")
39 ;;   (setq mew-w32-prog-print-arg "/p")
40 ;;   (setq mew-w32-cs-print       '*sjis*dos)      ;; Mule for Win32
41 ;;   (setq mew-w32-cs-print       'shift_jis-dos)  ;; Meadow
42 ;;   (define-process-argument-editing "/notepad\\.exe$"
43 ;;     (lambda (x)
44 ;;       (general-process-argument-editing-function x nil t)))
45 ;;   (setq mew-print-function (function mew-w32-print-buffer))
46
47 ;; Win32 programs.
48 (defvar mew-w32-exec           "fiber.exe")
49 (defvar mew-w32-prog-print     "notepad.exe")
50 (defvar mew-w32-prog-print-arg nil)
51
52
53 ;; Emacs version dependent variables.
54 (cond
55  ((featurep 'xemacs)    ; XEmacs?
56   (setq mew-prog-shell-arg  shell-command-switch))
57   
58  ((eq 20 emacs-major-version)
59   (if (boundp 'w32-system-coding-system)
60       (setq mew-cs-pick w32-system-coding-system))
61   (setq mew-prog-shell-arg  shell-command-switch)
62   
63   (if (featurep 'meadow);; Meadow
64       (progn
65         (require 'mw32script)
66         (mw32script-init))
67     (if (require 'mw32script nil t);; NTEmacs
68         (progn
69           (mw32script-make-pathext-regexp)
70           (fset 'call-process-original (symbol-function 'call-process))
71           (defun call-process (PROGRAM INFILE BUFFER DISPLAY &rest PROGRAM-ARGS)
72             (let (prog sargs)
73               (setq prog (mw32script-openp PROGRAM))
74               (if (not prog)
75                   (progn
76                     (setq prog (mew-which PROGRAM exec-path))
77                     (setq sargs (mw32script-resolve-script prog))))
78               (if sargs
79                   (apply (function call-process-original)
80                          (car sargs) INFILE BUFFER DISPLAY
81                          prog PROGRAM-ARGS)
82                 (apply (function call-process-original)
83                        PROGRAM INFILE BUFFER DISPLAY PROGRAM-ARGS))))
84           (fset 'start-process-original (symbol-function 'start-process))
85           (defun start-process (NAME BUFFER PROGRAM &rest PROGRAM-ARGS)
86             (let (prog sargs)
87               (setq prog (mw32script-openp PROGRAM))
88               (if (not prog)
89                   (progn
90                     (setq prog (mew-which PROGRAM exec-path))
91                     (setq sargs (mw32script-resolve-script prog))))
92               (if sargs
93                   (apply (function start-process-original)
94                          NAME BUFFER (car sargs) prog PROGRAM-ARGS)
95                 (apply (function start-process-original)
96                        NAME BUFFER PROGRAM PROGRAM-ARGS))))))
97     ))
98  (t                              ;; Mule for Windows
99   (setq mew-cs-pick         win32-system-coding-system)
100   (setq mew-use-timer       nil)
101   (setq mew-prog-shell-arg  shell-command-option)
102   (require 'win32-script)
103   (define-process-argument-editing
104     "/[^./]+$"
105     'script-process-argument-editing-function 'last)))
106
107 ;; common programs.
108 (setq mew-prog-mime-encode  "mewencode.exe")
109 (setq mew-prog-mime-decode  "mewdecode.exe")
110 (setq mew-prog-tar          "tar.exe")
111 (setq mew-prog-compress     "compress.exe")
112 (setq mew-prog-gzip         "gzip.exe")
113 (setq mew-prog-shell        shell-file-name)
114
115 ;(setq mew-prog-pgp          "pgp.exe")
116 (setq mew-prog-pgp2         "pgp.exe")
117 (setq mew-prog-pgp5         "pgp.exe")
118 (setq mew-prog-pgp5e        "pgpe.exe")
119 (setq mew-prog-pgp5s        "pgps.exe")
120 (setq mew-prog-pgp5v        "pgpv.exe")
121 (setq mew-prog-pgp5k        "pgpk.exe")
122 (setq mew-prog-gpg          "gpg.exe")
123
124 (setq mew-touch-folder-p    t)
125 (setq mew-delete-temp-file  nil)
126
127 (setq mew-prog-uncompface   "uncompface.exe")
128
129 (setq mew-prog-text/html     mew-w32-exec)
130 (setq mew-prog-text/html-arg nil)
131 (setq mew-ext-prog-url       mew-w32-exec)
132 (setq mew-ext-prog-url-args  nil)
133
134
135 ;; printing
136 (defun mew-w32-print-buffer ()
137   (interactive)
138   (setq tempfile (mew-make-temp-name))
139   (mew-frwlet
140    mew-cs-dummy mew-w32-cs-print
141    (write-region (point-min) (point-max) tempfile nil nil))
142   (setq w32-start-process-show-window t)
143   (cond
144    ((eq mew-w32-prog-print-arg nil)
145     (call-process mew-w32-prog-print nil nil nil tempfile))
146    (t
147     (call-process mew-w32-prog-print nil nil nil mew-w32-prog-print-arg tempfile)))
148   (setq w32-start-process-show-window nil)
149   (delete-file tempfile))
150
151
152 ;; MIME setting
153 (defvar mew-prog-plain           '(mew-mime-text/plain     () nil))
154 (defvar mew-prog-html            '(mew-mime-text/html      () nil))
155 (defvar mew-prog-enriched        '(mew-mime-text/enriched  () nil))
156 (defvar mew-prog-text            '(mew-mime-text/plain     () nil))
157 (defvar mew-prog-audio           (list mew-w32-exec        () t))
158 (defvar mew-prog-audio2          (list mew-w32-exec        () t))
159 (defvar mew-prog-gif             (list mew-w32-exec        () t))
160 (defvar mew-prog-tiff            (list mew-w32-exec        () t))
161 (defvar mew-prog-jpeg            (list mew-w32-exec        () t))
162 (defvar mew-prog-xwd             (list mew-w32-exec        () t))
163 (defvar mew-prog-xbm             (list mew-w32-exec        () t))
164 (defvar mew-prog-xpm             (list mew-w32-exec        () t))
165 (defvar mew-prog-png             (list mew-w32-exec        () t))
166 (defvar mew-prog-bmp             (list mew-w32-exec        () t))
167 (defvar mew-prog-image           (list mew-w32-exec        () t))
168 (defvar mew-prog-mpeg            (list mew-w32-exec        () t))
169 (defvar mew-prog-rfc822          '(mew-mime-message/rfc822 () nil))
170 (defvar mew-prog-external-body   '(mew-mime-external-body  () nil))
171 (defvar mew-prog-delivery-status '(mew-mime-text/plain     () nil))
172 (defvar mew-prog-postscript      (list mew-w32-exec        () t))
173 (defvar mew-prog-pgp-keys        '(mew-mime-pgp-keys       () nil))
174 (defvar mew-prog-pdf             (list mew-w32-exec        () t))
175 (defvar mew-prog-octet-stream    (list mew-w32-exec        () t))
176
177 (defvar mew-prog-w32             (list mew-w32-exec        () t))
178
179 (setq mew-mime-content-type
180       (append
181        '(
182          ;; Audio (mew-prog-audio)
183          ("audio/x-wav"     "\\.wav$"   mew-b64 mew-prog-audio mew-icon-audio)
184          ("audio/x-aiff"    "\\.aif?f$" mew-b64 mew-prog-audio mew-icon-audio)
185          ("audio/x-midi"    "\\.midi?$" mew-b64 mew-prog-audio mew-icon-audio)
186          ;; Image (mew-prog-image)
187          ("image/x-pcx"     "\\.pcx$"   mew-b64 mew-prog-image mew-icon-image)
188          ("image/x-tga"     "\\.tga$"   mew-b64 mew-prog-image mew-icon-image)
189          ;; Video (mew-prog-mpeg)
190          ("video/x-msvideo" "\\.avi$"   mew-b64 mew-prog-mpeg  mew-icon-video)
191          ("video/quicktime" "\\.mov$"   mew-b64 mew-prog-mpeg  mew-icon-video)
192          ;; Executable (mew-prog-w32)
193          ("application/octet-stream" "\\.exe$\\|\\.com$\\|\\.cmd$\\|\\.bat$"
194           mew-b64 mew-prog-w32 mew-icon-application/octet-stream)
195          ;; Archive (mew-prog-w32)
196          ("application/octet-stream"
197           "\\.taz$|\\.tar\\.?b?z?2?$\\|\\.bz2?$\\|\\.arj$\\|\\.zoo$\\|\\.rar$|\\.cab$"
198           mew-b64 mew-prog-w32 mew-icon-application/octet-stream)
199          ;; Document (mew-prog-w32)
200          ("application/x-dvi" "\\.dvi$"
201           mew-b64 mew-prog-w32 mew-icon-application/postscript)
202          ;; MS Application (mew-prog-w32)
203          ("application/msword" "\\.doc$"
204           mew-b64 mew-prog-w32 mew-icon-text)
205          ("application/vnd.ms-excel" "\\.xls$"
206           mew-b64 mew-prog-w32 mew-icon-text)
207          ("application/vnd.ms-powerpoint" "\\.ppt$"
208           mew-b64 mew-prog-w32 mew-icon-text)
209          ;; OASYS
210          ("application/vnd.fujitsu.oasys" "\\.oas$"
211           mew-b64 mew-prog-w32 mew-icon-text)
212          ("application/vnd.fujitsu.oasys2" "\\.oa2$"
213           mew-b64 mew-prog-w32 mew-icon-text)
214          ("application/vnd.fujitsu.oasys3" "\\.oa3$"
215           mew-b64 mew-prog-w32 mew-icon-text)
216          )
217        mew-mime-content-type))
218
219 (setq mew-mime-content-type-list
220       (append
221        '(
222          ;; Image
223          "image/x-pcx" "image/x-pic"
224          ;; Audio
225          "audio/x-wav" "audio/x-aiff" "audio/x-midi"
226          ;; Video
227          "video/x-msvideo" "video/quicktime"
228          ;; Document
229          "application/pdf" "application/x-dvi"
230          ;; MS Application
231          "application/msword" "application/vnd.ms-excel"
232          "application/vnd.ms-powerpoint"
233          ;; OASYS
234          "application/vnd.fujitsu.oasys"
235          "application/vnd.fujitsu.oasys2"
236          "application/vnd.fujitsu.oasys3"
237          )
238        mew-mime-content-type-list))
239
240 (provide 'mew-win32)
241
242 ;;; Copyright Notice:
243
244 ;; Copyright (C) 1996, 1997, 1998, 1999 Mew developing team.
245 ;; All rights reserved.
246
247 ;; Redistribution and use in source and binary forms, with or without
248 ;; modification, are permitted provided that the following conditions
249 ;; are met:
250 ;; 
251 ;; 1. Redistributions of source code must retain the above copyright
252 ;;    notice, this list of conditions and the following disclaimer.
253 ;; 2. Redistributions in binary form must reproduce the above copyright
254 ;;    notice, this list of conditions and the following disclaimer in the
255 ;;    documentation and/or other materials provided with the distribution.
256 ;; 3. Neither the name of the team nor the names of its contributors
257 ;;    may be used to endorse or promote products derived from this software
258 ;;    without specific prior written permission.
259 ;; 
260 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
261 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
262 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
263 ;; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
264 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
265 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
266 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
267 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
268 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
269 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
270 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271
272 ;;; mew-win32.el ends here