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