* gnus-picon.el: Don't require `mail-parse'.
[elisp/gnus.git-] / lisp / gnus.el
1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987, 1988, 1989, 1990, 1993, 1994, 1995, 1996, 
3 ;;        1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
4
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;;      Tatsuya Ichikawa <t-ichi@po.shiojiri.ne.jp>
8 ;;      Yoshiki Hayashi <t90553@mail.ecc.u-tokyo.ac.jp>
9 ;; Keywords: news, mail
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29
30 ;;; Code:
31
32 (eval '(run-hooks 'gnus-load-hook))
33
34 (eval-when-compile (require 'cl))
35 (eval-when-compile (require 'static))
36
37 (require 'wid-edit)
38
39 (require 'gnus-vers)
40
41 (defgroup gnus nil
42   "The coffee-brewing, all singing, all dancing, kitchen sink newsreader."
43   :group 'news
44   :group 'mail)
45
46 (defgroup gnus-format nil
47   "Dealing with formatting issues."
48   :group 'news
49   :group 'mail)
50
51 (defgroup gnus-charset nil
52   "Group character set issues."
53   :link '(custom-manual "(gnus)Charsets")
54   :version "21.1"
55   :group 'gnus)
56
57 (defgroup gnus-cache nil
58   "Cache interface."
59   :group 'gnus)
60
61 (defgroup gnus-start nil
62   "Starting your favorite newsreader."
63   :group 'gnus)
64
65 (defgroup gnus-start-server nil
66   "Server options at startup."
67   :group 'gnus-start)
68
69 ;; These belong to gnus-group.el.
70 (defgroup gnus-group nil
71   "Group buffers."
72   :link '(custom-manual "(gnus)The Group Buffer")
73   :group 'gnus)
74
75 (defgroup gnus-group-foreign nil
76   "Foreign groups."
77   :link '(custom-manual "(gnus)Foreign Groups")
78   :group 'gnus-group)
79
80 (defgroup gnus-group-new nil
81   "Automatic subscription of new groups."
82   :group 'gnus-group)
83
84 (defgroup gnus-group-levels nil
85   "Group levels."
86   :link '(custom-manual "(gnus)Group Levels")
87   :group 'gnus-group)
88
89 (defgroup gnus-group-select nil
90   "Selecting a Group."
91   :link '(custom-manual "(gnus)Selecting a Group")
92   :group 'gnus-group)
93
94 (defgroup gnus-group-listing nil
95   "Showing slices of the group list."
96   :link '(custom-manual "(gnus)Listing Groups")
97   :group 'gnus-group)
98
99 (defgroup gnus-group-visual nil
100   "Sorting the group buffer."
101   :link '(custom-manual "(gnus)Group Buffer Format")
102   :group 'gnus-group
103   :group 'gnus-visual)
104
105 (defgroup gnus-group-various nil
106   "Various group options."
107   :link '(custom-manual "(gnus)Scanning New Messages")
108   :group 'gnus-group)
109
110 ;; These belong to gnus-sum.el.
111 (defgroup gnus-summary nil
112   "Summary buffers."
113   :link '(custom-manual "(gnus)The Summary Buffer")
114   :group 'gnus)
115
116 (defgroup gnus-summary-exit nil
117   "Leaving summary buffers."
118   :link '(custom-manual "(gnus)Exiting the Summary Buffer")
119   :group 'gnus-summary)
120
121 (defgroup gnus-summary-marks nil
122   "Marks used in summary buffers."
123   :link '(custom-manual "(gnus)Marking Articles")
124   :group 'gnus-summary)
125
126 (defgroup gnus-thread nil
127   "Ordering articles according to replies."
128   :link '(custom-manual "(gnus)Threading")
129   :group 'gnus-summary)
130
131 (defgroup gnus-summary-format nil
132   "Formatting of the summary buffer."
133   :link '(custom-manual "(gnus)Summary Buffer Format")
134   :group 'gnus-summary)
135
136 (defgroup gnus-summary-choose nil
137   "Choosing Articles."
138   :link '(custom-manual "(gnus)Choosing Articles")
139   :group 'gnus-summary)
140
141 (defgroup gnus-summary-maneuvering nil
142   "Summary movement commands."
143   :link '(custom-manual "(gnus)Summary Maneuvering")
144   :group 'gnus-summary)
145
146 (defgroup gnus-summary-mail nil
147   "Mail group commands."
148   :link '(custom-manual "(gnus)Mail Group Commands")
149   :group 'gnus-summary)
150
151 (defgroup gnus-summary-sort nil
152   "Sorting the summary buffer."
153   :link '(custom-manual "(gnus)Sorting")
154   :group 'gnus-summary)
155
156 (defgroup gnus-summary-visual nil
157   "Highlighting and menus in the summary buffer."
158   :link '(custom-manual "(gnus)Summary Highlighting")
159   :group 'gnus-visual
160   :group 'gnus-summary)
161
162 (defgroup gnus-summary-various nil
163   "Various summary buffer options."
164   :link '(custom-manual "(gnus)Various Summary Stuff")
165   :group 'gnus-summary)
166
167 (defgroup gnus-summary-pick nil
168   "Pick mode in the summary buffer."
169   :link '(custom-manual "(gnus)Pick and Read")
170   :prefix "gnus-pick-"
171   :group 'gnus-summary)
172
173 (defgroup gnus-summary-tree nil
174   "Tree display of threads in the summary buffer."
175   :link '(custom-manual "(gnus)Tree Display")
176   :prefix "gnus-tree-"
177   :group 'gnus-summary)
178
179 ;; Belongs to gnus-uu.el
180 (defgroup gnus-extract-view nil
181   "Viewing extracted files."
182   :link '(custom-manual "(gnus)Viewing Files")
183   :group 'gnus-extract)
184
185 ;; Belongs to gnus-score.el
186 (defgroup gnus-score nil
187   "Score and kill file handling."
188   :group 'gnus)
189
190 (defgroup gnus-score-kill nil
191   "Kill files."
192   :group 'gnus-score)
193
194 (defgroup gnus-score-adapt nil
195   "Adaptive score files."
196   :group 'gnus-score)
197
198 (defgroup gnus-score-default nil
199   "Default values for score files."
200   :group 'gnus-score)
201
202 (defgroup gnus-score-expire nil
203   "Expiring score rules."
204   :group 'gnus-score)
205
206 (defgroup gnus-score-decay nil
207   "Decaying score rules."
208   :group 'gnus-score)
209
210 (defgroup gnus-score-files nil
211   "Score and kill file names."
212   :group 'gnus-score
213   :group 'gnus-files)
214
215 (defgroup gnus-score-various nil
216   "Various scoring and killing options."
217   :group 'gnus-score)
218
219 ;; Other
220 (defgroup gnus-visual nil
221   "Options controling the visual fluff."
222   :group 'gnus
223   :group 'faces)
224
225 (defgroup gnus-agent nil
226   "Offline support for Gnus."
227   :group 'gnus)
228
229 (defgroup gnus-files nil
230   "Files used by Gnus."
231   :group 'gnus)
232
233 (defgroup gnus-dribble-file nil
234   "Auto save file."
235   :link '(custom-manual "(gnus)Auto Save")
236   :group 'gnus-files)
237
238 (defgroup gnus-newsrc nil
239   "Storing Gnus state."
240   :group 'gnus-files)
241
242 (defgroup gnus-server nil
243   "Options related to newsservers and other servers used by Gnus."
244   :group 'gnus)
245
246 (defgroup gnus-server-visual nil
247   "Highlighting and menus in the server buffer."
248   :group 'gnus-visual
249   :group 'gnus-server)
250
251 (defgroup gnus-message '((message custom-group))
252   "Composing replies and followups in Gnus."
253   :group 'gnus)
254
255 (defgroup gnus-meta nil
256   "Meta variables controling major portions of Gnus.
257 In general, modifying these variables does not take affect until Gnus
258 is restarted, and sometimes reloaded."
259   :group 'gnus)
260
261 (defgroup gnus-various nil
262   "Other Gnus options."
263   :link '(custom-manual "(gnus)Various Various")
264   :group 'gnus)
265
266 (defgroup gnus-mime nil
267   "Variables for controlling the Gnus MIME interface."
268   :group 'gnus)
269
270 (defgroup gnus-exit nil
271   "Exiting gnus."
272   :link '(custom-manual "(gnus)Exiting Gnus")
273   :group 'gnus)
274
275 (defcustom gnus-inhibit-startup-message nil
276   "If non-nil, the startup message will not be displayed.
277 This variable is used before `.gnus.el' is loaded, so it should
278 be set in `.emacs' instead."
279   :group 'gnus-start
280   :type 'boolean)
281
282 (defcustom gnus-play-startup-jingle nil
283   "If non-nil, play the Gnus jingle at startup."
284   :group 'gnus-start
285   :type 'boolean)
286
287 (unless (fboundp 'gnus-group-remove-excess-properties)
288   (defalias 'gnus-group-remove-excess-properties 'ignore))
289
290 (unless (fboundp 'gnus-set-text-properties)
291   (defalias 'gnus-set-text-properties 'set-text-properties))
292
293 (unless (featurep 'gnus-xmas)
294   (defalias 'gnus-make-overlay 'make-overlay)
295   (defalias 'gnus-delete-overlay 'delete-overlay)
296   (defalias 'gnus-overlay-put 'overlay-put)
297   (defalias 'gnus-move-overlay 'move-overlay)
298   (defalias 'gnus-overlay-buffer 'overlay-buffer)
299   (defalias 'gnus-overlay-start 'overlay-start)
300   (defalias 'gnus-overlay-end 'overlay-end)
301   (defalias 'gnus-extent-detached-p 'ignore)
302   (defalias 'gnus-extent-start-open 'ignore)
303   (defalias 'gnus-appt-select-lowest-window 'appt-select-lowest-window)
304   (defalias 'gnus-mail-strip-quoted-names 'mail-strip-quoted-names)
305   (defalias 'gnus-character-to-event 'identity)
306   (defalias 'gnus-add-text-properties 'add-text-properties)
307   (defalias 'gnus-put-text-property 'put-text-property)
308   (defvar gnus-mode-line-image-cache t)
309   (if (fboundp 'find-image)
310       (defun gnus-mode-line-buffer-identification (line)
311         (let ((str (car-safe line)))
312           (if (and (stringp str)
313                    (string-match "^Gnus:" str))
314               (progn (add-text-properties
315                       0 5
316                       (list 'display
317                             (if (eq t gnus-mode-line-image-cache)
318                                 (setq gnus-mode-line-image-cache
319                                       (find-image
320                                        '((:type xpm :file "gnus-pointer.xpm"
321                                                 :ascent center)
322                                          (:type xbm :file "gnus-pointer.xbm"
323                                                 :ascent center))))
324                               gnus-mode-line-image-cache)
325                             'help-echo "This is Gnus")
326                       str)
327                      (list str))
328             line)))
329     (defalias 'gnus-mode-line-buffer-identification 'identity))
330   (defalias 'gnus-characterp 'numberp)
331   (defalias 'gnus-deactivate-mark 'deactivate-mark)
332   (defalias 'gnus-window-edges 'window-edges)
333   (defalias 'gnus-key-press-event-p 'numberp)
334   ;;(defalias 'gnus-decode-rfc1522 'ignore)
335   )
336
337 ;; We define these group faces here to avoid the display
338 ;; update forced when creating new faces.
339
340 (defface gnus-group-news-1-face
341   '((((class color)
342       (background dark))
343      (:foreground "PaleTurquoise" :bold t))
344     (((class color)
345       (background light))
346      (:foreground "ForestGreen" :bold t))
347     (t
348      ()))
349   "Level 1 newsgroup face.")
350
351 (defface gnus-group-news-1-empty-face
352   '((((class color)
353       (background dark))
354      (:foreground "PaleTurquoise"))
355     (((class color)
356       (background light))
357      (:foreground "ForestGreen"))
358     (t
359      ()))
360   "Level 1 empty newsgroup face.")
361
362 (defface gnus-group-news-2-face
363   '((((class color)
364       (background dark))
365      (:foreground "turquoise" :bold t))
366     (((class color)
367       (background light))
368      (:foreground "CadetBlue4" :bold t))
369     (t
370      ()))
371   "Level 2 newsgroup face.")
372
373 (defface gnus-group-news-2-empty-face
374   '((((class color)
375       (background dark))
376      (:foreground "turquoise"))
377     (((class color)
378       (background light))
379      (:foreground "CadetBlue4"))
380     (t
381      ()))
382   "Level 2 empty newsgroup face.")
383
384 (defface gnus-group-news-3-face
385   '((((class color)
386       (background dark))
387      (:bold t))
388     (((class color)
389       (background light))
390      (:bold t))
391     (t
392      ()))
393   "Level 3 newsgroup face.")
394
395 (defface gnus-group-news-3-empty-face
396   '((((class color)
397       (background dark))
398      ())
399     (((class color)
400       (background light))
401      ())
402     (t
403      ()))
404   "Level 3 empty newsgroup face.")
405
406 (defface gnus-group-news-4-face
407   '((((class color)
408       (background dark))
409      (:bold t))
410     (((class color)
411       (background light))
412      (:bold t))
413     (t
414      ()))
415   "Level 4 newsgroup face.")
416
417 (defface gnus-group-news-4-empty-face
418   '((((class color)
419       (background dark))
420      ())
421     (((class color)
422       (background light))
423      ())
424     (t
425      ()))
426   "Level 4 empty newsgroup face.")
427
428 (defface gnus-group-news-5-face
429   '((((class color)
430       (background dark))
431      (:bold t))
432     (((class color)
433       (background light))
434      (:bold t))
435     (t
436      ()))
437   "Level 5 newsgroup face.")
438
439 (defface gnus-group-news-5-empty-face
440   '((((class color)
441       (background dark))
442      ())
443     (((class color)
444       (background light))
445      ())
446     (t
447      ()))
448   "Level 5 empty newsgroup face.")
449
450 (defface gnus-group-news-6-face
451   '((((class color)
452       (background dark))
453      (:bold t))
454     (((class color)
455       (background light))
456      (:bold t))
457     (t
458      ()))
459   "Level 6 newsgroup face.")
460
461 (defface gnus-group-news-6-empty-face
462   '((((class color)
463       (background dark))
464      ())
465     (((class color)
466       (background light))
467      ())
468     (t
469      ()))
470   "Level 6 empty newsgroup face.")
471
472 (defface gnus-group-news-low-face
473   '((((class color)
474       (background dark))
475      (:foreground "DarkTurquoise" :bold t))
476     (((class color)
477       (background light))
478      (:foreground "DarkGreen" :bold t))
479     (t
480      ()))
481   "Low level newsgroup face.")
482
483 (defface gnus-group-news-low-empty-face
484   '((((class color)
485       (background dark))
486      (:foreground "DarkTurquoise"))
487     (((class color)
488       (background light))
489      (:foreground "DarkGreen"))
490     (t
491      ()))
492   "Low level empty newsgroup face.")
493
494 (defface gnus-group-mail-1-face
495   '((((class color)
496       (background dark))
497      (:foreground "aquamarine1" :bold t))
498     (((class color)
499       (background light))
500      (:foreground "DeepPink3" :bold t))
501     (t
502      (:bold t)))
503   "Level 1 mailgroup face.")
504
505 (defface gnus-group-mail-1-empty-face
506   '((((class color)
507       (background dark))
508      (:foreground "aquamarine1"))
509     (((class color)
510       (background light))
511      (:foreground "DeepPink3"))
512     (t
513      (:italic t :bold t)))
514   "Level 1 empty mailgroup face.")
515
516 (defface gnus-group-mail-2-face
517   '((((class color)
518       (background dark))
519      (:foreground "aquamarine2" :bold t))
520     (((class color)
521       (background light))
522      (:foreground "HotPink3" :bold t))
523     (t
524      (:bold t)))
525   "Level 2 mailgroup face.")
526
527 (defface gnus-group-mail-2-empty-face
528   '((((class color)
529       (background dark))
530      (:foreground "aquamarine2"))
531     (((class color)
532       (background light))
533      (:foreground "HotPink3"))
534     (t
535      (:bold t)))
536   "Level 2 empty mailgroup face.")
537
538 (defface gnus-group-mail-3-face
539   '((((class color)
540       (background dark))
541      (:foreground "aquamarine3" :bold t))
542     (((class color)
543       (background light))
544      (:foreground "magenta4" :bold t))
545     (t
546      (:bold t)))
547   "Level 3 mailgroup face.")
548
549 (defface gnus-group-mail-3-empty-face
550   '((((class color)
551       (background dark))
552      (:foreground "aquamarine3"))
553     (((class color)
554       (background light))
555      (:foreground "magenta4"))
556     (t
557      ()))
558   "Level 3 empty mailgroup face.")
559
560 (defface gnus-group-mail-low-face
561   '((((class color)
562       (background dark))
563      (:foreground "aquamarine4" :bold t))
564     (((class color)
565       (background light))
566      (:foreground "DeepPink4" :bold t))
567     (t
568      (:bold t)))
569   "Low level mailgroup face.")
570
571 (defface gnus-group-mail-low-empty-face
572   '((((class color)
573       (background dark))
574      (:foreground "aquamarine4"))
575     (((class color)
576       (background light))
577      (:foreground "DeepPink4"))
578     (t
579      (:bold t)))
580   "Low level empty mailgroup face.")
581
582 ;; Summary mode faces.
583
584 (defface gnus-summary-selected-face '((t
585                                        (:underline t)))
586   "Face used for selected articles.")
587
588 (defface gnus-summary-cancelled-face
589   '((((class color))
590      (:foreground "yellow" :background "black")))
591   "Face used for cancelled articles.")
592
593 (defface gnus-summary-high-ticked-face
594   '((((class color)
595       (background dark))
596      (:foreground "pink" :bold t))
597     (((class color)
598       (background light))
599      (:foreground "firebrick" :bold t))
600     (t
601      (:bold t)))
602   "Face used for high interest ticked articles.")
603
604 (defface gnus-summary-low-ticked-face
605   '((((class color)
606       (background dark))
607      (:foreground "pink" :italic t))
608     (((class color)
609       (background light))
610      (:foreground "firebrick" :italic t))
611     (t
612      (:italic t)))
613   "Face used for low interest ticked articles.")
614
615 (defface gnus-summary-normal-ticked-face
616   '((((class color)
617       (background dark))
618      (:foreground "pink"))
619     (((class color)
620       (background light))
621      (:foreground "firebrick"))
622     (t
623      ()))
624   "Face used for normal interest ticked articles.")
625
626 (defface gnus-summary-high-ancient-face
627   '((((class color)
628       (background dark))
629      (:foreground "SkyBlue" :bold t))
630     (((class color)
631       (background light))
632      (:foreground "RoyalBlue" :bold t))
633     (t
634      (:bold t)))
635   "Face used for high interest ancient articles.")
636
637 (defface gnus-summary-low-ancient-face
638   '((((class color)
639       (background dark))
640      (:foreground "SkyBlue" :italic t))
641     (((class color)
642       (background light))
643      (:foreground "RoyalBlue" :italic t))
644     (t
645      (:italic t)))
646   "Face used for low interest ancient articles.")
647
648 (defface gnus-summary-normal-ancient-face
649   '((((class color)
650       (background dark))
651      (:foreground "SkyBlue"))
652     (((class color)
653       (background light))
654      (:foreground "RoyalBlue"))
655     (t
656      ()))
657   "Face used for normal interest ancient articles.")
658
659 (defface gnus-summary-high-unread-face
660   '((t
661      (:bold t)))
662   "Face used for high interest unread articles.")
663
664 (defface gnus-summary-low-unread-face
665   '((t
666      (:italic t)))
667   "Face used for low interest unread articles.")
668
669 (defface gnus-summary-normal-unread-face
670   '((t
671      ()))
672   "Face used for normal interest unread articles.")
673
674 (defface gnus-summary-incorporated-face
675   '((t
676      ()))
677   "Face used for incorporated articles.")
678
679 (defface gnus-summary-high-read-face
680   '((((class color)
681       (background dark))
682      (:foreground "PaleGreen"
683                   :bold t))
684     (((class color)
685       (background light))
686      (:foreground "DarkGreen"
687                   :bold t))
688     (t
689      (:bold t)))
690   "Face used for high interest read articles.")
691
692 (defface gnus-summary-low-read-face
693   '((((class color)
694       (background dark))
695      (:foreground "PaleGreen"
696                   :italic t))
697     (((class color)
698       (background light))
699      (:foreground "DarkGreen"
700                   :italic t))
701     (t
702      (:italic t)))
703   "Face used for low interest read articles.")
704
705 (defface gnus-summary-normal-read-face
706   '((((class color)
707       (background dark))
708      (:foreground "PaleGreen"))
709     (((class color)
710       (background light))
711      (:foreground "DarkGreen"))
712     (t
713      ()))
714   "Face used for normal interest read articles.")
715
716
717 ;;;
718 ;;; Gnus buffers
719 ;;;
720
721 (defvar gnus-buffers nil)
722
723 (defun gnus-get-buffer-create (name)
724   "Do the same as `get-buffer-create', but store the created buffer."
725   (or (get-buffer name)
726       (car (push (get-buffer-create name) gnus-buffers))))
727
728 (defun gnus-add-buffer ()
729   "Add the current buffer to the list of Gnus buffers."
730   (push (current-buffer) gnus-buffers))
731
732 (defun gnus-buffers ()
733   "Return a list of live Gnus buffers."
734   (while (and gnus-buffers
735               (not (buffer-name (car gnus-buffers))))
736     (pop gnus-buffers))
737   (let ((buffers gnus-buffers))
738     (while (cdr buffers)
739       (if (buffer-name (cadr buffers))
740           (pop buffers)
741         (setcdr buffers (cddr buffers)))))
742   gnus-buffers)
743
744 ;;; Splash screen.
745
746 (defvar gnus-group-buffer "*Group*")
747
748 (eval-and-compile
749   (autoload 'gnus-play-jingle "gnus-audio"))
750
751 (defface gnus-splash-face
752   '((((class color)
753       (background dark))
754      (:foreground "#888888"))
755     (((class color)
756       (background light))
757      (:foreground "#888888"))
758     (t
759      ()))
760   "Face for the splash screen.")
761
762 (defun gnus-splash ()
763   (save-excursion
764     (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
765     (let ((buffer-read-only nil))
766       (erase-buffer)
767       (unless gnus-inhibit-startup-message
768         (gnus-group-startup-message)
769         (sit-for 0)
770         (when gnus-play-startup-jingle
771           (gnus-play-jingle))))))
772
773 (defun gnus-indent-rigidly (start end arg)
774   "Indent rigidly using only spaces and no tabs."
775   (save-excursion
776     (save-restriction
777       (narrow-to-region start end)
778       (let ((tab-width 8))
779         (indent-rigidly start end arg)
780         ;; We translate tabs into spaces -- not everybody uses
781         ;; an 8-character tab.
782         (goto-char (point-min))
783         (while (search-forward "\t" nil t)
784           (replace-match "        " t t))))))
785
786 (defvar gnus-simple-splash nil)
787
788 ;;(format "%02x%02x%02x" 114 66 20) "724214"
789
790 (defvar gnus-logo-color-alist
791   '((flame "#cc3300" "#ff2200")
792     (pine "#c0cc93" "#f8ffb8")
793     (moss "#a1cc93" "#d2ffb8")
794     (irish "#04cc90" "#05ff97")
795     (sky "#049acc" "#05deff")
796     (tin "#6886cc" "#82b6ff")
797     (velvet "#7c68cc" "#8c82ff")
798     (grape "#b264cc" "#cf7df")
799     (labia "#cc64c2" "#fd7dff")
800     (berry "#cc6485" "#ff7db5")
801     (dino "#724214" "#1e3f03")
802     (oort "#cccccc" "#888888")
803     (neutral "#b4b4b4" "#878787")
804     (september "#bf9900" "#ffcc00"))
805   "Color alist used for the Gnus logo.")
806
807 (defcustom gnus-logo-color-style 'oort
808   "*Color styles used for the Gnus logo."
809   :type '(choice (const flame) (const pine) (const moss)
810                  (const irish) (const sky) (const tin)
811                  (const velvet) (const grape) (const labia)
812                  (const berry) (const neutral) (const september)
813                  (const dino))
814   :group 'gnus-xmas)
815
816 (defvar gnus-logo-colors
817   (cdr (assq gnus-logo-color-style gnus-logo-color-alist))
818   "Colors used for the Gnus logo.")
819
820 (defun gnus-group-startup-message (&optional x y)
821   "Insert startup message in current buffer."
822   ;; Insert the message.
823   (erase-buffer)
824   (cond
825    ((and (fboundp 'find-image)
826          (display-graphic-p)
827          (let* ((bg (face-background 'default))
828                 (fg (face-foreground 'gnus-splash-face))
829                 (image (find-image
830                         `((:type xpm :file "gnus.xpm"
831                                  :color-symbols
832                                  (("thing" . ,(car gnus-logo-colors))
833                                   ("shadow" . ,(cadr gnus-logo-colors))
834                                   ("background" . ,bg)))
835                           (:type pbm :file "gnus.pbm"
836                                  ;; Account for the pbm's blackground.
837                                  :background ,bg :foreground ,fg)
838                           (:type xbm :file "gnus.xbm"
839                                  ;; Account for the xbm's blackground.
840                                  :background ,bg :foreground ,fg)))))
841            (when image
842              (insert
843               (propertize
844                (concat gnus-product-name " " gnus-version-number
845                        (if (zerop (string-to-number gnus-revision-number))
846                            ""
847                          (concat " (r" gnus-revision-number ")"))
848                        " based on " gnus-original-product-name " v"
849                        gnus-original-version-number)
850                'face `(variable-pitch :background ,bg :foreground ,fg)))
851              (let ((fill-column (window-width)))
852                (center-region (point-min) (point)))
853              (let ((size (image-size image)))
854                (insert-char ?\n (max 1 (round (- (window-height)
855                                                  (or y (cdr size))) 2)))
856                (insert
857                 (propertize " " 'display
858                             `(space :align-to
859                                     ,(max 0 (round (- (window-width)
860                                                       (or x (car size))) 2)))))
861                (insert-image image))
862              (setq gnus-simple-splash nil)
863              t))))
864    (t
865     (insert "
866           _    ___ _             _
867           _ ___ __ ___  __    _ ___
868           __   _     ___    __  ___
869               _           ___     _
870              _  _ __             _
871              ___   __            _
872                    __           _
873                     _      _   _
874                    _      _    _
875                       _  _    _
876                   __  ___
877                  _   _ _     _
878                 _   _
879               _    _
880              _    _
881             _
882           __
883
884 "
885             )
886     (goto-char (point-min))
887     (insert gnus-product-name " " gnus-version-number
888             (if (zerop (string-to-number gnus-revision-number))
889                 ""
890               (concat " (r" gnus-revision-number ")"))
891             " based on " gnus-original-product-name " v"
892             gnus-original-version-number)
893     (insert-char ?\  (prog1
894                          (max 0 (/ (- (window-width) (point)) 2))
895                        (goto-char (point-min))))
896     (forward-line 1)
897     ;; And then hack it.
898     (gnus-indent-rigidly (point) (point-max)
899                          (/ (max (- (window-width) (or x 46)) 0) 2))
900     (goto-char (point-min))
901     (forward-line 1)
902     (let* ((pheight (count-lines (point-min) (point-max)))
903            (wheight (window-height))
904            (rest (- wheight pheight)))
905       (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
906     ;; Fontify some.
907     (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)
908     (setq gnus-simple-splash t)))
909   (goto-char (point-min))
910   (setq mode-line-buffer-identification (concat " " gnus-version))
911   (set-buffer-modified-p t))
912
913 (eval-when (load)
914   (let ((command (format "%s" this-command)))
915     (if (and (string-match "gnus" command)
916              (not (string-match "gnus-other-frame" command)))
917         (gnus-splash)
918       (gnus-get-buffer-create gnus-group-buffer))))
919
920 ;;; Do the rest.
921
922 (require 'gnus-util)
923 (require 'nnheader)
924
925 (defcustom gnus-parameters nil
926   "Alist of group parameters.
927
928 For example:
929    ((\"mail\\\\..*\"  (gnus-show-threads nil)
930                   (gnus-use-scoring nil)
931                   (gnus-summary-line-format
932                         \"%U%R%z%I%(%[%d:%ub%-23,23f%]%) %s\\n\")
933                   (gcc-self . t)
934                   (display . all))
935      (\"mail\\\\.me\" (gnus-use-scoring  t))
936      (\"list\\\\..*\" (total-expire . t)
937                   (broken-reply-to . t)))"
938   :group 'gnus-group-various
939   :type '(repeat (cons regexp
940                        (repeat sexp))))
941
942 (defvar gnus-group-parameters-more nil)
943
944 (defvar gnus-colon-keywords
945   (eval-when-compile
946     (when (boundp 'dgnushack-colon-keywords)
947       (symbol-value 'dgnushack-colon-keywords)))
948   "List of the colon keywords should be bound at run-time.  This variable
949 defaults to a proper value only if this file is byte-compiled by make.")
950
951 (dolist (keyword gnus-colon-keywords)
952   (set keyword keyword))
953
954 (defmacro gnus-define-group-parameter (param &rest rest)
955   "Define a group parameter PARAM.
956 REST is a plist of following:
957 :type               One of `bool', `list' or `nil'.
958 :function           The name of the function.
959 :function-document  The documentation of the function.
960 :parameter-type     The type for customizing the parameter.
961 :parameter-document The documentation for the parameter.
962 :variable           The name of the variable.
963 :variable-document  The documentation for the variable.
964 :variable-group     The group for customizing the variable.
965 :variable-type      The type for customizing the variable.
966 :variable-default   The default value of the variable."
967   (let* ((type (plist-get rest :type))
968          (parameter-type (plist-get rest :parameter-type))
969          (parameter-document (plist-get rest :parameter-document))
970          (function (or (plist-get rest :function)
971                        (intern (format "gnus-parameter-%s" param))))
972          (function-document (or (plist-get rest :function-document) ""))
973          (variable (or (plist-get rest :variable)
974                        (intern (format "gnus-parameter-%s-alist" param))))
975          (variable-document (or (plist-get rest :variable-document) ""))
976          (variable-group (plist-get rest :variable-group))
977          (variable-type (or (plist-get rest :variable-type)
978                             `(quote (repeat
979                                      (list (regexp :tag "Group")
980                                            ,(car (cdr parameter-type)))))))
981          (variable-default (plist-get rest :variable-default)))
982     (list
983      'progn
984      `(defcustom ,variable ,variable-default
985         ,variable-document
986         :group 'gnus-group-parameter
987         :group ',variable-group
988         :type ,variable-type)
989      `(setq gnus-group-parameters-more
990             (delq (assq ',param gnus-group-parameters-more)
991                   gnus-group-parameters-more))
992      `(add-to-list 'gnus-group-parameters-more
993                    (list ',param
994                          ,parameter-type
995                          ,parameter-document))
996      (if (eq type 'bool)
997          `(defun ,function (name)
998             ,function-document
999             (let ((params (gnus-group-find-parameter name))
1000                   val)
1001               (cond
1002                ((memq ',param params)
1003                 t)
1004                ((setq val (assq ',param params))
1005                 (cdr val))
1006                ((stringp ,variable)
1007                 (string-match ,variable name))
1008                (,variable
1009                 (let ((alist ,variable)
1010                       elem value)
1011                   (while (setq elem (pop alist))
1012                     (when (and name
1013                                (string-match (car elem) name))
1014                       (setq alist nil
1015                             value (cdr elem))))
1016                   (if (consp value) (car value) value))))))
1017        `(defun ,function (name)
1018           ,function-document
1019           (and name
1020                (or (gnus-group-find-parameter name ',param ,(and type t))
1021                    (let ((alist ,variable)
1022                          elem value)
1023                      (while (setq elem (pop alist))
1024                        (when (and name
1025                                   (string-match (car elem) name))
1026                          (setq alist nil
1027                                value (cdr elem))))
1028                      ,(if type
1029                           'value
1030                         '(if (consp value) (car value) value))))))))))
1031
1032 (defcustom gnus-home-directory "~/"
1033   "Directory variable that specifies the \"home\" directory.
1034 All other Gnus path variables are initialized from this variable."
1035   :group 'gnus-files
1036   :type 'directory)
1037
1038 (defcustom gnus-directory (or (getenv "SAVEDIR")
1039                               (nnheader-concat gnus-home-directory "News/"))
1040   "*Directory variable from which all other Gnus file variables are derived.
1041
1042 Note that Gnus is mostly loaded when the `.gnus.el' file is read.
1043 This means that other directory variables that are initialized from
1044 this variable won't be set properly if you set this variable in `.gnus.el'.
1045 Set this variable in `.emacs' instead."
1046   :group 'gnus-files
1047   :type 'directory)
1048
1049 (defcustom gnus-default-directory nil
1050   "*Default directory for all Gnus buffers."
1051   :group 'gnus-files
1052   :type '(choice (const :tag "current" nil)
1053                  directory))
1054
1055 ;; Site dependent variables.  These variables should be defined in
1056 ;; paths.el.
1057
1058 (defvar gnus-default-nntp-server nil
1059   "Specify a default NNTP server.
1060 This variable should be defined in paths.el, and should never be set
1061 by the user.
1062 If you want to change servers, you should use `gnus-select-method'.
1063 See the documentation to that variable.")
1064
1065 ;; Don't touch this variable.
1066 (defvar gnus-nntp-service "nntp"
1067   "NNTP service name (\"nntp\" or 119).
1068 This is an obsolete variable, which is scarcely used.  If you use an
1069 nntp server for your newsgroup and want to change the port number
1070 used to 899, you would say something along these lines:
1071
1072  (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
1073
1074 (defcustom gnus-nntpserver-file "/etc/nntpserver"
1075   "A file with only the name of the nntp server in it."
1076   :group 'gnus-files
1077   :group 'gnus-server
1078   :type 'file)
1079
1080 ;; This function is used to check both the environment variable
1081 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
1082 ;; an nntp server name default.
1083 (defun gnus-getenv-nntpserver ()
1084   (or (getenv "NNTPSERVER")
1085       (and (file-readable-p gnus-nntpserver-file)
1086            (save-excursion
1087              (set-buffer (gnus-get-buffer-create " *gnus nntp*"))
1088              (insert-file-contents gnus-nntpserver-file)
1089              (let ((name (buffer-string)))
1090                (prog1
1091                    (if (string-match "\\'[ \t\n]*$" name)
1092                        nil
1093                      name)
1094                  (kill-buffer (current-buffer))))))))
1095
1096 (defcustom gnus-select-method
1097   (condition-case nil
1098       (nconc
1099        (list 'nntp (or (condition-case nil
1100                            (gnus-getenv-nntpserver)
1101                          (error nil))
1102                        (when (and gnus-default-nntp-server
1103                                   (not (string= gnus-default-nntp-server "")))
1104                          gnus-default-nntp-server)
1105                        "news"))
1106        (if (or (null gnus-nntp-service)
1107                (equal gnus-nntp-service "nntp"))
1108            nil
1109          (list gnus-nntp-service)))
1110     (error nil))
1111   "Default method for selecting a newsgroup.
1112 This variable should be a list, where the first element is how the
1113 news is to be fetched, the second is the address.
1114
1115 For instance, if you want to get your news via NNTP from
1116 \"flab.flab.edu\", you could say:
1117
1118 \(setq gnus-select-method '(nntp \"flab.flab.edu\"))
1119
1120 If you want to use your local spool, say:
1121
1122 \(setq gnus-select-method (list 'nnspool (system-name)))
1123
1124 If you use this variable, you must set `gnus-nntp-server' to nil.
1125
1126 There is a lot more to know about select methods and virtual servers -
1127 see the manual for details."
1128   :group 'gnus-server
1129   :type 'gnus-select-method)
1130
1131 (defcustom gnus-message-archive-method "archive"
1132   "*Method used for archiving messages you've sent.
1133 This should be a mail method."
1134   :group 'gnus-server
1135   :group 'gnus-message
1136   :type 'gnus-select-method)
1137
1138 (defcustom gnus-message-archive-group nil
1139   "*Name of the group in which to save the messages you've written.
1140 This can either be a string; a list of strings; or an alist
1141 of regexps/functions/forms to be evaluated to return a string (or a list
1142 of strings).  The functions are called with the name of the current
1143 group (or nil) as a parameter.
1144
1145 If you want to save your mail in one group and the news articles you
1146 write in another group, you could say something like:
1147
1148  \(setq gnus-message-archive-group
1149         '((if (message-news-p)
1150               \"misc-news\"
1151             \"misc-mail\")))
1152
1153 Normally the group names returned by this variable should be
1154 unprefixed -- which implicitly means \"store on the archive server\".
1155 However, you may wish to store the message on some other server.  In
1156 that case, just return a fully prefixed name of the group --
1157 \"nnml+private:mail.misc\", for instance."
1158   :group 'gnus-message
1159   :type '(choice (const :tag "none" nil)
1160                  function
1161                  sexp
1162                  string))
1163
1164 (defcustom gnus-secondary-servers nil
1165   "List of NNTP servers that the user can choose between interactively.
1166 To make Gnus query you for a server, you have to give `gnus' a
1167 non-numeric prefix - `C-u M-x gnus', in short."
1168   :group 'gnus-server
1169   :type '(repeat string))
1170
1171 (defcustom gnus-nntp-server nil
1172   "*The name of the host running the NNTP server.
1173 This variable is semi-obsolete.  Use the `gnus-select-method'
1174 variable instead."
1175   :group 'gnus-server
1176   :type '(choice (const :tag "disable" nil)
1177                  string))
1178
1179 (defcustom gnus-secondary-select-methods nil
1180   "A list of secondary methods that will be used for reading news.
1181 This is a list where each element is a complete select method (see
1182 `gnus-select-method').
1183
1184 If, for instance, you want to read your mail with the nnml backend,
1185 you could set this variable:
1186
1187 \(setq gnus-secondary-select-methods '((nnml \"\")))"
1188   :group 'gnus-server
1189   :type '(repeat gnus-select-method))
1190
1191 (defvar gnus-backup-default-subscribed-newsgroups
1192   '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
1193   "Default default new newsgroups the first time Gnus is run.
1194 Should be set in paths.el, and shouldn't be touched by the user.")
1195
1196 (defcustom gnus-local-domain nil
1197   "Local domain name without a host name.
1198 The DOMAINNAME environment variable is used instead if it is defined.
1199 If the function `system-name' returns the full Internet name, there is
1200 no need to set this variable."
1201   :group 'gnus-message
1202   :type '(choice (const :tag "default" nil)
1203                  string))
1204
1205 (defvar gnus-local-organization nil
1206   "String with a description of what organization (if any) the user belongs to.
1207 Obsolete variable; use `message-user-organization' instead.")
1208
1209 ;; Customization variables
1210
1211 (defcustom gnus-refer-article-method nil
1212   "Preferred method for fetching an article by Message-ID.
1213 If you are reading news from the local spool (with nnspool), fetching
1214 articles by Message-ID is painfully slow.  By setting this method to an
1215 nntp method, you might get acceptable results.
1216
1217 The value of this variable must be a valid select method as discussed
1218 in the documentation of `gnus-select-method'.
1219
1220 It can also be a list of select methods, as well as the special symbol
1221 `current', which means to use the current select method.  If it is a
1222 list, Gnus will try all the methods in the list until it finds a match."
1223   :group 'gnus-server
1224   :type '(choice (const :tag "default" nil)
1225                  (const :tag "DejaNews" (nnweb "refer" (nnweb-type dejanews)))
1226                  gnus-select-method
1227                  (repeat :menu-tag "Try multiple"
1228                          :tag "Multiple"
1229                          :value (current (nnweb "refer" (nnweb-type dejanews)))
1230                          (choice :tag "Method"
1231                                  (const current)
1232                                  (const :tag "DejaNews"
1233                                         (nnweb "refer" (nnweb-type dejanews)))
1234                                  gnus-select-method))))
1235
1236 (defcustom gnus-group-faq-directory
1237   '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
1238     "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
1239     "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
1240     "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
1241     "/ftp@ftp.pasteur.fr:/pub/FAQ/"
1242     "/ftp@rtfm.mit.edu:/pub/usenet/"
1243     "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
1244     "/ftp@ftp.sunet.se:/pub/usenet/"
1245     "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
1246     "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
1247     "/ftp@ftp.hk.super.net:/mirror/faqs/")
1248   "*Directory where the group FAQs are stored.
1249 This will most commonly be on a remote machine, and the file will be
1250 fetched by ange-ftp.
1251
1252 This variable can also be a list of directories.  In that case, the
1253 first element in the list will be used by default.  The others can
1254 be used when being prompted for a site.
1255
1256 Note that Gnus uses an aol machine as the default directory.  If this
1257 feels fundamentally unclean, just think of it as a way to finally get
1258 something of value back from them.
1259
1260 If the default site is too slow, try one of these:
1261
1262    North America: mirrors.aol.com                /pub/rtfm/usenet
1263                   ftp.seas.gwu.edu               /pub/rtfm
1264                   rtfm.mit.edu                   /pub/usenet
1265    Europe:        ftp.uni-paderborn.de           /pub/FAQ
1266                   src.doc.ic.ac.uk               /usenet/news-FAQS
1267                   ftp.sunet.se                   /pub/usenet
1268                   ftp.pasteur.fr                 /pub/FAQ
1269    Asia:          nctuccca.edu.tw                /USENET/FAQ
1270                   hwarang.postech.ac.kr          /pub/usenet
1271                   ftp.hk.super.net               /mirror/faqs"
1272   :group 'gnus-group-various
1273   :type '(choice directory
1274                  (repeat directory)))
1275
1276 (defcustom gnus-use-cross-reference t
1277   "*Non-nil means that cross referenced articles will be marked as read.
1278 If nil, ignore cross references.  If t, mark articles as read in
1279 subscribed newsgroups.  If neither t nor nil, mark as read in all
1280 newsgroups."
1281   :group 'gnus-server
1282   :type '(choice (const :tag "off" nil)
1283                  (const :tag "subscribed" t)
1284                  (sexp :format "all"
1285                        :value always)))
1286
1287 (defcustom gnus-process-mark ?#
1288   "*Process mark."
1289   :group 'gnus-group-visual
1290   :group 'gnus-summary-marks
1291   :type 'character)
1292
1293 (defcustom gnus-large-newsgroup 200
1294   "*The number of articles which indicates a large newsgroup.
1295 If the number of articles in a newsgroup is greater than this value,
1296 confirmation is required for selecting the newsgroup.
1297 If it is `nil', no confirmation is required."
1298   :group 'gnus-group-select
1299   :type 'integer)
1300
1301 (defcustom gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
1302   "*Non-nil means that the default name of a file to save articles in is the group name.
1303 If it's nil, the directory form of the group name is used instead.
1304
1305 If this variable is a list, and the list contains the element
1306 `not-score', long file names will not be used for score files; if it
1307 contains the element `not-save', long file names will not be used for
1308 saving; and if it contains the element `not-kill', long file names
1309 will not be used for kill files.
1310
1311 Note that the default for this variable varies according to what system
1312 type you're using.  On `usg-unix-v' and `xenix' this variable defaults
1313 to nil while on all other systems it defaults to t."
1314   :group 'gnus-start
1315   :type 'boolean)
1316
1317 (defcustom gnus-kill-files-directory gnus-directory
1318   "*Name of the directory where kill files will be stored (default \"~/News\")."
1319   :group 'gnus-score-files
1320   :group 'gnus-score-kill
1321   :type 'directory)
1322
1323 (defcustom gnus-save-score nil
1324   "*If non-nil, save group scoring info."
1325   :group 'gnus-score-various
1326   :group 'gnus-start
1327   :type 'boolean)
1328
1329 (defcustom gnus-use-undo t
1330   "*If non-nil, allow undoing in Gnus group mode buffers."
1331   :group 'gnus-meta
1332   :type 'boolean)
1333
1334 (defcustom gnus-use-adaptive-scoring nil
1335   "*If non-nil, use some adaptive scoring scheme.
1336 If a list, then the values `word' and `line' are meaningful.  The
1337 former will perform adaption on individual words in the subject
1338 header while `line' will perform adaption on several headers."
1339   :group 'gnus-meta
1340   :group 'gnus-score-adapt
1341   :type '(set (const word) (const line)))
1342
1343 (defcustom gnus-use-cache 'passive
1344   "*If nil, Gnus will ignore the article cache.
1345 If `passive', it will allow entering (and reading) articles
1346 explicitly entered into the cache.  If anything else, use the
1347 cache to the full extent of the law."
1348   :group 'gnus-meta
1349   :group 'gnus-cache
1350   :type '(choice (const :tag "off" nil)
1351                  (const :tag "passive" passive)
1352                  (const :tag "active" t)))
1353
1354 (defcustom gnus-use-trees nil
1355   "*If non-nil, display a thread tree buffer."
1356   :group 'gnus-meta
1357   :type 'boolean)
1358
1359 (defcustom gnus-use-grouplens nil
1360   "*If non-nil, use GroupLens ratings."
1361   :group 'gnus-meta
1362   :type 'boolean)
1363
1364 (defcustom gnus-keep-backlog nil
1365   "*If non-nil, Gnus will keep read articles for later re-retrieval.
1366 If it is a number N, then Gnus will only keep the last N articles
1367 read.  If it is neither nil nor a number, Gnus will keep all read
1368 articles.  This is not a good idea."
1369   :group 'gnus-meta
1370   :type '(choice (const :tag "off" nil)
1371                  integer
1372                  (sexp :format "all"
1373                        :value t)))
1374
1375 (defcustom gnus-use-nocem nil
1376   "*If non-nil, Gnus will read NoCeM cancel messages."
1377   :group 'gnus-meta
1378   :type 'boolean)
1379
1380 (defcustom gnus-suppress-duplicates nil
1381   "*If non-nil, Gnus will mark duplicate copies of the same article as read."
1382   :group 'gnus-meta
1383   :type 'boolean)
1384
1385 (defcustom gnus-use-scoring t
1386   "*If non-nil, enable scoring."
1387   :group 'gnus-meta
1388   :type 'boolean)
1389
1390 (defcustom gnus-summary-prepare-exit-hook
1391   '(gnus-summary-expire-articles)
1392   "*A hook called when preparing to exit from the summary buffer.
1393 It calls `gnus-summary-expire-articles' by default."
1394   :group 'gnus-summary-exit
1395   :type 'hook)
1396
1397 (defcustom gnus-novice-user t
1398   "*Non-nil means that you are a usenet novice.
1399 If non-nil, verbose messages may be displayed and confirmations may be
1400 required."
1401   :group 'gnus-meta
1402   :type 'boolean)
1403
1404 (defcustom gnus-expert-user nil
1405   "*Non-nil means that you will never be asked for confirmation about anything.
1406 That doesn't mean *anything* anything; particularly destructive
1407 commands will still require prompting."
1408   :group 'gnus-meta
1409   :type 'boolean)
1410
1411 (defcustom gnus-interactive-catchup t
1412   "*If non-nil, require your confirmation when catching up a group."
1413   :group 'gnus-group-select
1414   :type 'boolean)
1415
1416 (defcustom gnus-interactive-exit t
1417   "*If non-nil, require your confirmation when exiting Gnus."
1418   :group 'gnus-exit
1419   :type 'boolean)
1420
1421 (defcustom gnus-extract-address-components 'gnus-extract-address-components
1422   "Function for extracting address components from a From header.
1423 Three pre-defined functions exist: `gnus-extract-address-components',
1424 which is the default, quite fast, and too simplistic solution,
1425 `mail-extract-address-components', which works much better, but is
1426 slower, and `std11-extract-address-components'."
1427   :group 'gnus-summary-format
1428   :type '(radio (function-item gnus-extract-address-components)
1429                 (function-item mail-extract-address-components)
1430                 (function-item std11-extract-address-components)
1431                 (function :tag "Other")))
1432
1433 (defcustom gnus-carpal nil
1434   "*If non-nil, display clickable icons."
1435   :group 'gnus-meta
1436   :type 'boolean)
1437
1438 (defcustom gnus-shell-command-separator ";"
1439   "String used to separate to shell commands."
1440   :group 'gnus-files
1441   :type 'string)
1442
1443 (defcustom gnus-valid-select-methods
1444   '(("nntp" post address prompt-address physical-address)
1445     ("nnspool" post address)
1446     ("nnvirtual" post-mail virtual prompt-address)
1447     ("nnmbox" mail respool address)
1448     ("nnml" post-mail respool address)
1449     ("nnmh" mail respool address)
1450     ("nndir" post-mail prompt-address physical-address)
1451     ("nneething" none address prompt-address physical-address)
1452     ("nndoc" none address prompt-address)
1453     ("nnbabyl" mail address respool)
1454     ("nnkiboze" post virtual)
1455     ("nnsoup" post-mail address)
1456     ("nndraft" post-mail)
1457     ("nnfolder" mail respool address)
1458     ("nngateway" post-mail address prompt-address physical-address)
1459     ("nnweb" none)
1460     ("nnslashdot" post)
1461     ("nnultimate" none)
1462     ("nnrss" none)
1463     ("nnwfm" none)
1464     ("nnwarchive" none)
1465     ("nnlistserv" none)
1466     ("nnagent" post-mail)
1467     ("nnimap" post-mail address prompt-address physical-address)
1468     ("nnmaildir" mail respool address))
1469   "*An alist of valid select methods.
1470 The first element of each list lists should be a string with the name
1471 of the select method.  The other elements may be the category of
1472 this method (i. e., `post', `mail', `none' or whatever) or other
1473 properties that this method has (like being respoolable).
1474 If you implement a new select method, all you should have to change is
1475 this variable.  I think."
1476   :group 'gnus-server
1477   :type '(repeat (group (string :tag "Name")
1478                         (radio-button-choice (const :format "%v " post)
1479                                              (const :format "%v " mail)
1480                                              (const :format "%v " none)
1481                                              (const post-mail))
1482                         (checklist :inline t
1483                                    (const :format "%v " address)
1484                                    (const :format "%v " prompt-address)
1485                                    (const :format "%v " physical-address)
1486                                    (const :format "%v " virtual)
1487                                    (const respool)))))
1488
1489 (defun gnus-redefine-select-method-widget ()
1490   "Recomputes the select-method widget based on the value of
1491 `gnus-valid-select-methods'."
1492   (define-widget 'gnus-select-method 'list
1493     "Widget for entering a select method."
1494     :value '(nntp "")
1495     :tag "Select Method"
1496     :args `((choice :tag "Method"
1497                     ,@(mapcar (lambda (entry)
1498                                 (list 'const :format "%v\n"
1499                                       (intern (car entry))))
1500                               gnus-valid-select-methods)
1501                     (symbol :tag "other"))
1502             (string :tag "Address")
1503             (repeat :tag "Options"
1504                     :inline t
1505                     (list :format "%v"
1506                           variable
1507                           (sexp :tag "Value"))))))
1508
1509 (gnus-redefine-select-method-widget)
1510
1511 (defcustom gnus-updated-mode-lines '(group article summary tree)
1512   "List of buffers that should update their mode lines.
1513 The list may contain the symbols `group', `article', `tree' and
1514 `summary'.  If the corresponding symbol is present, Gnus will keep
1515 that mode line updated with information that may be pertinent.
1516 If this variable is nil, screen refresh may be quicker."
1517   :group 'gnus-various
1518   :type '(set (const group)
1519               (const article)
1520               (const summary)
1521               (const tree)))
1522
1523 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1524 (defcustom gnus-mode-non-string-length nil
1525   "*Max length of mode-line non-string contents.
1526 If this is nil, Gnus will take space as is needed, leaving the rest
1527 of the modeline intact.  Note that the default of nil is unlikely
1528 to be desirable; see the manual for further details."
1529   :group 'gnus-various
1530   :type '(choice (const nil)
1531                  integer))
1532
1533 ;; There should be special validation for this.
1534 (define-widget 'gnus-email-address 'string
1535   "An email address")
1536
1537 (gnus-define-group-parameter
1538  to-address
1539  :function-document
1540  "Return GROUP's to-address."
1541  :variable-document
1542  "*Alist of group regexps and correspondent to-addresses."
1543  :parameter-type '(gnus-email-address :tag "To Address")
1544  :parameter-document "\
1545 This will be used when doing followups and posts.
1546
1547 This is primarily useful in mail groups that represent closed
1548 mailing lists--mailing lists where it's expected that everybody that
1549 writes to the mailing list is subscribed to it.  Since using this
1550 parameter ensures that the mail only goes to the mailing list itself,
1551 it means that members won't receive two copies of your followups.
1552
1553 Using `to-address' will actually work whether the group is foreign or
1554 not.  Let's say there's a group on the server that is called
1555 `fa.4ad-l'.  This is a real newsgroup, but the server has gotten the
1556 articles from a mail-to-news gateway.  Posting directly to this group
1557 is therefore impossible--you have to send mail to the mailing list
1558 address instead.
1559
1560 The gnus-group-split mail splitting mechanism will behave as if this
1561 address was listed in gnus-group-split Addresses (see below).")
1562
1563 (gnus-define-group-parameter
1564  to-list
1565  :function-document
1566  "Return GROUP's to-list."
1567  :variable-document
1568  "*Alist of group regexps and correspondent to-lists."
1569  :parameter-type '(gnus-email-address :tag "To List")
1570  :parameter-document "\
1571 This address will be used when doing a `a' in the group.
1572
1573 It is totally ignored when doing a followup--except that if it is
1574 present in a news group, you'll get mail group semantics when doing
1575 `f'.
1576
1577 The gnus-group-split mail splitting mechanism will behave as if this
1578 address was listed in gnus-group-split Addresses (see below).")
1579
1580 (gnus-define-group-parameter
1581  auto-expire
1582  :type bool
1583  :function gnus-group-auto-expirable-p
1584  :function-document
1585  "Check whether GROUP is auto-expirable or not."
1586  :variable gnus-auto-expirable-newsgroups
1587  :variable-default nil
1588  :variable-document
1589  "*Groups in which to automatically mark read articles as expirable.
1590 If non-nil, this should be a regexp that should match all groups in
1591 which to perform auto-expiry.  This only makes sense for mail groups."
1592  :variable-group nnmail-expire
1593  :variable-type '(choice (const nil)
1594                          regexp)
1595  :parameter-type '(const :tag "Automatic Expire" t)
1596  :parameter-document
1597  "All articles that are read will be marked as expirable.")
1598
1599 (gnus-define-group-parameter
1600  total-expire
1601  :type bool
1602  :function gnus-group-total-expirable-p
1603  :function-document
1604  "Check whether GROUP is total-expirable or not."
1605  :variable gnus-total-expirable-newsgroups
1606  :variable-default nil
1607  :variable-document
1608  "*Groups in which to perform expiry of all read articles.
1609 Use with extreme caution.  All groups that match this regexp will be
1610 expiring - which means that all read articles will be deleted after
1611 \(say) one week.         (This only goes for mail groups and the like, of
1612 course.)"
1613  :variable-group nnmail-expire
1614  :variable-type '(choice (const nil)
1615                          regexp)
1616  :parameter-type '(const :tag "Total Expire" t)
1617  :parameter-document
1618  "All read articles will be put through the expiry process
1619
1620 This happens even if they are not marked as expirable.
1621 Use with caution.")
1622
1623 (gnus-define-group-parameter
1624  charset
1625  :function-document
1626  "Return the default charset of GROUP."
1627  :variable gnus-group-charset-alist
1628  :variable-default
1629  '(("\\(^\\|:\\)hk\\>\\|\\(^\\|:\\)tw\\>\\|\\<big5\\>" cn-big5)
1630    ("\\(^\\|:\\)cn\\>\\|\\<chinese\\>" cn-gb-2312)
1631    ("\\(^\\|:\\)fj\\>\\|\\(^\\|:\\)japan\\>" iso-2022-jp-2)
1632    ("\\(^\\|:\\)tnn\\>\\|\\(^\\|:\\)pin\\>\\|\\(^\\|:\\)sci.lang.japan" iso-2022-7bit)
1633    ("\\(^\\|:\\)relcom\\>" koi8-r)
1634    ("\\(^\\|:\\)fido7\\>" koi8-r)
1635    ("\\(^\\|:\\)\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
1636    ("\\(^\\|:\\)israel\\>" iso-8859-1)
1637    ("\\(^\\|:\\)han\\>" euc-kr)
1638    ("\\(^\\|:\\)alt.chinese.text.big5\\>" chinese-big5)
1639    ("\\(^\\|:\\)soc.culture.vietnamese\\>" vietnamese-viqr)
1640    ("\\(^\\|:\\)\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
1641    (".*" iso-8859-1))
1642  :variable-document
1643  "Alist of regexps (to match group names) and default charsets to be used when reading."
1644  :variable-group gnus-charset
1645  :variable-type '(repeat (list (regexp :tag "Group")
1646                                (symbol :tag "Charset")))
1647  :parameter-type '(symbol :tag "Charset")
1648  :parameter-document "\
1649 The default charset to use in the group.")
1650
1651 (gnus-define-group-parameter
1652  post-method
1653  :type list
1654  :function-document
1655  "Return a posting method for GROUP."
1656  :variable gnus-post-method-alist
1657  :variable-document
1658  "Alist of regexps (to match group names) and method to be used when
1659 posting an article."
1660  :variable-group gnus-group-foreign
1661  :parameter-type
1662  '(choice :tag "Posting Method"
1663           (const :tag "Use native server" native)
1664           (const :tag "Use current server" current)
1665           (list :convert-widget
1666                 (lambda (widget)
1667                   (list 'sexp :tag "Methods"
1668                         :value gnus-select-method))))
1669  :parameter-document
1670  "Posting method for this group.")
1671
1672 (defcustom gnus-group-uncollapsed-levels 1
1673   "Number of group name elements to leave alone when making a short group name."
1674   :group 'gnus-group-visual
1675   :type 'integer)
1676
1677 (defcustom gnus-group-use-permanent-levels nil
1678   "*If non-nil, once you set a level, Gnus will use this level."
1679   :group 'gnus-group-levels
1680   :type 'boolean)
1681
1682 ;; Hooks.
1683
1684 (defcustom gnus-load-hook nil
1685   "A hook run while Gnus is loaded."
1686   :group 'gnus-start
1687   :type 'hook)
1688
1689 (defcustom gnus-apply-kill-hook '(gnus-apply-kill-file)
1690   "A hook called to apply kill files to a group.
1691 This hook is intended to apply a kill file to the selected newsgroup.
1692 The function `gnus-apply-kill-file' is called by default.
1693
1694 Since a general kill file is too heavy to use only for a few
1695 newsgroups, I recommend you to use a lighter hook function.  For
1696 example, if you'd like to apply a kill file to articles which contains
1697 a string `rmgroup' in subject in newsgroup `control', you can use the
1698 following hook:
1699
1700  (setq gnus-apply-kill-hook
1701       (list
1702         (lambda ()
1703           (cond ((string-match \"control\" gnus-newsgroup-name)
1704                  (gnus-kill \"Subject\" \"rmgroup\")
1705                  (gnus-expunge \"X\"))))))"
1706   :group 'gnus-score-kill
1707   :options '(gnus-apply-kill-file)
1708   :type 'hook)
1709
1710 (defcustom gnus-group-change-level-function nil
1711   "Function run when a group level is changed.
1712 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL."
1713   :group 'gnus-group-levels
1714   :type 'function)
1715
1716 ;;; Face thingies.
1717
1718 (defcustom gnus-visual
1719   '(summary-highlight group-highlight article-highlight
1720                       mouse-face
1721                       summary-menu group-menu article-menu
1722                       tree-highlight menu highlight
1723                       browse-menu server-menu
1724                       page-marker tree-menu binary-menu pick-menu
1725                       grouplens-menu)
1726   "*Enable visual features.
1727 If `visual' is disabled, there will be no menus and few faces.  Most of
1728 the visual customization options below will be ignored.  Gnus will use
1729 less space and be faster as a result.
1730
1731 This variable can also be a list of visual elements to switch on.  For
1732 instance, to switch off all visual things except menus, you can say:
1733
1734    (setq gnus-visual '(menu))
1735
1736 Valid elements include `summary-highlight', `group-highlight',
1737 `article-highlight', `mouse-face', `summary-menu', `group-menu',
1738 `article-menu', `tree-highlight', `menu', `highlight', `browse-menu',
1739 `server-menu', `page-marker', `tree-menu', `binary-menu', `pick-menu',
1740 and `grouplens-menu'."
1741   :group 'gnus-meta
1742   :group 'gnus-visual
1743   :type '(set (const summary-highlight)
1744               (const group-highlight)
1745               (const article-highlight)
1746               (const mouse-face)
1747               (const summary-menu)
1748               (const group-menu)
1749               (const article-menu)
1750               (const tree-highlight)
1751               (const menu)
1752               (const highlight)
1753               (const browse-menu)
1754               (const server-menu)
1755               (const page-marker)
1756               (const tree-menu)
1757               (const binary-menu)
1758               (const pick-menu)
1759               (const grouplens-menu)))
1760
1761 ;; Byte-compiler warning.
1762 (defvar gnus-visual)
1763 ;; Find out whether the gnus-visual TYPE is wanted.
1764 (defun gnus-visual-p (&optional type class)
1765   (and gnus-visual                      ; Has to be non-nil, at least.
1766        (if (not type)                   ; We don't care about type.
1767            gnus-visual
1768          (if (listp gnus-visual)        ; It's a list, so we check it.
1769              (or (memq type gnus-visual)
1770                  (memq class gnus-visual))
1771            t))))
1772
1773 (defcustom gnus-mouse-face
1774   (condition-case ()
1775       (if (gnus-visual-p 'mouse-face 'highlight)
1776           (if (boundp 'gnus-mouse-face)
1777               (or gnus-mouse-face 'highlight)
1778             'highlight)
1779         'default)
1780     (error 'highlight))
1781   "*Face used for group or summary buffer mouse highlighting.
1782 The line beneath the mouse pointer will be highlighted with this
1783 face."
1784   :group 'gnus-visual
1785   :type 'face)
1786
1787 (defcustom gnus-article-save-directory gnus-directory
1788   "*Name of the directory articles will be saved in (default \"~/News\")."
1789   :group 'gnus-article-saving
1790   :type 'directory)
1791
1792 (defvar gnus-plugged t
1793   "Whether Gnus is plugged or not.")
1794
1795 (defcustom gnus-default-charset 'iso-8859-1
1796   "Default charset assumed to be used when viewing non-ASCII characters.
1797 This variable is overridden on a group-to-group basis by the
1798 gnus-group-charset-alist variable and is only used on groups not
1799 covered by that variable."
1800   :type 'symbol
1801   :group 'gnus-charset)
1802
1803 \f
1804 ;;; Internal variables
1805
1806 (defvar gnus-agent-gcc-header "X-Gnus-Agent-Gcc")
1807 (defvar gnus-agent-meta-information-header "X-Gnus-Agent-Meta-Information")
1808 (defvar gnus-draft-meta-information-header "X-Draft-From")
1809 (defvar gnus-group-get-parameter-function 'gnus-group-get-parameter)
1810 (defvar gnus-original-article-buffer " *Original Article*")
1811 (defvar gnus-newsgroup-name nil)
1812 (defvar gnus-ephemeral-servers nil)
1813
1814 (defvar gnus-agent nil
1815   "Whether we want to use the Gnus agent or not.")
1816
1817 (defvar gnus-agent-fetching nil
1818   "Whether Gnus agent is in fetching mode.")
1819
1820 (defvar gnus-command-method nil
1821   "Dynamically bound variable that says what the current backend is.")
1822
1823 (defvar gnus-current-select-method nil
1824   "The current method for selecting a newsgroup.")
1825
1826 (defvar gnus-tree-buffer "*Tree*"
1827   "Buffer where Gnus thread trees are displayed.")
1828
1829 ;; Dummy variable.
1830 (defvar gnus-use-generic-from nil)
1831
1832 ;; Variable holding the user answers to all method prompts.
1833 (defvar gnus-method-history nil)
1834
1835 ;; Variable holding the user answers to all mail method prompts.
1836 (defvar gnus-mail-method-history nil)
1837
1838 ;; Variable holding the user answers to all group prompts.
1839 (defvar gnus-group-history nil)
1840
1841 (defvar gnus-server-alist nil
1842   "List of available servers.")
1843
1844 (defcustom gnus-cache-directory
1845   (nnheader-concat gnus-directory "cache/")
1846   "*The directory where cached articles will be stored."
1847   :group 'gnus-cache
1848   :type 'directory)
1849
1850 (defvar gnus-predefined-server-alist
1851   `(("cache"
1852      nnspool "cache"
1853      (nnspool-spool-directory ,gnus-cache-directory)
1854      (nnspool-nov-directory ,gnus-cache-directory)
1855      (nnspool-active-file
1856       ,(nnheader-concat gnus-cache-directory "active"))))
1857   "List of predefined (convenience) servers.")
1858
1859 (defvar gnus-topic-indentation "");; Obsolete variable.
1860
1861 (defconst gnus-article-mark-lists
1862   '((marked . tick) (replied . reply)
1863     (expirable . expire) (killed . killed)
1864     (bookmarks . bookmark) (dormant . dormant)
1865     (scored . score) (saved . save)
1866     (cached . cache) (downloadable . download)
1867     (unsendable . unsend) (forwarded . forward)
1868     (recent . recent) (seen . seen)))
1869
1870 (defconst gnus-article-special-mark-lists
1871   '((seen range)
1872     (killed range)
1873     (bookmark tuple)
1874     (score tuple)))
1875
1876 ;; Propagate flags to server, with the following exceptions:
1877 ;; `seen' is private to each gnus installation
1878 ;; `cache' is a internal gnus flag for each gnus installation
1879 ;; `download' is a agent flag private to each gnus installation
1880 ;; `unsend' are for nndraft groups only
1881 ;; `score' is not a proper mark
1882 (defconst gnus-article-unpropagated-mark-lists
1883   '(seen cache download unsend score)
1884   "Marks that shouldn't be propagated to backends.
1885 Typical marks are those that make no sense in a standalone backend,
1886 such as a mark that says whether an article is stored in the cache
1887 (which doesn't make sense in a standalone backend).")
1888
1889 (defvar gnus-headers-retrieved-by nil)
1890 (defvar gnus-article-reply nil)
1891 (defvar gnus-override-method nil)
1892 (defvar gnus-article-check-size nil)
1893 (defvar gnus-opened-servers nil)
1894
1895 (defvar gnus-current-kill-article nil)
1896
1897 (defvar gnus-have-read-active-file nil)
1898
1899 (defconst gnus-maintainer
1900   "semi-gnus-ja@meadowy.org (T-gnus Bugfixing Girls + Boys)"
1901   "The mail address of the T-gnus maintainers.")
1902
1903 (defcustom gnus-info-filename nil
1904   "*Controls language of gnus Info.
1905 If nil and current-language-environment is Japanese, go to gnus-ja.
1906 Otherwise go to corresponding Info.
1907 This variable can be nil, gnus or gnus-ja."
1908   :group 'gnus-start
1909   :type '(choice (const nil)
1910                  (const :tag "English" gnus)
1911                  (const :tag "Japanese" gnus-ja)))
1912
1913 (defvar gnus-info-nodes
1914   '((gnus-group-mode "Group Buffer")
1915     (gnus-summary-mode "Summary Buffer")
1916     (gnus-article-mode "Article Buffer")
1917     (gnus-server-mode "Server Buffer")
1918     (gnus-browse-mode "Browse Foreign Server")
1919     (gnus-tree-mode "Tree Display"))
1920   "Alist of major modes and related Info nodes.")
1921
1922 (defvar gnus-group-buffer "*Group*")
1923 (defvar gnus-summary-buffer "*Summary*")
1924 (defvar gnus-article-buffer "*Article*")
1925 (defvar gnus-server-buffer "*Server*")
1926
1927 (defvar gnus-slave nil
1928   "Whether this Gnus is a slave or not.")
1929
1930 (defvar gnus-batch-mode nil
1931   "Whether this Gnus is running in batch mode or not.")
1932
1933 (defvar gnus-variable-list
1934   '(gnus-newsrc-options gnus-newsrc-options-n
1935                         gnus-newsrc-last-checked-date
1936                         gnus-newsrc-alist gnus-server-alist
1937                         gnus-killed-list gnus-zombie-list
1938                         gnus-topic-topology gnus-topic-alist)
1939   "Gnus variables saved in the quick startup file.")
1940
1941 (defvar gnus-product-variable-file-list
1942   (let ((version (product-version (product-find 'gnus-vers)))
1943         (codesys (static-if (boundp 'MULE) '*ctext* 'ctext)))
1944     `(("strict-cache" ((product-version ,version) (emacs-version))
1945        binary
1946        gnus-format-specs-compiled)
1947       ("cache" ((product-version ,version) (emacs-version))
1948        ,codesys
1949        gnus-format-specs)))
1950   "Gnus variables are saved in the produce depend quick startup files.")
1951
1952 (defcustom gnus-compile-user-specs t
1953   "If non-nil, the user-defined format specs will be byte-compiled
1954 automatically.
1955 It has an effect on the values of `gnus-*-line-format-spec'."
1956   :group 'gnus
1957   :type 'boolean)
1958
1959 (defvar gnus-newsrc-alist nil
1960   "Assoc list of read articles.
1961 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1962
1963 (defvar gnus-newsrc-hashtb nil
1964   "Hashtable of gnus-newsrc-alist.")
1965
1966 (defvar gnus-killed-list nil
1967   "List of killed newsgroups.")
1968
1969 (defvar gnus-killed-hashtb nil
1970   "Hash table equivalent of gnus-killed-list.")
1971
1972 (defvar gnus-zombie-list nil
1973   "List of almost dead newsgroups.")
1974
1975 (defvar gnus-description-hashtb nil
1976   "Descriptions of newsgroups.")
1977
1978 (defvar gnus-list-of-killed-groups nil
1979   "List of newsgroups that have recently been killed by the user.")
1980
1981 (defvar gnus-active-hashtb nil
1982   "Hashtable of active articles.")
1983
1984 (defvar gnus-moderated-hashtb nil
1985   "Hashtable of moderated newsgroups.")
1986
1987 ;; Save window configuration.
1988 (defvar gnus-prev-winconf nil)
1989
1990 (defvar gnus-reffed-article-number nil)
1991
1992 ;;; Let the byte-compiler know that we know about this variable.
1993 (defvar rmail-default-rmail-file)
1994
1995 (defvar gnus-dead-summary nil)
1996
1997 (defvar gnus-invalid-group-regexp "[: `'\"/]\\|^$"
1998   "Regexp matching invalid groups.")
1999
2000 ;;; End of variables.
2001
2002 ;; Define some autoload functions Gnus might use.
2003 (eval-and-compile
2004
2005   ;; This little mapcar goes through the list below and marks the
2006   ;; symbols in question as autoloaded functions.
2007   (mapcar
2008    (lambda (package)
2009      (let ((interactive (nth 1 (memq ':interactive package))))
2010        (mapcar
2011         (lambda (function)
2012           (let (keymap)
2013             (when (consp function)
2014               (setq keymap (car (memq 'keymap function)))
2015               (setq function (car function)))
2016             (unless (fboundp function)
2017               (autoload function (car package) nil interactive keymap))))
2018         (if (eq (nth 1 package) ':interactive)
2019             (nthcdr 3 package)
2020           (cdr package)))))
2021    '(("info" :interactive t Info-goto-node)
2022      ("pp" pp-to-string)
2023      ("ps-print" ps-print-preprint)
2024      ("message" :interactive t
2025       message-send-and-exit message-yank-original)
2026      ("babel" babel-as-string)
2027      ("nnmail" nnmail-split-fancy nnmail-article-group)
2028      ("nnvirtual" nnvirtual-catchup-group nnvirtual-convert-headers)
2029      ("rmailout" rmail-output rmail-output-to-rmail-file)
2030      ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2031       rmail-show-message rmail-summary-exists
2032       rmail-select-summary rmail-update-summary)
2033      ("gnus-audio" :interactive t gnus-audio-play)
2034      ("gnus-xmas" gnus-xmas-splash)
2035      ("gnus-soup" :interactive t
2036       gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2037       gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2038      ("nnsoup" nnsoup-pack-replies)
2039      ("score-mode" :interactive t gnus-score-mode)
2040      ("gnus-mh" gnus-summary-save-article-folder
2041       gnus-Folder-save-name gnus-folder-save-name)
2042      ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2043      ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2044       gnus-demon-add-rescan gnus-demon-add-scan-timestamps
2045       gnus-demon-add-disconnection gnus-demon-add-handler
2046       gnus-demon-remove-handler)
2047      ("gnus-demon" :interactive t
2048       gnus-demon-init gnus-demon-cancel)
2049      ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2050       gnus-tree-open gnus-tree-close gnus-carpal-setup-buffer)
2051      ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2052       gnus-nocem-unwanted-article-p)
2053      ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info
2054       gnus-server-server-name)
2055      ("gnus-srvr" gnus-browse-foreign-server)
2056      ("gnus-cite" :interactive t
2057       gnus-article-highlight-citation gnus-article-hide-citation-maybe
2058       gnus-article-hide-citation gnus-article-fill-cited-article
2059       gnus-article-hide-citation-in-followups)
2060      ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2061       gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2062       gnus-execute gnus-expunge gnus-batch-kill gnus-batch-score)
2063      ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2064       gnus-cache-possibly-remove-articles gnus-cache-request-article
2065       gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2066       gnus-cache-enter-remove-article gnus-cached-article-p
2067       gnus-cache-open gnus-cache-close gnus-cache-update-article
2068       gnus-cache-articles-in-group)
2069      ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2070       gnus-cache-remove-article gnus-summary-insert-cached-articles)
2071      ("gnus-score" :interactive t
2072       gnus-summary-increase-score gnus-summary-set-score
2073       gnus-summary-raise-thread gnus-summary-raise-same-subject
2074       gnus-summary-raise-score gnus-summary-raise-same-subject-and-select
2075       gnus-summary-lower-thread gnus-summary-lower-same-subject
2076       gnus-summary-lower-score gnus-summary-lower-same-subject-and-select
2077       gnus-summary-current-score gnus-score-delta-default
2078       gnus-score-flush-cache gnus-score-close
2079       gnus-possibly-score-headers gnus-score-followup-article
2080       gnus-score-followup-thread)
2081      ("gnus-score"
2082       (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2083       gnus-current-score-file-nondirectory gnus-score-adaptive
2084       gnus-score-find-trace gnus-score-file-name)
2085      ("gnus-cus" :interactive t gnus-custom-mode gnus-group-customize
2086       gnus-score-customize)
2087      ("gnus-topic" :interactive t gnus-topic-mode)
2088      ("gnus-topic" gnus-topic-remove-group gnus-topic-set-parameters
2089       gnus-subscribe-topics)
2090      ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2091      ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2092      ("gnus-uu" :interactive t
2093       gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2094       gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2095       gnus-uu-mark-by-regexp gnus-uu-mark-all
2096       gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2097       gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2098       gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2099       gnus-uu-decode-binhex gnus-uu-decode-uu-view
2100       gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2101       gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2102       gnus-uu-decode-binhex-view gnus-uu-unmark-thread
2103       gnus-uu-mark-over gnus-uu-post-news)
2104      ("gnus-uu" gnus-uu-delete-work-dir gnus-quote-arg-for-sh-or-csh
2105       gnus-uu-unmark-thread)
2106      ("gnus-msg" (gnus-summary-send-map keymap)
2107       gnus-article-mail gnus-copy-article-buffer gnus-following-method)
2108      ("gnus-msg" :interactive t
2109       gnus-group-post-news gnus-group-mail gnus-group-news
2110       gnus-summary-post-news gnus-summary-news-other-window
2111       gnus-summary-followup gnus-summary-followup-with-original
2112       gnus-summary-cancel-article gnus-summary-supersede-article
2113       gnus-post-news gnus-summary-reply gnus-summary-reply-with-original
2114       gnus-summary-mail-forward gnus-summary-mail-other-window
2115       gnus-summary-resend-message gnus-summary-resend-bounced-mail
2116       gnus-summary-wide-reply gnus-summary-followup-to-mail
2117       gnus-summary-followup-to-mail-with-original gnus-bug
2118       gnus-summary-wide-reply-with-original gnus-summary-post-forward
2119       gnus-summary-digest-mail-forward gnus-summary-digest-post-forward)
2120      ("gnus-picon" :interactive t gnus-treat-from-picon)
2121      ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2122       gnus-grouplens-mode)
2123      ("smiley" :interactive t gnus-smiley-display)
2124      ("gnus-win" gnus-configure-windows gnus-add-configuration)
2125      ("gnus-sum" gnus-summary-insert-line gnus-summary-read-group
2126       gnus-list-of-unread-articles gnus-list-of-read-articles
2127       gnus-offer-save-summaries gnus-make-thread-indent-array
2128       gnus-summary-exit gnus-update-read-articles gnus-summary-last-subject
2129       gnus-summary-skip-intangible gnus-summary-article-number
2130       gnus-data-header gnus-data-find gnus-summary-jump-to-other-group)
2131      ("gnus-group" gnus-group-insert-group-line gnus-group-quit
2132       gnus-group-list-groups gnus-group-first-unread-group
2133       gnus-group-set-mode-line gnus-group-set-info gnus-group-save-newsrc
2134       gnus-group-setup-buffer gnus-group-get-new-news
2135       gnus-group-make-help-group gnus-group-update-group
2136       gnus-group-iterate gnus-group-group-name)
2137      ("gnus-bcklg" gnus-backlog-request-article gnus-backlog-enter-article
2138       gnus-backlog-remove-article)
2139      ("gnus-art" gnus-article-read-summary-keys gnus-article-save
2140       gnus-article-prepare gnus-article-set-window-start
2141       gnus-article-next-page gnus-article-prev-page
2142       gnus-request-article-this-buffer gnus-article-mode
2143       gnus-article-setup-buffer gnus-narrow-to-page
2144       gnus-article-delete-invisible-text gnus-treat-article)
2145      ("gnus-art" :interactive t
2146       gnus-article-hide-headers gnus-article-hide-boring-headers
2147       gnus-article-treat-overstrike
2148       gnus-article-remove-cr gnus-article-remove-trailing-blank-lines
2149       gnus-article-display-x-face
2150       gnus-article-decode-HZ
2151       gnus-article-wash-html
2152       gnus-article-hide-pgp
2153       gnus-article-hide-pem gnus-article-hide-signature
2154       gnus-article-strip-leading-blank-lines gnus-article-date-local
2155       gnus-article-date-original gnus-article-date-lapsed
2156       gnus-article-show-all-headers gnus-article-show-all
2157       gnus-article-edit-mode gnus-article-edit-article
2158       gnus-article-edit-done article-decode-encoded-words
2159       gnus-start-date-timer gnus-stop-date-timer
2160       gnus-article-toggle-headers)
2161      ("gnus-int" gnus-request-type)
2162      ("gnus-start" gnus-newsrc-parse-options gnus-1 gnus-no-server-1
2163       gnus-dribble-enter gnus-read-init-file gnus-dribble-touch)
2164      ("gnus-dup" gnus-dup-suppress-articles gnus-dup-unsuppress-article
2165       gnus-dup-enter-articles)
2166      ("gnus-range" gnus-copy-sequence)
2167      ("gnus-eform" gnus-edit-form)
2168      ("gnus-move" :interactive t
2169       gnus-group-move-group-to-server gnus-change-server)
2170      ("gnus-logic" gnus-score-advanced)
2171      ("gnus-undo" gnus-undo-mode gnus-undo-register)
2172      ("gnus-async" gnus-async-request-fetched-article gnus-async-prefetch-next
2173       gnus-async-prefetch-article gnus-async-prefetch-remove-group
2174       gnus-async-halt-prefetch)
2175      ("gnus-offline"
2176       gnus-offline-setup)
2177      ("gnus-offline" :interactive t
2178       gnus-offline-toggle-plugged
2179       gnus-offline-set-unplugged-state
2180       gnus-offline-toggle-auto-hangup
2181       gnus-offline-toggle-on/off-send-mail
2182       gnus-offline-toggle-articles-to-fetch
2183       gnus-offline-set-interval-time
2184       gnus-offline-agent-expire)
2185      ("miee" :interactive t gnspool-get-news
2186       mail-spool-send news-spool-post)
2187      ("international/mw32misc" define-process-argument-editing
2188       general-process-argument-editing-function)
2189      ("gnus-agent" gnus-open-agent gnus-agent-get-function
2190       gnus-agent-save-groups gnus-agent-save-active gnus-agent-method-p
2191       gnus-agent-get-undownloaded-list gnus-agent-fetch-session
2192       gnus-summary-set-agent-mark gnus-agent-save-group-info)
2193      ("gnus-agent" :interactive t
2194       gnus-unplugged gnus-agentize gnus-agent-batch)
2195      ("gnus-vm" :interactive t gnus-summary-save-in-vm
2196       gnus-summary-save-article-vm)
2197      ("compface" uncompface)
2198      ("gnus-draft" :interactive t gnus-draft-mode gnus-group-send-queue)
2199      ("gnus-mlspl" gnus-group-split gnus-group-split-fancy)
2200      ("gnus-mlspl" :interactive t gnus-group-split-setup
2201       gnus-group-split-update))))
2202
2203 (eval-and-compile
2204   (unless (featurep 'xemacs)
2205     (if (>= emacs-major-version 21)
2206         (autoload 'x-face-decode-message-header "x-face-e21")
2207       (autoload 'gnus-smiley-display "gnus-bitmap" nil t)
2208       (autoload 'smiley-toggle-buffer "gnus-bitmap")
2209       (autoload 'x-face-mule-gnus-article-display-x-face "x-face-mule"))))
2210
2211 (unless (and (fboundp 'base64-encode-string)
2212              (subrp (symbol-function 'base64-encode-string)))
2213   (require 'base64))
2214
2215 ;; To search articles with Namazu.
2216 (autoload 'gnus-namazu-search "gnus-namazu" nil t)
2217
2218 ;; To make nnir groups.
2219 (autoload 'gnus-group-make-nnir-group "nnir" nil t)
2220
2221 ;; To make shimbun groups.
2222 (autoload 'gnus-group-make-shimbun-group "nnshimbun" nil t)
2223
2224 ;; A tool for the developers.
2225 (autoload 'find-cl-run-time-functions "gnus-clfns" nil t)
2226
2227 ;;; gnus-sum.el thingies
2228
2229
2230 (defcustom gnus-summary-line-format "%U%R%z%I%(%[%4L: %-23,23n%]%) %s\n"
2231   "*The format specification of the lines in the summary buffer.
2232
2233 It works along the same lines as a normal formatting string,
2234 with some simple extensions.
2235
2236 %N   Article number, left padded with spaces (string)
2237 %S   Subject (string)
2238 %s   Subject if it is at the root of a thread, and \"\" otherwise (string)
2239 %n   Name of the poster (string)
2240 %a   Extracted name of the poster (string)
2241 %A   Extracted address of the poster (string)
2242 %F   Contents of the From: header (string)
2243 %f   Contents of the From: or To: headers (string)
2244 %x   Contents of the Xref: header (string)
2245 %D   Date of the article (string)
2246 %d   Date of the article (string) in DD-MMM format
2247 %o   Date of the article (string) in YYYYMMDD`T'HHMMSS format
2248 %M   Message-id of the article (string)
2249 %r   References of the article (string)
2250 %c   Number of characters in the article (integer)
2251 %L   Number of lines in the article (integer)
2252 %I   Indentation based on thread level (a string of spaces)
2253 %B   A complex trn-style thread tree (string)
2254      The variables `gnus-sum-thread-*' can be used for customization.
2255 %T   A string with two possible values: 80 spaces if the article
2256      is on thread level two or larger and 0 spaces on level one
2257 %R   \"A\" if this article has been replied to, \" \" otherwise (character)
2258 %U   Status of this article (character, \"R\", \"K\", \"-\" or \" \")
2259 %[   Opening bracket (character, \"[\" or \"<\")
2260 %]   Closing bracket (character, \"]\" or \">\")
2261 %>   Spaces of length thread-level (string)
2262 %<   Spaces of length (- 20 thread-level) (string)
2263 %i   Article score (number)
2264 %z   Article zcore (character)
2265 %t   Number of articles under the current thread (number).
2266 %e   Whether the thread is empty or not (character).
2267 %l   GroupLens score (string).
2268 %V   Total thread score (number).
2269 %P   The line number (number).
2270 %O   Download mark (character).
2271 %u   User defined specifier.  The next character in the format string should
2272      be a letter.  Gnus will call the function gnus-user-format-function-X,
2273      where X is the letter following %u.  The function will be passed the
2274      current header as argument.  The function should return a string, which
2275      will be inserted into the summary just like information from any other
2276      summary specifier.
2277
2278 Text between %( and %) will be highlighted with `gnus-mouse-face'
2279 when the mouse point is placed inside the area.  There can only be one
2280 such area.
2281
2282 The %U (status), %R (replied) and %z (zcore) specs have to be handled
2283 with care.  For reasons of efficiency, Gnus will compute what column
2284 these characters will end up in, and \"hard-code\" that.  This means that
2285 it is invalid to have these specs after a variable-length spec.  Well,
2286 you might not be arrested, but your summary buffer will look strange,
2287 which is bad enough.
2288
2289 The smart choice is to have these specs as far to the left as
2290 possible.
2291
2292 This restriction may disappear in later versions of Gnus."
2293   :type 'string
2294   :group 'gnus-summary-format)
2295
2296 ;;;
2297 ;;; Skeleton keymaps
2298 ;;;
2299
2300 (defun gnus-suppress-keymap (keymap)
2301   (suppress-keymap keymap)
2302   (let ((keys `([backspace] [delete] "\177" "\M-u"))) ;gnus-mouse-2
2303     (while keys
2304       (define-key keymap (pop keys) 'undefined))))
2305
2306 (defvar gnus-article-mode-map
2307   (let ((keymap (make-sparse-keymap)))
2308     (gnus-suppress-keymap keymap)
2309     keymap))
2310 (defvar gnus-summary-mode-map
2311   (let ((keymap (make-keymap)))
2312     (gnus-suppress-keymap keymap)
2313     keymap))
2314 (defvar gnus-group-mode-map
2315   (let ((keymap (make-keymap)))
2316     (gnus-suppress-keymap keymap)
2317     keymap))
2318
2319 \f
2320
2321 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2322 ;; If you want the cursor to go somewhere else, set these two
2323 ;; functions in some startup hook to whatever you want.
2324 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2325 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2326
2327 ;;; Various macros and substs.
2328
2329 (defun gnus-header-from (header)
2330   (mail-header-from header))
2331
2332 (defmacro gnus-gethash (string hashtable)
2333   "Get hash value of STRING in HASHTABLE."
2334   `(symbol-value (intern-soft ,string ,hashtable)))
2335
2336 (defmacro gnus-sethash (string value hashtable)
2337   "Set hash value.  Arguments are STRING, VALUE, and HASHTABLE."
2338   `(set (intern ,string ,hashtable) ,value))
2339 (put 'gnus-sethash 'edebug-form-spec '(form form form))
2340
2341 (defmacro gnus-group-unread (group)
2342   "Get the currently computed number of unread articles in GROUP."
2343   `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2344
2345 (defmacro gnus-group-entry (group)
2346   "Get the newsrc entry for GROUP."
2347   `(gnus-gethash ,group gnus-newsrc-hashtb))
2348
2349 (defmacro gnus-active (group)
2350   "Get active info on GROUP."
2351   `(gnus-gethash ,group gnus-active-hashtb))
2352
2353 (defmacro gnus-set-active (group active)
2354   "Set GROUP's active info."
2355   `(gnus-sethash ,group ,active gnus-active-hashtb))
2356
2357 ;; Info access macros.
2358
2359 (defmacro gnus-info-group (info)
2360   `(nth 0 ,info))
2361 (defmacro gnus-info-rank (info)
2362   `(nth 1 ,info))
2363 (defmacro gnus-info-read (info)
2364   `(nth 2 ,info))
2365 (defmacro gnus-info-marks (info)
2366   `(nth 3 ,info))
2367 (defmacro gnus-info-method (info)
2368   `(nth 4 ,info))
2369 (defmacro gnus-info-params (info)
2370   `(nth 5 ,info))
2371
2372 (defmacro gnus-info-level (info)
2373   `(let ((rank (gnus-info-rank ,info)))
2374      (if (consp rank)
2375          (car rank)
2376        rank)))
2377 (defmacro gnus-info-score (info)
2378   `(let ((rank (gnus-info-rank ,info)))
2379      (or (and (consp rank) (cdr rank)) 0)))
2380
2381 (defmacro gnus-info-set-group (info group)
2382   `(setcar ,info ,group))
2383 (defmacro gnus-info-set-rank (info rank)
2384   `(setcar (nthcdr 1 ,info) ,rank))
2385 (defmacro gnus-info-set-read (info read)
2386   `(setcar (nthcdr 2 ,info) ,read))
2387 (defmacro gnus-info-set-marks (info marks &optional extend)
2388   (if extend
2389       `(gnus-info-set-entry ,info ,marks 3)
2390     `(setcar (nthcdr 3 ,info) ,marks)))
2391 (defmacro gnus-info-set-method (info method &optional extend)
2392   (if extend
2393       `(gnus-info-set-entry ,info ,method 4)
2394     `(setcar (nthcdr 4 ,info) ,method)))
2395 (defmacro gnus-info-set-params (info params &optional extend)
2396   (if extend
2397       `(gnus-info-set-entry ,info ,params 5)
2398     `(setcar (nthcdr 5 ,info) ,params)))
2399
2400 (defun gnus-info-set-entry (info entry number)
2401   ;; Extend the info until we have enough elements.
2402   (while (<= (length info) number)
2403     (nconc info (list nil)))
2404   ;; Set the entry.
2405   (setcar (nthcdr number info) entry))
2406
2407 (defmacro gnus-info-set-level (info level)
2408   `(let ((rank (cdr ,info)))
2409      (if (consp (car rank))
2410          (setcar (car rank) ,level)
2411        (setcar rank ,level))))
2412 (defmacro gnus-info-set-score (info score)
2413   `(let ((rank (cdr ,info)))
2414      (if (consp (car rank))
2415          (setcdr (car rank) ,score)
2416        (setcar rank (cons (car rank) ,score)))))
2417
2418 (defmacro gnus-get-info (group)
2419   `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2420
2421 ;;; Load the compatability functions.
2422
2423 (require 'gnus-ems)
2424
2425 \f
2426 ;;;
2427 ;;; Shutdown
2428 ;;;
2429
2430 (defvar gnus-shutdown-alist nil)
2431
2432 (defun gnus-add-shutdown (function &rest symbols)
2433   "Run FUNCTION whenever one of SYMBOLS is shut down."
2434   (push (cons function symbols) gnus-shutdown-alist))
2435
2436 (defun gnus-shutdown (symbol)
2437   "Shut down everything that waits for SYMBOL."
2438   (let ((alist gnus-shutdown-alist)
2439         entry)
2440     (while (setq entry (pop alist))
2441       (when (memq symbol (cdr entry))
2442         (funcall (car entry))))))
2443
2444 \f
2445 ;;;
2446 ;;; Gnus Utility Functions
2447 ;;;
2448
2449 (defun gnus-find-subscribed-addresses ()
2450   "Return a regexp matching the addresses of all subscribed mail groups.
2451 It consists of the `to-address' or `to-list' parameter of all groups
2452 with a `subscribed' parameter."
2453   (let (group address addresses)
2454     (dolist (entry (cdr gnus-newsrc-alist))
2455       (setq group (car entry))
2456       (when (gnus-group-find-parameter group 'subscribed)
2457         (setq address (or (gnus-group-fast-parameter group 'to-address)
2458                           (gnus-group-fast-parameter group 'to-list)))
2459         (when address
2460           (push address addresses))))
2461     (list (mapconcat 'regexp-quote addresses "\\|"))))
2462
2463 (defmacro gnus-string-or (&rest strings)
2464   "Return the first element of STRINGS that is a non-blank string.
2465 STRINGS will be evaluated in normal `or' order."
2466   `(gnus-string-or-1 ',strings))
2467
2468 (defun gnus-string-or-1 (strings)
2469   (let (string)
2470     (while strings
2471       (setq string (eval (pop strings)))
2472       (if (string-match "^[ \t]*$" string)
2473           (setq string nil)
2474         (setq strings nil)))
2475     string))
2476
2477 (defun gnus-info-find-node (&optional nodename)
2478   "Find Info documentation of Gnus."
2479   (interactive)
2480   ;; Enlarge info window if needed.
2481   (let (gnus-info-buffer)
2482     (Info-goto-node
2483      (format "(%s)%s"
2484              (or gnus-info-filename
2485                  (get-language-info current-language-environment 'gnus-info)
2486                  "gnus")
2487              (or nodename
2488                  (cadr (assq major-mode gnus-info-nodes))
2489                  (and (eq (current-buffer) (get-buffer gnus-article-buffer))
2490                       (cadr (assq 'gnus-article-mode gnus-info-nodes))))))
2491     (setq gnus-info-buffer (current-buffer))
2492     (gnus-configure-windows 'info)))
2493
2494 ;;;
2495 ;;; gnus-interactive
2496 ;;;
2497
2498 (defvar gnus-current-prefix-symbol nil
2499   "Current prefix symbol.")
2500
2501 (defvar gnus-current-prefix-symbols nil
2502   "List of current prefix symbols.")
2503
2504 (defun gnus-interactive (string &optional params)
2505   "Return a list that can be fed to `interactive'.
2506 See `interactive' for full documentation.
2507
2508 Adds the following specs:
2509
2510 y -- The current symbolic prefix.
2511 Y -- A list of the current symbolic prefix(es).
2512 A -- Article number.
2513 H -- Article header.
2514 g -- Group name."
2515   (let ((i 0)
2516         out c prompt)
2517     (while (< i (length string))
2518       (string-match ".\\([^\n]*\\)\n?" string i)
2519       (setq c (aref string i))
2520       (when (match-end 1)
2521         (setq prompt (match-string 1 string)))
2522       (setq i (match-end 0))
2523       ;; We basically emulate just about everything that
2524       ;; `interactive' does, but add the specs listed above.
2525       (push
2526        (cond
2527         ((= c ?a)
2528          (completing-read prompt obarray 'fboundp t))
2529         ((= c ?b)
2530          (read-buffer prompt (current-buffer) t))
2531         ((= c ?B)
2532          (read-buffer prompt (other-buffer (current-buffer))))
2533         ((= c ?c)
2534          (read-char))
2535         ((= c ?C)
2536          (completing-read prompt obarray 'commandp t))
2537         ((= c ?d)
2538          (point))
2539         ((= c ?D)
2540          (read-file-name prompt nil default-directory 'lambda))
2541         ((= c ?f)
2542          (read-file-name prompt nil nil 'lambda))
2543         ((= c ?F)
2544          (read-file-name prompt))
2545         ((= c ?k)
2546          (read-key-sequence prompt))
2547         ((= c ?K)
2548          (error "Not implemented spec"))
2549         ((= c ?e)
2550          (error "Not implemented spec"))
2551         ((= c ?m)
2552          (mark))
2553         ((= c ?N)
2554          (error "Not implemented spec"))
2555         ((= c ?n)
2556          (string-to-number (read-from-minibuffer prompt)))
2557         ((= c ?p)
2558          (prefix-numeric-value current-prefix-arg))
2559         ((= c ?P)
2560          current-prefix-arg)
2561         ((= c ?r)
2562          'gnus-prefix-nil)
2563         ((= c ?s)
2564          (read-string prompt))
2565         ((= c ?S)
2566          (intern (read-string prompt)))
2567         ((= c ?v)
2568          (read-variable prompt))
2569         ((= c ?x)
2570          (read-minibuffer prompt))
2571         ((= c ?x)
2572          (eval-minibuffer prompt))
2573         ;; And here the new specs come.
2574         ((= c ?y)
2575          gnus-current-prefix-symbol)
2576         ((= c ?Y)
2577          gnus-current-prefix-symbols)
2578         ((= c ?g)
2579          (gnus-group-group-name))
2580         ((= c ?A)
2581          (gnus-summary-skip-intangible)
2582          (or (get-text-property (point) 'gnus-number)
2583              (gnus-summary-last-subject)))
2584         ((= c ?H)
2585          (gnus-data-header (gnus-data-find (gnus-summary-article-number))))
2586         (t
2587          (error "Non-implemented spec")))
2588        out)
2589       (cond
2590        ((= c ?r)
2591         (push (if (< (point) (mark)) (point) (mark)) out)
2592         (push (if (> (point) (mark)) (point) (mark)) out))))
2593     (setq out (delq 'gnus-prefix-nil out))
2594     (nreverse out)))
2595
2596 (defun gnus-symbolic-argument (&optional arg)
2597   "Read a symbolic argument and a command, and then execute command."
2598   (interactive "P")
2599   (let* ((in-command (this-command-keys))
2600          (command in-command)
2601          gnus-current-prefix-symbols
2602          gnus-current-prefix-symbol
2603          syms)
2604     (while (equal in-command command)
2605       (message "%s-" (key-description (this-command-keys)))
2606       (push (intern (char-to-string (read-char))) syms)
2607       (setq command (read-key-sequence nil t)))
2608     (setq gnus-current-prefix-symbols (nreverse syms)
2609           gnus-current-prefix-symbol (car gnus-current-prefix-symbols))
2610     (call-interactively (key-binding command t))))
2611
2612 ;;; More various functions.
2613
2614 (defsubst gnus-check-backend-function (func group)
2615   "Check whether GROUP supports function FUNC.
2616 GROUP can either be a string (a group name) or a select method."
2617   (ignore-errors
2618     (let ((method (if (stringp group)
2619                       (car (gnus-find-method-for-group group))
2620                     group)))
2621       (unless (featurep method)
2622         (require method))
2623       (fboundp (intern (format "%s-%s" method func))))))
2624
2625 (defun gnus-group-read-only-p (&optional group)
2626   "Check whether GROUP supports editing or not.
2627 If GROUP is nil, `gnus-newsgroup-name' will be checked instead.  Note
2628 that that variable is buffer-local to the summary buffers."
2629   (let ((group (or group gnus-newsgroup-name)))
2630     (not (gnus-check-backend-function 'request-replace-article group))))
2631
2632 (defun gnus-virtual-group-p (group)
2633   "Say whether GROUP is virtual or not."
2634   (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
2635                         gnus-valid-select-methods)))
2636
2637 (defun gnus-news-group-p (group &optional article)
2638   "Return non-nil if GROUP (and ARTICLE) come from a news server."
2639   (cond ((gnus-member-of-valid 'post group) ;Ordinary news group
2640          t)                             ;is news of course.
2641         ((not (gnus-member-of-valid 'post-mail group)) ;Non-combined.
2642          nil)                           ;must be mail then.
2643         ((vectorp article)              ;Has header info.
2644          (eq (gnus-request-type group (mail-header-id article)) 'news))
2645         ((null article)                 ;Hasn't header info
2646          (eq (gnus-request-type group) 'news)) ;(unknown ==> mail)
2647         ((< article 0)                  ;Virtual message
2648          nil)                           ;we don't know, guess mail.
2649         (t                              ;Has positive number
2650          (eq (gnus-request-type group article) 'news)))) ;use it.
2651
2652 ;; Returns a list of writable groups.
2653 (defun gnus-writable-groups ()
2654   (let ((alist gnus-newsrc-alist)
2655         groups group)
2656     (while (setq group (car (pop alist)))
2657       (unless (gnus-group-read-only-p group)
2658         (push group groups)))
2659     (nreverse groups)))
2660
2661 ;; Check whether to use long file names.
2662 (defun gnus-use-long-file-name (symbol)
2663   ;; The variable has to be set...
2664   (and gnus-use-long-file-name
2665        ;; If it isn't a list, then we return t.
2666        (or (not (listp gnus-use-long-file-name))
2667            ;; If it is a list, and the list contains `symbol', we
2668            ;; return nil.
2669            (not (memq symbol gnus-use-long-file-name)))))
2670
2671 ;; Generate a unique new group name.
2672 (defun gnus-generate-new-group-name (leaf)
2673   (let ((name leaf)
2674         (num 0))
2675     (while (gnus-gethash name gnus-newsrc-hashtb)
2676       (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2677     name))
2678
2679 (defun gnus-ephemeral-group-p (group)
2680   "Say whether GROUP is ephemeral or not."
2681   (gnus-group-get-parameter group 'quit-config t))
2682
2683 (defun gnus-group-quit-config (group)
2684   "Return the quit-config of GROUP."
2685   (gnus-group-get-parameter group 'quit-config t))
2686
2687 (defun gnus-kill-ephemeral-group (group)
2688   "Remove ephemeral GROUP from relevant structures."
2689   (gnus-sethash group nil gnus-newsrc-hashtb))
2690
2691 (defun gnus-simplify-mode-line ()
2692   "Make mode lines a bit simpler."
2693   (setq mode-line-modified (cdr gnus-mode-line-modified))
2694   (when (listp mode-line-format)
2695     (make-local-variable 'mode-line-format)
2696     (setq mode-line-format (copy-sequence mode-line-format))
2697     (when (equal (nth 3 mode-line-format) "   ")
2698       (setcar (nthcdr 3 mode-line-format) " "))))
2699
2700 ;;; Servers and groups.
2701
2702 (defsubst gnus-server-add-address (method)
2703   (let ((method-name (symbol-name (car method))))
2704     (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
2705              (not (assq (intern (concat method-name "-address")) method))
2706              (memq 'physical-address (assq (car method)
2707                                            gnus-valid-select-methods)))
2708         (append method (list (list (intern (concat method-name "-address"))
2709                                    (nth 1 method))))
2710       method)))
2711
2712 (defsubst gnus-server-get-method (group method)
2713   ;; Input either a server name, and extended server name, or a
2714   ;; select method, and return a select method.
2715   (cond ((stringp method)
2716          (gnus-server-to-method method))
2717         ((equal method gnus-select-method)
2718          gnus-select-method)
2719         ((and (stringp (car method))
2720               group)
2721          (gnus-server-extend-method group method))
2722         ((and method
2723               (not group)
2724               (equal (cadr method) ""))
2725          method)
2726         (t
2727          (gnus-server-add-address method))))
2728
2729 (defun gnus-server-to-method (server)
2730   "Map virtual server names to select methods."
2731   (or
2732    ;; Is this a method, perhaps?
2733    (and server (listp server) server)
2734    ;; Perhaps this is the native server?
2735    (and (equal server "native") gnus-select-method)
2736    ;; It should be in the server alist.
2737    (cdr (assoc server gnus-server-alist))
2738    ;; It could be in the predefined server alist.
2739    (cdr (assoc server gnus-predefined-server-alist))
2740    ;; If not, we look through all the opened server
2741    ;; to see whether we can find it there.
2742    (let ((opened gnus-opened-servers))
2743      (while (and opened
2744                  (not (equal server (format "%s:%s" (caaar opened)
2745                                             (cadaar opened)))))
2746        (pop opened))
2747      (caar opened))
2748    ;; It could be a named method, search all servers
2749    (let ((servers gnus-secondary-select-methods))
2750      (while (and servers
2751                  (not (equal server (format "%s:%s" (caar servers)
2752                                             (cadar servers)))))
2753        (pop servers))
2754      (car servers))))
2755
2756 (defmacro gnus-method-equal (ss1 ss2)
2757   "Say whether two servers are equal."
2758   `(let ((s1 ,ss1)
2759          (s2 ,ss2))
2760      (or (equal s1 s2)
2761          (and (= (length s1) (length s2))
2762               (progn
2763                 (while (and s1 (member (car s1) s2))
2764                   (setq s1 (cdr s1)))
2765                 (null s1))))))
2766
2767 (defun gnus-methods-equal-p (m1 m2)
2768   (let ((m1 (or m1 gnus-select-method))
2769         (m2 (or m2 gnus-select-method)))
2770     (or (equal m1 m2)
2771         (and (eq (car m1) (car m2))
2772              (or (not (memq 'address (assoc (symbol-name (car m1))
2773                                             gnus-valid-select-methods)))
2774                  (equal (nth 1 m1) (nth 1 m2)))))))
2775
2776 (defun gnus-server-equal (m1 m2)
2777   "Say whether two methods are equal."
2778   (let ((m1 (cond ((null m1) gnus-select-method)
2779                   ((stringp m1) (gnus-server-to-method m1))
2780                   (t m1)))
2781         (m2 (cond ((null m2) gnus-select-method)
2782                   ((stringp m2) (gnus-server-to-method m2))
2783                   (t m2))))
2784     (gnus-method-equal m1 m2)))
2785
2786 (defun gnus-servers-using-backend (backend)
2787   "Return a list of known servers using BACKEND."
2788   (let ((opened gnus-opened-servers)
2789         out)
2790     (while opened
2791       (when (eq backend (caaar opened))
2792         (push (caar opened) out))
2793       (pop opened))
2794     out))
2795
2796 (defun gnus-archive-server-wanted-p ()
2797   "Say whether the user wants to use the archive server."
2798   (cond
2799    ((or (not gnus-message-archive-method)
2800         (not gnus-message-archive-group))
2801     nil)
2802    ((and gnus-message-archive-method gnus-message-archive-group)
2803     t)
2804    (t
2805     (let ((active (cadr (assq 'nnfolder-active-file
2806                               gnus-message-archive-method))))
2807       (and active
2808            (file-exists-p active))))))
2809
2810 (defsubst gnus-method-to-server-name (method)
2811   (concat
2812    (format "%s" (car method))
2813    (when (and
2814           (or (assoc (format "%s" (car method))
2815                      (gnus-methods-using 'address))
2816               (gnus-server-equal method gnus-message-archive-method))
2817           (nth 1 method)
2818           (not (string= (nth 1 method) "")))
2819      (concat "+" (nth 1 method)))))
2820
2821 (defsubst gnus-method-to-full-server-name (method)
2822   (format "%s+%s" (car method) (nth 1 method)))
2823
2824 (defun gnus-group-prefixed-name (group method)
2825   "Return the whole name from GROUP and METHOD."
2826   (and (stringp method) (setq method (gnus-server-to-method method)))
2827   (if (or (not method)
2828           (gnus-server-equal method "native")
2829           (string-match ":" group))
2830       group
2831     (concat (gnus-method-to-server-name method) ":" group)))
2832
2833 (defun gnus-group-real-prefix (group)
2834   "Return the prefix of the current group name."
2835   (if (string-match "^[^:]+:" group)
2836       (substring group 0 (match-end 0))
2837     ""))
2838
2839 (defun gnus-group-method (group)
2840   "Return the server or method used for selecting GROUP.
2841 You should probably use `gnus-find-method-for-group' instead."
2842   (let ((prefix (gnus-group-real-prefix group)))
2843     (if (equal prefix "")
2844         gnus-select-method
2845       (let ((servers gnus-opened-servers)
2846             (server "")
2847             backend possible found)
2848         (if (string-match "^[^\\+]+\\+" prefix)
2849             (setq backend (intern (substring prefix 0 (1- (match-end 0))))
2850                   server (substring prefix (match-end 0) (1- (length prefix))))
2851           (setq backend (intern (substring prefix 0 (1- (length prefix))))))
2852         (while servers
2853           (when (eq (caaar servers) backend)
2854             (setq possible (caar servers))
2855             (when (equal (cadaar servers) server)
2856               (setq found (caar servers))))
2857           (pop servers))
2858         (or (car (rassoc found gnus-server-alist))
2859             found
2860             (car (rassoc possible gnus-server-alist))
2861             possible
2862             (list backend server))))))
2863
2864 (defsubst gnus-native-method-p (method)
2865   "Return whether METHOD is the native select method."
2866   (gnus-method-equal method gnus-select-method))
2867
2868 (defsubst gnus-secondary-method-p (method)
2869   "Return whether METHOD is a secondary select method."
2870   (let ((methods gnus-secondary-select-methods)
2871         (gmethod (gnus-server-get-method nil method)))
2872     (while (and methods
2873                 (not (gnus-method-equal
2874                       (gnus-server-get-method nil (car methods))
2875                       gmethod)))
2876       (setq methods (cdr methods)))
2877     methods))
2878
2879 (defun gnus-method-simplify (method)
2880   "Return the shortest uniquely identifying string or method for METHOD."
2881   (cond ((stringp method)
2882          method)
2883         ((gnus-native-method-p method)
2884          nil)
2885         ((gnus-secondary-method-p method)
2886          (format "%s:%s" (nth 0 method) (nth 1 method)))
2887         (t
2888          method)))
2889
2890 (defun gnus-groups-from-server (server)
2891   "Return a list of all groups that are fetched from SERVER."
2892   (let ((alist (cdr gnus-newsrc-alist))
2893         info groups)
2894     (while (setq info (pop alist))
2895       (when (gnus-server-equal (gnus-info-method info) server)
2896         (push (gnus-info-group info) groups)))
2897     (sort groups 'string<)))
2898
2899 (defun gnus-group-foreign-p (group)
2900   "Say whether a group is foreign or not."
2901   (and (not (gnus-group-native-p group))
2902        (not (gnus-group-secondary-p group))))
2903
2904 (defun gnus-group-native-p (group)
2905   "Say whether the group is native or not."
2906   (not (string-match ":" group)))
2907
2908 (defun gnus-group-secondary-p (group)
2909   "Say whether the group is secondary or not."
2910   (gnus-secondary-method-p (gnus-find-method-for-group group)))
2911
2912 (defun gnus-parameters-get-parameter (group)
2913   "Return the group parameters for GROUP from `gnus-parameters'."
2914   (let (params-list)
2915     (dolist (elem gnus-parameters)
2916       (when (string-match (car elem) group)
2917         (setq params-list
2918               (nconc (gnus-expand-group-parameters
2919                       (car elem) (cdr elem) group)
2920                      params-list))))
2921     params-list))
2922
2923 (defun gnus-expand-group-parameter (match value group)
2924   "Use MATCH to expand VALUE in GROUP."
2925   (with-temp-buffer
2926     (insert group)
2927     (goto-char (point-min))
2928     (while (re-search-forward match nil t)
2929       (replace-match value))
2930     (buffer-string)))
2931
2932 (defun gnus-expand-group-parameters (match parameters group)
2933   "Go through PARAMETERS and expand them according to the match data."
2934   (let (new)
2935     (dolist (elem parameters)
2936       (if (and (stringp (cdr elem))
2937                (string-match "\\\\" (cdr elem)))
2938           (push (cons (car elem)
2939                       (gnus-expand-group-parameter match (cdr elem) group))
2940                 new)
2941         (push elem new)))
2942     new))
2943
2944 (defun gnus-group-fast-parameter (group symbol &optional allow-list)
2945   "For GROUP, return the value of SYMBOL.
2946
2947 You should call this in the `gnus-group-buffer' buffer.
2948 The function `gnus-group-find-parameter' will do that for you."
2949   ;; The speed trick:  No cons'ing and quit early.
2950   (or (let ((params (funcall gnus-group-get-parameter-function group)))
2951         ;; Start easy, check the "real" group parameters.
2952         (gnus-group-parameter-value params symbol allow-list))
2953       ;; We didn't found it there, try `gnus-parameters'.
2954       (let ((result nil)
2955             (head nil)
2956             (tail gnus-parameters))
2957         ;; A good old-fashioned non-cl loop.
2958         (while tail
2959           (setq head (car tail)
2960                 tail (cdr tail))
2961           ;; The car is regexp matching for matching the group name.
2962           (when (string-match (car head) group)
2963             ;; The cdr is the parameters.
2964             (setq result (gnus-group-parameter-value (cdr head)
2965                                                      symbol allow-list))
2966             (when result
2967               ;; Expand if necessary.
2968               (if (and (stringp result) (string-match "\\\\" result))
2969                   (setq result (gnus-expand-group-parameter (car head)
2970                                                             result group)))
2971               ;; Exit the loop early.
2972               (setq tail nil))))
2973         ;; Done.
2974         result)))
2975
2976 (defun gnus-group-find-parameter (group &optional symbol allow-list)
2977   "Return the group parameters for GROUP.
2978 If SYMBOL, return the value of that symbol in the group parameters.
2979
2980 If you call this function inside a loop, consider using the faster
2981 `gnus-group-fast-parameter' instead."
2982   (save-excursion
2983     (set-buffer gnus-group-buffer)
2984     (if symbol
2985         (gnus-group-fast-parameter group symbol allow-list)
2986       (let ((parameters
2987              (nconc
2988               (copy-sequence
2989                (funcall gnus-group-get-parameter-function group))
2990               (gnus-parameters-get-parameter group))))
2991         parameters))))
2992
2993 (defun gnus-group-get-parameter (group &optional symbol allow-list)
2994   "Return the group parameters for GROUP.
2995 If SYMBOL, return the value of that symbol in the group parameters.
2996 Most functions should use `gnus-group-find-parameter', which
2997 also examines the topic parameters."
2998   (let ((params (gnus-info-params (gnus-get-info group))))
2999     (if symbol
3000         (gnus-group-parameter-value params symbol allow-list)
3001       params)))
3002
3003 (defun gnus-group-parameter-value (params symbol &optional allow-list)
3004   "Return the value of SYMBOL in group PARAMS."
3005   ;; We only wish to return group parameters (dotted lists) and
3006   ;; not local variables, which may have the same names.
3007   ;; But first we handle single elements...
3008   (or (car (memq symbol params))
3009       ;; Handle alist.
3010       (let (elem)
3011         (catch 'found
3012           (while (setq elem (pop params))
3013             (when (and (consp elem)
3014                        (eq (car elem) symbol)
3015                        (or allow-list
3016                            (atom (cdr elem))))
3017               (throw 'found (cdr elem))))))))
3018
3019 (defun gnus-group-add-parameter (group param)
3020   "Add parameter PARAM to GROUP."
3021   (let ((info (gnus-get-info group)))
3022     (when info
3023       (gnus-group-remove-parameter group (if (consp param) (car param) param))
3024       ;; Cons the new param to the old one and update.
3025       (gnus-group-set-info (cons param (gnus-info-params info))
3026                            group 'params))))
3027
3028 (defun gnus-group-set-parameter (group name value)
3029   "Set parameter NAME to VALUE in GROUP."
3030   (let ((info (gnus-get-info group)))
3031     (when info
3032       (gnus-group-remove-parameter group name)
3033       (let ((old-params (gnus-info-params info))
3034             (new-params (list (cons name value))))
3035         (while old-params
3036           (when (or (not (listp (car old-params)))
3037                     (not (eq (caar old-params) name)))
3038             (setq new-params (append new-params (list (car old-params)))))
3039           (setq old-params (cdr old-params)))
3040         (gnus-group-set-info new-params group 'params)))))
3041
3042 (defun gnus-group-remove-parameter (group name)
3043   "Remove parameter NAME from GROUP."
3044   (let ((info (gnus-get-info group)))
3045     (when info
3046       (let ((params (gnus-info-params info)))
3047         (when params
3048           (setq params (delq name params))
3049           (while (assq name params)
3050             (gnus-pull name params))
3051           (gnus-info-set-params info params))))))
3052
3053 (defun gnus-group-add-score (group &optional score)
3054   "Add SCORE to the GROUP score.
3055 If SCORE is nil, add 1 to the score of GROUP."
3056   (let ((info (gnus-get-info group)))
3057     (when info
3058       (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
3059
3060 (defun gnus-short-group-name (group &optional levels)
3061   "Collapse GROUP name LEVELS.
3062 Select methods are stripped and any remote host name is stripped down to
3063 just the host name."
3064   (let* ((name "")
3065          (foreign "")
3066          (depth 0)
3067          (skip 1)
3068          (levels (or levels
3069                      gnus-group-uncollapsed-levels
3070                      (progn
3071                        (while (string-match "\\." group skip)
3072                          (setq skip (match-end 0)
3073                                depth (+ depth 1)))
3074                        depth))))
3075     ;; Separate foreign select method from group name and collapse.
3076     ;; If method contains a server, collapse to non-domain server name,
3077     ;; otherwise collapse to select method.
3078     (let* ((colon (string-match ":" group))
3079            (server (and colon (substring group 0 colon)))
3080            (plus (and server (string-match "+" server))))
3081       (when server
3082         (if plus
3083             (setq foreign (substring server (+ 1 plus)
3084                                      (string-match "\\." server))
3085                   group (substring group (+ 1 colon)))
3086           (setq foreign server
3087                 group (substring group (+ 1 colon))))
3088         (setq foreign (concat foreign ":")))
3089       ;; Collapse group name leaving LEVELS uncollapsed elements
3090       (let* ((slist (split-string group "/"))
3091              (slen (length slist))
3092              (dlist (split-string group "\\."))
3093              (dlen (length dlist))
3094              glist
3095              glen
3096              gsep
3097              res)
3098         (if (> slen dlen)
3099             (setq glist slist
3100                   glen slen
3101                   gsep "/")
3102           (setq glist dlist
3103                 glen dlen
3104                 gsep "."))
3105         (setq levels (- glen levels))
3106         (dolist (g glist)
3107           (push (if (>= (decf levels) 0)
3108                     (if (zerop (length g))
3109                         ""
3110                       (substring g 0 1))
3111                   g)
3112                 res))
3113         (concat foreign (mapconcat 'identity (nreverse res) gsep))))))
3114
3115 (defun gnus-narrow-to-body ()
3116   "Narrow to the body of an article."
3117   (narrow-to-region
3118    (progn
3119      (goto-char (point-min))
3120      (or (search-forward "\n\n" nil t)
3121          (point-max)))
3122    (point-max)))
3123
3124 \f
3125 ;;;
3126 ;;; Kill file handling.
3127 ;;;
3128
3129 (defun gnus-apply-kill-file ()
3130   "Apply a kill file to the current newsgroup.
3131 Returns the number of articles marked as read."
3132   (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
3133           (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
3134       (gnus-apply-kill-file-internal)
3135     0))
3136
3137 (defun gnus-kill-save-kill-buffer ()
3138   (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
3139     (when (get-file-buffer file)
3140       (save-excursion
3141         (set-buffer (get-file-buffer file))
3142         (when (buffer-modified-p)
3143           (save-buffer))
3144         (kill-buffer (current-buffer))))))
3145
3146 (defcustom gnus-kill-file-name "KILL"
3147   "Suffix of the kill files."
3148   :group 'gnus-score-kill
3149   :group 'gnus-score-files
3150   :type 'string)
3151
3152 (defun gnus-newsgroup-kill-file (newsgroup)
3153   "Return the name of a kill file name for NEWSGROUP.
3154 If NEWSGROUP is nil, return the global kill file name instead."
3155   (cond
3156    ;; The global KILL file is placed at top of the directory.
3157    ((or (null newsgroup)
3158         (string-equal newsgroup ""))
3159     (expand-file-name gnus-kill-file-name
3160                       gnus-kill-files-directory))
3161    ;; Append ".KILL" to newsgroup name.
3162    ((gnus-use-long-file-name 'not-kill)
3163     (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
3164                               "." gnus-kill-file-name)
3165                       gnus-kill-files-directory))
3166    ;; Place "KILL" under the hierarchical directory.
3167    (t
3168     (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
3169                               "/" gnus-kill-file-name)
3170                       gnus-kill-files-directory))))
3171
3172 ;;; Server things.
3173
3174 (defun gnus-member-of-valid (symbol group)
3175   "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
3176   (memq symbol (assoc
3177                 (symbol-name (car (gnus-find-method-for-group group)))
3178                 gnus-valid-select-methods)))
3179
3180 (defun gnus-method-option-p (method option)
3181   "Return non-nil if select METHOD has OPTION as a parameter."
3182   (when (stringp method)
3183     (setq method (gnus-server-to-method method)))
3184   (memq option (assoc (format "%s" (car method))
3185                       gnus-valid-select-methods)))
3186
3187 (defun gnus-similar-server-opened (method)
3188   (let ((opened gnus-opened-servers))
3189     (while (and method opened)
3190       (when (and (equal (cadr method) (cadaar opened))
3191                  (equal (car method) (caaar opened))
3192                  (not (equal method (caar opened))))
3193         (setq method nil))
3194       (pop opened))
3195     (not method)))
3196
3197 (defun gnus-server-extend-method (group method)
3198   ;; This function "extends" a virtual server.  If the server is
3199   ;; "hello", and the select method is ("hello" (my-var "something"))
3200   ;; in the group "alt.alt", this will result in a new virtual server
3201   ;; called "hello+alt.alt".
3202   (if (or (not (inline (gnus-similar-server-opened method)))
3203           (not (cddr method)))
3204       method
3205     `(,(car method) ,(concat (cadr method) "+" group)
3206       (,(intern (format "%s-address" (car method))) ,(cadr method))
3207       ,@(cddr method))))
3208
3209 (defun gnus-server-status (method)
3210   "Return the status of METHOD."
3211   (nth 1 (assoc method gnus-opened-servers)))
3212
3213 (defun gnus-group-name-to-method (group)
3214   "Guess a select method based on GROUP."
3215   (if (string-match ":" group)
3216       (let ((server (substring group 0 (match-beginning 0))))
3217         (if (string-match "\\+" server)
3218             (list (intern (substring server 0 (match-beginning 0)))
3219                   (substring server (match-end 0)))
3220           (list (intern server) "")))
3221     gnus-select-method))
3222
3223 (defun gnus-server-string (server)
3224   "Return a readable string that describes SERVER."
3225   (let* ((server (gnus-server-to-method server))
3226          (address (nth 1 server)))
3227     (if (and address
3228              (not (zerop (length address))))
3229         (format "%s via %s" address (car server))
3230       (format "%s" (car server)))))
3231
3232 (defun gnus-find-method-for-group (group &optional info)
3233   "Find the select method that GROUP uses."
3234   (or gnus-override-method
3235       (and (not group)
3236            gnus-select-method)
3237       (and (not (gnus-group-entry group));; a new group
3238            (gnus-group-name-to-method group))
3239       (let ((info (or info (gnus-get-info group)))
3240             method)
3241         (if (or (not info)
3242                 (not (setq method (gnus-info-method info)))
3243                 (equal method "native"))
3244             gnus-select-method
3245           (setq method
3246                 (cond ((stringp method)
3247                        (inline (gnus-server-to-method method)))
3248                       ((stringp (cadr method))
3249                        (inline (gnus-server-extend-method group method)))
3250                       (t
3251                        method)))
3252           (cond ((equal (cadr method) "")
3253                  method)
3254                 ((null (cadr method))
3255                  (list (car method) ""))
3256                 (t
3257                  (gnus-server-add-address method)))))))
3258
3259 (defun gnus-methods-using (feature)
3260   "Find all methods that have FEATURE."
3261   (let ((valids gnus-valid-select-methods)
3262         outs)
3263     (while valids
3264       (when (memq feature (car valids))
3265         (push (car valids) outs))
3266       (setq valids (cdr valids)))
3267     outs))
3268
3269 (defun gnus-read-group (prompt &optional default)
3270   "Prompt the user for a group name.
3271 Disallow invalid group names."
3272   (let ((prefix "")
3273         group)
3274     (while (not group)
3275       (when (string-match
3276              gnus-invalid-group-regexp
3277              (setq group (read-string (concat prefix prompt)
3278                                       (cons (or default "") 0)
3279                                       'gnus-group-history)))
3280         (setq prefix (format "Invalid group name: \"%s\".  " group)
3281               group nil)))
3282     group))
3283
3284 (defun gnus-read-method (prompt)
3285   "Prompt the user for a method.
3286 Allow completion over sensible values."
3287   (let* ((open-servers
3288           (mapcar (lambda (i) (cons (format "%s:%s" (caar i) (cadar i)) i))
3289                   gnus-opened-servers))
3290          (valid-methods
3291           (let (methods)
3292             (dolist (method gnus-valid-select-methods)
3293               (if (or (memq 'prompt-address method)
3294                       (not (assoc (format "%s:" (car method)) open-servers)))
3295                   (push method methods)))
3296             methods))
3297          (servers
3298           (append valid-methods
3299                   open-servers
3300                   gnus-predefined-server-alist
3301                   gnus-server-alist))
3302          (method
3303           (completing-read
3304            prompt servers
3305            nil t nil 'gnus-method-history)))
3306     (cond
3307      ((equal method "")
3308       (setq method gnus-select-method))
3309      ((assoc method gnus-valid-select-methods)
3310       (let ((address (if (memq 'prompt-address
3311                                (assoc method gnus-valid-select-methods))
3312                          (read-string "Address: ")
3313                        "")))
3314         (or (cadr (assoc (format "%s:%s" method address) open-servers))
3315             (list (intern method) address))))
3316      ((assoc method servers)
3317       method)
3318      (t
3319       (list (intern method) "")))))
3320
3321 ;;; User-level commands.
3322
3323 ;;;###autoload
3324 (defun gnus-slave-no-server (&optional arg)
3325   "Read network news as a slave, without connecting to local server."
3326   (interactive "P")
3327   (gnus-no-server arg t))
3328
3329 ;;;###autoload
3330 (defun gnus-no-server (&optional arg slave)
3331   "Read network news.
3332 If ARG is a positive number, Gnus will use that as the
3333 startup level.  If ARG is nil, Gnus will be started at level 2.
3334 If ARG is non-nil and not a positive number, Gnus will
3335 prompt the user for the name of an NNTP server to use.
3336 As opposed to `gnus', this command will not connect to the local server."
3337   (interactive "P")
3338   (gnus-no-server-1 arg slave))
3339
3340 ;;;###autoload
3341 (defun gnus-slave (&optional arg)
3342   "Read news as a slave."
3343   (interactive "P")
3344   (gnus arg nil 'slave))
3345
3346 (defcustom gnus-frame-properties nil
3347   "The properties of the frame in which gnus is displayed. Under XEmacs,
3348 the variable `toolbar-news-frame-plist' will be refered instead."
3349   :type '(repeat (cons :format "%v"
3350                        (symbol :tag "Parameter")
3351                        (sexp :tag "Value")))
3352   :group 'gnus)
3353
3354 (defvar gnus-frame nil
3355   "The frame in which gnus is displayed. It is not used under XEmacs.")
3356
3357 ;;;###autoload
3358 (defun gnus-other-frame (&optional arg)
3359   "Pop up a frame to read news."
3360   (interactive "P")
3361   (static-if (featurep 'xemacs)
3362       (let ((toolbar-news-use-separate-frame t))
3363         (toolbar-gnus))
3364     (if (frame-live-p gnus-frame)
3365         (raise-frame gnus-frame)
3366       (setq gnus-frame (make-frame gnus-frame-properties))
3367       (if (and (gnus-buffer-live-p gnus-group-buffer)
3368                (save-current-buffer
3369                  (set-buffer gnus-group-buffer)
3370                  (eq 'gnus-group-mode major-mode)))
3371           (progn
3372             (select-frame gnus-frame)
3373             (switch-to-buffer gnus-group-buffer))
3374         (add-hook 'gnus-exit-gnus-hook
3375                   (lambda ()
3376                     (when (and (frame-live-p gnus-frame)
3377                                (cdr (frame-list)))
3378                       (delete-frame gnus-frame))
3379                     (setq gnus-frame nil)))
3380         (select-frame gnus-frame)
3381         (gnus arg)))))
3382
3383 ;;;###autoload
3384 (defun gnus (&optional arg dont-connect slave)
3385   "Read network news.
3386 If ARG is non-nil and a positive number, Gnus will use that as the
3387 startup level.  If ARG is non-nil and not a positive number, Gnus will
3388 prompt the user for the name of an NNTP server to use."
3389   (interactive "P")
3390   (unless (byte-code-function-p (symbol-function 'gnus))
3391     (message "You should byte-compile Gnus")
3392     (sit-for 2))
3393   (gnus-1 arg dont-connect slave))
3394
3395 ;; Allow redefinition of Gnus functions.
3396
3397 (gnus-ems-redefine)
3398
3399 (product-provide (provide 'gnus) 'gnus-vers)
3400
3401 ;;; gnus.el ends here