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