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