1 ;;; wl-mule.el -- Wanderlust modules for Mule compatible Emacsen.
2 ;; (Mule2.3@19.28, Mule2.3@19.34, Emacs 20.x)
4 ;; Copyright (C) 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."
58 (start (progn (beginning-of-line) (point)))
61 (cond ((looking-at wl-highlight-folder-opened-regexp)
62 'wl-highlight-folder-opened-face)
63 ((looking-at wl-highlight-folder-closed-regexp)
64 'wl-highlight-folder-closed-face)
66 (if (looking-at (format "^[ \t]*\\(%s\\|%s\\)"
67 wl-folder-unsubscribe-mark
68 wl-folder-removed-mark))
69 'wl-highlight-folder-killed-face
70 'wl-highlight-folder-unknown-face)))))
71 (if (and wl-highlight-folder-by-numbers
72 numbers (nth 0 numbers) (nth 1 numbers)
73 (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" end t))
74 (let* ((unsync (nth 0 numbers))
75 (unread (nth 1 numbers))
77 ((and unsync (zerop unsync))
78 (if (and unread (zerop unread))
79 'wl-highlight-folder-zero-face
80 'wl-highlight-folder-unread-face))
82 (>= unsync wl-folder-many-unsync-threshold))
83 'wl-highlight-folder-many-face)
85 'wl-highlight-folder-few-face))))
86 (if (numberp wl-highlight-folder-by-numbers)
88 (put-text-property start (match-beginning 0) 'face text-face)
89 (put-text-property (match-beginning 0) (point) 'face face))
90 ;; Remove previous face.
91 (put-text-property start (point) 'face nil)
92 (put-text-property start (point) 'face face))
94 (put-text-property start end 'face text-face)))
95 (when wl-use-highlight-mouse-line
96 (wl-highlight-folder-mouse-line))))
98 (defun wl-highlight-plugged-current-line ())
99 (defun wl-plugged-set-folder-icon (folder string)
102 (defun wl-message-define-keymap ()
103 (let ((keymap (make-sparse-keymap)))
104 (define-key keymap "l" 'wl-message-toggle-disp-summary)
105 (define-key keymap [mouse-4] 'wl-message-wheel-down)
106 (define-key keymap [mouse-5] 'wl-message-wheel-up)
107 (define-key keymap [S-mouse-4] 'wl-message-wheel-down)
108 (define-key keymap [S-mouse-5] 'wl-message-wheel-up)
109 (set-keymap-parent wl-message-button-map keymap)
110 (define-key wl-message-button-map [mouse-2]
111 'wl-message-button-dispatcher)
114 (defun wl-message-wheel-up (event)
116 (if (string-match (regexp-quote wl-message-buffer-cache-name)
117 (regexp-quote (buffer-name)))
118 (wl-message-next-page)
119 (let ((cur-buf (current-buffer))
121 (save-selected-window
122 (select-window (posn-window (event-start event)))
124 (setq proceed (wl-message-next-page)))
126 (if (memq 'shift (event-modifiers event))
128 (wl-summary-next t))))))
130 (defun wl-message-wheel-down (event)
132 (if (string-match (regexp-quote wl-message-buffer-cache-name)
133 (regexp-quote (buffer-name)))
134 (wl-message-prev-page)
135 (let ((cur-buf (current-buffer))
137 (save-selected-window
138 (select-window (posn-window (event-start event)))
140 (setq proceed (wl-message-prev-page)))
142 (if (memq 'shift (event-modifiers event))
144 (wl-summary-prev t))))))
146 (defun wl-draft-key-setup ()
147 (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
148 (define-key wl-draft-mode-map "\C-c\C-s" 'wl-draft-send)
149 (define-key wl-draft-mode-map "\C-c\C-c" 'wl-draft-send-and-exit)
150 (define-key wl-draft-mode-map "\C-c\C-z" 'wl-draft-save-and-exit)
151 (define-key wl-draft-mode-map "\C-c\C-k" 'wl-draft-kill)
152 (define-key wl-draft-mode-map "\C-l" 'wl-draft-highlight-and-recenter)
153 (define-key wl-draft-mode-map "\C-i" 'wl-complete-field-body-or-tab)
154 (define-key wl-draft-mode-map "\C-c\C-r" 'wl-draft-caesar-region)
155 (define-key wl-draft-mode-map "\M-t" 'wl-toggle-plugged)
156 (define-key wl-draft-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
157 (define-key wl-draft-mode-map "\C-c\C-e" 'wl-draft-config-exec)
158 (define-key wl-draft-mode-map "\C-c\C-j" 'wl-template-select)
159 (define-key wl-draft-mode-map "\C-c\C-p" 'wl-draft-preview-message)
160 (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
161 (define-key wl-draft-mode-map "\C-c\C-a" 'wl-addrmgr)
162 (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer))
164 (defun wl-draft-overload-menubar ()
165 (local-set-key [menu-bar mail send]
166 '("Send Message" . wl-draft-send-and-exit))
167 (local-set-key [menu-bar mail send-stay]
168 '("Send, Keep Editing" . wl-draft-send))
169 (local-set-key [menu-bar mail cancel]
170 '("Kill Current Draft" . wl-draft-kill))
171 (local-set-key [menu-bar mail yank]
172 '("Cite Message" . wl-draft-yank-original))
173 (local-set-key [menu-bar mail signature]
174 '("Insert Signature" . insert-signature))
175 (local-set-key [menu-bar headers fcc]
176 '("Fcc" . wl-draft-fcc)))
178 (defun wl-draft-overload-functions ()
179 (wl-mode-line-buffer-identification)
180 ;; (local-set-key "\C-c\C-s" 'wl-draft-send);; override
181 (wl-draft-overload-menubar))
183 ;; for "ja-mule-canna-2.3.mini" on PocketBSD
184 (defun-maybe make-face (a))
189 ((and (fboundp 'defface)
190 (not (featurep 'tinycustom)))
191 (defalias 'wl-defface 'defface)
193 (defun wl-face-spec-set-match-display (display frame))
194 (defun wl-frame-parameter (frame property &optional default))
195 (defun wl-get-frame-properties (&optional frame))))
197 (defmacro wl-defface (face spec doc &rest args)
198 (nconc (list 'wl-declare-face (list 'quote face) spec)))
200 (defun wl-declare-face (face spec)
203 (let* ((entry (car spec))
204 (display (nth 0 entry))
205 (atts (nth 1 entry)))
206 (setq spec (cdr spec))
207 (when (wl-face-spec-set-match-display display nil)
208 (apply 'wl-face-attributes-set face nil atts)))))
210 (defconst wl-face-attributes
211 '((:bold set-face-bold-p)
212 (:italic set-face-italic-p)
213 (:underline set-face-underline-p)
214 (:foreground set-face-foreground)
215 (:background set-face-background)
216 (:stipple set-face-stipple)))
218 (defun wl-face-attributes-set (face frame &rest atts)
219 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
220 Each keyword should be listed in `custom-face-attributes'.
222 If FRAME is nil, set the default face."
224 (let* ((name (nth 0 atts))
226 (fun (nth 1 (assq name wl-face-attributes))))
227 (setq atts (cdr (cdr atts)))
229 (funcall fun face value frame)
232 (defun wl-frame-parameter (frame property &optional default)
233 "Return FRAME's value for property PROPERTY."
234 (or (cdr (assq property (frame-parameters frame)))
238 (defun-maybe x-display-grayscale-p ()))
240 (defun wl-get-frame-properties (&optional frame)
241 "Return a plist with the frame properties of FRAME used by custom."
242 (list (cons 'type window-system)
243 (cons 'class (or (wl-frame-parameter frame 'display-type)
245 (cond ((x-display-color-p)
247 ((and (fboundp 'x-display-grayscale-p)
248 (x-display-grayscale-p))
251 (cons 'background (or (wl-frame-parameter frame 'background-mode)
252 wl-highlight-background-mode))))
254 (defun wl-face-spec-set-match-display (display frame)
255 "Non-nil iff DISPLAY matches FRAME.
256 If FRAME is nil, the current FRAME is used."
257 ;; This is a kludge to get started, we really should use specifiers!
260 (let* ((props (wl-get-frame-properties frame))
261 (type (cdr (assq 'type props)))
262 (class (cdr (assq 'class props)))
263 (background (cdr (assq 'background props)))
267 (while (and entries match)
268 (setq entry (car entries)
269 entries (cdr entries)
272 match (cond ((eq req 'type)
275 (memq class options))
276 ((eq req 'background)
277 (memq background options))
280 Warning: Unknown req `%S' with options `%S'" req options))
284 (defun wl-read-event-char ()
285 "Get the next event."
286 (let ((event (read-event)))
287 (cons (and (numberp event) event) event)))
290 (product-provide (provide 'wl-mule) (require 'wl-version))
292 ;;; wl-mule.el ends here