1 ;;; gnus.el --- a newsreader for GNU Emacs
3 ;; Copyright (C) 1987, 1988, 1989, 1990, 1993, 1994, 1995, 1996, 1997,
4 ;; 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
6 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; Keywords: news, mail
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval '(run-hooks 'gnus-load-hook))
33 (eval-when-compile (require 'cl))
37 (autoload 'message-y-or-n-p "message" nil nil 'macro)
40 "The coffee-brewing, all singing, all dancing, kitchen sink newsreader."
44 (defgroup gnus-format nil
45 "Dealing with formatting issues."
48 (defgroup gnus-charset nil
49 "Group character set issues."
50 :link '(custom-manual "(gnus)Charsets")
54 (defgroup gnus-cache nil
56 :link '(custom-manual "(gnus)Article Caching")
59 (defgroup gnus-registry nil
63 (defgroup gnus-start nil
64 "Starting your favorite newsreader."
67 (defgroup gnus-start-server nil
68 "Server options at startup."
71 ;; These belong to gnus-group.el.
72 (defgroup gnus-group nil
74 :link '(custom-manual "(gnus)Group Buffer")
77 (defgroup gnus-group-foreign nil
79 :link '(custom-manual "(gnus)Foreign Groups")
82 (defgroup gnus-group-new nil
83 "Automatic subscription of new groups."
86 (defgroup gnus-group-levels nil
88 :link '(custom-manual "(gnus)Group Levels")
91 (defgroup gnus-group-select nil
93 :link '(custom-manual "(gnus)Selecting a Group")
96 (defgroup gnus-group-listing nil
97 "Showing slices of the group list."
98 :link '(custom-manual "(gnus)Listing Groups")
101 (defgroup gnus-group-visual nil
102 "Sorting the group buffer."
103 :link '(custom-manual "(gnus)Group Buffer Format")
107 (defgroup gnus-group-various nil
108 "Various group options."
109 :link '(custom-manual "(gnus)Scanning New Messages")
112 ;; These belong to gnus-sum.el.
113 (defgroup gnus-summary nil
115 :link '(custom-manual "(gnus)Summary Buffer")
118 (defgroup gnus-summary-exit nil
119 "Leaving summary buffers."
120 :link '(custom-manual "(gnus)Exiting the Summary Buffer")
121 :group 'gnus-summary)
123 (defgroup gnus-summary-marks nil
124 "Marks used in summary buffers."
125 :link '(custom-manual "(gnus)Marking Articles")
126 :group 'gnus-summary)
128 (defgroup gnus-thread nil
129 "Ordering articles according to replies."
130 :link '(custom-manual "(gnus)Threading")
131 :group 'gnus-summary)
133 (defgroup gnus-summary-format nil
134 "Formatting of the summary buffer."
135 :link '(custom-manual "(gnus)Summary Buffer Format")
136 :group 'gnus-summary)
138 (defgroup gnus-summary-choose nil
140 :link '(custom-manual "(gnus)Choosing Articles")
141 :group 'gnus-summary)
143 (defgroup gnus-summary-maneuvering nil
144 "Summary movement commands."
145 :link '(custom-manual "(gnus)Summary Maneuvering")
146 :group 'gnus-summary)
148 (defgroup gnus-picon nil
149 "Show pictures of people, domains, and newsgroups."
152 (defgroup gnus-summary-mail nil
153 "Mail group commands."
154 :link '(custom-manual "(gnus)Mail Group Commands")
155 :group 'gnus-summary)
157 (defgroup gnus-summary-sort nil
158 "Sorting the summary buffer."
159 :link '(custom-manual "(gnus)Sorting the Summary Buffer")
160 :group 'gnus-summary)
162 (defgroup gnus-summary-visual nil
163 "Highlighting and menus in the summary buffer."
164 :link '(custom-manual "(gnus)Summary Highlighting")
166 :group 'gnus-summary)
168 (defgroup gnus-summary-various nil
169 "Various summary buffer options."
170 :link '(custom-manual "(gnus)Various Summary Stuff")
171 :group 'gnus-summary)
173 (defgroup gnus-summary-pick nil
174 "Pick mode in the summary buffer."
175 :link '(custom-manual "(gnus)Pick and Read")
177 :group 'gnus-summary)
179 (defgroup gnus-summary-tree nil
180 "Tree display of threads in the summary buffer."
181 :link '(custom-manual "(gnus)Tree Display")
183 :group 'gnus-summary)
185 ;; Belongs to gnus-uu.el
186 (defgroup gnus-extract-view nil
187 "Viewing extracted files."
188 :link '(custom-manual "(gnus)Viewing Files")
189 :group 'gnus-extract)
191 ;; Belongs to gnus-score.el
192 (defgroup gnus-score nil
193 "Score and kill file handling."
196 (defgroup gnus-score-kill nil
200 (defgroup gnus-score-adapt nil
201 "Adaptive score files."
204 (defgroup gnus-score-default nil
205 "Default values for score files."
208 (defgroup gnus-score-expire nil
209 "Expiring score rules."
212 (defgroup gnus-score-decay nil
213 "Decaying score rules."
216 (defgroup gnus-score-files nil
217 "Score and kill file names."
221 (defgroup gnus-score-various nil
222 "Various scoring and killing options."
226 (defgroup gnus-visual nil
227 "Options controlling the visual fluff."
231 (defgroup gnus-agent nil
232 "Offline support for Gnus."
235 (defgroup gnus-files nil
236 "Files used by Gnus."
239 (defgroup gnus-dribble-file nil
241 :link '(custom-manual "(gnus)Auto Save")
244 (defgroup gnus-newsrc nil
245 "Storing Gnus state."
248 (defgroup gnus-server nil
249 "Options related to newsservers and other servers used by Gnus."
252 (defgroup gnus-server-visual nil
253 "Highlighting and menus in the server buffer."
257 (defgroup gnus-message '((message custom-group))
258 "Composing replies and followups in Gnus."
261 (defgroup gnus-meta nil
262 "Meta variables controlling major portions of Gnus.
263 In general, modifying these variables does not take affect until Gnus
264 is restarted, and sometimes reloaded."
267 (defgroup gnus-various nil
268 "Other Gnus options."
269 :link '(custom-manual "(gnus)Various Various")
272 (defgroup gnus-mime nil
273 "Variables for controlling the Gnus MIME interface."
276 (defgroup gnus-exit nil
278 :link '(custom-manual "(gnus)Exiting Gnus")
281 (defgroup gnus-fun nil
282 "Frivolous Gnus extensions."
283 :link '(custom-manual "(gnus)Exiting Gnus")
286 (defconst gnus-version-number "0.3"
287 "Version number for this version of Gnus.")
289 (defconst gnus-version (format "No Gnus v%s" gnus-version-number)
290 "Version string for this version of Gnus.")
292 (defcustom gnus-inhibit-startup-message nil
293 "If non-nil, the startup message will not be displayed.
294 This variable is used before `.gnus.el' is loaded, so it should
295 be set in `.emacs' instead."
299 (defcustom gnus-play-startup-jingle nil
300 "If non-nil, play the Gnus jingle at startup."
304 (unless (fboundp 'gnus-group-remove-excess-properties)
305 (defalias 'gnus-group-remove-excess-properties 'ignore))
307 (unless (featurep 'gnus-xmas)
308 (defalias 'gnus-make-overlay 'make-overlay)
309 (defalias 'gnus-delete-overlay 'delete-overlay)
310 (defalias 'gnus-overlay-put 'overlay-put)
311 (defalias 'gnus-move-overlay 'move-overlay)
312 (defalias 'gnus-overlay-buffer 'overlay-buffer)
313 (defalias 'gnus-overlay-start 'overlay-start)
314 (defalias 'gnus-overlay-end 'overlay-end)
315 (defalias 'gnus-extent-detached-p 'ignore)
316 (defalias 'gnus-extent-start-open 'ignore)
317 (defalias 'gnus-mail-strip-quoted-names 'mail-strip-quoted-names)
318 (defalias 'gnus-character-to-event 'identity)
319 (defalias 'gnus-assq-delete-all 'assq-delete-all)
320 (defalias 'gnus-add-text-properties 'add-text-properties)
321 (defalias 'gnus-put-text-property 'put-text-property)
322 (defvar gnus-mode-line-image-cache t)
323 (if (fboundp 'find-image)
324 (defun gnus-mode-line-buffer-identification (line)
325 (let ((str (car-safe line)))
326 (if (and (stringp str)
327 (string-match "^Gnus:" str))
328 (progn (add-text-properties
331 (if (eq t gnus-mode-line-image-cache)
332 (setq gnus-mode-line-image-cache
334 '((:type xpm :file "gnus-pointer.xpm"
336 (:type xbm :file "gnus-pointer.xbm"
338 gnus-mode-line-image-cache)
341 gnus-version (gnus-emacs-version)))
345 (defalias 'gnus-mode-line-buffer-identification 'identity))
346 (defalias 'gnus-characterp 'numberp)
347 (defalias 'gnus-deactivate-mark 'deactivate-mark)
348 (defalias 'gnus-window-edges 'window-edges)
349 (defalias 'gnus-key-press-event-p 'numberp)
350 ;;(defalias 'gnus-decode-rfc1522 'ignore)
353 ;; We define these group faces here to avoid the display
354 ;; update forced when creating new faces.
356 (defface gnus-group-news-1-face
359 (:foreground "PaleTurquoise" :bold t))
362 (:foreground "ForestGreen" :bold t))
365 "Level 1 newsgroup face.")
367 (defface gnus-group-news-1-empty-face
370 (:foreground "PaleTurquoise"))
373 (:foreground "ForestGreen"))
376 "Level 1 empty newsgroup face.")
378 (defface gnus-group-news-2-face
381 (:foreground "turquoise" :bold t))
384 (:foreground "CadetBlue4" :bold t))
387 "Level 2 newsgroup face.")
389 (defface gnus-group-news-2-empty-face
392 (:foreground "turquoise"))
395 (:foreground "CadetBlue4"))
398 "Level 2 empty newsgroup face.")
400 (defface gnus-group-news-3-face
409 "Level 3 newsgroup face.")
411 (defface gnus-group-news-3-empty-face
420 "Level 3 empty newsgroup face.")
422 (defface gnus-group-news-4-face
431 "Level 4 newsgroup face.")
433 (defface gnus-group-news-4-empty-face
442 "Level 4 empty newsgroup face.")
444 (defface gnus-group-news-5-face
453 "Level 5 newsgroup face.")
455 (defface gnus-group-news-5-empty-face
464 "Level 5 empty newsgroup face.")
466 (defface gnus-group-news-6-face
475 "Level 6 newsgroup face.")
477 (defface gnus-group-news-6-empty-face
486 "Level 6 empty newsgroup face.")
488 (defface gnus-group-news-low-face
491 (:foreground "DarkTurquoise" :bold t))
494 (:foreground "DarkGreen" :bold t))
497 "Low level newsgroup face.")
499 (defface gnus-group-news-low-empty-face
502 (:foreground "DarkTurquoise"))
505 (:foreground "DarkGreen"))
508 "Low level empty newsgroup face.")
510 (defface gnus-group-mail-1-face
513 (:foreground "aquamarine1" :bold t))
516 (:foreground "DeepPink3" :bold t))
519 "Level 1 mailgroup face.")
521 (defface gnus-group-mail-1-empty-face
524 (:foreground "aquamarine1"))
527 (:foreground "DeepPink3"))
529 (:italic t :bold t)))
530 "Level 1 empty mailgroup face.")
532 (defface gnus-group-mail-2-face
535 (:foreground "aquamarine2" :bold t))
538 (:foreground "HotPink3" :bold t))
541 "Level 2 mailgroup face.")
543 (defface gnus-group-mail-2-empty-face
546 (:foreground "aquamarine2"))
549 (:foreground "HotPink3"))
552 "Level 2 empty mailgroup face.")
554 (defface gnus-group-mail-3-face
557 (:foreground "aquamarine3" :bold t))
560 (:foreground "magenta4" :bold t))
563 "Level 3 mailgroup face.")
565 (defface gnus-group-mail-3-empty-face
568 (:foreground "aquamarine3"))
571 (:foreground "magenta4"))
574 "Level 3 empty mailgroup face.")
576 (defface gnus-group-mail-low-face
579 (:foreground "aquamarine4" :bold t))
582 (:foreground "DeepPink4" :bold t))
585 "Low level mailgroup face.")
587 (defface gnus-group-mail-low-empty-face
590 (:foreground "aquamarine4"))
593 (:foreground "DeepPink4"))
596 "Low level empty mailgroup face.")
598 ;; Summary mode faces.
600 (defface gnus-summary-selected-face '((t
602 "Face used for selected articles.")
604 (defface gnus-summary-cancelled-face
606 (:foreground "yellow" :background "black")))
607 "Face used for cancelled articles.")
609 (defface gnus-summary-high-ticked-face
612 (:foreground "pink" :bold t))
615 (:foreground "firebrick" :bold t))
618 "Face used for high interest ticked articles.")
620 (defface gnus-summary-low-ticked-face
623 (:foreground "pink" :italic t))
626 (:foreground "firebrick" :italic t))
629 "Face used for low interest ticked articles.")
631 (defface gnus-summary-normal-ticked-face
634 (:foreground "pink"))
637 (:foreground "firebrick"))
640 "Face used for normal interest ticked articles.")
642 (defface gnus-summary-high-ancient-face
645 (:foreground "SkyBlue" :bold t))
648 (:foreground "RoyalBlue" :bold t))
651 "Face used for high interest ancient articles.")
653 (defface gnus-summary-low-ancient-face
656 (:foreground "SkyBlue" :italic t))
659 (:foreground "RoyalBlue" :italic t))
662 "Face used for low interest ancient articles.")
664 (defface gnus-summary-normal-ancient-face
667 (:foreground "SkyBlue"))
670 (:foreground "RoyalBlue"))
673 "Face used for normal interest ancient articles.")
675 (defface gnus-summary-high-undownloaded-face
678 (:bold t :foreground "cyan4"))
679 (((class color) (background dark))
680 (:bold t :foreground "LightGray"))
681 (t (:inverse-video t :bold t)))
682 "Face used for high interest uncached articles.")
684 (defface gnus-summary-low-undownloaded-face
687 (:italic t :foreground "cyan4" :bold nil))
688 (((class color) (background dark))
689 (:italic t :foreground "LightGray" :bold nil))
690 (t (:inverse-video t :italic t)))
691 "Face used for low interest uncached articles.")
693 (defface gnus-summary-normal-undownloaded-face
696 (:foreground "cyan4" :bold nil))
697 (((class color) (background dark))
698 (:foreground "LightGray" :bold nil))
699 (t (:inverse-video t)))
700 "Face used for normal interest uncached articles.")
702 (defface gnus-summary-high-unread-face
705 "Face used for high interest unread articles.")
707 (defface gnus-summary-low-unread-face
710 "Face used for low interest unread articles.")
712 (defface gnus-summary-normal-unread-face
715 "Face used for normal interest unread articles.")
717 (defface gnus-summary-high-read-face
720 (:foreground "PaleGreen"
724 (:foreground "DarkGreen"
728 "Face used for high interest read articles.")
730 (defface gnus-summary-low-read-face
733 (:foreground "PaleGreen"
737 (:foreground "DarkGreen"
741 "Face used for low interest read articles.")
743 (defface gnus-summary-normal-read-face
746 (:foreground "PaleGreen"))
749 (:foreground "DarkGreen"))
752 "Face used for normal interest read articles.")
759 (defvar gnus-buffers nil)
761 (defun gnus-get-buffer-create (name)
762 "Do the same as `get-buffer-create', but store the created buffer."
763 (or (get-buffer name)
764 (car (push (get-buffer-create name) gnus-buffers))))
766 (defun gnus-add-buffer ()
767 "Add the current buffer to the list of Gnus buffers."
768 (push (current-buffer) gnus-buffers))
770 (defmacro gnus-kill-buffer (buffer)
771 "Kill BUFFER and remove from the list of Gnus buffers."
772 `(let ((buf ,buffer))
773 (when (gnus-buffer-exists-p buf)
774 (setq gnus-buffers (delete (get-buffer buf) gnus-buffers))
777 (defun gnus-buffers ()
778 "Return a list of live Gnus buffers."
779 (while (and gnus-buffers
780 (not (buffer-name (car gnus-buffers))))
782 (let ((buffers gnus-buffers))
784 (if (buffer-name (cadr buffers))
786 (setcdr buffers (cddr buffers)))))
791 (defvar gnus-group-buffer "*Group*")
794 (autoload 'gnus-play-jingle "gnus-audio"))
796 (defface gnus-splash-face
799 (:foreground "#888888"))
802 (:foreground "#888888"))
805 "Face for the splash screen.")
807 (defun gnus-splash ()
809 (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
810 (let ((buffer-read-only nil))
812 (unless gnus-inhibit-startup-message
813 (gnus-group-startup-message)
815 (when gnus-play-startup-jingle
816 (gnus-play-jingle))))))
818 (defun gnus-indent-rigidly (start end arg)
819 "Indent rigidly using only spaces and no tabs."
822 (narrow-to-region start end)
824 (indent-rigidly start end arg)
825 ;; We translate tabs into spaces -- not everybody uses
826 ;; an 8-character tab.
827 (goto-char (point-min))
828 (while (search-forward "\t" nil t)
829 (replace-match " " t t))))))
831 (defvar gnus-simple-splash nil)
833 ;;(format "%02x%02x%02x" 114 66 20) "724214"
835 (defvar gnus-logo-color-alist
836 '((flame "#cc3300" "#ff2200")
837 (pine "#c0cc93" "#f8ffb8")
838 (moss "#a1cc93" "#d2ffb8")
839 (irish "#04cc90" "#05ff97")
840 (sky "#049acc" "#05deff")
841 (tin "#6886cc" "#82b6ff")
842 (velvet "#7c68cc" "#8c82ff")
843 (grape "#b264cc" "#cf7df")
844 (labia "#cc64c2" "#fd7dff")
845 (berry "#cc6485" "#ff7db5")
846 (dino "#724214" "#1e3f03")
847 (oort "#cccccc" "#888888")
848 (storm "#666699" "#99ccff")
849 (pdino "#9999cc" "#99ccff")
850 (purp "#9999cc" "#666699")
851 (no "#ff0000" "#ffff00")
852 (neutral "#b4b4b4" "#878787")
853 (september "#bf9900" "#ffcc00"))
854 "Color alist used for the Gnus logo.")
856 (defcustom gnus-logo-color-style 'no
857 "*Color styles used for the Gnus logo."
858 :type `(choice ,@(mapcar (lambda (elem) (list 'const (car elem)))
859 gnus-logo-color-alist))
862 (defvar gnus-logo-colors
863 (cdr (assq gnus-logo-color-style gnus-logo-color-alist))
864 "Colors used for the Gnus logo.")
866 (defun gnus-group-startup-message (&optional x y)
867 "Insert startup message in current buffer."
868 ;; Insert the message.
872 (fboundp 'find-image)
874 (let* ((data-directory (nnheader-find-etc-directory "gnus"))
876 `((:type xpm :file "gnus.xpm"
878 (("thing" . ,(car gnus-logo-colors))
879 ("shadow" . ,(cadr gnus-logo-colors))
881 ("background" . ,(face-background 'default))))
882 (:type pbm :file "gnus.pbm"
883 ;; Account for the pbm's blackground.
884 :background ,(face-foreground 'gnus-splash-face)
885 :foreground ,(face-background 'default))
886 (:type xbm :file "gnus.xbm"
887 ;; Account for the xbm's blackground.
888 :background ,(face-foreground 'gnus-splash-face)
889 :foreground ,(face-background 'default))))))
891 (let ((size (image-size image)))
892 (insert-char ?\n (max 0 (round (- (window-height)
893 (or y (cdr size)) 1) 2)))
894 (insert-char ?\ (max 0 (round (- (window-width)
895 (or x (car size))) 2)))
896 (insert-image image))
897 (setq gnus-simple-splash nil)
903 _ ___ __ ___ __ _ ___
923 (gnus-indent-rigidly (point-min) (point-max)
924 (/ (max (- (window-width) (or x 46)) 0) 2))
925 (goto-char (point-min))
927 (let* ((pheight (count-lines (point-min) (point-max)))
928 (wheight (window-height))
929 (rest (- wheight pheight)))
930 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
932 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)
933 (setq gnus-simple-splash t)))
934 (goto-char (point-min))
935 (setq mode-line-buffer-identification (concat " " gnus-version))
936 (set-buffer-modified-p t))
939 (let ((command (format "%s" this-command)))
940 (when (string-match "gnus" command)
941 (if (string-match "gnus-other-frame" command)
942 (gnus-get-buffer-create gnus-group-buffer)
950 (defcustom gnus-parameters nil
951 "Alist of group parameters.
954 ((\"mail\\\\..*\" (gnus-show-threads nil)
955 (gnus-use-scoring nil)
956 (gnus-summary-line-format
957 \"%U%R%z%I%(%[%d:%ub%-23,23f%]%) %s\\n\")
960 (\"mail\\\\.me\" (gnus-use-scoring t))
961 (\"list\\\\..*\" (total-expire . t)
962 (broken-reply-to . t)))"
964 :group 'gnus-group-various
965 :type '(repeat (cons regexp
968 (defvar gnus-group-parameters-more nil)
970 (defmacro gnus-define-group-parameter (param &rest rest)
971 "Define a group parameter PARAM.
972 REST is a plist of following:
973 :type One of `bool', `list' or nil.
974 :function The name of the function.
975 :function-document The documentation of the function.
976 :parameter-type The type for customizing the parameter.
977 :parameter-document The documentation for the parameter.
978 :variable The name of the variable.
979 :variable-document The documentation for the variable.
980 :variable-group The group for customizing the variable.
981 :variable-type The type for customizing the variable.
982 :variable-default The default value of the variable."
983 (let* ((type (plist-get rest :type))
984 (parameter-type (plist-get rest :parameter-type))
985 (parameter-document (plist-get rest :parameter-document))
986 (function (or (plist-get rest :function)
987 (intern (format "gnus-parameter-%s" param))))
988 (function-document (or (plist-get rest :function-document) ""))
989 (variable (or (plist-get rest :variable)
990 (intern (format "gnus-parameter-%s-alist" param))))
991 (variable-document (or (plist-get rest :variable-document) ""))
992 (variable-group (plist-get rest :variable-group))
993 (variable-type (or (plist-get rest :variable-type)
995 (list (regexp :tag "Group")
996 ,(car (cdr parameter-type)))))))
997 (variable-default (plist-get rest :variable-default)))
1000 `(defcustom ,variable ,variable-default