* wl.el (toplevel): Added (C) to copyright notice, and
[elisp/wanderlust.git] / wl / wl-e21.el
1 ;;; wl-e21.el -- Wanderlust modules for Emacs 21.
2
3 ;; Copyright (C) 2000 Katsumi Yamaoka <yamaoka@jpl.org>
4 ;; Copyright (C) 2000 Yuuichi Teranishi <teranisi@gohome.org>
5
6 ;; Author: Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, net news
8
9 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15 ;;
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20 ;;
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25 ;;
26
27 ;;; Commentary:
28 ;;
29 ;; This module uses `before-string' overlay property to show icon
30 ;; images instead of `insert-image', so don't delete such overlays
31 ;; sloppily.  Here is a sample code to show icons in the buffer.
32 ;;
33 ;;(let (image icon from to overlay)
34 ;;  ;; The function `find-image' will look for an image first on `load-path'
35 ;;  ;; and then in `data-directory'.
36 ;;  (let ((load-path (cons wl-icon-dir load-path)))
37 ;;    (setq image (find-image (list (list :type 'xpm :file wl-nntp-folder-icon
38 ;;                                      :ascent 'center)))))
39 ;;  ;; `propertize' is a convenient function in such a case.
40 ;;  ;; String must have one or more length to wear an image.
41 ;;  (setq icon (propertize "any string" 'display image))
42 ;;  (pop-to-buffer (get-buffer-create "*wl-e21-demo*"))
43 ;;  (erase-buffer)
44 ;;  (insert "   ")
45 ;;  (setq from (point))
46 ;;  (insert "-fj.wanderlust:0/0/0")
47 ;;  (setq to (point))
48 ;;  (insert "\n")
49 ;;  (setq overlay (make-overlay from to))
50 ;;  ;; Put an image.
51 ;;  (overlay-put overlay 'before-string icon)
52 ;;  ;; Put a mark to indicate that this overlay is made by `wl-e21'.
53 ;;  ;; It is not always necessarily.
54 ;;  (overlay-put overlay 'wl-e21-icon t)
55 ;;  ;; Make it to be removable.
56 ;;  (overlay-put overlay 'evaporate t))
57
58 ;;; Code:
59 ;;
60
61 (eval-when-compile
62   (require 'wl-folder)
63   (require 'wl-summary)
64   (require 'wl-draft)
65   (require 'wl-message)
66   (require 'wl-highlight)
67   (defvar-maybe wl-folder-mode-map (make-sparse-keymap))
68   (defvar-maybe wl-draft-mode-map (make-sparse-keymap)))
69
70 (add-hook 'wl-folder-mode-hook 'wl-setup-folder)
71 (add-hook 'wl-folder-mode-hook 'wl-folder-init-icons)
72
73 (add-hook 'wl-init-hook 'wl-biff-init-icons)
74 (add-hook 'wl-init-hook 'wl-plugged-init-icons)
75
76 (add-hook 'wl-summary-mode-hook 'wl-setup-summary)
77
78 (defvar wl-use-toolbar (image-type-available-p 'xpm))
79 (defvar wl-plugged-image nil)
80 (defvar wl-unplugged-image nil)
81 (defvar wl-biff-mail-image nil)
82 (defvar wl-biff-nomail-image nil)
83
84 (defvar wl-folder-toolbar
85   '([wl-folder-jump-to-current-entity
86      wl-folder-jump-to-current-entity t "Enter Current Folder"]
87     [wl-folder-next-entity
88      wl-folder-next-entity t "Next Folder"]
89     [wl-folder-prev-entity
90      wl-folder-prev-entity t "Previous Folder"]
91     [wl-folder-check-current-entity
92      wl-folder-check-current-entity t "Check Current Folder"]
93     ;;[wl-draft
94     ;; wl-draft t "Write a New Message"]
95     [wl-folder-sync-current-entity
96      wl-folder-sync-current-entity t "Sync Current Folder"]
97     [wl-draft
98      wl-draft t "Write a New Message"]
99     [wl-folder-empty-trash
100      wl-folder-empty-trash t "Empty Trash"]
101     [wl-exit
102      wl-exit t "Quit Wanderlust"]
103     )
104   "The Folder buffer toolbar.")
105
106 (defvar wl-summary-toolbar
107   '([wl-summary-read
108      wl-summary-read t "Read Messages"]
109     [wl-summary-next
110      wl-summary-next t "Next Message"]
111     [wl-summary-prev
112      wl-summary-prev t "Previous Message"]
113     [wl-summary-jump-to-current-message
114      wl-summary-jump-to-current-message t "Jump to Current Message"]
115     [wl-summary-sync-force-update
116      wl-summary-sync-force-update t "Sync Current Folder"]
117     [wl-summary-delete
118      wl-summary-delete t "Delete Current Message"]
119     [wl-summary-mark-as-important
120      wl-summary-mark-as-important t "Mark Current Message as Important"]
121     [wl-draft
122      wl-draft t "Write a New Message"]
123     [wl-summary-reply
124      wl-summary-reply t "Reply to Current Message" ]
125     [wl-summary-reply-with-citation
126      wl-summary-reply-with-citation t "Reply to Current Message with Citation"]
127     [wl-summary-forward
128      wl-summary-forward t "Forward Current Message"]
129     [wl-summary-exit
130      wl-summary-exit t "Exit Current Summary"]
131     )
132   "The Summary buffer toolbar.")
133
134 (defvar wl-message-toolbar
135   '([wl-message-read
136      wl-message-read t "Read Contents"]
137     [wl-message-next-content
138      wl-message-next-content t "Next Content"]
139     [wl-message-prev-content
140      wl-message-prev-content t "Previous Content"]
141     [wl-message-quit
142      wl-message-quit t "Back to Summary"]
143     [wl-message-play-content
144      wl-message-play-content t "Play Content"]
145     [wl-message-extract-content
146      wl-message-extract-content t "Extract Content"]
147     )
148   "The Message buffer toolbar.")
149
150 (defalias 'wl-draft-insert-signature 'insert-signature);; for draft toolbar.
151
152 (defvar wl-draft-toolbar
153   '([wl-draft-send-from-toolbar
154      wl-draft-send-from-toolbar t "Send Current Draft"]
155     [wl-draft-yank-original
156      wl-draft-yank-original t "Yank Displaying Message"]
157     [wl-draft-insert-signature
158      wl-draft-insert-signature t "Insert Signature"]
159     [wl-draft-kill
160      wl-draft-kill t "Kill Current Draft"]
161     )
162   "The Draft buffer toolbar.")
163
164 (defun wl-e21-setup-toolbar (bar)
165   (let ((load-path (cons wl-icon-dir load-path))
166         (props '(:type xpm :ascent center
167                        :color-symbols (("backgroundToolBarColor" . "None"))
168                        :file))
169         (success t)
170         icon up down disabled name success)
171     (while bar
172       (setq icon (aref (pop bar) 0))
173       (unless (boundp icon)
174         (setq name (symbol-name icon)
175               up (find-image `((,@props ,(concat name "-up.xpm")))))
176         (if up
177             (progn
178               (setq down (find-image `((,@props ,(concat name "-down.xpm"))))
179                     disabled (find-image `((,@props
180                                             ,(concat name "-disabled.xpm")))))
181               (set icon (vector down up disabled disabled)))
182           (setq bar nil
183                 success nil))))
184     success))
185
186 (defvar wl-e21-toolbar-configurations
187   '((auto-resize-tool-bar        . t)
188     (auto-raise-tool-bar-buttons . t)
189     (tool-bar-button-margin      . 0)
190     (tool-bar-button-relief      . 2)))
191
192 (defun wl-e21-make-toolbar-buttons (keymap defs)
193   (let ((configs wl-e21-toolbar-configurations)
194         config)
195     (while (setq config (pop configs))
196       (set (make-local-variable (car config)) (cdr config))))
197   ;; Invalidate the default bindings.
198   (let ((keys (cdr (key-binding [tool-bar] t)))
199         item)
200     (while (setq item (pop keys))
201       (when (setq item (car-safe item))
202         (define-key keymap (vector 'tool-bar item) 'undefined))))
203   (let ((n (length defs))
204         def)
205     (while (>= n 0)
206       (setq n (1- n)
207             def (nth n defs))
208       (define-key keymap (vector 'tool-bar (aref def 1))
209         (list 'menu-item (aref def 3) (aref def 1)
210               :enable (aref def 2)
211               :image (symbol-value (aref def 0)))))))
212
213 (defun wl-e21-setup-folder-toolbar ()
214   (and wl-use-toolbar
215        (display-graphic-p)
216        (wl-e21-setup-toolbar wl-folder-toolbar)
217        (wl-e21-make-toolbar-buttons wl-folder-mode-map wl-folder-toolbar)))
218
219 (defun wl-e21-setup-summary-toolbar ()
220   (and wl-use-toolbar
221        (display-graphic-p)
222        (wl-e21-setup-toolbar wl-summary-toolbar)
223        (wl-e21-make-toolbar-buttons wl-summary-mode-map wl-summary-toolbar)))
224
225 (eval-when-compile
226   (defsubst wl-e21-setup-message-toolbar (keymap)
227     (and wl-use-toolbar
228          (display-graphic-p)
229          (wl-e21-setup-toolbar wl-message-toolbar)
230          (wl-e21-make-toolbar-buttons keymap wl-message-toolbar)))
231
232   (defsubst wl-e21-setup-draft-toolbar ()
233     (and wl-use-toolbar
234          (display-graphic-p)
235          (wl-e21-setup-toolbar wl-draft-toolbar)
236          (wl-e21-make-toolbar-buttons wl-draft-mode-map wl-draft-toolbar))))
237
238 (defvar wl-folder-toggle-icon-list
239   '((wl-folder-opened-image       . wl-opened-group-folder-icon)
240     (wl-folder-closed-image       . wl-closed-group-folder-icon)))
241
242 (eval-when-compile
243   (defsubst wl-e21-highlight-folder-group-line (start end icon numbers)
244     (when (display-graphic-p)
245       (let (overlay)
246         (let ((overlays (overlays-in start end)))
247           (while (and (setq overlay (pop overlays))
248                       (not (overlay-get overlay 'wl-e21-icon)))))
249         (unless overlay
250           (setq overlay (make-overlay start end))
251           (overlay-put overlay 'wl-e21-icon t)
252           (overlay-put overlay 'evaporate t))
253         (let ((image (get icon 'image)))
254           (unless image
255             (let ((name (symbol-value
256                          (cdr (assq icon wl-folder-toggle-icon-list))))
257                   (load-path (cons wl-icon-dir load-path)))
258               (when (setq image (find-image `((:type xpm :file ,name
259                                                      :ascent center))))
260                 (setq image (put icon 'image (propertize name
261                                                          'display image))))))
262           (overlay-put overlay 'before-string image)
263           (overlay-put overlay 'invisible (and image t))
264           (when (and wl-use-highlight-mouse-line (display-mouse-p))
265             (let ((inhibit-read-only t))
266               (put-text-property (if image
267                                      (max (1- start) (line-beginning-position))
268                                    start)
269                                  (line-end-position)
270                                  'mouse-face 'highlight)))))))
271
272   (defsubst wl-e21-highlight-folder-by-numbers (start end text-face numbers)
273     (when (display-color-p)
274       (let ((inhibit-read-only t))
275         (if (and wl-highlight-folder-by-numbers
276                  numbers (nth 0 numbers) (nth 1 numbers)
277                  (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+"
278                                     (line-end-position) t))
279             (let* ((unsync (nth 0 numbers))
280                    (unread (nth 1 numbers))
281                    (face (cond ((and unsync (zerop unsync))
282                                 (if (and unread (zerop unread))
283                                     'wl-highlight-folder-zero-face
284                                   'wl-highlight-folder-unread-face))
285                                ((and unsync
286                                      (>= unsync
287                                          wl-folder-many-unsync-threshold))
288                                 'wl-highlight-folder-many-face)
289                                (t
290                                 'wl-highlight-folder-few-face))))
291               (if (numberp wl-highlight-folder-by-numbers)
292                   (progn
293                     (put-text-property start (match-beginning 0)
294                                        'face text-face)
295                     (put-text-property (match-beginning 0) (match-end 0)
296                                        'face face))
297                 (put-text-property start (match-end 0) 'face face)))
298           (put-text-property start (line-end-position) 'face text-face))))))
299
300 (defun wl-highlight-folder-current-line (&optional numbers)
301   (interactive)
302   (save-excursion
303     (beginning-of-line)
304     (let (fld-name start end)
305       (cond
306        (;; opened folder group
307         (looking-at wl-highlight-folder-opened-regexp)
308         (setq start (match-beginning 1)
309               end (match-end 1))
310         (wl-e21-highlight-folder-group-line start end
311                                             'wl-folder-opened-image
312                                             numbers)
313         (wl-e21-highlight-folder-by-numbers start end
314                                             'wl-highlight-folder-opened-face
315                                             numbers))
316        (;; closed folder group
317         (looking-at wl-highlight-folder-closed-regexp)
318         (setq start (match-beginning 1)
319               end (match-end 1))
320         (wl-e21-highlight-folder-group-line start end
321                                             'wl-folder-closed-image
322                                             numbers)
323         (wl-e21-highlight-folder-by-numbers start end
324                                             'wl-highlight-folder-closed-face
325                                             numbers))
326        (;; basic folder
327         (and (setq fld-name (wl-folder-get-folder-name-by-id
328                              (get-text-property (point) 'wl-folder-entity-id)))
329              (looking-at "[\t ]+\\([^\t\n ]+\\)"))
330         (setq start (match-beginning 1)
331               end (match-end 1))
332         (let (image)
333           (when (display-graphic-p)
334             (let (overlay)
335               (let ((overlays (overlays-in start end)))
336                 (while (and (setq overlay (pop overlays))
337                             (not (overlay-get overlay 'wl-e21-icon)))))
338               (unless overlay
339                 (setq overlay (make-overlay start end))
340                 (overlay-put overlay 'wl-e21-icon t)
341                 (overlay-put overlay 'evaporate t))
342               (let (type)
343                 (setq image
344                       (cond ((string= fld-name wl-trash-folder);; trash folder
345                              (let ((num (nth 2 numbers)));; number of messages
346                                (get (if (or (not num) (zerop num))
347                                         'wl-folder-trash-empty-image
348                                       'wl-folder-trash-image)
349                                     'image)))
350                             ((string= fld-name wl-draft-folder);; draft folder
351                              (get 'wl-folder-draft-image 'image))
352                             ((string= fld-name wl-queue-folder);; queue folder
353                              (get 'wl-folder-queue-image 'image))
354                             (;; and one of many other folders
355                              (setq type (elmo-folder-get-type fld-name))
356                              (get (intern (format "wl-folder-%s-image" type))
357                                   'image)))))
358               (overlay-put overlay 'before-string image)))
359           (when (and wl-use-highlight-mouse-line (display-mouse-p))
360             (let ((inhibit-read-only t))
361               (put-text-property (if image
362                                      (max (1- start)
363                                           (line-beginning-position))
364                                    start)
365                                  (line-end-position)
366                                  'mouse-face 'highlight))))
367         (when (display-color-p)
368           (wl-e21-highlight-folder-by-numbers
369            start end
370            (if (looking-at (format "^[\t ]*\\(%s\\|%s\\)"
371                                    wl-folder-unsubscribe-mark
372                                    wl-folder-removed-mark))
373                'wl-highlight-folder-killed-face
374              'wl-highlight-folder-unknown-face)
375            numbers)))))))
376
377 (defun wl-highlight-plugged-current-line ()
378   (interactive)
379   (when (display-graphic-p)
380     (save-excursion
381       (beginning-of-line)
382       (when (looking-at "[\t ]*\\(\\[\\([^]]+\\)\\]\\)")
383         (let* ((start (match-beginning 1))
384                (end (match-end 1))
385                (status (match-string-no-properties 2))
386                (image (if (string-equal wl-plugged-plug-on status)
387                           wl-plugged-image
388                         wl-unplugged-image)))
389           (when image
390             (let (overlay)
391               (let ((overlays (overlays-in start end)))
392                 (while (and (setq overlay (pop overlays))
393                             (not (overlay-get overlay 'wl-e21-icon)))))
394               (unless overlay
395                 (setq overlay (make-overlay start end))
396                 (overlay-put overlay 'wl-e21-icon t)
397                 (overlay-put overlay 'evaporate t))
398               (put-text-property 0 (length status) 'display image status)
399               (overlay-put overlay 'before-string status)
400               (overlay-put overlay 'invisible t))))))))
401
402 (defun wl-plugged-set-folder-icon (folder string)
403   (if (display-graphic-p)
404       (let (type)
405         (cond ((string= folder wl-queue-folder)
406                (concat (propertize " " 'display
407                                    (get 'wl-folder-queue-image 'image))
408                        string))
409               ((setq type (elmo-folder-get-type folder))
410                (concat (propertize " " 'display
411                                    (get (intern (format "wl-folder-%s-image"
412                                                         type))
413                                         'image))
414                        string))
415               (t
416                string)))
417     string))
418
419 (defvar wl-folder-internal-icon-list
420   ;; alist of (image . icon-file)
421   '((wl-folder-nntp-image         . wl-nntp-folder-icon)
422     (wl-folder-imap4-image        . wl-imap-folder-icon)
423     (wl-folder-pop3-image         . wl-pop-folder-icon)
424     (wl-folder-localdir-image     . wl-localdir-folder-icon)
425     (wl-folder-localnews-image    . wl-localnews-folder-icon)
426     (wl-folder-internal-image     . wl-internal-folder-icon)
427     (wl-folder-multi-image        . wl-multi-folder-icon)
428     (wl-folder-filter-image       . wl-filter-folder-icon)
429     (wl-folder-archive-image      . wl-archive-folder-icon)
430     (wl-folder-pipe-image         . wl-pipe-folder-icon)
431     (wl-folder-maildir-image      . wl-maildir-folder-icon)
432     (wl-folder-trash-empty-image  . wl-empty-trash-folder-icon)
433     (wl-folder-draft-image        . wl-draft-folder-icon)
434     (wl-folder-queue-image        . wl-queue-folder-icon)
435     (wl-folder-trash-image        . wl-trash-folder-icon)))
436
437 (defun wl-folder-init-icons ()
438   (let ((load-path (cons wl-icon-dir load-path))
439         (icons wl-folder-internal-icon-list)
440         icon name image)
441     (while (setq icon (pop icons))
442       (unless (get (car icon) 'image)
443         (setq name (symbol-value (cdr icon))
444               image (find-image `((:type xpm :file ,name :ascent center))))
445         (when image
446           (put (car icon) 'image (propertize name 'display image)))))))
447
448 (defun wl-plugged-init-icons ()
449   (unless wl-plugged-image
450     (let ((load-path (cons wl-icon-dir load-path)))
451       (setq wl-plugged-image (find-image `((:type xpm
452                                                   :file ,wl-plugged-icon
453                                                   :ascent center)))
454             wl-unplugged-image (find-image `((:type xpm
455                                                     :file ,wl-unplugged-icon
456                                                     :ascent center))))))
457   (if (display-mouse-p)
458       (let ((props (list 'local-map (purecopy (make-mode-line-mouse2-map
459                                                #'wl-toggle-plugged))
460                          'help-echo "mouse-2 toggles plugged status")))
461         (if (display-graphic-p)
462             (setq wl-modeline-plug-state-on
463                   (apply 'propertize wl-plug-state-indicator-on
464                          `(display ,wl-plugged-image ,@props))
465                   wl-modeline-plug-state-off
466                   (apply 'propertize wl-plug-state-indicator-off
467                          `(display ,wl-unplugged-image ,@props)))
468           (setq wl-modeline-plug-state-on
469                 (apply 'propertize wl-plug-state-indicator-on props)
470                 wl-modeline-plug-state-off
471                 (apply 'propertize wl-plug-state-indicator-off props))))
472     (setq wl-modeline-plug-state-on wl-plug-state-indicator-on
473           wl-modeline-plug-state-off wl-plug-state-indicator-off)))
474
475 (defun wl-biff-init-icons ()
476   (unless wl-biff-mail-image
477     (let ((load-path (cons wl-icon-dir load-path)))
478       (setq wl-biff-mail-image (find-image
479                                 `((:type xpm :file ,wl-biff-mail-icon
480                                          :ascent center)))
481             wl-biff-nomail-image (find-image
482                                   `((:type xpm :file ,wl-biff-nomail-icon
483                                            :ascent center))))))
484   (if (display-mouse-p)
485       (let ((props (list 'local-map (purecopy (make-mode-line-mouse2-map
486                                                (lambda nil
487                                                  (call-interactively
488                                                   'wl-biff-check-folders))))
489                          'help-echo "mouse-2 checks new mails")))
490         (if (display-graphic-p)
491             (setq wl-modeline-biff-state-on
492                   (apply 'propertize wl-biff-state-indicator-on
493                          `(display ,wl-biff-mail-image ,@props))
494                   wl-modeline-biff-state-off
495                   (apply 'propertize wl-biff-state-indicator-off
496                          `(display ,wl-biff-nomail-image ,@props)))
497           (setq wl-modeline-biff-state-on
498                 (apply 'propertize wl-biff-state-indicator-on props)
499                 wl-modeline-biff-state-off
500                 (apply 'propertize wl-biff-state-indicator-off props))))
501     (setq wl-modeline-biff-state-on wl-biff-state-indicator-on
502           wl-modeline-biff-state-off wl-biff-state-indicator-off)))
503
504 (defun wl-make-date-string ()
505   (format-time-string "%a, %d %b %Y %T %z"))
506
507 (defalias 'wl-setup-folder 'wl-e21-setup-folder-toolbar)
508
509 (defalias 'wl-setup-summary 'wl-e21-setup-summary-toolbar)
510
511 (defun wl-message-overload-functions ()
512   (let ((keymap (current-local-map)))
513     (when keymap
514       (wl-e21-setup-message-toolbar keymap)
515       (define-key keymap "l" 'wl-message-toggle-disp-summary)
516       (define-key keymap [mouse-2] 'wl-message-refer-article-or-url)
517       (define-key keymap [mouse-4] 'wl-message-wheel-down)
518       (define-key keymap [mouse-5] 'wl-message-wheel-up)
519       (define-key keymap [S-mouse-4] 'wl-message-wheel-down)
520       (define-key keymap [S-mouse-5] 'wl-message-wheel-up)
521       (set-keymap-parent wl-message-button-map keymap)
522       (define-key wl-message-button-map
523         [mouse-2] 'wl-message-button-dispatcher))))
524
525 (defun wl-message-wheel-up (event)
526   (interactive "e")
527   (if (string-match wl-message-buf-name (buffer-name))
528       (wl-message-next-page)
529     (let ((cur-buf (current-buffer))
530           proceed)
531       (save-selected-window
532         (select-window (posn-window (event-start event)))
533         (set-buffer cur-buf)
534         (setq proceed (wl-message-next-page)))
535       (if proceed
536           (if (memq 'shift (event-modifiers event))
537               (wl-summary-down t)
538             (wl-summary-next t))))))
539
540 (defun wl-message-wheel-down (event)
541   (interactive "e")
542   (if (string-match wl-message-buf-name (buffer-name))
543       (wl-message-prev-page)
544     (let ((cur-buf (current-buffer))
545           proceed)
546       (save-selected-window
547         (select-window (posn-window (event-start event)))
548         (set-buffer cur-buf)
549         (setq proceed (wl-message-prev-page)))
550       (if proceed
551           (if (memq 'shift (event-modifiers event))
552               (wl-summary-up t)
553             (wl-summary-prev t))))))
554
555 (defun wl-draft-overload-menubar ()
556   (let ((keymap (current-local-map)))
557     (define-key keymap [menu-bar mail send]
558       '("Send Message" . wl-draft-send-and-exit))
559     (define-key keymap [menu-bar mail send-stay]
560       '("Send, Keep Editing" . wl-draft-send))
561     (define-key keymap [menu-bar mail cancel]
562       '("Kill Current Draft" . wl-draft-kill))
563     (define-key keymap [menu-bar mail yank]
564       '("Cite Message" . wl-draft-yank-original))
565     (define-key keymap [menu-bar mail signature]
566       '("Insert Signature" . insert-signature))
567     (define-key keymap [menu-bar headers fcc]
568       '("FCC" . wl-draft-fcc))))
569
570 (defun wl-draft-mode-setup ()
571   (require 'derived)
572   (define-derived-mode wl-draft-mode mail-mode "Draft"
573     "draft mode for Wanderlust derived from mail mode.
574 See info under Wanderlust for full documentation.
575
576 Special commands:
577 \\{wl-draft-mode-map}"))
578
579 (defun wl-draft-key-setup ()
580   (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
581   (define-key wl-draft-mode-map "\C-c\C-s" 'wl-draft-send)
582   (define-key wl-draft-mode-map "\C-c\C-a" 'wl-draft-insert-x-face-field)
583   (define-key wl-draft-mode-map "\C-c\C-c" 'wl-draft-send-and-exit)
584   (define-key wl-draft-mode-map "\C-c\C-z" 'wl-draft-save-and-exit)
585   (define-key wl-draft-mode-map "\C-c\C-k" 'wl-draft-kill)
586   (define-key wl-draft-mode-map "\C-l" 'wl-draft-highlight-and-recenter)
587   (define-key wl-draft-mode-map "\C-i" 'wl-complete-field-body-or-tab)
588   (define-key wl-draft-mode-map "\C-c\C-r" 'wl-draft-caesar-region)
589   (define-key wl-draft-mode-map "\M-t" 'wl-toggle-plugged)
590   (define-key wl-draft-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
591   (define-key wl-draft-mode-map "\C-c\C-e" 'wl-draft-config-exec)
592   (define-key wl-draft-mode-map "\C-c\C-j" 'wl-template-select)
593   (define-key wl-draft-mode-map "\C-c\C-p" 'wl-draft-preview-message)
594   (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
595   (define-key wl-draft-mode-map "\C-xk"    'wl-draft-mimic-kill-buffer))
596
597 (defun wl-draft-overload-functions ()
598   (wl-mode-line-buffer-identification)
599   (local-set-key "\C-c\C-s" 'wl-draft-send);; override
600   (wl-e21-setup-draft-toolbar)
601   (wl-draft-overload-menubar))
602
603 (defalias 'wl-defface 'defface)
604
605 (require 'product)
606 (product-provide (provide 'wl-e21) (require 'wl-version))
607
608 ;;; wl-e21.el ends here