1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %U Number of unseen articles (integer)
160 %t Estimated total number of articles (integer)
161 %y Number of unread, unticked articles (integer)
162 %G Group name (string)
163 %g Qualified group name (string)
164 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
165 %C Group comment (string)
166 %D Group description (string)
167 %s Select method (string)
168 %o Moderated group (char, \"m\")
169 %p Process mark (char)
170 %B Whether a summary buffer for the group is open (char, \"*\")
171 %O Moderated group (string, \"(m)\" or \"\")
172 %P Topic indentation (string)
173 %m Whether there is new(ish) mail in the group (char, \"%\")
174 %w Number of new(ish) mails in the group (integer)
175 %l Whether there are GroupLens predictions for this group (string)
176 %n Select from where (string)
177 %z A string that look like `<%s:%n>' if a foreign select method is used
178 %d The date the group was last entered.
179 %E Icon as defined by `gnus-group-icon-list'.
180 %u User defined specifier. The next character in the format string should
181 be a letter. Gnus will call the function gnus-user-format-function-X,
182 where X is the letter following %u. The function will be passed a
183 single dummy parameter as argument.. The function should return a
184 string, which will be inserted into the buffer just like information
185 from any other group specifier.
187 Note that this format specification is not always respected. For
188 reasons of efficiency, when listing killed groups, this specification
189 is ignored altogether. If the spec is changed considerably, your
190 output may end up looking strange when listing both alive and killed
193 If you use %o or %O, reading the active file will be slower and quite
194 a bit of extra memory will be used. %D will also worsen performance.
195 Also note that if you change the format specification to include any
196 of these specs, you must probably re-start Gnus to see them go into
199 General format specifiers can also be used.
200 See Info node `(gnus)Formatting Variables'."
201 :link '(custom-manual "(gnus)Formatting Variables")
202 :group 'gnus-group-visual
205 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
206 "*The format specification for the group mode line.
207 It works along the same lines as a normal formatting string,
208 with some simple extensions:
210 %S The native news server.
211 %M The native select method.
212 %: \":\" if %S isn't \"\"."
213 :group 'gnus-group-visual
216 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
217 (when (featurep 'xemacs)
218 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
219 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
221 (defcustom gnus-group-menu-hook nil
222 "Hook run after the creation of the group mode menu."
223 :group 'gnus-group-various
226 (defcustom gnus-group-catchup-group-hook nil
227 "Hook run when catching up a group from the group buffer."
228 :group 'gnus-group-various
229 :link '(custom-manual "(gnus)Group Data")
232 (defcustom gnus-group-update-group-hook nil
233 "Hook called when updating group lines."
234 :group 'gnus-group-visual
237 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
238 "*A function that is called to generate the group buffer.
239 The function is called with three arguments: The first is a number;
240 all group with a level less or equal to that number should be listed,
241 if the second is non-nil, empty groups should also be displayed. If
242 the third is non-nil, it is a number. No groups with a level lower
243 than this number should be displayed.
245 The only current function implemented is `gnus-group-prepare-flat'."
246 :group 'gnus-group-listing
249 (defcustom gnus-group-prepare-hook nil
250 "Hook called after the group buffer has been generated.
251 If you want to modify the group buffer, you can use this hook."
252 :group 'gnus-group-listing
255 (defcustom gnus-suspend-gnus-hook nil
256 "Hook called when suspending (not exiting) Gnus."
260 (defcustom gnus-exit-gnus-hook nil
261 "Hook called when exiting Gnus."
265 (defcustom gnus-after-exiting-gnus-hook nil
266 "Hook called after exiting Gnus."
270 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
271 "Hook called when a group line is changed.
272 The hook will not be called if `gnus-visual' is nil.
274 The default function `gnus-group-highlight-line' will
275 highlight the line according to the `gnus-group-highlight'
277 :group 'gnus-group-visual
280 (defcustom gnus-useful-groups
281 '(("(ding) mailing list mirrored at sunsite.auc.dk"
283 (nntp "sunsite.auc.dk"
284 (nntp-address "sunsite.auc.dk")))
287 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
291 (nndoc-article-type mbox)
292 (eval `(nndoc-address
293 ,(let ((file (nnheader-find-etc-directory
296 (error "Couldn't find doc group"))
298 "*Alist of useful group-server pairs."
299 :group 'gnus-group-listing
300 :type '(repeat (list (string :tag "Description")
302 (sexp :tag "Method"))))
304 (defcustom gnus-group-highlight
306 ((and mailp (= unread 0) (eq level 1)) .
307 gnus-group-mail-1-empty-face)
308 ((and mailp (eq level 1)) .
309 gnus-group-mail-1-face)
310 ((and mailp (= unread 0) (eq level 2)) .
311 gnus-group-mail-2-empty-face)
312 ((and mailp (eq level 2)) .
313 gnus-group-mail-2-face)
314 ((and mailp (= unread 0) (eq level 3)) .
315 gnus-group-mail-3-empty-face)
316 ((and mailp (eq level 3)) .
317 gnus-group-mail-3-face)
318 ((and mailp (= unread 0)) .
319 gnus-group-mail-low-empty-face)
321 gnus-group-mail-low-face)
323 ((and (= unread 0) (eq level 1)) .
324 gnus-group-news-1-empty-face)
325 ((and (eq level 1)) .
326 gnus-group-news-1-face)
327 ((and (= unread 0) (eq level 2)) .
328 gnus-group-news-2-empty-face)
329 ((and (eq level 2)) .
330 gnus-group-news-2-face)
331 ((and (= unread 0) (eq level 3)) .
332 gnus-group-news-3-empty-face)
333 ((and (eq level 3)) .
334 gnus-group-news-3-face)
335 ((and (= unread 0) (eq level 4)) .
336 gnus-group-news-4-empty-face)
337 ((and (eq level 4)) .
338 gnus-group-news-4-face)
339 ((and (= unread 0) (eq level 5)) .
340 gnus-group-news-5-empty-face)
341 ((and (eq level 5)) .
342 gnus-group-news-5-face)
343 ((and (= unread 0) (eq level 6)) .
344 gnus-group-news-6-empty-face)
345 ((and (eq level 6)) .
346 gnus-group-news-6-face)
347 ((and (= unread 0)) .
348 gnus-group-news-low-empty-face)
350 gnus-group-news-low-face))
351 "*Controls the highlighting of group buffer lines.
353 Below is a list of `Form'/`Face' pairs. When deciding how a a
354 particular group line should be displayed, each form is
355 evaluated. The content of the face field after the first true form is
356 used. You can change how those group lines are displayed by
357 editing the face field.
359 It is also possible to change and add form fields, but currently that
360 requires an understanding of Lisp expressions. Hopefully this will
361 change in a future release. For now, you can use the following
362 variables in the Lisp expression:
364 group: The name of the group.
365 unread: The number of unread articles in the group.
366 method: The select method used.
367 mailp: Whether it's a mail group or not.
368 level: The level of the group.
369 score: The score of the group.
370 ticked: The number of ticked articles."
371 :group 'gnus-group-visual
372 :type '(repeat (cons (sexp :tag "Form") face)))
374 (defcustom gnus-new-mail-mark ?%
375 "Mark used for groups with new mail."
376 :group 'gnus-group-visual
379 (defgroup gnus-group-icons nil
380 "Add Icons to your group buffer. "
381 :group 'gnus-group-visual)
383 (defcustom gnus-group-icon-list
385 "*Controls the insertion of icons into group buffer lines.
387 Below is a list of `Form'/`File' pairs. When deciding how a
388 particular group line should be displayed, each form is evaluated.
389 The icon from the file field after the first true form is used. You
390 can change how those group lines are displayed by editing the file
391 field. The File will either be found in the
392 `gnus-group-glyph-directory' or by designating absolute name of the
395 It is also possible to change and add form fields, but currently that
396 requires an understanding of Lisp expressions. Hopefully this will
397 change in a future release. For now, you can use the following
398 variables in the Lisp expression:
400 group: The name of the group.
401 unread: The number of unread articles in the group.
402 method: The select method used.
403 mailp: Whether it's a mail group or not.
404 newsp: Whether it's a news group or not
405 level: The level of the group.
406 score: The score of the group.
407 ticked: The number of ticked articles."
408 :group 'gnus-group-icons
409 :type '(repeat (cons (sexp :tag "Form") file)))
411 (defcustom gnus-group-name-charset-method-alist nil
412 "Alist of method and the charset for group names.
415 (((nntp \"news.com.cn\") . cn-gb-2312))"
418 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
420 (defcustom gnus-group-name-charset-group-alist
421 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
422 (and (fboundp 'coding-system-p) (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-sort-alist-function 'gnus-group-sort-flat
450 "Function for sorting the group buffer.")
452 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
453 "Function for sorting the selected groups in the group buffer.")
455 (defvar gnus-group-indentation-function nil)
456 (defvar gnus-goto-missing-group-function nil)
457 (defvar gnus-group-update-group-function nil)
458 (defvar gnus-group-goto-next-group-function nil
459 "Function to override finding the next group after listing groups.")
461 (defvar gnus-group-edit-buffer nil)
463 (defvar gnus-group-line-format-alist
464 `((?M gnus-tmp-marked-mark ?c)
465 (?S gnus-tmp-subscribed ?c)
466 (?L gnus-tmp-level ?d)
467 (?N (cond ((eq number t) "*" )
471 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
472 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
474 (?R gnus-tmp-number-of-read ?s)
475 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
476 (?t gnus-tmp-number-total ?d)
477 (?y gnus-tmp-number-of-unread ?s)
478 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
479 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
480 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
481 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
482 (?g gnus-tmp-group ?s)
483 (?G gnus-tmp-qualified-group ?s)
484 (?c (gnus-short-group-name gnus-tmp-group) ?s)
485 (?C gnus-tmp-comment ?s)
486 (?D gnus-tmp-newsgroup-description ?s)
487 (?o gnus-tmp-moderated ?c)
488 (?O gnus-tmp-moderated-string ?s)
489 (?p gnus-tmp-process-marked ?c)
490 (?s gnus-tmp-news-server ?s)
491 (?n gnus-tmp-news-method ?s)
492 (?P gnus-group-indentation ?s)
493 (?E gnus-tmp-group-icon ?s)
494 (?B gnus-tmp-summary-live ?c)
495 (?l gnus-tmp-grouplens ?s)
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)
537 (gnus-define-keys gnus-group-mode-map
538 " " gnus-group-read-group
539 "=" gnus-group-select-group
540 "\r" gnus-group-select-group
541 "\M-\r" gnus-group-quick-select-group
542 "\M- " gnus-group-visible-select-group
543 [(meta control return)] gnus-group-select-group-ephemerally
544 "j" gnus-group-jump-to-group
545 "n" gnus-group-next-unread-group
546 "p" gnus-group-prev-unread-group
547 "\177" gnus-group-prev-unread-group
548 [delete] gnus-group-prev-unread-group
549 [backspace] gnus-group-prev-unread-group
550 "N" gnus-group-next-group
551 "P" gnus-group-prev-group
552 "\M-n" gnus-group-next-unread-group-same-level
553 "\M-p" gnus-group-prev-unread-group-same-level
554 "," gnus-group-best-unread-group
555 "." gnus-group-first-unread-group
556 "u" gnus-group-unsubscribe-current-group
557 "U" gnus-group-unsubscribe-group
558 "c" gnus-group-catchup-current
559 "C" gnus-group-catchup-current-all
560 "\M-c" gnus-group-clear-data
561 "l" gnus-group-list-groups
562 "L" gnus-group-list-all-groups
565 "g" gnus-group-get-new-news
566 "\M-g" gnus-group-get-new-news-this-group
567 "R" gnus-group-restart
568 "r" gnus-group-read-init-file
569 "B" gnus-group-browse-foreign-server
570 "b" gnus-group-check-bogus-groups
571 "F" gnus-group-find-new-groups
572 "\C-c\C-d" gnus-group-describe-group
573 "\M-d" gnus-group-describe-all-groups
574 "\C-c\C-a" gnus-group-apropos
575 "\C-c\M-\C-a" gnus-group-description-apropos
576 "a" gnus-group-post-news
577 "\ek" gnus-group-edit-local-kill
578 "\eK" gnus-group-edit-global-kill
579 "\C-k" gnus-group-kill-group
580 "\C-y" gnus-group-yank-group
581 "\C-w" gnus-group-kill-region
582 "\C-x\C-t" gnus-group-transpose-groups
583 "\C-c\C-l" gnus-group-list-killed
584 "\C-c\C-x" gnus-group-expire-articles
585 "\C-c\M-\C-x" gnus-group-expire-all-groups
587 "s" gnus-group-save-newsrc
588 "z" gnus-group-suspend
591 "?" gnus-group-describe-briefly
592 "\C-c\C-i" gnus-info-find-node
593 "\M-e" gnus-group-edit-group-method
594 "^" gnus-group-enter-server-mode
595 gnus-mouse-2 gnus-mouse-pick-group
596 "<" beginning-of-buffer
599 "\C-c\C-n" gnus-namazu-search
600 "\C-c\C-s" gnus-group-sort-groups
602 "\C-c\M-g" gnus-activate-all-groups
603 "\M-&" gnus-group-universal-argument
604 "#" gnus-group-mark-group
605 "\M-#" gnus-group-unmark-group)
607 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
608 "m" gnus-group-mark-group
609 "u" gnus-group-unmark-group
610 "w" gnus-group-mark-region
611 "b" gnus-group-mark-buffer
612 "r" gnus-group-mark-regexp
613 "U" gnus-group-unmark-all-groups)
615 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
616 "u" gnus-sieve-update
617 "g" gnus-sieve-generate)
619 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
620 "d" gnus-group-make-directory-group
621 "h" gnus-group-make-help-group
622 "u" gnus-group-make-useful-group
623 "a" gnus-group-make-archive-group
624 "k" gnus-group-make-kiboze-group
625 "l" gnus-group-nnimap-edit-acl
626 "m" gnus-group-make-group
627 "n" gnus-group-make-shimbun-group
628 "E" gnus-group-edit-group
629 "e" gnus-group-edit-group-method
630 "p" gnus-group-edit-group-parameters
631 "v" gnus-group-add-to-virtual
632 "V" gnus-group-make-empty-virtual
633 "D" gnus-group-enter-directory
634 "f" gnus-group-make-doc-group
635 "G" gnus-group-make-nnir-group
636 "w" gnus-group-make-web-group
637 "r" gnus-group-rename-group
638 "c" gnus-group-customize
639 "x" gnus-group-nnimap-expunge
640 "\177" gnus-group-delete-group
641 [delete] gnus-group-delete-group)
643 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
644 "b" gnus-group-brew-soup
645 "w" gnus-soup-save-areas
646 "s" gnus-soup-send-replies
647 "p" gnus-soup-pack-packet
648 "r" nnsoup-pack-replies)
650 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
651 "s" gnus-group-sort-groups
652 "a" gnus-group-sort-groups-by-alphabet
653 "u" gnus-group-sort-groups-by-unread
654 "l" gnus-group-sort-groups-by-level
655 "v" gnus-group-sort-groups-by-score
656 "r" gnus-group-sort-groups-by-rank
657 "m" gnus-group-sort-groups-by-method
658 "n" gnus-group-sort-groups-by-real-name)
660 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
661 "s" gnus-group-sort-selected-groups
662 "a" gnus-group-sort-selected-groups-by-alphabet
663 "u" gnus-group-sort-selected-groups-by-unread
664 "l" gnus-group-sort-selected-groups-by-level
665 "v" gnus-group-sort-selected-groups-by-score
666 "r" gnus-group-sort-selected-groups-by-rank
667 "m" gnus-group-sort-selected-groups-by-method
668 "n" gnus-group-sort-selected-groups-by-real-name)
670 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
671 "k" gnus-group-list-killed
672 "z" gnus-group-list-zombies
673 "s" gnus-group-list-groups
674 "u" gnus-group-list-all-groups
675 "A" gnus-group-list-active
676 "a" gnus-group-apropos
677 "d" gnus-group-description-apropos
678 "m" gnus-group-list-matching
679 "M" gnus-group-list-all-matching
680 "l" gnus-group-list-level
681 "c" gnus-group-list-cached
682 "?" gnus-group-list-dormant)
684 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
685 "k" gnus-group-list-limit
686 "z" gnus-group-list-limit
687 "s" gnus-group-list-limit
688 "u" gnus-group-list-limit
689 "A" gnus-group-list-limit
690 "m" gnus-group-list-limit
691 "M" gnus-group-list-limit
692 "l" gnus-group-list-limit
693 "c" gnus-group-list-limit
694 "?" gnus-group-list-limit)
696 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
697 "k" gnus-group-list-flush
698 "z" gnus-group-list-flush
699 "s" gnus-group-list-flush
700 "u" gnus-group-list-flush
701 "A" gnus-group-list-flush
702 "m" gnus-group-list-flush
703 "M" gnus-group-list-flush
704 "l" gnus-group-list-flush
705 "c" gnus-group-list-flush
706 "?" gnus-group-list-flush)
708 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
709 "k" gnus-group-list-plus
710 "z" gnus-group-list-plus
711 "s" gnus-group-list-plus
712 "u" gnus-group-list-plus
713 "A" gnus-group-list-plus
714 "m" gnus-group-list-plus
715 "M" gnus-group-list-plus
716 "l" gnus-group-list-plus
717 "c" gnus-group-list-plus
718 "?" gnus-group-list-plus)
720 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
721 "f" gnus-score-flush-cache)
723 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
724 "c" gnus-group-fetch-charter
725 "C" gnus-group-fetch-control
726 "d" gnus-group-describe-group
727 "f" gnus-group-fetch-faq
730 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
731 "l" gnus-group-set-current-level
732 "t" gnus-group-unsubscribe-current-group
733 "s" gnus-group-unsubscribe-group
734 "k" gnus-group-kill-group
735 "y" gnus-group-yank-group
736 "w" gnus-group-kill-region
737 "\C-k" gnus-group-kill-level
738 "z" gnus-group-kill-all-zombies))
740 (defun gnus-topic-mode-p ()
741 "Return non-nil in `gnus-topic-mode'."
742 (and (boundp 'gnus-topic-mode)
745 (defun gnus-group-make-menu-bar ()
746 (gnus-turn-off-edit-menu 'group)
747 (unless (boundp 'gnus-group-reading-menu)
750 gnus-group-reading-menu gnus-group-mode-map ""
752 ["Read" gnus-group-read-group
753 :included (not (gnus-topic-mode-p))
754 :active (gnus-group-group-name)]
755 ["Read " gnus-topic-read-group
756 :included (gnus-topic-mode-p)]
757 ["Select" gnus-group-select-group
758 :included (not (gnus-topic-mode-p))
759 :active (gnus-group-group-name)]
760 ["Select " gnus-topic-select-group
761 :included (gnus-topic-mode-p)]
762 ["See old articles" (gnus-group-select-group 'all)
763 :keys "C-u SPC" :active (gnus-group-group-name)]
764 ["Catch up" gnus-group-catchup-current
765 :included (not (gnus-topic-mode-p))
766 :active (gnus-group-group-name)
767 ,@(if (featurep 'xemacs) nil
768 '(:help "Mark unread articles in the current group as read"))]
769 ["Catch up " gnus-topic-catchup-articles
770 :included (gnus-topic-mode-p)
771 ,@(if (featurep 'xemacs) nil
772 '(:help "Mark unread articles in the current group or topic as read"))]
773 ["Catch up all articles" gnus-group-catchup-current-all
774 (gnus-group-group-name)]
775 ["Check for new articles" gnus-group-get-new-news-this-group
776 :included (not (gnus-topic-mode-p))
777 :active (gnus-group-group-name)
778 ,@(if (featurep 'xemacs) nil
779 '(:help "Check for new messages in current group"))]
780 ["Check for new articles " gnus-topic-get-new-news-this-topic
781 :included (gnus-topic-mode-p)
782 ,@(if (featurep 'xemacs) nil
783 '(:help "Check for new messages in current group or topic"))]
784 ["Toggle subscription" gnus-group-unsubscribe-current-group
785 (gnus-group-group-name)]
786 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
787 ,@(if (featurep 'xemacs) nil
788 '(:help "Kill (remove) current group"))]
789 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
790 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Display description of the current group"))]
793 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
794 ["Fetch charter" gnus-group-fetch-charter
795 :active (gnus-group-group-name)
796 ,@(if (featurep 'xemacs) nil
797 '(:help "Display the charter of the current group"))]
798 ["Fetch control message" gnus-group-fetch-control
799 :active (gnus-group-group-name)
800 ,@(if (featurep 'xemacs) nil
801 '(:help "Display the archived control message for the current group"))]
802 ;; Actually one should check, if any of the marked groups gives t for
803 ;; (gnus-check-backend-function 'request-expire-articles ...)
804 ["Expire articles" gnus-group-expire-articles
805 :included (not (gnus-topic-mode-p))
806 :active (or (and (gnus-group-group-name)
807 (gnus-check-backend-function
808 'request-expire-articles
809 (gnus-group-group-name))) gnus-group-marked)]
810 ["Expire articles " gnus-topic-expire-articles
811 :included (gnus-topic-mode-p)]
812 ["Set group level..." gnus-group-set-current-level
813 (gnus-group-group-name)]
814 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
815 ["Customize" gnus-group-customize (gnus-group-group-name)]
817 ["Parameters" gnus-group-edit-group-parameters
818 :included (not (gnus-topic-mode-p))
819 :active (gnus-group-group-name)]
820 ["Parameters " gnus-topic-edit-parameters
821 :included (gnus-topic-mode-p)]
822 ["Select method" gnus-group-edit-group-method
823 (gnus-group-group-name)]
824 ["Info" gnus-group-edit-group (gnus-group-group-name)]
825 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
826 ["Global kill file" gnus-group-edit-global-kill t])))
829 gnus-group-group-menu gnus-group-mode-map ""
832 ["List unread subscribed groups" gnus-group-list-groups t]
833 ["List (un)subscribed groups" gnus-group-list-all-groups t]
834 ["List killed groups" gnus-group-list-killed gnus-killed-list]
835 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
836 ["List level..." gnus-group-list-level t]
837 ["Describe all groups" gnus-group-describe-all-groups t]
838 ["Group apropos..." gnus-group-apropos t]
839 ["Group and description apropos..." gnus-group-description-apropos t]
840 ["List groups matching..." gnus-group-list-matching t]
841 ["List all groups matching..." gnus-group-list-all-matching t]
842 ["List active file" gnus-group-list-active t]
843 ["List groups with cached" gnus-group-list-cached t]
844 ["List groups with dormant" gnus-group-list-dormant t])
846 ["Default sort" gnus-group-sort-groups t]
847 ["Sort by method" gnus-group-sort-groups-by-method t]
848 ["Sort by rank" gnus-group-sort-groups-by-rank t]
849 ["Sort by score" gnus-group-sort-groups-by-score t]
850 ["Sort by level" gnus-group-sort-groups-by-level t]
851 ["Sort by unread" gnus-group-sort-groups-by-unread t]
852 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
853 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
854 ("Sort process/prefixed"
855 ["Default sort" gnus-group-sort-selected-groups
856 (not (gnus-topic-mode-p))]
857 ["Sort by method" gnus-group-sort-selected-groups-by-method
858 (not (gnus-topic-mode-p))]
859 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
860 (not (gnus-topic-mode-p))]
861 ["Sort by score" gnus-group-sort-selected-groups-by-score
862 (not (gnus-topic-mode-p))]
863 ["Sort by level" gnus-group-sort-selected-groups-by-level
864 (not (gnus-topic-mode-p))]
865 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
866 (not (gnus-topic-mode-p))]
867 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
868 (not (gnus-topic-mode-p))]
869 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
870 (not (gnus-topic-mode-p))])
872 ["Mark group" gnus-group-mark-group
873 (and (gnus-group-group-name)
874 (not (memq (gnus-group-group-name) gnus-group-marked)))]
875 ["Unmark group" gnus-group-unmark-group
876 (and (gnus-group-group-name)
877 (memq (gnus-group-group-name) gnus-group-marked))]
878 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
879 ["Mark regexp..." gnus-group-mark-regexp t]
880 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
881 ["Mark buffer" gnus-group-mark-buffer t]
882 ["Execute command" gnus-group-universal-argument
883 (or gnus-group-marked (gnus-group-group-name))])
885 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
886 ["Kill all newsgroups in region" gnus-group-kill-region
887 :active (gnus-mark-active-p)]
888 ["Kill all zombie groups" gnus-group-kill-all-zombies
890 ["Kill all groups on level..." gnus-group-kill-level t])
892 ["Make a foreign group..." gnus-group-make-group t]
893 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
894 ["Add a directory group..." gnus-group-make-directory-group t]
895 ["Add the help group" gnus-group-make-help-group t]
896 ["Add the archive group" gnus-group-make-archive-group t]
897 ["Make a doc group..." gnus-group-make-doc-group t]
898 ["Make a web group..." gnus-group-make-web-group t]
899 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
900 ["Make a virtual group..." gnus-group-make-empty-virtual t]
901 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
902 ["Rename group..." gnus-group-rename-group
903 (gnus-check-backend-function
904 'request-rename-group (gnus-group-group-name))]
905 ["Delete group" gnus-group-delete-group
906 (gnus-check-backend-function
907 'request-delete-group (gnus-group-group-name))])
909 ["Next" gnus-group-next-group t]
910 ["Previous" gnus-group-prev-group t]
911 ["Next unread" gnus-group-next-unread-group t]
912 ["Previous unread" gnus-group-prev-unread-group t]
913 ["Next unread same level" gnus-group-next-unread-group-same-level t]
914 ["Previous unread same level"
915 gnus-group-prev-unread-group-same-level t]
916 ["Jump to group..." gnus-group-jump-to-group t]
917 ["First unread group" gnus-group-first-unread-group t]
918 ["Best unread group" gnus-group-best-unread-group t])
920 ["Generate" gnus-sieve-generate t]
921 ["Generate and update" gnus-sieve-update t])
922 ["Delete bogus groups" gnus-group-check-bogus-groups t]
923 ["Find new newsgroups" gnus-group-find-new-groups t]
924 ["Transpose" gnus-group-transpose-groups
925 (gnus-group-group-name)]
926 ["Read a directory as a group..." gnus-group-enter-directory t]))
929 gnus-group-misc-menu gnus-group-mode-map ""
932 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
933 ["Send replies" gnus-soup-send-replies
934 (fboundp 'gnus-soup-pack-packet)]
935 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
936 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
937 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
938 ["Send a mail" gnus-group-mail t]
939 ["Send a message (mail or news)" gnus-group-post-news t]
940 ["Create a local message" gnus-group-news t]
941 ["Check for new news" gnus-group-get-new-news
942 ,@(if (featurep 'xemacs) '(t)
943 '(:help "Get newly arrived articles"))
945 ["Send queued messages" gnus-delay-send-queue
946 ,@(if (featurep 'xemacs) '(t)
947 '(:help "Send all messages that are scheduled to be sent now"))
949 ["Activate all groups" gnus-activate-all-groups t]
950 ["Restart Gnus" gnus-group-restart t]
951 ["Read init file" gnus-group-read-init-file t]
952 ["Browse foreign server..." gnus-group-browse-foreign-server t]
953 ["Enter server buffer" gnus-group-enter-server-mode t]
954 ["Expire all expirable articles" gnus-group-expire-all-groups t]
955 ["Generate any kiboze groups" nnkiboze-generate-groups t]
956 ["Gnus version" gnus-version t]
957 ["Save .newsrc files" gnus-group-save-newsrc t]
958 ["Suspend Gnus" gnus-group-suspend t]
959 ["Clear dribble buffer" gnus-group-clear-dribble t]
960 ["Read manual" gnus-info-find-node t]
961 ["Flush score cache" gnus-score-flush-cache t]
962 ["Toggle topics" gnus-topic-mode t]
963 ["Send a bug report" gnus-bug t]
964 ["Exit from Gnus" gnus-group-exit
965 ,@(if (featurep 'xemacs) '(t)
966 '(:help "Quit reading news"))]
967 ["Exit without saving" gnus-group-quit t]))
969 (gnus-run-hooks 'gnus-group-menu-hook)))
971 (defvar gnus-group-toolbar-map nil)
973 ;; Emacs 21 tool bar. Should be no-op otherwise.
974 (defun gnus-group-make-tool-bar ()
976 (condition-case nil (require 'tool-bar) (error nil))
977 (fboundp 'tool-bar-add-item-from-menu)
978 (default-value 'tool-bar-mode)
979 (not gnus-group-toolbar-map))
980 (setq gnus-group-toolbar-map
981 (let ((tool-bar-map (make-sparse-keymap))
982 (load-path (mm-image-load-path)))
983 (tool-bar-add-item-from-menu
984 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
985 (tool-bar-add-item-from-menu
986 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
987 (tool-bar-add-item-from-menu
988 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
989 (tool-bar-add-item-from-menu
990 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
991 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
992 :help "Subscribe to the current group")
993 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
995 :help "Unsubscribe from the current group")
996 (tool-bar-add-item-from-menu
997 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
999 (if gnus-group-toolbar-map
1000 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1002 (defun gnus-group-mode ()
1003 "Major mode for reading news.
1005 All normal editing commands are switched off.
1006 \\<gnus-group-mode-map>
1007 The group buffer lists (some of) the groups available. For instance,
1008 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1009 lists all zombie groups.
1011 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1012 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1014 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1016 The following commands are available:
1018 \\{gnus-group-mode-map}"
1020 (kill-all-local-variables)
1021 (when (gnus-visual-p 'group-menu 'menu)
1022 (gnus-group-make-menu-bar)
1023 (gnus-group-make-tool-bar))
1024 (gnus-simplify-mode-line)
1025 (setq major-mode 'gnus-group-mode)
1026 (setq mode-name "Group")
1027 (gnus-group-set-mode-line)
1028 (setq mode-line-process nil)
1029 (use-local-map gnus-group-mode-map)
1030 (buffer-disable-undo)
1031 (setq truncate-lines t)
1032 (setq buffer-read-only t)
1033 (gnus-set-default-directory)
1034 (gnus-update-format-specifications nil 'group 'group-mode)
1035 (gnus-update-group-mark-positions)
1040 (gnus-run-hooks 'gnus-group-mode-hook))
1042 (defun gnus-update-group-mark-positions ()
1044 (let ((gnus-process-mark ?\200)
1045 (gnus-group-update-hook nil)
1046 (gnus-group-marked '("dummy.group"))
1047 (gnus-active-hashtb (make-vector 10 0))
1049 (gnus-set-active "dummy.group" '(0 . 0))
1050 (gnus-set-work-buffer)
1051 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1052 (goto-char (point-min))
1053 (setq gnus-group-mark-positions
1054 (list (cons 'process (and (search-forward "\200" nil t)
1055 (- (point) 2))))))))
1057 (defun gnus-mouse-pick-group (e)
1058 "Enter the group under the mouse pointer."
1061 (gnus-group-read-group nil))
1063 ;; Look at LEVEL and find out what the level is really supposed to be.
1064 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1065 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1066 (defun gnus-group-default-level (&optional level number-or-nil)
1068 (gnus-group-use-permanent-levels
1069 (or (setq gnus-group-use-permanent-levels
1070 (or level (if (numberp gnus-group-use-permanent-levels)
1071 gnus-group-use-permanent-levels
1072 (or gnus-group-default-list-level
1073 gnus-level-subscribed))))
1074 gnus-group-default-list-level gnus-level-subscribed))
1078 (or level gnus-group-default-list-level gnus-level-subscribed))))
1080 (defun gnus-group-setup-buffer ()
1081 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1082 (unless (eq major-mode 'gnus-group-mode)
1085 (gnus-carpal-setup-buffer 'group))))
1087 (defun gnus-group-name-charset (method group)
1089 (setq method (gnus-find-method-for-group group)))
1090 (let ((item (assoc method gnus-group-name-charset-method-alist))
1091 (alist gnus-group-name-charset-group-alist)
1095 (while (setq item (pop alist))
1096 (if (string-match (car item) group)
1098 result (cdr item))))
1101 (defun gnus-group-name-decode (string charset)
1102 (if (and string charset (featurep 'mule))
1103 (decode-coding-string string charset)
1106 (defun gnus-group-decoded-name (string)
1107 (let ((charset (gnus-group-name-charset nil string)))
1108 (gnus-group-name-decode string charset)))
1110 (defun gnus-group-name-encode (string charset)
1111 (if (and string charset (featurep 'mule))
1112 (encode-coding-string string charset)
1115 (defun gnus-group-encoded-name (string)
1116 (let ((charset (gnus-group-name-charset nil string)))
1117 (gnus-group-name-encode string charset)))
1119 (defun gnus-group-completing-read-group-name
1120 (prompt table &optional predicate require-match initial-contents history)
1124 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1128 (dolist (entry (prog1
1131 (push (list (gnus-group-decoded-name (car entry))) table)))
1132 (gnus-group-encoded-name
1134 prompt table predicate
1139 (defun gnus-group-list-groups (&optional level unread lowest)
1140 "List newsgroups with level LEVEL or lower that have unread articles.
1141 Default is all subscribed groups.
1142 If argument UNREAD is non-nil, groups with no unread articles are also
1145 Also see the `gnus-group-use-permanent-levels' variable."
1147 (list (if current-prefix-arg
1148 (prefix-numeric-value current-prefix-arg)
1150 (gnus-group-default-level nil t)
1151 gnus-group-default-list-level
1152 gnus-level-subscribed))))
1154 (setq level (car gnus-group-list-mode)
1155 unread (cdr gnus-group-list-mode)))
1156 (setq level (gnus-group-default-level level))
1157 (gnus-group-setup-buffer)
1158 (gnus-update-format-specifications nil 'group 'group-mode)
1159 (let ((case-fold-search nil)
1160 (props (text-properties-at (gnus-point-at-bol)))
1161 (empty (= (point-min) (point-max)))
1162 (group (gnus-group-group-name))
1164 (set-buffer gnus-group-buffer)
1165 (setq number (funcall gnus-group-prepare-function level unread lowest))
1166 (when (or (and (numberp number)
1168 (zerop (buffer-size)))
1169 ;; No groups in the buffer.
1170 (gnus-message 5 gnus-no-groups-message))
1171 ;; We have some groups displayed.
1172 (goto-char (point-max))
1173 (when (or (not gnus-group-goto-next-group-function)
1174 (not (funcall gnus-group-goto-next-group-function
1178 (goto-char (point-min)))
1180 ;; Go to the first group with unread articles.
1181 (gnus-group-search-forward t))
1183 ;; Find the right group to put point on. If the current group
1184 ;; has disappeared in the new listing, try to find the next
1185 ;; one. If no next one can be found, just leave point at the
1186 ;; first newsgroup in the buffer.
1187 (when (not (gnus-goto-char
1189 (point-min) (point-max)
1190 'gnus-group (gnus-intern-safe
1191 group gnus-active-hashtb))))
1192 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1194 (not (gnus-goto-char
1196 (point-min) (point-max) 'gnus-group
1198 (caar newsrc) gnus-active-hashtb)))))
1199 (setq newsrc (cdr newsrc)))
1201 (goto-char (point-max))
1202 (forward-line -1)))))))
1203 ;; Adjust cursor point.
1204 (gnus-group-position-point)))
1206 (defun gnus-group-list-level (level &optional all)
1207 "List groups on LEVEL.
1208 If ALL (the prefix), also list groups that have no unread articles."
1209 (interactive "nList groups on level: \nP")
1210 (gnus-group-list-groups level all level))
1212 (defun gnus-group-prepare-logic (group test)
1213 (or (and gnus-group-listed-groups
1214 (null gnus-group-list-option)
1215 (member group gnus-group-listed-groups))
1217 ((null gnus-group-listed-groups) test)
1218 ((null gnus-group-list-option) test)
1219 (t (and (member group gnus-group-listed-groups)
1220 (if (eq gnus-group-list-option 'flush)
1224 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1225 "List all newsgroups with unread articles of level LEVEL or lower.
1226 If PREDICATE is a function, list groups that the function returns non-nil;
1227 if it is t, list groups that have no unread articles.
1228 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1229 If REGEXP is a function, list dead groups that the function returns non-nil;
1230 if it is a string, only list groups matching REGEXP."
1231 (set-buffer gnus-group-buffer)
1232 (let ((buffer-read-only nil)
1233 (newsrc (cdr gnus-newsrc-alist))
1234 (lowest (or lowest 1))
1235 (not-in-list (and gnus-group-listed-groups
1236 (copy-sequence gnus-group-listed-groups)))
1237 info clevel unread group params)
1239 (when (or (< lowest gnus-level-zombie)
1240 gnus-group-listed-groups)
1241 ;; List living groups.
1243 (setq info (car newsrc)
1244 group (gnus-info-group info)
1245 params (gnus-info-params info)
1247 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1249 (setq not-in-list (delete group not-in-list)))
1250 (when (gnus-group-prepare-logic
1252 (and unread ; This group might be unchecked
1253 (or (not (stringp regexp))
1254 (string-match regexp group))
1255 (<= (setq clevel (gnus-info-level info)) level)
1258 ((functionp predicate)
1259 (funcall predicate info))
1260 (predicate t) ; We list all groups?
1263 (if (eq unread t) ; Unactivated?
1264 gnus-group-list-inactive-groups
1265 ; We list unactivated
1267 ; We list groups with unread articles
1268 (and gnus-list-groups-with-ticked-articles
1269 (cdr (assq 'tick (gnus-info-marks info))))
1270 ; And groups with tickeds
1271 ;; Check for permanent visibility.
1272 (and gnus-permanently-visible-groups
1273 (string-match gnus-permanently-visible-groups
1275 (memq 'visible params)
1276 (cdr (assq 'visible params)))))))
1277 (gnus-group-insert-group-line
1278 group (gnus-info-level info)
1279 (gnus-info-marks info) unread (gnus-info-method info)))))
1281 ;; List dead groups.
1282 (when (or gnus-group-listed-groups
1283 (and (>= level gnus-level-zombie)
1284 (<= lowest gnus-level-zombie)))
1285 (gnus-group-prepare-flat-list-dead
1286 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1287 gnus-level-zombie ?Z
1290 (dolist (group gnus-zombie-list)
1291 (setq not-in-list (delete group not-in-list))))
1292 (when (or gnus-group-listed-groups
1293 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1294 (gnus-group-prepare-flat-list-dead
1297 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1298 gnus-level-killed ?K regexp))
1300 (gnus-group-set-mode-line)
1301 (setq gnus-group-list-mode (cons level predicate))
1302 (gnus-run-hooks 'gnus-group-prepare-hook)
1305 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1306 ;; List zombies and killed lists somewhat faster, which was
1307 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1308 ;; this by ignoring the group format specification altogether.
1310 (if (> (length groups) gnus-group-listing-limit)
1312 (setq group (pop groups))
1313 (when (gnus-group-prepare-logic
1316 (and (stringp regexp) (string-match regexp group))
1317 (and (functionp regexp) (funcall regexp group))))
1318 (gnus-add-text-properties
1319 (point) (prog1 (1+ (point))
1320 (insert " " mark " *: "
1321 (gnus-group-decoded-name group)
1323 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1325 'gnus-level level))))
1327 (setq group (pop groups))
1328 (when (gnus-group-prepare-logic
1331 (and (stringp regexp) (string-match regexp group))
1332 (and (functionp regexp) (funcall regexp group))))
1333 (gnus-group-insert-group-line
1335 (let ((active (gnus-active group)))
1337 (if (zerop (cdr active))
1339 (- (1+ (cdr active)) (car active)))
1341 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1343 (defun gnus-group-update-group-line ()
1344 "Update the current line in the group buffer."
1345 (let* ((buffer-read-only nil)
1346 (group (gnus-group-group-name))
1347 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1348 gnus-group-indentation)
1351 (not (gnus-ephemeral-group-p group))
1353 (concat "(gnus-group-set-info '"
1354 (gnus-prin1-to-string (nth 2 entry))
1356 (setq gnus-group-indentation (gnus-group-group-indentation))
1358 (gnus-group-insert-group-line-info group)
1360 (gnus-group-position-point))))
1362 (defun gnus-group-insert-group-line-info (group)
1363 "Insert GROUP on the current line."
1364 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1365 (gnus-group-indentation (gnus-group-group-indentation))
1369 ;; (Un)subscribed group.
1370 (setq info (nth 2 entry))
1371 (gnus-group-insert-group-line
1372 group (gnus-info-level info) (gnus-info-marks info)
1373 (or (car entry) t) (gnus-info-method info)))
1374 ;; This group is dead.
1375 (gnus-group-insert-group-line
1377 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1379 (if (setq active (gnus-active group))
1380 (if (zerop (cdr active))
1382 (- (1+ (cdr active)) (car active)))
1384 (gnus-method-simplify (gnus-find-method-for-group group))))))
1386 (defun gnus-number-of-unseen-articles-in-group (group)
1387 (let* ((info (nth 2 (gnus-group-entry group)))
1388 (marked (gnus-info-marks info))
1389 (seen (cdr (assq 'seen marked)))
1390 (active (gnus-active group)))
1393 (length (gnus-uncompress-range
1394 (gnus-range-difference
1395 (gnus-range-difference (list active) (gnus-info-read info))
1398 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1399 gnus-tmp-marked number
1401 "Insert a group line in the group buffer."
1402 (let* ((gnus-tmp-method
1403 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1404 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1406 (gnus-tmp-active (gnus-active gnus-tmp-group))
1407 (gnus-tmp-number-total
1409 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1411 (gnus-tmp-number-of-unread
1412 (if (numberp number) (int-to-string (max 0 number))
1414 (gnus-tmp-number-of-read
1415 (if (numberp number)
1416 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1418 (gnus-tmp-subscribed
1419 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1420 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1421 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1423 (gnus-tmp-qualified-group
1424 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1425 group-name-charset))
1427 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1429 (gnus-tmp-newsgroup-description
1430 (if gnus-description-hashtb
1431 (or (gnus-group-name-decode
1432 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1433 group-name-charset) "")
1436 (if (and gnus-moderated-hashtb
1437 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1439 (gnus-tmp-moderated-string
1440 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1441 (gnus-tmp-group-icon "==&&==")
1442 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1443 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1444 (gnus-tmp-news-method-string
1446 (format "(%s:%s)" (car gnus-tmp-method)
1447 (cadr gnus-tmp-method)) ""))
1448 (gnus-tmp-marked-mark
1449 (if (and (numberp number)
1451 (cdr (assq 'tick gnus-tmp-marked)))
1453 (gnus-tmp-summary-live
1454 (if (and (not gnus-group-is-exiting-p)
1455 (gnus-buffer-live-p (gnus-summary-buffer-name
1458 (gnus-tmp-process-marked
1459 (if (member gnus-tmp-group gnus-group-marked)
1460 gnus-process-mark ? ))
1462 (or (and gnus-use-grouplens
1463 (bbb-grouplens-group-p gnus-tmp-group))
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 (progn (end-of-line) (point)))
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 (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-gethash group gnus-newsrc-hashtb)))
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-gethash group gnus-newsrc-hashtb))))
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 (gnus-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 (gnus-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 (gnus-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 (gnus-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))
1725 (subst-char-in-region
1726 (point) (1+ (point)) (char-after)
1729 (setq gnus-group-marked (delete group gnus-group-marked))
1731 (setq gnus-group-marked
1732 (cons group (delete group gnus-group-marked)))
1733 gnus-process-mark)))
1735 (gnus-group-next-group 1))
1737 (gnus-summary-position-point)
1740 (defun gnus-group-unmark-group (n)
1741 "Remove the mark from the current group."
1743 (gnus-group-mark-group n 'unmark)
1744 (gnus-group-position-point))
1746 (defun gnus-group-unmark-all-groups ()
1747 "Unmark all groups."
1749 (let ((groups gnus-group-marked))
1752 (gnus-group-remove-mark (pop groups)))))
1753 (gnus-group-position-point))
1755 (defun gnus-group-mark-region (unmark beg end)
1756 "Mark all groups between point and mark.
1757 If UNMARK, remove the mark instead."
1758 (interactive "P\nr")
1759 (let ((num (count-lines beg end)))
1762 (- num (gnus-group-mark-group num unmark)))))
1764 (defun gnus-group-mark-buffer (&optional unmark)
1765 "Mark all groups in the buffer.
1766 If UNMARK, remove the mark instead."
1768 (gnus-group-mark-region unmark (point-min) (point-max)))
1770 (defun gnus-group-mark-regexp (regexp)
1771 "Mark all groups that match some regexp."
1772 (interactive "sMark (regexp): ")
1773 (let ((alist (cdr gnus-newsrc-alist))
1776 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1777 (gnus-group-set-mark group))))
1778 (gnus-group-position-point))
1780 (defun gnus-group-remove-mark (group &optional test-marked)
1781 "Remove the process mark from GROUP and move point there.
1782 Return nil if the group isn't displayed."
1783 (if (gnus-group-goto-group group nil test-marked)
1785 (gnus-group-mark-group 1 'unmark t)
1787 (setq gnus-group-marked
1788 (delete group gnus-group-marked))
1791 (defun gnus-group-set-mark (group)
1792 "Set the process mark on GROUP."
1793 (if (gnus-group-goto-group group)
1795 (gnus-group-mark-group 1 nil t))
1796 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1798 (defun gnus-group-universal-argument (arg &optional groups func)
1799 "Perform any command on all groups according to the process/prefix convention."
1801 (if (eq (setq func (or func
1804 (substitute-command-keys
1805 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1807 (gnus-error 1 "Undefined key")
1808 (gnus-group-iterate arg
1810 (command-execute func))))
1811 (gnus-group-position-point))
1813 (defun gnus-group-process-prefix (n)
1814 "Return a list of groups to work on.
1815 Take into consideration N (the prefix) and the list of marked groups."
1818 (setq n (prefix-numeric-value n))
1819 ;; There is a prefix, so we return a list of the N next
1821 (let ((way (if (< n 0) -1 1))
1826 (if (setq group (gnus-group-group-name))
1827 (push group groups))
1829 (gnus-group-next-group way)))
1831 ((and (gnus-region-active-p) (mark))
1832 ;; Work on the region between point and mark.
1833 (let ((max (max (point) (mark)))
1836 (goto-char (min (point) (mark)))
1839 (push (gnus-group-group-name) groups)
1840 (zerop (gnus-group-next-group 1))
1842 (nreverse groups))))
1844 ;; No prefix, but a list of marked articles.
1845 (reverse gnus-group-marked))
1847 ;; Neither marked articles or a prefix, so we return the
1849 (let ((group (gnus-group-group-name)))
1850 (and group (list group))))))
1852 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1853 ;;; imagine why I went through these contortions...
1855 (let ((function (make-symbol "gnus-group-iterate-function"))
1856 (window (make-symbol "gnus-group-iterate-window"))
1857 (groups (make-symbol "gnus-group-iterate-groups"))
1858 (group (make-symbol "gnus-group-iterate-group")))
1860 `(defun gnus-group-iterate (arg ,function)
1861 "Iterate FUNCTION over all process/prefixed groups.
1862 FUNCTION will be called with the group name as the parameter
1863 and with point over the group in question."
1864 (let ((,groups (gnus-group-process-prefix arg))
1865 (,window (selected-window))
1868 (setq ,group (car ,groups)
1869 ,groups (cdr ,groups))
1870 (select-window ,window)
1871 (gnus-group-remove-mark ,group)
1872 (save-selected-window
1874 (funcall ,function ,group)))))))))
1876 (put 'gnus-group-iterate 'lisp-indent-function 1)
1878 ;; Selecting groups.
1880 (defun gnus-group-read-group (&optional all no-article group select-articles)
1881 "Read news in this newsgroup.
1882 If the prefix argument ALL is non-nil, already read articles become
1883 readable. IF ALL is a number, fetch this number of articles. If the
1884 optional argument NO-ARTICLE is non-nil, no article will be
1885 auto-selected upon group entry. If GROUP is non-nil, fetch that
1888 (let ((no-display (eq all 0))
1889 (group (or group (gnus-group-group-name)))
1890 number active marked entry)
1894 (error "No group on current line"))
1895 (setq marked (gnus-info-marks
1896 (nth 2 (setq entry (gnus-gethash
1897 group gnus-newsrc-hashtb)))))
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 (gnus-group-read-group all t))
1922 (defun gnus-group-quick-select-group (&optional all)
1923 "Select the current group \"quickly\".
1924 This means that no highlighting or scoring will be performed.
1925 If ALL (the prefix argument) is 0, don't even generate the summary
1928 This might be useful if you want to toggle threading
1929 before entering the group."
1931 (require 'gnus-score)
1933 gnus-score-find-score-files-function
1934 gnus-home-score-file
1935 gnus-apply-kill-hook
1936 gnus-summary-expunge-below)
1937 (gnus-group-read-group all t)))
1939 (defun gnus-group-visible-select-group (&optional all)
1940 "Select the current group without hiding any articles."
1942 (let ((gnus-inhibit-limiting t))
1943 (gnus-group-read-group all t)))
1945 (defun gnus-group-select-group-ephemerally ()
1946 "Select the current group without doing any processing whatsoever.
1947 You will actually be entered into a group that's a copy of
1948 the current group; no changes you make while in this group will
1951 (require 'gnus-score)
1953 gnus-score-find-score-files-function gnus-apply-kill-hook
1954 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1955 gnus-summary-mode-hook gnus-select-group-hook
1956 (group (gnus-group-group-name))
1957 (method (gnus-find-method-for-group group)))
1958 (gnus-group-read-ephemeral-group
1959 (gnus-group-prefixed-name group method) method)))
1962 (defun gnus-fetch-group (group &optional articles)
1963 "Start Gnus if necessary and enter GROUP.
1964 Returns whether the fetching was successful or not."
1965 (interactive (list (gnus-group-completing-read-group-name
1966 "Group name: " gnus-active-hashtb)))
1967 (unless (get-buffer gnus-group-buffer)
1969 (gnus-group-read-group articles nil group))
1972 (defun gnus-fetch-group-other-frame (group)
1973 "Pop up a frame and enter GROUP."
1975 (let ((window (get-buffer-window gnus-group-buffer)))
1977 (select-frame (window-frame window)))
1978 ((= (length (frame-list)) 1)
1979 (select-frame (make-frame)))
1982 (gnus-fetch-group group))
1984 (defvar gnus-ephemeral-group-server 0)
1986 ;; Enter a group that is not in the group buffer. Non-nil is returned
1987 ;; if selection was successful.
1988 (defun gnus-group-read-ephemeral-group (group method &optional activate
1989 quit-config request-only
1992 "Read GROUP from METHOD as an ephemeral group.
1993 If ACTIVATE, request the group first.
1994 If QUIT-CONFIG, use that window configuration when exiting from the
1996 If REQUEST-ONLY, don't actually read the group; just request it.
1997 If SELECT-ARTICLES, only select those articles.
1998 If PARAMETERS, use those as the group parameters.
2000 Return the name of the group if selection was successful."
2001 ;; Transform the select method into a unique server.
2002 (when (stringp method)
2003 (setq method (gnus-server-to-method method)))
2005 `(,(car method) ,(concat (cadr method) "-ephemeral")
2006 (,(intern (format "%s-address" (car method))) ,(cadr method))
2008 (let ((group (if (gnus-group-foreign-p group) group
2009 (gnus-group-prefixed-name (gnus-group-real-name group)
2014 ,gnus-level-default-subscribed nil nil ,method
2017 (cons 'quit-config quit-config)
2019 (cons gnus-summary-buffer
2020 gnus-current-window-configuration)))
2023 (push method gnus-ephemeral-servers)
2024 (set-buffer gnus-group-buffer)
2025 (unless (gnus-check-server method)
2026 (error "Unable to contact server: %s" (gnus-status-message method)))
2028 (gnus-activate-group group 'scan)
2029 (unless (gnus-request-group group)
2030 (error "Couldn't request group: %s"
2031 (nnheader-get-report (car method)))))
2035 (when (gnus-group-read-group t t group select-articles)
2039 (message "Quit reading the ephemeral group")
2042 (defun gnus-group-jump-to-group (group)
2043 "Jump to newsgroup GROUP."
2045 (list (gnus-group-completing-read-group-name
2046 "Group: " gnus-active-hashtb nil
2047 (gnus-read-active-file-p)
2048 gnus-group-jump-to-group-prompt
2049 'gnus-group-history)))
2051 (when (equal group "")
2052 (error "Empty group name"))
2054 (unless (gnus-ephemeral-group-p group)
2055 ;; Either go to the line in the group buffer...
2056 (unless (gnus-group-goto-group group)
2057 ;; ... or insert the line.
2058 (gnus-group-update-group group)
2059 (gnus-group-goto-group group)))
2060 ;; Adjust cursor point.
2061 (gnus-group-position-point))
2063 (defun gnus-group-goto-group (group &optional far test-marked)
2064 "Goto to newsgroup GROUP.
2065 If FAR, it is likely that the group is not on the current line.
2066 If TEST-MARKED, the line must be marked."
2070 ;; It's quite likely that we are on the right line, so
2071 ;; we check the current line first.
2073 (eq (get-text-property (point) 'gnus-group)
2074 (gnus-intern-safe group gnus-active-hashtb))
2075 (or (not test-marked) (gnus-group-mark-line-p)))
2077 ;; Previous and next line are also likely, so we check them as well.
2081 (and (eq (get-text-property (point) 'gnus-group)
2082 (gnus-intern-safe group gnus-active-hashtb))
2083 (or (not test-marked) (gnus-group-mark-line-p)))))
2089 (and (eq (get-text-property (point) 'gnus-group)
2090 (gnus-intern-safe group gnus-active-hashtb))
2091 (or (not test-marked) (gnus-group-mark-line-p)))))
2095 (goto-char (point-min))
2097 (while (and (not found)
2102 (gnus-intern-safe group gnus-active-hashtb))))
2103 (if (gnus-group-mark-line-p)
2108 ;; Search through the entire buffer.
2111 (point-min) (point-max)
2112 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2114 (defun gnus-group-next-group (n &optional silent)
2115 "Go to next N'th newsgroup.
2116 If N is negative, search backward instead.
2117 Returns the difference between N and the number of skips actually
2120 (gnus-group-next-unread-group n t nil silent))
2122 (defun gnus-group-next-unread-group (n &optional all level silent)
2123 "Go to next N'th unread newsgroup.
2124 If N is negative, search backward instead.
2125 If ALL is non-nil, choose any newsgroup, unread or not.
2126 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2127 such group can be found, the next group with a level higher than
2129 Returns the difference between N and the number of skips actually
2132 (let ((backward (< n 0))
2135 (gnus-group-search-forward
2136 backward (or (not gnus-group-goto-unread) all) level))
2140 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2141 (if level " on this level or higher" "")))
2144 (defun gnus-group-prev-group (n)
2145 "Go to previous N'th newsgroup.
2146 Returns the difference between N and the number of skips actually
2149 (gnus-group-next-unread-group (- n) t))
2151 (defun gnus-group-prev-unread-group (n)
2152 "Go to previous N'th unread newsgroup.
2153 Returns the difference between N and the number of skips actually
2156 (gnus-group-next-unread-group (- n)))
2158 (defun gnus-group-next-unread-group-same-level (n)
2159 "Go to next N'th unread newsgroup on the same level.
2160 If N is negative, search backward instead.
2161 Returns the difference between N and the number of skips actually
2164 (gnus-group-next-unread-group n t (gnus-group-group-level))
2165 (gnus-group-position-point))
2167 (defun gnus-group-prev-unread-group-same-level (n)
2168 "Go to next N'th unread newsgroup on the same level.
2169 Returns the difference between N and the number of skips actually
2172 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2173 (gnus-group-position-point))
2175 (defun gnus-group-best-unread-group (&optional exclude-group)
2176 "Go to the group with the highest level.
2177 If EXCLUDE-GROUP, do not go to that group."
2179 (goto-char (point-min))
2183 (setq unread (get-text-property (point) 'gnus-unread))
2184 (when (and (numberp unread) (> unread 0))
2185 (when (and (get-text-property (point) 'gnus-level)
2186 (< (get-text-property (point) 'gnus-level) best)
2187 (or (not exclude-group)
2188 (not (equal exclude-group (gnus-group-group-name)))))
2189 (setq best (get-text-property (point) 'gnus-level))
2190 (setq best-point (point))))
2193 (goto-char best-point))
2194 (gnus-group-position-point)
2195 (and best-point (gnus-group-group-name))))
2197 (defun gnus-group-first-unread-group ()
2198 "Go to the first group with unread articles."
2201 (let ((opoint (point))
2203 (goto-char (point-min))
2204 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2205 (and (numberp unread) ; Not a topic.
2206 (not (zerop unread))) ; Has unread articles.
2207 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2210 nil)) ; Not success.
2211 (gnus-group-position-point)))
2213 (defun gnus-group-enter-server-mode ()
2214 "Jump to the server buffer."
2216 (gnus-enter-server-buffer))
2218 (defun gnus-group-make-group (name &optional method address args)
2219 "Add a new newsgroup.
2220 The user will be prompted for a NAME, for a select METHOD, and an
2224 (gnus-read-group "Group name: ")
2225 (gnus-read-method "From method: ")))
2227 (when (stringp method)
2228 (setq method (or (gnus-server-to-method method) method)))
2229 (let* ((meth (gnus-method-simplify
2231 (not (gnus-server-equal method gnus-select-method)))
2232 (if address (list (intern method) address)
2234 (nname (if method (gnus-group-prefixed-name name meth) name))
2236 (when (gnus-gethash nname gnus-newsrc-hashtb)
2237 (error "Group %s already exists" nname))
2238 ;; Subscribe to the new group.
2239 (gnus-group-change-level
2240 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2241 gnus-level-default-subscribed gnus-level-killed
2242 (and (gnus-group-group-name)
2243 (gnus-gethash (gnus-group-group-name)
2244 gnus-newsrc-hashtb))
2247 (gnus-set-active nname (cons 1 0))
2248 (unless (gnus-ephemeral-group-p name)
2250 (concat "(gnus-group-set-info '"
2251 (gnus-prin1-to-string (cdr info)) ")")))
2253 (gnus-group-insert-group-line-info nname)
2255 (gnus-group-position-point)
2257 ;; Load the backend and try to make the backend create
2258 ;; the group as well.
2259 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2261 gnus-valid-select-methods)
2263 (gnus-check-server meth)
2264 (when (gnus-check-backend-function 'request-create-group nname)
2265 (unless (gnus-request-create-group nname nil args)
2266 (error "Could not create group on server: %s"
2267 (nnheader-get-report backend))))
2270 (defun gnus-group-delete-groups (&optional arg)
2271 "Delete the current group. Only meaningful with editable groups."
2273 (let ((n (length (gnus-group-process-prefix arg))))
2274 (when (gnus-yes-or-no-p
2276 "Delete this 1 group? "
2277 (format "Delete these %d groups? " n)))
2278 (gnus-group-iterate arg
2280 (gnus-group-delete-group group nil t))))))
2282 (defun gnus-group-delete-group (group &optional force no-prompt)
2283 "Delete the current group. Only meaningful with editable groups.
2284 If FORCE (the prefix) is non-nil, all the articles in the group will
2285 be deleted. This is \"deleted\" as in \"removed forever from the face
2286 of the Earth\". There is no undo. The user will be prompted before
2287 doing the deletion."
2289 (list (gnus-group-group-name)
2290 current-prefix-arg))
2292 (error "No group to delete"))
2293 (unless (gnus-check-backend-function 'request-delete-group group)
2294 (error "This backend does not support group deletion"))
2296 (if (and (not no-prompt)
2297 (not (gnus-yes-or-no-p
2299 "Do you really want to delete %s%s? "
2300 group (if force " and all its contents" "")))))
2302 (gnus-message 6 "Deleting group %s..." group)
2303 (if (not (gnus-request-delete-group group force))
2304 (gnus-error 3 "Couldn't delete group %s" group)
2305 (gnus-message 6 "Deleting group %s...done" group)
2306 (gnus-group-goto-group group)
2307 (gnus-group-kill-group 1 t)
2308 (gnus-sethash group nil gnus-active-hashtb)
2309 (when (and (boundp 'gnus-cache-active-hashtb)
2310 gnus-cache-active-hashtb)
2311 (gnus-sethash group nil gnus-cache-active-hashtb)
2312 (setq gnus-cache-active-altered t))
2314 (gnus-group-position-point)))
2316 (defun gnus-group-rename-group (group new-name)
2317 "Rename group from GROUP to NEW-NAME.
2318 When used interactively, GROUP is the group under point
2319 and NEW-NAME will be prompted for."
2322 (gnus-group-group-name)
2324 (unless (gnus-check-backend-function
2325 'request-rename-group (gnus-group-group-name))
2326 (error "This backend does not support renaming groups"))
2327 (gnus-read-group "Rename group to: "
2328 (gnus-group-real-name (gnus-group-group-name))))))
2330 (unless (gnus-check-backend-function 'request-rename-group group)
2331 (error "This backend does not support renaming groups"))
2333 (error "No group to rename"))
2334 (when (equal (gnus-group-real-name group) new-name)
2335 (error "Can't rename to the same name"))
2337 ;; We find the proper prefixed name.
2339 (if (gnus-group-native-p group)
2343 (gnus-group-prefixed-name
2344 (gnus-group-real-name new-name)
2345 (gnus-info-method (gnus-get-info group)))))
2347 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2350 (gnus-group-goto-group group)
2351 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2352 (gnus-request-rename-group group new-name))))
2353 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2354 ;; We rename the group internally by killing it...
2355 (gnus-group-kill-group)
2356 ;; ... changing its name ...
2357 (setcar (cdar gnus-list-of-killed-groups) new-name)
2358 ;; ... and then yanking it. Magic!
2359 (gnus-group-yank-group)
2360 (gnus-set-active new-name (gnus-active group))
2361 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2363 (setq gnus-killed-list (delete group gnus-killed-list))
2364 (gnus-set-active group nil)
2365 (gnus-dribble-touch)
2366 (gnus-group-position-point)))
2368 (defun gnus-group-edit-group (group &optional part)
2369 "Edit the group on the current line."
2370 (interactive (list (gnus-group-group-name)))
2371 (let ((part (or part 'info))
2374 (error "No group on current line"))
2375 (unless (setq info (gnus-get-info group))
2376 (error "Killed group; can't be edited"))
2378 (gnus-close-group group))
2380 ;; Find the proper form to edit.
2381 (cond ((eq part 'method)
2382 (or (gnus-info-method info) "native"))
2384 (gnus-info-params info))
2386 ;; The proper documentation.
2388 "Editing the %s for `%s'."
2390 ((eq part 'method) "select method")
2391 ((eq part 'params) "group parameters")
2393 (gnus-group-decoded-name group))
2395 (gnus-group-edit-group-done ',part ,group form)))
2398 (gnus-create-info-command
2401 "(gnus)Select Methods")
2403 "(gnus)Group Parameters")
2405 "(gnus)Group Info"))))))
2407 (defun gnus-group-edit-group-method (group)
2408 "Edit the select method of GROUP."
2409 (interactive (list (gnus-group-group-name)))
2410 (gnus-group-edit-group group 'method))
2412 (defun gnus-group-edit-group-parameters (group)
2413 "Edit the group parameters of GROUP."
2414 (interactive (list (gnus-group-group-name)))
2415 (gnus-group-edit-group group 'params))
2417 (defun gnus-group-edit-group-done (part group form)
2419 (let* ((method (cond ((eq part 'info) (nth 4 form))
2420 ((eq part 'method) form)
2422 (info (cond ((eq part 'info) form)
2423 ((eq part 'method) (gnus-get-info group))
2426 (if (or (not method)
2428 gnus-select-method method))
2429 (gnus-group-real-name (car info))
2430 (gnus-group-prefixed-name
2431 (gnus-group-real-name (car info)) method))
2433 (when (and new-group
2434 (not (equal new-group group)))
2435 (when (gnus-group-goto-group group)
2436 (gnus-group-kill-group 1))
2437 (gnus-activate-group new-group))
2439 (if (not (and info new-group))
2440 (gnus-group-set-info form (or new-group group) part)
2441 (setq info (gnus-copy-sequence info))
2442 (setcar info new-group)
2443 (unless (gnus-server-equal method "native")
2444 (unless (nthcdr 3 info)
2445 (nconc info (list nil nil)))
2446 (unless (nthcdr 4 info)
2447 (nconc info (list nil)))
2448 (gnus-info-set-method info method))
2449 (gnus-group-set-info info))
2450 (gnus-group-update-group (or new-group group))
2451 (gnus-group-position-point)))
2453 (defun gnus-group-make-useful-group (group method)
2454 "Create one of the groups described in `gnus-useful-groups'."
2456 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2458 gnus-useful-groups)))
2459 (list (cadr entry) (caddr entry))))
2460 (setq method (gnus-copy-sequence method))
2462 (while (setq entry (memq (assq 'eval method) method))
2463 (setcar entry (eval (cadar entry)))))
2464 (gnus-group-make-group group method))
2466 (defun gnus-group-make-help-group (&optional noerror)
2467 "Create the Gnus documentation group.
2468 Optional argument NOERROR modifies the behavior of this function when the
2469 group already exists:
2470 - if not given, and error is signaled,
2471 - if t, stay silent,
2472 - if anything else, just print a message."
2474 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2475 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2476 (if (gnus-gethash name gnus-newsrc-hashtb)
2477 (cond ((eq noerror nil)
2478 (error "Documentation group already exists"))
2483 (gnus-message 1 "Documentation group already exists")))
2486 (gnus-message 1 "Couldn't find doc group")
2487 (gnus-group-make-group
2488 (gnus-group-real-name name)
2489 (list 'nndoc "gnus-help"
2490 (list 'nndoc-address file)
2491 (list 'nndoc-article-type 'mbox))))
2493 (gnus-group-position-point))
2495 (defun gnus-group-make-doc-group (file type)
2496 "Create a group that uses a single file as the source."
2498 (list (read-file-name "File name: ")
2499 (and current-prefix-arg 'ask)))
2500 (when (eq type 'ask)
2505 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2507 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2508 ((= char ?b) 'babyl)
2509 ((= char ?d) 'digest)
2510 ((= char ?f) 'forward)
2512 ((= char ?g) 'guess)
2513 (t (setq err (format "%c unknown. " char))
2516 (let* ((file (expand-file-name file))
2517 (name (gnus-generate-new-group-name
2518 (gnus-group-prefixed-name
2519 (file-name-nondirectory file) '(nndoc "")))))
2520 (gnus-group-make-group
2521 (gnus-group-real-name name)
2523 (list 'nndoc-address file)
2524 (list 'nndoc-article-type (or type 'guess))))))
2526 (defvar nnweb-type-definition)
2527 (defvar gnus-group-web-type-history nil)
2528 (defvar gnus-group-web-search-history nil)
2529 (defun gnus-group-make-web-group (&optional solid)
2530 "Create an ephemeral nnweb group.
2531 If SOLID (the prefix), create a solid group."
2535 (if solid (gnus-read-group "Group name: ")
2536 (message-unique-id)))
2537 (default-type (or (car gnus-group-web-type-history)
2538 (symbol-name (caar nnweb-type-definition))))
2542 (format "Search engine type (default %s): " default-type)
2543 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2544 nnweb-type-definition)
2545 nil t nil 'gnus-group-web-type-history)
2550 (cons (or (car gnus-group-web-search-history) "") 0)
2551 'gnus-group-web-search-history))
2553 `(nnweb ,group (nnweb-search ,search)
2554 (nnweb-type ,(intern type))
2555 (nnweb-ephemeral-p t))))
2558 (gnus-pull 'nnweb-ephemeral-p method)
2559 (gnus-group-make-group group method))
2560 (gnus-group-read-ephemeral-group
2562 (cons (current-buffer)
2563 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2565 (defvar nnwarchive-type-definition)
2566 (defvar gnus-group-warchive-type-history nil)
2567 (defvar gnus-group-warchive-login-history nil)
2568 (defvar gnus-group-warchive-address-history nil)
2570 (defun gnus-group-make-warchive-group ()
2571 "Create a nnwarchive group."
2573 (require 'nnwarchive)
2574 (let* ((group (gnus-read-group "Group name: "))
2575 (default-type (or (car gnus-group-warchive-type-history)
2576 (symbol-name (caar nnwarchive-type-definition))))
2580 (format "Warchive type (default %s): " default-type)
2581 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2582 nnwarchive-type-definition)
2583 nil t nil 'gnus-group-warchive-type-history)
2585 (address (read-string "Warchive address: "
2586 nil 'gnus-group-warchive-address-history))
2587 (default-login (or (car gnus-group-warchive-login-history)
2592 (format "Warchive login (default %s): " user-mail-address)
2593 default-login 'gnus-group-warchive-login-history)
2596 `(nnwarchive ,address
2597 (nnwarchive-type ,(intern type))
2598 (nnwarchive-login ,login))))
2599 (gnus-group-make-group group method)))
2601 (defun gnus-group-make-archive-group (&optional all)
2602 "Create the (ding) Gnus archive group of the most recent articles.
2603 Given a prefix, create a full group."
2605 (let ((group (gnus-group-prefixed-name
2606 (if all "ding.archives" "ding.recent") '(nndir ""))))
2607 (when (gnus-gethash group gnus-newsrc-hashtb)
2608 (error "Archive group already exists"))
2609 (gnus-group-make-group
2610 (gnus-group-real-name group)
2611 (list 'nndir (if all "hpc" "edu")
2612 (list 'nndir-directory
2613 (if all gnus-group-archive-directory
2614 gnus-group-recent-archive-directory))))
2615 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2617 (defun gnus-group-make-directory-group (dir)
2618 "Create an nndir group.
2619 The user will be prompted for a directory. The contents of this
2620 directory will be used as a newsgroup. The directory should contain
2621 mail messages or news articles in files that have numeric names."
2623 (list (read-file-name "Create group from directory: ")))
2624 (unless (file-exists-p dir)
2625 (error "No such directory"))
2626 (unless (file-directory-p dir)
2627 (error "Not a directory"))
2631 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2633 (gnus-group-prefixed-name
2634 (expand-file-name ext dir)
2636 (setq ext (format "<%d>" (setq i (1+ i)))))
2637 (gnus-group-make-group
2638 (gnus-group-real-name group)
2639 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2641 (eval-when-compile (defvar nnkiboze-score-file))
2642 (defun gnus-group-make-kiboze-group (group address scores)
2643 "Create an nnkiboze group.
2644 The user will be prompted for a name, a regexp to match groups, and
2645 score file entries for articles to include in the group."
2648 (read-string "nnkiboze group name: ")
2649 (read-string "Source groups (regexp): ")
2650 (let ((headers (mapcar (lambda (group) (list group))
2651 '("subject" "from" "number" "date" "message-id"
2652 "references" "chars" "lines" "xref"
2653 "followup" "all" "body" "head")))
2654 scores header regexp regexps)
2655 (while (not (equal "" (setq header (completing-read
2656 "Match on header: " headers nil t))))
2658 (while (not (equal "" (setq regexp (read-string
2659 (format "Match on %s (regexp): "
2661 (push (list regexp nil nil 'r) regexps))
2662 (push (cons header regexps) scores))
2664 (gnus-group-make-group group "nnkiboze" address)
2665 (let* ((nnkiboze-current-group group)
2666 (score-file (car (nnkiboze-score-file "")))
2667 (score-dir (file-name-directory score-file)))
2668 (unless (file-exists-p score-dir)
2669 (make-directory score-dir))
2670 (with-temp-file score-file
2671 (let (emacs-lisp-mode-hook)
2672 (pp scores (current-buffer))))))
2674 (defun gnus-group-add-to-virtual (n vgroup)
2675 "Add the current group to a virtual group."
2677 (list current-prefix-arg
2678 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2680 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2681 (error "%s is not an nnvirtual group" vgroup))
2682 (gnus-close-group vgroup)
2683 (let* ((groups (gnus-group-process-prefix n))
2684 (method (gnus-info-method (gnus-get-info vgroup))))
2685 (setcar (cdr method)
2687 (nth 1 method) "\\|"
2690 (gnus-group-remove-mark s)
2691 (concat "\\(^" (regexp-quote s) "$\\)"))
2693 (gnus-group-position-point))
2695 (defun gnus-group-make-empty-virtual (group)
2696 "Create a new, fresh, empty virtual group."
2697 (interactive "sCreate new, empty virtual group: ")
2698 (let* ((method (list 'nnvirtual "^$"))
2699 (pgroup (gnus-group-prefixed-name group method)))
2700 ;; Check whether it exists already.
2701 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2702 (error "Group %s already exists" pgroup))
2703 ;; Subscribe the new group after the group on the current line.
2704 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2705 (gnus-group-update-group pgroup)
2707 (gnus-group-position-point)))
2709 (defun gnus-group-enter-directory (dir)
2710 "Enter an ephemeral nneething group."
2711 (interactive "DDirectory to read: ")
2712 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2713 (leaf (gnus-group-prefixed-name
2714 (file-name-nondirectory (directory-file-name dir))
2716 (name (gnus-generate-new-group-name leaf)))
2717 (unless (gnus-group-read-ephemeral-group
2719 (cons (current-buffer)
2720 (if (eq major-mode 'gnus-summary-mode)
2722 (error "Couldn't enter %s" dir))))
2725 (autoload 'nnimap-expunge "nnimap")
2726 (autoload 'nnimap-acl-get "nnimap")
2727 (autoload 'nnimap-acl-edit "nnimap"))
2729 (defun gnus-group-nnimap-expunge (group)
2730 "Expunge deleted articles in current nnimap GROUP."
2731 (interactive (list (gnus-group-group-name)))
2732 (let ((mailbox (gnus-group-real-name group)) method)
2734 (error "No group on current line"))
2735 (unless (gnus-get-info group)
2736 (error "Killed group; can't be edited"))
2737 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2738 (error "%s is not an nnimap group" group))
2739 (nnimap-expunge mailbox (cadr method))))
2741 (defun gnus-group-nnimap-edit-acl (group)
2742 "Edit the Access Control List of current nnimap GROUP."
2743 (interactive (list (gnus-group-group-name)))
2744 (let ((mailbox (gnus-group-real-name group)) method acl)
2746 (error "No group on current line"))
2747 (unless (gnus-get-info group)
2748 (error "Killed group; can't be edited"))
2749 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2750 (error "%s is not an nnimap group" group))
2751 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2752 (error "Server does not support ACL's"))
2753 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2755 An access control list is a list of (identifier . rights) elements.
2757 The identifier string specifies the corresponding user. The
2758 identifier \"anyone\" is reserved to refer to the universal identity.
2760 Rights is a string listing a (possibly empty) set of alphanumeric
2761 characters, each character listing a set of operations which is being
2762 controlled. Letters are reserved for ``standard'' rights, listed
2763 below. Digits are reserved for implementation or site defined rights.
2765 l - lookup (mailbox is visible to LIST/LSUB commands)
2766 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2767 SEARCH, COPY from mailbox)
2768 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2769 w - write (STORE flags other than \\SEEN and \\DELETED)
2770 i - insert (perform APPEND, COPY into mailbox)
2771 p - post (send mail to submission address for mailbox,
2772 not enforced by IMAP4 itself)
2773 c - create and delete mailbox (CREATE new sub-mailboxes in any
2774 implementation-defined hierarchy, RENAME or DELETE mailbox)
2775 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2776 a - administer (perform SETACL)" group)
2779 ,mailbox ',method ',acl form)))))
2781 ;; Group sorting commands
2782 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2784 (defun gnus-group-sort-groups (func &optional reverse)
2785 "Sort the group buffer according to FUNC.
2786 When used interactively, the sorting function used will be
2787 determined by the `gnus-group-sort-function' variable.
2788 If REVERSE (the prefix), reverse the sorting order."
2789 (interactive (list gnus-group-sort-function current-prefix-arg))
2790 (funcall gnus-group-sort-alist-function
2791 (gnus-make-sort-function func) reverse)
2792 (gnus-group-unmark-all-groups)
2793 (gnus-group-list-groups)
2794 (gnus-dribble-touch))
2796 (defun gnus-group-sort-flat (func reverse)
2797 ;; We peel off the dummy group from the alist.
2799 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2800 (pop gnus-newsrc-alist))
2802 (setq gnus-newsrc-alist
2803 (sort gnus-newsrc-alist func))
2805 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2806 ;; Regenerate the hash table.
2807 (gnus-make-hashtable-from-newsrc-alist)))
2809 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2810 "Sort the group buffer alphabetically by group name.
2811 If REVERSE, sort in reverse order."
2813 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2815 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2816 "Sort the group buffer alphabetically by real (unprefixed) group name.
2817 If REVERSE, sort in reverse order."
2819 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2821 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2822 "Sort the group buffer by number of unread articles.
2823 If REVERSE, sort in reverse order."
2825 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2827 (defun gnus-group-sort-groups-by-level (&optional reverse)
2828 "Sort the group buffer by group level.
2829 If REVERSE, sort in reverse order."
2831 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2833 (defun gnus-group-sort-groups-by-score (&optional reverse)
2834 "Sort the group buffer by group score.
2835 If REVERSE, sort in reverse order."
2837 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2839 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2840 "Sort the group buffer by group rank.
2841 If REVERSE, sort in reverse order."
2843 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2845 (defun gnus-group-sort-groups-by-method (&optional reverse)
2846 "Sort the group buffer alphabetically by backend name.
2847 If REVERSE, sort in reverse order."
2849 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2851 (defun gnus-group-sort-groups-by-server (&optional reverse)
2852 "Sort the group buffer alphabetically by server name.
2853 If REVERSE, sort in reverse order."
2855 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2857 ;;; Selected group sorting.
2859 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2860 "Sort the process/prefixed groups."
2861 (interactive (list current-prefix-arg gnus-group-sort-function))
2862 (let ((groups (gnus-group-process-prefix n)))
2863 (funcall gnus-group-sort-selected-function
2864 groups (gnus-make-sort-function func) reverse)
2865 (gnus-group-unmark-all-groups)
2866 (gnus-group-list-groups)
2867 (gnus-dribble-touch)))
2869 (defun gnus-group-sort-selected-flat (groups func reverse)
2870 (let (entries infos)
2871 ;; First find all the group entries for these groups.
2873 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2875 ;; Then sort the infos.
2879 (lambda (entry) (car entry))
2880 (setq entries (nreverse entries)))
2883 (setq infos (nreverse infos)))
2884 ;; Go through all the infos and replace the old entries
2885 ;; with the new infos.
2887 (setcar (car entries) (pop infos))
2889 ;; Update the hashtable.
2890 (gnus-make-hashtable-from-newsrc-alist)))
2892 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2893 "Sort the group buffer alphabetically by group name.
2894 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2895 sort in reverse order."
2896 (interactive (gnus-interactive "P\ny"))
2897 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2899 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2900 "Sort the group buffer alphabetically by real group name.
2901 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2902 sort in reverse order."
2903 (interactive (gnus-interactive "P\ny"))
2904 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2906 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2907 "Sort the group buffer by number of unread articles.
2908 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2909 sort in reverse order."
2910 (interactive (gnus-interactive "P\ny"))
2911 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2913 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2914 "Sort the group buffer by group level.
2915 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2916 sort in reverse order."
2917 (interactive (gnus-interactive "P\ny"))
2918 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2920 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2921 "Sort the group buffer by group score.
2922 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2923 sort in reverse order."
2924 (interactive (gnus-interactive "P\ny"))
2925 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2927 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2928 "Sort the group buffer by group rank.
2929 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2930 sort in reverse order."
2931 (interactive (gnus-interactive "P\ny"))
2932 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2934 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2935 "Sort the group buffer alphabetically by backend name.
2936 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2937 sort in reverse order."
2938 (interactive (gnus-interactive "P\ny"))
2939 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2941 ;;; Sorting predicates.
2943 (defun gnus-group-sort-by-alphabet (info1 info2)
2944 "Sort alphabetically."
2945 (string< (gnus-info-group info1) (gnus-info-group info2)))
2947 (defun gnus-group-sort-by-real-name (info1 info2)
2948 "Sort alphabetically on real (unprefixed) names."
2949 (string< (gnus-group-real-name (gnus-info-group info1))
2950 (gnus-group-real-name (gnus-info-group info2))))
2952 (defun gnus-group-sort-by-unread (info1 info2)
2953 "Sort by number of unread articles."
2954 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2955 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2956 (< (or (and (numberp n1) n1) 0)
2957 (or (and (numberp n2) n2) 0))))
2959 (defun gnus-group-sort-by-level (info1 info2)
2961 (< (gnus-info-level info1) (gnus-info-level info2)))
2963 (defun gnus-group-sort-by-method (info1 info2)
2964 "Sort alphabetically by backend name."
2965 (string< (car (gnus-find-method-for-group
2966 (gnus-info-group info1) info1))
2967 (car (gnus-find-method-for-group
2968 (gnus-info-group info2) info2))))
2970 (defun gnus-group-sort-by-server (info1 info2)
2971 "Sort alphabetically by server name."
2972 (string< (gnus-method-to-full-server-name
2973 (gnus-find-method-for-group
2974 (gnus-info-group info1) info1))
2975 (gnus-method-to-full-server-name
2976 (gnus-find-method-for-group
2977 (gnus-info-group info2) info2))))
2979 (defun gnus-group-sort-by-score (info1 info2)
2980 "Sort by group score."
2981 (> (gnus-info-score info1) (gnus-info-score info2)))
2983 (defun gnus-group-sort-by-rank (info1 info2)
2984 "Sort by level and score."
2985 (let ((level1 (gnus-info-level info1))
2986 (level2 (gnus-info-level info2)))
2987 (or (< level1 level2)
2988 (and (= level1 level2)
2989 (> (gnus-info-score info1) (gnus-info-score info2))))))
2993 (defun gnus-group-clear-data (&optional arg)
2994 "Clear all marks and read ranges from the current group."
2996 (gnus-group-iterate arg
2999 (gnus-info-clear-data (setq info (gnus-get-info group)))
3000 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3001 (when (gnus-group-goto-group group)
3002 (gnus-group-update-group-line))))))
3004 (defun gnus-group-clear-data-on-native-groups ()
3005 "Clear all marks and read ranges from all native groups."
3007 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3008 (let ((alist (cdr gnus-newsrc-alist))
3010 (while (setq info (pop alist))
3011 (when (gnus-group-native-p (gnus-info-group info))
3012 (gnus-info-clear-data info)))
3013 (gnus-get-unread-articles)
3014 (gnus-dribble-touch)
3015 (when (gnus-y-or-n-p
3016 "Move the cache away to avoid problems in the future? ")
3017 (call-interactively 'gnus-cache-move-cache)))))
3019 (defun gnus-info-clear-data (info)
3020 "Clear all marks and read ranges from INFO."
3021 (let ((group (gnus-info-group info))
3023 (dolist (el (gnus-info-marks info))
3024 (push `(,(cdr el) add (,(car el))) action))
3025 (push `(,(gnus-info-read info) add (read)) action)
3028 (gnus-request-set-mark ,group ',action)
3029 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3030 (gnus-info-set-read ',info ',(gnus-info-read info))
3031 (when (gnus-group-goto-group ,group)
3032 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3033 (gnus-group-update-group-line))))
3034 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3036 (gnus-request-set-mark group action)
3037 (gnus-info-set-read info nil)
3038 (when (gnus-info-marks info)
3039 (gnus-info-set-marks info nil))))
3041 ;; Group catching up.
3043 (defun gnus-group-catchup-current (&optional n all)
3044 "Mark all unread articles in the current newsgroup as read.
3045 If prefix argument N is numeric, the next N newsgroups will be
3046 caught up. If ALL is non-nil, marked articles will also be marked as
3047 read. Cross references (Xref: header) of articles are ignored.
3048 The number of newsgroups that this function was unable to catch
3051 (let ((groups (gnus-group-process-prefix n))
3054 (unless groups (error "No groups selected"))
3056 (or (not gnus-interactive-catchup) ;Without confirmation?
3061 "Do you really want to mark all articles in %s as read? "
3062 "Mark all unread articles in %s as read? ")
3063 (if (= (length groups) 1)
3065 (format "these %d groups" (length groups)))))))
3067 (while (setq group (pop groups))
3068 (gnus-group-remove-mark group)
3069 ;; Virtual groups have to be given special treatment.
3070 (let ((method (gnus-find-method-for-group group)))
3071 (when (eq 'nnvirtual (car method))
3072 (nnvirtual-catchup-group
3073 (gnus-group-real-name group) (nth 1 method) all)))
3074 (if (>= (gnus-group-level group) gnus-level-zombie)
3075 (gnus-message 2 "Dead groups can't be caught up")
3077 (gnus-group-goto-group group)
3078 (gnus-group-catchup group all))
3079 (gnus-group-update-group-line)
3080 (setq ret (1+ ret)))))
3081 (gnus-group-next-unread-group 1)
3084 (defun gnus-group-catchup-current-all (&optional n)
3085 "Mark all articles in current newsgroup as read.
3086 Cross references (Xref: header) of articles are ignored."
3088 (gnus-group-catchup-current n 'all))
3090 (defun gnus-group-catchup (group &optional all)
3091 "Mark all articles in GROUP as read.
3092 If ALL is non-nil, all articles are marked as read.
3093 The return value is the number of articles that were marked as read,
3094 or nil if no action could be taken."
3095 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3097 (marks (nth 3 (nth 2 entry)))
3098 (unread (gnus-list-of-unread-articles group)))
3099 ;; Remove entries for this group.
3100 (nnmail-purge-split-history (gnus-group-real-name group))
3101 ;; Do the updating only if the newsgroup isn't killed.
3102 (if (not (numberp (car entry)))
3103 (gnus-message 1 "Can't catch up %s; non-active group" group)
3104 (gnus-update-read-articles group nil)
3106 ;; Nix out the lists of marks and dormants.
3107 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3109 (list (cdr (assq 'dormant marks))
3111 (setq unread (gnus-uncompress-range
3112 (gnus-range-add (gnus-range-add
3113 unread (cdr (assq 'dormant marks)))
3114 (cdr (assq 'tick marks)))))
3115 (gnus-add-marked-articles group 'tick nil nil 'force)
3116 (gnus-add-marked-articles group 'dormant nil nil 'force))
3117 ;; Do auto-expirable marks if that's required.
3118 (when (gnus-group-auto-expirable-p group)
3119 (gnus-add-marked-articles group 'expire unread)
3120 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3121 (let ((gnus-newsgroup-name group))
3122 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3125 (defun gnus-group-expire-articles (&optional n)
3126 "Expire all expirable articles in the current newsgroup.
3127 Uses the process/prefix convention."
3129 (let ((groups (gnus-group-process-prefix n))
3132 (error "No groups to expire"))
3133 (while (setq group (pop groups))
3134 (gnus-group-remove-mark group)
3135 (gnus-group-expire-articles-1 group)
3136 (gnus-dribble-touch)
3137 (gnus-group-position-point))))
3139 (defun gnus-group-expire-articles-1 (group)
3140 (when (gnus-check-backend-function 'request-expire-articles group)
3141 (gnus-message 6 "Expiring articles in %s..." group)
3142 (let* ((info (gnus-get-info group))
3143 (expirable (if (gnus-group-total-expirable-p group)
3144 (cons nil (gnus-list-of-read-articles group))
3145 (assq 'expire (gnus-info-marks info))))
3146 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3147 (nnmail-expiry-target
3148 (or (gnus-group-find-parameter group 'expiry-target)
3149 nnmail-expiry-target)))
3151 (gnus-check-group group)
3154 (gnus-compress-sequence
3156 ;; We set the expiry variables to the group
3158 (let ((nnmail-expiry-wait-function nil)
3159 (nnmail-expiry-wait expiry-wait))
3160 (gnus-request-expire-articles
3161 (gnus-uncompress-sequence (cdr expirable)) group))
3162 ;; Just expire using the normal expiry values.
3163 (gnus-request-expire-articles
3164 (gnus-uncompress-sequence (cdr expirable)) group))))
3165 (gnus-close-group group))
3166 (gnus-message 6 "Expiring articles in %s...done" group)
3167 ;; Return the list of un-expired articles.
3170 (defun gnus-group-expire-all-groups ()
3171 "Expire all expirable articles in all newsgroups."
3174 (gnus-message 5 "Expiring...")
3175 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3176 (cdr gnus-newsrc-alist))))
3177 (gnus-group-expire-articles nil)))
3178 (gnus-group-position-point)
3179 (gnus-message 5 "Expiring...done"))
3181 (defun gnus-group-set-current-level (n level)
3182 "Set the level of the next N groups to LEVEL."
3187 (let ((s (read-string
3188 (format "Level (default %s): "
3189 (or (gnus-group-group-level)
3190 gnus-level-default-subscribed)))))
3191 (if (string-match "^\\s-*$" s)
3192 (int-to-string (or (gnus-group-group-level)
3193 gnus-level-default-subscribed))
3195 (unless (and (>= level 1) (<= level gnus-level-killed))
3196 (error "Invalid level: %d" level))
3197 (let ((groups (gnus-group-process-prefix n))
3199 (while (setq group (pop groups))
3200 (gnus-group-remove-mark group)
3201 (gnus-message 6 "Changed level of %s from %d to %d"
3202 group (or (gnus-group-group-level) gnus-level-killed)
3204 (gnus-group-change-level
3205 group level (or (gnus-group-group-level) gnus-level-killed))
3206 (gnus-group-update-group-line)))
3207 (gnus-group-position-point))
3209 (defun gnus-group-unsubscribe (&optional n)
3210 "Unsubscribe the current group."
3212 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3214 (defun gnus-group-subscribe (&optional n)
3215 "Subscribe the current group."
3217 (gnus-group-unsubscribe-current-group n 'subscribe))
3219 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3220 "Toggle subscription of the current group.
3221 If given numerical prefix, toggle the N next groups."
3223 (let ((groups (gnus-group-process-prefix n))
3226 (setq group (car groups)
3227 groups (cdr groups))
3228 (gnus-group-remove-mark group)
3229 (gnus-group-unsubscribe-group
3232 ((eq do-sub 'unsubscribe)
3233 gnus-level-default-unsubscribed)
3234 ((eq do-sub 'subscribe)
3235 gnus-level-default-subscribed)
3236 ((<= (gnus-group-group-level) gnus-level-subscribed)
3237 gnus-level-default-unsubscribed)
3239 gnus-level-default-subscribed))
3241 (gnus-group-update-group-line))
3242 (gnus-group-next-group 1)))
3244 (defun gnus-group-unsubscribe-group (group &optional level silent)
3245 "Toggle subscription to GROUP.
3246 Killed newsgroups are subscribed. If SILENT, don't try to update the
3249 (list (gnus-group-completing-read-group-name
3250 "Group: " gnus-active-hashtb nil
3251 (gnus-read-active-file-p)
3253 'gnus-group-history)))
3254 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3256 ((string-match "^[ \t]*$" group)
3257 (error "Empty group name"))
3259 ;; Toggle subscription flag.
3260 (gnus-group-change-level
3261 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3262 gnus-level-subscribed)
3263 (1+ gnus-level-subscribed)
3264 gnus-level-default-subscribed)))
3266 (gnus-group-update-group group)))
3267 ((and (stringp group)
3268 (or (not (gnus-read-active-file-p))
3269 (gnus-active group)))
3270 ;; Add new newsgroup.
3271 (gnus-group-change-level
3273 (if level level gnus-level-default-subscribed)
3274 (or (and (member group gnus-zombie-list)
3277 (when (gnus-group-group-name)
3278 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3280 (gnus-group-update-group group)))
3281 (t (error "No such newsgroup: %s" group)))
3282 (gnus-group-position-point)))
3284 (defun gnus-group-transpose-groups (n)
3285 "Move the current newsgroup up N places.
3286 If given a negative prefix, move down instead. The difference between
3287 N and the number of steps taken is returned."
3289 (unless (gnus-group-group-name)
3290 (error "No group on current line"))
3291 (gnus-group-kill-group 1)
3293 (forward-line (- n))
3294 (gnus-group-yank-group)
3295 (gnus-group-position-point)))
3297 (defun gnus-group-kill-all-zombies (&optional dummy)
3298 "Kill all zombie newsgroups.
3299 The optional DUMMY should always be nil."
3300 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3302 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3303 (setq gnus-zombie-list nil)
3304 (gnus-dribble-touch)
3305 (gnus-group-list-groups)))
3307 (defun gnus-group-kill-region (begin end)
3308 "Kill newsgroups in current region (excluding current point).
3309 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3324 (beginning-of-line) ;Important when LINES < 1
3325 (gnus-group-kill-group lines)))
3327 (defun gnus-group-kill-group (&optional n discard)
3328 "Kill the next N groups.
3329 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3330 However, only groups that were alive can be yanked; already killed
3331 groups or zombie groups can't be yanked.
3332 The return value is the name of the group that was killed, or a list
3335 (let ((buffer-read-only nil)
3336 (groups (gnus-group-process-prefix n))
3337 group entry level out)
3338 (if (< (length groups) 10)
3339 ;; This is faster when there are few groups.
3341 (push (setq group (pop groups)) out)
3342 (gnus-group-remove-mark group)
3343 (setq level (gnus-group-group-level))
3345 (when (and (not discard)
3346 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3349 (gnus-group-goto-group ,(gnus-group-group-name))
3350 (gnus-group-yank-group)))
3351 (push (cons (car entry) (nth 2 entry))
3352 gnus-list-of-killed-groups))
3353 (gnus-group-change-level
3354 (if entry entry group) gnus-level-killed (if entry nil level))
3355 (message "Killed group %s" group))
3356 ;; If there are lots and lots of groups to be killed, we use
3357 ;; this thing instead.
3359 (setq groups (nreverse groups))
3361 (gnus-group-remove-mark (setq group (pop groups)))
3363 (push group gnus-killed-list)
3364 (setq gnus-newsrc-alist
3365 (delq (assoc group gnus-newsrc-alist)
3367 (when gnus-group-change-level-function
3368 (funcall gnus-group-change-level-function
3369 group gnus-level-killed 3))
3371 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3372 (push (cons (car entry) (nth 2 entry))
3373 gnus-list-of-killed-groups)
3374 (setcdr (cdr entry) (cdddr entry)))
3375 ((member group gnus-zombie-list)
3376 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3377 ;; There may be more than one instance displayed.
3378 (while (gnus-group-goto-group group)
3379 (gnus-delete-line)))
3380 (gnus-make-hashtable-from-newsrc-alist)))
3382 (gnus-group-position-point)
3383 (if (< (length out) 2) (car out) (nreverse out))))
3385 (defun gnus-group-yank-group (&optional arg)
3386 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3387 The numeric ARG specifies how many newsgroups are to be yanked. The
3388 name of the newsgroup yanked is returned, or (if several groups are
3389 yanked) a list of yanked groups is returned."
3391 (setq arg (or arg 1))
3392 (let (info group prev out)
3393 (while (>= (decf arg) 0)
3394 (when (not (setq info (pop gnus-list-of-killed-groups)))
3395 (error "No more newsgroups to yank"))
3396 (push (setq group (nth 1 info)) out)
3397 ;; Find which newsgroup to insert this one before - search
3398 ;; backward until something suitable is found. If there are no
3399 ;; other newsgroups in this buffer, just make this newsgroup the
3401 (setq prev (gnus-group-group-name))
3402 (gnus-group-change-level
3403 info (gnus-info-level (cdr info)) gnus-level-killed
3404 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3406 (gnus-group-insert-group-line-info group)
3408 `(when (gnus-group-goto-group ,group)
3409 (gnus-group-kill-group 1))))
3411 (gnus-group-position-point)
3412 (if (< (length out) 2) (car out) (nreverse out))))
3414 (defun gnus-group-kill-level (level)
3415 "Kill all groups that is on a certain LEVEL."
3416 (interactive "nKill all groups on level: ")
3418 ((= level gnus-level-zombie)
3419 (setq gnus-killed-list
3420 (nconc gnus-zombie-list gnus-killed-list))
3421 (setq gnus-zombie-list nil))
3422 ((and (< level gnus-level-zombie)
3424 (or gnus-expert-user
3427 "Do you really want to kill all groups on level %d? "
3429 (let* ((prev gnus-newsrc-alist)
3432 (if (= (gnus-info-level (car alist)) level)
3434 (push (gnus-info-group (car alist)) gnus-killed-list)
3435 (setcdr prev (cdr alist)))
3437 (setq alist (cdr alist)))
3438 (gnus-make-hashtable-from-newsrc-alist)
3439 (gnus-group-list-groups)))
3441 (error "Can't kill; invalid level: %d" level))))
3443 (defun gnus-group-list-all-groups (&optional arg)
3444 "List all newsgroups with level ARG or lower.
3445 Default is gnus-level-unsubscribed, which lists all subscribed and most
3446 unsubscribed groups."
3448 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3450 ;; Redefine this to list ALL killed groups if prefix arg used.
3451 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3452 (defun gnus-group-list-killed (&optional arg)
3453 "List all killed newsgroups in the group buffer.
3454 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3455 entail asking the server for the groups."
3457 ;; Find all possible killed newsgroups if arg.
3459 (gnus-get-killed-groups))
3460 (if (not gnus-killed-list)
3461 (gnus-message 6 "No killed groups")
3462 (let (gnus-group-list-mode)
3463 (funcall gnus-group-prepare-function
3464 gnus-level-killed t gnus-level-killed))
3465 (goto-char (point-min)))
3466 (gnus-group-position-point))
3468 (defun gnus-group-list-zombies ()
3469 "List all zombie newsgroups in the group buffer."
3471 (if (not gnus-zombie-list)
3472 (gnus-message 6 "No zombie groups")
3473 (let (gnus-group-list-mode)
3474 (funcall gnus-group-prepare-function
3475 gnus-level-zombie t gnus-level-zombie))
3476 (goto-char (point-min)))
3477 (gnus-group-position-point))
3479 (defun gnus-group-list-active ()
3480 "List all groups that are available from the server(s)."
3482 ;; First we make sure that we have really read the active file.
3483 (unless (gnus-read-active-file-p)
3484 (let ((gnus-read-active-file t)
3485 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3486 (gnus-read-active-file)))
3487 ;; Find all groups and sort them.
3495 (push (symbol-name sym) list)))
3499 (buffer-read-only nil)
3503 (setq group (pop groups))
3504 (gnus-add-text-properties
3505 (point) (prog1 (1+ (point))
3507 (gnus-group-decoded-name group)
3509 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3511 'gnus-level (inline (gnus-group-level group)))))
3512 (goto-char (point-min))))
3514 (defun gnus-activate-all-groups (level)
3515 "Activate absolutely all groups."
3516 (interactive (list gnus-level-unsubscribed))
3517 (let ((gnus-activate-level level)
3518 (gnus-activate-foreign-newsgroups level))
3519 (gnus-group-get-new-news)))
3521 (defun gnus-group-get-new-news (&optional arg)
3522 "Get newly arrived articles.
3523 If ARG is a number, it specifies which levels you are interested in
3524 re-scanning. If ARG is non-nil and not a number, this will force
3525 \"hard\" re-reading of the active files from all servers."
3528 (let ((gnus-inhibit-demon t)
3529 ;; Binding this variable will inhibit multiple fetchings
3530 ;; of the same mail source.
3531 (nnmail-fetched-sources (list t)))
3532 (gnus-run-hooks 'gnus-get-new-news-hook)
3534 ;; Read any slave files.
3536 (gnus-master-read-slave-newsrc))
3538 ;; We might read in new NoCeM messages here.
3539 (when (and gnus-use-nocem
3541 (gnus-nocem-scan-groups))
3542 ;; If ARG is not a number, then we read the active file.
3543 (when (and arg (not (numberp arg)))
3544 (let ((gnus-read-active-file t))
3545 (gnus-read-active-file))
3548 ;; If the user wants it, we scan for new groups.
3549 (when (eq gnus-check-new-newsgroups 'always)
3550 (gnus-find-new-newsgroups)))
3552 (setq arg (gnus-group-default-level arg t))
3553 (if (and gnus-read-active-file (not arg))
3555 (gnus-read-active-file)
3556 (gnus-get-unread-articles arg))
3557 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3558 (gnus-get-unread-articles arg)))
3559 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3560 (gnus-group-list-groups (and (numberp arg)
3561 (max (car gnus-group-list-mode) arg))))
3563 (when (and gnus-agent (not (interactive-p)))
3564 (gnus-agent-toggle-plugged gnus-plugged)))
3566 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3567 "Check for newly arrived news in the current group (and the N-1 next groups).
3568 The difference between N and the number of newsgroup checked is returned.
3569 If N is negative, this group and the N-1 previous groups will be checked."
3571 (let* ((groups (gnus-group-process-prefix n))
3572 (ret (if (numberp n) (- n (length groups)) 0))
3576 (gnus-inhibit-demon t)
3577 ;; Binding this variable will inhibit multiple fetchings
3578 ;; of the same mail source.
3579 (nnmail-fetched-sources (list t)))
3580 (gnus-run-hooks 'gnus-get-new-news-hook)
3581 (while (setq group (pop groups))
3582 (gnus-group-remove-mark group)
3583 ;; Bypass any previous denials from the server.
3584 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3585 (if (gnus-activate-group group (if dont-scan nil 'scan))
3587 (gnus-get-unread-articles-in-group
3588 (gnus-get-info group) (gnus-active group) t)
3589 (unless (gnus-virtual-group-p group)
3590 (gnus-close-group group))
3592 (gnus-agent-save-group-info
3593 method (gnus-group-real-name group) (gnus-active group)))
3594 (gnus-group-update-group group))
3595 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3597 (gnus-error 3 "Server denied access")
3598 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3601 (when gnus-goto-next-group-when-activating
3602 (gnus-group-next-unread-group 1 t))
3603 (gnus-summary-position-point)
3606 (defun gnus-group-fetch-faq (group &optional faq-dir)
3607 "Fetch the FAQ for the current group.
3608 If given a prefix argument, prompt for the FAQ dir
3612 (gnus-group-group-name)
3613 (when current-prefix-arg
3615 "FAQ dir: " (and (listp gnus-group-faq-directory)
3617 gnus-group-faq-directory))))))
3619 (error "No group name given"))
3620 (let ((dirs (or faq-dir gnus-group-faq-directory))
3622 (unless (listp dirs)
3623 (setq dirs (list dirs)))
3624 (while (and (not found)
3625 (setq dir (pop dirs)))
3626 (let ((name (gnus-group-real-name group)))
3627 (setq file (expand-file-name name dir)))
3628 (if (not (file-exists-p file))
3629 (gnus-message 1 "No such file: %s" file)
3630 (let ((enable-local-variables nil))
3634 (defun gnus-group-fetch-charter (group)
3635 "Fetch the charter for the current group.
3636 If given a prefix argument, prompt for a group."
3638 (list (or (when current-prefix-arg
3639 (completing-read "Group: " gnus-active-hashtb))
3640 (gnus-group-group-name)
3641 gnus-newsgroup-name)))
3643 (error "No group name given"))
3645 (condition-case nil (require 'url-http) (error nil))
3646 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3648 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3649 (setq hierarchy (match-string 1 name))
3650 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3651 (if (fboundp 'url-http-file-exists-p)
3652 (url-http-file-exists-p (eval url))
3654 (browse-url (eval url))
3655 (setq url (concat "http://" hierarchy
3656 ".news-admin.org/charters/" name))
3657 (if (and (fboundp 'url-http-file-exists-p)
3658 (url-http-file-exists-p url))
3660 (gnus-group-fetch-control group))))))
3662 (defun gnus-group-fetch-control (group)
3663 "Fetch the archived control messages for the current group.
3664 If given a prefix argument, prompt for a group."
3666 (list (or (when current-prefix-arg
3667 (completing-read "Group: " gnus-active-hashtb))
3668 (gnus-group-group-name)
3669 gnus-newsgroup-name)))
3671 (error "No group name given"))
3672 (let ((name (gnus-group-real-name group))
3674 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3675 (setq hierarchy (match-string 1 name))
3676 (if gnus-group-fetch-control-use-browse-url
3677 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3678 hierarchy "/" name ".Z"))
3679 (let ((enable-local-variables nil))
3680 (gnus-group-read-ephemeral-group
3682 `(nndoc ,group (nndoc-address
3683 ,(find-file-noselect
3684 (concat "/ftp@ftp.isc.org:/usenet/control/"
3685 hierarchy "/" name ".Z")))
3686 (nndoc-article-type mbox)) t nil nil))))))
3688 (defun gnus-group-describe-group (force &optional group)
3689 "Display a description of the current newsgroup."
3690 (interactive (list current-prefix-arg (gnus-group-group-name)))
3691 (let* ((method (gnus-find-method-for-group group))
3692 (mname (gnus-group-prefixed-name "" method))
3695 gnus-description-hashtb)
3696 (gnus-sethash mname nil gnus-description-hashtb))
3698 (error "No group name given"))
3699 (when (or (and gnus-description-hashtb
3700 ;; We check whether this group's method has been
3701 ;; queried for a description file.
3702 (gnus-gethash mname gnus-description-hashtb))
3703 (setq desc (gnus-group-get-description group))
3704 (gnus-read-descriptions-file method))
3706 (or desc (gnus-gethash group gnus-description-hashtb)
3707 "No description available")))))
3709 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3710 (defun gnus-group-describe-all-groups (&optional force)
3711 "Pop up a buffer with descriptions of all newsgroups."
3714 (setq gnus-description-hashtb nil))
3715 (when (not (or gnus-description-hashtb
3716 (gnus-read-all-descriptions-files)))
3717 (error "Couldn't request descriptions file"))
3718 (let ((buffer-read-only nil)
3724 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3725 (insert (format " *: %-20s %s\n"
3726 (gnus-group-name-decode
3727 (symbol-name group) charset)
3728 (gnus-group-name-decode
3729 (symbol-value group) charset))))
3730 (gnus-add-text-properties
3731 b (1+ b) (list 'gnus-group group
3732 'gnus-unread t 'gnus-marked nil
3733 'gnus-level (1+ gnus-level-subscribed))))
3734 gnus-description-hashtb)
3735 (goto-char (point-min))
3736 (gnus-group-position-point)))
3738 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3739 (defun gnus-group-apropos (regexp &optional search-description)
3740 "List all newsgroups that have names that match a regexp."
3741 (interactive "sGnus apropos (regexp): ")
3743 (obuf (current-buffer))
3745 ;; Go through all newsgroups that are known to Gnus.
3748 (and (symbol-name group)
3749 (string-match regexp (symbol-name group))
3750 (symbol-value group)
3751 (push (symbol-name group) groups)))
3753 ;; Also go through all descriptions that are known to Gnus.
3754 (when search-description
3757 (and (string-match regexp (symbol-value group))
3758 (push (symbol-name group) groups)))
3759 gnus-description-hashtb))
3761 (gnus-message 3 "No groups matched \"%s\"." regexp)
3762 ;; Print out all the groups.
3764 (pop-to-buffer "*Gnus Help*")
3765 (buffer-disable-undo)
3767 (setq groups (sort groups 'string<))
3769 ;; Groups may be entered twice into the list of groups.
3770 (when (not (string= (car groups) prev))
3771 (setq prev (car groups))
3772 (let ((charset (gnus-group-name-charset nil prev)))
3773 (insert (gnus-group-name-decode prev charset) "\n")
3774 (when (and gnus-description-hashtb
3775 (setq des (gnus-gethash (car groups)
3776 gnus-description-hashtb)))
3777 (insert " " (gnus-group-name-decode des charset) "\n"))))
3778 (setq groups (cdr groups)))
3779 (goto-char (point-min))))
3780 (pop-to-buffer obuf)))
3782 (defun gnus-group-description-apropos (regexp)
3783 "List all newsgroups that have names or descriptions that match a regexp."
3784 (interactive "sGnus description apropos (regexp): ")
3785 (when (not (or gnus-description-hashtb
3786 (gnus-read-all-descriptions-files)))
3787 (error "Couldn't request descriptions file"))
3788 (gnus-group-apropos regexp t))
3790 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3791 (defun gnus-group-list-matching (level regexp &optional all lowest)
3792 "List all groups with unread articles that match REGEXP.
3793 If the prefix LEVEL is non-nil, it should be a number that says which
3794 level to cut off listing groups.
3795 If ALL, also list groups with no unread articles.
3796 If LOWEST, don't list groups with level lower than LOWEST.
3798 This command may read the active file."
3799 (interactive "P\nsList newsgroups matching: ")
3800 ;; First make sure active file has been read.
3802 (> (prefix-numeric-value level) gnus-level-killed))
3803 (gnus-get-killed-groups))
3804 (funcall gnus-group-prepare-function
3805 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3806 (goto-char (point-min))
3807 (gnus-group-position-point))
3809 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3810 "List all groups that match REGEXP.
3811 If the prefix LEVEL is non-nil, it should be a number that says which
3812 level to cut off listing groups.
3813 If LOWEST, don't list groups with level lower than LOWEST."
3814 (interactive "P\nsList newsgroups matching: ")
3816 (setq level (prefix-numeric-value level)))
3817 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3819 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3820 (defun gnus-group-save-newsrc (&optional force)
3821 "Save the Gnus startup files.
3822 If FORCE, force saving whether it is necessary or not."
3824 (gnus-save-newsrc-file force))
3826 (defun gnus-group-restart (&optional arg)
3827 "Force Gnus to read the .newsrc file."
3829 (when (gnus-yes-or-no-p
3830 (format "Are you sure you want to restart Gnus? "))
3831 (gnus-save-newsrc-file)
3835 (defun gnus-group-read-init-file ()
3836 "Read the Gnus elisp init file."
3838 (gnus-read-init-file)
3839 (gnus-message 5 "Read %s" gnus-init-file))
3841 (defun gnus-group-check-bogus-groups (&optional silent)
3842 "Check bogus newsgroups.
3843 If given a prefix, don't ask for confirmation before removing a bogus
3846 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3847 (gnus-group-list-groups))
3849 (defun gnus-group-find-new-groups (&optional arg)
3850 "Search for new groups and add them.
3851 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3852 With 1 C-u, use the `ask-server' method to query the server for new
3854 With 2 C-u's, use most complete method possible to query the server
3855 for new groups, and subscribe the new groups as zombies."
3857 (gnus-find-new-newsgroups (or arg 1))
3858 (gnus-group-list-groups))
3860 (defun gnus-group-edit-global-kill (&optional article group)
3861 "Edit the global kill file.
3862 If GROUP, edit that local kill file instead."
3864 (setq gnus-current-kill-article article)
3865 (gnus-kill-file-edit-file group)
3868 (substitute-command-keys
3869 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3870 (if group "local" "global")))))
3872 (defun gnus-group-edit-local-kill (article group)
3873 "Edit a local kill file."
3874 (interactive (list nil (gnus-group-group-name)))
3875 (gnus-group-edit-global-kill article group))
3877 (defun gnus-group-force-update ()
3878 "Update `.newsrc' file."
3880 (gnus-save-newsrc-file))
3882 (defun gnus-group-suspend ()
3883 "Suspend the current Gnus session.
3884 In fact, cleanup buffers except for group mode buffer.
3885 The hook gnus-suspend-gnus-hook is called before actually suspending."
3887 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3888 (gnus-offer-save-summaries)
3889 ;; Kill Gnus buffers except for group mode buffer.
3890 (let ((group-buf (get-buffer gnus-group-buffer)))
3891 (mapcar (lambda (buf)
3892 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3896 (eq major-mode 'message-mode))))
3897 (gnus-kill-buffer buf)))
3899 (gnus-kill-gnus-frames)
3901 (bury-buffer group-buf)
3902 (delete-windows-on group-buf t))))
3904 (defun gnus-group-clear-dribble ()
3905 "Clear all information from the dribble buffer."
3907 (gnus-dribble-clear)
3908 (gnus-message 7 "Cleared dribble buffer"))
3910 (defun gnus-group-exit ()
3911 "Quit reading news after updating .newsrc.eld and .newsrc.
3912 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3915 (or noninteractive ;For gnus-batch-kill
3916 (not gnus-interactive-exit) ;Without confirmation
3918 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3919 (gnus-run-hooks 'gnus-exit-gnus-hook)
3920 ;; Offer to save data from non-quitted summary buffers.
3921 (gnus-offer-save-summaries)
3922 ;; Save the newsrc file(s).
3923 (gnus-save-newsrc-file)
3925 (gnus-close-backends)
3926 ;; Reset everything.
3928 ;; Allow the user to do things after cleaning up.
3929 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3931 (defun gnus-group-quit ()
3932 "Quit reading news without updating .newsrc.eld or .newsrc.
3933 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3935 (when (or noninteractive ;For gnus-batch-kill
3936 (zerop (buffer-size))
3937 (not (gnus-server-opened gnus-select-method))
3939 (not gnus-current-startup-file)
3941 (format "Quit reading news without saving %s? "
3942 (file-name-nondirectory gnus-current-startup-file))))
3943 (gnus-run-hooks 'gnus-exit-gnus-hook)
3944 (gnus-configure-windows 'group t)
3945 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3946 (not (zerop (save-excursion
3947 (set-buffer gnus-dribble-buffer)
3950 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3952 (gnus-close-backends)
3954 (gnus-kill-buffer gnus-group-buffer)
3955 ;; Allow the user to do things after cleaning up.
3956 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3958 (defun gnus-group-describe-briefly ()
3959 "Give a one line description of the group mode commands."
3961 (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")))
3963 (defun gnus-group-browse-foreign-server (method)
3964 "Browse a foreign news server.
3965 If called interactively, this function will ask for a select method
3966 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3967 If not, METHOD should be a list where the first element is the method
3968 and the second element is the address."
3970 (list (let ((how (completing-read
3972 (append gnus-valid-select-methods gnus-server-alist)
3973 nil t (cons "nntp" 0) 'gnus-method-history)))
3974 ;; We either got a backend name or a virtual server name.
3975 ;; If the first, we also need an address.
3976 (if (assoc how gnus-valid-select-methods)
3978 ;; Suggested by mapjph@bath.ac.uk.
3981 (mapcar (lambda (server) (list server))
3982 gnus-secondary-servers)))
3983 ;; We got a server name.
3985 (gnus-browse-foreign-server method))
3987 (defun gnus-group-set-info (info &optional method-only-group part)
3988 (when (or info part)
3989 (let* ((entry (gnus-gethash
3990 (or method-only-group (gnus-info-group info))
3991 gnus-newsrc-hashtb))
3993 (info (if method-only-group (nth 2 entry) info))
3995 (when method-only-group
3997 (error "Trying to change non-existent group %s" method-only-group))
3998 ;; We have received parts of the actual group info - either the
3999 ;; select method or the group parameters. We first check
4000 ;; whether we have to extend the info, and if so, do that.
4001 (let ((len (length info))
4002 (total (if (eq part 'method) 5 6)))
4004 (setcdr (nthcdr (1- len) info)
4005 (make-list (- total len) nil)))
4006 ;; Then we enter the new info.
4007 (setcar (nthcdr (1- total) info) part-info)))
4009 ;; This is a new group, so we just create it.
4011 (set-buffer gnus-group-buffer)
4012 (setq method (gnus-info-method info))
4013 (when (gnus-server-equal method "native")
4016 (set-buffer gnus-group-buffer)
4018 ;; It's a foreign group...
4019 (gnus-group-make-group
4020 (gnus-group-real-name (gnus-info-group info))
4021 (if (stringp method) method
4022 (prin1-to-string (car method)))
4024 (nth 1 (gnus-info-method info))))
4025 ;; It's a native group.
4026 (gnus-group-make-group (gnus-info-group info))))
4027 (gnus-message 6 "Note: New group created")
4029 (gnus-gethash (gnus-group-prefixed-name
4030 (gnus-group-real-name (gnus-info-group info))
4031 (or (gnus-info-method info) gnus-select-method))
4032 gnus-newsrc-hashtb))))
4033 ;; Whether it was a new group or not, we now have the entry, so we
4034 ;; can do the update.
4037 (setcar (nthcdr 2 entry) info)
4038 (when (and (not (eq (car entry) t))
4039 (gnus-active (gnus-info-group info)))
4040 (setcar entry (length
4041 (gnus-list-of-unread-articles (car info))))))
4042 (error "No such group: %s" (gnus-info-group info))))))
4044 (defun gnus-group-set-method-info (group select-method)
4045 (gnus-group-set-info select-method group 'method))
4047 (defun gnus-group-set-params-info (group params)
4048 (gnus-group-set-info params group 'params))
4050 (defun gnus-add-marked-articles (group type articles &optional info force)
4051 ;; Add ARTICLES of TYPE to the info of GROUP.
4052 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4053 ;; add, but replace marked articles of TYPE with ARTICLES.
4054 (let ((info (or info (gnus-get-info group)))
4057 (and (not (setq marked (nthcdr 3 info)))
4059 (setcdr (nthcdr 2 info)
4060 (list (list (cons type (gnus-compress-sequence
4062 (and (not (setq m (assq type (car marked))))
4065 (cons (cons type (gnus-compress-sequence articles t) )
4069 (setcar (nthcdr 3 info)
4070 (gnus-delete-alist type (car marked)))
4071 (setcdr m (gnus-compress-sequence articles t)))
4072 (setcdr m (gnus-compress-sequence
4073 (sort (nconc (gnus-uncompress-range (cdr m))
4074 (copy-sequence articles)) '<) t))))))
4076 (defun gnus-add-mark (group mark article)
4077 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4078 (let ((buffer (gnus-summary-buffer-name group)))
4079 (if (gnus-buffer-live-p buffer)
4081 (set-buffer (get-buffer buffer))
4082 (gnus-summary-add-mark article mark))
4083 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4087 ;;; Group timestamps
4090 (defun gnus-group-set-timestamp ()
4091 "Change the timestamp of the current group to the current time.
4092 This function can be used in hooks like `gnus-select-group-hook'
4093 or `gnus-group-catchup-group-hook'."
4094 (when gnus-newsgroup-name
4095 (let ((time (current-time)))
4096 (setcdr (cdr time) nil)
4097 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4099 (defsubst gnus-group-timestamp (group)
4100 "Return the timestamp for GROUP."
4101 (gnus-group-get-parameter group 'timestamp t))
4103 (defun gnus-group-timestamp-delta (group)
4104 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4105 (let* ((time (or (gnus-group-timestamp group)
4107 (delta (subtract-time (current-time) time)))
4108 (+ (* (nth 0 delta) 65536.0)
4111 (defun gnus-group-timestamp-string (group)
4112 "Return a string of the timestamp for GROUP."
4113 (let ((time (gnus-group-timestamp group)))
4116 (gnus-time-iso8601 time))))
4118 (defun gnus-group-list-cached (level &optional lowest)
4119 "List all groups with cached articles.
4120 If the prefix LEVEL is non-nil, it should be a number that says which
4121 level to cut off listing groups.
4122 If LOWEST, don't list groups with level lower than LOWEST.
4124 This command may read the active file."
4127 (setq level (prefix-numeric-value level)))
4128 (when (or (not level) (>= level gnus-level-zombie))
4130 (funcall gnus-group-prepare-function
4131 (or level gnus-level-subscribed)
4133 (let ((marks (gnus-info-marks info)))
4134 (assq 'cache marks)))
4137 (or (gnus-gethash group
4138 gnus-cache-active-hashtb)
4139 ;; Cache active file might use "."
4142 (mapconcat 'identity
4143 (split-string group ":")
4145 gnus-cache-active-hashtb))))
4146 (goto-char (point-min))
4147 (gnus-group-position-point))
4149 (defun gnus-group-list-dormant (level &optional lowest)
4150 "List all groups with dormant articles.
4151 If the prefix LEVEL is non-nil, it should be a number that says which
4152 level to cut off listing groups.
4153 If LOWEST, don't list groups with level lower than LOWEST.
4155 This command may read the active file."
4158 (setq level (prefix-numeric-value level)))
4159 (when (or (not level) (>= level gnus-level-zombie))
4161 (funcall gnus-group-prepare-function
4162 (or level gnus-level-subscribed)
4164 (let ((marks (gnus-info-marks info)))
4165 (assq 'dormant marks)))
4168 (goto-char (point-min))
4169 (gnus-group-position-point))
4171 (defun gnus-group-listed-groups ()
4172 "Return a list of listed groups."
4174 (goto-char (point-min))
4175 (while (setq point (text-property-not-all (point) (point-max)
4178 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4182 (defun gnus-group-list-plus (&optional args)
4183 "List groups plus the current selection."
4185 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4186 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4188 (push last-command-event unread-command-events)
4189 (if (featurep 'xemacs)
4190 (push (make-event 'key-press '(key ?A)) unread-command-events)
4191 (push ?A unread-command-events))
4192 (let (gnus-pick-mode keys)
4193 (setq keys (if (featurep 'xemacs)
4194 (events-to-keys (read-key-sequence nil))
4195 (read-key-sequence nil)))
4196 (setq func (lookup-key (current-local-map) keys)))
4200 (call-interactively func))))
4202 (defun gnus-group-list-flush (&optional args)
4203 "Flush groups from the current selection."
4205 (let ((gnus-group-list-option 'flush))
4206 (gnus-group-list-plus args)))
4208 (defun gnus-group-list-limit (&optional args)
4209 "List groups limited within the current selection."
4211 (let ((gnus-group-list-option 'limit))
4212 (gnus-group-list-plus args)))
4214 (defun gnus-group-mark-article-read (group article)
4215 "Mark ARTICLE read."
4216 (let ((buffer (gnus-summary-buffer-name group))
4217 (mark gnus-read-mark)
4219 (if (get-buffer buffer)
4220 (with-current-buffer buffer
4221 (setq active gnus-newsgroup-active)
4222 (gnus-activate-group group)
4223 (when gnus-newsgroup-prepared
4224 (when (and gnus-newsgroup-auto-expire
4225 (memq mark gnus-auto-expirable-marks))
4226 (setq mark gnus-expirable-mark))
4227 (setq mark (gnus-request-update-mark
4228 group article mark))
4229 (gnus-mark-article-as-read article mark)
4230 (setq gnus-newsgroup-active (gnus-active group))
4232 (setq n (1+ (cdr active)))
4233 (while (<= n (cdr gnus-newsgroup-active))
4234 (unless (eq n article)
4235 (push n gnus-newsgroup-unselected))
4237 (setq gnus-newsgroup-unselected
4238 (nreverse gnus-newsgroup-unselected)))))
4239 (gnus-activate-group group)
4240 (gnus-group-make-articles-read group (list article))
4241 (when (gnus-group-auto-expirable-p group)
4242 (gnus-add-marked-articles
4243 group 'expire (list article))))))
4245 (provide 'gnus-group)
4247 ;;; gnus-group.el ends here