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