1 ;;; wl-mule.el --- Wanderlust modules for Mule compatible Emacsen.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
8 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; For Mule2.3@19.34, Emacs 20.x
37 (require 'wl-highlight)
39 (defvar-maybe wl-draft-mode-map (make-sparse-keymap)))
41 (defun wl-draft-mode-setup ()
43 (define-derived-mode wl-draft-mode mail-mode "Draft"
44 "draft mode for Wanderlust derived from mail mode.
45 See info under Wanderlust for full documentation.
48 \\{wl-draft-mode-map}"))
50 ;; Common implementations.
51 (defun wl-highlight-folder-current-line (&optional numbers)
52 "Highlight current folder line."
57 (start (progn (beginning-of-line) (point)))
60 (cond ((and (wl-folder-buffer-group-p)
61 (looking-at wl-highlight-folder-opened-regexp))
62 'wl-highlight-folder-opened-face)
63 ((and (wl-folder-buffer-group-p)
64 (looking-at wl-highlight-folder-closed-regexp))
65 'wl-highlight-folder-closed-face)
67 (if (looking-at (format "^[ \t]*\\(%s\\|%s\\)"
68 wl-folder-unsubscribe-mark
69 wl-folder-removed-mark))
70 'wl-highlight-folder-killed-face
71 'wl-highlight-folder-unknown-face)))))
72 (if (and wl-highlight-folder-by-numbers
73 numbers (nth 0 numbers) (nth 1 numbers)
74 (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" end t))
75 (let* ((unsync (nth 0 numbers))
76 (unread (nth 1 numbers))
78 ((and unsync (zerop unsync))
79 (if (and unread (zerop unread))
80 'wl-highlight-folder-zero-face
81 'wl-highlight-folder-unread-face))
83 (>= unsync wl-folder-many-unsync-threshold))
84 'wl-highlight-folder-many-face)
86 'wl-highlight-folder-few-face))))
87 (if (numberp wl-highlight-folder-by-numbers)
89 (put-text-property start (match-beginning 0) 'face text-face)
90 (put-text-property (match-beginning 0) (point) 'face face))
91 ;; Remove previous face.
92 (put-text-property start (point) 'face nil)
93 (put-text-property start (point) 'face face))
95 (put-text-property start end 'face text-face)))
96 (when wl-use-highlight-mouse-line
97 (wl-highlight-folder-mouse-line))))
99 (defun wl-highlight-plugged-current-line ())
100 (defun wl-plugged-set-folder-icon (folder string)
103 (defun wl-message-define-keymap ()
104 (let ((keymap (make-sparse-keymap)))
105 (define-key keymap "D" 'wl-message-delete-current-part)
106 (define-key keymap "l" 'wl-message-toggle-disp-summary)
107 (define-key keymap "\C-c:d" 'wl-message-decrypt-pgp-nonmime)
108 (define-key keymap "\C-c:v" 'wl-message-verify-pgp-nonmime)
109 (define-key keymap "w" 'wl-draft)
110 (define-key keymap [mouse-4] 'wl-message-wheel-down)
111 (define-key keymap [mouse-5] 'wl-message-wheel-up)
112 (define-key keymap [S-mouse-4] 'wl-message-wheel-down)
113 (define-key keymap [S-mouse-5] 'wl-message-wheel-up)
114 (set-keymap-parent wl-message-button-map keymap)
115 (define-key wl-message-button-map [mouse-2]
116 'wl-message-button-dispatcher)
119 (defun wl-message-wheel-up (event)
121 (if (string-match (regexp-quote wl-message-buffer-name)
122 (regexp-quote (buffer-name)))
123 (wl-message-next-page)
124 (let ((cur-buf (current-buffer))
126 (save-selected-window
127 (select-window (posn-window (event-start event)))
129 (setq proceed (wl-message-next-page)))
131 (if (memq 'shift (event-modifiers event))
133 (wl-summary-next t))))))
135 (defun wl-message-wheel-down (event)
137 (if (string-match (regexp-quote wl-message-buffer-name)
138 (regexp-quote (buffer-name)))
139 (wl-message-prev-page)
140 (let ((cur-buf (current-buffer))
142 (save-selected-window
143 (select-window (posn-window (event-start event)))
145 (setq proceed (wl-message-prev-page)))
147 (if (memq 'shift (event-modifiers event))
149 (wl-summary-prev t))))))
151 (defun wl-draft-key-setup ()
152 (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
153 (define-key wl-draft-mode-map "\C-c\C-s" 'wl-draft-send)
154 (define-key wl-draft-mode-map "\C-c\C-c" 'wl-draft-send-and-exit)
155 (define-key wl-draft-mode-map "\C-c\C-z" 'wl-draft-save-and-exit)
156 (define-key wl-draft-mode-map "\C-c\C-k" 'wl-draft-kill)
157 (define-key wl-draft-mode-map "\C-l" 'wl-draft-highlight-and-recenter)
158 (define-key wl-draft-mode-map "\C-i" 'wl-complete-field-body-or-tab)
159 (define-key wl-draft-mode-map "\C-c\C-r" 'wl-draft-caesar-region)
160 (define-key wl-draft-mode-map "\M-t" 'wl-toggle-plugged)
161 (define-key wl-draft-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
162 (define-key wl-draft-mode-map "\C-c\C-e" 'wl-draft-config-exec)
163 (define-key wl-draft-mode-map "\C-c\C-j" 'wl-template-select)
164 (define-key wl-draft-mode-map "\C-c\C-p" 'wl-draft-preview-message)
165 ;; (define-key wl-draft-mode-map "\C-x\C-s" 'wl-draft-save)
166 (define-key wl-draft-mode-map "\C-c\C-a" 'wl-addrmgr)
167 (define-key wl-draft-mode-map "\C-xk" 'wl-draft-mimic-kill-buffer)
168 (define-key wl-draft-mode-map "\C-c\C-d" 'wl-draft-elide-region)
169 (define-key wl-draft-mode-map "\C-a" 'wl-draft-beginning-of-line)
170 (define-key wl-draft-mode-map "\M-p" 'wl-draft-previous-history-element)
171 (define-key wl-draft-mode-map "\M-n" 'wl-draft-next-history-element))
173 (defun wl-draft-overload-menubar ()
174 (let ((keymap (current-local-map)))
175 (define-key keymap [menu-bar mail send]
176 '("Send Message" . wl-draft-send-and-exit))
177 (define-key keymap [menu-bar mail send-stay]
178 '("Send, Keep Editing" . wl-draft-send))
179 (define-key-after (lookup-key keymap [menu-bar mail])
180 [mail-sep-send] '("--")
182 (define-key keymap [menu-bar mail cancel]
183 '("Kill Current Draft" . wl-draft-kill))
184 (define-key-after (lookup-key keymap [menu-bar mail])
185 [save] '("Save Draft and Exit" . wl-draft-save-and-exit)
187 (define-key-after (lookup-key keymap [menu-bar mail])
188 [mail-sep-exit] '("--")
190 (define-key-after (lookup-key keymap [menu-bar mail])
191 [preview] '("Preview Message" . wl-draft-preview-message)
193 (define-key keymap [menu-bar mail yank]
194 '("Cite Message" . wl-draft-yank-original))
195 (define-key keymap [menu-bar mail signature]
196 '("Insert Signature" . insert-signature))
197 (define-key keymap [menu-bar headers fcc]
198 '("Fcc" . wl-draft-fcc))))
200 (defun wl-draft-overload-functions ()
201 (wl-mode-line-buffer-identification)
202 ;; (local-set-key "\C-c\C-s" 'wl-draft-send);; override
203 (wl-draft-overload-menubar))
205 ;; for "ja-mule-canna-2.3.mini" on PocketBSD
206 (defun-maybe make-face (a))
211 ((and (fboundp 'defface)
212 (not (featurep 'tinycustom)))
213 (defalias 'wl-defface 'defface)
215 (defun wl-face-spec-set-match-display (display frame))
216 (defun wl-frame-parameter (frame property &optional default))
217 (defun wl-get-frame-properties (&optional frame))))
219 (defmacro wl-defface (face spec doc &rest args)
220 (nconc (list 'wl-declare-face (list 'quote face) spec)))
222 (defun wl-declare-face (face spec)
225 (let* ((entry (car spec))
226 (display (nth 0 entry))
227 (atts (nth 1 entry)))
228 (setq spec (cdr spec))
229 (when (wl-face-spec-set-match-display display nil)
230 (apply 'wl-face-attributes-set face nil atts)))))
232 (defconst wl-face-attributes
233 '((:bold set-face-bold-p)
234 (:italic set-face-italic-p)
235 (:underline set-face-underline-p)
236 (:foreground set-face-foreground)
237 (:background set-face-background)
238 (:stipple set-face-stipple)))
240 (defun wl-face-attributes-set (face frame &rest atts)
241 "For FACE on FRAME set the attributes [KEYWORD VALUE]....
242 Each keyword should be listed in `custom-face-attributes'.
244 If FRAME is nil, set the default face."
246 (let* ((name (nth 0 atts))
248 (fun (nth 1 (assq name wl-face-attributes))))
249 (setq atts (cdr (cdr atts)))
251 (funcall fun face value frame)
254 (defun wl-frame-parameter (frame property &optional default)
255 "Return FRAME's value for property PROPERTY."
256 (or (cdr (assq property (frame-parameters frame)))
260 (defun-maybe x-display-grayscale-p ()))
262 (defun wl-get-frame-properties (&optional frame)
263 "Return a plist with the frame properties of FRAME used by custom."
264 (list (cons 'type window-system)
265 (cons 'class (or (wl-frame-parameter frame 'display-type)
267 (cond ((x-display-color-p)
269 ((and (fboundp 'x-display-grayscale-p)
270 (x-display-grayscale-p))
273 (cons 'background (or (wl-frame-parameter frame 'background-mode)
274 wl-highlight-background-mode))))
276 (defun wl-face-spec-set-match-display (display frame)
277 "Non-nil iff DISPLAY matches FRAME.
278 If FRAME is nil, the current FRAME is used."
279 ;; This is a kludge to get started, we really should use specifiers!
282 (let* ((props (wl-get-frame-properties frame))
283 (type (cdr (assq 'type props)))
284 (class (cdr (assq 'class props)))
285 (background (cdr (assq 'background props)))
289 (while (and entries match)
290 (setq entry (car entries)
291 entries (cdr entries)
294 match (cond ((eq req 'type)
297 (memq class options))
298 ((eq req 'background)
299 (memq background options))
302 Warning: Unknown req `%S' with options `%S'" req options)
306 (defun wl-read-event-char ()
307 "Get the next event."
308 (let ((event (read-event)))
309 (cons (and (numberp event) event) event)))
311 (defun wl-completing-read-multiple (prompt
314 require-match initial-input)
315 "Read multiple strings in the minibuffer"
316 (split-string (completing-read prompt table predicate require-match
320 (product-provide (provide 'wl-mule) (require 'wl-version))
322 ;;; wl-mule.el ends here