Support curved quotes
[gnus] / lisp / gnus.el
1 ;;; gnus.el --- a newsreader for GNU Emacs
2
3 ;; Copyright (C) 1987-1990, 1993-1998, 2000-2015 Free Software
4 ;; Foundation, Inc.
5
6 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
7 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; Keywords: news, mail
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (eval '(run-hooks 'gnus-load-hook))
30
31 (eval-when-compile (require 'cl))
32 (require 'wid-edit)
33 (require 'mm-util)
34 (require 'nnheader)
35 (require 'gnus-compat)
36
37 ;; These are defined afterwards with gnus-define-group-parameter
38 (defvar gnus-ham-process-destinations)
39 (defvar gnus-parameter-ham-marks-alist)
40 (defvar gnus-parameter-spam-marks-alist)
41 (defvar gnus-spam-autodetect)
42 (defvar gnus-spam-autodetect-methods)
43 (defvar gnus-spam-newsgroup-contents)
44 (defvar gnus-spam-process-destinations)
45 (defvar gnus-spam-resend-to)
46 (defvar gnus-ham-resend-to)
47 (defvar gnus-spam-process-newsgroups)
48
49
50 (defgroup gnus nil
51   "The coffee-brewing, all singing, all dancing, kitchen sink newsreader."
52   :group 'news
53   :group 'mail)
54
55 (defgroup gnus-start nil
56   "Starting your favorite newsreader."
57   :group 'gnus)
58
59 (defgroup gnus-format nil
60   "Dealing with formatting issues."
61   :group 'gnus)
62
63 (defgroup gnus-charset nil
64   "Group character set issues."
65   :link '(custom-manual "(gnus)Charsets")
66   :version "21.1"
67   :group 'gnus)
68
69 (defgroup gnus-cache nil
70   "Cache interface."
71   :link '(custom-manual "(gnus)Article Caching")
72   :group 'gnus)
73
74 (defgroup gnus-registry nil
75   "Article Registry."
76   :group 'gnus)
77
78 (defgroup gnus-start-server nil
79   "Server options at startup."
80   :group 'gnus-start)
81
82 ;; These belong to gnus-group.el.
83 (defgroup gnus-group nil
84   "Group buffers."
85   :link '(custom-manual "(gnus)Group Buffer")
86   :group 'gnus)
87
88 (defgroup gnus-group-foreign nil
89   "Foreign groups."
90   :link '(custom-manual "(gnus)Foreign Groups")
91   :group 'gnus-group)
92
93 (defgroup gnus-group-new nil
94   "Automatic subscription of new groups."
95   :group 'gnus-group)
96
97 (defgroup gnus-group-levels nil
98   "Group levels."
99   :link '(custom-manual "(gnus)Group Levels")
100   :group 'gnus-group)
101
102 (defgroup gnus-group-select nil
103   "Selecting a Group."
104   :link '(custom-manual "(gnus)Selecting a Group")
105   :group 'gnus-group)
106
107 (defgroup gnus-group-listing nil
108   "Showing slices of the group list."
109   :link '(custom-manual "(gnus)Listing Groups")
110   :group 'gnus-group)
111
112 (defgroup gnus-group-visual nil
113   "Sorting the group buffer."
114   :link '(custom-manual "(gnus)Group Buffer Format")
115   :group 'gnus-group
116   :group 'gnus-visual)
117
118 (defgroup gnus-group-various nil
119   "Various group options."
120   :link '(custom-manual "(gnus)Scanning New Messages")
121   :group 'gnus-group)
122
123 ;; These belong to gnus-sum.el.
124 (defgroup gnus-summary nil
125   "Summary buffers."
126   :link '(custom-manual "(gnus)Summary Buffer")
127   :group 'gnus)
128
129 (defgroup gnus-summary-exit nil
130   "Leaving summary buffers."
131   :link '(custom-manual "(gnus)Exiting the Summary Buffer")
132   :group 'gnus-summary)
133
134 (defgroup gnus-summary-marks nil
135   "Marks used in summary buffers."
136   :link '(custom-manual "(gnus)Marking Articles")
137   :group 'gnus-summary)
138
139 (defgroup gnus-thread nil
140   "Ordering articles according to replies."
141   :link '(custom-manual "(gnus)Threading")
142   :group 'gnus-summary)
143
144 (defgroup gnus-summary-format nil
145   "Formatting of the summary buffer."
146   :link '(custom-manual "(gnus)Summary Buffer Format")
147   :group 'gnus-summary)
148
149 (defgroup gnus-summary-choose nil
150   "Choosing Articles."
151   :link '(custom-manual "(gnus)Choosing Articles")
152   :group 'gnus-summary)
153
154 (defgroup gnus-summary-maneuvering nil
155   "Summary movement commands."
156   :link '(custom-manual "(gnus)Summary Maneuvering")
157   :group 'gnus-summary)
158
159 (defgroup gnus-picon nil
160   "Show pictures of people, domains, and newsgroups."
161   :group 'gnus-visual)
162
163 (defgroup gnus-summary-mail nil
164   "Mail group commands."
165   :link '(custom-manual "(gnus)Mail Group Commands")
166   :group 'gnus-summary)
167
168 (defgroup gnus-summary-sort nil
169   "Sorting the summary buffer."
170   :link '(custom-manual "(gnus)Sorting the Summary Buffer")
171   :group 'gnus-summary)
172
173 (defgroup gnus-summary-visual nil
174   "Highlighting and menus in the summary buffer."
175   :link '(custom-manual "(gnus)Summary Highlighting")
176   :group 'gnus-visual
177   :group 'gnus-summary)
178
179 (defgroup gnus-summary-various nil
180   "Various summary buffer options."
181   :link '(custom-manual "(gnus)Various Summary Stuff")
182   :group 'gnus-summary)
183
184 (defgroup gnus-summary-pick nil
185   "Pick mode in the summary buffer."
186   :link '(custom-manual "(gnus)Pick and Read")
187   :prefix "gnus-pick-"
188   :group 'gnus-summary)
189
190 (defgroup gnus-summary-tree nil
191   "Tree display of threads in the summary buffer."
192   :link '(custom-manual "(gnus)Tree Display")
193   :prefix "gnus-tree-"
194   :group 'gnus-summary)
195
196 ;; Belongs to gnus-uu.el
197 (defgroup gnus-extract-view nil
198   "Viewing extracted files."
199   :link '(custom-manual "(gnus)Viewing Files")
200   :group 'gnus-extract)
201
202 ;; Belongs to gnus-score.el
203 (defgroup gnus-score nil
204   "Score and kill file handling."
205   :group 'gnus)
206
207 (defgroup gnus-score-kill nil
208   "Kill files."
209   :group 'gnus-score)
210
211 (defgroup gnus-score-adapt nil
212   "Adaptive score files."
213   :group 'gnus-score)
214
215 (defgroup gnus-score-default nil
216   "Default values for score files."
217   :group 'gnus-score)
218
219 (defgroup gnus-score-expire nil
220   "Expiring score rules."
221   :group 'gnus-score)
222
223 (defgroup gnus-score-decay nil
224   "Decaying score rules."
225   :group 'gnus-score)
226
227 (defgroup gnus-score-files nil
228   "Score and kill file names."
229   :group 'gnus-score
230   :group 'gnus-files)
231
232 (defgroup gnus-score-various nil
233   "Various scoring and killing options."
234   :group 'gnus-score)
235
236 ;; Other
237 (defgroup gnus-visual nil
238   "Options controlling the visual fluff."
239   :group 'gnus
240   :group 'faces)
241
242 (defgroup gnus-agent nil
243   "Offline support for Gnus."
244   :group 'gnus)
245
246 (defgroup gnus-files nil
247   "Files used by Gnus."
248   :group 'gnus)
249
250 (defgroup gnus-dribble-file nil
251   "Auto save file."
252   :link '(custom-manual "(gnus)Auto Save")
253   :group 'gnus-files)
254
255 (defgroup gnus-newsrc nil
256   "Storing Gnus state."
257   :group 'gnus-files)
258
259 (defgroup gnus-server nil
260   "Options related to newsservers and other servers used by Gnus."
261   :group 'gnus)
262
263 (defgroup gnus-server-visual nil
264   "Highlighting and menus in the server buffer."
265   :group 'gnus-visual
266   :group 'gnus-server)
267
268 (defgroup gnus-message '((message custom-group))
269   "Composing replies and followups in Gnus."
270   :group 'gnus)
271
272 (defgroup gnus-meta nil
273   "Meta variables controlling major portions of Gnus.
274 In general, modifying these variables does not take effect until Gnus
275 is restarted, and sometimes reloaded."
276   :group 'gnus)
277
278 (defgroup gnus-various nil
279   "Other Gnus options."
280   :link '(custom-manual "(gnus)Various Various")
281   :group 'gnus)
282
283 (defgroup gnus-exit nil
284   "Exiting Gnus."
285   :link '(custom-manual "(gnus)Exiting Gnus")
286   :group 'gnus)
287
288 (defgroup gnus-fun nil
289   "Frivolous Gnus extensions."
290   :link '(custom-manual "(gnus)Exiting Gnus")
291   :group 'gnus)
292
293 (defconst gnus-version-number "0.14"
294   "Version number for this version of Gnus.")
295
296 (defconst gnus-version (format "Ma Gnus v%s" gnus-version-number)
297   "Version string for this version of Gnus.")
298
299 (defcustom gnus-inhibit-startup-message nil
300   "If non-nil, the startup message will not be displayed.
301 This variable is used before `.gnus.el' is loaded, so it should
302 be set in `.emacs' instead."
303   :group 'gnus-start
304   :type 'boolean)
305
306 (unless (featurep 'gnus-xmas)
307   (defalias 'gnus-make-overlay 'make-overlay)
308   (defalias 'gnus-copy-overlay 'copy-overlay)
309   (defalias 'gnus-delete-overlay 'delete-overlay)
310   (defalias 'gnus-overlay-get 'overlay-get)
311   (defalias 'gnus-overlay-put 'overlay-put)
312   (defalias 'gnus-move-overlay 'move-overlay)
313   (defalias 'gnus-overlay-buffer 'overlay-buffer)
314   (defalias 'gnus-overlay-start 'overlay-start)
315   (defalias 'gnus-overlay-end 'overlay-end)
316   (defalias 'gnus-overlays-at 'overlays-at)
317   (defalias 'gnus-overlays-in 'overlays-in)
318   (defalias 'gnus-extent-detached-p 'ignore)
319   (defalias 'gnus-extent-start-open 'ignore)
320   (defalias 'gnus-mail-strip-quoted-names 'mail-strip-quoted-names)
321   (defalias 'gnus-character-to-event 'identity)
322   (defalias 'gnus-assq-delete-all 'assq-delete-all)
323   (defalias 'gnus-add-text-properties 'add-text-properties)
324   (defalias 'gnus-put-text-property 'put-text-property)
325   (defvar gnus-mode-line-image-cache t)
326   (if (fboundp 'find-image)
327       (defun gnus-mode-line-buffer-identification (line)
328         (let ((str (car-safe line))
329               (load-path (append (mm-image-load-path) load-path)))
330           (if (and (display-graphic-p)
331                    (stringp str)
332                    (string-match "^Gnus:" str))
333               (progn (add-text-properties
334                       0 5
335                       (list 'display
336                             (if (eq t gnus-mode-line-image-cache)
337                                 (setq gnus-mode-line-image-cache
338                                       (find-image
339                                        '((:type xpm :file "gnus-pointer.xpm"
340                                                 :ascent center)
341                                          (:type xbm :file "gnus-pointer.xbm"
342                                                 :ascent center))))
343                               gnus-mode-line-image-cache)
344                             'help-echo (format
345                                         "This is %s, %s."
346                                         gnus-version (gnus-emacs-version)))
347                       str)
348                      (list str))
349             line)))
350     (defalias 'gnus-mode-line-buffer-identification 'identity))
351   (defalias 'gnus-deactivate-mark 'deactivate-mark)
352   (defalias 'gnus-window-edges 'window-edges)
353   (defalias 'gnus-key-press-event-p 'numberp)
354   ;;(defalias 'gnus-decode-rfc1522 'ignore)
355   )
356
357 ;; We define these group faces here to avoid the display
358 ;; update forced when creating new faces.
359
360 (defface gnus-group-news-1
361   '((((class color)
362       (background dark))
363      (:foreground "PaleTurquoise" :bold t))
364     (((class color)
365       (background light))
366      (:foreground "ForestGreen" :bold t))
367     (t
368      ()))
369   "Level 1 newsgroup face."
370   :group 'gnus-group)
371 ;; backward-compatibility alias
372 (put 'gnus-group-news-1-face 'face-alias 'gnus-group-news-1)
373 (put 'gnus-group-news-1-face 'obsolete-face "22.1")
374
375 (defface gnus-group-news-1-empty
376   '((((class color)
377       (background dark))
378      (:foreground "PaleTurquoise"))
379     (((class color)
380       (background light))
381      (:foreground "ForestGreen"))
382     (t
383      ()))
384   "Level 1 empty newsgroup face."
385   :group 'gnus-group)
386 ;; backward-compatibility alias
387 (put 'gnus-group-news-1-empty-face 'face-alias 'gnus-group-news-1-empty)
388 (put 'gnus-group-news-1-empty-face 'obsolete-face "22.1")
389
390 (defface gnus-group-news-2
391   '((((class color)
392       (background dark))
393      (:foreground "turquoise" :bold t))
394     (((class color)
395       (background light))
396      (:foreground "CadetBlue4" :bold t))
397     (t
398      ()))
399   "Level 2 newsgroup face."
400   :group 'gnus-group)
401 ;; backward-compatibility alias
402 (put 'gnus-group-news-2-face 'face-alias 'gnus-group-news-2)
403 (put 'gnus-group-news-2-face 'obsolete-face "22.1")
404
405 (defface gnus-group-news-2-empty
406   '((((class color)
407       (background dark))
408      (:foreground "turquoise"))
409     (((class color)
410       (background light))
411      (:foreground "CadetBlue4"))
412     (t
413      ()))
414   "Level 2 empty newsgroup face."
415   :group 'gnus-group)
416 ;; backward-compatibility alias
417 (put 'gnus-group-news-2-empty-face 'face-alias 'gnus-group-news-2-empty)
418 (put 'gnus-group-news-2-empty-face 'obsolete-face "22.1")
419
420 (defface gnus-group-news-3
421   '((((class color)
422       (background dark))
423      (:bold t))
424     (((class color)
425       (background light))
426      (:bold t))
427     (t
428      ()))
429   "Level 3 newsgroup face."
430   :group 'gnus-group)
431 ;; backward-compatibility alias
432 (put 'gnus-group-news-3-face 'face-alias 'gnus-group-news-3)
433 (put 'gnus-group-news-3-face 'obsolete-face "22.1")
434
435 (defface gnus-group-news-3-empty
436   '((((class color)
437       (background dark))
438      ())
439     (((class color)
440       (background light))
441      ())
442     (t
443      ()))
444   "Level 3 empty newsgroup face."
445   :group 'gnus-group)
446 ;; backward-compatibility alias
447 (put 'gnus-group-news-3-empty-face 'face-alias 'gnus-group-news-3-empty)
448 (put 'gnus-group-news-3-empty-face 'obsolete-face "22.1")
449
450 (defface gnus-group-news-4
451   '((((class color)
452       (background dark))
453      (:bold t))
454     (((class color)
455       (background light))
456      (:bold t))
457     (t
458      ()))
459   "Level 4 newsgroup face."
460   :group 'gnus-group)
461 ;; backward-compatibility alias
462 (put 'gnus-group-news-4-face 'face-alias 'gnus-group-news-4)
463 (put 'gnus-group-news-4-face 'obsolete-face "22.1")
464
465 (defface gnus-group-news-4-empty
466   '((((class color)
467       (background dark))
468      ())
469     (((class color)
470       (background light))
471      ())
472     (t
473      ()))
474   "Level 4 empty newsgroup face."
475   :group 'gnus-group)
476 ;; backward-compatibility alias
477 (put 'gnus-group-news-4-empty-face 'face-alias 'gnus-group-news-4-empty)
478 (put 'gnus-group-news-4-empty-face 'obsolete-face "22.1")
479
480 (defface gnus-group-news-5
481   '((((class color)
482       (background dark))
483      (:bold t))
484     (((class color)
485       (background light))
486      (:bold t))
487     (t
488      ()))
489   "Level 5 newsgroup face."
490   :group 'gnus-group)
491 ;; backward-compatibility alias
492 (put 'gnus-group-news-5-face 'face-alias 'gnus-group-news-5)
493 (put 'gnus-group-news-5-face 'obsolete-face "22.1")
494
495 (defface gnus-group-news-5-empty
496   '((((class color)
497       (background dark))
498      ())
499     (((class color)
500       (background light))
501      ())
502     (t
503      ()))
504   "Level 5 empty newsgroup face."
505   :group 'gnus-group)
506 ;; backward-compatibility alias
507 (put 'gnus-group-news-5-empty-face 'face-alias 'gnus-group-news-5-empty)
508 (put 'gnus-group-news-5-empty-face 'obsolete-face "22.1")
509
510 (defface gnus-group-news-6
511   '((((class color)
512       (background dark))
513      (:bold t))
514     (((class color)
515       (background light))
516      (:bold t))
517     (t
518      ()))
519   "Level 6 newsgroup face."
520   :group 'gnus-group)
521 ;; backward-compatibility alias
522 (put 'gnus-group-news-6-face 'face-alias 'gnus-group-news-6)
523 (put 'gnus-group-news-6-face 'obsolete-face "22.1")
524
525 (defface gnus-group-news-6-empty
526   '((((class color)
527       (background dark))
528      ())
529     (((class color)
530       (background light))
531      ())
532     (t
533      ()))
534   "Level 6 empty newsgroup face."
535   :group 'gnus-group)
536 ;; backward-compatibility alias
537 (put 'gnus-group-news-6-empty-face 'face-alias 'gnus-group-news-6-empty)
538 (put 'gnus-group-news-6-empty-face 'obsolete-face "22.1")
539
540 (defface gnus-group-news-low
541   '((((class color)
542       (background dark))
543      (:foreground "DarkTurquoise" :bold t))
544     (((class color)
545       (background light))
546      (:foreground "DarkGreen" :bold t))
547     (t
548      ()))
549   "Low level newsgroup face."
550   :group 'gnus-group)
551 ;; backward-compatibility alias
552 (put 'gnus-group-news-low-face 'face-alias 'gnus-group-news-low)
553 (put 'gnus-group-news-low-face 'obsolete-face "22.1")
554
555 (defface gnus-group-news-low-empty
556   '((((class color)
557       (background dark))
558      (:foreground "DarkTurquoise"))
559     (((class color)
560       (background light))
561      (:foreground "DarkGreen"))
562     (t
563      ()))
564   "Low level empty newsgroup face."
565   :group 'gnus-group)
566 ;; backward-compatibility alias
567 (put 'gnus-group-news-low-empty-face 'face-alias 'gnus-group-news-low-empty)
568 (put 'gnus-group-news-low-empty-face 'obsolete-face "22.1")
569
570 (defface gnus-group-mail-1
571   '((((class color)
572       (background dark))
573      (:foreground "#e1ffe1" :bold t))
574     (((class color)
575       (background light))
576      (:foreground "DeepPink3" :bold t))
577     (t
578      (:bold t)))
579   "Level 1 mailgroup face."
580   :group 'gnus-group)
581 ;; backward-compatibility alias
582 (put 'gnus-group-mail-1-face 'face-alias 'gnus-group-mail-1)
583 (put 'gnus-group-mail-1-face 'obsolete-face "22.1")
584
585 (defface gnus-group-mail-1-empty
586   '((((class color)
587       (background dark))
588      (:foreground "#e1ffe1"))
589     (((class color)
590       (background light))
591      (:foreground "DeepPink3"))
592     (t
593      (:italic t :bold t)))
594   "Level 1 empty mailgroup face."
595   :group 'gnus-group)
596 ;; backward-compatibility alias
597 (put 'gnus-group-mail-1-empty-face 'face-alias 'gnus-group-mail-1-empty)
598 (put 'gnus-group-mail-1-empty-face 'obsolete-face "22.1")
599
600 (defface gnus-group-mail-2
601   '((((class color)
602       (background dark))
603      (:foreground "DarkSeaGreen1" :bold t))
604     (((class color)
605       (background light))
606      (:foreground "HotPink3" :bold t))
607     (t
608      (:bold t)))
609   "Level 2 mailgroup face."
610   :group 'gnus-group)
611 ;; backward-compatibility alias
612 (put 'gnus-group-mail-2-face 'face-alias 'gnus-group-mail-2)
613 (put 'gnus-group-mail-2-face 'obsolete-face "22.1")
614
615 (defface gnus-group-mail-2-empty
616   '((((class color)
617       (background dark))
618      (:foreground "DarkSeaGreen1"))
619     (((class color)
620       (background light))
621      (:foreground "HotPink3"))
622     (t
623      (:bold t)))
624   "Level 2 empty mailgroup face."
625   :group 'gnus-group)
626 ;; backward-compatibility alias
627 (put 'gnus-group-mail-2-empty-face 'face-alias 'gnus-group-mail-2-empty)
628 (put 'gnus-group-mail-2-empty-face 'obsolete-face "22.1")
629
630 (defface gnus-group-mail-3
631   '((((class color)
632       (background dark))
633      (:foreground "aquamarine1" :bold t))
634     (((class color)
635       (background light))
636      (:foreground "magenta4" :bold t))
637     (t
638      (:bold t)))
639   "Level 3 mailgroup face."
640   :group 'gnus-group)
641 ;; backward-compatibility alias
642 (put 'gnus-group-mail-3-face 'face-alias 'gnus-group-mail-3)
643 (put 'gnus-group-mail-3-face 'obsolete-face "22.1")
644
645 (defface gnus-group-mail-3-empty
646   '((((class color)
647       (background dark))
648      (:foreground "aquamarine1"))
649     (((class color)
650       (background light))
651      (:foreground "magenta4"))
652     (t
653      ()))
654   "Level 3 empty mailgroup face."
655   :group 'gnus-group)
656 ;; backward-compatibility alias
657 (put 'gnus-group-mail-3-empty-face 'face-alias 'gnus-group-mail-3-empty)
658 (put 'gnus-group-mail-3-empty-face 'obsolete-face "22.1")
659
660 (defface gnus-group-mail-low
661   '((((class color)
662       (background dark))
663      (:foreground "aquamarine2" :bold t))
664     (((class color)
665       (background light))
666      (:foreground "DeepPink4" :bold t))
667     (t
668      (:bold t)))
669   "Low level mailgroup face."
670   :group 'gnus-group)
671 ;; backward-compatibility alias
672 (put 'gnus-group-mail-low-face 'face-alias 'gnus-group-mail-low)
673 (put 'gnus-group-mail-low-face 'obsolete-face "22.1")
674
675 (defface gnus-group-mail-low-empty
676   '((((class color)
677       (background dark))
678      (:foreground "aquamarine2"))
679     (((class color)
680       (background light))
681      (:foreground "DeepPink4"))
682     (t
683      (:bold t)))
684   "Low level empty mailgroup face."
685   :group 'gnus-group)
686 ;; backward-compatibility alias
687 (put 'gnus-group-mail-low-empty-face 'face-alias 'gnus-group-mail-low-empty)
688 (put 'gnus-group-mail-low-empty-face 'obsolete-face "22.1")
689
690 ;; Summary mode faces.
691
692 (defface gnus-summary-selected '((t (:underline t)))
693   "Face used for selected articles."
694   :group 'gnus-summary)
695 ;; backward-compatibility alias
696 (put 'gnus-summary-selected-face 'face-alias 'gnus-summary-selected)
697 (put 'gnus-summary-selected-face 'obsolete-face "22.1")
698
699 (defface gnus-summary-cancelled
700   '((((class color))
701      (:foreground "yellow" :background "black")))
702   "Face used for canceled articles."
703   :group 'gnus-summary)
704 ;; backward-compatibility alias
705 (put 'gnus-summary-cancelled-face 'face-alias 'gnus-summary-cancelled)
706 (put 'gnus-summary-cancelled-face 'obsolete-face "22.1")
707
708 (defface gnus-summary-high-ticked
709   '((((class color)
710       (background dark))
711      (:foreground "pink" :bold t))
712     (((class color)
713       (background light))
714      (:foreground "firebrick" :bold t))
715     (t
716      (:bold t)))
717   "Face used for high interest ticked articles."
718   :group 'gnus-summary)
719 ;; backward-compatibility alias
720 (put 'gnus-summary-high-ticked-face 'face-alias 'gnus-summary-high-ticked)
721 (put 'gnus-summary-high-ticked-face 'obsolete-face "22.1")
722
723 (defface gnus-summary-low-ticked
724   '((((class color)
725       (background dark))
726      (:foreground "pink" :italic t))
727     (((class color)
728       (background light))
729      (:foreground "firebrick" :italic t))
730     (t
731      (:italic t)))
732   "Face used for low interest ticked articles."
733   :group 'gnus-summary)
734 ;; backward-compatibility alias
735 (put 'gnus-summary-low-ticked-face 'face-alias 'gnus-summary-low-ticked)
736 (put 'gnus-summary-low-ticked-face 'obsolete-face "22.1")
737
738 (defface gnus-summary-normal-ticked
739   '((((class color)
740       (background dark))
741      (:foreground "pink"))
742     (((class color)
743       (background light))
744      (:foreground "firebrick"))
745     (t
746      ()))
747   "Face used for normal interest ticked articles."
748   :group 'gnus-summary)
749 ;; backward-compatibility alias
750 (put 'gnus-summary-normal-ticked-face 'face-alias 'gnus-summary-normal-ticked)
751 (put 'gnus-summary-normal-ticked-face 'obsolete-face "22.1")
752
753 (defface gnus-summary-high-ancient
754   '((((class color)
755       (background dark))
756      (:foreground "SkyBlue" :bold t))
757     (((class color)
758       (background light))
759      (:foreground "RoyalBlue" :bold t))
760     (t
761      (:bold t)))
762   "Face used for high interest ancient articles."
763   :group 'gnus-summary)
764 ;; backward-compatibility alias
765 (put 'gnus-summary-high-ancient-face 'face-alias 'gnus-summary-high-ancient)
766 (put 'gnus-summary-high-ancient-face 'obsolete-face "22.1")
767
768 (defface gnus-summary-low-ancient
769   '((((class color)
770       (background dark))
771      (:foreground "SkyBlue" :italic t))
772     (((class color)
773       (background light))
774      (:foreground "RoyalBlue" :italic t))
775     (t
776      (:italic t)))
777   "Face used for low interest ancient articles."
778   :group 'gnus-summary)
779 ;; backward-compatibility alias
780 (put 'gnus-summary-low-ancient-face 'face-alias 'gnus-summary-low-ancient)
781 (put 'gnus-summary-low-ancient-face 'obsolete-face "22.1")
782
783 (defface gnus-summary-normal-ancient
784   '((((class color)
785       (background dark))
786      (:foreground "SkyBlue"))
787     (((class color)
788       (background light))
789      (:foreground "RoyalBlue"))
790     (t
791      ()))
792   "Face used for normal interest ancient articles."
793   :group 'gnus-summary)
794 ;; backward-compatibility alias
795 (put 'gnus-summary-normal-ancient-face 'face-alias 'gnus-summary-normal-ancient)
796 (put 'gnus-summary-normal-ancient-face 'obsolete-face "22.1")
797
798 (defface gnus-summary-high-undownloaded
799    '((((class color)
800        (background light))
801       (:bold t :foreground "cyan4"))
802      (((class color) (background dark))
803       (:bold t :foreground "LightGray"))
804      (t (:inverse-video t :bold t)))
805   "Face used for high interest uncached articles."
806   :group 'gnus-summary)
807 ;; backward-compatibility alias
808 (put 'gnus-summary-high-undownloaded-face 'face-alias 'gnus-summary-high-undownloaded)
809 (put 'gnus-summary-high-undownloaded-face 'obsolete-face "22.1")
810
811 (defface gnus-summary-low-undownloaded
812    '((((class color)
813        (background light))
814       (:italic t :foreground "cyan4" :bold nil))
815      (((class color) (background dark))
816       (:italic t :foreground "LightGray" :bold nil))
817      (t (:inverse-video t :italic t)))
818   "Face used for low interest uncached articles."
819   :group 'gnus-summary)
820 ;; backward-compatibility alias
821 (put 'gnus-summary-low-undownloaded-face 'face-alias 'gnus-summary-low-undownloaded)
822 (put 'gnus-summary-low-undownloaded-face 'obsolete-face "22.1")
823
824 (defface gnus-summary-normal-undownloaded
825    '((((class color)
826        (background light))
827       (:foreground "cyan4" :bold nil))
828      (((class color) (background dark))
829       (:foreground "LightGray" :bold nil))
830      (t (:inverse-video t)))
831   "Face used for normal interest uncached articles."
832   :group 'gnus-summary)
833 ;; backward-compatibility alias
834 (put 'gnus-summary-normal-undownloaded-face 'face-alias 'gnus-summary-normal-undownloaded)
835 (put 'gnus-summary-normal-undownloaded-face 'obsolete-face "22.1")
836
837 (defface gnus-summary-high-unread
838   '((t
839      (:bold t)))
840   "Face used for high interest unread articles."
841   :group 'gnus-summary)
842 ;; backward-compatibility alias
843 (put 'gnus-summary-high-unread-face 'face-alias 'gnus-summary-high-unread)
844 (put 'gnus-summary-high-unread-face 'obsolete-face "22.1")
845
846 (defface gnus-summary-low-unread
847   '((t
848      (:italic t)))
849   "Face used for low interest unread articles."
850   :group 'gnus-summary)
851 ;; backward-compatibility alias
852 (put 'gnus-summary-low-unread-face 'face-alias 'gnus-summary-low-unread)
853 (put 'gnus-summary-low-unread-face 'obsolete-face "22.1")
854
855 (defface gnus-summary-normal-unread
856   '((t
857      ()))
858   "Face used for normal interest unread articles."
859   :group 'gnus-summary)
860 ;; backward-compatibility alias
861 (put 'gnus-summary-normal-unread-face 'face-alias 'gnus-summary-normal-unread)
862 (put 'gnus-summary-normal-unread-face 'obsolete-face "22.1")
863
864 (defface gnus-summary-high-read
865   '((((class color)
866       (background dark))
867      (:foreground "PaleGreen"
868                   :bold t))
869     (((class color)
870       (background light))
871      (:foreground "DarkGreen"
872                   :bold t))
873     (t
874      (:bold t)))
875   "Face used for high interest read articles."
876   :group 'gnus-summary)
877 ;; backward-compatibility alias
878 (put 'gnus-summary-high-read-face 'face-alias 'gnus-summary-high-read)
879 (put 'gnus-summary-high-read-face 'obsolete-face "22.1")
880
881 (defface gnus-summary-low-read
882   '((((class color)
883       (background dark))
884      (:foreground "PaleGreen"
885                   :italic t))
886     (((class color)
887       (background light))
888      (:foreground "DarkGreen"
889                   :italic t))
890     (t
891      (:italic t)))
892   "Face used for low interest read articles."
893   :group 'gnus-summary)
894 ;; backward-compatibility alias
895 (put 'gnus-summary-low-read-face 'face-alias 'gnus-summary-low-read)
896 (put 'gnus-summary-low-read-face 'obsolete-face "22.1")
897
898 (defface gnus-summary-normal-read
899   '((((class color)
900       (background dark))
901      (:foreground "PaleGreen"))
902     (((class color)
903       (background light))
904      (:foreground "DarkGreen"))
905     (t
906      ()))
907   "Face used for normal interest read articles."
908   :group 'gnus-summary)
909 ;; backward-compatibility alias
910 (put 'gnus-summary-normal-read-face 'face-alias 'gnus-summary-normal-read)
911 (put 'gnus-summary-normal-read-face 'obsolete-face "22.1")
912
913
914 ;;;
915 ;;; Gnus buffers
916 ;;;
917
918 (defvar gnus-buffers nil
919   "List of buffers handled by Gnus.")
920
921 (defun gnus-get-buffer-create (name)
922   "Do the same as `get-buffer-create', but store the created buffer."
923   (or (get-buffer name)
924       (car (push (get-buffer-create name) gnus-buffers))))
925
926 (defun gnus-add-buffer ()
927   "Add the current buffer to the list of Gnus buffers."
928   (push (current-buffer) gnus-buffers))
929
930 (defmacro gnus-kill-buffer (buffer)
931   "Kill BUFFER and remove from the list of Gnus buffers."
932   `(let ((buf ,buffer))
933      (when (gnus-buffer-exists-p buf)
934        (setq gnus-buffers (delete (get-buffer buf) gnus-buffers))
935        (kill-buffer buf))))
936
937 (defun gnus-buffers ()
938   "Return a list of live Gnus buffers."
939   (while (and gnus-buffers
940               (not (buffer-name (car gnus-buffers))))
941     (pop gnus-buffers))
942   (let ((buffers gnus-buffers))
943     (while (cdr buffers)
944       (if (buffer-name (cadr buffers))
945           (pop buffers)
946         (setcdr buffers (cddr buffers)))))
947   gnus-buffers)
948
949 ;;; Splash screen.
950
951 (defvar gnus-group-buffer "*Group*"
952   "Name of the Gnus group buffer.")
953
954 (defface gnus-splash
955   '((((class color)
956       (background dark))
957      (:foreground "#cccccc"))
958     (((class color)
959       (background light))
960      (:foreground "#888888"))
961     (t
962      ()))
963   "Face for the splash screen."
964   :group 'gnus-start)
965 ;; backward-compatibility alias
966 (put 'gnus-splash-face 'face-alias 'gnus-splash)
967 (put 'gnus-splash-face 'obsolete-face "22.1")
968
969 (defun gnus-splash ()
970   (save-excursion
971     (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
972     (let ((buffer-read-only nil))
973       (erase-buffer)
974       (unless gnus-inhibit-startup-message
975         (gnus-group-startup-message)
976         (sit-for 0)))))
977
978 (defun gnus-indent-rigidly (start end arg)
979   "Indent rigidly using only spaces and no tabs."
980   (save-excursion
981     (save-restriction
982       (narrow-to-region start end)
983       (let ((tab-width 8))
984         (indent-rigidly start end arg)
985         ;; We translate tabs into spaces -- not everybody uses
986         ;; an 8-character tab.
987         (goto-char (point-min))
988         (while (search-forward "\t" nil t)
989           (replace-match "        " t t))))))
990
991 ;;(format "%02x%02x%02x" 114 66 20) "724214"
992
993 (defvar gnus-logo-color-alist
994   '((flame "#cc3300" "#ff2200")
995     (pine "#c0cc93" "#f8ffb8")
996     (moss "#a1cc93" "#d2ffb8")
997     (irish "#04cc90" "#05ff97")
998     (sky "#049acc" "#05deff")
999     (tin "#6886cc" "#82b6ff")
1000     (velvet "#7c68cc" "#8c82ff")
1001     (grape "#b264cc" "#cf7df")
1002     (labia "#cc64c2" "#fd7dff")
1003     (berry "#cc6485" "#ff7db5")
1004     (dino "#724214" "#1e3f03")
1005     (oort "#cccccc" "#888888")
1006     (storm "#666699" "#99ccff")
1007     (pdino "#9999cc" "#99ccff")
1008     (purp "#9999cc" "#666699")
1009     (no "#ff0000" "#ffff00")
1010     (neutral "#b4b4b4" "#878787")
1011     (ma "#2020e0" "#8080ff")
1012     (september "#bf9900" "#ffcc00"))
1013   "Color alist used for the Gnus logo.")
1014
1015 (defcustom gnus-logo-color-style 'ma
1016   "*Color styles used for the Gnus logo."
1017   :type `(choice ,@(mapcar (lambda (elem) (list 'const (car elem)))
1018                            gnus-logo-color-alist))
1019   :group 'gnus-xmas)
1020
1021 (defvar gnus-logo-colors
1022   (cdr (assq gnus-logo-color-style gnus-logo-color-alist))
1023   "Colors used for the Gnus logo.")
1024
1025 (declare-function image-size "image.c" (spec &optional pixels frame))
1026
1027 (defun gnus-group-startup-message (&optional x y)
1028   "Insert startup message in current buffer."
1029   ;; Insert the message.
1030   (erase-buffer)
1031   (unless (and
1032            (fboundp 'find-image)
1033            (display-graphic-p)
1034            ;; Make sure the library defining `image-load-path' is
1035            ;; loaded (`find-image' is autoloaded) (and discard the
1036            ;; result).  Else, we may get "defvar ignored because
1037            ;; image-load-path is let-bound" when calling `find-image'
1038            ;; below.
1039            (or (find-image '(nil (:type xpm :file "gnus.xpm"))) t)
1040            (let* ((data-directory (nnheader-find-etc-directory "images/gnus"))
1041                   (image-load-path (cond (data-directory
1042                                           (list data-directory))
1043                                          ((boundp 'image-load-path)
1044                                           (symbol-value 'image-load-path))
1045                                          (t load-path)))
1046                   (image (gnus-splash-svg-color-symbols (find-image
1047                           `((:type svg :file "gnus.svg"
1048                                    :color-symbols
1049                                    (("#bf9900" . ,(car gnus-logo-colors))
1050                                     ("#ffcc00" . ,(cadr gnus-logo-colors))))
1051                             (:type xpm :file "gnus.xpm"
1052                                    :color-symbols
1053                                    (("thing" . ,(car gnus-logo-colors))
1054                                     ("shadow" . ,(cadr gnus-logo-colors))))
1055                             (:type png :file "gnus.png")
1056                             (:type pbm :file "gnus.pbm"
1057                                    ;; Account for the pbm's background.
1058                                    :background ,(face-foreground 'gnus-splash)
1059                                    :foreground ,(face-background 'default))
1060                             (:type xbm :file "gnus.xbm"
1061                                    ;; Account for the xbm's background.
1062                                    :background ,(face-foreground 'gnus-splash)
1063                                    :foreground ,(face-background 'default)))))))
1064              (when image
1065                (let ((size (image-size image)))
1066                  (insert-char ?\n (max 0 (round (- (window-height)
1067                                                    (or y (cdr size)) 1) 2)))
1068                  (insert-char ?\  (max 0 (round (- (window-width)
1069                                                    (or x (car size))) 2)))
1070                  (insert-image image))
1071                (goto-char (point-min))
1072                t)))
1073     (insert
1074      (format "
1075           _    ___ _             _
1076           _ ___ __ ___  __    _ ___
1077           __   _     ___    __  ___
1078               _           ___     _
1079              _  _ __             _
1080              ___   __            _
1081                    __           _
1082                     _      _   _
1083                    _      _    _
1084                       _  _    _
1085                   __  ___
1086                  _   _ _     _
1087                 _   _
1088               _    _
1089              _    _
1090             _
1091           __
1092
1093 "))
1094     ;; And then hack it.
1095     (gnus-indent-rigidly (point-min) (point-max)
1096                          (/ (max (- (window-width) (or x 46)) 0) 2))
1097     (goto-char (point-min))
1098     (forward-line 1)
1099     (let* ((pheight (count-lines (point-min) (point-max)))
1100            (wheight (window-height))
1101            (rest (- wheight pheight)))
1102       (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
1103     ;; Fontify some.
1104     (put-text-property (point-min) (point-max) 'face 'gnus-splash)
1105     (goto-char (point-min))
1106     (setq mode-line-buffer-identification (concat " " gnus-version))
1107     (set-buffer-modified-p t)))
1108
1109 (defun gnus-splash-svg-color-symbols (list)
1110   "Do color-symbol search-and-replace in svg file."
1111   (let ((type (plist-get (cdr list) :type))
1112         (file (plist-get (cdr list) :file))
1113         (color-symbols (plist-get (cdr list) :color-symbols)))
1114     (if (string= type "svg")
1115         (let ((data (with-temp-buffer (insert-file-contents file)
1116                                       (buffer-string))))
1117           (mapc (lambda (rule)
1118                   (setq data (replace-regexp-in-string
1119                               (concat "fill:" (car rule))
1120                               (concat "fill:" (cdr rule)) data)))
1121                 color-symbols)
1122           (cons (car list) (list :type type :data data)))
1123        list)))
1124
1125 (eval-when (load)
1126   (let ((command (format "%s" this-command)))
1127     (when (string-match "gnus" command)
1128       (if (string-match "gnus-other-frame" command)
1129           (gnus-get-buffer-create gnus-group-buffer)
1130         (gnus-splash)))))
1131
1132 ;;; Do the rest.
1133
1134 (require 'gnus-util)
1135 (require 'nnheader)
1136
1137 (defcustom gnus-parameters nil
1138   "Alist of group parameters.
1139
1140 For example:
1141    ((\"mail\\\\..*\"  (gnus-show-threads nil)
1142                   (gnus-use-scoring nil)
1143                   (gnus-summary-line-format
1144                         \"%U%R%z%I%(%[%d:%ub%-23,23f%]%) %s\\n\")
1145                   (gcc-self . t)
1146                   (display . all))
1147      (\"mail\\\\.me\" (gnus-use-scoring  t))
1148      (\"list\\\\..*\" (total-expire . t)
1149                   (broken-reply-to . t)))"
1150   :version "22.1"
1151   :group 'gnus-group-various
1152   :type '(repeat (cons regexp
1153                        (repeat sexp))))
1154
1155 (defcustom gnus-parameters-case-fold-search 'default
1156   "If it is t, ignore case of group names specified in `gnus-parameters'.
1157 If it is nil, don't ignore case.  If it is `default', which is for the
1158 backward compatibility, use the value of `case-fold-search'."
1159   :version "22.1"
1160   :group 'gnus-group-various
1161   :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
1162                  (const :tag "Use `case-fold-search'" default)
1163                  (const nil)
1164                  (const t)))
1165
1166 (defvar gnus-group-parameters-more nil)
1167
1168 (defmacro gnus-define-group-parameter (param &rest rest)
1169   "Define a group parameter PARAM.
1170 REST is a plist of following:
1171 :type               One of `bool', `list' or nil.
1172 :function           The name of the function.
1173 :function-document  The documentation of the function.
1174 :parameter-type     The type for customizing the parameter.
1175 :parameter-document The documentation for the parameter.
1176 :variable           The name of the variable.
1177 :variable-document  The documentation for the variable.
1178 :variable-group     The group for customizing the variable.
1179 :variable-type      The type for customizing the variable.
1180 :variable-default   The default value of the variable."
1181   (let* ((type (plist-get rest :type))
1182          (parameter-type (plist-get rest :parameter-type))
1183          (parameter-document (plist-get rest :parameter-document))
1184          (function (or (plist-get rest :function)
1185                        (intern (format "gnus-parameter-%s" param))))
1186          (function-document (or (plist-get rest :function-document) ""))
1187          (variable (or (plist-get rest :variable)
1188                        (intern (format "gnus-parameter-%s-alist" param))))
1189          (variable-document (or (plist-get rest :variable-document) ""))
1190          (variable-group (plist-get rest :variable-group))
1191          (variable-type (or (plist-get rest :variable-type)
1192                             `(quote (repeat
1193                                      (list (regexp :tag "Group")
1194                                            ,(car (cdr parameter-type)))))))
1195          (variable-default (plist-get rest :variable-default)))
1196     (list
1197      'progn
1198      `(defcustom ,variable ,variable-default
1199         ,variable-document
1200         :group 'gnus-group-parameter
1201         :group ',variable-group
1202         :type ,variable-type)
1203      `(setq gnus-group-parameters-more
1204             (delq (assq ',param gnus-group-parameters-more)
1205                   gnus-group-parameters-more))
1206      `(add-to-list 'gnus-group-parameters-more
1207                    (list ',param
1208                          ,parameter-type
1209                          ,parameter-document))
1210      (if (eq type 'bool)
1211          `(defun ,function (name)
1212             ,function-document
1213             (let ((params (gnus-group-find-parameter name))
1214                   val)
1215               (cond
1216                ((memq ',param params)
1217                 t)
1218                ((setq val (assq ',param params))
1219                 (cdr val))
1220                ((stringp ,variable)
1221                 (string-match ,variable name))
1222                (,variable
1223                 (let ((alist ,variable)
1224                       elem value)
1225                   (while (setq elem (pop alist))
1226                     (when (and name
1227                                (string-match (car elem) name))
1228                       (setq alist nil
1229                             value (cdr elem))))
1230                   (if (consp value) (car value) value))))))
1231        `(defun ,function (name)
1232           ,function-document
1233           (and name
1234                (or (gnus-group-find-parameter name ',param ,(and type t))
1235                    (let ((alist ,variable)
1236                          elem value)
1237                      (while (setq elem (pop alist))
1238                        (when (and name
1239                                   (string-match (car elem) name))
1240                          (setq alist nil
1241                                value (cdr elem))))
1242                      ,(if type
1243                           'value
1244                         '(if (consp value) (car value) value))))))))))
1245
1246 (defcustom gnus-home-directory "~/"
1247   "Directory variable that specifies the \"home\" directory.
1248 All other Gnus file and directory variables are initialized from this variable.
1249
1250 Note that Gnus is mostly loaded when the `.gnus.el' file is read.
1251 This means that other directory variables that are initialized
1252 from this variable won't be set properly if you set this variable
1253 in `.gnus.el'.  Set this variable in `.emacs' instead."
1254   :group 'gnus-files
1255   :type 'directory)
1256
1257 (defcustom gnus-directory (or (getenv "SAVEDIR")
1258                               (nnheader-concat gnus-home-directory "News/"))
1259   "*Directory variable from which all other Gnus file variables are derived.
1260
1261 Note that Gnus is mostly loaded when the `.gnus.el' file is read.
1262 This means that other directory variables that are initialized from
1263 this variable won't be set properly if you set this variable in `.gnus.el'.
1264 Set this variable in `.emacs' instead."
1265   :group 'gnus-files
1266   :type 'directory)
1267
1268 (defcustom gnus-default-directory nil
1269   "*Default directory for all Gnus buffers."
1270   :group 'gnus-files
1271   :type '(choice (const :tag "current" nil)
1272                  directory))
1273
1274 ;; Site dependent variables.
1275
1276 ;; Should this be obsolete?
1277 (defcustom gnus-default-nntp-server nil
1278   "The hostname of the default NNTP server.
1279 The empty string, or nil, means to use the local host.
1280 You may wish to set this on a site-wide basis.
1281
1282 If you want to change servers, you should use `gnus-select-method'."
1283   :group 'gnus-server
1284   :type '(choice (const :tag "local host" nil)
1285                  (string :tag "host name")))
1286
1287 (defcustom gnus-nntpserver-file "/etc/nntpserver"
1288   "A file with only the name of the nntp server in it."
1289   :group 'gnus-files
1290   :group 'gnus-server
1291   :type 'file)
1292
1293 (defun gnus-getenv-nntpserver ()
1294   "Find default nntp server.
1295 Check the NNTPSERVER environment variable and the
1296 `gnus-nntpserver-file' file."
1297   (or (getenv "NNTPSERVER")
1298       (and (file-readable-p gnus-nntpserver-file)
1299            (with-temp-buffer
1300              (insert-file-contents gnus-nntpserver-file)
1301              (when (re-search-forward "[^ \t\n\r]+" nil t)
1302                (match-string 0))))))
1303
1304 ;; `M-x customize-variable RET gnus-select-method RET' should work without
1305 ;; starting or even loading Gnus.
1306 ;;;###autoload(when (fboundp 'custom-autoload)
1307 ;;;###autoload  (custom-autoload 'gnus-select-method "gnus"))
1308
1309 (defcustom gnus-select-method
1310   (list 'nntp (or (gnus-getenv-nntpserver)
1311                   (when (and gnus-default-nntp-server
1312                              (not (string= gnus-default-nntp-server "")))
1313                     gnus-default-nntp-server)
1314                   "news"))
1315   "Default method for selecting a newsgroup.
1316 This variable should be a list, where the first element is how the
1317 news is to be fetched, the second is the address.
1318
1319 For instance, if you want to get your news via \"flab.flab.edu\" using
1320 NNTP, you could say:
1321
1322 \(setq gnus-select-method '(nntp \"flab.flab.edu\"))
1323
1324 If you want to use your local spool, say:
1325
1326 \(setq gnus-select-method (list 'nnspool (system-name)))
1327
1328 If you use this variable, you must set `gnus-nntp-server' to nil.
1329
1330 There is a lot more to know about select methods and virtual servers -
1331 see the manual for details."
1332   ;; Emacs has set-after since 22.1.
1333   ;set-after '(gnus-default-nntp-server)
1334   :group 'gnus-server
1335   :group 'gnus-start
1336   :initialize 'custom-initialize-default
1337   :type 'gnus-select-method)
1338
1339 (defcustom gnus-message-archive-method "archive"
1340   "*Method used for archiving messages you've sent.
1341 This should be a mail method.
1342
1343 See also `gnus-update-message-archive-method'."
1344   :group 'gnus-server
1345   :group 'gnus-message
1346   :type '(choice (const :tag "Default archive method" "archive")
1347                  gnus-select-method))
1348
1349 (defcustom gnus-update-message-archive-method nil
1350   "Non-nil means always update the saved \"archive\" method.
1351
1352 The archive method is initially set according to the value of
1353 `gnus-message-archive-method' and is saved in the \"~/.newsrc.eld\" file
1354 so that it may be used as a real method of the server which is named
1355 \"archive\" ever since.  If it once has been saved, it will never be
1356 updated if the value of this variable is nil, even if you change the
1357 value of `gnus-message-archive-method' afterward.  If you want the
1358 saved \"archive\" method to be updated whenever you change the value of
1359 `gnus-message-archive-method', set this variable to a non-nil value."
1360   :version "23.1"
1361   :group 'gnus-server
1362   :group 'gnus-message
1363   :type 'boolean)
1364
1365 (defcustom gnus-message-archive-group '((format-time-string "sent.%Y-%m"))
1366   "*Name of the group in which to save the messages you've written.
1367 This can either be a string; a list of strings; or an alist
1368 of regexps/functions/forms to be evaluated to return a string (or a list
1369 of strings).  The functions are called with the name of the current
1370 group (or nil) as a parameter.
1371
1372 If you want to save your mail in one group and the news articles you
1373 write in another group, you could say something like:
1374
1375  \(setq gnus-message-archive-group
1376         '((if (message-news-p)
1377               \"misc-news\"
1378             \"misc-mail\")))
1379
1380 Normally the group names returned by this variable should be
1381 unprefixed -- which implicitly means \"store on the archive server\".
1382 However, you may wish to store the message on some other server.  In
1383 that case, just return a fully prefixed name of the group --
1384 \"nnml+private:mail.misc\", for instance."
1385   :version "24.1"
1386   :group 'gnus-message
1387   :type '(choice (const :tag "none" nil)
1388                  (const :tag "Weekly" ((format-time-string "sent.%Yw%U")))
1389                  (const :tag "Monthly" ((format-time-string "sent.%Y-%m")))
1390                  (const :tag "Yearly" ((format-time-string "sent.%Y")))
1391                  function
1392                  sexp
1393                  string))
1394
1395 (defcustom gnus-secondary-servers nil
1396   "List of NNTP servers that the user can choose between interactively.
1397 To make Gnus query you for a server, you have to give `gnus' a
1398 non-numeric prefix - `C-u M-x gnus', in short."
1399   :group 'gnus-server
1400   :type '(repeat string))
1401 (make-obsolete-variable 'gnus-secondary-servers 'gnus-select-method "24.1")
1402
1403 (defcustom gnus-secondary-select-methods nil
1404   "A list of secondary methods that will be used for reading news.
1405 This is a list where each element is a complete select method (see
1406 `gnus-select-method').
1407
1408 If, for instance, you want to read your mail with the nnml back end,
1409 you could set this variable:
1410
1411 \(setq gnus-secondary-select-methods '((nnml \"\")))"
1412   :group 'gnus-server
1413   :type '(repeat gnus-select-method))
1414
1415 (defcustom gnus-local-domain nil
1416   "Local domain name without a host name.
1417 The DOMAINNAME environment variable is used instead if it is defined.
1418 If the function `system-name' returns the full Internet name, there is
1419 no need to set this variable."
1420   :group 'gnus-message
1421   :type '(choice (const :tag "default" nil)
1422                  string))
1423 (make-obsolete-variable 'gnus-local-domain nil "Emacs 24.1")
1424
1425 ;; Customization variables
1426
1427 (defcustom gnus-refer-article-method 'current
1428   "Preferred method for fetching an article by Message-ID.
1429 The value of this variable must be a valid select method as discussed
1430 in the documentation of `gnus-select-method'.
1431
1432 It can also be a list of select methods, as well as the special symbol
1433 `current', which means to use the current select method.  If it is a
1434 list, Gnus will try all the methods in the list until it finds a match."
1435   :version "24.1"
1436   :group 'gnus-server
1437   :type '(choice (const :tag "default" nil)
1438                  (const current)
1439                  (const :tag "Google" (nnweb "refer" (nnweb-type google)))
1440                  gnus-select-method
1441                  sexp
1442                  (repeat :menu-tag "Try multiple"
1443                          :tag "Multiple"
1444                          :value (current (nnweb "refer" (nnweb-type google)))
1445                          (choice :tag "Method"
1446                                  (const current)
1447                                  (const :tag "Google"
1448                                         (nnweb "refer" (nnweb-type google)))
1449                                  gnus-select-method))))
1450
1451 (defcustom gnus-use-cross-reference t
1452   "*Non-nil means that cross referenced articles will be marked as read.
1453 If nil, ignore cross references.  If t, mark articles as read in
1454 subscribed newsgroups.  If neither t nor nil, mark as read in all
1455 newsgroups."
1456   :group 'gnus-server
1457   :type '(choice (const :tag "off" nil)
1458                  (const :tag "subscribed" t)
1459                  (sexp :format "all"
1460                        :value always)))
1461
1462 (defcustom gnus-process-mark ?#
1463   "*Process mark."
1464   :group 'gnus-group-visual
1465   :group 'gnus-summary-marks
1466   :type 'character)
1467
1468 (defcustom gnus-large-newsgroup 200
1469   "*The number of articles which indicates a large newsgroup.
1470 If the number of articles in a newsgroup is greater than this value,
1471 confirmation is required for selecting the newsgroup.
1472 If it is nil, no confirmation is required.
1473
1474 Also see `gnus-large-ephemeral-newsgroup'."
1475   :group 'gnus-group-select
1476   :type '(choice (const :tag "No limit" nil)
1477                  integer))
1478
1479 (defcustom gnus-use-long-file-name (not (memq system-type '(usg-unix-v)))
1480   "Non-nil means that the default name of a file to save articles in is the group name.
1481 If it's nil, the directory form of the group name is used instead.
1482
1483 If this variable is a list, and the list contains the element
1484 `not-score', long file names will not be used for score files; if it
1485 contains the element `not-save', long file names will not be used for
1486 saving; and if it contains the element `not-kill', long file names
1487 will not be used for kill files.
1488
1489 Note that the default for this variable varies according to what system
1490 type you're using.  On `usg-unix-v' this variable defaults to nil while
1491 on all other systems it defaults to t."
1492   :group 'gnus-start
1493   :type '(radio (sexp :format "Non-nil\n"
1494                       :match (lambda (widget value)
1495                                (and value (not (listp value))))
1496                       :value t)
1497                 (const nil)
1498                 (checklist (const :format "%v " not-score)
1499                            (const :format "%v " not-save)
1500                            (const not-kill))))
1501
1502 (defcustom gnus-kill-files-directory gnus-directory
1503   "*Name of the directory where kill files will be stored (default \"~/News\")."
1504   :group 'gnus-score-files
1505   :group 'gnus-score-kill
1506   :type 'directory)
1507
1508 (defcustom gnus-save-score nil
1509   "*If non-nil, save group scoring info."
1510   :group 'gnus-score-various
1511   :group 'gnus-start
1512   :type 'boolean)
1513
1514 (defcustom gnus-use-undo t
1515   "*If non-nil, allow undoing in Gnus group mode buffers."
1516   :group 'gnus-meta
1517   :type 'boolean)
1518
1519 (defcustom gnus-use-adaptive-scoring nil
1520   "*If non-nil, use some adaptive scoring scheme.
1521 If a list, then the values `word' and `line' are meaningful.  The
1522 former will perform adaption on individual words in the subject
1523 header while `line' will perform adaption on several headers."
1524   :group 'gnus-meta
1525   :group 'gnus-score-adapt
1526   :type '(set (const word) (const line)))
1527
1528 (defcustom gnus-use-cache 'passive
1529   "*If nil, Gnus will ignore the article cache.
1530 If `passive', it will allow entering (and reading) articles
1531 explicitly entered into the cache.  If anything else, use the
1532 cache to the full extent of the law."
1533   :group 'gnus-meta
1534   :group 'gnus-cache
1535   :type '(choice (const :tag "off" nil)
1536                  (const :tag "passive" passive)
1537                  (const :tag "active" t)))
1538
1539 (defcustom gnus-use-trees nil
1540   "*If non-nil, display a thread tree buffer."
1541   :group 'gnus-meta
1542   :type 'boolean)
1543
1544 (defcustom gnus-keep-backlog 20
1545   "*If non-nil, Gnus will keep read articles for later re-retrieval.
1546 If it is a number N, then Gnus will only keep the last N articles
1547 read.  If it is neither nil nor a number, Gnus will keep all read
1548 articles.  This is not a good idea."
1549   :group 'gnus-meta
1550   :type '(choice (const :tag "off" nil)
1551                  integer
1552                  (sexp :format "all"
1553                        :value t)))
1554
1555 (defcustom gnus-suppress-duplicates nil
1556   "*If non-nil, Gnus will mark duplicate copies of the same article as read."
1557   :group 'gnus-meta
1558   :type 'boolean)
1559
1560 (defcustom gnus-use-scoring t
1561   "*If non-nil, enable scoring."
1562   :group 'gnus-meta
1563   :type 'boolean)
1564
1565 (defcustom gnus-summary-prepare-exit-hook
1566   '(gnus-summary-expire-articles)
1567   "*A hook called when preparing to exit from the summary buffer.
1568 It calls `gnus-summary-expire-articles' by default."
1569   :group 'gnus-summary-exit
1570   :type 'hook)
1571
1572 (defcustom gnus-novice-user t
1573   "*Non-nil means that you are a Usenet novice.
1574 If non-nil, verbose messages may be displayed and confirmations may be
1575 required."
1576   :group 'gnus-meta
1577   :type 'boolean)
1578
1579 (defcustom gnus-expert-user nil
1580   "*Non-nil means that you will never be asked for confirmation about anything.
1581 That doesn't mean *anything* anything; particularly destructive
1582 commands will still require prompting."
1583   :group 'gnus-meta
1584   :type 'boolean)
1585
1586 (defcustom gnus-interactive-catchup t
1587   "*If non-nil, require your confirmation when catching up a group."
1588   :group 'gnus-group-select
1589   :type 'boolean)
1590
1591 (defcustom gnus-interactive-exit t
1592   "*If non-nil, require your confirmation when exiting Gnus.
1593 If `quiet', update any active summary buffers automatically
1594 first before exiting."
1595   :group 'gnus-exit
1596   :type '(choice boolean
1597                  (const quiet)))
1598
1599 (defcustom gnus-extract-address-components 'gnus-extract-address-components
1600   "*Function for extracting address components from a From header.
1601 Two pre-defined function exist: `gnus-extract-address-components',
1602 which is the default, quite fast, and too simplistic solution, and
1603 `mail-extract-address-components', which works much better, but is
1604 slower."
1605   :group 'gnus-summary-format
1606   :type '(radio (function-item gnus-extract-address-components)
1607                 (function-item mail-extract-address-components)
1608                 (function :tag "Other")))
1609
1610 (defcustom gnus-shell-command-separator ";"
1611   "String used to separate shell commands."
1612   :group 'gnus-files
1613   :type 'string)
1614
1615 (defcustom gnus-valid-select-methods
1616   '(("nntp" post address prompt-address physical-address cloud)
1617     ("nnspool" post address)
1618     ("nnvirtual" post-mail virtual prompt-address)
1619     ("nnmbox" mail respool address)
1620     ("nnml" post-mail respool address)
1621     ("nnmh" mail respool address)
1622     ("nndir" post-mail prompt-address physical-address)
1623     ("nneething" none address prompt-address physical-address)
1624     ("nndoc" none address prompt-address)
1625     ("nnbabyl" mail address respool)
1626     ("nndraft" post-mail)
1627     ("nnfolder" mail respool address)
1628     ("nngateway" post-mail address prompt-address physical-address)
1629     ("nnweb" none)
1630     ("nnrss" none global)
1631     ("nnagent" post-mail)
1632     ("nnimap" post-mail address prompt-address physical-address respool
1633      server-marks cloud)
1634     ("nnmaildir" mail respool address server-marks)
1635     ("nnnil" none))
1636   "*An alist of valid select methods.
1637 The first element of each list lists should be a string with the name
1638 of the select method.  The other elements may be the category of
1639 this method (i. e., `post', `mail', `none' or whatever) or other
1640 properties that this method has (like being respoolable).
1641 If you implement a new select method, all you should have to change is
1642 this variable.  I think."
1643   :group 'gnus-server
1644   :type '(repeat (group (string :tag "Name")
1645                         (radio-button-choice (const :format "%v " post)
1646                                              (const :format "%v " mail)
1647                                              (const :format "%v " none)
1648                                              (const post-mail))
1649                         (checklist :inline t :greedy t
1650                                    (const :format "%v " address)
1651                                    (const global)
1652                                    (const :format "%v " prompt-address)
1653                                    (const :format "%v " physical-address)
1654                                    (const virtual)
1655                                    (const :format "%v " respool)
1656                                    (const server-marks))))
1657   :version "24.1")
1658
1659 (defun gnus-redefine-select-method-widget ()
1660   "Recomputes the select-method widget based on the value of
1661 `gnus-valid-select-methods'."
1662   (define-widget 'gnus-select-method 'list
1663     "Widget for entering a select method."
1664     :value '(nntp "")
1665     :tag "Select Method"
1666     :args `((choice :tag "Method"
1667                     ,@(mapcar (lambda (entry)
1668                                 (list 'const :format "%v\n"
1669                                       (intern (car entry))))
1670                               gnus-valid-select-methods)
1671                     (symbol :tag "other"))
1672             (string :tag "Address")
1673             (repeat :tag "Options"
1674                     :inline t
1675                     (list :format "%v"
1676                           variable
1677                           (sexp :tag "Value"))))))
1678
1679 (gnus-redefine-select-method-widget)
1680
1681 (defcustom gnus-updated-mode-lines '(group article summary tree)
1682   "List of buffers that should update their mode lines.
1683 The list may contain the symbols `group', `article', `tree' and
1684 `summary'.  If the corresponding symbol is present, Gnus will keep
1685 that mode line updated with information that may be pertinent.
1686 If this variable is nil, screen refresh may be quicker."
1687   :group 'gnus-various
1688   :type '(set (const group)
1689               (const article)
1690               (const summary)
1691               (const tree)))
1692
1693 (defcustom gnus-mode-non-string-length 30
1694   "*Max length of mode-line non-string contents.
1695 If this is nil, Gnus will take space as is needed, leaving the rest
1696 of the mode line intact."
1697   :version "24.1"
1698   :group 'gnus-various
1699   :type '(choice (const nil)
1700                  integer))
1701
1702 ;; There should be special validation for this.
1703 (define-widget 'gnus-email-address 'string
1704   "An email address.")
1705
1706 (gnus-define-group-parameter
1707  to-address
1708  :function-document
1709  "Return GROUP's to-address."
1710  :variable-document
1711  "*Alist of group regexps and correspondent to-addresses."
1712  :variable-group gnus-group-parameter
1713  :parameter-type '(gnus-email-address :tag "To Address")
1714  :parameter-document "\
1715 This will be used when doing followups and posts.
1716
1717 This is primarily useful in mail groups that represent closed
1718 mailing lists--mailing lists where it's expected that everybody that
1719 writes to the mailing list is subscribed to it.  Since using this
1720 parameter ensures that the mail only goes to the mailing list itself,
1721 it means that members won't receive two copies of your followups.
1722
1723 Using `to-address' will actually work whether the group is foreign or
1724 not.  Let's say there's a group on the server that is called
1725 `fa.4ad-l'.  This is a real newsgroup, but the server has gotten the
1726 articles from a mail-to-news gateway.  Posting directly to this group
1727 is therefore impossible--you have to send mail to the mailing list
1728 address instead.
1729
1730 The gnus-group-split mail splitting mechanism will behave as if this
1731 address was listed in gnus-group-split Addresses (see below).")
1732
1733 (gnus-define-group-parameter
1734  to-list
1735  :function-document
1736  "Return GROUP's to-list."
1737  :variable-document
1738  "*Alist of group regexps and correspondent to-lists."
1739  :variable-group gnus-group-parameter
1740  :parameter-type '(gnus-email-address :tag "To List")
1741  :parameter-document "\
1742 This address will be used when doing a `a' in the group.
1743
1744 It is totally ignored when doing a followup--except that if it is
1745 present in a news group, you'll get mail group semantics when doing
1746 `f'.
1747
1748 The gnus-group-split mail splitting mechanism will behave as if this
1749 address was listed in gnus-group-split Addresses (see below).")
1750
1751 (gnus-define-group-parameter
1752  subscribed
1753  :type bool
1754  :function-document
1755  "Return GROUP's subscription status."
1756  :variable-document
1757  "*Groups which are automatically considered subscribed."
1758  :variable-group gnus-group-parameter
1759  :parameter-type '(const :tag "Subscribed" t)
1760  :parameter-document "\
1761 Gnus assumed that you are subscribed to the To/List address.
1762
1763 When constructing a list of subscribed groups using
1764 `gnus-find-subscribed-addresses', Gnus includes the To address given
1765 above, or the list address (if the To address has not been set).")
1766
1767 (gnus-define-group-parameter
1768  auto-expire
1769  :type bool
1770  :function gnus-group-auto-expirable-p
1771  :function-document
1772  "Check whether GROUP is auto-expirable or not."
1773  :variable gnus-auto-expirable-newsgroups
1774  :variable-default nil
1775  :variable-document
1776  "*Groups in which to automatically mark read articles as expirable.
1777 If non-nil, this should be a regexp that should match all groups in
1778 which to perform auto-expiry.  This only makes sense for mail groups."
1779  :variable-group nnmail-expire
1780  :variable-type '(choice (const nil)
1781                          regexp)
1782  :parameter-type '(const :tag "Automatic Expire" t)
1783  :parameter-document
1784  "All articles that are read will be marked as expirable.")
1785
1786 (gnus-define-group-parameter
1787  total-expire
1788  :type bool
1789  :function gnus-group-total-expirable-p
1790  :function-document
1791  "Check whether GROUP is total-expirable or not."
1792  :variable gnus-total-expirable-newsgroups
1793  :variable-default nil
1794  :variable-document
1795  "*Groups in which to perform expiry of all read articles.
1796 Use with extreme caution.  All groups that match this regexp will be
1797 expiring - which means that all read articles will be deleted after
1798 \(say) one week.  (This only goes for mail groups and the like, of
1799 course.)"
1800  :variable-group nnmail-expire
1801  :variable-type '(choice (const nil)
1802                          regexp)
1803  :parameter-type '(const :tag "Total Expire" t)
1804  :parameter-document
1805  "All read articles will be put through the expiry process
1806
1807 This happens even if they are not marked as expirable.
1808 Use with caution.")
1809
1810 (gnus-define-group-parameter
1811  charset
1812  :function-document
1813  "Return the default charset of GROUP."
1814  :variable gnus-group-charset-alist
1815  :variable-default
1816  '(("\\(^\\|:\\)hk\\>\\|\\(^\\|:\\)tw\\>\\|\\<big5\\>" cn-big5)
1817    ("\\(^\\|:\\)cn\\>\\|\\<chinese\\>" cn-gb-2312)
1818    ("\\(^\\|:\\)fj\\>\\|\\(^\\|:\\)japan\\>" iso-2022-jp-2)
1819    ("\\(^\\|:\\)tnn\\>\\|\\(^\\|:\\)pin\\>\\|\\(^\\|:\\)sci.lang.japan" iso-2022-7bit)
1820    ("\\(^\\|:\\)relcom\\>" koi8-r)
1821    ("\\(^\\|:\\)fido7\\>" koi8-r)
1822    ("\\(^\\|:\\)\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
1823    ("\\(^\\|:\\)israel\\>" iso-8859-1)
1824    ("\\(^\\|:\\)han\\>" euc-kr)
1825    ("\\(^\\|:\\)alt.chinese.text.big5\\>" chinese-big5)
1826    ("\\(^\\|:\\)soc.culture.vietnamese\\>" vietnamese-viqr)
1827    ("\\(^\\|:\\)\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1))
1828  :variable-document
1829  "Alist of regexps (to match group names) and default charsets to be used when reading."
1830  :variable-group gnus-charset
1831  :variable-type '(repeat (list (regexp :tag "Group")
1832                                (symbol :tag "Charset")))
1833  :parameter-type '(symbol :tag "Charset")
1834  :parameter-document "\
1835 The default charset to use in the group.")
1836
1837 (gnus-define-group-parameter
1838  post-method
1839  :type list
1840  :function-document
1841  "Return a posting method for GROUP."
1842  :variable gnus-post-method-alist
1843  :variable-document
1844  "Alist of regexps (to match group names) and method to be used when
1845 posting an article."
1846  :variable-group gnus-group-foreign
1847  :parameter-type
1848  '(choice :tag "Posting Method"
1849           (const :tag "Use native server" native)
1850           (const :tag "Use current server" current)
1851           (list :convert-widget
1852                 (lambda (widget)
1853                   (list 'sexp :tag "Methods"
1854                         :value gnus-select-method))))
1855  :parameter-document
1856  "Posting method for this group.")
1857
1858 (gnus-define-group-parameter
1859  large-newsgroup-initial
1860  :type integer
1861  :function-document
1862  "Return GROUP's initial input of the number of articles."
1863  :variable-document
1864  "*Alist of group regexps and its initial input of the number of articles."
1865  :variable-group gnus-group-parameter
1866  :parameter-type '(choice :tag "Initial Input for Large Newsgroup"
1867                           (const :tag "All" nil)
1868                           (integer))
1869  :parameter-document "\
1870
1871 This number will be prompted as the initial value of the number of
1872 articles to list when the group is a large newsgroup (see
1873 `gnus-large-newsgroup').  If it is nil, the default value is the
1874 total number of articles in the group.")
1875
1876 ;; The Gnus registry's ignored groups
1877 (gnus-define-group-parameter
1878  registry-ignore
1879  :type list
1880  :function-document
1881  "Whether this group should be ignored by the registry."
1882  :variable gnus-registry-ignored-groups
1883  :variable-default (mapcar
1884                     (lambda (g) (list g t))
1885                     '("delayed$" "drafts$" "queue$" "INBOX$"
1886                       "^nnmairix:" "^nnir:" "archive"))
1887  :variable-document
1888  "*Groups in which the registry should be turned off."
1889  :variable-group gnus-registry
1890  :variable-type '(repeat
1891                   (list
1892                    (regexp :tag "Group Name Regular Expression")
1893                    (boolean :tag "Ignored")))
1894
1895  :parameter-type '(boolean :tag "Group Ignored by the Registry")
1896  :parameter-document
1897  "Whether the Gnus Registry should ignore this group.")
1898
1899 ;; group parameters for spam processing added by Ted Zlatanov <tzz@lifelogs.com>
1900 (defcustom gnus-install-group-spam-parameters t
1901   "*Disable the group parameters for spam detection.
1902 Enable if `G c' in XEmacs is giving you trouble, and make sure to submit a bug report."
1903   :version "22.1"
1904   :type 'boolean
1905   :group 'gnus-start)
1906
1907 (when gnus-install-group-spam-parameters
1908   (defvar gnus-group-spam-classification-spam t
1909     "Spam group classification (requires spam.el).
1910 This group contains spam messages.  On summary entry, unread messages
1911 will be marked as spam.  On summary exit, the specified spam
1912 processors will be invoked on spam-marked messages, then those
1913 messages will be expired, so the spam processor will only see a
1914 spam-marked message once.")
1915
1916   (defvar gnus-group-spam-classification-ham 'ask
1917     "The ham value for the spam group parameter (requires spam.el).
1918 On summary exit, the specified ham processors will be invoked on
1919 ham-marked messages.  Exercise caution, since the ham processor will
1920 see the same message more than once because there is no ham message
1921 registry.")
1922
1923   (gnus-define-group-parameter
1924    spam-contents
1925    :type list
1926    :function-document
1927    "The spam type (spam, ham, or neither) of the group."
1928    :variable gnus-spam-newsgroup-contents
1929    :variable-default nil
1930    :variable-document
1931    "*Group classification (spam, ham, or neither).  Only
1932 meaningful when spam.el is loaded.  If non-nil, this should be a
1933 list of group name regexps associated with a classification for
1934 each one.  In spam groups, new articles are marked as spam on
1935 summary entry.  There is other behavior associated with ham and
1936 no classification when spam.el is loaded - see the manual."
1937    :variable-group spam
1938    :variable-type '(repeat
1939                     (list :tag "Group contents spam/ham classification"
1940                           (regexp :tag "Group")
1941                           (choice
1942                            (variable-item gnus-group-spam-classification-spam)
1943                            (variable-item gnus-group-spam-classification-ham)
1944                            (const :tag "Unclassified" nil))))
1945
1946    :parameter-type '(list :tag "Group contents spam/ham classification"
1947                           (choice :tag "Group contents classification for spam sorting"
1948                                   (variable-item gnus-group-spam-classification-spam)
1949                                   (variable-item gnus-group-spam-classification-ham)
1950                                   (const :tag "Unclassified" nil)))
1951    :parameter-document
1952    "The spam classification (spam, ham, or neither) of this group.
1953 When a spam group is entered, all unread articles are marked as
1954 spam.  There is other behavior associated with ham and no
1955 classification when spam.el is loaded - see the manual.")
1956
1957   (gnus-define-group-parameter
1958    spam-resend-to
1959    :type list
1960    :function-document
1961    "The address to get spam resent (through spam-report-resend)."
1962    :variable gnus-spam-resend-to
1963    :variable-default nil
1964    :variable-document
1965    "The address to get spam resent (through spam-report-resend)."
1966    :variable-group spam
1967    :variable-type '(repeat
1968                     (list :tag "Group address for resending spam"
1969                           (regexp :tag "Group")
1970                           (string :tag "E-mail address for resending spam (requires the spam-use-resend exit processor)")))
1971    :parameter-type 'string :tag "E-mail address for resending spam (requires the spam-use-resend exit processor)"
1972    :parameter-document
1973    "The address to get spam resent (through spam-report-resend).")
1974
1975   (gnus-define-group-parameter
1976    ham-resend-to
1977    :type list
1978    :function-document
1979    "The address to get ham resent (through spam-report-resend)."
1980    :variable gnus-ham-resend-to
1981    :variable-default nil
1982    :variable-document
1983    "The address to get ham resent (through spam-report-resend)."
1984    :variable-group spam
1985    :variable-type '(repeat
1986                     (list :tag "Group address for resending ham"
1987                           (regexp :tag "Group")
1988                           (string :tag "E-mail address for resending ham (requires the spam-use-resend exit processor)")))
1989    :parameter-type 'string :tag "E-mail address for resending ham (requires the spam-use-resend exit processor)"
1990    :parameter-document
1991    "The address to get ham resent (through spam-report-resend).")
1992
1993   (defvar gnus-group-spam-exit-processor-ifile "ifile"
1994     "OBSOLETE: The ifile summary exit spam processor.")
1995
1996   (defvar gnus-group-spam-exit-processor-stat "stat"
1997     "OBSOLETE: The spam-stat summary exit spam processor.")
1998
1999   (defvar gnus-group-spam-exit-processor-bogofilter "bogofilter"
2000     "OBSOLETE: The Bogofilter summary exit spam processor.")
2001
2002   (defvar gnus-group-spam-exit-processor-blacklist "blacklist"
2003     "OBSOLETE: The Blacklist summary exit spam processor.")
2004
2005   (defvar gnus-group-spam-exit-processor-report-gmane "report-gmane"
2006     "OBSOLETE: The Gmane reporting summary exit spam processor.
2007 Only applicable to NNTP groups with articles from Gmane.  See spam-report.el")
2008
2009   (defvar gnus-group-spam-exit-processor-spamoracle "spamoracle-spam"
2010     "OBSOLETE: The spamoracle summary exit spam processor.")
2011
2012   (defvar gnus-group-ham-exit-processor-ifile "ifile-ham"
2013     "OBSOLETE: The ifile summary exit ham processor.
2014 Only applicable to non-spam (unclassified and ham) groups.")
2015
2016   (defvar gnus-group-ham-exit-processor-bogofilter "bogofilter-ham"
2017     "OBSOLETE: The Bogofilter summary exit ham processor.
2018 Only applicable to non-spam (unclassified and ham) groups.")
2019
2020   (defvar gnus-group-ham-exit-processor-stat "stat-ham"
2021     "OBSOLETE: The spam-stat summary exit ham processor.
2022 Only applicable to non-spam (unclassified and ham) groups.")
2023
2024   (defvar gnus-group-ham-exit-processor-whitelist "whitelist"
2025     "OBSOLETE: The whitelist summary exit ham processor.
2026 Only applicable to non-spam (unclassified and ham) groups.")
2027
2028   (defvar gnus-group-ham-exit-processor-BBDB "bbdb"
2029     "OBSOLETE: The BBDB summary exit ham processor.
2030 Only applicable to non-spam (unclassified and ham) groups.")
2031
2032   (defvar gnus-group-ham-exit-processor-copy "copy"
2033     "OBSOLETE: The ham copy exit ham processor.
2034 Only applicable to non-spam (unclassified and ham) groups.")
2035
2036   (defvar gnus-group-ham-exit-processor-spamoracle "spamoracle-ham"
2037     "OBSOLETE: The spamoracle summary exit ham processor.
2038 Only applicable to non-spam (unclassified and ham) groups.")
2039
2040   (gnus-define-group-parameter
2041    spam-process
2042    :type list
2043    :parameter-type
2044    '(choice
2045      :tag "Spam Summary Exit Processor"
2046      :value nil
2047      (list :tag "Spam Summary Exit Processor Choices"
2048            (set
2049             (const :tag "Spam: Bogofilter"    (spam spam-use-bogofilter))
2050             (const :tag "Spam: Blacklist"     (spam spam-use-blacklist))
2051             (const :tag "Spam: Bsfilter"      (spam spam-use-bsfilter))
2052             (const :tag "Spam: Gmane Report"  (spam spam-use-gmane))
2053             (const :tag "Spam: Resend Message"(spam spam-use-resend))
2054             (const :tag "Spam: ifile"         (spam spam-use-ifile))
2055             (const :tag "Spam: Spam Oracle"   (spam spam-use-spamoracle))
2056             (const :tag "Spam: Spam-stat"     (spam spam-use-stat))
2057             (const :tag "Spam: SpamAssassin"  (spam spam-use-spamassassin))
2058             (const :tag "Spam: CRM114"        (spam spam-use-crm114))
2059             (const :tag "Ham: BBDB"           (ham spam-use-BBDB))
2060             (const :tag "Ham: Bogofilter"     (ham spam-use-bogofilter))
2061             (const :tag "Ham: Bsfilter"       (ham spam-use-bsfilter))
2062             (const :tag "Ham: Copy"           (ham spam-use-ham-copy))
2063             (const :tag "Ham: Resend Message" (ham spam-use-resend))
2064             (const :tag "Ham: ifile"          (ham spam-use-ifile))
2065             (const :tag "Ham: Spam Oracle"    (ham spam-use-spamoracle))
2066             (const :tag "Ham: Spam-stat"      (ham spam-use-stat))
2067             (const :tag "Ham: SpamAssassin"   (ham spam-use-spamassassin))
2068             (const :tag "Ham: CRM114"         (ham spam-use-crm114))
2069             (const :tag "Ham: Whitelist"      (ham spam-use-whitelist))
2070             (variable-item gnus-group-spam-exit-processor-ifile)
2071             (variable-item gnus-group-spam-exit-processor-stat)
2072             (variable-item gnus-group-spam-exit-processor-bogofilter)
2073             (variable-item gnus-group-spam-exit-processor-blacklist)
2074             (variable-item gnus-group-spam-exit-processor-spamoracle)
2075             (variable-item gnus-group-spam-exit-processor-report-gmane)
2076             (variable-item gnus-group-ham-exit-processor-bogofilter)
2077             (variable-item gnus-group-ham-exit-processor-ifile)
2078             (variable-item gnus-group-ham-exit-processor-stat)
2079             (variable-item gnus-group-ham-exit-processor-whitelist)
2080             (variable-item gnus-group-ham-exit-processor-BBDB)
2081             (variable-item gnus-group-ham-exit-processor-spamoracle)
2082             (variable-item gnus-group-ham-exit-processor-copy))))
2083    :function-document
2084    "Which spam or ham processors will be applied when the summary is exited."
2085    :variable gnus-spam-process-newsgroups
2086    :variable-default nil
2087    :variable-document
2088    "*Groups in which to automatically process spam or ham articles with
2089 a backend on summary exit.  If non-nil, this should be a list of group
2090 name regexps that should match all groups in which to do automatic
2091 spam processing, associated with the appropriate processor."
2092    :variable-group spam
2093    :variable-type
2094    '(repeat :tag "Spam/Ham Processors"
2095             (list :tag "Spam Summary Exit Processor Choices"
2096                   (regexp :tag "Group Regexp")
2097                   (set
2098                    :tag "Spam/Ham Summary Exit Processor"
2099                    (const :tag "Spam: Bogofilter"    (spam spam-use-bogofilter))
2100                    (const :tag "Spam: Blacklist"     (spam spam-use-blacklist))
2101                    (const :tag "Spam: Bsfilter"      (spam spam-use-bsfilter))
2102                    (const :tag "Spam: Gmane Report"  (spam spam-use-gmane))
2103                    (const :tag "Spam: Resend Message"(spam spam-use-resend))
2104                    (const :tag "Spam: ifile"         (spam spam-use-ifile))
2105                    (const :tag "Spam: Spam-stat"     (spam spam-use-stat))
2106                    (const :tag "Spam: Spam Oracle"   (spam spam-use-spamoracle))
2107                    (const :tag "Spam: SpamAssassin"  (spam spam-use-spamassassin))
2108                    (const :tag "Spam: CRM114"        (spam spam-use-crm114))
2109                    (const :tag "Ham: BBDB"           (ham spam-use-BBDB))
2110                    (const :tag "Ham: Bogofilter"     (ham spam-use-bogofilter))
2111                    (const :tag "Ham: Bsfilter"       (ham spam-use-bsfilter))
2112                    (const :tag "Ham: Copy"           (ham spam-use-ham-copy))
2113                    (const :tag "Ham: Resend Message" (ham spam-use-resend))
2114                    (const :tag "Ham: ifile"          (ham spam-use-ifile))
2115                    (const :tag "Ham: Spam-stat"      (ham spam-use-stat))
2116                    (const :tag "Ham: Spam Oracle"    (ham spam-use-spamoracle))
2117                    (const :tag "Ham: SpamAssassin"   (ham spam-use-spamassassin))
2118                    (const :tag "Ham: CRM114"         (ham spam-use-crm114))
2119                    (const :tag "Ham: Whitelist"      (ham spam-use-whitelist))
2120                    (variable-item gnus-group-spam-exit-processor-ifile)
2121                    (variable-item gnus-group-spam-exit-processor-stat)
2122                    (variable-item gnus-group-spam-exit-processor-bogofilter)
2123                    (variable-item gnus-group-spam-exit-processor-blacklist)
2124                    (variable-item gnus-group-spam-exit-processor-spamoracle)
2125                    (variable-item gnus-group-spam-exit-processor-report-gmane)
2126                    (variable-item gnus-group-ham-exit-processor-bogofilter)
2127                    (variable-item gnus-group-ham-exit-processor-ifile)
2128                    (variable-item gnus-group-ham-exit-processor-stat)
2129                    (variable-item gnus-group-ham-exit-processor-whitelist)
2130                    (variable-item gnus-group-ham-exit-processor-BBDB)
2131                    (variable-item gnus-group-ham-exit-processor-spamoracle)
2132                    (variable-item gnus-group-ham-exit-processor-copy))))
2133
2134    :parameter-document
2135    "Which spam or ham processors will be applied when the summary is exited.")
2136
2137   (gnus-define-group-parameter
2138    spam-autodetect
2139    :type list
2140    :parameter-type
2141    '(boolean :tag "Spam autodetection")
2142    :function-document
2143    "Should spam be autodetected (with spam-split) in this group?"
2144    :variable gnus-spam-autodetect
2145    :variable-default nil
2146    :variable-document
2147    "*Groups in which spam should be autodetected when they are entered.
2148    Only unseen articles will be examined, unless
2149    spam-autodetect-recheck-messages is set."
2150    :variable-group spam
2151    :variable-type
2152    '(repeat
2153      :tag "Autodetection setting"
2154      (list
2155       (regexp :tag "Group Regexp")
2156       boolean))
2157    :parameter-document
2158    "Spam autodetection.
2159 Only unseen articles will be examined, unless
2160 spam-autodetect-recheck-messages is set.")
2161
2162   (gnus-define-group-parameter
2163    spam-autodetect-methods
2164    :type list
2165    :parameter-type
2166    '(choice :tag "Spam autodetection-specific methods"
2167      (const none)
2168      (const default)
2169      (set :tag "Use specific methods"
2170           (variable-item spam-use-blacklist)
2171           (variable-item spam-use-gmane-xref)
2172           (variable-item spam-use-regex-headers)
2173           (variable-item spam-use-regex-body)
2174           (variable-item spam-use-whitelist)
2175           (variable-item spam-use-BBDB)
2176           (variable-item spam-use-ifile)
2177           (variable-item spam-use-spamoracle)
2178           (variable-item spam-use-crm114)
2179           (variable-item spam-use-spamassassin)
2180           (variable-item spam-use-spamassassin-headers)
2181           (variable-item spam-use-bsfilter)
2182           (variable-item spam-use-bsfilter-headers)
2183           (variable-item spam-use-stat)
2184           (variable-item spam-use-blackholes)
2185           (variable-item spam-use-hashcash)
2186           (variable-item spam-use-bogofilter-headers)
2187           (variable-item spam-use-bogofilter)))
2188    :function-document
2189    "Methods to be used for autodetection in each group"
2190    :variable gnus-spam-autodetect-methods
2191    :variable-default nil
2192    :variable-document
2193    "*Methods for autodetecting spam per group.
2194 Requires the spam-autodetect parameter.  Only unseen articles
2195 will be examined, unless spam-autodetect-recheck-messages is
2196 set."
2197    :variable-group spam
2198    :variable-type
2199    '(repeat
2200      :tag "Autodetection methods"
2201      (list
2202       (regexp :tag "Group Regexp")
2203       (choice
2204        (const none)
2205        (const default)
2206        (set :tag "Use specific methods"
2207         (variable-item spam-use-blacklist)
2208         (variable-item spam-use-gmane-xref)
2209         (variable-item spam-use-regex-headers)
2210         (variable-item spam-use-regex-body)
2211         (variable-item spam-use-whitelist)
2212         (variable-item spam-use-BBDB)
2213         (variable-item spam-use-ifile)
2214         (variable-item spam-use-spamoracle)
2215         (variable-item spam-use-crm114)
2216         (variable-item spam-use-stat)
2217         (variable-item spam-use-blackholes)
2218         (variable-item spam-use-hashcash)
2219         (variable-item spam-use-spamassassin)
2220         (variable-item spam-use-spamassassin-headers)
2221         (variable-item spam-use-bsfilter)
2222         (variable-item spam-use-bsfilter-headers)
2223         (variable-item spam-use-bogofilter-headers)
2224         (variable-item spam-use-bogofilter)))))
2225      :parameter-document
2226    "Spam autodetection methods.
2227 Requires the spam-autodetect parameter.  Only unseen articles
2228 will be examined, unless spam-autodetect-recheck-messages is
2229 set.")
2230
2231   (gnus-define-group-parameter
2232    spam-process-destination
2233    :type list
2234    :parameter-type
2235    '(choice :tag "Destination for spam-processed articles at summary exit"
2236             (string :tag "Move to a group")
2237             (repeat :tag "Move to multiple groups"
2238                     (string :tag "Destination group"))
2239             (const :tag "Expire" nil))
2240    :function-document
2241    "Where spam-processed articles will go at summary exit."
2242    :variable gnus-spam-process-destinations
2243    :variable-default nil
2244    :variable-document
2245    "*Groups in which to explicitly send spam-processed articles to
2246 another group, or expire them (the default).  If non-nil, this should
2247 be a list of group name regexps that should match all groups in which
2248 to do spam-processed article moving, associated with the destination
2249 group or nil for explicit expiration.  This only makes sense for
2250 mail groups."
2251    :variable-group spam
2252    :variable-type
2253    '(repeat
2254      :tag "Spam-processed articles destination"
2255      (list
2256       (regexp :tag "Group Regexp")
2257       (choice
2258        :tag "Destination for spam-processed articles at summary exit"
2259        (string :tag "Move to a group")
2260        (repeat :tag "Move to multiple groups"
2261                (string :tag "Destination group"))
2262        (const :tag "Expire" nil))))
2263    :parameter-document
2264    "Where spam-processed articles will go at summary exit.")
2265
2266   (gnus-define-group-parameter
2267    ham-process-destination
2268    :type list
2269    :parameter-type
2270    '(choice
2271      :tag "Destination for ham articles at summary exit from a spam group"
2272      (string :tag "Move to a group")
2273      (repeat :tag "Move to multiple groups"
2274              (string :tag "Destination group"))
2275      (const :tag "Respool" respool)
2276      (const :tag "Do nothing" nil))
2277    :function-document
2278    "Where ham articles will go at summary exit from a spam group."
2279    :variable gnus-ham-process-destinations
2280    :variable-default nil
2281    :variable-document
2282    "*Groups in which to explicitly send ham articles to
2283 another group, or do nothing (the default).  If non-nil, this should
2284 be a list of group name regexps that should match all groups in which
2285 to do ham article moving, associated with the destination
2286 group or nil for explicit ignoring.  This only makes sense for
2287 mail groups, and only works in spam groups."
2288    :variable-group spam
2289    :variable-type
2290    '(repeat
2291      :tag "Ham articles destination"
2292      (list
2293       (regexp :tag "Group Regexp")
2294       (choice
2295        :tag "Destination for ham articles at summary exit from spam group"
2296        (string :tag "Move to a group")
2297        (repeat :tag "Move to multiple groups"
2298                 (string :tag "Destination group"))
2299        (const :tag "Respool" respool)
2300        (const :tag "Expire" nil))))
2301    :parameter-document
2302    "Where ham articles will go at summary exit from a spam group.")
2303
2304   (gnus-define-group-parameter
2305    ham-marks
2306    :type 'list
2307    :parameter-type '(list :tag "Ham mark choices"
2308                           (set
2309                            (variable-item gnus-del-mark)
2310                            (variable-item gnus-read-mark)
2311                            (variable-item gnus-ticked-mark)
2312                            (variable-item gnus-killed-mark)
2313                            (variable-item gnus-kill-file-mark)
2314                            (variable-item gnus-low-score-mark)))
2315
2316    :parameter-document
2317    "Marks considered ham (positively not spam).  Such articles will be
2318 processed as ham (non-spam) on group exit.  When nil, the global
2319 spam-ham-marks variable takes precedence."
2320    :variable-default '((".*" ((gnus-del-mark
2321                                gnus-read-mark
2322                                gnus-killed-mark
2323                                gnus-kill-file-mark
2324                                gnus-low-score-mark))))
2325    :variable-group spam
2326    :variable-document
2327    "*Groups in which to explicitly set the ham marks to some value.")
2328
2329   (gnus-define-group-parameter
2330    spam-marks
2331    :type 'list
2332    :parameter-type '(list :tag "Spam mark choices"
2333                           (set
2334                            (variable-item gnus-spam-mark)
2335                            (variable-item gnus-killed-mark)
2336                            (variable-item gnus-kill-file-mark)
2337                            (variable-item gnus-low-score-mark)))
2338
2339    :parameter-document
2340    "Marks considered spam.
2341 Such articles will be processed as spam on group exit.  When nil, the global
2342 spam-spam-marks variable takes precedence."
2343    :variable-default '((".*" ((gnus-spam-mark))))
2344    :variable-group spam
2345    :variable-document
2346    "*Groups in which to explicitly set the spam marks to some value."))
2347
2348 (defcustom gnus-group-uncollapsed-levels 1
2349   "Number of group name elements to leave alone when making a short group name."
2350   :group 'gnus-group-visual
2351   :type 'integer)
2352
2353 (defcustom gnus-group-use-permanent-levels nil
2354   "*If non-nil, once you set a level, Gnus will use this level."
2355   :group 'gnus-group-levels
2356   :type 'boolean)
2357
2358 ;; Hooks.
2359
2360 (defcustom gnus-load-hook nil
2361   "A hook run while Gnus is loaded."
2362   :group 'gnus-start
2363   :type 'hook)
2364
2365 (defcustom gnus-apply-kill-hook '(gnus-apply-kill-file)
2366   "A hook called to apply kill files to a group.
2367 This hook is intended to apply a kill file to the selected newsgroup.
2368 The function `gnus-apply-kill-file' is called by default.
2369
2370 Since a general kill file is too heavy to use only for a few
2371 newsgroups, I recommend you to use a lighter hook function.  For
2372 example, if you'd like to apply a kill file to articles which contains
2373 a string `rmgroup' in subject in newsgroup `control', you can use the
2374 following hook:
2375
2376  (setq gnus-apply-kill-hook
2377       (list
2378         (lambda ()
2379           (cond ((string-match \"control\" gnus-newsgroup-name)
2380                  (gnus-kill \"Subject\" \"rmgroup\")
2381                  (gnus-expunge \"X\"))))))"
2382   :group 'gnus-score-kill
2383   :options '(gnus-apply-kill-file)
2384   :type 'hook)
2385
2386 (defcustom gnus-group-change-level-function nil
2387   "Function run when a group level is changed.
2388 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL."
2389   :group 'gnus-group-levels
2390   :type '(choice (const nil)
2391                  function))
2392
2393 ;;; Face thingies.
2394
2395 (defcustom gnus-visual
2396   '(summary-highlight group-highlight article-highlight
2397                       mouse-face
2398                       summary-menu group-menu article-menu
2399                       tree-highlight menu highlight
2400                       browse-menu server-menu
2401                       page-marker tree-menu binary-menu pick-menu)
2402   "*Enable visual features.
2403 If `visual' is disabled, there will be no menus and few faces.  Most of
2404 the visual customization options below will be ignored.  Gnus will use
2405 less space and be faster as a result.
2406
2407 This variable can also be a list of visual elements to switch on.  For
2408 instance, to switch off all visual things except menus, you can say:
2409
2410    (setq gnus-visual '(menu))
2411
2412 Valid elements include `summary-highlight', `group-highlight',
2413 `article-highlight', `mouse-face', `summary-menu', `group-menu',
2414 `article-menu', `tree-highlight', `menu', `highlight', `browse-menu',
2415 `server-menu', `page-marker', `tree-menu', `binary-menu', and`pick-menu'."
2416   :group 'gnus-meta
2417   :group 'gnus-visual
2418   :type '(set (const summary-highlight)
2419               (const group-highlight)
2420               (const article-highlight)
2421               (const mouse-face)
2422               (const summary-menu)
2423               (const group-menu)
2424               (const article-menu)
2425               (const tree-highlight)
2426               (const menu)
2427               (const highlight)
2428               (const browse-menu)
2429               (const server-menu)
2430               (const page-marker)
2431               (const tree-menu)
2432               (const binary-menu)
2433               (const pick-menu)))
2434
2435 ;; Byte-compiler warning.
2436 (defvar gnus-visual)
2437 ;; Find out whether the gnus-visual TYPE is wanted.
2438 (defun gnus-visual-p (&optional type class)
2439   (and gnus-visual                      ; Has to be non-nil, at least.
2440        (if (not type)                   ; We don't care about type.
2441            gnus-visual
2442          (if (listp gnus-visual)        ; It's a list, so we check it.
2443              (or (memq type gnus-visual)
2444                  (memq class gnus-visual))
2445            t))))
2446
2447 (defcustom gnus-mouse-face
2448   (condition-case ()
2449       (if (gnus-visual-p 'mouse-face 'highlight)
2450           (if (boundp 'gnus-mouse-face)
2451               (or gnus-mouse-face 'highlight)
2452             'highlight)
2453         'default)
2454     (error 'highlight))
2455   "*Face used for group or summary buffer mouse highlighting.
2456 The line beneath the mouse pointer will be highlighted with this
2457 face."
2458   :group 'gnus-visual
2459   :type 'face)
2460
2461 (defcustom gnus-article-save-directory gnus-directory
2462   "*Name of the directory articles will be saved in (default \"~/News\")."
2463   :group 'gnus-article-saving
2464   :type 'directory)
2465
2466 (defvar gnus-plugged t
2467   "Whether Gnus is plugged or not.")
2468
2469 (defcustom gnus-agent-cache t
2470   "Controls use of the agent cache while plugged.
2471 When set, Gnus will prefer using the locally stored content rather
2472 than re-fetching it from the server.  You also need to enable
2473 `gnus-agent' for this to have any affect."
2474   :version "22.1"
2475   :group 'gnus-agent
2476   :type 'boolean)
2477
2478 (defcustom gnus-default-charset 'undecided
2479   "Default charset assumed to be used when viewing non-ASCII characters.
2480 This variable is overridden on a group-to-group basis by the
2481 `gnus-group-charset-alist' variable and is only used on groups not
2482 covered by that variable."
2483   :type 'symbol
2484   :group 'gnus-charset)
2485
2486 ;; Fixme: Doc reference to agent.
2487 (defcustom gnus-agent t
2488   "Whether we want to use the Gnus agent or not.
2489
2490 You may customize gnus-agent to disable its use.  However, some
2491 back ends have started to use the agent as a client-side cache.
2492 Disabling the agent may result in noticeable loss of performance."
2493   :version "22.1"
2494   :group 'gnus-agent
2495   :type 'boolean)
2496
2497 (defcustom gnus-other-frame-function 'gnus
2498   "Function called by the command `gnus-other-frame' when starting Gnus."
2499   :group 'gnus-start
2500   :type '(choice (function-item gnus)
2501                  (function-item gnus-no-server)
2502                  (function-item gnus-slave)
2503                  (function-item gnus-slave-no-server)))
2504
2505 (defcustom gnus-other-frame-resume-function 'gnus-group-get-new-news
2506   "Function called by the command `gnus-other-frame' when resuming Gnus."
2507   :version "24.4"
2508   :group 'gnus-start
2509   :type '(choice (function-item gnus)
2510                  (function-item gnus-group-get-new-news)
2511                  (function-item gnus-no-server)
2512                  (function-item gnus-slave)
2513                  (function-item gnus-slave-no-server)))
2514
2515 (defcustom gnus-other-frame-parameters nil
2516   "Frame parameters used by `gnus-other-frame' to create a Gnus frame.
2517 This should be an alist for Emacs, or a plist for XEmacs."
2518   :group 'gnus-start
2519   :type (if (featurep 'xemacs)
2520             '(repeat (list :inline t :format "%v"
2521                            (symbol :tag "Property")
2522                            (sexp :tag "Value")))
2523           '(repeat (cons :format "%v"
2524                          (symbol :tag "Parameter")
2525                          (sexp :tag "Value")))))
2526
2527 (defcustom gnus-user-agent '(emacs gnus type)
2528   "Which information should be exposed in the User-Agent header.
2529
2530 Can be a list of symbols or a string.  Valid symbols are `gnus'
2531 \(show Gnus version\) and `emacs' \(show Emacs version\).  In
2532 addition to the Emacs version, you can add `codename' \(show
2533 \(S\)XEmacs codename\) or either `config' \(show system
2534 configuration\) or `type' \(show system type\).  If you set it to
2535 a string, be sure to use a valid format, see RFC 2616."
2536
2537   :version "22.1"
2538   :group 'gnus-message
2539   :type '(choice (list (set :inline t
2540                             (const gnus  :tag "Gnus version")
2541                             (const emacs :tag "Emacs version")
2542                             (choice :tag "system"
2543                                     (const type   :tag "system type")
2544                                     (const config :tag "system configuration"))
2545                             (const codename :tag "Emacs codename")))
2546                  (string)))
2547
2548 ;; Convert old (< 2005-01-10) symbol type values:
2549 (when (symbolp gnus-user-agent)
2550   (setq gnus-user-agent
2551         (cond ((eq gnus-user-agent 'emacs-gnus-config)
2552                '(emacs gnus config))
2553               ((eq gnus-user-agent 'emacs-gnus-type)
2554                '(emacs gnus type))
2555               ((eq gnus-user-agent 'emacs-gnus)
2556                '(emacs gnus))
2557               ((eq gnus-user-agent 'gnus)
2558                '(gnus))
2559               (t gnus-user-agent)))
2560   (gnus-message 1 "Converted `gnus-user-agent' to `%s'." gnus-user-agent)
2561   (sit-for 1)
2562   (if (get 'gnus-user-agent 'saved-value)
2563       (customize-save-variable 'gnus-user-agent gnus-user-agent)
2564     (gnus-message 1 "Edit your init file to make this change permanent.")
2565     (sit-for 2)))
2566
2567 \f
2568 ;;; Internal variables
2569
2570 (defvar gnus-agent-gcc-header "X-Gnus-Agent-Gcc")
2571 (defvar gnus-agent-meta-information-header "X-Gnus-Agent-Meta-Information")
2572 (defvar gnus-agent-method-p-cache nil
2573   ; Reset each time gnus-agent-covered-methods is changed else
2574   ; gnus-agent-method-p may mis-report a methods status.
2575   )
2576 (defvar gnus-agent-target-move-group-header "X-Gnus-Agent-Move-To")
2577 (defvar gnus-draft-meta-information-header "X-Draft-From")
2578 (defvar gnus-group-get-parameter-function 'gnus-group-get-parameter)
2579 (defvar gnus-original-article-buffer " *Original Article*")
2580 (defvar gnus-newsgroup-name nil)
2581 (defvar gnus-ephemeral-servers nil)
2582 (defvar gnus-server-method-cache nil)
2583 (defvar gnus-extended-servers nil)
2584
2585 ;; The carpal mode has been removed, but define the variable for
2586 ;; backwards compatibility.
2587 (defvar gnus-carpal nil)
2588 (make-obsolete-variable 'gnus-carpal nil "Emacs 24.1")
2589
2590 (defvar gnus-agent-fetching nil
2591   "Whether Gnus agent is in fetching mode.")
2592
2593 (defvar gnus-agent-covered-methods nil
2594   "A list of servers, NOT methods, showing which servers are covered by the agent.")
2595
2596 (defvar gnus-command-method nil
2597   "Dynamically bound variable that says what the current back end is.")
2598
2599 (defvar gnus-current-select-method nil
2600   "The current method for selecting a newsgroup.")
2601
2602 (defvar gnus-tree-buffer "*Tree*"
2603   "Buffer where Gnus thread trees are displayed.")
2604
2605 ;; Variable holding the user answers to all method prompts.
2606 (defvar gnus-method-history nil)
2607
2608 ;; Variable holding the user answers to all mail method prompts.
2609 (defvar gnus-mail-method-history nil)
2610
2611 ;; Variable holding the user answers to all group prompts.
2612 (defvar gnus-group-history nil)
2613
2614 (defvar gnus-server-alist nil
2615   "List of available servers.")
2616
2617 (defcustom gnus-cache-directory
2618   (nnheader-concat gnus-directory "cache/")
2619   "*The directory where cached articles will be stored."
2620   :group 'gnus-cache
2621   :type 'directory)
2622
2623 (defvar gnus-predefined-server-alist
2624   `(("cache"
2625      nnspool "cache"
2626      (nnspool-spool-directory ,gnus-cache-directory)
2627      (nnspool-nov-directory ,gnus-cache-directory)
2628      (nnspool-active-file
2629       ,(nnheader-concat gnus-cache-directory "active"))))
2630   "List of predefined (convenience) servers.")
2631
2632 (defconst gnus-article-mark-lists
2633   '((marked . tick) (replied . reply)
2634     (expirable . expire) (killed . killed)
2635     (bookmarks . bookmark) (dormant . dormant)
2636     (scored . score) (saved . save)
2637     (cached . cache) (downloadable . download)
2638     (unsendable . unsend) (forwarded . forward)
2639     (seen . seen) (unexist . unexist)))
2640
2641 (defconst gnus-article-special-mark-lists
2642   '((seen range)
2643     (unexist range)
2644     (killed range)
2645     (bookmark tuple)
2646     (uid tuple)
2647     (active tuple)
2648     (score tuple)))
2649
2650 ;; Propagate flags to server, with the following exceptions:
2651 ;; `seen' is private to each gnus installation
2652 ;; `cache' is a internal gnus flag for each gnus installation
2653 ;; `download' is a agent flag private to each gnus installation
2654 ;; `unsend' are for nndraft groups only
2655 ;; `score' is not a proper mark
2656 ;; `bookmark': don't propagated it, or fix the bug in update-mark.
2657 (defconst gnus-article-unpropagated-mark-lists
2658   '(seen cache download unsend score bookmark unexist)
2659   "Marks that shouldn't be propagated to back ends.
2660 Typical marks are those that make no sense in a standalone back end,
2661 such as a mark that says whether an article is stored in the cache
2662 \(which doesn't make sense in a standalone back end).")
2663
2664 (defvar gnus-headers-retrieved-by nil)
2665 (defvar gnus-article-reply nil)
2666 (defvar gnus-override-method nil)
2667 (defvar gnus-opened-servers nil)
2668
2669 (defvar gnus-current-kill-article nil)
2670
2671 (defvar gnus-have-read-active-file nil)
2672
2673 (defconst gnus-maintainer
2674   "submit@debbugs.gnu.org (The Gnus Bugfixing Girls + Boys)"
2675   "The mail address of the Gnus maintainers.")
2676
2677 (defconst gnus-bug-package
2678   "gnus"
2679   "The package to use in the bug submission.")
2680
2681 (defvar gnus-info-nodes
2682   '((gnus-group-mode "(gnus)Group Buffer")
2683     (gnus-summary-mode "(gnus)Summary Buffer")
2684     (gnus-article-mode "(gnus)Article Buffer")
2685     (gnus-server-mode "(gnus)Server Buffer")
2686     (gnus-browse-mode "(gnus)Browse Foreign Server")
2687     (gnus-tree-mode "(gnus)Tree Display"))
2688   "Alist of major modes and related Info nodes.")
2689
2690 (defvar gnus-summary-buffer "*Summary*")
2691 (defvar gnus-article-buffer "*Article*")
2692 (defvar gnus-server-buffer "*Server*")
2693
2694 (defvar gnus-slave nil
2695   "Whether this Gnus is a slave or not.")
2696
2697 (defvar gnus-batch-mode nil
2698   "Whether this Gnus is running in batch mode or not.")
2699
2700 (defvar gnus-variable-list
2701   '(gnus-newsrc-options gnus-newsrc-options-n
2702                         gnus-newsrc-last-checked-date
2703                         gnus-newsrc-alist gnus-server-alist
2704                         gnus-killed-list gnus-zombie-list
2705                         gnus-topic-topology gnus-topic-alist
2706                         gnus-cloud-sequence
2707                         gnus-cloud-covered-servers
2708                         gnus-cloud-file-timestamps)
2709   "Gnus variables saved in the quick startup file.")
2710
2711 (defvar gnus-newsrc-alist nil
2712   "Assoc list of read articles.
2713 `gnus-newsrc-hashtb' should be kept so that both hold the same information.")
2714
2715 (defvar gnus-registry-alist nil
2716   "Assoc list of registry data.
2717 gnus-registry.el will populate this if it's loaded.")
2718
2719 (defvar gnus-newsrc-hashtb nil
2720   "Hashtable of `gnus-newsrc-alist'.")
2721
2722 (defvar gnus-killed-list nil
2723   "List of killed newsgroups.")
2724
2725 (defvar gnus-killed-hashtb nil
2726   "Hash table equivalent of `gnus-killed-list'.")
2727
2728 (defvar gnus-zombie-list nil
2729   "List of almost dead newsgroups.")
2730
2731 (defvar gnus-description-hashtb nil
2732   "Descriptions of newsgroups.")
2733
2734 (defvar gnus-list-of-killed-groups nil
2735   "List of newsgroups that have recently been killed by the user.")
2736
2737 (defvar gnus-active-hashtb nil
2738   "Hashtable of active articles.")
2739
2740 (defvar gnus-moderated-hashtb nil
2741   "Hashtable of moderated newsgroups.")
2742
2743 ;; Save window configuration.
2744 (defvar gnus-prev-winconf nil)
2745
2746 (defvar gnus-reffed-article-number nil)
2747
2748 (defvar gnus-dead-summary nil)
2749
2750 (defvar gnus-invalid-group-regexp "[: `'\"/]\\|^$"
2751   "Regexp matching invalid groups.")
2752
2753 (defvar gnus-other-frame-object nil
2754   "A frame object which will be created by `gnus-other-frame'.")
2755
2756 ;;; End of variables.
2757
2758 ;; Define some autoload functions Gnus might use.
2759 (eval-and-compile
2760
2761   ;; This little mapcar goes through the list below and marks the
2762   ;; symbols in question as autoloaded functions.
2763   (mapc
2764    (lambda (package)
2765      (let ((interactive (nth 1 (memq ':interactive package))))
2766        (mapcar
2767         (lambda (function)
2768           (let (keymap)
2769             (when (consp function)
2770               (setq keymap (car (memq 'keymap function)))
2771               (setq function (car function)))
2772             (unless (fboundp function)
2773               (autoload function (car package) nil interactive keymap))))
2774         (if (eq (nth 1 package) ':interactive)
2775             (nthcdr 3 package)
2776           (cdr package)))))
2777    '(("info" :interactive t Info-goto-node)
2778      ("pp" pp-to-string)
2779      ("qp" quoted-printable-decode-region quoted-printable-decode-string)
2780      ("ps-print" ps-print-preprint)
2781      ("message" :interactive t
2782       message-send-and-exit message-yank-original)
2783      ("babel" babel-as-string)
2784      ("nnmail" nnmail-split-fancy nnmail-article-group)
2785      ("nnvirtual" nnvirtual-catchup-group nnvirtual-convert-headers)
2786      ;; This is only used in message.el, which has an autoload.
2787      ("rmailout" rmail-output)
2788      ;; Next two used in gnus-util, which has autoloads, and contrib/sendmail.
2789      ("rmail" rmail-count-new-messages rmail-show-message
2790       ;; Next two only used in gnus-util.
2791       rmail-summary-exists rmail-select-summary)
2792      ;; Only used in gnus-util, which has an autoload.
2793      ("rmailsum" rmail-update-summary)
2794      ("gnus-xmas" gnus-xmas-splash)
2795      ("score-mode" :interactive t gnus-score-mode)
2796      ("gnus-mh" gnus-summary-save-article-folder
2797       gnus-Folder-save-name gnus-folder-save-name)
2798      ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2799      ("gnus-demon" gnus-demon-add-scanmail
2800       gnus-demon-add-rescan gnus-demon-add-scan-timestamps
2801       gnus-demon-add-disconnection gnus-demon-add-handler
2802       gnus-demon-remove-handler)
2803      ("gnus-demon" :interactive t
2804       gnus-demon-init gnus-demon-cancel)
2805      ("gnus-fun" gnus-convert-gray-x-face-to-xpm gnus-display-x-face-in-from
2806       gnus-convert-image-to-gray-x-face gnus-convert-face-to-png
2807       gnus-face-from-file)
2808      ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2809       gnus-tree-open gnus-tree-close)
2810      ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info
2811       gnus-server-server-name)
2812      ("gnus-srvr" gnus-browse-foreign-server)
2813      ("gnus-cite" :interactive t
2814       gnus-article-highlight-citation gnus-article-hide-citation-maybe
2815       gnus-article-hide-citation gnus-article-fill-cited-article
2816       gnus-article-hide-citation-in-followups
2817       gnus-article-fill-cited-long-lines)
2818      ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2819       gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2820       gnus-execute gnus-expunge gnus-batch-kill gnus-batch-score)
2821      ("gnus-registry" gnus-try-warping-via-registry
2822       gnus-registry-handle-action)
2823      ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2824       gnus-cache-possibly-remove-articles gnus-cache-request-article
2825       gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2826       gnus-cache-enter-remove-article gnus-cached-article-p
2827       gnus-cache-open gnus-cache-close gnus-cache-update-article
2828       gnus-cache-articles-in-group)
2829      ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2830       gnus-cache-remove-article gnus-summary-insert-cached-articles)
2831      ("gnus-score" :interactive t
2832       gnus-summary-increase-score gnus-summary-set-score
2833       gnus-summary-raise-thread gnus-summary-raise-same-subject
2834       gnus-summary-raise-score gnus-summary-raise-same-subject-and-select
2835       gnus-summary-lower-thread gnus-summary-lower-same-subject
2836       gnus-summary-lower-score gnus-summary-lower-same-subject-and-select
2837       gnus-summary-current-score gnus-score-delta-default
2838       gnus-score-flush-cache gnus-score-close
2839       gnus-possibly-score-headers gnus-score-followup-article
2840       gnus-score-followup-thread)
2841      ("gnus-score"
2842       (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2843       gnus-current-score-file-nondirectory gnus-score-adaptive
2844       gnus-score-find-trace gnus-score-file-name)
2845      ("gnus-cus" :interactive t gnus-group-customize gnus-score-customize)
2846      ("gnus-topic" :interactive t gnus-topic-mode)
2847      ("gnus-topic" gnus-topic-remove-group gnus-topic-set-parameters
2848       gnus-subscribe-topics)
2849      ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2850      ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2851      ("gnus-uu" :interactive t
2852       gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2853       gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2854       gnus-uu-mark-by-regexp gnus-uu-mark-all
2855       gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2856       gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2857       gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2858       gnus-uu-decode-binhex gnus-uu-decode-uu-view
2859       gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2860       gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2861       gnus-uu-decode-binhex-view gnus-uu-unmark-thread
2862       gnus-uu-mark-over gnus-uu-post-news gnus-uu-invert-processable)
2863      ("gnus-uu" gnus-uu-delete-work-dir gnus-uu-unmark-thread)
2864      ("gnus-msg" (gnus-summary-send-map keymap)
2865       gnus-article-mail gnus-copy-article-buffer gnus-extended-version)
2866      ("gnus-msg" :interactive t
2867       gnus-group-post-news gnus-group-mail gnus-group-news
2868       gnus-summary-post-news gnus-summary-news-other-window
2869       gnus-summary-followup gnus-summary-followup-with-original
2870       gnus-summary-cancel-article gnus-summary-supersede-article
2871       gnus-post-news gnus-summary-reply gnus-summary-reply-with-original
2872       gnus-summary-mail-forward gnus-summary-mail-other-window
2873       gnus-summary-resend-message gnus-summary-resend-bounced-mail
2874       gnus-summary-wide-reply gnus-summary-followup-to-mail
2875       gnus-summary-followup-to-mail-with-original gnus-bug
2876       gnus-summary-wide-reply-with-original
2877       gnus-summary-post-forward gnus-summary-wide-reply-with-original
2878       gnus-summary-post-forward)
2879      ("gnus-picon" :interactive t gnus-treat-from-picon)
2880      ("smiley" :interactive t smiley-region)
2881      ("gnus-win" gnus-configure-windows gnus-add-configuration)
2882      ("gnus-sum" gnus-summary-insert-line gnus-summary-read-group
2883       gnus-list-of-unread-articles gnus-list-of-read-articles
2884       gnus-offer-save-summaries gnus-make-thread-indent-array
2885       gnus-summary-exit gnus-update-read-articles gnus-summary-last-subject
2886       gnus-summary-skip-intangible gnus-summary-article-number
2887       gnus-data-header gnus-data-find)
2888      ("gnus-group" gnus-group-insert-group-line gnus-group-quit
2889       gnus-group-list-groups gnus-group-first-unread-group
2890       gnus-group-set-mode-line gnus-group-set-info gnus-group-save-newsrc
2891       gnus-group-setup-buffer gnus-group-get-new-news
2892       gnus-group-make-help-group gnus-group-update-group
2893       gnus-group-iterate gnus-group-group-name)
2894      ("gnus-bcklg" gnus-backlog-request-article gnus-backlog-enter-article
2895       gnus-backlog-remove-article)
2896      ("gnus-art" gnus-article-read-summary-keys gnus-article-save
2897       gnus-article-prepare gnus-article-set-window-start
2898       gnus-article-next-page gnus-article-prev-page
2899       gnus-request-article-this-buffer gnus-article-mode
2900       gnus-article-setup-buffer gnus-narrow-to-page
2901       gnus-article-delete-invisible-text gnus-treat-article)
2902      ("gnus-art" :interactive t
2903       gnus-article-hide-headers gnus-article-hide-boring-headers
2904       gnus-article-treat-overstrike
2905       gnus-article-remove-cr gnus-article-remove-trailing-blank-lines
2906       gnus-article-display-x-face gnus-article-de-quoted-unreadable
2907       gnus-article-de-base64-unreadable
2908       gnus-article-decode-HZ
2909       gnus-article-wash-html
2910       gnus-article-unsplit-urls
2911       gnus-article-hide-pem gnus-article-hide-signature
2912       gnus-article-strip-leading-blank-lines gnus-article-date-local
2913       gnus-article-date-original gnus-article-date-lapsed
2914       ;;gnus-article-show-all-headers
2915       gnus-article-edit-mode gnus-article-edit-article
2916       gnus-article-edit-done gnus-article-decode-encoded-words
2917       gnus-start-date-timer gnus-stop-date-timer
2918       gnus-mime-view-all-parts)
2919      ("gnus-int" gnus-request-type)
2920      ("gnus-start" gnus-newsrc-parse-options gnus-1 gnus-no-server-1
2921       gnus-dribble-enter gnus-read-init-file gnus-dribble-touch
2922       gnus-check-reasonable-setup)
2923      ("gnus-dup" gnus-dup-suppress-articles gnus-dup-unsuppress-article
2924       gnus-dup-enter-articles)
2925      ("gnus-range" gnus-copy-sequence)
2926      ("gnus-eform" gnus-edit-form)
2927      ("gnus-logic" gnus-score-advanced)
2928      ("gnus-undo" gnus-undo-mode gnus-undo-register)
2929      ("gnus-async" gnus-async-request-fetched-article gnus-async-prefetch-next
2930       gnus-async-prefetch-article gnus-async-prefetch-remove-group
2931       gnus-async-halt-prefetch)
2932      ("gnus-agent" gnus-open-agent gnus-agent-get-function
2933       gnus-agent-save-active gnus-agent-method-p
2934       gnus-agent-get-undownloaded-list gnus-agent-fetch-session
2935       gnus-summary-set-agent-mark gnus-agent-save-group-info
2936       gnus-agent-request-article gnus-agent-retrieve-headers
2937       gnus-agent-store-article gnus-agent-group-covered-p)
2938      ("gnus-agent" :interactive t
2939       gnus-unplugged gnus-agentize gnus-agent-batch)
2940      ("gnus-vm" :interactive t gnus-summary-save-in-vm
2941       gnus-summary-save-article-vm)
2942      ("compface" uncompface)
2943      ("gnus-draft" :interactive t gnus-draft-mode gnus-group-send-queue)
2944      ("gnus-mlspl" gnus-group-split gnus-group-split-fancy)
2945      ("gnus-mlspl" :interactive t gnus-group-split-setup
2946       gnus-group-split-update)
2947      ("gnus-delay" gnus-delay-initialize))))
2948
2949 ;;; gnus-sum.el thingies
2950
2951
2952 (defcustom gnus-summary-line-format "%U%R%z%I%(%[%4L: %-23,23f%]%) %s\n"
2953   "*The format specification of the lines in the summary buffer.
2954
2955 It works along the same lines as a normal formatting string,
2956 with some simple extensions.
2957
2958 %N          Article number, left padded with spaces (string)
2959 %S          Subject (string)
2960 %s          Subject if it is at the root of a thread, and \"\"
2961             otherwise (string)
2962 %n          Name of the poster (string)
2963 %a          Extracted name of the poster (string)
2964 %A          Extracted address of the poster (string)
2965 %F          Contents of the From: header (string)
2966 %f          Contents of the From: or To: headers (string)
2967 %x          Contents of the Xref: header (string)
2968 %D          Date of the article (string)
2969 %d          Date of the article (string) in DD-MMM format
2970 %o          Date of the article (string) in YYYYMMDD`T'HHMMSS
2971             format
2972 %M          Message-id of the article (string)
2973 %r          References of the article (string)
2974 %c          Number of characters in the article (integer)
2975 %k          Pretty-printed version of the above (string)
2976             For example, \"1.2k\" or \"0.4M\".
2977 %L          Number of lines in the article (integer)
2978 %I          Indentation based on thread level (a string of
2979             spaces)
2980 %B          A complex trn-style thread tree (string)
2981             The variables `gnus-sum-thread-*' can be used for
2982             customization.
2983 %T          A string with two possible values: 80 spaces if the
2984             article is on thread level two or larger and 0 spaces
2985             on level one
2986 %R          \"A\" if this article has been replied to, \" \"
2987             otherwise (character)
2988 %U          \"Read\" status of this article.
2989             See Info node `(gnus)Marking Articles'
2990 %[          Opening bracket (character, \"[\" or \"<\")
2991 %]          Closing bracket (character, \"]\" or \">\")
2992 %>          Spaces of length thread-level (string)
2993 %<          Spaces of length (- 20 thread-level) (string)
2994 %i          Article score (number)
2995 %z          Article zcore (character)
2996 %t          Number of articles under the current thread (number).
2997 %e          Whether the thread is empty or not (character).
2998 %V          Total thread score (number).
2999 %P          The line number (number).
3000 %O          Download mark (character).
3001 %*          If present, indicates desired cursor position
3002             (instead of after first colon).
3003 %u          User defined specifier. The next character in the
3004             format string should be a letter. Gnus will call the
3005             function gnus-user-format-function-X, where X is the
3006             letter following %u. The function will be passed the
3007             current header as argument. The function should
3008             return a string, which will be inserted into the
3009             summary just like information from any other summary
3010             specifier.
3011 &user-date; Age sensitive date format. Various date format is
3012             defined in `gnus-user-date-format-alist'.
3013
3014
3015 The %U (status), %R (replied) and %z (zcore) specs have to be handled
3016 with care.  For reasons of efficiency, Gnus will compute what column
3017 these characters will end up in, and \"hard-code\" that.  This means that
3018 it is invalid to have these specs after a variable-length spec.  Well,
3019 you might not be arrested, but your summary buffer will look strange,
3020 which is bad enough.
3021
3022 The smart choice is to have these specs as far to the left as
3023 possible.
3024
3025 This restriction may disappear in later versions of Gnus.
3026
3027 General format specifiers can also be used.
3028 See Info node `(gnus)Formatting Variables'."
3029   :link '(custom-manual "(gnus)Formatting Variables")
3030   :type 'string
3031   :group 'gnus-summary-format)
3032
3033 ;;;
3034 ;;; Skeleton keymaps
3035 ;;;
3036
3037 (defun gnus-suppress-keymap (keymap)
3038   (suppress-keymap keymap)
3039   (let ((keys `([delete] "\177" "\M-u"))) ;gnus-mouse-2
3040     (while keys
3041       (define-key keymap (pop keys) 'undefined))))
3042
3043 (defvar gnus-article-mode-map
3044   (let ((keymap (make-sparse-keymap)))
3045     (gnus-suppress-keymap keymap)
3046     keymap))
3047 (defvar gnus-summary-mode-map
3048   (let ((keymap (make-keymap)))
3049     (gnus-suppress-keymap keymap)
3050     keymap))
3051 (defvar gnus-group-mode-map
3052   (let ((keymap (make-keymap)))
3053     (gnus-suppress-keymap keymap)
3054     keymap))
3055
3056 \f
3057
3058 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3059 ;; If you want the cursor to go somewhere else, set these two
3060 ;; functions in some startup hook to whatever you want.
3061 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
3062 (defalias 'gnus-group-position-point 'gnus-goto-colon)
3063
3064 ;;; Various macros and substs.
3065
3066 (defun gnus-header-from (header)
3067   (mail-header-from header))
3068
3069 (defmacro gnus-gethash (string hashtable)
3070   "Get hash value of STRING in HASHTABLE."
3071   `(symbol-value (intern-soft ,string ,hashtable)))
3072
3073 (defmacro gnus-gethash-safe (string hashtable)
3074   "Get hash value of STRING in HASHTABLE.
3075 Return nil if not defined."
3076   `(let ((sym (intern-soft ,string ,hashtable)))
3077      (and (boundp sym) (symbol-value sym))))
3078
3079 (defmacro gnus-sethash (string value hashtable)
3080   "Set hash value.  Arguments are STRING, VALUE, and HASHTABLE."
3081   `(set (intern ,string ,hashtable) ,value))
3082 (put 'gnus-sethash 'edebug-form-spec '(form form form))
3083
3084 (defmacro gnus-group-unread (group)
3085   "Get the currently computed number of unread articles in GROUP."
3086   `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
3087
3088 (defmacro gnus-group-entry (group)
3089   "Get the newsrc entry for GROUP."
3090   `(gnus-gethash ,group gnus-newsrc-hashtb))
3091
3092 (defmacro gnus-active (group)
3093   "Get active info on GROUP."
3094   `(gnus-gethash ,group gnus-active-hashtb))
3095
3096 (defmacro gnus-set-active (group active)
3097   "Set GROUP's active info."
3098   `(gnus-sethash ,group ,active gnus-active-hashtb))
3099
3100 ;; Info access macros.
3101
3102 (defmacro gnus-info-group (info)
3103   `(nth 0 ,info))
3104 (defmacro gnus-info-rank (info)
3105   `(nth 1 ,info))
3106 (defmacro gnus-info-read (info)
3107   `(nth 2 ,info))
3108 (defmacro gnus-info-marks (info)
3109   `(nth 3 ,info))
3110 (defmacro gnus-info-method (info)
3111   `(nth 4 ,info))
3112 (defmacro gnus-info-params (info)
3113   `(nth 5 ,info))
3114
3115 (defmacro gnus-info-level (info)
3116   `(let ((rank (gnus-info-rank ,info)))
3117      (if (consp rank)
3118          (car rank)
3119        rank)))
3120 (defmacro gnus-info-score (info)
3121   `(let ((rank (gnus-info-rank ,info)))
3122      (or (and (consp rank) (cdr rank)) 0)))
3123
3124 (defmacro gnus-info-set-group (info group)
3125   `(setcar ,info ,group))
3126 (defmacro gnus-info-set-rank (info rank)
3127   `(setcar (nthcdr 1 ,info) ,rank))
3128 (defmacro gnus-info-set-read (info read)
3129   `(setcar (nthcdr 2 ,info) ,read))
3130 (defmacro gnus-info-set-marks (info marks &optional extend)
3131   (if extend
3132       `(gnus-info-set-entry ,info ,marks 3)
3133     `(setcar (nthcdr 3 ,info) ,marks)))
3134 (defmacro gnus-info-set-method (info method &optional extend)
3135   (if extend
3136       `(gnus-info-set-entry ,info ,method 4)
3137     `(setcar (nthcdr 4 ,info) ,method)))
3138 (defmacro gnus-info-set-params (info params &optional extend)
3139   (if extend
3140       `(gnus-info-set-entry ,info ,params 5)
3141     `(setcar (nthcdr 5 ,info) ,params)))
3142
3143 (defun gnus-info-set-entry (info entry number)
3144   ;; Extend the info until we have enough elements.
3145   (while (<= (length info) number)
3146     (nconc info (list nil)))
3147   ;; Set the entry.
3148   (setcar (nthcdr number info) entry))
3149
3150 (defmacro gnus-info-set-level (info level)
3151   `(let ((rank (cdr ,info)))
3152      (if (consp (car rank))
3153          (setcar (car rank) ,level)
3154        (setcar rank ,level))))
3155 (defmacro gnus-info-set-score (info score)
3156   `(let ((rank (cdr ,info)))
3157      (if (consp (car rank))
3158          (setcdr (car rank) ,score)
3159        (setcar rank (cons (car rank) ,score)))))
3160
3161 (defmacro gnus-get-info (group)
3162   `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
3163
3164 (defun gnus-set-info (group info)
3165   (setcar (nthcdr 2 (gnus-gethash group gnus-newsrc-hashtb))
3166           info))
3167
3168 ;;; Load the compatibility functions.
3169
3170 (require 'gnus-ems)
3171
3172 \f
3173 ;;;
3174 ;;; Shutdown
3175 ;;;
3176
3177 (defvar gnus-shutdown-alist nil)
3178
3179 (defun gnus-add-shutdown (function &rest symbols)
3180   "Run FUNCTION whenever one of SYMBOLS is shut down."
3181   (push (cons function symbols) gnus-shutdown-alist))
3182
3183 (defun gnus-shutdown (symbol)
3184   "Shut down everything that waits for SYMBOL."
3185   (dolist (entry gnus-shutdown-alist)
3186     (when (memq symbol (cdr entry))
3187       (funcall (car entry)))))
3188
3189 \f
3190 ;;;
3191 ;;; Gnus Utility Functions
3192 ;;;
3193
3194 (defun gnus-find-subscribed-addresses ()
3195   "Return a regexp matching the addresses of all subscribed mail groups.
3196 It consists of the `to-address' or `to-list' parameter of all groups
3197 with a `subscribed' parameter."
3198   (let (group address addresses)
3199     (dolist (entry (cdr gnus-newsrc-alist))
3200       (setq group (car entry))
3201       (when (gnus-parameter-subscribed group)
3202         (setq address (mail-strip-quoted-names
3203                        (or (gnus-group-fast-parameter group 'to-address)
3204                            (gnus-group-fast-parameter group 'to-list))))
3205         (when address
3206           (add-to-list 'addresses address))))
3207     (when addresses
3208       (list (mapconcat 'regexp-quote addresses "\\|")))))
3209
3210 (defmacro gnus-string-or (&rest strings)
3211   "Return the first element of STRINGS that is a non-blank string.
3212 STRINGS will be evaluated in normal `or' order."
3213   `(gnus-string-or-1 (list ,@strings)))
3214
3215 (defun gnus-string-or-1 (strings)
3216   (let (string)
3217     (while strings
3218       (setq string (pop strings))
3219       (if (string-match "^[ \t]*$" string)
3220           (setq string nil)
3221         (setq strings nil)))
3222     string))
3223
3224 (defun gnus-version (&optional arg)
3225   "Version number of this version of Gnus.
3226 If ARG, insert string at point."
3227   (interactive "P")
3228   (if arg
3229       (insert (message gnus-version))
3230     (message gnus-version)))
3231
3232 (defun gnus-continuum-version (&optional version)
3233   "Return VERSION as a floating point number."
3234   (unless version
3235     (setq version gnus-version))
3236   (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
3237             (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
3238     (let ((alpha (and (match-beginning 1) (match-string 1 version)))
3239           (number (match-string 2 version))
3240           major minor least)
3241       (unless (string-match
3242                "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
3243         (error "Invalid version string: %s" version))
3244       (setq major (string-to-number (match-string 1 number))
3245             minor (string-to-number (match-string 2 number))
3246             least (if (match-beginning 3)
3247                       (string-to-number (match-string 3 number))
3248                     0))
3249       (string-to-number
3250        (if (zerop major)
3251              (format "%1.2f00%02d%02d"
3252                      (if (member alpha '("(ding)" "d"))
3253                          4.99
3254                        (+ 5 (* 0.02
3255                                (abs
3256                                 (- (mm-char-int (aref (downcase alpha) 0))
3257                                    (mm-char-int ?t))))
3258                           -0.01))
3259                      minor least)
3260          (format "%d.%02d%02d" major minor least))))))
3261
3262 (defun gnus-info-find-node (&optional nodename)
3263   "Find Info documentation of Gnus."
3264   (interactive)
3265   ;; Enlarge info window if needed.
3266   (let (gnus-info-buffer)
3267     (Info-goto-node (or nodename (cadr (assq major-mode gnus-info-nodes))))
3268     (setq gnus-info-buffer (current-buffer))
3269     (gnus-configure-windows 'info)))
3270
3271 ;;;
3272 ;;; gnus-interactive
3273 ;;;
3274
3275 (defvar gnus-current-prefix-symbol nil
3276   "Current prefix symbol.")
3277
3278 (defvar gnus-current-prefix-symbols nil
3279   "List of current prefix symbols.")
3280
3281 (defun gnus-interactive (string &optional params)
3282   "Return a list that can be fed to `interactive'.
3283 See `interactive' for full documentation.
3284
3285 Adds the following specs:
3286
3287 y -- The current symbolic prefix.
3288 Y -- A list of the current symbolic prefix(es).
3289 A -- Article number.
3290 H -- Article header.
3291 g -- Group name."
3292   (let ((i 0)
3293         out c prompt)
3294     (while (< i (length string))
3295       (string-match ".\\([^\n]*\\)\n?" string i)
3296       (setq c (aref string i))
3297       (when (match-end 1)
3298         (setq prompt (match-string 1 string)))
3299       (setq i (match-end 0))
3300       ;; We basically emulate just about everything that
3301       ;; `interactive' does, but add the specs listed above.
3302       (push
3303        (cond
3304         ((= c ?a)
3305          (completing-read prompt obarray 'fboundp t))
3306         ((= c ?b)
3307          (read-buffer prompt (current-buffer) t))
3308         ((= c ?B)
3309          (read-buffer prompt (other-buffer (current-buffer))))
3310         ((= c ?c)
3311          (read-char))
3312         ((= c ?C)
3313          (completing-read prompt obarray 'commandp t))
3314         ((= c ?d)
3315          (point))
3316         ((= c ?D)
3317          (read-directory-name prompt nil default-directory 'lambda))
3318         ((= c ?f)
3319          (read-file-name prompt nil nil 'lambda))
3320         ((= c ?F)
3321          (read-file-name prompt))
3322         ((= c ?k)
3323          (read-key-sequence prompt))
3324         ((= c ?K)
3325          (error "Not implemented spec"))
3326         ((= c ?e)
3327          (error "Not implemented spec"))
3328         ((= c ?m)
3329          (mark))
3330         ((= c ?N)
3331          (error "Not implemented spec"))
3332         ((= c ?n)
3333          (string-to-number (read-from-minibuffer prompt)))
3334         ((= c ?p)
3335          (prefix-numeric-value current-prefix-arg))
3336         ((= c ?P)
3337          current-prefix-arg)
3338         ((= c ?r)
3339          'gnus-prefix-nil)
3340         ((= c ?s)
3341          (read-string prompt))
3342         ((= c ?S)
3343          (intern (read-string prompt)))
3344         ((= c ?v)
3345          (read-variable prompt))
3346         ((= c ?x)
3347          (read-minibuffer prompt))
3348         ((= c ?x)
3349          (eval-minibuffer prompt))
3350         ;; And here the new specs come.
3351         ((= c ?y)
3352          gnus-current-prefix-symbol)
3353         ((= c ?Y)
3354          gnus-current-prefix-symbols)
3355         ((= c ?g)
3356          (gnus-group-group-name))
3357         ((= c ?A)
3358          (gnus-summary-skip-intangible)
3359          (or (get-text-property (point) 'gnus-number)
3360              (gnus-summary-last-subject)))
3361         ((= c ?H)
3362          (gnus-data-header (gnus-data-find (gnus-summary-article-number))))
3363         (t
3364          (error "Non-implemented spec")))
3365        out)
3366       (cond
3367        ((= c ?r)
3368         (push (if (< (point) (mark)) (point) (mark)) out)
3369         (push (if (> (point) (mark)) (point) (mark)) out))))
3370     (setq out (delq 'gnus-prefix-nil out))
3371     (nreverse out)))
3372
3373 (defun gnus-symbolic-argument (&optional arg)
3374   "Read a symbolic argument and a command, and then execute command."
3375   (interactive "P")
3376   (let* ((in-command (this-command-keys))
3377          (command in-command)
3378          gnus-current-prefix-symbols
3379          gnus-current-prefix-symbol
3380          syms)
3381     (while (equal in-command command)
3382       (message "%s-" (key-description (this-command-keys)))
3383       (push (intern (char-to-string (read-char))) syms)
3384       (setq command (read-key-sequence nil t)))
3385     (setq gnus-current-prefix-symbols (nreverse syms)
3386           gnus-current-prefix-symbol (car gnus-current-prefix-symbols))
3387     (call-interactively (key-binding command t))))
3388
3389 ;;; More various functions.
3390
3391 (defsubst gnus-check-backend-function (func group)
3392   "Check whether GROUP supports function FUNC.
3393 GROUP can either be a string (a group name) or a select method."
3394   (ignore-errors
3395     (let ((method (if (stringp group)
3396                       (car (gnus-find-method-for-group group))
3397                     group)))
3398       (unless (featurep method)
3399         (require method))
3400       (fboundp (intern (format "%s-%s" method func))))))
3401
3402 (defun gnus-group-read-only-p (&optional group)
3403   "Check whether GROUP supports editing or not.
3404 If GROUP is nil, `gnus-newsgroup-name' will be checked instead.  Note
3405 that that variable is buffer-local to the summary buffers."
3406   (let ((group (or group gnus-newsgroup-name)))
3407     (not (gnus-check-backend-function 'request-replace-article group))))
3408
3409 (defun gnus-virtual-group-p (group)
3410   "Say whether GROUP is virtual or not."
3411   (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3412                         gnus-valid-select-methods)))
3413
3414 (defun gnus-news-group-p (group &optional article)
3415   "Return non-nil if GROUP (and ARTICLE) come from a news server."
3416   (cond ((gnus-member-of-valid 'post group) ;Ordinary news group
3417          t)                                 ;is news of course.
3418         ((not (gnus-member-of-valid 'post-mail group)) ;Non-combined.
3419          nil)                           ;must be mail then.
3420         ((vectorp article)              ;Has header info.
3421          (eq (gnus-request-type group (mail-header-id article)) 'news))
3422         ((null article)                        ;Hasn't header info
3423          (eq (gnus-request-type group) 'news)) ;(unknown ==> mail)
3424         ((< article 0)                         ;Virtual message
3425          nil)                           ;we don't know, guess mail.
3426         (t                              ;Has positive number
3427          (eq (gnus-request-type group article) 'news)))) ;use it.
3428
3429 ;; Check whether to use long file names.
3430 (defun gnus-use-long-file-name (symbol)
3431   ;; The variable has to be set...
3432   (and gnus-use-long-file-name
3433        ;; If it isn't a list, then we return t.
3434        (or (not (listp gnus-use-long-file-name))
3435            ;; If it is a list, and the list contains `symbol', we
3436            ;; return nil.
3437            (not (memq symbol gnus-use-long-file-name)))))
3438
3439 ;; Generate a unique new group name.
3440 (defun gnus-generate-new-group-name (leaf)
3441   (let ((name leaf)
3442         (num 0))
3443     (while (gnus-group-entry name)
3444       (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3445     name))
3446
3447 (defun gnus-ephemeral-group-p (group)
3448   "Say whether GROUP is ephemeral or not."
3449   (gnus-group-get-parameter group 'quit-config t))
3450
3451 (defun gnus-group-quit-config (group)
3452   "Return the quit-config of GROUP."
3453   (gnus-group-get-parameter group 'quit-config t))
3454
3455 (defun gnus-kill-ephemeral-group (group)
3456   "Remove ephemeral GROUP from relevant structures."
3457   (gnus-sethash group nil gnus-newsrc-hashtb))
3458
3459 (defun gnus-simplify-mode-line ()
3460   "Make mode lines a bit simpler."
3461   (setq mode-line-modified (cdr gnus-mode-line-modified))
3462   (when (listp mode-line-format)
3463     (make-local-variable 'mode-line-format)
3464     (setq mode-line-format (copy-sequence mode-line-format))
3465     (when (equal (nth 3 mode-line-format) "   ")
3466       (setcar (nthcdr 3 mode-line-format) " "))))
3467
3468 ;;; Servers and groups.
3469
3470 (defsubst gnus-server-add-address (method)
3471   (let ((method-name (symbol-name (car method))))
3472     (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
3473              (not (assq (intern (concat method-name "-address")) method))
3474              (memq 'physical-address (assq (car method)
3475                                            gnus-valid-select-methods)))
3476         (append method (list (list (intern (concat method-name "-address"))
3477                                    (nth 1 method))))
3478       method)))
3479
3480 (defsubst gnus-method-to-server (method &optional nocache no-enter-cache)
3481   (catch 'server-name
3482     (setq method (or method gnus-select-method))
3483
3484     ;; Perhaps it is already in the cache.
3485     (unless nocache
3486       (mapc (lambda (name-method)
3487               (if (equal (cdr name-method) method)
3488                   (throw 'server-name (car name-method))))
3489             gnus-server-method-cache))
3490
3491     (mapc
3492      (lambda (server-alist)
3493        (mapc (lambda (name-method)
3494                (when (gnus-methods-equal-p (cdr name-method) method)
3495                  (unless (member name-method gnus-server-method-cache)
3496                    (push name-method gnus-server-method-cache))
3497                  (throw 'server-name (car name-method))))
3498              server-alist))
3499      (list gnus-server-alist
3500            gnus-predefined-server-alist))
3501
3502     (let* ((name (if (member (cadr method) '(nil ""))
3503                      (format "%s" (car method))
3504                    (format "%s:%s" (car method) (cadr method))))
3505            (name-method (cons name method)))
3506       (when (and (not (member name-method gnus-server-method-cache))
3507                  (not no-enter-cache)
3508                  (not (assoc (car name-method) gnus-server-method-cache)))
3509         (push name-method gnus-server-method-cache))
3510       name)))
3511
3512 (defsubst gnus-server-to-method (server)
3513   "Map virtual server names to select methods."
3514   (or (and server (listp server) server)
3515       (cdr (assoc server gnus-server-method-cache))
3516       (let ((result
3517              (or
3518               ;; Perhaps this is the native server?
3519               (and (equal server "native") gnus-select-method)
3520               ;; It should be in the server alist.
3521               (cdr (assoc server gnus-server-alist))
3522               ;; It could be in the predefined server alist.
3523               (cdr (assoc server gnus-predefined-server-alist))
3524               ;; If not, we look through all the opened server
3525               ;; to see whether we can find it there.
3526               (let ((opened gnus-opened-servers))
3527                 (while (and opened
3528                             (not (equal server (format "%s:%s" (caaar opened)
3529                                                        (cadaar opened)))))
3530                   (pop opened))
3531                 (caar opened))
3532               ;; It could be a named method, search all servers
3533               (let ((servers gnus-secondary-select-methods))
3534                 (while (and servers
3535                             (not (equal server (format "%s:%s" (caar servers)
3536                                                        (cadar servers)))))
3537                   (pop servers))
3538                 (car servers))
3539               ;; This could be some sort of foreign server that I
3540               ;; simply haven't opened (yet).  Do a brute-force scan
3541               ;; of the entire gnus-newsrc-alist for the server name
3542               ;; of every method.  As a side-effect, loads the
3543               ;; gnus-server-method-cache so this only happens once,
3544               ;; if at all.
3545               (let ((alist (cdr gnus-newsrc-alist))
3546                     method match)
3547                 (while alist
3548                   (setq method (gnus-info-method (pop alist)))
3549                   (when (and (not (stringp method))
3550                              (equal server
3551                                     (gnus-method-to-server method nil t)))
3552                     (setq match method
3553                           alist nil)))
3554                 match))))
3555         (when (and result
3556                    (not (assoc server gnus-server-method-cache)))
3557           (push (cons server result) gnus-server-method-cache))
3558         result)))
3559
3560 (defsubst gnus-server-get-method (group method)
3561   ;; Input either a server name, and extended server name, or a
3562   ;; select method, and return a select method.
3563   (cond ((stringp method)
3564          (gnus-server-to-method method))
3565         ((equal method gnus-select-method)
3566          gnus-select-method)
3567         ((and (stringp (car method))
3568               group)
3569          (gnus-server-extend-method group method))
3570         ((and method
3571               (not group)
3572               (equal (cadr method) ""))
3573          method)
3574         (t
3575          (gnus-server-add-address method))))
3576
3577 (defmacro gnus-method-equal (ss1 ss2)
3578   "Say whether two servers are equal."
3579   `(let ((s1 ,ss1)
3580          (s2 ,ss2))
3581      (or (equal s1 s2)
3582          (and (= (length s1) (length s2))
3583               (progn
3584                 (while (and s1 (member (car s1) s2))
3585                   (setq s1 (cdr s1)))
3586                 (null s1))))))
3587
3588 (defun gnus-methods-equal-p (m1 m2)
3589   (let ((m1 (or m1 gnus-select-method))
3590         (m2 (or m2 gnus-select-method)))
3591     (or (equal m1 m2)
3592         (and (eq (car m1) (car m2))
3593              (or (not (memq 'address (assoc (symbol-name (car m1))
3594                                             gnus-valid-select-methods)))
3595                  (equal (nth 1 m1) (nth 1 m2)))))))
3596
3597 (defsubst gnus-sloppily-equal-method-parameters (m1 m2)
3598   ;; Check parameters for sloppy equality.
3599   (let ((p1 (copy-sequence (cddr m1)))
3600         (p2 (copy-sequence (cddr m2)))
3601         e1 e2)
3602     (block nil
3603       (while (setq e1 (pop p1))
3604         (unless (setq e2 (assq (car e1) p2))
3605           ;; The parameter doesn't exist in p2.
3606           (return nil))
3607         (setq p2 (delq e2 p2))
3608         (unless (equal e1 e2)
3609           (if (not (and (stringp (cadr e1))
3610                         (stringp (cadr e2))))
3611               (return nil)
3612             ;; Special-case string parameter comparison so that we
3613             ;; can uniquify them.
3614             (let ((s1 (cadr e1))
3615                   (s2 (cadr e2)))
3616               (when (string-match "/$" s1)
3617                 (setq s1 (directory-file-name s1)))
3618               (when (string-match "/$" s2)
3619                 (setq s2 (directory-file-name s2)))
3620               (unless (equal s1 s2)
3621                 (return nil))))))
3622       ;; If p2 now is empty, they were equal.
3623       (null p2))))
3624
3625 (defun gnus-method-ephemeral-p (method)
3626   (let ((equal nil))
3627     (dolist (ephemeral gnus-ephemeral-servers)
3628       (when (gnus-sloppily-equal-method-parameters method ephemeral)
3629         (setq equal t)))
3630     equal))
3631
3632 (defun gnus-methods-sloppily-equal (m1 m2)
3633   ;; Same method.
3634   (or
3635    (eq m1 m2)
3636    ;; Type and name are equal.
3637    (and
3638     (eq (car m1) (car m2))
3639     (equal (cadr m1) (cadr m2))
3640     (gnus-sloppily-equal-method-parameters m1 m2))))
3641
3642 (defun gnus-server-equal (m1 m2)
3643   "Say whether two methods are equal."
3644   (let ((m1 (cond ((null m1) gnus-select-method)
3645                   ((stringp m1) (gnus-server-to-method m1))
3646                   (t m1)))
3647         (m2 (cond ((null m2) gnus-select-method)
3648                   ((stringp m2) (gnus-server-to-method m2))
3649                   (t m2))))
3650     (gnus-method-equal m1 m2)))
3651
3652 (defun gnus-servers-using-backend (backend)
3653   "Return a list of known servers using BACKEND."
3654   (let ((opened gnus-opened-servers)
3655         out)
3656     (while opened
3657       (when (eq backend (caaar opened))
3658         (push (caar opened) out))
3659       (pop opened))
3660     out))
3661
3662 (defun gnus-archive-server-wanted-p ()
3663   "Say whether the user wants to use the archive server."
3664   (cond
3665    ((or (not gnus-message-archive-method)
3666         (not gnus-message-archive-group))
3667     nil)
3668    ((and gnus-message-archive-method gnus-message-archive-group)
3669     t)
3670    (t
3671     (let ((active (cadr (assq 'nnfolder-active-file
3672                               gnus-message-archive-method))))
3673       (and active
3674            (file-exists-p active))))))
3675
3676 (defsubst gnus-method-to-server-name (method)
3677   (concat
3678    (format "%s" (car method))
3679    (when (and
3680           (or (assoc (format "%s" (car method))
3681                      (gnus-methods-using 'address))
3682               (gnus-server-equal method gnus-message-archive-method))
3683           (nth 1 method)
3684           (not (string= (nth 1 method) "")))
3685      (concat "+" (nth 1 method)))))
3686
3687 (defsubst gnus-method-to-full-server-name (method)
3688   (format "%s+%s" (car method) (nth 1 method)))
3689
3690 (defun gnus-group-prefixed-name (group method &optional full)
3691   "Return the whole name from GROUP and METHOD.
3692 Call with full set to get the fully qualified group name (even if the
3693 server is native)."
3694   (when (stringp method)
3695     (setq method (gnus-server-to-method method)))
3696   (if (or (not method)
3697           (and (not full) (gnus-server-equal method "native"))
3698           ;;;!!! This might not be right.  We'll see...
3699           ;(string-match ":" group)
3700           )
3701       group
3702     (concat (gnus-method-to-server-name method) ":" group)))
3703
3704 (defun gnus-group-full-name (group method)
3705   "Return the full name from GROUP and METHOD, even if the method is native."
3706   (gnus-group-prefixed-name group method t))
3707
3708 (defun gnus-group-guess-full-name-from-command-method (group)
3709   "Guess the full name from GROUP, even if the method is native."
3710   (if (gnus-group-prefixed-p group)
3711       group
3712     (gnus-group-full-name group gnus-command-method)))
3713
3714 (defun gnus-group-real-prefix (group)
3715   "Return the prefix of the current group name."
3716   (if (stringp group)
3717       (if (string-match "^[^:]+:" group)
3718           (substring group 0 (match-end 0))
3719         "")
3720     nil))
3721
3722 (defun gnus-group-short-name (group)
3723   "Return the short group name."
3724   (let ((prefix (gnus-group-real-prefix group)))
3725     (if (< 0 (length prefix))
3726         (substring group (length prefix) nil)
3727       group)))
3728
3729 (defun gnus-group-prefixed-p (group)
3730   "Return the prefix of the current group name."
3731   (< 0 (length (gnus-group-real-prefix group))))
3732
3733 (declare-function gnus-group-decoded-name "gnus-group" (string))
3734
3735 (defun gnus-summary-buffer-name (group)
3736   "Return the summary buffer name of GROUP."
3737   (concat "*Summary " (gnus-group-decoded-name group) "*"))
3738
3739 (defun gnus-group-method (group)
3740   "Return the server or method used for selecting GROUP.
3741 You should probably use `gnus-find-method-for-group' instead."
3742   (let ((prefix (gnus-group-real-prefix group)))
3743     (if (equal prefix "")
3744         gnus-select-method
3745       (let ((servers gnus-opened-servers)
3746             (server "")
3747             backend possible found)
3748         (if (string-match "^[^\\+]+\\+" prefix)
3749             (setq backend (intern (substring prefix 0 (1- (match-end 0))))
3750                   server (substring prefix (match-end 0) (1- (length prefix))))
3751           (setq backend (intern (substring prefix 0 (1- (length prefix))))))
3752         (while servers
3753           (when (eq (caaar servers) backend)
3754             (setq possible (caar servers))
3755             (when (equal (cadaar servers) server)
3756               (setq found (caar servers))))
3757           (pop servers))
3758         (or (car (rassoc found gnus-server-alist))
3759             found
3760             (car (rassoc possible gnus-server-alist))
3761             possible
3762             (list backend server))))))
3763
3764 (defsubst gnus-native-method-p (method)
3765   "Return whether METHOD is the native select method."
3766   (gnus-method-equal method gnus-select-method))
3767
3768 (defsubst gnus-secondary-method-p (method)
3769   "Return whether METHOD is a secondary select method."
3770   (let ((methods gnus-secondary-select-methods)
3771         (gmethod (inline (gnus-server-get-method nil method))))
3772     (while (and methods
3773                 (not (gnus-method-equal
3774                       (inline (gnus-server-get-method nil (car methods)))
3775                       gmethod)))
3776       (setq methods (cdr methods)))
3777     methods))
3778
3779 (defun gnus-method-simplify (method)
3780   "Return the shortest uniquely identifying string or method for METHOD."
3781   (cond ((stringp method)
3782          method)
3783         ((gnus-native-method-p method)
3784          nil)
3785         ((gnus-secondary-method-p method)
3786          (format "%s:%s" (nth 0 method) (nth 1 method)))
3787         (t
3788          method)))
3789
3790 (defun gnus-groups-from-server (server)
3791   "Return a list of all groups that are fetched from SERVER."
3792   (let ((alist (cdr gnus-newsrc-alist))
3793         info groups)
3794     (while (setq info (pop alist))
3795       (when (gnus-server-equal (gnus-info-method info) server)
3796         (push (gnus-info-group info) groups)))
3797     (sort groups 'string<)))
3798
3799 (defun gnus-group-foreign-p (group)
3800   "Say whether a group is foreign or not."
3801   (and (not (gnus-group-native-p group))
3802        (not (gnus-group-secondary-p group))))
3803
3804 (defun gnus-group-native-p (group)
3805   "Say whether the group is native or not."
3806   (not (string-match ":" group)))
3807
3808 (defun gnus-group-secondary-p (group)
3809   "Say whether the group is secondary or not."
3810   (gnus-secondary-method-p (gnus-find-method-for-group group)))
3811
3812 (defun gnus-parameters-get-parameter (group)
3813   "Return the group parameters for GROUP from `gnus-parameters'."
3814   (let ((case-fold-search (if (eq gnus-parameters-case-fold-search 'default)
3815                               case-fold-search
3816                             gnus-parameters-case-fold-search))
3817         params-list)
3818     (dolist (elem gnus-parameters)
3819       (when (string-match (car elem) group)
3820         (setq params-list
3821               (nconc (gnus-expand-group-parameters
3822                       (car elem) (cdr elem) group)
3823                      params-list))))
3824     params-list))
3825
3826 (defun gnus-expand-group-parameter (match value group)
3827   "Use MATCH to expand VALUE in GROUP."
3828   (let ((start (string-match match group)))
3829     (if start
3830         (let ((matched-string (substring group start (match-end 0))))
3831           ;; Build match groups
3832           (string-match match matched-string)
3833           (replace-match value nil nil matched-string))
3834       group)))
3835
3836 (defun gnus-expand-group-parameters (match parameters group)
3837   "Go through PARAMETERS and expand them according to the match data."
3838   (let (new)
3839     (dolist (elem parameters)
3840       (cond
3841        ((and (stringp (cdr elem))
3842              (string-match "\\\\[0-9&]" (cdr elem)))
3843         (push (cons (car elem)
3844                     (gnus-expand-group-parameter match (cdr elem) group))
3845               new))
3846        ;; For `sieve' group parameters, perform substitutions for every
3847        ;; string within the match rule.  This allows for parameters such
3848        ;; as:
3849        ;;  ("list\\.\\(.*\\)"
3850        ;;   (sieve header :is "list-id" "<\\1.domain.org>"))
3851        ((eq 'sieve (car elem))
3852         (push (mapcar (lambda (sieve-elem)
3853                         (if (and (stringp sieve-elem)
3854                                  (string-match "\\\\[0-9&]" sieve-elem))
3855                             (gnus-expand-group-parameter match sieve-elem
3856                                                          group)
3857                           sieve-elem))
3858                       (cdr elem))
3859               new))
3860        (t
3861         (push elem new))))
3862     new))
3863
3864 (defun gnus-group-fast-parameter (group symbol &optional allow-list)
3865   "For GROUP, return the value of SYMBOL.
3866
3867 You should call this in the `gnus-group-buffer' buffer.
3868 The function `gnus-group-find-parameter' will do that for you."
3869   ;; The speed trick:  No cons'ing and quit early.
3870   (let* ((params (funcall gnus-group-get-parameter-function group))
3871          ;; Start easy, check the "real" group parameters.
3872          (simple-results
3873           (gnus-group-parameter-value params symbol allow-list t)))
3874     (if simple-results
3875         ;; Found results; return them.
3876         (car simple-results)
3877       ;; We didn't find it there, try `gnus-parameters'.
3878       (let ((result nil)
3879             (head nil)
3880             (tail gnus-parameters))
3881         ;; A good old-fashioned non-cl loop.
3882         (while tail
3883           (setq head (car tail)
3884                 tail (cdr tail))
3885           ;; The car is regexp matching for matching the group name.
3886           (when (string-match (car head) group)
3887             ;; The cdr is the parameters.
3888             (let ((this-result
3889                    (gnus-group-parameter-value (cdr head) symbol allow-list t)))
3890               (when this-result
3891                 (setq result (car this-result))
3892                 ;; Expand if necessary.
3893                 (cond
3894                  ((and (stringp result) (string-match "\\\\[0-9&]" result))
3895                   (setq result (gnus-expand-group-parameter
3896                                 (car head) result group)))
3897                  ;; For `sieve' group parameters, perform substitutions
3898                  ;; for every string within the match rule (see above).
3899                  ((eq symbol 'sieve)
3900                   (setq result
3901                         (mapcar (lambda (elem)
3902                                   (if (stringp elem)
3903                                       (gnus-expand-group-parameter (car head)
3904                                                                    elem group)
3905                                     elem))
3906                                 result))))))))
3907         ;; Done.
3908         result))))
3909
3910 (defun gnus-group-find-parameter (group &optional symbol allow-list)
3911   "Return the group parameters for GROUP.
3912 If SYMBOL, return the value of that symbol in the group parameters.
3913
3914 If you call this function inside a loop, consider using the faster
3915 `gnus-group-fast-parameter' instead."
3916   (with-current-buffer (if (buffer-live-p (get-buffer gnus-group-buffer))
3917                            gnus-group-buffer
3918                          (current-buffer))
3919     (if symbol
3920         (gnus-group-fast-parameter group symbol allow-list)
3921       (nconc
3922        (copy-sequence
3923         (funcall gnus-group-get-parameter-function group))
3924        (gnus-parameters-get-parameter group)))))
3925
3926 (defun gnus-group-get-parameter (group &optional symbol allow-list)
3927   "Return the group parameters for GROUP.
3928 If SYMBOL, return the value of that symbol in the group parameters.
3929 If ALLOW-LIST, also allow list as a result.
3930 Most functions should use `gnus-group-find-parameter', which
3931 also examines the topic parameters."
3932   (let ((params (gnus-info-params (gnus-get-info group))))
3933     (if symbol
3934         (gnus-group-parameter-value params symbol allow-list)
3935       params)))
3936
3937 (defun gnus-group-parameter-value (params symbol &optional
3938                                           allow-list present-p)
3939   "Return the value of SYMBOL in group PARAMS.
3940 If ALLOW-LIST, also allow list as a result."
3941   ;; We only wish to return group parameters (dotted lists) and
3942   ;; not local variables, which may have the same names.
3943   ;; But first we handle single elements...
3944   (or (car (memq symbol params))
3945       ;; Handle alist.
3946       (let (elem)
3947         (catch 'found
3948           (while (setq elem (pop params))
3949             (when (and (consp elem)
3950                        (eq (car elem) symbol)
3951                        (or allow-list
3952                            (atom (cdr elem))))
3953               (throw 'found (if present-p (list (cdr elem))
3954                               (cdr elem)))))))))
3955
3956 (defun gnus-group-add-parameter (group param)
3957   "Add parameter PARAM to GROUP."
3958   (let ((info (gnus-get-info group)))
3959     (when info
3960       (gnus-group-remove-parameter group (if (consp param) (car param) param))
3961       ;; Cons the new param to the old one and update.
3962       (gnus-group-set-info (cons param (gnus-info-params info))
3963                            group 'params))))
3964
3965 (defun gnus-group-set-parameter (group name value)
3966   "Set parameter NAME to VALUE in GROUP.
3967 GROUP can also be an INFO structure."
3968   (let ((info (if (listp group)
3969                   group
3970                 (gnus-get-info group))))
3971     (when info
3972       (gnus-group-remove-parameter group name)
3973       (let ((old-params (gnus-info-params info))
3974             (new-params (list (cons name value))))
3975         (while old-params
3976           (when (or (not (listp (car old-params)))
3977                     (not (eq (caar old-params) name)))
3978             (setq new-params (append new-params (list (car old-params)))))
3979           (setq old-params (cdr old-params)))
3980         (if (listp group)
3981             (gnus-info-set-params info new-params t)
3982           (gnus-group-set-info new-params (gnus-info-group info) 'params))))))
3983
3984 (defun gnus-group-remove-parameter (group name)
3985   "Remove parameter NAME from GROUP.
3986 GROUP can also be an INFO structure."
3987   (let ((info (if (listp group)
3988                   group
3989                 (gnus-get-info group))))
3990     (when info
3991       (let ((params (gnus-info-params info)))
3992         (when params
3993           (setq params (delq name params))
3994           (while (assq name params)
3995             (gnus-alist-pull name params))
3996           (gnus-info-set-params info params))))))
3997
3998 (defun gnus-group-add-score (group &optional score)
3999   "Add SCORE to the GROUP score.
4000 If SCORE is nil, add 1 to the score of GROUP."
4001   (let ((info (gnus-get-info group)))
4002     (when info
4003       (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4004
4005 (defun gnus-short-group-name (group &optional levels)
4006   "Collapse GROUP name LEVELS.
4007 Select methods are stripped and any remote host name is stripped down to
4008 just the host name."
4009   (let* ((name "")
4010          (foreign "")
4011          (depth 0)
4012          (skip 1)
4013          (levels (or levels
4014                      gnus-group-uncollapsed-levels
4015                      (progn
4016                        (while (string-match "\\." group skip)
4017                          (setq skip (match-end 0)
4018                                depth (+ depth 1)))
4019                        depth))))
4020     ;; Separate foreign select method from group name and collapse.
4021    ;; If method contains a server, collapse to non-domain server name,
4022     ;; otherwise collapse to select method.
4023     (let* ((colon (string-match ":" group))
4024            (server (and colon (substring group 0 colon)))
4025            (plus (and server (string-match "+" server))))
4026       (when server
4027         (if plus
4028             (setq foreign (substring server (+ 1 plus)
4029                                      (string-match "\\." server))
4030                   group (substring group (+ 1 colon)))
4031           (setq foreign server
4032                 group (substring group (+ 1 colon))))
4033         (setq foreign (concat foreign ":")))
4034       ;; Collapse group name leaving LEVELS uncollapsed elements
4035       (let* ((slist (split-string group "/"))
4036              (slen (length slist))
4037              (dlist (split-string group "\\."))
4038              (dlen (length dlist))
4039              glist
4040              glen
4041              gsep
4042              res)
4043         (if (> slen dlen)
4044             (setq glist slist
4045                   glen slen
4046                   gsep "/")
4047           (setq glist dlist
4048                 glen dlen
4049                 gsep "."))
4050         (setq levels (- glen levels))
4051         (dolist (g glist)
4052           (push (if (>= (decf levels) 0)
4053                     (if (zerop (length g))
4054                         ""
4055                       (substring g 0 1))
4056                   g)
4057                 res))
4058         (concat foreign (mapconcat 'identity (nreverse res) gsep))))))
4059
4060 (defun gnus-narrow-to-body ()
4061   "Narrow to the body of an article."
4062   (narrow-to-region
4063    (progn
4064      (goto-char (point-min))
4065      (or (search-forward "\n\n" nil t)
4066          (point-max)))
4067    (point-max)))
4068
4069 \f
4070 ;;;
4071 ;;; Kill file handling.
4072 ;;;
4073
4074 (defun gnus-apply-kill-file ()
4075   "Apply a kill file to the current newsgroup.
4076 Returns the number of articles marked as read."
4077   (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
4078           (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
4079       (gnus-apply-kill-file-internal)
4080     0))
4081
4082 (defun gnus-kill-save-kill-buffer ()
4083   (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
4084     (when (get-file-buffer file)
4085       (with-current-buffer (get-file-buffer file)
4086         (when (buffer-modified-p)
4087           (save-buffer))
4088         (kill-buffer (current-buffer))))))
4089
4090 (defcustom gnus-kill-file-name "KILL"
4091   "Suffix of the kill files."
4092   :group 'gnus-score-kill
4093   :group 'gnus-score-files
4094   :type 'string)
4095
4096 (defun gnus-newsgroup-kill-file (newsgroup)
4097   "Return the name of a kill file name for NEWSGROUP.
4098 If NEWSGROUP is nil, return the global kill file name instead."
4099   (cond
4100    ;; The global KILL file is placed at top of the directory.
4101    ((or (null newsgroup)
4102         (string-equal newsgroup ""))
4103     (expand-file-name gnus-kill-file-name
4104                       gnus-kill-files-directory))
4105    ;; Append ".KILL" to newsgroup name.
4106    ((gnus-use-long-file-name 'not-kill)
4107     (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
4108                               "." gnus-kill-file-name)
4109                       gnus-kill-files-directory))
4110    ;; Place "KILL" under the hierarchical directory.
4111    (t
4112     (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
4113                               "/" gnus-kill-file-name)
4114                       gnus-kill-files-directory))))
4115
4116 ;;; Server things.
4117
4118 (defun gnus-member-of-valid (symbol group)
4119   "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
4120   (memq symbol (assoc
4121                 (symbol-name (car (gnus-find-method-for-group group)))
4122                 gnus-valid-select-methods)))
4123
4124 (defun gnus-method-option-p (method option)
4125   "Return non-nil if select METHOD has OPTION as a parameter."
4126   (when (stringp method)
4127     (setq method (gnus-server-to-method method)))
4128   (memq option (assoc (format "%s" (car method))
4129                       gnus-valid-select-methods)))
4130
4131 (defun gnus-similar-server-opened (method)
4132   "Return non-nil if we have a similar server opened.
4133 This is defined as a server with the same name, but different
4134 parameters."
4135   (let ((opened gnus-opened-servers)
4136         open)
4137     (while (and method opened)
4138       (setq open (car (pop opened)))
4139       ;; Type and name are the same...
4140       (when (and (equal (car method) (car open))
4141                  (equal (cadr method) (cadr open))
4142                  ;; ... but the rest of the parameters differ.
4143                  (not (gnus-methods-sloppily-equal method open)))
4144         (setq method nil)))
4145     (not method)))
4146
4147 (defun gnus-server-extend-method (group method)
4148   ;; This function "extends" a virtual server.  If the server is
4149   ;; "hello", and the select method is ("hello" (my-var "something"))
4150   ;; in the group "alt.alt", this will result in a new virtual server
4151   ;; called "hello+alt.alt".
4152   (if (or (not (inline (gnus-similar-server-opened method)))
4153           (not (cddr method)))
4154       method
4155     (let ((address-slot
4156            (intern (format "%s-address" (car method)))))
4157       (setq method
4158             (if (assq address-slot (cddr method))
4159                 `(,(car method) ,(concat (cadr method) "+" group)
4160                   ,@(cddr method))
4161               `(,(car method) ,(concat (cadr method) "+" group)
4162                 (,address-slot ,(cadr method))
4163                 ,@(cddr method))))
4164       (push method gnus-extended-servers)
4165       method)))
4166
4167 (defun gnus-server-status (method)
4168   "Return the status of METHOD."
4169   (nth 1 (assoc method gnus-opened-servers)))
4170
4171 (defun gnus-group-name-to-method (group)
4172   "Guess a select method based on GROUP."
4173   (if (string-match ":" group)
4174       (let ((server (substring group 0 (match-beginning 0))))
4175         (if (string-match "\\+" server)
4176             (list (intern (substring server 0 (match-beginning 0)))
4177                   (substring server (match-end 0)))
4178           (list (intern server) "")))
4179     gnus-select-method))
4180
4181 (defun gnus-server-string (server)
4182   "Return a readable string that describes SERVER."
4183   (let* ((server (gnus-server-to-method server))
4184          (address (nth 1 server)))
4185     (if (and address
4186              (not (zerop (length address))))
4187         (format "%s using %s" address (car server))
4188       (format "%s" (car server)))))
4189
4190 (defun gnus-same-method-different-name (method)
4191   (let ((slot (intern (concat (symbol-name (car method)) "-address"))))
4192     (unless (assq slot (cddr method))
4193       (setq method
4194             (append method (list (list slot (nth 1 method)))))))
4195   (let ((methods gnus-extended-servers)
4196         open found)
4197     (while (and (not found)
4198                 (setq open (pop methods)))
4199       (when (and (eq (car method) (car open))
4200                  (gnus-sloppily-equal-method-parameters method open))
4201         (setq found open)))
4202     found))
4203
4204 (defun gnus-find-method-for-group (group &optional info)
4205   "Find the select method that GROUP uses."
4206   (or gnus-override-method
4207       (and (not group)
4208            gnus-select-method)
4209       (and (not (gnus-group-entry group))
4210            ;; Killed or otherwise unknown group.
4211            (or
4212             ;; If we know a virtual server by that name, return its method.
4213             (gnus-server-to-method (gnus-group-server group))
4214             ;; Guess a new method as last resort.
4215             (gnus-group-name-to-method group)))
4216       (let ((info (or info (gnus-get-info group)))
4217             method)
4218         (if (or (not info)
4219                 (not (setq method (gnus-info-method info)))
4220                 (equal method "native"))
4221             gnus-select-method
4222           (setq method
4223                 (cond ((stringp method)
4224                        (inline (gnus-server-to-method method)))
4225                       ((stringp (cadr method))
4226                        (or
4227                         (inline
4228                          (gnus-same-method-different-name method))
4229                         (inline (gnus-server-extend-method group method))))
4230                       (t
4231                        method)))
4232           (cond ((equal (cadr method) "")
4233                  method)
4234                 ((null (cadr method))
4235                  (list (car method) ""))
4236                 (t
4237                  (gnus-server-add-address method)))))))
4238
4239 (defun gnus-methods-using (feature)
4240   "Find all methods that have FEATURE."
4241   (let ((valids gnus-valid-select-methods)
4242         outs)
4243     (while valids
4244       (when (memq feature (car valids))
4245         (push (car valids) outs))
4246       (setq valids (cdr valids)))
4247     outs))
4248
4249 (autoload 'message-y-or-n-p "message" nil nil 'macro)
4250
4251 (defun gnus-read-group (prompt &optional default)
4252   "Prompt the user for a group name.
4253 Disallow invalid group names."
4254   (let ((prefix "")
4255         group)
4256     (while (not group)
4257       (when (string-match
4258              gnus-invalid-group-regexp
4259              (setq group (read-string (concat prefix prompt)
4260                                       (cons (or default "") 0)
4261                                       'gnus-group-history)))
4262         (let ((match (match-string 0 group)))
4263           ;; Might be okay (e.g. for nnimap), so ask the user:
4264           (unless (and (not (string-match "^$\\|:" match))
4265                        (message-y-or-n-p
4266                         "Proceed and create group anyway? " t
4267 "The group name \"" group "\" contains a forbidden character: \"" match "\".
4268
4269 Usually, it's dangerous to create a group with this name, because it's not
4270 supported by all back ends and servers.  On IMAP servers it should work,
4271 though.  If you are really sure, you can proceed anyway and create the group.
4272
4273 You may customize the variable `gnus-invalid-group-regexp', which currently is
4274 set to \"" gnus-invalid-group-regexp
4275 "\", if you want to get rid of this query permanently."))
4276             (setq prefix (format "Invalid group name: \"%s\".  " group)
4277                   group nil)))))
4278     group))
4279
4280 (defun gnus-read-method (prompt)
4281   "Prompt the user for a method.
4282 Allow completion over sensible values."
4283   (let* ((open-servers
4284           (mapcar (lambda (i) (cons (format "%s:%s" (caar i) (cadar i)) i))
4285                   gnus-opened-servers))
4286          (valid-methods
4287           (let (methods)
4288             (dolist (method gnus-valid-select-methods)
4289               (if (or (memq 'prompt-address method)
4290                       (not (assoc (format "%s:" (car method)) open-servers)))
4291                   (push method methods)))
4292             methods))
4293          (servers
4294           (append valid-methods
4295                   open-servers
4296                   gnus-predefined-server-alist
4297                   gnus-server-alist))
4298          (method
4299           (gnus-completing-read
4300            prompt (mapcar 'car servers)
4301            t nil 'gnus-method-history)))
4302     (cond
4303      ((equal method "")
4304       (setq method gnus-select-method))
4305      ((assoc method gnus-valid-select-methods)
4306       (let ((address (if (memq 'prompt-address
4307                                (assoc method gnus-valid-select-methods))
4308                          (read-string "Address: ")
4309                        "")))
4310         (or (cadr (assoc (format "%s:%s" method address) open-servers))
4311             (list (intern method) address))))
4312      ((assoc method servers)
4313       method)
4314      (t
4315       (list (intern method) "")))))
4316
4317 ;;; Agent functions
4318
4319 (defun gnus-agent-method-p (method-or-server)
4320   "Say whether METHOD is covered by the agent."
4321   (or (eq (car gnus-agent-method-p-cache) method-or-server)
4322       (let* ((method (if (stringp method-or-server)
4323                          (gnus-server-to-method method-or-server)
4324                        method-or-server))
4325              (server (gnus-method-to-server method t)))
4326         (setq gnus-agent-method-p-cache
4327               (cons method-or-server
4328                     (member server gnus-agent-covered-methods)))))
4329   (cdr gnus-agent-method-p-cache))
4330
4331 (defun gnus-online (method)
4332   (not
4333    (if gnus-plugged
4334        (eq (cadr (assoc method gnus-opened-servers)) 'offline)
4335      (gnus-agent-method-p method))))
4336
4337 ;;; User-level commands.
4338
4339 ;;;###autoload
4340 (defun gnus-slave-no-server (&optional arg)
4341   "Read network news as a slave, without connecting to the local server."
4342   (interactive "P")
4343   (gnus-no-server arg t))
4344
4345 ;;;###autoload
4346 (defun gnus-no-server (&optional arg slave)
4347   "Read network news.
4348 If ARG is a positive number, Gnus will use that as the startup
4349 level. If ARG is nil, Gnus will be started at level 2.  If ARG is
4350 non-nil and not a positive number, Gnus will prompt the user for the
4351 name of an NNTP server to use.
4352 As opposed to `gnus', this command will not connect to the local
4353 server."
4354   (interactive "P")
4355   (gnus-no-server-1 arg slave))
4356
4357 ;;;###autoload
4358 (defun gnus-slave (&optional arg)
4359   "Read news as a slave."
4360   (interactive "P")
4361   (gnus arg nil 'slave))
4362
4363 (defun gnus-delete-gnus-frame ()
4364   "Delete gnus frame unless it is the only one.
4365 Used for `gnus-exit-gnus-hook' in `gnus-other-frame'."
4366   (when (and (frame-live-p gnus-other-frame-object)
4367              (cdr (frame-list)))
4368     (delete-frame gnus-other-frame-object))
4369   (setq gnus-other-frame-object nil))
4370
4371 ;;;###autoload
4372 (defun gnus-other-frame (&optional arg display)
4373   "Pop up a frame to read news.
4374 This will call one of the Gnus commands which is specified by the user
4375 option `gnus-other-frame-function' (default `gnus') with the argument
4376 ARG if Gnus is not running, otherwise pop up a Gnus frame and run the
4377 command specified by `gnus-other-frame-resume-function'.
4378 The optional second argument DISPLAY should be a standard display string
4379 such as \"unix:0\" to specify where to pop up a frame.  If DISPLAY is
4380 omitted or the function `make-frame-on-display' is not available, the
4381 current display is used."
4382   (interactive "P")
4383   (if (fboundp 'make-frame-on-display)
4384       (unless display
4385         (setq display (gnus-frame-or-window-display-name (selected-frame))))
4386     (setq display nil))
4387   (let ((alive (gnus-alive-p)))
4388     (unless (and alive
4389                  (catch 'found
4390                    (walk-windows
4391                     (lambda (window)
4392                       (when (and (or (not display)
4393                                      (equal display
4394                                             (gnus-frame-or-window-display-name
4395                                              window)))
4396                                  (with-current-buffer (window-buffer window)
4397                                    (string-match "\\`gnus-"
4398                                                  (symbol-name major-mode))))
4399                         (gnus-select-frame-set-input-focus
4400                          (setq gnus-other-frame-object (window-frame window)))
4401                         (select-window window)
4402                         (throw 'found t)))
4403                     'ignore t)))
4404       (gnus-select-frame-set-input-focus
4405        (setq gnus-other-frame-object
4406              (if display
4407                  (make-frame-on-display display gnus-other-frame-parameters)
4408                (make-frame gnus-other-frame-parameters))))
4409       (if alive
4410           (progn (switch-to-buffer gnus-group-buffer)
4411                  (funcall gnus-other-frame-resume-function arg))
4412         (funcall gnus-other-frame-function arg)
4413         (add-hook 'gnus-exit-gnus-hook 'gnus-delete-gnus-frame)
4414   ;; One might argue that `gnus-delete-gnus-frame' should not be called
4415   ;; from `gnus-suspend-gnus-hook', but, on the other hand, one might
4416   ;; argue that it should.  No matter what you think, for the sake of
4417   ;; those who want it to be called from it, please keep (defun
4418   ;; gnus-delete-gnus-frame) even if you remove the next `add-hook'.
4419   (add-hook 'gnus-suspend-gnus-hook 'gnus-delete-gnus-frame)))))
4420
4421 ;;;###autoload
4422 (defun gnus (&optional arg dont-connect slave)
4423   "Read network news.
4424 If ARG is non-nil and a positive number, Gnus will use that as the
4425 startup level.  If ARG is non-nil and not a positive number, Gnus will
4426 prompt the user for the name of an NNTP server to use."
4427   (interactive "P")
4428   ;; When using the development version of Gnus, load the gnus-load
4429   ;; file.
4430   (unless (string-match "^Gnus" gnus-version)
4431     (load "gnus-load" nil t))
4432   (unless (byte-code-function-p (symbol-function 'gnus))
4433     (message "You should byte-compile Gnus")
4434     (sit-for 2))
4435   (let ((gnus-action-message-log (list nil)))
4436     (gnus-1 arg dont-connect slave)
4437     (gnus-final-warning)))
4438
4439 (declare-function debbugs-gnu "ext:debbugs-gnu"
4440                   (severities &optional packages archivedp suppress tags))
4441
4442 (defun gnus-list-debbugs ()
4443   "List all open Gnus bug reports."
4444   (interactive)
4445   (require 'debbugs-gnu)
4446   (debbugs-gnu nil "gnus"))
4447
4448 ;; Allow redefinition of Gnus functions.
4449
4450 (gnus-ems-redefine)
4451
4452 (provide 'gnus)
4453
4454 ;;; gnus.el ends here