Wrongly places parens.
[emacs/old-mirror.git] / lisp / gnus-cus.el
blob37a30b00a84b98ecb6d6c57a86f6d05873432dd1
1 ;;; gnus-cus.el --- User friendly customization of Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
3 ;;
4 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
5 ;; Keywords: help, news
6 ;; Version: 0.1
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs 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)
13 ;; any later version.
15 ;; GNU Emacs 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.
25 ;;; Commentary:
27 ;;; Code:
29 (require 'custom)
30 (require 'gnus-ems)
31 (require 'browse-url)
32 (eval-when-compile (require 'cl))
34 ;; The following is just helper functions and data, not meant to be set
35 ;; by the user.
36 (defun gnus-make-face (color)
37 ;; Create entry for face with COLOR.
38 (custom-face-lookup color nil nil nil nil nil))
40 (defvar gnus-face-light-name-list
41 '("light blue" "light cyan" "light yellow" "light pink"
42 "pale green" "beige" "orange" "magenta" "violet" "medium purple"
43 "turquoise"))
45 (defvar gnus-face-dark-name-list
46 '("dark blue" "firebrick" "dark green" "OrangeRed"
47 "dark khaki" "dark violet" "SteelBlue4"))
48 ; CornflowerBlue SeaGreen OrangeRed SteelBlue4 DeepPink3
49 ; DarkOlviveGreen4
51 (custom-declare '()
52 '((tag . "Gnus")
53 (doc . "\
54 The coffee-brewing, all singing, all dancing, kitchen sink newsreader.")
55 (type . group)
56 (data
57 ((tag . "Visual")
58 (doc . "\
59 Gnus can be made colorful and fun or grey and dull as you wish.")
60 (type . group)
61 (data
62 ((tag . "Visual")
63 (doc . "Enable visual features.
64 If `visual' is disabled, there will be no menus and few faces. Most of
65 the visual customization options below will be ignored. Gnus will use
66 less space and be faster as a result.")
67 (default .
68 (summary-highlight group-highlight
69 article-highlight
70 mouse-face
71 summary-menu group-menu article-menu
72 tree-highlight menu highlight
73 browse-menu server-menu
74 page-marker tree-menu binary-menu pick-menu
75 grouplens-menu))
76 (name . gnus-visual)
77 (type . sexp))
78 ((tag . "WWW Browser")
79 (doc . "\
80 WWW Browser to call when clicking on an URL button in the article buffer.
82 You can choose between one of the predefined browsers, or `Other'.")
83 (name . browse-url-browser-function)
84 (calculate . (cond ((boundp 'browse-url-browser-function)
85 browse-url-browser-function)
86 ((fboundp 'w3-fetch)
87 'w3-fetch)
88 ((eq window-system 'x)
89 'gnus-netscape-open-url)))
90 (type . choice)
91 (data
92 ((tag . "W3")
93 (type . const)
94 (default . w3-fetch))
95 ((tag . "Netscape")
96 (type . const)
97 (default . browse-url-netscape))
98 ((prompt . "Other")
99 (doc . "\
100 You must specify the name of a Lisp function here. The lisp function
101 should open a WWW browser when called with an URL (a string).
103 (default . __uninitialized__)
104 (type . symbol))))
105 ((tag . "Mouse Face")
106 (doc . "\
107 Face used for group or summary buffer mouse highlighting.
108 The line beneath the mouse pointer will be highlighted with this
109 face.")
110 (name . gnus-mouse-face)
111 (calculate . (condition-case ()
112 (if (gnus-visual-p 'mouse-face 'highlight)
113 (if (boundp 'gnus-mouse-face)
114 gnus-mouse-face
115 'highlight)
116 'default)
117 (error 'default)))
118 (type . face))
119 ((tag . "Article Display")
120 (doc . "Controls how the article buffer will look.
122 If you leave the list empty, the article will appear exactly as it is
123 stored on the disk. The list entries will hide or highlight various
124 parts of the article, making it easier to find the information you
125 want.")
126 (name . gnus-article-display-hook)
127 (type . list)
128 (calculate
129 . (if (and (string-match "xemacs" emacs-version)
130 (featurep 'xface))
131 '(gnus-article-hide-headers-if-wanted
132 gnus-article-hide-boring-headers
133 gnus-article-treat-overstrike
134 gnus-article-maybe-highlight
135 gnus-article-display-x-face)
136 '(gnus-article-hide-headers-if-wanted
137 gnus-article-hide-boring-headers
138 gnus-article-treat-overstrike
139 gnus-article-maybe-highlight)))
140 (data
141 ((type . repeat)
142 (header . nil)
143 (data
144 (tag . "Filter")
145 (type . choice)
146 (data
147 ((tag . "Treat Overstrike")
148 (doc . "\
149 Convert use of overstrike into bold and underline.
151 Two identical letters separated by a backspace are displayed as a
152 single bold letter, while a letter followed by a backspace and an
153 underscore will be displayed as a single underlined letter. This
154 technique was developed for old line printers (think about it), and is
155 still in use on some newsgroups, in particular the ClariNet
156 hierarchy.
158 (type . const)
159 (default .
160 gnus-article-treat-overstrike))
161 ((tag . "Word Wrap")
162 (doc . "\
163 Format too long lines.
165 (type . const)
166 (default . gnus-article-word-wrap))
167 ((tag . "Remove CR")
168 (doc . "\
169 Remove carriage returns from an article.
171 (type . const)
172 (default . gnus-article-remove-cr))
173 ((tag . "Display X-Face")
174 (doc . "\
175 Look for an X-Face header and display it if present.
177 See also `X Face Command' for a definition of the external command
178 used for decoding and displaying the face.
180 (type . const)
181 (default . gnus-article-display-x-face))
182 ((tag . "Unquote Printable")
183 (doc . "\
184 Transform MIME quoted printable into 8-bit characters.
186 Quoted printable is often seen by strings like `=EF' where you would
187 expect a non-English letter.
189 (type . const)
190 (default .
191 gnus-article-de-quoted-unreadable))
192 ((tag . "Universal Time")
193 (doc . "\
194 Convert date header to universal time.
196 (type . const)
197 (default . gnus-article-date-ut))
198 ((tag . "Local Time")
199 (doc . "\
200 Convert date header to local timezone.
202 (type . const)
203 (default . gnus-article-date-local))
204 ((tag . "Lapsed Time")
205 (doc . "\
206 Replace date header with a header showing the articles age.
208 (type . const)
209 (default . gnus-article-date-lapsed))
210 ((tag . "Highlight")
211 (doc . "\
212 Highlight headers, citations, signature, and buttons.
214 (type . const)
215 (default . gnus-article-highlight))
216 ((tag . "Maybe Highlight")
217 (doc . "\
218 Highlight headers, signature, and buttons if `Visual' is turned on.
220 (type . const)
221 (default .
222 gnus-article-maybe-highlight))
223 ((tag . "Highlight Some")
224 (doc . "\
225 Highlight headers, signature, and buttons.
227 (type . const)
228 (default . gnus-article-highlight-some))
229 ((tag . "Highlight Headers")
230 (doc . "\
231 Highlight headers as specified by `Article Header Highlighting'.
233 (type . const)
234 (default .
235 gnus-article-highlight-headers))
236 ((tag . "Highlight Signature")
237 (doc . "\
238 Highlight the signature as specified by `Article Signature Face'.
240 (type . const)
241 (default .
242 gnus-article-highlight-signature))
243 ((tag . "Citation")
244 (doc . "\
245 Highlight the citations as specified by `Citation Faces'.
247 (type . const)
248 (default .
249 gnus-article-highlight-citation))
250 ((tag . "Hide")
251 (doc . "\
252 Hide unwanted headers, excess citation, and the signature.
254 (type . const)
255 (default . gnus-article-hide))
256 ((tag . "Hide Headers If Wanted")
257 (doc . "\
258 Hide headers, but allow user to display them with `t' or `v'.
260 (type . const)
261 (default .
262 gnus-article-hide-headers-if-wanted))
263 ((tag . "Hide Headers")
264 (doc . "\
265 Hide unwanted headers and possibly sort them as well.
266 Most likely you want to use `Hide Headers If Wanted' instead.
268 (type . const)
269 (default . gnus-article-hide-headers))
270 ((tag . "Hide Signature")
271 (doc . "\
272 Hide the signature.
274 (type . const)
275 (default . gnus-article-hide-signature))
276 ((tag . "Hide Excess Citations")
277 (doc . "\
278 Hide excess citation.
280 Excess is defined by `Citation Hide Percentage' and `Citation Hide Absolute'.
282 (type . const)
283 (default .
284 gnus-article-hide-citation-maybe))
285 ((tag . "Hide Citations")
286 (doc . "\
287 Hide all cited text.
289 (type . const)
290 (default . gnus-article-hide-citation))
291 ((tag . "Add Buttons")
292 (doc . "\
293 Make URL's into clickable buttons.
295 (type . const)
296 (default . gnus-article-add-buttons))
297 ((prompt . "Other")
298 (doc . "\
299 Name of Lisp function to call.
301 Push the `Filter' button to select one of the predefined filters.
303 (type . symbol)))))))
304 ((tag . "Article Button Face")
305 (doc . "\
306 Face used for highlighting buttons in the article buffer.
308 An article button is a piece of text that you can activate by pressing
309 `RET' or `mouse-2' above it.")
310 (name . gnus-article-button-face)
311 (default . bold)
312 (type . face))
313 ((tag . "Article Mouse Face")
314 (doc . "\
315 Face used for mouse highlighting in the article buffer.
317 Article buttons will be displayed in this face when the cursor is
318 above them.")
319 (name . gnus-article-mouse-face)
320 (default . highlight)
321 (type . face))
322 ((tag . "Article Signature Face")
323 (doc . "\
324 Face used for highlighting a signature in the article buffer.")
325 (name . gnus-signature-face)
326 (default . italic)
327 (type . face))
328 ((tag . "Article Header Highlighting")
329 (doc . "\
330 Controls highlighting of article header.
332 Below is a list of article header names, and the faces used for
333 displaying the name and content of the header. The `Header' field
334 should contain the name of the header. The field actually contains a
335 regular expression that should match the beginning of the header line,
336 but if you don't know what a regular expression is, just write the
337 name of the header. The second field is the `Name' field, which
338 determines how the the header name (i.e. the part of the header left
339 of the `:') is displayed. The third field is the `Content' field,
340 which determines how the content (i.e. the part of the header right of
341 the `:') is displayed.
343 If you leave the last `Header' field in the list empty, the `Name' and
344 `Content' fields will determine how headers not listed above are
345 displayed.
347 If you only want to change the display of the name part for a specific
348 header, specify `None' in the `Content' field. Similarly, specify
349 `None' in the `Name' field if you only want to leave the name part
350 alone.")
351 (name . gnus-header-face-alist)
352 (type . list)
353 (calculate
354 . (cond
355 ((not (eq gnus-display-type 'color))
356 '(("" bold italic)))
357 ((eq gnus-background-mode 'dark)
358 (list
359 (list "From" nil
360 (custom-face-lookup "light blue" nil nil t t nil))
361 (list "Subject" nil
362 (custom-face-lookup "pink" nil nil t t nil))
363 (list "Newsgroups:.*," nil
364 (custom-face-lookup "yellow" nil nil t t nil))
365 (list
367 (custom-face-lookup "cyan" nil nil t nil nil)
368 (custom-face-lookup "forestgreen" nil nil nil t
369 nil))))
371 (list
372 (list "From" nil
373 (custom-face-lookup "MidnightBlue" nil nil t t nil))
374 (list "Subject" nil
375 (custom-face-lookup "firebrick" nil nil t t nil))
376 (list "Newsgroups:.*," nil
377 (custom-face-lookup "indianred" nil nil t t nil))
378 (list ""
379 (custom-face-lookup
380 "DarkGreen" nil nil t nil nil)
381 (custom-face-lookup "DarkGreen" nil nil
382 nil t nil))))))
383 (data
384 ((type . repeat)
385 (header . nil)
386 (data
387 (type . list)
388 (compact . t)
389 (data
390 ((type . string)
391 (prompt . "Header")
392 (tag . "Header "))
393 "\n "
394 ((type . face)
395 (prompt . "Name")
396 (tag . "Name "))
397 "\n "
398 ((type . face)
399 (tag . "Content"))
400 "\n")))))
401 ((tag . "Attribution Face")
402 (doc . "\
403 Face used for attribution lines.
404 It is merged with the face for the cited text belonging to the attribution.")
405 (name . gnus-cite-attribution-face)
406 (default . underline)
407 (type . face))
408 ((tag . "Citation Faces")
409 (doc . "\
410 List of faces used for highlighting citations.
412 When there are citations from multiple articles in the same message,
413 Gnus will try to give each citation from each article its own face.
414 This should make it easier to see who wrote what.")
415 (name . gnus-cite-face-list)
416 (import . gnus-custom-import-cite-face-list)
417 (type . list)
418 (calculate . (cond ((not (eq gnus-display-type 'color))
419 '(italic))
420 ((eq gnus-background-mode 'dark)
421 (mapcar 'gnus-make-face
422 gnus-face-light-name-list))
424 (mapcar 'gnus-make-face
425 gnus-face-dark-name-list))))
426 (data
427 ((type . repeat)
428 (header . nil)
429 (data (type . face)
430 (tag . "Face")))))
431 ((tag . "Citation Hide Percentage")
432 (doc . "\
433 Only hide excess citation if above this percentage of the body.")
434 (name . gnus-cite-hide-percentage)
435 (default . 50)
436 (type . integer))
437 ((tag . "Citation Hide Absolute")
438 (doc . "\
439 Only hide excess citation if above this number of lines in the body.")
440 (name . gnus-cite-hide-absolute)
441 (default . 10)
442 (type . integer))
443 ((tag . "Summary Selected Face")
444 (doc . "\
445 Face used for highlighting the current article in the summary buffer.")
446 (name . gnus-summary-selected-face)
447 (default . underline)
448 (type . face))
449 ((tag . "Summary Line Highlighting")
450 (doc . "\
451 Controls the highlighting of summary buffer lines.
453 Below is a list of `Form'/`Face' pairs. When deciding how a a
454 particular summary line should be displayed, each form is
455 evaluated. The content of the face field after the first true form is
456 used. You can change how those summary lines are displayed, by
457 editing the face field.
459 It is also possible to change and add form fields, but currently that
460 requires an understanding of Lisp expressions. Hopefully this will
461 change in a future release. For now, you can use the following
462 variables in the Lisp expression:
464 score: The article's score
465 default: The default article score.
466 below: The score below which articles are automatically marked as read.
467 mark: The article's mark.")
468 (name . gnus-summary-highlight)
469 (type . list)
470 (calculate
471 . (cond
472 ((not (eq gnus-display-type 'color))
473 '(((> score default) . bold)
474 ((< score default) . italic)))
475 ((eq gnus-background-mode 'dark)
476 (list
477 (cons
478 '(= mark gnus-canceled-mark)
479 (custom-face-lookup "yellow" "black" nil
480 nil nil nil))
481 (cons '(and (> score default)
482 (or (= mark gnus-dormant-mark)
483 (= mark gnus-ticked-mark)))
484 (custom-face-lookup
485 "pink" nil nil t nil nil))
486 (cons '(and (< score default)
487 (or (= mark gnus-dormant-mark)
488 (= mark gnus-ticked-mark)))
489 (custom-face-lookup "pink" nil nil
490 nil t nil))
491 (cons '(or (= mark gnus-dormant-mark)
492 (= mark gnus-ticked-mark))
493 (custom-face-lookup
494 "pink" nil nil nil nil nil))
496 (cons
497 '(and (> score default) (= mark gnus-ancient-mark))
498 (custom-face-lookup "medium blue" nil nil t
499 nil nil))
500 (cons
501 '(and (< score default) (= mark gnus-ancient-mark))
502 (custom-face-lookup "SkyBlue" nil nil
503 nil t nil))
504 (cons
505 '(= mark gnus-ancient-mark)
506 (custom-face-lookup "SkyBlue" nil nil
507 nil nil nil))
508 (cons '(and (> score default) (= mark gnus-unread-mark))
509 (custom-face-lookup "white" nil nil t
510 nil nil))
511 (cons '(and (< score default) (= mark gnus-unread-mark))
512 (custom-face-lookup "white" nil nil
513 nil t nil))
514 (cons '(= mark gnus-unread-mark)
515 (custom-face-lookup
516 "white" nil nil nil nil nil))
518 (cons '(> score default) 'bold)
519 (cons '(< score default) 'italic)))
521 (list
522 (cons
523 '(= mark gnus-canceled-mark)
524 (custom-face-lookup
525 "yellow" "black" nil nil nil nil))
526 (cons '(and (> score default)
527 (or (= mark gnus-dormant-mark)
528 (= mark gnus-ticked-mark)))
529 (custom-face-lookup "firebrick" nil nil
530 t nil nil))
531 (cons '(and (< score default)
532 (or (= mark gnus-dormant-mark)
533 (= mark gnus-ticked-mark)))
534 (custom-face-lookup "firebrick" nil nil
535 nil t nil))
536 (cons
537 '(or (= mark gnus-dormant-mark)
538 (= mark gnus-ticked-mark))
539 (custom-face-lookup
540 "firebrick" nil nil nil nil nil))
542 (cons '(and (> score default) (= mark gnus-ancient-mark))
543 (custom-face-lookup "RoyalBlue" nil nil
544 t nil nil))
545 (cons '(and (< score default) (= mark gnus-ancient-mark))
546 (custom-face-lookup "RoyalBlue" nil nil
547 nil t nil))
548 (cons
549 '(= mark gnus-ancient-mark)
550 (custom-face-lookup
551 "RoyalBlue" nil nil nil nil nil))
553 (cons '(and (> score default) (/= mark gnus-unread-mark))
554 (custom-face-lookup "DarkGreen" nil nil
555 t nil nil))
556 (cons '(and (< score default) (/= mark gnus-unread-mark))
557 (custom-face-lookup "DarkGreen" nil nil
558 nil t nil))
559 (cons
560 '(/= mark gnus-unread-mark)
561 (custom-face-lookup "DarkGreen" nil nil
562 nil nil nil))
564 (cons '(> score default) 'bold)
565 (cons '(< score default) 'italic)))))
566 (data
567 ((type . repeat)
568 (header . nil)
569 (data (type . pair)
570 (compact . t)
571 (data ((type . sexp)
572 (width . 60)
573 (tag . "Form"))
574 "\n "
575 ((type . face)
576 (tag . "Face"))
577 "\n")))))
579 ((tag . "Group Line Highlighting")
580 (doc . "\
581 Controls the highlighting of group buffer lines.
583 Below is a list of `Form'/`Face' pairs. When deciding how a a
584 particular group line should be displayed, each form is
585 evaluated. The content of the face field after the first true form is
586 used. You can change how those group lines are displayed by
587 editing the face field.
589 It is also possible to change and add form fields, but currently that
590 requires an understanding of Lisp expressions. Hopefully this will
591 change in a future release. For now, you can use the following
592 variables in the Lisp expression:
594 group: The name of the group.
595 unread: The number of unread articles in the group.
596 method: The select method used.
597 mailp: Whether it's a mail group or not.
598 level: The level of the group.
599 score: The score of the group.
600 ticked: The number of ticked articles.")
601 (name . gnus-group-highlight)
602 (type . list)
603 (calculate
604 . (cond
605 ((not (eq gnus-display-type 'color))
606 '((mailp . bold)
607 ((= unread 0) . italic)))
608 ((eq gnus-background-mode 'dark)
609 `(((and (not mailp) (eq level 1)) .
610 ,(custom-face-lookup "PaleTurquoise" nil nil t))
611 ((and (not mailp) (eq level 2)) .
612 ,(custom-face-lookup "turquoise" nil nil t))
613 ((and (not mailp) (eq level 3)) .
614 ,(custom-face-lookup "MediumTurquoise" nil nil t))
615 ((and (not mailp) (>= level 4)) .
616 ,(custom-face-lookup "DarkTurquoise" nil nil t))
617 ((and mailp (eq level 1)) .
618 ,(custom-face-lookup "aquamarine1" nil nil t))
619 ((and mailp (eq level 2)) .
620 ,(custom-face-lookup "aquamarine2" nil nil t))
621 ((and mailp (eq level 3)) .
622 ,(custom-face-lookup "aquamarine3" nil nil t))
623 ((and mailp (>= level 4)) .
624 ,(custom-face-lookup "aquamarine4" nil nil t))
627 `(((and (not mailp) (<= level 3)) .
628 ,(custom-face-lookup "ForestGreen" nil nil t))
629 ((and (not mailp) (eq level 4)) .
630 ,(custom-face-lookup "DarkGreen" nil nil t))
631 ((and (not mailp) (eq level 5)) .
632 ,(custom-face-lookup "CadetBlue4" nil nil t))
633 ((and mailp (eq level 1)) .
634 ,(custom-face-lookup "DeepPink3" nil nil t))
635 ((and mailp (eq level 2)) .
636 ,(custom-face-lookup "HotPink3" nil nil t))
637 ((and mailp (eq level 3)) .
638 ,(custom-face-lookup "dark magenta" nil nil t))
639 ((and mailp (eq level 4)) .
640 ,(custom-face-lookup "DeepPink4" nil nil t))
641 ((and mailp (> level 4)) .
642 ,(custom-face-lookup "DarkOrchid4" nil nil t))
643 ))))
644 (data
645 ((type . repeat)
646 (header . nil)
647 (data (type . pair)
648 (compact . t)
649 (data ((type . sexp)
650 (width . 60)
651 (tag . "Form"))
652 "\n "
653 ((type . face)
654 (tag . "Face"))
655 "\n")))))
657 ;; Do not define `gnus-button-alist' before we have
658 ;; some `complexity' attribute so we can hide it from
659 ;; beginners.
660 )))))
662 (defun gnus-custom-import-cite-face-list (custom alist)
663 ;; Backward compatible grokking of light and dark.
664 (cond ((eq alist 'light)
665 (setq alist (mapcar 'gnus-make-face gnus-face-light-name-list)))
666 ((eq alist 'dark)
667 (setq alist (mapcar 'gnus-make-face gnus-face-dark-name-list))))
668 (funcall (custom-super custom 'import) custom alist))
670 (provide 'gnus-cus)
672 ;;; gnus-cus.el ends here