0
|
1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
|
16
|
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
|
0
|
3
|
|
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
|
|
5 ;; Keywords: news
|
|
6
|
|
7 ;; This file is part of GNU Emacs.
|
|
8
|
|
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
10 ;; it under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 ;; GNU General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 ;; Boston, MA 02111-1307, USA.
|
|
23
|
|
24 ;;; Commentary:
|
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28 (require 'text-props)
|
|
29 (defvar menu-bar-mode (featurep 'menubar))
|
|
30 (require 'messagexmas)
|
|
31
|
|
32 (defvar gnus-xmas-glyph-directory nil
|
|
33 "*Directory where Gnus logos and icons are located.
|
|
34 If this variable is nil, Gnus will try to locate the directory
|
|
35 automatically.")
|
|
36
|
|
37 (defvar gnus-xmas-logo-color-alist
|
16
|
38 '((flame "#cc3300" "#ff2200")
|
|
39 (pine "#c0cc93" "#f8ffb8")
|
0
|
40 (moss "#a1cc93" "#d2ffb8")
|
|
41 (irish "#04cc90" "#05ff97")
|
|
42 (sky "#049acc" "#05deff")
|
|
43 (tin "#6886cc" "#82b6ff")
|
|
44 (velvet "#7c68cc" "#8c82ff")
|
|
45 (grape "#b264cc" "#cf7df")
|
|
46 (labia "#cc64c2" "#fd7dff")
|
|
47 (berry "#cc6485" "#ff7db5")
|
|
48 (neutral "#b4b4b4" "#878787")
|
|
49 (september "#bf9900" "#ffcc00"))
|
|
50 "Color alist used for the Gnus logo.")
|
|
51
|
16
|
52 (defvar gnus-xmas-logo-color-style 'flame
|
0
|
53 "Color styles used for the Gnus logo.")
|
|
54
|
|
55 (defvar gnus-xmas-logo-colors
|
|
56 (cdr (assq gnus-xmas-logo-color-style gnus-xmas-logo-color-alist))
|
|
57 "Colors used for the Gnus logo.")
|
|
58
|
|
59 (defvar gnus-article-x-face-command
|
|
60 (if (featurep 'xface)
|
|
61 'gnus-xmas-article-display-xface
|
|
62 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -")
|
|
63 "String or function to be executed to display an X-Face header.
|
|
64 If it is a string, the command will be executed in a sub-shell
|
|
65 asynchronously. The compressed face will be piped to this command.")
|
|
66
|
|
67 ;;; Internal variables.
|
|
68
|
|
69 ;; Don't warn about these undefined variables.
|
|
70
|
|
71 (defvar gnus-group-mode-hook)
|
|
72 (defvar gnus-summary-mode-hook)
|
|
73 (defvar gnus-article-mode-hook)
|
|
74
|
|
75 ;;defined in gnus.el
|
|
76 (defvar gnus-active-hashtb)
|
|
77 (defvar gnus-article-buffer)
|
|
78 (defvar gnus-auto-center-summary)
|
|
79 (defvar gnus-buffer-list)
|
|
80 (defvar gnus-current-headers)
|
|
81 (defvar gnus-level-killed)
|
|
82 (defvar gnus-level-zombie)
|
|
83 (defvar gnus-newsgroup-bookmarks)
|
|
84 (defvar gnus-newsgroup-dependencies)
|
|
85 (defvar gnus-newsgroup-selected-overlay)
|
|
86 (defvar gnus-newsrc-hashtb)
|
|
87 (defvar gnus-read-mark)
|
|
88 (defvar gnus-refer-article-method)
|
|
89 (defvar gnus-reffed-article-number)
|
|
90 (defvar gnus-unread-mark)
|
|
91 (defvar gnus-version)
|
|
92 (defvar gnus-view-pseudos)
|
|
93 (defvar gnus-view-pseudos-separately)
|
|
94 (defvar gnus-visual)
|
|
95 (defvar gnus-zombie-list)
|
|
96 ;;defined in gnus-msg.el
|
|
97 (defvar gnus-article-copy)
|
|
98 (defvar gnus-check-before-posting)
|
|
99 ;;defined in gnus-vis.el
|
|
100 (defvar gnus-article-button-face)
|
|
101 (defvar gnus-article-mouse-face)
|
|
102 (defvar gnus-summary-selected-face)
|
|
103 (defvar gnus-group-reading-menu)
|
|
104 (defvar gnus-group-group-menu)
|
|
105 (defvar gnus-group-misc-menu)
|
|
106 (defvar gnus-summary-article-menu)
|
|
107 (defvar gnus-summary-thread-menu)
|
|
108 (defvar gnus-summary-misc-menu)
|
|
109 (defvar gnus-summary-post-menu)
|
|
110 (defvar gnus-summary-kill-menu)
|
|
111 (defvar gnus-article-article-menu)
|
|
112 (defvar gnus-article-treatment-menu)
|
|
113 (defvar gnus-mouse-2)
|
|
114 (defvar standard-display-table)
|
|
115 (defvar gnus-tree-minimize-window)
|
|
116
|
|
117 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
|
|
118 "You should NEVER use this function. It is ideologically blasphemous.
|
|
119 It is provided only to ease porting of broken FSF Emacs programs."
|
16
|
120 (if (stringp buffer)
|
0
|
121 nil
|
|
122 (map-extents (lambda (extent ignored)
|
|
123 (remove-text-properties
|
|
124 start end
|
|
125 (list (extent-property extent 'text-prop) nil)
|
|
126 buffer))
|
|
127 buffer start end nil nil 'text-prop)
|
|
128 (gnus-add-text-properties start end props buffer)))
|
|
129
|
|
130 (defun gnus-xmas-highlight-selected-summary ()
|
|
131 ;; Highlight selected article in summary buffer
|
|
132 (when gnus-summary-selected-face
|
16
|
133 (when gnus-newsgroup-selected-overlay
|
|
134 (delete-extent gnus-newsgroup-selected-overlay))
|
0
|
135 (setq gnus-newsgroup-selected-overlay
|
18
|
136 (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
|
0
|
137 (set-extent-face gnus-newsgroup-selected-overlay
|
|
138 gnus-summary-selected-face)))
|
|
139
|
16
|
140 (defvar gnus-xmas-force-redisplay t
|
|
141 "If non-nil, force a redisplay before recentering the summary buffer.
|
|
142 This is ugly, but it works around a bug in `window-displayed-height'.")
|
|
143
|
0
|
144 (defun gnus-xmas-summary-recenter ()
|
|
145 "\"Center\" point in the summary window.
|
|
146 If `gnus-auto-center-summary' is nil, or the article buffer isn't
|
|
147 displayed, no centering will be performed."
|
|
148 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
|
|
149 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
|
16
|
150 ;; Force redisplay to get properly computed window height.
|
|
151 (when gnus-xmas-force-redisplay
|
|
152 (sit-for 0))
|
0
|
153 (when gnus-auto-center-summary
|
|
154 (let* ((height (if (fboundp 'window-displayed-height)
|
|
155 (window-displayed-height)
|
|
156 (- (window-height) 2)))
|
|
157 (top (cond ((< height 4) 0)
|
|
158 ((< height 7) 1)
|
|
159 (t 2)))
|
|
160 (bottom (save-excursion (goto-char (point-max))
|
|
161 (forward-line (- height))
|
|
162 (point)))
|
|
163 (window (get-buffer-window (current-buffer))))
|
|
164 (when (get-buffer-window gnus-article-buffer)
|
|
165 ;; Only do recentering when the article buffer is displayed,
|
|
166 ;; Set the window start to either `bottom', which is the biggest
|
|
167 ;; possible valid number, or the second line from the top,
|
|
168 ;; whichever is the least.
|
|
169 (set-window-start
|
16
|
170 window (min bottom (save-excursion (forward-line (- top)) (point)))))
|
0
|
171 ;; Do horizontal recentering while we're at it.
|
|
172 (when (and (get-buffer-window (current-buffer) t)
|
|
173 (not (eq gnus-auto-center-summary 'vertical)))
|
|
174 (let ((selected (selected-window)))
|
|
175 (select-window (get-buffer-window (current-buffer) t))
|
|
176 (gnus-summary-position-point)
|
|
177 (gnus-horizontal-recenter)
|
|
178 (select-window selected))))))
|
|
179
|
|
180 (defun gnus-xmas-add-hook (hook function &optional append local)
|
|
181 (add-hook hook function))
|
|
182
|
|
183 (defun gnus-xmas-add-text-properties (start end props &optional object)
|
|
184 (add-text-properties start end props object)
|
|
185 (put-text-property start end 'start-closed nil object))
|
|
186
|
|
187 (defun gnus-xmas-put-text-property (start end prop value &optional object)
|
|
188 (put-text-property start end prop value object)
|
|
189 (put-text-property start end 'start-closed nil object))
|
|
190
|
|
191 (defun gnus-xmas-extent-start-open (point)
|
|
192 (map-extents (lambda (extent arg)
|
|
193 (set-extent-property extent 'start-open t))
|
|
194 nil point (min (1+ (point)) (point-max))))
|
|
195
|
|
196 (defun gnus-xmas-article-push-button (event)
|
|
197 "Check text under the mouse pointer for a callback function.
|
|
198 If the text under the mouse pointer has a `gnus-callback' property,
|
|
199 call it with the value of the `gnus-data' text property."
|
|
200 (interactive "e")
|
|
201 (set-buffer (window-buffer (event-window event)))
|
|
202 (let* ((pos (event-closest-point event))
|
|
203 (data (get-text-property pos 'gnus-data))
|
|
204 (fun (get-text-property pos 'gnus-callback)))
|
16
|
205 (when fun
|
|
206 (funcall fun data))))
|
0
|
207
|
|
208 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
|
|
209 (set-extent-endpoints extent start end))
|
|
210
|
|
211 ;; Fixed by Christopher Davis <ckd@loiosh.kei.com>.
|
|
212 (defun gnus-xmas-article-add-button (from to fun &optional data)
|
|
213 "Create a button between FROM and TO with callback FUN and data DATA."
|
16
|
214 (when gnus-article-button-face
|
|
215 (gnus-overlay-put (gnus-make-overlay from to)
|
|
216 'face gnus-article-button-face))
|
0
|
217 (gnus-add-text-properties
|
|
218 from to
|
|
219 (nconc
|
|
220 (and gnus-article-mouse-face
|
|
221 (list 'mouse-face gnus-article-mouse-face))
|
|
222 (list 'gnus-callback fun)
|
|
223 (and data (list 'gnus-data data))
|
|
224 (list 'highlight t))))
|
|
225
|
|
226 (defun gnus-xmas-window-top-edge (&optional window)
|
|
227 (nth 1 (window-pixel-edges window)))
|
|
228
|
|
229 (defun gnus-xmas-tree-minimize ()
|
|
230 (when (and gnus-tree-minimize-window
|
|
231 (not (one-window-p)))
|
|
232 (let* ((window-min-height 2)
|
|
233 (height (1+ (count-lines (point-min) (point-max))))
|
|
234 (min (max (1- window-min-height) height))
|
|
235 (tot (if (numberp gnus-tree-minimize-window)
|
|
236 (min gnus-tree-minimize-window min)
|
|
237 min))
|
|
238 (win (get-buffer-window (current-buffer)))
|
|
239 (wh (and win (1- (window-height win)))))
|
|
240 (when (and win
|
|
241 (not (eq tot wh)))
|
|
242 (let ((selected (selected-window)))
|
|
243 (select-window win)
|
|
244 (enlarge-window (- tot wh))
|
|
245 (select-window selected))))))
|
|
246
|
|
247 ;; Select the lowest window on the frame.
|
|
248 (defun gnus-xmas-appt-select-lowest-window ()
|
|
249 (let* ((lowest-window (selected-window))
|
|
250 (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
|
|
251 (last-window (previous-window))
|
|
252 (window-search t))
|
|
253 (while window-search
|
|
254 (let* ((this-window (next-window))
|
|
255 (next-bottom-edge (car (cdr (cdr (cdr
|
|
256 (window-pixel-edges
|
|
257 this-window)))))))
|
16
|
258 (when (< bottom-edge next-bottom-edge)
|
|
259 (setq bottom-edge next-bottom-edge)
|
|
260 (setq lowest-window this-window))
|
0
|
261
|
|
262 (select-window this-window)
|
16
|
263 (when (eq last-window this-window)
|
|
264 (select-window lowest-window)
|
|
265 (setq window-search nil))))))
|
0
|
266
|
|
267 (defmacro gnus-xmas-menu-add (type &rest menus)
|
|
268 `(gnus-xmas-menu-add-1 ',type ',menus))
|
|
269 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
|
|
270
|
|
271 (defun gnus-xmas-menu-add-1 (type menus)
|
|
272 (when (and menu-bar-mode
|
|
273 (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
|
|
274 (while menus
|
|
275 (easy-menu-add (symbol-value (pop menus))))))
|
|
276
|
|
277 (defun gnus-xmas-group-menu-add ()
|
|
278 (gnus-xmas-menu-add group
|
|
279 gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
|
|
280
|
|
281 (defun gnus-xmas-summary-menu-add ()
|
|
282 (gnus-xmas-menu-add summary
|
|
283 gnus-summary-misc-menu gnus-summary-kill-menu
|
|
284 gnus-summary-article-menu gnus-summary-thread-menu
|
|
285 gnus-summary-post-menu ))
|
|
286
|
|
287 (defun gnus-xmas-article-menu-add ()
|
|
288 (gnus-xmas-menu-add article
|
|
289 gnus-article-article-menu gnus-article-treatment-menu))
|
|
290
|
|
291 (defun gnus-xmas-score-menu-add ()
|
|
292 (gnus-xmas-menu-add score
|
|
293 gnus-score-menu))
|
|
294
|
|
295 (defun gnus-xmas-pick-menu-add ()
|
|
296 (gnus-xmas-menu-add pick
|
|
297 gnus-pick-menu))
|
|
298
|
16
|
299 (defun gnus-xmas-topic-menu-add ()
|
|
300 (gnus-xmas-menu-add topic
|
|
301 gnus-topic-menu))
|
|
302
|
0
|
303 (defun gnus-xmas-binary-menu-add ()
|
|
304 (gnus-xmas-menu-add binary
|
|
305 gnus-binary-menu))
|
|
306
|
|
307 (defun gnus-xmas-tree-menu-add ()
|
|
308 (gnus-xmas-menu-add tree
|
|
309 gnus-tree-menu))
|
|
310
|
|
311 (defun gnus-xmas-server-menu-add ()
|
|
312 (gnus-xmas-menu-add menu
|
|
313 gnus-server-server-menu gnus-server-connections-menu))
|
|
314
|
|
315 (defun gnus-xmas-browse-menu-add ()
|
|
316 (gnus-xmas-menu-add browse
|
|
317 gnus-browse-menu))
|
|
318
|
|
319 (defun gnus-xmas-grouplens-menu-add ()
|
|
320 (gnus-xmas-menu-add grouplens
|
|
321 gnus-grouplens-menu))
|
|
322
|
|
323 (defun gnus-xmas-read-event-char ()
|
|
324 "Get the next event."
|
16
|
325 (let ((event (next-command-event)))
|
|
326 (sit-for 0)
|
0
|
327 ;; We junk all non-key events. Is this naughty?
|
|
328 (while (not (key-press-event-p event))
|
16
|
329 (setq event (next-command-event)))
|
0
|
330 (cons (and (key-press-event-p event)
|
|
331 (event-to-character event))
|
|
332 event)))
|
|
333
|
|
334 (defun gnus-xmas-group-remove-excess-properties ()
|
|
335 (let ((end (point))
|
|
336 (beg (progn (forward-line -1) (point))))
|
|
337 (remove-text-properties (1+ beg) end '(gnus-group nil))
|
|
338 (remove-text-properties
|
|
339 beg end
|
|
340 '(gnus-topic nil gnus-topic-level nil gnus-topic-visible nil))
|
|
341 (goto-char end)
|
|
342 (map-extents
|
|
343 (lambda (e ma)
|
|
344 (set-extent-property e 'start-closed t))
|
|
345 (current-buffer) beg end)))
|
|
346
|
|
347 (defun gnus-xmas-topic-remove-excess-properties ()
|
|
348 (let ((end (point))
|
|
349 (beg (progn (forward-line -1) (point))))
|
|
350 (remove-text-properties beg end '(gnus-group nil gnus-unread nil))
|
|
351 (remove-text-properties (1+ beg) end '(gnus-topic nil))
|
|
352 (goto-char end)))
|
|
353
|
|
354 (defun gnus-xmas-seconds-since-epoch (date)
|
|
355 "Return a floating point number that says how many seconds have lapsed between Jan 1 12:00:00 1970 and DATE."
|
|
356 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
|
|
357 (timezone-parse-date date)))
|
|
358 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
|
|
359 (timezone-parse-time
|
|
360 (aref (timezone-parse-date date) 3))))
|
|
361 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
|
|
362 (timezone-parse-date "Jan 1 12:00:00 1970")))
|
|
363 (tday (- (timezone-absolute-from-gregorian
|
|
364 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
|
|
365 (timezone-absolute-from-gregorian
|
|
366 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
|
|
367 (+ (nth 2 ttime)
|
|
368 (* (nth 1 ttime) 60)
|
|
369 (* (float (nth 0 ttime)) 60 60)
|
|
370 (* (float tday) 60 60 24))))
|
|
371
|
|
372 (defun gnus-xmas-define ()
|
|
373 (setq gnus-mouse-2 [button2])
|
|
374
|
16
|
375 (unless (memq 'underline (face-list))
|
|
376 (and (fboundp 'make-face)
|
|
377 (funcall (intern "make-face") 'underline)))
|
0
|
378 ;; Must avoid calling set-face-underline-p directly, because it
|
|
379 ;; is a defsubst in emacs19, and will make the .elc files non
|
|
380 ;; portable!
|
16
|
381 (unless (face-differs-from-default-p 'underline)
|
|
382 (funcall (intern "set-face-underline-p") 'underline t))
|
|
383
|
|
384 (cond
|
|
385 ((fboundp 'char-or-char-int-p)
|
|
386 ;; Handle both types of marks for XEmacs-20.x.
|
|
387 (fset 'gnus-characterp 'char-or-char-int-p))
|
|
388 ;; V19 of XEmacs, probably.
|
|
389 (t
|
|
390 (fset 'gnus-characterp 'characterp)))
|
0
|
391
|
|
392 (fset 'gnus-make-overlay 'make-extent)
|
|
393 (fset 'gnus-overlay-put 'set-extent-property)
|
|
394 (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
|
|
395 (fset 'gnus-overlay-end 'extent-end-position)
|
|
396 (fset 'gnus-extent-detached-p 'extent-detached-p)
|
|
397 (fset 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
|
|
398 (fset 'gnus-put-text-property 'gnus-xmas-put-text-property)
|
|
399
|
|
400 (require 'text-props)
|
16
|
401 (if (and (<= emacs-major-version 19)
|
|
402 (< emacs-minor-version 14))
|
0
|
403 (fset 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
|
|
404
|
16
|
405 (when (fboundp 'turn-off-scroll-in-place)
|
|
406 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
|
|
407
|
|
408 (unless (boundp 'standard-display-table)
|
|
409 (setq standard-display-table nil))
|
0
|
410
|
|
411 (defvar gnus-mouse-face-prop 'highlight)
|
|
412
|
|
413 (unless (fboundp 'encode-time)
|
|
414 (defun encode-time (sec minute hour day month year &optional zone)
|
|
415 (let ((seconds
|
|
416 (gnus-xmas-seconds-since-epoch
|
|
417 (timezone-make-arpa-date
|
|
418 year month day (timezone-make-time-string hour minute sec)
|
|
419 zone))))
|
|
420 (list (floor (/ seconds (expt 2 16)))
|
|
421 (round (mod seconds (expt 2 16)))))))
|
|
422
|
|
423 (defun gnus-byte-code (func)
|
|
424 "Return a form that can be `eval'ed based on FUNC."
|
|
425 (let ((fval (symbol-function func)))
|
|
426 (if (compiled-function-p fval)
|
|
427 (list 'funcall fval)
|
|
428 (cons 'progn (cdr (cdr fval))))))
|
|
429
|
|
430 (fset 'gnus-x-color-values
|
|
431 (if (fboundp 'x-color-values)
|
|
432 'x-color-values
|
|
433 (lambda (color)
|
|
434 (color-instance-rgb-components
|
16
|
435 (make-color-instance color))))))
|
0
|
436
|
22
|
437 (defun gnus-xmas-region-active-p ()
|
|
438 (and (fboundp 'region-active-p)
|
|
439 (region-active-p)))
|
0
|
440
|
|
441 (defun gnus-xmas-redefine ()
|
|
442 "Redefine lots of Gnus functions for XEmacs."
|
|
443 (fset 'gnus-summary-make-display-table 'ignore)
|
|
444 (fset 'gnus-visual-turn-off-edit-menu 'identity)
|
|
445 (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
|
|
446 (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
|
|
447 (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
|
|
448 (fset 'gnus-article-add-button 'gnus-xmas-article-add-button)
|
|
449 (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
|
|
450 (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
|
|
451 (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
|
|
452 (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
|
|
453 (fset 'gnus-appt-select-lowest-window
|
|
454 'gnus-xmas-appt-select-lowest-window)
|
|
455 (fset 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
|
|
456 (fset 'gnus-add-hook 'gnus-xmas-add-hook)
|
|
457 (fset 'gnus-character-to-event 'character-to-event)
|
|
458 (fset 'gnus-mode-line-buffer-identification
|
|
459 'gnus-xmas-mode-line-buffer-identification)
|
16
|
460 (fset 'gnus-key-press-event-p 'key-press-event-p)
|
22
|
461 (fset 'gnus-region-active-p 'gnus-xmas-region-active-p)
|
|
462
|
0
|
463 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
|
|
464 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
|
|
465 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
|
|
466 (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
|
|
467
|
|
468 (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
|
16
|
469 (add-hook 'gnus-topic-mode-hook 'gnus-xmas-topic-menu-add)
|
0
|
470 (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
|
|
471 (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
|
|
472 (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
|
|
473 (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
|
|
474 (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
|
|
475
|
|
476 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
|
|
477 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
|
|
478
|
|
479 (when (and (<= emacs-major-version 19)
|
|
480 (<= emacs-minor-version 13))
|
16
|
481 (setq gnus-article-x-face-too-ugly (when (eq (device-type) 'tty)
|
|
482 "."))
|
0
|
483 (fset 'gnus-highlight-selected-summary
|
|
484 'gnus-xmas-highlight-selected-summary)
|
|
485 (fset 'gnus-group-remove-excess-properties
|
|
486 'gnus-xmas-group-remove-excess-properties)
|
|
487 (fset 'gnus-topic-remove-excess-properties
|
|
488 'gnus-xmas-topic-remove-excess-properties)
|
|
489 (fset 'gnus-mode-line-buffer-identification 'identity)
|
|
490 (unless (boundp 'shell-command-switch)
|
16
|
491 (setq shell-command-switch "-c"))))
|
0
|
492
|
|
493
|
|
494 ;;; XEmacs logo and toolbar.
|
|
495
|
|
496 (defun gnus-xmas-group-startup-message (&optional x y)
|
|
497 "Insert startup message in current buffer."
|
|
498 ;; Insert the message.
|
|
499 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
|
|
500 (erase-buffer)
|
|
501 (let ((logo (and gnus-xmas-glyph-directory
|
|
502 (concat
|
|
503 (file-name-as-directory gnus-xmas-glyph-directory)
|
|
504 "gnus."
|
|
505 (if (featurep 'xpm) "xpm" "xbm"))))
|
|
506 (xpm-color-symbols
|
|
507 (and (featurep 'xpm)
|
|
508 (append `(("thing" ,(car gnus-xmas-logo-colors))
|
|
509 ("shadow" ,(cadr gnus-xmas-logo-colors)))
|
|
510 xpm-color-symbols))))
|
|
511 (if (and (featurep 'xpm)
|
|
512 (not (equal (device-type) 'tty))
|
|
513 logo
|
|
514 (file-exists-p logo))
|
|
515 (progn
|
|
516 (setq logo (make-glyph logo))
|
|
517 (insert " ")
|
|
518 (set-extent-begin-glyph (make-extent (point) (point)) logo)
|
|
519 (goto-char (point-min))
|
|
520 (while (not (eobp))
|
|
521 (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
|
|
522 ? ))
|
|
523 (forward-line 1))
|
|
524 (goto-char (point-min))
|
|
525 (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
|
|
526 (wheight (window-height))
|
|
527 (rest (- wheight pheight)))
|
|
528 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
|
|
529
|
|
530 (insert
|
|
531 (format " %s
|
|
532 _ ___ _ _
|
|
533 _ ___ __ ___ __ _ ___
|
|
534 __ _ ___ __ ___
|
|
535 _ ___ _
|
|
536 _ _ __ _
|
|
537 ___ __ _
|
|
538 __ _
|
|
539 _ _ _
|
|
540 _ _ _
|
|
541 _ _ _
|
|
542 __ ___
|
|
543 _ _ _ _
|
|
544 _ _
|
|
545 _ _
|
|
546 _ _
|
|
547 _
|
|
548 __
|
|
549
|
|
550 "
|
|
551 ""))
|
|
552 ;; And then hack it.
|
16
|
553 (gnus-indent-rigidly (point-min) (point-max)
|
0
|
554 (/ (max (- (window-width) (or x 46)) 0) 2))
|
|
555 (goto-char (point-min))
|
|
556 (forward-line 1)
|
|
557 (let* ((pheight (count-lines (point-min) (point-max)))
|
|
558 (wheight (window-height))
|
|
559 (rest (- wheight pheight)))
|
|
560 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
|
|
561 ;; Fontify some.
|
|
562 (goto-char (point-min))
|
16
|
563 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)
|
0
|
564 (goto-char (point-min))
|
16
|
565 (setq modeline-buffer-identification
|
|
566 (list (concat gnus-version ": *Group*")))
|
|
567 (set-buffer-modified-p t)))
|
0
|
568
|
|
569
|
|
570 ;;; The toolbar.
|
|
571
|
|
572 (defvar gnus-use-toolbar (if (featurep 'toolbar)
|
|
573 'default-toolbar
|
|
574 nil)
|
|
575 "*If nil, do not use a toolbar.
|
|
576 If it is non-nil, it must be a toolbar. The five legal values are
|
|
577 `default-toolbar', `top-toolbar', `bottom-toolbar',
|
|
578 `right-toolbar', and `left-toolbar'.")
|
|
579
|
|
580 (defvar gnus-group-toolbar
|
16
|
581 '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
|
0
|
582 [gnus-group-get-new-news-this-group
|
|
583 gnus-group-get-new-news-this-group t "Get new news in this group"]
|
|
584 [gnus-group-catchup-current
|
|
585 gnus-group-catchup-current t "Catchup group"]
|
|
586 [gnus-group-describe-group
|
|
587 gnus-group-describe-group t "Describe group"]
|
16
|
588 [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
|
|
589 [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
|
0
|
590 [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
|
|
591 [gnus-group-exit gnus-group-exit t "Exit Gnus"]
|
|
592 )
|
|
593 "The group buffer toolbar.")
|
|
594
|
|
595 (defvar gnus-summary-toolbar
|
16
|
596 '([gnus-summary-prev-unread
|
0
|
597 gnus-summary-prev-unread-article t "Prev unread article"]
|
|
598 [gnus-summary-next-unread
|
|
599 gnus-summary-next-unread-article t "Next unread article"]
|
|
600 [gnus-summary-post-news
|
|
601 gnus-summary-post-news t "Post an article"]
|
|
602 [gnus-summary-followup-with-original
|
|
603 gnus-summary-followup-with-original t
|
|
604 "Post a followup and yank the original"]
|
|
605 [gnus-summary-followup
|
|
606 gnus-summary-followup t "Post a followup"]
|
|
607 [gnus-summary-reply-with-original
|
|
608 gnus-summary-reply-with-original t "Mail a reply and yank the original"]
|
|
609 [gnus-summary-reply
|
|
610 gnus-summary-reply t "Mail a reply"]
|
|
611 [gnus-summary-caesar-message
|
|
612 gnus-summary-caesar-message t "Rot 13"]
|
|
613 [gnus-uu-decode-uu
|
|
614 gnus-uu-decode-uu t "Decode uuencoded articles"]
|
|
615 [gnus-summary-save-article-file
|
|
616 gnus-summary-save-article-file t "Save article in file"]
|
|
617 [gnus-summary-save-article
|
|
618 gnus-summary-save-article t "Save article"]
|
|
619 [gnus-uu-post-news
|
|
620 gnus-uu-post-news t "Post an uuencoded article"]
|
|
621 [gnus-summary-cancel-article
|
|
622 gnus-summary-cancel-article t "Cancel article"]
|
16
|
623 [gnus-summary-catchup
|
|
624 gnus-summary-catchup t "Catchup"]
|
0
|
625 [gnus-summary-catchup-and-exit
|
|
626 gnus-summary-catchup-and-exit t "Catchup and exit"]
|
|
627 [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
|
|
628 )
|
|
629 "The summary buffer toolbar.")
|
|
630
|
|
631 (defvar gnus-summary-mail-toolbar
|
|
632 '(
|
|
633 [gnus-summary-prev-unread
|
|
634 gnus-summary-prev-unread-article t "Prev unread article"]
|
|
635 [gnus-summary-next-unread
|
|
636 gnus-summary-next-unread-article t "Next unread article"]
|
|
637 [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
|
16
|
638 ; [gnus-summary-mail-get gnus-mail-get t "Message get"]
|
0
|
639 [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
|
|
640 [gnus-summary-mail-save gnus-summary-save-article t "Save"]
|
|
641 [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
|
|
642 ; [gnus-summary-mail-delete gnus-summary-delete-article t "Delete message"]
|
|
643 [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
|
|
644 ; [gnus-summary-mail-spell gnus-mail-spell t "Spell"]
|
|
645 ; [gnus-summary-mail-help gnus-mail-help t "Message help"]
|
|
646 [gnus-summary-caesar-message
|
|
647 gnus-summary-caesar-message t "Rot 13"]
|
|
648 [gnus-uu-decode-uu
|
|
649 gnus-uu-decode-uu t "Decode uuencoded articles"]
|
|
650 [gnus-summary-save-article-file
|
|
651 gnus-summary-save-article-file t "Save article in file"]
|
|
652 [gnus-summary-save-article
|
|
653 gnus-summary-save-article t "Save article"]
|
16
|
654 [gnus-summary-catchup
|
|
655 gnus-summary-catchup t "Catchup"]
|
0
|
656 [gnus-summary-catchup-and-exit
|
|
657 gnus-summary-catchup-and-exit t "Catchup and exit"]
|
|
658 [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
|
|
659 )
|
|
660 "The summary buffer mail toolbar.")
|
|
661
|
|
662 (defun gnus-xmas-setup-group-toolbar ()
|
|
663 (and gnus-use-toolbar
|
|
664 (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
|
|
665 (set-specifier (symbol-value gnus-use-toolbar)
|
|
666 (cons (current-buffer) gnus-group-toolbar))))
|
|
667
|
|
668 (defun gnus-xmas-setup-summary-toolbar ()
|
|
669 (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
|
|
670 gnus-summary-toolbar gnus-summary-mail-toolbar)))
|
|
671 (and gnus-use-toolbar
|
|
672 (message-xmas-setup-toolbar bar nil "gnus")
|
|
673 (set-specifier (symbol-value gnus-use-toolbar)
|
|
674 (cons (current-buffer) bar)))))
|
|
675
|
|
676 (defun gnus-xmas-mail-strip-quoted-names (address)
|
|
677 "Protect mail-strip-quoted-names from NIL input.
|
|
678 XEmacs compatibility workaround."
|
|
679 (if (null address)
|
|
680 nil
|
|
681 (mail-strip-quoted-names address)))
|
|
682
|
|
683 (defun gnus-xmas-call-region (command &rest args)
|
|
684 (apply
|
|
685 'call-process-region (point-min) (point-max) command t '(t nil) nil
|
|
686 args))
|
|
687
|
|
688 (unless (find-face 'gnus-x-face)
|
|
689 (copy-face 'default 'gnus-x-face)
|
|
690 (set-face-foreground 'gnus-x-face "black")
|
|
691 (set-face-background 'gnus-x-face "white"))
|
|
692
|
|
693 (defun gnus-xmas-article-display-xface (beg end)
|
|
694 "Display any XFace headers in the current article."
|
|
695 (save-excursion
|
|
696 (let (xface-glyph)
|
|
697 (if (featurep 'xface)
|
|
698 (setq xface-glyph
|
|
699 (make-glyph (vector 'xface :data
|
|
700 (concat "X-Face: "
|
|
701 (buffer-substring beg end)))))
|
|
702 (let ((cur (current-buffer)))
|
|
703 (save-excursion
|
|
704 (gnus-set-work-buffer)
|
|
705 (insert (format "%s" (buffer-substring beg end cur)))
|
|
706 (gnus-xmas-call-region "uncompface")
|
|
707 (goto-char (point-min))
|
|
708 (insert "/* Width=48, Height=48 */\n")
|
|
709 (gnus-xmas-call-region "icontopbm")
|
|
710 (gnus-xmas-call-region "ppmtoxpm")
|
|
711 (setq xface-glyph
|
|
712 (make-glyph
|
|
713 (vector 'xpm :data (buffer-string )))))))
|
|
714 (set-glyph-face xface-glyph 'gnus-x-face)
|
|
715 (goto-char (point-min))
|
|
716 (re-search-forward "^From:" nil t)
|
|
717 (set-extent-begin-glyph
|
|
718 (make-extent (point) (1+ (point))) xface-glyph))))
|
|
719
|
16
|
720 (defvar gnus-xmas-pointer-glyph
|
|
721 (progn
|
|
722 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
|
|
723 (make-pointer-glyph (concat gnus-xmas-glyph-directory "gnus-pointer."
|
|
724 (if (featurep 'xpm) "xpm" "xbm")))))
|
|
725
|
|
726 (defvar gnus-xmas-modeline-left-extent
|
|
727 (let ((ext (copy-extent modeline-buffer-id-left-extent)))
|
|
728 ;(set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
|
|
729 ext))
|
|
730
|
|
731 (defvar gnus-xmas-modeline-right-extent
|
|
732 (let ((ext (copy-extent modeline-buffer-id-right-extent)))
|
|
733 ;(set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
|
|
734 ext))
|
|
735
|
|
736 (defvar gnus-xmas-modeline-glyph
|
|
737 (progn
|
|
738 (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
|
|
739 (let* ((file (concat gnus-xmas-glyph-directory "gnus-pointer."
|
|
740 (if (featurep 'xpm) "xpm" "xbm")))
|
|
741 (glyph (make-glyph file)))
|
|
742 (when (and (featurep 'x)
|
|
743 (file-exists-p file))
|
24
|
744 (set-glyph-face glyph 'modeline-buffer-id)
|
|
745 (set-glyph-property glyph 'image (cons 'tty "Gnus:"))
|
|
746 glyph))))
|
0
|
747
|
|
748 (defun gnus-xmas-mode-line-buffer-identification (line)
|
|
749 (let ((line (car line))
|
|
750 chop)
|
24
|
751 (cond
|
|
752 ;; This is some weird type of id.
|
|
753 ((not (stringp line))
|
|
754 (list line))
|
|
755 ;; This is non-standard, so we just pass it through.
|
|
756 ((not (string-match "^Gnus:" line))
|
|
757 (list line))
|
|
758 ;; We have a standard line, so we colorize and glyphize it a bit.
|
|
759 (t
|
|
760 (setq chop (match-end 0))
|
|
761 (list
|
|
762 (if gnus-xmas-modeline-glyph
|
|
763 (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
|
|
764 (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
|
|
765 (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
|
16
|
766
|
|
767 (defun gnus-xmas-splash ()
|
|
768 (when (eq (device-type) 'x)
|
|
769 (gnus-splash)))
|
0
|
770
|
|
771 (provide 'gnus-xmas)
|
|
772
|
|
773 ;;; gnus-xmas.el ends here
|