File: wl-mule.el

package info (click to toggle)
wl-beta 2.15.9+0.20190205-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 6,260 kB
  • sloc: lisp: 51,446; sh: 191; makefile: 141
file content (317 lines) | stat: -rw-r--r-- 11,407 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
;;; wl-mule.el --- Wanderlust modules for Mule compatible Emacsen.

;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>

;; Author: Yuuichi Teranishi <teranisi@gohome.org>
;; Keywords: mail, net news

;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;

;;; Commentary:
;; For Mule2.3@19.34, Emacs 20.x

;;; Code:
;;

(eval-when-compile
  (require 'wl-folder)
  (require 'wl-summary)
  (require 'wl-draft)
  (require 'wl-message)
  (require 'wl-highlight)
  (require 'wl-vars)
  (defvar-maybe wl-draft-mode-map (make-sparse-keymap)))

(defun wl-draft-mode-setup ()
  (require 'derived)
  (define-derived-mode wl-draft-mode mail-mode "Draft"
    "draft mode for Wanderlust derived from mail mode.
See info under Wanderlust for full documentation.

Special commands:
\\{wl-draft-mode-map}"))

;; Common implementations.
(defun wl-highlight-folder-current-line (&optional numbers)
  "Highlight current folder line."
  (interactive)
  (save-excursion
    (end-of-line)
    (let ((end (point))
	  (start (progn (beginning-of-line) (point)))
	  (inhibit-read-only t)
	  (text-face
	   (cond ((and (wl-folder-buffer-group-p)
		       (looking-at wl-highlight-folder-opened-regexp))
		  'wl-highlight-folder-opened-face)
		 ((and (wl-folder-buffer-group-p)
		       (looking-at wl-highlight-folder-closed-regexp))
		  'wl-highlight-folder-closed-face)
		 (t
		  (if (looking-at (format "^[ \t]*\\(%s\\|%s\\)"
					  wl-folder-unsubscribe-mark
					  wl-folder-removed-mark))
		      'wl-highlight-folder-killed-face
		    'wl-highlight-folder-unknown-face)))))
      (if (and wl-highlight-folder-by-numbers
	       numbers (nth 0 numbers) (nth 1 numbers)
	       (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" end t))
	  (let* ((unsync (nth 0 numbers))
		 (unread (nth 1 numbers))
		 (face (cond
			((and unsync (zerop unsync))
			 (if (and unread (zerop unread))
			     'wl-highlight-folder-zero-face
			   'wl-highlight-folder-unread-face))
			((and unsync
			      (>= unsync wl-folder-many-unsync-threshold))
			 'wl-highlight-folder-many-face)
			(t
			 'wl-highlight-folder-few-face))))
	    (if (numberp wl-highlight-folder-by-numbers)
		(progn
		  (put-text-property start (match-beginning 0) 'face text-face)
		  (put-text-property (match-beginning 0) (point) 'face face))
	      ;; Remove previous face.
	      (put-text-property start (point) 'face nil)
	      (put-text-property start (point) 'face face))
	    (goto-char start))
	(put-text-property start end 'face text-face)))
    (when wl-use-highlight-mouse-line
      (wl-highlight-folder-mouse-line))))

(defun wl-highlight-plugged-current-line ())
(defun wl-plugged-set-folder-icon (folder string)
  string)

(defun wl-message-define-keymap ()
  (let ((keymap (make-sparse-keymap)))
    (define-key keymap "D" 'wl-message-delete-current-part)
    (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)
    (define-key keymap [S-mouse-5] 'wl-message-wheel-up)
    (set-keymap-parent wl-message-button-map keymap)
    (define-key wl-message-button-map [mouse-2]
      'wl-message-button-dispatcher)
    keymap))

(defun wl-message-wheel-up (event)
  (interactive "e")
  (if (string-match (regexp-quote wl-message-buffer-name)
		    (regexp-quote (buffer-name)))
      (wl-message-next-page)
    (let ((cur-buf (current-buffer))
	  proceed)
      (save-selected-window
	(select-window (posn-window (event-start event)))
	(set-buffer cur-buf)
	(setq proceed (wl-message-next-page)))
      (if proceed
	  (if (memq 'shift (event-modifiers event))
	      (wl-summary-down t)
	    (wl-summary-next t))))))

(defun wl-message-wheel-down (event)
  (interactive "e")
  (if (string-match (regexp-quote wl-message-buffer-name)
		    (regexp-quote (buffer-name)))
      (wl-message-prev-page)
    (let ((cur-buf (current-buffer))
	  proceed)
      (save-selected-window
	(select-window (posn-window (event-start event)))
	(set-buffer cur-buf)
	(setq proceed (wl-message-prev-page)))
      (if proceed
	  (if (memq 'shift (event-modifiers event))
	      (wl-summary-up t)
	    (wl-summary-prev t))))))

(defun wl-draft-key-setup ()
  (define-key wl-draft-mode-map "\C-c\C-y" 'wl-draft-yank-original)
  (define-key wl-draft-mode-map "\C-c\C-s" 'wl-draft-send)
  (define-key wl-draft-mode-map "\C-c\C-c" 'wl-draft-send-and-exit)
  (define-key wl-draft-mode-map "\C-c\C-z" 'wl-draft-save-and-exit)
  (define-key wl-draft-mode-map "\C-c\C-k" 'wl-draft-kill)
  (define-key wl-draft-mode-map "\C-l"     'wl-draft-highlight-and-recenter)
  (define-key wl-draft-mode-map "\C-i"     'wl-complete-field-body-or-tab)
  (define-key wl-draft-mode-map "\C-c\C-r" 'wl-draft-caesar-region)
  (define-key wl-draft-mode-map "\M-t"     'wl-toggle-plugged)
  (define-key wl-draft-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
  (define-key wl-draft-mode-map "\C-c\C-e" 'wl-draft-config-exec)
  (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-x\C-s" 'wl-draft-save)
  (define-key wl-draft-mode-map "\C-c\C-a" 'wl-addrmgr)
  (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)
  (define-key wl-draft-mode-map "\M-p" 'wl-draft-previous-history-element)
  (define-key wl-draft-mode-map "\M-n" 'wl-draft-next-history-element))

(defun wl-draft-overload-menubar ()
  (let ((keymap (current-local-map)))
    (define-key keymap [menu-bar mail send]
      '("Send Message" . wl-draft-send-and-exit))
    (define-key keymap [menu-bar mail send-stay]
      '("Send, Keep Editing" . wl-draft-send))
    (define-key-after (lookup-key keymap [menu-bar mail])
      [mail-sep-send] '("--")
      'send-stay)
    (define-key keymap [menu-bar mail cancel]
      '("Kill Current Draft" . wl-draft-kill))
    (define-key-after (lookup-key keymap [menu-bar mail])
      [save] '("Save Draft and Exit" . wl-draft-save-and-exit)
      'cancel)
    (define-key-after (lookup-key keymap [menu-bar mail])
      [mail-sep-exit] '("--")
      'save)
    (define-key-after (lookup-key keymap [menu-bar mail])
      [preview] '("Preview Message" . wl-draft-preview-message)
      'mail-sep-exit)
    (define-key keymap [menu-bar mail yank]
      '("Cite Message" . wl-draft-yank-original))
    (define-key keymap [menu-bar mail signature]
      `("Insert Signature" . ,(if (and (boundp 'mime-setup-use-signature)
				       mime-setup-use-signature)
				  'insert-signature
				'mime-edit-insert-signature)))
    (define-key keymap [menu-bar headers fcc]
      '("Fcc" . wl-draft-fcc))))

(defun wl-draft-overload-functions ()
  (wl-mode-line-buffer-identification)
;;;  (local-set-key "\C-c\C-s" 'wl-draft-send) ; override
  (wl-draft-overload-menubar))

;; for "ja-mule-canna-2.3.mini" on PocketBSD
(defun-maybe make-face (a))

(eval-when-compile
  (require 'static))
(static-cond
 ((and (fboundp 'defface)
       (not (featurep 'tinycustom)))
  (defalias 'wl-defface 'defface)
  (eval-when-compile
    (defun wl-face-spec-set-match-display (display frame))
    (defun wl-frame-parameter (frame property &optional default))
    (defun wl-get-frame-properties (&optional frame))))
 (t
  (defmacro wl-defface (face spec doc &rest args)
    (nconc (list 'wl-declare-face (list 'quote face) spec)))

  (defun wl-declare-face (face spec)
    (make-face face)
    (while spec
      (let* ((entry (car spec))
	     (display (nth 0 entry))
	     (atts (nth 1 entry)))
	(setq spec (cdr spec))
	(when (wl-face-spec-set-match-display display nil)
	  (apply 'wl-face-attributes-set face nil atts)))))

  (defconst wl-face-attributes
    '((:bold set-face-bold-p)
      (:italic set-face-italic-p)
      (:underline set-face-underline-p)
      (:foreground set-face-foreground)
      (:background set-face-background)
      (:stipple set-face-stipple)))

  (defun wl-face-attributes-set (face frame &rest atts)
    "For FACE on FRAME set the attributes [KEYWORD VALUE]....
Each keyword should be listed in `custom-face-attributes'.

If FRAME is nil, set the default face."
    (while atts
      (let* ((name (nth 0 atts))
	     (value (nth 1 atts))
	     (fun (nth 1 (assq name wl-face-attributes))))
	(setq atts (cdr (cdr atts)))
	(condition-case nil
	    (funcall fun face value frame)
	  (error nil)))))

  (defun wl-frame-parameter (frame property &optional default)
    "Return FRAME's value for property PROPERTY."
    (or (cdr (assq property (frame-parameters frame)))
	default))

  (eval-when-compile
    (defun-maybe x-display-grayscale-p ()))

  (defun wl-get-frame-properties (&optional frame)
    "Return a plist with the frame properties of FRAME used by custom."
    (list (cons 'type window-system)
	  (cons 'class (or (wl-frame-parameter frame 'display-type)
			   (when window-system
			     (cond ((x-display-color-p)
				    'color)
				   ((and (fboundp 'x-display-grayscale-p)
					 (x-display-grayscale-p))
				    'grayscale)
				   (t 'mono)))))
	  (cons 'background (or (wl-frame-parameter frame 'background-mode)
				wl-highlight-background-mode))))

  (defun wl-face-spec-set-match-display (display frame)
    "Non-nil iff DISPLAY matches FRAME.
If FRAME is nil, the current FRAME is used."
    ;; This is a kludge to get started, we really should use specifiers!
    (if (eq display t)
	t
      (let* ((props (wl-get-frame-properties frame))
	     (type (cdr (assq 'type props)))
	     (class (cdr (assq 'class props)))
	     (background (cdr (assq 'background props)))
	     (match t)
	     (entries display)
	     entry req options)
	(while (and entries match)
	  (setq entry (car entries)
		entries (cdr entries)
		req (car entry)
		options (cdr entry)
		match (cond ((eq req 'type)
			     (memq type options))
			    ((eq req 'class)
			     (memq class options))
			    ((eq req 'background)
			     (memq background options))
			    (t
			     (message "\
Warning: Unknown req `%S' with options `%S'" req options)
			     nil))))
	match)))))

(defun wl-read-event-char (&optional prompt)
  "Get the next event."
  (let ((event (read-event prompt)))
    (cons (and (numberp event) event) event)))

(require 'product)
(product-provide (provide 'wl-mule) (require 'wl-version))

;;; wl-mule.el ends here