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
8 ;; Time-stamp: <2000-03-22 15:57:29 teranisi>
10 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
39 (require 'wl-highlight)
41 (defvar-maybe wl-draft-mode-map (make-sparse-keymap)))
43 (defun wl-draft-mode-setup ()
45 (define-derived-mode wl-draft-mode mail-mode "Draft"
46 "draft mode for Wanderlust derived from mail mode.
47 See info under Wanderlust for full documentation.
50 \\{wl-draft-mode-map}"))
52 ;; Common implementations.
53 (defun wl-highlight-folder-current-line (&optional numbers)
54 "Highlight current folder line."
57 (let ((highlights (list "opened" "closed"))
59 (fld-name (wl-folder-get-folder-name-by-id
60 (get-text-property (point) 'wl-folder-entity-id)))
61 fregexp fsymbol bol eol matched type extent num type)
64 (save-excursion (end-of-line) (setq eol (point)))
65 (if (and numbers (nth 0 numbers) (nth 1 numbers))
68 (let ((unsync (nth 0 numbers))
69 (unread (nth 1 numbers)))
70 (cond ((and unsync (eq unsync 0))
71 (if (and unread (> unread 0))
72 'wl-highlight-folder-unread-face
73 'wl-highlight-folder-zero-face))
75 (>= unsync wl-folder-many-unsync-threshold))
76 'wl-highlight-folder-many-face)
78 'wl-highlight-folder-few-face))))
79 (put-text-property bol eol 'face fsymbol)
83 (setq fregexp (symbol-value
84 (intern (format "wl-highlight-folder-%s-regexp"
86 (if (not wl-highlight-group-folder-by-numbers)
87 (setq fsymbol (intern (format "wl-highlight-folder-%s-face"
89 (when (looking-at fregexp)
90 (put-text-property bol eol 'face fsymbol)
92 (throw 'highlighted nil))
93 (setq highlights (cdr highlights))))
95 (if (looking-at (format "^[ ]*\\(%s\\|%s\\)"
96 wl-folder-unsubscribe-mark
97 wl-folder-removed-mark))
98 (put-text-property bol eol 'face
99 'wl-highlight-folder-killed-face)
100 (put-text-property bol eol 'face
101 'wl-highlight-folder-unknown-face)))
102 (if wl-use-highlight-mouse-line
103 (wl-highlight-folder-mouse-line)))))
105 (defun wl-highlight-plugged-current-line ())
106 (defun wl-plugged-set-folder-icon (folder string)
109 (defun wl-folder-init-icons ()) ; dummy.
110 (defun wl-plugged-init-icons ()) ; dummy.
112 (defun wl-xmas-setup-folder ()) ; dummy
113 (defun wl-xmas-setup-summary ())
114 (defun wl-xmas-setup-draft-toolbar ())
116 (defun wl-message-overload-functions ()
117 (local-set-key "l" 'wl-message-toggle-disp-summary)
118 (local-set-key [mouse-2] 'wl-message-refer-article-or-url)
119 (local-set-key [mouse-4] 'wl-message-wheel-down)
120 (local-set-key [mouse-5] 'wl-message-wheel-up)
121 (local-set-key [S-mouse-4] 'wl-message-wheel-down)
122 (local-set-key [S-mouse-5] 'wl-message-wheel-up))
124 (defun wl-message-wheel-up (event)
126 (if (string-match wl-message-buf-name (buffer-name))
127 (wl-message-next-page)
128 (let ((cur-buf (current-buffer))
130 (save-selected-window
131 (select-window (posn-window (event-start event)))
133 (setq proceed (wl-message-next-page)))
135 (if (memq 'shift (event-modifiers event))
137 (wl-summary-next t))))))
139 (defun wl-message-wheel-down (event)
141 (if (string-match wl-message-buf-name (buffer-name))
142 (wl-message-prev-page)
143 (let ((cur-buf (current-buffer))
145 (save-selected-window
146 (select-window (posn-window (event-start event)))
148 (setq proceed (wl-message-prev-page)))
150 (if (memq 'shift (event-modifiers event))
152 (wl-summary-prev t))))))
154 (defun wl-draft-key-setup ()
155 (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
156 (define-key wl-draft-mode-map "\C-c\C-a" 'wl-draft-insert-x-face-field)
157 (define-key wl-draft-mode-map "\C-c\C-s" 'wl-draft-send)
158 (define-key wl-draft-mode-map "\C-c\C-c" 'wl-draft-send-and-exit)
159 (define-key wl-draft-mode-map "\C-c\C-z" 'wl-draft-save-and-exit)
160 (define-key wl-draft-mode-map "\C-c\C-k" 'wl-draft-kill)
161 (define-key wl-draft-mode-map "\C-l" 'wl-draft-highlight-and-recenter)
162 (define-key wl-draft-mode-map "\C-i" 'wl-complete-field-body-or-tab)
163 (define-key wl-draft-mode-map "\C-c\C-r" 'wl-draft-caesar-region)
164 (define-key wl-draft-mode-map "\M-t" 'wl-toggle-plugged)
165 (define-key wl-draft-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
166 (define-key wl-draft-mode-map "\C-c\C-e" 'wl-draft-config-exec)
167 (define-key wl-draft-mode-map "\C-c\C-j" 'wl-template-select)
168 (define-key wl-draft-mode-map "\C-c\C-p" 'wl-draft-preview-message)
169 (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
170 (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer))
172 (defun wl-draft-overload-menubar ()
173 (local-set-key [menu-bar mail send]
174 '("Send Message" . wl-draft-send-and-exit))
175 (local-set-key [menu-bar mail send-stay]
176 '("Send, Keep Editing" . wl-draft-send))
177 (local-set-key [menu-bar mail cancel]
178 '("Kill Current Draft" . wl-draft-kill))
179 (local-set-key [menu-bar mail yank]
180 '("Cite Message" . wl-draft-yank-original))
181 (local-set-key [menu-bar mail signature]
182 '("Insert Signature" . insert-signature))
183 (local-set-key [menu-bar headers fcc]
184 '("FCC" . wl-draft-fcc)))
186 (defun wl-draft-overload-functions ()
187 (setq mode-line-buffer-identification
188 (format "Wanderlust: %s" (buffer-name)))
189 (local-set-key "\C-c\C-s" 'wl-draft-send) ; override
190 (wl-draft-overload-menubar)
191 (when wl-show-plug-status-on-modeline
192 (setq mode-line-format (wl-make-modeline))))
194 (defalias 'wl-make-modeline 'wl-make-modeline-subr)
196 ;; for "ja-mule-canna-2.3.mini" on PocketBSD
197 (defun-maybe make-face (a))
202 ((and (fboundp 'defface)
203 (not (featurep 'tinycustom)))
204 (defalias 'wl-defface 'defface)
206 (defun wl-face-spec-set-match-display (display frame))
207 (defun wl-frame-parameter (frame property &optional default))
208 (defun wl-get-frame-properties (&optional frame))))
210 (defmacro wl-defface (face spec doc &rest args)
211 (nconc (list 'wl-declare-face (list 'quote face) spec)))
213 (defun wl-declare-face (face spec)
216 (let* ((entry (car spec))
217 (display (nth 0 entry))
218 (atts (nth 1 entry)))
219 (setq spec (cdr spec))
220 (when (wl-face-spec-set-match-display display nil)
221 (apply 'wl-face-attributes-set face nil atts)))))
223 (defconst wl-face-attributes
224 '((:bold set-face-bold-p)
225 (:italic set-face-italic-p)
226 (:underline set-face-underline-p)
227 (:foreground set-face-foreground)
228 (:background set-face-background)
229 (:stipple set-face-stipple)))
231 (defun wl-face-attributes-set (face frame &rest atts)
232 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
233 Each keyword should be listed in `custom-face-attributes'.
235 If FRAME is nil, set the default face."
237 (let* ((name (nth 0 atts))
239 (fun (nth 1 (assq name wl-face-attributes))))
240 (setq atts (cdr (cdr atts)))
242 (funcall fun face value frame)
245 (defun wl-frame-parameter (frame property &optional default)
246 "Return FRAME's value for property PROPERTY."
247 (or (cdr (assq property (frame-parameters frame)))
251 (defun-maybe x-display-grayscale-p ()))
253 (defun wl-get-frame-properties (&optional frame)
254 "Return a plist with the frame properties of FRAME used by custom."
255 (list (cons 'type window-system)
256 (cons 'class (or (wl-frame-parameter frame 'display-type)
258 (cond ((x-display-color-p)
260 ((and (fboundp 'x-display-grayscale-p)
261 (x-display-grayscale-p))
264 (cons 'background (or (wl-frame-parameter frame 'background-mode)
265 wl-highlight-background-mode))))
267 (defun wl-face-spec-set-match-display (display frame)
268 "Non-nil iff DISPLAY matches FRAME.
269 If FRAME is nil, the current FRAME is used."
270 ;; This is a kludge to get started, we really should use specifiers!
273 (let* ((props (wl-get-frame-properties frame))
274 (type (cdr (assq 'type props)))
275 (class (cdr (assq 'class props)))
276 (background (cdr (assq 'background props)))
280 (while (and entries match)
281 (setq entry (car entries)
282 entries (cdr entries)
285 match (cond ((eq req 'type)
288 (memq class options))
289 ((eq req 'background)
290 (memq background options))
293 Warning: Unknown req `%S' with options `%S'" req options))
299 ;;; wl-mule.el ends here