1 ;;; wl-mule.el -- Wanderlust modules for Mule compatible Emacsen.
2 ;; (Mule2.3@19.28, Mule2.3@19.34, Emacs 20.x)
4 ;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; Keywords: mail, net news
9 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
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)
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.
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.
38 (require 'wl-highlight)
40 (defvar-maybe wl-draft-mode-map (make-sparse-keymap)))
42 (defun wl-draft-mode-setup ()
44 (define-derived-mode wl-draft-mode mail-mode "Draft"
45 "draft mode for Wanderlust derived from mail mode.
46 See info under Wanderlust for full documentation.
49 \\{wl-draft-mode-map}"))
51 ;; Common implementations.
52 (defun wl-highlight-folder-current-line (&optional numbers)
53 "Highlight current folder line."
56 (let ((highlights (list "opened" "closed"))
58 (fld-name (wl-folder-get-folder-name-by-id
59 (get-text-property (point) 'wl-folder-entity-id)))
60 fregexp fsymbol bol eol matched type extent num type)
63 (save-excursion (end-of-line) (setq eol (point)))
64 (if (and numbers (nth 0 numbers) (nth 1 numbers))
67 (let ((unsync (nth 0 numbers))
68 (unread (nth 1 numbers)))
69 (cond ((and unsync (eq unsync 0))
70 (if (and unread (> unread 0))
71 'wl-highlight-folder-unread-face
72 'wl-highlight-folder-zero-face))
74 (>= unsync wl-folder-many-unsync-threshold))
75 'wl-highlight-folder-many-face)
77 'wl-highlight-folder-few-face))))
78 (put-text-property bol eol 'face fsymbol)
82 (setq fregexp (symbol-value
83 (intern (format "wl-highlight-folder-%s-regexp"
85 (if (not wl-highlight-group-folder-by-numbers)
86 (setq fsymbol (intern (format "wl-highlight-folder-%s-face"
88 (when (looking-at fregexp)
89 (put-text-property bol eol 'face fsymbol)
91 (throw 'highlighted nil))
92 (setq highlights (cdr highlights))))
94 (if (looking-at (format "^[ ]*\\(%s\\|%s\\)"
95 wl-folder-unsubscribe-mark
96 wl-folder-removed-mark))
97 (put-text-property bol eol 'face
98 'wl-highlight-folder-killed-face)
99 (put-text-property bol eol 'face
100 'wl-highlight-folder-unknown-face)))
101 (if wl-use-highlight-mouse-line
102 (wl-highlight-folder-mouse-line)))))
104 (defun wl-highlight-plugged-current-line ())
105 (defun wl-plugged-set-folder-icon (folder string)
108 (defun wl-folder-init-icons ()) ; dummy.
109 (defun wl-plugged-init-icons ()) ; dummy.
111 (defun wl-xmas-setup-folder ()) ; dummy
112 (defun wl-xmas-setup-summary ())
113 (defun wl-xmas-setup-draft-toolbar ())
115 (defun wl-message-overload-functions ()
116 (local-set-key "l" 'wl-message-toggle-disp-summary)
117 (local-set-key [mouse-2] 'wl-message-refer-article-or-url)
118 (local-set-key [mouse-4] 'wl-message-wheel-down)
119 (local-set-key [mouse-5] 'wl-message-wheel-up)
120 (local-set-key [S-mouse-4] 'wl-message-wheel-down)
121 (local-set-key [S-mouse-5] 'wl-message-wheel-up))
123 (defun wl-message-wheel-up (event)
125 (if (string-match wl-message-buf-name (buffer-name))
126 (wl-message-next-page)
127 (let ((cur-buf (current-buffer))
129 (save-selected-window
130 (select-window (posn-window (event-start event)))
132 (setq proceed (wl-message-next-page)))
134 (if (memq 'shift (event-modifiers event))
136 (wl-summary-next t))))))
138 (defun wl-message-wheel-down (event)
140 (if (string-match wl-message-buf-name (buffer-name))
141 (wl-message-prev-page)
142 (let ((cur-buf (current-buffer))
144 (save-selected-window
145 (select-window (posn-window (event-start event)))
147 (setq proceed (wl-message-prev-page)))
149 (if (memq 'shift (event-modifiers event))
151 (wl-summary-prev t))))))
153 (defun wl-draft-key-setup ()
154 (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
155 (define-key wl-draft-mode-map "\C-c\C-a" 'wl-draft-insert-x-face-field)
156 (define-key wl-draft-mode-map "\C-c\C-s" 'wl-draft-send)
157 (define-key wl-draft-mode-map "\C-c\C-c" 'wl-draft-send-and-exit)
158 (define-key wl-draft-mode-map "\C-c\C-z" 'wl-draft-save-and-exit)
159 (define-key wl-draft-mode-map "\C-c\C-k" 'wl-draft-kill)
160 (define-key wl-draft-mode-map "\C-l" 'wl-draft-highlight-and-recenter)
161 (define-key wl-draft-mode-map "\C-i" 'wl-complete-field-body-or-tab)
162 (define-key wl-draft-mode-map "\C-c\C-r" 'wl-draft-caesar-region)
163 (define-key wl-draft-mode-map "\M-t" 'wl-toggle-plugged)
164 (define-key wl-draft-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
165 (define-key wl-draft-mode-map "\C-c\C-e" 'wl-draft-config-exec)
166 (define-key wl-draft-mode-map "\C-c\C-j" 'wl-template-select)
167 (define-key wl-draft-mode-map "\C-c\C-p" 'wl-draft-preview-message)
168 (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
169 (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer))
171 (defun wl-draft-overload-menubar ()
172 (local-set-key [menu-bar mail send]
173 '("Send Message" . wl-draft-send-and-exit))
174 (local-set-key [menu-bar mail send-stay]
175 '("Send, Keep Editing" . wl-draft-send))
176 (local-set-key [menu-bar mail cancel]
177 '("Kill Current Draft" . wl-draft-kill))
178 (local-set-key [menu-bar mail yank]
179 '("Cite Message" . wl-draft-yank-original))
180 (local-set-key [menu-bar mail signature]
181 '("Insert Signature" . insert-signature))
182 (local-set-key [menu-bar headers fcc]
183 '("FCC" . wl-draft-fcc)))
185 (defun wl-draft-overload-functions ()
186 (setq mode-line-buffer-identification
187 (format "Wanderlust: %s" (buffer-name)))
188 (local-set-key "\C-c\C-s" 'wl-draft-send) ; override
189 (wl-draft-overload-menubar)
190 (when wl-show-plug-status-on-modeline
191 (setq mode-line-format (wl-make-modeline))))
193 (defalias 'wl-make-modeline 'wl-make-modeline-subr)
195 ;; for "ja-mule-canna-2.3.mini" on PocketBSD
196 (defun-maybe make-face (a))
201 ((and (fboundp 'defface)
202 (not (featurep 'tinycustom)))
203 (defalias 'wl-defface 'defface)
205 (defun wl-face-spec-set-match-display (display frame))
206 (defun wl-frame-parameter (frame property &optional default))
207 (defun wl-get-frame-properties (&optional frame))))
209 (defmacro wl-defface (face spec doc &rest args)
210 (nconc (list 'wl-declare-face (list 'quote face) spec)))
212 (defun wl-declare-face (face spec)
215 (let* ((entry (car spec))
216 (display (nth 0 entry))
217 (atts (nth 1 entry)))
218 (setq spec (cdr spec))
219 (when (wl-face-spec-set-match-display display nil)
220 (apply 'wl-face-attributes-set face nil atts)))))
222 (defconst wl-face-attributes
223 '((:bold set-face-bold-p)
224 (:italic set-face-italic-p)
225 (:underline set-face-underline-p)
226 (:foreground set-face-foreground)
227 (:background set-face-background)
228 (:stipple set-face-stipple)))
230 (defun wl-face-attributes-set (face frame &rest atts)
231 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
232 Each keyword should be listed in `custom-face-attributes'.
234 If FRAME is nil, set the default face."
236 (let* ((name (nth 0 atts))
238 (fun (nth 1 (assq name wl-face-attributes))))
239 (setq atts (cdr (cdr atts)))
241 (funcall fun face value frame)
244 (defun wl-frame-parameter (frame property &optional default)
245 "Return FRAME's value for property PROPERTY."
246 (or (cdr (assq property (frame-parameters frame)))
250 (defun-maybe x-display-grayscale-p ()))
252 (defun wl-get-frame-properties (&optional frame)
253 "Return a plist with the frame properties of FRAME used by custom."
254 (list (cons 'type window-system)
255 (cons 'class (or (wl-frame-parameter frame 'display-type)
257 (cond ((x-display-color-p)
259 ((and (fboundp 'x-display-grayscale-p)
260 (x-display-grayscale-p))
263 (cons 'background (or (wl-frame-parameter frame 'background-mode)
264 wl-highlight-background-mode))))
266 (defun wl-face-spec-set-match-display (display frame)
267 "Non-nil iff DISPLAY matches FRAME.
268 If FRAME is nil, the current FRAME is used."
269 ;; This is a kludge to get started, we really should use specifiers!
272 (let* ((props (wl-get-frame-properties frame))
273 (type (cdr (assq 'type props)))
274 (class (cdr (assq 'class props)))
275 (background (cdr (assq 'background props)))
279 (while (and entries match)
280 (setq entry (car entries)
281 entries (cdr entries)
284 match (cond ((eq req 'type)
287 (memq class options))
288 ((eq req 'background)
289 (memq background options))
292 Warning: Unknown req `%S' with options `%S'" req options))
298 ;;; wl-mule.el ends here