Merge from gnus--rel--5.10
[gnus] / lisp / gnus-group.el
1 ;;; gnus-group.el --- group mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;;   2005, 2006, 2007 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31   (require 'cl)
32   (defvar tool-bar-mode))
33
34 (require 'gnus)
35 (require 'gnus-start)
36 (require 'nnmail)
37 (require 'gnus-spec)
38 (require 'gnus-int)
39 (require 'gnus-range)
40 (require 'gnus-win)
41 (require 'gnus-undo)
42 (require 'gmm-utils)
43 (require 'time-date)
44 (require 'gnus-ems)
45
46 (eval-when-compile
47   (require 'mm-url)
48   (let ((features (cons 'gnus-group features)))
49     (require 'gnus-sum))
50   (unless (boundp 'gnus-cache-active-hashtb)
51     (defvar gnus-cache-active-hashtb nil)))
52
53 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
54 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
55
56 (defcustom gnus-group-archive-directory
57   "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
58   "*The address of the (ding) archives."
59   :group 'gnus-group-foreign
60   :type 'directory)
61
62 (defcustom gnus-group-recent-archive-directory
63   "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
64   "*The address of the most recent (ding) articles."
65   :group 'gnus-group-foreign
66   :type 'directory)
67
68 (defcustom gnus-no-groups-message "No Gnus is good news"
69   "*Message displayed by Gnus when no groups are available."
70   :group 'gnus-start
71   :type 'string)
72
73 (defcustom gnus-keep-same-level nil
74   "*Non-nil means that the next newsgroup after the current will be on the same level.
75 When you type, for instance, `n' after reading the last article in the
76 current newsgroup, you will go to the next newsgroup.  If this variable
77 is nil, the next newsgroup will be the next from the group
78 buffer.
79 If this variable is non-nil, Gnus will either put you in the
80 next newsgroup with the same level, or, if no such newsgroup is
81 available, the next newsgroup with the lowest possible level higher
82 than the current level.
83 If this variable is `best', Gnus will make the next newsgroup the one
84 with the best level."
85   :group 'gnus-group-levels
86   :type '(choice (const nil)
87                  (const best)
88                  (sexp :tag "other" t)))
89
90 (defcustom gnus-group-goto-unread t
91   "*If non-nil, movement commands will go to the next unread and subscribed group."
92   :link '(custom-manual "(gnus)Group Maneuvering")
93   :group 'gnus-group-various
94   :type 'boolean)
95
96 (defcustom gnus-goto-next-group-when-activating t
97   "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
98   :link '(custom-manual "(gnus)Scanning New Messages")
99   :group 'gnus-group-various
100   :type 'boolean)
101
102 (defcustom gnus-permanently-visible-groups nil
103   "*Regexp to match groups that should always be listed in the group buffer.
104 This means that they will still be listed even when there are no
105 unread articles in the groups.
106
107 If nil, no groups are permanently visible."
108   :group 'gnus-group-listing
109   :type '(choice regexp (const nil)))
110
111 (defcustom gnus-list-groups-with-ticked-articles t
112   "*If non-nil, list groups that have only ticked articles.
113 If nil, only list groups that have unread articles."
114   :group 'gnus-group-listing
115   :type 'boolean)
116
117 (defcustom gnus-group-default-list-level gnus-level-subscribed
118   "*Default listing level.
119 Ignored if `gnus-group-use-permanent-levels' is non-nil."
120   :group 'gnus-group-listing
121   :type 'integer)
122
123 (defcustom gnus-group-list-inactive-groups t
124   "*If non-nil, inactive groups will be listed."
125   :group 'gnus-group-listing
126   :group 'gnus-group-levels
127   :type 'boolean)
128
129 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
130   "*Function used for sorting the group buffer.
131 This function will be called with group info entries as the arguments
132 for the groups to be sorted.  Pre-made functions include
133 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
134 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
135 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
136 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
137
138 This variable can also be a list of sorting functions.  In that case,
139 the most significant sort function should be the last function in the
140 list."
141   :group 'gnus-group-listing
142   :link '(custom-manual "(gnus)Sorting Groups")
143   :type '(repeat :value-to-internal (lambda (widget value)
144                                       (if (listp value) value (list value)))
145                  :match (lambda (widget value)
146                           (or (symbolp value)
147                               (widget-editable-list-match widget value)))
148                  (choice (function-item gnus-group-sort-by-alphabet)
149                          (function-item gnus-group-sort-by-real-name)
150                          (function-item gnus-group-sort-by-unread)
151                          (function-item gnus-group-sort-by-level)
152                          (function-item gnus-group-sort-by-score)
153                          (function-item gnus-group-sort-by-method)
154                          (function-item gnus-group-sort-by-server)
155                          (function-item gnus-group-sort-by-rank)
156                          (function :tag "other" nil))))
157
158 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
159   "*Format of group lines.
160 It works along the same lines as a normal formatting string,
161 with some simple extensions.
162
163 %M    Only marked articles (character, \"*\" or \" \")
164 %S    Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
165 %L    Level of subscribedness (integer)
166 %N    Number of unread articles (integer)
167 %I    Number of dormant articles (integer)
168 %i    Number of ticked and dormant (integer)
169 %T    Number of ticked articles (integer)
170 %R    Number of read articles (integer)
171 %U    Number of unseen articles (integer)
172 %t    Estimated total number of articles (integer)
173 %y    Number of unread, unticked articles (integer)
174 %G    Group name (string)
175 %g    Qualified group name (string)
176 %c    Short (collapsed) group name.  See `gnus-group-uncollapsed-levels'.
177 %C    Group comment (string)
178 %D    Group description (string)
179 %s    Select method (string)
180 %o    Moderated group (char, \"m\")
181 %p    Process mark (char)
182 %B    Whether a summary buffer for the group is open (char, \"*\")
183 %O    Moderated group (string, \"(m)\" or \"\")
184 %P    Topic indentation (string)
185 %m    Whether there is new(ish) mail in the group (char, \"%\")
186 %n    Select from where (string)
187 %z    A string that look like `<%s:%n>' if a foreign select method is used
188 %d    The date the group was last entered.
189 %E    Icon as defined by `gnus-group-icon-list'.
190 %F    The disk space used by the articles fetched by both the cache and agent.
191 %u    User defined specifier.  The next character in the format string should
192       be a letter.  Gnus will call the function gnus-user-format-function-X,
193       where X is the letter following %u.  The function will be passed a
194       single dummy parameter as argument.  The function should return a
195       string, which will be inserted into the buffer just like information
196       from any other group specifier.
197
198 Note that this format specification is not always respected.  For
199 reasons of efficiency, when listing killed groups, this specification
200 is ignored altogether.  If the spec is changed considerably, your
201 output may end up looking strange when listing both alive and killed
202 groups.
203
204 If you use %o or %O, reading the active file will be slower and quite
205 a bit of extra memory will be used.  %D and %F will also worsen
206 performance.  Also note that if you change the format specification to
207 include any of these specs, you must probably re-start Gnus to see
208 them go into effect.
209
210 General format specifiers can also be used.
211 See Info node `(gnus)Formatting Variables'."
212   :link '(custom-manual "(gnus)Formatting Variables")
213   :group 'gnus-group-visual
214   :type 'string)
215
216 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
217   "*The format specification for the group mode line.
218 It works along the same lines as a normal formatting string,
219 with some simple extensions:
220
221 %S   The native news server.
222 %M   The native select method.
223 %:   \":\" if %S isn't \"\"."
224   :group 'gnus-group-visual
225   :type 'string)
226
227 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
228 (when (featurep 'xemacs)
229   (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
230   (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
231
232 (defcustom gnus-group-menu-hook nil
233   "Hook run after the creation of the group mode menu."
234   :group 'gnus-group-various
235   :type 'hook)
236
237 (defcustom gnus-group-catchup-group-hook nil
238   "Hook run when catching up a group from the group buffer."
239   :group 'gnus-group-various
240   :link '(custom-manual "(gnus)Group Data")
241   :type 'hook)
242
243 (defcustom gnus-group-update-group-hook nil
244   "Hook called when updating group lines."
245   :group 'gnus-group-visual
246   :type 'hook)
247
248 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
249   "*A function that is called to generate the group buffer.
250 The function is called with three arguments: The first is a number;
251 all group with a level less or equal to that number should be listed,
252 if the second is non-nil, empty groups should also be displayed.  If
253 the third is non-nil, it is a number.  No groups with a level lower
254 than this number should be displayed.
255
256 The only current function implemented is `gnus-group-prepare-flat'."
257   :group 'gnus-group-listing
258   :type 'function)
259
260 (defcustom gnus-group-prepare-hook nil
261   "Hook called after the group buffer has been generated.
262 If you want to modify the group buffer, you can use this hook."
263   :group 'gnus-group-listing
264   :type 'hook)
265
266 (defcustom gnus-suspend-gnus-hook nil
267   "Hook called when suspending (not exiting) Gnus."
268   :group 'gnus-exit
269   :type 'hook)
270
271 (defcustom gnus-exit-gnus-hook nil
272   "Hook called when exiting Gnus."
273   :group 'gnus-exit
274   :type 'hook)
275
276 (defcustom gnus-after-exiting-gnus-hook nil
277   "Hook called after exiting Gnus."
278   :group 'gnus-exit
279   :type 'hook)
280
281 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
282   "Hook called when a group line is changed.
283 The hook will not be called if `gnus-visual' is nil.
284
285 The default function `gnus-group-highlight-line' will
286 highlight the line according to the `gnus-group-highlight'
287 variable."
288   :group 'gnus-group-visual
289   :type 'hook)
290
291 (defcustom gnus-useful-groups
292   '(("(ding) mailing list mirrored at gmane.org"
293      "gmane.emacs.gnus.general"
294      (nntp "Gmane"
295            (nntp-address "news.gmane.org")))
296     ("Gnus bug archive"
297      "gnus.gnus-bug"
298      (nntp "news.gnus.org"
299            (nntp-address "news.gnus.org")))
300     ("Local Gnus help group"
301      "gnus-help"
302      (nndoc "gnus-help"
303             (nndoc-article-type mbox)
304             (eval `(nndoc-address
305                     ,(let ((file (nnheader-find-etc-directory
306                                   "gnus-tut.txt" t)))
307                        (unless file
308                          (error "Couldn't find doc group"))
309                        file))))))
310   "*Alist of useful group-server pairs."
311   :group 'gnus-group-listing
312   :type '(repeat (list (string :tag "Description")
313                        (string :tag "Name")
314                        (sexp :tag "Method"))))
315
316 (defcustom gnus-group-highlight
317   '(;; Mail.
318     ((and mailp (= unread 0) (eq level 1)) .
319      gnus-group-mail-1-empty)
320     ((and mailp (eq level 1)) .
321      gnus-group-mail-1)
322     ((and mailp (= unread 0) (eq level 2)) .
323      gnus-group-mail-2-empty)
324     ((and mailp (eq level 2)) .
325      gnus-group-mail-2)
326     ((and mailp (= unread 0) (eq level 3)) .
327      gnus-group-mail-3-empty)
328     ((and mailp (eq level 3)) .
329      gnus-group-mail-3)
330     ((and mailp (= unread 0)) .
331      gnus-group-mail-low-empty)
332     ((and mailp) .
333      gnus-group-mail-low)
334     ;; News.
335     ((and (= unread 0) (eq level 1)) .
336      gnus-group-news-1-empty)
337     ((and (eq level 1)) .
338      gnus-group-news-1)
339     ((and (= unread 0) (eq level 2)) .
340      gnus-group-news-2-empty)
341     ((and (eq level 2)) .
342      gnus-group-news-2)
343     ((and (= unread 0) (eq level 3)) .
344      gnus-group-news-3-empty)
345     ((and (eq level 3)) .
346      gnus-group-news-3)
347     ((and (= unread 0) (eq level 4)) .
348      gnus-group-news-4-empty)
349     ((and (eq level 4)) .
350      gnus-group-news-4)
351     ((and (= unread 0) (eq level 5)) .
352      gnus-group-news-5-empty)
353     ((and (eq level 5)) .
354      gnus-group-news-5)
355     ((and (= unread 0) (eq level 6)) .
356      gnus-group-news-6-empty)
357     ((and (eq level 6)) .
358      gnus-group-news-6)
359     ((and (= unread 0)) .
360      gnus-group-news-low-empty)
361     (t .
362      gnus-group-news-low))
363   "*Controls the highlighting of group buffer lines.
364
365 Below is a list of `Form'/`Face' pairs.  When deciding how a a
366 particular group line should be displayed, each form is
367 evaluated.  The content of the face field after the first true form is
368 used.  You can change how those group lines are displayed by
369 editing the face field.
370
371 It is also possible to change and add form fields, but currently that
372 requires an understanding of Lisp expressions.  Hopefully this will
373 change in a future release.  For now, you can use the following
374 variables in the Lisp expression:
375
376 group: The name of the group.
377 unread: The number of unread articles in the group.
378 method: The select method used.
379 mailp: Whether it's a mail group or not.
380 level: The level of the group.
381 score: The score of the group.
382 ticked: The number of ticked articles."
383   :group 'gnus-group-visual
384   :type '(repeat (cons (sexp :tag "Form") face)))
385
386 (defcustom gnus-new-mail-mark ?%
387   "Mark used for groups with new mail."
388   :group 'gnus-group-visual
389   :type 'character)
390
391 (defgroup gnus-group-icons nil
392   "Add Icons to your group buffer."
393   :group 'gnus-group-visual)
394
395 (defcustom gnus-group-icon-list
396   nil
397   "*Controls the insertion of icons into group buffer lines.
398
399 Below is a list of `Form'/`File' pairs.  When deciding how a
400 particular group line should be displayed, each form is evaluated.
401 The icon from the file field after the first true form is used.  You
402 can change how those group lines are displayed by editing the file
403 field.  The File will either be found in the
404 `gnus-group-glyph-directory' or by designating absolute name of the
405 file.
406
407 It is also possible to change and add form fields, but currently that
408 requires an understanding of Lisp expressions.  Hopefully this will
409 change in a future release.  For now, you can use the following
410 variables in the Lisp expression:
411
412 group: The name of the group.
413 unread: The number of unread articles in the group.
414 method: The select method used.
415 mailp: Whether it's a mail group or not.
416 newsp: Whether it's a news group or not
417 level: The level of the group.
418 score: The score of the group.
419 ticked: The number of ticked articles."
420   :group 'gnus-group-icons
421   :type '(repeat (cons (sexp :tag "Form") file)))
422
423 (defcustom gnus-group-name-charset-method-alist nil
424   "Alist of method and the charset for group names.
425
426 For example:
427     (((nntp \"news.com.cn\") . cn-gb-2312))"
428   :version "21.1"
429   :group 'gnus-charset
430   :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
431
432 (defcustom gnus-group-name-charset-group-alist
433   (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
434           (mm-coding-system-p 'utf-8))
435       '((".*" . utf-8))
436     nil)
437   "Alist of group regexp and the charset for group names.
438
439 For example:
440     ((\"\\.com\\.cn:\" . cn-gb-2312))"
441   :group 'gnus-charset
442   :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
443
444 (defcustom gnus-group-jump-to-group-prompt nil
445   "Default prompt for `gnus-group-jump-to-group'.
446
447 If non-nil, the value should be a string or an alist.  If it is a string,
448 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
449 nnml:\" in the minibuffer prompt.
450
451 If it is an alist, it must consist of \(NUMBER .  PROMPT\) pairs, for example:
452 \((1 .  \"\") (2 .  \"nnfolder+archive:\")).  The element with number 0 is
453 used when no prefix argument is given to `gnus-group-jump-to-group'."
454   :version "22.1"
455   :group 'gnus-group-various
456   :type '(choice (string :tag "Prompt string")
457                  (const :tag "Empty" nil)
458                  (repeat (cons (integer :tag "Argument")
459                                (string :tag "Prompt string")))))
460
461 (defvar gnus-group-listing-limit 1000
462   "*A limit of the number of groups when listing.
463 If the number of groups is larger than the limit, list them in a
464 simple manner.")
465
466 ;;; Internal variables
467
468 (defvar gnus-group-is-exiting-p nil)
469 (defvar gnus-group-is-exiting-without-update-p nil)
470 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
471   "Function for sorting the group buffer.")
472
473 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
474   "Function for sorting the selected groups in the group buffer.")
475
476 (defvar gnus-group-indentation-function nil)
477 (defvar gnus-goto-missing-group-function nil)
478 (defvar gnus-group-update-group-function nil)
479 (defvar gnus-group-goto-next-group-function nil
480   "Function to override finding the next group after listing groups.")
481
482 (defvar gnus-group-edit-buffer nil)
483
484 (defvar gnus-group-line-format-alist
485   `((?M gnus-tmp-marked-mark ?c)
486     (?S gnus-tmp-subscribed ?c)
487     (?L gnus-tmp-level ?d)
488     (?N (cond ((eq number t) "*" )
489               ((numberp number)
490                (int-to-string
491                 (+ number
492                    (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
493                    (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
494               (t number)) ?s)
495     (?R gnus-tmp-number-of-read ?s)
496     (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
497     (?t gnus-tmp-number-total ?d)
498     (?y gnus-tmp-number-of-unread ?s)
499     (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
500     (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
501     (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
502            (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
503     (?g (if (boundp 'gnus-tmp-decoded-group)
504             gnus-tmp-decoded-group
505           gnus-tmp-group)
506         ?s)
507     (?G gnus-tmp-qualified-group ?s)
508     (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
509                                    gnus-tmp-decoded-group
510                                  gnus-tmp-group))
511         ?s)
512     (?C gnus-tmp-comment ?s)
513     (?D gnus-tmp-newsgroup-description ?s)
514     (?o gnus-tmp-moderated ?c)
515     (?O gnus-tmp-moderated-string ?s)
516     (?p gnus-tmp-process-marked ?c)
517     (?s gnus-tmp-news-server ?s)
518     (?n ,(if (featurep 'xemacs)
519              '(symbol-name gnus-tmp-news-method)
520            'gnus-tmp-news-method)
521         ?s)
522     (?P gnus-group-indentation ?s)
523     (?E gnus-tmp-group-icon ?s)
524     (?B gnus-tmp-summary-live ?c)
525     (?z gnus-tmp-news-method-string ?s)
526     (?m (gnus-group-new-mail gnus-tmp-group) ?c)
527     (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
528     (?u gnus-tmp-user-defined ?s)
529     (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
530     ))
531
532 (defvar gnus-group-mode-line-format-alist
533   `((?S gnus-tmp-news-server ?s)
534     (?M gnus-tmp-news-method ?s)
535     (?u gnus-tmp-user-defined ?s)
536     (?: gnus-tmp-colon ?s)))
537
538 (defvar gnus-topic-topology nil
539   "The complete topic hierarchy.")
540
541 (defvar gnus-topic-alist nil
542   "The complete topic-group alist.")
543
544 (defvar gnus-group-marked nil)
545
546 (defvar gnus-group-list-mode nil)
547
548
549 (defvar gnus-group-icon-cache nil)
550
551 (defvar gnus-group-listed-groups nil)
552 (defvar gnus-group-list-option nil)
553
554 ;;;
555 ;;; Gnus group mode
556 ;;;
557
558 (put 'gnus-group-mode 'mode-class 'special)
559
560 (gnus-define-keys gnus-group-mode-map
561   " " gnus-group-read-group
562   "=" gnus-group-select-group
563   "\r" gnus-group-select-group
564   "\M-\r" gnus-group-quick-select-group
565   "\M- " gnus-group-visible-select-group
566   [(meta control return)] gnus-group-select-group-ephemerally
567   "j" gnus-group-jump-to-group
568   "n" gnus-group-next-unread-group
569   "p" gnus-group-prev-unread-group
570   "\177" gnus-group-prev-unread-group
571   [delete] gnus-group-prev-unread-group
572   [backspace] gnus-group-prev-unread-group
573   "N" gnus-group-next-group
574   "P" gnus-group-prev-group
575   "\M-n" gnus-group-next-unread-group-same-level
576   "\M-p" gnus-group-prev-unread-group-same-level
577   "," gnus-group-best-unread-group
578   "." gnus-group-first-unread-group
579   "u" gnus-group-unsubscribe-current-group
580   "U" gnus-group-unsubscribe-group
581   "c" gnus-group-catchup-current
582   "C" gnus-group-catchup-current-all
583   "\M-c" gnus-group-clear-data
584   "l" gnus-group-list-groups
585   "L" gnus-group-list-all-groups
586   "m" gnus-group-mail
587   "i" gnus-group-news
588   "g" gnus-group-get-new-news
589   "\M-g" gnus-group-get-new-news-this-group
590   "R" gnus-group-restart
591   "r" gnus-group-read-init-file
592   "B" gnus-group-browse-foreign-server
593   "b" gnus-group-check-bogus-groups
594   "F" gnus-group-find-new-groups
595   "\C-c\C-d" gnus-group-describe-group
596   "\M-d" gnus-group-describe-all-groups
597   "\C-c\C-a" gnus-group-apropos
598   "\C-c\M-\C-a" gnus-group-description-apropos
599   "a" gnus-group-post-news
600   "\ek" gnus-group-edit-local-kill
601   "\eK" gnus-group-edit-global-kill
602   "\C-k" gnus-group-kill-group
603   "\C-y" gnus-group-yank-group
604   "\C-w" gnus-group-kill-region
605   "\C-x\C-t" gnus-group-transpose-groups
606   "\C-c\C-l" gnus-group-list-killed
607   "\C-c\C-x" gnus-group-expire-articles
608   "\C-c\M-\C-x" gnus-group-expire-all-groups
609   "V" gnus-version
610   "s" gnus-group-save-newsrc
611   "z" gnus-group-suspend
612   "q" gnus-group-exit
613   "Q" gnus-group-quit
614   "?" gnus-group-describe-briefly
615   "\C-c\C-i" gnus-info-find-node
616   "\M-e" gnus-group-edit-group-method
617   "^" gnus-group-enter-server-mode
618   gnus-mouse-2 gnus-mouse-pick-group
619   [follow-link] mouse-face
620   "<" beginning-of-buffer
621   ">" end-of-buffer
622   "\C-c\C-b" gnus-bug
623   "\C-c\C-s" gnus-group-sort-groups
624   "t" gnus-topic-mode
625   "\C-c\M-g" gnus-activate-all-groups
626   "\M-&" gnus-group-universal-argument
627   "#" gnus-group-mark-group
628   "\M-#" gnus-group-unmark-group)
629
630 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
631   "m" gnus-group-mark-group
632   "u" gnus-group-unmark-group
633   "w" gnus-group-mark-region
634   "b" gnus-group-mark-buffer
635   "r" gnus-group-mark-regexp
636   "U" gnus-group-unmark-all-groups)
637
638 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
639   "u" gnus-sieve-update
640   "g" gnus-sieve-generate)
641
642 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
643   "d" gnus-group-make-directory-group
644   "h" gnus-group-make-help-group
645   "u" gnus-group-make-useful-group
646   "a" gnus-group-make-archive-group
647   "k" gnus-group-make-kiboze-group
648   "l" gnus-group-nnimap-edit-acl
649   "m" gnus-group-make-group
650   "E" gnus-group-edit-group
651   "e" gnus-group-edit-group-method
652   "p" gnus-group-edit-group-parameters
653   "v" gnus-group-add-to-virtual
654   "V" gnus-group-make-empty-virtual
655   "D" gnus-group-enter-directory
656   "f" gnus-group-make-doc-group
657   "w" gnus-group-make-web-group
658   "M" gnus-group-read-ephemeral-group
659   "r" gnus-group-rename-group
660   "R" gnus-group-make-rss-group
661   "c" gnus-group-customize
662   "z" gnus-group-compact-group
663   "x" gnus-group-nnimap-expunge
664   "\177" gnus-group-delete-group
665   [delete] gnus-group-delete-group)
666
667 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
668   "b" gnus-group-brew-soup
669   "w" gnus-soup-save-areas
670   "s" gnus-soup-send-replies
671   "p" gnus-soup-pack-packet
672   "r" nnsoup-pack-replies)
673
674 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
675   "s" gnus-group-sort-groups
676   "a" gnus-group-sort-groups-by-alphabet
677   "u" gnus-group-sort-groups-by-unread
678   "l" gnus-group-sort-groups-by-level
679   "v" gnus-group-sort-groups-by-score
680   "r" gnus-group-sort-groups-by-rank
681   "m" gnus-group-sort-groups-by-method
682   "n" gnus-group-sort-groups-by-real-name)
683
684 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
685   "s" gnus-group-sort-selected-groups
686   "a" gnus-group-sort-selected-groups-by-alphabet
687   "u" gnus-group-sort-selected-groups-by-unread
688   "l" gnus-group-sort-selected-groups-by-level
689   "v" gnus-group-sort-selected-groups-by-score
690   "r" gnus-group-sort-selected-groups-by-rank
691   "m" gnus-group-sort-selected-groups-by-method
692   "n" gnus-group-sort-selected-groups-by-real-name)
693
694 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
695   "k" gnus-group-list-killed
696   "z" gnus-group-list-zombies
697   "s" gnus-group-list-groups
698   "u" gnus-group-list-all-groups
699   "A" gnus-group-list-active
700   "a" gnus-group-apropos
701   "d" gnus-group-description-apropos
702   "m" gnus-group-list-matching
703   "M" gnus-group-list-all-matching
704   "l" gnus-group-list-level
705   "c" gnus-group-list-cached
706   "?" gnus-group-list-dormant)
707
708 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
709   "k"  gnus-group-list-limit
710   "z"  gnus-group-list-limit
711   "s"  gnus-group-list-limit
712   "u"  gnus-group-list-limit
713   "A"  gnus-group-list-limit
714   "m"  gnus-group-list-limit
715   "M"  gnus-group-list-limit
716   "l"  gnus-group-list-limit
717   "c"  gnus-group-list-limit
718   "?"  gnus-group-list-limit)
719
720 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
721   "k"  gnus-group-list-flush
722   "z"  gnus-group-list-flush
723   "s"  gnus-group-list-flush
724   "u"  gnus-group-list-flush
725   "A"  gnus-group-list-flush
726   "m"  gnus-group-list-flush
727   "M"  gnus-group-list-flush
728   "l"  gnus-group-list-flush
729   "c"  gnus-group-list-flush
730   "?"  gnus-group-list-flush)
731
732 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
733   "k"  gnus-group-list-plus
734   "z"  gnus-group-list-plus
735   "s"  gnus-group-list-plus
736   "u"  gnus-group-list-plus
737   "A"  gnus-group-list-plus
738   "m"  gnus-group-list-plus
739   "M"  gnus-group-list-plus
740   "l"  gnus-group-list-plus
741   "c"  gnus-group-list-plus
742   "?"  gnus-group-list-plus)
743
744 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
745   "f" gnus-score-flush-cache
746   "e" gnus-score-edit-all-score)
747
748 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
749   "c" gnus-group-fetch-charter
750   "C" gnus-group-fetch-control
751   "d" gnus-group-describe-group
752   "f" gnus-group-fetch-faq
753   "v" gnus-version)
754
755 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
756   "l" gnus-group-set-current-level
757   "t" gnus-group-unsubscribe-current-group
758   "s" gnus-group-unsubscribe-group
759   "k" gnus-group-kill-group
760   "y" gnus-group-yank-group
761   "w" gnus-group-kill-region
762   "\C-k" gnus-group-kill-level
763   "z" gnus-group-kill-all-zombies)
764
765 (defun gnus-topic-mode-p ()
766   "Return non-nil in `gnus-topic-mode'."
767   (and (boundp 'gnus-topic-mode)
768        (symbol-value 'gnus-topic-mode)))
769
770 (defun gnus-group-make-menu-bar ()
771   (gnus-turn-off-edit-menu 'group)
772   (unless (boundp 'gnus-group-reading-menu)
773
774     (easy-menu-define
775      gnus-group-reading-menu gnus-group-mode-map ""
776      `("Group"
777        ["Read" gnus-group-read-group
778         :included (not (gnus-topic-mode-p))
779         :active (gnus-group-group-name)]
780        ["Read " gnus-topic-read-group
781         :included (gnus-topic-mode-p)]
782        ["Select" gnus-group-select-group
783         :included (not (gnus-topic-mode-p))
784         :active (gnus-group-group-name)]
785        ["Select " gnus-topic-select-group
786         :included (gnus-topic-mode-p)]
787        ["See old articles" (gnus-group-select-group 'all)
788         :keys "C-u SPC" :active (gnus-group-group-name)]
789        ["Catch up" gnus-group-catchup-current
790         :included (not (gnus-topic-mode-p))
791         :active (gnus-group-group-name)
792         ,@(if (featurep 'xemacs) nil
793             '(:help "Mark unread articles in the current group as read"))]
794        ["Catch up " gnus-topic-catchup-articles
795         :included (gnus-topic-mode-p)
796         ,@(if (featurep 'xemacs) nil
797             '(:help "Mark unread articles in the current group or topic as read"))]
798        ["Catch up all articles" gnus-group-catchup-current-all
799         (gnus-group-group-name)]
800        ["Check for new articles" gnus-group-get-new-news-this-group
801         :included (not (gnus-topic-mode-p))
802         :active (gnus-group-group-name)
803         ,@(if (featurep 'xemacs) nil
804             '(:help "Check for new messages in current group"))]
805        ["Check for new articles " gnus-topic-get-new-news-this-topic
806         :included (gnus-topic-mode-p)
807         ,@(if (featurep 'xemacs) nil
808             '(:help "Check for new messages in current group or topic"))]
809        ["Toggle subscription" gnus-group-unsubscribe-current-group
810         (gnus-group-group-name)]
811        ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
812         ,@(if (featurep 'xemacs) nil
813               '(:help "Kill (remove) current group"))]
814        ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
815        ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
816         ,@(if (featurep 'xemacs) nil
817             '(:help "Display description of the current group"))]
818        ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
819        ["Fetch charter" gnus-group-fetch-charter
820         :active (gnus-group-group-name)
821         ,@(if (featurep 'xemacs) nil
822             '(:help "Display the charter of the current group"))]
823        ["Fetch control message" gnus-group-fetch-control
824         :active (gnus-group-group-name)
825         ,@(if (featurep 'xemacs) nil
826             '(:help "Display the archived control message for the current group"))]
827        ;; Actually one should check, if any of the marked groups gives t for
828        ;; (gnus-check-backend-function 'request-expire-articles ...)
829        ["Expire articles" gnus-group-expire-articles
830         :included (not (gnus-topic-mode-p))
831         :active (or (and (gnus-group-group-name)
832                          (gnus-check-backend-function
833                           'request-expire-articles
834                           (gnus-group-group-name))) gnus-group-marked)]
835        ["Expire articles " gnus-topic-expire-articles
836         :included (gnus-topic-mode-p)]
837        ["Set group level..." gnus-group-set-current-level
838         (gnus-group-group-name)]
839        ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
840        ["Customize" gnus-group-customize (gnus-group-group-name)]
841        ["Compact" gnus-group-compact-group
842         :active (gnus-group-group-name)]
843        ("Edit"
844         ["Parameters" gnus-group-edit-group-parameters
845          :included (not (gnus-topic-mode-p))
846          :active (gnus-group-group-name)]
847         ["Parameters " gnus-topic-edit-parameters
848          :included (gnus-topic-mode-p)]
849         ["Select method" gnus-group-edit-group-method
850          (gnus-group-group-name)]
851         ["Info" gnus-group-edit-group (gnus-group-group-name)]
852         ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
853         ["Global kill file" gnus-group-edit-global-kill t])))
854
855     (easy-menu-define
856      gnus-group-group-menu gnus-group-mode-map ""
857      '("Groups"
858        ("Listing"
859         ["List unread subscribed groups" gnus-group-list-groups t]
860         ["List (un)subscribed groups" gnus-group-list-all-groups t]
861         ["List killed groups" gnus-group-list-killed gnus-killed-list]
862         ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
863         ["List level..." gnus-group-list-level t]
864         ["Describe all groups" gnus-group-describe-all-groups t]
865         ["Group apropos..." gnus-group-apropos t]
866         ["Group and description apropos..." gnus-group-description-apropos t]
867         ["List groups matching..." gnus-group-list-matching t]
868         ["List all groups matching..." gnus-group-list-all-matching t]
869         ["List active file" gnus-group-list-active t]
870         ["List groups with cached" gnus-group-list-cached t]
871         ["List groups with dormant" gnus-group-list-dormant t])
872        ("Sort"
873         ["Default sort" gnus-group-sort-groups t]
874         ["Sort by method" gnus-group-sort-groups-by-method t]
875         ["Sort by rank" gnus-group-sort-groups-by-rank t]
876         ["Sort by score" gnus-group-sort-groups-by-score t]
877         ["Sort by level" gnus-group-sort-groups-by-level t]
878         ["Sort by unread" gnus-group-sort-groups-by-unread t]
879         ["Sort by name" gnus-group-sort-groups-by-alphabet t]
880         ["Sort by real name" gnus-group-sort-groups-by-real-name t])
881        ("Sort process/prefixed"
882         ["Default sort" gnus-group-sort-selected-groups
883          (not (gnus-topic-mode-p))]
884         ["Sort by method" gnus-group-sort-selected-groups-by-method
885          (not (gnus-topic-mode-p))]
886         ["Sort by rank" gnus-group-sort-selected-groups-by-rank
887          (not (gnus-topic-mode-p))]
888         ["Sort by score" gnus-group-sort-selected-groups-by-score
889          (not (gnus-topic-mode-p))]
890         ["Sort by level" gnus-group-sort-selected-groups-by-level
891          (not (gnus-topic-mode-p))]
892         ["Sort by unread" gnus-group-sort-selected-groups-by-unread
893          (not (gnus-topic-mode-p))]
894         ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
895          (not (gnus-topic-mode-p))]
896         ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
897          (not (gnus-topic-mode-p))])
898        ("Mark"
899         ["Mark group" gnus-group-mark-group
900          (and (gnus-group-group-name)
901               (not (memq (gnus-group-group-name) gnus-group-marked)))]
902         ["Unmark group" gnus-group-unmark-group
903          (and (gnus-group-group-name)
904               (memq (gnus-group-group-name) gnus-group-marked))]
905         ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
906         ["Mark regexp..." gnus-group-mark-regexp t]
907         ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
908         ["Mark buffer" gnus-group-mark-buffer t]
909         ["Execute command" gnus-group-universal-argument
910          (or gnus-group-marked (gnus-group-group-name))])
911        ("Subscribe"
912         ["Subscribe to a group..." gnus-group-unsubscribe-group t]
913         ["Kill all newsgroups in region" gnus-group-kill-region
914          :active (gnus-mark-active-p)]
915         ["Kill all zombie groups" gnus-group-kill-all-zombies
916          gnus-zombie-list]
917         ["Kill all groups on level..." gnus-group-kill-level t])
918        ("Foreign groups"
919         ["Make a foreign group..." gnus-group-make-group t]
920         ["Add a directory group..." gnus-group-make-directory-group t]
921         ["Add the help group" gnus-group-make-help-group t]
922         ["Add the archive group" gnus-group-make-archive-group t]
923         ["Make a doc group..." gnus-group-make-doc-group t]
924         ["Make a web group..." gnus-group-make-web-group t]
925         ["Make a kiboze group..." gnus-group-make-kiboze-group t]
926         ["Make a virtual group..." gnus-group-make-empty-virtual t]
927         ["Add a group to a virtual..." gnus-group-add-to-virtual t]
928         ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
929         ["Make an RSS group..." gnus-group-make-rss-group t]
930         ["Rename group..." gnus-group-rename-group
931          (gnus-check-backend-function
932           'request-rename-group (gnus-group-group-name))]
933         ["Delete group" gnus-group-delete-group
934          (gnus-check-backend-function
935           'request-delete-group (gnus-group-group-name))])
936        ("Move"
937         ["Next" gnus-group-next-group t]
938         ["Previous" gnus-group-prev-group t]
939         ["Next unread" gnus-group-next-unread-group t]
940         ["Previous unread" gnus-group-prev-unread-group t]
941         ["Next unread same level" gnus-group-next-unread-group-same-level t]
942         ["Previous unread same level"
943          gnus-group-prev-unread-group-same-level t]
944         ["Jump to group..." gnus-group-jump-to-group t]
945         ["First unread group" gnus-group-first-unread-group t]
946         ["Best unread group" gnus-group-best-unread-group t])
947        ("Sieve"
948         ["Generate" gnus-sieve-generate t]
949         ["Generate and update" gnus-sieve-update t])
950        ["Delete bogus groups" gnus-group-check-bogus-groups t]
951        ["Find new newsgroups" gnus-group-find-new-groups t]
952        ["Transpose" gnus-group-transpose-groups
953         (gnus-group-group-name)]
954        ["Read a directory as a group..." gnus-group-enter-directory t]))
955
956     (easy-menu-define
957      gnus-group-misc-menu gnus-group-mode-map ""
958      `("Gnus"
959        ("SOUP"
960         ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
961         ["Send replies" gnus-soup-send-replies
962          (fboundp 'gnus-soup-pack-packet)]
963         ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
964         ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
965         ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
966        ["Send a mail" gnus-group-mail t]
967        ["Send a message (mail or news)" gnus-group-post-news t]
968        ["Create a local message" gnus-group-news t]
969        ["Check for new news" gnus-group-get-new-news
970         ,@(if (featurep 'xemacs) '(t)
971             '(:help "Get newly arrived articles"))
972         ]
973        ["Send queued messages" gnus-delay-send-queue
974         ,@(if (featurep 'xemacs) '(t)
975             '(:help "Send all messages that are scheduled to be sent now"))
976         ]
977        ["Activate all groups" gnus-activate-all-groups t]
978        ["Restart Gnus" gnus-group-restart t]
979        ["Read init file" gnus-group-read-init-file t]
980        ["Browse foreign server..." gnus-group-browse-foreign-server t]
981        ["Enter server buffer" gnus-group-enter-server-mode t]
982        ["Expire all expirable articles" gnus-group-expire-all-groups t]
983        ["Generate any kiboze groups" nnkiboze-generate-groups t]
984        ["Gnus version" gnus-version t]
985        ["Save .newsrc files" gnus-group-save-newsrc t]
986        ["Suspend Gnus" gnus-group-suspend t]
987        ["Clear dribble buffer" gnus-group-clear-dribble t]
988        ["Read manual" gnus-info-find-node t]
989        ["Flush score cache" gnus-score-flush-cache t]
990        ["Toggle topics" gnus-topic-mode t]
991        ["Send a bug report" gnus-bug t]
992        ["Exit from Gnus" gnus-group-exit
993         ,@(if (featurep 'xemacs) '(t)
994             '(:help "Quit reading news"))]
995        ["Exit without saving" gnus-group-quit t]))
996
997     (gnus-run-hooks 'gnus-group-menu-hook)))
998
999
1000 (defvar gnus-group-tool-bar-map nil)
1001
1002 (defun gnus-group-tool-bar-update (&optional symbol value)
1003   "Update group buffer toolbar.
1004 Setter function for custom variables."
1005   (when symbol
1006     (set-default symbol value))
1007   ;; (setq-default gnus-group-tool-bar-map nil)
1008   ;; (use-local-map gnus-group-mode-map)
1009   (when (gnus-alive-p)
1010     (with-current-buffer gnus-group-buffer
1011       (gnus-group-make-tool-bar t))))
1012
1013 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
1014                                    'gnus-group-tool-bar-gnome
1015                                  'gnus-group-tool-bar-retro)
1016   "Specifies the Gnus group tool bar.
1017
1018 It can be either a list or a symbol refering to a list.  See
1019 `gmm-tool-bar-from-list' for the format of the list.  The
1020 default key map is `gnus-group-mode-map'.
1021
1022 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1023 `gnus-group-tool-bar-retro'."
1024   :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1025                  (const :tag "Retro look" gnus-group-tool-bar-retro)
1026                  (repeat :tag "User defined list" gmm-tool-bar-item)
1027                  (symbol))
1028   :version "23.0" ;; No Gnus
1029   :initialize 'custom-initialize-default
1030   :set 'gnus-group-tool-bar-update
1031   :group 'gnus-group)
1032
1033 (defcustom gnus-group-tool-bar-gnome
1034   '((gnus-group-post-news "mail/compose")
1035     ;; Some useful agent icons?  I don't use the agent so agent users should
1036     ;; suggest useful commands:
1037     (gnus-agent-toggle-plugged "disconnect" t
1038                                :help "Gnus is currently unplugged.  Click to work online."
1039                                :visible (and gnus-agent (not gnus-plugged)))
1040     (gnus-agent-toggle-plugged "connect" t
1041                                :help "Gnus is currently plugged.  Click to work offline."
1042                                :visible (and gnus-agent gnus-plugged))
1043     ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1044     ;; should have a better help text.
1045     (gnus-group-send-queue "mail/outbox" t
1046                            :visible (and gnus-agent gnus-plugged)
1047                            :help "Send articles from the queue group")
1048     (gnus-group-get-new-news "mail/inbox" nil
1049                              :visible (or (not gnus-agent)
1050                                           gnus-plugged))
1051     ;; FIXME: gnus-*-read-group should have a better help text.
1052     (gnus-topic-read-group "open" nil
1053                            :visible (and (boundp 'gnus-topic-mode)
1054                                          gnus-topic-mode))
1055     (gnus-group-read-group "open" nil
1056                            :visible (not (and (boundp 'gnus-topic-mode)
1057                                               gnus-topic-mode)))
1058     ;; (gnus-group-find-new-groups "???" nil)
1059     (gnus-group-save-newsrc "save")
1060     (gnus-group-describe-group "describe")
1061     (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1062     (gnus-group-prev-unread-group "left-arrow")
1063     (gnus-group-next-unread-group "right-arrow")
1064     (gnus-group-exit "exit")
1065     (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1066     (gnus-info-find-node "help"))
1067   "List of functions for the group tool bar (GNOME style).
1068
1069 See `gmm-tool-bar-from-list' for the format of the list."
1070   :type '(repeat gmm-tool-bar-item)
1071   :version "23.0" ;; No Gnus
1072   :initialize 'custom-initialize-default
1073   :set 'gnus-group-tool-bar-update
1074   :group 'gnus-group)
1075
1076 (defcustom gnus-group-tool-bar-retro
1077   '((gnus-group-get-new-news "gnus/get-news")
1078     (gnus-group-get-new-news-this-group "gnus/gnntg")
1079     (gnus-group-catchup-current "gnus/catchup")
1080     (gnus-group-describe-group "gnus/describe-group")
1081     (gnus-group-subscribe "gnus/subscribe" t
1082                           :help "Subscribe to the current group")
1083     (gnus-group-unsubscribe "gnus/unsubscribe" t
1084                             :help "Unsubscribe from the current group")
1085     (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1086   "List of functions for the group tool bar (retro look).
1087
1088 See `gmm-tool-bar-from-list' for the format of the list."
1089   :type '(repeat gmm-tool-bar-item)
1090   :version "23.0" ;; No Gnus
1091   :initialize 'custom-initialize-default
1092   :set 'gnus-group-tool-bar-update
1093   :group 'gnus-group)
1094
1095 (defcustom gnus-group-tool-bar-zap-list t
1096   "List of icon items from the global tool bar.
1097 These items are not displayed in the Gnus group mode tool bar.
1098
1099 See `gmm-tool-bar-from-list' for the format of the list."
1100   :type 'gmm-tool-bar-zap-list
1101   :version "23.0" ;; No Gnus
1102   :initialize 'custom-initialize-default
1103   :set 'gnus-group-tool-bar-update
1104   :group 'gnus-group)
1105
1106 (defvar image-load-path)
1107
1108 (defun gnus-group-make-tool-bar (&optional force)
1109   "Make a group mode tool bar from `gnus-group-tool-bar'.
1110 When FORCE, rebuild the tool bar."
1111   (when (and (not (featurep 'xemacs))
1112              (boundp 'tool-bar-mode)
1113              tool-bar-mode
1114              ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1115              ;; Why?  --rsteib
1116              (or (not gnus-group-tool-bar-map) force))
1117     (let* ((load-path
1118             (gmm-image-load-path-for-library "gnus"
1119                                              "gnus/toggle-subscription.xpm"
1120                                              nil t))
1121            (image-load-path (cons (car load-path)
1122                                   (when (boundp 'image-load-path)
1123                                     image-load-path)))
1124            (map (gmm-tool-bar-from-list gnus-group-tool-bar
1125                                         gnus-group-tool-bar-zap-list
1126                                         'gnus-group-mode-map)))
1127       (if map
1128           (set (make-local-variable 'tool-bar-map) map))))
1129   gnus-group-tool-bar-map)
1130
1131 (defun gnus-group-mode ()
1132   "Major mode for reading news.
1133
1134 All normal editing commands are switched off.
1135 \\<gnus-group-mode-map>
1136 The group buffer lists (some of) the groups available.  For instance,
1137 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1138 lists all zombie groups.
1139
1140 Groups that are displayed can be entered with `\\[gnus-group-read-group]'.  To subscribe
1141 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1142
1143 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1144
1145 The following commands are available:
1146
1147 \\{gnus-group-mode-map}"
1148   (interactive)
1149   (kill-all-local-variables)
1150   (when (gnus-visual-p 'group-menu 'menu)
1151     (gnus-group-make-menu-bar)
1152     (gnus-group-make-tool-bar))
1153   (gnus-simplify-mode-line)
1154   (setq major-mode 'gnus-group-mode)
1155   (setq mode-name "Group")
1156   (gnus-group-set-mode-line)
1157   (setq mode-line-process nil)
1158   (use-local-map gnus-group-mode-map)
1159   (buffer-disable-undo)
1160   (setq truncate-lines t)
1161   (setq buffer-read-only t
1162         show-trailing-whitespace nil)
1163   (gnus-set-default-directory)
1164   (gnus-update-format-specifications nil 'group 'group-mode)
1165   (gnus-update-group-mark-positions)
1166   (when gnus-use-undo
1167     (gnus-undo-mode 1))
1168   (when gnus-slave
1169     (gnus-slave-mode))
1170   (gnus-run-mode-hooks 'gnus-group-mode-hook))
1171
1172 (defun gnus-update-group-mark-positions ()
1173   (save-excursion
1174     (let ((gnus-process-mark ?\200)
1175           (gnus-group-update-hook nil)
1176           (gnus-group-marked '("dummy.group"))
1177           (gnus-active-hashtb (make-vector 10 0))
1178           (topic ""))
1179       (gnus-set-active "dummy.group" '(0 . 0))
1180       (gnus-set-work-buffer)
1181       (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1182       (goto-char (point-min))
1183       (setq gnus-group-mark-positions
1184             (list (cons 'process (and (search-forward
1185                                        (mm-string-as-multibyte "\200") nil t)
1186                                       (- (point) 2))))))))
1187
1188 (defun gnus-mouse-pick-group (e)
1189   "Enter the group under the mouse pointer."
1190   (interactive "e")
1191   (mouse-set-point e)
1192   (gnus-group-read-group nil))
1193
1194 ;; Look at LEVEL and find out what the level is really supposed to be.
1195 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1196 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1197 (defun gnus-group-default-level (&optional level number-or-nil)
1198   (cond
1199    (gnus-group-use-permanent-levels
1200     (or (setq gnus-group-use-permanent-levels
1201               (or level (if (numberp gnus-group-use-permanent-levels)
1202                             gnus-group-use-permanent-levels
1203                           (or gnus-group-default-list-level
1204                               gnus-level-subscribed))))
1205         gnus-group-default-list-level gnus-level-subscribed))
1206    (number-or-nil
1207     level)
1208    (t
1209     (or level gnus-group-default-list-level gnus-level-subscribed))))
1210
1211 (defun gnus-group-setup-buffer ()
1212   (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1213   (unless (eq major-mode 'gnus-group-mode)
1214     (gnus-group-mode)
1215     (when gnus-carpal
1216       (gnus-carpal-setup-buffer 'group))))
1217
1218 (defun gnus-group-name-charset (method group)
1219   (if (null method)
1220       (setq method (gnus-find-method-for-group group)))
1221   (let ((item (assoc method gnus-group-name-charset-method-alist))
1222         (alist gnus-group-name-charset-group-alist)
1223         result)
1224     (if item
1225         (cdr item)
1226       (while (setq item (pop alist))
1227         (if (string-match (car item) group)
1228             (setq alist nil
1229                   result (cdr item))))
1230       result)))
1231
1232 (defun gnus-group-name-decode (string charset)
1233   ;; Fixme: Don't decode in unibyte mode.
1234   (if (and string charset (featurep 'mule))
1235       (mm-decode-coding-string string charset)
1236     string))
1237
1238 (defun gnus-group-decoded-name (string)
1239   (let ((charset (gnus-group-name-charset nil string)))
1240     (gnus-group-name-decode string charset)))
1241
1242 (defun gnus-group-list-groups (&optional level unread lowest)
1243   "List newsgroups with level LEVEL or lower that have unread articles.
1244 Default is all subscribed groups.
1245 If argument UNREAD is non-nil, groups with no unread articles are also
1246 listed.
1247
1248 Also see the `gnus-group-use-permanent-levels' variable."
1249   (interactive
1250    (list (if current-prefix-arg
1251              (prefix-numeric-value current-prefix-arg)
1252            (or
1253             (gnus-group-default-level nil t)
1254             gnus-group-default-list-level
1255             gnus-level-subscribed))))
1256   (unless level
1257     (setq level (car gnus-group-list-mode)
1258           unread (cdr gnus-group-list-mode)))
1259   (setq level (gnus-group-default-level level))
1260   (gnus-group-setup-buffer)
1261   (gnus-update-format-specifications nil 'group 'group-mode)
1262   (let ((case-fold-search nil)
1263         (props (text-properties-at (point-at-bol)))
1264         (empty (= (point-min) (point-max)))
1265         (group (gnus-group-group-name))
1266         number)
1267     (set-buffer gnus-group-buffer)
1268     (setq number (funcall gnus-group-prepare-function level unread lowest))
1269     (when (or (and (numberp number)
1270                    (zerop number))
1271               (zerop (buffer-size)))
1272       ;; No groups in the buffer.
1273       (gnus-message 5 gnus-no-groups-message))
1274     ;; We have some groups displayed.
1275     (goto-char (point-max))
1276     (when (or (not gnus-group-goto-next-group-function)
1277               (not (funcall gnus-group-goto-next-group-function
1278                             group props)))
1279       (cond
1280        (empty
1281         (goto-char (point-min)))
1282        ((not group)
1283         ;; Go to the first group with unread articles.
1284         (gnus-group-search-forward t))
1285        (t
1286         ;; Find the right group to put point on.  If the current group
1287         ;; has disappeared in the new listing, try to find the next
1288         ;; one.  If no next one can be found, just leave point at the
1289         ;; first newsgroup in the buffer.
1290         (when (not (gnus-goto-char
1291                     (text-property-any
1292                      (point-min) (point-max)
1293                      'gnus-group (gnus-intern-safe
1294                                   group gnus-active-hashtb))))
1295           (let ((newsrc (cdddr (gnus-group-entry group))))
1296             (while (and newsrc
1297                         (not (gnus-goto-char
1298                               (text-property-any
1299                                (point-min) (point-max) 'gnus-group
1300                                (gnus-intern-safe
1301                                 (caar newsrc) gnus-active-hashtb)))))
1302               (setq newsrc (cdr newsrc)))
1303             (unless newsrc
1304               (goto-char (point-max))
1305               (forward-line -1)))))))
1306     ;; Adjust cursor point.
1307     (gnus-group-position-point)))
1308
1309 (defun gnus-group-list-level (level &optional all)
1310   "List groups on LEVEL.
1311 If ALL (the prefix), also list groups that have no unread articles."
1312   (interactive "nList groups on level: \nP")
1313   (gnus-group-list-groups level all level))
1314
1315 (defun gnus-group-prepare-logic (group test)
1316   (or (and gnus-group-listed-groups
1317            (null gnus-group-list-option)
1318            (member group gnus-group-listed-groups))
1319       (cond
1320        ((null gnus-group-listed-groups) test)
1321        ((null gnus-group-list-option) test)
1322        (t (and (member group gnus-group-listed-groups)
1323                (if (eq gnus-group-list-option 'flush)
1324                    (not test)
1325                  test))))))
1326
1327 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1328   "List all newsgroups with unread articles of level LEVEL or lower.
1329 If PREDICATE is a function, list groups that the function returns non-nil;
1330 if it is t, list groups that have no unread articles.
1331 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1332 If REGEXP is a function, list dead groups that the function returns non-nil;
1333 if it is a string, only list groups matching REGEXP."
1334   (set-buffer gnus-group-buffer)
1335   (let ((buffer-read-only nil)
1336         (newsrc (cdr gnus-newsrc-alist))
1337         (lowest (or lowest 1))
1338         (not-in-list (and gnus-group-listed-groups
1339                           (copy-sequence gnus-group-listed-groups)))
1340         info clevel unread group params)
1341     (erase-buffer)
1342     (when (or (< lowest gnus-level-zombie)
1343               gnus-group-listed-groups)
1344       ;; List living groups.
1345       (while newsrc
1346         (setq info (car newsrc)
1347               group (gnus-info-group info)
1348               params (gnus-info-params info)
1349               newsrc (cdr newsrc)
1350               unread (gnus-group-unread group))
1351         (when not-in-list
1352           (setq not-in-list (delete group not-in-list)))
1353         (when (gnus-group-prepare-logic
1354                group
1355                (and unread              ; This group might be unchecked
1356                     (or (not (stringp regexp))
1357                         (string-match regexp group))
1358                     (<= (setq clevel (gnus-info-level info)) level)
1359                     (>= clevel lowest)
1360                     (cond
1361                      ((functionp predicate)
1362                       (funcall predicate info))
1363                      (predicate t)      ; We list all groups?
1364                      (t
1365                       (or
1366                        (if (eq unread t) ; Unactivated?
1367                            gnus-group-list-inactive-groups
1368                                         ; We list unactivated
1369                          (> unread 0))
1370                                         ; We list groups with unread articles
1371                        (and gnus-list-groups-with-ticked-articles
1372                             (cdr (assq 'tick (gnus-info-marks info))))
1373                                         ; And groups with tickeds
1374                        ;; Check for permanent visibility.
1375                        (and gnus-permanently-visible-groups
1376                             (string-match gnus-permanently-visible-groups
1377                                           group))
1378                        (memq 'visible params)
1379                        (cdr (assq 'visible params)))))))
1380           (gnus-group-insert-group-line
1381            group (gnus-info-level info)
1382            (gnus-info-marks info) unread (gnus-info-method info)))))
1383
1384     ;; List dead groups.
1385     (when (or gnus-group-listed-groups
1386               (and (>= level gnus-level-zombie)
1387                    (<= lowest gnus-level-zombie)))
1388       (gnus-group-prepare-flat-list-dead
1389        (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1390        gnus-level-zombie ?Z
1391        regexp))
1392     (when not-in-list
1393       (dolist (group gnus-zombie-list)
1394         (setq not-in-list (delete group not-in-list))))
1395     (when (or gnus-group-listed-groups
1396               (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1397       (gnus-group-prepare-flat-list-dead
1398        (gnus-union
1399         not-in-list
1400         (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1401        gnus-level-killed ?K regexp))
1402
1403     (gnus-group-set-mode-line)
1404     (setq gnus-group-list-mode (cons level predicate))
1405     (gnus-run-hooks 'gnus-group-prepare-hook)
1406     t))
1407
1408 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1409   ;; List zombies and killed lists somewhat faster, which was
1410   ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.  It does
1411   ;; this by ignoring the group format specification altogether.
1412   (let (group)
1413     (if (> (length groups) gnus-group-listing-limit)
1414         (while groups
1415           (setq group (pop groups))
1416           (when (gnus-group-prepare-logic
1417                  group
1418                  (or (not regexp)
1419                      (and (stringp regexp) (string-match regexp group))
1420                      (and (functionp regexp) (funcall regexp group))))
1421             (gnus-add-text-properties
1422              (point) (prog1 (1+ (point))
1423                        (insert " " mark "     *: "
1424                                (gnus-group-decoded-name group)
1425                                "\n"))
1426              (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1427                    'gnus-unread t
1428                    'gnus-level level))))
1429       (while groups
1430         (setq group (pop groups))
1431         (when (gnus-group-prepare-logic
1432                group
1433                (or (not regexp)
1434                    (and (stringp regexp) (string-match regexp group))
1435                    (and (functionp regexp) (funcall regexp group))))
1436           (gnus-group-insert-group-line
1437            group level nil
1438            (let ((active (gnus-active group)))
1439              (if active
1440                  (if (zerop (cdr active))
1441                      0
1442                    (- (1+ (cdr active)) (car active)))
1443                nil))
1444            (gnus-method-simplify (gnus-find-method-for-group group))))))))
1445
1446 (defun gnus-group-update-group-line ()
1447   "Update the current line in the group buffer."
1448   (let* ((buffer-read-only nil)
1449          (group (gnus-group-group-name))
1450          (entry (and group (gnus-group-entry group)))
1451          gnus-group-indentation)
1452     (when group
1453       (and entry
1454            (not (gnus-ephemeral-group-p group))
1455            (gnus-dribble-enter
1456             (concat "(gnus-group-set-info '"
1457                     (gnus-prin1-to-string (nth 2 entry))
1458                     ")")))
1459       (setq gnus-group-indentation (gnus-group-group-indentation))
1460       (gnus-delete-line)
1461       (gnus-group-insert-group-line-info group)
1462       (forward-line -1)
1463       (gnus-group-position-point))))
1464
1465 (defun gnus-group-insert-group-line-info (group)
1466   "Insert GROUP on the current line."
1467   (let ((entry (gnus-group-entry group))
1468         (gnus-group-indentation (gnus-group-group-indentation))
1469         active info)
1470     (if entry
1471         (progn
1472           ;; (Un)subscribed group.
1473           (setq info (nth 2 entry))
1474           (gnus-group-insert-group-line
1475            group (gnus-info-level info) (gnus-info-marks info)
1476            (or (car entry) t) (gnus-info-method info)))
1477       ;; This group is dead.
1478       (gnus-group-insert-group-line
1479        group
1480        (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1481        nil
1482        (if (setq active (gnus-active group))
1483            (if (zerop (cdr active))
1484                0
1485              (- (1+ (cdr active)) (car active)))
1486          nil)
1487        (gnus-method-simplify (gnus-find-method-for-group group))))))
1488
1489 (defun gnus-number-of-unseen-articles-in-group (group)
1490   (let* ((info (nth 2 (gnus-group-entry group)))
1491          (marked (gnus-info-marks info))
1492          (seen (cdr (assq 'seen marked)))
1493          (active (gnus-active group)))
1494     (if (not active)
1495         0
1496       (length (gnus-uncompress-range
1497                (gnus-range-difference
1498                 (gnus-range-difference (list active) (gnus-info-read info))
1499                 seen))))))
1500
1501 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1502 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1503 ;; automatically.  After `C-l' the state is correct.  See the following report
1504 ;; on emacs-devel
1505 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1506 ;; From: Reiner Steib
1507 ;; Subject: tool bar icons not updated according to :active condition
1508 ;; Newsgroups: gmane.emacs.devel
1509 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1510 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1511
1512 (defcustom gnus-group-update-tool-bar
1513   (and (not (featurep 'xemacs))
1514        (boundp 'tool-bar-mode)
1515        tool-bar-mode
1516        ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs 21 might
1517        ;; be confusing, so maybe we shouldn't call it by default.
1518        (fboundp 'force-window-update))
1519   "Force updating the group buffer tool bar."
1520   :group 'gnus-group
1521   :version "22.1"
1522   :initialize 'custom-initialize-default
1523   :set (lambda (symbol value)
1524          (set-default symbol value)
1525          (when (gnus-alive-p)
1526            (with-current-buffer gnus-group-buffer
1527              ;; FIXME: Is there a better way to redraw the group buffer?
1528              (gnus-group-get-new-news 0))))
1529   :type 'boolean)
1530
1531 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1532                                                     gnus-tmp-marked number
1533                                                     gnus-tmp-method)
1534   "Insert a group line in the group buffer."
1535   (let* ((gnus-tmp-method
1536           (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1537          (group-name-charset (gnus-group-name-charset gnus-tmp-method
1538                                                       gnus-tmp-group))
1539          (gnus-tmp-active (gnus-active gnus-tmp-group))
1540          (gnus-tmp-number-total
1541           (if gnus-tmp-active
1542               (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1543             0))
1544          (gnus-tmp-number-of-unread
1545           (if (numberp number) (int-to-string (max 0 number))
1546             "*"))
1547          (gnus-tmp-number-of-read
1548           (if (numberp number)
1549               (int-to-string (max 0 (- gnus-tmp-number-total number)))
1550             "*"))
1551          (gnus-tmp-subscribed
1552           (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1553                 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1554                 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1555                 (t ?K)))
1556          (gnus-tmp-qualified-group
1557           (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1558                                   group-name-charset))
1559          (gnus-tmp-comment
1560           (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1561               gnus-tmp-group))
1562          (gnus-tmp-newsgroup-description
1563           (if gnus-description-hashtb
1564               (or (gnus-group-name-decode
1565                    (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1566                    group-name-charset) "")
1567             ""))
1568          (gnus-tmp-moderated
1569           (if (and gnus-moderated-hashtb
1570                    (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1571               ?m ? ))
1572          (gnus-tmp-moderated-string
1573           (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1574          (gnus-tmp-group-icon "==&&==")
1575          (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1576          (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1577          (gnus-tmp-news-method-string
1578           (if gnus-tmp-method
1579               (format "(%s:%s)" (car gnus-tmp-method)
1580                       (cadr gnus-tmp-method)) ""))
1581          (gnus-tmp-marked-mark
1582           (if (and (numberp number)
1583                    (zerop number)
1584                    (cdr (assq 'tick gnus-tmp-marked)))
1585               ?* ? ))
1586          (gnus-tmp-summary-live
1587           (if (and (not gnus-group-is-exiting-p)
1588                    (gnus-buffer-live-p (gnus-summary-buffer-name
1589                                         gnus-tmp-group)))
1590               ?* ? ))
1591          (gnus-tmp-process-marked
1592           (if (member gnus-tmp-group gnus-group-marked)
1593               gnus-process-mark ? ))
1594          (buffer-read-only nil)
1595          beg end
1596          header gnus-tmp-header)        ; passed as parameter to user-funcs.
1597     (beginning-of-line)
1598     (setq beg (point))
1599     (gnus-add-text-properties
1600      (point)
1601      (prog1 (1+ (point))
1602        ;; Insert the text.
1603        (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1604                                       gnus-tmp-group group-name-charset)))
1605          (eval gnus-group-line-format-spec)))
1606      `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1607                   gnus-unread ,(if (numberp number)
1608                                    (string-to-number gnus-tmp-number-of-unread)
1609                                  t)
1610                   gnus-marked ,gnus-tmp-marked-mark
1611                   gnus-indentation ,gnus-group-indentation
1612                   gnus-level ,gnus-tmp-level))
1613     (setq end (point))
1614     (when gnus-group-update-tool-bar
1615       (gnus-put-text-property beg end 'point-entered
1616                               'gnus-tool-bar-update)
1617       (gnus-put-text-property beg end 'point-left
1618                               'gnus-tool-bar-update))
1619     (forward-line -1)
1620     (when (inline (gnus-visual-p 'group-highlight 'highlight))
1621       (gnus-run-hooks 'gnus-group-update-hook))
1622     (forward-line)
1623     ;; Allow XEmacs to remove front-sticky text properties.
1624     (gnus-group-remove-excess-properties)))
1625
1626 (defun gnus-group-highlight-line ()
1627   "Highlight the current line according to `gnus-group-highlight'."
1628   (let* ((list gnus-group-highlight)
1629          (p (point))
1630          (end (point-at-eol))
1631          ;; now find out where the line starts and leave point there.
1632          (beg (progn (beginning-of-line) (point)))
1633          (group (gnus-group-group-name))
1634          (entry (gnus-group-entry group))
1635          (unread (if (numberp (car entry)) (car entry) 0))
1636          (active (gnus-active group))
1637          (total (if active (1+ (- (cdr active) (car active))) 0))
1638          (info (nth 2 entry))
1639          (method (inline (gnus-server-get-method group (gnus-info-method info))))
1640          (marked (gnus-info-marks info))
1641          (mailp (apply 'append
1642                        (mapcar
1643                         (lambda (x)
1644                           (memq x (assoc (symbol-name
1645                                           (car (or method gnus-select-method)))
1646                                          gnus-valid-select-methods)))
1647                         '(mail post-mail))))
1648          (level (or (gnus-info-level info) gnus-level-killed))
1649          (score (or (gnus-info-score info) 0))
1650          (ticked (gnus-range-length (cdr (assq 'tick marked))))
1651          (group-age (gnus-group-timestamp-delta group))
1652          (inhibit-read-only t))
1653     ;; Eval the cars of the lists until we find a match.
1654     (while (and list
1655                 (not (eval (caar list))))
1656       (setq list (cdr list)))
1657     (let ((face (cdar list)))
1658       (unless (eq face (get-text-property beg 'face))
1659         (gnus-put-text-property-excluding-characters-with-faces
1660          beg end 'face
1661          (setq face (if (boundp face) (symbol-value face) face)))
1662         (gnus-extent-start-open beg)))
1663     (goto-char p)))
1664
1665 (defun gnus-group-update-group (group &optional visible-only)
1666   "Update all lines where GROUP appear.
1667 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1668 already."
1669   ;; Can't use `save-excursion' here, so we do it manually.
1670   (let ((buf (current-buffer))
1671         mark)
1672     (set-buffer gnus-group-buffer)
1673     (setq mark (point-marker))
1674     ;; The buffer may be narrowed.
1675     (save-restriction
1676       (widen)
1677       (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1678             (loc (point-min))
1679             found buffer-read-only)
1680         ;; Enter the current status into the dribble buffer.
1681         (let ((entry (gnus-group-entry group)))
1682           (when (and entry
1683                      (not (gnus-ephemeral-group-p group)))
1684             (gnus-dribble-enter
1685              (concat "(gnus-group-set-info '"
1686                      (gnus-prin1-to-string (nth 2 entry))
1687                      ")"))))
1688         ;; Find all group instances.  If topics are in use, each group
1689         ;; may be listed in more than once.
1690         (while (setq loc (text-property-any
1691                           loc (point-max) 'gnus-group ident))
1692           (setq found t)
1693           (goto-char loc)
1694           (let ((gnus-group-indentation (gnus-group-group-indentation)))
1695             (gnus-delete-line)
1696             (gnus-group-insert-group-line-info group)
1697             (save-excursion
1698               (forward-line -1)
1699               (gnus-run-hooks 'gnus-group-update-group-hook)))
1700           (setq loc (1+ loc)))
1701         (unless (or found visible-only)
1702           ;; No such line in the buffer, find out where it's supposed to
1703           ;; go, and insert it there (or at the end of the buffer).
1704           (if gnus-goto-missing-group-function
1705               (funcall gnus-goto-missing-group-function group)
1706             (let ((entry (cddr (gnus-group-entry group))))
1707               (while (and entry (car entry)
1708                           (not
1709                            (gnus-goto-char
1710                             (text-property-any
1711                              (point-min) (point-max)
1712                              'gnus-group (gnus-intern-safe
1713                                           (caar entry) gnus-active-hashtb)))))
1714                 (setq entry (cdr entry)))
1715               (or entry (goto-char (point-max)))))
1716           ;; Finally insert the line.
1717           (let ((gnus-group-indentation (gnus-group-group-indentation)))
1718             (gnus-group-insert-group-line-info group)
1719             (save-excursion
1720               (forward-line -1)
1721               (gnus-run-hooks 'gnus-group-update-group-hook))))
1722         (when gnus-group-update-group-function
1723           (funcall gnus-group-update-group-function group))
1724         (gnus-group-set-mode-line)))
1725     (goto-char mark)
1726     (set-marker mark nil)
1727     (set-buffer buf)))
1728
1729 (defun gnus-group-set-mode-line ()
1730   "Update the mode line in the group buffer."
1731   (when (memq 'group gnus-updated-mode-lines)
1732     ;; Yes, we want to keep this mode line updated.
1733     (save-excursion
1734       (set-buffer gnus-group-buffer)
1735       (let* ((gformat (or gnus-group-mode-line-format-spec
1736                           (gnus-set-format 'group-mode)))
1737              (gnus-tmp-news-server (cadr gnus-select-method))
1738              (gnus-tmp-news-method (car gnus-select-method))
1739              (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1740              (max-len 60)
1741              gnus-tmp-header            ;Dummy binding for user-defined formats
1742              ;; Get the resulting string.
1743              (modified
1744               (and gnus-dribble-buffer
1745                    (buffer-name gnus-dribble-buffer)
1746                    (buffer-modified-p gnus-dribble-buffer)
1747                    (save-excursion
1748                      (set-buffer gnus-dribble-buffer)
1749                      (not (zerop (buffer-size))))))
1750              (mode-string (eval gformat)))
1751         ;; Say whether the dribble buffer has been modified.
1752         (setq mode-line-modified
1753               (if modified (car gnus-mode-line-modified)
1754                 (cdr gnus-mode-line-modified)))
1755         ;; If the line is too long, we chop it off.
1756         (when (> (length mode-string) max-len)
1757           (setq mode-string (substring mode-string 0 (- max-len 4))))
1758         (prog1
1759             (setq mode-line-buffer-identification
1760                   (gnus-mode-line-buffer-identification
1761                    (list mode-string)))
1762           (set-buffer-modified-p modified))))))
1763
1764 (defun gnus-group-group-name ()
1765   "Get the name of the newsgroup on the current line."
1766   (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1767     (when group
1768       (symbol-name group))))
1769
1770 (defun gnus-group-group-level ()
1771   "Get the level of the newsgroup on the current line."
1772   (get-text-property (point-at-bol) 'gnus-level))
1773
1774 (defun gnus-group-group-indentation ()
1775   "Get the indentation of the newsgroup on the current line."
1776   (or (get-text-property (point-at-bol) 'gnus-indentation)
1777       (and gnus-group-indentation-function
1778            (funcall gnus-group-indentation-function))
1779       ""))
1780
1781 (defun gnus-group-group-unread ()
1782   "Get the number of unread articles of the newsgroup on the current line."
1783   (get-text-property (point-at-bol) 'gnus-unread))
1784
1785 (defun gnus-group-new-mail (group)
1786   (if (nnmail-new-mail-p (gnus-group-real-name group))
1787       gnus-new-mail-mark
1788     ? ))
1789
1790 (defun gnus-group-level (group)
1791   "Return the estimated level of GROUP."
1792   (or (gnus-info-level (gnus-get-info group))
1793       (and (member group gnus-zombie-list) gnus-level-zombie)
1794       gnus-level-killed))
1795
1796 (defun gnus-group-search-forward (&optional backward all level first-too)
1797   "Find the next newsgroup with unread articles.
1798 If BACKWARD is non-nil, find the previous newsgroup instead.
1799 If ALL is non-nil, just find any newsgroup.
1800 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1801 group exists.
1802 If FIRST-TOO, the current line is also eligible as a target."
1803   (let ((way (if backward -1 1))
1804         (low gnus-level-killed)
1805         (beg (point))
1806         pos found lev)
1807     (if (and backward (progn (beginning-of-line)) (bobp))
1808         nil
1809       (unless first-too
1810         (forward-line way))
1811       (while (and
1812               (not (eobp))
1813               (not (setq
1814                     found
1815                     (and
1816                      (get-text-property (point) 'gnus-group)
1817                      (or all
1818                          (and
1819                           (let ((unread
1820                                  (get-text-property (point) 'gnus-unread)))
1821                             (and (numberp unread) (> unread 0)))
1822                           (setq lev (get-text-property (point)
1823                                                        'gnus-level))
1824                           (<= lev gnus-level-subscribed)))
1825                      (or (not level)
1826                          (and (setq lev (get-text-property (point)
1827                                                            'gnus-level))
1828                               (or (= lev level)
1829                                   (and (< lev low)
1830                                        (< level lev)
1831                                        (progn
1832                                          (setq low lev)
1833                                          (setq pos (point))
1834                                          nil))))))))
1835               (zerop (forward-line way)))))
1836     (if found
1837         (progn (gnus-group-position-point) t)
1838       (goto-char (or pos beg))
1839       (and pos t))))
1840
1841 (defun gnus-total-fetched-for (group)
1842   (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1843          (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1844          (size (+ size-in-cache size-in-agent))
1845          (suffix '("B" "K" "M" "G"))
1846          (scale 1024.0)
1847          (cutoff scale))
1848     (while (> size cutoff)
1849       (setq size (/ size scale)
1850             suffix (cdr suffix)))
1851     (format "%5.1f%s" size (car suffix))))
1852
1853 ;;; Gnus group mode commands
1854
1855 ;; Group marking.
1856
1857 (defun gnus-group-mark-line-p ()
1858   (save-excursion
1859     (beginning-of-line)
1860     (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1861     (eq (char-after) gnus-process-mark)))
1862
1863 (defun gnus-group-mark-group (n &optional unmark no-advance)
1864   "Mark the current group."
1865   (interactive "p")
1866   (let ((buffer-read-only nil)
1867         group)
1868     (while (and (> n 0)
1869                 (not (eobp)))
1870       (when (setq group (gnus-group-group-name))
1871         ;; Go to the mark position.
1872         (beginning-of-line)
1873         (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1874         (delete-char 1)
1875         (if unmark
1876             (progn
1877               (setq gnus-group-marked (delete group gnus-group-marked))
1878               (insert-char ? 1 t))
1879            (setq gnus-group-marked
1880                  (cons group (delete group gnus-group-marked)))
1881            (insert-char gnus-process-mark 1 t)))
1882       (unless no-advance
1883         (gnus-group-next-group 1))
1884       (decf n))
1885     (gnus-summary-position-point)
1886     n))
1887
1888 (defun gnus-group-unmark-group (n)
1889   "Remove the mark from the current group."
1890   (interactive "p")
1891   (gnus-group-mark-group n 'unmark)
1892   (gnus-group-position-point))
1893
1894 (defun gnus-group-unmark-all-groups ()
1895   "Unmark all groups."
1896   (interactive)
1897   (save-excursion
1898     (mapc 'gnus-group-remove-mark gnus-group-marked))
1899   (gnus-group-position-point))
1900
1901 (defun gnus-group-mark-region (unmark beg end)
1902   "Mark all groups between point and mark.
1903 If UNMARK, remove the mark instead."
1904   (interactive "P\nr")
1905   (let ((num (count-lines beg end)))
1906     (save-excursion
1907       (goto-char beg)
1908       (- num (gnus-group-mark-group num unmark)))))
1909
1910 (defun gnus-group-mark-buffer (&optional unmark)
1911   "Mark all groups in the buffer.
1912 If UNMARK, remove the mark instead."
1913   (interactive "P")
1914   (gnus-group-mark-region unmark (point-min) (point-max)))
1915
1916 (defun gnus-group-mark-regexp (regexp)
1917   "Mark all groups that match some regexp."
1918   (interactive "sMark (regexp): ")
1919   (let ((alist (cdr gnus-newsrc-alist))
1920         group)
1921     (save-excursion
1922       (while alist
1923         (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1924           (gnus-group-jump-to-group group)
1925           (gnus-group-set-mark group)))))
1926   (gnus-group-position-point))
1927
1928 (defun gnus-group-remove-mark (group &optional test-marked)
1929   "Remove the process mark from GROUP and move point there.
1930 Return nil if the group isn't displayed."
1931   (if (gnus-group-goto-group group nil test-marked)
1932       (save-excursion
1933         (gnus-group-mark-group 1 'unmark t)
1934         t)
1935     (setq gnus-group-marked
1936           (delete group gnus-group-marked))
1937     nil))
1938
1939 (defun gnus-group-set-mark (group)
1940   "Set the process mark on GROUP."
1941   (if (gnus-group-goto-group group)
1942       (save-excursion
1943         (gnus-group-mark-group 1 nil t))
1944     (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1945
1946 (defun gnus-group-universal-argument (arg &optional groups func)
1947   "Perform any command on all groups according to the process/prefix convention."
1948   (interactive "P")
1949   (if (eq (setq func (or func
1950                          (key-binding
1951                           (read-key-sequence
1952                            (substitute-command-keys
1953                             "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1954           'undefined)
1955       (gnus-error 1 "Undefined key")
1956     (gnus-group-iterate arg
1957       (lambda (group)
1958         (command-execute func))))
1959   (gnus-group-position-point))
1960
1961 (defun gnus-group-process-prefix (n)
1962   "Return a list of groups to work on.
1963 Take into consideration N (the prefix) and the list of marked groups."
1964   (cond
1965    (n
1966     (setq n (prefix-numeric-value n))
1967     ;; There is a prefix, so we return a list of the N next
1968     ;; groups.
1969     (let ((way (if (< n 0) -1 1))
1970           (n (abs n))
1971           group groups)
1972       (save-excursion
1973         (while (> n 0)
1974           (if (setq group (gnus-group-group-name))
1975               (push group groups))
1976           (setq n (1- n))
1977           (gnus-group-next-group way)))
1978       (nreverse groups)))
1979    ((and (gnus-region-active-p) (mark))
1980     ;; Work on the region between point and mark.
1981     (let ((max (max (point) (mark)))
1982           groups)
1983       (save-excursion
1984         (goto-char (min (point) (mark)))
1985         (while
1986             (and
1987              (push (gnus-group-group-name) groups)
1988              (zerop (gnus-group-next-group 1))
1989              (< (point) max)))
1990         (nreverse groups))))
1991    (gnus-group-marked
1992     ;; No prefix, but a list of marked articles.
1993     (reverse gnus-group-marked))
1994    (t
1995     ;; Neither marked articles or a prefix, so we return the
1996     ;; current group.
1997     (let ((group (gnus-group-group-name)))
1998       (and group (list group))))))
1999
2000 ;;; !!!Surely gnus-group-iterate should be a macro instead?  I can't
2001 ;;; imagine why I went through these contortions...
2002 (eval-and-compile
2003   (let ((function (make-symbol "gnus-group-iterate-function"))
2004         (window (make-symbol "gnus-group-iterate-window"))
2005         (groups (make-symbol "gnus-group-iterate-groups"))
2006         (group (make-symbol "gnus-group-iterate-group")))
2007     (eval
2008      `(defun gnus-group-iterate (arg ,function)
2009         "Iterate FUNCTION over all process/prefixed groups.
2010 FUNCTION will be called with the group name as the parameter
2011 and with point over the group in question."
2012         (let ((,groups (gnus-group-process-prefix arg))
2013               (,window (selected-window))
2014               ,group)
2015           (while ,groups
2016             (setq ,group (car ,groups)
2017                   ,groups (cdr ,groups))
2018             (select-window ,window)
2019             (gnus-group-remove-mark ,group)
2020             (save-selected-window
2021               (save-excursion
2022                 (funcall ,function ,group)))))))))
2023
2024 (put 'gnus-group-iterate 'lisp-indent-function 1)
2025
2026 ;; Selecting groups.
2027
2028 (defun gnus-group-read-group (&optional all no-article group select-articles)
2029   "Read news in this newsgroup.
2030 If the prefix argument ALL is non-nil, already read articles become
2031 readable.  IF ALL is a number, fetch this number of articles.  If the
2032 optional argument NO-ARTICLE is non-nil, no article will be
2033 auto-selected upon group entry.  If GROUP is non-nil, fetch that
2034 group."
2035   (interactive "P")
2036   (let ((no-display (eq all 0))
2037         (group (or group (gnus-group-group-name)))
2038         number active marked entry)
2039     (when (eq all 0)
2040       (setq all nil))
2041     (unless group
2042       (error "No group on current line"))
2043     (setq marked (gnus-info-marks
2044                   (nth 2 (setq entry (gnus-group-entry group)))))
2045     ;; This group might be a dead group.  In that case we have to get
2046     ;; the number of unread articles from `gnus-active-hashtb'.
2047     (setq number
2048           (cond ((numberp all) all)
2049                 (entry (car entry))
2050                 ((setq active (gnus-active group))
2051                  (- (1+ (cdr active)) (car active)))))
2052     (gnus-summary-read-group
2053      group (or all (and (numberp number)
2054                         (zerop (+ number (gnus-range-length
2055                                           (cdr (assq 'tick marked)))
2056                                   (gnus-range-length
2057                                    (cdr (assq 'dormant marked)))))))
2058      no-article nil no-display nil select-articles)))
2059
2060 (defun gnus-group-select-group (&optional all)
2061   "Select this newsgroup.
2062 No article is selected automatically.
2063 If the group is opened, just switch the summary buffer.
2064 If ALL is non-nil, already read articles become readable.
2065 If ALL is a positive number, fetch this number of the latest
2066 articles in the group.
2067 If ALL is a negative number, fetch this number of the earliest
2068 articles in the group."
2069   (interactive "P")
2070   (when (and (eobp) (not (gnus-group-group-name)))
2071     (forward-line -1))
2072   (gnus-group-read-group all t))
2073
2074 (defun gnus-group-quick-select-group (&optional all group)
2075   "Select the GROUP \"quickly\".
2076 This means that no highlighting or scoring will be performed.  If
2077 ALL (the prefix argument) is 0, don't even generate the summary
2078 buffer.  If GROUP is nil, use current group.
2079
2080 This might be useful if you want to toggle threading
2081 before entering the group."
2082   (interactive "P")
2083   (require 'gnus-score)
2084   (let (gnus-visual
2085         gnus-score-find-score-files-function
2086         gnus-home-score-file
2087         gnus-apply-kill-hook
2088         gnus-summary-expunge-below)
2089     (gnus-group-read-group all t group)))
2090
2091 (defun gnus-group-visible-select-group (&optional all)
2092   "Select the current group without hiding any articles."
2093   (interactive "P")
2094   (let ((gnus-inhibit-limiting t))
2095     (gnus-group-read-group all t)))
2096
2097 (defun gnus-group-select-group-ephemerally ()
2098   "Select the current group without doing any processing whatsoever.
2099 You will actually be entered into a group that's a copy of
2100 the current group; no changes you make while in this group will
2101 be permanent."
2102   (interactive)
2103   (require 'gnus-score)
2104   (let* (gnus-visual
2105          gnus-score-find-score-files-function gnus-apply-kill-hook
2106          gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2107          gnus-summary-mode-hook gnus-select-group-hook
2108          (group (gnus-group-group-name))
2109          (method (gnus-find-method-for-group group)))
2110     (gnus-group-read-ephemeral-group
2111      (gnus-group-prefixed-name group method) method)))
2112
2113 (defun group-name-at-point ()
2114   (let ((regexp "[^-a-zA-Z+.:_]"))
2115     (save-excursion
2116       (buffer-substring
2117        (progn
2118          (re-search-backward regexp nil t)
2119          (forward-char 1)
2120          (point))
2121        (progn
2122          (re-search-forward regexp nil t)
2123          (forward-char -1)
2124          (point))))))
2125
2126 ;;;###autoload
2127 (defun gnus-fetch-group (group &optional articles)
2128   "Start Gnus if necessary and enter GROUP.
2129 If ARTICLES, display those articles.
2130 Returns whether the fetching was successful or not."
2131   (interactive (list (completing-read "Group name: " gnus-active-hashtb
2132                                       nil nil nil nil
2133                                       (group-name-at-point))))
2134   (unless (get-buffer gnus-group-buffer)
2135     (gnus-no-server))
2136   (gnus-group-read-group (if articles nil t) nil group articles))
2137
2138 ;;;###autoload
2139 (defun gnus-fetch-group-other-frame (group)
2140   "Pop up a frame and enter GROUP."
2141   (interactive "P")
2142   (let ((window (get-buffer-window gnus-group-buffer)))
2143     (cond (window
2144            (select-frame (window-frame window)))
2145           ((= (length (frame-list)) 1)
2146            (select-frame (make-frame)))
2147           (t
2148            (other-frame 1))))
2149   (gnus-fetch-group group))
2150
2151 (defvar gnus-ephemeral-group-server 0)
2152
2153 (defcustom gnus-large-ephemeral-newsgroup 200
2154   "The number of articles which indicates a large ephemeral newsgroup.
2155 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2156
2157 If the number of articles in a newsgroup is greater than this value,
2158 confirmation is required for selecting the newsgroup.  If it is nil, no
2159 confirmation is required."
2160   :version "22.1"
2161   :group 'gnus-group-select
2162   :type '(choice (const :tag "No limit" nil)
2163                  integer))
2164
2165 (defcustom gnus-fetch-old-ephemeral-headers nil
2166   "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2167   :version "22.1"
2168   :group 'gnus-thread
2169   :type '(choice (const :tag "off" nil)
2170                  (const some)
2171                  number
2172                  (sexp :menu-tag "other" t)))
2173
2174 ;; Enter a group that is not in the group buffer.  Non-nil is returned
2175 ;; if selection was successful.
2176 (defun gnus-group-read-ephemeral-group (group method &optional activate
2177                                               quit-config request-only
2178                                               select-articles
2179                                               parameters
2180                                               number)
2181   "Read GROUP from METHOD as an ephemeral group.
2182 If ACTIVATE, request the group first.
2183 If QUIT-CONFIG, use that window configuration when exiting from the
2184 ephemeral group.
2185 If REQUEST-ONLY, don't actually read the group; just request it.
2186 If SELECT-ARTICLES, only select those articles.
2187 If PARAMETERS, use those as the group parameters.
2188 If NUMBER, fetch this number of articles.
2189
2190 Return the name of the group if selection was successful."
2191   (interactive
2192    (list
2193     ;; (gnus-read-group "Group name: ")
2194     (completing-read
2195      "Group: " gnus-active-hashtb
2196      nil nil nil
2197      'gnus-group-history)
2198     (gnus-read-method "From method: ")))
2199   ;; Transform the select method into a unique server.
2200   (when (stringp method)
2201     (setq method (gnus-server-to-method method)))
2202   (setq method
2203         `(,(car method) ,(concat (cadr method) "-ephemeral")
2204           (,(intern (format "%s-address" (car method))) ,(cadr method))
2205           ,@(cddr method)))
2206   (let ((group (if (gnus-group-foreign-p group) group
2207                  (gnus-group-prefixed-name (gnus-group-real-name group)
2208                                            method))))
2209     (gnus-sethash
2210      group
2211      `(-1 nil (,group
2212                ,gnus-level-default-subscribed nil nil ,method
2213                ,(cons
2214                  (if quit-config
2215                      (cons 'quit-config quit-config)
2216                    (cons 'quit-config
2217                          (cons gnus-summary-buffer
2218                                gnus-current-window-configuration)))
2219                  parameters)))
2220      gnus-newsrc-hashtb)
2221     (push method gnus-ephemeral-servers)
2222     (set-buffer gnus-group-buffer)
2223     (unless (gnus-check-server method)
2224       (error "Unable to contact server: %s" (gnus-status-message method)))
2225     (when activate
2226       (gnus-activate-group group 'scan)
2227       (unless (gnus-request-group group)
2228         (error "Couldn't request group: %s"
2229                (nnheader-get-report (car method)))))
2230     (if request-only
2231         group
2232       (condition-case ()
2233           (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2234                       (gnus-fetch-old-headers
2235                        gnus-fetch-old-ephemeral-headers))
2236                   (gnus-group-read-group (or number t) t group select-articles))
2237             group)
2238         ;;(error nil)
2239         (quit
2240          (message "Quit reading the ephemeral group")
2241          nil)))))
2242
2243 (defun gnus-group-jump-to-group (group &optional prompt)
2244   "Jump to newsgroup GROUP.
2245
2246 If PROMPT (the prefix) is a number, use the prompt specified in
2247 `gnus-group-jump-to-group-prompt'."
2248   (interactive
2249    (list (mm-string-make-unibyte
2250           (completing-read
2251            "Group: " gnus-active-hashtb nil
2252            (gnus-read-active-file-p)
2253            (if current-prefix-arg
2254                (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2255              (or (and (stringp gnus-group-jump-to-group-prompt)
2256                       gnus-group-jump-to-group-prompt)
2257                  (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2258                    (and (stringp p) p))))
2259            'gnus-group-history))))
2260
2261   (when (equal group "")
2262     (error "Empty group name"))
2263
2264   (unless (gnus-ephemeral-group-p group)
2265     ;; Either go to the line in the group buffer...
2266     (unless (gnus-group-goto-group group)
2267       ;; ... or insert the line.
2268       (gnus-group-update-group group)
2269       (gnus-group-goto-group group)))
2270   ;; Adjust cursor point.
2271   (gnus-group-position-point))
2272
2273 (defun gnus-group-goto-group (group &optional far test-marked)
2274   "Goto to newsgroup GROUP.
2275 If FAR, it is likely that the group is not on the current line.
2276 If TEST-MARKED, the line must be marked."
2277   (when group
2278     (beginning-of-line)
2279     (cond
2280      ;; It's quite likely that we are on the right line, so
2281      ;; we check the current line first.
2282      ((and (not far)
2283            (eq (get-text-property (point) 'gnus-group)
2284                (gnus-intern-safe group gnus-active-hashtb))
2285            (or (not test-marked) (gnus-group-mark-line-p)))
2286       (point))
2287      ;; Previous and next line are also likely, so we check them as well.
2288      ((and (not far)
2289            (save-excursion
2290              (forward-line -1)
2291              (and (eq (get-text-property (point) 'gnus-group)
2292                       (gnus-intern-safe group gnus-active-hashtb))
2293                   (or (not test-marked) (gnus-group-mark-line-p)))))
2294       (forward-line -1)
2295       (point))
2296      ((and (not far)
2297            (save-excursion
2298              (forward-line 1)
2299              (and (eq (get-text-property (point) 'gnus-group)
2300                       (gnus-intern-safe group gnus-active-hashtb))
2301                   (or (not test-marked) (gnus-group-mark-line-p)))))
2302       (forward-line 1)
2303       (point))
2304      (test-marked
2305       (goto-char (point-min))
2306       (let (found)
2307         (while (and (not found)
2308                     (gnus-goto-char
2309                      (text-property-any
2310                       (point) (point-max)
2311                       'gnus-group
2312                       (gnus-intern-safe group gnus-active-hashtb))))
2313           (if (gnus-group-mark-line-p)
2314               (setq found t)
2315             (forward-line 1)))
2316         found))
2317      (t
2318       ;; Search through the entire buffer.
2319       (gnus-goto-char
2320        (text-property-any
2321         (point-min) (point-max)
2322         'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2323
2324 (defun gnus-group-next-group (n &optional silent)
2325   "Go to next N'th newsgroup.
2326 If N is negative, search backward instead.
2327 Returns the difference between N and the number of skips actually
2328 done."
2329   (interactive "p")
2330   (gnus-group-next-unread-group n t nil silent))
2331
2332 (defun gnus-group-next-unread-group (n &optional all level silent)
2333   "Go to next N'th unread newsgroup.
2334 If N is negative, search backward instead.
2335 If ALL is non-nil, choose any newsgroup, unread or not.
2336 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2337 such group can be found, the next group with a level higher than
2338 LEVEL.
2339 Returns the difference between N and the number of skips actually
2340 made."
2341   (interactive "p")
2342   (let ((backward (< n 0))
2343         (n (abs n)))
2344     (while (and (> n 0)
2345                 (gnus-group-search-forward
2346                  backward (or (not gnus-group-goto-unread) all) level))
2347       (setq n (1- n)))
2348     (when (and (/= 0 n)
2349                (not silent))
2350       (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2351                     (if level " on this level or higher" "")))
2352     n))
2353
2354 (defun gnus-group-prev-group (n)
2355   "Go to previous N'th newsgroup.
2356 Returns the difference between N and the number of skips actually
2357 done."
2358   (interactive "p")
2359   (gnus-group-next-unread-group (- n) t))
2360
2361 (defun gnus-group-prev-unread-group (n)
2362   "Go to previous N'th unread newsgroup.
2363 Returns the difference between N and the number of skips actually
2364 done."
2365   (interactive "p")
2366   (gnus-group-next-unread-group (- n)))
2367
2368 (defun gnus-group-next-unread-group-same-level (n)
2369   "Go to next N'th unread newsgroup on the same level.
2370 If N is negative, search backward instead.
2371 Returns the difference between N and the number of skips actually
2372 done."
2373   (interactive "p")
2374   (gnus-group-next-unread-group n t (gnus-group-group-level))
2375   (gnus-group-position-point))
2376
2377 (defun gnus-group-prev-unread-group-same-level (n)
2378   "Go to next N'th unread newsgroup on the same level.
2379 Returns the difference between N and the number of skips actually
2380 done."
2381   (interactive "p")
2382   (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2383   (gnus-group-position-point))
2384
2385 (defun gnus-group-best-unread-group (&optional exclude-group)
2386   "Go to the group with the highest level.
2387 If EXCLUDE-GROUP, do not go to that group."
2388   (interactive)
2389   (goto-char (point-min))
2390   (let ((best 100000)
2391         unread best-point)
2392     (while (not (eobp))
2393       (setq unread (get-text-property (point) 'gnus-unread))
2394       (when (and (numberp unread) (> unread 0))
2395         (when (and (get-text-property (point) 'gnus-level)
2396                    (< (get-text-property (point) 'gnus-level) best)
2397                    (or (not exclude-group)
2398                        (not (equal exclude-group (gnus-group-group-name)))))
2399           (setq best (get-text-property (point) 'gnus-level))
2400           (setq best-point (point))))
2401       (forward-line 1))
2402     (when best-point
2403       (goto-char best-point))
2404     (gnus-group-position-point)
2405     (and best-point (gnus-group-group-name))))
2406
2407 ;; Is there something like an after-point-motion-hook?
2408 ;; (inhibit-point-motion-hooks?).  Is there a tool-bar-update function?
2409
2410 ;; (defun gnus-group-menu-bar-update ()
2411 ;;   (let* ((buf (list (with-current-buffer gnus-group-buffer
2412 ;;                    (current-buffer))))
2413 ;;       (name (buffer-name (car buf))))
2414 ;;     (setcdr buf
2415 ;;          (if (> (length name) 27)
2416 ;;              (concat (substring name 0 12)
2417 ;;                      "..."
2418 ;;                      (substring name -12))
2419 ;;            name))
2420 ;;     (menu-bar-update-buffers-1 buf)))
2421
2422 ;; (defun gnus-group-position-point ()
2423 ;;   (gnus-goto-colon)
2424 ;;   (gnus-group-menu-bar-update))
2425
2426 (defun gnus-group-first-unread-group ()
2427   "Go to the first group with unread articles."
2428   (interactive)
2429   (prog1
2430       (let ((opoint (point))
2431             unread)
2432         (goto-char (point-min))
2433         (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2434                 (and (numberp unread)   ; Not a topic.
2435                      (not (zerop unread))) ; Has unread articles.
2436                 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2437             (point)                     ; Success.
2438           (goto-char opoint)
2439           nil))                         ; Not success.
2440     (gnus-group-position-point)))
2441
2442 (defun gnus-group-enter-server-mode ()
2443   "Jump to the server buffer."
2444   (interactive)
2445   (gnus-enter-server-buffer))
2446
2447 (defun gnus-group-make-group-simple (&optional group)
2448   "Add a new newsgroup.
2449 The user will be prompted for GROUP."
2450   (interactive
2451    (list (completing-read "Group: " gnus-active-hashtb
2452                           nil nil nil 'gnus-group-history)))
2453   (gnus-group-make-group
2454    (gnus-group-real-name group)
2455    (gnus-group-server group)))
2456
2457 (defun gnus-group-make-group (name &optional method address args)
2458   "Add a new newsgroup.
2459 The user will be prompted for a NAME, for a select METHOD, and an
2460 ADDRESS."
2461   (interactive
2462    (list
2463     (gnus-read-group "Group name: ")
2464     (gnus-read-method "From method: ")))
2465
2466   (when (stringp method)
2467     (setq method (or (gnus-server-to-method method) method)))
2468   (let* ((meth (gnus-method-simplify
2469                 (when (and method
2470                            (not (gnus-server-equal method gnus-select-method)))
2471                   (if address (list (intern method) address)
2472                     method))))
2473          (nname (if method (gnus-group-prefixed-name name meth) name))
2474          backend info)
2475     (when (gnus-group-entry nname)
2476       (error "Group %s already exists" (gnus-group-decoded-name nname)))
2477     ;; Subscribe to the new group.
2478     (gnus-group-change-level
2479      (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2480      gnus-level-default-subscribed gnus-level-killed
2481      (and (gnus-group-group-name)
2482           (gnus-group-entry (gnus-group-group-name)))
2483      t)
2484     ;; Make it active.
2485     (gnus-set-active nname (cons 1 0))
2486     (unless (gnus-ephemeral-group-p name)
2487       (gnus-dribble-enter
2488        (concat "(gnus-group-set-info '"
2489                (gnus-prin1-to-string (cdr info)) ")")))
2490     ;; Insert the line.
2491     (gnus-group-insert-group-line-info nname)
2492     (forward-line -1)
2493     (gnus-group-position-point)
2494
2495     ;; Load the back end and try to make the back end create
2496     ;; the group as well.
2497     (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2498                                                   nil meth))))
2499                  gnus-valid-select-methods)
2500       (require backend))
2501     (gnus-check-server meth)
2502     (when (gnus-check-backend-function 'request-create-group nname)
2503       (unless (gnus-request-create-group nname nil args)
2504         (error "Could not create group on server: %s"
2505                (nnheader-get-report backend))))
2506     t))
2507
2508 (defun gnus-group-delete-groups (&optional arg)
2509   "Delete the current group.  Only meaningful with editable groups."
2510   (interactive "P")
2511   (let ((n (length (gnus-group-process-prefix arg))))
2512     (when (gnus-yes-or-no-p
2513            (if (= n 1)
2514                "Delete this 1 group? "
2515              (format "Delete these %d groups? " n)))
2516       (gnus-group-iterate arg
2517         (lambda (group)
2518           (gnus-group-delete-group group nil t))))))
2519
2520 (defun gnus-group-delete-group (group &optional force no-prompt)
2521   "Delete the current group.  Only meaningful with editable groups.
2522 If FORCE (the prefix) is non-nil, all the articles in the group will
2523 be deleted.  This is \"deleted\" as in \"removed forever from the face
2524 of the Earth\".  There is no undo.  The user will be prompted before
2525 doing the deletion.
2526 Note that you also have to specify FORCE if you want the group to
2527 be removed from the server, even when it's empty."
2528   (interactive
2529    (list (gnus-group-group-name)
2530          current-prefix-arg))
2531   (unless group
2532     (error "No group to delete"))
2533   (unless (gnus-check-backend-function 'request-delete-group group)
2534     (error "This back end does not support group deletion"))
2535   (prog1
2536       (let ((group-decoded (gnus-group-decoded-name group)))
2537         (if (and (not no-prompt)
2538                  (not (gnus-yes-or-no-p
2539                        (format
2540                         "Do you really want to delete %s%s? "
2541                         group-decoded (if force " and all its contents" "")))))
2542             ()                          ; Whew!
2543           (gnus-message 6 "Deleting group %s..." group-decoded)
2544           (if (not (gnus-request-delete-group group force))
2545               (gnus-error 3 "Couldn't delete group %s" group-decoded)
2546             (gnus-message 6 "Deleting group %s...done" group-decoded)
2547             (gnus-group-goto-group group)
2548             (gnus-group-kill-group 1 t)
2549             (gnus-set-active group nil)
2550             t)))
2551     (gnus-group-position-point)))
2552
2553 (defun gnus-group-rename-group (group new-name)
2554   "Rename group from GROUP to NEW-NAME.
2555 When used interactively, GROUP is the group under point
2556 and NEW-NAME will be prompted for."
2557   (interactive
2558    (list
2559     (gnus-group-group-name)
2560     (progn
2561       (unless (gnus-check-backend-function
2562                'request-rename-group (gnus-group-group-name))
2563         (error "This back end does not support renaming groups"))
2564       (gnus-read-group "Rename group to: "
2565                        (gnus-group-real-name (gnus-group-group-name))))))
2566
2567   (unless (gnus-check-backend-function 'request-rename-group group)
2568     (error "This back end does not support renaming groups"))
2569   (unless group
2570     (error "No group to rename"))
2571   (when (equal (gnus-group-real-name group) new-name)
2572     (error "Can't rename to the same name"))
2573
2574   ;; We find the proper prefixed name.
2575   (setq new-name
2576         (if (gnus-group-native-p group)
2577             ;; Native group.
2578             new-name
2579           ;; Foreign group.
2580           (gnus-group-prefixed-name
2581            (gnus-group-real-name new-name)
2582            (gnus-info-method (gnus-get-info group)))))
2583
2584   (when (gnus-active new-name)
2585     (error "The group %s already exists" new-name))
2586
2587   (gnus-message 6 "Renaming group %s to %s..." group new-name)
2588   (prog1
2589       (if (progn
2590             (gnus-group-goto-group group)
2591             (not (when (< (gnus-group-group-level) gnus-level-zombie)
2592                    (gnus-request-rename-group group new-name))))
2593           (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2594         ;; We rename the group internally by killing it...
2595         (gnus-group-kill-group)
2596         ;; ... changing its name ...
2597         (setcar (cdar gnus-list-of-killed-groups) new-name)
2598         ;; ... and then yanking it.  Magic!
2599         (gnus-group-yank-group)
2600         (gnus-set-active new-name (gnus-active group))
2601         (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2602         new-name)
2603     (setq gnus-killed-list (delete group gnus-killed-list))
2604     (gnus-set-active group nil)
2605     (gnus-dribble-touch)
2606     (gnus-group-position-point)))
2607
2608 (defun gnus-group-edit-group (group &optional part)
2609   "Edit the group on the current line."
2610   (interactive (list (gnus-group-group-name)))
2611   (let ((part (or part 'info))
2612         info)
2613     (unless group
2614       (error "No group on current line"))
2615     (unless (setq info (gnus-get-info group))
2616       (error "Killed group; can't be edited"))
2617     (ignore-errors
2618       (gnus-close-group group))
2619     (gnus-edit-form
2620      ;; Find the proper form to edit.
2621      (cond ((eq part 'method)
2622             (or (gnus-info-method info) "native"))
2623            ((eq part 'params)
2624             (gnus-info-params info))
2625            (t info))
2626      ;; The proper documentation.
2627      (format
2628       "Editing the %s for `%s'."
2629       (cond
2630        ((eq part 'method) "select method")
2631        ((eq part 'params) "group parameters")
2632        (t "group info"))
2633       (gnus-group-decoded-name group))
2634      `(lambda (form)
2635         (gnus-group-edit-group-done ',part ,group form)))
2636     (local-set-key
2637      "\C-c\C-i"
2638      (gnus-create-info-command
2639       (cond
2640        ((eq part 'method)
2641         "(gnus)Select Methods")
2642        ((eq part 'params)
2643         "(gnus)Group Parameters")
2644        (t
2645         "(gnus)Group Info"))))))
2646
2647 (defun gnus-group-edit-group-method (group)
2648   "Edit the select method of GROUP."
2649   (interactive (list (gnus-group-group-name)))
2650   (gnus-group-edit-group group 'method))
2651
2652 (defun gnus-group-edit-group-parameters (group)
2653   "Edit the group parameters of GROUP."
2654   (interactive (list (gnus-group-group-name)))
2655   (gnus-group-edit-group group 'params))
2656
2657 (defun gnus-group-edit-group-done (part group form)
2658   "Update variables."
2659   (let* ((method (cond ((eq part 'info) (nth 4 form))
2660                        ((eq part 'method) form)
2661                        (t nil)))
2662          (info (cond ((eq part 'info) form)
2663                      ((eq part 'method) (gnus-get-info group))
2664                      (t nil)))
2665          (new-group (if info
2666                         (if (or (not method)
2667                                 (gnus-server-equal
2668                                  gnus-select-method method))
2669                             (gnus-group-real-name (car info))
2670                           (gnus-group-prefixed-name
2671                            (gnus-group-real-name (car info)) method))
2672                       nil)))
2673     (when (and new-group
2674                (not (equal new-group group)))
2675       (when (gnus-group-goto-group group)
2676         (gnus-group-kill-group 1))
2677       (gnus-activate-group new-group))
2678     ;; Set the info.
2679     (if (not (and info new-group))
2680         (gnus-group-set-info form (or new-group group) part)
2681       (setq info (gnus-copy-sequence info))
2682       (setcar info new-group)
2683       (unless (gnus-server-equal method "native")
2684         (unless (nthcdr 3 info)
2685           (nconc info (list nil nil)))
2686         (unless (nthcdr 4 info)
2687           (nconc info (list nil)))
2688         (gnus-info-set-method info method))
2689       (gnus-group-set-info info))
2690     (gnus-group-update-group (or new-group group))
2691     (gnus-group-position-point)))
2692
2693 (defun gnus-group-make-useful-group (group method)
2694   "Create one of the groups described in `gnus-useful-groups'."
2695   (interactive
2696    (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2697                                         nil t)
2698                        gnus-useful-groups)))
2699      (list (cadr entry) (caddr entry))))
2700   (setq method (gnus-copy-sequence method))
2701   (let (entry)
2702     (while (setq entry (memq (assq 'eval method) method))
2703       (setcar entry (eval (cadar entry)))))
2704   (gnus-group-make-group group method))
2705
2706 (defun gnus-group-make-help-group (&optional noerror)
2707   "Create the Gnus documentation group.
2708 Optional argument NOERROR modifies the behavior of this function when the
2709 group already exists:
2710 - if not given, and error is signaled,
2711 - if t, stay silent,
2712 - if anything else, just print a message."
2713   (interactive)
2714   (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2715         (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2716     (if (gnus-group-entry name)
2717         (cond ((eq noerror nil)
2718                (error "Documentation group already exists"))
2719               ((eq noerror t)
2720                ;; stay silent
2721                )
2722               (t
2723                (gnus-message 1 "Documentation group already exists")))
2724       ;; else:
2725       (if (not file)
2726           (gnus-message 1 "Couldn't find doc group")
2727         (gnus-group-make-group
2728          (gnus-group-real-name name)
2729          (list 'nndoc "gnus-help"
2730                (list 'nndoc-address file)
2731                (list 'nndoc-article-type 'mbox))))
2732       ))
2733   (gnus-group-position-point))
2734
2735 (defun gnus-group-make-doc-group (file type)
2736   "Create a group that uses a single file as the source.
2737
2738 If called with a prefix argument, ask for the file type."
2739   (interactive
2740    (list (read-file-name "File name: ")
2741          (and current-prefix-arg 'ask)))
2742   (when (eq type 'ask)
2743     (let ((err "")
2744           char found)
2745       (while (not found)
2746         (message
2747          "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2748          err)
2749         (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2750                           ((= char ?b) 'babyl)
2751                           ((= char ?d) 'digest)
2752                           ((= char ?f) 'forward)
2753                           ((= char ?a) 'mmfd)
2754                           ((= char ?g) 'guess)
2755                           (t (setq err (format "%c unknown. " char))
2756                              nil))))
2757       (setq type found)))
2758   (setq file (expand-file-name file))
2759   (let ((name (gnus-generate-new-group-name
2760                (gnus-group-prefixed-name
2761                 (file-name-nondirectory file) '(nndoc ""))))
2762         (encodable (mm-coding-system-p 'utf-8)))
2763     (gnus-group-make-group
2764      (if encodable
2765          (mm-encode-coding-string (gnus-group-real-name name) 'utf-8)
2766        (gnus-group-real-name name))
2767      (list 'nndoc (if encodable
2768                       (mm-encode-coding-string file 'utf-8)
2769                     file)
2770            (list 'nndoc-address file)
2771            (list 'nndoc-article-type (or type 'guess))))))
2772
2773 (defvar nnweb-type-definition)
2774 (defvar gnus-group-web-type-history nil)
2775 (defvar gnus-group-web-search-history nil)
2776 (defun gnus-group-make-web-group (&optional solid)
2777   "Create an ephemeral nnweb group.
2778 If SOLID (the prefix), create a solid group."
2779   (interactive "P")
2780   (require 'nnweb)
2781   (let* ((group
2782           (if solid (gnus-read-group "Group name: ")
2783             (message-unique-id)))
2784          (default-type (or (car gnus-group-web-type-history)
2785                            (symbol-name (caar nnweb-type-definition))))
2786          (type
2787           (gnus-string-or
2788            (completing-read
2789             (format "Search engine type (default %s): " default-type)
2790             (mapcar (lambda (elem) (list (symbol-name (car elem))))
2791                     nnweb-type-definition)
2792             nil t nil 'gnus-group-web-type-history)
2793            default-type))
2794          (search
2795           (read-string
2796            "Search string: "
2797            (cons (or (car gnus-group-web-search-history) "") 0)
2798            'gnus-group-web-search-history))
2799          (method
2800           `(nnweb ,group (nnweb-search ,search)
2801                   (nnweb-type ,(intern type))
2802                   (nnweb-ephemeral-p t))))
2803     (if solid
2804         (progn
2805           (gnus-pull 'nnweb-ephemeral-p method)
2806           (gnus-group-make-group group method))
2807       (gnus-group-read-ephemeral-group
2808        group method t
2809        (cons (current-buffer)
2810              (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2811
2812 (eval-when-compile
2813   (defvar nnrss-group-alist)
2814   (defun nnrss-discover-feed (arg))
2815   (defun nnrss-save-server-data (arg)))
2816 (defun gnus-group-make-rss-group (&optional url)
2817   "Given a URL, discover if there is an RSS feed.
2818 If there is, use Gnus to create an nnrss group"
2819   (interactive)
2820   (require 'nnrss)
2821   (if (not url)
2822       (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2823   (let ((feedinfo (nnrss-discover-feed url)))
2824     (if feedinfo
2825         (let ((title (gnus-newsgroup-savable-name
2826                       (read-from-minibuffer "Title: "
2827                                             (gnus-newsgroup-savable-name
2828                                              (or (cdr (assoc 'title
2829                                                              feedinfo))
2830                                                  "")))))
2831               (desc  (read-from-minibuffer "Description: "
2832                                            (cdr (assoc 'description
2833                                                        feedinfo))))
2834               (href (cdr (assoc 'href feedinfo)))
2835               (encodable (mm-coding-system-p 'utf-8)))
2836           (when encodable
2837             ;; Unify non-ASCII text.
2838             (setq title (mm-decode-coding-string
2839                          (mm-encode-coding-string title 'utf-8) 'utf-8)))
2840           (gnus-group-make-group (if encodable
2841                                      (mm-encode-coding-string title 'utf-8)
2842                                    title)
2843                                  '(nnrss ""))
2844           (push (list title href desc) nnrss-group-alist)
2845           (nnrss-save-server-data nil))
2846       (error "No feeds found for %s" url))))
2847
2848 (defvar nnwarchive-type-definition)
2849 (defvar gnus-group-warchive-type-history nil)
2850 (defvar gnus-group-warchive-login-history nil)
2851 (defvar gnus-group-warchive-address-history nil)
2852
2853 (defun gnus-group-make-warchive-group ()
2854   "Create a nnwarchive group."
2855   (interactive)
2856   (require 'nnwarchive)
2857   (let* ((group (gnus-read-group "Group name: "))
2858          (default-type (or (car gnus-group-warchive-type-history)
2859                            (symbol-name (caar nnwarchive-type-definition))))
2860          (type
2861           (gnus-string-or
2862            (completing-read
2863             (format "Warchive type (default %s): " default-type)
2864             (mapcar (lambda (elem) (list (symbol-name (car elem))))
2865                     nnwarchive-type-definition)
2866             nil t nil 'gnus-group-warchive-type-history)
2867            default-type))
2868          (address (read-string "Warchive address: "
2869                                nil 'gnus-group-warchive-address-history))
2870          (default-login (or (car gnus-group-warchive-login-history)
2871                             user-mail-address))
2872          (login
2873           (gnus-string-or
2874            (read-string
2875             (format "Warchive login (default %s): " user-mail-address)
2876             default-login 'gnus-group-warchive-login-history)
2877            user-mail-address))
2878          (method
2879           `(nnwarchive ,address
2880                        (nnwarchive-type ,(intern type))
2881                        (nnwarchive-login ,login))))
2882     (gnus-group-make-group group method)))
2883
2884 (defun gnus-group-make-archive-group (&optional all)
2885   "Create the (ding) Gnus archive group of the most recent articles.
2886 Given a prefix, create a full group."
2887   (interactive "P")
2888   (let ((group (gnus-group-prefixed-name
2889                 (if all "ding.archives" "ding.recent") '(nndir ""))))
2890     (when (gnus-group-entry group)
2891       (error "Archive group already exists"))
2892     (gnus-group-make-group
2893      (gnus-group-real-name group)
2894      (list 'nndir (if all "hpc" "edu")
2895            (list 'nndir-directory
2896                  (if all gnus-group-archive-directory
2897                    gnus-group-recent-archive-directory))))
2898     (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2899
2900 (defun gnus-group-make-directory-group (dir)
2901   "Create an nndir group.
2902 The user will be prompted for a directory.  The contents of this
2903 directory will be used as a newsgroup.  The directory should contain
2904 mail messages or news articles in files that have numeric names."
2905   (interactive
2906    (list (read-file-name "Create group from directory: ")))
2907   (unless (file-exists-p dir)
2908     (error "No such directory"))
2909   (unless (file-directory-p dir)
2910     (error "Not a directory"))
2911   (let ((ext "")
2912         (i 0)
2913         group)
2914     (while (or (not group) (gnus-group-entry group))
2915       (setq group
2916             (gnus-group-prefixed-name
2917              (expand-file-name ext dir)
2918              '(nndir "")))
2919       (setq ext (format "<%d>" (setq i (1+ i)))))
2920     (gnus-group-make-group
2921      (gnus-group-real-name group)
2922      (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2923
2924 (defvar nnkiboze-score-file)
2925 (defun gnus-group-make-kiboze-group (group address scores)
2926   "Create an nnkiboze group.
2927 The user will be prompted for a name, a regexp to match groups, and
2928 score file entries for articles to include in the group."
2929   (interactive
2930    (list
2931     (read-string "nnkiboze group name: ")
2932     (read-string "Source groups (regexp): ")
2933     (let ((headers (mapcar 'list
2934                            '("subject" "from" "number" "date" "message-id"
2935                              "references" "chars" "lines" "xref"
2936                              "followup" "all" "body" "head")))
2937           scores header regexp regexps)
2938       (while (not (equal "" (setq header (completing-read
2939                                           "Match on header: " headers nil t))))
2940         (setq regexps nil)
2941         (while (not (equal "" (setq regexp (read-string
2942                                             (format "Match on %s (regexp): "
2943                                                     header)))))
2944           (push (list regexp nil nil 'r) regexps))
2945         (push (cons header regexps) scores))
2946       scores)))
2947   (gnus-group-make-group group "nnkiboze" address)
2948   (let* ((nnkiboze-current-group group)
2949          (score-file (car (nnkiboze-score-file "")))
2950          (score-dir (file-name-directory score-file)))
2951     (unless (file-exists-p score-dir)
2952       (make-directory score-dir))
2953     (with-temp-file score-file
2954       (let (emacs-lisp-mode-hook)
2955         (gnus-pp scores)))))
2956
2957 (defun gnus-group-add-to-virtual (n vgroup)
2958   "Add the current group to a virtual group."
2959   (interactive
2960    (list current-prefix-arg
2961          (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2962                           "nnvirtual:")))
2963   (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2964     (error "%s is not an nnvirtual group" vgroup))
2965   (gnus-close-group vgroup)
2966   (let* ((groups (gnus-group-process-prefix n))
2967          (method (gnus-info-method (gnus-get-info vgroup))))
2968     (setcar (cdr method)
2969             (concat
2970              (nth 1 method) "\\|"
2971              (mapconcat
2972               (lambda (s)
2973                 (gnus-group-remove-mark s)
2974                 (concat "\\(^" (regexp-quote s) "$\\)"))
2975               groups "\\|"))))
2976   (gnus-group-position-point))
2977
2978 (defun gnus-group-make-empty-virtual (group)
2979   "Create a new, fresh, empty virtual group."
2980   (interactive "sCreate new, empty virtual group: ")
2981   (let* ((method (list 'nnvirtual "^$"))
2982          (pgroup (gnus-group-prefixed-name group method)))
2983     ;; Check whether it exists already.
2984     (when (gnus-group-entry pgroup)
2985       (error "Group %s already exists" pgroup))
2986     ;; Subscribe the new group after the group on the current line.
2987     (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2988     (gnus-group-update-group pgroup)
2989     (forward-line -1)
2990     (gnus-group-position-point)))
2991
2992 (defun gnus-group-enter-directory (dir)
2993   "Enter an ephemeral nneething group."
2994   (interactive "DDirectory to read: ")
2995   (let* ((method (list 'nneething dir '(nneething-read-only t)))
2996          (leaf (gnus-group-prefixed-name
2997                 (file-name-nondirectory (directory-file-name dir))
2998                 method))
2999          (name (gnus-generate-new-group-name leaf)))
3000     (unless (gnus-group-read-ephemeral-group
3001              name method t
3002              (cons (current-buffer)
3003                    (if (eq major-mode 'gnus-summary-mode)
3004                        'summary 'group)))
3005       (error "Couldn't enter %s" dir))))
3006
3007 (eval-and-compile
3008   (autoload 'nnimap-expunge "nnimap")
3009   (autoload 'nnimap-acl-get "nnimap")
3010   (autoload 'nnimap-acl-edit "nnimap"))
3011
3012 (defun gnus-group-nnimap-expunge (group)
3013   "Expunge deleted articles in current nnimap GROUP."
3014   (interactive (list (gnus-group-group-name)))
3015   (let ((mailbox (gnus-group-real-name group)) method)
3016     (unless group
3017       (error "No group on current line"))
3018     (unless (gnus-get-info group)
3019       (error "Killed group; can't be edited"))
3020     (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
3021       (error "%s is not an nnimap group" group))
3022     (nnimap-expunge mailbox (cadr method))))
3023
3024 (defun gnus-group-nnimap-edit-acl (group)
3025   "Edit the Access Control List of current nnimap GROUP."
3026   (interactive (list (gnus-group-group-name)))
3027   (let ((mailbox (gnus-group-real-name group)) method acl)
3028     (unless group
3029       (error "No group on current line"))
3030     (unless (gnus-get-info group)
3031       (error "Killed group; can't be edited"))
3032     (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3033       (error "%s is not an nnimap group" group))
3034     (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3035       (error "Server does not support ACL's"))
3036     (gnus-edit-form acl (format "Editing the access control list for `%s'.
3037
3038    An access control list is a list of (identifier . rights) elements.
3039
3040    The identifier string specifies the corresponding user.  The
3041    identifier \"anyone\" is reserved to refer to the universal identity.
3042
3043    Rights is a string listing a (possibly empty) set of alphanumeric
3044    characters, each character listing a set of operations which is being
3045    controlled.  Letters are reserved for ``standard'' rights, listed
3046    below.  Digits are reserved for implementation or site defined rights.
3047
3048    l - lookup (mailbox is visible to LIST/LSUB commands)
3049    r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3050        SEARCH, COPY from mailbox)
3051    s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3052    w - write (STORE flags other than \\SEEN and \\DELETED)
3053    i - insert (perform APPEND, COPY into mailbox)
3054    p - post (send mail to submission address for mailbox,
3055        not enforced by IMAP4 itself)
3056    c - create and delete mailbox (CREATE new sub-mailboxes in any
3057        implementation-defined hierarchy, RENAME or DELETE mailbox)
3058    d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3059    a - administer (perform SETACL)" group)
3060                     `(lambda (form)
3061                        (nnimap-acl-edit
3062                         ,mailbox ',method ',acl form)))))
3063
3064 ;; Group sorting commands
3065 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3066
3067 (defun gnus-group-sort-groups (func &optional reverse)
3068   "Sort the group buffer according to FUNC.
3069 When used interactively, the sorting function used will be
3070 determined by the `gnus-group-sort-function' variable.
3071 If REVERSE (the prefix), reverse the sorting order."
3072   (interactive (list gnus-group-sort-function current-prefix-arg))
3073   (funcall gnus-group-sort-alist-function
3074            (gnus-make-sort-function func) reverse)
3075   (gnus-group-unmark-all-groups)
3076   (gnus-group-list-groups)
3077   (gnus-dribble-touch))
3078
3079 (defun gnus-group-sort-flat (func reverse)
3080   ;; We peel off the dummy group from the alist.
3081   (when func
3082     (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3083       (pop gnus-newsrc-alist))
3084     ;; Do the sorting.
3085     (setq gnus-newsrc-alist
3086           (sort gnus-newsrc-alist func))
3087     (when reverse
3088       (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3089     ;; Regenerate the hash table.
3090     (gnus-make-hashtable-from-newsrc-alist)))
3091
3092 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3093   "Sort the group buffer alphabetically by group name.
3094 If REVERSE, sort in reverse order."
3095   (interactive "P")
3096   (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3097
3098 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3099   "Sort the group buffer alphabetically by real (unprefixed) group name.
3100 If REVERSE, sort in reverse order."
3101   (interactive "P")
3102   (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3103
3104 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3105   "Sort the group buffer by number of unread articles.
3106 If REVERSE, sort in reverse order."
3107   (interactive "P")
3108   (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3109
3110 (defun gnus-group-sort-groups-by-level (&optional reverse)
3111   "Sort the group buffer by group level.
3112 If REVERSE, sort in reverse order."
3113   (interactive "P")
3114   (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3115
3116 (defun gnus-group-sort-groups-by-score (&optional reverse)
3117   "Sort the group buffer by group score.
3118 If REVERSE, sort in reverse order."
3119   (interactive "P")
3120   (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3121
3122 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3123   "Sort the group buffer by group rank.
3124 If REVERSE, sort in reverse order."
3125   (interactive "P")
3126   (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3127
3128 (defun gnus-group-sort-groups-by-method (&optional reverse)
3129   "Sort the group buffer alphabetically by back end name.
3130 If REVERSE, sort in reverse order."
3131   (interactive "P")
3132   (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3133
3134 (defun gnus-group-sort-groups-by-server (&optional reverse)
3135   "Sort the group buffer alphabetically by server name.
3136 If REVERSE, sort in reverse order."
3137   (interactive "P")
3138   (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3139
3140 ;;; Selected group sorting.
3141
3142 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3143   "Sort the process/prefixed groups."
3144   (interactive (list current-prefix-arg gnus-group-sort-function))
3145   (let ((groups (gnus-group-process-prefix n)))
3146     (funcall gnus-group-sort-selected-function
3147              groups (gnus-make-sort-function func) reverse)
3148     (gnus-group-unmark-all-groups)
3149     (gnus-group-list-groups)
3150     (gnus-dribble-touch)))
3151
3152 (defun gnus-group-sort-selected-flat (groups func reverse)
3153   (let (entries infos)
3154     ;; First find all the group entries for these groups.
3155     (while groups
3156       (push (nthcdr 2 (gnus-group-entry (pop groups)))
3157             entries))
3158     ;; Then sort the infos.
3159     (setq infos
3160           (sort
3161            (mapcar
3162             (lambda (entry) (car entry))
3163             (setq entries (nreverse entries)))
3164            func))
3165     (when reverse
3166       (setq infos (nreverse infos)))
3167     ;; Go through all the infos and replace the old entries
3168     ;; with the new infos.
3169     (while infos
3170       (setcar (car entries) (pop infos))
3171       (pop entries))
3172     ;; Update the hashtable.
3173     (gnus-make-hashtable-from-newsrc-alist)))
3174
3175 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3176   "Sort the group buffer alphabetically by group name.
3177 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3178 sort in reverse order."
3179   (interactive (gnus-interactive "P\ny"))
3180   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3181
3182 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3183   "Sort the group buffer alphabetically by real group name.
3184 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3185 sort in reverse order."
3186   (interactive (gnus-interactive "P\ny"))
3187   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3188
3189 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3190   "Sort the group buffer by number of unread articles.
3191 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3192 sort in reverse order."
3193   (interactive (gnus-interactive "P\ny"))
3194   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3195
3196 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3197   "Sort the group buffer by group level.
3198 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3199 sort in reverse order."
3200   (interactive (gnus-interactive "P\ny"))
3201   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3202
3203 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3204   "Sort the group buffer by group score.
3205 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3206 sort in reverse order."
3207   (interactive (gnus-interactive "P\ny"))
3208   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3209
3210 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3211   "Sort the group buffer by group rank.
3212 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3213 sort in reverse order."
3214   (interactive (gnus-interactive "P\ny"))
3215   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3216
3217 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3218   "Sort the group buffer alphabetically by back end name.
3219 Obeys the process/prefix convention.  If REVERSE (the symbolic prefix),
3220 sort in reverse order."
3221   (interactive (gnus-interactive "P\ny"))
3222   (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3223
3224 ;;; Sorting predicates.
3225
3226 (defun gnus-group-sort-by-alphabet (info1 info2)
3227   "Sort alphabetically."
3228   (string< (gnus-info-group info1) (gnus-info-group info2)))
3229
3230 (defun gnus-group-sort-by-real-name (info1 info2)
3231   "Sort alphabetically on real (unprefixed) names."
3232   (string< (gnus-group-real-name (gnus-info-group info1))
3233            (gnus-group-real-name (gnus-info-group info2))))
3234
3235 (defun gnus-group-sort-by-unread (info1 info2)
3236   "Sort by number of unread articles."
3237   (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3238         (n2 (gnus-group-unread (gnus-info-group info2))))
3239     (< (or (and (numberp n1) n1) 0)
3240        (or (and (numberp n2) n2) 0))))
3241
3242 (defun gnus-group-sort-by-level (info1 info2)
3243   "Sort by level."
3244   (< (gnus-info-level info1) (gnus-info-level info2)))
3245
3246 (defun gnus-group-sort-by-method (info1 info2)
3247   "Sort alphabetically by back end name."
3248   (string< (car (gnus-find-method-for-group
3249                  (gnus-info-group info1) info1))
3250            (car (gnus-find-method-for-group
3251                  (gnus-info-group info2) info2))))
3252
3253 (defun gnus-group-sort-by-server (info1 info2)
3254   "Sort alphabetically by server name."
3255   (string< (gnus-method-to-full-server-name
3256             (gnus-find-method-for-group
3257              (gnus-info-group info1) info1))
3258            (gnus-method-to-full-server-name
3259             (gnus-find-method-for-group
3260              (gnus-info-group info2) info2))))
3261
3262 (defun gnus-group-sort-by-score (info1 info2)
3263   "Sort by group score."
3264   (> (gnus-info-score info1) (gnus-info-score info2)))
3265
3266 (defun gnus-group-sort-by-rank (info1 info2)
3267   "Sort by level and score."
3268   (let ((level1 (gnus-info-level info1))
3269         (level2 (gnus-info-level info2)))
3270     (or (< level1 level2)
3271         (and (= level1 level2)
3272              (> (gnus-info-score info1) (gnus-info-score info2))))))
3273
3274 ;;; Clearing data
3275
3276 (defun gnus-group-clear-data (&optional arg)
3277   "Clear all marks and read ranges from the current group.
3278 Obeys the process/prefix convention."
3279   (interactive "P")
3280   (gnus-group-iterate arg
3281     (lambda (group)
3282       (let (info)
3283         (gnus-info-clear-data (setq info (gnus-get-info group)))
3284         (gnus-get-unread-articles-in-group info (gnus-active group) t)
3285         (when (gnus-group-goto-group group)
3286           (gnus-group-update-group-line))))))
3287
3288 (defun gnus-group-clear-data-on-native-groups ()
3289   "Clear all marks and read ranges from all native groups."
3290   (interactive)
3291   (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3292     (let ((alist (cdr gnus-newsrc-alist))
3293           info)
3294       (while (setq info (pop alist))
3295         (when (gnus-group-native-p (gnus-info-group info))
3296           (gnus-info-clear-data info)))
3297       (gnus-get-unread-articles)
3298       (gnus-dribble-touch)
3299       (when (gnus-y-or-n-p
3300              "Move the cache away to avoid problems in the future? ")
3301         (call-interactively 'gnus-cache-move-cache)))))
3302
3303 (defun gnus-info-clear-data (info)
3304   "Clear all marks and read ranges from INFO."
3305   (let ((group (gnus-info-group info))
3306         action)
3307     (dolist (el (gnus-info-marks info))
3308       (push `(,(cdr el) add (,(car el))) action))
3309     (push `(,(gnus-info-read info) add (read)) action)
3310     (gnus-undo-register
3311       `(progn
3312          (gnus-request-set-mark ,group ',action)
3313          (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3314          (gnus-info-set-read ',info ',(gnus-info-read info))
3315          (when (gnus-group-goto-group ,group)
3316            (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3317            (gnus-group-update-group-line))))
3318     (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3319                          action))
3320     (gnus-request-set-mark group action)
3321     (gnus-info-set-read info nil)
3322     (when (gnus-info-marks info)
3323       (gnus-info-set-marks info nil))))
3324
3325 ;; Group catching up.
3326
3327 (defun gnus-group-catchup-current (&optional n all)
3328   "Mark all unread articles in the current newsgroup as read.
3329 If prefix argument N is numeric, the next N newsgroups will be
3330 caught up.  If ALL is non-nil, marked articles will also be marked as
3331 read.  Cross references (Xref: header) of articles are ignored.
3332 The number of newsgroups that this function was unable to catch
3333 up is returned."
3334   (interactive "P")
3335   (let ((groups (gnus-group-process-prefix n))
3336         (ret 0)
3337         group)
3338     (unless groups (error "No groups selected"))
3339     (if (not
3340          (or (not gnus-interactive-catchup) ;Without confirmation?
3341              gnus-expert-user
3342              (gnus-y-or-n-p
3343               (format
3344                (if all
3345                    "Do you really want to mark all articles in %s as read? "
3346                  "Mark all unread articles in %s as read? ")
3347                (if (= (length groups) 1)
3348                    (gnus-group-decoded-name (car groups))
3349                  (format "these %d groups" (length groups)))))))
3350         n
3351       (while (setq group (pop groups))
3352         (gnus-group-remove-mark group)
3353         ;; Virtual groups have to be given special treatment.
3354         (let ((method (gnus-find-method-for-group group)))
3355           (when (eq 'nnvirtual (car method))
3356             (nnvirtual-catchup-group
3357              (gnus-group-real-name group) (nth 1 method) all)))
3358         (cond
3359          ((>= (gnus-group-level group) gnus-level-zombie)
3360           (gnus-message 2 "Dead groups can't be caught up"))
3361          ((prog1
3362               (gnus-group-goto-group group)
3363             (gnus-group-catchup group all))
3364           (gnus-group-update-group-line))
3365          (t
3366           (setq ret (1+ ret)))))
3367       (gnus-group-next-unread-group 1)
3368       ret)))
3369
3370 (defun gnus-group-catchup-current-all (&optional n)
3371   "Mark all articles in current newsgroup as read.
3372 Cross references (Xref: header) of articles are ignored."
3373   (interactive "P")
3374   (gnus-group-catchup-current n 'all))
3375
3376 (defun gnus-group-catchup (group &optional all)
3377   "Mark all articles in GROUP as read.
3378 If ALL is non-nil, all articles are marked as read.
3379 The return value is the number of articles that were marked as read,
3380 or nil if no action could be taken."
3381   (let* ((entry (gnus-group-entry group))
3382          (num (car entry))
3383          (marks (gnus-info-marks (nth 2 entry)))
3384          (unread (gnus-sequence-of-unread-articles group)))
3385     ;; Remove entries for this group.
3386     (nnmail-purge-split-history (gnus-group-real-name group))
3387     ;; Do the updating only if the newsgroup isn't killed.
3388     (if (not (numberp (car entry)))
3389         (gnus-message 1 "Can't catch up %s; non-active group" group)
3390       (gnus-update-read-articles group nil)
3391       (when all
3392         ;; Nix out the lists of marks and dormants.
3393         (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3394                                                  'del '(tick))
3395                                            (list (cdr (assq 'dormant marks))
3396                                                  'del '(dormant))))
3397         (setq unread (gnus-range-add (gnus-range-add
3398                                       unread (cdr (assq 'dormant marks)))
3399                                      (cdr (assq 'tick marks))))
3400         (gnus-add-marked-articles group 'tick nil nil 'force)
3401         (gnus-add-marked-articles group 'dormant nil nil 'force))
3402       ;; Do auto-expirable marks if that's required.
3403       (when (gnus-group-auto-expirable-p group)
3404         (gnus-range-map
3405          (lambda (article)
3406            (gnus-add-marked-articles group 'expire (list article))
3407            (gnus-request-set-mark group (list (list (list article)
3408                                                     'add '(expire)))))
3409          unread))
3410       (let ((gnus-newsgroup-name group))
3411         (gnus-run-hooks 'gnus-group-catchup-group-hook))
3412       num)))
3413
3414 (defun gnus-group-expire-articles (&optional n)
3415   "Expire all expirable articles in the current newsgroup.
3416 Uses the process/prefix convention."
3417   (interactive "P")
3418   (let ((groups (gnus-group-process-prefix n))
3419         group)
3420     (unless groups
3421       (error "No groups to expire"))
3422     (while (setq group (pop groups))
3423       (gnus-group-remove-mark group)
3424       (gnus-group-expire-articles-1 group)
3425       (gnus-dribble-touch)
3426       (gnus-group-position-point))))
3427
3428 (defun gnus-group-expire-articles-1 (group)
3429   (when (gnus-check-backend-function 'request-expire-articles group)
3430     (gnus-message 6 "Expiring articles in %s..."
3431                   (gnus-group-decoded-name group))
3432     (let* ((info (gnus-get-info group))
3433            (expirable (if (gnus-group-total-expirable-p group)
3434                           (cons nil (gnus-list-of-read-articles group))
3435                         (assq 'expire (gnus-info-marks info))))
3436            (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3437            (nnmail-expiry-target
3438             (or (gnus-group-find-parameter group 'expiry-target)
3439                 nnmail-expiry-target)))
3440       (when expirable
3441         (gnus-check-group group)
3442         (setcdr
3443          expirable
3444          (gnus-compress-sequence
3445           (if expiry-wait
3446               ;; We set the expiry variables to the group
3447               ;; parameter.
3448               (let ((nnmail-expiry-wait-function nil)
3449                     (nnmail-expiry-wait expiry-wait))
3450                 (gnus-request-expire-articles
3451                  (gnus-uncompress-sequence (cdr expirable)) group))
3452             ;; Just expire using the normal expiry values.
3453             (gnus-request-expire-articles
3454              (gnus-uncompress-sequence (cdr expirable)) group))))
3455         (gnus-close-group group))
3456       (gnus-message 6 "Expiring articles in %s...done"
3457                     (gnus-group-decoded-name group))
3458       ;; Return the list of un-expired articles.
3459       (cdr expirable))))
3460
3461 (defun gnus-group-expire-all-groups ()
3462   "Expire all expirable articles in all newsgroups."
3463   (interactive)
3464   (save-excursion
3465     (gnus-message 5 "Expiring...")
3466     (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3467                                      (cdr gnus-newsrc-alist))))
3468       (gnus-group-expire-articles nil)))
3469   (gnus-group-position-point)
3470   (gnus-message 5 "Expiring...done"))
3471
3472 (defun gnus-group-set-current-level (n level)
3473   "Set the level of the next N groups to LEVEL."
3474   (interactive
3475    (list
3476     current-prefix-arg
3477     (progn
3478       (unless (gnus-group-process-prefix current-prefix-arg)
3479         (error "No group on the current line"))
3480       (string-to-number
3481        (let ((s (read-string
3482                  (format "Level (default %s): "
3483                          (or (gnus-group-group-level)
3484                              gnus-level-default-subscribed)))))
3485          (if (string-match "^\\s-*$" s)
3486              (int-to-string (or (gnus-group-group-level)
3487                                 gnus-level-default-subscribed))
3488            s))))))
3489   (unless (and (>= level 1) (<= level gnus-level-killed))
3490     (error "Invalid level: %d" level))
3491   (dolist (group (gnus-group-process-prefix n))
3492     (gnus-group-remove-mark group)
3493     (gnus-message 6 "Changed level of %s from %d to %d"
3494                   (gnus-group-decoded-name group)
3495                   (or (gnus-group-group-level) gnus-level-killed)
3496                   level)
3497     (gnus-group-change-level
3498      group level (or (gnus-group-group-level) gnus-level-killed))
3499     (gnus-group-update-group-line))
3500   (gnus-group-position-point))
3501
3502 (defun gnus-group-unsubscribe (&optional n)
3503   "Unsubscribe the current group."
3504   (interactive "P")
3505   (gnus-group-unsubscribe-current-group n 'unsubscribe))
3506
3507 (defun gnus-group-subscribe (&optional n)
3508   "Subscribe the current group."
3509   (interactive "P")
3510   (gnus-group-unsubscribe-current-group n 'subscribe))
3511
3512 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3513   "Toggle subscription of the current group.
3514 If given numerical prefix, toggle the N next groups."
3515   (interactive "P")
3516   (dolist (group (gnus-group-process-prefix n))
3517     (gnus-group-remove-mark group)
3518     (gnus-group-unsubscribe-group
3519      group
3520      (cond
3521       ((eq do-sub 'unsubscribe)
3522        gnus-level-default-unsubscribed)
3523       ((eq do-sub 'subscribe)
3524        gnus-level-default-subscribed)
3525       ((<= (gnus-group-group-level) gnus-level-subscribed)
3526        gnus-level-default-unsubscribed)
3527       (t
3528        gnus-level-default-subscribed))
3529      t)
3530     (gnus-group-update-group-line))
3531   (gnus-group-next-group 1))
3532
3533 (defun gnus-group-unsubscribe-group (group &optional level silent)
3534   "Toggle subscription to GROUP.
3535 Killed newsgroups are subscribed.  If SILENT, don't try to update the
3536 group line."
3537   (interactive
3538    (list (completing-read
3539           "Group: " gnus-active-hashtb nil
3540           (gnus-read-active-file-p)
3541           nil
3542           'gnus-group-history)))
3543   (let ((newsrc (gnus-group-entry group)))
3544     (cond
3545      ((string-match "^[ \t]*$" group)
3546       (error "Empty group name"))
3547      (newsrc
3548       ;; Toggle subscription flag.
3549       (gnus-group-change-level
3550        newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3551                                       gnus-level-subscribed)
3552                                   (1+ gnus-level-subscribed)
3553                                 gnus-level-default-subscribed)))
3554       (unless silent
3555         (gnus-group-update-group group)))
3556      ((and (stringp group)
3557            (or (not (gnus-read-active-file-p))
3558                (gnus-active group)))
3559       ;; Add new newsgroup.
3560       (gnus-group-change-level
3561        group
3562        (if level level gnus-level-default-subscribed)
3563        (or (and (member group gnus-zombie-list)
3564                 gnus-level-zombie)
3565            gnus-level-killed)
3566        (when (gnus-group-group-name)
3567          (gnus-group-entry (gnus-group-group-name))))
3568       (unless silent
3569         (gnus-group-update-group group)))
3570      (t (error "No such newsgroup: %s" group)))
3571     (gnus-group-position-point)))
3572
3573 (defun gnus-group-transpose-groups (n)
3574   "Move the current newsgroup up N places.
3575 If given a negative prefix, move down instead.  The difference between
3576 N and the number of steps taken is returned."
3577   (interactive "p")
3578   (unless (gnus-group-group-name)
3579     (error "No group on current line"))
3580   (gnus-group-kill-group 1)
3581   (prog1
3582       (forward-line (- n))
3583     (gnus-group-yank-group)
3584     (gnus-group-position-point)))
3585
3586 (defun gnus-group-kill-all-zombies (&optional dummy)
3587   "Kill all zombie newsgroups.
3588 The optional DUMMY should always be nil."
3589   (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3590   (unless dummy
3591     (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3592     (setq gnus-zombie-list nil)
3593     (gnus-dribble-touch)
3594     (gnus-group-list-groups)))
3595
3596 (defun gnus-group-kill-region (begin end)
3597   "Kill newsgroups in current region (excluding current point).
3598 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3599   (interactive "r")
3600   (let ((lines
3601          ;; Count lines.
3602          (save-excursion
3603            (count-lines
3604             (progn
3605               (goto-char begin)
3606               (point-at-bol))
3607             (progn
3608               (goto-char end)
3609               (point-at-bol))))))
3610     (goto-char begin)
3611     (beginning-of-line)                 ;Important when LINES < 1
3612     (gnus-group-kill-group lines)))
3613
3614 (defun gnus-group-kill-group (&optional n discard)
3615   "Kill the next N groups.
3616 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3617 However, only groups that were alive can be yanked; already killed
3618 groups or zombie groups can't be yanked.
3619 The return value is the name of the group that was killed, or a list
3620 of groups killed."
3621   (interactive "P")
3622   (let ((buffer-read-only nil)
3623         (groups (gnus-group-process-prefix n))
3624         group entry level out)
3625     (if (< (length groups) 10)
3626         ;; This is faster when there are few groups.
3627         (while groups
3628           (push (setq group (pop groups)) out)
3629           (gnus-group-remove-mark group)
3630           (setq level (gnus-group-group-level))
3631           (gnus-delete-line)
3632           (when (and (not discard)
3633                      (setq entry (gnus-group-entry group)))
3634             (gnus-undo-register
3635               `(progn
3636                  (gnus-group-goto-group ,(gnus-group-group-name))
3637                  (gnus-group-yank-group)))
3638             (push (cons (car entry) (nth 2 entry))
3639                   gnus-list-of-killed-groups))
3640           (gnus-group-change-level
3641            (if entry entry group) gnus-level-killed (if entry nil level))
3642           (message "Killed group %s" (gnus-group-decoded-name group)))
3643       ;; If there are lots and lots of groups to be killed, we use
3644       ;; this thing instead.
3645       (dolist (group (nreverse groups))
3646         (gnus-group-remove-mark group)
3647         (gnus-delete-line)
3648         (push group gnus-killed-list)
3649         (setq gnus-newsrc-alist
3650               (delq (assoc group gnus-newsrc-alist)
3651                     gnus-newsrc-alist))
3652         (when gnus-group-change-level-function
3653           (funcall gnus-group-change-level-function
3654                    group gnus-level-killed 3))
3655         (cond
3656          ((setq entry (gnus-group-entry group))
3657           (push (cons (car entry) (nth 2 entry))
3658                 gnus-list-of-killed-groups)
3659           (setcdr (cdr entry) (cdddr entry)))
3660          ((member group gnus-zombie-list)
3661           (setq gnus-zombie-list (delete group gnus-zombie-list))))
3662         ;; There may be more than one instance displayed.
3663         (while (gnus-group-goto-group group)
3664           (gnus-delete-line)))
3665       (gnus-make-hashtable-from-newsrc-alist))
3666
3667     (gnus-group-position-point)
3668     (if (< (length out) 2) (car out) (nreverse out))))
3669
3670 (defun gnus-group-yank-group (&optional arg)
3671   "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3672 The numeric ARG specifies how many newsgroups are to be yanked.  The
3673 name of the newsgroup yanked is returned, or (if several groups are
3674 yanked) a list of yanked groups is returned."
3675   (interactive "p")
3676   (setq arg (or arg 1))
3677   (let (info group prev out)
3678     (while (>= (decf arg) 0)
3679       (when (not (setq info (pop gnus-list-of-killed-groups)))
3680         (error "No more newsgroups to yank"))
3681       (push (setq group (nth 1 info)) out)
3682       ;; Find which newsgroup to insert this one before - search
3683       ;; backward until something suitable is found.  If there are no
3684       ;; other newsgroups in this buffer, just make this newsgroup the
3685       ;; first newsgroup.
3686       (setq prev (gnus-group-group-name))
3687       (gnus-group-change-level
3688        info (gnus-info-level (cdr info)) gnus-level-killed
3689        (and prev (gnus-group-entry prev))
3690        t)
3691       (gnus-group-insert-group-line-info group)
3692       (gnus-undo-register
3693         `(when (gnus-group-goto-group ,group)
3694            (gnus-group-kill-group 1))))
3695     (forward-line -1)
3696     (gnus-group-position-point)
3697     (if (< (length out) 2) (car out) (nreverse out))))
3698
3699 (defun gnus-group-kill-level (level)
3700   "Kill all groups that is on a certain LEVEL."
3701   (interactive "nKill all groups on level: ")
3702   (cond
3703    ((= level gnus-level-zombie)
3704     (setq gnus-killed-list
3705           (nconc gnus-zombie-list gnus-killed-list))
3706     (setq gnus-zombie-list nil))
3707    ((and (< level gnus-level-zombie)
3708          (> level 0)
3709          (or gnus-expert-user
3710              (gnus-yes-or-no-p
3711               (format
3712                "Do you really want to kill all groups on level %d? "
3713                level))))
3714     (let* ((prev gnus-newsrc-alist)
3715            (alist (cdr prev)))
3716       (while alist
3717         (if (= (gnus-info-level (car alist)) level)
3718             (progn
3719               (push (gnus-info-group (car alist)) gnus-killed-list)
3720               (setcdr prev (cdr alist)))
3721           (setq prev alist))
3722         (setq alist (cdr alist)))
3723       (gnus-make-hashtable-from-newsrc-alist)
3724       (gnus-group-list-groups)))
3725    (t
3726     (error "Can't kill; invalid level: %d" level))))
3727
3728 (defun gnus-group-list-all-groups (&optional arg)
3729   "List all newsgroups with level ARG or lower.
3730 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3731 unsubscribed groups."
3732   (interactive "P")
3733   (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3734
3735 ;; Redefine this to list ALL killed groups if prefix arg used.
3736 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3737 (defun gnus-group-list-killed (&optional arg)
3738   "List all killed newsgroups in the group buffer.
3739 If ARG is non-nil, list ALL killed groups known to Gnus.  This may
3740 entail asking the server for the groups."
3741   (interactive "P")
3742   ;; Find all possible killed newsgroups if arg.
3743   (when arg
3744     (gnus-get-killed-groups))
3745   (if (not gnus-killed-list)
3746       (gnus-message 6 "No killed groups")
3747     (let (gnus-group-list-mode)
3748       (funcall gnus-group-prepare-function
3749                gnus-level-killed t gnus-level-killed))
3750     (goto-char (point-min)))
3751   (gnus-group-position-point))
3752
3753 (defun gnus-group-list-zombies ()
3754   "List all zombie newsgroups in the group buffer."
3755   (interactive)
3756   (if (not gnus-zombie-list)
3757       (gnus-message 6 "No zombie groups")
3758     (let (gnus-group-list-mode)
3759       (funcall gnus-group-prepare-function
3760                gnus-level-zombie t gnus-level-zombie))
3761     (goto-char (point-min)))
3762   (gnus-group-position-point))
3763
3764 (defun gnus-group-list-active ()
3765   "List all groups that are available from the server(s)."
3766   (interactive)
3767   ;; First we make sure that we have really read the active file.
3768   (unless (gnus-read-active-file-p)
3769     (let ((gnus-read-active-file t)
3770           (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3771       (gnus-read-active-file)))
3772   ;; Find all groups and sort them.
3773   (let ((groups
3774          (sort
3775           (let (list)
3776             (mapatoms
3777              (lambda (sym)
3778                (and (boundp sym)
3779                     (symbol-value sym)
3780                     (push (symbol-name sym) list)))
3781              gnus-active-hashtb)
3782             list)
3783           'string<))
3784         (buffer-read-only nil)
3785         group)
3786     (erase-buffer)
3787     (while groups
3788       (setq group (pop groups))
3789       (gnus-add-text-properties
3790        (point) (prog1 (1+ (point))
3791                  (insert "       *: "
3792                          (gnus-group-decoded-name group)
3793                          "\n"))
3794        (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3795              'gnus-unread t
3796              'gnus-level (inline (gnus-group-level group)))))
3797     (goto-char (point-min))))
3798
3799 (defun gnus-activate-all-groups (level)
3800   "Activate absolutely all groups."
3801   (interactive (list gnus-level-unsubscribed))
3802   (let ((gnus-activate-level level)
3803         (gnus-activate-foreign-newsgroups level))
3804     (gnus-group-get-new-news)))
3805
3806 (defun gnus-group-get-new-news (&optional arg)
3807   "Get newly arrived articles.
3808 If ARG is a number, it specifies which levels you are interested in
3809 re-scanning.  If ARG is non-nil and not a number, this will force
3810 \"hard\" re-reading of the active files from all servers."
3811   (interactive "P")
3812   (require 'nnmail)
3813   (let ((gnus-inhibit-demon t)
3814         ;; Binding this variable will inhibit multiple fetchings
3815         ;; of the same mail source.
3816         (nnmail-fetched-sources (list t)))
3817     (gnus-run-hooks 'gnus-get-top-new-news-hook)
3818     (gnus-run-hooks 'gnus-get-new-news-hook)
3819
3820     ;; Read any slave files.
3821     (unless gnus-slave
3822       (gnus-master-read-slave-newsrc))
3823
3824     ;; We might read in new NoCeM messages here.
3825     (when (and gnus-use-nocem
3826                (or (and (numberp gnus-use-nocem)
3827                         (numberp arg)
3828                         (>= arg gnus-use-nocem))
3829                    (not arg)))
3830       (gnus-nocem-scan-groups))
3831     ;; If ARG is not a number, then we read the active file.
3832     (when (and arg (not (numberp arg)))
3833       (let ((gnus-read-active-file t))
3834         (gnus-read-active-file))
3835       (setq arg nil)
3836
3837       ;; If the user wants it, we scan for new groups.
3838       (when (eq gnus-check-new-newsgroups 'always)
3839         (gnus-find-new-newsgroups)))
3840
3841     (setq arg (gnus-group-default-level arg t))
3842     (if (and gnus-read-active-file (not arg))
3843         (progn
3844           (gnus-read-active-file)
3845           (gnus-get-unread-articles arg))
3846       (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3847         (gnus-get-unread-articles arg)))
3848     (gnus-check-reasonable-setup)
3849     (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3850     (gnus-group-list-groups (and (numberp arg)
3851                                  (max (car gnus-group-list-mode) arg)))))
3852
3853 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3854   "Check for newly arrived news in the current group (and the N-1 next groups).
3855 The difference between N and the number of newsgroup checked is returned.
3856 If N is negative, this group and the N-1 previous groups will be checked.
3857 If DONT-SCAN is non-nil, scan non-activated groups as well."
3858   (interactive "P")
3859   (let* ((groups (gnus-group-process-prefix n))
3860          (ret (if (numberp n) (- n (length groups)) 0))
3861          (beg (unless n
3862                 (point)))
3863          group method
3864          (gnus-inhibit-demon t)
3865          ;; Binding this variable will inhibit multiple fetchings
3866          ;; of the same mail source.
3867          (nnmail-fetched-sources (list t)))
3868     (gnus-run-hooks 'gnus-get-new-news-hook)
3869     (while (setq group (pop groups))
3870       (gnus-group-remove-mark group)
3871       ;; Bypass any previous denials from the server.
3872       (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3873       (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3874           (let ((info (gnus-get-info group))
3875                 (active (gnus-active group)))
3876             (when info
3877               (gnus-request-update-info info method))
3878             (gnus-get-unread-articles-in-group info active)
3879             (unless (gnus-virtual-group-p group)
3880               (gnus-close-group group))
3881             (when gnus-agent
3882               (gnus-agent-save-group-info
3883                method (gnus-group-real-name group) active))
3884             (gnus-group-update-group group))
3885         (if (eq (gnus-server-status (gnus-find-method-for-group group))
3886                 'denied)
3887             (gnus-error 3 "Server denied access")
3888           (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3889     (when beg
3890       (goto-char beg))
3891     (when gnus-goto-next-group-when-activating
3892       (gnus-group-next-unread-group 1 t))
3893     (gnus-summary-position-point)
3894     ret))
3895
3896 (defun gnus-group-fetch-faq (group &optional faq-dir)
3897   "Fetch the FAQ for the current group.
3898 If given a prefix argument, prompt for the FAQ dir
3899 to use."
3900   (interactive
3901    (list
3902     (gnus-group-group-name)
3903     (when current-prefix-arg
3904       (completing-read
3905        "FAQ dir: " (and (listp gnus-group-faq-directory)
3906                         (mapcar #'list
3907                                 gnus-group-faq-directory))))))
3908   (unless group
3909     (error "No group name given"))
3910   (let ((dirs (or faq-dir gnus-group-faq-directory))
3911         dir found file)
3912     (unless (listp dirs)
3913       (setq dirs (list dirs)))
3914     (while (and (not found)
3915                 (setq dir (pop dirs)))
3916       (let ((name (gnus-group-real-name group)))
3917         (setq file (expand-file-name name dir)))
3918       (if (not (file-exists-p file))
3919           (gnus-message 1 "No such file: %s" file)
3920         (let ((enable-local-variables nil))
3921           (find-file file)
3922           (setq found t))))))
3923
3924 (defun gnus-group-fetch-charter (group)
3925   "Fetch the charter for the current group.
3926 If given a prefix argument, prompt for a group."
3927   (interactive
3928    (list (or (when current-prefix-arg
3929                (completing-read "Group: " gnus-active-hashtb))
3930              (gnus-group-group-name)
3931              gnus-newsgroup-name)))
3932   (unless group
3933     (error "No group name given"))
3934   (require 'mm-url)
3935   (condition-case nil (require 'url-http) (error nil))
3936   (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3937         url hierarchy)
3938     (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3939       (setq hierarchy (match-string 1 name))
3940       (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3941                (if (fboundp 'url-http-file-exists-p)
3942                    (url-http-file-exists-p (eval url))
3943                  t))
3944           (browse-url (eval url))
3945         (setq url (concat "http://" hierarchy
3946                           ".news-admin.org/charters/" name))
3947         (if (and (fboundp 'url-http-file-exists-p)
3948                  (url-http-file-exists-p url))
3949             (browse-url url)
3950           (gnus-group-fetch-control group))))))
3951
3952 (defun gnus-group-fetch-control (group)
3953   "Fetch the archived control messages for the current group.
3954 If given a prefix argument, prompt for a group."
3955   (interactive
3956    (list (or (when current-prefix-arg
3957                (completing-read "Group: " gnus-active-hashtb))
3958              (gnus-group-group-name)
3959              gnus-newsgroup-name)))
3960   (unless group
3961     (error "No group name given"))
3962   (let ((name (gnus-group-real-name group))
3963         hierarchy)
3964     (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3965       (setq hierarchy (match-string 1 name))
3966       (if gnus-group-fetch-control-use-browse-url
3967           (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3968                               hierarchy "/" name ".gz"))
3969         (let ((enable-local-variables nil))
3970           (gnus-group-read-ephemeral-group
3971            group
3972            `(nndoc ,group (nndoc-address
3973                            ,(find-file-noselect
3974                              (concat "/ftp@ftp.isc.org:/usenet/control/"
3975                                      hierarchy "/" name ".gz")))
3976                    (nndoc-article-type mbox)) t nil nil))))))
3977
3978 (defun gnus-group-describe-group (force &optional group)
3979   "Display a description of the current newsgroup."
3980   (interactive (list current-prefix-arg (gnus-group-group-name)))
3981   (let* ((method (gnus-find-method-for-group group))
3982          (mname (gnus-group-prefixed-name "" method))
3983          desc)
3984     (when (and force
3985                gnus-description-hashtb)
3986       (gnus-sethash mname nil gnus-description-hashtb))
3987     (unless group
3988       (error "No group name given"))
3989     (when (or (and gnus-description-hashtb
3990                    ;; We check whether this group's method has been
3991                    ;; queried for a description file.
3992                    (gnus-gethash mname gnus-description-hashtb))
3993               (setq desc (gnus-group-get-description group))
3994               (gnus-read-descriptions-file method))
3995       (gnus-message 1
3996                     (or desc (gnus-gethash group gnus-description-hashtb)
3997                         "No description available")))))
3998
3999 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4000 (defun gnus-group-describe-all-groups (&optional force)
4001   "Pop up a buffer with descriptions of all newsgroups."
4002   (interactive "P")
4003   (when force
4004     (setq gnus-description-hashtb nil))
4005   (when (not (or gnus-description-hashtb
4006                  (gnus-read-all-descriptions-files)))
4007     (error "Couldn't request descriptions file"))
4008   (let ((buffer-read-only nil)
4009         b)
4010     (erase-buffer)
4011     (mapatoms
4012      (lambda (group)
4013        (setq b (point))
4014        (let ((charset (gnus-group-name-charset nil (symbol-name group))))
4015          (insert (format "      *: %-20s %s\n"
4016                          (gnus-group-name-decode
4017                           (symbol-name group) charset)
4018                          (gnus-group-name-decode
4019                           (symbol-value group) charset))))
4020        (gnus-add-text-properties
4021         b (1+ b) (list 'gnus-group group
4022                        'gnus-unread t 'gnus-marked nil
4023                        'gnus-level (1+ gnus-level-subscribed))))
4024      gnus-description-hashtb)
4025     (goto-char (point-min))
4026     (gnus-group-position-point)))
4027
4028 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4029 (defun gnus-group-apropos (regexp &optional search-description)
4030   "List all newsgroups that have names that match a regexp."
4031   (interactive "sGnus apropos (regexp): ")
4032   (let ((prev "")
4033         (obuf (current-buffer))
4034         groups des)
4035     ;; Go through all newsgroups that are known to Gnus.
4036     (mapatoms
4037      (lambda (group)
4038        (and (symbol-name group)
4039             (string-match regexp (symbol-name group))
4040             (symbol-value group)
4041             (push (symbol-name group) groups)))
4042      gnus-active-hashtb)
4043     ;; Also go through all descriptions that are known to Gnus.
4044     (when search-description
4045       (mapatoms
4046        (lambda (group)
4047          (and (string-match regexp (symbol-value group))
4048               (push (symbol-name group) groups)))
4049        gnus-description-hashtb))
4050     (if (not groups)
4051         (gnus-message 3 "No groups matched \"%s\"." regexp)
4052       ;; Print out all the groups.
4053       (save-excursion
4054         (pop-to-buffer "*Gnus Help*")
4055         (buffer-disable-undo)
4056         (erase-buffer)
4057         (setq groups (sort groups 'string<))
4058         (while groups
4059           ;; Groups may be entered twice into the list of groups.
4060           (when (not (string= (car groups) prev))
4061             (setq prev (car groups))
4062             (let ((charset (gnus-group-name-charset nil prev)))
4063               (insert (gnus-group-name-decode prev charset) "\n")
4064               (when (and gnus-description-hashtb
4065                          (setq des (gnus-gethash (car groups)
4066                                                  gnus-description-hashtb)))
4067                 (insert "  " (gnus-group-name-decode des charset) "\n"))))
4068           (setq groups (cdr groups)))
4069         (goto-char (point-min))))
4070     (pop-to-buffer obuf)))
4071
4072 (defun gnus-group-description-apropos (regexp)
4073   "List all newsgroups that have names or descriptions that match REGEXP."
4074   (interactive "sGnus description apropos (regexp): ")
4075   (when (not (or gnus-description-hashtb
4076                  (gnus-read-all-descriptions-files)))
4077     (error "Couldn't request descriptions file"))
4078   (gnus-group-apropos regexp t))
4079
4080 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4081 (defun gnus-group-list-matching (level regexp &optional all lowest)
4082   "List all groups with unread articles that match REGEXP.
4083 If the prefix LEVEL is non-nil, it should be a number that says which
4084 level to cut off listing groups.
4085 If ALL, also list groups with no unread articles.
4086 If LOWEST, don't list groups with level lower than LOWEST.
4087
4088 This command may read the active file."
4089   (interactive "P\nsList newsgroups matching: ")
4090   ;; First make sure active file has been read.
4091   (when (and level
4092              (> (prefix-numeric-value level) gnus-level-killed))
4093     (gnus-get-killed-groups))
4094   (funcall gnus-group-prepare-function
4095    (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4096   (goto-char (point-min))
4097   (gnus-group-position-point))
4098
4099 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4100   "List all groups that match REGEXP.
4101 If the prefix LEVEL is non-nil, it should be a number that says which
4102 level to cut off listing groups.
4103 If LOWEST, don't list groups with level lower than LOWEST."
4104   (interactive "P\nsList newsgroups matching: ")
4105   (when level
4106     (setq level (prefix-numeric-value level)))
4107   (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4108
4109 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4110 (defun gnus-group-save-newsrc (&optional force)
4111   "Save the Gnus startup files.
4112 If FORCE, force saving whether it is necessary or not."
4113   (interactive "P")
4114   (gnus-save-newsrc-file force))
4115
4116 (defun gnus-group-restart (&optional arg)
4117   "Force Gnus to read the .newsrc file."
4118   (interactive "P")
4119   (when (gnus-yes-or-no-p
4120          (format "Are you sure you want to restart Gnus? "))
4121     (gnus-save-newsrc-file)
4122     (gnus-clear-system)
4123     (gnus)))
4124
4125 (defun gnus-group-read-init-file ()
4126   "Read the Gnus elisp init file."
4127   (interactive)
4128   (gnus-read-init-file)
4129   (gnus-message 5 "Read %s" gnus-init-file))
4130
4131 (defun gnus-group-check-bogus-groups (&optional silent)
4132   "Check bogus newsgroups.
4133 If given a prefix, don't ask for confirmation before removing a bogus
4134 group."
4135   (interactive "P")
4136   (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4137   (gnus-group-list-groups))
4138
4139 (defun gnus-group-find-new-groups (&optional arg)
4140   "Search for new groups and add them.
4141 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4142 With 1 C-u, use the `ask-server' method to query the server for new
4143 groups.
4144 With 2 C-u's, use most complete method possible to query the server
4145 for new groups, and subscribe the new groups as zombies."
4146   (interactive "p")
4147   (gnus-find-new-newsgroups (or arg 1))
4148   (gnus-group-list-groups))
4149
4150 (defun gnus-group-edit-global-kill (&optional article group)
4151   "Edit the global kill file.
4152 If GROUP, edit that local kill file instead."
4153   (interactive "P")
4154   (setq gnus-current-kill-article article)
4155   (gnus-kill-file-edit-file group)
4156   (gnus-message
4157    6
4158    (substitute-command-keys
4159     (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4160             (if group "local" "global")))))
4161
4162 (defun gnus-group-edit-local-kill (article group)
4163   "Edit a local kill file."
4164   (interactive (list nil (gnus-group-group-name)))
4165   (gnus-group-edit-global-kill article group))
4166
4167 (defun gnus-group-force-update ()
4168   "Update `.newsrc' file."
4169   (interactive)
4170   (gnus-save-newsrc-file))
4171
4172 (defvar gnus-backlog-articles)
4173
4174 (defun gnus-group-suspend ()
4175   "Suspend the current Gnus session.
4176 In fact, cleanup buffers except for group mode buffer.
4177 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4178   (interactive)
4179   (gnus-run-hooks 'gnus-suspend-gnus-hook)
4180   (gnus-offer-save-summaries)
4181   ;; Kill Gnus buffers except for group mode buffer.
4182   (let ((group-buf (get-buffer gnus-group-buffer)))
4183     (mapcar (lambda (buf)
4184               (unless (or (member buf (list group-buf gnus-dribble-buffer))
4185                           (with-current-buffer buf
4186                             (eq major-mode 'message-mode)))
4187                 (gnus-kill-buffer buf)))
4188             (gnus-buffers))
4189     (setq gnus-backlog-articles nil)
4190     (gnus-kill-gnus-frames)
4191     (when group-buf
4192       (bury-buffer group-buf)
4193       (delete-windows-on group-buf t))))
4194
4195 (defun gnus-group-clear-dribble ()
4196   "Clear all information from the dribble buffer."
4197   (interactive)
4198   (gnus-dribble-clear)
4199   (gnus-message 7 "Cleared dribble buffer"))
4200
4201 (defun gnus-group-exit ()
4202   "Quit reading news after updating .newsrc.eld and .newsrc.
4203 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4204   (interactive)
4205   (when
4206       (or noninteractive                ;For gnus-batch-kill
4207           (not gnus-interactive-exit)   ;Without confirmation
4208           gnus-expert-user
4209           (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4210     (gnus-run-hooks 'gnus-exit-gnus-hook)
4211     ;; Offer to save data from non-quitted summary buffers.
4212     (gnus-offer-save-summaries)
4213     ;; Save the newsrc file(s).
4214     (gnus-save-newsrc-file)
4215     ;; Kill-em-all.
4216     (gnus-close-backends)
4217     ;; Reset everything.
4218     (gnus-clear-system)
4219     ;; Allow the user to do things after cleaning up.
4220     (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4221
4222 (defun gnus-group-quit ()
4223   "Quit reading news without updating .newsrc.eld or .newsrc.
4224 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4225   (interactive)
4226   (when (or noninteractive              ;For gnus-batch-kill
4227             (zerop (buffer-size))
4228             (not (gnus-server-opened gnus-select-method))
4229             gnus-expert-user
4230             (not gnus-current-startup-file)
4231             (gnus-yes-or-no-p
4232              (format "Quit reading news without saving %s? "
4233                      (file-name-nondirectory gnus-current-startup-file))))
4234     (gnus-run-hooks 'gnus-exit-gnus-hook)
4235     (gnus-configure-windows 'group t)
4236     (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4237                (not (zerop (save-excursion
4238                             (set-buffer gnus-dribble-buffer)
4239                             (buffer-size)))))
4240       (gnus-dribble-enter
4241        ";;; Gnus was exited on purpose without saving the .newsrc files."))
4242     (gnus-dribble-save)
4243     (gnus-close-backends)
4244     (gnus-clear-system)
4245     (gnus-kill-buffer gnus-group-buffer)
4246     ;; Allow the user to do things after cleaning up.
4247     (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4248
4249 (defun gnus-group-describe-briefly ()
4250   "Give a one line description of the group mode commands."
4251   (interactive)
4252   (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select  \\[gnus-group-next-unread-group]:Forward  \\[gnus-group-prev-unread-group]:Backward  \\[gnus-group-exit]:Exit  \\[gnus-info-find-node]:Run Info  \\[gnus-group-describe-briefly]:This help")))
4253
4254 (defun gnus-group-browse-foreign-server (method)
4255   "Browse a foreign news server.
4256 If called interactively, this function will ask for a select method
4257  (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4258 If not, METHOD should be a list where the first element is the method
4259 and the second element is the address."
4260   (interactive
4261    (list (let ((how (completing-read
4262                      "Which back end: "
4263                      (append gnus-valid-select-methods gnus-server-alist)
4264                      nil t (cons "nntp" 0) 'gnus-method-history)))
4265            ;; We either got a back end name or a virtual server name.
4266            ;; If the first, we also need an address.
4267            (if (assoc how gnus-valid-select-methods)
4268                (list (intern how)
4269                      ;; Suggested by mapjph@bath.ac.uk.
4270                      (completing-read
4271                       "Address: "
4272                       (mapcar 'list gnus-secondary-servers)))
4273              ;; We got a server name.
4274              how))))
4275   (gnus-browse-foreign-server method))
4276
4277 (defun gnus-group-set-info (info &optional method-only-group part)
4278   (when (or info part)
4279     (let* ((entry (gnus-group-entry
4280                    (or method-only-group (gnus-info-group info))))
4281            (part-info info)
4282            (info (if method-only-group (nth 2 entry) info))
4283            method)
4284       (when method-only-group
4285         (unless entry
4286           (error "Trying to change non-existent group %s" method-only-group))
4287         ;; We have received parts of the actual group info - either the
4288         ;; select method or the group parameters.  We first check
4289         ;; whether we have to extend the info, and if so, do that.
4290         (let ((len (length info))
4291               (total (if (eq part 'method) 5 6)))
4292           (when (< len total)
4293             (setcdr (nthcdr (1- len) info)
4294                     (make-list (- total len) nil)))
4295           ;; Then we enter the new info.
4296           (setcar (nthcdr (1- total) info) part-info)))
4297       (unless entry
4298         ;; This is a new group, so we just create it.
4299         (save-excursion
4300           (set-buffer gnus-group-buffer)
4301           (setq method (gnus-info-method info))
4302           (when (gnus-server-equal method "native")
4303             (setq method nil))
4304           (save-excursion
4305             (set-buffer gnus-group-buffer)
4306             (if method
4307                 ;; It's a foreign group...
4308                 (gnus-group-make-group
4309                  (gnus-group-real-name (gnus-info-group info))
4310                  (if (stringp method) method
4311                    (prin1-to-string (car method)))
4312                  (and (consp method)
4313                       (nth 1 (gnus-info-method info))))
4314               ;; It's a native group.
4315               (gnus-group-make-group (gnus-info-group info))))
4316           (gnus-message 6 "Note: New group created")
4317           (setq entry
4318                 (gnus-group-entry (gnus-group-prefixed-name
4319                                    (gnus-group-real-name (gnus-info-group info))
4320                                    (or (gnus-info-method info) gnus-select-method))))))
4321       ;; Whether it was a new group or not, we now have the entry, so we
4322       ;; can do the update.
4323       (if entry
4324           (progn
4325             (setcar (nthcdr 2 entry) info)
4326             (when (and (not (eq (car entry) t))
4327                        (gnus-active (gnus-info-group info)))
4328               (setcar entry (length
4329                              (gnus-list-of-unread-articles (car info))))))
4330         (error "No such group: %s" (gnus-info-group info))))))
4331
4332 (defun gnus-group-set-method-info (group select-method)
4333   (gnus-group-set-info select-method group 'method))
4334
4335 (defun gnus-group-set-params-info (group params)
4336   (gnus-group-set-info params group 'params))
4337
4338 (defun gnus-add-marked-articles (group type articles &optional info force)
4339   ;; Add ARTICLES of TYPE to the info of GROUP.
4340   ;; If INFO is non-nil, use that info.  If FORCE is non-nil, don't
4341   ;; add, but replace marked articles of TYPE with ARTICLES.
4342   (let ((info (or info (gnus-get-info group)))
4343         marked m)
4344     (or (not info)
4345         (and (not (setq marked (nthcdr 3 info)))
4346              (or (null articles)
4347                  (setcdr (nthcdr 2 info)
4348                          (list (list (cons type (gnus-compress-sequence
4349                                                  articles t)))))))
4350         (and (not (setq m (assq type (car marked))))
4351              (or (null articles)
4352                  (setcar marked
4353                          (cons (cons type (gnus-compress-sequence articles t) )
4354                                (car marked)))))
4355         (if force
4356             (if (null articles)
4357                 (setcar (nthcdr 3 info)
4358                         (gnus-delete-alist type (car marked)))
4359               (setcdr m (gnus-compress-sequence articles t)))
4360           (setcdr m (gnus-compress-sequence
4361                      (sort (nconc (gnus-uncompress-range (cdr m))
4362                                   (copy-sequence articles)) '<) t))))))
4363
4364 (defun gnus-add-mark (group mark article)
4365   "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4366   (let ((buffer (gnus-summary-buffer-name group)))
4367     (if (gnus-buffer-live-p buffer)
4368         (save-excursion
4369           (set-buffer (get-buffer buffer))
4370           (gnus-summary-add-mark article mark))
4371       (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4372                                 (list article)))))
4373
4374 ;;;
4375 ;;; Group timestamps
4376 ;;;
4377
4378 (defun gnus-group-set-timestamp ()
4379   "Change the timestamp of the current group to the current time.
4380 This function can be used in hooks like `gnus-select-group-hook'
4381 or `gnus-group-catchup-group-hook'."
4382   (when gnus-newsgroup-name
4383     (let ((time (current-time)))
4384       (setcdr (cdr time) nil)
4385       (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4386
4387 (defsubst gnus-group-timestamp (group)
4388   "Return the timestamp for GROUP."
4389   (gnus-group-get-parameter group 'timestamp t))
4390
4391 (defun gnus-group-timestamp-delta (group)
4392   "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4393   (let* ((time (or (gnus-group-timestamp group)
4394                    (list 0 0)))
4395          (delta (subtract-time (current-time) time)))
4396     (+ (* (nth 0 delta) 65536.0)
4397        (nth 1 delta))))
4398
4399 (defun gnus-group-timestamp-string (group)
4400   "Return a string of the timestamp for GROUP."
4401   (let ((time (gnus-group-timestamp group)))
4402     (if (not time)
4403         ""
4404       (gnus-time-iso8601 time))))
4405
4406 (defun gnus-group-list-cached (level &optional lowest)
4407   "List all groups with cached articles.
4408 If the prefix LEVEL is non-nil, it should be a number that says which
4409 level to cut off listing groups.
4410 If LOWEST, don't list groups with level lower than LOWEST.
4411
4412 This command may read the active file."
4413   (interactive "P")
4414   (when level
4415     (setq level (prefix-numeric-value level)))
4416   (when (or (not level) (>= level gnus-level-zombie))
4417     (gnus-cache-open))
4418   (funcall gnus-group-prepare-function
4419            (or level gnus-level-subscribed)
4420            #'(lambda (info)
4421                (let ((marks (gnus-info-marks info)))
4422                  (assq 'cache marks)))
4423            lowest
4424            #'(lambda (group)
4425                (or (gnus-gethash group
4426                                  gnus-cache-active-hashtb)
4427                    ;; Cache active file might use "."
4428                    ;; instead of ":".
4429                    (gnus-gethash
4430                     (mapconcat 'identity
4431                                (split-string group ":")
4432                                ".")
4433                     gnus-cache-active-hashtb))))
4434   (goto-char (point-min))
4435   (gnus-group-position-point))
4436
4437 (defun gnus-group-list-dormant (level &optional lowest)
4438   "List all groups with dormant articles.
4439 If the prefix LEVEL is non-nil, it should be a number that says which
4440 level to cut off listing groups.
4441 If LOWEST, don't list groups with level lower than LOWEST.
4442
4443 This command may read the active file."
4444   (interactive "P")
4445   (when level
4446     (setq level (prefix-numeric-value level)))
4447   (when (or (not level) (>= level gnus-level-zombie))
4448     (gnus-cache-open))
4449   (funcall gnus-group-prepare-function
4450            (or level gnus-level-subscribed)
4451            #'(lambda (info)
4452                (let ((marks (gnus-info-marks info)))
4453                  (assq 'dormant marks)))
4454            lowest
4455            'ignore)
4456   (goto-char (point-min))
4457   (gnus-group-position-point))
4458
4459 (defun gnus-group-listed-groups ()
4460   "Return a list of listed groups."
4461   (let (point groups)
4462     (goto-char (point-min))
4463     (while (setq point (text-property-not-all (point) (point-max)
4464                                               'gnus-group nil))
4465       (goto-char point)
4466       (push (symbol-name (get-text-property point 'gnus-group)) groups)
4467       (forward-char 1))
4468     groups))
4469
4470 (defun gnus-group-list-plus (&optional args)
4471   "List groups plus the current selection."
4472   (interactive "P")
4473   (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4474         (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4475         func)
4476     (push last-command-event unread-command-events)
4477     (if (featurep 'xemacs)
4478         (push (make-event 'key-press '(key ?A)) unread-command-events)
4479       (push ?A unread-command-events))
4480     (let (gnus-pick-mode keys)
4481       (setq keys (if (featurep 'xemacs)
4482                      (events-to-keys (read-key-sequence nil))
4483                    (read-key-sequence nil)))
4484       (setq func (lookup-key (current-local-map) keys)))
4485     (if (or (not func)
4486             (numberp func))
4487         (ding)
4488       (call-interactively func))))
4489
4490 (defun gnus-group-list-flush (&optional args)
4491   "Flush groups from the current selection."
4492   (interactive "P")
4493   (let ((gnus-group-list-option 'flush))
4494     (gnus-group-list-plus args)))
4495
4496 (defun gnus-group-list-limit (&optional args)
4497   "List groups limited within the current selection."
4498   (interactive "P")
4499   (let ((gnus-group-list-option 'limit))
4500     (gnus-group-list-plus args)))
4501
4502 (defun gnus-group-mark-article-read (group article)
4503   "Mark ARTICLE read."
4504   (let ((buffer (gnus-summary-buffer-name group))
4505         (mark gnus-read-mark)
4506         active n)
4507     (if (get-buffer buffer)
4508         (with-current-buffer buffer
4509           (setq active gnus-newsgroup-active)
4510           (gnus-activate-group group)
4511           (when gnus-newsgroup-prepared
4512             (when (and gnus-newsgroup-auto-expire
4513                        (memq mark gnus-auto-expirable-marks))
4514               (setq mark gnus-expirable-mark))
4515             (setq mark (gnus-request-update-mark
4516                         group article mark))
4517             (gnus-mark-article-as-read article mark)
4518             (setq gnus-newsgroup-active (gnus-active group))
4519             (when active
4520               (setq n (1+ (cdr active)))
4521               (while (<= n (cdr gnus-newsgroup-active))
4522                 (unless (eq n article)
4523                   (push n gnus-newsgroup-unselected))
4524                 (setq n (1+ n)))
4525               (setq gnus-newsgroup-unselected
4526                     (nreverse gnus-newsgroup-unselected)))))
4527       (gnus-activate-group group)
4528       (gnus-group-make-articles-read group (list article))
4529       (when (gnus-group-auto-expirable-p group)
4530         (gnus-add-marked-articles
4531          group 'expire (list article))))))
4532
4533
4534 ;;;
4535 ;;; Group compaction. -- dvl
4536 ;;;
4537
4538 (defun gnus-group-compact-group (group)
4539   "Compact the current group.
4540 Compaction means removing gaps between article numbers.  Hence, this
4541 operation is only meaningful for back ends using one file per article
4542 \(e.g. nnml).
4543
4544 Note: currently only implemented in nnml."
4545   (interactive (list (gnus-group-group-name)))
4546   (unless group
4547     (error "No group to compact"))
4548   (unless (gnus-check-backend-function 'request-compact-group group)
4549     (error "This back end does not support group compaction"))
4550   (let ((group-decoded (gnus-group-decoded-name group)))
4551     (gnus-message 6 "\
4552 Compacting group %s... (this may take a long time)"
4553                   group-decoded)
4554     (prog1
4555         (if (not (gnus-request-compact-group group))
4556             (gnus-error 3 "Couldn't compact group %s" group-decoded)
4557           (gnus-message 6 "Compacting group %s...done" group-decoded)
4558           t)
4559       ;; Invalidate the "original article" buffer which might be out of date.
4560       ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4561       ;; #### will not happen very often, I think this is acceptable.
4562       (let ((original (get-buffer gnus-original-article-buffer)))
4563         (and original (gnus-kill-buffer original)))
4564       ;; Update the group line to reflect new information (art number etc).
4565       (gnus-group-update-group-line))))
4566
4567 (provide 'gnus-group)
4568
4569 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4570 ;;; gnus-group.el ends here