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