1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (unless (boundp 'gnus-cache-active-hashtb)
49 (defvar gnus-cache-active-hashtb nil)))
51 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
52 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54 (defcustom gnus-group-archive-directory
55 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
56 "*The address of the (ding) archives."
57 :group 'gnus-group-foreign
60 (defcustom gnus-group-recent-archive-directory
61 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
62 "*The address of the most recent (ding) articles."
63 :group 'gnus-group-foreign
66 (defcustom gnus-no-groups-message "No Gnus is good news"
67 "*Message displayed by Gnus when no groups are available."
71 (defcustom gnus-keep-same-level nil
72 "*Non-nil means that the next newsgroup after the current will be on the same level.
73 When you type, for instance, `n' after reading the last article in the
74 current newsgroup, you will go to the next newsgroup. If this variable
75 is nil, the next newsgroup will be the next from the group
77 If this variable is non-nil, Gnus will either put you in the
78 next newsgroup with the same level, or, if no such newsgroup is
79 available, the next newsgroup with the lowest possible level higher
80 than the current level.
81 If this variable is `best', Gnus will make the next newsgroup the one
83 :group 'gnus-group-levels
84 :type '(choice (const nil)
86 (sexp :tag "other" t)))
88 (defcustom gnus-group-goto-unread t
89 "*If non-nil, movement commands will go to the next unread and subscribed group."
90 :link '(custom-manual "(gnus)Group Maneuvering")
91 :group 'gnus-group-various
94 (defcustom gnus-goto-next-group-when-activating t
95 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
96 :link '(custom-manual "(gnus)Scanning New Messages")
97 :group 'gnus-group-various
100 (defcustom gnus-permanently-visible-groups nil
101 "*Regexp to match groups that should always be listed in the group buffer.
102 This means that they will still be listed even when there are no
103 unread articles in the groups.
105 If nil, no groups are permanently visible."
106 :group 'gnus-group-listing
107 :type '(choice regexp (const nil)))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "*If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "*Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
121 (defcustom gnus-group-list-inactive-groups t
122 "*If non-nil, inactive groups will be listed."
123 :group 'gnus-group-listing
124 :group 'gnus-group-levels
127 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
128 "*Function used for sorting the group buffer.
129 This function will be called with group info entries as the arguments
130 for the groups to be sorted. Pre-made functions include
131 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
132 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
133 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
134 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136 This variable can also be a list of sorting functions. In that case,
137 the most significant sort function should be the last function in the
139 :group 'gnus-group-listing
140 :link '(custom-manual "(gnus)Sorting Groups")
141 :type '(repeat :value-to-internal (lambda (widget value)
142 (if (listp value) value (list value)))
143 :match (lambda (widget value)
145 (widget-editable-list-match widget value)))
146 (choice (function-item gnus-group-sort-by-alphabet)
147 (function-item gnus-group-sort-by-real-name)
148 (function-item gnus-group-sort-by-unread)
149 (function-item gnus-group-sort-by-level)
150 (function-item gnus-group-sort-by-score)
151 (function-item gnus-group-sort-by-method)
152 (function-item gnus-group-sort-by-server)
153 (function-item gnus-group-sort-by-rank)
154 (function :tag "other" nil))))
156 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
157 "*Format of group lines.
158 It works along the same lines as a normal formatting string,
159 with some simple extensions.
161 %M Only marked articles (character, \"*\" or \" \")
162 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
163 %L Level of subscribedness (integer)
164 %N Number of unread articles (integer)
165 %I Number of dormant articles (integer)
166 %i Number of ticked and dormant (integer)
167 %T Number of ticked articles (integer)
168 %R Number of read articles (integer)
169 %U Number of unseen articles (integer)
170 %t Estimated total number of articles (integer)
171 %y Number of unread, unticked articles (integer)
172 %G Group name (string)
173 %g Qualified group name (string)
174 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
175 %C Group comment (string)
176 %D Group description (string)
177 %s Select method (string)
178 %o Moderated group (char, \"m\")
179 %p Process mark (char)
180 %B Whether a summary buffer for the group is open (char, \"*\")
181 %O Moderated group (string, \"(m)\" or \"\")
182 %P Topic indentation (string)
183 %m Whether there is new(ish) mail in the group (char, \"%\")
184 %w Number of new(ish) mails in the group (integer)
185 %n Select from where (string)
186 %z A string that look like `<%s:%n>' if a foreign select method is used
187 %d The date the group was last entered.
188 %E Icon as defined by `gnus-group-icon-list'.
189 %F The disk space used by the articles fetched by both the cache and agent.
190 %u User defined specifier. The next character in the format string should
191 be a letter. Gnus will call the function gnus-user-format-function-X,
192 where X is the letter following %u. The function will be passed a
193 single dummy parameter as argument. The function should return a
194 string, which will be inserted into the buffer just like information
195 from any other group specifier.
197 Note that this format specification is not always respected. For
198 reasons of efficiency, when listing killed groups, this specification
199 is ignored altogether. If the spec is changed considerably, your
200 output may end up looking strange when listing both alive and killed
203 If you use %o or %O, reading the active file will be slower and quite
204 a bit of extra memory will be used. %D and %F will also worsen
205 performance. Also note that if you change the format specification to
206 include any of these specs, you must probably re-start Gnus to see
209 General format specifiers can also be used.
210 See Info node `(gnus)Formatting Variables'."
211 :link '(custom-manual "(gnus)Formatting Variables")
212 :group 'gnus-group-visual
215 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
216 "*The format specification for the group mode line.
217 It works along the same lines as a normal formatting string,
218 with some simple extensions:
220 %S The native news server.
221 %M The native select method.
222 %: \":\" if %S isn't \"\"."
223 :group 'gnus-group-visual
226 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
227 (when (featurep 'xemacs)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
229 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
231 (defcustom gnus-group-menu-hook nil
232 "Hook run after the creation of the group mode menu."
233 :group 'gnus-group-various
236 (defcustom gnus-group-catchup-group-hook nil
237 "Hook run when catching up a group from the group buffer."
238 :group 'gnus-group-various
239 :link '(custom-manual "(gnus)Group Data")
242 (defcustom gnus-group-update-group-hook nil
243 "Hook called when updating group lines."
244 :group 'gnus-group-visual
247 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
248 "*A function that is called to generate the group buffer.
249 The function is called with three arguments: The first is a number;
250 all group with a level less or equal to that number should be listed,
251 if the second is non-nil, empty groups should also be displayed. If
252 the third is non-nil, it is a number. No groups with a level lower
253 than this number should be displayed.
255 The only current function implemented is `gnus-group-prepare-flat'."
256 :group 'gnus-group-listing
259 (defcustom gnus-group-prepare-hook nil
260 "Hook called after the group buffer has been generated.
261 If you want to modify the group buffer, you can use this hook."
262 :group 'gnus-group-listing
265 (defcustom gnus-suspend-gnus-hook nil
266 "Hook called when suspending (not exiting) Gnus."
270 (defcustom gnus-exit-gnus-hook nil
271 "Hook called when exiting Gnus."
275 (defcustom gnus-after-exiting-gnus-hook nil
276 "Hook called after exiting Gnus."
280 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
281 "Hook called when a group line is changed.
282 The hook will not be called if `gnus-visual' is nil.
284 The default function `gnus-group-highlight-line' will
285 highlight the line according to the `gnus-group-highlight'
287 :group 'gnus-group-visual
290 (defcustom gnus-useful-groups
291 '(("(ding) mailing list mirrored at sunsite.auc.dk"
293 (nntp "sunsite.auc.dk"
294 (nntp-address "sunsite.auc.dk")))
297 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
301 (nndoc-article-type mbox)
302 (eval `(nndoc-address
303 ,(let ((file (nnheader-find-etc-directory
306 (error "Couldn't find doc group"))
308 "*Alist of useful group-server pairs."
309 :group 'gnus-group-listing
310 :type '(repeat (list (string :tag "Description")
312 (sexp :tag "Method"))))
314 (defcustom gnus-group-highlight
316 ((and mailp (= unread 0) (eq level 1)) .
317 gnus-group-mail-1-empty-face)
318 ((and mailp (eq level 1)) .
319 gnus-group-mail-1-face)
320 ((and mailp (= unread 0) (eq level 2)) .
321 gnus-group-mail-2-empty-face)
322 ((and mailp (eq level 2)) .
323 gnus-group-mail-2-face)
324 ((and mailp (= unread 0) (eq level 3)) .
325 gnus-group-mail-3-empty-face)
326 ((and mailp (eq level 3)) .
327 gnus-group-mail-3-face)
328 ((and mailp (= unread 0)) .
329 gnus-group-mail-low-empty-face)
331 gnus-group-mail-low-face)
333 ((and (= unread 0) (eq level 1)) .
334 gnus-group-news-1-empty-face)
335 ((and (eq level 1)) .
336 gnus-group-news-1-face)
337 ((and (= unread 0) (eq level 2)) .
338 gnus-group-news-2-empty-face)
339 ((and (eq level 2)) .
340 gnus-group-news-2-face)
341 ((and (= unread 0) (eq level 3)) .
342 gnus-group-news-3-empty-face)
343 ((and (eq level 3)) .
344 gnus-group-news-3-face)
345 ((and (= unread 0) (eq level 4)) .
346 gnus-group-news-4-empty-face)
347 ((and (eq level 4)) .
348 gnus-group-news-4-face)
349 ((and (= unread 0) (eq level 5)) .
350 gnus-group-news-5-empty-face)
351 ((and (eq level 5)) .
352 gnus-group-news-5-face)
353 ((and (= unread 0) (eq level 6)) .
354 gnus-group-news-6-empty-face)
355 ((and (eq level 6)) .
356 gnus-group-news-6-face)
357 ((and (= unread 0)) .
358 gnus-group-news-low-empty-face)
360 gnus-group-news-low-face))
361 "*Controls the highlighting of group buffer lines.
363 Below is a list of `Form'/`Face' pairs. When deciding how a a
364 particular group line should be displayed, each form is
365 evaluated. The content of the face field after the first true form is
366 used. You can change how those group lines are displayed by
367 editing the face field.
369 It is also possible to change and add form fields, but currently that
370 requires an understanding of Lisp expressions. Hopefully this will
371 change in a future release. For now, you can use the following
372 variables in the Lisp expression:
374 group: The name of the group.
375 unread: The number of unread articles in the group.
376 method: The select method used.
377 mailp: Whether it's a mail group or not.
378 level: The level of the group.
379 score: The score of the group.
380 ticked: The number of ticked articles."
381 :group 'gnus-group-visual
382 :type '(repeat (cons (sexp :tag "Form") face)))
384 (defcustom gnus-new-mail-mark ?%
385 "Mark used for groups with new mail."
386 :group 'gnus-group-visual
389 (defgroup gnus-group-icons nil
390 "Add Icons to your group buffer. "
391 :group 'gnus-group-visual)
393 (defcustom gnus-group-icon-list
395 "*Controls the insertion of icons into group buffer lines.
397 Below is a list of `Form'/`File' pairs. When deciding how a
398 particular group line should be displayed, each form is evaluated.
399 The icon from the file field after the first true form is used. You
400 can change how those group lines are displayed by editing the file
401 field. The File will either be found in the
402 `gnus-group-glyph-directory' or by designating absolute name of the
405 It is also possible to change and add form fields, but currently that
406 requires an understanding of Lisp expressions. Hopefully this will
407 change in a future release. For now, you can use the following
408 variables in the Lisp expression:
410 group: The name of the group.
411 unread: The number of unread articles in the group.
412 method: The select method used.
413 mailp: Whether it's a mail group or not.
414 newsp: Whether it's a news group or not
415 level: The level of the group.
416 score: The score of the group.
417 ticked: The number of ticked articles."
418 :group 'gnus-group-icons
419 :type '(repeat (cons (sexp :tag "Form") file)))
421 (defcustom gnus-group-name-charset-method-alist nil
422 "Alist of method and the charset for group names.
425 (((nntp \"news.com.cn\") . cn-gb-2312))"
428 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
430 (defcustom gnus-group-name-charset-group-alist
431 (if (mm-coding-system-p 'utf-8)
432 '(("[^\000-\177]" . utf-8))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
444 If non-nil, the value should be a string or an alist. If it is a string,
445 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
446 nnml:\" in the minibuffer prompt.
448 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
449 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
450 used when no prefix argument is given to `gnus-group-jump-to-group'."
451 :group 'gnus-group-various
452 :type '(choice (string :tag "Prompt string")
453 (const :tag "Empty" nil)
454 (repeat (cons (integer :tag "Argument")
455 (string :tag "Prompt string")))))
457 (defvar gnus-group-listing-limit 1000
458 "*A limit of the number of groups when listing.
459 If the number of groups is larger than the limit, list them in a
462 ;;; Internal variables
464 (defvar gnus-group-is-exiting-p nil)
465 (defvar gnus-group-is-exiting-without-update-p nil)
466 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
467 "Function for sorting the group buffer.")
469 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
470 "Function for sorting the selected groups in the group buffer.")
472 (defvar gnus-group-indentation-function nil)
473 (defvar gnus-goto-missing-group-function nil)
474 (defvar gnus-group-update-group-function nil)
475 (defvar gnus-group-goto-next-group-function nil
476 "Function to override finding the next group after listing groups.")
478 (defvar gnus-group-edit-buffer nil)
480 (defvar gnus-group-line-format-alist
481 `((?M gnus-tmp-marked-mark ?c)
482 (?S gnus-tmp-subscribed ?c)
483 (?L gnus-tmp-level ?d)
484 (?N (cond ((eq number t) "*" )
488 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
489 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
491 (?R gnus-tmp-number-of-read ?s)
492 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
493 (?t gnus-tmp-number-total ?d)
494 (?y gnus-tmp-number-of-unread ?s)
495 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
496 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
497 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
498 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
499 (?g gnus-tmp-group ?s)
500 (?G gnus-tmp-qualified-group ?s)
501 (?c (gnus-short-group-name gnus-tmp-group) ?s)
502 (?C gnus-tmp-comment ?s)
503 (?D gnus-tmp-newsgroup-description ?s)
504 (?o gnus-tmp-moderated ?c)
505 (?O gnus-tmp-moderated-string ?s)
506 (?p gnus-tmp-process-marked ?c)
507 (?s gnus-tmp-news-server ?s)
508 (?n gnus-tmp-news-method ?s)
509 (?P gnus-group-indentation ?s)
510 (?E gnus-tmp-group-icon ?s)
511 (?B gnus-tmp-summary-live ?c)
512 (?z gnus-tmp-news-method-string ?s)
513 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
514 (?w (if (gnus-news-group-p gnus-tmp-group)
518 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
521 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
522 (?u gnus-tmp-user-defined ?s)
523 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
526 (defvar gnus-group-mode-line-format-alist
527 `((?S gnus-tmp-news-server ?s)
528 (?M gnus-tmp-news-method ?s)
529 (?u gnus-tmp-user-defined ?s)
530 (?: gnus-tmp-colon ?s)))
532 (defvar gnus-topic-topology nil
533 "The complete topic hierarchy.")
535 (defvar gnus-topic-alist nil
536 "The complete topic-group alist.")
538 (defvar gnus-group-marked nil)
540 (defvar gnus-group-list-mode nil)
543 (defvar gnus-group-icon-cache nil)
545 (defvar gnus-group-listed-groups nil)
546 (defvar gnus-group-list-option nil)
552 (put 'gnus-group-mode 'mode-class 'special)
554 (gnus-define-keys gnus-group-mode-map
555 " " gnus-group-read-group
556 "=" gnus-group-select-group
557 "\r" gnus-group-select-group
558 "\M-\r" gnus-group-quick-select-group
559 "\M- " gnus-group-visible-select-group
560 [(meta control return)] gnus-group-select-group-ephemerally
561 "j" gnus-group-jump-to-group
562 "n" gnus-group-next-unread-group
563 "p" gnus-group-prev-unread-group
564 "\177" gnus-group-prev-unread-group
565 [delete] gnus-group-prev-unread-group
566 [backspace] gnus-group-prev-unread-group
567 "N" gnus-group-next-group
568 "P" gnus-group-prev-group
569 "\M-n" gnus-group-next-unread-group-same-level
570 "\M-p" gnus-group-prev-unread-group-same-level
571 "," gnus-group-best-unread-group
572 "." gnus-group-first-unread-group
573 "u" gnus-group-unsubscribe-current-group
574 "U" gnus-group-unsubscribe-group
575 "c" gnus-group-catchup-current
576 "C" gnus-group-catchup-current-all
577 "\M-c" gnus-group-clear-data
578 "l" gnus-group-list-groups
579 "L" gnus-group-list-all-groups
582 "g" gnus-group-get-new-news
583 "\M-g" gnus-group-get-new-news-this-group
584 "R" gnus-group-restart
585 "r" gnus-group-read-init-file
586 "B" gnus-group-browse-foreign-server
587 "b" gnus-group-check-bogus-groups
588 "F" gnus-group-find-new-groups
589 "\C-c\C-d" gnus-group-describe-group
590 "\M-d" gnus-group-describe-all-groups
591 "\C-c\C-a" gnus-group-apropos
592 "\C-c\M-\C-a" gnus-group-description-apropos
593 "a" gnus-group-post-news
594 "\ek" gnus-group-edit-local-kill
595 "\eK" gnus-group-edit-global-kill
596 "\C-k" gnus-group-kill-group
597 "\C-y" gnus-group-yank-group
598 "\C-w" gnus-group-kill-region
599 "\C-x\C-t" gnus-group-transpose-groups
600 "\C-c\C-l" gnus-group-list-killed
601 "\C-c\C-x" gnus-group-expire-articles
602 "\C-c\M-\C-x" gnus-group-expire-all-groups
604 "s" gnus-group-save-newsrc
605 "z" gnus-group-suspend
608 "?" gnus-group-describe-briefly
609 "\C-c\C-i" gnus-info-find-node
610 "\M-e" gnus-group-edit-group-method
611 "^" gnus-group-enter-server-mode
612 gnus-mouse-2 gnus-mouse-pick-group
613 "<" beginning-of-buffer
616 "\C-c\C-n" gnus-namazu-search
617 "\C-c\C-s" gnus-group-sort-groups
619 "\C-c\M-g" gnus-activate-all-groups
620 "\M-&" gnus-group-universal-argument
621 "#" gnus-group-mark-group
622 "\M-#" gnus-group-unmark-group)
624 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
625 "m" gnus-group-mark-group
626 "u" gnus-group-unmark-group
627 "w" gnus-group-mark-region
628 "b" gnus-group-mark-buffer
629 "r" gnus-group-mark-regexp
630 "U" gnus-group-unmark-all-groups)
632 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
633 "u" gnus-sieve-update
634 "g" gnus-sieve-generate)
636 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
637 "d" gnus-group-make-directory-group
638 "h" gnus-group-make-help-group
639 "u" gnus-group-make-useful-group
640 "a" gnus-group-make-archive-group
641 "k" gnus-group-make-kiboze-group
642 "l" gnus-group-nnimap-edit-acl
643 "m" gnus-group-make-group-simple
644 "n" gnus-group-make-shimbun-group
645 "E" gnus-group-edit-group
646 "e" gnus-group-edit-group-method
647 "p" gnus-group-edit-group-parameters
648 "v" gnus-group-add-to-virtual
649 "V" gnus-group-make-empty-virtual
650 "D" gnus-group-enter-directory
651 "f" gnus-group-make-doc-group
652 "G" gnus-group-make-nnir-group
653 "w" gnus-group-make-web-group
654 "M" gnus-group-read-ephemeral-group
655 "r" gnus-group-rename-group
656 "R" gnus-group-make-rss-group
657 "c" gnus-group-customize
658 "x" gnus-group-nnimap-expunge
659 "\177" gnus-group-delete-group
660 [delete] gnus-group-delete-group)
662 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
663 "b" gnus-group-brew-soup
664 "w" gnus-soup-save-areas
665 "s" gnus-soup-send-replies
666 "p" gnus-soup-pack-packet
667 "r" nnsoup-pack-replies)
669 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
670 "s" gnus-group-sort-groups
671 "a" gnus-group-sort-groups-by-alphabet
672 "u" gnus-group-sort-groups-by-unread
673 "l" gnus-group-sort-groups-by-level
674 "v" gnus-group-sort-groups-by-score
675 "r" gnus-group-sort-groups-by-rank
676 "m" gnus-group-sort-groups-by-method
677 "n" gnus-group-sort-groups-by-real-name)
679 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
680 "s" gnus-group-sort-selected-groups
681 "a" gnus-group-sort-selected-groups-by-alphabet
682 "u" gnus-group-sort-selected-groups-by-unread
683 "l" gnus-group-sort-selected-groups-by-level
684 "v" gnus-group-sort-selected-groups-by-score
685 "r" gnus-group-sort-selected-groups-by-rank
686 "m" gnus-group-sort-selected-groups-by-method
687 "n" gnus-group-sort-selected-groups-by-real-name)
689 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
690 "k" gnus-group-list-killed
691 "z" gnus-group-list-zombies
692 "s" gnus-group-list-groups
693 "u" gnus-group-list-all-groups
694 "A" gnus-group-list-active
695 "a" gnus-group-apropos
696 "d" gnus-group-description-apropos
697 "m" gnus-group-list-matching
698 "M" gnus-group-list-all-matching
699 "l" gnus-group-list-level
700 "c" gnus-group-list-cached
701 "?" gnus-group-list-dormant)
703 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
704 "k" gnus-group-list-limit
705 "z" gnus-group-list-limit
706 "s" gnus-group-list-limit
707 "u" gnus-group-list-limit
708 "A" gnus-group-list-limit
709 "m" gnus-group-list-limit
710 "M" gnus-group-list-limit
711 "l" gnus-group-list-limit
712 "c" gnus-group-list-limit
713 "?" gnus-group-list-limit)
715 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
716 "k" gnus-group-list-flush
717 "z" gnus-group-list-flush
718 "s" gnus-group-list-flush
719 "u" gnus-group-list-flush
720 "A" gnus-group-list-flush
721 "m" gnus-group-list-flush
722 "M" gnus-group-list-flush
723 "l" gnus-group-list-flush
724 "c" gnus-group-list-flush
725 "?" gnus-group-list-flush)
727 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
728 "k" gnus-group-list-plus
729 "z" gnus-group-list-plus
730 "s" gnus-group-list-plus
731 "u" gnus-group-list-plus
732 "A" gnus-group-list-plus
733 "m" gnus-group-list-plus
734 "M" gnus-group-list-plus
735 "l" gnus-group-list-plus
736 "c" gnus-group-list-plus
737 "?" gnus-group-list-plus)
739 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
740 "f" gnus-score-flush-cache
741 "e" gnus-score-edit-all-score)
743 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
744 "c" gnus-group-fetch-charter
745 "C" gnus-group-fetch-control
746 "d" gnus-group-describe-group
747 "f" gnus-group-fetch-faq
750 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
751 "l" gnus-group-set-current-level
752 "t" gnus-group-unsubscribe-current-group
753 "s" gnus-group-unsubscribe-group
754 "k" gnus-group-kill-group
755 "y" gnus-group-yank-group
756 "w" gnus-group-kill-region
757 "\C-k" gnus-group-kill-level
758 "z" gnus-group-kill-all-zombies)
760 (defun gnus-topic-mode-p ()
761 "Return non-nil in `gnus-topic-mode'."
762 (and (boundp 'gnus-topic-mode)
763 (symbol-value 'gnus-topic-mode)))
765 (defun gnus-group-make-menu-bar ()
766 (gnus-turn-off-edit-menu 'group)
767 (unless (boundp 'gnus-group-reading-menu)
770 gnus-group-reading-menu gnus-group-mode-map ""
772 ["Read" gnus-group-read-group
773 :included (not (gnus-topic-mode-p))
774 :active (gnus-group-group-name)]
775 ["Read " gnus-topic-read-group
776 :included (gnus-topic-mode-p)]
777 ["Select" gnus-group-select-group
778 :included (not (gnus-topic-mode-p))
779 :active (gnus-group-group-name)]
780 ["Select " gnus-topic-select-group
781 :included (gnus-topic-mode-p)]
782 ["See old articles" (gnus-group-select-group 'all)
783 :keys "C-u SPC" :active (gnus-group-group-name)]
784 ["Catch up" gnus-group-catchup-current
785 :included (not (gnus-topic-mode-p))
786 :active (gnus-group-group-name)
787 ,@(if (featurep 'xemacs) nil
788 '(:help "Mark unread articles in the current group as read"))]
789 ["Catch up " gnus-topic-catchup-articles
790 :included (gnus-topic-mode-p)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Mark unread articles in the current group or topic as read"))]
793 ["Catch up all articles" gnus-group-catchup-current-all
794 (gnus-group-group-name)]
795 ["Check for new articles" gnus-group-get-new-news-this-group
796 :included (not (gnus-topic-mode-p))
797 :active (gnus-group-group-name)
798 ,@(if (featurep 'xemacs) nil
799 '(:help "Check for new messages in current group"))]
800 ["Check for new articles " gnus-topic-get-new-news-this-topic
801 :included (gnus-topic-mode-p)
802 ,@(if (featurep 'xemacs) nil
803 '(:help "Check for new messages in current group or topic"))]
804 ["Toggle subscription" gnus-group-unsubscribe-current-group
805 (gnus-group-group-name)]
806 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
807 ,@(if (featurep 'xemacs) nil
808 '(:help "Kill (remove) current group"))]
809 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
810 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
811 ,@(if (featurep 'xemacs) nil
812 '(:help "Display description of the current group"))]
813 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
814 ["Fetch charter" gnus-group-fetch-charter
815 :active (gnus-group-group-name)
816 ,@(if (featurep 'xemacs) nil
817 '(:help "Display the charter of the current group"))]
818 ["Fetch control message" gnus-group-fetch-control
819 :active (gnus-group-group-name)
820 ,@(if (featurep 'xemacs) nil
821 '(:help "Display the archived control message for the current group"))]
822 ;; Actually one should check, if any of the marked groups gives t for
823 ;; (gnus-check-backend-function 'request-expire-articles ...)
824 ["Expire articles" gnus-group-expire-articles
825 :included (not (gnus-topic-mode-p))
826 :active (or (and (gnus-group-group-name)
827 (gnus-check-backend-function
828 'request-expire-articles
829 (gnus-group-group-name))) gnus-group-marked)]
830 ["Expire articles " gnus-topic-expire-articles
831 :included (gnus-topic-mode-p)]
832 ["Set group level..." gnus-group-set-current-level
833 (gnus-group-group-name)]
834 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
835 ["Customize" gnus-group-customize (gnus-group-group-name)]
837 ["Parameters" gnus-group-edit-group-parameters
838 :included (not (gnus-topic-mode-p))
839 :active (gnus-group-group-name)]
840 ["Parameters " gnus-topic-edit-parameters
841 :included (gnus-topic-mode-p)]
842 ["Select method" gnus-group-edit-group-method
843 (gnus-group-group-name)]
844 ["Info" gnus-group-edit-group (gnus-group-group-name)]
845 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
846 ["Global kill file" gnus-group-edit-global-kill t])))
849 gnus-group-group-menu gnus-group-mode-map ""
852 ["List unread subscribed groups" gnus-group-list-groups t]
853 ["List (un)subscribed groups" gnus-group-list-all-groups t]
854 ["List killed groups" gnus-group-list-killed gnus-killed-list]
855 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
856 ["List level..." gnus-group-list-level t]
857 ["Describe all groups" gnus-group-describe-all-groups t]
858 ["Group apropos..." gnus-group-apropos t]
859 ["Group and description apropos..." gnus-group-description-apropos t]
860 ["List groups matching..." gnus-group-list-matching t]
861 ["List all groups matching..." gnus-group-list-all-matching t]
862 ["List active file" gnus-group-list-active t]
863 ["List groups with cached" gnus-group-list-cached t]
864 ["List groups with dormant" gnus-group-list-dormant t])
866 ["Default sort" gnus-group-sort-groups t]
867 ["Sort by method" gnus-group-sort-groups-by-method t]
868 ["Sort by rank" gnus-group-sort-groups-by-rank t]
869 ["Sort by score" gnus-group-sort-groups-by-score t]
870 ["Sort by level" gnus-group-sort-groups-by-level t]
871 ["Sort by unread" gnus-group-sort-groups-by-unread t]
872 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
873 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
874 ("Sort process/prefixed"
875 ["Default sort" gnus-group-sort-selected-groups
876 (not (gnus-topic-mode-p))]
877 ["Sort by method" gnus-group-sort-selected-groups-by-method
878 (not (gnus-topic-mode-p))]
879 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
880 (not (gnus-topic-mode-p))]
881 ["Sort by score" gnus-group-sort-selected-groups-by-score
882 (not (gnus-topic-mode-p))]
883 ["Sort by level" gnus-group-sort-selected-groups-by-level
884 (not (gnus-topic-mode-p))]
885 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
886 (not (gnus-topic-mode-p))]
887 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
888 (not (gnus-topic-mode-p))]
889 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
890 (not (gnus-topic-mode-p))])
892 ["Mark group" gnus-group-mark-group
893 (and (gnus-group-group-name)
894 (not (memq (gnus-group-group-name) gnus-group-marked)))]
895 ["Unmark group" gnus-group-unmark-group
896 (and (gnus-group-group-name)
897 (memq (gnus-group-group-name) gnus-group-marked))]
898 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
899 ["Mark regexp..." gnus-group-mark-regexp t]
900 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
901 ["Mark buffer" gnus-group-mark-buffer t]
902 ["Execute command" gnus-group-universal-argument
903 (or gnus-group-marked (gnus-group-group-name))])
905 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
906 ["Kill all newsgroups in region" gnus-group-kill-region
907 :active (gnus-mark-active-p)]
908 ["Kill all zombie groups" gnus-group-kill-all-zombies
910 ["Kill all groups on level..." gnus-group-kill-level t])
912 ["Make a foreign group..." gnus-group-make-group t]
913 ["Make a foreign group..." gnus-group-make-group-simple t]
914 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
915 ["Add a directory group..." gnus-group-make-directory-group t]
916 ["Add the help group" gnus-group-make-help-group t]
917 ["Add the archive group" gnus-group-make-archive-group t]
918 ["Make a doc group..." gnus-group-make-doc-group t]
919 ["Make a web group..." gnus-group-make-web-group t]
920 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
921 ["Make a virtual group..." gnus-group-make-empty-virtual t]
922 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
923 ["Make an RSS group..." gnus-group-make-rss-group t]
924 ["Rename group..." gnus-group-rename-group
925 (gnus-check-backend-function
926 'request-rename-group (gnus-group-group-name))]
927 ["Delete group" gnus-group-delete-group
928 (gnus-check-backend-function
929 'request-delete-group (gnus-group-group-name))])
931 ["Next" gnus-group-next-group t]
932 ["Previous" gnus-group-prev-group t]
933 ["Next unread" gnus-group-next-unread-group t]
934 ["Previous unread" gnus-group-prev-unread-group t]
935 ["Next unread same level" gnus-group-next-unread-group-same-level t]
936 ["Previous unread same level"
937 gnus-group-prev-unread-group-same-level t]
938 ["Jump to group..." gnus-group-jump-to-group t]
939 ["First unread group" gnus-group-first-unread-group t]
940 ["Best unread group" gnus-group-best-unread-group t])
942 ["Generate" gnus-sieve-generate t]
943 ["Generate and update" gnus-sieve-update t])
944 ["Delete bogus groups" gnus-group-check-bogus-groups t]
945 ["Find new newsgroups" gnus-group-find-new-groups t]
946 ["Transpose" gnus-group-transpose-groups
947 (gnus-group-group-name)]
948 ["Read a directory as a group..." gnus-group-enter-directory t]))
951 gnus-group-misc-menu gnus-group-mode-map ""
954 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
955 ["Send replies" gnus-soup-send-replies
956 (fboundp 'gnus-soup-pack-packet)]
957 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
958 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
959 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
960 ["Send a mail" gnus-group-mail t]
961 ["Send a message (mail or news)" gnus-group-post-news t]
962 ["Create a local message" gnus-group-news t]
963 ["Check for new news" gnus-group-get-new-news
964 ,@(if (featurep 'xemacs) '(t)
965 '(:help "Get newly arrived articles"))
967 ["Send queued messages" gnus-delay-send-queue
968 ,@(if (featurep 'xemacs) '(t)
969 '(:help "Send all messages that are scheduled to be sent now"))
971 ["Activate all groups" gnus-activate-all-groups t]
972 ["Restart Gnus" gnus-group-restart t]
973 ["Read init file" gnus-group-read-init-file t]
974 ["Browse foreign server..." gnus-group-browse-foreign-server t]
975 ["Enter server buffer" gnus-group-enter-server-mode t]
976 ["Expire all expirable articles" gnus-group-expire-all-groups t]
977 ["Generate any kiboze groups" nnkiboze-generate-groups t]
978 ["Gnus version" gnus-version t]
979 ["Save .newsrc files" gnus-group-save-newsrc t]
980 ["Suspend Gnus" gnus-group-suspend t]
981 ["Clear dribble buffer" gnus-group-clear-dribble t]
982 ["Read manual" gnus-info-find-node t]
983 ["Flush score cache" gnus-score-flush-cache t]
984 ["Toggle topics" gnus-topic-mode t]
985 ["Send a bug report" gnus-bug t]
986 ["Exit from Gnus" gnus-group-exit
987 ,@(if (featurep 'xemacs) '(t)
988 '(:help "Quit reading news"))]
989 ["Exit without saving" gnus-group-quit t]))
991 (gnus-run-hooks 'gnus-group-menu-hook)))
993 (defvar gnus-group-toolbar-map nil)
995 ;; Emacs 21 tool bar. Should be no-op otherwise.
996 (defun gnus-group-make-tool-bar ()
998 (condition-case nil (require 'tool-bar) (error nil))
999 (fboundp 'tool-bar-add-item-from-menu)
1000 (default-value 'tool-bar-mode)
1001 (not gnus-group-toolbar-map))
1002 (setq gnus-group-toolbar-map
1003 (let ((tool-bar-map (make-sparse-keymap))
1004 (load-path (mm-image-load-path)))
1005 (tool-bar-add-item-from-menu
1006 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1007 (tool-bar-add-item-from-menu
1008 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1009 (tool-bar-add-item-from-menu
1010 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1011 (tool-bar-add-item-from-menu
1012 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1013 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1014 :help "Subscribe to the current group")
1015 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1017 :help "Unsubscribe from the current group")
1018 (tool-bar-add-item-from-menu
1019 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1021 (if gnus-group-toolbar-map
1022 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1024 (defun gnus-group-mode ()
1025 "Major mode for reading news.
1027 All normal editing commands are switched off.
1028 \\<gnus-group-mode-map>
1029 The group buffer lists (some of) the groups available. For instance,
1030 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1031 lists all zombie groups.
1033 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1034 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1036 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1038 The following commands are available:
1040 \\{gnus-group-mode-map}"
1042 (kill-all-local-variables)
1043 (when (gnus-visual-p 'group-menu 'menu)
1044 (gnus-group-make-menu-bar)
1045 (gnus-group-make-tool-bar))
1046 (gnus-simplify-mode-line)
1047 (setq major-mode 'gnus-group-mode)
1048 (setq mode-name "Group")
1049 (gnus-group-set-mode-line)
1050 (setq mode-line-process nil)
1051 (use-local-map gnus-group-mode-map)
1052 (buffer-disable-undo)
1053 (setq truncate-lines t)
1054 (setq buffer-read-only t
1055 show-trailing-whitespace nil)
1056 (gnus-set-default-directory)
1057 (gnus-update-format-specifications nil 'group 'group-mode)
1058 (gnus-update-group-mark-positions)
1063 (gnus-run-hooks 'gnus-group-mode-hook))
1065 (defun gnus-update-group-mark-positions ()
1067 (let ((gnus-process-mark ?\200)
1068 (gnus-group-update-hook nil)
1069 (gnus-group-marked '("dummy.group"))
1070 (gnus-active-hashtb (make-vector 10 0))
1072 (gnus-set-active "dummy.group" '(0 . 0))
1073 (gnus-set-work-buffer)
1074 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1075 (goto-char (point-min))
1076 (setq gnus-group-mark-positions
1077 (list (cons 'process (and (search-forward "\200" nil t)
1078 (- (point) 2))))))))
1080 (defun gnus-mouse-pick-group (e)
1081 "Enter the group under the mouse pointer."
1084 (gnus-group-read-group nil))
1086 ;; Look at LEVEL and find out what the level is really supposed to be.
1087 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1088 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1089 (defun gnus-group-default-level (&optional level number-or-nil)
1091 (gnus-group-use-permanent-levels
1092 (or (setq gnus-group-use-permanent-levels
1093 (or level (if (numberp gnus-group-use-permanent-levels)
1094 gnus-group-use-permanent-levels
1095 (or gnus-group-default-list-level
1096 gnus-level-subscribed))))
1097 gnus-group-default-list-level gnus-level-subscribed))
1101 (or level gnus-group-default-list-level gnus-level-subscribed))))
1103 (defun gnus-group-setup-buffer ()
1104 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1105 (unless (eq major-mode 'gnus-group-mode)
1108 (gnus-carpal-setup-buffer 'group))))
1110 (defun gnus-group-name-charset (method group)
1112 (setq method (gnus-find-method-for-group group)))
1113 (let ((item (assoc method gnus-group-name-charset-method-alist))
1114 (alist gnus-group-name-charset-group-alist)
1118 (while (setq item (pop alist))
1119 (if (string-match (car item) group)
1121 result (cdr item))))
1124 (defun gnus-group-name-decode (string charset)
1125 ;; Fixme: Don't decode in unibyte mode.
1126 (if (and string charset (featurep 'mule))
1127 (decode-coding-string string charset)
1130 (defun gnus-group-decoded-name (string)
1131 (let ((charset (gnus-group-name-charset nil string)))
1132 (gnus-group-name-decode string charset)))
1134 (defun gnus-group-name-encode (string charset)
1135 (if (and string charset (featurep 'mule))
1136 (encode-coding-string string charset)
1139 (defun gnus-group-encoded-name (string)
1140 (let ((charset (gnus-group-name-charset nil string)))
1141 (gnus-group-name-encode string charset)))
1143 (defun gnus-group-completing-read-group-name
1144 (prompt table &optional predicate require-match initial-contents history)
1148 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1152 (dolist (entry (prog1
1155 (push (list (gnus-group-decoded-name (car entry))) table)))
1156 (gnus-group-encoded-name
1158 prompt table predicate
1163 (defun gnus-group-list-groups (&optional level unread lowest)
1164 "List newsgroups with level LEVEL or lower that have unread articles.
1165 Default is all subscribed groups.
1166 If argument UNREAD is non-nil, groups with no unread articles are also
1169 Also see the `gnus-group-use-permanent-levels' variable."
1171 (list (if current-prefix-arg
1172 (prefix-numeric-value current-prefix-arg)
1174 (gnus-group-default-level nil t)
1175 gnus-group-default-list-level
1176 gnus-level-subscribed))))
1178 (setq level (car gnus-group-list-mode)
1179 unread (cdr gnus-group-list-mode)))
1180 (setq level (gnus-group-default-level level))
1181 (gnus-group-setup-buffer)
1182 (gnus-update-format-specifications nil 'group 'group-mode)
1183 (let ((case-fold-search nil)
1184 (props (text-properties-at (point-at-bol)))
1185 (empty (= (point-min) (point-max)))
1186 (group (gnus-group-group-name))
1188 (set-buffer gnus-group-buffer)
1189 (setq number (funcall gnus-group-prepare-function level unread lowest))
1190 (when (or (and (numberp number)
1192 (zerop (buffer-size)))
1193 ;; No groups in the buffer.
1194 (gnus-message 5 gnus-no-groups-message))
1195 ;; We have some groups displayed.
1196 (goto-char (point-max))
1197 (when (or (not gnus-group-goto-next-group-function)
1198 (not (funcall gnus-group-goto-next-group-function
1202 (goto-char (point-min)))
1204 ;; Go to the first group with unread articles.
1205 (gnus-group-search-forward t))
1207 ;; Find the right group to put point on. If the current group
1208 ;; has disappeared in the new listing, try to find the next
1209 ;; one. If no next one can be found, just leave point at the
1210 ;; first newsgroup in the buffer.
1211 (when (not (gnus-goto-char
1213 (point-min) (point-max)
1214 'gnus-group (gnus-intern-safe
1215 group gnus-active-hashtb))))
1216 (let ((newsrc (cdddr (gnus-group-entry group))))
1218 (not (gnus-goto-char
1220 (point-min) (point-max) 'gnus-group
1222 (caar newsrc) gnus-active-hashtb)))))
1223 (setq newsrc (cdr newsrc)))
1225 (goto-char (point-max))
1226 (forward-line -1)))))))
1227 ;; Adjust cursor point.
1228 (gnus-group-position-point)))
1230 (defun gnus-group-list-level (level &optional all)
1231 "List groups on LEVEL.
1232 If ALL (the prefix), also list groups that have no unread articles."
1233 (interactive "nList groups on level: \nP")
1234 (gnus-group-list-groups level all level))
1236 (defun gnus-group-prepare-logic (group test)
1237 (or (and gnus-group-listed-groups
1238 (null gnus-group-list-option)
1239 (member group gnus-group-listed-groups))
1241 ((null gnus-group-listed-groups) test)
1242 ((null gnus-group-list-option) test)
1243 (t (and (member group gnus-group-listed-groups)
1244 (if (eq gnus-group-list-option 'flush)
1248 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1249 "List all newsgroups with unread articles of level LEVEL or lower.
1250 If PREDICATE is a function, list groups that the function returns non-nil;
1251 if it is t, list groups that have no unread articles.
1252 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1253 If REGEXP is a function, list dead groups that the function returns non-nil;
1254 if it is a string, only list groups matching REGEXP."
1255 (set-buffer gnus-group-buffer)
1256 (let ((buffer-read-only nil)
1257 (newsrc (cdr gnus-newsrc-alist))
1258 (lowest (or lowest 1))
1259 (not-in-list (and gnus-group-listed-groups
1260 (copy-sequence gnus-group-listed-groups)))
1261 info clevel unread group params)
1263 (when (or (< lowest gnus-level-zombie)
1264 gnus-group-listed-groups)
1265 ;; List living groups.
1267 (setq info (car newsrc)
1268 group (gnus-info-group info)
1269 params (gnus-info-params info)
1271 unread (gnus-group-unread group))
1273 (setq not-in-list (delete group not-in-list)))
1274 (when (gnus-group-prepare-logic
1276 (and unread ; This group might be unchecked
1277 (or (not (stringp regexp))
1278 (string-match regexp group))
1279 (<= (setq clevel (gnus-info-level info)) level)
1282 ((functionp predicate)
1283 (funcall predicate info))
1284 (predicate t) ; We list all groups?
1287 (if (eq unread t) ; Unactivated?
1288 gnus-group-list-inactive-groups
1289 ; We list unactivated
1291 ; We list groups with unread articles
1292 (and gnus-list-groups-with-ticked-articles
1293 (cdr (assq 'tick (gnus-info-marks info))))
1294 ; And groups with tickeds
1295 ;; Check for permanent visibility.
1296 (and gnus-permanently-visible-groups
1297 (string-match gnus-permanently-visible-groups
1299 (memq 'visible params)
1300 (cdr (assq 'visible params)))))))
1301 (gnus-group-insert-group-line
1302 group (gnus-info-level info)
1303 (gnus-info-marks info) unread (gnus-info-method info)))))
1305 ;; List dead groups.
1306 (when (or gnus-group-listed-groups
1307 (and (>= level gnus-level-zombie)
1308 (<= lowest gnus-level-zombie)))
1309 (gnus-group-prepare-flat-list-dead
1310 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1311 gnus-level-zombie ?Z
1314 (dolist (group gnus-zombie-list)
1315 (setq not-in-list (delete group not-in-list))))
1316 (when (or gnus-group-listed-groups
1317 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1318 (gnus-group-prepare-flat-list-dead
1321 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1322 gnus-level-killed ?K regexp))
1324 (gnus-group-set-mode-line)
1325 (setq gnus-group-list-mode (cons level predicate))
1326 (gnus-run-hooks 'gnus-group-prepare-hook)
1329 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1330 ;; List zombies and killed lists somewhat faster, which was
1331 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1332 ;; this by ignoring the group format specification altogether.
1334 (if (> (length groups) gnus-group-listing-limit)
1336 (setq group (pop groups))
1337 (when (gnus-group-prepare-logic
1340 (and (stringp regexp) (string-match regexp group))
1341 (and (functionp regexp) (funcall regexp group))))
1342 (gnus-add-text-properties
1343 (point) (prog1 (1+ (point))
1344 (insert " " mark " *: "
1345 (gnus-group-decoded-name group)
1347 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1349 'gnus-level level))))
1351 (setq group (pop groups))
1352 (when (gnus-group-prepare-logic
1355 (and (stringp regexp) (string-match regexp group))
1356 (and (functionp regexp) (funcall regexp group))))
1357 (gnus-group-insert-group-line
1359 (let ((active (gnus-active group)))
1361 (if (zerop (cdr active))
1363 (- (1+ (cdr active)) (car active)))
1365 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1367 (defun gnus-group-update-group-line ()
1368 "Update the current line in the group buffer."
1369 (let* ((buffer-read-only nil)
1370 (group (gnus-group-group-name))
1371 (entry (and group (gnus-group-entry group)))
1372 gnus-group-indentation)
1375 (not (gnus-ephemeral-group-p group))
1377 (concat "(gnus-group-set-info '"
1378 (gnus-prin1-to-string (nth 2 entry))
1380 (setq gnus-group-indentation (gnus-group-group-indentation))
1382 (gnus-group-insert-group-line-info group)
1384 (gnus-group-position-point))))
1386 (defun gnus-group-insert-group-line-info (group)
1387 "Insert GROUP on the current line."
1388 (let ((entry (gnus-group-entry group))
1389 (gnus-group-indentation (gnus-group-group-indentation))
1393 ;; (Un)subscribed group.
1394 (setq info (nth 2 entry))
1395 (gnus-group-insert-group-line
1396 group (gnus-info-level info) (gnus-info-marks info)
1397 (or (car entry) t) (gnus-info-method info)))
1398 ;; This group is dead.
1399 (gnus-group-insert-group-line
1401 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1403 (if (setq active (gnus-active group))
1404 (if (zerop (cdr active))
1406 (- (1+ (cdr active)) (car active)))
1408 (gnus-method-simplify (gnus-find-method-for-group group))))))
1410 (defun gnus-number-of-unseen-articles-in-group (group)
1411 (let* ((info (nth 2 (gnus-group-entry group)))
1412 (marked (gnus-info-marks info))
1413 (seen (cdr (assq 'seen marked)))
1414 (active (gnus-active group)))
1417 (length (gnus-uncompress-range
1418 (gnus-range-difference
1419 (gnus-range-difference (list active) (gnus-info-read info))
1422 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1423 gnus-tmp-marked number
1425 "Insert a group line in the group buffer."
1426 (let* ((gnus-tmp-method
1427 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1428 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1430 (gnus-tmp-active (gnus-active gnus-tmp-group))
1431 (gnus-tmp-number-total
1433 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1435 (gnus-tmp-number-of-unread
1436 (if (numberp number) (int-to-string (max 0 number))
1438 (gnus-tmp-number-of-read
1439 (if (numberp number)
1440 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1442 (gnus-tmp-subscribed
1443 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1444 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1445 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1447 (gnus-tmp-qualified-group
1448 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1449 group-name-charset))
1451 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1453 (gnus-tmp-newsgroup-description
1454 (if gnus-description-hashtb
1455 (or (gnus-group-name-decode
1456 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1457 group-name-charset) "")
1460 (if (and gnus-moderated-hashtb
1461 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1463 (gnus-tmp-moderated-string
1464 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1465 (gnus-tmp-group-icon "==&&==")
1466 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1467 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1468 (gnus-tmp-news-method-string
1470 (format "(%s:%s)" (car gnus-tmp-method)
1471 (cadr gnus-tmp-method)) ""))
1472 (gnus-tmp-marked-mark
1473 (if (and (numberp number)
1475 (cdr (assq 'tick gnus-tmp-marked)))
1477 (gnus-tmp-summary-live
1478 (if (and (not gnus-group-is-exiting-p)
1479 (gnus-buffer-live-p (gnus-summary-buffer-name
1482 (gnus-tmp-process-marked
1483 (if (member gnus-tmp-group gnus-group-marked)
1484 gnus-process-mark ? ))
1485 (buffer-read-only nil)
1486 header gnus-tmp-header) ; passed as parameter to user-funcs.
1488 (gnus-add-text-properties
1492 (let ((gnus-tmp-group (gnus-group-name-decode
1493 gnus-tmp-group group-name-charset)))
1494 (eval gnus-group-line-format-spec)))
1495 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1496 gnus-unread ,(if (numberp number)
1497 (string-to-int gnus-tmp-number-of-unread)
1499 gnus-marked ,gnus-tmp-marked-mark
1500 gnus-indentation ,gnus-group-indentation
1501 gnus-level ,gnus-tmp-level))
1503 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1504 (gnus-run-hooks 'gnus-group-update-hook))
1506 ;; Allow XEmacs to remove front-sticky text properties.
1507 (gnus-group-remove-excess-properties)))
1509 (defun gnus-group-highlight-line ()
1510 "Highlight the current line according to `gnus-group-highlight'."
1511 (let* ((list gnus-group-highlight)
1513 (end (point-at-eol))
1514 ;; now find out where the line starts and leave point there.
1515 (beg (progn (beginning-of-line) (point)))
1516 (group (gnus-group-group-name))
1517 (entry (gnus-group-entry group))
1518 (unread (if (numberp (car entry)) (car entry) 0))
1519 (active (gnus-active group))
1520 (total (if active (1+ (- (cdr active) (car active))) 0))
1521 (info (nth 2 entry))
1522 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1523 (marked (gnus-info-marks info))
1524 (mailp (apply 'append
1527 (memq x (assoc (symbol-name
1528 (car (or method gnus-select-method)))
1529 gnus-valid-select-methods)))
1530 '(mail post-mail))))
1531 (level (or (gnus-info-level info) gnus-level-killed))
1532 (score (or (gnus-info-score info) 0))
1533 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1534 (group-age (gnus-group-timestamp-delta group))
1535 (inhibit-read-only t))
1536 ;; Eval the cars of the lists until we find a match.
1538 (not (eval (caar list))))
1539 (setq list (cdr list)))
1540 (let ((face (cdar list)))
1541 (unless (eq face (get-text-property beg 'face))
1542 (gnus-put-text-property-excluding-characters-with-faces
1544 (setq face (if (boundp face) (symbol-value face) face)))
1545 (gnus-extent-start-open beg)))
1548 (defun gnus-group-update-group (group &optional visible-only)
1549 "Update all lines where GROUP appear.
1550 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1552 ;; Can't use `save-excursion' here, so we do it manually.
1553 (let ((buf (current-buffer))
1555 (set-buffer gnus-group-buffer)
1556 (setq mark (point-marker))
1557 ;; The buffer may be narrowed.
1560 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1562 found buffer-read-only)
1563 ;; Enter the current status into the dribble buffer.
1564 (let ((entry (gnus-group-entry group)))
1566 (not (gnus-ephemeral-group-p group)))
1568 (concat "(gnus-group-set-info '"
1569 (gnus-prin1-to-string (nth 2 entry))
1571 ;; Find all group instances. If topics are in use, each group
1572 ;; may be listed in more than once.
1573 (while (setq loc (text-property-any
1574 loc (point-max) 'gnus-group ident))
1577 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1579 (gnus-group-insert-group-line-info group)
1582 (gnus-run-hooks 'gnus-group-update-group-hook)))
1583 (setq loc (1+ loc)))
1584 (unless (or found visible-only)
1585 ;; No such line in the buffer, find out where it's supposed to
1586 ;; go, and insert it there (or at the end of the buffer).
1587 (if gnus-goto-missing-group-function
1588 (funcall gnus-goto-missing-group-function group)
1589 (let ((entry (cddr (gnus-group-entry group))))
1590 (while (and entry (car entry)
1594 (point-min) (point-max)
1595 'gnus-group (gnus-intern-safe
1596 (caar entry) gnus-active-hashtb)))))
1597 (setq entry (cdr entry)))
1598 (or entry (goto-char (point-max)))))
1599 ;; Finally insert the line.
1600 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1601 (gnus-group-insert-group-line-info group)
1604 (gnus-run-hooks 'gnus-group-update-group-hook))))
1605 (when gnus-group-update-group-function
1606 (funcall gnus-group-update-group-function group))
1607 (gnus-group-set-mode-line)))
1609 (set-marker mark nil)
1612 (defun gnus-group-set-mode-line ()
1613 "Update the mode line in the group buffer."
1614 (when (memq 'group gnus-updated-mode-lines)
1615 ;; Yes, we want to keep this mode line updated.
1617 (set-buffer gnus-group-buffer)
1618 (let* ((gformat (or gnus-group-mode-line-format-spec
1619 (gnus-set-format 'group-mode)))
1620 (gnus-tmp-news-server (cadr gnus-select-method))
1621 (gnus-tmp-news-method (car gnus-select-method))
1622 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1624 gnus-tmp-header ;Dummy binding for user-defined formats
1625 ;; Get the resulting string.
1627 (and gnus-dribble-buffer
1628 (buffer-name gnus-dribble-buffer)
1629 (buffer-modified-p gnus-dribble-buffer)
1631 (set-buffer gnus-dribble-buffer)
1632 (not (zerop (buffer-size))))))
1633 (mode-string (eval gformat)))
1634 ;; Say whether the dribble buffer has been modified.
1635 (setq mode-line-modified
1636 (if modified (car gnus-mode-line-modified)
1637 (cdr gnus-mode-line-modified)))
1638 ;; If the line is too long, we chop it off.
1639 (when (> (length mode-string) max-len)
1640 (setq mode-string (substring mode-string 0 (- max-len 4))))
1642 (setq mode-line-buffer-identification
1643 (gnus-mode-line-buffer-identification
1644 (list mode-string)))
1645 (set-buffer-modified-p modified))))))
1647 (defun gnus-group-group-name ()
1648 "Get the name of the newsgroup on the current line."
1649 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1651 (symbol-name group))))
1653 (defun gnus-group-group-level ()
1654 "Get the level of the newsgroup on the current line."
1655 (get-text-property (point-at-bol) 'gnus-level))
1657 (defun gnus-group-group-indentation ()
1658 "Get the indentation of the newsgroup on the current line."
1659 (or (get-text-property (point-at-bol) 'gnus-indentation)
1660 (and gnus-group-indentation-function
1661 (funcall gnus-group-indentation-function))
1664 (defun gnus-group-group-unread ()
1665 "Get the number of unread articles of the newsgroup on the current line."
1666 (get-text-property (point-at-bol) 'gnus-unread))
1668 (defun gnus-group-new-mail (group)
1669 (if (nnmail-new-mail-p (gnus-group-real-name group))
1673 (defun gnus-group-level (group)
1674 "Return the estimated level of GROUP."
1675 (or (gnus-info-level (gnus-get-info group))
1676 (and (member group gnus-zombie-list) gnus-level-zombie)
1679 (defun gnus-group-search-forward (&optional backward all level first-too)
1680 "Find the next newsgroup with unread articles.
1681 If BACKWARD is non-nil, find the previous newsgroup instead.
1682 If ALL is non-nil, just find any newsgroup.
1683 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1685 If FIRST-TOO, the current line is also eligible as a target."
1686 (let ((way (if backward -1 1))
1687 (low gnus-level-killed)
1690 (if (and backward (progn (beginning-of-line)) (bobp))
1699 (get-text-property (point) 'gnus-group)
1703 (get-text-property (point) 'gnus-unread)))
1704 (and (numberp unread) (> unread 0)))
1705 (setq lev (get-text-property (point)
1707 (<= lev gnus-level-subscribed)))
1709 (and (setq lev (get-text-property (point)
1718 (zerop (forward-line way)))))
1720 (progn (gnus-group-position-point) t)
1721 (goto-char (or pos beg))
1724 (defun gnus-total-fetched-for (group)
1725 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1726 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1727 (size (+ size-in-cache size-in-agent))
1728 (suffix '("B" "K" "M" "G"))
1730 (cutoff (* 10 scale)))
1731 (while (> size cutoff)
1732 (setq size (/ size scale)
1733 suffix (cdr suffix)))
1734 (format "%5.1f%s" size (car suffix))))
1736 ;;; Gnus group mode commands
1740 (defun gnus-group-mark-line-p ()
1743 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1744 (eq (char-after) gnus-process-mark)))
1746 (defun gnus-group-mark-group (n &optional unmark no-advance)
1747 "Mark the current group."
1749 (let ((buffer-read-only nil)
1753 (when (setq group (gnus-group-group-name))
1754 ;; Go to the mark position.
1756 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1760 (setq gnus-group-marked (delete group gnus-group-marked))
1761 (insert-char ? 1 t))
1762 (setq gnus-group-marked
1763 (cons group (delete group gnus-group-marked)))
1764 (insert-char gnus-process-mark 1 t)))
1766 (gnus-group-next-group 1))
1768 (gnus-summary-position-point)
1771 (defun gnus-group-unmark-group (n)
1772 "Remove the mark from the current group."
1774 (gnus-group-mark-group n 'unmark)
1775 (gnus-group-position-point))
1777 (defun gnus-group-unmark-all-groups ()
1778 "Unmark all groups."
1780 (let ((groups gnus-group-marked))
1783 (gnus-group-remove-mark (pop groups)))))
1784 (gnus-group-position-point))
1786 (defun gnus-group-mark-region (unmark beg end)
1787 "Mark all groups between point and mark.
1788 If UNMARK, remove the mark instead."
1789 (interactive "P\nr")
1790 (let ((num (count-lines beg end)))
1793 (- num (gnus-group-mark-group num unmark)))))
1795 (defun gnus-group-mark-buffer (&optional unmark)
1796 "Mark all groups in the buffer.
1797 If UNMARK, remove the mark instead."
1799 (gnus-group-mark-region unmark (point-min) (point-max)))
1801 (defun gnus-group-mark-regexp (regexp)
1802 "Mark all groups that match some regexp."
1803 (interactive "sMark (regexp): ")
1804 (let ((alist (cdr gnus-newsrc-alist))
1808 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1809 (gnus-group-jump-to-group group)
1810 (gnus-group-set-mark group)))))
1811 (gnus-group-position-point))
1813 (defun gnus-group-remove-mark (group &optional test-marked)
1814 "Remove the process mark from GROUP and move point there.
1815 Return nil if the group isn't displayed."
1816 (if (gnus-group-goto-group group nil test-marked)
1818 (gnus-group-mark-group 1 'unmark t)
1820 (setq gnus-group-marked
1821 (delete group gnus-group-marked))
1824 (defun gnus-group-set-mark (group)
1825 "Set the process mark on GROUP."
1826 (if (gnus-group-goto-group group)
1828 (gnus-group-mark-group 1 nil t))
1829 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1831 (defun gnus-group-universal-argument (arg &optional groups func)
1832 "Perform any command on all groups according to the process/prefix convention."
1834 (if (eq (setq func (or func
1837 (substitute-command-keys
1838 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1840 (gnus-error 1 "Undefined key")
1841 (gnus-group-iterate arg
1843 (command-execute func))))
1844 (gnus-group-position-point))
1846 (defun gnus-group-process-prefix (n)
1847 "Return a list of groups to work on.
1848 Take into consideration N (the prefix) and the list of marked groups."
1851 (setq n (prefix-numeric-value n))
1852 ;; There is a prefix, so we return a list of the N next
1854 (let ((way (if (< n 0) -1 1))
1859 (if (setq group (gnus-group-group-name))
1860 (push group groups))
1862 (gnus-group-next-group way)))
1864 ((and (gnus-region-active-p) (mark))
1865 ;; Work on the region between point and mark.
1866 (let ((max (max (point) (mark)))
1869 (goto-char (min (point) (mark)))
1872 (push (gnus-group-group-name) groups)
1873 (zerop (gnus-group-next-group 1))
1875 (nreverse groups))))
1877 ;; No prefix, but a list of marked articles.
1878 (reverse gnus-group-marked))
1880 ;; Neither marked articles or a prefix, so we return the
1882 (let ((group (gnus-group-group-name)))
1883 (and group (list group))))))
1885 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1886 ;;; imagine why I went through these contortions...
1888 (let ((function (make-symbol "gnus-group-iterate-function"))
1889 (window (make-symbol "gnus-group-iterate-window"))
1890 (groups (make-symbol "gnus-group-iterate-groups"))
1891 (group (make-symbol "gnus-group-iterate-group")))
1893 `(defun gnus-group-iterate (arg ,function)
1894 "Iterate FUNCTION over all process/prefixed groups.
1895 FUNCTION will be called with the group name as the parameter
1896 and with point over the group in question."
1897 (let ((,groups (gnus-group-process-prefix arg))
1898 (,window (selected-window))
1901 (setq ,group (car ,groups)
1902 ,groups (cdr ,groups))
1903 (select-window ,window)
1904 (gnus-group-remove-mark ,group)
1905 (save-selected-window
1907 (funcall ,function ,group)))))))))
1909 (put 'gnus-group-iterate 'lisp-indent-function 1)
1911 ;; Selecting groups.
1913 (defun gnus-group-read-group (&optional all no-article group select-articles)
1914 "Read news in this newsgroup.
1915 If the prefix argument ALL is non-nil, already read articles become
1916 readable. IF ALL is a number, fetch this number of articles. If the
1917 optional argument NO-ARTICLE is non-nil, no article will be
1918 auto-selected upon group entry. If GROUP is non-nil, fetch that
1921 (let ((no-display (eq all 0))
1922 (group (or group (gnus-group-group-name)))
1923 number active marked entry)
1927 (error "No group on current line"))
1928 (setq marked (gnus-info-marks
1929 (nth 2 (setq entry (gnus-group-entry group)))))
1930 ;; This group might be a dead group. In that case we have to get
1931 ;; the number of unread articles from `gnus-active-hashtb'.
1933 (cond ((numberp all) all)
1935 ((setq active (gnus-active group))
1936 (- (1+ (cdr active)) (car active)))))
1937 (gnus-summary-read-group
1938 group (or all (and (numberp number)
1939 (zerop (+ number (gnus-range-length
1940 (cdr (assq 'tick marked)))
1942 (cdr (assq 'dormant marked)))))))
1943 no-article nil no-display nil select-articles)))
1945 (defun gnus-group-select-group (&optional all)
1946 "Select this newsgroup.
1947 No article is selected automatically.
1948 If the group is opened, just switch the summary buffer.
1949 If ALL is non-nil, already read articles become readable.
1950 If ALL is a positive number, fetch this number of the latest
1951 articles in the group.
1952 If ALL is a negative number, fetch this number of the earliest
1953 articles in the group."
1955 (when (and (eobp) (not (gnus-group-group-name)))
1957 (gnus-group-read-group all t))
1959 (defun gnus-group-quick-select-group (&optional all)
1960 "Select the current group \"quickly\".
1961 This means that no highlighting or scoring will be performed.
1962 If ALL (the prefix argument) is 0, don't even generate the summary
1965 This might be useful if you want to toggle threading
1966 before entering the group."
1968 (require 'gnus-score)
1970 gnus-score-find-score-files-function
1971 gnus-home-score-file
1972 gnus-apply-kill-hook
1973 gnus-summary-expunge-below)
1974 (gnus-group-read-group all t)))
1976 (defun gnus-group-visible-select-group (&optional all)
1977 "Select the current group without hiding any articles."
1979 (let ((gnus-inhibit-limiting t))
1980 (gnus-group-read-group all t)))
1982 (defun gnus-group-select-group-ephemerally ()
1983 "Select the current group without doing any processing whatsoever.
1984 You will actually be entered into a group that's a copy of
1985 the current group; no changes you make while in this group will
1988 (require 'gnus-score)
1990 gnus-score-find-score-files-function gnus-apply-kill-hook
1991 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1992 gnus-summary-mode-hook gnus-select-group-hook
1993 (group (gnus-group-group-name))
1994 (method (gnus-find-method-for-group group)))
1995 (gnus-group-read-ephemeral-group
1996 (gnus-group-prefixed-name group method) method)))
1999 (defun gnus-fetch-group (group &optional articles)
2000 "Start Gnus if necessary and enter GROUP.
2001 Returns whether the fetching was successful or not."
2002 (interactive (list (gnus-group-completing-read-group-name
2003 "Group name: " gnus-active-hashtb)))
2004 (unless (get-buffer gnus-group-buffer)
2006 (gnus-group-read-group articles nil group))
2009 (defun gnus-fetch-group-other-frame (group)
2010 "Pop up a frame and enter GROUP."
2012 (let ((window (get-buffer-window gnus-group-buffer)))
2014 (select-frame (window-frame window)))
2015 ((= (length (frame-list)) 1)
2016 (select-frame (make-frame)))
2019 (gnus-fetch-group group))
2021 (defvar gnus-ephemeral-group-server 0)
2023 (defcustom gnus-large-ephemeral-newsgroup 200
2024 "The number of articles which indicates a large ephemeral newsgroup.
2025 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2027 If the number of articles in a newsgroup is greater than this value,
2028 confirmation is required for selecting the newsgroup. If it is nil, no
2029 confirmation is required."
2030 :group 'gnus-group-select
2031 :type '(choice (const :tag "No limit" nil)
2034 (defcustom gnus-fetch-old-ephemeral-headers nil
2035 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2037 :type '(choice (const :tag "off" nil)
2040 (sexp :menu-tag "other" t)))
2042 ;; Enter a group that is not in the group buffer. Non-nil is returned
2043 ;; if selection was successful.
2044 (defun gnus-group-read-ephemeral-group (group method &optional activate
2045 quit-config request-only
2048 "Read GROUP from METHOD as an ephemeral group.
2049 If ACTIVATE, request the group first.
2050 If QUIT-CONFIG, use that window configuration when exiting from the
2052 If REQUEST-ONLY, don't actually read the group; just request it.
2053 If SELECT-ARTICLES, only select those articles.
2054 If PARAMETERS, use those as the group parameters.
2056 Return the name of the group if selection was successful."
2059 ;; (gnus-read-group "Group name: ")
2061 "Group: " gnus-active-hashtb
2063 'gnus-group-history)
2064 (gnus-read-method "From method: ")))
2065 ;; Transform the select method into a unique server.
2066 (when (stringp method)
2067 (setq method (gnus-server-to-method method)))
2069 `(,(car method) ,(concat (cadr method) "-ephemeral")
2070 (,(intern (format "%s-address" (car method))) ,(cadr method))
2072 (let ((group (if (gnus-group-foreign-p group) group
2073 (gnus-group-prefixed-name (gnus-group-real-name group)
2078 ,gnus-level-default-subscribed nil nil ,method
2081 (cons 'quit-config quit-config)
2083 (cons gnus-summary-buffer
2084 gnus-current-window-configuration)))
2087 (push method gnus-ephemeral-servers)
2088 (set-buffer gnus-group-buffer)
2089 (unless (gnus-check-server method)
2090 (error "Unable to contact server: %s" (gnus-status-message method)))
2092 (gnus-activate-group group 'scan)
2093 (unless (gnus-request-group group)
2094 (error "Couldn't request group: %s"
2095 (nnheader-get-report (car method)))))
2099 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2100 (gnus-fetch-old-headers
2101 gnus-fetch-old-ephemeral-headers))
2102 (gnus-group-read-group t t group select-articles))
2106 (message "Quit reading the ephemeral group")
2109 (defun gnus-group-jump-to-group (group &optional prompt)
2110 "Jump to newsgroup GROUP.
2112 If PROMPT (the prefix) is a number, use the prompt specified in
2113 `gnus-group-jump-to-group-prompt'."
2115 (list (mm-string-make-unibyte
2117 "Group: " gnus-active-hashtb nil
2118 (gnus-read-active-file-p)
2119 (if current-prefix-arg
2120 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2121 (or (and (stringp gnus-group-jump-to-group-prompt)
2122 gnus-group-jump-to-group-prompt)
2123 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2124 (and (stringp p) p))))
2125 'gnus-group-history))))
2127 (when (equal group "")
2128 (error "Empty group name"))
2130 (unless (gnus-ephemeral-group-p group)
2131 ;; Either go to the line in the group buffer...
2132 (unless (gnus-group-goto-group group)
2133 ;; ... or insert the line.
2134 (gnus-group-update-group group)
2135 (gnus-group-goto-group group)))
2136 ;; Adjust cursor point.
2137 (gnus-group-position-point))
2139 (defun gnus-group-goto-group (group &optional far test-marked)
2140 "Goto to newsgroup GROUP.
2141 If FAR, it is likely that the group is not on the current line.
2142 If TEST-MARKED, the line must be marked."
2146 ;; It's quite likely that we are on the right line, so
2147 ;; we check the current line first.
2149 (eq (get-text-property (point) 'gnus-group)
2150 (gnus-intern-safe group gnus-active-hashtb))
2151 (or (not test-marked) (gnus-group-mark-line-p)))
2153 ;; Previous and next line are also likely, so we check them as well.
2157 (and (eq (get-text-property (point) 'gnus-group)
2158 (gnus-intern-safe group gnus-active-hashtb))
2159 (or (not test-marked) (gnus-group-mark-line-p)))))
2165 (and (eq (get-text-property (point) 'gnus-group)
2166 (gnus-intern-safe group gnus-active-hashtb))
2167 (or (not test-marked) (gnus-group-mark-line-p)))))
2171 (goto-char (point-min))
2173 (while (and (not found)
2178 (gnus-intern-safe group gnus-active-hashtb))))
2179 (if (gnus-group-mark-line-p)
2184 ;; Search through the entire buffer.
2187 (point-min) (point-max)
2188 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2190 (defun gnus-group-next-group (n &optional silent)
2191 "Go to next N'th newsgroup.
2192 If N is negative, search backward instead.
2193 Returns the difference between N and the number of skips actually
2196 (gnus-group-next-unread-group n t nil silent))
2198 (defun gnus-group-next-unread-group (n &optional all level silent)
2199 "Go to next N'th unread newsgroup.
2200 If N is negative, search backward instead.
2201 If ALL is non-nil, choose any newsgroup, unread or not.
2202 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2203 such group can be found, the next group with a level higher than
2205 Returns the difference between N and the number of skips actually
2208 (let ((backward (< n 0))
2211 (gnus-group-search-forward
2212 backward (or (not gnus-group-goto-unread) all) level))
2216 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2217 (if level " on this level or higher" "")))
2220 (defun gnus-group-prev-group (n)
2221 "Go to previous N'th newsgroup.
2222 Returns the difference between N and the number of skips actually
2225 (gnus-group-next-unread-group (- n) t))
2227 (defun gnus-group-prev-unread-group (n)
2228 "Go to previous N'th unread newsgroup.
2229 Returns the difference between N and the number of skips actually
2232 (gnus-group-next-unread-group (- n)))
2234 (defun gnus-group-next-unread-group-same-level (n)
2235 "Go to next N'th unread newsgroup on the same level.
2236 If N is negative, search backward instead.
2237 Returns the difference between N and the number of skips actually
2240 (gnus-group-next-unread-group n t (gnus-group-group-level))
2241 (gnus-group-position-point))
2243 (defun gnus-group-prev-unread-group-same-level (n)
2244 "Go to next N'th unread newsgroup on the same level.
2245 Returns the difference between N and the number of skips actually
2248 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2249 (gnus-group-position-point))
2251 (defun gnus-group-best-unread-group (&optional exclude-group)
2252 "Go to the group with the highest level.
2253 If EXCLUDE-GROUP, do not go to that group."
2255 (goto-char (point-min))
2259 (setq unread (get-text-property (point) 'gnus-unread))
2260 (when (and (numberp unread) (> unread 0))
2261 (when (and (get-text-property (point) 'gnus-level)
2262 (< (get-text-property (point) 'gnus-level) best)
2263 (or (not exclude-group)
2264 (not (equal exclude-group (gnus-group-group-name)))))
2265 (setq best (get-text-property (point) 'gnus-level))
2266 (setq best-point (point))))
2269 (goto-char best-point))
2270 (gnus-group-position-point)
2271 (and best-point (gnus-group-group-name))))
2273 (defun gnus-group-first-unread-group ()
2274 "Go to the first group with unread articles."
2277 (let ((opoint (point))
2279 (goto-char (point-min))
2280 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2281 (and (numberp unread) ; Not a topic.
2282 (not (zerop unread))) ; Has unread articles.
2283 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2286 nil)) ; Not success.
2287 (gnus-group-position-point)))
2289 (defun gnus-group-enter-server-mode ()
2290 "Jump to the server buffer."
2292 (gnus-enter-server-buffer))
2294 (defun gnus-group-make-group-simple (&optional group)
2295 "Add a new newsgroup.
2296 The user will be prompted for GROUP."
2298 (list (completing-read "Group: " gnus-active-hashtb
2299 nil nil nil 'gnus-group-history)))
2300 (gnus-group-make-group
2301 (gnus-group-real-name group)
2302 (gnus-group-server group)))
2304 (defun gnus-group-make-group (name &optional method address args)
2305 "Add a new newsgroup.
2306 The user will be prompted for a NAME, for a select METHOD, and an
2310 (gnus-read-group "Group name: ")
2311 (gnus-read-method "From method: ")))
2313 (when (stringp method)
2314 (setq method (or (gnus-server-to-method method) method)))
2315 (let* ((meth (gnus-method-simplify
2317 (not (gnus-server-equal method gnus-select-method)))
2318 (if address (list (intern method) address)
2320 (nname (if method (gnus-group-prefixed-name name meth) name))
2322 (when (gnus-group-entry nname)
2323 (error "Group %s already exists" nname))
2324 ;; Subscribe to the new group.
2325 (gnus-group-change-level
2326 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2327 gnus-level-default-subscribed gnus-level-killed
2328 (and (gnus-group-group-name)
2329 (gnus-group-entry (gnus-group-group-name)))
2332 (gnus-set-active nname (cons 1 0))
2333 (unless (gnus-ephemeral-group-p name)
2335 (concat "(gnus-group-set-info '"
2336 (gnus-prin1-to-string (cdr info)) ")")))
2338 (gnus-group-insert-group-line-info nname)
2340 (gnus-group-position-point)
2342 ;; Load the back end and try to make the back end create
2343 ;; the group as well.
2344 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2346 gnus-valid-select-methods)
2348 (gnus-check-server meth)
2349 (when (gnus-check-backend-function 'request-create-group nname)
2350 (unless (gnus-request-create-group nname nil args)
2351 (error "Could not create group on server: %s"
2352 (nnheader-get-report backend))))
2355 (defun gnus-group-delete-groups (&optional arg)
2356 "Delete the current group. Only meaningful with editable groups."
2358 (let ((n (length (gnus-group-process-prefix arg))))
2359 (when (gnus-yes-or-no-p
2361 "Delete this 1 group? "
2362 (format "Delete these %d groups? " n)))
2363 (gnus-group-iterate arg
2365 (gnus-group-delete-group group nil t))))))
2367 (defun gnus-group-delete-group (group &optional force no-prompt)
2368 "Delete the current group. Only meaningful with editable groups.
2369 If FORCE (the prefix) is non-nil, all the articles in the group will
2370 be deleted. This is \"deleted\" as in \"removed forever from the face
2371 of the Earth\". There is no undo. The user will be prompted before
2373 Note that you also have to specify FORCE if you want the group to
2374 be removed from the server, even when it's empty."
2376 (list (gnus-group-group-name)
2377 current-prefix-arg))
2379 (error "No group to delete"))
2380 (unless (gnus-check-backend-function 'request-delete-group group)
2381 (error "This back end does not support group deletion"))
2383 (if (and (not no-prompt)
2384 (not (gnus-yes-or-no-p
2386 "Do you really want to delete %s%s? "
2387 group (if force " and all its contents" "")))))
2389 (gnus-message 6 "Deleting group %s..." group)
2390 (if (not (gnus-request-delete-group group force))
2391 (gnus-error 3 "Couldn't delete group %s" group)
2392 (gnus-message 6 "Deleting group %s...done" group)
2393 (gnus-group-goto-group group)
2394 (gnus-group-kill-group 1 t)
2395 (gnus-set-active group nil)
2397 (gnus-group-position-point)))
2399 (defun gnus-group-rename-group (group new-name)
2400 "Rename group from GROUP to NEW-NAME.
2401 When used interactively, GROUP is the group under point
2402 and NEW-NAME will be prompted for."
2405 (gnus-group-group-name)
2407 (unless (gnus-check-backend-function
2408 'request-rename-group (gnus-group-group-name))
2409 (error "This back end does not support renaming groups"))
2410 (gnus-read-group "Rename group to: "
2411 (gnus-group-real-name (gnus-group-group-name))))))
2413 (unless (gnus-check-backend-function 'request-rename-group group)
2414 (error "This back end does not support renaming groups"))
2416 (error "No group to rename"))
2417 (when (equal (gnus-group-real-name group) new-name)
2418 (error "Can't rename to the same name"))
2420 ;; We find the proper prefixed name.
2422 (if (gnus-group-native-p group)
2426 (gnus-group-prefixed-name
2427 (gnus-group-real-name new-name)
2428 (gnus-info-method (gnus-get-info group)))))
2430 (when (gnus-active new-name)
2431 (error "The group %s already exists" new-name))
2433 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2436 (gnus-group-goto-group group)
2437 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2438 (gnus-request-rename-group group new-name))))
2439 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2440 ;; We rename the group internally by killing it...
2441 (gnus-group-kill-group)
2442 ;; ... changing its name ...
2443 (setcar (cdar gnus-list-of-killed-groups) new-name)
2444 ;; ... and then yanking it. Magic!
2445 (gnus-group-yank-group)
2446 (gnus-set-active new-name (gnus-active group))
2447 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2449 (setq gnus-killed-list (delete group gnus-killed-list))
2450 (gnus-set-active group nil)
2451 (gnus-dribble-touch)
2452 (gnus-group-position-point)))
2454 (defun gnus-group-edit-group (group &optional part)
2455 "Edit the group on the current line."
2456 (interactive (list (gnus-group-group-name)))
2457 (let ((part (or part 'info))
2460 (error "No group on current line"))
2461 (unless (setq info (gnus-get-info group))
2462 (error "Killed group; can't be edited"))
2464 (gnus-close-group group))
2466 ;; Find the proper form to edit.
2467 (cond ((eq part 'method)
2468 (or (gnus-info-method info) "native"))
2470 (gnus-info-params info))
2472 ;; The proper documentation.
2474 "Editing the %s for `%s'."
2476 ((eq part 'method) "select method")
2477 ((eq part 'params) "group parameters")
2479 (gnus-group-decoded-name group))
2481 (gnus-group-edit-group-done ',part ,group form)))
2484 (gnus-create-info-command
2486 (or gnus-info-filename
2487 (get-language-info current-language-environment 'gnus-info)
2489 (cond ((eq part 'method)
2496 (defun gnus-group-edit-group-method (group)
2497 "Edit the select method of GROUP."
2498 (interactive (list (gnus-group-group-name)))
2499 (gnus-group-edit-group group 'method))
2501 (defun gnus-group-edit-group-parameters (group)
2502 "Edit the group parameters of GROUP."
2503 (interactive (list (gnus-group-group-name)))
2504 (gnus-group-edit-group group 'params))
2506 (defun gnus-group-edit-group-done (part group form)
2508 (let* ((method (cond ((eq part 'info) (nth 4 form))
2509 ((eq part 'method) form)
2511 (info (cond ((eq part 'info) form)
2512 ((eq part 'method) (gnus-get-info group))
2515 (if (or (not method)
2517 gnus-select-method method))
2518 (gnus-group-real-name (car info))
2519 (gnus-group-prefixed-name
2520 (gnus-group-real-name (car info)) method))
2522 (when (and new-group
2523 (not (equal new-group group)))
2524 (when (gnus-group-goto-group group)
2525 (gnus-group-kill-group 1))
2526 (gnus-activate-group new-group))
2528 (if (not (and info new-group))
2529 (gnus-group-set-info form (or new-group group) part)
2530 (setq info (gnus-copy-sequence info))
2531 (setcar info new-group)
2532 (unless (gnus-server-equal method "native")
2533 (unless (nthcdr 3 info)
2534 (nconc info (list nil nil)))
2535 (unless (nthcdr 4 info)
2536 (nconc info (list nil)))
2537 (gnus-info-set-method info method))
2538 (gnus-group-set-info info))
2539 (gnus-group-update-group (or new-group group))
2540 (gnus-group-position-point)))
2542 (defun gnus-group-make-useful-group (group method)
2543 "Create one of the groups described in `gnus-useful-groups'."
2545 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2547 gnus-useful-groups)))
2548 (list (cadr entry) (caddr entry))))
2549 (setq method (gnus-copy-sequence method))
2551 (while (setq entry (memq (assq 'eval method) method))
2552 (setcar entry (eval (cadar entry)))))
2553 (gnus-group-make-group group method))
2555 (defun gnus-group-make-help-group (&optional noerror)
2556 "Create the Gnus documentation group.
2557 Optional argument NOERROR modifies the behavior of this function when the
2558 group already exists:
2559 - if not given, and error is signaled,
2560 - if t, stay silent,
2561 - if anything else, just print a message."
2563 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2564 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2565 (if (gnus-group-entry name)
2566 (cond ((eq noerror nil)
2567 (error "Documentation group already exists"))
2572 (gnus-message 1 "Documentation group already exists")))
2575 (gnus-message 1 "Couldn't find doc group")
2576 (gnus-group-make-group
2577 (gnus-group-real-name name)
2578 (list 'nndoc "gnus-help"
2579 (list 'nndoc-address file)
2580 (list 'nndoc-article-type 'mbox))))
2582 (gnus-group-position-point))
2584 (defun gnus-group-make-doc-group (file type)
2585 "Create a group that uses a single file as the source."
2587 (list (read-file-name "File name: ")
2588 (and current-prefix-arg 'ask)))
2589 (when (eq type 'ask)
2594 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2596 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2597 ((= char ?b) 'babyl)
2598 ((= char ?d) 'digest)
2599 ((= char ?f) 'forward)
2601 ((= char ?g) 'guess)
2602 (t (setq err (format "%c unknown. " char))
2605 (let* ((file (expand-file-name file))
2606 (name (gnus-generate-new-group-name
2607 (gnus-group-prefixed-name
2608 (file-name-nondirectory file) '(nndoc "")))))
2609 (gnus-group-make-group
2610 (gnus-group-real-name name)
2612 (list 'nndoc-address file)
2613 (list 'nndoc-article-type (or type 'guess))))))
2615 (defvar nnweb-type-definition)
2616 (defvar gnus-group-web-type-history nil)
2617 (defvar gnus-group-web-search-history nil)
2618 (defun gnus-group-make-web-group (&optional solid)
2619 "Create an ephemeral nnweb group.
2620 If SOLID (the prefix), create a solid group."
2624 (if solid (gnus-read-group "Group name: ")
2625 (message-unique-id)))
2626 (default-type (or (car gnus-group-web-type-history)
2627 (symbol-name (caar nnweb-type-definition))))
2631 (format "Search engine type (default %s): " default-type)
2632 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2633 nnweb-type-definition)
2634 nil t nil 'gnus-group-web-type-history)
2639 (cons (or (car gnus-group-web-search-history) "") 0)
2640 'gnus-group-web-search-history))
2642 `(nnweb ,group (nnweb-search ,search)
2643 (nnweb-type ,(intern type))
2644 (nnweb-ephemeral-p t))))
2647 (gnus-pull 'nnweb-ephemeral-p method)
2648 (gnus-group-make-group group method))
2649 (gnus-group-read-ephemeral-group
2651 (cons (current-buffer)
2652 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2655 (defvar nnrss-group-alist)
2656 (defun nnrss-discover-feed (arg))
2657 (defun nnrss-save-server-data (arg)))
2658 (defun gnus-group-make-rss-group (&optional url)
2659 "Given a URL, discover if there is an RSS feed.
2660 If there is, use Gnus to create an nnrss group"
2664 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2665 (let ((feedinfo (nnrss-discover-feed url)))
2667 (let ((title (read-from-minibuffer "Title: "
2670 (desc (read-from-minibuffer "Description: "
2671 (cdr (assoc 'description
2673 (href (cdr (assoc 'href feedinfo))))
2674 (push (list title href desc)
2676 (gnus-group-unsubscribe-group
2677 (concat "nnrss:" title))
2678 (nnrss-save-server-data nil))
2679 (error "No feeds found for %s" url))))
2681 (defvar nnwarchive-type-definition)
2682 (defvar gnus-group-warchive-type-history nil)
2683 (defvar gnus-group-warchive-login-history nil)
2684 (defvar gnus-group-warchive-address-history nil)
2686 (defun gnus-group-make-warchive-group ()
2687 "Create a nnwarchive group."
2689 (require 'nnwarchive)
2690 (let* ((group (gnus-read-group "Group name: "))
2691 (default-type (or (car gnus-group-warchive-type-history)
2692 (symbol-name (caar nnwarchive-type-definition))))
2696 (format "Warchive type (default %s): " default-type)
2697 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2698 nnwarchive-type-definition)
2699 nil t nil 'gnus-group-warchive-type-history)
2701 (address (read-string "Warchive address: "
2702 nil 'gnus-group-warchive-address-history))
2703 (default-login (or (car gnus-group-warchive-login-history)
2708 (format "Warchive login (default %s): " user-mail-address)
2709 default-login 'gnus-group-warchive-login-history)
2712 `(nnwarchive ,address
2713 (nnwarchive-type ,(intern type))
2714 (nnwarchive-login ,login))))
2715 (gnus-group-make-group group method)))
2717 (defun gnus-group-make-archive-group (&optional all)
2718 "Create the (ding) Gnus archive group of the most recent articles.
2719 Given a prefix, create a full group."
2721 (let ((group (gnus-group-prefixed-name
2722 (if all "ding.archives" "ding.recent") '(nndir ""))))
2723 (when (gnus-group-entry group)
2724 (error "Archive group already exists"))
2725 (gnus-group-make-group
2726 (gnus-group-real-name group)
2727 (list 'nndir (if all "hpc" "edu")
2728 (list 'nndir-directory
2729 (if all gnus-group-archive-directory
2730 gnus-group-recent-archive-directory))))
2731 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2733 (defun gnus-group-make-directory-group (dir)
2734 "Create an nndir group.
2735 The user will be prompted for a directory. The contents of this
2736 directory will be used as a newsgroup. The directory should contain
2737 mail messages or news articles in files that have numeric names."
2739 (list (read-file-name "Create group from directory: ")))
2740 (unless (file-exists-p dir)
2741 (error "No such directory"))
2742 (unless (file-directory-p dir)
2743 (error "Not a directory"))
2747 (while (or (not group) (gnus-group-entry group))
2749 (gnus-group-prefixed-name
2750 (expand-file-name ext dir)
2752 (setq ext (format "<%d>" (setq i (1+ i)))))
2753 (gnus-group-make-group
2754 (gnus-group-real-name group)
2755 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2757 (defvar nnkiboze-score-file)
2758 (defun gnus-group-make-kiboze-group (group address scores)
2759 "Create an nnkiboze group.
2760 The user will be prompted for a name, a regexp to match groups, and
2761 score file entries for articles to include in the group."
2764 (read-string "nnkiboze group name: ")
2765 (read-string "Source groups (regexp): ")
2766 (let ((headers (mapcar 'list
2767 '("subject" "from" "number" "date" "message-id"
2768 "references" "chars" "lines" "xref"
2769 "followup" "all" "body" "head")))
2770 scores header regexp regexps)
2771 (while (not (equal "" (setq header (completing-read
2772 "Match on header: " headers nil t))))
2774 (while (not (equal "" (setq regexp (read-string
2775 (format "Match on %s (regexp): "
2777 (push (list regexp nil nil 'r) regexps))
2778 (push (cons header regexps) scores))
2780 (gnus-group-make-group group "nnkiboze" address)
2781 (let* ((nnkiboze-current-group group)
2782 (score-file (car (nnkiboze-score-file "")))
2783 (score-dir (file-name-directory score-file)))
2784 (unless (file-exists-p score-dir)
2785 (make-directory score-dir))
2786 (with-temp-file score-file
2787 (let (emacs-lisp-mode-hook)
2788 (pp scores (current-buffer))))))
2790 (defun gnus-group-add-to-virtual (n vgroup)
2791 "Add the current group to a virtual group."
2793 (list current-prefix-arg
2794 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2796 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2797 (error "%s is not an nnvirtual group" vgroup))
2798 (gnus-close-group vgroup)
2799 (let* ((groups (gnus-group-process-prefix n))
2800 (method (gnus-info-method (gnus-get-info vgroup))))
2801 (setcar (cdr method)
2803 (nth 1 method) "\\|"
2806 (gnus-group-remove-mark s)
2807 (concat "\\(^" (regexp-quote s) "$\\)"))
2809 (gnus-group-position-point))
2811 (defun gnus-group-make-empty-virtual (group)
2812 "Create a new, fresh, empty virtual group."
2813 (interactive "sCreate new, empty virtual group: ")
2814 (let* ((method (list 'nnvirtual "^$"))
2815 (pgroup (gnus-group-prefixed-name group method)))
2816 ;; Check whether it exists already.
2817 (when (gnus-group-entry pgroup)
2818 (error "Group %s already exists" pgroup))
2819 ;; Subscribe the new group after the group on the current line.
2820 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2821 (gnus-group-update-group pgroup)
2823 (gnus-group-position-point)))
2825 (defun gnus-group-enter-directory (dir)
2826 "Enter an ephemeral nneething group."
2827 (interactive "DDirectory to read: ")
2828 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2829 (leaf (gnus-group-prefixed-name
2830 (file-name-nondirectory (directory-file-name dir))
2832 (name (gnus-generate-new-group-name leaf)))
2833 (unless (gnus-group-read-ephemeral-group
2835 (cons (current-buffer)
2836 (if (eq major-mode 'gnus-summary-mode)
2838 (error "Couldn't enter %s" dir))))
2841 (autoload 'nnimap-expunge "nnimap")
2842 (autoload 'nnimap-acl-get "nnimap")
2843 (autoload 'nnimap-acl-edit "nnimap"))
2845 (defun gnus-group-nnimap-expunge (group)
2846 "Expunge deleted articles in current nnimap GROUP."
2847 (interactive (list (gnus-group-group-name)))
2848 (let ((mailbox (gnus-group-real-name group)) method)
2850 (error "No group on current line"))
2851 (unless (gnus-get-info group)
2852 (error "Killed group; can't be edited"))
2853 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2854 (error "%s is not an nnimap group" group))
2855 (nnimap-expunge mailbox (cadr method))))
2857 (defun gnus-group-nnimap-edit-acl (group)
2858 "Edit the Access Control List of current nnimap GROUP."
2859 (interactive (list (gnus-group-group-name)))
2860 (let ((mailbox (gnus-group-real-name group)) method acl)
2862 (error "No group on current line"))
2863 (unless (gnus-get-info group)
2864 (error "Killed group; can't be edited"))
2865 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2866 (error "%s is not an nnimap group" group))
2867 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2868 (error "Server does not support ACL's"))
2869 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2871 An access control list is a list of (identifier . rights) elements.
2873 The identifier string specifies the corresponding user. The
2874 identifier \"anyone\" is reserved to refer to the universal identity.
2876 Rights is a string listing a (possibly empty) set of alphanumeric
2877 characters, each character listing a set of operations which is being
2878 controlled. Letters are reserved for ``standard'' rights, listed
2879 below. Digits are reserved for implementation or site defined rights.
2881 l - lookup (mailbox is visible to LIST/LSUB commands)
2882 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2883 SEARCH, COPY from mailbox)
2884 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2885 w - write (STORE flags other than \\SEEN and \\DELETED)
2886 i - insert (perform APPEND, COPY into mailbox)
2887 p - post (send mail to submission address for mailbox,
2888 not enforced by IMAP4 itself)
2889 c - create and delete mailbox (CREATE new sub-mailboxes in any
2890 implementation-defined hierarchy, RENAME or DELETE mailbox)
2891 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2892 a - administer (perform SETACL)" group)
2895 ,mailbox ',method ',acl form)))))
2897 ;; Group sorting commands
2898 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2900 (defun gnus-group-sort-groups (func &optional reverse)
2901 "Sort the group buffer according to FUNC.
2902 When used interactively, the sorting function used will be
2903 determined by the `gnus-group-sort-function' variable.
2904 If REVERSE (the prefix), reverse the sorting order."
2905 (interactive (list gnus-group-sort-function current-prefix-arg))
2906 (funcall gnus-group-sort-alist-function
2907 (gnus-make-sort-function func) reverse)
2908 (gnus-group-unmark-all-groups)
2909 (gnus-group-list-groups)
2910 (gnus-dribble-touch))
2912 (defun gnus-group-sort-flat (func reverse)
2913 ;; We peel off the dummy group from the alist.
2915 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2916 (pop gnus-newsrc-alist))
2918 (setq gnus-newsrc-alist
2919 (sort gnus-newsrc-alist func))
2921 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2922 ;; Regenerate the hash table.
2923 (gnus-make-hashtable-from-newsrc-alist)))
2925 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2926 "Sort the group buffer alphabetically by group name.
2927 If REVERSE, sort in reverse order."
2929 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2931 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2932 "Sort the group buffer alphabetically by real (unprefixed) group name.
2933 If REVERSE, sort in reverse order."
2935 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2937 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2938 "Sort the group buffer by number of unread articles.
2939 If REVERSE, sort in reverse order."
2941 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2943 (defun gnus-group-sort-groups-by-level (&optional reverse)
2944 "Sort the group buffer by group level.
2945 If REVERSE, sort in reverse order."
2947 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2949 (defun gnus-group-sort-groups-by-score (&optional reverse)
2950 "Sort the group buffer by group score.
2951 If REVERSE, sort in reverse order."
2953 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2955 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2956 "Sort the group buffer by group rank.
2957 If REVERSE, sort in reverse order."
2959 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2961 (defun gnus-group-sort-groups-by-method (&optional reverse)
2962 "Sort the group buffer alphabetically by back end name.
2963 If REVERSE, sort in reverse order."
2965 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2967 (defun gnus-group-sort-groups-by-server (&optional reverse)
2968 "Sort the group buffer alphabetically by server name.
2969 If REVERSE, sort in reverse order."
2971 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2973 ;;; Selected group sorting.
2975 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2976 "Sort the process/prefixed groups."
2977 (interactive (list current-prefix-arg gnus-group-sort-function))
2978 (let ((groups (gnus-group-process-prefix n)))
2979 (funcall gnus-group-sort-selected-function
2980 groups (gnus-make-sort-function func) reverse)
2981 (gnus-group-unmark-all-groups)
2982 (gnus-group-list-groups)
2983 (gnus-dribble-touch)))
2985 (defun gnus-group-sort-selected-flat (groups func reverse)
2986 (let (entries infos)
2987 ;; First find all the group entries for these groups.
2989 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2991 ;; Then sort the infos.
2995 (lambda (entry) (car entry))
2996 (setq entries (nreverse entries)))
2999 (setq infos (nreverse infos)))
3000 ;; Go through all the infos and replace the old entries
3001 ;; with the new infos.
3003 (setcar (car entries) (pop infos))
3005 ;; Update the hashtable.
3006 (gnus-make-hashtable-from-newsrc-alist)))
3008 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3009 "Sort the group buffer alphabetically by group name.
3010 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3011 sort in reverse order."
3012 (interactive (gnus-interactive "P\ny"))
3013 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3015 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3016 "Sort the group buffer alphabetically by real group name.
3017 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3018 sort in reverse order."
3019 (interactive (gnus-interactive "P\ny"))
3020 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3022 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3023 "Sort the group buffer by number of unread articles.
3024 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3025 sort in reverse order."
3026 (interactive (gnus-interactive "P\ny"))
3027 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3029 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3030 "Sort the group buffer by group level.
3031 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3032 sort in reverse order."
3033 (interactive (gnus-interactive "P\ny"))
3034 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3036 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3037 "Sort the group buffer by group score.
3038 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3039 sort in reverse order."
3040 (interactive (gnus-interactive "P\ny"))
3041 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3043 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3044 "Sort the group buffer by group rank.
3045 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3046 sort in reverse order."
3047 (interactive (gnus-interactive "P\ny"))
3048 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3050 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3051 "Sort the group buffer alphabetically by back end name.
3052 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3053 sort in reverse order."
3054 (interactive (gnus-interactive "P\ny"))
3055 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3057 ;;; Sorting predicates.
3059 (defun gnus-group-sort-by-alphabet (info1 info2)
3060 "Sort alphabetically."
3061 (string< (gnus-info-group info1) (gnus-info-group info2)))
3063 (defun gnus-group-sort-by-real-name (info1 info2)
3064 "Sort alphabetically on real (unprefixed) names."
3065 (string< (gnus-group-real-name (gnus-info-group info1))
3066 (gnus-group-real-name (gnus-info-group info2))))
3068 (defun gnus-group-sort-by-unread (info1 info2)
3069 "Sort by number of unread articles."
3070 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3071 (n2 (gnus-group-unread (gnus-info-group info1))))
3072 (< (or (and (numberp n1) n1) 0)
3073 (or (and (numberp n2) n2) 0))))
3075 (defun gnus-group-sort-by-level (info1 info2)
3077 (< (gnus-info-level info1) (gnus-info-level info2)))
3079 (defun gnus-group-sort-by-method (info1 info2)
3080 "Sort alphabetically by back end name."
3081 (string< (car (gnus-find-method-for-group
3082 (gnus-info-group info1) info1))
3083 (car (gnus-find-method-for-group
3084 (gnus-info-group info2) info2))))
3086 (defun gnus-group-sort-by-server (info1 info2)
3087 "Sort alphabetically by server name."
3088 (string< (gnus-method-to-full-server-name
3089 (gnus-find-method-for-group
3090 (gnus-info-group info1) info1))
3091 (gnus-method-to-full-server-name
3092 (gnus-find-method-for-group
3093 (gnus-info-group info2) info2))))
3095 (defun gnus-group-sort-by-score (info1 info2)
3096 "Sort by group score."
3097 (> (gnus-info-score info1) (gnus-info-score info2)))
3099 (defun gnus-group-sort-by-rank (info1 info2)
3100 "Sort by level and score."
3101 (let ((level1 (gnus-info-level info1))
3102 (level2 (gnus-info-level info2)))
3103 (or (< level1 level2)
3104 (and (= level1 level2)
3105 (> (gnus-info-score info1) (gnus-info-score info2))))))
3109 (defun gnus-group-clear-data (&optional arg)
3110 "Clear all marks and read ranges from the current group."
3112 (gnus-group-iterate arg
3115 (gnus-info-clear-data (setq info (gnus-get-info group)))
3116 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3117 (when (gnus-group-goto-group group)
3118 (gnus-group-update-group-line))))))
3120 (defun gnus-group-clear-data-on-native-groups ()
3121 "Clear all marks and read ranges from all native groups."
3123 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3124 (let ((alist (cdr gnus-newsrc-alist))
3126 (while (setq info (pop alist))
3127 (when (gnus-group-native-p (gnus-info-group info))
3128 (gnus-info-clear-data info)))
3129 (gnus-get-unread-articles)
3130 (gnus-dribble-touch)
3131 (when (gnus-y-or-n-p
3132 "Move the cache away to avoid problems in the future? ")
3133 (call-interactively 'gnus-cache-move-cache)))))
3135 (defun gnus-info-clear-data (info)
3136 "Clear all marks and read ranges from INFO."
3137 (let ((group (gnus-info-group info))
3139 (dolist (el (gnus-info-marks info))
3140 (push `(,(cdr el) add (,(car el))) action))
3141 (push `(,(gnus-info-read info) add (read)) action)
3144 (gnus-request-set-mark ,group ',action)
3145 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3146 (gnus-info-set-read ',info ',(gnus-info-read info))
3147 (when (gnus-group-goto-group ,group)
3148 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3149 (gnus-group-update-group-line))))
3150 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3152 (gnus-request-set-mark group action)
3153 (gnus-info-set-read info nil)
3154 (when (gnus-info-marks info)
3155 (gnus-info-set-marks info nil))))
3157 ;; Group catching up.
3159 (defun gnus-group-catchup-current (&optional n all)
3160 "Mark all unread articles in the current newsgroup as read.
3161 If prefix argument N is numeric, the next N newsgroups will be
3162 caught up. If ALL is non-nil, marked articles will also be marked as
3163 read. Cross references (Xref: header) of articles are ignored.
3164 The number of newsgroups that this function was unable to catch
3167 (let ((groups (gnus-group-process-prefix n))
3170 (unless groups (error "No groups selected"))
3172 (or (not gnus-interactive-catchup) ;Without confirmation?
3177 "Do you really want to mark all articles in %s as read? "
3178 "Mark all unread articles in %s as read? ")
3179 (if (= (length groups) 1)
3181 (format "these %d groups" (length groups)))))))
3183 (while (setq group (pop groups))
3184 (gnus-group-remove-mark group)
3185 ;; Virtual groups have to be given special treatment.
3186 (let ((method (gnus-find-method-for-group group)))
3187 (when (eq 'nnvirtual (car method))
3188 (nnvirtual-catchup-group
3189 (gnus-group-real-name group) (nth 1 method) all)))
3190 (if (>= (gnus-group-level group) gnus-level-zombie)
3191 (gnus-message 2 "Dead groups can't be caught up")
3193 (gnus-group-goto-group group)
3194 (gnus-group-catchup group all))
3195 (gnus-group-update-group-line)
3196 (setq ret (1+ ret)))))
3197 (gnus-group-next-unread-group 1)
3200 (defun gnus-group-catchup-current-all (&optional n)
3201 "Mark all articles in current newsgroup as read.
3202 Cross references (Xref: header) of articles are ignored."
3204 (gnus-group-catchup-current n 'all))
3206 (defun gnus-group-catchup (group &optional all)
3207 "Mark all articles in GROUP as read.
3208 If ALL is non-nil, all articles are marked as read.
3209 The return value is the number of articles that were marked as read,
3210 or nil if no action could be taken."
3211 (let* ((entry (gnus-group-entry group))
3213 (marks (gnus-info-marks (nth 2 entry)))
3214 (unread (gnus-sequence-of-unread-articles group)))
3215 ;; Remove entries for this group.
3216 (nnmail-purge-split-history (gnus-group-real-name group))
3217 ;; Do the updating only if the newsgroup isn't killed.
3218 (if (not (numberp (car entry)))
3219 (gnus-message 1 "Can't catch up %s; non-active group" group)
3220 (gnus-update-read-articles group nil)
3222 ;; Nix out the lists of marks and dormants.
3223 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3225 (list (cdr (assq 'dormant marks))
3227 (setq unread (gnus-range-add (gnus-range-add
3228 unread (cdr (assq 'dormant marks)))
3229 (cdr (assq 'tick marks))))
3230 (gnus-add-marked-articles group 'tick nil nil 'force)
3231 (gnus-add-marked-articles group 'dormant nil nil 'force))
3232 ;; Do auto-expirable marks if that's required.
3233 (when (gnus-group-auto-expirable-p group)
3234 (gnus-range-map (lambda (article)
3235 (gnus-add-marked-articles group 'expire (list article))
3236 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3238 (let ((gnus-newsgroup-name group))
3239 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3242 (defun gnus-group-expire-articles (&optional n)
3243 "Expire all expirable articles in the current newsgroup.
3244 Uses the process/prefix convention."
3246 (let ((groups (gnus-group-process-prefix n))
3249 (error "No groups to expire"))
3250 (while (setq group (pop groups))
3251 (gnus-group-remove-mark group)
3252 (gnus-group-expire-articles-1 group)
3253 (gnus-dribble-touch)
3254 (gnus-group-position-point))))
3256 (defun gnus-group-expire-articles-1 (group)
3257 (when (gnus-check-backend-function 'request-expire-articles group)
3258 (gnus-message 6 "Expiring articles in %s..." group)
3259 (let* ((info (gnus-get-info group))
3260 (expirable (if (gnus-group-total-expirable-p group)
3261 (cons nil (gnus-list-of-read-articles group))
3262 (assq 'expire (gnus-info-marks info))))
3263 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3264 (nnmail-expiry-target
3265 (or (gnus-group-find-parameter group 'expiry-target)
3266 nnmail-expiry-target)))
3268 (gnus-check-group group)
3271 (gnus-compress-sequence
3273 ;; We set the expiry variables to the group
3275 (let ((nnmail-expiry-wait-function nil)
3276 (nnmail-expiry-wait expiry-wait))
3277 (gnus-request-expire-articles
3278 (gnus-uncompress-sequence (cdr expirable)) group))
3279 ;; Just expire using the normal expiry values.
3280 (gnus-request-expire-articles
3281 (gnus-uncompress-sequence (cdr expirable)) group))))
3282 (gnus-close-group group))
3283 (gnus-message 6 "Expiring articles in %s...done" group)
3284 ;; Return the list of un-expired articles.
3287 (defun gnus-group-expire-all-groups ()
3288 "Expire all expirable articles in all newsgroups."
3291 (gnus-message 5 "Expiring...")
3292 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3293 (cdr gnus-newsrc-alist))))
3294 (gnus-group-expire-articles nil)))
3295 (gnus-group-position-point)
3296 (gnus-message 5 "Expiring...done"))
3298 (defun gnus-group-set-current-level (n level)
3299 "Set the level of the next N groups to LEVEL."
3304 (unless (gnus-group-process-prefix current-prefix-arg)
3305 (error "No group on the current line"))
3307 (let ((s (read-string
3308 (format "Level (default %s): "
3309 (or (gnus-group-group-level)
3310 gnus-level-default-subscribed)))))
3311 (if (string-match "^\\s-*$" s)
3312 (int-to-string (or (gnus-group-group-level)
3313 gnus-level-default-subscribed))
3315 (unless (and (>= level 1) (<= level gnus-level-killed))
3316 (error "Invalid level: %d" level))
3317 (let ((groups (gnus-group-process-prefix n))
3319 (while (setq group (pop groups))
3320 (gnus-group-remove-mark group)
3321 (gnus-message 6 "Changed level of %s from %d to %d"
3322 group (or (gnus-group-group-level) gnus-level-killed)
3324 (gnus-group-change-level
3325 group level (or (gnus-group-group-level) gnus-level-killed))
3326 (gnus-group-update-group-line)))
3327 (gnus-group-position-point))
3329 (defun gnus-group-unsubscribe (&optional n)
3330 "Unsubscribe the current group."
3332 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3334 (defun gnus-group-subscribe (&optional n)
3335 "Subscribe the current group."
3337 (gnus-group-unsubscribe-current-group n 'subscribe))
3339 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3340 "Toggle subscription of the current group.
3341 If given numerical prefix, toggle the N next groups."
3343 (dolist (group (gnus-group-process-prefix n))
3344 (gnus-group-remove-mark group)
3345 (gnus-group-unsubscribe-group
3348 ((eq do-sub 'unsubscribe)
3349 gnus-level-default-unsubscribed)
3350 ((eq do-sub 'subscribe)
3351 gnus-level-default-subscribed)
3352 ((<= (gnus-group-group-level) gnus-level-subscribed)
3353 gnus-level-default-unsubscribed)
3355 gnus-level-default-subscribed))
3357 (gnus-group-update-group-line))
3358 (gnus-group-next-group 1))
3360 (defun gnus-group-unsubscribe-group (group &optional level silent)
3361 "Toggle subscription to GROUP.
3362 Killed newsgroups are subscribed. If SILENT, don't try to update the
3365 (list (gnus-group-completing-read-group-name
3366 "Group: " gnus-active-hashtb nil
3367 (gnus-read-active-file-p)
3369 'gnus-group-history)))
3370 (let ((newsrc (gnus-group-entry group)))
3372 ((string-match "^[ \t]*$" group)
3373 (error "Empty group name"))
3375 ;; Toggle subscription flag.
3376 (gnus-group-change-level
3377 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3378 gnus-level-subscribed)
3379 (1+ gnus-level-subscribed)
3380 gnus-level-default-subscribed)))
3382 (gnus-group-update-group group)))
3383 ((and (stringp group)
3384 (or (not (gnus-read-active-file-p))
3385 (gnus-active group)))
3386 ;; Add new newsgroup.
3387 (gnus-group-change-level
3389 (if level level gnus-level-default-subscribed)
3390 (or (and (member group gnus-zombie-list)
3393 (when (gnus-group-group-name)
3394 (gnus-group-entry (gnus-group-group-name))))
3396 (gnus-group-update-group group)))
3397 (t (error "No such newsgroup: %s" group)))
3398 (gnus-group-position-point)))
3400 (defun gnus-group-transpose-groups (n)
3401 "Move the current newsgroup up N places.
3402 If given a negative prefix, move down instead. The difference between
3403 N and the number of steps taken is returned."
3405 (unless (gnus-group-group-name)
3406 (error "No group on current line"))
3407 (gnus-group-kill-group 1)
3409 (forward-line (- n))
3410 (gnus-group-yank-group)
3411 (gnus-group-position-point)))
3413 (defun gnus-group-kill-all-zombies (&optional dummy)
3414 "Kill all zombie newsgroups.
3415 The optional DUMMY should always be nil."
3416 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3418 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3419 (setq gnus-zombie-list nil)
3420 (gnus-dribble-touch)
3421 (gnus-group-list-groups)))
3423 (defun gnus-group-kill-region (begin end)
3424 "Kill newsgroups in current region (excluding current point).
3425 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3438 (beginning-of-line) ;Important when LINES < 1
3439 (gnus-group-kill-group lines)))
3441 (defun gnus-group-kill-group (&optional n discard)
3442 "Kill the next N groups.
3443 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3444 However, only groups that were alive can be yanked; already killed
3445 groups or zombie groups can't be yanked.
3446 The return value is the name of the group that was killed, or a list
3449 (let ((buffer-read-only nil)
3450 (groups (gnus-group-process-prefix n))
3451 group entry level out)
3452 (if (< (length groups) 10)
3453 ;; This is faster when there are few groups.
3455 (push (setq group (pop groups)) out)
3456 (gnus-group-remove-mark group)
3457 (setq level (gnus-group-group-level))
3459 (when (and (not discard)
3460 (setq entry (gnus-group-entry group)))
3463 (gnus-group-goto-group ,(gnus-group-group-name))
3464 (gnus-group-yank-group)))
3465 (push (cons (car entry) (nth 2 entry))
3466 gnus-list-of-killed-groups))
3467 (gnus-group-change-level
3468 (if entry entry group) gnus-level-killed (if entry nil level))
3469 (message "Killed group %s" group))
3470 ;; If there are lots and lots of groups to be killed, we use
3471 ;; this thing instead.
3472 (dolist (group (nreverse groups))
3473 (gnus-group-remove-mark group)
3475 (push group gnus-killed-list)
3476 (setq gnus-newsrc-alist
3477 (delq (assoc group gnus-newsrc-alist)
3479 (when gnus-group-change-level-function
3480 (funcall gnus-group-change-level-function
3481 group gnus-level-killed 3))
3483 ((setq entry (gnus-group-entry group))
3484 (push (cons (car entry) (nth 2 entry))
3485 gnus-list-of-killed-groups)
3486 (setcdr (cdr entry) (cdddr entry)))
3487 ((member group gnus-zombie-list)
3488 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3489 ;; There may be more than one instance displayed.
3490 (while (gnus-group-goto-group group)
3491 (gnus-delete-line)))
3492 (gnus-make-hashtable-from-newsrc-alist))
3494 (gnus-group-position-point)
3495 (if (< (length out) 2) (car out) (nreverse out))))
3497 (defun gnus-group-yank-group (&optional arg)
3498 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3499 The numeric ARG specifies how many newsgroups are to be yanked. The
3500 name of the newsgroup yanked is returned, or (if several groups are
3501 yanked) a list of yanked groups is returned."
3503 (setq arg (or arg 1))
3504 (let (info group prev out)
3505 (while (>= (decf arg) 0)
3506 (when (not (setq info (pop gnus-list-of-killed-groups)))
3507 (error "No more newsgroups to yank"))
3508 (push (setq group (nth 1 info)) out)
3509 ;; Find which newsgroup to insert this one before - search
3510 ;; backward until something suitable is found. If there are no
3511 ;; other newsgroups in this buffer, just make this newsgroup the
3513 (setq prev (gnus-group-group-name))
3514 (gnus-group-change-level
3515 info (gnus-info-level (cdr info)) gnus-level-killed
3516 (and prev (gnus-group-entry prev))
3518 (gnus-group-insert-group-line-info group)
3520 `(when (gnus-group-goto-group ,group)
3521 (gnus-group-kill-group 1))))
3523 (gnus-group-position-point)
3524 (if (< (length out) 2) (car out) (nreverse out))))
3526 (defun gnus-group-kill-level (level)
3527 "Kill all groups that is on a certain LEVEL."
3528 (interactive "nKill all groups on level: ")
3530 ((= level gnus-level-zombie)
3531 (setq gnus-killed-list
3532 (nconc gnus-zombie-list gnus-killed-list))
3533 (setq gnus-zombie-list nil))
3534 ((and (< level gnus-level-zombie)
3536 (or gnus-expert-user
3539 "Do you really want to kill all groups on level %d? "
3541 (let* ((prev gnus-newsrc-alist)
3544 (if (= (gnus-info-level (car alist)) level)
3546 (push (gnus-info-group (car alist)) gnus-killed-list)
3547 (setcdr prev (cdr alist)))
3549 (setq alist (cdr alist)))
3550 (gnus-make-hashtable-from-newsrc-alist)
3551 (gnus-group-list-groups)))
3553 (error "Can't kill; invalid level: %d" level))))
3555 (defun gnus-group-list-all-groups (&optional arg)
3556 "List all newsgroups with level ARG or lower.
3557 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3558 unsubscribed groups."
3560 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3562 ;; Redefine this to list ALL killed groups if prefix arg used.
3563 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3564 (defun gnus-group-list-killed (&optional arg)
3565 "List all killed newsgroups in the group buffer.
3566 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3567 entail asking the server for the groups."
3569 ;; Find all possible killed newsgroups if arg.
3571 (gnus-get-killed-groups))
3572 (if (not gnus-killed-list)
3573 (gnus-message 6 "No killed groups")
3574 (let (gnus-group-list-mode)
3575 (funcall gnus-group-prepare-function
3576 gnus-level-killed t gnus-level-killed))
3577 (goto-char (point-min)))
3578 (gnus-group-position-point))
3580 (defun gnus-group-list-zombies ()
3581 "List all zombie newsgroups in the group buffer."
3583 (if (not gnus-zombie-list)
3584 (gnus-message 6 "No zombie groups")
3585 (let (gnus-group-list-mode)
3586 (funcall gnus-group-prepare-function
3587 gnus-level-zombie t gnus-level-zombie))
3588 (goto-char (point-min)))
3589 (gnus-group-position-point))
3591 (defun gnus-group-list-active ()
3592 "List all groups that are available from the server(s)."
3594 ;; First we make sure that we have really read the active file.
3595 (unless (gnus-read-active-file-p)
3596 (let ((gnus-read-active-file t)
3597 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3598 (gnus-read-active-file)))
3599 ;; Find all groups and sort them.
3607 (push (symbol-name sym) list)))
3611 (buffer-read-only nil)
3615 (setq group (pop groups))
3616 (gnus-add-text-properties
3617 (point) (prog1 (1+ (point))
3619 (gnus-group-decoded-name group)
3621 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3623 'gnus-level (inline (gnus-group-level group)))))
3624 (goto-char (point-min))))
3626 (defun gnus-activate-all-groups (level)
3627 "Activate absolutely all groups."
3628 (interactive (list gnus-level-unsubscribed))
3629 (let ((gnus-activate-level level)
3630 (gnus-activate-foreign-newsgroups level))
3631 (gnus-group-get-new-news)))
3633 (defun gnus-group-get-new-news (&optional arg)
3634 "Get newly arrived articles.
3635 If ARG is a number, it specifies which levels you are interested in
3636 re-scanning. If ARG is non-nil and not a number, this will force
3637 \"hard\" re-reading of the active files from all servers."
3640 (let ((gnus-inhibit-demon t)
3641 ;; Binding this variable will inhibit multiple fetchings
3642 ;; of the same mail source.
3643 (nnmail-fetched-sources (list t)))
3644 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3645 (gnus-run-hooks 'gnus-get-new-news-hook)
3647 ;; Read any slave files.
3649 (gnus-master-read-slave-newsrc))
3651 ;; We might read in new NoCeM messages here.
3652 (when (and gnus-use-nocem
3654 (gnus-nocem-scan-groups))
3655 ;; If ARG is not a number, then we read the active file.
3656 (when (and arg (not (numberp arg)))
3657 (let ((gnus-read-active-file t))
3658 (gnus-read-active-file))
3661 ;; If the user wants it, we scan for new groups.
3662 (when (eq gnus-check-new-newsgroups 'always)
3663 (gnus-find-new-newsgroups)))
3665 (setq arg (gnus-group-default-level arg t))
3666 (if (and gnus-read-active-file (not arg))
3668 (gnus-read-active-file)
3669 (gnus-get-unread-articles arg))
3670 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3671 (gnus-get-unread-articles arg)))
3672 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3673 (gnus-group-list-groups (and (numberp arg)
3674 (max (car gnus-group-list-mode) arg))))
3676 (when (and gnus-agent (not (interactive-p)))
3677 (gnus-agent-toggle-plugged gnus-plugged)))
3679 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3680 "Check for newly arrived news in the current group (and the N-1 next groups).
3681 The difference between N and the number of newsgroup checked is returned.
3682 If N is negative, this group and the N-1 previous groups will be checked.
3683 If DONT-SCAN is non-nil, scan non-activated groups as well."
3685 (let* ((groups (gnus-group-process-prefix n))
3686 (ret (if (numberp n) (- n (length groups)) 0))
3690 (gnus-inhibit-demon t)
3691 ;; Binding this variable will inhibit multiple fetchings
3692 ;; of the same mail source.
3693 (nnmail-fetched-sources (list t)))
3694 (gnus-run-hooks 'gnus-get-new-news-hook)
3695 (while (setq group (pop groups))
3696 (gnus-group-remove-mark group)
3697 ;; Bypass any previous denials from the server.
3698 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3699 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3700 (let ((info (gnus-get-info group))
3701 (active (gnus-active group)))
3703 (gnus-request-update-info info method))
3704 (gnus-get-unread-articles-in-group info active)
3705 (unless (gnus-virtual-group-p group)
3706 (gnus-close-group group))
3708 (gnus-agent-save-group-info
3709 method (gnus-group-real-name group) active))
3710 (gnus-group-update-group group))
3711 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3713 (gnus-error 3 "Server denied access")
3714 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3717 (when gnus-goto-next-group-when-activating
3718 (gnus-group-next-unread-group 1 t))
3719 (gnus-summary-position-point)
3722 (defun gnus-group-fetch-faq (group &optional faq-dir)
3723 "Fetch the FAQ for the current group.
3724 If given a prefix argument, prompt for the FAQ dir
3728 (gnus-group-group-name)
3729 (when current-prefix-arg
3731 "FAQ dir: " (and (listp gnus-group-faq-directory)
3733 gnus-group-faq-directory))))))
3735 (error "No group name given"))
3736 (let ((dirs (or faq-dir gnus-group-faq-directory))
3738 (unless (listp dirs)
3739 (setq dirs (list dirs)))
3740 (while (and (not found)
3741 (setq dir (pop dirs)))
3742 (let ((name (gnus-group-real-name group)))
3743 (setq file (expand-file-name name dir)))
3744 (if (not (file-exists-p file))
3745 (gnus-message 1 "No such file: %s" file)
3746 (let ((enable-local-variables nil))
3750 (defun gnus-group-fetch-charter (group)
3751 "Fetch the charter for the current group.
3752 If given a prefix argument, prompt for a group."
3754 (list (or (when current-prefix-arg
3755 (completing-read "Group: " gnus-active-hashtb))
3756 (gnus-group-group-name)
3757 gnus-newsgroup-name)))
3759 (error "No group name given"))
3761 (condition-case nil (require 'url-http) (error nil))
3762 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3764 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3765 (setq hierarchy (match-string 1 name))
3766 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3767 (if (fboundp 'url-http-file-exists-p)
3768 (url-http-file-exists-p (eval url))
3770 (browse-url (eval url))
3771 (setq url (concat "http://" hierarchy
3772 ".news-admin.org/charters/" name))
3773 (if (and (fboundp 'url-http-file-exists-p)
3774 (url-http-file-exists-p url))
3776 (gnus-group-fetch-control group))))))
3778 (defun gnus-group-fetch-control (group)
3779 "Fetch the archived control messages for the current group.
3780 If given a prefix argument, prompt for a group."
3782 (list (or (when current-prefix-arg
3783 (completing-read "Group: " gnus-active-hashtb))
3784 (gnus-group-group-name)
3785 gnus-newsgroup-name)))
3787 (error "No group name given"))
3788 (let ((name (gnus-group-real-name group))
3790 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3791 (setq hierarchy (match-string 1 name))
3792 (if gnus-group-fetch-control-use-browse-url
3793 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3794 hierarchy "/" name ".gz"))
3795 (let ((enable-local-variables nil))
3796 (gnus-group-read-ephemeral-group
3798 `(nndoc ,group (nndoc-address
3799 ,(find-file-noselect
3800 (concat "/ftp@ftp.isc.org:/usenet/control/"
3801 hierarchy "/" name ".gz")))
3802 (nndoc-article-type mbox)) t nil nil))))))
3804 (defun gnus-group-describe-group (force &optional group)
3805 "Display a description of the current newsgroup."
3806 (interactive (list current-prefix-arg (gnus-group-group-name)))
3807 (let* ((method (gnus-find-method-for-group group))
3808 (mname (gnus-group-prefixed-name "" method))
3811 gnus-description-hashtb)
3812 (gnus-sethash mname nil gnus-description-hashtb))
3814 (error "No group name given"))
3815 (when (or (and gnus-description-hashtb
3816 ;; We check whether this group's method has been
3817 ;; queried for a description file.
3818 (gnus-gethash mname gnus-description-hashtb))
3819 (setq desc (gnus-group-get-description group))
3820 (gnus-read-descriptions-file method))
3822 (or desc (gnus-gethash group gnus-description-hashtb)
3823 "No description available")))))
3825 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3826 (defun gnus-group-describe-all-groups (&optional force)
3827 "Pop up a buffer with descriptions of all newsgroups."
3830 (setq gnus-description-hashtb nil))
3831 (when (not (or gnus-description-hashtb
3832 (gnus-read-all-descriptions-files)))
3833 (error "Couldn't request descriptions file"))
3834 (let ((buffer-read-only nil)
3840 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3841 (insert (format " *: %-20s %s\n"
3842 (gnus-group-name-decode
3843 (symbol-name group) charset)
3844 (gnus-group-name-decode
3845 (symbol-value group) charset))))
3846 (gnus-add-text-properties
3847 b (1+ b) (list 'gnus-group group
3848 'gnus-unread t 'gnus-marked nil
3849 'gnus-level (1+ gnus-level-subscribed))))
3850 gnus-description-hashtb)
3851 (goto-char (point-min))
3852 (gnus-group-position-point)))
3854 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3855 (defun gnus-group-apropos (regexp &optional search-description)
3856 "List all newsgroups that have names that match a regexp."
3857 (interactive "sGnus apropos (regexp): ")
3859 (obuf (current-buffer))
3861 ;; Go through all newsgroups that are known to Gnus.
3864 (and (symbol-name group)
3865 (string-match regexp (symbol-name group))
3866 (symbol-value group)
3867 (push (symbol-name group) groups)))
3869 ;; Also go through all descriptions that are known to Gnus.
3870 (when search-description
3873 (and (string-match regexp (symbol-value group))
3874 (push (symbol-name group) groups)))
3875 gnus-description-hashtb))
3877 (gnus-message 3 "No groups matched \"%s\"." regexp)
3878 ;; Print out all the groups.
3880 (pop-to-buffer "*Gnus Help*")
3881 (buffer-disable-undo)
3883 (setq groups (sort groups 'string<))
3885 ;; Groups may be entered twice into the list of groups.
3886 (when (not (string= (car groups) prev))
3887 (setq prev (car groups))
3888 (let ((charset (gnus-group-name-charset nil prev)))
3889 (insert (gnus-group-name-decode prev charset) "\n")
3890 (when (and gnus-description-hashtb
3891 (setq des (gnus-gethash (car groups)
3892 gnus-description-hashtb)))
3893 (insert " " (gnus-group-name-decode des charset) "\n"))))
3894 (setq groups (cdr groups)))
3895 (goto-char (point-min))))
3896 (pop-to-buffer obuf)))
3898 (defun gnus-group-description-apropos (regexp)
3899 "List all newsgroups that have names or descriptions that match REGEXP."
3900 (interactive "sGnus description apropos (regexp): ")
3901 (when (not (or gnus-description-hashtb
3902 (gnus-read-all-descriptions-files)))
3903 (error "Couldn't request descriptions file"))
3904 (gnus-group-apropos regexp t))
3906 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3907 (defun gnus-group-list-matching (level regexp &optional all lowest)
3908 "List all groups with unread articles that match REGEXP.
3909 If the prefix LEVEL is non-nil, it should be a number that says which
3910 level to cut off listing groups.
3911 If ALL, also list groups with no unread articles.
3912 If LOWEST, don't list groups with level lower than LOWEST.
3914 This command may read the active file."
3915 (interactive "P\nsList newsgroups matching: ")
3916 ;; First make sure active file has been read.
3918 (> (prefix-numeric-value level) gnus-level-killed))
3919 (gnus-get-killed-groups))
3920 (funcall gnus-group-prepare-function
3921 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3922 (goto-char (point-min))
3923 (gnus-group-position-point))
3925 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3926 "List all groups that match REGEXP.
3927 If the prefix LEVEL is non-nil, it should be a number that says which
3928 level to cut off listing groups.
3929 If LOWEST, don't list groups with level lower than LOWEST."
3930 (interactive "P\nsList newsgroups matching: ")
3932 (setq level (prefix-numeric-value level)))
3933 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3935 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3936 (defun gnus-group-save-newsrc (&optional force)
3937 "Save the Gnus startup files.
3938 If FORCE, force saving whether it is necessary or not."
3940 (gnus-save-newsrc-file force))
3942 (defun gnus-group-restart (&optional arg)
3943 "Force Gnus to read the .newsrc file."
3945 (when (gnus-yes-or-no-p
3946 (format "Are you sure you want to restart Gnus? "))
3947 (gnus-save-newsrc-file)
3951 (defun gnus-group-read-init-file ()
3952 "Read the Gnus elisp init file."
3954 (gnus-read-init-file)
3955 (gnus-message 5 "Read %s" gnus-init-file))
3957 (defun gnus-group-check-bogus-groups (&optional silent)
3958 "Check bogus newsgroups.
3959 If given a prefix, don't ask for confirmation before removing a bogus
3962 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3963 (gnus-group-list-groups))
3965 (defun gnus-group-find-new-groups (&optional arg)
3966 "Search for new groups and add them.
3967 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3968 With 1 C-u, use the `ask-server' method to query the server for new
3970 With 2 C-u's, use most complete method possible to query the server
3971 for new groups, and subscribe the new groups as zombies."
3973 (gnus-find-new-newsgroups (or arg 1))
3974 (gnus-group-list-groups))
3976 (defun gnus-group-edit-global-kill (&optional article group)
3977 "Edit the global kill file.
3978 If GROUP, edit that local kill file instead."
3980 (setq gnus-current-kill-article article)
3981 (gnus-kill-file-edit-file group)
3984 (substitute-command-keys
3985 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3986 (if group "local" "global")))))
3988 (defun gnus-group-edit-local-kill (article group)
3989 "Edit a local kill file."
3990 (interactive (list nil (gnus-group-group-name)))
3991 (gnus-group-edit-global-kill article group))
3993 (defun gnus-group-force-update ()
3994 "Update `.newsrc' file."
3996 (gnus-save-newsrc-file))
3998 (defvar gnus-backlog-articles)
4000 (defun gnus-group-suspend ()
4001 "Suspend the current Gnus session.
4002 In fact, cleanup buffers except for group mode buffer.
4003 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4005 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4006 (gnus-offer-save-summaries)
4007 ;; Kill Gnus buffers except for group mode buffer.
4008 (let ((group-buf (get-buffer gnus-group-buffer)))
4009 (mapcar (lambda (buf)
4010 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4011 (with-current-buffer buf
4012 (eq major-mode 'message-mode)))
4013 (gnus-kill-buffer buf)))
4015 (setq gnus-backlog-articles nil)
4016 (gnus-kill-gnus-frames)
4018 (bury-buffer group-buf)
4019 (delete-windows-on group-buf t))))
4021 (defun gnus-group-clear-dribble ()
4022 "Clear all information from the dribble buffer."
4024 (gnus-dribble-clear)
4025 (gnus-message 7 "Cleared dribble buffer"))
4027 (defun gnus-group-exit ()
4028 "Quit reading news after updating .newsrc.eld and .newsrc.
4029 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4032 (or noninteractive ;For gnus-batch-kill
4033 (not gnus-interactive-exit) ;Without confirmation
4035 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4036 (gnus-run-hooks 'gnus-exit-gnus-hook)
4037 ;; Offer to save data from non-quitted summary buffers.
4038 (gnus-offer-save-summaries)
4039 ;; Save the newsrc file(s).
4040 (gnus-save-newsrc-file)
4042 (gnus-close-backends)
4043 ;; Reset everything.
4045 ;; Allow the user to do things after cleaning up.
4046 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4048 (defun gnus-group-quit ()
4049 "Quit reading news without updating .newsrc.eld or .newsrc.
4050 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4052 (when (or noninteractive ;For gnus-batch-kill
4053 (zerop (buffer-size))
4054 (not (gnus-server-opened gnus-select-method))
4056 (not gnus-current-startup-file)
4058 (format "Quit reading news without saving %s? "
4059 (file-name-nondirectory gnus-current-startup-file))))
4060 (gnus-run-hooks 'gnus-exit-gnus-hook)
4061 (gnus-configure-windows 'group t)
4062 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4063 (not (zerop (save-excursion
4064 (set-buffer gnus-dribble-buffer)
4067 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4069 (gnus-close-backends)
4071 (gnus-kill-buffer gnus-group-buffer)
4072 ;; Allow the user to do things after cleaning up.
4073 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4075 (defun gnus-group-describe-briefly ()
4076 "Give a one line description of the group mode commands."
4078 (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")))
4080 (defun gnus-group-browse-foreign-server (method)
4081 "Browse a foreign news server.
4082 If called interactively, this function will ask for a select method
4083 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4084 If not, METHOD should be a list where the first element is the method
4085 and the second element is the address."
4087 (list (let ((how (completing-read
4089 (append gnus-valid-select-methods gnus-server-alist)
4090 nil t (cons "nntp" 0) 'gnus-method-history)))
4091 ;; We either got a back end name or a virtual server name.
4092 ;; If the first, we also need an address.
4093 (if (assoc how gnus-valid-select-methods)
4095 ;; Suggested by mapjph@bath.ac.uk.
4098 (mapcar 'list gnus-secondary-servers)))
4099 ;; We got a server name.
4101 (gnus-browse-foreign-server method))
4103 (defun gnus-group-set-info (info &optional method-only-group part)
4104 (when (or info part)
4105 (let* ((entry (gnus-group-entry
4106 (or method-only-group (gnus-info-group info))))
4108 (info (if method-only-group (nth 2 entry) info))
4110 (when method-only-group
4112 (error "Trying to change non-existent group %s" method-only-group))
4113 ;; We have received parts of the actual group info - either the
4114 ;; select method or the group parameters. We first check
4115 ;; whether we have to extend the info, and if so, do that.
4116 (let ((len (length info))
4117 (total (if (eq part 'method) 5 6)))
4119 (setcdr (nthcdr (1- len) info)
4120 (make-list (- total len) nil)))
4121 ;; Then we enter the new info.
4122 (setcar (nthcdr (1- total) info) part-info)))
4124 ;; This is a new group, so we just create it.
4126 (set-buffer gnus-group-buffer)
4127 (setq method (gnus-info-method info))
4128 (when (gnus-server-equal method "native")
4131 (set-buffer gnus-group-buffer)
4133 ;; It's a foreign group...
4134 (gnus-group-make-group
4135 (gnus-group-real-name (gnus-info-group info))
4136 (if (stringp method) method
4137 (prin1-to-string (car method)))
4139 (nth 1 (gnus-info-method info))))
4140 ;; It's a native group.
4141 (gnus-group-make-group (gnus-info-group info))))
4142 (gnus-message 6 "Note: New group created")
4144 (gnus-group-entry (gnus-group-prefixed-name
4145 (gnus-group-real-name (gnus-info-group info))
4146 (or (gnus-info-method info) gnus-select-method))))))
4147 ;; Whether it was a new group or not, we now have the entry, so we
4148 ;; can do the update.
4151 (setcar (nthcdr 2 entry) info)
4152 (when (and (not (eq (car entry) t))
4153 (gnus-active (gnus-info-group info)))
4154 (setcar entry (length
4155 (gnus-list-of-unread-articles (car info))))))
4156 (error "No such group: %s" (gnus-info-group info))))))
4158 (defun gnus-group-set-method-info (group select-method)
4159 (gnus-group-set-info select-method group 'method))
4161 (defun gnus-group-set-params-info (group params)
4162 (gnus-group-set-info params group 'params))
4164 (defun gnus-add-marked-articles (group type articles &optional info force)
4165 ;; Add ARTICLES of TYPE to the info of GROUP.
4166 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4167 ;; add, but replace marked articles of TYPE with ARTICLES.
4168 (let ((info (or info (gnus-get-info group)))
4171 (and (not (setq marked (nthcdr 3 info)))
4173 (setcdr (nthcdr 2 info)
4174 (list (list (cons type (gnus-compress-sequence
4176 (and (not (setq m (assq type (car marked))))
4179 (cons (cons type (gnus-compress-sequence articles t) )
4183 (setcar (nthcdr 3 info)
4184 (gnus-delete-alist type (car marked)))
4185 (setcdr m (gnus-compress-sequence articles t)))
4186 (setcdr m (gnus-compress-sequence
4187 (sort (nconc (gnus-uncompress-range (cdr m))
4188 (copy-sequence articles)) '<) t))))))
4190 (defun gnus-add-mark (group mark article)
4191 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4192 (let ((buffer (gnus-summary-buffer-name group)))
4193 (if (gnus-buffer-live-p buffer)
4195 (set-buffer (get-buffer buffer))
4196 (gnus-summary-add-mark article mark))
4197 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4201 ;;; Group timestamps
4204 (defun gnus-group-set-timestamp ()
4205 "Change the timestamp of the current group to the current time.
4206 This function can be used in hooks like `gnus-select-group-hook'
4207 or `gnus-group-catchup-group-hook'."
4208 (when gnus-newsgroup-name
4209 (let ((time (current-time)))
4210 (setcdr (cdr time) nil)
4211 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4213 (defsubst gnus-group-timestamp (group)
4214 "Return the timestamp for GROUP."
4215 (gnus-group-get-parameter group 'timestamp t))
4217 (defun gnus-group-timestamp-delta (group)
4218 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4219 (let* ((time (or (gnus-group-timestamp group)
4221 (delta (subtract-time (current-time) time)))
4222 (+ (* (nth 0 delta) 65536.0)
4225 (defun gnus-group-timestamp-string (group)
4226 "Return a string of the timestamp for GROUP."
4227 (let ((time (gnus-group-timestamp group)))
4230 (gnus-time-iso8601 time))))
4232 (defun gnus-group-list-cached (level &optional lowest)
4233 "List all groups with cached articles.
4234 If the prefix LEVEL is non-nil, it should be a number that says which
4235 level to cut off listing groups.
4236 If LOWEST, don't list groups with level lower than LOWEST.
4238 This command may read the active file."
4241 (setq level (prefix-numeric-value level)))
4242 (when (or (not level) (>= level gnus-level-zombie))
4244 (funcall gnus-group-prepare-function
4245 (or level gnus-level-subscribed)
4247 (let ((marks (gnus-info-marks info)))
4248 (assq 'cache marks)))
4251 (or (gnus-gethash group
4252 gnus-cache-active-hashtb)
4253 ;; Cache active file might use "."
4256 (mapconcat 'identity
4257 (split-string group ":")
4259 gnus-cache-active-hashtb))))
4260 (goto-char (point-min))
4261 (gnus-group-position-point))
4263 (defun gnus-group-list-dormant (level &optional lowest)
4264 "List all groups with dormant articles.
4265 If the prefix LEVEL is non-nil, it should be a number that says which
4266 level to cut off listing groups.
4267 If LOWEST, don't list groups with level lower than LOWEST.
4269 This command may read the active file."
4272 (setq level (prefix-numeric-value level)))
4273 (when (or (not level) (>= level gnus-level-zombie))
4275 (funcall gnus-group-prepare-function
4276 (or level gnus-level-subscribed)
4278 (let ((marks (gnus-info-marks info)))
4279 (assq 'dormant marks)))
4282 (goto-char (point-min))
4283 (gnus-group-position-point))
4285 (defun gnus-group-listed-groups ()
4286 "Return a list of listed groups."
4288 (goto-char (point-min))
4289 (while (setq point (text-property-not-all (point) (point-max)
4292 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4296 (defun gnus-group-list-plus (&optional args)
4297 "List groups plus the current selection."
4299 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4300 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4302 (push last-command-event unread-command-events)
4303 (if (featurep 'xemacs)
4304 (push (make-event 'key-press '(key ?A)) unread-command-events)
4305 (push ?A unread-command-events))
4306 (let (gnus-pick-mode keys)
4307 (setq keys (if (featurep 'xemacs)
4308 (events-to-keys (read-key-sequence nil))
4309 (read-key-sequence nil)))
4310 (setq func (lookup-key (current-local-map) keys)))
4314 (call-interactively func))))
4316 (defun gnus-group-list-flush (&optional args)
4317 "Flush groups from the current selection."
4319 (let ((gnus-group-list-option 'flush))
4320 (gnus-group-list-plus args)))
4322 (defun gnus-group-list-limit (&optional args)
4323 "List groups limited within the current selection."
4325 (let ((gnus-group-list-option 'limit))
4326 (gnus-group-list-plus args)))
4328 (defun gnus-group-mark-article-read (group article)
4329 "Mark ARTICLE read."
4330 (let ((buffer (gnus-summary-buffer-name group))
4331 (mark gnus-read-mark)
4333 (if (get-buffer buffer)
4334 (with-current-buffer buffer
4335 (setq active gnus-newsgroup-active)
4336 (gnus-activate-group group)
4337 (when gnus-newsgroup-prepared
4338 (when (and gnus-newsgroup-auto-expire
4339 (memq mark gnus-auto-expirable-marks))
4340 (setq mark gnus-expirable-mark))
4341 (setq mark (gnus-request-update-mark
4342 group article mark))
4343 (gnus-mark-article-as-read article mark)
4344 (setq gnus-newsgroup-active (gnus-active group))
4346 (setq n (1+ (cdr active)))
4347 (while (<= n (cdr gnus-newsgroup-active))
4348 (unless (eq n article)
4349 (push n gnus-newsgroup-unselected))
4351 (setq gnus-newsgroup-unselected
4352 (nreverse gnus-newsgroup-unselected)))))
4353 (gnus-activate-group group)
4354 (gnus-group-make-articles-read group (list article))
4355 (when (gnus-group-auto-expirable-p group)
4356 (gnus-add-marked-articles
4357 group 'expire (list article))))))
4359 (provide 'gnus-group)
4361 ;;; gnus-group.el ends here