1 ;;; mew-xemacs.el --- Environment of XEmacs for Mew
3 ;; Author: Kazu Yamamoto <Kazu@Mew.org>
4 ;; Created: Mar 20, 1997
5 ;; Revised: Aug 30, 1999
9 (defconst mew-xemacs-version "mew-xemacs.el version 0.09")
17 (defvar mew-icon-directory nil)
18 (defvar mew-icon-separate-spec nil)
19 (defvar mew-icon-blank nil)
20 (defvar mew-icon-audio nil)
21 (defvar mew-icon-image nil)
22 (defvar mew-icon-video nil)
23 (defvar mew-icon-application/postscript nil)
24 (defvar mew-icon-application/octet-stream nil)
25 (defvar mew-icon-message/rfc822 nil)
26 (defvar mew-icon-message/external-body nil)
27 (defvar mew-icon-text nil)
28 (defvar mew-icon-multipart nil)
29 (defvar mew-icon-unknown nil)
30 (defvar mew-summary-toolbar nil)
31 (defvar mew-draft-toolbar nil))
33 (defvar mew-icon-directory (locate-data-directory "mew"))
35 (defvar mew-icon-separate
36 (toolbar-make-button-list
37 (expand-file-name "mew-sep.xpm" mew-icon-directory)))
39 (defvar mew-icon-separate-spec
40 (list [mew-icon-separate nil nil ""]))
42 (defvar mew-icon-blank
43 (toolbar-make-button-list
44 (expand-file-name "mew-Blank.xpm" mew-icon-directory)))
46 (defvar mew-icon-audio
47 (toolbar-make-button-list
48 (expand-file-name "mew-Audio.xpm" mew-icon-directory)))
50 (defvar mew-icon-image
51 (toolbar-make-button-list
52 (expand-file-name "mew-Image.xpm" mew-icon-directory)))
54 (defvar mew-icon-video
55 (toolbar-make-button-list
56 (expand-file-name "mew-Video.xpm" mew-icon-directory)))
58 (defvar mew-icon-application/postscript
59 (toolbar-make-button-list
60 (expand-file-name "mew-Postscript.xpm" mew-icon-directory)))
62 (defvar mew-icon-application/octet-stream
63 (toolbar-make-button-list
64 (expand-file-name "mew-Octet-Stream.xpm" mew-icon-directory)))
66 (defvar mew-icon-message/rfc822
67 (toolbar-make-button-list
68 (expand-file-name "mew-Rfc822.xpm" mew-icon-directory)))
70 (defvar mew-icon-message/external-body
71 (toolbar-make-button-list
72 (expand-file-name "mew-External.xpm" mew-icon-directory)))
75 (toolbar-make-button-list
76 (expand-file-name "mew-Text.xpm" mew-icon-directory)))
78 (defvar mew-icon-multipart
79 (toolbar-make-button-list
80 (expand-file-name "mew-Folder.xpm" mew-icon-directory)))
82 (defvar mew-icon-unknown
83 (toolbar-make-button-list
84 (expand-file-name "mew-Unknown.xpm" mew-icon-directory)))
90 (defvar mew-summary-toolbar-icon-show
91 (toolbar-make-button-list
92 (expand-file-name "mew-show.xpm" mew-icon-directory)))
94 (defvar mew-summary-toolbar-icon-next
95 (toolbar-make-button-list
96 (expand-file-name "mew-next.xpm" mew-icon-directory)))
98 (defvar mew-summary-toolbar-icon-prev
99 (toolbar-make-button-list
100 (expand-file-name "mew-prev.xpm" mew-icon-directory)))
102 (defvar mew-summary-toolbar-icon-inc
103 (toolbar-make-button-list
104 (expand-file-name "mew-inc.xpm" mew-icon-directory)))
106 (defvar mew-summary-toolbar-icon-write
107 (toolbar-make-button-list
108 (expand-file-name "mew-write.xpm" mew-icon-directory)))
110 (defvar mew-summary-toolbar-icon-reply
111 (toolbar-make-button-list
112 (expand-file-name "mew-reply.xpm" mew-icon-directory)))
114 (defvar mew-summary-toolbar-icon-forward
115 (toolbar-make-button-list
116 (expand-file-name "mew-forward.xpm" mew-icon-directory)))
118 (defvar mew-summary-toolbar-icon-refile
119 (toolbar-make-button-list
120 (expand-file-name "mew-refile.xpm" mew-icon-directory)))
122 (defvar mew-summary-toolbar
124 [mew-summary-toolbar-icon-show
128 [mew-summary-toolbar-icon-next
129 mew-summary-display-down
132 [mew-summary-toolbar-icon-prev
133 mew-summary-display-up
135 "Show Previous Message"]
136 [mew-summary-toolbar-icon-inc
139 "Check New Messages"]
140 [mew-summary-toolbar-icon-write
144 [mew-summary-toolbar-icon-reply
147 "Reply to This Message"]
148 [mew-summary-toolbar-icon-forward
151 "Forward This Message"]
152 [mew-summary-toolbar-icon-refile
155 "Refile This Message"]
162 (defvar mew-draft-toolbar-icon-comp
163 (toolbar-make-button-list
164 (expand-file-name "mew-comp.xpm" mew-icon-directory)))
166 (defvar mew-draft-toolbar-icon-send
167 (toolbar-make-button-list
168 (expand-file-name "mew-send.xpm" mew-icon-directory)))
170 (defvar mew-draft-toolbar-icon-attach
171 (toolbar-make-button-list
172 (expand-file-name "mew-attach.xpm" mew-icon-directory)))
174 (defvar mew-draft-toolbar-icon-cite
175 (toolbar-make-button-list
176 (expand-file-name "mew-cite.xpm" mew-icon-directory)))
178 (defvar mew-draft-toolbar-icon-yank
179 (toolbar-make-button-list
180 (expand-file-name "mew-yank.xpm" mew-icon-directory)))
182 (defvar mew-draft-toolbar-icon-pgp-sign
183 (toolbar-make-button-list
184 (expand-file-name "mew-pgp-sign.xpm" mew-icon-directory)))
186 (defvar mew-draft-toolbar-icon-pgp-enc
187 (toolbar-make-button-list
188 (expand-file-name "mew-pgp-enc.xpm" mew-icon-directory)))
190 (defvar mew-draft-toolbar-icon-pgp-sigenc
191 (toolbar-make-button-list
192 (expand-file-name "mew-pgp-sigenc.xpm" mew-icon-directory)))
194 (defvar mew-draft-toolbar
196 [mew-draft-toolbar-icon-comp
197 mew-draft-make-message
200 [mew-draft-toolbar-icon-send
201 mew-draft-send-letter
204 [mew-draft-toolbar-icon-cite
208 [mew-draft-toolbar-icon-yank
211 "Cite Message without Label"]
212 [mew-draft-toolbar-icon-attach
213 mew-draft-prepare-attachments
214 (and (mew-header-p) (not (mew-attach-p)))
215 "Prepare Attachments"]
216 [mew-draft-toolbar-icon-pgp-sign
219 "Sign Message with PGP"]
220 [mew-draft-toolbar-icon-pgp-enc
221 mew-pgp-encrypt-letter
223 "Encrypt Message with PGP"]
224 [mew-draft-toolbar-icon-pgp-sigenc
225 mew-pgp-sign-encrypt-letter
227 "Sign Then Encrypt Message with PGP"]
234 (define-key toolbar-map 'button3 'pressed-and-activate-toolbar-button)
235 (define-key toolbar-map 'button3up 'release-and-activate-toolbar-button)
237 (defun mew-summary-button ()
238 "Call back function for toolbar of Summary mode.
239 If event is button 1, show a part.
240 If event is button 3, show a menu."
242 (let* ((msg (mew-summary-message-number))
243 (part (mew-syntax-number))
244 (nums (mew-syntax-number-to-nums part))
245 (button (event-button last-command-event)))
246 (mew-summary-goto-part msg part)
247 (mew-summary-recenter)
250 (mew-summary-show-part msg nums))
252 (popup-menu mew-summary-mode-toolbar-menu)))))
254 (defun mew-summary-show-part (msg nums)
255 "Show a part according to the clicked icon."
257 (let ((fld (mew-summary-folder-name))
258 (ofld-msg (mew-current-get 'message))
261 (message "No message")
262 (mew-summary-toggle-disp-msg 'on)
265 (mew-window-configure buf 'message)
267 (mew-summary-display-part
268 (mew-cache-decode-syntax (mew-cache-hit ofld-msg)) nums))
269 (mew-pop-to-buffer buf)))))
271 (defun mew-draft-button ()
272 "Call back function for toolbar of Draft mode.
273 If event is button 1, show a part.
274 If event is button 3, show a menu."
276 (let ((nums (mew-syntax-nums))
277 (button (event-button last-command-event)))
278 (mew-attach-goto-number 'here nums)
281 (mew-draft-show-attach nums))
283 (popup-menu mew-draft-mode-toolbar-menu)))))
285 ;; This is a toy at present. Support only CT: Image/*.
286 ;; To make Summary and Draft symmetric, left button click on icon
287 ;; should display the attachment.
288 (defun mew-draft-show-attach (nums)
289 "Show a part according to the clicked icon."
291 (let ((case-fold-search t)
292 (str (toolbar-button-help-string last-pressed-toolbar-button))
293 (image-extent (extent-at (point-max) nil nil nil 'at))
295 (if (and image-extent (glyphp image-extent))
296 (mew-overlay-delete image-extent))
297 (if (null (string-match "(\\(.*\\))" str))
299 (setq ct (mew-match 1 str))
300 (if (string-match "^Image/" ct)
301 (let* ((subdir (mew-attach-expand-path mew-encode-syntax nums))
302 (syntax (mew-syntax-get-entry mew-encode-syntax nums))
303 (name (mew-syntax-get-file syntax))
304 (ename (if (equal subdir "") name (concat subdir name)))
305 (file (expand-file-name ename (mew-attachdir)))
306 (attr (mew-attr-by-ct ct))
307 (program (mew-attr-get-prog attr))
308 (options (mew-attr-get-opt attr))
309 (async (mew-attr-get-async attr))
310 (zmacs-regions nil) ;; for XEmacs
312 ((and (string-match "jpeg" ct)
313 (valid-image-instantiator-format-p 'jpeg))
315 ((and (string-match "gif" ct)
316 (valid-image-instantiator-format-p 'gif))
318 ((and (string-match "xbm" ct)
319 (valid-image-instantiator-format-p 'xbm))
321 ((and (string-match "xpm" ct)
322 (valid-image-instantiator-format-p 'xpm))
324 ((and (string-match "png" ct)
325 (valid-image-instantiator-format-p 'png))
331 (message "Loading image...")
332 (setq glyph (make-glyph (vector format :file file)))
334 (set-glyph-property glyph 'face 'x-face))
335 (set-extent-begin-glyph
336 (mew-overlay-make (point-max) (point-max)) glyph)
337 (message "Loading image...done."))
338 (if (and (stringp program) (mew-which program exec-path))
340 (mew-mime-start-process program options file)
341 (mew-mime-call-process program options file)))))))))
343 (defun pressed-and-activate-toolbar-button (event)
344 "A replacement function 'press-toolbar-button' so that
345 popup menu can be implemented."
347 (or (button-press-event-p event)
348 (error "%s must be invoked by a mouse-press" this-command))
349 (let ((button (event-toolbar-button event)) callback)
350 (if (null (toolbar-button-p button))
352 (setq last-pressed-toolbar-button button)
353 (if (and (setq callback (toolbar-button-callback button))
354 (or (equal callback 'mew-summary-button)
355 (equal callback 'mew-draft-button)))
356 (if (null (toolbar-button-enabled-p button))
358 ;; (setq toolbar-active t) is meaningless... why?
359 (setq this-command callback)
360 (if (symbolp callback)
361 (call-interactively callback)
363 ;; emulate press-toolbar-button
364 (setq this-command last-command)
365 (setq toolbar-active t)
366 (set-toolbar-button-down-flag button t)))))
371 (defmacro mew-summary-toolbar-update ()
373 (set-specifier default-toolbar
374 (cons (current-buffer) mew-summary-toolbar))))
376 (defmacro mew-draft-toolbar-update ()
378 (set-specifier default-toolbar
379 (cons (current-buffer) mew-draft-toolbar))))
381 (defvar mew-x-emacs-end-of-message nil)
382 (defvar mew-x-emacs-end-of-part nil)
384 (defmacro mew-message-set-end-of-message ()
386 (if (not (glyphp mew-x-emacs-end-of-message))
387 (setq mew-x-emacs-end-of-message
389 (vector 'string :data mew-end-of-message-string))))
390 (mew-overlay-put mew-message-overlay
392 mew-x-emacs-end-of-message)))
394 (defmacro mew-message-set-end-of-part ()
396 (if (not (glyphp mew-x-emacs-end-of-part))
397 (setq mew-x-emacs-end-of-part
399 (vector 'string :data mew-end-of-part-string))))
400 (mew-overlay-put mew-message-overlay
402 mew-x-emacs-end-of-part)))
404 (defmacro mew-message-set-end-of-nil ()
405 '(mew-overlay-put mew-message-overlay 'begin-glyph nil))
407 (provide 'mew-xemacs)
409 ;;; Copyright Notice:
411 ;; Copyright (C) 1997, 1998, 1999 Mew developing team.
412 ;; All rights reserved.
414 ;; Redistribution and use in source and binary forms, with or without
415 ;; modification, are permitted provided that the following conditions
418 ;; 1. Redistributions of source code must retain the above copyright
419 ;; notice, this list of conditions and the following disclaimer.
420 ;; 2. Redistributions in binary form must reproduce the above copyright
421 ;; notice, this list of conditions and the following disclaimer in the
422 ;; documentation and/or other materials provided with the distribution.
423 ;; 3. Neither the name of the team nor the names of its contributors
424 ;; may be used to endorse or promote products derived from this software
425 ;; without specific prior written permission.
427 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
428 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
429 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
430 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
431 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
432 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
433 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
434 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
435 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
436 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
437 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
439 ;;; mew-xemacs.el ends here