1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
44 (eval-when-compile (require 'mm-url))
46 (defcustom gnus-group-archive-directory
47 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
48 "*The address of the (ding) archives."
49 :group 'gnus-group-foreign
52 (defcustom gnus-group-recent-archive-directory
53 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
54 "*The address of the most recent (ding) articles."
55 :group 'gnus-group-foreign
58 (defcustom gnus-no-groups-message "No Gnus is good news"
59 "*Message displayed by Gnus when no groups are available."
63 (defcustom gnus-keep-same-level nil
64 "*Non-nil means that the next newsgroup after the current will be on the same level.
65 When you type, for instance, `n' after reading the last article in the
66 current newsgroup, you will go to the next newsgroup. If this variable
67 is nil, the next newsgroup will be the next from the group
69 If this variable is non-nil, Gnus will either put you in the
70 next newsgroup with the same level, or, if no such newsgroup is
71 available, the next newsgroup with the lowest possible level higher
72 than the current level.
73 If this variable is `best', Gnus will make the next newsgroup the one
75 :group 'gnus-group-levels
76 :type '(choice (const nil)
78 (sexp :tag "other" t)))
80 (defcustom gnus-group-goto-unread t
81 "*If non-nil, movement commands will go to the next unread and subscribed group."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-group-various
86 (defcustom gnus-goto-next-group-when-activating t
87 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
88 :link '(custom-manual "(gnus)Scanning New Messages")
89 :group 'gnus-group-various
92 (defcustom gnus-permanently-visible-groups nil
93 "*Regexp to match groups that should always be listed in the group buffer.
94 This means that they will still be listed even when there are no
95 unread articles in the groups.
97 If nil, no groups are permanently visible."
98 :group 'gnus-group-listing
99 :type '(choice regexp (const nil)))
101 (defcustom gnus-list-groups-with-ticked-articles t
102 "*If non-nil, list groups that have only ticked articles.
103 If nil, only list groups that have unread articles."
104 :group 'gnus-group-listing
107 (defcustom gnus-group-default-list-level gnus-level-subscribed
108 "*Default listing level.
109 Ignored if `gnus-group-use-permanent-levels' is non-nil."
110 :group 'gnus-group-listing
113 (defcustom gnus-group-list-inactive-groups t
114 "*If non-nil, inactive groups will be listed."
115 :group 'gnus-group-listing
116 :group 'gnus-group-levels
119 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
120 "*Function used for sorting the group buffer.
121 This function will be called with group info entries as the arguments
122 for the groups to be sorted. Pre-made functions include
123 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
124 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
125 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
126 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
128 This variable can also be a list of sorting functions. In that case,
129 the most significant sort function should be the last function in the
131 :group 'gnus-group-listing
132 :link '(custom-manual "(gnus)Sorting Groups")
133 :type '(repeat :value-to-internal (lambda (widget value)
134 (if (listp value) value (list value)))
135 :match (lambda (widget value)
137 (widget-editable-list-match widget value)))
138 (choice (function-item gnus-group-sort-by-alphabet)
139 (function-item gnus-group-sort-by-real-name)
140 (function-item gnus-group-sort-by-unread)
141 (function-item gnus-group-sort-by-level)
142 (function-item gnus-group-sort-by-score)
143 (function-item gnus-group-sort-by-method)
144 (function-item gnus-group-sort-by-server)
145 (function-item gnus-group-sort-by-rank)
146 (function :tag "other" nil))))
148 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
149 "*Format of group lines.
150 It works along the same lines as a normal formatting string,
151 with some simple extensions.
153 %M Only marked articles (character, \"*\" or \" \")
154 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
155 %L Level of subscribedness (integer)
156 %N Number of unread articles (integer)
157 %I Number of dormant articles (integer)
158 %i Number of ticked and dormant (integer)
159 %T Number of ticked articles (integer)
160 %R Number of read articles (integer)
161 %U Number of unseen articles (integer)
162 %t Estimated total number of articles (integer)
163 %y Number of unread, unticked articles (integer)
164 %G Group name (string)
165 %g Qualified group name (string)
166 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
167 %C Group comment (string)
168 %D Group description (string)
169 %s Select method (string)
170 %o Moderated group (char, \"m\")
171 %p Process mark (char)
172 %B Whether a summary buffer for the group is open (char, \"*\")
173 %O Moderated group (string, \"(m)\" or \"\")
174 %P Topic indentation (string)
175 %m Whether there is new(ish) mail in the group (char, \"%\")
176 %w Number of new(ish) mails in the group (integer)
177 %n Select from where (string)
178 %z A string that look like `<%s:%n>' if a foreign select method is used
179 %d The date the group was last entered.
180 %E Icon as defined by `gnus-group-icon-list'.
181 %u User defined specifier. The next character in the format string should
182 be a letter. Gnus will call the function gnus-user-format-function-X,
183 where X is the letter following %u. The function will be passed a
184 single dummy parameter as argument. The function should return a
185 string, which will be inserted into the buffer just like information
186 from any other group specifier.
188 Note that this format specification is not always respected. For
189 reasons of efficiency, when listing killed groups, this specification
190 is ignored altogether. If the spec is changed considerably, your
191 output may end up looking strange when listing both alive and killed
194 If you use %o or %O, reading the active file will be slower and quite
195 a bit of extra memory will be used. %D will also worsen performance.
196 Also note that if you change the format specification to include any
197 of these specs, you must probably re-start Gnus to see them go into
200 General format specifiers can also be used.
201 See Info node `(gnus)Formatting Variables'."
202 :link '(custom-manual "(gnus)Formatting Variables")
203 :group 'gnus-group-visual
206 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
207 "*The format specification for the group mode line.
208 It works along the same lines as a normal formatting string,
209 with some simple extensions:
211 %S The native news server.
212 %M The native select method.
213 %: \":\" if %S isn't \"\"."
214 :group 'gnus-group-visual
217 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
218 (when (featurep 'xemacs)
219 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
220 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
222 (defcustom gnus-group-menu-hook nil
223 "Hook run after the creation of the group mode menu."
224 :group 'gnus-group-various
227 (defcustom gnus-group-catchup-group-hook nil
228 "Hook run when catching up a group from the group buffer."
229 :group 'gnus-group-various
230 :link '(custom-manual "(gnus)Group Data")
233 (defcustom gnus-group-update-group-hook nil
234 "Hook called when updating group lines."
235 :group 'gnus-group-visual
238 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
239 "*A function that is called to generate the group buffer.
240 The function is called with three arguments: The first is a number;
241 all group with a level less or equal to that number should be listed,
242 if the second is non-nil, empty groups should also be displayed. If
243 the third is non-nil, it is a number. No groups with a level lower
244 than this number should be displayed.
246 The only current function implemented is `gnus-group-prepare-flat'."
247 :group 'gnus-group-listing
250 (defcustom gnus-group-prepare-hook nil
251 "Hook called after the group buffer has been generated.
252 If you want to modify the group buffer, you can use this hook."
253 :group 'gnus-group-listing
256 (defcustom gnus-suspend-gnus-hook nil
257 "Hook called when suspending (not exiting) Gnus."
261 (defcustom gnus-exit-gnus-hook nil
262 "Hook called when exiting Gnus."
266 (defcustom gnus-after-exiting-gnus-hook nil
267 "Hook called after exiting Gnus."
271 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
272 "Hook called when a group line is changed.
273 The hook will not be called if `gnus-visual' is nil.
275 The default function `gnus-group-highlight-line' will
276 highlight the line according to the `gnus-group-highlight'
278 :group 'gnus-group-visual
281 (defcustom gnus-useful-groups
282 '(("(ding) mailing list mirrored at sunsite.auc.dk"
284 (nntp "sunsite.auc.dk"
285 (nntp-address "sunsite.auc.dk")))
288 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
292 (nndoc-article-type mbox)
293 (eval `(nndoc-address
294 ,(let ((file (nnheader-find-etc-directory
297 (error "Couldn't find doc group"))
299 "*Alist of useful group-server pairs."
300 :group 'gnus-group-listing
301 :type '(repeat (list (string :tag "Description")
303 (sexp :tag "Method"))))
305 (defcustom gnus-group-highlight
307 ((and mailp (= unread 0) (eq level 1)) .
308 gnus-group-mail-1-empty-face)
309 ((and mailp (eq level 1)) .
310 gnus-group-mail-1-face)
311 ((and mailp (= unread 0) (eq level 2)) .
312 gnus-group-mail-2-empty-face)
313 ((and mailp (eq level 2)) .
314 gnus-group-mail-2-face)
315 ((and mailp (= unread 0) (eq level 3)) .
316 gnus-group-mail-3-empty-face)
317 ((and mailp (eq level 3)) .
318 gnus-group-mail-3-face)
319 ((and mailp (= unread 0)) .
320 gnus-group-mail-low-empty-face)
322 gnus-group-mail-low-face)
324 ((and (= unread 0) (eq level 1)) .
325 gnus-group-news-1-empty-face)
326 ((and (eq level 1)) .
327 gnus-group-news-1-face)
328 ((and (= unread 0) (eq level 2)) .
329 gnus-group-news-2-empty-face)
330 ((and (eq level 2)) .
331 gnus-group-news-2-face)
332 ((and (= unread 0) (eq level 3)) .
333 gnus-group-news-3-empty-face)
334 ((and (eq level 3)) .
335 gnus-group-news-3-face)
336 ((and (= unread 0) (eq level 4)) .
337 gnus-group-news-4-empty-face)
338 ((and (eq level 4)) .
339 gnus-group-news-4-face)
340 ((and (= unread 0) (eq level 5)) .
341 gnus-group-news-5-empty-face)
342 ((and (eq level 5)) .
343 gnus-group-news-5-face)
344 ((and (= unread 0) (eq level 6)) .
345 gnus-group-news-6-empty-face)
346 ((and (eq level 6)) .
347 gnus-group-news-6-face)
348 ((and (= unread 0)) .
349 gnus-group-news-low-empty-face)
351 gnus-group-news-low-face))
352 "*Controls the highlighting of group buffer lines.
354 Below is a list of `Form'/`Face' pairs. When deciding how a a
355 particular group line should be displayed, each form is
356 evaluated. The content of the face field after the first true form is
357 used. You can change how those group lines are displayed by
358 editing the face field.
360 It is also possible to change and add form fields, but currently that
361 requires an understanding of Lisp expressions. Hopefully this will
362 change in a future release. For now, you can use the following
363 variables in the Lisp expression:
365 group: The name of the group.
366 unread: The number of unread articles in the group.
367 method: The select method used.
368 mailp: Whether it's a mail group or not.
369 level: The level of the group.
370 score: The score of the group.
371 ticked: The number of ticked articles."
372 :group 'gnus-group-visual
373 :type '(repeat (cons (sexp :tag "Form") face)))
375 (defcustom gnus-new-mail-mark ?%
376 "Mark used for groups with new mail."
377 :group 'gnus-group-visual
380 (defgroup gnus-group-icons nil
381 "Add Icons to your group buffer. "
382 :group 'gnus-group-visual)
384 (defcustom gnus-group-icon-list
386 "*Controls the insertion of icons into group buffer lines.
388 Below is a list of `Form'/`File' pairs. When deciding how a
389 particular group line should be displayed, each form is evaluated.
390 The icon from the file field after the first true form is used. You
391 can change how those group lines are displayed by editing the file
392 field. The File will either be found in the
393 `gnus-group-glyph-directory' or by designating absolute name of the
396 It is also possible to change and add form fields, but currently that
397 requires an understanding of Lisp expressions. Hopefully this will
398 change in a future release. For now, you can use the following
399 variables in the Lisp expression:
401 group: The name of the group.
402 unread: The number of unread articles in the group.
403 method: The select method used.
404 mailp: Whether it's a mail group or not.
405 newsp: Whether it's a news group or not
406 level: The level of the group.
407 score: The score of the group.
408 ticked: The number of ticked articles."
409 :group 'gnus-group-icons
410 :type '(repeat (cons (sexp :tag "Form") file)))
412 (defcustom gnus-group-name-charset-method-alist nil
413 "Alist of method and the charset for group names.
416 (((nntp \"news.com.cn\") . cn-gb-2312))"
419 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
421 (defcustom gnus-group-name-charset-group-alist
422 (if (mm-coding-system-p 'utf-8)
423 '(("[^\000-\177]" . utf-8))
425 "Alist of group regexp and the charset for group names.
428 ((\"\\.com\\.cn:\" . cn-gb-2312))"
430 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
432 (defcustom gnus-group-jump-to-group-prompt nil
433 "Default prompt for `gnus-group-jump-to-group'.
434 If non-nil, the value should be a string, e.g. \"nnml:\",
435 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
436 in the minibuffer prompt."
437 :group 'gnus-group-various
438 :type '(choice (string :tag "Prompt string")
439 (const :tag "Empty" nil)))
441 (defvar gnus-group-listing-limit 1000
442 "*A limit of the number of groups when listing.
443 If the number of groups is larger than the limit, list them in a
446 ;;; Internal variables
448 (defvar gnus-group-is-exiting-p nil)
449 (defvar gnus-group-is-exiting-without-update-p nil)
450 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
451 "Function for sorting the group buffer.")
453 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
454 "Function for sorting the selected groups in the group buffer.")
456 (defvar gnus-group-indentation-function nil)
457 (defvar gnus-goto-missing-group-function nil)
458 (defvar gnus-group-update-group-function nil)
459 (defvar gnus-group-goto-next-group-function nil
460 "Function to override finding the next group after listing groups.")
462 (defvar gnus-group-edit-buffer nil)
464 (defvar gnus-group-line-format-alist
465 `((?M gnus-tmp-marked-mark ?c)
466 (?S gnus-tmp-subscribed ?c)
467 (?L gnus-tmp-level ?d)
468 (?N (cond ((eq number t) "*" )
472 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
473 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
475 (?R gnus-tmp-number-of-read ?s)
476 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
477 (?t gnus-tmp-number-total ?d)
478 (?y gnus-tmp-number-of-unread ?s)
479 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
480 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
481 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
482 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
483 (?g gnus-tmp-group ?s)
484 (?G gnus-tmp-qualified-group ?s)
485 (?c (gnus-short-group-name gnus-tmp-group) ?s)
486 (?C gnus-tmp-comment ?s)
487 (?D gnus-tmp-newsgroup-description ?s)
488 (?o gnus-tmp-moderated ?c)
489 (?O gnus-tmp-moderated-string ?s)
490 (?p gnus-tmp-process-marked ?c)
491 (?s gnus-tmp-news-server ?s)
492 (?n gnus-tmp-news-method ?s)
493 (?P gnus-group-indentation ?s)
494 (?E gnus-tmp-group-icon ?s)
495 (?B gnus-tmp-summary-live ?c)
496 (?z gnus-tmp-news-method-string ?s)
497 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
498 (?w (if (gnus-news-group-p gnus-tmp-group)
502 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
505 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
506 (?u gnus-tmp-user-defined ?s)))
508 (defvar gnus-group-mode-line-format-alist
509 `((?S gnus-tmp-news-server ?s)
510 (?M gnus-tmp-news-method ?s)
511 (?u gnus-tmp-user-defined ?s)
512 (?: gnus-tmp-colon ?s)))
514 (defvar gnus-topic-topology nil
515 "The complete topic hierarchy.")
517 (defvar gnus-topic-alist nil
518 "The complete topic-group alist.")
520 (defvar gnus-group-marked nil)
522 (defvar gnus-group-list-mode nil)
525 (defvar gnus-group-icon-cache nil)
527 (defvar gnus-group-listed-groups nil)
528 (defvar gnus-group-list-option nil)
534 (put 'gnus-group-mode 'mode-class 'special)
536 (gnus-define-keys gnus-group-mode-map
537 " " gnus-group-read-group
538 "=" gnus-group-select-group
539 "\r" gnus-group-select-group
540 "\M-\r" gnus-group-quick-select-group
541 "\M- " gnus-group-visible-select-group
542 [(meta control return)] gnus-group-select-group-ephemerally
543 "j" gnus-group-jump-to-group
544 "n" gnus-group-next-unread-group
545 "p" gnus-group-prev-unread-group
546 "\177" gnus-group-prev-unread-group
547 [delete] gnus-group-prev-unread-group
548 [backspace] gnus-group-prev-unread-group
549 "N" gnus-group-next-group
550 "P" gnus-group-prev-group
551 "\M-n" gnus-group-next-unread-group-same-level
552 "\M-p" gnus-group-prev-unread-group-same-level
553 "," gnus-group-best-unread-group
554 "." gnus-group-first-unread-group
555 "u" gnus-group-unsubscribe-current-group
556 "U" gnus-group-unsubscribe-group
557 "c" gnus-group-catchup-current
558 "C" gnus-group-catchup-current-all
559 "\M-c" gnus-group-clear-data
560 "l" gnus-group-list-groups
561 "L" gnus-group-list-all-groups
564 "g" gnus-group-get-new-news
565 "\M-g" gnus-group-get-new-news-this-group
566 "R" gnus-group-restart
567 "r" gnus-group-read-init-file
568 "B" gnus-group-browse-foreign-server
569 "b" gnus-group-check-bogus-groups
570 "F" gnus-group-find-new-groups
571 "\C-c\C-d" gnus-group-describe-group
572 "\M-d" gnus-group-describe-all-groups
573 "\C-c\C-a" gnus-group-apropos
574 "\C-c\M-\C-a" gnus-group-description-apropos
575 "a" gnus-group-post-news
576 "\ek" gnus-group-edit-local-kill
577 "\eK" gnus-group-edit-global-kill
578 "\C-k" gnus-group-kill-group
579 "\C-y" gnus-group-yank-group
580 "\C-w" gnus-group-kill-region
581 "\C-x\C-t" gnus-group-transpose-groups
582 "\C-c\C-l" gnus-group-list-killed
583 "\C-c\C-x" gnus-group-expire-articles
584 "\C-c\M-\C-x" gnus-group-expire-all-groups
586 "s" gnus-group-save-newsrc
587 "z" gnus-group-suspend
590 "?" gnus-group-describe-briefly
591 "\C-c\C-i" gnus-info-find-node
592 "\M-e" gnus-group-edit-group-method
593 "^" gnus-group-enter-server-mode
594 gnus-mouse-2 gnus-mouse-pick-group
595 "<" beginning-of-buffer
598 "\C-c\C-n" gnus-namazu-search
599 "\C-c\C-s" gnus-group-sort-groups
601 "\C-c\M-g" gnus-activate-all-groups
602 "\M-&" gnus-group-universal-argument
603 "#" gnus-group-mark-group
604 "\M-#" gnus-group-unmark-group)
606 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
607 "m" gnus-group-mark-group
608 "u" gnus-group-unmark-group
609 "w" gnus-group-mark-region
610 "b" gnus-group-mark-buffer
611 "r" gnus-group-mark-regexp
612 "U" gnus-group-unmark-all-groups)
614 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
615 "u" gnus-sieve-update
616 "g" gnus-sieve-generate)
618 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
619 "d" gnus-group-make-directory-group
620 "h" gnus-group-make-help-group
621 "u" gnus-group-make-useful-group
622 "a" gnus-group-make-archive-group
623 "k" gnus-group-make-kiboze-group
624 "l" gnus-group-nnimap-edit-acl
625 "m" gnus-group-make-group
626 "n" gnus-group-make-shimbun-group
627 "E" gnus-group-edit-group
628 "e" gnus-group-edit-group-method
629 "p" gnus-group-edit-group-parameters
630 "v" gnus-group-add-to-virtual
631 "V" gnus-group-make-empty-virtual
632 "D" gnus-group-enter-directory
633 "f" gnus-group-make-doc-group
634 "G" gnus-group-make-nnir-group
635 "w" gnus-group-make-web-group
636 "M" gnus-group-read-ephemeral-group
637 "r" gnus-group-rename-group
638 "R" gnus-group-make-rss-group
639 "c" gnus-group-customize
640 "x" gnus-group-nnimap-expunge
641 "\177" gnus-group-delete-group
642 [delete] gnus-group-delete-group)
644 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
645 "b" gnus-group-brew-soup
646 "w" gnus-soup-save-areas
647 "s" gnus-soup-send-replies
648 "p" gnus-soup-pack-packet
649 "r" nnsoup-pack-replies)
651 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
652 "s" gnus-group-sort-groups
653 "a" gnus-group-sort-groups-by-alphabet
654 "u" gnus-group-sort-groups-by-unread
655 "l" gnus-group-sort-groups-by-level
656 "v" gnus-group-sort-groups-by-score
657 "r" gnus-group-sort-groups-by-rank
658 "m" gnus-group-sort-groups-by-method
659 "n" gnus-group-sort-groups-by-real-name)
661 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
662 "s" gnus-group-sort-selected-groups
663 "a" gnus-group-sort-selected-groups-by-alphabet
664 "u" gnus-group-sort-selected-groups-by-unread
665 "l" gnus-group-sort-selected-groups-by-level
666 "v" gnus-group-sort-selected-groups-by-score
667 "r" gnus-group-sort-selected-groups-by-rank
668 "m" gnus-group-sort-selected-groups-by-method
669 "n" gnus-group-sort-selected-groups-by-real-name)
671 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
672 "k" gnus-group-list-killed
673 "z" gnus-group-list-zombies
674 "s" gnus-group-list-groups
675 "u" gnus-group-list-all-groups
676 "A" gnus-group-list-active
677 "a" gnus-group-apropos
678 "d" gnus-group-description-apropos
679 "m" gnus-group-list-matching
680 "M" gnus-group-list-all-matching
681 "l" gnus-group-list-level
682 "c" gnus-group-list-cached
683 "?" gnus-group-list-dormant)
685 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
686 "k" gnus-group-list-limit
687 "z" gnus-group-list-limit
688 "s" gnus-group-list-limit
689 "u" gnus-group-list-limit
690 "A" gnus-group-list-limit
691 "m" gnus-group-list-limit
692 "M" gnus-group-list-limit
693 "l" gnus-group-list-limit
694 "c" gnus-group-list-limit
695 "?" gnus-group-list-limit)
697 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
698 "k" gnus-group-list-flush
699 "z" gnus-group-list-flush
700 "s" gnus-group-list-flush
701 "u" gnus-group-list-flush
702 "A" gnus-group-list-flush
703 "m" gnus-group-list-flush
704 "M" gnus-group-list-flush
705 "l" gnus-group-list-flush
706 "c" gnus-group-list-flush
707 "?" gnus-group-list-flush)
709 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
710 "k" gnus-group-list-plus
711 "z" gnus-group-list-plus
712 "s" gnus-group-list-plus
713 "u" gnus-group-list-plus
714 "A" gnus-group-list-plus
715 "m" gnus-group-list-plus
716 "M" gnus-group-list-plus
717 "l" gnus-group-list-plus
718 "c" gnus-group-list-plus
719 "?" gnus-group-list-plus)
721 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
722 "f" gnus-score-flush-cache
723 "e" gnus-score-edit-all-score)
725 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
726 "c" gnus-group-fetch-charter
727 "C" gnus-group-fetch-control
728 "d" gnus-group-describe-group
729 "f" gnus-group-fetch-faq
732 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
733 "l" gnus-group-set-current-level
734 "t" gnus-group-unsubscribe-current-group
735 "s" gnus-group-unsubscribe-group
736 "k" gnus-group-kill-group
737 "y" gnus-group-yank-group
738 "w" gnus-group-kill-region
739 "\C-k" gnus-group-kill-level
740 "z" gnus-group-kill-all-zombies)
742 (defun gnus-topic-mode-p ()
743 "Return non-nil in `gnus-topic-mode'."
744 (and (boundp 'gnus-topic-mode)
745 (symbol-value 'gnus-topic-mode)))
747 (defun gnus-group-make-menu-bar ()
748 (gnus-turn-off-edit-menu 'group)
749 (unless (boundp 'gnus-group-reading-menu)
752 gnus-group-reading-menu gnus-group-mode-map ""
754 ["Read" gnus-group-read-group
755 :included (not (gnus-topic-mode-p))
756 :active (gnus-group-group-name)]
757 ["Read " gnus-topic-read-group
758 :included (gnus-topic-mode-p)]
759 ["Select" gnus-group-select-group
760 :included (not (gnus-topic-mode-p))
761 :active (gnus-group-group-name)]
762 ["Select " gnus-topic-select-group
763 :included (gnus-topic-mode-p)]
764 ["See old articles" (gnus-group-select-group 'all)
765 :keys "C-u SPC" :active (gnus-group-group-name)]
766 ["Catch up" gnus-group-catchup-current
767 :included (not (gnus-topic-mode-p))
768 :active (gnus-group-group-name)
769 ,@(if (featurep 'xemacs) nil
770 '(:help "Mark unread articles in the current group as read"))]
771 ["Catch up " gnus-topic-catchup-articles
772 :included (gnus-topic-mode-p)
773 ,@(if (featurep 'xemacs) nil
774 '(:help "Mark unread articles in the current group or topic as read"))]
775 ["Catch up all articles" gnus-group-catchup-current-all
776 (gnus-group-group-name)]
777 ["Check for new articles" gnus-group-get-new-news-this-group
778 :included (not (gnus-topic-mode-p))
779 :active (gnus-group-group-name)
780 ,@(if (featurep 'xemacs) nil
781 '(:help "Check for new messages in current group"))]
782 ["Check for new articles " gnus-topic-get-new-news-this-topic
783 :included (gnus-topic-mode-p)
784 ,@(if (featurep 'xemacs) nil
785 '(:help "Check for new messages in current group or topic"))]
786 ["Toggle subscription" gnus-group-unsubscribe-current-group
787 (gnus-group-group-name)]
788 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
789 ,@(if (featurep 'xemacs) nil
790 '(:help "Kill (remove) current group"))]
791 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
792 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
793 ,@(if (featurep 'xemacs) nil
794 '(:help "Display description of the current group"))]
795 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
796 ["Fetch charter" gnus-group-fetch-charter
797 :active (gnus-group-group-name)
798 ,@(if (featurep 'xemacs) nil
799 '(:help "Display the charter of the current group"))]
800 ["Fetch control message" gnus-group-fetch-control
801 :active (gnus-group-group-name)
802 ,@(if (featurep 'xemacs) nil
803 '(:help "Display the archived control message for the current group"))]
804 ;; Actually one should check, if any of the marked groups gives t for
805 ;; (gnus-check-backend-function 'request-expire-articles ...)
806 ["Expire articles" gnus-group-expire-articles
807 :included (not (gnus-topic-mode-p))
808 :active (or (and (gnus-group-group-name)
809 (gnus-check-backend-function
810 'request-expire-articles
811 (gnus-group-group-name))) gnus-group-marked)]
812 ["Expire articles " gnus-topic-expire-articles
813 :included (gnus-topic-mode-p)]
814 ["Set group level..." gnus-group-set-current-level
815 (gnus-group-group-name)]
816 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
817 ["Customize" gnus-group-customize (gnus-group-group-name)]
819 ["Parameters" gnus-group-edit-group-parameters
820 :included (not (gnus-topic-mode-p))
821 :active (gnus-group-group-name)]
822 ["Parameters " gnus-topic-edit-parameters
823 :included (gnus-topic-mode-p)]
824 ["Select method" gnus-group-edit-group-method
825 (gnus-group-group-name)]
826 ["Info" gnus-group-edit-group (gnus-group-group-name)]
827 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
828 ["Global kill file" gnus-group-edit-global-kill t])))
831 gnus-group-group-menu gnus-group-mode-map ""
834 ["List unread subscribed groups" gnus-group-list-groups t]
835 ["List (un)subscribed groups" gnus-group-list-all-groups t]
836 ["List killed groups" gnus-group-list-killed gnus-killed-list]
837 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
838 ["List level..." gnus-group-list-level t]
839 ["Describe all groups" gnus-group-describe-all-groups t]
840 ["Group apropos..." gnus-group-apropos t]
841 ["Group and description apropos..." gnus-group-description-apropos t]
842 ["List groups matching..." gnus-group-list-matching t]
843 ["List all groups matching..." gnus-group-list-all-matching t]
844 ["List active file" gnus-group-list-active t]
845 ["List groups with cached" gnus-group-list-cached t]
846 ["List groups with dormant" gnus-group-list-dormant t])
848 ["Default sort" gnus-group-sort-groups t]
849 ["Sort by method" gnus-group-sort-groups-by-method t]
850 ["Sort by rank" gnus-group-sort-groups-by-rank t]
851 ["Sort by score" gnus-group-sort-groups-by-score t]
852 ["Sort by level" gnus-group-sort-groups-by-level t]
853 ["Sort by unread" gnus-group-sort-groups-by-unread t]
854 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
855 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
856 ("Sort process/prefixed"
857 ["Default sort" gnus-group-sort-selected-groups
858 (not (gnus-topic-mode-p))]
859 ["Sort by method" gnus-group-sort-selected-groups-by-method
860 (not (gnus-topic-mode-p))]
861 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
862 (not (gnus-topic-mode-p))]
863 ["Sort by score" gnus-group-sort-selected-groups-by-score
864 (not (gnus-topic-mode-p))]
865 ["Sort by level" gnus-group-sort-selected-groups-by-level
866 (not (gnus-topic-mode-p))]
867 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
868 (not (gnus-topic-mode-p))]
869 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
870 (not (gnus-topic-mode-p))]
871 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
872 (not (gnus-topic-mode-p))])
874 ["Mark group" gnus-group-mark-group
875 (and (gnus-group-group-name)
876 (not (memq (gnus-group-group-name) gnus-group-marked)))]
877 ["Unmark group" gnus-group-unmark-group
878 (and (gnus-group-group-name)
879 (memq (gnus-group-group-name) gnus-group-marked))]
880 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
881 ["Mark regexp..." gnus-group-mark-regexp t]
882 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
883 ["Mark buffer" gnus-group-mark-buffer t]
884 ["Execute command" gnus-group-universal-argument
885 (or gnus-group-marked (gnus-group-group-name))])
887 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
888 ["Kill all newsgroups in region" gnus-group-kill-region
889 :active (gnus-mark-active-p)]
890 ["Kill all zombie groups" gnus-group-kill-all-zombies
892 ["Kill all groups on level..." gnus-group-kill-level t])
894 ["Make a foreign group..." gnus-group-make-group t]
895 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
896 ["Add a directory group..." gnus-group-make-directory-group t]
897 ["Add the help group" gnus-group-make-help-group t]
898 ["Add the archive group" gnus-group-make-archive-group t]
899 ["Make a doc group..." gnus-group-make-doc-group t]
900 ["Make a web group..." gnus-group-make-web-group t]
901 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
902 ["Make a virtual group..." gnus-group-make-empty-virtual t]
903 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
904 ["Make an RSS group..." gnus-group-make-rss-group t]
905 ["Rename group..." gnus-group-rename-group
906 (gnus-check-backend-function
907 'request-rename-group (gnus-group-group-name))]
908 ["Delete group" gnus-group-delete-group
909 (gnus-check-backend-function
910 'request-delete-group (gnus-group-group-name))])
912 ["Next" gnus-group-next-group t]
913 ["Previous" gnus-group-prev-group t]
914 ["Next unread" gnus-group-next-unread-group t]
915 ["Previous unread" gnus-group-prev-unread-group t]
916 ["Next unread same level" gnus-group-next-unread-group-same-level t]
917 ["Previous unread same level"
918 gnus-group-prev-unread-group-same-level t]
919 ["Jump to group..." gnus-group-jump-to-group t]
920 ["First unread group" gnus-group-first-unread-group t]
921 ["Best unread group" gnus-group-best-unread-group t])
923 ["Generate" gnus-sieve-generate t]
924 ["Generate and update" gnus-sieve-update t])
925 ["Delete bogus groups" gnus-group-check-bogus-groups t]
926 ["Find new newsgroups" gnus-group-find-new-groups t]
927 ["Transpose" gnus-group-transpose-groups
928 (gnus-group-group-name)]
929 ["Read a directory as a group..." gnus-group-enter-directory t]))
932 gnus-group-misc-menu gnus-group-mode-map ""
935 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
936 ["Send replies" gnus-soup-send-replies
937 (fboundp 'gnus-soup-pack-packet)]
938 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
939 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
940 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
941 ["Send a mail" gnus-group-mail t]
942 ["Send a message (mail or news)" gnus-group-post-news t]
943 ["Create a local message" gnus-group-news t]
944 ["Check for new news" gnus-group-get-new-news
945 ,@(if (featurep 'xemacs) '(t)
946 '(:help "Get newly arrived articles"))
948 ["Send queued messages" gnus-delay-send-queue
949 ,@(if (featurep 'xemacs) '(t)
950 '(:help "Send all messages that are scheduled to be sent now"))
952 ["Activate all groups" gnus-activate-all-groups t]
953 ["Restart Gnus" gnus-group-restart t]
954 ["Read init file" gnus-group-read-init-file t]
955 ["Browse foreign server..." gnus-group-browse-foreign-server t]
956 ["Enter server buffer" gnus-group-enter-server-mode t]
957 ["Expire all expirable articles" gnus-group-expire-all-groups t]
958 ["Generate any kiboze groups" nnkiboze-generate-groups t]
959 ["Gnus version" gnus-version t]
960 ["Save .newsrc files" gnus-group-save-newsrc t]
961 ["Suspend Gnus" gnus-group-suspend t]
962 ["Clear dribble buffer" gnus-group-clear-dribble t]
963 ["Read manual" gnus-info-find-node t]
964 ["Flush score cache" gnus-score-flush-cache t]
965 ["Toggle topics" gnus-topic-mode t]
966 ["Send a bug report" gnus-bug t]
967 ["Exit from Gnus" gnus-group-exit
968 ,@(if (featurep 'xemacs) '(t)
969 '(:help "Quit reading news"))]
970 ["Exit without saving" gnus-group-quit t]))
972 (gnus-run-hooks 'gnus-group-menu-hook)))
974 (defvar gnus-group-toolbar-map nil)
976 ;; Emacs 21 tool bar. Should be no-op otherwise.
977 (defun gnus-group-make-tool-bar ()
979 (condition-case nil (require 'tool-bar) (error nil))
980 (fboundp 'tool-bar-add-item-from-menu)
981 (default-value 'tool-bar-mode)
982 (not gnus-group-toolbar-map))
983 (setq gnus-group-toolbar-map
984 (let ((tool-bar-map (make-sparse-keymap))
985 (load-path (mm-image-load-path)))
986 (tool-bar-add-item-from-menu
987 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
988 (tool-bar-add-item-from-menu
989 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
990 (tool-bar-add-item-from-menu
991 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
992 (tool-bar-add-item-from-menu
993 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
994 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
995 :help "Subscribe to the current group")
996 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
998 :help "Unsubscribe from the current group")
999 (tool-bar-add-item-from-menu
1000 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1002 (if gnus-group-toolbar-map
1003 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1005 (defun gnus-group-mode ()
1006 "Major mode for reading news.
1008 All normal editing commands are switched off.
1009 \\<gnus-group-mode-map>
1010 The group buffer lists (some of) the groups available. For instance,
1011 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1012 lists all zombie groups.
1014 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1015 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1017 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1019 The following commands are available:
1021 \\{gnus-group-mode-map}"
1023 (kill-all-local-variables)
1024 (when (gnus-visual-p 'group-menu 'menu)
1025 (gnus-group-make-menu-bar)
1026 (gnus-group-make-tool-bar))
1027 (gnus-simplify-mode-line)
1028 (setq major-mode 'gnus-group-mode)
1029 (setq mode-name "Group")
1030 (gnus-group-set-mode-line)
1031 (setq mode-line-process nil)
1032 (use-local-map gnus-group-mode-map)
1033 (buffer-disable-undo)
1034 (setq truncate-lines t)
1035 (setq buffer-read-only t)
1036 (gnus-set-default-directory)
1037 (gnus-update-format-specifications nil 'group 'group-mode)
1038 (gnus-update-group-mark-positions)
1043 (gnus-run-hooks 'gnus-group-mode-hook))
1045 (defun gnus-update-group-mark-positions ()
1047 (let ((gnus-process-mark ?\200)
1048 (gnus-group-update-hook nil)
1049 (gnus-group-marked '("dummy.group"))
1050 (gnus-active-hashtb (make-vector 10 0))
1052 (gnus-set-active "dummy.group" '(0 . 0))
1053 (gnus-set-work-buffer)
1054 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1055 (goto-char (point-min))
1056 (setq gnus-group-mark-positions
1057 (list (cons 'process (and (search-forward "\200" nil t)
1058 (- (point) 2))))))))
1060 (defun gnus-mouse-pick-group (e)
1061 "Enter the group under the mouse pointer."
1064 (gnus-group-read-group nil))
1066 ;; Look at LEVEL and find out what the level is really supposed to be.
1067 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1068 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1069 (defun gnus-group-default-level (&optional level number-or-nil)
1071 (gnus-group-use-permanent-levels
1072 (or (setq gnus-group-use-permanent-levels
1073 (or level (if (numberp gnus-group-use-permanent-levels)
1074 gnus-group-use-permanent-levels
1075 (or gnus-group-default-list-level
1076 gnus-level-subscribed))))
1077 gnus-group-default-list-level gnus-level-subscribed))
1081 (or level gnus-group-default-list-level gnus-level-subscribed))))
1083 (defun gnus-group-setup-buffer ()
1084 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1085 (unless (eq major-mode 'gnus-group-mode)
1088 (gnus-carpal-setup-buffer 'group))))
1090 (defun gnus-group-name-charset (method group)
1092 (setq method (gnus-find-method-for-group group)))
1093 (let ((item (assoc method gnus-group-name-charset-method-alist))
1094 (alist gnus-group-name-charset-group-alist)
1098 (while (setq item (pop alist))
1099 (if (string-match (car item) group)
1101 result (cdr item))))
1104 (defun gnus-group-name-decode (string charset)
1105 ;; Fixme: Don't decode in unibyte mode.
1106 (if (and string charset (featurep 'mule))
1107 (decode-coding-string string charset)
1110 (defun gnus-group-decoded-name (string)
1111 (let ((charset (gnus-group-name-charset nil string)))
1112 (gnus-group-name-decode string charset)))
1114 (defun gnus-group-name-encode (string charset)
1115 (if (and string charset (featurep 'mule))
1116 (encode-coding-string string charset)
1119 (defun gnus-group-encoded-name (string)
1120 (let ((charset (gnus-group-name-charset nil string)))
1121 (gnus-group-name-encode string charset)))
1123 (defun gnus-group-completing-read-group-name
1124 (prompt table &optional predicate require-match initial-contents history)
1128 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1132 (dolist (entry (prog1
1135 (push (list (gnus-group-decoded-name (car entry))) table)))
1136 (gnus-group-encoded-name
1138 prompt table predicate
1143 (defun gnus-group-list-groups (&optional level unread lowest)
1144 "List newsgroups with level LEVEL or lower that have unread articles.
1145 Default is all subscribed groups.
1146 If argument UNREAD is non-nil, groups with no unread articles are also
1149 Also see the `gnus-group-use-permanent-levels' variable."
1151 (list (if current-prefix-arg
1152 (prefix-numeric-value current-prefix-arg)
1154 (gnus-group-default-level nil t)
1155 gnus-group-default-list-level
1156 gnus-level-subscribed))))
1158 (setq level (car gnus-group-list-mode)
1159 unread (cdr gnus-group-list-mode)))
1160 (setq level (gnus-group-default-level level))
1161 (gnus-group-setup-buffer)
1162 (gnus-update-format-specifications nil 'group 'group-mode)
1163 (let ((case-fold-search nil)
1164 (props (text-properties-at (point-at-bol)))
1165 (empty (= (point-min) (point-max)))
1166 (group (gnus-group-group-name))
1168 (set-buffer gnus-group-buffer)
1169 (setq number (funcall gnus-group-prepare-function level unread lowest))
1170 (when (or (and (numberp number)
1172 (zerop (buffer-size)))
1173 ;; No groups in the buffer.
1174 (gnus-message 5 gnus-no-groups-message))
1175 ;; We have some groups displayed.
1176 (goto-char (point-max))
1177 (when (or (not gnus-group-goto-next-group-function)
1178 (not (funcall gnus-group-goto-next-group-function
1182 (goto-char (point-min)))
1184 ;; Go to the first group with unread articles.
1185 (gnus-group-search-forward t))
1187 ;; Find the right group to put point on. If the current group
1188 ;; has disappeared in the new listing, try to find the next
1189 ;; one. If no next one can be found, just leave point at the
1190 ;; first newsgroup in the buffer.
1191 (when (not (gnus-goto-char
1193 (point-min) (point-max)
1194 'gnus-group (gnus-intern-safe
1195 group gnus-active-hashtb))))
1196 (let ((newsrc (cdddr (gnus-group-entry group))))
1198 (not (gnus-goto-char
1200 (point-min) (point-max) 'gnus-group
1202 (caar newsrc) gnus-active-hashtb)))))
1203 (setq newsrc (cdr newsrc)))
1205 (goto-char (point-max))
1206 (forward-line -1)))))))
1207 ;; Adjust cursor point.
1208 (gnus-group-position-point)))
1210 (defun gnus-group-list-level (level &optional all)
1211 "List groups on LEVEL.
1212 If ALL (the prefix), also list groups that have no unread articles."
1213 (interactive "nList groups on level: \nP")
1214 (gnus-group-list-groups level all level))
1216 (defun gnus-group-prepare-logic (group test)
1217 (or (and gnus-group-listed-groups
1218 (null gnus-group-list-option)
1219 (member group gnus-group-listed-groups))
1221 ((null gnus-group-listed-groups) test)
1222 ((null gnus-group-list-option) test)
1223 (t (and (member group gnus-group-listed-groups)
1224 (if (eq gnus-group-list-option 'flush)
1228 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1229 "List all newsgroups with unread articles of level LEVEL or lower.
1230 If PREDICATE is a function, list groups that the function returns non-nil;
1231 if it is t, list groups that have no unread articles.
1232 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1233 If REGEXP is a function, list dead groups that the function returns non-nil;
1234 if it is a string, only list groups matching REGEXP."
1235 (set-buffer gnus-group-buffer)
1236 (let ((buffer-read-only nil)
1237 (newsrc (cdr gnus-newsrc-alist))
1238 (lowest (or lowest 1))
1239 (not-in-list (and gnus-group-listed-groups
1240 (copy-sequence gnus-group-listed-groups)))
1241 info clevel unread group params)
1243 (when (or (< lowest gnus-level-zombie)
1244 gnus-group-listed-groups)
1245 ;; List living groups.
1247 (setq info (car newsrc)
1248 group (gnus-info-group info)
1249 params (gnus-info-params info)
1251 unread (gnus-group-unread group))
1253 (setq not-in-list (delete group not-in-list)))
1254 (when (gnus-group-prepare-logic
1256 (and unread ; This group might be unchecked
1257 (or (not (stringp regexp))
1258 (string-match regexp group))
1259 (<= (setq clevel (gnus-info-level info)) level)
1262 ((functionp predicate)
1263 (funcall predicate info))
1264 (predicate t) ; We list all groups?
1267 (if (eq unread t) ; Unactivated?
1268 gnus-group-list-inactive-groups
1269 ; We list unactivated
1271 ; We list groups with unread articles
1272 (and gnus-list-groups-with-ticked-articles
1273 (cdr (assq 'tick (gnus-info-marks info))))
1274 ; And groups with tickeds
1275 ;; Check for permanent visibility.
1276 (and gnus-permanently-visible-groups
1277 (string-match gnus-permanently-visible-groups
1279 (memq 'visible params)
1280 (cdr (assq 'visible params)))))))
1281 (gnus-group-insert-group-line
1282 group (gnus-info-level info)
1283 (gnus-info-marks info) unread (gnus-info-method info)))))
1285 ;; List dead groups.
1286 (when (or gnus-group-listed-groups
1287 (and (>= level gnus-level-zombie)
1288 (<= lowest gnus-level-zombie)))
1289 (gnus-group-prepare-flat-list-dead
1290 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1291 gnus-level-zombie ?Z
1294 (dolist (group gnus-zombie-list)
1295 (setq not-in-list (delete group not-in-list))))
1296 (when (or gnus-group-listed-groups
1297 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1298 (gnus-group-prepare-flat-list-dead
1301 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1302 gnus-level-killed ?K regexp))
1304 (gnus-group-set-mode-line)
1305 (setq gnus-group-list-mode (cons level predicate))
1306 (gnus-run-hooks 'gnus-group-prepare-hook)
1309 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1310 ;; List zombies and killed lists somewhat faster, which was
1311 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1312 ;; this by ignoring the group format specification altogether.
1314 (if (> (length groups) gnus-group-listing-limit)
1316 (setq group (pop groups))
1317 (when (gnus-group-prepare-logic
1320 (and (stringp regexp) (string-match regexp group))
1321 (and (functionp regexp) (funcall regexp group))))
1322 (gnus-add-text-properties
1323 (point) (prog1 (1+ (point))
1324 (insert " " mark " *: "
1325 (gnus-group-decoded-name group)
1327 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1329 'gnus-level level))))
1331 (setq group (pop groups))
1332 (when (gnus-group-prepare-logic
1335 (and (stringp regexp) (string-match regexp group))
1336 (and (functionp regexp) (funcall regexp group))))
1337 (gnus-group-insert-group-line
1339 (let ((active (gnus-active group)))
1341 (if (zerop (cdr active))
1343 (- (1+ (cdr active)) (car active)))
1345 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1347 (defun gnus-group-update-group-line ()
1348 "Update the current line in the group buffer."
1349 (let* ((buffer-read-only nil)
1350 (group (gnus-group-group-name))
1351 (entry (and group (gnus-group-entry group)))
1352 gnus-group-indentation)
1355 (not (gnus-ephemeral-group-p group))
1357 (concat "(gnus-group-set-info '"
1358 (gnus-prin1-to-string (nth 2 entry))
1360 (setq gnus-group-indentation (gnus-group-group-indentation))
1362 (gnus-group-insert-group-line-info group)
1364 (gnus-group-position-point))))
1366 (defun gnus-group-insert-group-line-info (group)
1367 "Insert GROUP on the current line."
1368 (let ((entry (gnus-group-entry group))
1369 (gnus-group-indentation (gnus-group-group-indentation))
1373 ;; (Un)subscribed group.
1374 (setq info (nth 2 entry))
1375 (gnus-group-insert-group-line
1376 group (gnus-info-level info) (gnus-info-marks info)
1377 (or (car entry) t) (gnus-info-method info)))
1378 ;; This group is dead.
1379 (gnus-group-insert-group-line
1381 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1383 (if (setq active (gnus-active group))
1384 (if (zerop (cdr active))
1386 (- (1+ (cdr active)) (car active)))
1388 (gnus-method-simplify (gnus-find-method-for-group group))))))
1390 (defun gnus-number-of-unseen-articles-in-group (group)
1391 (let* ((info (nth 2 (gnus-group-entry group)))
1392 (marked (gnus-info-marks info))
1393 (seen (cdr (assq 'seen marked)))
1394 (active (gnus-active group)))
1397 (length (gnus-uncompress-range
1398 (gnus-range-difference
1399 (gnus-range-difference (list active) (gnus-info-read info))
1402 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1403 gnus-tmp-marked number
1405 "Insert a group line in the group buffer."
1406 (let* ((gnus-tmp-method
1407 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1408 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1410 (gnus-tmp-active (gnus-active gnus-tmp-group))
1411 (gnus-tmp-number-total
1413 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1415 (gnus-tmp-number-of-unread
1416 (if (numberp number) (int-to-string (max 0 number))
1418 (gnus-tmp-number-of-read
1419 (if (numberp number)
1420 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1422 (gnus-tmp-subscribed
1423 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1424 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1425 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1427 (gnus-tmp-qualified-group
1428 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1429 group-name-charset))
1431 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1433 (gnus-tmp-newsgroup-description
1434 (if gnus-description-hashtb
1435 (or (gnus-group-name-decode
1436 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1437 group-name-charset) "")
1440 (if (and gnus-moderated-hashtb
1441 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1443 (gnus-tmp-moderated-string
1444 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1445 (gnus-tmp-group-icon "==&&==")
1446 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1447 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1448 (gnus-tmp-news-method-string
1450 (format "(%s:%s)" (car gnus-tmp-method)
1451 (cadr gnus-tmp-method)) ""))
1452 (gnus-tmp-marked-mark
1453 (if (and (numberp number)
1455 (cdr (assq 'tick gnus-tmp-marked)))
1457 (gnus-tmp-summary-live
1458 (if (and (not gnus-group-is-exiting-p)
1459 (gnus-buffer-live-p (gnus-summary-buffer-name
1462 (gnus-tmp-process-marked
1463 (if (member gnus-tmp-group gnus-group-marked)
1464 gnus-process-mark ? ))
1465 (buffer-read-only nil)
1466 header gnus-tmp-header) ; passed as parameter to user-funcs.
1468 (gnus-add-text-properties
1472 (let ((gnus-tmp-group (gnus-group-name-decode
1473 gnus-tmp-group group-name-charset)))
1474 (eval gnus-group-line-format-spec)))
1475 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1476 gnus-unread ,(if (numberp number)
1477 (string-to-int gnus-tmp-number-of-unread)
1479 gnus-marked ,gnus-tmp-marked-mark
1480 gnus-indentation ,gnus-group-indentation
1481 gnus-level ,gnus-tmp-level))
1483 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1484 (gnus-run-hooks 'gnus-group-update-hook))
1486 ;; Allow XEmacs to remove front-sticky text properties.
1487 (gnus-group-remove-excess-properties)))
1489 (defun gnus-group-highlight-line ()
1490 "Highlight the current line according to `gnus-group-highlight'."
1491 (let* ((list gnus-group-highlight)
1493 (end (point-at-eol))
1494 ;; now find out where the line starts and leave point there.
1495 (beg (progn (beginning-of-line) (point)))
1496 (group (gnus-group-group-name))
1497 (entry (gnus-group-entry group))
1498 (unread (if (numberp (car entry)) (car entry) 0))
1499 (active (gnus-active group))
1500 (total (if active (1+ (- (cdr active) (car active))) 0))
1501 (info (nth 2 entry))
1502 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1503 (marked (gnus-info-marks info))
1504 (mailp (apply 'append
1507 (memq x (assoc (symbol-name
1508 (car (or method gnus-select-method)))
1509 gnus-valid-select-methods)))
1510 '(mail post-mail))))
1511 (level (or (gnus-info-level info) gnus-level-killed))
1512 (score (or (gnus-info-score info) 0))
1513 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1514 (group-age (gnus-group-timestamp-delta group))
1515 (inhibit-read-only t))
1516 ;; Eval the cars of the lists until we find a match.
1518 (not (eval (caar list))))
1519 (setq list (cdr list)))
1520 (let ((face (cdar list)))
1521 (unless (eq face (get-text-property beg 'face))
1522 (gnus-put-text-property-excluding-characters-with-faces
1524 (setq face (if (boundp face) (symbol-value face) face)))
1525 (gnus-extent-start-open beg)))
1528 (defun gnus-group-update-group (group &optional visible-only)
1529 "Update all lines where GROUP appear.
1530 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1532 ;; Can't use `save-excursion' here, so we do it manually.
1533 (let ((buf (current-buffer))
1535 (set-buffer gnus-group-buffer)
1536 (setq mark (point-marker))
1537 ;; The buffer may be narrowed.
1540 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1542 found buffer-read-only)
1543 ;; Enter the current status into the dribble buffer.
1544 (let ((entry (gnus-group-entry group)))
1546 (not (gnus-ephemeral-group-p group)))
1548 (concat "(gnus-group-set-info '"
1549 (gnus-prin1-to-string (nth 2 entry))
1551 ;; Find all group instances. If topics are in use, each group
1552 ;; may be listed in more than once.
1553 (while (setq loc (text-property-any
1554 loc (point-max) 'gnus-group ident))
1557 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1559 (gnus-group-insert-group-line-info group)
1562 (gnus-run-hooks 'gnus-group-update-group-hook)))
1563 (setq loc (1+ loc)))
1564 (unless (or found visible-only)
1565 ;; No such line in the buffer, find out where it's supposed to
1566 ;; go, and insert it there (or at the end of the buffer).
1567 (if gnus-goto-missing-group-function
1568 (funcall gnus-goto-missing-group-function group)
1569 (let ((entry (cddr (gnus-group-entry group))))
1570 (while (and entry (car entry)
1574 (point-min) (point-max)
1575 'gnus-group (gnus-intern-safe
1576 (caar entry) gnus-active-hashtb)))))
1577 (setq entry (cdr entry)))
1578 (or entry (goto-char (point-max)))))
1579 ;; Finally insert the line.
1580 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1581 (gnus-group-insert-group-line-info group)
1584 (gnus-run-hooks 'gnus-group-update-group-hook))))
1585 (when gnus-group-update-group-function
1586 (funcall gnus-group-update-group-function group))
1587 (gnus-group-set-mode-line)))
1589 (set-marker mark nil)
1592 (defun gnus-group-set-mode-line ()
1593 "Update the mode line in the group buffer."
1594 (when (memq 'group gnus-updated-mode-lines)
1595 ;; Yes, we want to keep this mode line updated.
1597 (set-buffer gnus-group-buffer)
1598 (let* ((gformat (or gnus-group-mode-line-format-spec
1599 (gnus-set-format 'group-mode)))
1600 (gnus-tmp-news-server (cadr gnus-select-method))
1601 (gnus-tmp-news-method (car gnus-select-method))
1602 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1604 gnus-tmp-header ;Dummy binding for user-defined formats
1605 ;; Get the resulting string.
1607 (and gnus-dribble-buffer
1608 (buffer-name gnus-dribble-buffer)
1609 (buffer-modified-p gnus-dribble-buffer)
1611 (set-buffer gnus-dribble-buffer)
1612 (not (zerop (buffer-size))))))
1613 (mode-string (eval gformat)))
1614 ;; Say whether the dribble buffer has been modified.
1615 (setq mode-line-modified
1616 (if modified (car gnus-mode-line-modified)
1617 (cdr gnus-mode-line-modified)))
1618 ;; If the line is too long, we chop it off.
1619 (when (> (length mode-string) max-len)
1620 (setq mode-string (substring mode-string 0 (- max-len 4))))
1622 (setq mode-line-buffer-identification
1623 (gnus-mode-line-buffer-identification
1624 (list mode-string)))
1625 (set-buffer-modified-p modified))))))
1627 (defun gnus-group-group-name ()
1628 "Get the name of the newsgroup on the current line."
1629 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1631 (symbol-name group))))
1633 (defun gnus-group-group-level ()
1634 "Get the level of the newsgroup on the current line."
1635 (get-text-property (point-at-bol) 'gnus-level))
1637 (defun gnus-group-group-indentation ()
1638 "Get the indentation of the newsgroup on the current line."
1639 (or (get-text-property (point-at-bol) 'gnus-indentation)
1640 (and gnus-group-indentation-function
1641 (funcall gnus-group-indentation-function))
1644 (defun gnus-group-group-unread ()
1645 "Get the number of unread articles of the newsgroup on the current line."
1646 (get-text-property (point-at-bol) 'gnus-unread))
1648 (defun gnus-group-new-mail (group)
1649 (if (nnmail-new-mail-p (gnus-group-real-name group))
1653 (defun gnus-group-level (group)
1654 "Return the estimated level of GROUP."
1655 (or (gnus-info-level (gnus-get-info group))
1656 (and (member group gnus-zombie-list) gnus-level-zombie)
1659 (defun gnus-group-search-forward (&optional backward all level first-too)
1660 "Find the next newsgroup with unread articles.
1661 If BACKWARD is non-nil, find the previous newsgroup instead.
1662 If ALL is non-nil, just find any newsgroup.
1663 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1665 If FIRST-TOO, the current line is also eligible as a target."
1666 (let ((way (if backward -1 1))
1667 (low gnus-level-killed)
1670 (if (and backward (progn (beginning-of-line)) (bobp))
1679 (get-text-property (point) 'gnus-group)
1683 (get-text-property (point) 'gnus-unread)))
1684 (and (numberp unread) (> unread 0)))
1685 (setq lev (get-text-property (point)
1687 (<= lev gnus-level-subscribed)))
1689 (and (setq lev (get-text-property (point)
1698 (zerop (forward-line way)))))
1700 (progn (gnus-group-position-point) t)
1701 (goto-char (or pos beg))
1704 ;;; Gnus group mode commands
1708 (defun gnus-group-mark-line-p ()
1711 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1712 (eq (char-after) gnus-process-mark)))
1714 (defun gnus-group-mark-group (n &optional unmark no-advance)
1715 "Mark the current group."
1717 (let ((buffer-read-only nil)
1721 (when (setq group (gnus-group-group-name))
1722 ;; Go to the mark position.
1724 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1728 (setq gnus-group-marked (delete group gnus-group-marked))
1729 (insert-char ? 1 t))
1730 (setq gnus-group-marked
1731 (cons group (delete group gnus-group-marked)))
1732 (insert-char gnus-process-mark 1 t)))
1734 (gnus-group-next-group 1))
1736 (gnus-summary-position-point)
1739 (defun gnus-group-unmark-group (n)
1740 "Remove the mark from the current group."
1742 (gnus-group-mark-group n 'unmark)
1743 (gnus-group-position-point))
1745 (defun gnus-group-unmark-all-groups ()
1746 "Unmark all groups."
1748 (let ((groups gnus-group-marked))
1751 (gnus-group-remove-mark (pop groups)))))
1752 (gnus-group-position-point))
1754 (defun gnus-group-mark-region (unmark beg end)
1755 "Mark all groups between point and mark.
1756 If UNMARK, remove the mark instead."
1757 (interactive "P\nr")
1758 (let ((num (count-lines beg end)))
1761 (- num (gnus-group-mark-group num unmark)))))
1763 (defun gnus-group-mark-buffer (&optional unmark)
1764 "Mark all groups in the buffer.
1765 If UNMARK, remove the mark instead."
1767 (gnus-group-mark-region unmark (point-min) (point-max)))
1769 (defun gnus-group-mark-regexp (regexp)
1770 "Mark all groups that match some regexp."
1771 (interactive "sMark (regexp): ")
1772 (let ((alist (cdr gnus-newsrc-alist))
1776 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1777 (gnus-group-jump-to-group group)
1778 (gnus-group-set-mark group)))))
1779 (gnus-group-position-point))
1781 (defun gnus-group-remove-mark (group &optional test-marked)
1782 "Remove the process mark from GROUP and move point there.
1783 Return nil if the group isn't displayed."
1784 (if (gnus-group-goto-group group nil test-marked)
1786 (gnus-group-mark-group 1 'unmark t)
1788 (setq gnus-group-marked
1789 (delete group gnus-group-marked))
1792 (defun gnus-group-set-mark (group)
1793 "Set the process mark on GROUP."
1794 (if (gnus-group-goto-group group)
1796 (gnus-group-mark-group 1 nil t))
1797 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1799 (defun gnus-group-universal-argument (arg &optional groups func)
1800 "Perform any command on all groups according to the process/prefix convention."
1802 (if (eq (setq func (or func
1805 (substitute-command-keys
1806 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1808 (gnus-error 1 "Undefined key")
1809 (gnus-group-iterate arg
1811 (command-execute func))))
1812 (gnus-group-position-point))
1814 (defun gnus-group-process-prefix (n)
1815 "Return a list of groups to work on.
1816 Take into consideration N (the prefix) and the list of marked groups."
1819 (setq n (prefix-numeric-value n))
1820 ;; There is a prefix, so we return a list of the N next
1822 (let ((way (if (< n 0) -1 1))
1827 (if (setq group (gnus-group-group-name))
1828 (push group groups))
1830 (gnus-group-next-group way)))
1832 ((and (gnus-region-active-p) (mark))
1833 ;; Work on the region between point and mark.
1834 (let ((max (max (point) (mark)))
1837 (goto-char (min (point) (mark)))
1840 (push (gnus-group-group-name) groups)
1841 (zerop (gnus-group-next-group 1))
1843 (nreverse groups))))
1845 ;; No prefix, but a list of marked articles.
1846 (reverse gnus-group-marked))
1848 ;; Neither marked articles or a prefix, so we return the
1850 (let ((group (gnus-group-group-name)))
1851 (and group (list group))))))
1853 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1854 ;;; imagine why I went through these contortions...
1856 (let ((function (make-symbol "gnus-group-iterate-function"))
1857 (window (make-symbol "gnus-group-iterate-window"))
1858 (groups (make-symbol "gnus-group-iterate-groups"))
1859 (group (make-symbol "gnus-group-iterate-group")))
1861 `(defun gnus-group-iterate (arg ,function)
1862 "Iterate FUNCTION over all process/prefixed groups.
1863 FUNCTION will be called with the group name as the parameter
1864 and with point over the group in question."
1865 (let ((,groups (gnus-group-process-prefix arg))
1866 (,window (selected-window))
1869 (setq ,group (car ,groups)
1870 ,groups (cdr ,groups))
1871 (select-window ,window)
1872 (gnus-group-remove-mark ,group)
1873 (save-selected-window
1875 (funcall ,function ,group)))))))))
1877 (put 'gnus-group-iterate 'lisp-indent-function 1)
1879 ;; Selecting groups.
1881 (defun gnus-group-read-group (&optional all no-article group select-articles)
1882 "Read news in this newsgroup.
1883 If the prefix argument ALL is non-nil, already read articles become
1884 readable. IF ALL is a number, fetch this number of articles. If the
1885 optional argument NO-ARTICLE is non-nil, no article will be
1886 auto-selected upon group entry. If GROUP is non-nil, fetch that
1889 (let ((no-display (eq all 0))
1890 (group (or group (gnus-group-group-name)))
1891 number active marked entry)
1895 (error "No group on current line"))
1896 (setq marked (gnus-info-marks
1897 (nth 2 (setq entry (gnus-group-entry group)))))
1898 ;; This group might be a dead group. In that case we have to get
1899 ;; the number of unread articles from `gnus-active-hashtb'.
1901 (cond ((numberp all) all)
1903 ((setq active (gnus-active group))
1904 (- (1+ (cdr active)) (car active)))))
1905 (gnus-summary-read-group
1906 group (or all (and (numberp number)
1907 (zerop (+ number (gnus-range-length
1908 (cdr (assq 'tick marked)))
1910 (cdr (assq 'dormant marked)))))))
1911 no-article nil no-display nil select-articles)))
1913 (defun gnus-group-select-group (&optional all)
1914 "Select this newsgroup.
1915 No article is selected automatically.
1916 If the group is opened, just switch the summary buffer.
1917 If ALL is non-nil, already read articles become readable.
1918 If ALL is a number, fetch this number of articles."
1920 (when (and (eobp) (not (gnus-group-group-name)))
1922 (gnus-group-read-group all t))
1924 (defun gnus-group-quick-select-group (&optional all)
1925 "Select the current group \"quickly\".
1926 This means that no highlighting or scoring will be performed.
1927 If ALL (the prefix argument) is 0, don't even generate the summary
1930 This might be useful if you want to toggle threading
1931 before entering the group."
1933 (require 'gnus-score)
1935 gnus-score-find-score-files-function
1936 gnus-home-score-file
1937 gnus-apply-kill-hook
1938 gnus-summary-expunge-below)
1939 (gnus-group-read-group all t)))
1941 (defun gnus-group-visible-select-group (&optional all)
1942 "Select the current group without hiding any articles."
1944 (let ((gnus-inhibit-limiting t))
1945 (gnus-group-read-group all t)))
1947 (defun gnus-group-select-group-ephemerally ()
1948 "Select the current group without doing any processing whatsoever.
1949 You will actually be entered into a group that's a copy of
1950 the current group; no changes you make while in this group will
1953 (require 'gnus-score)
1955 gnus-score-find-score-files-function gnus-apply-kill-hook
1956 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1957 gnus-summary-mode-hook gnus-select-group-hook
1958 (group (gnus-group-group-name))
1959 (method (gnus-find-method-for-group group)))
1960 (gnus-group-read-ephemeral-group
1961 (gnus-group-prefixed-name group method) method)))
1964 (defun gnus-fetch-group (group &optional articles)
1965 "Start Gnus if necessary and enter GROUP.
1966 Returns whether the fetching was successful or not."
1967 (interactive (list (gnus-group-completing-read-group-name
1968 "Group name: " gnus-active-hashtb)))
1969 (unless (get-buffer gnus-group-buffer)
1971 (gnus-group-read-group articles nil group))
1974 (defun gnus-fetch-group-other-frame (group)
1975 "Pop up a frame and enter GROUP."
1977 (let ((window (get-buffer-window gnus-group-buffer)))
1979 (select-frame (window-frame window)))
1980 ((= (length (frame-list)) 1)
1981 (select-frame (make-frame)))
1984 (gnus-fetch-group group))
1986 (defvar gnus-ephemeral-group-server 0)
1988 (defcustom gnus-large-ephemeral-newsgroup 200
1989 "The number of articles which indicates a large ephemeral newsgroup.
1990 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1992 If the number of articles in a newsgroup is greater than this value,
1993 confirmation is required for selecting the newsgroup. If it is nil, no
1994 confirmation is required."
1995 :group 'gnus-group-select
1996 :type '(choice (const :tag "No limit" nil)
1999 (defcustom gnus-fetch-old-ephemeral-headers nil
2000 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2002 :type '(choice (const :tag "off" nil)
2005 (sexp :menu-tag "other" t)))
2007 ;; Enter a group that is not in the group buffer. Non-nil is returned
2008 ;; if selection was successful.
2009 (defun gnus-group-read-ephemeral-group (group method &optional activate
2010 quit-config request-only
2013 "Read GROUP from METHOD as an ephemeral group.
2014 If ACTIVATE, request the group first.
2015 If QUIT-CONFIG, use that window configuration when exiting from the
2017 If REQUEST-ONLY, don't actually read the group; just request it.
2018 If SELECT-ARTICLES, only select those articles.
2019 If PARAMETERS, use those as the group parameters.
2021 Return the name of the group if selection was successful."
2024 ;; (gnus-read-group "Group name: ")
2026 "Group: " gnus-active-hashtb
2028 'gnus-group-history)
2029 (gnus-read-method "From method: ")))
2030 ;; Transform the select method into a unique server.
2031 (when (stringp method)
2032 (setq method (gnus-server-to-method method)))
2034 `(,(car method) ,(concat (cadr method) "-ephemeral")
2035 (,(intern (format "%s-address" (car method))) ,(cadr method))
2037 (let ((group (if (gnus-group-foreign-p group) group
2038 (gnus-group-prefixed-name (gnus-group-real-name group)
2043 ,gnus-level-default-subscribed nil nil ,method
2046 (cons 'quit-config quit-config)
2048 (cons gnus-summary-buffer
2049 gnus-current-window-configuration)))
2052 (push method gnus-ephemeral-servers)
2053 (set-buffer gnus-group-buffer)
2054 (unless (gnus-check-server method)
2055 (error "Unable to contact server: %s" (gnus-status-message method)))
2057 (gnus-activate-group group 'scan)
2058 (unless (gnus-request-group group)
2059 (error "Couldn't request group: %s"
2060 (nnheader-get-report (car method)))))
2064 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2065 (gnus-fetch-old-headers
2066 gnus-fetch-old-ephemeral-headers))
2067 (gnus-group-read-group t t group select-articles))
2071 (message "Quit reading the ephemeral group")
2074 (defun gnus-group-jump-to-group (group)
2075 "Jump to newsgroup GROUP."
2077 (list (gnus-group-completing-read-group-name
2078 "Group: " gnus-active-hashtb nil
2079 (gnus-read-active-file-p)
2080 gnus-group-jump-to-group-prompt
2081 'gnus-group-history)))
2083 (when (equal group "")
2084 (error "Empty group name"))
2086 (unless (gnus-ephemeral-group-p group)
2087 ;; Either go to the line in the group buffer...
2088 (unless (gnus-group-goto-group group)
2089 ;; ... or insert the line.
2090 (gnus-group-update-group group)
2091 (gnus-group-goto-group group)))
2092 ;; Adjust cursor point.
2093 (gnus-group-position-point))
2095 (defun gnus-group-goto-group (group &optional far test-marked)
2096 "Goto to newsgroup GROUP.
2097 If FAR, it is likely that the group is not on the current line.
2098 If TEST-MARKED, the line must be marked."
2102 ;; It's quite likely that we are on the right line, so
2103 ;; we check the current line first.
2105 (eq (get-text-property (point) 'gnus-group)
2106 (gnus-intern-safe group gnus-active-hashtb))
2107 (or (not test-marked) (gnus-group-mark-line-p)))
2109 ;; Previous and next line are also likely, so we check them as well.
2113 (and (eq (get-text-property (point) 'gnus-group)
2114 (gnus-intern-safe group gnus-active-hashtb))
2115 (or (not test-marked) (gnus-group-mark-line-p)))))
2121 (and (eq (get-text-property (point) 'gnus-group)
2122 (gnus-intern-safe group gnus-active-hashtb))
2123 (or (not test-marked) (gnus-group-mark-line-p)))))
2127 (goto-char (point-min))
2129 (while (and (not found)
2134 (gnus-intern-safe group gnus-active-hashtb))))
2135 (if (gnus-group-mark-line-p)
2140 ;; Search through the entire buffer.
2143 (point-min) (point-max)
2144 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2146 (defun gnus-group-next-group (n &optional silent)
2147 "Go to next N'th newsgroup.
2148 If N is negative, search backward instead.
2149 Returns the difference between N and the number of skips actually
2152 (gnus-group-next-unread-group n t nil silent))
2154 (defun gnus-group-next-unread-group (n &optional all level silent)
2155 "Go to next N'th unread newsgroup.
2156 If N is negative, search backward instead.
2157 If ALL is non-nil, choose any newsgroup, unread or not.
2158 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2159 such group can be found, the next group with a level higher than
2161 Returns the difference between N and the number of skips actually
2164 (let ((backward (< n 0))
2167 (gnus-group-search-forward
2168 backward (or (not gnus-group-goto-unread) all) level))
2172 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2173 (if level " on this level or higher" "")))
2176 (defun gnus-group-prev-group (n)
2177 "Go to previous N'th newsgroup.
2178 Returns the difference between N and the number of skips actually
2181 (gnus-group-next-unread-group (- n) t))
2183 (defun gnus-group-prev-unread-group (n)
2184 "Go to previous N'th unread newsgroup.
2185 Returns the difference between N and the number of skips actually
2188 (gnus-group-next-unread-group (- n)))
2190 (defun gnus-group-next-unread-group-same-level (n)
2191 "Go to next N'th unread newsgroup on the same level.
2192 If N is negative, search backward instead.
2193 Returns the difference between N and the number of skips actually
2196 (gnus-group-next-unread-group n t (gnus-group-group-level))
2197 (gnus-group-position-point))
2199 (defun gnus-group-prev-unread-group-same-level (n)
2200 "Go to next N'th unread newsgroup on the same level.
2201 Returns the difference between N and the number of skips actually
2204 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2205 (gnus-group-position-point))
2207 (defun gnus-group-best-unread-group (&optional exclude-group)
2208 "Go to the group with the highest level.
2209 If EXCLUDE-GROUP, do not go to that group."
2211 (goto-char (point-min))
2215 (setq unread (get-text-property (point) 'gnus-unread))
2216 (when (and (numberp unread) (> unread 0))
2217 (when (and (get-text-property (point) 'gnus-level)
2218 (< (get-text-property (point) 'gnus-level) best)
2219 (or (not exclude-group)
2220 (not (equal exclude-group (gnus-group-group-name)))))
2221 (setq best (get-text-property (point) 'gnus-level))
2222 (setq best-point (point))))
2225 (goto-char best-point))
2226 (gnus-group-position-point)
2227 (and best-point (gnus-group-group-name))))
2229 (defun gnus-group-first-unread-group ()
2230 "Go to the first group with unread articles."
2233 (let ((opoint (point))
2235 (goto-char (point-min))
2236 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2237 (and (numberp unread) ; Not a topic.
2238 (not (zerop unread))) ; Has unread articles.
2239 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2242 nil)) ; Not success.
2243 (gnus-group-position-point)))
2245 (defun gnus-group-enter-server-mode ()
2246 "Jump to the server buffer."
2248 (gnus-enter-server-buffer))
2250 (defun gnus-group-make-group (name &optional method address args)
2251 "Add a new newsgroup.
2252 The user will be prompted for a NAME, for a select METHOD, and an
2256 (gnus-read-group "Group name: ")
2257 (gnus-read-method "From method: ")))
2259 (when (stringp method)
2260 (setq method (or (gnus-server-to-method method) method)))
2261 (let* ((meth (gnus-method-simplify
2263 (not (gnus-server-equal method gnus-select-method)))
2264 (if address (list (intern method) address)
2266 (nname (if method (gnus-group-prefixed-name name meth) name))
2268 (when (gnus-group-entry nname)
2269 (error "Group %s already exists" nname))
2270 ;; Subscribe to the new group.
2271 (gnus-group-change-level
2272 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2273 gnus-level-default-subscribed gnus-level-killed
2274 (and (gnus-group-group-name)
2275 (gnus-group-entry (gnus-group-group-name)))
2278 (gnus-set-active nname (cons 1 0))
2279 (unless (gnus-ephemeral-group-p name)
2281 (concat "(gnus-group-set-info '"
2282 (gnus-prin1-to-string (cdr info)) ")")))
2284 (gnus-group-insert-group-line-info nname)
2286 (gnus-group-position-point)
2288 ;; Load the back end and try to make the back end create
2289 ;; the group as well.
2290 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2292 gnus-valid-select-methods)
2294 (gnus-check-server meth)
2295 (when (gnus-check-backend-function 'request-create-group nname)
2296 (unless (gnus-request-create-group nname nil args)
2297 (error "Could not create group on server: %s"
2298 (nnheader-get-report backend))))
2301 (defun gnus-group-delete-groups (&optional arg)
2302 "Delete the current group. Only meaningful with editable groups."
2304 (let ((n (length (gnus-group-process-prefix arg))))
2305 (when (gnus-yes-or-no-p
2307 "Delete this 1 group? "
2308 (format "Delete these %d groups? " n)))
2309 (gnus-group-iterate arg
2311 (gnus-group-delete-group group nil t))))))
2313 (defvar gnus-cache-active-altered)
2315 (defun gnus-group-delete-group (group &optional force no-prompt)
2316 "Delete the current group. Only meaningful with editable groups.
2317 If FORCE (the prefix) is non-nil, all the articles in the group will
2318 be deleted. This is \"deleted\" as in \"removed forever from the face
2319 of the Earth\". There is no undo. The user will be prompted before
2321 Note that you also have to specify FORCE if you want the group to
2322 be removed from the server, even when it's empty."
2324 (list (gnus-group-group-name)
2325 current-prefix-arg))
2327 (error "No group to delete"))
2328 (unless (gnus-check-backend-function 'request-delete-group group)
2329 (error "This back end does not support group deletion"))
2331 (if (and (not no-prompt)
2332 (not (gnus-yes-or-no-p
2334 "Do you really want to delete %s%s? "
2335 group (if force " and all its contents" "")))))
2337 (gnus-message 6 "Deleting group %s..." group)
2338 (if (not (gnus-request-delete-group group force))
2339 (gnus-error 3 "Couldn't delete group %s" group)
2340 (gnus-message 6 "Deleting group %s...done" group)
2341 (gnus-group-goto-group group)
2342 (gnus-group-kill-group 1 t)
2343 (gnus-set-active group nil)
2344 (if (boundp 'gnus-cache-active-hashtb)
2345 (when gnus-cache-active-hashtb
2346 (gnus-sethash group nil gnus-cache-active-hashtb)
2347 (setq gnus-cache-active-altered t)))
2349 (gnus-group-position-point)))
2351 (defun gnus-group-rename-group (group new-name)
2352 "Rename group from GROUP to NEW-NAME.
2353 When used interactively, GROUP is the group under point
2354 and NEW-NAME will be prompted for."
2357 (gnus-group-group-name)
2359 (unless (gnus-check-backend-function
2360 'request-rename-group (gnus-group-group-name))
2361 (error "This back end does not support renaming groups"))
2362 (gnus-read-group "Rename group to: "
2363 (gnus-group-real-name (gnus-group-group-name))))))
2365 (unless (gnus-check-backend-function 'request-rename-group group)
2366 (error "This back end does not support renaming groups"))
2368 (error "No group to rename"))
2369 (when (equal (gnus-group-real-name group) new-name)
2370 (error "Can't rename to the same name"))
2372 ;; We find the proper prefixed name.
2374 (if (gnus-group-native-p group)
2378 (gnus-group-prefixed-name
2379 (gnus-group-real-name new-name)
2380 (gnus-info-method (gnus-get-info group)))))
2382 (when (gnus-active new-name)
2383 (error "The group %s already exists" new-name))
2385 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2388 (gnus-group-goto-group group)
2389 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2390 (gnus-request-rename-group group new-name))))
2391 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2392 ;; We rename the group internally by killing it...
2393 (gnus-group-kill-group)
2394 ;; ... changing its name ...
2395 (setcar (cdar gnus-list-of-killed-groups) new-name)
2396 ;; ... and then yanking it. Magic!
2397 (gnus-group-yank-group)
2398 (gnus-set-active new-name (gnus-active group))
2399 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2401 (setq gnus-killed-list (delete group gnus-killed-list))
2402 (gnus-set-active group nil)
2403 (gnus-dribble-touch)
2404 (gnus-group-position-point)))
2406 (defun gnus-group-edit-group (group &optional part)
2407 "Edit the group on the current line."
2408 (interactive (list (gnus-group-group-name)))
2409 (let ((part (or part 'info))
2412 (error "No group on current line"))
2413 (unless (setq info (gnus-get-info group))
2414 (error "Killed group; can't be edited"))
2416 (gnus-close-group group))
2418 ;; Find the proper form to edit.
2419 (cond ((eq part 'method)
2420 (or (gnus-info-method info) "native"))
2422 (gnus-info-params info))
2424 ;; The proper documentation.
2426 "Editing the %s for `%s'."
2428 ((eq part 'method) "select method")
2429 ((eq part 'params) "group parameters")
2431 (gnus-group-decoded-name group))
2433 (gnus-group-edit-group-done ',part ,group form)))
2436 (gnus-create-info-command
2438 (or gnus-info-filename
2439 (get-language-info current-language-environment 'gnus-info)
2441 (cond ((eq part 'method)
2448 (defun gnus-group-edit-group-method (group)
2449 "Edit the select method of GROUP."
2450 (interactive (list (gnus-group-group-name)))
2451 (gnus-group-edit-group group 'method))
2453 (defun gnus-group-edit-group-parameters (group)
2454 "Edit the group parameters of GROUP."
2455 (interactive (list (gnus-group-group-name)))
2456 (gnus-group-edit-group group 'params))
2458 (defun gnus-group-edit-group-done (part group form)
2460 (let* ((method (cond ((eq part 'info) (nth 4 form))
2461 ((eq part 'method) form)
2463 (info (cond ((eq part 'info) form)
2464 ((eq part 'method) (gnus-get-info group))
2467 (if (or (not method)
2469 gnus-select-method method))
2470 (gnus-group-real-name (car info))
2471 (gnus-group-prefixed-name
2472 (gnus-group-real-name (car info)) method))
2474 (when (and new-group
2475 (not (equal new-group group)))
2476 (when (gnus-group-goto-group group)
2477 (gnus-group-kill-group 1))
2478 (gnus-activate-group new-group))
2480 (if (not (and info new-group))
2481 (gnus-group-set-info form (or new-group group) part)
2482 (setq info (gnus-copy-sequence info))
2483 (setcar info new-group)
2484 (unless (gnus-server-equal method "native")
2485 (unless (nthcdr 3 info)
2486 (nconc info (list nil nil)))
2487 (unless (nthcdr 4 info)
2488 (nconc info (list nil)))
2489 (gnus-info-set-method info method))
2490 (gnus-group-set-info info))
2491 (gnus-group-update-group (or new-group group))
2492 (gnus-group-position-point)))
2494 (defun gnus-group-make-useful-group (group method)
2495 "Create one of the groups described in `gnus-useful-groups'."
2497 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2499 gnus-useful-groups)))
2500 (list (cadr entry) (caddr entry))))
2501 (setq method (gnus-copy-sequence method))
2503 (while (setq entry (memq (assq 'eval method) method))
2504 (setcar entry (eval (cadar entry)))))
2505 (gnus-group-make-group group method))
2507 (defun gnus-group-make-help-group (&optional noerror)
2508 "Create the Gnus documentation group.
2509 Optional argument NOERROR modifies the behavior of this function when the
2510 group already exists:
2511 - if not given, and error is signaled,
2512 - if t, stay silent,
2513 - if anything else, just print a message."
2515 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2516 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2517 (if (gnus-group-entry name)
2518 (cond ((eq noerror nil)
2519 (error "Documentation group already exists"))
2524 (gnus-message 1 "Documentation group already exists")))
2527 (gnus-message 1 "Couldn't find doc group")
2528 (gnus-group-make-group
2529 (gnus-group-real-name name)
2530 (list 'nndoc "gnus-help"
2531 (list 'nndoc-address file)
2532 (list 'nndoc-article-type 'mbox))))
2534 (gnus-group-position-point))
2536 (defun gnus-group-make-doc-group (file type)
2537 "Create a group that uses a single file as the source."
2539 (list (read-file-name "File name: ")
2540 (and current-prefix-arg 'ask)))
2541 (when (eq type 'ask)
2546 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2548 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2549 ((= char ?b) 'babyl)
2550 ((= char ?d) 'digest)
2551 ((= char ?f) 'forward)
2553 ((= char ?g) 'guess)
2554 (t (setq err (format "%c unknown. " char))
2557 (let* ((file (expand-file-name file))
2558 (name (gnus-generate-new-group-name
2559 (gnus-group-prefixed-name
2560 (file-name-nondirectory file) '(nndoc "")))))
2561 (gnus-group-make-group
2562 (gnus-group-real-name name)
2564 (list 'nndoc-address file)
2565 (list 'nndoc-article-type (or type 'guess))))))
2567 (defvar nnweb-type-definition)
2568 (defvar gnus-group-web-type-history nil)
2569 (defvar gnus-group-web-search-history nil)
2570 (defun gnus-group-make-web-group (&optional solid)
2571 "Create an ephemeral nnweb group.
2572 If SOLID (the prefix), create a solid group."
2576 (if solid (gnus-read-group "Group name: ")
2577 (message-unique-id)))
2578 (default-type (or (car gnus-group-web-type-history)
2579 (symbol-name (caar nnweb-type-definition))))
2583 (format "Search engine type (default %s): " default-type)
2584 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2585 nnweb-type-definition)
2586 nil t nil 'gnus-group-web-type-history)
2591 (cons (or (car gnus-group-web-search-history) "") 0)
2592 'gnus-group-web-search-history))
2594 `(nnweb ,group (nnweb-search ,search)
2595 (nnweb-type ,(intern type))
2596 (nnweb-ephemeral-p t))))
2599 (gnus-pull 'nnweb-ephemeral-p method)
2600 (gnus-group-make-group group method))
2601 (gnus-group-read-ephemeral-group
2603 (cons (current-buffer)
2604 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2607 (defvar nnrss-group-alist)
2608 (defun nnrss-discover-feed (arg))
2609 (defun nnrss-save-server-data (arg)))
2610 (defun gnus-group-make-rss-group (&optional url)
2611 "Given a URL, discover if there is an RSS feed.
2612 If there is, use Gnus to create an nnrss group"
2616 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2617 (let ((feedinfo (nnrss-discover-feed url)))
2619 (let ((title (read-from-minibuffer "Title: "
2622 (desc (read-from-minibuffer "Description: "
2623 (cdr (assoc 'description
2625 (href (cdr (assoc 'href feedinfo))))
2626 (push (list title href desc)
2628 (gnus-group-unsubscribe-group
2629 (concat "nnrss:" title))
2630 (nnrss-save-server-data nil))
2631 (error "No feeds found for %s" url))))
2633 (defvar nnwarchive-type-definition)
2634 (defvar gnus-group-warchive-type-history nil)
2635 (defvar gnus-group-warchive-login-history nil)
2636 (defvar gnus-group-warchive-address-history nil)
2638 (defun gnus-group-make-warchive-group ()
2639 "Create a nnwarchive group."
2641 (require 'nnwarchive)
2642 (let* ((group (gnus-read-group "Group name: "))
2643 (default-type (or (car gnus-group-warchive-type-history)
2644 (symbol-name (caar nnwarchive-type-definition))))
2648 (format "Warchive type (default %s): " default-type)
2649 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2650 nnwarchive-type-definition)
2651 nil t nil 'gnus-group-warchive-type-history)
2653 (address (read-string "Warchive address: "
2654 nil 'gnus-group-warchive-address-history))
2655 (default-login (or (car gnus-group-warchive-login-history)
2660 (format "Warchive login (default %s): " user-mail-address)
2661 default-login 'gnus-group-warchive-login-history)
2664 `(nnwarchive ,address
2665 (nnwarchive-type ,(intern type))
2666 (nnwarchive-login ,login))))
2667 (gnus-group-make-group group method)))
2669 (defun gnus-group-make-archive-group (&optional all)
2670 "Create the (ding) Gnus archive group of the most recent articles.
2671 Given a prefix, create a full group."
2673 (let ((group (gnus-group-prefixed-name
2674 (if all "ding.archives" "ding.recent") '(nndir ""))))
2675 (when (gnus-group-entry group)
2676 (error "Archive group already exists"))
2677 (gnus-group-make-group
2678 (gnus-group-real-name group)
2679 (list 'nndir (if all "hpc" "edu")
2680 (list 'nndir-directory
2681 (if all gnus-group-archive-directory
2682 gnus-group-recent-archive-directory))))
2683 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2685 (defun gnus-group-make-directory-group (dir)
2686 "Create an nndir group.
2687 The user will be prompted for a directory. The contents of this
2688 directory will be used as a newsgroup. The directory should contain
2689 mail messages or news articles in files that have numeric names."
2691 (list (read-file-name "Create group from directory: ")))
2692 (unless (file-exists-p dir)
2693 (error "No such directory"))
2694 (unless (file-directory-p dir)
2695 (error "Not a directory"))
2699 (while (or (not group) (gnus-group-entry group))
2701 (gnus-group-prefixed-name
2702 (expand-file-name ext dir)
2704 (setq ext (format "<%d>" (setq i (1+ i)))))
2705 (gnus-group-make-group
2706 (gnus-group-real-name group)
2707 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2709 (defvar nnkiboze-score-file)
2710 (defun gnus-group-make-kiboze-group (group address scores)
2711 "Create an nnkiboze group.
2712 The user will be prompted for a name, a regexp to match groups, and
2713 score file entries for articles to include in the group."
2716 (read-string "nnkiboze group name: ")
2717 (read-string "Source groups (regexp): ")
2718 (let ((headers (mapcar (lambda (group) (list group))
2719 '("subject" "from" "number" "date" "message-id"
2720 "references" "chars" "lines" "xref"
2721 "followup" "all" "body" "head")))
2722 scores header regexp regexps)
2723 (while (not (equal "" (setq header (completing-read
2724 "Match on header: " headers nil t))))
2726 (while (not (equal "" (setq regexp (read-string
2727 (format "Match on %s (regexp): "
2729 (push (list regexp nil nil 'r) regexps))
2730 (push (cons header regexps) scores))
2732 (gnus-group-make-group group "nnkiboze" address)
2733 (let* ((nnkiboze-current-group group)
2734 (score-file (car (nnkiboze-score-file "")))
2735 (score-dir (file-name-directory score-file)))
2736 (unless (file-exists-p score-dir)
2737 (make-directory score-dir))
2738 (with-temp-file score-file
2739 (let (emacs-lisp-mode-hook)
2740 (pp scores (current-buffer))))))
2742 (defun gnus-group-add-to-virtual (n vgroup)
2743 "Add the current group to a virtual group."
2745 (list current-prefix-arg
2746 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2748 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2749 (error "%s is not an nnvirtual group" vgroup))
2750 (gnus-close-group vgroup)
2751 (let* ((groups (gnus-group-process-prefix n))
2752 (method (gnus-info-method (gnus-get-info vgroup))))
2753 (setcar (cdr method)
2755 (nth 1 method) "\\|"
2758 (gnus-group-remove-mark s)
2759 (concat "\\(^" (regexp-quote s) "$\\)"))
2761 (gnus-group-position-point))
2763 (defun gnus-group-make-empty-virtual (group)
2764 "Create a new, fresh, empty virtual group."
2765 (interactive "sCreate new, empty virtual group: ")
2766 (let* ((method (list 'nnvirtual "^$"))
2767 (pgroup (gnus-group-prefixed-name group method)))
2768 ;; Check whether it exists already.
2769 (when (gnus-group-entry pgroup)
2770 (error "Group %s already exists" pgroup))
2771 ;; Subscribe the new group after the group on the current line.
2772 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2773 (gnus-group-update-group pgroup)
2775 (gnus-group-position-point)))
2777 (defun gnus-group-enter-directory (dir)
2778 "Enter an ephemeral nneething group."
2779 (interactive "DDirectory to read: ")
2780 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2781 (leaf (gnus-group-prefixed-name
2782 (file-name-nondirectory (directory-file-name dir))
2784 (name (gnus-generate-new-group-name leaf)))
2785 (unless (gnus-group-read-ephemeral-group
2787 (cons (current-buffer)
2788 (if (eq major-mode 'gnus-summary-mode)
2790 (error "Couldn't enter %s" dir))))
2793 (autoload 'nnimap-expunge "nnimap")
2794 (autoload 'nnimap-acl-get "nnimap")
2795 (autoload 'nnimap-acl-edit "nnimap"))
2797 (defun gnus-group-nnimap-expunge (group)
2798 "Expunge deleted articles in current nnimap GROUP."
2799 (interactive (list (gnus-group-group-name)))
2800 (let ((mailbox (gnus-group-real-name group)) method)
2802 (error "No group on current line"))
2803 (unless (gnus-get-info group)
2804 (error "Killed group; can't be edited"))
2805 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2806 (error "%s is not an nnimap group" group))
2807 (nnimap-expunge mailbox (cadr method))))
2809 (defun gnus-group-nnimap-edit-acl (group)
2810 "Edit the Access Control List of current nnimap GROUP."
2811 (interactive (list (gnus-group-group-name)))
2812 (let ((mailbox (gnus-group-real-name group)) method acl)
2814 (error "No group on current line"))
2815 (unless (gnus-get-info group)
2816 (error "Killed group; can't be edited"))
2817 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2818 (error "%s is not an nnimap group" group))
2819 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2820 (error "Server does not support ACL's"))
2821 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2823 An access control list is a list of (identifier . rights) elements.
2825 The identifier string specifies the corresponding user. The
2826 identifier \"anyone\" is reserved to refer to the universal identity.
2828 Rights is a string listing a (possibly empty) set of alphanumeric
2829 characters, each character listing a set of operations which is being
2830 controlled. Letters are reserved for ``standard'' rights, listed
2831 below. Digits are reserved for implementation or site defined rights.
2833 l - lookup (mailbox is visible to LIST/LSUB commands)
2834 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2835 SEARCH, COPY from mailbox)
2836 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2837 w - write (STORE flags other than \\SEEN and \\DELETED)
2838 i - insert (perform APPEND, COPY into mailbox)
2839 p - post (send mail to submission address for mailbox,
2840 not enforced by IMAP4 itself)
2841 c - create and delete mailbox (CREATE new sub-mailboxes in any
2842 implementation-defined hierarchy, RENAME or DELETE mailbox)
2843 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2844 a - administer (perform SETACL)" group)
2847 ,mailbox ',method ',acl form)))))
2849 ;; Group sorting commands
2850 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2852 (defun gnus-group-sort-groups (func &optional reverse)
2853 "Sort the group buffer according to FUNC.
2854 When used interactively, the sorting function used will be
2855 determined by the `gnus-group-sort-function' variable.
2856 If REVERSE (the prefix), reverse the sorting order."
2857 (interactive (list gnus-group-sort-function current-prefix-arg))
2858 (funcall gnus-group-sort-alist-function
2859 (gnus-make-sort-function func) reverse)
2860 (gnus-group-unmark-all-groups)
2861 (gnus-group-list-groups)
2862 (gnus-dribble-touch))
2864 (defun gnus-group-sort-flat (func reverse)
2865 ;; We peel off the dummy group from the alist.
2867 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2868 (pop gnus-newsrc-alist))
2870 (setq gnus-newsrc-alist
2871 (sort gnus-newsrc-alist func))
2873 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2874 ;; Regenerate the hash table.
2875 (gnus-make-hashtable-from-newsrc-alist)))
2877 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2878 "Sort the group buffer alphabetically by group name.
2879 If REVERSE, sort in reverse order."
2881 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2883 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2884 "Sort the group buffer alphabetically by real (unprefixed) group name.
2885 If REVERSE, sort in reverse order."
2887 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2889 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2890 "Sort the group buffer by number of unread articles.
2891 If REVERSE, sort in reverse order."
2893 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2895 (defun gnus-group-sort-groups-by-level (&optional reverse)
2896 "Sort the group buffer by group level.
2897 If REVERSE, sort in reverse order."
2899 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2901 (defun gnus-group-sort-groups-by-score (&optional reverse)
2902 "Sort the group buffer by group score.
2903 If REVERSE, sort in reverse order."
2905 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2907 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2908 "Sort the group buffer by group rank.
2909 If REVERSE, sort in reverse order."
2911 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2913 (defun gnus-group-sort-groups-by-method (&optional reverse)
2914 "Sort the group buffer alphabetically by back end name.
2915 If REVERSE, sort in reverse order."
2917 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2919 (defun gnus-group-sort-groups-by-server (&optional reverse)
2920 "Sort the group buffer alphabetically by server name.
2921 If REVERSE, sort in reverse order."
2923 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2925 ;;; Selected group sorting.
2927 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2928 "Sort the process/prefixed groups."
2929 (interactive (list current-prefix-arg gnus-group-sort-function))
2930 (let ((groups (gnus-group-process-prefix n)))
2931 (funcall gnus-group-sort-selected-function
2932 groups (gnus-make-sort-function func) reverse)
2933 (gnus-group-unmark-all-groups)
2934 (gnus-group-list-groups)
2935 (gnus-dribble-touch)))
2937 (defun gnus-group-sort-selected-flat (groups func reverse)
2938 (let (entries infos)
2939 ;; First find all the group entries for these groups.
2941 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2943 ;; Then sort the infos.
2947 (lambda (entry) (car entry))
2948 (setq entries (nreverse entries)))
2951 (setq infos (nreverse infos)))
2952 ;; Go through all the infos and replace the old entries
2953 ;; with the new infos.
2955 (setcar (car entries) (pop infos))
2957 ;; Update the hashtable.
2958 (gnus-make-hashtable-from-newsrc-alist)))
2960 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2961 "Sort the group buffer alphabetically by group name.
2962 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2963 sort in reverse order."
2964 (interactive (gnus-interactive "P\ny"))
2965 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2967 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2968 "Sort the group buffer alphabetically by real group name.
2969 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2970 sort in reverse order."
2971 (interactive (gnus-interactive "P\ny"))
2972 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2974 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2975 "Sort the group buffer by number of unread articles.
2976 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2977 sort in reverse order."
2978 (interactive (gnus-interactive "P\ny"))
2979 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2981 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2982 "Sort the group buffer by group level.
2983 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2984 sort in reverse order."
2985 (interactive (gnus-interactive "P\ny"))
2986 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2988 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2989 "Sort the group buffer by group score.
2990 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2991 sort in reverse order."
2992 (interactive (gnus-interactive "P\ny"))
2993 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2995 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2996 "Sort the group buffer by group rank.
2997 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2998 sort in reverse order."
2999 (interactive (gnus-interactive "P\ny"))
3000 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3002 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3003 "Sort the group buffer alphabetically by back end name.
3004 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3005 sort in reverse order."
3006 (interactive (gnus-interactive "P\ny"))
3007 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3009 ;;; Sorting predicates.
3011 (defun gnus-group-sort-by-alphabet (info1 info2)
3012 "Sort alphabetically."
3013 (string< (gnus-info-group info1) (gnus-info-group info2)))
3015 (defun gnus-group-sort-by-real-name (info1 info2)
3016 "Sort alphabetically on real (unprefixed) names."
3017 (string< (gnus-group-real-name (gnus-info-group info1))
3018 (gnus-group-real-name (gnus-info-group info2))))
3020 (defun gnus-group-sort-by-unread (info1 info2)
3021 "Sort by number of unread articles."
3022 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3023 (n2 (gnus-group-unread (gnus-info-group info1))))
3024 (< (or (and (numberp n1) n1) 0)
3025 (or (and (numberp n2) n2) 0))))
3027 (defun gnus-group-sort-by-level (info1 info2)
3029 (< (gnus-info-level info1) (gnus-info-level info2)))
3031 (defun gnus-group-sort-by-method (info1 info2)
3032 "Sort alphabetically by back end name."
3033 (string< (car (gnus-find-method-for-group
3034 (gnus-info-group info1) info1))
3035 (car (gnus-find-method-for-group
3036 (gnus-info-group info2) info2))))
3038 (defun gnus-group-sort-by-server (info1 info2)
3039 "Sort alphabetically by server name."
3040 (string< (gnus-method-to-full-server-name
3041 (gnus-find-method-for-group
3042 (gnus-info-group info1) info1))
3043 (gnus-method-to-full-server-name
3044 (gnus-find-method-for-group
3045 (gnus-info-group info2) info2))))
3047 (defun gnus-group-sort-by-score (info1 info2)
3048 "Sort by group score."
3049 (> (gnus-info-score info1) (gnus-info-score info2)))
3051 (defun gnus-group-sort-by-rank (info1 info2)
3052 "Sort by level and score."
3053 (let ((level1 (gnus-info-level info1))
3054 (level2 (gnus-info-level info2)))
3055 (or (< level1 level2)
3056 (and (= level1 level2)
3057 (> (gnus-info-score info1) (gnus-info-score info2))))))
3061 (defun gnus-group-clear-data (&optional arg)
3062 "Clear all marks and read ranges from the current group."
3064 (gnus-group-iterate arg
3067 (gnus-info-clear-data (setq info (gnus-get-info group)))
3068 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3069 (when (gnus-group-goto-group group)
3070 (gnus-group-update-group-line))))))
3072 (defun gnus-group-clear-data-on-native-groups ()
3073 "Clear all marks and read ranges from all native groups."
3075 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3076 (let ((alist (cdr gnus-newsrc-alist))
3078 (while (setq info (pop alist))
3079 (when (gnus-group-native-p (gnus-info-group info))
3080 (gnus-info-clear-data info)))
3081 (gnus-get-unread-articles)
3082 (gnus-dribble-touch)
3083 (when (gnus-y-or-n-p
3084 "Move the cache away to avoid problems in the future? ")
3085 (call-interactively 'gnus-cache-move-cache)))))
3087 (defun gnus-info-clear-data (info)
3088 "Clear all marks and read ranges from INFO."
3089 (let ((group (gnus-info-group info))
3091 (dolist (el (gnus-info-marks info))
3092 (push `(,(cdr el) add (,(car el))) action))
3093 (push `(,(gnus-info-read info) add (read)) action)
3096 (gnus-request-set-mark ,group ',action)
3097 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3098 (gnus-info-set-read ',info ',(gnus-info-read info))
3099 (when (gnus-group-goto-group ,group)
3100 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3101 (gnus-group-update-group-line))))
3102 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3104 (gnus-request-set-mark group action)
3105 (gnus-info-set-read info nil)
3106 (when (gnus-info-marks info)
3107 (gnus-info-set-marks info nil))))
3109 ;; Group catching up.
3111 (defun gnus-group-catchup-current (&optional n all)
3112 "Mark all unread articles in the current newsgroup as read.
3113 If prefix argument N is numeric, the next N newsgroups will be
3114 caught up. If ALL is non-nil, marked articles will also be marked as
3115 read. Cross references (Xref: header) of articles are ignored.
3116 The number of newsgroups that this function was unable to catch
3119 (let ((groups (gnus-group-process-prefix n))
3122 (unless groups (error "No groups selected"))
3124 (or (not gnus-interactive-catchup) ;Without confirmation?
3129 "Do you really want to mark all articles in %s as read? "
3130 "Mark all unread articles in %s as read? ")
3131 (if (= (length groups) 1)
3133 (format "these %d groups" (length groups)))))))
3135 (while (setq group (pop groups))
3136 (gnus-group-remove-mark group)
3137 ;; Virtual groups have to be given special treatment.
3138 (let ((method (gnus-find-method-for-group group)))
3139 (when (eq 'nnvirtual (car method))
3140 (nnvirtual-catchup-group
3141 (gnus-group-real-name group) (nth 1 method) all)))
3142 (if (>= (gnus-group-level group) gnus-level-zombie)
3143 (gnus-message 2 "Dead groups can't be caught up")
3145 (gnus-group-goto-group group)
3146 (gnus-group-catchup group all))
3147 (gnus-group-update-group-line)
3148 (setq ret (1+ ret)))))
3149 (gnus-group-next-unread-group 1)
3152 (defun gnus-group-catchup-current-all (&optional n)
3153 "Mark all articles in current newsgroup as read.
3154 Cross references (Xref: header) of articles are ignored."
3156 (gnus-group-catchup-current n 'all))
3158 (defun gnus-group-catchup (group &optional all)
3159 "Mark all articles in GROUP as read.
3160 If ALL is non-nil, all articles are marked as read.
3161 The return value is the number of articles that were marked as read,
3162 or nil if no action could be taken."
3163 (let* ((entry (gnus-group-entry group))
3165 (marks (gnus-info-marks (nth 2 entry)))
3166 (unread (gnus-sequence-of-unread-articles group)))
3167 ;; Remove entries for this group.
3168 (nnmail-purge-split-history (gnus-group-real-name group))
3169 ;; Do the updating only if the newsgroup isn't killed.
3170 (if (not (numberp (car entry)))
3171 (gnus-message 1 "Can't catch up %s; non-active group" group)
3172 (gnus-update-read-articles group nil)
3174 ;; Nix out the lists of marks and dormants.
3175 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3177 (list (cdr (assq 'dormant marks))
3179 (setq unread (gnus-range-add (gnus-range-add
3180 unread (cdr (assq 'dormant marks)))
3181 (cdr (assq 'tick marks))))
3182 (gnus-add-marked-articles group 'tick nil nil 'force)
3183 (gnus-add-marked-articles group 'dormant nil nil 'force))
3184 ;; Do auto-expirable marks if that's required.
3185 (when (gnus-group-auto-expirable-p group)
3186 (gnus-range-map (lambda (article)
3187 (gnus-add-marked-articles group 'expire (list article))
3188 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3190 (let ((gnus-newsgroup-name group))
3191 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3194 (defun gnus-group-expire-articles (&optional n)
3195 "Expire all expirable articles in the current newsgroup.
3196 Uses the process/prefix convention."
3198 (let ((groups (gnus-group-process-prefix n))
3201 (error "No groups to expire"))
3202 (while (setq group (pop groups))
3203 (gnus-group-remove-mark group)
3204 (gnus-group-expire-articles-1 group)
3205 (gnus-dribble-touch)
3206 (gnus-group-position-point))))
3208 (defun gnus-group-expire-articles-1 (group)
3209 (when (gnus-check-backend-function 'request-expire-articles group)
3210 (gnus-message 6 "Expiring articles in %s..." group)
3211 (let* ((info (gnus-get-info group))
3212 (expirable (if (gnus-group-total-expirable-p group)
3213 (cons nil (gnus-list-of-read-articles group))
3214 (assq 'expire (gnus-info-marks info))))
3215 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3216 (nnmail-expiry-target
3217 (or (gnus-group-find-parameter group 'expiry-target)
3218 nnmail-expiry-target)))
3220 (gnus-check-group group)
3223 (gnus-compress-sequence
3225 ;; We set the expiry variables to the group
3227 (let ((nnmail-expiry-wait-function nil)
3228 (nnmail-expiry-wait expiry-wait))
3229 (gnus-request-expire-articles
3230 (gnus-uncompress-sequence (cdr expirable)) group))
3231 ;; Just expire using the normal expiry values.
3232 (gnus-request-expire-articles
3233 (gnus-uncompress-sequence (cdr expirable)) group))))
3234 (gnus-close-group group))
3235 (gnus-message 6 "Expiring articles in %s...done" group)
3236 ;; Return the list of un-expired articles.
3239 (defun gnus-group-expire-all-groups ()
3240 "Expire all expirable articles in all newsgroups."
3243 (gnus-message 5 "Expiring...")
3244 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3245 (cdr gnus-newsrc-alist))))
3246 (gnus-group-expire-articles nil)))
3247 (gnus-group-position-point)
3248 (gnus-message 5 "Expiring...done"))
3250 (defun gnus-group-set-current-level (n level)
3251 "Set the level of the next N groups to LEVEL."
3256 (unless (gnus-group-process-prefix current-prefix-arg)
3257 (error "No group on the current line"))
3259 (let ((s (read-string
3260 (format "Level (default %s): "
3261 (or (gnus-group-group-level)
3262 gnus-level-default-subscribed)))))
3263 (if (string-match "^\\s-*$" s)
3264 (int-to-string (or (gnus-group-group-level)
3265 gnus-level-default-subscribed))
3267 (unless (and (>= level 1) (<= level gnus-level-killed))
3268 (error "Invalid level: %d" level))
3269 (let ((groups (gnus-group-process-prefix n))
3271 (while (setq group (pop groups))
3272 (gnus-group-remove-mark group)
3273 (gnus-message 6 "Changed level of %s from %d to %d"
3274 group (or (gnus-group-group-level) gnus-level-killed)
3276 (gnus-group-change-level
3277 group level (or (gnus-group-group-level) gnus-level-killed))
3278 (gnus-group-update-group-line)))
3279 (gnus-group-position-point))
3281 (defun gnus-group-unsubscribe (&optional n)
3282 "Unsubscribe the current group."
3284 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3286 (defun gnus-group-subscribe (&optional n)
3287 "Subscribe the current group."
3289 (gnus-group-unsubscribe-current-group n 'subscribe))
3291 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3292 "Toggle subscription of the current group.
3293 If given numerical prefix, toggle the N next groups."
3295 (dolist (group (gnus-group-process-prefix n))
3296 (gnus-group-remove-mark group)
3297 (gnus-group-unsubscribe-group
3300 ((eq do-sub 'unsubscribe)
3301 gnus-level-default-unsubscribed)
3302 ((eq do-sub 'subscribe)
3303 gnus-level-default-subscribed)
3304 ((<= (gnus-group-group-level) gnus-level-subscribed)
3305 gnus-level-default-unsubscribed)
3307 gnus-level-default-subscribed))
3309 (gnus-group-update-group-line))
3310 (gnus-group-next-group 1))
3312 (defun gnus-group-unsubscribe-group (group &optional level silent)
3313 "Toggle subscription to GROUP.
3314 Killed newsgroups are subscribed. If SILENT, don't try to update the
3317 (list (gnus-group-completing-read-group-name
3318 "Group: " gnus-active-hashtb nil
3319 (gnus-read-active-file-p)
3321 'gnus-group-history)))
3322 (let ((newsrc (gnus-group-entry group)))
3324 ((string-match "^[ \t]*$" group)
3325 (error "Empty group name"))
3327 ;; Toggle subscription flag.
3328 (gnus-group-change-level
3329 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3330 gnus-level-subscribed)
3331 (1+ gnus-level-subscribed)
3332 gnus-level-default-subscribed)))
3334 (gnus-group-update-group group)))
3335 ((and (stringp group)
3336 (or (not (gnus-read-active-file-p))
3337 (gnus-active group)))
3338 ;; Add new newsgroup.
3339 (gnus-group-change-level
3341 (if level level gnus-level-default-subscribed)
3342 (or (and (member group gnus-zombie-list)
3345 (when (gnus-group-group-name)
3346 (gnus-group-entry (gnus-group-group-name))))
3348 (gnus-group-update-group group)))
3349 (t (error "No such newsgroup: %s" group)))
3350 (gnus-group-position-point)))
3352 (defun gnus-group-transpose-groups (n)
3353 "Move the current newsgroup up N places.
3354 If given a negative prefix, move down instead. The difference between
3355 N and the number of steps taken is returned."
3357 (unless (gnus-group-group-name)
3358 (error "No group on current line"))
3359 (gnus-group-kill-group 1)
3361 (forward-line (- n))
3362 (gnus-group-yank-group)
3363 (gnus-group-position-point)))
3365 (defun gnus-group-kill-all-zombies (&optional dummy)
3366 "Kill all zombie newsgroups.
3367 The optional DUMMY should always be nil."
3368 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3370 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3371 (setq gnus-zombie-list nil)
3372 (gnus-dribble-touch)
3373 (gnus-group-list-groups)))
3375 (defun gnus-group-kill-region (begin end)
3376 "Kill newsgroups in current region (excluding current point).
3377 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3392 (beginning-of-line) ;Important when LINES < 1
3393 (gnus-group-kill-group lines)))
3395 (defun gnus-group-kill-group (&optional n discard)
3396 "Kill the next N groups.
3397 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3398 However, only groups that were alive can be yanked; already killed
3399 groups or zombie groups can't be yanked.
3400 The return value is the name of the group that was killed, or a list
3403 (let ((buffer-read-only nil)
3404 (groups (gnus-group-process-prefix n))
3405 group entry level out)
3406 (if (< (length groups) 10)
3407 ;; This is faster when there are few groups.
3409 (push (setq group (pop groups)) out)
3410 (gnus-group-remove-mark group)
3411 (setq level (gnus-group-group-level))
3413 (when (and (not discard)
3414 (setq entry (gnus-group-entry group)))
3417 (gnus-group-goto-group ,(gnus-group-group-name))
3418 (gnus-group-yank-group)))
3419 (push (cons (car entry) (nth 2 entry))
3420 gnus-list-of-killed-groups))
3421 (gnus-group-change-level
3422 (if entry entry group) gnus-level-killed (if entry nil level))
3423 (message "Killed group %s" group))
3424 ;; If there are lots and lots of groups to be killed, we use
3425 ;; this thing instead.
3426 (dolist (group (nreverse groups))
3427 (gnus-group-remove-mark group)
3429 (push group gnus-killed-list)
3430 (setq gnus-newsrc-alist
3431 (delq (assoc group gnus-newsrc-alist)
3433 (when gnus-group-change-level-function
3434 (funcall gnus-group-change-level-function
3435 group gnus-level-killed 3))
3437 ((setq entry (gnus-group-entry group))
3438 (push (cons (car entry) (nth 2 entry))
3439 gnus-list-of-killed-groups)
3440 (setcdr (cdr entry) (cdddr entry)))
3441 ((member group gnus-zombie-list)
3442 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3443 ;; There may be more than one instance displayed.
3444 (while (gnus-group-goto-group group)
3445 (gnus-delete-line)))
3446 (gnus-make-hashtable-from-newsrc-alist))
3448 (gnus-group-position-point)
3449 (if (< (length out) 2) (car out) (nreverse out))))
3451 (defun gnus-group-yank-group (&optional arg)
3452 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3453 The numeric ARG specifies how many newsgroups are to be yanked. The
3454 name of the newsgroup yanked is returned, or (if several groups are
3455 yanked) a list of yanked groups is returned."
3457 (setq arg (or arg 1))
3458 (let (info group prev out)
3459 (while (>= (decf arg) 0)
3460 (when (not (setq info (pop gnus-list-of-killed-groups)))
3461 (error "No more newsgroups to yank"))
3462 (push (setq group (nth 1 info)) out)
3463 ;; Find which newsgroup to insert this one before - search
3464 ;; backward until something suitable is found. If there are no
3465 ;; other newsgroups in this buffer, just make this newsgroup the
3467 (setq prev (gnus-group-group-name))
3468 (gnus-group-change-level
3469 info (gnus-info-level (cdr info)) gnus-level-killed
3470 (and prev (gnus-group-entry prev))
3472 (gnus-group-insert-group-line-info group)
3474 `(when (gnus-group-goto-group ,group)
3475 (gnus-group-kill-group 1))))
3477 (gnus-group-position-point)
3478 (if (< (length out) 2) (car out) (nreverse out))))
3480 (defun gnus-group-kill-level (level)
3481 "Kill all groups that is on a certain LEVEL."
3482 (interactive "nKill all groups on level: ")
3484 ((= level gnus-level-zombie)
3485 (setq gnus-killed-list
3486 (nconc gnus-zombie-list gnus-killed-list))
3487 (setq gnus-zombie-list nil))
3488 ((and (< level gnus-level-zombie)
3490 (or gnus-expert-user
3493 "Do you really want to kill all groups on level %d? "
3495 (let* ((prev gnus-newsrc-alist)
3498 (if (= (gnus-info-level (car alist)) level)
3500 (push (gnus-info-group (car alist)) gnus-killed-list)
3501 (setcdr prev (cdr alist)))
3503 (setq alist (cdr alist)))
3504 (gnus-make-hashtable-from-newsrc-alist)
3505 (gnus-group-list-groups)))
3507 (error "Can't kill; invalid level: %d" level))))
3509 (defun gnus-group-list-all-groups (&optional arg)
3510 "List all newsgroups with level ARG or lower.
3511 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3512 unsubscribed groups."
3514 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3516 ;; Redefine this to list ALL killed groups if prefix arg used.
3517 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3518 (defun gnus-group-list-killed (&optional arg)
3519 "List all killed newsgroups in the group buffer.
3520 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3521 entail asking the server for the groups."
3523 ;; Find all possible killed newsgroups if arg.
3525 (gnus-get-killed-groups))
3526 (if (not gnus-killed-list)
3527 (gnus-message 6 "No killed groups")
3528 (let (gnus-group-list-mode)
3529 (funcall gnus-group-prepare-function
3530 gnus-level-killed t gnus-level-killed))
3531 (goto-char (point-min)))
3532 (gnus-group-position-point))
3534 (defun gnus-group-list-zombies ()
3535 "List all zombie newsgroups in the group buffer."
3537 (if (not gnus-zombie-list)
3538 (gnus-message 6 "No zombie groups")
3539 (let (gnus-group-list-mode)
3540 (funcall gnus-group-prepare-function
3541 gnus-level-zombie t gnus-level-zombie))
3542 (goto-char (point-min)))
3543 (gnus-group-position-point))
3545 (defun gnus-group-list-active ()
3546 "List all groups that are available from the server(s)."
3548 ;; First we make sure that we have really read the active file.
3549 (unless (gnus-read-active-file-p)
3550 (let ((gnus-read-active-file t)
3551 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3552 (gnus-read-active-file)))
3553 ;; Find all groups and sort them.
3561 (push (symbol-name sym) list)))
3565 (buffer-read-only nil)
3569 (setq group (pop groups))
3570 (gnus-add-text-properties
3571 (point) (prog1 (1+ (point))
3573 (gnus-group-decoded-name group)
3575 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3577 'gnus-level (inline (gnus-group-level group)))))
3578 (goto-char (point-min))))
3580 (defun gnus-activate-all-groups (level)
3581 "Activate absolutely all groups."
3582 (interactive (list gnus-level-unsubscribed))
3583 (let ((gnus-activate-level level)
3584 (gnus-activate-foreign-newsgroups level))
3585 (gnus-group-get-new-news)))
3587 (defun gnus-group-get-new-news (&optional arg)
3588 "Get newly arrived articles.
3589 If ARG is a number, it specifies which levels you are interested in
3590 re-scanning. If ARG is non-nil and not a number, this will force
3591 \"hard\" re-reading of the active files from all servers."
3594 (let ((gnus-inhibit-demon t)
3595 ;; Binding this variable will inhibit multiple fetchings
3596 ;; of the same mail source.
3597 (nnmail-fetched-sources (list t)))
3598 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3599 (gnus-run-hooks 'gnus-get-new-news-hook)
3601 ;; Read any slave files.
3603 (gnus-master-read-slave-newsrc))
3605 ;; We might read in new NoCeM messages here.
3606 (when (and gnus-use-nocem
3608 (gnus-nocem-scan-groups))
3609 ;; If ARG is not a number, then we read the active file.
3610 (when (and arg (not (numberp arg)))
3611 (let ((gnus-read-active-file t))
3612 (gnus-read-active-file))
3615 ;; If the user wants it, we scan for new groups.
3616 (when (eq gnus-check-new-newsgroups 'always)
3617 (gnus-find-new-newsgroups)))
3619 (setq arg (gnus-group-default-level arg t))
3620 (if (and gnus-read-active-file (not arg))
3622 (gnus-read-active-file)
3623 (gnus-get-unread-articles arg))
3624 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3625 (gnus-get-unread-articles arg)))
3626 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3627 (gnus-group-list-groups (and (numberp arg)
3628 (max (car gnus-group-list-mode) arg))))
3630 (when (and gnus-agent (not (interactive-p)))
3631 (gnus-agent-toggle-plugged gnus-plugged)))
3633 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3634 "Check for newly arrived news in the current group (and the N-1 next groups).
3635 The difference between N and the number of newsgroup checked is returned.
3636 If N is negative, this group and the N-1 previous groups will be checked."
3638 (let* ((groups (gnus-group-process-prefix n))
3639 (ret (if (numberp n) (- n (length groups)) 0))
3643 (gnus-inhibit-demon t)
3644 ;; Binding this variable will inhibit multiple fetchings
3645 ;; of the same mail source.
3646 (nnmail-fetched-sources (list t)))
3647 (gnus-run-hooks 'gnus-get-new-news-hook)
3648 (while (setq group (pop groups))
3649 (gnus-group-remove-mark group)
3650 ;; Bypass any previous denials from the server.
3651 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3652 (if (gnus-activate-group group (if dont-scan nil 'scan))
3654 (gnus-get-unread-articles-in-group
3655 (gnus-get-info group) (gnus-active group) t)
3656 (unless (gnus-virtual-group-p group)
3657 (gnus-close-group group))
3659 (gnus-agent-save-group-info
3660 method (gnus-group-real-name group) (gnus-active group)))
3661 (gnus-group-update-group group))
3662 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3664 (gnus-error 3 "Server denied access")
3665 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3668 (when gnus-goto-next-group-when-activating
3669 (gnus-group-next-unread-group 1 t))
3670 (gnus-summary-position-point)
3673 (defun gnus-group-fetch-faq (group &optional faq-dir)
3674 "Fetch the FAQ for the current group.
3675 If given a prefix argument, prompt for the FAQ dir
3679 (gnus-group-group-name)
3680 (when current-prefix-arg
3682 "FAQ dir: " (and (listp gnus-group-faq-directory)
3684 gnus-group-faq-directory))))))
3686 (error "No group name given"))
3687 (let ((dirs (or faq-dir gnus-group-faq-directory))
3689 (unless (listp dirs)
3690 (setq dirs (list dirs)))
3691 (while (and (not found)
3692 (setq dir (pop dirs)))
3693 (let ((name (gnus-group-real-name group)))
3694 (setq file (expand-file-name name dir)))
3695 (if (not (file-exists-p file))
3696 (gnus-message 1 "No such file: %s" file)
3697 (let ((enable-local-variables nil))
3701 (defun gnus-group-fetch-charter (group)
3702 "Fetch the charter for the current group.
3703 If given a prefix argument, prompt for a group."
3705 (list (or (when current-prefix-arg
3706 (completing-read "Group: " gnus-active-hashtb))
3707 (gnus-group-group-name)
3708 gnus-newsgroup-name)))
3710 (error "No group name given"))
3712 (condition-case nil (require 'url-http) (error nil))
3713 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3715 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3716 (setq hierarchy (match-string 1 name))
3717 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3718 (if (fboundp 'url-http-file-exists-p)
3719 (url-http-file-exists-p (eval url))
3721 (browse-url (eval url))
3722 (setq url (concat "http://" hierarchy
3723 ".news-admin.org/charters/" name))
3724 (if (and (fboundp 'url-http-file-exists-p)
3725 (url-http-file-exists-p url))
3727 (gnus-group-fetch-control group))))))
3729 (defun gnus-group-fetch-control (group)
3730 "Fetch the archived control messages for the current group.
3731 If given a prefix argument, prompt for a group."
3733 (list (or (when current-prefix-arg
3734 (completing-read "Group: " gnus-active-hashtb))
3735 (gnus-group-group-name)
3736 gnus-newsgroup-name)))
3738 (error "No group name given"))
3739 (let ((name (gnus-group-real-name group))
3741 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3742 (setq hierarchy (match-string 1 name))
3743 (if gnus-group-fetch-control-use-browse-url
3744 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3745 hierarchy "/" name ".gz"))
3746 (let ((enable-local-variables nil))
3747 (gnus-group-read-ephemeral-group
3749 `(nndoc ,group (nndoc-address
3750 ,(find-file-noselect
3751 (concat "/ftp@ftp.isc.org:/usenet/control/"
3752 hierarchy "/" name ".gz")))
3753 (nndoc-article-type mbox)) t nil nil))))))
3755 (defun gnus-group-describe-group (force &optional group)
3756 "Display a description of the current newsgroup."
3757 (interactive (list current-prefix-arg (gnus-group-group-name)))
3758 (let* ((method (gnus-find-method-for-group group))
3759 (mname (gnus-group-prefixed-name "" method))
3762 gnus-description-hashtb)
3763 (gnus-sethash mname nil gnus-description-hashtb))
3765 (error "No group name given"))
3766 (when (or (and gnus-description-hashtb
3767 ;; We check whether this group's method has been
3768 ;; queried for a description file.
3769 (gnus-gethash mname gnus-description-hashtb))
3770 (setq desc (gnus-group-get-description group))
3771 (gnus-read-descriptions-file method))
3773 (or desc (gnus-gethash group gnus-description-hashtb)
3774 "No description available")))))
3776 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3777 (defun gnus-group-describe-all-groups (&optional force)
3778 "Pop up a buffer with descriptions of all newsgroups."
3781 (setq gnus-description-hashtb nil))
3782 (when (not (or gnus-description-hashtb
3783 (gnus-read-all-descriptions-files)))
3784 (error "Couldn't request descriptions file"))
3785 (let ((buffer-read-only nil)
3791 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3792 (insert (format " *: %-20s %s\n"
3793 (gnus-group-name-decode
3794 (symbol-name group) charset)
3795 (gnus-group-name-decode
3796 (symbol-value group) charset))))
3797 (gnus-add-text-properties
3798 b (1+ b) (list 'gnus-group group
3799 'gnus-unread t 'gnus-marked nil
3800 'gnus-level (1+ gnus-level-subscribed))))
3801 gnus-description-hashtb)
3802 (goto-char (point-min))
3803 (gnus-group-position-point)))
3805 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3806 (defun gnus-group-apropos (regexp &optional search-description)
3807 "List all newsgroups that have names that match a regexp."
3808 (interactive "sGnus apropos (regexp): ")
3810 (obuf (current-buffer))
3812 ;; Go through all newsgroups that are known to Gnus.
3815 (and (symbol-name group)
3816 (string-match regexp (symbol-name group))
3817 (symbol-value group)
3818 (push (symbol-name group) groups)))
3820 ;; Also go through all descriptions that are known to Gnus.
3821 (when search-description
3824 (and (string-match regexp (symbol-value group))
3825 (push (symbol-name group) groups)))
3826 gnus-description-hashtb))
3828 (gnus-message 3 "No groups matched \"%s\"." regexp)
3829 ;; Print out all the groups.
3831 (pop-to-buffer "*Gnus Help*")
3832 (buffer-disable-undo)
3834 (setq groups (sort groups 'string<))
3836 ;; Groups may be entered twice into the list of groups.
3837 (when (not (string= (car groups) prev))
3838 (setq prev (car groups))
3839 (let ((charset (gnus-group-name-charset nil prev)))
3840 (insert (gnus-group-name-decode prev charset) "\n")
3841 (when (and gnus-description-hashtb
3842 (setq des (gnus-gethash (car groups)
3843 gnus-description-hashtb)))
3844 (insert " " (gnus-group-name-decode des charset) "\n"))))
3845 (setq groups (cdr groups)))
3846 (goto-char (point-min))))
3847 (pop-to-buffer obuf)))
3849 (defun gnus-group-description-apropos (regexp)
3850 "List all newsgroups that have names or descriptions that match REGEXP."
3851 (interactive "sGnus description apropos (regexp): ")
3852 (when (not (or gnus-description-hashtb
3853 (gnus-read-all-descriptions-files)))
3854 (error "Couldn't request descriptions file"))
3855 (gnus-group-apropos regexp t))
3857 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3858 (defun gnus-group-list-matching (level regexp &optional all lowest)
3859 "List all groups with unread articles that match REGEXP.
3860 If the prefix LEVEL is non-nil, it should be a number that says which
3861 level to cut off listing groups.
3862 If ALL, also list groups with no unread articles.
3863 If LOWEST, don't list groups with level lower than LOWEST.
3865 This command may read the active file."
3866 (interactive "P\nsList newsgroups matching: ")
3867 ;; First make sure active file has been read.
3869 (> (prefix-numeric-value level) gnus-level-killed))
3870 (gnus-get-killed-groups))
3871 (funcall gnus-group-prepare-function
3872 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3873 (goto-char (point-min))
3874 (gnus-group-position-point))
3876 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3877 "List all groups that match REGEXP.
3878 If the prefix LEVEL is non-nil, it should be a number that says which
3879 level to cut off listing groups.
3880 If LOWEST, don't list groups with level lower than LOWEST."
3881 (interactive "P\nsList newsgroups matching: ")
3883 (setq level (prefix-numeric-value level)))
3884 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3886 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3887 (defun gnus-group-save-newsrc (&optional force)
3888 "Save the Gnus startup files.
3889 If FORCE, force saving whether it is necessary or not."
3891 (gnus-save-newsrc-file force))
3893 (defun gnus-group-restart (&optional arg)
3894 "Force Gnus to read the .newsrc file."
3896 (when (gnus-yes-or-no-p
3897 (format "Are you sure you want to restart Gnus? "))
3898 (gnus-save-newsrc-file)
3902 (defun gnus-group-read-init-file ()
3903 "Read the Gnus elisp init file."
3905 (gnus-read-init-file)
3906 (gnus-message 5 "Read %s" gnus-init-file))
3908 (defun gnus-group-check-bogus-groups (&optional silent)
3909 "Check bogus newsgroups.
3910 If given a prefix, don't ask for confirmation before removing a bogus
3913 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3914 (gnus-group-list-groups))
3916 (defun gnus-group-find-new-groups (&optional arg)
3917 "Search for new groups and add them.
3918 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3919 With 1 C-u, use the `ask-server' method to query the server for new
3921 With 2 C-u's, use most complete method possible to query the server
3922 for new groups, and subscribe the new groups as zombies."
3924 (gnus-find-new-newsgroups (or arg 1))
3925 (gnus-group-list-groups))
3927 (defun gnus-group-edit-global-kill (&optional article group)
3928 "Edit the global kill file.
3929 If GROUP, edit that local kill file instead."
3931 (setq gnus-current-kill-article article)
3932 (gnus-kill-file-edit-file group)
3935 (substitute-command-keys
3936 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3937 (if group "local" "global")))))
3939 (defun gnus-group-edit-local-kill (article group)
3940 "Edit a local kill file."
3941 (interactive (list nil (gnus-group-group-name)))
3942 (gnus-group-edit-global-kill article group))
3944 (defun gnus-group-force-update ()
3945 "Update `.newsrc' file."
3947 (gnus-save-newsrc-file))
3949 (defvar gnus-backlog-articles)
3951 (defun gnus-group-suspend ()
3952 "Suspend the current Gnus session.
3953 In fact, cleanup buffers except for group mode buffer.
3954 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3956 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3957 (gnus-offer-save-summaries)
3958 ;; Kill Gnus buffers except for group mode buffer.
3959 (let ((group-buf (get-buffer gnus-group-buffer)))
3960 (mapcar (lambda (buf)
3961 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3965 (eq major-mode 'message-mode))))
3966 (gnus-kill-buffer buf)))
3968 (setq gnus-backlog-articles nil)
3969 (gnus-kill-gnus-frames)
3971 (bury-buffer group-buf)
3972 (delete-windows-on group-buf t))))
3974 (defun gnus-group-clear-dribble ()
3975 "Clear all information from the dribble buffer."
3977 (gnus-dribble-clear)
3978 (gnus-message 7 "Cleared dribble buffer"))
3980 (defun gnus-group-exit ()
3981 "Quit reading news after updating .newsrc.eld and .newsrc.
3982 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3985 (or noninteractive ;For gnus-batch-kill
3986 (not gnus-interactive-exit) ;Without confirmation
3988 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3989 (gnus-run-hooks 'gnus-exit-gnus-hook)
3990 ;; Offer to save data from non-quitted summary buffers.
3991 (gnus-offer-save-summaries)
3992 ;; Save the newsrc file(s).
3993 (gnus-save-newsrc-file)
3995 (gnus-close-backends)
3996 ;; Reset everything.
3998 ;; Allow the user to do things after cleaning up.
3999 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4001 (defun gnus-group-quit ()
4002 "Quit reading news without updating .newsrc.eld or .newsrc.
4003 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4005 (when (or noninteractive ;For gnus-batch-kill
4006 (zerop (buffer-size))
4007 (not (gnus-server-opened gnus-select-method))
4009 (not gnus-current-startup-file)
4011 (format "Quit reading news without saving %s? "
4012 (file-name-nondirectory gnus-current-startup-file))))
4013 (gnus-run-hooks 'gnus-exit-gnus-hook)
4014 (gnus-configure-windows 'group t)
4015 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4016 (not (zerop (save-excursion
4017 (set-buffer gnus-dribble-buffer)
4020 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4022 (gnus-close-backends)
4024 (gnus-kill-buffer gnus-group-buffer)
4025 ;; Allow the user to do things after cleaning up.
4026 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4028 (defun gnus-group-describe-briefly ()
4029 "Give a one line description of the group mode commands."
4031 (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")))
4033 (defun gnus-group-browse-foreign-server (method)
4034 "Browse a foreign news server.
4035 If called interactively, this function will ask for a select method
4036 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4037 If not, METHOD should be a list where the first element is the method
4038 and the second element is the address."
4040 (list (let ((how (completing-read
4042 (append gnus-valid-select-methods gnus-server-alist)
4043 nil t (cons "nntp" 0) 'gnus-method-history)))
4044 ;; We either got a back end name or a virtual server name.
4045 ;; If the first, we also need an address.
4046 (if (assoc how gnus-valid-select-methods)
4048 ;; Suggested by mapjph@bath.ac.uk.
4051 (mapcar (lambda (server) (list server))
4052 gnus-secondary-servers)))
4053 ;; We got a server name.
4055 (gnus-browse-foreign-server method))
4057 (defun gnus-group-set-info (info &optional method-only-group part)
4058 (when (or info part)
4059 (let* ((entry (gnus-group-entry
4060 (or method-only-group (gnus-info-group info))))
4062 (info (if method-only-group (nth 2 entry) info))
4064 (when method-only-group
4066 (error "Trying to change non-existent group %s" method-only-group))
4067 ;; We have received parts of the actual group info - either the
4068 ;; select method or the group parameters. We first check
4069 ;; whether we have to extend the info, and if so, do that.
4070 (let ((len (length info))
4071 (total (if (eq part 'method) 5 6)))
4073 (setcdr (nthcdr (1- len) info)
4074 (make-list (- total len) nil)))
4075 ;; Then we enter the new info.
4076 (setcar (nthcdr (1- total) info) part-info)))
4078 ;; This is a new group, so we just create it.
4080 (set-buffer gnus-group-buffer)
4081 (setq method (gnus-info-method info))
4082 (when (gnus-server-equal method "native")
4085 (set-buffer gnus-group-buffer)
4087 ;; It's a foreign group...
4088 (gnus-group-make-group
4089 (gnus-group-real-name (gnus-info-group info))
4090 (if (stringp method) method
4091 (prin1-to-string (car method)))
4093 (nth 1 (gnus-info-method info))))
4094 ;; It's a native group.
4095 (gnus-group-make-group (gnus-info-group info))))
4096 (gnus-message 6 "Note: New group created")
4098 (gnus-group-entry (gnus-group-prefixed-name
4099 (gnus-group-real-name (gnus-info-group info))
4100 (or (gnus-info-method info) gnus-select-method))))))
4101 ;; Whether it was a new group or not, we now have the entry, so we
4102 ;; can do the update.
4105 (setcar (nthcdr 2 entry) info)
4106 (when (and (not (eq (car entry) t))
4107 (gnus-active (gnus-info-group info)))
4108 (setcar entry (length
4109 (gnus-list-of-unread-articles (car info))))))
4110 (error "No such group: %s" (gnus-info-group info))))))
4112 (defun gnus-group-set-method-info (group select-method)
4113 (gnus-group-set-info select-method group 'method))
4115 (defun gnus-group-set-params-info (group params)
4116 (gnus-group-set-info params group 'params))
4118 (defun gnus-add-marked-articles (group type articles &optional info force)
4119 ;; Add ARTICLES of TYPE to the info of GROUP.
4120 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4121 ;; add, but replace marked articles of TYPE with ARTICLES.
4122 (let ((info (or info (gnus-get-info group)))
4125 (and (not (setq marked (nthcdr 3 info)))
4127 (setcdr (nthcdr 2 info)
4128 (list (list (cons type (gnus-compress-sequence
4130 (and (not (setq m (assq type (car marked))))
4133 (cons (cons type (gnus-compress-sequence articles t) )
4137 (setcar (nthcdr 3 info)
4138 (gnus-delete-alist type (car marked)))
4139 (setcdr m (gnus-compress-sequence articles t)))
4140 (setcdr m (gnus-compress-sequence
4141 (sort (nconc (gnus-uncompress-range (cdr m))
4142 (copy-sequence articles)) '<) t))))))
4144 (defun gnus-add-mark (group mark article)
4145 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4146 (let ((buffer (gnus-summary-buffer-name group)))
4147 (if (gnus-buffer-live-p buffer)
4149 (set-buffer (get-buffer buffer))
4150 (gnus-summary-add-mark article mark))
4151 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4155 ;;; Group timestamps
4158 (defun gnus-group-set-timestamp ()
4159 "Change the timestamp of the current group to the current time.
4160 This function can be used in hooks like `gnus-select-group-hook'
4161 or `gnus-group-catchup-group-hook'."
4162 (when gnus-newsgroup-name
4163 (let ((time (current-time)))
4164 (setcdr (cdr time) nil)
4165 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4167 (defsubst gnus-group-timestamp (group)
4168 "Return the timestamp for GROUP."
4169 (gnus-group-get-parameter group 'timestamp t))
4171 (defun gnus-group-timestamp-delta (group)
4172 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4173 (let* ((time (or (gnus-group-timestamp group)
4175 (delta (subtract-time (current-time) time)))
4176 (+ (* (nth 0 delta) 65536.0)
4179 (defun gnus-group-timestamp-string (group)
4180 "Return a string of the timestamp for GROUP."
4181 (let ((time (gnus-group-timestamp group)))
4184 (gnus-time-iso8601 time))))
4186 (defun gnus-group-list-cached (level &optional lowest)
4187 "List all groups with cached articles.
4188 If the prefix LEVEL is non-nil, it should be a number that says which
4189 level to cut off listing groups.
4190 If LOWEST, don't list groups with level lower than LOWEST.
4192 This command may read the active file."
4195 (setq level (prefix-numeric-value level)))
4196 (when (or (not level) (>= level gnus-level-zombie))
4198 (funcall gnus-group-prepare-function
4199 (or level gnus-level-subscribed)
4201 (let ((marks (gnus-info-marks info)))
4202 (assq 'cache marks)))
4205 (or (gnus-gethash group
4206 gnus-cache-active-hashtb)
4207 ;; Cache active file might use "."
4210 (mapconcat 'identity
4211 (split-string group ":")
4213 gnus-cache-active-hashtb))))
4214 (goto-char (point-min))
4215 (gnus-group-position-point))
4217 (defun gnus-group-list-dormant (level &optional lowest)
4218 "List all groups with dormant articles.
4219 If the prefix LEVEL is non-nil, it should be a number that says which
4220 level to cut off listing groups.
4221 If LOWEST, don't list groups with level lower than LOWEST.
4223 This command may read the active file."
4226 (setq level (prefix-numeric-value level)))
4227 (when (or (not level) (>= level gnus-level-zombie))
4229 (funcall gnus-group-prepare-function
4230 (or level gnus-level-subscribed)
4232 (let ((marks (gnus-info-marks info)))
4233 (assq 'dormant marks)))
4236 (goto-char (point-min))
4237 (gnus-group-position-point))
4239 (defun gnus-group-listed-groups ()
4240 "Return a list of listed groups."
4242 (goto-char (point-min))
4243 (while (setq point (text-property-not-all (point) (point-max)
4246 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4250 (defun gnus-group-list-plus (&optional args)
4251 "List groups plus the current selection."
4253 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4254 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4256 (push last-command-event unread-command-events)
4257 (if (featurep 'xemacs)
4258 (push (make-event 'key-press '(key ?A)) unread-command-events)
4259 (push ?A unread-command-events))
4260 (let (gnus-pick-mode keys)
4261 (setq keys (if (featurep 'xemacs)
4262 (events-to-keys (read-key-sequence nil))
4263 (read-key-sequence nil)))
4264 (setq func (lookup-key (current-local-map) keys)))
4268 (call-interactively func))))
4270 (defun gnus-group-list-flush (&optional args)
4271 "Flush groups from the current selection."
4273 (let ((gnus-group-list-option 'flush))
4274 (gnus-group-list-plus args)))
4276 (defun gnus-group-list-limit (&optional args)
4277 "List groups limited within the current selection."
4279 (let ((gnus-group-list-option 'limit))
4280 (gnus-group-list-plus args)))
4282 (defun gnus-group-mark-article-read (group article)
4283 "Mark ARTICLE read."
4284 (let ((buffer (gnus-summary-buffer-name group))
4285 (mark gnus-read-mark)
4287 (if (get-buffer buffer)
4288 (with-current-buffer buffer
4289 (setq active gnus-newsgroup-active)
4290 (gnus-activate-group group)
4291 (when gnus-newsgroup-prepared
4292 (when (and gnus-newsgroup-auto-expire
4293 (memq mark gnus-auto-expirable-marks))
4294 (setq mark gnus-expirable-mark))
4295 (setq mark (gnus-request-update-mark
4296 group article mark))
4297 (gnus-mark-article-as-read article mark)
4298 (setq gnus-newsgroup-active (gnus-active group))
4300 (setq n (1+ (cdr active)))
4301 (while (<= n (cdr gnus-newsgroup-active))
4302 (unless (eq n article)
4303 (push n gnus-newsgroup-unselected))
4305 (setq gnus-newsgroup-unselected
4306 (nreverse gnus-newsgroup-unselected)))))
4307 (gnus-activate-group group)
4308 (gnus-group-make-articles-read group (list article))
4309 (when (gnus-group-auto-expirable-p group)
4310 (gnus-add-marked-articles
4311 group 'expire (list article))))))
4313 (provide 'gnus-group)
4315 ;;; gnus-group.el ends here