* wl-e21.el (wl-draft-insert-signature): Fix comment style.
[elisp/wanderlust.git] / wl / wl-e21.el
index 93b6349..89bdaa7 100644 (file)
     )
   "The Message buffer toolbar.")
 
-(defalias 'wl-draft-insert-signature 'insert-signature);; for draft toolbar.
+(defalias 'wl-draft-insert-signature 'insert-signature)        ; for draft toolbar.
 
 (defvar wl-draft-toolbar
   '([wl-draft-send-from-toolbar
     '(and wl-highlight-folder-with-icon
          (image-type-available-p 'xpm))))
 
+(eval-and-compile
+  (if (boundp 'image-load-path)
+      (defun wl-e21-find-image (specs)
+       (let ((image-load-path (cons 'wl-icon-directory image-load-path)))
+         (find-image specs)))
+    (defun wl-e21-find-image (specs)
+      (let ((load-path (cons wl-icon-directory load-path)))
+       (find-image specs)))))
+
 (defun wl-e21-setup-toolbar (bar)
   (when (and wl-use-toolbar
             (wl-e21-display-image-p))
-    (let ((load-path (cons wl-icon-directory load-path))
-         (props '(:type xpm :ascent center
+    (let ((props '(:type xpm :ascent center
                         :color-symbols (("backgroundToolBarColor" . "None"))
                         :file))
          (success t)
        (setq icon (aref (pop bar) 0))
        (unless (boundp icon)
          (setq name (symbol-name icon)
-               up (find-image `((,@props ,(concat name "-up.xpm")))))
+               up (wl-e21-find-image `((,@props ,(concat name "-up.xpm")))))
          (if up
              (progn
-               (setq down (find-image `((,@props ,(concat name "-down.xpm"))))
-                     disabled (find-image
+               (setq down (wl-e21-find-image
+                           `((,@props ,(concat name "-down.xpm"))))
+                     disabled (wl-e21-find-image
                                `((,@props ,(concat name "-disabled.xpm")))))
-               (set icon (vector down up disabled disabled)))
+               (if (and down disabled)
+                   (set icon (vector down up disabled disabled))
+                 (set icon up)))
            (setq bar nil
                  success nil))))
       success)))
          (setq image (get icon 'image))
          (unless image
            (let ((name (symbol-value
-                        (cdr (assq icon wl-folder-toggle-icon-list))))
-                 (load-path (cons wl-icon-directory load-path)))
-             (setq image (find-image `((:type xpm :file ,name
-                                              :ascent center))))))
+                        (cdr (assq icon wl-folder-toggle-icon-list)))))
+             (setq image (wl-e21-find-image
+                          `((:type xpm :file ,name :ascent center))))))
          (overlay-put overlay 'display image)))
       (when (and wl-use-highlight-mouse-line (display-mouse-p))
        (let ((inhibit-read-only t))
     (beginning-of-line)
     (let (fld-name start end)
       (cond
-       (;; opened folder group
-       (and (wl-folder-buffer-group-p)
+       ;; opened folder group
+       ((and (wl-folder-buffer-group-p)
             (looking-at wl-highlight-folder-opened-regexp))
        (setq start (match-beginning 1)
              end (match-end 1))
        (wl-e21-highlight-folder-by-numbers start end
                                            'wl-highlight-folder-opened-face
                                            numbers))
-       (;; closed folder group
-       (and (wl-folder-buffer-group-p)
+       ;; closed folder group
+       ((and (wl-folder-buffer-group-p)
             (looking-at wl-highlight-folder-closed-regexp))
        (setq start (match-beginning 1)
              end (match-end 1))
        (wl-e21-highlight-folder-by-numbers start end
                                            'wl-highlight-folder-closed-face
                                            numbers))
-       (;; basic folder
-       (and (setq fld-name (wl-folder-get-folder-name-by-id
+       ;; basic folder
+       ((and (setq fld-name (wl-folder-get-folder-name-by-id
                             (get-text-property (point) 'wl-folder-entity-id)))
             (looking-at "[[:blank:]]+\\([^[:blank:]\n]+\\)"))
        (setq start (match-beginning 1)
                (unless (get (caar wl-folder-internal-icon-list) 'image)
                  (wl-folder-init-icons))
                (setq image
-                     (cond ((string= fld-name wl-trash-folder);; trash folder
-                            (let ((num (nth 2 numbers)));; number of messages
-                              (get (if (or (not num) (zerop num))
-                                       'wl-folder-trash-empty-image
-                                     'wl-folder-trash-image)
-                                   'image)))
-                           ((string= fld-name wl-draft-folder);; draft folder
-                            (get 'wl-folder-draft-image 'image))
-                           ((string= fld-name wl-queue-folder);; queue folder
-                            (get 'wl-folder-queue-image 'image))
-                           (;; and one of many other folders
-                            (setq type (or (elmo-folder-type fld-name)
-                                           (elmo-folder-type-internal
-                                            (elmo-make-folder fld-name))))
-                            (get (intern (format "wl-folder-%s-image" type))
-                                 'image)))))
+                     (cond
+                      ;; trash folder
+                      ((string= fld-name wl-trash-folder)
+                       (let ((num (nth 2 numbers))) ; number of messages
+                         (get (if (or (not num) (zerop num))
+                                  'wl-folder-trash-empty-image
+                                'wl-folder-trash-image)
+                              'image)))
+                      ;; draft folder
+                      ((string= fld-name wl-draft-folder)
+                       (get 'wl-folder-draft-image 'image))
+                      ;; queue folder
+                      ((string= fld-name wl-queue-folder)
+                       (get 'wl-folder-queue-image 'image))
+                      ;; and one of many other folders
+                      ((setq type (or (elmo-folder-type fld-name)
+                                      (elmo-folder-type-internal
+                                       (elmo-make-folder fld-name))))
+                       (get (intern (format "wl-folder-%s-image" type))
+                            'image)))))
              (overlay-put overlay 'before-string
                           (propertize " " 'display image
                                       'invisible t))))
              (overlay-put overlay 'display image))))))))
 
 (defun wl-plugged-set-folder-icon (folder string)
-  (if (wl-e21-display-image-p)
-      (let (type)
-       (cond ((string= folder wl-queue-folder)
-              (concat (get 'wl-folder-queue-image 'image)
-                      string))
-             ((setq type (elmo-folder-type folder))
-              (concat (get (intern (format "wl-folder-%s-image"
-                                           type))
-                           'image)
-                      string))
-             (t
-              string)))
-    string))
+  (let (image type)
+    (when (wl-e21-display-image-p)
+      (setq image
+           (cond ((string= folder wl-queue-folder)
+                  (get 'wl-folder-queue-image 'image))
+                 ((setq type (or (elmo-folder-type folder)
+                                 (elmo-folder-type-internal
+                                  (elmo-make-folder folder))))
+                  (get (intern (format "wl-folder-%s-image" type))
+                       'image)))))
+    (if image
+       (concat (propertize " " 'display image 'invisible t) string)
+      string)))
 
 (defvar wl-folder-internal-icon-list
   ;; alist of (image . icon-file)
     (wl-folder-archive-image      . wl-archive-folder-icon)
     (wl-folder-pipe-image        . wl-pipe-folder-icon)
     (wl-folder-maildir-image      . wl-maildir-folder-icon)
-    (wl-folder-nmz-image         . wl-nmz-folder-icon)
+    (wl-folder-search-image      . wl-search-folder-icon)
     (wl-folder-shimbun-image      . wl-shimbun-folder-icon)
     (wl-folder-file-image        . wl-file-folder-icon)
+    (wl-folder-access-image      . wl-access-folder-icon)
     (wl-folder-trash-empty-image  . wl-empty-trash-folder-icon)
     (wl-folder-draft-image       . wl-draft-folder-icon)
     (wl-folder-queue-image       . wl-queue-folder-icon)
 
 (defun wl-folder-init-icons ()
   (when (wl-e21-display-image-p)
-    (let ((load-path (cons wl-icon-directory load-path))
-         (icons wl-folder-internal-icon-list)
+    (let ((icons wl-folder-internal-icon-list)
          icon name image)
       (while (setq icon (pop icons))
        (unless (get (car icon) 'image)
          (setq name (symbol-value (cdr icon))
-               image (find-image `((:type xpm :file ,name :ascent center))))
+               image (wl-e21-find-image
+                      `((:type xpm :file ,name :ascent center))))
          (when image
            (put (car icon) 'image image)))))))
 
     (if (wl-e21-display-image-p)
        (progn
          (unless wl-plugged-image
-           (let ((load-path (cons wl-icon-directory load-path)))
-             (setq wl-plugged-image (find-image
+           (setq wl-plugged-image (wl-e21-find-image
+                                   `((:type xpm
+                                            :file ,wl-plugged-icon
+                                            :ascent center)))
+                 wl-unplugged-image (wl-e21-find-image
                                      `((:type xpm
-                                              :file ,wl-plugged-icon
-                                              :ascent center)))
-                   wl-unplugged-image (find-image
-                                       `((:type xpm
-                                                :file ,wl-unplugged-icon
-                                                :ascent center))))))
+                                              :file ,wl-unplugged-icon
+                                              :ascent center)))))
          (setq wl-modeline-plug-state-on
                (apply 'propertize wl-plug-state-indicator-on
                       `(display ,wl-plugged-image ,@props))
     (if (wl-e21-display-image-p)
        (progn
          (unless wl-biff-mail-image
-           (let ((load-path (cons wl-icon-directory load-path)))
-             (setq wl-biff-mail-image (find-image
+           (setq wl-biff-mail-image (wl-e21-find-image
+                                     `((:type xpm
+                                              :file ,wl-biff-mail-icon
+                                              :ascent center)))
+                 wl-biff-nomail-image (wl-e21-find-image
                                        `((:type xpm
-                                                :file ,wl-biff-mail-icon
-                                                :ascent center)))
-                   wl-biff-nomail-image (find-image
-                                         `((:type xpm
-                                                  :file ,wl-biff-nomail-icon
-                                                  :ascent center))))))
+                                                :file ,wl-biff-nomail-icon
+                                                :ascent center)))))
          (setq wl-modeline-biff-state-on
                (apply 'propertize wl-biff-state-indicator-on
                       `(display ,wl-biff-mail-image ,@props))
     (define-key keymap "l" 'wl-message-toggle-disp-summary)
     (define-key keymap "\C-c:d" 'wl-message-decrypt-pgp-nonmime)
     (define-key keymap "\C-c:v" 'wl-message-verify-pgp-nonmime)
+    (define-key keymap "w" 'wl-draft)
     (define-key keymap [mouse-4] 'wl-message-wheel-down)
     (define-key keymap [mouse-5] 'wl-message-wheel-up)
     (define-key keymap [S-mouse-4] 'wl-message-wheel-down)
 See info under Wanderlust for full documentation.
 
 Special commands:
-\\{wl-draft-mode-map}"))
+\\{wl-draft-mode-map}"
+    (setq font-lock-defaults nil)))
 
 (defun wl-draft-key-setup ()
   (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
@@ -648,7 +663,7 @@ Special commands:
   (define-key wl-draft-mode-map "\C-c\C-j" 'wl-template-select)
   (define-key wl-draft-mode-map "\C-c\C-p" 'wl-draft-preview-message)
   (define-key wl-draft-mode-map "\C-c\C-a" 'wl-addrmgr)
-;;  (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
+;;;  (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
   (define-key wl-draft-mode-map "\C-xk"    'wl-draft-mimic-kill-buffer)
   (define-key wl-draft-mode-map "\C-c\C-d" 'wl-draft-elide-region)
   (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line)
@@ -657,19 +672,17 @@ Special commands:
 
 (defun wl-draft-overload-functions ()
   (wl-mode-line-buffer-identification)
-;;  (local-set-key "\C-c\C-s" 'wl-draft-send);; override
+;;;  (local-set-key "\C-c\C-s" 'wl-draft-send) ; override
   (wl-e21-setup-draft-toolbar)
   (wl-draft-overload-menubar))
 
 (defalias 'wl-defface 'defface)
 
-(defun wl-read-event-char ()
+(defun wl-read-event-char (&optional prompt)
   "Get the next event."
-  (let ((event (read-event)))
+  (let ((event (read-event prompt)))
     (cons (and (numberp event) event) event)))
 
-(defalias 'wl-completing-read-multiple 'completing-read-multiple)
-
 (put 'wl-modeline-biff-state-on 'risky-local-variable t)
 (put 'wl-modeline-biff-state-off 'risky-local-variable t)
 (put 'wl-modeline-plug-state-on 'risky-local-variable t)