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