(What's EMH?): Modify for the new URLs of APEL, FLIM and SEMI.
[elisp/emh.git] / emh-e21.el
1 ;;; emh-e21.el --- EMH modules for Emacs 21.
2
3 ;; Copyright (C) 2002 TSUMURA Tomoaki <tsumura@tomo.gr.jp>
4
5 ;; Author: TSUMURA Tomoaki <tsumura@tomo.gr.jp>
6
7 ;; This file is part of emh.
8
9 ;; This program is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU General Public License as
11 ;; published by the Free Software Foundation; either version 2, or (at
12 ;; your option) any later version.
13
14 ;; This program is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Code:
25
26 ;; All code is stolen from wl-e21.el
27 (eval-when-compile
28   (defvar-maybe mh-folder-mode-map (make-sparse-keymap))
29 )
30
31 (defvar emh-folder-toolbar
32   '([mh-show
33      mh-show t "Show Mail"]
34     [mh-next-undeleted-msg
35      mh-next-undeleted-msg t "Next Message"]
36     [mh-previous-undeleted-msg
37      mh-previous-undeleted-msg t "Previous Message"]
38     [mh-inc-folder
39      mh-inc-folder t "Incorporate New Mails"]
40     [mh-delete-msg
41      mh-delete-msg t "Delete Message"]
42     [mh-send
43      mh-send t "New Message"]
44     [mh-reply
45      mh-reply t "Reply Message"]
46     [emh-forward
47      emh-forward t "Forward Message"]
48     [mh-rescan-folder
49      mh-rescan-folder t "Rescan Folder"]
50     [mh-quit
51      mh-quit t "Exit MH-E"]
52     )
53   "Folder buffer toolbar.")
54
55 (defvar emh-draft-toolbar
56   '([mh-send-letter
57      mh-send-letter t "Send Letter"]
58     [mh-yank-cur-msg
59      mh-yank-cur-msg t "Yank and Cite Message"]
60     [mh-insert-signature
61      mh-insert-signature t "Insert Signature"]
62     [mime-edit-set-encrypt
63      mime-edit-set-encrypt t "PGP Encrypt"]
64     [mime-edit-set-sign
65      mime-edit-set-sign t "PGP Signature"]
66     [mh-fully-kill-draft
67      mh-fully-kill-draft t "Delete Draft"]
68     )
69   )
70
71 (defun emh-e21-setup-toolbar (bar)
72   (when (and (display-images-p)
73              (image-type-available-p 'xpm))
74     (let ((load-path (cons emh-icon-directory load-path))
75           (props '(:type xpm :ascent center
76                          :color-symbols (("backgroundToolBarColor" . "None"))
77                          :file))
78           (success t)
79           icon up down disabled name)
80       (while bar
81         (setq icon (aref (pop bar) 0))
82         (unless (boundp icon)
83           (setq name (symbol-name icon)
84                 up (find-image `((,@props ,(concat name "-up.xpm")))))
85           (if up
86               (set icon (vector up up up up))
87             (setq bar nil success nil))
88           )
89         )
90       success)))
91
92 (defun emh-e21-make-toolbar-buttons (keymap defs)
93   (let ((configs '((auto-resize-tool-bars . t)
94                    (auto-raise-tool-bar-buttons . t)
95                    (tool-bar-button-margin . 0)
96                    (tool-bar-button-relief . 2)))
97         config)
98     (while (setq config (pop configs))
99       (set (make-local-variable (car config)) (cdr config))))
100   (let ((keys (cdr (key-binding [tool-bar] t)))
101         item)
102     (while (setq item (pop keys))
103       (when (setq item (car-safe item))
104         (define-key keymap (vector 'tool-bar item) 'undefined))))
105   (let ((n (length defs))
106         def)
107     (while (>= n 0)
108       (setq n (1- n)
109             def (nth n defs))
110       (define-key keymap (vector 'tool-bar (aref def 1))
111         (list 'menu-item (aref def 3) (aref def 1)
112               :enable (aref def 2)
113               :image (symbol-value (aref def 0)))))))
114
115 (defun emh-e21-setup-folder-toolbar ()
116   (when (emh-e21-setup-toolbar emh-folder-toolbar)
117     (emh-e21-make-toolbar-buttons mh-folder-mode-map emh-folder-toolbar)))
118 (add-hook 'mh-folder-mode-hook 'emh-e21-setup-folder-toolbar)
119
120 (defun emh-e21-setup-draft-toolbar ()
121   (when (emh-e21-setup-toolbar emh-draft-toolbar)
122     (emh-e21-make-toolbar-buttons mime-edit-mode-map emh-draft-toolbar)))
123 (add-hook 'mime-edit-mode-hook 'emh-e21-setup-draft-toolbar)
124
125 ;;; @ end
126 ;;;
127
128 (provide 'emh-e21)
129
130 ;;; emh-e21.el ends here