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