forked from knu/elscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elscreen-wl.el
155 lines (134 loc) · 5.83 KB
/
elscreen-wl.el
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
;; -*- Mode: Emacs-Lisp -*-
;;
;; elscreen-wl.el
;;
(defconst elscreen-wl-version "0.8.0 (November 03, 2007)")
;;
;; Author: Naoto Morishima <[email protected]>
;; Created: March 24, 2001
;; Revised: November 03, 2007
;; 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 this program; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
(provide 'elscreen-wl)
(require 'elscreen)
(require 'wl)
;;; User Customizable Variables:
(defcustom elscreen-wl-draft-use-elscreen t
"Non-nil to use ElScreen when Wanderlust prepares draft buffer.
This option will override the option `wl-draft-use-frame'."
:type 'boolean
:group 'wl-draft)
(defcustom elscreen-wl-display-biff-on-tab t
"Non-nil to use ElScreen's tab to display biff icon instead of
mode-line."
:type 'boolean
:set (lambda (symbol value)
(custom-set-default symbol value)
(let ((buf (get-buffer wl-folder-buffer-name)))
(when buf
(with-current-buffer buf
(wl-mode-line-buffer-identification))))
(elscreen-notify-screen-modification 'force-immediately))
:group 'wl-highlight)
(defcustom elscreen-wl-mode-to-nickname-alist
'(("^wl-folder-mode$" . (lambda (buf)
(elscreen-wl-nickname-with-biff-status "Folder")))
("^wl-summary-mode$" . (lambda (buf)
(elscreen-wl-nickname-with-biff-status
(wl-summary-buffer-folder-name))))
("^wl-draft-mode$" . (lambda (buf)
(let ((buffer-name (buffer-name))
(subject (std11-field-body "Subject")))
(format "WL(%s%s)"
buffer-name
(if (zerop (length subject))
""
(concat "[" subject "]"))))))
("^wl-" . "Wanderlust"))
"*Alist composed of the pair of mode-name and corresponding screen-name."
:type '(alist :key-type string :value-type (choice string function))
:tag "Wanderlust major-mode to screen nickname alist"
:set (lambda (symbol value)
(custom-set-default symbol value)
(elscreen-rebuild-mode-to-nickname-alist))
:group 'wl)
(elscreen-set-mode-to-nickname-alist 'elscreen-wl-mode-to-nickname-alist)
;;; Code:
(defmacro elscreen-wl-draft-create-buffer (ad-do-it)
`(let ((wl-draft-use-frame wl-draft-use-frame)
(wl-draft-reply-buffer-style wl-draft-reply-buffer-style))
(when elscreen-wl-draft-use-elscreen
(setq wl-draft-use-frame nil)
(setq wl-draft-reply-buffer-style 'full)
(elscreen-create))
,ad-do-it
(when elscreen-wl-draft-use-elscreen
(make-local-variable 'kill-buffer-hook)
(add-hook 'kill-buffer-hook
(lambda ()
(when `(buffer-live-p ,(current-buffer))
(elscreen-kill)))))))
(defadvice wl-draft-create-buffer (around
elscreen-ad-wl-draft-create-buffer
activate)
(elscreen-wl-draft-create-buffer ad-do-it))
(defadvice wl-draft-reedit (around
elscreen-ad-wl-draft-reedit
activate)
(elscreen-wl-draft-create-buffer ad-do-it))
(defadvice wl-jump-to-draft-buffer (around
elscreen-ad-wl-jump-to-draft-screen
activate)
(let ((original-buffer (current-buffer))
draft-buffer)
ad-do-it
(when elscreen-wl-draft-use-elscreen
(setq draft-buffer (current-buffer))
(if (not (eq original-buffer draft-buffer))
(progn
(switch-to-buffer original-buffer)
(elscreen-find-and-goto-by-buffer draft-buffer))))))
(defmacro elscreen-wl-compensate-summary-window (ad-do-it)
`(let ((wl-draft-use-frame (or wl-draft-use-frame
elscreen-wl-draft-use-elscreen)))
,ad-do-it))
(defadvice wl-draft-forward (around elscreen-ad-wl-draft-forward activate)
(elscreen-wl-compensate-summary-window ad-do-it))
(defadvice wl-draft-reply (around elscreen-ad-wl-draft-forward activate)
(elscreen-wl-compensate-summary-window ad-do-it))
;; Biff on ElScreen's tab
(defsubst elscreen-wl-nickname-with-biff-status (name)
(concat
(when (and wl-biff-check-folder-list elscreen-wl-display-biff-on-tab)
(concat
(if wl-modeline-biff-status
wl-modeline-biff-state-on
wl-modeline-biff-state-off)
(propertize " " 'display '(space :width 0.5))))
(format "WL(%s)" name)))
(add-hook 'wl-biff-notify-hook
(lambda ()
(when elscreen-wl-display-biff-on-tab
(setq wl-modeline-biff-status t)
(elscreen-notify-screen-modification 'force-immediately))))
(add-hook 'wl-biff-unnotify-hook
(lambda ()
(when elscreen-wl-display-biff-on-tab
(setq wl-modeline-biff-status nil)
(elscreen-notify-screen-modification 'force-immediately))))
(defadvice wl-mode-line-buffer-identification (around elscreen-wl-mode-line-buffer-identification activate)
(let ((wl-biff-check-folder-list wl-biff-check-folder-list))
(when elscreen-wl-display-biff-on-tab
(setq wl-biff-check-folder-list nil))
ad-do-it))