1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
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.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %t Estimated total number of articles (integer)
160 %y Number of unread, unticked articles (integer)
161 %G Group name (string)
162 %g Qualified group name (string)
163 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
164 %C Group comment (string)
165 %D Group description (string)
166 %s Select method (string)
167 %o Moderated group (char, \"m\")
168 %p Process mark (char)
169 %O Moderated group (string, \"(m)\" or \"\")
170 %P Topic indentation (string)
171 %m Whether there is new(ish) mail in the group (char, \"%\")
172 %l Whether there are GroupLens predictions for this group (string)
173 %n Select from where (string)
174 %z A string that look like `<%s:%n>' if a foreign select method is used
175 %d The date the group was last entered.
176 %E Icon as defined by `gnus-group-icon-list'.
177 %u User defined specifier. The next character in the format string should
178 be a letter. Gnus will call the function gnus-user-format-function-X,
179 where X is the letter following %u. The function will be passed a
180 single dummy parameter as argument.. The function should return a
181 string, which will be inserted into the buffer just like information
182 from any other group specifier.
184 Note that this format specification is not always respected. For
185 reasons of efficiency, when listing killed groups, this specification
186 is ignored altogether. If the spec is changed considerably, your
187 output may end up looking strange when listing both alive and killed
190 If you use %o or %O, reading the active file will be slower and quite
191 a bit of extra memory will be used. %D will also worsen performance.
192 Also note that if you change the format specification to include any
193 of these specs, you must probably re-start Gnus to see them go into
196 General format specifiers can also be used.
197 See Info node `(gnus)Formatting Variables'."
198 :link '(custom-manual "(gnus)Formatting Variables")
199 :group 'gnus-group-visual
202 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
203 "*The format specification for the group mode line.
204 It works along the same lines as a normal formatting string,
205 with some simple extensions:
207 %S The native news server.
208 %M The native select method.
209 %: \":\" if %S isn't \"\"."
210 :group 'gnus-group-visual
213 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
214 (when (featurep 'xemacs)
215 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
216 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
218 (defcustom gnus-group-menu-hook nil
219 "Hook run after the creation of the group mode menu."
220 :group 'gnus-group-various
223 (defcustom gnus-group-catchup-group-hook nil
224 "Hook run when catching up a group from the group buffer."
225 :group 'gnus-group-various
226 :link '(custom-manual "(gnus)Group Data")
229 (defcustom gnus-group-update-group-hook nil
230 "Hook called when updating group lines."
231 :group 'gnus-group-visual
234 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
235 "*A function that is called to generate the group buffer.
236 The function is called with three arguments: The first is a number;
237 all group with a level less or equal to that number should be listed,
238 if the second is non-nil, empty groups should also be displayed. If
239 the third is non-nil, it is a number. No groups with a level lower
240 than this number should be displayed.
242 The only current function implemented is `gnus-group-prepare-flat'."
243 :group 'gnus-group-listing
246 (defcustom gnus-group-prepare-hook nil
247 "Hook called after the group buffer has been generated.
248 If you want to modify the group buffer, you can use this hook."
249 :group 'gnus-group-listing
252 (defcustom gnus-suspend-gnus-hook nil
253 "Hook called when suspending (not exiting) Gnus."
257 (defcustom gnus-exit-gnus-hook nil
258 "Hook called when exiting Gnus."
262 (defcustom gnus-after-exiting-gnus-hook nil
263 "Hook called after exiting Gnus."
267 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
268 "Hook called when a group line is changed.
269 The hook will not be called if `gnus-visual' is nil.
271 The default function `gnus-group-highlight-line' will
272 highlight the line according to the `gnus-group-highlight'
274 :group 'gnus-group-visual
277 (defcustom gnus-useful-groups
278 '(("(ding) mailing list mirrored at sunsite.auc.dk"
280 (nntp "sunsite.auc.dk"
281 (nntp-address "sunsite.auc.dk")))
284 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
288 (nndoc-article-type mbox)
289 (eval `(nndoc-address
290 ,(let ((file (nnheader-find-etc-directory
293 (error "Couldn't find doc group"))
295 "*Alist of useful group-server pairs."
296 :group 'gnus-group-listing
297 :type '(repeat (list (string :tag "Description")
299 (sexp :tag "Method"))))
301 (defcustom gnus-group-highlight
303 ((and mailp (= unread 0) (eq level 1)) .
304 gnus-group-mail-1-empty-face)
305 ((and mailp (eq level 1)) .
306 gnus-group-mail-1-face)
307 ((and mailp (= unread 0) (eq level 2)) .
308 gnus-group-mail-2-empty-face)
309 ((and mailp (eq level 2)) .
310 gnus-group-mail-2-face)
311 ((and mailp (= unread 0) (eq level 3)) .
312 gnus-group-mail-3-empty-face)
313 ((and mailp (eq level 3)) .
314 gnus-group-mail-3-face)
315 ((and mailp (= unread 0)) .
316 gnus-group-mail-low-empty-face)
318 gnus-group-mail-low-face)
320 ((and (= unread 0) (eq level 1)) .
321 gnus-group-news-1-empty-face)
322 ((and (eq level 1)) .
323 gnus-group-news-1-face)
324 ((and (= unread 0) (eq level 2)) .
325 gnus-group-news-2-empty-face)
326 ((and (eq level 2)) .
327 gnus-group-news-2-face)
328 ((and (= unread 0) (eq level 3)) .
329 gnus-group-news-3-empty-face)
330 ((and (eq level 3)) .
331 gnus-group-news-3-face)
332 ((and (= unread 0) (eq level 4)) .
333 gnus-group-news-4-empty-face)
334 ((and (eq level 4)) .
335 gnus-group-news-4-face)
336 ((and (= unread 0) (eq level 5)) .
337 gnus-group-news-5-empty-face)
338 ((and (eq level 5)) .
339 gnus-group-news-5-face)
340 ((and (= unread 0) (eq level 6)) .
341 gnus-group-news-6-empty-face)
342 ((and (eq level 6)) .
343 gnus-group-news-6-face)
344 ((and (= unread 0)) .
345 gnus-group-news-low-empty-face)
347 gnus-group-news-low-face))
348 "*Controls the highlighting of group buffer lines.
350 Below is a list of `Form'/`Face' pairs. When deciding how a a
351 particular group line should be displayed, each form is
352 evaluated. The content of the face field after the first true form is
353 used. You can change how those group lines are displayed by
354 editing the face field.
356 It is also possible to change and add form fields, but currently that
357 requires an understanding of Lisp expressions. Hopefully this will
358 change in a future release. For now, you can use the following
359 variables in the Lisp expression:
361 group: The name of the group.
362 unread: The number of unread articles in the group.
363 method: The select method used.
364 mailp: Whether it's a mail group or not.
365 level: The level of the group.
366 score: The score of the group.
367 ticked: The number of ticked articles."
368 :group 'gnus-group-visual
369 :type '(repeat (cons (sexp :tag "Form") face)))
371 (defcustom gnus-new-mail-mark ?%
372 "Mark used for groups with new mail."
373 :group 'gnus-group-visual
376 (defgroup gnus-group-icons nil
377 "Add Icons to your group buffer. "
378 :group 'gnus-group-visual)
380 (defcustom gnus-group-icon-list
382 "*Controls the insertion of icons into group buffer lines.
384 Below is a list of `Form'/`File' pairs. When deciding how a
385 particular group line should be displayed, each form is evaluated.
386 The icon from the file field after the first true form is used. You
387 can change how those group lines are displayed by editing the file
388 field. The File will either be found in the
389 `gnus-group-glyph-directory' or by designating absolute path to the
392 It is also possible to change and add form fields, but currently that
393 requires an understanding of Lisp expressions. Hopefully this will
394 change in a future release. For now, you can use the following
395 variables in the Lisp expression:
397 group: The name of the group.
398 unread: The number of unread articles in the group.
399 method: The select method used.
400 mailp: Whether it's a mail group or not.
401 newsp: Whether it's a news group or not
402 level: The level of the group.
403 score: The score of the group.
404 ticked: The number of ticked articles."
405 :group 'gnus-group-icons
406 :type '(repeat (cons (sexp :tag "Form") file)))
408 (defcustom gnus-group-name-charset-method-alist nil
409 "Alist of method and the charset for group names.
412 (((nntp \"news.com.cn\") . cn-gb-2312))"
415 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
417 (defcustom gnus-group-name-charset-group-alist
418 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
419 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
422 "Alist of group regexp and the charset for group names.
425 ((\"\\.com\\.cn:\" . cn-gb-2312))"
427 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
429 (defcustom gnus-group-jump-to-group-prompt nil
430 "Default prompt for `gnus-group-jump-to-group'.
431 If non-nil, the value should be a string, e.g. \"nnml:\",
432 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
433 in the minibuffer prompt."
434 :group 'gnus-group-various
435 :type '(choice (string :tag "Prompt string")
436 (const :tag "Empty" nil)))
438 (defvar gnus-group-listing-limit 1000
439 "*A limit of the number of groups when listing.
440 If the number of groups is larger than the limit, list them in a
443 ;;; Internal variables
445 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
446 "Function for sorting the group buffer.")
448 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
449 "Function for sorting the selected groups in the group buffer.")
451 (defvar gnus-group-indentation-function nil)
452 (defvar gnus-goto-missing-group-function nil)
453 (defvar gnus-group-update-group-function nil)
454 (defvar gnus-group-goto-next-group-function nil
455 "Function to override finding the next group after listing groups.")
457 (defvar gnus-group-edit-buffer nil)
459 (defvar gnus-group-line-format-alist
460 `((?M gnus-tmp-marked-mark ?c)
461 (?S gnus-tmp-subscribed ?c)
462 (?L gnus-tmp-level ?d)
463 (?N (cond ((eq number t) "*" )
467 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
468 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
470 (?R gnus-tmp-number-of-read ?s)
471 (?t gnus-tmp-number-total ?d)
472 (?y gnus-tmp-number-of-unread ?s)
473 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
474 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
475 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
476 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
477 (?g gnus-tmp-group ?s)
478 (?G gnus-tmp-qualified-group ?s)
479 (?c (gnus-short-group-name gnus-tmp-group) ?s)
480 (?C gnus-tmp-comment ?s)
481 (?D gnus-tmp-newsgroup-description ?s)
482 (?o gnus-tmp-moderated ?c)
483 (?O gnus-tmp-moderated-string ?s)
484 (?p gnus-tmp-process-marked ?c)
485 (?s gnus-tmp-news-server ?s)
486 (?n gnus-tmp-news-method ?s)
487 (?P gnus-group-indentation ?s)
488 (?E gnus-tmp-group-icon ?s)
489 (?l gnus-tmp-grouplens ?s)
490 (?z gnus-tmp-news-method-string ?s)
491 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
492 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
493 (?u gnus-tmp-user-defined ?s)))
495 (defvar gnus-group-mode-line-format-alist
496 `((?S gnus-tmp-news-server ?s)
497 (?M gnus-tmp-news-method ?s)
498 (?u gnus-tmp-user-defined ?s)
499 (?: gnus-tmp-colon ?s)))
501 (defvar gnus-topic-topology nil
502 "The complete topic hierarchy.")
504 (defvar gnus-topic-alist nil
505 "The complete topic-group alist.")
507 (defvar gnus-group-marked nil)
509 (defvar gnus-group-list-mode nil)
512 (defvar gnus-group-icon-cache nil)
514 (defvar gnus-group-listed-groups nil)
515 (defvar gnus-group-list-option nil)
521 (put 'gnus-group-mode 'mode-class 'special)
524 (gnus-define-keys gnus-group-mode-map
525 " " gnus-group-read-group
526 "=" gnus-group-select-group
527 "\r" gnus-group-select-group
528 "\M-\r" gnus-group-quick-select-group
529 "\M- " gnus-group-visible-select-group
530 [(meta control return)] gnus-group-select-group-ephemerally
531 "j" gnus-group-jump-to-group
532 "n" gnus-group-next-unread-group
533 "p" gnus-group-prev-unread-group
534 "\177" gnus-group-prev-unread-group
535 [delete] gnus-group-prev-unread-group
536 [backspace] gnus-group-prev-unread-group
537 "N" gnus-group-next-group
538 "P" gnus-group-prev-group
539 "\M-n" gnus-group-next-unread-group-same-level
540 "\M-p" gnus-group-prev-unread-group-same-level
541 "," gnus-group-best-unread-group
542 "." gnus-group-first-unread-group
543 "u" gnus-group-unsubscribe-current-group
544 "U" gnus-group-unsubscribe-group
545 "c" gnus-group-catchup-current
546 "C" gnus-group-catchup-current-all
547 "\M-c" gnus-group-clear-data
548 "l" gnus-group-list-groups
549 "L" gnus-group-list-all-groups
552 "g" gnus-group-get-new-news
553 "\M-g" gnus-group-get-new-news-this-group
554 "R" gnus-group-restart
555 "r" gnus-group-read-init-file
556 "B" gnus-group-browse-foreign-server
557 "b" gnus-group-check-bogus-groups
558 "F" gnus-group-find-new-groups
559 "\C-c\C-d" gnus-group-describe-group
560 "\M-d" gnus-group-describe-all-groups
561 "\C-c\C-a" gnus-group-apropos
562 "\C-c\M-\C-a" gnus-group-description-apropos
563 "a" gnus-group-post-news
564 "\ek" gnus-group-edit-local-kill
565 "\eK" gnus-group-edit-global-kill
566 "\C-k" gnus-group-kill-group
567 "\C-y" gnus-group-yank-group
568 "\C-w" gnus-group-kill-region
569 "\C-x\C-t" gnus-group-transpose-groups
570 "\C-c\C-l" gnus-group-list-killed
571 "\C-c\C-x" gnus-group-expire-articles
572 "\C-c\M-\C-x" gnus-group-expire-all-groups
574 "s" gnus-group-save-newsrc
575 "z" gnus-group-suspend
578 "?" gnus-group-describe-briefly
579 "\C-c\C-i" gnus-info-find-node
580 "\M-e" gnus-group-edit-group-method
581 "^" gnus-group-enter-server-mode
582 gnus-mouse-2 gnus-mouse-pick-group
583 "<" beginning-of-buffer
586 "\C-c\C-s" gnus-group-sort-groups
588 "\C-c\M-g" gnus-activate-all-groups
589 "\M-&" gnus-group-universal-argument
590 "#" gnus-group-mark-group
591 "\M-#" gnus-group-unmark-group)
593 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
594 "m" gnus-group-mark-group
595 "u" gnus-group-unmark-group
596 "w" gnus-group-mark-region
597 "b" gnus-group-mark-buffer
598 "r" gnus-group-mark-regexp
599 "U" gnus-group-unmark-all-groups)
601 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
602 "u" gnus-sieve-update
603 "g" gnus-sieve-generate)
605 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
606 "d" gnus-group-make-directory-group
607 "h" gnus-group-make-help-group
608 "u" gnus-group-make-useful-group
609 "a" gnus-group-make-archive-group
610 "k" gnus-group-make-kiboze-group
611 "l" gnus-group-nnimap-edit-acl
612 "m" gnus-group-make-group
613 "E" gnus-group-edit-group
614 "e" gnus-group-edit-group-method
615 "p" gnus-group-edit-group-parameters
616 "v" gnus-group-add-to-virtual
617 "V" gnus-group-make-empty-virtual
618 "D" gnus-group-enter-directory
619 "f" gnus-group-make-doc-group
620 "w" gnus-group-make-web-group
621 "r" gnus-group-rename-group
622 "c" gnus-group-customize
623 "x" gnus-group-nnimap-expunge
624 "\177" gnus-group-delete-group
625 [delete] gnus-group-delete-group)
627 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
628 "b" gnus-group-brew-soup
629 "w" gnus-soup-save-areas
630 "s" gnus-soup-send-replies
631 "p" gnus-soup-pack-packet
632 "r" nnsoup-pack-replies)
634 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
635 "s" gnus-group-sort-groups
636 "a" gnus-group-sort-groups-by-alphabet
637 "u" gnus-group-sort-groups-by-unread
638 "l" gnus-group-sort-groups-by-level
639 "v" gnus-group-sort-groups-by-score
640 "r" gnus-group-sort-groups-by-rank
641 "m" gnus-group-sort-groups-by-method
642 "n" gnus-group-sort-groups-by-real-name)
644 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
645 "s" gnus-group-sort-selected-groups
646 "a" gnus-group-sort-selected-groups-by-alphabet
647 "u" gnus-group-sort-selected-groups-by-unread
648 "l" gnus-group-sort-selected-groups-by-level
649 "v" gnus-group-sort-selected-groups-by-score
650 "r" gnus-group-sort-selected-groups-by-rank
651 "m" gnus-group-sort-selected-groups-by-method
652 "n" gnus-group-sort-selected-groups-by-real-name)
654 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
655 "k" gnus-group-list-killed
656 "z" gnus-group-list-zombies
657 "s" gnus-group-list-groups
658 "u" gnus-group-list-all-groups
659 "A" gnus-group-list-active
660 "a" gnus-group-apropos
661 "d" gnus-group-description-apropos
662 "m" gnus-group-list-matching
663 "M" gnus-group-list-all-matching
664 "l" gnus-group-list-level
665 "c" gnus-group-list-cached
666 "?" gnus-group-list-dormant)
668 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
669 "k" gnus-group-list-limit
670 "z" gnus-group-list-limit
671 "s" gnus-group-list-limit
672 "u" gnus-group-list-limit
673 "A" gnus-group-list-limit
674 "m" gnus-group-list-limit
675 "M" gnus-group-list-limit
676 "l" gnus-group-list-limit
677 "c" gnus-group-list-limit
678 "?" gnus-group-list-limit)
680 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
681 "k" gnus-group-list-flush
682 "z" gnus-group-list-flush
683 "s" gnus-group-list-flush
684 "u" gnus-group-list-flush
685 "A" gnus-group-list-flush
686 "m" gnus-group-list-flush
687 "M" gnus-group-list-flush
688 "l" gnus-group-list-flush
689 "c" gnus-group-list-flush
690 "?" gnus-group-list-flush)
692 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
693 "k" gnus-group-list-plus
694 "z" gnus-group-list-plus
695 "s" gnus-group-list-plus
696 "u" gnus-group-list-plus
697 "A" gnus-group-list-plus
698 "m" gnus-group-list-plus
699 "M" gnus-group-list-plus
700 "l" gnus-group-list-plus
701 "c" gnus-group-list-plus
702 "?" gnus-group-list-plus)
704 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
705 "f" gnus-score-flush-cache)
707 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
708 "c" gnus-group-fetch-charter
709 "C" gnus-group-fetch-control
710 "d" gnus-group-describe-group
711 "f" gnus-group-fetch-faq
714 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
715 "l" gnus-group-set-current-level
716 "t" gnus-group-unsubscribe-current-group
717 "s" gnus-group-unsubscribe-group
718 "k" gnus-group-kill-group
719 "y" gnus-group-yank-group
720 "w" gnus-group-kill-region
721 "\C-k" gnus-group-kill-level
722 "z" gnus-group-kill-all-zombies))
724 (defun gnus-group-make-menu-bar ()
725 (gnus-turn-off-edit-menu 'group)
726 (unless (boundp 'gnus-group-reading-menu)
729 gnus-group-reading-menu gnus-group-mode-map ""
731 ["Read" gnus-group-read-group (gnus-group-group-name)]
732 ["Select" gnus-group-select-group (gnus-group-group-name)]
733 ["See old articles" (gnus-group-select-group 'all)
734 :keys "C-u SPC" :active (gnus-group-group-name)]
735 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
736 ,@(if (featurep 'xemacs) nil
737 '(:help "Mark unread articles in the current group as read"))]
738 ["Catch up all articles" gnus-group-catchup-current-all
739 (gnus-group-group-name)]
740 ["Check for new articles" gnus-group-get-new-news-this-group
741 :active (gnus-group-group-name)
742 ,@(if (featurep 'xemacs) nil
743 '(:help "Check for new messages in current group"))]
744 ["Toggle subscription" gnus-group-unsubscribe-current-group
745 (gnus-group-group-name)]
746 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
747 ,@(if (featurep 'xemacs) nil
748 '(:help "Kill (remove) current group"))]
749 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
750 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
751 ,@(if (featurep 'xemacs) nil
752 '(:help "Display description of the current group"))]
753 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
754 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
755 ,@(if (featurep 'xemacs) nil
756 '(:help "Display the charter of the current group"))]
757 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
758 ,@(if (featurep 'xemacs) nil
759 '(:help "Display the archived control message for the current group"))]
760 ;; Actually one should check, if any of the marked groups gives t for
761 ;; (gnus-check-backend-function 'request-expire-articles ...)
762 ["Expire articles" gnus-group-expire-articles
763 (or (and (gnus-group-group-name)
764 (gnus-check-backend-function
765 'request-expire-articles
766 (gnus-group-group-name))) gnus-group-marked)]
767 ["Set group level..." gnus-group-set-current-level
768 (gnus-group-group-name)]
769 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
770 ["Customize" gnus-group-customize (gnus-group-group-name)]
772 ["Parameters" gnus-group-edit-group-parameters
773 (gnus-group-group-name)]
774 ["Select method" gnus-group-edit-group-method
775 (gnus-group-group-name)]
776 ["Info" gnus-group-edit-group (gnus-group-group-name)]
777 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
778 ["Global kill file" gnus-group-edit-global-kill t])))
781 gnus-group-group-menu gnus-group-mode-map ""
784 ["List unread subscribed groups" gnus-group-list-groups t]
785 ["List (un)subscribed groups" gnus-group-list-all-groups t]
786 ["List killed groups" gnus-group-list-killed gnus-killed-list]
787 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
788 ["List level..." gnus-group-list-level t]
789 ["Describe all groups" gnus-group-describe-all-groups t]
790 ["Group apropos..." gnus-group-apropos t]
791 ["Group and description apropos..." gnus-group-description-apropos t]
792 ["List groups matching..." gnus-group-list-matching t]
793 ["List all groups matching..." gnus-group-list-all-matching t]
794 ["List active file" gnus-group-list-active t]
795 ["List groups with cached" gnus-group-list-cached t]
796 ["List groups with dormant" gnus-group-list-dormant t])
798 ["Default sort" gnus-group-sort-groups t]
799 ["Sort by method" gnus-group-sort-groups-by-method t]
800 ["Sort by rank" gnus-group-sort-groups-by-rank t]
801 ["Sort by score" gnus-group-sort-groups-by-score t]
802 ["Sort by level" gnus-group-sort-groups-by-level t]
803 ["Sort by unread" gnus-group-sort-groups-by-unread t]
804 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
805 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
806 ("Sort process/prefixed"
807 ["Default sort" gnus-group-sort-selected-groups
808 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
809 ["Sort by method" gnus-group-sort-selected-groups-by-method
810 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
811 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
812 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
813 ["Sort by score" gnus-group-sort-selected-groups-by-score
814 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
815 ["Sort by level" gnus-group-sort-selected-groups-by-level
816 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
817 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
818 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
819 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
820 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
821 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
822 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
824 ["Mark group" gnus-group-mark-group
825 (and (gnus-group-group-name)
826 (not (memq (gnus-group-group-name) gnus-group-marked)))]
827 ["Unmark group" gnus-group-unmark-group
828 (and (gnus-group-group-name)
829 (memq (gnus-group-group-name) gnus-group-marked))]
830 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
831 ["Mark regexp..." gnus-group-mark-regexp t]
832 ["Mark region" gnus-group-mark-region t]
833 ["Mark buffer" gnus-group-mark-buffer t]
834 ["Execute command" gnus-group-universal-argument
835 (or gnus-group-marked (gnus-group-group-name))])
837 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
838 ["Kill all newsgroups in region" gnus-group-kill-region t]
839 ["Kill all zombie groups" gnus-group-kill-all-zombies
841 ["Kill all groups on level..." gnus-group-kill-level t])
843 ["Make a foreign group..." gnus-group-make-group t]
844 ["Add a directory group..." gnus-group-make-directory-group t]
845 ["Add the help group" gnus-group-make-help-group t]
846 ["Add the archive group" gnus-group-make-archive-group t]
847 ["Make a doc group..." gnus-group-make-doc-group t]
848 ["Make a web group..." gnus-group-make-web-group t]
849 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
850 ["Make a virtual group..." gnus-group-make-empty-virtual t]
851 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
852 ["Rename group..." gnus-group-rename-group
853 (gnus-check-backend-function
854 'request-rename-group (gnus-group-group-name))]
855 ["Delete group" gnus-group-delete-group
856 (gnus-check-backend-function
857 'request-delete-group (gnus-group-group-name))])
859 ["Next" gnus-group-next-group t]
860 ["Previous" gnus-group-prev-group t]
861 ["Next unread" gnus-group-next-unread-group t]
862 ["Previous unread" gnus-group-prev-unread-group t]
863 ["Next unread same level" gnus-group-next-unread-group-same-level t]
864 ["Previous unread same level"
865 gnus-group-prev-unread-group-same-level t]
866 ["Jump to group..." gnus-group-jump-to-group t]
867 ["First unread group" gnus-group-first-unread-group t]
868 ["Best unread group" gnus-group-best-unread-group t])
870 ["Generate" gnus-sieve-generate t]
871 ["Generate and update" gnus-sieve-update t])
872 ["Delete bogus groups" gnus-group-check-bogus-groups t]
873 ["Find new newsgroups" gnus-group-find-new-groups t]
874 ["Transpose" gnus-group-transpose-groups
875 (gnus-group-group-name)]
876 ["Read a directory as a group..." gnus-group-enter-directory t]))
879 gnus-group-misc-menu gnus-group-mode-map ""
882 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
883 ["Send replies" gnus-soup-send-replies
884 (fboundp 'gnus-soup-pack-packet)]
885 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
886 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
887 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
888 ["Send a mail" gnus-group-mail t]
889 ["Send a message (mail or news)" gnus-group-post-news t]
890 ["Create a local message" gnus-group-news t]
891 ["Check for new news" gnus-group-get-new-news
892 ,@(if (featurep 'xemacs) '(t)
893 '(:help "Get newly arrived articles"))
895 ["Send queued messages" gnus-delay-send-queue
896 ,@(if (featurep 'xemacs) '(t)
897 '(:help "Send all messages that are scheduled to be sent now"))
899 ["Activate all groups" gnus-activate-all-groups t]
900 ["Restart Gnus" gnus-group-restart t]
901 ["Read init file" gnus-group-read-init-file t]
902 ["Browse foreign server..." gnus-group-browse-foreign-server t]
903 ["Enter server buffer" gnus-group-enter-server-mode t]
904 ["Expire all expirable articles" gnus-group-expire-all-groups t]
905 ["Generate any kiboze groups" nnkiboze-generate-groups t]
906 ["Gnus version" gnus-version t]
907 ["Save .newsrc files" gnus-group-save-newsrc t]
908 ["Suspend Gnus" gnus-group-suspend t]
909 ["Clear dribble buffer" gnus-group-clear-dribble t]
910 ["Read manual" gnus-info-find-node t]
911 ["Flush score cache" gnus-score-flush-cache t]
912 ["Toggle topics" gnus-topic-mode t]
913 ["Send a bug report" gnus-bug t]
914 ["Exit from Gnus" gnus-group-exit
915 ,@(if (featurep 'xemacs) '(t)
916 '(:help "Quit reading news"))]
917 ["Exit without saving" gnus-group-quit t]))
919 (gnus-run-hooks 'gnus-group-menu-hook)))
921 (defvar gnus-group-toolbar-map nil)
923 ;; Emacs 21 tool bar. Should be no-op otherwise.
924 (defun gnus-group-make-tool-bar ()
926 (condition-case nil (require 'tool-bar) (error nil))
927 (fboundp 'tool-bar-add-item-from-menu)
928 (default-value 'tool-bar-mode)
929 (not gnus-group-toolbar-map))
930 (setq gnus-group-toolbar-map
931 (let ((tool-bar-map (make-sparse-keymap))
932 (load-path (mm-image-load-path)))
933 (tool-bar-add-item-from-menu
934 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
935 (tool-bar-add-item-from-menu
936 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
937 (tool-bar-add-item-from-menu
938 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
939 (tool-bar-add-item-from-menu
940 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
941 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
942 :help "Subscribe to the current group")
943 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
945 :help "Unsubscribe from the current group")
946 (tool-bar-add-item-from-menu
947 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
949 (if gnus-group-toolbar-map
950 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
952 (defun gnus-group-mode ()
953 "Major mode for reading news.
955 All normal editing commands are switched off.
956 \\<gnus-group-mode-map>
957 The group buffer lists (some of) the groups available. For instance,
958 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
959 lists all zombie groups.
961 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
962 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
964 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
966 The following commands are available:
968 \\{gnus-group-mode-map}"
970 (kill-all-local-variables)
971 (when (gnus-visual-p 'group-menu 'menu)
972 (gnus-group-make-menu-bar)
973 (gnus-group-make-tool-bar))
974 (gnus-simplify-mode-line)
975 (setq major-mode 'gnus-group-mode)
976 (setq mode-name "Group")
977 (gnus-group-set-mode-line)
978 (setq mode-line-process nil)
979 (use-local-map gnus-group-mode-map)
980 (buffer-disable-undo)
981 (setq truncate-lines t)
982 (setq buffer-read-only t)
983 (gnus-set-default-directory)
984 (gnus-update-format-specifications nil 'group 'group-mode)
985 (gnus-update-group-mark-positions)
990 (gnus-run-hooks 'gnus-group-mode-hook))
992 (defun gnus-update-group-mark-positions ()
994 (let ((gnus-process-mark ?\200)
995 (gnus-group-update-hook nil)
996 (gnus-group-marked '("dummy.group"))
997 (gnus-active-hashtb (make-vector 10 0))
999 (gnus-set-active "dummy.group" '(0 . 0))
1000 (gnus-set-work-buffer)
1001 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1002 (goto-char (point-min))
1003 (setq gnus-group-mark-positions
1004 (list (cons 'process (and (search-forward "\200" nil t)
1005 (- (point) 2))))))))
1007 (defun gnus-mouse-pick-group (e)
1008 "Enter the group under the mouse pointer."
1011 (gnus-group-read-group nil))
1013 ;; Look at LEVEL and find out what the level is really supposed to be.
1014 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1015 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1016 (defun gnus-group-default-level (&optional level number-or-nil)
1018 (gnus-group-use-permanent-levels
1019 (or (setq gnus-group-use-permanent-levels
1020 (or level (if (numberp gnus-group-use-permanent-levels)
1021 gnus-group-use-permanent-levels
1022 (or gnus-group-default-list-level
1023 gnus-level-subscribed))))
1024 gnus-group-default-list-level gnus-level-subscribed))
1028 (or level gnus-group-default-list-level gnus-level-subscribed))))
1030 (defun gnus-group-setup-buffer ()
1031 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1032 (unless (eq major-mode 'gnus-group-mode)
1035 (gnus-carpal-setup-buffer 'group))))
1037 (defun gnus-group-name-charset (method group)
1039 (setq method (gnus-find-method-for-group group)))
1040 (let ((item (assoc method gnus-group-name-charset-method-alist))
1041 (alist gnus-group-name-charset-group-alist)
1045 (while (setq item (pop alist))
1046 (if (string-match (car item) group)
1048 result (cdr item))))
1051 (defun gnus-group-name-decode (string charset)
1052 (if (and string charset (featurep 'mule))
1053 (mm-decode-coding-string string charset)
1056 (defun gnus-group-decoded-name (string)
1057 (let ((charset (gnus-group-name-charset nil string)))
1058 (gnus-group-name-decode string charset)))
1060 (defun gnus-group-list-groups (&optional level unread lowest)
1061 "List newsgroups with level LEVEL or lower that have unread articles.
1062 Default is all subscribed groups.
1063 If argument UNREAD is non-nil, groups with no unread articles are also
1066 Also see the `gnus-group-use-permanent-levels' variable."
1068 (list (if current-prefix-arg
1069 (prefix-numeric-value current-prefix-arg)
1071 (gnus-group-default-level nil t)
1072 gnus-group-default-list-level
1073 gnus-level-subscribed))))
1075 (setq level (car gnus-group-list-mode)
1076 unread (cdr gnus-group-list-mode)))
1077 (setq level (gnus-group-default-level level))
1078 (gnus-group-setup-buffer)
1079 (gnus-update-format-specifications nil 'group 'group-mode)
1080 (let ((case-fold-search nil)
1081 (props (text-properties-at (gnus-point-at-bol)))
1082 (empty (= (point-min) (point-max)))
1083 (group (gnus-group-group-name))
1085 (set-buffer gnus-group-buffer)
1086 (setq number (funcall gnus-group-prepare-function level unread lowest))
1087 (when (or (and (numberp number)
1089 (zerop (buffer-size)))
1090 ;; No groups in the buffer.
1091 (gnus-message 5 gnus-no-groups-message))
1092 ;; We have some groups displayed.
1093 (goto-char (point-max))
1094 (when (or (not gnus-group-goto-next-group-function)
1095 (not (funcall gnus-group-goto-next-group-function
1099 (goto-char (point-min)))
1101 ;; Go to the first group with unread articles.
1102 (gnus-group-search-forward t))
1104 ;; Find the right group to put point on. If the current group
1105 ;; has disappeared in the new listing, try to find the next
1106 ;; one. If no next one can be found, just leave point at the
1107 ;; first newsgroup in the buffer.
1108 (when (not (gnus-goto-char
1110 (point-min) (point-max)
1111 'gnus-group (gnus-intern-safe
1112 group gnus-active-hashtb))))
1113 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1115 (not (gnus-goto-char
1117 (point-min) (point-max) 'gnus-group
1119 (caar newsrc) gnus-active-hashtb)))))
1120 (setq newsrc (cdr newsrc)))
1122 (goto-char (point-max))
1123 (forward-line -1)))))))
1124 ;; Adjust cursor point.
1125 (gnus-group-position-point)))
1127 (defun gnus-group-list-level (level &optional all)
1128 "List groups on LEVEL.
1129 If ALL (the prefix), also list groups that have no unread articles."
1130 (interactive "nList groups on level: \nP")
1131 (gnus-group-list-groups level all level))
1133 (defun gnus-group-prepare-logic (group test)
1134 (or (and gnus-group-listed-groups
1135 (null gnus-group-list-option)
1136 (member group gnus-group-listed-groups))
1138 ((null gnus-group-listed-groups) test)
1139 ((null gnus-group-list-option) test)
1140 (t (and (member group gnus-group-listed-groups)
1141 (if (eq gnus-group-list-option 'flush)
1145 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1146 "List all newsgroups with unread articles of level LEVEL or lower.
1147 If PREDICATE is a function, list groups that the function returns non-nil;
1148 if it is t, list groups that have no unread articles.
1149 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1150 If REGEXP is a function, list dead groups that the function returns non-nil;
1151 if it is a string, only list groups matching REGEXP."
1152 (set-buffer gnus-group-buffer)
1153 (let ((buffer-read-only nil)
1154 (newsrc (cdr gnus-newsrc-alist))
1155 (lowest (or lowest 1))
1156 (not-in-list (and gnus-group-listed-groups
1157 (copy-sequence gnus-group-listed-groups)))
1158 info clevel unread group params)
1160 (when (or (< lowest gnus-level-zombie)
1161 gnus-group-listed-groups)
1162 ;; List living groups.
1164 (setq info (car newsrc)
1165 group (gnus-info-group info)
1166 params (gnus-info-params info)
1168 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1170 (setq not-in-list (delete group not-in-list)))
1171 (when (gnus-group-prepare-logic
1173 (and unread ; This group might be unchecked
1174 (or (not (stringp regexp))
1175 (string-match regexp group))
1176 (<= (setq clevel (gnus-info-level info)) level)
1179 ((functionp predicate)
1180 (funcall predicate info))
1181 (predicate t) ; We list all groups?
1184 (if (eq unread t) ; Unactivated?
1185 gnus-group-list-inactive-groups
1186 ; We list unactivated
1188 ; We list groups with unread articles
1189 (and gnus-list-groups-with-ticked-articles
1190 (cdr (assq 'tick (gnus-info-marks info))))
1191 ; And groups with tickeds
1192 ;; Check for permanent visibility.
1193 (and gnus-permanently-visible-groups
1194 (string-match gnus-permanently-visible-groups
1196 (memq 'visible params)
1197 (cdr (assq 'visible params)))))))
1198 (gnus-group-insert-group-line
1199 group (gnus-info-level info)
1200 (gnus-info-marks info) unread (gnus-info-method info)))))
1202 ;; List dead groups.
1203 (when (or gnus-group-listed-groups
1204 (and (>= level gnus-level-zombie)
1205 (<= lowest gnus-level-zombie)))
1206 (gnus-group-prepare-flat-list-dead
1207 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1208 gnus-level-zombie ?Z
1211 (dolist (group gnus-zombie-list)
1212 (setq not-in-list (delete group not-in-list))))
1213 (when (or gnus-group-listed-groups
1214 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1215 (gnus-group-prepare-flat-list-dead
1218 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1219 gnus-level-killed ?K regexp))
1221 (gnus-group-set-mode-line)
1222 (setq gnus-group-list-mode (cons level predicate))
1223 (gnus-run-hooks 'gnus-group-prepare-hook)
1226 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1227 ;; List zombies and killed lists somewhat faster, which was
1228 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1229 ;; this by ignoring the group format specification altogether.
1231 (if (> (length groups) gnus-group-listing-limit)
1233 (setq group (pop groups))
1234 (when (gnus-group-prepare-logic
1237 (and (stringp regexp) (string-match regexp group))
1238 (and (functionp regexp) (funcall regexp group))))
1239 (gnus-add-text-properties
1240 (point) (prog1 (1+ (point))
1241 (insert " " mark " *: "
1242 (gnus-group-decoded-name group)
1244 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1246 'gnus-level level))))
1248 (setq group (pop groups))
1249 (when (gnus-group-prepare-logic
1252 (and (stringp regexp) (string-match regexp group))
1253 (and (functionp regexp) (funcall regexp group))))
1254 (gnus-group-insert-group-line
1256 (let ((active (gnus-active group)))
1258 (if (zerop (cdr active))
1260 (- (1+ (cdr active)) (car active)))
1262 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1264 (defun gnus-group-update-group-line ()
1265 "Update the current line in the group buffer."
1266 (let* ((buffer-read-only nil)
1267 (group (gnus-group-group-name))
1268 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1269 gnus-group-indentation)
1272 (not (gnus-ephemeral-group-p group))
1274 (concat "(gnus-group-set-info '"
1275 (gnus-prin1-to-string (nth 2 entry))
1277 (setq gnus-group-indentation (gnus-group-group-indentation))
1279 (gnus-group-insert-group-line-info group)
1281 (gnus-group-position-point))))
1283 (defun gnus-group-insert-group-line-info (group)
1284 "Insert GROUP on the current line."
1285 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1286 (gnus-group-indentation (gnus-group-group-indentation))
1290 ;; (Un)subscribed group.
1291 (setq info (nth 2 entry))
1292 (gnus-group-insert-group-line
1293 group (gnus-info-level info) (gnus-info-marks info)
1294 (or (car entry) t) (gnus-info-method info)))
1295 ;; This group is dead.
1296 (gnus-group-insert-group-line
1298 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1300 (if (setq active (gnus-active group))
1301 (if (zerop (cdr active))
1303 (- (1+ (cdr active)) (car active)))
1305 (gnus-method-simplify (gnus-find-method-for-group group))))))
1307 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1308 gnus-tmp-marked number
1310 "Insert a group line in the group buffer."
1311 (let* ((gnus-tmp-method
1312 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1313 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1315 (gnus-tmp-active (gnus-active gnus-tmp-group))
1316 (gnus-tmp-number-total
1318 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1320 (gnus-tmp-number-of-unread
1321 (if (numberp number) (int-to-string (max 0 number))
1323 (gnus-tmp-number-of-read
1324 (if (numberp number)
1325 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1327 (gnus-tmp-subscribed
1328 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1329 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1330 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1332 (gnus-tmp-qualified-group
1333 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1334 group-name-charset))
1336 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1338 (gnus-tmp-newsgroup-description
1339 (if gnus-description-hashtb
1340 (or (gnus-group-name-decode
1341 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1342 group-name-charset) "")
1345 (if (and gnus-moderated-hashtb
1346 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1348 (gnus-tmp-moderated-string
1349 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1350 (gnus-tmp-group-icon "==&&==")
1351 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1352 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1353 (gnus-tmp-news-method-string
1355 (format "(%s:%s)" (car gnus-tmp-method)
1356 (cadr gnus-tmp-method)) ""))
1357 (gnus-tmp-marked-mark
1358 (if (and (numberp number)
1360 (cdr (assq 'tick gnus-tmp-marked)))
1362 (gnus-tmp-process-marked
1363 (if (member gnus-tmp-group gnus-group-marked)
1364 gnus-process-mark ? ))
1366 (or (and gnus-use-grouplens
1367 (bbb-grouplens-group-p gnus-tmp-group))
1369 (buffer-read-only nil)
1370 header gnus-tmp-header) ; passed as parameter to user-funcs.
1372 (gnus-add-text-properties
1376 (let ((gnus-tmp-group (gnus-group-name-decode
1377 gnus-tmp-group group-name-charset)))
1378 (eval gnus-group-line-format-spec)))
1379 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1380 gnus-unread ,(if (numberp number)
1381 (string-to-int gnus-tmp-number-of-unread)
1383 gnus-marked ,gnus-tmp-marked-mark
1384 gnus-indentation ,gnus-group-indentation
1385 gnus-level ,gnus-tmp-level))
1387 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1388 (gnus-run-hooks 'gnus-group-update-hook))
1390 ;; Allow XEmacs to remove front-sticky text properties.
1391 (gnus-group-remove-excess-properties)))
1393 (defun gnus-group-highlight-line ()
1394 "Highlight the current line according to `gnus-group-highlight'."
1395 (let* ((list gnus-group-highlight)
1397 (end (progn (end-of-line) (point)))
1398 ;; now find out where the line starts and leave point there.
1399 (beg (progn (beginning-of-line) (point)))
1400 (group (gnus-group-group-name))
1401 (entry (gnus-group-entry group))
1402 (unread (if (numberp (car entry)) (car entry) 0))
1403 (active (gnus-active group))
1404 (total (if active (1+ (- (cdr active) (car active))) 0))
1405 (info (nth 2 entry))
1406 (method (gnus-server-get-method group (gnus-info-method info)))
1407 (marked (gnus-info-marks info))
1408 (mailp (apply 'append
1411 (memq x (assoc (symbol-name
1412 (car (or method gnus-select-method)))
1413 gnus-valid-select-methods)))
1414 '(mail post-mail))))
1415 (level (or (gnus-info-level info) gnus-level-killed))
1416 (score (or (gnus-info-score info) 0))
1417 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1418 (group-age (gnus-group-timestamp-delta group))
1419 (inhibit-read-only t))
1420 ;; Eval the cars of the lists until we find a match.
1422 (not (eval (caar list))))
1423 (setq list (cdr list)))
1424 (let ((face (cdar list)))
1425 (unless (eq face (get-text-property beg 'face))
1426 (gnus-put-text-property-excluding-characters-with-faces
1428 (setq face (if (boundp face) (symbol-value face) face)))
1429 (gnus-extent-start-open beg)))
1432 (defun gnus-group-update-group (group &optional visible-only)
1433 "Update all lines where GROUP appear.
1434 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1436 ;; Can't use `save-excursion' here, so we do it manually.
1437 (let ((buf (current-buffer))
1439 (set-buffer gnus-group-buffer)
1440 (setq mark (point-marker))
1441 ;; The buffer may be narrowed.
1444 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1446 found buffer-read-only)
1447 ;; Enter the current status into the dribble buffer.
1448 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1450 (not (gnus-ephemeral-group-p group)))
1452 (concat "(gnus-group-set-info '"
1453 (gnus-prin1-to-string (nth 2 entry))
1455 ;; Find all group instances. If topics are in use, each group
1456 ;; may be listed in more than once.
1457 (while (setq loc (text-property-any
1458 loc (point-max) 'gnus-group ident))
1461 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1463 (gnus-group-insert-group-line-info group)
1466 (gnus-run-hooks 'gnus-group-update-group-hook)))
1467 (setq loc (1+ loc)))
1468 (unless (or found visible-only)
1469 ;; No such line in the buffer, find out where it's supposed to
1470 ;; go, and insert it there (or at the end of the buffer).
1471 (if gnus-goto-missing-group-function
1472 (funcall gnus-goto-missing-group-function group)
1473 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1474 (while (and entry (car entry)
1478 (point-min) (point-max)
1479 'gnus-group (gnus-intern-safe
1480 (caar entry) gnus-active-hashtb)))))
1481 (setq entry (cdr entry)))
1482 (or entry (goto-char (point-max)))))
1483 ;; Finally insert the line.
1484 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1485 (gnus-group-insert-group-line-info group)
1488 (gnus-run-hooks 'gnus-group-update-group-hook))))
1489 (when gnus-group-update-group-function
1490 (funcall gnus-group-update-group-function group))
1491 (gnus-group-set-mode-line)))
1493 (set-marker mark nil)
1496 (defun gnus-group-set-mode-line ()
1497 "Update the mode line in the group buffer."
1498 (when (memq 'group gnus-updated-mode-lines)
1499 ;; Yes, we want to keep this mode line updated.
1501 (set-buffer gnus-group-buffer)
1502 (let* ((gformat (or gnus-group-mode-line-format-spec
1503 (gnus-set-format 'group-mode)))
1504 (gnus-tmp-news-server (cadr gnus-select-method))
1505 (gnus-tmp-news-method (car gnus-select-method))
1506 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1508 gnus-tmp-header ;Dummy binding for user-defined formats
1509 ;; Get the resulting string.
1511 (and gnus-dribble-buffer
1512 (buffer-name gnus-dribble-buffer)
1513 (buffer-modified-p gnus-dribble-buffer)
1515 (set-buffer gnus-dribble-buffer)
1516 (not (zerop (buffer-size))))))
1517 (mode-string (eval gformat)))
1518 ;; Say whether the dribble buffer has been modified.
1519 (setq mode-line-modified
1520 (if modified (car gnus-mode-line-modified)
1521 (cdr gnus-mode-line-modified)))
1522 ;; If the line is too long, we chop it off.
1523 (when (> (length mode-string) max-len)
1524 (setq mode-string (substring mode-string 0 (- max-len 4))))
1526 (setq mode-line-buffer-identification
1527 (gnus-mode-line-buffer-identification
1528 (list mode-string)))
1529 (set-buffer-modified-p modified))))))
1531 (defun gnus-group-group-name ()
1532 "Get the name of the newsgroup on the current line."
1533 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1535 (symbol-name group))))
1537 (defun gnus-group-group-level ()
1538 "Get the level of the newsgroup on the current line."
1539 (get-text-property (gnus-point-at-bol) 'gnus-level))
1541 (defun gnus-group-group-indentation ()
1542 "Get the indentation of the newsgroup on the current line."
1543 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1544 (and gnus-group-indentation-function
1545 (funcall gnus-group-indentation-function))
1548 (defun gnus-group-group-unread ()
1549 "Get the number of unread articles of the newsgroup on the current line."
1550 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1552 (defun gnus-group-new-mail (group)
1553 (if (nnmail-new-mail-p (gnus-group-real-name group))
1557 (defun gnus-group-level (group)
1558 "Return the estimated level of GROUP."
1559 (or (gnus-info-level (gnus-get-info group))
1560 (and (member group gnus-zombie-list) gnus-level-zombie)
1563 (defun gnus-group-search-forward (&optional backward all level first-too)
1564 "Find the next newsgroup with unread articles.
1565 If BACKWARD is non-nil, find the previous newsgroup instead.
1566 If ALL is non-nil, just find any newsgroup.
1567 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1569 If FIRST-TOO, the current line is also eligible as a target."
1570 (let ((way (if backward -1 1))
1571 (low gnus-level-killed)
1574 (if (and backward (progn (beginning-of-line)) (bobp))
1583 (get-text-property (point) 'gnus-group)
1587 (get-text-property (point) 'gnus-unread)))
1588 (and (numberp unread) (> unread 0)))
1589 (setq lev (get-text-property (point)
1591 (<= lev gnus-level-subscribed)))
1593 (and (setq lev (get-text-property (point)
1602 (zerop (forward-line way)))))
1604 (progn (gnus-group-position-point) t)
1605 (goto-char (or pos beg))
1608 ;;; Gnus group mode commands
1612 (defun gnus-group-mark-line-p ()
1615 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1616 (eq (char-after) gnus-process-mark)))
1618 (defun gnus-group-mark-group (n &optional unmark no-advance)
1619 "Mark the current group."
1621 (let ((buffer-read-only nil)
1625 (when (setq group (gnus-group-group-name))
1626 ;; Go to the mark position.
1628 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1629 (subst-char-in-region
1630 (point) (1+ (point)) (char-after)
1633 (setq gnus-group-marked (delete group gnus-group-marked))
1635 (setq gnus-group-marked
1636 (cons group (delete group gnus-group-marked)))
1637 gnus-process-mark)))
1639 (gnus-group-next-group 1))
1641 (gnus-summary-position-point)
1644 (defun gnus-group-unmark-group (n)
1645 "Remove the mark from the current group."
1647 (gnus-group-mark-group n 'unmark)
1648 (gnus-group-position-point))
1650 (defun gnus-group-unmark-all-groups ()
1651 "Unmark all groups."
1653 (let ((groups gnus-group-marked))
1656 (gnus-group-remove-mark (pop groups)))))
1657 (gnus-group-position-point))
1659 (defun gnus-group-mark-region (unmark beg end)
1660 "Mark all groups between point and mark.
1661 If UNMARK, remove the mark instead."
1662 (interactive "P\nr")
1663 (let ((num (count-lines beg end)))
1666 (- num (gnus-group-mark-group num unmark)))))
1668 (defun gnus-group-mark-buffer (&optional unmark)
1669 "Mark all groups in the buffer.
1670 If UNMARK, remove the mark instead."
1672 (gnus-group-mark-region unmark (point-min) (point-max)))
1674 (defun gnus-group-mark-regexp (regexp)
1675 "Mark all groups that match some regexp."
1676 (interactive "sMark (regexp): ")
1677 (let ((alist (cdr gnus-newsrc-alist))
1680 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1681 (gnus-group-set-mark group))))
1682 (gnus-group-position-point))
1684 (defun gnus-group-remove-mark (group &optional test-marked)
1685 "Remove the process mark from GROUP and move point there.
1686 Return nil if the group isn't displayed."
1687 (if (gnus-group-goto-group group nil test-marked)
1689 (gnus-group-mark-group 1 'unmark t)
1691 (setq gnus-group-marked
1692 (delete group gnus-group-marked))
1695 (defun gnus-group-set-mark (group)
1696 "Set the process mark on GROUP."
1697 (if (gnus-group-goto-group group)
1699 (gnus-group-mark-group 1 nil t))
1700 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1702 (defun gnus-group-universal-argument (arg &optional groups func)
1703 "Perform any command on all groups according to the process/prefix convention."
1705 (if (eq (setq func (or func
1708 (substitute-command-keys
1709 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1711 (gnus-error 1 "Undefined key")
1712 (gnus-group-iterate arg
1714 (command-execute func))))
1715 (gnus-group-position-point))
1717 (defun gnus-group-process-prefix (n)
1718 "Return a list of groups to work on.
1719 Take into consideration N (the prefix) and the list of marked groups."
1722 (setq n (prefix-numeric-value n))
1723 ;; There is a prefix, so we return a list of the N next
1725 (let ((way (if (< n 0) -1 1))
1730 (if (setq group (gnus-group-group-name))
1731 (push group groups))
1733 (gnus-group-next-group way)))
1735 ((and (gnus-region-active-p) (mark))
1736 ;; Work on the region between point and mark.
1737 (let ((max (max (point) (mark)))
1740 (goto-char (min (point) (mark)))
1743 (push (gnus-group-group-name) groups)
1744 (zerop (gnus-group-next-group 1))
1746 (nreverse groups))))
1748 ;; No prefix, but a list of marked articles.
1749 (reverse gnus-group-marked))
1751 ;; Neither marked articles or a prefix, so we return the
1753 (let ((group (gnus-group-group-name)))
1754 (and group (list group))))))
1756 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1757 ;;; imagine why I went through these contortions...
1759 (let ((function (make-symbol "gnus-group-iterate-function"))
1760 (window (make-symbol "gnus-group-iterate-window"))
1761 (groups (make-symbol "gnus-group-iterate-groups"))
1762 (group (make-symbol "gnus-group-iterate-group")))
1764 `(defun gnus-group-iterate (arg ,function)
1765 "Iterate FUNCTION over all process/prefixed groups.
1766 FUNCTION will be called with the group name as the parameter
1767 and with point over the group in question."
1768 (let ((,groups (gnus-group-process-prefix arg))
1769 (,window (selected-window))
1772 (setq ,group (car ,groups)
1773 ,groups (cdr ,groups))
1774 (select-window ,window)
1775 (gnus-group-remove-mark ,group)
1776 (save-selected-window
1778 (funcall ,function ,group)))))))))
1780 (put 'gnus-group-iterate 'lisp-indent-function 1)
1782 ;; Selecting groups.
1784 (defun gnus-group-read-group (&optional all no-article group select-articles)
1785 "Read news in this newsgroup.
1786 If the prefix argument ALL is non-nil, already read articles become
1787 readable. IF ALL is a number, fetch this number of articles. If the
1788 optional argument NO-ARTICLE is non-nil, no article will be
1789 auto-selected upon group entry. If GROUP is non-nil, fetch that
1792 (let ((no-display (eq all 0))
1793 (group (or group (gnus-group-group-name)))
1794 number active marked entry)
1798 (error "No group on current line"))
1799 (setq marked (gnus-info-marks
1800 (nth 2 (setq entry (gnus-gethash
1801 group gnus-newsrc-hashtb)))))
1802 ;; This group might be a dead group. In that case we have to get
1803 ;; the number of unread articles from `gnus-active-hashtb'.
1805 (cond ((numberp all) all)
1807 ((setq active (gnus-active group))
1808 (- (1+ (cdr active)) (car active)))))
1809 (gnus-summary-read-group
1810 group (or all (and (numberp number)
1811 (zerop (+ number (gnus-range-length
1812 (cdr (assq 'tick marked)))
1814 (cdr (assq 'dormant marked)))))))
1815 no-article nil no-display nil select-articles)))
1817 (defun gnus-group-select-group (&optional all)
1818 "Select this newsgroup.
1819 No article is selected automatically.
1820 If the group is opened, just switch the summary buffer.
1821 If ALL is non-nil, already read articles become readable.
1822 If ALL is a number, fetch this number of articles."
1824 (gnus-group-read-group all t))
1826 (defun gnus-group-quick-select-group (&optional all)
1827 "Select the current group \"quickly\".
1828 This means that no highlighting or scoring will be performed.
1829 If ALL (the prefix argument) is 0, don't even generate the summary
1832 This might be useful if you want to toggle threading
1833 before entering the group."
1835 (require 'gnus-score)
1837 gnus-score-find-score-files-function
1838 gnus-home-score-file
1839 gnus-apply-kill-hook
1840 gnus-summary-expunge-below)
1841 (gnus-group-read-group all t)))
1843 (defun gnus-group-visible-select-group (&optional all)
1844 "Select the current group without hiding any articles."
1846 (let ((gnus-inhibit-limiting t))
1847 (gnus-group-read-group all t)))
1849 (defun gnus-group-select-group-ephemerally ()
1850 "Select the current group without doing any processing whatsoever.
1851 You will actually be entered into a group that's a copy of
1852 the current group; no changes you make while in this group will
1855 (require 'gnus-score)
1857 gnus-score-find-score-files-function gnus-apply-kill-hook
1858 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1859 gnus-summary-mode-hook gnus-select-group-hook
1860 (group (gnus-group-group-name))
1861 (method (gnus-find-method-for-group group)))
1862 (gnus-group-read-ephemeral-group
1863 (gnus-group-prefixed-name group method) method)))
1866 (defun gnus-fetch-group (group &optional articles)
1867 "Start Gnus if necessary and enter GROUP.
1868 Returns whether the fetching was successful or not."
1869 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1870 (unless (get-buffer gnus-group-buffer)
1872 (gnus-group-read-group articles nil group))
1875 (defun gnus-fetch-group-other-frame (group)
1876 "Pop up a frame and enter GROUP."
1878 (let ((window (get-buffer-window gnus-group-buffer)))
1880 (select-frame (window-frame window)))
1881 ((= (length (frame-list)) 1)
1882 (select-frame (make-frame)))
1885 (gnus-fetch-group group))
1887 (defvar gnus-ephemeral-group-server 0)
1889 ;; Enter a group that is not in the group buffer. Non-nil is returned
1890 ;; if selection was successful.
1891 (defun gnus-group-read-ephemeral-group (group method &optional activate
1892 quit-config request-only
1895 "Read GROUP from METHOD as an ephemeral group.
1896 If ACTIVATE, request the group first.
1897 If QUIT-CONFIG, use that window configuration when exiting from the
1899 If REQUEST-ONLY, don't actually read the group; just request it.
1900 If SELECT-ARTICLES, only select those articles.
1901 If PARAMETERS, use those as the group parameters.
1903 Return the name of the group if selection was successful."
1904 ;; Transform the select method into a unique server.
1905 (when (stringp method)
1906 (setq method (gnus-server-to-method method)))
1908 `(,(car method) ,(concat (cadr method) "-ephemeral")
1909 (,(intern (format "%s-address" (car method))) ,(cadr method))
1911 (let ((group (if (gnus-group-foreign-p group) group
1912 (gnus-group-prefixed-name (gnus-group-real-name group)
1917 ,gnus-level-default-subscribed nil nil ,method
1920 (cons 'quit-config quit-config)
1922 (cons gnus-summary-buffer
1923 gnus-current-window-configuration)))
1926 (push method gnus-ephemeral-servers)
1927 (set-buffer gnus-group-buffer)
1928 (unless (gnus-check-server method)
1929 (error "Unable to contact server: %s" (gnus-status-message method)))
1931 (gnus-activate-group group 'scan)
1932 (unless (gnus-request-group group)
1933 (error "Couldn't request group: %s"
1934 (nnheader-get-report (car method)))))
1938 (when (gnus-group-read-group t t group select-articles)
1942 (message "Quit reading the ephemeral group")
1945 (defun gnus-group-jump-to-group (group)
1946 "Jump to newsgroup GROUP."
1948 (list (completing-read
1949 "Group: " gnus-active-hashtb nil
1950 (gnus-read-active-file-p)
1951 gnus-group-jump-to-group-prompt
1952 'gnus-group-history)))
1954 (when (equal group "")
1955 (error "Empty group name"))
1957 (unless (gnus-ephemeral-group-p group)
1958 ;; Either go to the line in the group buffer...
1959 (unless (gnus-group-goto-group group)
1960 ;; ... or insert the line.
1961 (gnus-group-update-group group)
1962 (gnus-group-goto-group group)))
1963 ;; Adjust cursor point.
1964 (gnus-group-position-point))
1966 (defun gnus-group-goto-group (group &optional far test-marked)
1967 "Goto to newsgroup GROUP.
1968 If FAR, it is likely that the group is not on the current line.
1969 If TEST-MARKED, the line must be marked."
1973 ;; It's quite likely that we are on the right line, so
1974 ;; we check the current line first.
1976 (eq (get-text-property (point) 'gnus-group)
1977 (gnus-intern-safe group gnus-active-hashtb))
1978 (or (not test-marked) (gnus-group-mark-line-p)))
1980 ;; Previous and next line are also likely, so we check them as well.
1984 (and (eq (get-text-property (point) 'gnus-group)
1985 (gnus-intern-safe group gnus-active-hashtb))
1986 (or (not test-marked) (gnus-group-mark-line-p)))))
1992 (and (eq (get-text-property (point) 'gnus-group)
1993 (gnus-intern-safe group gnus-active-hashtb))
1994 (or (not test-marked) (gnus-group-mark-line-p)))))
1998 (goto-char (point-min))
2000 (while (and (not found)
2005 (gnus-intern-safe group gnus-active-hashtb))))
2006 (if (gnus-group-mark-line-p)
2011 ;; Search through the entire buffer.
2014 (point-min) (point-max)
2015 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2017 (defun gnus-group-next-group (n &optional silent)
2018 "Go to next N'th newsgroup.
2019 If N is negative, search backward instead.
2020 Returns the difference between N and the number of skips actually
2023 (gnus-group-next-unread-group n t nil silent))
2025 (defun gnus-group-next-unread-group (n &optional all level silent)
2026 "Go to next N'th unread newsgroup.
2027 If N is negative, search backward instead.
2028 If ALL is non-nil, choose any newsgroup, unread or not.
2029 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2030 such group can be found, the next group with a level higher than
2032 Returns the difference between N and the number of skips actually
2035 (let ((backward (< n 0))
2038 (gnus-group-search-forward
2039 backward (or (not gnus-group-goto-unread) all) level))
2043 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2044 (if level " on this level or higher" "")))
2047 (defun gnus-group-prev-group (n)
2048 "Go to previous N'th newsgroup.
2049 Returns the difference between N and the number of skips actually
2052 (gnus-group-next-unread-group (- n) t))
2054 (defun gnus-group-prev-unread-group (n)
2055 "Go to previous N'th unread newsgroup.
2056 Returns the difference between N and the number of skips actually
2059 (gnus-group-next-unread-group (- n)))
2061 (defun gnus-group-next-unread-group-same-level (n)
2062 "Go to next N'th unread newsgroup on the same level.
2063 If N is negative, search backward instead.
2064 Returns the difference between N and the number of skips actually
2067 (gnus-group-next-unread-group n t (gnus-group-group-level))
2068 (gnus-group-position-point))
2070 (defun gnus-group-prev-unread-group-same-level (n)
2071 "Go to next N'th unread newsgroup on the same level.
2072 Returns the difference between N and the number of skips actually
2075 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2076 (gnus-group-position-point))
2078 (defun gnus-group-best-unread-group (&optional exclude-group)
2079 "Go to the group with the highest level.
2080 If EXCLUDE-GROUP, do not go to that group."
2082 (goto-char (point-min))
2086 (setq unread (get-text-property (point) 'gnus-unread))
2087 (when (and (numberp unread) (> unread 0))
2088 (when (and (get-text-property (point) 'gnus-level)
2089 (< (get-text-property (point) 'gnus-level) best)
2090 (or (not exclude-group)
2091 (not (equal exclude-group (gnus-group-group-name)))))
2092 (setq best (get-text-property (point) 'gnus-level))
2093 (setq best-point (point))))
2096 (goto-char best-point))
2097 (gnus-group-position-point)
2098 (and best-point (gnus-group-group-name))))
2100 (defun gnus-group-first-unread-group ()
2101 "Go to the first group with unread articles."
2104 (let ((opoint (point))
2106 (goto-char (point-min))
2107 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2108 (and (numberp unread) ; Not a topic.
2109 (not (zerop unread))) ; Has unread articles.
2110 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2113 nil)) ; Not success.
2114 (gnus-group-position-point)))
2116 (defun gnus-group-enter-server-mode ()
2117 "Jump to the server buffer."
2119 (gnus-enter-server-buffer))
2121 (defun gnus-group-make-group (name &optional method address args)
2122 "Add a new newsgroup.
2123 The user will be prompted for a NAME, for a select METHOD, and an
2127 (gnus-read-group "Group name: ")
2128 (gnus-read-method "From method: ")))
2130 (when (stringp method)
2131 (setq method (or (gnus-server-to-method method) method)))
2132 (let* ((meth (gnus-method-simplify
2134 (not (gnus-server-equal method gnus-select-method)))
2135 (if address (list (intern method) address)
2137 (nname (if method (gnus-group-prefixed-name name meth) name))
2139 (when (gnus-gethash nname gnus-newsrc-hashtb)
2140 (error "Group %s already exists" nname))
2141 ;; Subscribe to the new group.
2142 (gnus-group-change-level
2143 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2144 gnus-level-default-subscribed gnus-level-killed
2145 (and (gnus-group-group-name)
2146 (gnus-gethash (gnus-group-group-name)
2147 gnus-newsrc-hashtb))
2150 (gnus-set-active nname (cons 1 0))
2151 (unless (gnus-ephemeral-group-p name)
2153 (concat "(gnus-group-set-info '"
2154 (gnus-prin1-to-string (cdr info)) ")")))
2156 (gnus-group-insert-group-line-info nname)
2158 (gnus-group-position-point)
2160 ;; Load the backend and try to make the backend create
2161 ;; the group as well.
2162 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2164 gnus-valid-select-methods)
2166 (gnus-check-server meth)
2167 (when (gnus-check-backend-function 'request-create-group nname)
2168 (gnus-request-create-group nname nil args))
2171 (defun gnus-group-delete-groups (&optional arg)
2172 "Delete the current group. Only meaningful with editable groups."
2174 (let ((n (length (gnus-group-process-prefix arg))))
2175 (when (gnus-yes-or-no-p
2177 "Delete this 1 group? "
2178 (format "Delete these %d groups? " n)))
2179 (gnus-group-iterate arg
2181 (gnus-group-delete-group group nil t))))))
2183 (defun gnus-group-delete-group (group &optional force no-prompt)
2184 "Delete the current group. Only meaningful with editable groups.
2185 If FORCE (the prefix) is non-nil, all the articles in the group will
2186 be deleted. This is \"deleted\" as in \"removed forever from the face
2187 of the Earth\". There is no undo. The user will be prompted before
2188 doing the deletion."
2190 (list (gnus-group-group-name)
2191 current-prefix-arg))
2193 (error "No group to delete"))
2194 (unless (gnus-check-backend-function 'request-delete-group group)
2195 (error "This backend does not support group deletion"))
2197 (if (and (not no-prompt)
2198 (not (gnus-yes-or-no-p
2200 "Do you really want to delete %s%s? "
2201 group (if force " and all its contents" "")))))
2203 (gnus-message 6 "Deleting group %s..." group)
2204 (if (not (gnus-request-delete-group group force))
2205 (gnus-error 3 "Couldn't delete group %s" group)
2206 (gnus-message 6 "Deleting group %s...done" group)
2207 (gnus-group-goto-group group)
2208 (gnus-group-kill-group 1 t)
2209 (gnus-sethash group nil gnus-active-hashtb)
2210 (when (and (boundp 'gnus-cache-active-hashtb)
2211 gnus-cache-active-hashtb)
2212 (gnus-sethash group nil gnus-cache-active-hashtb)
2213 (setq gnus-cache-active-altered t))
2215 (gnus-group-position-point)))
2217 (defun gnus-group-rename-group (group new-name)
2218 "Rename group from GROUP to NEW-NAME.
2219 When used interactively, GROUP is the group under point
2220 and NEW-NAME will be prompted for."
2223 (gnus-group-group-name)
2225 (unless (gnus-check-backend-function
2226 'request-rename-group (gnus-group-group-name))
2227 (error "This backend does not support renaming groups"))
2228 (gnus-read-group "Rename group to: "
2229 (gnus-group-real-name (gnus-group-group-name))))))
2231 (unless (gnus-check-backend-function 'request-rename-group group)
2232 (error "This backend does not support renaming groups"))
2234 (error "No group to rename"))
2235 (when (equal (gnus-group-real-name group) new-name)
2236 (error "Can't rename to the same name"))
2238 ;; We find the proper prefixed name.
2240 (if (gnus-group-native-p group)
2244 (gnus-group-prefixed-name
2245 (gnus-group-real-name new-name)
2246 (gnus-info-method (gnus-get-info group)))))
2248 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2251 (gnus-group-goto-group group)
2252 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2253 (gnus-request-rename-group group new-name))))
2254 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2255 ;; We rename the group internally by killing it...
2256 (gnus-group-kill-group)
2257 ;; ... changing its name ...
2258 (setcar (cdar gnus-list-of-killed-groups) new-name)
2259 ;; ... and then yanking it. Magic!
2260 (gnus-group-yank-group)
2261 (gnus-set-active new-name (gnus-active group))
2262 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2264 (setq gnus-killed-list (delete group gnus-killed-list))
2265 (gnus-set-active group nil)
2266 (gnus-dribble-touch)
2267 (gnus-group-position-point)))
2269 (defun gnus-group-edit-group (group &optional part)
2270 "Edit the group on the current line."
2271 (interactive (list (gnus-group-group-name)))
2272 (let ((part (or part 'info))
2275 (error "No group on current line"))
2276 (unless (setq info (gnus-get-info group))
2277 (error "Killed group; can't be edited"))
2279 (gnus-close-group group))
2281 ;; Find the proper form to edit.
2282 (cond ((eq part 'method)
2283 (or (gnus-info-method info) "native"))
2285 (gnus-info-params info))
2287 ;; The proper documentation.
2289 "Editing the %s for `%s'."
2291 ((eq part 'method) "select method")
2292 ((eq part 'params) "group parameters")
2294 (gnus-group-decoded-name group))
2296 (gnus-group-edit-group-done ',part ,group form)))
2299 (gnus-create-info-command
2302 "(gnus)Select Methods")
2304 "(gnus)Group Parameters")
2306 "(gnus)Group Info"))))))
2308 (defun gnus-group-edit-group-method (group)
2309 "Edit the select method of GROUP."
2310 (interactive (list (gnus-group-group-name)))
2311 (gnus-group-edit-group group 'method))
2313 (defun gnus-group-edit-group-parameters (group)
2314 "Edit the group parameters of GROUP."
2315 (interactive (list (gnus-group-group-name)))
2316 (gnus-group-edit-group group 'params))
2318 (defun gnus-group-edit-group-done (part group form)
2320 (let* ((method (cond ((eq part 'info) (nth 4 form))
2321 ((eq part 'method) form)
2323 (info (cond ((eq part 'info) form)
2324 ((eq part 'method) (gnus-get-info group))
2327 (if (or (not method)
2329 gnus-select-method method))
2330 (gnus-group-real-name (car info))
2331 (gnus-group-prefixed-name
2332 (gnus-group-real-name (car info)) method))
2334 (when (and new-group
2335 (not (equal new-group group)))
2336 (when (gnus-group-goto-group group)
2337 (gnus-group-kill-group 1))
2338 (gnus-activate-group new-group))
2340 (if (not (and info new-group))
2341 (gnus-group-set-info form (or new-group group) part)
2342 (setq info (gnus-copy-sequence info))
2343 (setcar info new-group)
2344 (unless (gnus-server-equal method "native")
2345 (unless (nthcdr 3 info)
2346 (nconc info (list nil nil)))
2347 (unless (nthcdr 4 info)
2348 (nconc info (list nil)))
2349 (gnus-info-set-method info method))
2350 (gnus-group-set-info info))
2351 (gnus-group-update-group (or new-group group))
2352 (gnus-group-position-point)))
2354 (defun gnus-group-make-useful-group (group method)
2355 "Create one of the groups described in `gnus-useful-groups'."
2357 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2359 gnus-useful-groups)))
2360 (list (cadr entry) (caddr entry))))
2361 (setq method (gnus-copy-sequence method))
2363 (while (setq entry (memq (assq 'eval method) method))
2364 (setcar entry (eval (cadar entry)))))
2365 (gnus-group-make-group group method))
2367 (defun gnus-group-make-help-group (&optional noerror)
2368 "Create the Gnus documentation group.
2369 Optional argument NOERROR modifies the behavior of this function when the
2370 group already exists:
2371 - if not given, and error is signaled,
2372 - if t, stay silent,
2373 - if anything else, just print a message."
2375 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2376 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2377 (if (gnus-gethash name gnus-newsrc-hashtb)
2378 (cond ((eq noerror nil)
2379 (error "Documentation group already exists"))
2384 (gnus-message 1 "Documentation group already exists")))
2387 (gnus-message 1 "Couldn't find doc group")
2388 (gnus-group-make-group
2389 (gnus-group-real-name name)
2390 (list 'nndoc "gnus-help"
2391 (list 'nndoc-address file)
2392 (list 'nndoc-article-type 'mbox))))
2394 (gnus-group-position-point))
2396 (defun gnus-group-make-doc-group (file type)
2397 "Create a group that uses a single file as the source."
2399 (list (read-file-name "File name: ")
2400 (and current-prefix-arg 'ask)))
2401 (when (eq type 'ask)
2406 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2408 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2409 ((= char ?b) 'babyl)
2410 ((= char ?d) 'digest)
2411 ((= char ?f) 'forward)
2413 ((= char ?g) 'guess)
2414 (t (setq err (format "%c unknown. " char))
2417 (let* ((file (expand-file-name file))
2418 (name (gnus-generate-new-group-name
2419 (gnus-group-prefixed-name
2420 (file-name-nondirectory file) '(nndoc "")))))
2421 (gnus-group-make-group
2422 (gnus-group-real-name name)
2424 (list 'nndoc-address file)
2425 (list 'nndoc-article-type (or type 'guess))))))
2427 (defvar nnweb-type-definition)
2428 (defvar gnus-group-web-type-history nil)
2429 (defvar gnus-group-web-search-history nil)
2430 (defun gnus-group-make-web-group (&optional solid)
2431 "Create an ephemeral nnweb group.
2432 If SOLID (the prefix), create a solid group."
2436 (if solid (gnus-read-group "Group name: ")
2437 (message-unique-id)))
2438 (default-type (or (car gnus-group-web-type-history)
2439 (symbol-name (caar nnweb-type-definition))))
2443 (format "Search engine type (default %s): " default-type)
2444 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2445 nnweb-type-definition)
2446 nil t nil 'gnus-group-web-type-history)
2451 (cons (or (car gnus-group-web-search-history) "") 0)
2452 'gnus-group-web-search-history))
2454 `(nnweb ,group (nnweb-search ,search)
2455 (nnweb-type ,(intern type))
2456 (nnweb-ephemeral-p t))))
2458 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2459 (gnus-group-read-ephemeral-group
2461 (cons (current-buffer)
2462 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2464 (defvar nnwarchive-type-definition)
2465 (defvar gnus-group-warchive-type-history nil)
2466 (defvar gnus-group-warchive-login-history nil)
2467 (defvar gnus-group-warchive-address-history nil)
2469 (defun gnus-group-make-warchive-group ()
2470 "Create a nnwarchive group."
2472 (require 'nnwarchive)
2473 (let* ((group (gnus-read-group "Group name: "))
2474 (default-type (or (car gnus-group-warchive-type-history)
2475 (symbol-name (caar nnwarchive-type-definition))))
2479 (format "Warchive type (default %s): " default-type)
2480 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2481 nnwarchive-type-definition)
2482 nil t nil 'gnus-group-warchive-type-history)
2484 (address (read-string "Warchive address: "
2485 nil 'gnus-group-warchive-address-history))
2486 (default-login (or (car gnus-group-warchive-login-history)
2491 (format "Warchive login (default %s): " user-mail-address)
2492 default-login 'gnus-group-warchive-login-history)
2495 `(nnwarchive ,address
2496 (nnwarchive-type ,(intern type))
2497 (nnwarchive-login ,login))))
2498 (gnus-group-make-group group method)))
2500 (defun gnus-group-make-archive-group (&optional all)
2501 "Create the (ding) Gnus archive group of the most recent articles.
2502 Given a prefix, create a full group."
2504 (let ((group (gnus-group-prefixed-name
2505 (if all "ding.archives" "ding.recent") '(nndir ""))))
2506 (when (gnus-gethash group gnus-newsrc-hashtb)
2507 (error "Archive group already exists"))
2508 (gnus-group-make-group
2509 (gnus-group-real-name group)
2510 (list 'nndir (if all "hpc" "edu")
2511 (list 'nndir-directory
2512 (if all gnus-group-archive-directory
2513 gnus-group-recent-archive-directory))))
2514 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2516 (defun gnus-group-make-directory-group (dir)
2517 "Create an nndir group.
2518 The user will be prompted for a directory. The contents of this
2519 directory will be used as a newsgroup. The directory should contain
2520 mail messages or news articles in files that have numeric names."
2522 (list (read-file-name "Create group from directory: ")))
2523 (unless (file-exists-p dir)
2524 (error "No such directory"))
2525 (unless (file-directory-p dir)
2526 (error "Not a directory"))
2530 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2532 (gnus-group-prefixed-name
2533 (expand-file-name ext dir)
2535 (setq ext (format "<%d>" (setq i (1+ i)))))
2536 (gnus-group-make-group
2537 (gnus-group-real-name group)
2538 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2540 (eval-when-compile (defvar nnkiboze-score-file))
2541 (defun gnus-group-make-kiboze-group (group address scores)
2542 "Create an nnkiboze group.
2543 The user will be prompted for a name, a regexp to match groups, and
2544 score file entries for articles to include in the group."
2547 (read-string "nnkiboze group name: ")
2548 (read-string "Source groups (regexp): ")
2549 (let ((headers (mapcar (lambda (group) (list group))
2550 '("subject" "from" "number" "date" "message-id"
2551 "references" "chars" "lines" "xref"
2552 "followup" "all" "body" "head")))
2553 scores header regexp regexps)
2554 (while (not (equal "" (setq header (completing-read
2555 "Match on header: " headers nil t))))
2557 (while (not (equal "" (setq regexp (read-string
2558 (format "Match on %s (regexp): "
2560 (push (list regexp nil nil 'r) regexps))
2561 (push (cons header regexps) scores))
2563 (gnus-group-make-group group "nnkiboze" address)
2564 (let* ((nnkiboze-current-group group)
2565 (score-file (car (nnkiboze-score-file "")))
2566 (score-dir (file-name-directory score-file)))
2567 (unless (file-exists-p score-dir)
2568 (make-directory score-dir))
2569 (with-temp-file score-file
2570 (let (emacs-lisp-mode-hook)
2571 (pp scores (current-buffer))))))
2573 (defun gnus-group-add-to-virtual (n vgroup)
2574 "Add the current group to a virtual group."
2576 (list current-prefix-arg
2577 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2579 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2580 (error "%s is not an nnvirtual group" vgroup))
2581 (gnus-close-group vgroup)
2582 (let* ((groups (gnus-group-process-prefix n))
2583 (method (gnus-info-method (gnus-get-info vgroup))))
2584 (setcar (cdr method)
2586 (nth 1 method) "\\|"
2589 (gnus-group-remove-mark s)
2590 (concat "\\(^" (regexp-quote s) "$\\)"))
2592 (gnus-group-position-point))
2594 (defun gnus-group-make-empty-virtual (group)
2595 "Create a new, fresh, empty virtual group."
2596 (interactive "sCreate new, empty virtual group: ")
2597 (let* ((method (list 'nnvirtual "^$"))
2598 (pgroup (gnus-group-prefixed-name group method)))
2599 ;; Check whether it exists already.
2600 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2601 (error "Group %s already exists" pgroup))
2602 ;; Subscribe the new group after the group on the current line.
2603 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2604 (gnus-group-update-group pgroup)
2606 (gnus-group-position-point)))
2608 (defun gnus-group-enter-directory (dir)
2609 "Enter an ephemeral nneething group."
2610 (interactive "DDirectory to read: ")
2611 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2612 (leaf (gnus-group-prefixed-name
2613 (file-name-nondirectory (directory-file-name dir))
2615 (name (gnus-generate-new-group-name leaf)))
2616 (unless (gnus-group-read-ephemeral-group
2618 (cons (current-buffer)
2619 (if (eq major-mode 'gnus-summary-mode)
2621 (error "Couldn't enter %s" dir))))
2624 (autoload 'nnimap-expunge "nnimap")
2625 (autoload 'nnimap-acl-get "nnimap")
2626 (autoload 'nnimap-acl-edit "nnimap"))
2628 (defun gnus-group-nnimap-expunge (group)
2629 "Expunge deleted articles in current nnimap GROUP."
2630 (interactive (list (gnus-group-group-name)))
2631 (let ((mailbox (gnus-group-real-name group)) method)
2633 (error "No group on current line"))
2634 (unless (gnus-get-info group)
2635 (error "Killed group; can't be edited"))
2636 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2637 (error "%s is not an nnimap group" group))
2638 (nnimap-expunge mailbox (cadr method))))
2640 (defun gnus-group-nnimap-edit-acl (group)
2641 "Edit the Access Control List of current nnimap GROUP."
2642 (interactive (list (gnus-group-group-name)))
2643 (let ((mailbox (gnus-group-real-name group)) method acl)
2645 (error "No group on current line"))
2646 (unless (gnus-get-info group)
2647 (error "Killed group; can't be edited"))
2648 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2649 (error "%s is not an nnimap group" group))
2650 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2651 (error "Server does not support ACL's"))
2652 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2654 An access control list is a list of (identifier . rights) elements.
2656 The identifier string specifies the corresponding user. The
2657 identifier \"anyone\" is reserved to refer to the universal identity.
2659 Rights is a string listing a (possibly empty) set of alphanumeric
2660 characters, each character listing a set of operations which is being
2661 controlled. Letters are reserved for ``standard'' rights, listed
2662 below. Digits are reserved for implementation or site defined rights.
2664 l - lookup (mailbox is visible to LIST/LSUB commands)
2665 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2666 SEARCH, COPY from mailbox)
2667 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2668 w - write (STORE flags other than \\SEEN and \\DELETED)
2669 i - insert (perform APPEND, COPY into mailbox)
2670 p - post (send mail to submission address for mailbox,
2671 not enforced by IMAP4 itself)
2672 c - create and delete mailbox (CREATE new sub-mailboxes in any
2673 implementation-defined hierarchy, RENAME or DELETE mailbox)
2674 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2675 a - administer (perform SETACL)" group)
2678 ,mailbox ',method ',acl form)))))
2680 ;; Group sorting commands
2681 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2683 (defun gnus-group-sort-groups (func &optional reverse)
2684 "Sort the group buffer according to FUNC.
2685 When used interactively, the sorting function used will be
2686 determined by the `gnus-group-sort-function' variable.
2687 If REVERSE (the prefix), reverse the sorting order."
2688 (interactive (list gnus-group-sort-function current-prefix-arg))
2689 (funcall gnus-group-sort-alist-function
2690 (gnus-make-sort-function func) reverse)
2691 (gnus-group-unmark-all-groups)
2692 (gnus-group-list-groups)
2693 (gnus-dribble-touch))
2695 (defun gnus-group-sort-flat (func reverse)
2696 ;; We peel off the dummy group from the alist.
2698 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2699 (pop gnus-newsrc-alist))
2701 (setq gnus-newsrc-alist
2702 (sort gnus-newsrc-alist func))
2704 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2705 ;; Regenerate the hash table.
2706 (gnus-make-hashtable-from-newsrc-alist)))
2708 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2709 "Sort the group buffer alphabetically by group name.
2710 If REVERSE, sort in reverse order."
2712 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2714 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2715 "Sort the group buffer alphabetically by real (unprefixed) group name.
2716 If REVERSE, sort in reverse order."
2718 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2720 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2721 "Sort the group buffer by number of unread articles.
2722 If REVERSE, sort in reverse order."
2724 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2726 (defun gnus-group-sort-groups-by-level (&optional reverse)
2727 "Sort the group buffer by group level.
2728 If REVERSE, sort in reverse order."
2730 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2732 (defun gnus-group-sort-groups-by-score (&optional reverse)
2733 "Sort the group buffer by group score.
2734 If REVERSE, sort in reverse order."
2736 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2738 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2739 "Sort the group buffer by group rank.
2740 If REVERSE, sort in reverse order."
2742 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2744 (defun gnus-group-sort-groups-by-method (&optional reverse)
2745 "Sort the group buffer alphabetically by backend name.
2746 If REVERSE, sort in reverse order."
2748 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2750 (defun gnus-group-sort-groups-by-server (&optional reverse)
2751 "Sort the group buffer alphabetically by server name.
2752 If REVERSE, sort in reverse order."
2754 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2756 ;;; Selected group sorting.
2758 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2759 "Sort the process/prefixed groups."
2760 (interactive (list current-prefix-arg gnus-group-sort-function))
2761 (let ((groups (gnus-group-process-prefix n)))
2762 (funcall gnus-group-sort-selected-function
2763 groups (gnus-make-sort-function func) reverse)
2764 (gnus-group-unmark-all-groups)
2765 (gnus-group-list-groups)
2766 (gnus-dribble-touch)))
2768 (defun gnus-group-sort-selected-flat (groups func reverse)
2769 (let (entries infos)
2770 ;; First find all the group entries for these groups.
2772 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2774 ;; Then sort the infos.
2778 (lambda (entry) (car entry))
2779 (setq entries (nreverse entries)))
2782 (setq infos (nreverse infos)))
2783 ;; Go through all the infos and replace the old entries
2784 ;; with the new infos.
2786 (setcar (car entries) (pop infos))
2788 ;; Update the hashtable.
2789 (gnus-make-hashtable-from-newsrc-alist)))
2791 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2792 "Sort the group buffer alphabetically by group name.
2793 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2794 sort in reverse order."
2795 (interactive (gnus-interactive "P\ny"))
2796 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2798 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2799 "Sort the group buffer alphabetically by real group name.
2800 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2801 sort in reverse order."
2802 (interactive (gnus-interactive "P\ny"))
2803 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2805 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2806 "Sort the group buffer by number of unread articles.
2807 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2808 sort in reverse order."
2809 (interactive (gnus-interactive "P\ny"))
2810 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2812 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2813 "Sort the group buffer by group level.
2814 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2815 sort in reverse order."
2816 (interactive (gnus-interactive "P\ny"))
2817 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2819 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2820 "Sort the group buffer by group score.
2821 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2822 sort in reverse order."
2823 (interactive (gnus-interactive "P\ny"))
2824 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2826 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2827 "Sort the group buffer by group rank.
2828 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2829 sort in reverse order."
2830 (interactive (gnus-interactive "P\ny"))
2831 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2833 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2834 "Sort the group buffer alphabetically by backend name.
2835 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2836 sort in reverse order."
2837 (interactive (gnus-interactive "P\ny"))
2838 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2840 ;;; Sorting predicates.
2842 (defun gnus-group-sort-by-alphabet (info1 info2)
2843 "Sort alphabetically."
2844 (string< (gnus-info-group info1) (gnus-info-group info2)))
2846 (defun gnus-group-sort-by-real-name (info1 info2)
2847 "Sort alphabetically on real (unprefixed) names."
2848 (string< (gnus-group-real-name (gnus-info-group info1))
2849 (gnus-group-real-name (gnus-info-group info2))))
2851 (defun gnus-group-sort-by-unread (info1 info2)
2852 "Sort by number of unread articles."
2853 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2854 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2855 (< (or (and (numberp n1) n1) 0)
2856 (or (and (numberp n2) n2) 0))))
2858 (defun gnus-group-sort-by-level (info1 info2)
2860 (< (gnus-info-level info1) (gnus-info-level info2)))
2862 (defun gnus-group-sort-by-method (info1 info2)
2863 "Sort alphabetically by backend name."
2864 (string< (car (gnus-find-method-for-group
2865 (gnus-info-group info1) info1))
2866 (car (gnus-find-method-for-group
2867 (gnus-info-group info2) info2))))
2869 (defun gnus-group-sort-by-server (info1 info2)
2870 "Sort alphabetically by server name."
2871 (string< (gnus-method-to-full-server-name
2872 (gnus-find-method-for-group
2873 (gnus-info-group info1) info1))
2874 (gnus-method-to-full-server-name
2875 (gnus-find-method-for-group
2876 (gnus-info-group info2) info2))))
2878 (defun gnus-group-sort-by-score (info1 info2)
2879 "Sort by group score."
2880 (> (gnus-info-score info1) (gnus-info-score info2)))
2882 (defun gnus-group-sort-by-rank (info1 info2)
2883 "Sort by level and score."
2884 (let ((level1 (gnus-info-level info1))
2885 (level2 (gnus-info-level info2)))
2886 (or (< level1 level2)
2887 (and (= level1 level2)
2888 (> (gnus-info-score info1) (gnus-info-score info2))))))
2892 (defun gnus-group-clear-data (&optional arg)
2893 "Clear all marks and read ranges from the current group."
2895 (gnus-group-iterate arg
2898 (gnus-info-clear-data (setq info (gnus-get-info group)))
2899 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2900 (when (gnus-group-goto-group group)
2901 (gnus-group-update-group-line))))))
2903 (defun gnus-group-clear-data-on-native-groups ()
2904 "Clear all marks and read ranges from all native groups."
2906 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2907 (let ((alist (cdr gnus-newsrc-alist))
2909 (while (setq info (pop alist))
2910 (when (gnus-group-native-p (gnus-info-group info))
2911 (gnus-info-clear-data info)))
2912 (gnus-get-unread-articles)
2913 (gnus-dribble-touch)
2914 (when (gnus-y-or-n-p
2915 "Move the cache away to avoid problems in the future? ")
2916 (call-interactively 'gnus-cache-move-cache)))))
2918 (defun gnus-info-clear-data (info)
2919 "Clear all marks and read ranges from INFO."
2920 (let ((group (gnus-info-group info))
2922 (dolist (el (gnus-info-marks info))
2923 (push `(,(cdr el) add (,(car el))) action))
2924 (push `(,(gnus-info-read info) add (read)) action)
2927 (gnus-request-set-mark ,group ',action)
2928 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2929 (gnus-info-set-read ',info ',(gnus-info-read info))
2930 (when (gnus-group-goto-group ,group)
2931 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2932 (gnus-group-update-group-line))))
2933 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2935 (gnus-request-set-mark group action)
2936 (gnus-info-set-read info nil)
2937 (when (gnus-info-marks info)
2938 (gnus-info-set-marks info nil))))
2940 ;; Group catching up.
2942 (defun gnus-group-catchup-current (&optional n all)
2943 "Mark all unread articles in the current newsgroup as read.
2944 If prefix argument N is numeric, the next N newsgroups will be
2945 caught up. If ALL is non-nil, marked articles will also be marked as
2946 read. Cross references (Xref: header) of articles are ignored.
2947 The number of newsgroups that this function was unable to catch
2950 (let ((groups (gnus-group-process-prefix n))
2953 (unless groups (error "No groups selected"))
2955 (or (not gnus-interactive-catchup) ;Without confirmation?
2960 "Do you really want to mark all articles in %s as read? "
2961 "Mark all unread articles in %s as read? ")
2962 (if (= (length groups) 1)
2964 (format "these %d groups" (length groups)))))))
2966 (while (setq group (pop groups))
2967 (gnus-group-remove-mark group)
2968 ;; Virtual groups have to be given special treatment.
2969 (let ((method (gnus-find-method-for-group group)))
2970 (when (eq 'nnvirtual (car method))
2971 (nnvirtual-catchup-group
2972 (gnus-group-real-name group) (nth 1 method) all)))
2973 (if (>= (gnus-group-level group) gnus-level-zombie)
2974 (gnus-message 2 "Dead groups can't be caught up")
2976 (gnus-group-goto-group group)
2977 (gnus-group-catchup group all))
2978 (gnus-group-update-group-line)
2979 (setq ret (1+ ret)))))
2980 (gnus-group-next-unread-group 1)
2983 (defun gnus-group-catchup-current-all (&optional n)
2984 "Mark all articles in current newsgroup as read.
2985 Cross references (Xref: header) of articles are ignored."
2987 (gnus-group-catchup-current n 'all))
2989 (defun gnus-group-catchup (group &optional all)
2990 "Mark all articles in GROUP as read.
2991 If ALL is non-nil, all articles are marked as read.
2992 The return value is the number of articles that were marked as read,
2993 or nil if no action could be taken."
2994 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2996 (marks (nth 3 (nth 2 entry)))
2997 (unread (gnus-list-of-unread-articles group)))
2998 ;; Remove entries for this group.
2999 (nnmail-purge-split-history (gnus-group-real-name group))
3000 ;; Do the updating only if the newsgroup isn't killed.
3001 (if (not (numberp (car entry)))
3002 (gnus-message 1 "Can't catch up %s; non-active group" group)
3003 (gnus-update-read-articles group nil)
3005 ;; Nix out the lists of marks and dormants.
3006 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3008 (list (cdr (assq 'dormant marks))
3010 (setq unread (gnus-uncompress-range
3011 (gnus-range-add (gnus-range-add
3012 unread (cdr (assq 'dormant marks)))
3013 (cdr (assq 'tick marks)))))
3014 (gnus-add-marked-articles group 'tick nil nil 'force)
3015 (gnus-add-marked-articles group 'dormant nil nil 'force))
3016 ;; Do auto-expirable marks if that's required.
3017 (when (gnus-group-auto-expirable-p group)
3018 (gnus-add-marked-articles group 'expire unread)
3019 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3020 (let ((gnus-newsgroup-name group))
3021 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3024 (defun gnus-group-expire-articles (&optional n)
3025 "Expire all expirable articles in the current newsgroup."
3027 (let ((groups (gnus-group-process-prefix n))
3030 (error "No groups to expire"))
3031 (while (setq group (pop groups))
3032 (gnus-group-remove-mark group)
3033 (gnus-group-expire-articles-1 group)
3034 (gnus-dribble-touch)
3035 (gnus-group-position-point))))
3037 (defun gnus-group-expire-articles-1 (group)
3038 (when (gnus-check-backend-function 'request-expire-articles group)
3039 (gnus-message 6 "Expiring articles in %s..." group)
3040 (let* ((info (gnus-get-info group))
3041 (expirable (if (gnus-group-total-expirable-p group)
3042 (cons nil (gnus-list-of-read-articles group))
3043 (assq 'expire (gnus-info-marks info))))
3044 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3045 (nnmail-expiry-target
3046 (or (gnus-group-find-parameter group 'expiry-target)
3047 nnmail-expiry-target)))
3049 (gnus-check-group group)
3052 (gnus-compress-sequence
3054 ;; We set the expiry variables to the group
3056 (let ((nnmail-expiry-wait-function nil)
3057 (nnmail-expiry-wait expiry-wait))
3058 (gnus-request-expire-articles
3059 (gnus-uncompress-sequence (cdr expirable)) group))
3060 ;; Just expire using the normal expiry values.
3061 (gnus-request-expire-articles
3062 (gnus-uncompress-sequence (cdr expirable)) group))))
3063 (gnus-close-group group))
3064 (gnus-message 6 "Expiring articles in %s...done" group)
3065 ;; Return the list of un-expired articles.
3068 (defun gnus-group-expire-all-groups ()
3069 "Expire all expirable articles in all newsgroups."
3072 (gnus-message 5 "Expiring...")
3073 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3074 (cdr gnus-newsrc-alist))))
3075 (gnus-group-expire-articles nil)))
3076 (gnus-group-position-point)
3077 (gnus-message 5 "Expiring...done"))
3079 (defun gnus-group-set-current-level (n level)
3080 "Set the level of the next N groups to LEVEL."
3085 (let ((s (read-string
3086 (format "Level (default %s): "
3087 (or (gnus-group-group-level)
3088 gnus-level-default-subscribed)))))
3089 (if (string-match "^\\s-*$" s)
3090 (int-to-string (or (gnus-group-group-level)
3091 gnus-level-default-subscribed))
3093 (unless (and (>= level 1) (<= level gnus-level-killed))
3094 (error "Invalid level: %d" level))
3095 (let ((groups (gnus-group-process-prefix n))
3097 (while (setq group (pop groups))
3098 (gnus-group-remove-mark group)
3099 (gnus-message 6 "Changed level of %s from %d to %d"
3100 group (or (gnus-group-group-level) gnus-level-killed)
3102 (gnus-group-change-level
3103 group level (or (gnus-group-group-level) gnus-level-killed))
3104 (gnus-group-update-group-line)))
3105 (gnus-group-position-point))
3107 (defun gnus-group-unsubscribe (&optional n)
3108 "Unsubscribe the current group."
3110 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3112 (defun gnus-group-subscribe (&optional n)
3113 "Subscribe the current group."
3115 (gnus-group-unsubscribe-current-group n 'subscribe))
3117 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3118 "Toggle subscription of the current group.
3119 If given numerical prefix, toggle the N next groups."
3121 (let ((groups (gnus-group-process-prefix n))
3124 (setq group (car groups)
3125 groups (cdr groups))
3126 (gnus-group-remove-mark group)
3127 (gnus-group-unsubscribe-group
3130 ((eq do-sub 'unsubscribe)
3131 gnus-level-default-unsubscribed)
3132 ((eq do-sub 'subscribe)
3133 gnus-level-default-subscribed)
3134 ((<= (gnus-group-group-level) gnus-level-subscribed)
3135 gnus-level-default-unsubscribed)
3137 gnus-level-default-subscribed))
3139 (gnus-group-update-group-line))
3140 (gnus-group-next-group 1)))
3142 (defun gnus-group-unsubscribe-group (group &optional level silent)
3143 "Toggle subscription to GROUP.
3144 Killed newsgroups are subscribed. If SILENT, don't try to update the
3147 (list (completing-read
3148 "Group: " gnus-active-hashtb nil
3149 (gnus-read-active-file-p)
3151 'gnus-group-history)))
3152 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3154 ((string-match "^[ \t]*$" group)
3155 (error "Empty group name"))
3157 ;; Toggle subscription flag.
3158 (gnus-group-change-level
3159 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3160 gnus-level-subscribed)
3161 (1+ gnus-level-subscribed)
3162 gnus-level-default-subscribed)))
3164 (gnus-group-update-group group)))
3165 ((and (stringp group)
3166 (or (not (gnus-read-active-file-p))
3167 (gnus-active group)))
3168 ;; Add new newsgroup.
3169 (gnus-group-change-level
3171 (if level level gnus-level-default-subscribed)
3172 (or (and (member group gnus-zombie-list)
3175 (when (gnus-group-group-name)
3176 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3178 (gnus-group-update-group group)))
3179 (t (error "No such newsgroup: %s" group)))
3180 (gnus-group-position-point)))
3182 (defun gnus-group-transpose-groups (n)
3183 "Move the current newsgroup up N places.
3184 If given a negative prefix, move down instead. The difference between
3185 N and the number of steps taken is returned."
3187 (unless (gnus-group-group-name)
3188 (error "No group on current line"))
3189 (gnus-group-kill-group 1)
3191 (forward-line (- n))
3192 (gnus-group-yank-group)
3193 (gnus-group-position-point)))
3195 (defun gnus-group-kill-all-zombies (&optional dummy)
3196 "Kill all zombie newsgroups.
3197 The optional DUMMY should always be nil."
3198 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3200 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3201 (setq gnus-zombie-list nil)
3202 (gnus-dribble-touch)
3203 (gnus-group-list-groups)))
3205 (defun gnus-group-kill-region (begin end)
3206 "Kill newsgroups in current region (excluding current point).
3207 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3222 (beginning-of-line) ;Important when LINES < 1
3223 (gnus-group-kill-group lines)))
3225 (defun gnus-group-kill-group (&optional n discard)
3226 "Kill the next N groups.
3227 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3228 However, only groups that were alive can be yanked; already killed
3229 groups or zombie groups can't be yanked.
3230 The return value is the name of the group that was killed, or a list
3233 (let ((buffer-read-only nil)
3234 (groups (gnus-group-process-prefix n))
3235 group entry level out)
3236 (if (< (length groups) 10)
3237 ;; This is faster when there are few groups.
3239 (push (setq group (pop groups)) out)
3240 (gnus-group-remove-mark group)
3241 (setq level (gnus-group-group-level))
3243 (when (and (not discard)
3244 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3247 (gnus-group-goto-group ,(gnus-group-group-name))
3248 (gnus-group-yank-group)))
3249 (push (cons (car entry) (nth 2 entry))
3250 gnus-list-of-killed-groups))
3251 (gnus-group-change-level
3252 (if entry entry group) gnus-level-killed (if entry nil level))
3253 (message "Killed group %s" group))
3254 ;; If there are lots and lots of groups to be killed, we use
3255 ;; this thing instead.
3257 (setq groups (nreverse groups))
3259 (gnus-group-remove-mark (setq group (pop groups)))
3261 (push group gnus-killed-list)
3262 (setq gnus-newsrc-alist
3263 (delq (assoc group gnus-newsrc-alist)
3265 (when gnus-group-change-level-function
3266 (funcall gnus-group-change-level-function
3267 group gnus-level-killed 3))
3269 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3270 (push (cons (car entry) (nth 2 entry))
3271 gnus-list-of-killed-groups)
3272 (setcdr (cdr entry) (cdddr entry)))
3273 ((member group gnus-zombie-list)
3274 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3275 ;; There may be more than one instance displayed.
3276 (while (gnus-group-goto-group group)
3277 (gnus-delete-line)))
3278 (gnus-make-hashtable-from-newsrc-alist)))
3280 (gnus-group-position-point)
3281 (if (< (length out) 2) (car out) (nreverse out))))
3283 (defun gnus-group-yank-group (&optional arg)
3284 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3285 The numeric ARG specifies how many newsgroups are to be yanked. The
3286 name of the newsgroup yanked is returned, or (if several groups are
3287 yanked) a list of yanked groups is returned."
3289 (setq arg (or arg 1))
3290 (let (info group prev out)
3291 (while (>= (decf arg) 0)
3292 (when (not (setq info (pop gnus-list-of-killed-groups)))
3293 (error "No more newsgroups to yank"))
3294 (push (setq group (nth 1 info)) out)
3295 ;; Find which newsgroup to insert this one before - search
3296 ;; backward until something suitable is found. If there are no
3297 ;; other newsgroups in this buffer, just make this newsgroup the
3299 (setq prev (gnus-group-group-name))
3300 (gnus-group-change-level
3301 info (gnus-info-level (cdr info)) gnus-level-killed
3302 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3304 (gnus-group-insert-group-line-info group)
3306 `(when (gnus-group-goto-group ,group)
3307 (gnus-group-kill-group 1))))
3309 (gnus-group-position-point)
3310 (if (< (length out) 2) (car out) (nreverse out))))
3312 (defun gnus-group-kill-level (level)
3313 "Kill all groups that is on a certain LEVEL."
3314 (interactive "nKill all groups on level: ")
3316 ((= level gnus-level-zombie)
3317 (setq gnus-killed-list
3318 (nconc gnus-zombie-list gnus-killed-list))
3319 (setq gnus-zombie-list nil))
3320 ((and (< level gnus-level-zombie)
3322 (or gnus-expert-user
3325 "Do you really want to kill all groups on level %d? "
3327 (let* ((prev gnus-newsrc-alist)
3330 (if (= (gnus-info-level (car alist)) level)
3332 (push (gnus-info-group (car alist)) gnus-killed-list)
3333 (setcdr prev (cdr alist)))
3335 (setq alist (cdr alist)))
3336 (gnus-make-hashtable-from-newsrc-alist)
3337 (gnus-group-list-groups)))
3339 (error "Can't kill; invalid level: %d" level))))
3341 (defun gnus-group-list-all-groups (&optional arg)
3342 "List all newsgroups with level ARG or lower.
3343 Default is gnus-level-unsubscribed, which lists all subscribed and most
3344 unsubscribed groups."
3346 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3348 ;; Redefine this to list ALL killed groups if prefix arg used.
3349 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3350 (defun gnus-group-list-killed (&optional arg)
3351 "List all killed newsgroups in the group buffer.
3352 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3353 entail asking the server for the groups."
3355 ;; Find all possible killed newsgroups if arg.
3357 (gnus-get-killed-groups))
3358 (if (not gnus-killed-list)
3359 (gnus-message 6 "No killed groups")
3360 (let (gnus-group-list-mode)
3361 (funcall gnus-group-prepare-function
3362 gnus-level-killed t gnus-level-killed))
3363 (goto-char (point-min)))
3364 (gnus-group-position-point))
3366 (defun gnus-group-list-zombies ()
3367 "List all zombie newsgroups in the group buffer."
3369 (if (not gnus-zombie-list)
3370 (gnus-message 6 "No zombie groups")
3371 (let (gnus-group-list-mode)
3372 (funcall gnus-group-prepare-function
3373 gnus-level-zombie t gnus-level-zombie))
3374 (goto-char (point-min)))
3375 (gnus-group-position-point))
3377 (defun gnus-group-list-active ()
3378 "List all groups that are available from the server(s)."
3380 ;; First we make sure that we have really read the active file.
3381 (unless (gnus-read-active-file-p)
3382 (let ((gnus-read-active-file t)
3383 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3384 (gnus-read-active-file)))
3385 ;; Find all groups and sort them.
3393 (push (symbol-name sym) list)))
3397 (buffer-read-only nil)
3401 (setq group (pop groups))
3402 (gnus-add-text-properties
3403 (point) (prog1 (1+ (point))
3405 (gnus-group-decoded-name group)
3407 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3409 'gnus-level (inline (gnus-group-level group)))))
3410 (goto-char (point-min))))
3412 (defun gnus-activate-all-groups (level)
3413 "Activate absolutely all groups."
3414 (interactive (list gnus-level-unsubscribed))
3415 (let ((gnus-activate-level level)
3416 (gnus-activate-foreign-newsgroups level))
3417 (gnus-group-get-new-news)))
3419 (defun gnus-group-get-new-news (&optional arg)
3420 "Get newly arrived articles.
3421 If ARG is a number, it specifies which levels you are interested in
3422 re-scanning. If ARG is non-nil and not a number, this will force
3423 \"hard\" re-reading of the active files from all servers."
3426 (let ((gnus-inhibit-demon t)
3427 ;; Binding this variable will inhibit multiple fetchings
3428 ;; of the same mail source.
3429 (nnmail-fetched-sources (list t)))
3430 (gnus-run-hooks 'gnus-get-new-news-hook)
3432 ;; Read any slave files.
3434 (gnus-master-read-slave-newsrc))
3436 ;; We might read in new NoCeM messages here.
3437 (when (and gnus-use-nocem
3439 (gnus-nocem-scan-groups))
3440 ;; If ARG is not a number, then we read the active file.
3441 (when (and arg (not (numberp arg)))
3442 (let ((gnus-read-active-file t))
3443 (gnus-read-active-file))
3446 ;; If the user wants it, we scan for new groups.
3447 (when (eq gnus-check-new-newsgroups 'always)
3448 (gnus-find-new-newsgroups)))
3450 (setq arg (gnus-group-default-level arg t))
3451 (if (and gnus-read-active-file (not arg))
3453 (gnus-read-active-file)
3454 (gnus-get-unread-articles arg))
3455 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3456 (gnus-get-unread-articles arg)))
3457 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3458 (gnus-group-list-groups (and (numberp arg)
3459 (max (car gnus-group-list-mode) arg)))))
3461 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3462 "Check for newly arrived news in the current group (and the N-1 next groups).
3463 The difference between N and the number of newsgroup checked is returned.
3464 If N is negative, this group and the N-1 previous groups will be checked."
3466 (let* ((groups (gnus-group-process-prefix n))
3467 (ret (if (numberp n) (- n (length groups)) 0))
3471 (gnus-inhibit-demon t)
3472 ;; Binding this variable will inhibit multiple fetchings
3473 ;; of the same mail source.
3474 (nnmail-fetched-sources (list t)))
3475 (gnus-run-hooks 'gnus-get-new-news-hook)
3476 (while (setq group (pop groups))
3477 (gnus-group-remove-mark group)
3478 ;; Bypass any previous denials from the server.
3479 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3480 (if (gnus-activate-group group (if dont-scan nil 'scan))
3482 (gnus-get-unread-articles-in-group
3483 (gnus-get-info group) (gnus-active group) t)
3484 (unless (gnus-virtual-group-p group)
3485 (gnus-close-group group))
3487 (gnus-agent-save-group-info
3488 method (gnus-group-real-name group) (gnus-active group)))
3489 (gnus-group-update-group group))
3490 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3492 (gnus-error 3 "Server denied access")
3493 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3496 (when gnus-goto-next-group-when-activating
3497 (gnus-group-next-unread-group 1 t))
3498 (gnus-summary-position-point)
3501 (defun gnus-group-fetch-faq (group &optional faq-dir)
3502 "Fetch the FAQ for the current group.
3503 If given a prefix argument, prompt for the FAQ dir
3507 (gnus-group-group-name)
3508 (when current-prefix-arg
3510 "FAQ dir: " (and (listp gnus-group-faq-directory)
3512 gnus-group-faq-directory))))))
3514 (error "No group name given"))
3515 (let ((dirs (or faq-dir gnus-group-faq-directory))
3517 (unless (listp dirs)
3518 (setq dirs (list dirs)))
3519 (while (and (not found)
3520 (setq dir (pop dirs)))
3521 (let ((name (gnus-group-real-name group)))
3522 (setq file (expand-file-name name dir)))
3523 (if (not (file-exists-p file))
3524 (gnus-message 1 "No such file: %s" file)
3525 (let ((enable-local-variables nil))
3529 (defun gnus-group-fetch-charter (group)
3530 "Fetch the charter for the current group.
3531 If given a prefix argument, prompt for a group."
3533 (list (or (when current-prefix-arg
3534 (completing-read "Group: " gnus-active-hashtb))
3535 (gnus-group-group-name)
3536 gnus-newsgroup-name)))
3538 (error "No group name given"))
3540 (condition-case nil (require 'url-http) (error nil))
3541 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3543 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3544 (setq hierarchy (match-string 1 name))
3545 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3546 (if (fboundp 'url-http-file-exists-p)
3547 (url-http-file-exists-p (eval url))
3549 (browse-url (eval url))
3550 (setq url (concat "http://" hierarchy
3551 ".news-admin.org/charters/" name))
3552 (if (and (fboundp 'url-http-file-exists-p)
3553 (url-http-file-exists-p url))
3555 (gnus-group-fetch-control group))))))
3557 (defun gnus-group-fetch-control (group)
3558 "Fetch the archived control messages for the current group.
3559 If given a prefix argument, prompt for a group."
3561 (list (or (when current-prefix-arg
3562 (completing-read "Group: " gnus-active-hashtb))
3563 (gnus-group-group-name)
3564 gnus-newsgroup-name)))
3566 (error "No group name given"))
3567 (let ((name (gnus-group-real-name group))
3569 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3570 (setq hierarchy (match-string 1 name))
3571 (if gnus-group-fetch-control-use-browse-url
3572 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3573 hierarchy "/" name ".Z"))
3574 (let ((enable-local-variables nil))
3575 (gnus-group-read-ephemeral-group
3577 `(nndoc ,group (nndoc-address
3578 ,(find-file-noselect
3579 (concat "/ftp@ftp.isc.org:/usenet/control/"
3580 hierarchy "/" name ".Z")))
3581 (nndoc-article-type mbox)) t nil nil))))))
3583 (defun gnus-group-describe-group (force &optional group)
3584 "Display a description of the current newsgroup."
3585 (interactive (list current-prefix-arg (gnus-group-group-name)))
3586 (let* ((method (gnus-find-method-for-group group))
3587 (mname (gnus-group-prefixed-name "" method))
3590 gnus-description-hashtb)
3591 (gnus-sethash mname nil gnus-description-hashtb))
3593 (error "No group name given"))
3594 (when (or (and gnus-description-hashtb
3595 ;; We check whether this group's method has been
3596 ;; queried for a description file.
3597 (gnus-gethash mname gnus-description-hashtb))
3598 (setq desc (gnus-group-get-description group))
3599 (gnus-read-descriptions-file method))
3601 (or desc (gnus-gethash group gnus-description-hashtb)
3602 "No description available")))))
3604 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3605 (defun gnus-group-describe-all-groups (&optional force)
3606 "Pop up a buffer with descriptions of all newsgroups."
3609 (setq gnus-description-hashtb nil))
3610 (when (not (or gnus-description-hashtb
3611 (gnus-read-all-descriptions-files)))
3612 (error "Couldn't request descriptions file"))
3613 (let ((buffer-read-only nil)
3619 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3620 (insert (format " *: %-20s %s\n"
3621 (gnus-group-name-decode
3622 (symbol-name group) charset)
3623 (gnus-group-name-decode
3624 (symbol-value group) charset))))
3625 (gnus-add-text-properties
3626 b (1+ b) (list 'gnus-group group
3627 'gnus-unread t 'gnus-marked nil
3628 'gnus-level (1+ gnus-level-subscribed))))
3629 gnus-description-hashtb)
3630 (goto-char (point-min))
3631 (gnus-group-position-point)))
3633 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3634 (defun gnus-group-apropos (regexp &optional search-description)
3635 "List all newsgroups that have names that match a regexp."
3636 (interactive "sGnus apropos (regexp): ")
3638 (obuf (current-buffer))
3640 ;; Go through all newsgroups that are known to Gnus.
3643 (and (symbol-name group)
3644 (string-match regexp (symbol-name group))
3645 (symbol-value group)
3646 (push (symbol-name group) groups)))
3648 ;; Also go through all descriptions that are known to Gnus.
3649 (when search-description
3652 (and (string-match regexp (symbol-value group))
3653 (push (symbol-name group) groups)))
3654 gnus-description-hashtb))
3656 (gnus-message 3 "No groups matched \"%s\"." regexp)
3657 ;; Print out all the groups.
3659 (pop-to-buffer "*Gnus Help*")
3660 (buffer-disable-undo)
3662 (setq groups (sort groups 'string<))
3664 ;; Groups may be entered twice into the list of groups.
3665 (when (not (string= (car groups) prev))
3666 (setq prev (car groups))
3667 (let ((charset (gnus-group-name-charset nil prev)))
3668 (insert (gnus-group-name-decode prev charset) "\n")
3669 (when (and gnus-description-hashtb
3670 (setq des (gnus-gethash (car groups)
3671 gnus-description-hashtb)))
3672 (insert " " (gnus-group-name-decode des charset) "\n"))))
3673 (setq groups (cdr groups)))
3674 (goto-char (point-min))))
3675 (pop-to-buffer obuf)))
3677 (defun gnus-group-description-apropos (regexp)
3678 "List all newsgroups that have names or descriptions that match a regexp."
3679 (interactive "sGnus description apropos (regexp): ")
3680 (when (not (or gnus-description-hashtb
3681 (gnus-read-all-descriptions-files)))
3682 (error "Couldn't request descriptions file"))
3683 (gnus-group-apropos regexp t))
3685 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3686 (defun gnus-group-list-matching (level regexp &optional all lowest)
3687 "List all groups with unread articles that match REGEXP.
3688 If the prefix LEVEL is non-nil, it should be a number that says which
3689 level to cut off listing groups.
3690 If ALL, also list groups with no unread articles.
3691 If LOWEST, don't list groups with level lower than LOWEST.
3693 This command may read the active file."
3694 (interactive "P\nsList newsgroups matching: ")
3695 ;; First make sure active file has been read.
3697 (> (prefix-numeric-value level) gnus-level-killed))
3698 (gnus-get-killed-groups))
3699 (funcall gnus-group-prepare-function
3700 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3701 (goto-char (point-min))
3702 (gnus-group-position-point))
3704 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3705 "List all groups that match REGEXP.
3706 If the prefix LEVEL is non-nil, it should be a number that says which
3707 level to cut off listing groups.
3708 If LOWEST, don't list groups with level lower than LOWEST."
3709 (interactive "P\nsList newsgroups matching: ")
3711 (setq level (prefix-numeric-value level)))
3712 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3714 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3715 (defun gnus-group-save-newsrc (&optional force)
3716 "Save the Gnus startup files.
3717 If FORCE, force saving whether it is necessary or not."
3719 (gnus-save-newsrc-file force))
3721 (defun gnus-group-restart (&optional arg)
3722 "Force Gnus to read the .newsrc file."
3724 (when (gnus-yes-or-no-p
3725 (format "Are you sure you want to restart Gnus? "))
3726 (gnus-save-newsrc-file)
3730 (defun gnus-group-read-init-file ()
3731 "Read the Gnus elisp init file."
3733 (gnus-read-init-file)
3734 (gnus-message 5 "Read %s" gnus-init-file))
3736 (defun gnus-group-check-bogus-groups (&optional silent)
3737 "Check bogus newsgroups.
3738 If given a prefix, don't ask for confirmation before removing a bogus
3741 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3742 (gnus-group-list-groups))
3744 (defun gnus-group-find-new-groups (&optional arg)
3745 "Search for new groups and add them.
3746 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3747 With 1 C-u, use the `ask-server' method to query the server for new
3749 With 2 C-u's, use most complete method possible to query the server
3750 for new groups, and subscribe the new groups as zombies."
3752 (gnus-find-new-newsgroups (or arg 1))
3753 (gnus-group-list-groups))
3755 (defun gnus-group-edit-global-kill (&optional article group)
3756 "Edit the global kill file.
3757 If GROUP, edit that local kill file instead."
3759 (setq gnus-current-kill-article article)
3760 (gnus-kill-file-edit-file group)
3763 (substitute-command-keys
3764 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3765 (if group "local" "global")))))
3767 (defun gnus-group-edit-local-kill (article group)
3768 "Edit a local kill file."
3769 (interactive (list nil (gnus-group-group-name)))
3770 (gnus-group-edit-global-kill article group))
3772 (defun gnus-group-force-update ()
3773 "Update `.newsrc' file."
3775 (gnus-save-newsrc-file))
3777 (defun gnus-group-suspend ()
3778 "Suspend the current Gnus session.
3779 In fact, cleanup buffers except for group mode buffer.
3780 The hook gnus-suspend-gnus-hook is called before actually suspending."
3782 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3783 (gnus-offer-save-summaries)
3784 ;; Kill Gnus buffers except for group mode buffer.
3785 (let ((group-buf (get-buffer gnus-group-buffer)))
3786 (mapcar (lambda (buf)
3787 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3791 (eq major-mode 'message-mode))))
3792 (gnus-kill-buffer buf)))
3794 (gnus-kill-gnus-frames)
3796 (bury-buffer group-buf)
3797 (delete-windows-on group-buf t))))
3799 (defun gnus-group-clear-dribble ()
3800 "Clear all information from the dribble buffer."
3802 (gnus-dribble-clear)
3803 (gnus-message 7 "Cleared dribble buffer"))
3805 (defun gnus-group-exit ()
3806 "Quit reading news after updating .newsrc.eld and .newsrc.
3807 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3810 (or noninteractive ;For gnus-batch-kill
3811 (not gnus-interactive-exit) ;Without confirmation
3813 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3814 (gnus-run-hooks 'gnus-exit-gnus-hook)
3815 ;; Offer to save data from non-quitted summary buffers.
3816 (gnus-offer-save-summaries)
3817 ;; Save the newsrc file(s).
3818 (gnus-save-newsrc-file)
3820 (gnus-close-backends)
3821 ;; Reset everything.
3823 ;; Allow the user to do things after cleaning up.
3824 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3826 (defun gnus-group-quit ()
3827 "Quit reading news without updating .newsrc.eld or .newsrc.
3828 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3830 (when (or noninteractive ;For gnus-batch-kill
3831 (zerop (buffer-size))
3832 (not (gnus-server-opened gnus-select-method))
3834 (not gnus-current-startup-file)
3836 (format "Quit reading news without saving %s? "
3837 (file-name-nondirectory gnus-current-startup-file))))
3838 (gnus-run-hooks 'gnus-exit-gnus-hook)
3839 (gnus-configure-windows 'group t)
3840 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3841 (not (zerop (save-excursion
3842 (set-buffer gnus-dribble-buffer)
3845 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3847 (gnus-close-backends)
3849 (gnus-kill-buffer gnus-group-buffer)
3850 ;; Allow the user to do things after cleaning up.
3851 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3853 (defun gnus-group-describe-briefly ()
3854 "Give a one line description of the group mode commands."
3856 (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")))
3858 (defun gnus-group-browse-foreign-server (method)
3859 "Browse a foreign news server.
3860 If called interactively, this function will ask for a select method
3861 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3862 If not, METHOD should be a list where the first element is the method
3863 and the second element is the address."
3865 (list (let ((how (completing-read
3867 (append gnus-valid-select-methods gnus-server-alist)
3868 nil t (cons "nntp" 0) 'gnus-method-history)))
3869 ;; We either got a backend name or a virtual server name.
3870 ;; If the first, we also need an address.
3871 (if (assoc how gnus-valid-select-methods)
3873 ;; Suggested by mapjph@bath.ac.uk.
3876 (mapcar (lambda (server) (list server))
3877 gnus-secondary-servers)))
3878 ;; We got a server name.
3880 (gnus-browse-foreign-server method))
3882 (defun gnus-group-set-info (info &optional method-only-group part)
3883 (when (or info part)
3884 (let* ((entry (gnus-gethash
3885 (or method-only-group (gnus-info-group info))
3886 gnus-newsrc-hashtb))
3888 (info (if method-only-group (nth 2 entry) info))
3890 (when method-only-group
3892 (error "Trying to change non-existent group %s" method-only-group))
3893 ;; We have received parts of the actual group info - either the
3894 ;; select method or the group parameters. We first check
3895 ;; whether we have to extend the info, and if so, do that.
3896 (let ((len (length info))
3897 (total (if (eq part 'method) 5 6)))
3899 (setcdr (nthcdr (1- len) info)
3900 (make-list (- total len) nil)))
3901 ;; Then we enter the new info.
3902 (setcar (nthcdr (1- total) info) part-info)))
3904 ;; This is a new group, so we just create it.
3906 (set-buffer gnus-group-buffer)
3907 (setq method (gnus-info-method info))
3908 (when (gnus-server-equal method "native")
3911 (set-buffer gnus-group-buffer)
3913 ;; It's a foreign group...
3914 (gnus-group-make-group
3915 (gnus-group-real-name (gnus-info-group info))
3916 (if (stringp method) method
3917 (prin1-to-string (car method)))
3919 (nth 1 (gnus-info-method info))))
3920 ;; It's a native group.
3921 (gnus-group-make-group (gnus-info-group info))))
3922 (gnus-message 6 "Note: New group created")
3924 (gnus-gethash (gnus-group-prefixed-name
3925 (gnus-group-real-name (gnus-info-group info))
3926 (or (gnus-info-method info) gnus-select-method))
3927 gnus-newsrc-hashtb))))
3928 ;; Whether it was a new group or not, we now have the entry, so we
3929 ;; can do the update.
3932 (setcar (nthcdr 2 entry) info)
3933 (when (and (not (eq (car entry) t))
3934 (gnus-active (gnus-info-group info)))
3935 (setcar entry (length
3936 (gnus-list-of-unread-articles (car info))))))
3937 (error "No such group: %s" (gnus-info-group info))))))
3939 (defun gnus-group-set-method-info (group select-method)
3940 (gnus-group-set-info select-method group 'method))
3942 (defun gnus-group-set-params-info (group params)
3943 (gnus-group-set-info params group 'params))
3945 (defun gnus-add-marked-articles (group type articles &optional info force)
3946 ;; Add ARTICLES of TYPE to the info of GROUP.
3947 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3948 ;; add, but replace marked articles of TYPE with ARTICLES.
3949 (let ((info (or info (gnus-get-info group)))
3952 (and (not (setq marked (nthcdr 3 info)))
3954 (setcdr (nthcdr 2 info)
3955 (list (list (cons type (gnus-compress-sequence
3957 (and (not (setq m (assq type (car marked))))
3960 (cons (cons type (gnus-compress-sequence articles t) )
3964 (setcar (nthcdr 3 info)
3965 (gnus-delete-alist type (car marked)))
3966 (setcdr m (gnus-compress-sequence articles t)))
3967 (setcdr m (gnus-compress-sequence
3968 (sort (nconc (gnus-uncompress-range (cdr m))
3969 (copy-sequence articles)) '<) t))))))
3971 (defun gnus-add-mark (group mark article)
3972 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3973 (let ((buffer (gnus-summary-buffer-name group)))
3974 (if (gnus-buffer-live-p buffer)
3976 (set-buffer (get-buffer buffer))
3977 (gnus-summary-add-mark article mark))
3978 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3982 ;;; Group timestamps
3985 (defun gnus-group-set-timestamp ()
3986 "Change the timestamp of the current group to the current time.
3987 This function can be used in hooks like `gnus-select-group-hook'
3988 or `gnus-group-catchup-group-hook'."
3989 (when gnus-newsgroup-name
3990 (let ((time (current-time)))
3991 (setcdr (cdr time) nil)
3992 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3994 (defsubst gnus-group-timestamp (group)
3995 "Return the timestamp for GROUP."
3996 (gnus-group-get-parameter group 'timestamp t))
3998 (defun gnus-group-timestamp-delta (group)
3999 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4000 (let* ((time (or (gnus-group-timestamp group)
4002 (delta (subtract-time (current-time) time)))
4003 (+ (* (nth 0 delta) 65536.0)
4006 (defun gnus-group-timestamp-string (group)
4007 "Return a string of the timestamp for GROUP."
4008 (let ((time (gnus-group-timestamp group)))
4011 (gnus-time-iso8601 time))))
4013 (defun gnus-group-list-cached (level &optional lowest)
4014 "List all groups with cached articles.
4015 If the prefix LEVEL is non-nil, it should be a number that says which
4016 level to cut off listing groups.
4017 If LOWEST, don't list groups with level lower than LOWEST.
4019 This command may read the active file."
4022 (setq level (prefix-numeric-value level)))
4023 (when (or (not level) (>= level gnus-level-zombie))
4025 (funcall gnus-group-prepare-function
4026 (or level gnus-level-subscribed)
4028 (let ((marks (gnus-info-marks info)))
4029 (assq 'cache marks)))
4032 (or (gnus-gethash group
4033 gnus-cache-active-hashtb)
4034 ;; Cache active file might use "."
4037 (mapconcat 'identity
4038 (split-string group ":")
4040 gnus-cache-active-hashtb))))
4041 (goto-char (point-min))
4042 (gnus-group-position-point))
4044 (defun gnus-group-list-dormant (level &optional lowest)
4045 "List all groups with dormant articles.
4046 If the prefix LEVEL is non-nil, it should be a number that says which
4047 level to cut off listing groups.
4048 If LOWEST, don't list groups with level lower than LOWEST.
4050 This command may read the active file."
4053 (setq level (prefix-numeric-value level)))
4054 (when (or (not level) (>= level gnus-level-zombie))
4056 (funcall gnus-group-prepare-function
4057 (or level gnus-level-subscribed)
4059 (let ((marks (gnus-info-marks info)))
4060 (assq 'dormant marks)))
4063 (goto-char (point-min))
4064 (gnus-group-position-point))
4066 (defun gnus-group-listed-groups ()
4067 "Return a list of listed groups."
4069 (goto-char (point-min))
4070 (while (setq point (text-property-not-all (point) (point-max)
4073 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4077 (defun gnus-group-list-plus (&optional args)
4078 "List groups plus the current selection."
4080 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4081 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4083 (push last-command-event unread-command-events)
4084 (if (featurep 'xemacs)
4085 (push (make-event 'key-press '(key ?A)) unread-command-events)
4086 (push ?A unread-command-events))
4087 (let (gnus-pick-mode keys)
4088 (setq keys (if (featurep 'xemacs)
4089 (events-to-keys (read-key-sequence nil))
4090 (read-key-sequence nil)))
4091 (setq func (lookup-key (current-local-map) keys)))
4095 (call-interactively func))))
4097 (defun gnus-group-list-flush (&optional args)
4098 "Flush groups from the current selection."
4100 (let ((gnus-group-list-option 'flush))
4101 (gnus-group-list-plus args)))
4103 (defun gnus-group-list-limit (&optional args)
4104 "List groups limited within the current selection."
4106 (let ((gnus-group-list-option 'limit))
4107 (gnus-group-list-plus args)))
4109 (defun gnus-group-mark-article-read (group article)
4110 "Mark ARTICLE read."
4111 (let ((buffer (gnus-summary-buffer-name group))
4112 (mark gnus-read-mark)
4114 (if (get-buffer buffer)
4115 (with-current-buffer buffer
4116 (setq active gnus-newsgroup-active)
4117 (gnus-activate-group group)
4118 (when gnus-newsgroup-prepared
4119 (when (and gnus-newsgroup-auto-expire
4120 (memq mark gnus-auto-expirable-marks))
4121 (setq mark gnus-expirable-mark))
4122 (setq mark (gnus-request-update-mark
4123 group article mark))
4124 (gnus-mark-article-as-read article mark)
4125 (setq gnus-newsgroup-active (gnus-active group))
4127 (setq n (1+ (cdr active)))
4128 (while (<= n (cdr gnus-newsgroup-active))
4129 (unless (eq n article)
4130 (push n gnus-newsgroup-unselected))
4132 (setq gnus-newsgroup-unselected
4133 (nreverse gnus-newsgroup-unselected)))))
4134 (gnus-activate-group group)
4135 (gnus-group-make-articles-read group (list article))
4136 (when (gnus-group-auto-expirable-p group)
4137 (gnus-add-marked-articles
4138 group 'expire (list article))))))
4140 (provide 'gnus-group)
4142 ;;; gnus-group.el ends here