1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %t Estimated total number of articles (integer)
160 %y Number of unread, unticked articles (integer)
161 %G Group name (string)
162 %g Qualified group name (string)
163 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
164 %C Group comment (string)
165 %D Group description (string)
166 %s Select method (string)
167 %o Moderated group (char, \"m\")
168 %p Process mark (char)
169 %O Moderated group (string, \"(m)\" or \"\")
170 %P Topic indentation (string)
171 %m Whether there is new(ish) mail in the group (char, \"%\")
172 %w Number of new(ish) mails in the group (integer)
173 %l Whether there are GroupLens predictions for this group (string)
174 %n Select from where (string)
175 %z A string that look like `<%s:%n>' if a foreign select method is used
176 %d The date the group was last entered.
177 %E Icon as defined by `gnus-group-icon-list'.
178 %u User defined specifier. The next character in the format string should
179 be a letter. Gnus will call the function gnus-user-format-function-X,
180 where X is the letter following %u. The function will be passed a
181 single dummy parameter as argument.. The function should return a
182 string, which will be inserted into the buffer just like information
183 from any other group specifier.
185 Note that this format specification is not always respected. For
186 reasons of efficiency, when listing killed groups, this specification
187 is ignored altogether. If the spec is changed considerably, your
188 output may end up looking strange when listing both alive and killed
191 If you use %o or %O, reading the active file will be slower and quite
192 a bit of extra memory will be used. %D will also worsen performance.
193 Also note that if you change the format specification to include any
194 of these specs, you must probably re-start Gnus to see them go into
197 General format specifiers can also be used.
198 See Info node `(gnus)Formatting Variables'."
199 :link '(custom-manual "(gnus)Formatting Variables")
200 :group 'gnus-group-visual
203 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
204 "*The format specification for the group mode line.
205 It works along the same lines as a normal formatting string,
206 with some simple extensions:
208 %S The native news server.
209 %M The native select method.
210 %: \":\" if %S isn't \"\"."
211 :group 'gnus-group-visual
214 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
215 (when (featurep 'xemacs)
216 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
219 (defcustom gnus-group-menu-hook nil
220 "Hook run after the creation of the group mode menu."
221 :group 'gnus-group-various
224 (defcustom gnus-group-catchup-group-hook nil
225 "Hook run when catching up a group from the group buffer."
226 :group 'gnus-group-various
227 :link '(custom-manual "(gnus)Group Data")
230 (defcustom gnus-group-update-group-hook nil
231 "Hook called when updating group lines."
232 :group 'gnus-group-visual
235 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
236 "*A function that is called to generate the group buffer.
237 The function is called with three arguments: The first is a number;
238 all group with a level less or equal to that number should be listed,
239 if the second is non-nil, empty groups should also be displayed. If
240 the third is non-nil, it is a number. No groups with a level lower
241 than this number should be displayed.
243 The only current function implemented is `gnus-group-prepare-flat'."
244 :group 'gnus-group-listing
247 (defcustom gnus-group-prepare-hook nil
248 "Hook called after the group buffer has been generated.
249 If you want to modify the group buffer, you can use this hook."
250 :group 'gnus-group-listing
253 (defcustom gnus-suspend-gnus-hook nil
254 "Hook called when suspending (not exiting) Gnus."
258 (defcustom gnus-exit-gnus-hook nil
259 "Hook called when exiting Gnus."
263 (defcustom gnus-after-exiting-gnus-hook nil
264 "Hook called after exiting Gnus."
268 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
269 "Hook called when a group line is changed.
270 The hook will not be called if `gnus-visual' is nil.
272 The default function `gnus-group-highlight-line' will
273 highlight the line according to the `gnus-group-highlight'
275 :group 'gnus-group-visual
278 (defcustom gnus-useful-groups
279 '(("(ding) mailing list mirrored at sunsite.auc.dk"
281 (nntp "sunsite.auc.dk"
282 (nntp-address "sunsite.auc.dk")))
285 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
289 (nndoc-article-type mbox)
290 (eval `(nndoc-address
291 ,(let ((file (nnheader-find-etc-directory
294 (error "Couldn't find doc group"))
296 "*Alist of useful group-server pairs."
297 :group 'gnus-group-listing
298 :type '(repeat (list (string :tag "Description")
300 (sexp :tag "Method"))))
302 (defcustom gnus-group-highlight
304 ((and mailp (= unread 0) (eq level 1)) .
305 gnus-group-mail-1-empty-face)
306 ((and mailp (eq level 1)) .
307 gnus-group-mail-1-face)
308 ((and mailp (= unread 0) (eq level 2)) .
309 gnus-group-mail-2-empty-face)
310 ((and mailp (eq level 2)) .
311 gnus-group-mail-2-face)
312 ((and mailp (= unread 0) (eq level 3)) .
313 gnus-group-mail-3-empty-face)
314 ((and mailp (eq level 3)) .
315 gnus-group-mail-3-face)
316 ((and mailp (= unread 0)) .
317 gnus-group-mail-low-empty-face)
319 gnus-group-mail-low-face)
321 ((and (= unread 0) (eq level 1)) .
322 gnus-group-news-1-empty-face)
323 ((and (eq level 1)) .
324 gnus-group-news-1-face)
325 ((and (= unread 0) (eq level 2)) .
326 gnus-group-news-2-empty-face)
327 ((and (eq level 2)) .
328 gnus-group-news-2-face)
329 ((and (= unread 0) (eq level 3)) .
330 gnus-group-news-3-empty-face)
331 ((and (eq level 3)) .
332 gnus-group-news-3-face)
333 ((and (= unread 0) (eq level 4)) .
334 gnus-group-news-4-empty-face)
335 ((and (eq level 4)) .
336 gnus-group-news-4-face)
337 ((and (= unread 0) (eq level 5)) .
338 gnus-group-news-5-empty-face)
339 ((and (eq level 5)) .
340 gnus-group-news-5-face)
341 ((and (= unread 0) (eq level 6)) .
342 gnus-group-news-6-empty-face)
343 ((and (eq level 6)) .
344 gnus-group-news-6-face)
345 ((and (= unread 0)) .
346 gnus-group-news-low-empty-face)
348 gnus-group-news-low-face))
349 "*Controls the highlighting of group buffer lines.
351 Below is a list of `Form'/`Face' pairs. When deciding how a a
352 particular group line should be displayed, each form is
353 evaluated. The content of the face field after the first true form is
354 used. You can change how those group lines are displayed by
355 editing the face field.
357 It is also possible to change and add form fields, but currently that
358 requires an understanding of Lisp expressions. Hopefully this will
359 change in a future release. For now, you can use the following
360 variables in the Lisp expression:
362 group: The name of the group.
363 unread: The number of unread articles in the group.
364 method: The select method used.
365 mailp: Whether it's a mail group or not.
366 level: The level of the group.
367 score: The score of the group.
368 ticked: The number of ticked articles."
369 :group 'gnus-group-visual
370 :type '(repeat (cons (sexp :tag "Form") face)))
372 (defcustom gnus-new-mail-mark ?%
373 "Mark used for groups with new mail."
374 :group 'gnus-group-visual
377 (defgroup gnus-group-icons nil
378 "Add Icons to your group buffer. "
379 :group 'gnus-group-visual)
381 (defcustom gnus-group-icon-list
383 "*Controls the insertion of icons into group buffer lines.
385 Below is a list of `Form'/`File' pairs. When deciding how a
386 particular group line should be displayed, each form is evaluated.
387 The icon from the file field after the first true form is used. You
388 can change how those group lines are displayed by editing the file
389 field. The File will either be found in the
390 `gnus-group-glyph-directory' or by designating absolute path to the
393 It is also possible to change and add form fields, but currently that
394 requires an understanding of Lisp expressions. Hopefully this will
395 change in a future release. For now, you can use the following
396 variables in the Lisp expression:
398 group: The name of the group.
399 unread: The number of unread articles in the group.
400 method: The select method used.
401 mailp: Whether it's a mail group or not.
402 newsp: Whether it's a news group or not
403 level: The level of the group.
404 score: The score of the group.
405 ticked: The number of ticked articles."
406 :group 'gnus-group-icons
407 :type '(repeat (cons (sexp :tag "Form") file)))
409 (defcustom gnus-group-name-charset-method-alist nil
410 "Alist of method and the charset for group names.
413 (((nntp \"news.com.cn\") . cn-gb-2312))"
416 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
418 (defcustom gnus-group-name-charset-group-alist
419 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
420 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
421 '(("[^\000-\177]" . utf-8))
423 "Alist of group regexp and the charset for group names.
426 ((\"\\.com\\.cn:\" . cn-gb-2312))"
428 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
430 (defcustom gnus-group-jump-to-group-prompt nil
431 "Default prompt for `gnus-group-jump-to-group'.
432 If non-nil, the value should be a string, e.g. \"nnml:\",
433 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
434 in the minibuffer prompt."
435 :group 'gnus-group-various
436 :type '(choice (string :tag "Prompt string")
437 (const :tag "Empty" nil)))
439 (defvar gnus-group-listing-limit 1000
440 "*A limit of the number of groups when listing.
441 If the number of groups is larger than the limit, list them in a
444 ;;; Internal variables
446 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
447 "Function for sorting the group buffer.")
449 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
450 "Function for sorting the selected groups in the group buffer.")
452 (defvar gnus-group-indentation-function nil)
453 (defvar gnus-goto-missing-group-function nil)
454 (defvar gnus-group-update-group-function nil)
455 (defvar gnus-group-goto-next-group-function nil
456 "Function to override finding the next group after listing groups.")
458 (defvar gnus-group-edit-buffer nil)
460 (defvar gnus-group-line-format-alist
461 `((?M gnus-tmp-marked-mark ?c)
462 (?S gnus-tmp-subscribed ?c)
463 (?L gnus-tmp-level ?d)
464 (?N (cond ((eq number t) "*" )
468 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
469 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
471 (?R gnus-tmp-number-of-read ?s)
472 (?t gnus-tmp-number-total ?d)
473 (?y gnus-tmp-number-of-unread ?s)
474 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
475 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
476 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
477 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
478 (?g gnus-tmp-group ?s)
479 (?G gnus-tmp-qualified-group ?s)
480 (?c (gnus-short-group-name gnus-tmp-group) ?s)
481 (?C gnus-tmp-comment ?s)
482 (?D gnus-tmp-newsgroup-description ?s)
483 (?o gnus-tmp-moderated ?c)
484 (?O gnus-tmp-moderated-string ?s)
485 (?p gnus-tmp-process-marked ?c)
486 (?s gnus-tmp-news-server ?s)
487 (?n gnus-tmp-news-method ?s)
488 (?P gnus-group-indentation ?s)
489 (?E gnus-tmp-group-icon ?s)
490 (?l gnus-tmp-grouplens ?s)
491 (?z gnus-tmp-news-method-string ?s)
492 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
493 (?w (if (gnus-news-group-p gnus-tmp-group)
497 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
500 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
501 (?u gnus-tmp-user-defined ?s)))
503 (defvar gnus-group-mode-line-format-alist
504 `((?S gnus-tmp-news-server ?s)
505 (?M gnus-tmp-news-method ?s)
506 (?u gnus-tmp-user-defined ?s)
507 (?: gnus-tmp-colon ?s)))
509 (defvar gnus-topic-topology nil
510 "The complete topic hierarchy.")
512 (defvar gnus-topic-alist nil
513 "The complete topic-group alist.")
515 (defvar gnus-group-marked nil)
517 (defvar gnus-group-list-mode nil)
520 (defvar gnus-group-icon-cache nil)
522 (defvar gnus-group-listed-groups nil)
523 (defvar gnus-group-list-option nil)
529 (put 'gnus-group-mode 'mode-class 'special)
532 (gnus-define-keys gnus-group-mode-map
533 " " gnus-group-read-group
534 "=" gnus-group-select-group
535 "\r" gnus-group-select-group
536 "\M-\r" gnus-group-quick-select-group
537 "\M- " gnus-group-visible-select-group
538 [(meta control return)] gnus-group-select-group-ephemerally
539 "j" gnus-group-jump-to-group
540 "n" gnus-group-next-unread-group
541 "p" gnus-group-prev-unread-group
542 "\177" gnus-group-prev-unread-group
543 [delete] gnus-group-prev-unread-group
544 [backspace] gnus-group-prev-unread-group
545 "N" gnus-group-next-group
546 "P" gnus-group-prev-group
547 "\M-n" gnus-group-next-unread-group-same-level
548 "\M-p" gnus-group-prev-unread-group-same-level
549 "," gnus-group-best-unread-group
550 "." gnus-group-first-unread-group
551 "u" gnus-group-unsubscribe-current-group
552 "U" gnus-group-unsubscribe-group
553 "c" gnus-group-catchup-current
554 "C" gnus-group-catchup-current-all
555 "\M-c" gnus-group-clear-data
556 "l" gnus-group-list-groups
557 "L" gnus-group-list-all-groups
560 "g" gnus-group-get-new-news
561 "\M-g" gnus-group-get-new-news-this-group
562 "R" gnus-group-restart
563 "r" gnus-group-read-init-file
564 "B" gnus-group-browse-foreign-server
565 "b" gnus-group-check-bogus-groups
566 "F" gnus-group-find-new-groups
567 "\C-c\C-d" gnus-group-describe-group
568 "\M-d" gnus-group-describe-all-groups
569 "\C-c\C-a" gnus-group-apropos
570 "\C-c\M-\C-a" gnus-group-description-apropos
571 "a" gnus-group-post-news
572 "\ek" gnus-group-edit-local-kill
573 "\eK" gnus-group-edit-global-kill
574 "\C-k" gnus-group-kill-group
575 "\C-y" gnus-group-yank-group
576 "\C-w" gnus-group-kill-region
577 "\C-x\C-t" gnus-group-transpose-groups
578 "\C-c\C-l" gnus-group-list-killed
579 "\C-c\C-x" gnus-group-expire-articles
580 "\C-c\M-\C-x" gnus-group-expire-all-groups
582 "s" gnus-group-save-newsrc
583 "z" gnus-group-suspend
586 "?" gnus-group-describe-briefly
587 "\C-c\C-i" gnus-info-find-node
588 "\M-e" gnus-group-edit-group-method
589 "^" gnus-group-enter-server-mode
590 gnus-mouse-2 gnus-mouse-pick-group
591 "<" beginning-of-buffer
594 "\C-c\C-n" gnus-namazu-search
595 "\C-c\C-s" gnus-group-sort-groups
597 "\C-c\M-g" gnus-activate-all-groups
598 "\M-&" gnus-group-universal-argument
599 "#" gnus-group-mark-group
600 "\M-#" gnus-group-unmark-group)
602 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
603 "m" gnus-group-mark-group
604 "u" gnus-group-unmark-group
605 "w" gnus-group-mark-region
606 "b" gnus-group-mark-buffer
607 "r" gnus-group-mark-regexp
608 "U" gnus-group-unmark-all-groups)
610 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
611 "u" gnus-sieve-update
612 "g" gnus-sieve-generate)
614 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
615 "d" gnus-group-make-directory-group
616 "h" gnus-group-make-help-group
617 "u" gnus-group-make-useful-group
618 "a" gnus-group-make-archive-group
619 "k" gnus-group-make-kiboze-group
620 "l" gnus-group-nnimap-edit-acl
621 "m" gnus-group-make-group
622 "n" gnus-group-make-shimbun-group
623 "E" gnus-group-edit-group
624 "e" gnus-group-edit-group-method
625 "p" gnus-group-edit-group-parameters
626 "v" gnus-group-add-to-virtual
627 "V" gnus-group-make-empty-virtual
628 "D" gnus-group-enter-directory
629 "f" gnus-group-make-doc-group
630 "G" gnus-group-make-nnir-group
631 "w" gnus-group-make-web-group
632 "r" gnus-group-rename-group
633 "c" gnus-group-customize
634 "x" gnus-group-nnimap-expunge
635 "\177" gnus-group-delete-group
636 [delete] gnus-group-delete-group)
638 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
639 "b" gnus-group-brew-soup
640 "w" gnus-soup-save-areas
641 "s" gnus-soup-send-replies
642 "p" gnus-soup-pack-packet
643 "r" nnsoup-pack-replies)
645 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
646 "s" gnus-group-sort-groups
647 "a" gnus-group-sort-groups-by-alphabet
648 "u" gnus-group-sort-groups-by-unread
649 "l" gnus-group-sort-groups-by-level
650 "v" gnus-group-sort-groups-by-score
651 "r" gnus-group-sort-groups-by-rank
652 "m" gnus-group-sort-groups-by-method)
654 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
655 "s" gnus-group-sort-selected-groups
656 "a" gnus-group-sort-selected-groups-by-alphabet
657 "u" gnus-group-sort-selected-groups-by-unread
658 "l" gnus-group-sort-selected-groups-by-level
659 "v" gnus-group-sort-selected-groups-by-score
660 "r" gnus-group-sort-selected-groups-by-rank
661 "m" gnus-group-sort-selected-groups-by-method)
663 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
664 "k" gnus-group-list-killed
665 "z" gnus-group-list-zombies
666 "s" gnus-group-list-groups
667 "u" gnus-group-list-all-groups
668 "A" gnus-group-list-active
669 "a" gnus-group-apropos
670 "d" gnus-group-description-apropos
671 "m" gnus-group-list-matching
672 "M" gnus-group-list-all-matching
673 "l" gnus-group-list-level
674 "c" gnus-group-list-cached
675 "?" gnus-group-list-dormant)
677 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
678 "k" gnus-group-list-limit
679 "z" gnus-group-list-limit
680 "s" gnus-group-list-limit
681 "u" gnus-group-list-limit
682 "A" gnus-group-list-limit
683 "m" gnus-group-list-limit
684 "M" gnus-group-list-limit
685 "l" gnus-group-list-limit
686 "c" gnus-group-list-limit
687 "?" gnus-group-list-limit)
689 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
690 "k" gnus-group-list-flush
691 "z" gnus-group-list-flush
692 "s" gnus-group-list-flush
693 "u" gnus-group-list-flush
694 "A" gnus-group-list-flush
695 "m" gnus-group-list-flush
696 "M" gnus-group-list-flush
697 "l" gnus-group-list-flush
698 "c" gnus-group-list-flush
699 "?" gnus-group-list-flush)
701 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
702 "k" gnus-group-list-plus
703 "z" gnus-group-list-plus
704 "s" gnus-group-list-plus
705 "u" gnus-group-list-plus
706 "A" gnus-group-list-plus
707 "m" gnus-group-list-plus
708 "M" gnus-group-list-plus
709 "l" gnus-group-list-plus
710 "c" gnus-group-list-plus
711 "?" gnus-group-list-plus)
713 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
714 "f" gnus-score-flush-cache)
716 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
717 "c" gnus-group-fetch-charter
718 "C" gnus-group-fetch-control
719 "d" gnus-group-describe-group
720 "f" gnus-group-fetch-faq
723 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
724 "l" gnus-group-set-current-level
725 "t" gnus-group-unsubscribe-current-group
726 "s" gnus-group-unsubscribe-group
727 "k" gnus-group-kill-group
728 "y" gnus-group-yank-group
729 "w" gnus-group-kill-region
730 "\C-k" gnus-group-kill-level
731 "z" gnus-group-kill-all-zombies))
733 (defun gnus-group-make-menu-bar ()
734 (gnus-turn-off-edit-menu 'group)
735 (unless (boundp 'gnus-group-reading-menu)
738 gnus-group-reading-menu gnus-group-mode-map ""
740 ["Read" gnus-group-read-group (gnus-group-group-name)]
741 ["Select" gnus-group-select-group (gnus-group-group-name)]
742 ["See old articles" (gnus-group-select-group 'all)
743 :keys "C-u SPC" :active (gnus-group-group-name)]
744 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
745 ,@(if (featurep 'xemacs) nil
746 '(:help "Mark unread articles in the current group as read"))]
747 ["Catch up all articles" gnus-group-catchup-current-all
748 (gnus-group-group-name)]
749 ["Check for new articles" gnus-group-get-new-news-this-group
750 :active (gnus-group-group-name)
751 ,@(if (featurep 'xemacs) nil
752 '(:help "Check for new messages in current group"))]
753 ["Toggle subscription" gnus-group-unsubscribe-current-group
754 (gnus-group-group-name)]
755 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
756 ,@(if (featurep 'xemacs) nil
757 '(:help "Kill (remove) current group"))]
758 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
759 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
760 ,@(if (featurep 'xemacs) nil
761 '(:help "Display description of the current group"))]
762 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
763 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
764 ,@(if (featurep 'xemacs) nil
765 '(:help "Display the charter of the current group"))]
766 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
767 ,@(if (featurep 'xemacs) nil
768 '(:help "Display the archived control message for the current group"))]
769 ;; Actually one should check, if any of the marked groups gives t for
770 ;; (gnus-check-backend-function 'request-expire-articles ...)
771 ["Expire articles" gnus-group-expire-articles
772 (or (and (gnus-group-group-name)
773 (gnus-check-backend-function
774 'request-expire-articles
775 (gnus-group-group-name))) gnus-group-marked)]
776 ["Set group level..." gnus-group-set-current-level
777 (gnus-group-group-name)]
778 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
779 ["Customize" gnus-group-customize (gnus-group-group-name)]
781 ["Parameters" gnus-group-edit-group-parameters
782 (gnus-group-group-name)]
783 ["Select method" gnus-group-edit-group-method
784 (gnus-group-group-name)]
785 ["Info" gnus-group-edit-group (gnus-group-group-name)]
786 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
787 ["Global kill file" gnus-group-edit-global-kill t])))
790 gnus-group-group-menu gnus-group-mode-map ""
793 ["List unread subscribed groups" gnus-group-list-groups t]
794 ["List (un)subscribed groups" gnus-group-list-all-groups t]
795 ["List killed groups" gnus-group-list-killed gnus-killed-list]
796 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
797 ["List level..." gnus-group-list-level t]
798 ["Describe all groups" gnus-group-describe-all-groups t]
799 ["Group apropos..." gnus-group-apropos t]
800 ["Group and description apropos..." gnus-group-description-apropos t]
801 ["List groups matching..." gnus-group-list-matching t]
802 ["List all groups matching..." gnus-group-list-all-matching t]
803 ["List active file" gnus-group-list-active t]
804 ["List groups with cached" gnus-group-list-cached t]
805 ["List groups with dormant" gnus-group-list-dormant t])
807 ["Default sort" gnus-group-sort-groups t]
808 ["Sort by method" gnus-group-sort-groups-by-method t]
809 ["Sort by rank" gnus-group-sort-groups-by-rank t]
810 ["Sort by score" gnus-group-sort-groups-by-score t]
811 ["Sort by level" gnus-group-sort-groups-by-level t]
812 ["Sort by unread" gnus-group-sort-groups-by-unread t]
813 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
814 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
815 ("Sort process/prefixed"
816 ["Default sort" gnus-group-sort-selected-groups
817 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
818 ["Sort by method" gnus-group-sort-selected-groups-by-method
819 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
820 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
821 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
822 ["Sort by score" gnus-group-sort-selected-groups-by-score
823 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
824 ["Sort by level" gnus-group-sort-selected-groups-by-level
825 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
826 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
827 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
828 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
829 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
830 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
831 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
833 ["Mark group" gnus-group-mark-group
834 (and (gnus-group-group-name)
835 (not (memq (gnus-group-group-name) gnus-group-marked)))]
836 ["Unmark group" gnus-group-unmark-group
837 (and (gnus-group-group-name)
838 (memq (gnus-group-group-name) gnus-group-marked))]
839 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
840 ["Mark regexp..." gnus-group-mark-regexp t]
841 ["Mark region" gnus-group-mark-region t]
842 ["Mark buffer" gnus-group-mark-buffer t]
843 ["Execute command" gnus-group-universal-argument
844 (or gnus-group-marked (gnus-group-group-name))])
846 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
847 ["Kill all newsgroups in region" gnus-group-kill-region t]
848 ["Kill all zombie groups" gnus-group-kill-all-zombies
850 ["Kill all groups on level..." gnus-group-kill-level t])
852 ["Make a foreign group..." gnus-group-make-group t]
853 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
854 ["Add a directory group..." gnus-group-make-directory-group t]
855 ["Add the help group" gnus-group-make-help-group t]
856 ["Add the archive group" gnus-group-make-archive-group t]
857 ["Make a doc group..." gnus-group-make-doc-group t]
858 ["Make a web group..." gnus-group-make-web-group t]
859 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
860 ["Make a virtual group..." gnus-group-make-empty-virtual t]
861 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
862 ["Rename group..." gnus-group-rename-group
863 (gnus-check-backend-function
864 'request-rename-group (gnus-group-group-name))]
865 ["Delete group" gnus-group-delete-group
866 (gnus-check-backend-function
867 'request-delete-group (gnus-group-group-name))])
869 ["Next" gnus-group-next-group t]
870 ["Previous" gnus-group-prev-group t]
871 ["Next unread" gnus-group-next-unread-group t]
872 ["Previous unread" gnus-group-prev-unread-group t]
873 ["Next unread same level" gnus-group-next-unread-group-same-level t]
874 ["Previous unread same level"
875 gnus-group-prev-unread-group-same-level t]
876 ["Jump to group..." gnus-group-jump-to-group t]
877 ["First unread group" gnus-group-first-unread-group t]
878 ["Best unread group" gnus-group-best-unread-group t])
880 ["Generate" gnus-sieve-generate t]
881 ["Generate and update" gnus-sieve-update t])
882 ["Delete bogus groups" gnus-group-check-bogus-groups t]
883 ["Find new newsgroups" gnus-group-find-new-groups t]
884 ["Transpose" gnus-group-transpose-groups
885 (gnus-group-group-name)]
886 ["Read a directory as a group..." gnus-group-enter-directory t]))
889 gnus-group-misc-menu gnus-group-mode-map ""
892 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
893 ["Send replies" gnus-soup-send-replies
894 (fboundp 'gnus-soup-pack-packet)]
895 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
896 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
897 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
898 ["Send a mail" gnus-group-mail t]
899 ["Send a message (mail or news)" gnus-group-post-news t]
900 ["Create a local message" gnus-group-news t]
901 ["Check for new news" gnus-group-get-new-news
902 ,@(if (featurep 'xemacs) '(t)
903 '(:help "Get newly arrived articles"))
905 ["Send queued messages" gnus-delay-send-queue
906 ,@(if (featurep 'xemacs) '(t)
907 '(:help "Send all messages that are scheduled to be sent now"))
909 ["Activate all groups" gnus-activate-all-groups t]
910 ["Restart Gnus" gnus-group-restart t]
911 ["Read init file" gnus-group-read-init-file t]
912 ["Browse foreign server..." gnus-group-browse-foreign-server t]
913 ["Enter server buffer" gnus-group-enter-server-mode t]
914 ["Expire all expirable articles" gnus-group-expire-all-groups t]
915 ["Generate any kiboze groups" nnkiboze-generate-groups t]
916 ["Gnus version" gnus-version t]
917 ["Save .newsrc files" gnus-group-save-newsrc t]
918 ["Suspend Gnus" gnus-group-suspend t]
919 ["Clear dribble buffer" gnus-group-clear-dribble t]
920 ["Read manual" gnus-info-find-node t]
921 ["Flush score cache" gnus-score-flush-cache t]
922 ["Toggle topics" gnus-topic-mode t]
923 ["Send a bug report" gnus-bug t]
924 ["Exit from Gnus" gnus-group-exit
925 ,@(if (featurep 'xemacs) '(t)
926 '(:help "Quit reading news"))]
927 ["Exit without saving" gnus-group-quit t]))
929 (gnus-run-hooks 'gnus-group-menu-hook)))
931 (defvar gnus-group-toolbar-map nil)
933 ;; Emacs 21 tool bar. Should be no-op otherwise.
934 (defun gnus-group-make-tool-bar ()
936 (condition-case nil (require 'tool-bar) (error nil))
937 (fboundp 'tool-bar-add-item-from-menu)
938 (default-value 'tool-bar-mode)
939 (not gnus-group-toolbar-map))
940 (setq gnus-group-toolbar-map
941 (let ((tool-bar-map (make-sparse-keymap))
942 (load-path (mm-image-load-path)))
943 (tool-bar-add-item-from-menu
944 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
945 (tool-bar-add-item-from-menu
946 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
947 (tool-bar-add-item-from-menu
948 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
949 (tool-bar-add-item-from-menu
950 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
951 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
952 :help "Subscribe to the current group")
953 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
955 :help "Unsubscribe from the current group")
956 (tool-bar-add-item-from-menu
957 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
959 (if gnus-group-toolbar-map
960 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
962 (defun gnus-group-mode ()
963 "Major mode for reading news.
965 All normal editing commands are switched off.
966 \\<gnus-group-mode-map>
967 The group buffer lists (some of) the groups available. For instance,
968 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
969 lists all zombie groups.
971 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
972 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
974 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
976 The following commands are available:
978 \\{gnus-group-mode-map}"
980 (kill-all-local-variables)
981 (when (gnus-visual-p 'group-menu 'menu)
982 (gnus-group-make-menu-bar)
983 (gnus-group-make-tool-bar))
984 (gnus-simplify-mode-line)
985 (setq major-mode 'gnus-group-mode)
986 (setq mode-name "Group")
987 (gnus-group-set-mode-line)
988 (setq mode-line-process nil)
989 (use-local-map gnus-group-mode-map)
990 (buffer-disable-undo)
991 (setq truncate-lines t)
992 (setq buffer-read-only t)
993 (gnus-set-default-directory)
994 (gnus-update-format-specifications nil 'group 'group-mode)
995 (gnus-update-group-mark-positions)
1000 (gnus-run-hooks 'gnus-group-mode-hook))
1002 (defun gnus-update-group-mark-positions ()
1004 (let ((gnus-process-mark ?\200)
1005 (gnus-group-update-hook nil)
1006 (gnus-group-marked '("dummy.group"))
1007 (gnus-active-hashtb (make-vector 10 0))
1009 (gnus-set-active "dummy.group" '(0 . 0))
1010 (gnus-set-work-buffer)
1011 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1012 (goto-char (point-min))
1013 (setq gnus-group-mark-positions
1014 (list (cons 'process (and (search-forward "\200" nil t)
1015 (- (point) 2))))))))
1017 (defun gnus-mouse-pick-group (e)
1018 "Enter the group under the mouse pointer."
1021 (gnus-group-read-group nil))
1023 ;; Look at LEVEL and find out what the level is really supposed to be.
1024 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1025 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1026 (defun gnus-group-default-level (&optional level number-or-nil)
1028 (gnus-group-use-permanent-levels
1029 (or (setq gnus-group-use-permanent-levels
1030 (or level (if (numberp gnus-group-use-permanent-levels)
1031 gnus-group-use-permanent-levels
1032 (or gnus-group-default-list-level
1033 gnus-level-subscribed))))
1034 gnus-group-default-list-level gnus-level-subscribed))
1038 (or level gnus-group-default-list-level gnus-level-subscribed))))
1040 (defun gnus-group-setup-buffer ()
1041 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1042 (unless (eq major-mode 'gnus-group-mode)
1045 (gnus-carpal-setup-buffer 'group))))
1047 (defun gnus-group-name-charset (method group)
1049 (setq method (gnus-find-method-for-group group)))
1050 (let ((item (assoc method gnus-group-name-charset-method-alist))
1051 (alist gnus-group-name-charset-group-alist)
1055 (while (setq item (pop alist))
1056 (if (string-match (car item) group)
1058 result (cdr item))))
1061 (defun gnus-group-name-decode (string charset)
1062 (if (and string charset (featurep 'mule))
1063 (decode-coding-string string charset)
1066 (defun gnus-group-decoded-name (string)
1067 (let ((charset (gnus-group-name-charset nil string)))
1068 (gnus-group-name-decode string charset)))
1070 (defun gnus-group-name-encode (string charset)
1071 (if (and string charset (featurep 'mule))
1072 (encode-coding-string string charset)
1075 (defun gnus-group-encoded-name (string)
1076 (let ((charset (gnus-group-name-charset nil string)))
1077 (gnus-group-name-encode string charset)))
1079 (defun gnus-group-completing-read-group-name
1080 (prompt table &optional predicate require-match initial-contents history)
1084 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1088 (dolist (entry (prog1
1091 (push (list (gnus-group-decoded-name (car entry))) table)))
1092 (gnus-group-encoded-name
1094 prompt table predicate
1099 (defun gnus-group-list-groups (&optional level unread lowest)
1100 "List newsgroups with level LEVEL or lower that have unread articles.
1101 Default is all subscribed groups.
1102 If argument UNREAD is non-nil, groups with no unread articles are also
1105 Also see the `gnus-group-use-permanent-levels' variable."
1107 (list (if current-prefix-arg
1108 (prefix-numeric-value current-prefix-arg)
1110 (gnus-group-default-level nil t)
1111 gnus-group-default-list-level
1112 gnus-level-subscribed))))
1114 (setq level (car gnus-group-list-mode)
1115 unread (cdr gnus-group-list-mode)))
1116 (setq level (gnus-group-default-level level))
1117 (gnus-group-setup-buffer)
1118 (gnus-update-format-specifications nil 'group 'group-mode)
1119 (let ((case-fold-search nil)
1120 (props (text-properties-at (gnus-point-at-bol)))
1121 (empty (= (point-min) (point-max)))
1122 (group (gnus-group-group-name))
1124 (set-buffer gnus-group-buffer)
1125 (setq number (funcall gnus-group-prepare-function level unread lowest))
1126 (when (or (and (numberp number)
1128 (zerop (buffer-size)))
1129 ;; No groups in the buffer.
1130 (gnus-message 5 gnus-no-groups-message))
1131 ;; We have some groups displayed.
1132 (goto-char (point-max))
1133 (when (or (not gnus-group-goto-next-group-function)
1134 (not (funcall gnus-group-goto-next-group-function
1138 (goto-char (point-min)))
1140 ;; Go to the first group with unread articles.
1141 (gnus-group-search-forward t))
1143 ;; Find the right group to put point on. If the current group
1144 ;; has disappeared in the new listing, try to find the next
1145 ;; one. If no next one can be found, just leave point at the
1146 ;; first newsgroup in the buffer.
1147 (when (not (gnus-goto-char
1149 (point-min) (point-max)
1150 'gnus-group (gnus-intern-safe
1151 group gnus-active-hashtb))))
1152 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1154 (not (gnus-goto-char
1156 (point-min) (point-max) 'gnus-group
1158 (caar newsrc) gnus-active-hashtb)))))
1159 (setq newsrc (cdr newsrc)))
1161 (goto-char (point-max))
1162 (forward-line -1)))))))
1163 ;; Adjust cursor point.
1164 (gnus-group-position-point)))
1166 (defun gnus-group-list-level (level &optional all)
1167 "List groups on LEVEL.
1168 If ALL (the prefix), also list groups that have no unread articles."
1169 (interactive "nList groups on level: \nP")
1170 (gnus-group-list-groups level all level))
1172 (defun gnus-group-prepare-logic (group test)
1173 (or (and gnus-group-listed-groups
1174 (null gnus-group-list-option)
1175 (member group gnus-group-listed-groups))
1177 ((null gnus-group-listed-groups) test)
1178 ((null gnus-group-list-option) test)
1179 (t (and (member group gnus-group-listed-groups)
1180 (if (eq gnus-group-list-option 'flush)
1184 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1185 "List all newsgroups with unread articles of level LEVEL or lower.
1186 If PREDICATE is a function, list groups that the function returns non-nil;
1187 if it is t, list groups that have no unread articles.
1188 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1189 If REGEXP is a function, list dead groups that the function returns non-nil;
1190 if it is a string, only list groups matching REGEXP."
1191 (set-buffer gnus-group-buffer)
1192 (let ((buffer-read-only nil)
1193 (newsrc (cdr gnus-newsrc-alist))
1194 (lowest (or lowest 1))
1195 (not-in-list (and gnus-group-listed-groups
1196 (copy-sequence gnus-group-listed-groups)))
1197 info clevel unread group params)
1199 (when (or (< lowest gnus-level-zombie)
1200 gnus-group-listed-groups)
1201 ;; List living groups.
1203 (setq info (car newsrc)
1204 group (gnus-info-group info)
1205 params (gnus-info-params info)
1207 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1209 (setq not-in-list (delete group not-in-list)))
1211 (gnus-group-prepare-logic
1213 (and unread ; This group might be unchecked
1214 (or (not (stringp regexp))
1215 (string-match regexp group))
1216 (<= (setq clevel (gnus-info-level info)) level)
1219 ((functionp predicate)
1220 (funcall predicate info))
1221 (predicate t) ; We list all groups?
1224 (if (eq unread t) ; Unactivated?
1225 gnus-group-list-inactive-groups
1226 ; We list unactivated
1228 ; We list groups with unread articles
1229 (and gnus-list-groups-with-ticked-articles
1230 (cdr (assq 'tick (gnus-info-marks info))))
1231 ; And groups with tickeds
1232 ;; Check for permanent visibility.
1233 (and gnus-permanently-visible-groups
1234 (string-match gnus-permanently-visible-groups group))
1235 (memq 'visible params)
1236 (cdr (assq 'visible params)))))))
1237 (gnus-group-insert-group-line
1238 group (gnus-info-level info)
1239 (gnus-info-marks info) unread (gnus-info-method info)))))
1241 ;; List dead groups.
1242 (if (or gnus-group-listed-groups
1243 (and (>= level gnus-level-zombie)
1244 (<= lowest gnus-level-zombie)))
1245 (gnus-group-prepare-flat-list-dead
1246 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1247 gnus-level-zombie ?Z
1250 (dolist (group gnus-zombie-list)
1251 (setq not-in-list (delete group not-in-list))))
1252 (if (or gnus-group-listed-groups
1253 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1254 (gnus-group-prepare-flat-list-dead
1257 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1258 gnus-level-killed ?K regexp))
1260 (gnus-group-set-mode-line)
1261 (setq gnus-group-list-mode (cons level predicate))
1262 (gnus-run-hooks 'gnus-group-prepare-hook)
1265 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1266 ;; List zombies and killed lists somewhat faster, which was
1267 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1268 ;; this by ignoring the group format specification altogether.
1270 (if (> (length groups) gnus-group-listing-limit)
1272 (setq group (pop groups))
1273 (when (gnus-group-prepare-logic
1276 (and (stringp regexp) (string-match regexp group))
1277 (and (functionp regexp) (funcall regexp group))))
1278 (gnus-add-text-properties
1279 (point) (prog1 (1+ (point))
1280 (insert " " mark " *: "
1281 (gnus-group-decoded-name group)
1283 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1285 'gnus-level level))))
1287 (setq group (pop groups))
1288 (when (gnus-group-prepare-logic
1291 (and (stringp regexp) (string-match regexp group))
1292 (and (functionp regexp) (funcall regexp group))))
1293 (gnus-group-insert-group-line
1295 (let ((active (gnus-active group)))
1297 (if (zerop (cdr active))
1299 (- (1+ (cdr active)) (car active)))
1301 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1303 (defun gnus-group-update-group-line ()
1304 "Update the current line in the group buffer."
1305 (let* ((buffer-read-only nil)
1306 (group (gnus-group-group-name))
1307 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1308 gnus-group-indentation)
1311 (not (gnus-ephemeral-group-p group))
1313 (concat "(gnus-group-set-info '"
1314 (gnus-prin1-to-string (nth 2 entry))
1316 (setq gnus-group-indentation (gnus-group-group-indentation))
1318 (gnus-group-insert-group-line-info group)
1320 (gnus-group-position-point))))
1322 (defun gnus-group-insert-group-line-info (group)
1323 "Insert GROUP on the current line."
1324 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1325 (gnus-group-indentation (gnus-group-group-indentation))
1329 ;; (Un)subscribed group.
1330 (setq info (nth 2 entry))
1331 (gnus-group-insert-group-line
1332 group (gnus-info-level info) (gnus-info-marks info)
1333 (or (car entry) t) (gnus-info-method info)))
1334 ;; This group is dead.
1335 (gnus-group-insert-group-line
1337 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1339 (if (setq active (gnus-active group))
1340 (if (zerop (cdr active))
1342 (- (1+ (cdr active)) (car active)))
1344 (gnus-method-simplify (gnus-find-method-for-group group))))))
1346 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1347 gnus-tmp-marked number
1349 "Insert a group line in the group buffer."
1350 (let* ((gnus-tmp-method
1351 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1352 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1354 (gnus-tmp-active (gnus-active gnus-tmp-group))
1355 (gnus-tmp-number-total
1357 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1359 (gnus-tmp-number-of-unread
1360 (if (numberp number) (int-to-string (max 0 number))
1362 (gnus-tmp-number-of-read
1363 (if (numberp number)
1364 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1366 (gnus-tmp-subscribed
1367 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1368 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1369 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1371 (gnus-tmp-qualified-group
1372 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1373 group-name-charset))
1375 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1377 (gnus-tmp-newsgroup-description
1378 (if gnus-description-hashtb
1379 (or (gnus-group-name-decode
1380 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1381 group-name-charset) "")
1384 (if (and gnus-moderated-hashtb
1385 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1387 (gnus-tmp-moderated-string
1388 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1389 (gnus-tmp-group-icon "==&&==")
1390 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1391 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1392 (gnus-tmp-news-method-string
1394 (format "(%s:%s)" (car gnus-tmp-method)
1395 (cadr gnus-tmp-method)) ""))
1396 (gnus-tmp-marked-mark
1397 (if (and (numberp number)
1399 (cdr (assq 'tick gnus-tmp-marked)))
1401 (gnus-tmp-process-marked
1402 (if (member gnus-tmp-group gnus-group-marked)
1403 gnus-process-mark ? ))
1405 (or (and gnus-use-grouplens
1406 (bbb-grouplens-group-p gnus-tmp-group))
1408 (buffer-read-only nil)
1409 header gnus-tmp-header) ; passed as parameter to user-funcs.
1411 (gnus-add-text-properties
1415 (let ((gnus-tmp-group (gnus-group-name-decode
1416 gnus-tmp-group group-name-charset)))
1417 (eval gnus-group-line-format-spec)))
1418 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1419 gnus-unread ,(if (numberp number)
1420 (string-to-int gnus-tmp-number-of-unread)
1422 gnus-marked ,gnus-tmp-marked-mark
1423 gnus-indentation ,gnus-group-indentation
1424 gnus-level ,gnus-tmp-level))
1426 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1427 (gnus-run-hooks 'gnus-group-update-hook))
1429 ;; Allow XEmacs to remove front-sticky text properties.
1430 (gnus-group-remove-excess-properties)))
1432 (defun gnus-group-highlight-line ()
1433 "Highlight the current line according to `gnus-group-highlight'."
1434 (let* ((list gnus-group-highlight)
1436 (end (progn (end-of-line) (point)))
1437 ;; now find out where the line starts and leave point there.
1438 (beg (progn (beginning-of-line) (point)))
1439 (group (gnus-group-group-name))
1440 (entry (gnus-group-entry group))
1441 (unread (if (numberp (car entry)) (car entry) 0))
1442 (active (gnus-active group))
1443 (total (if active (1+ (- (cdr active) (car active))) 0))
1444 (info (nth 2 entry))
1445 (method (gnus-server-get-method group (gnus-info-method info)))
1446 (marked (gnus-info-marks info))
1447 (mailp (apply 'append
1450 (memq x (assoc (symbol-name
1451 (car (or method gnus-select-method)))
1452 gnus-valid-select-methods)))
1453 '(mail post-mail))))
1454 (level (or (gnus-info-level info) gnus-level-killed))
1455 (score (or (gnus-info-score info) 0))
1456 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1457 (group-age (gnus-group-timestamp-delta group))
1458 (inhibit-read-only t))
1459 ;; Eval the cars of the lists until we find a match.
1461 (not (eval (caar list))))
1462 (setq list (cdr list)))
1463 (let ((face (cdar list)))
1464 (unless (eq face (get-text-property beg 'face))
1465 (gnus-put-text-property-excluding-characters-with-faces
1467 (setq face (if (boundp face) (symbol-value face) face)))
1468 (gnus-extent-start-open beg)))
1471 (defun gnus-group-update-group (group &optional visible-only)
1472 "Update all lines where GROUP appear.
1473 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1475 ;; Can't use `save-excursion' here, so we do it manually.
1476 (let ((buf (current-buffer))
1478 (set-buffer gnus-group-buffer)
1479 (setq mark (point-marker))
1480 ;; The buffer may be narrowed.
1483 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1485 found buffer-read-only)
1486 ;; Enter the current status into the dribble buffer.
1487 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1489 (not (gnus-ephemeral-group-p group)))
1491 (concat "(gnus-group-set-info '"
1492 (gnus-prin1-to-string (nth 2 entry))
1494 ;; Find all group instances. If topics are in use, each group
1495 ;; may be listed in more than once.
1496 (while (setq loc (text-property-any
1497 loc (point-max) 'gnus-group ident))
1500 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1502 (gnus-group-insert-group-line-info group)
1505 (gnus-run-hooks 'gnus-group-update-group-hook)))
1506 (setq loc (1+ loc)))
1507 (unless (or found visible-only)
1508 ;; No such line in the buffer, find out where it's supposed to
1509 ;; go, and insert it there (or at the end of the buffer).
1510 (if gnus-goto-missing-group-function
1511 (funcall gnus-goto-missing-group-function group)
1512 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1513 (while (and entry (car entry)
1517 (point-min) (point-max)
1518 'gnus-group (gnus-intern-safe
1519 (caar entry) gnus-active-hashtb)))))
1520 (setq entry (cdr entry)))
1521 (or entry (goto-char (point-max)))))
1522 ;; Finally insert the line.
1523 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1524 (gnus-group-insert-group-line-info group)
1527 (gnus-run-hooks 'gnus-group-update-group-hook))))
1528 (when gnus-group-update-group-function
1529 (funcall gnus-group-update-group-function group))
1530 (gnus-group-set-mode-line)))
1532 (set-marker mark nil)
1535 (defun gnus-group-set-mode-line ()
1536 "Update the mode line in the group buffer."
1537 (when (memq 'group gnus-updated-mode-lines)
1538 ;; Yes, we want to keep this mode line updated.
1540 (set-buffer gnus-group-buffer)
1541 (let* ((gformat (or gnus-group-mode-line-format-spec
1542 (gnus-set-format 'group-mode)))
1543 (gnus-tmp-news-server (cadr gnus-select-method))
1544 (gnus-tmp-news-method (car gnus-select-method))
1545 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1547 gnus-tmp-header ;Dummy binding for user-defined formats
1548 ;; Get the resulting string.
1550 (and gnus-dribble-buffer
1551 (buffer-name gnus-dribble-buffer)
1552 (buffer-modified-p gnus-dribble-buffer)
1554 (set-buffer gnus-dribble-buffer)
1555 (not (zerop (buffer-size))))))
1556 (mode-string (eval gformat)))
1557 ;; Say whether the dribble buffer has been modified.
1558 (setq mode-line-modified
1559 (if modified (car gnus-mode-line-modified)
1560 (cdr gnus-mode-line-modified)))
1561 ;; If the line is too long, we chop it off.
1562 (when (> (length mode-string) max-len)
1563 (setq mode-string (substring mode-string 0 (- max-len 4))))
1565 (setq mode-line-buffer-identification
1566 (gnus-mode-line-buffer-identification
1567 (list mode-string)))
1568 (set-buffer-modified-p modified))))))
1570 (defun gnus-group-group-name ()
1571 "Get the name of the newsgroup on the current line."
1572 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1574 (symbol-name group))))
1576 (defun gnus-group-group-level ()
1577 "Get the level of the newsgroup on the current line."
1578 (get-text-property (gnus-point-at-bol) 'gnus-level))
1580 (defun gnus-group-group-indentation ()
1581 "Get the indentation of the newsgroup on the current line."
1582 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1583 (and gnus-group-indentation-function
1584 (funcall gnus-group-indentation-function))
1587 (defun gnus-group-group-unread ()
1588 "Get the number of unread articles of the newsgroup on the current line."
1589 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1591 (defun gnus-group-new-mail (group)
1592 (if (nnmail-new-mail-p (gnus-group-real-name group))
1596 (defun gnus-group-level (group)
1597 "Return the estimated level of GROUP."
1598 (or (gnus-info-level (gnus-get-info group))
1599 (and (member group gnus-zombie-list) gnus-level-zombie)
1602 (defun gnus-group-search-forward (&optional backward all level first-too)
1603 "Find the next newsgroup with unread articles.
1604 If BACKWARD is non-nil, find the previous newsgroup instead.
1605 If ALL is non-nil, just find any newsgroup.
1606 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1608 If FIRST-TOO, the current line is also eligible as a target."
1609 (let ((way (if backward -1 1))
1610 (low gnus-level-killed)
1613 (if (and backward (progn (beginning-of-line)) (bobp))
1622 (get-text-property (point) 'gnus-group)
1626 (get-text-property (point) 'gnus-unread)))
1627 (and (numberp unread) (> unread 0)))
1628 (setq lev (get-text-property (point)
1630 (<= lev gnus-level-subscribed)))
1632 (and (setq lev (get-text-property (point)
1641 (zerop (forward-line way)))))
1643 (progn (gnus-group-position-point) t)
1644 (goto-char (or pos beg))
1647 ;;; Gnus group mode commands
1651 (defun gnus-group-mark-line-p ()
1654 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1655 (eq (char-after) gnus-process-mark)))
1657 (defun gnus-group-mark-group (n &optional unmark no-advance)
1658 "Mark the current group."
1660 (let ((buffer-read-only nil)
1664 (when (setq group (gnus-group-group-name))
1665 ;; Go to the mark position.
1667 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1668 (subst-char-in-region
1669 (point) (1+ (point)) (char-after)
1672 (setq gnus-group-marked (delete group gnus-group-marked))
1674 (setq gnus-group-marked
1675 (cons group (delete group gnus-group-marked)))
1676 gnus-process-mark)))
1678 (gnus-group-next-group 1))
1680 (gnus-summary-position-point)
1683 (defun gnus-group-unmark-group (n)
1684 "Remove the mark from the current group."
1686 (gnus-group-mark-group n 'unmark)
1687 (gnus-group-position-point))
1689 (defun gnus-group-unmark-all-groups ()
1690 "Unmark all groups."
1692 (let ((groups gnus-group-marked))
1695 (gnus-group-remove-mark (pop groups)))))
1696 (gnus-group-position-point))
1698 (defun gnus-group-mark-region (unmark beg end)
1699 "Mark all groups between point and mark.
1700 If UNMARK, remove the mark instead."
1701 (interactive "P\nr")
1702 (let ((num (count-lines beg end)))
1705 (- num (gnus-group-mark-group num unmark)))))
1707 (defun gnus-group-mark-buffer (&optional unmark)
1708 "Mark all groups in the buffer.
1709 If UNMARK, remove the mark instead."
1711 (gnus-group-mark-region unmark (point-min) (point-max)))
1713 (defun gnus-group-mark-regexp (regexp)
1714 "Mark all groups that match some regexp."
1715 (interactive "sMark (regexp): ")
1716 (let ((alist (cdr gnus-newsrc-alist))
1719 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1720 (gnus-group-set-mark group))))
1721 (gnus-group-position-point))
1723 (defun gnus-group-remove-mark (group &optional test-marked)
1724 "Remove the process mark from GROUP and move point there.
1725 Return nil if the group isn't displayed."
1726 (if (gnus-group-goto-group group nil test-marked)
1728 (gnus-group-mark-group 1 'unmark t)
1730 (setq gnus-group-marked
1731 (delete group gnus-group-marked))
1734 (defun gnus-group-set-mark (group)
1735 "Set the process mark on GROUP."
1736 (if (gnus-group-goto-group group)
1738 (gnus-group-mark-group 1 nil t))
1739 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1741 (defun gnus-group-universal-argument (arg &optional groups func)
1742 "Perform any command on all groups according to the process/prefix convention."
1744 (if (eq (setq func (or func
1747 (substitute-command-keys
1748 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1750 (gnus-error 1 "Undefined key")
1751 (gnus-group-iterate arg
1753 (command-execute func))))
1754 (gnus-group-position-point))
1756 (defun gnus-group-process-prefix (n)
1757 "Return a list of groups to work on.
1758 Take into consideration N (the prefix) and the list of marked groups."
1761 (setq n (prefix-numeric-value n))
1762 ;; There is a prefix, so we return a list of the N next
1764 (let ((way (if (< n 0) -1 1))
1769 (if (setq group (gnus-group-group-name))
1770 (push group groups))
1772 (gnus-group-next-group way)))
1774 ((and (gnus-region-active-p) (mark))
1775 ;; Work on the region between point and mark.
1776 (let ((max (max (point) (mark)))
1779 (goto-char (min (point) (mark)))
1782 (push (gnus-group-group-name) groups)
1783 (zerop (gnus-group-next-group 1))
1785 (nreverse groups))))
1787 ;; No prefix, but a list of marked articles.
1788 (reverse gnus-group-marked))
1790 ;; Neither marked articles or a prefix, so we return the
1792 (let ((group (gnus-group-group-name)))
1793 (and group (list group))))))
1795 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1796 ;;; imagine why I went through these contortions...
1798 (let ((function (make-symbol "gnus-group-iterate-function"))
1799 (window (make-symbol "gnus-group-iterate-window"))
1800 (groups (make-symbol "gnus-group-iterate-groups"))
1801 (group (make-symbol "gnus-group-iterate-group")))
1803 `(defun gnus-group-iterate (arg ,function)
1804 "Iterate FUNCTION over all process/prefixed groups.
1805 FUNCTION will be called with the group name as the parameter
1806 and with point over the group in question."
1807 (let ((,groups (gnus-group-process-prefix arg))
1808 (,window (selected-window))
1811 (setq ,group (car ,groups)
1812 ,groups (cdr ,groups))
1813 (select-window ,window)
1814 (gnus-group-remove-mark ,group)
1815 (save-selected-window
1817 (funcall ,function ,group)))))))))
1819 (put 'gnus-group-iterate 'lisp-indent-function 1)
1821 ;; Selecting groups.
1823 (defun gnus-group-read-group (&optional all no-article group select-articles)
1824 "Read news in this newsgroup.
1825 If the prefix argument ALL is non-nil, already read articles become
1826 readable. IF ALL is a number, fetch this number of articles. If the
1827 optional argument NO-ARTICLE is non-nil, no article will be
1828 auto-selected upon group entry. If GROUP is non-nil, fetch that
1831 (let ((no-display (eq all 0))
1832 (group (or group (gnus-group-group-name)))
1833 number active marked entry)
1837 (error "No group on current line"))
1838 (setq marked (gnus-info-marks
1839 (nth 2 (setq entry (gnus-gethash
1840 group gnus-newsrc-hashtb)))))
1841 ;; This group might be a dead group. In that case we have to get
1842 ;; the number of unread articles from `gnus-active-hashtb'.
1844 (cond ((numberp all) all)
1846 ((setq active (gnus-active group))
1847 (- (1+ (cdr active)) (car active)))))
1848 (gnus-summary-read-group
1849 group (or all (and (numberp number)
1850 (zerop (+ number (gnus-range-length
1851 (cdr (assq 'tick marked)))
1853 (cdr (assq 'dormant marked)))))))
1854 no-article nil no-display nil select-articles)))
1856 (defun gnus-group-select-group (&optional all)
1857 "Select this newsgroup.
1858 No article is selected automatically.
1859 If the group is opened, just switch the summary buffer.
1860 If ALL is non-nil, already read articles become readable.
1861 If ALL is a number, fetch this number of articles."
1863 (gnus-group-read-group all t))
1865 (defun gnus-group-quick-select-group (&optional all)
1866 "Select the current group \"quickly\".
1867 This means that no highlighting or scoring will be performed.
1868 If ALL (the prefix argument) is 0, don't even generate the summary
1871 This might be useful if you want to toggle threading
1872 before entering the group."
1874 (require 'gnus-score)
1876 gnus-score-find-score-files-function
1877 gnus-home-score-file
1878 gnus-apply-kill-hook
1879 gnus-summary-expunge-below)
1880 (gnus-group-read-group all t)))
1882 (defun gnus-group-visible-select-group (&optional all)
1883 "Select the current group without hiding any articles."
1885 (let ((gnus-inhibit-limiting t))
1886 (gnus-group-read-group all t)))
1888 (defun gnus-group-select-group-ephemerally ()
1889 "Select the current group without doing any processing whatsoever.
1890 You will actually be entered into a group that's a copy of
1891 the current group; no changes you make while in this group will
1894 (require 'gnus-score)
1896 gnus-score-find-score-files-function gnus-apply-kill-hook
1897 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1898 gnus-summary-mode-hook gnus-select-group-hook
1899 (group (gnus-group-group-name))
1900 (method (gnus-find-method-for-group group)))
1901 (gnus-group-read-ephemeral-group
1902 (gnus-group-prefixed-name group method) method)))
1905 (defun gnus-fetch-group (group &optional articles)
1906 "Start Gnus if necessary and enter GROUP.
1907 Returns whether the fetching was successful or not."
1908 (interactive (list (gnus-group-completing-read-group-name
1909 "Group name: " gnus-active-hashtb)))
1910 (unless (get-buffer gnus-group-buffer)
1912 (gnus-group-read-group articles nil group))
1915 (defun gnus-fetch-group-other-frame (group)
1916 "Pop up a frame and enter GROUP."
1918 (let ((window (get-buffer-window gnus-group-buffer)))
1920 (select-frame (window-frame window)))
1921 ((= (length (frame-list)) 1)
1922 (select-frame (make-frame)))
1925 (gnus-fetch-group group))
1927 (defvar gnus-ephemeral-group-server 0)
1929 ;; Enter a group that is not in the group buffer. Non-nil is returned
1930 ;; if selection was successful.
1931 (defun gnus-group-read-ephemeral-group (group method &optional activate
1932 quit-config request-only
1935 "Read GROUP from METHOD as an ephemeral group.
1936 If ACTIVATE, request the group first.
1937 If QUIT-CONFIG, use that window configuration when exiting from the
1939 If REQUEST-ONLY, don't actually read the group; just request it.
1940 If SELECT-ARTICLES, only select those articles.
1941 If PARAMETERS, use those as the group parameters.
1943 Return the name of the group if selection was successful."
1944 ;; Transform the select method into a unique server.
1945 (when (stringp method)
1946 (setq method (gnus-server-to-method method)))
1948 `(,(car method) ,(concat (cadr method) "-ephemeral")
1949 (,(intern (format "%s-address" (car method))) ,(cadr method))
1951 (let ((group (if (gnus-group-foreign-p group) group
1952 (gnus-group-prefixed-name (gnus-group-real-name group)
1957 ,gnus-level-default-subscribed nil nil ,method
1960 (cons 'quit-config quit-config)
1962 (cons gnus-summary-buffer
1963 gnus-current-window-configuration)))
1966 (push method gnus-ephemeral-servers)
1967 (set-buffer gnus-group-buffer)
1968 (unless (gnus-check-server method)
1969 (error "Unable to contact server: %s" (gnus-status-message method)))
1971 (gnus-activate-group group 'scan)
1972 (unless (gnus-request-group group)
1973 (error "Couldn't request group: %s"
1974 (nnheader-get-report (car method)))))
1978 (when (gnus-group-read-group t t group select-articles)
1982 (message "Quit reading the ephemeral group")
1985 (defun gnus-group-jump-to-group (group)
1986 "Jump to newsgroup GROUP."
1988 (list (gnus-group-completing-read-group-name
1989 "Group: " gnus-active-hashtb nil
1990 (gnus-read-active-file-p)
1991 gnus-group-jump-to-group-prompt
1992 'gnus-group-history)))
1994 (when (equal group "")
1995 (error "Empty group name"))
1997 (unless (gnus-ephemeral-group-p group)
1998 ;; Either go to the line in the group buffer...
1999 (unless (gnus-group-goto-group group)
2000 ;; ... or insert the line.
2001 (gnus-group-update-group group)
2002 (gnus-group-goto-group group)))
2003 ;; Adjust cursor point.
2004 (gnus-group-position-point))
2006 (defun gnus-group-goto-group (group &optional far test-marked)
2007 "Goto to newsgroup GROUP.
2008 If FAR, it is likely that the group is not on the current line.
2009 If TEST-MARKED, the line must be marked."
2013 ;; It's quite likely that we are on the right line, so
2014 ;; we check the current line first.
2016 (eq (get-text-property (point) 'gnus-group)
2017 (gnus-intern-safe group gnus-active-hashtb))
2018 (or (not test-marked) (gnus-group-mark-line-p)))
2020 ;; Previous and next line are also likely, so we check them as well.
2024 (and (eq (get-text-property (point) 'gnus-group)
2025 (gnus-intern-safe group gnus-active-hashtb))
2026 (or (not test-marked) (gnus-group-mark-line-p)))))
2032 (and (eq (get-text-property (point) 'gnus-group)
2033 (gnus-intern-safe group gnus-active-hashtb))
2034 (or (not test-marked) (gnus-group-mark-line-p)))))
2038 (goto-char (point-min))
2040 (while (and (not found)
2045 (gnus-intern-safe group gnus-active-hashtb))))
2046 (if (gnus-group-mark-line-p)
2051 ;; Search through the entire buffer.
2054 (point-min) (point-max)
2055 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2057 (defun gnus-group-next-group (n &optional silent)
2058 "Go to next N'th newsgroup.
2059 If N is negative, search backward instead.
2060 Returns the difference between N and the number of skips actually
2063 (gnus-group-next-unread-group n t nil silent))
2065 (defun gnus-group-next-unread-group (n &optional all level silent)
2066 "Go to next N'th unread newsgroup.
2067 If N is negative, search backward instead.
2068 If ALL is non-nil, choose any newsgroup, unread or not.
2069 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2070 such group can be found, the next group with a level higher than
2072 Returns the difference between N and the number of skips actually
2075 (let ((backward (< n 0))
2078 (gnus-group-search-forward
2079 backward (or (not gnus-group-goto-unread) all) level))
2083 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2084 (if level " on this level or higher" "")))
2087 (defun gnus-group-prev-group (n)
2088 "Go to previous N'th newsgroup.
2089 Returns the difference between N and the number of skips actually
2092 (gnus-group-next-unread-group (- n) t))
2094 (defun gnus-group-prev-unread-group (n)
2095 "Go to previous N'th unread newsgroup.
2096 Returns the difference between N and the number of skips actually
2099 (gnus-group-next-unread-group (- n)))
2101 (defun gnus-group-next-unread-group-same-level (n)
2102 "Go to next N'th unread newsgroup on the same level.
2103 If N is negative, search backward instead.
2104 Returns the difference between N and the number of skips actually
2107 (gnus-group-next-unread-group n t (gnus-group-group-level))
2108 (gnus-group-position-point))
2110 (defun gnus-group-prev-unread-group-same-level (n)
2111 "Go to next N'th unread newsgroup on the same level.
2112 Returns the difference between N and the number of skips actually
2115 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2116 (gnus-group-position-point))
2118 (defun gnus-group-best-unread-group (&optional exclude-group)
2119 "Go to the group with the highest level.
2120 If EXCLUDE-GROUP, do not go to that group."
2122 (goto-char (point-min))
2126 (setq unread (get-text-property (point) 'gnus-unread))
2127 (when (and (numberp unread) (> unread 0))
2128 (when (and (get-text-property (point) 'gnus-level)
2129 (< (get-text-property (point) 'gnus-level) best)
2130 (or (not exclude-group)
2131 (not (equal exclude-group (gnus-group-group-name)))))
2132 (setq best (get-text-property (point) 'gnus-level))
2133 (setq best-point (point))))
2136 (goto-char best-point))
2137 (gnus-group-position-point)
2138 (and best-point (gnus-group-group-name))))
2140 (defun gnus-group-first-unread-group ()
2141 "Go to the first group with unread articles."
2144 (let ((opoint (point))
2146 (goto-char (point-min))
2147 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2148 (and (numberp unread) ; Not a topic.
2149 (not (zerop unread))) ; Has unread articles.
2150 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2153 nil)) ; Not success.
2154 (gnus-group-position-point)))
2156 (defun gnus-group-enter-server-mode ()
2157 "Jump to the server buffer."
2159 (gnus-enter-server-buffer))
2161 (defun gnus-group-make-group (name &optional method address args)
2162 "Add a new newsgroup.
2163 The user will be prompted for a NAME, for a select METHOD, and an
2167 (gnus-read-group "Group name: ")
2168 (gnus-read-method "From method: ")))
2170 (when (stringp method)
2171 (setq method (or (gnus-server-to-method method) method)))
2172 (let* ((meth (gnus-method-simplify
2174 (not (gnus-server-equal method gnus-select-method)))
2175 (if address (list (intern method) address)
2177 (nname (if method (gnus-group-prefixed-name name meth) name))
2179 (when (gnus-gethash nname gnus-newsrc-hashtb)
2180 (error "Group %s already exists" nname))
2181 ;; Subscribe to the new group.
2182 (gnus-group-change-level
2183 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2184 gnus-level-default-subscribed gnus-level-killed
2185 (and (gnus-group-group-name)
2186 (gnus-gethash (gnus-group-group-name)
2187 gnus-newsrc-hashtb))
2190 (gnus-set-active nname (cons 1 0))
2191 (unless (gnus-ephemeral-group-p name)
2193 (concat "(gnus-group-set-info '"
2194 (gnus-prin1-to-string (cdr info)) ")")))
2196 (gnus-group-insert-group-line-info nname)
2198 (gnus-group-position-point)
2200 ;; Load the backend and try to make the backend create
2201 ;; the group as well.
2202 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2204 gnus-valid-select-methods)
2206 (gnus-check-server meth)
2207 (when (gnus-check-backend-function 'request-create-group nname)
2208 (gnus-request-create-group nname nil args))
2211 (defun gnus-group-delete-groups (&optional arg)
2212 "Delete the current group. Only meaningful with editable groups."
2214 (let ((n (length (gnus-group-process-prefix arg))))
2215 (when (gnus-yes-or-no-p
2217 "Delete this 1 group? "
2218 (format "Delete these %d groups? " n)))
2219 (gnus-group-iterate arg
2221 (gnus-group-delete-group group nil t))))))
2223 (defun gnus-group-delete-group (group &optional force no-prompt)
2224 "Delete the current group. Only meaningful with editable groups.
2225 If FORCE (the prefix) is non-nil, all the articles in the group will
2226 be deleted. This is \"deleted\" as in \"removed forever from the face
2227 of the Earth\". There is no undo. The user will be prompted before
2228 doing the deletion."
2230 (list (gnus-group-group-name)
2231 current-prefix-arg))
2233 (error "No group to delete"))
2234 (unless (gnus-check-backend-function 'request-delete-group group)
2235 (error "This backend does not support group deletion"))
2237 (if (and (not no-prompt)
2238 (not (gnus-yes-or-no-p
2240 "Do you really want to delete %s%s? "
2241 group (if force " and all its contents" "")))))
2243 (gnus-message 6 "Deleting group %s..." group)
2244 (if (not (gnus-request-delete-group group force))
2245 (gnus-error 3 "Couldn't delete group %s" group)
2246 (gnus-message 6 "Deleting group %s...done" group)
2247 (gnus-group-goto-group group)
2248 (gnus-group-kill-group 1 t)
2249 (gnus-sethash group nil gnus-active-hashtb)
2250 (when (and (boundp 'gnus-cache-active-hashtb)
2251 gnus-cache-active-hashtb)
2252 (gnus-sethash group nil gnus-cache-active-hashtb)
2253 (setq gnus-cache-active-altered t))
2255 (gnus-group-position-point)))
2257 (defun gnus-group-rename-group (group new-name)
2258 "Rename group from GROUP to NEW-NAME.
2259 When used interactively, GROUP is the group under point
2260 and NEW-NAME will be prompted for."
2263 (gnus-group-group-name)
2265 (unless (gnus-check-backend-function
2266 'request-rename-group (gnus-group-group-name))
2267 (error "This backend does not support renaming groups"))
2268 (gnus-read-group "Rename group to: "
2269 (gnus-group-real-name (gnus-group-group-name))))))
2271 (unless (gnus-check-backend-function 'request-rename-group group)
2272 (error "This backend does not support renaming groups"))
2274 (error "No group to rename"))
2275 (when (equal (gnus-group-real-name group) new-name)
2276 (error "Can't rename to the same name"))
2278 ;; We find the proper prefixed name.
2280 (if (gnus-group-native-p group)
2284 (gnus-group-prefixed-name
2285 (gnus-group-real-name new-name)
2286 (gnus-info-method (gnus-get-info group)))))
2288 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2291 (gnus-group-goto-group group)
2292 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2293 (gnus-request-rename-group group new-name))))
2294 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2295 ;; We rename the group internally by killing it...
2296 (gnus-group-kill-group)
2297 ;; ... changing its name ...
2298 (setcar (cdar gnus-list-of-killed-groups) new-name)
2299 ;; ... and then yanking it. Magic!
2300 (gnus-group-yank-group)
2301 (gnus-set-active new-name (gnus-active group))
2302 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2304 (setq gnus-killed-list (delete group gnus-killed-list))
2305 (gnus-set-active group nil)
2306 (gnus-dribble-touch)
2307 (gnus-group-position-point)))
2309 (defun gnus-group-edit-group (group &optional part)
2310 "Edit the group on the current line."
2311 (interactive (list (gnus-group-group-name)))
2312 (let ((part (or part 'info))
2315 (error "No group on current line"))
2316 (unless (setq info (gnus-get-info group))
2317 (error "Killed group; can't be edited"))
2319 (gnus-close-group group))
2321 ;; Find the proper form to edit.
2322 (cond ((eq part 'method)
2323 (or (gnus-info-method info) "native"))
2325 (gnus-info-params info))
2327 ;; The proper documentation.
2329 "Editing the %s for `%s'."
2331 ((eq part 'method) "select method")
2332 ((eq part 'params) "group parameters")
2334 (gnus-group-decoded-name group))
2336 (gnus-group-edit-group-done ',part ,group form)))
2339 (gnus-create-info-command
2342 "(gnus)Select Methods")
2344 "(gnus)Group Parameters")
2346 "(gnus)Group Info"))))))
2348 (defun gnus-group-edit-group-method (group)
2349 "Edit the select method of GROUP."
2350 (interactive (list (gnus-group-group-name)))
2351 (gnus-group-edit-group group 'method))
2353 (defun gnus-group-edit-group-parameters (group)
2354 "Edit the group parameters of GROUP."
2355 (interactive (list (gnus-group-group-name)))
2356 (gnus-group-edit-group group 'params))
2358 (defun gnus-group-edit-group-done (part group form)
2360 (let* ((method (cond ((eq part 'info) (nth 4 form))
2361 ((eq part 'method) form)
2363 (info (cond ((eq part 'info) form)
2364 ((eq part 'method) (gnus-get-info group))
2367 (if (or (not method)
2369 gnus-select-method method))
2370 (gnus-group-real-name (car info))
2371 (gnus-group-prefixed-name
2372 (gnus-group-real-name (car info)) method))
2374 (when (and new-group
2375 (not (equal new-group group)))
2376 (when (gnus-group-goto-group group)
2377 (gnus-group-kill-group 1))
2378 (gnus-activate-group new-group))
2380 (if (not (and info new-group))
2381 (gnus-group-set-info form (or new-group group) part)
2382 (setq info (gnus-copy-sequence info))
2383 (setcar info new-group)
2384 (unless (gnus-server-equal method "native")
2385 (unless (nthcdr 3 info)
2386 (nconc info (list nil nil)))
2387 (unless (nthcdr 4 info)
2388 (nconc info (list nil)))
2389 (gnus-info-set-method info method))
2390 (gnus-group-set-info info))
2391 (gnus-group-update-group (or new-group group))
2392 (gnus-group-position-point)))
2394 (defun gnus-group-make-useful-group (group method)
2395 "Create one of the groups described in `gnus-useful-groups'."
2397 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2399 gnus-useful-groups)))
2400 (list (cadr entry) (caddr entry))))
2401 (setq method (gnus-copy-sequence method))
2403 (while (setq entry (memq (assq 'eval method) method))
2404 (setcar entry (eval (cadar entry)))))
2405 (gnus-group-make-group group method))
2407 (defun gnus-group-make-help-group (&optional noerror)
2408 "Create the Gnus documentation group.
2409 Optional argument NOERROR modifies the behavior of this function when the
2410 group already exists:
2411 - if not given, and error is signaled,
2412 - if t, stay silent,
2413 - if anything else, just print a message."
2415 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2416 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2417 (if (gnus-gethash name gnus-newsrc-hashtb)
2418 (cond ((eq noerror nil)
2419 (error "Documentation group already exists"))
2424 (gnus-message 1 "Documentation group already exists")))
2427 (gnus-message 1 "Couldn't find doc group")
2428 (gnus-group-make-group
2429 (gnus-group-real-name name)
2430 (list 'nndoc "gnus-help"
2431 (list 'nndoc-address file)
2432 (list 'nndoc-article-type 'mbox))))
2434 (gnus-group-position-point))
2436 (defun gnus-group-make-doc-group (file type)
2437 "Create a group that uses a single file as the source."
2439 (list (read-file-name "File name: ")
2440 (and current-prefix-arg 'ask)))
2441 (when (eq type 'ask)
2446 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2448 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2449 ((= char ?b) 'babyl)
2450 ((= char ?d) 'digest)
2451 ((= char ?f) 'forward)
2453 ((= char ?g) 'guess)
2454 (t (setq err (format "%c unknown. " char))
2457 (let* ((file (expand-file-name file))
2458 (name (gnus-generate-new-group-name
2459 (gnus-group-prefixed-name
2460 (file-name-nondirectory file) '(nndoc "")))))
2461 (gnus-group-make-group
2462 (gnus-group-real-name name)
2464 (list 'nndoc-address file)
2465 (list 'nndoc-article-type (or type 'guess))))))
2467 (defvar nnweb-type-definition)
2468 (defvar gnus-group-web-type-history nil)
2469 (defvar gnus-group-web-search-history nil)
2470 (defun gnus-group-make-web-group (&optional solid)
2471 "Create an ephemeral nnweb group.
2472 If SOLID (the prefix), create a solid group."
2476 (if solid (gnus-read-group "Group name: ")
2477 (message-unique-id)))
2478 (default-type (or (car gnus-group-web-type-history)
2479 (symbol-name (caar nnweb-type-definition))))
2483 (format "Search engine type (default %s): " default-type)
2484 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2485 nnweb-type-definition)
2486 nil t nil 'gnus-group-web-type-history)
2491 (cons (or (car gnus-group-web-search-history) "") 0)
2492 'gnus-group-web-search-history))
2494 `(nnweb ,group (nnweb-search ,search)
2495 (nnweb-type ,(intern type))
2496 (nnweb-ephemeral-p t))))
2498 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2499 (gnus-group-read-ephemeral-group
2501 (cons (current-buffer)
2502 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2504 (defvar nnwarchive-type-definition)
2505 (defvar gnus-group-warchive-type-history nil)
2506 (defvar gnus-group-warchive-login-history nil)
2507 (defvar gnus-group-warchive-address-history nil)
2509 (defun gnus-group-make-warchive-group ()
2510 "Create a nnwarchive group."
2512 (require 'nnwarchive)
2513 (let* ((group (gnus-read-group "Group name: "))
2514 (default-type (or (car gnus-group-warchive-type-history)
2515 (symbol-name (caar nnwarchive-type-definition))))
2519 (format "Warchive type (default %s): " default-type)
2520 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2521 nnwarchive-type-definition)
2522 nil t nil 'gnus-group-warchive-type-history)
2524 (address (read-string "Warchive address: "
2525 nil 'gnus-group-warchive-address-history))
2526 (default-login (or (car gnus-group-warchive-login-history)
2531 (format "Warchive login (default %s): " user-mail-address)
2532 default-login 'gnus-group-warchive-login-history)
2535 `(nnwarchive ,address
2536 (nnwarchive-type ,(intern type))
2537 (nnwarchive-login ,login))))
2538 (gnus-group-make-group group method)))
2540 (defun gnus-group-make-archive-group (&optional all)
2541 "Create the (ding) Gnus archive group of the most recent articles.
2542 Given a prefix, create a full group."
2544 (let ((group (gnus-group-prefixed-name
2545 (if all "ding.archives" "ding.recent") '(nndir ""))))
2546 (when (gnus-gethash group gnus-newsrc-hashtb)
2547 (error "Archive group already exists"))
2548 (gnus-group-make-group
2549 (gnus-group-real-name group)
2550 (list 'nndir (if all "hpc" "edu")
2551 (list 'nndir-directory
2552 (if all gnus-group-archive-directory
2553 gnus-group-recent-archive-directory))))
2554 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2556 (defun gnus-group-make-directory-group (dir)
2557 "Create an nndir group.
2558 The user will be prompted for a directory. The contents of this
2559 directory will be used as a newsgroup. The directory should contain
2560 mail messages or news articles in files that have numeric names."
2562 (list (read-file-name "Create group from directory: ")))
2563 (unless (file-exists-p dir)
2564 (error "No such directory"))
2565 (unless (file-directory-p dir)
2566 (error "Not a directory"))
2570 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2572 (gnus-group-prefixed-name
2573 (expand-file-name ext dir)
2575 (setq ext (format "<%d>" (setq i (1+ i)))))
2576 (gnus-group-make-group
2577 (gnus-group-real-name group)
2578 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2580 (eval-when-compile (defvar nnkiboze-score-file))
2581 (defun gnus-group-make-kiboze-group (group address scores)
2582 "Create an nnkiboze group.
2583 The user will be prompted for a name, a regexp to match groups, and
2584 score file entries for articles to include in the group."
2587 (read-string "nnkiboze group name: ")
2588 (read-string "Source groups (regexp): ")
2589 (let ((headers (mapcar (lambda (group) (list group))
2590 '("subject" "from" "number" "date" "message-id"
2591 "references" "chars" "lines" "xref"
2592 "followup" "all" "body" "head")))
2593 scores header regexp regexps)
2594 (while (not (equal "" (setq header (completing-read
2595 "Match on header: " headers nil t))))
2597 (while (not (equal "" (setq regexp (read-string
2598 (format "Match on %s (regexp): "
2600 (push (list regexp nil nil 'r) regexps))
2601 (push (cons header regexps) scores))
2603 (gnus-group-make-group group "nnkiboze" address)
2604 (let* ((nnkiboze-current-group group)
2605 (score-file (car (nnkiboze-score-file "")))
2606 (score-dir (file-name-directory score-file)))
2607 (unless (file-exists-p score-dir)
2608 (make-directory score-dir))
2609 (with-temp-file score-file
2610 (let (emacs-lisp-mode-hook)
2611 (pp scores (current-buffer))))))
2613 (defun gnus-group-add-to-virtual (n vgroup)
2614 "Add the current group to a virtual group."
2616 (list current-prefix-arg
2617 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2619 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2620 (error "%s is not an nnvirtual group" vgroup))
2621 (gnus-close-group vgroup)
2622 (let* ((groups (gnus-group-process-prefix n))
2623 (method (gnus-info-method (gnus-get-info vgroup))))
2624 (setcar (cdr method)
2626 (nth 1 method) "\\|"
2629 (gnus-group-remove-mark s)
2630 (concat "\\(^" (regexp-quote s) "$\\)"))
2632 (gnus-group-position-point))
2634 (defun gnus-group-make-empty-virtual (group)
2635 "Create a new, fresh, empty virtual group."
2636 (interactive "sCreate new, empty virtual group: ")
2637 (let* ((method (list 'nnvirtual "^$"))
2638 (pgroup (gnus-group-prefixed-name group method)))
2639 ;; Check whether it exists already.
2640 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2641 (error "Group %s already exists" pgroup))
2642 ;; Subscribe the new group after the group on the current line.
2643 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2644 (gnus-group-update-group pgroup)
2646 (gnus-group-position-point)))
2648 (defun gnus-group-enter-directory (dir)
2649 "Enter an ephemeral nneething group."
2650 (interactive "DDirectory to read: ")
2651 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2652 (leaf (gnus-group-prefixed-name
2653 (file-name-nondirectory (directory-file-name dir))
2655 (name (gnus-generate-new-group-name leaf)))
2656 (unless (gnus-group-read-ephemeral-group
2658 (cons (current-buffer)
2659 (if (eq major-mode 'gnus-summary-mode)
2661 (error "Couldn't enter %s" dir))))
2664 (autoload 'nnimap-expunge "nnimap")
2665 (autoload 'nnimap-acl-get "nnimap")
2666 (autoload 'nnimap-acl-edit "nnimap"))
2668 (defun gnus-group-nnimap-expunge (group)
2669 "Expunge deleted articles in current nnimap GROUP."
2670 (interactive (list (gnus-group-group-name)))
2671 (let ((mailbox (gnus-group-real-name group)) method)
2673 (error "No group on current line"))
2674 (unless (gnus-get-info group)
2675 (error "Killed group; can't be edited"))
2676 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2677 (error "%s is not an nnimap group" group))
2678 (nnimap-expunge mailbox (cadr method))))
2680 (defun gnus-group-nnimap-edit-acl (group)
2681 "Edit the Access Control List of current nnimap GROUP."
2682 (interactive (list (gnus-group-group-name)))
2683 (let ((mailbox (gnus-group-real-name group)) method acl)
2685 (error "No group on current line"))
2686 (unless (gnus-get-info group)
2687 (error "Killed group; can't be edited"))
2688 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2689 (error "%s is not an nnimap group" group))
2690 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2691 (error "Server does not support ACL's"))
2692 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2694 An access control list is a list of (identifier . rights) elements.
2696 The identifier string specifies the corresponding user. The
2697 identifier \"anyone\" is reserved to refer to the universal identity.
2699 Rights is a string listing a (possibly empty) set of alphanumeric
2700 characters, each character listing a set of operations which is being
2701 controlled. Letters are reserved for ``standard'' rights, listed
2702 below. Digits are reserved for implementation or site defined rights.
2704 l - lookup (mailbox is visible to LIST/LSUB commands)
2705 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2706 SEARCH, COPY from mailbox)
2707 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2708 w - write (STORE flags other than \\SEEN and \\DELETED)
2709 i - insert (perform APPEND, COPY into mailbox)
2710 p - post (send mail to submission address for mailbox,
2711 not enforced by IMAP4 itself)
2712 c - create and delete mailbox (CREATE new sub-mailboxes in any
2713 implementation-defined hierarchy, RENAME or DELETE mailbox)
2714 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2715 a - administer (perform SETACL)" group)
2718 ,mailbox ',method ',acl form)))))
2720 ;; Group sorting commands
2721 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2723 (defun gnus-group-sort-groups (func &optional reverse)
2724 "Sort the group buffer according to FUNC.
2725 When used interactively, the sorting function used will be
2726 determined by the `gnus-group-sort-function' variable.
2727 If REVERSE (the prefix), reverse the sorting order."
2728 (interactive (list gnus-group-sort-function current-prefix-arg))
2729 (funcall gnus-group-sort-alist-function
2730 (gnus-make-sort-function func) reverse)
2731 (gnus-group-unmark-all-groups)
2732 (gnus-group-list-groups)
2733 (gnus-dribble-touch))
2735 (defun gnus-group-sort-flat (func reverse)
2736 ;; We peel off the dummy group from the alist.
2738 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2739 (pop gnus-newsrc-alist))
2741 (setq gnus-newsrc-alist
2742 (sort gnus-newsrc-alist func))
2744 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2745 ;; Regenerate the hash table.
2746 (gnus-make-hashtable-from-newsrc-alist)))
2748 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2749 "Sort the group buffer alphabetically by group name.
2750 If REVERSE, sort in reverse order."
2752 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2754 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2755 "Sort the group buffer alphabetically by real (unprefixed) group name.
2756 If REVERSE, sort in reverse order."
2758 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2760 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2761 "Sort the group buffer by number of unread articles.
2762 If REVERSE, sort in reverse order."
2764 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2766 (defun gnus-group-sort-groups-by-level (&optional reverse)
2767 "Sort the group buffer by group level.
2768 If REVERSE, sort in reverse order."
2770 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2772 (defun gnus-group-sort-groups-by-score (&optional reverse)
2773 "Sort the group buffer by group score.
2774 If REVERSE, sort in reverse order."
2776 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2778 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2779 "Sort the group buffer by group rank.
2780 If REVERSE, sort in reverse order."
2782 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2784 (defun gnus-group-sort-groups-by-method (&optional reverse)
2785 "Sort the group buffer alphabetically by backend name.
2786 If REVERSE, sort in reverse order."
2788 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2790 (defun gnus-group-sort-groups-by-server (&optional reverse)
2791 "Sort the group buffer alphabetically by server name.
2792 If REVERSE, sort in reverse order."
2794 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2796 ;;; Selected group sorting.
2798 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2799 "Sort the process/prefixed groups."
2800 (interactive (list current-prefix-arg gnus-group-sort-function))
2801 (let ((groups (gnus-group-process-prefix n)))
2802 (funcall gnus-group-sort-selected-function
2803 groups (gnus-make-sort-function func) reverse)
2804 (gnus-group-unmark-all-groups)
2805 (gnus-group-list-groups)
2806 (gnus-dribble-touch)))
2808 (defun gnus-group-sort-selected-flat (groups func reverse)
2809 (let (entries infos)
2810 ;; First find all the group entries for these groups.
2812 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2814 ;; Then sort the infos.
2818 (lambda (entry) (car entry))
2819 (setq entries (nreverse entries)))
2822 (setq infos (nreverse infos)))
2823 ;; Go through all the infos and replace the old entries
2824 ;; with the new infos.
2826 (setcar (car entries) (pop infos))
2828 ;; Update the hashtable.
2829 (gnus-make-hashtable-from-newsrc-alist)))
2831 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2832 "Sort the group buffer alphabetically by group name.
2833 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2834 sort in reverse order."
2835 (interactive (gnus-interactive "P\ny"))
2836 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2838 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2839 "Sort the group buffer alphabetically by real group name.
2840 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2841 sort in reverse order."
2842 (interactive (gnus-interactive "P\ny"))
2843 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2845 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2846 "Sort the group buffer by number of unread articles.
2847 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2848 sort in reverse order."
2849 (interactive (gnus-interactive "P\ny"))
2850 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2852 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2853 "Sort the group buffer by group level.
2854 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2855 sort in reverse order."
2856 (interactive (gnus-interactive "P\ny"))
2857 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2859 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2860 "Sort the group buffer by group score.
2861 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2862 sort in reverse order."
2863 (interactive (gnus-interactive "P\ny"))
2864 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2866 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2867 "Sort the group buffer by group rank.
2868 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2869 sort in reverse order."
2870 (interactive (gnus-interactive "P\ny"))
2871 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2873 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2874 "Sort the group buffer alphabetically by backend name.
2875 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2876 sort in reverse order."
2877 (interactive (gnus-interactive "P\ny"))
2878 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2880 ;;; Sorting predicates.
2882 (defun gnus-group-sort-by-alphabet (info1 info2)
2883 "Sort alphabetically."
2884 (string< (gnus-info-group info1) (gnus-info-group info2)))
2886 (defun gnus-group-sort-by-real-name (info1 info2)
2887 "Sort alphabetically on real (unprefixed) names."
2888 (string< (gnus-group-real-name (gnus-info-group info1))
2889 (gnus-group-real-name (gnus-info-group info2))))
2891 (defun gnus-group-sort-by-unread (info1 info2)
2892 "Sort by number of unread articles."
2893 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2894 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2895 (< (or (and (numberp n1) n1) 0)
2896 (or (and (numberp n2) n2) 0))))
2898 (defun gnus-group-sort-by-level (info1 info2)
2900 (< (gnus-info-level info1) (gnus-info-level info2)))
2902 (defun gnus-group-sort-by-method (info1 info2)
2903 "Sort alphabetically by backend name."
2904 (string< (car (gnus-find-method-for-group
2905 (gnus-info-group info1) info1))
2906 (car (gnus-find-method-for-group
2907 (gnus-info-group info2) info2))))
2909 (defun gnus-group-sort-by-server (info1 info2)
2910 "Sort alphabetically by server name."
2911 (string< (gnus-method-to-full-server-name
2912 (gnus-find-method-for-group
2913 (gnus-info-group info1) info1))
2914 (gnus-method-to-full-server-name
2915 (gnus-find-method-for-group
2916 (gnus-info-group info2) info2))))
2918 (defun gnus-group-sort-by-score (info1 info2)
2919 "Sort by group score."
2920 (> (gnus-info-score info1) (gnus-info-score info2)))
2922 (defun gnus-group-sort-by-rank (info1 info2)
2923 "Sort by level and score."
2924 (let ((level1 (gnus-info-level info1))
2925 (level2 (gnus-info-level info2)))
2926 (or (< level1 level2)
2927 (and (= level1 level2)
2928 (> (gnus-info-score info1) (gnus-info-score info2))))))
2932 (defun gnus-group-clear-data (&optional arg)
2933 "Clear all marks and read ranges from the current group."
2935 (gnus-group-iterate arg
2938 (gnus-info-clear-data (setq info (gnus-get-info group)))
2939 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2940 (when (gnus-group-goto-group group)
2941 (gnus-group-update-group-line))))))
2943 (defun gnus-group-clear-data-on-native-groups ()
2944 "Clear all marks and read ranges from all native groups."
2946 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2947 (let ((alist (cdr gnus-newsrc-alist))
2949 (while (setq info (pop alist))
2950 (when (gnus-group-native-p (gnus-info-group info))
2951 (gnus-info-clear-data info)))
2952 (gnus-get-unread-articles)
2953 (gnus-dribble-touch)
2954 (when (gnus-y-or-n-p
2955 "Move the cache away to avoid problems in the future? ")
2956 (call-interactively 'gnus-cache-move-cache)))))
2958 (defun gnus-info-clear-data (info)
2959 "Clear all marks and read ranges from INFO."
2960 (let ((group (gnus-info-group info))
2962 (dolist (el (gnus-info-marks info))
2963 (push `(,(cdr el) add (,(car el))) action))
2964 (push `(,(gnus-info-read info) add (read)) action)
2967 (gnus-request-set-mark ,group ',action)
2968 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2969 (gnus-info-set-read ',info ',(gnus-info-read info))
2970 (when (gnus-group-goto-group ,group)
2971 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2972 (gnus-group-update-group-line))))
2973 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2975 (gnus-request-set-mark group action)
2976 (gnus-info-set-read info nil)
2977 (when (gnus-info-marks info)
2978 (gnus-info-set-marks info nil))))
2980 ;; Group catching up.
2982 (defun gnus-group-catchup-current (&optional n all)
2983 "Mark all unread articles in the current newsgroup as read.
2984 If prefix argument N is numeric, the next N newsgroups will be
2985 caught up. If ALL is non-nil, marked articles will also be marked as
2986 read. Cross references (Xref: header) of articles are ignored.
2987 The number of newsgroups that this function was unable to catch
2990 (let ((groups (gnus-group-process-prefix n))
2993 (unless groups (error "No groups selected"))
2995 (or (not gnus-interactive-catchup) ;Without confirmation?
3000 "Do you really want to mark all articles in %s as read? "
3001 "Mark all unread articles in %s as read? ")
3002 (if (= (length groups) 1)
3004 (format "these %d groups" (length groups)))))))
3006 (while (setq group (pop groups))
3007 (gnus-group-remove-mark group)
3008 ;; Virtual groups have to be given special treatment.
3009 (let ((method (gnus-find-method-for-group group)))
3010 (when (eq 'nnvirtual (car method))
3011 (nnvirtual-catchup-group
3012 (gnus-group-real-name group) (nth 1 method) all)))
3013 (if (>= (gnus-group-level group) gnus-level-zombie)
3014 (gnus-message 2 "Dead groups can't be caught up")
3016 (gnus-group-goto-group group)
3017 (gnus-group-catchup group all))
3018 (gnus-group-update-group-line)
3019 (setq ret (1+ ret)))))
3020 (gnus-group-next-unread-group 1)
3023 (defun gnus-group-catchup-current-all (&optional n)
3024 "Mark all articles in current newsgroup as read.
3025 Cross references (Xref: header) of articles are ignored."
3027 (gnus-group-catchup-current n 'all))
3029 (defun gnus-group-catchup (group &optional all)
3030 "Mark all articles in GROUP as read.
3031 If ALL is non-nil, all articles are marked as read.
3032 The return value is the number of articles that were marked as read,
3033 or nil if no action could be taken."
3034 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3036 (marks (nth 3 (nth 2 entry)))
3037 (unread (gnus-list-of-unread-articles group)))
3038 ;; Remove entries for this group.
3039 (nnmail-purge-split-history (gnus-group-real-name group))
3040 ;; Do the updating only if the newsgroup isn't killed.
3041 (if (not (numberp (car entry)))
3042 (gnus-message 1 "Can't catch up %s; non-active group" group)
3043 (gnus-update-read-articles group nil)
3045 ;; Nix out the lists of marks and dormants.
3046 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3048 (list (cdr (assq 'dormant marks))
3050 (setq unread (gnus-uncompress-range
3051 (gnus-range-add (gnus-range-add
3052 unread (cdr (assq 'dormant marks)))
3053 (cdr (assq 'tick marks)))))
3054 (gnus-add-marked-articles group 'tick nil nil 'force)
3055 (gnus-add-marked-articles group 'dormant nil nil 'force))
3056 ;; Do auto-expirable marks if that's required.
3057 (when (gnus-group-auto-expirable-p group)
3058 (gnus-add-marked-articles group 'expire unread)
3059 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3060 (let ((gnus-newsgroup-name group))
3061 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3064 (defun gnus-group-expire-articles (&optional n)
3065 "Expire all expirable articles in the current newsgroup."
3067 (let ((groups (gnus-group-process-prefix n))
3070 (error "No groups to expire"))
3071 (while (setq group (pop groups))
3072 (gnus-group-remove-mark group)
3073 (gnus-group-expire-articles-1 group)
3074 (gnus-dribble-touch)
3075 (gnus-group-position-point))))
3077 (defun gnus-group-expire-articles-1 (group)
3078 (when (gnus-check-backend-function 'request-expire-articles group)
3079 (gnus-message 6 "Expiring articles in %s..." group)
3080 (let* ((info (gnus-get-info group))
3081 (expirable (if (gnus-group-total-expirable-p group)
3082 (cons nil (gnus-list-of-read-articles group))
3083 (assq 'expire (gnus-info-marks info))))
3084 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3085 (nnmail-expiry-target
3086 (or (gnus-group-find-parameter group 'expiry-target)
3087 nnmail-expiry-target)))
3089 (gnus-check-group group)
3092 (gnus-compress-sequence
3094 ;; We set the expiry variables to the group
3096 (let ((nnmail-expiry-wait-function nil)
3097 (nnmail-expiry-wait expiry-wait))
3098 (gnus-request-expire-articles
3099 (gnus-uncompress-sequence (cdr expirable)) group))
3100 ;; Just expire using the normal expiry values.
3101 (gnus-request-expire-articles
3102 (gnus-uncompress-sequence (cdr expirable)) group))))
3103 (gnus-close-group group))
3104 (gnus-message 6 "Expiring articles in %s...done" group)
3105 ;; Return the list of un-expired articles.
3108 (defun gnus-group-expire-all-groups ()
3109 "Expire all expirable articles in all newsgroups."
3112 (gnus-message 5 "Expiring...")
3113 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3114 (cdr gnus-newsrc-alist))))
3115 (gnus-group-expire-articles nil)))
3116 (gnus-group-position-point)
3117 (gnus-message 5 "Expiring...done"))
3119 (defun gnus-group-set-current-level (n level)
3120 "Set the level of the next N groups to LEVEL."
3125 (let ((s (read-string
3126 (format "Level (default %s): "
3127 (or (gnus-group-group-level)
3128 gnus-level-default-subscribed)))))
3129 (if (string-match "^\\s-*$" s)
3130 (int-to-string (or (gnus-group-group-level)
3131 gnus-level-default-subscribed))
3133 (unless (and (>= level 1) (<= level gnus-level-killed))
3134 (error "Invalid level: %d" level))
3135 (let ((groups (gnus-group-process-prefix n))
3137 (while (setq group (pop groups))
3138 (gnus-group-remove-mark group)
3139 (gnus-message 6 "Changed level of %s from %d to %d"
3140 group (or (gnus-group-group-level) gnus-level-killed)
3142 (gnus-group-change-level
3143 group level (or (gnus-group-group-level) gnus-level-killed))
3144 (gnus-group-update-group-line)))
3145 (gnus-group-position-point))
3147 (defun gnus-group-unsubscribe (&optional n)
3148 "Unsubscribe the current group."
3150 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3152 (defun gnus-group-subscribe (&optional n)
3153 "Subscribe the current group."
3155 (gnus-group-unsubscribe-current-group n 'subscribe))
3157 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3158 "Toggle subscription of the current group.
3159 If given numerical prefix, toggle the N next groups."
3161 (let ((groups (gnus-group-process-prefix n))
3164 (setq group (car groups)
3165 groups (cdr groups))
3166 (gnus-group-remove-mark group)
3167 (gnus-group-unsubscribe-group
3170 ((eq do-sub 'unsubscribe)
3171 gnus-level-default-unsubscribed)
3172 ((eq do-sub 'subscribe)
3173 gnus-level-default-subscribed)
3174 ((<= (gnus-group-group-level) gnus-level-subscribed)
3175 gnus-level-default-unsubscribed)
3177 gnus-level-default-subscribed))
3179 (gnus-group-update-group-line))
3180 (gnus-group-next-group 1)))
3182 (defun gnus-group-unsubscribe-group (group &optional level silent)
3183 "Toggle subscription to GROUP.
3184 Killed newsgroups are subscribed. If SILENT, don't try to update the
3187 (list (gnus-group-completing-read-group-name
3188 "Group: " gnus-active-hashtb nil
3189 (gnus-read-active-file-p)
3191 'gnus-group-history)))
3192 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3194 ((string-match "^[ \t]*$" group)
3195 (error "Empty group name"))
3197 ;; Toggle subscription flag.
3198 (gnus-group-change-level
3199 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3200 gnus-level-subscribed)
3201 (1+ gnus-level-subscribed)
3202 gnus-level-default-subscribed)))
3204 (gnus-group-update-group group)))
3205 ((and (stringp group)
3206 (or (not (gnus-read-active-file-p))
3207 (gnus-active group)))
3208 ;; Add new newsgroup.
3209 (gnus-group-change-level
3211 (if level level gnus-level-default-subscribed)
3212 (or (and (member group gnus-zombie-list)
3215 (when (gnus-group-group-name)
3216 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3218 (gnus-group-update-group group)))
3219 (t (error "No such newsgroup: %s" group)))
3220 (gnus-group-position-point)))
3222 (defun gnus-group-transpose-groups (n)
3223 "Move the current newsgroup up N places.
3224 If given a negative prefix, move down instead. The difference between
3225 N and the number of steps taken is returned."
3227 (unless (gnus-group-group-name)
3228 (error "No group on current line"))
3229 (gnus-group-kill-group 1)
3231 (forward-line (- n))
3232 (gnus-group-yank-group)
3233 (gnus-group-position-point)))
3235 (defun gnus-group-kill-all-zombies (&optional dummy)
3236 "Kill all zombie newsgroups.
3237 The optional DUMMY should always be nil."
3238 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3240 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3241 (setq gnus-zombie-list nil)
3242 (gnus-dribble-touch)
3243 (gnus-group-list-groups)))
3245 (defun gnus-group-kill-region (begin end)
3246 "Kill newsgroups in current region (excluding current point).
3247 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3262 (beginning-of-line) ;Important when LINES < 1
3263 (gnus-group-kill-group lines)))
3265 (defun gnus-group-kill-group (&optional n discard)
3266 "Kill the next N groups.
3267 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3268 However, only groups that were alive can be yanked; already killed
3269 groups or zombie groups can't be yanked.
3270 The return value is the name of the group that was killed, or a list
3273 (let ((buffer-read-only nil)
3274 (groups (gnus-group-process-prefix n))
3275 group entry level out)
3276 (if (< (length groups) 10)
3277 ;; This is faster when there are few groups.
3279 (push (setq group (pop groups)) out)
3280 (gnus-group-remove-mark group)
3281 (setq level (gnus-group-group-level))
3283 (when (and (not discard)
3284 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3287 (gnus-group-goto-group ,(gnus-group-group-name))
3288 (gnus-group-yank-group)))
3289 (push (cons (car entry) (nth 2 entry))
3290 gnus-list-of-killed-groups))
3291 (gnus-group-change-level
3292 (if entry entry group) gnus-level-killed (if entry nil level))
3293 (message "Killed group %s" group))
3294 ;; If there are lots and lots of groups to be killed, we use
3295 ;; this thing instead.
3297 (setq groups (nreverse groups))
3299 (gnus-group-remove-mark (setq group (pop groups)))
3301 (push group gnus-killed-list)
3302 (setq gnus-newsrc-alist
3303 (delq (assoc group gnus-newsrc-alist)
3305 (when gnus-group-change-level-function
3306 (funcall gnus-group-change-level-function
3307 group gnus-level-killed 3))
3309 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3310 (push (cons (car entry) (nth 2 entry))
3311 gnus-list-of-killed-groups)
3312 (setcdr (cdr entry) (cdddr entry)))
3313 ((member group gnus-zombie-list)
3314 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3315 ;; There may be more than one instance displayed.
3316 (while (gnus-group-goto-group group)
3317 (gnus-delete-line)))
3318 (gnus-make-hashtable-from-newsrc-alist)))
3320 (gnus-group-position-point)
3321 (if (< (length out) 2) (car out) (nreverse out))))
3323 (defun gnus-group-yank-group (&optional arg)
3324 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3325 The numeric ARG specifies how many newsgroups are to be yanked. The
3326 name of the newsgroup yanked is returned, or (if several groups are
3327 yanked) a list of yanked groups is returned."
3329 (setq arg (or arg 1))
3330 (let (info group prev out)
3331 (while (>= (decf arg) 0)
3332 (when (not (setq info (pop gnus-list-of-killed-groups)))
3333 (error "No more newsgroups to yank"))
3334 (push (setq group (nth 1 info)) out)
3335 ;; Find which newsgroup to insert this one before - search
3336 ;; backward until something suitable is found. If there are no
3337 ;; other newsgroups in this buffer, just make this newsgroup the
3339 (setq prev (gnus-group-group-name))
3340 (gnus-group-change-level
3341 info (gnus-info-level (cdr info)) gnus-level-killed
3342 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3344 (gnus-group-insert-group-line-info group)
3346 `(when (gnus-group-goto-group ,group)
3347 (gnus-group-kill-group 1))))
3349 (gnus-group-position-point)
3350 (if (< (length out) 2) (car out) (nreverse out))))
3352 (defun gnus-group-kill-level (level)
3353 "Kill all groups that is on a certain LEVEL."
3354 (interactive "nKill all groups on level: ")
3356 ((= level gnus-level-zombie)
3357 (setq gnus-killed-list
3358 (nconc gnus-zombie-list gnus-killed-list))
3359 (setq gnus-zombie-list nil))
3360 ((and (< level gnus-level-zombie)
3362 (or gnus-expert-user
3365 "Do you really want to kill all groups on level %d? "
3367 (let* ((prev gnus-newsrc-alist)
3370 (if (= (gnus-info-level (car alist)) level)
3372 (push (gnus-info-group (car alist)) gnus-killed-list)
3373 (setcdr prev (cdr alist)))
3375 (setq alist (cdr alist)))
3376 (gnus-make-hashtable-from-newsrc-alist)
3377 (gnus-group-list-groups)))
3379 (error "Can't kill; invalid level: %d" level))))
3381 (defun gnus-group-list-all-groups (&optional arg)
3382 "List all newsgroups with level ARG or lower.
3383 Default is gnus-level-unsubscribed, which lists all subscribed and most
3384 unsubscribed groups."
3386 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3388 ;; Redefine this to list ALL killed groups if prefix arg used.
3389 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3390 (defun gnus-group-list-killed (&optional arg)
3391 "List all killed newsgroups in the group buffer.
3392 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3393 entail asking the server for the groups."
3395 ;; Find all possible killed newsgroups if arg.
3397 (gnus-get-killed-groups))
3398 (if (not gnus-killed-list)
3399 (gnus-message 6 "No killed groups")
3400 (let (gnus-group-list-mode)
3401 (funcall gnus-group-prepare-function
3402 gnus-level-killed t gnus-level-killed))
3403 (goto-char (point-min)))
3404 (gnus-group-position-point))
3406 (defun gnus-group-list-zombies ()
3407 "List all zombie newsgroups in the group buffer."
3409 (if (not gnus-zombie-list)
3410 (gnus-message 6 "No zombie groups")
3411 (let (gnus-group-list-mode)
3412 (funcall gnus-group-prepare-function
3413 gnus-level-zombie t gnus-level-zombie))
3414 (goto-char (point-min)))
3415 (gnus-group-position-point))
3417 (defun gnus-group-list-active ()
3418 "List all groups that are available from the server(s)."
3420 ;; First we make sure that we have really read the active file.
3421 (unless (gnus-read-active-file-p)
3422 (let ((gnus-read-active-file t)
3423 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3424 (gnus-read-active-file)))
3425 ;; Find all groups and sort them.
3433 (push (symbol-name sym) list)))
3437 (buffer-read-only nil)
3441 (setq group (pop groups))
3442 (gnus-add-text-properties
3443 (point) (prog1 (1+ (point))
3445 (gnus-group-decoded-name group)
3447 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3449 'gnus-level (inline (gnus-group-level group)))))
3450 (goto-char (point-min))))
3452 (defun gnus-activate-all-groups (level)
3453 "Activate absolutely all groups."
3454 (interactive (list gnus-level-unsubscribed))
3455 (let ((gnus-activate-level level)
3456 (gnus-activate-foreign-newsgroups level))
3457 (gnus-group-get-new-news)))
3459 (defun gnus-group-get-new-news (&optional arg)
3460 "Get newly arrived articles.
3461 If ARG is a number, it specifies which levels you are interested in
3462 re-scanning. If ARG is non-nil and not a number, this will force
3463 \"hard\" re-reading of the active files from all servers."
3466 (let ((gnus-inhibit-demon t)
3467 ;; Binding this variable will inhibit multiple fetchings
3468 ;; of the same mail source.
3469 (nnmail-fetched-sources (list t)))
3470 (gnus-run-hooks 'gnus-get-new-news-hook)
3472 ;; Read any slave files.
3474 (gnus-master-read-slave-newsrc))
3476 ;; We might read in new NoCeM messages here.
3477 (when (and gnus-use-nocem
3479 (gnus-nocem-scan-groups))
3480 ;; If ARG is not a number, then we read the active file.
3481 (when (and arg (not (numberp arg)))
3482 (let ((gnus-read-active-file t))
3483 (gnus-read-active-file))
3486 ;; If the user wants it, we scan for new groups.
3487 (when (eq gnus-check-new-newsgroups 'always)
3488 (gnus-find-new-newsgroups)))
3490 (setq arg (gnus-group-default-level arg t))
3491 (if (and gnus-read-active-file (not arg))
3493 (gnus-read-active-file)
3494 (gnus-get-unread-articles arg))
3495 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3496 (gnus-get-unread-articles arg)))
3497 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3498 (gnus-group-list-groups (and (numberp arg)
3499 (max (car gnus-group-list-mode) arg))))
3501 (when (and gnus-agent (not (interactive-p)))
3502 (gnus-agent-toggle-plugged gnus-plugged)))
3504 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3505 "Check for newly arrived news in the current group (and the N-1 next groups).
3506 The difference between N and the number of newsgroup checked is returned.
3507 If N is negative, this group and the N-1 previous groups will be checked."
3509 (let* ((groups (gnus-group-process-prefix n))
3510 (ret (if (numberp n) (- n (length groups)) 0))
3514 (gnus-inhibit-demon t)
3515 ;; Binding this variable will inhibit multiple fetchings
3516 ;; of the same mail source.
3517 (nnmail-fetched-sources (list t)))
3518 (gnus-run-hooks 'gnus-get-new-news-hook)
3519 (while (setq group (pop groups))
3520 (gnus-group-remove-mark group)
3521 ;; Bypass any previous denials from the server.
3522 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3523 (if (gnus-activate-group group (if dont-scan nil 'scan))
3525 (gnus-get-unread-articles-in-group
3526 (gnus-get-info group) (gnus-active group) t)
3527 (unless (gnus-virtual-group-p group)
3528 (gnus-close-group group))
3530 (gnus-agent-save-group-info
3531 method (gnus-group-real-name group) (gnus-active group)))
3532 (gnus-group-update-group group))
3533 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3535 (gnus-error 3 "Server denied access")
3536 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3539 (when gnus-goto-next-group-when-activating
3540 (gnus-group-next-unread-group 1 t))
3541 (gnus-summary-position-point)
3544 (defun gnus-group-fetch-faq (group &optional faq-dir)
3545 "Fetch the FAQ for the current group.
3546 If given a prefix argument, prompt for the FAQ dir
3550 (gnus-group-group-name)
3551 (when current-prefix-arg
3553 "Faq dir: " (and (listp gnus-group-faq-directory)
3555 gnus-group-faq-directory))))))
3557 (error "No group name given"))
3558 (let ((dirs (or faq-dir gnus-group-faq-directory))
3560 (unless (listp dirs)
3561 (setq dirs (list dirs)))
3562 (while (and (not found)
3563 (setq dir (pop dirs)))
3564 (let ((name (gnus-group-real-name group)))
3565 (setq file (expand-file-name name dir)))
3566 (if (not (file-exists-p file))
3567 (gnus-message 1 "No such file: %s" file)
3568 (let ((enable-local-variables nil))
3572 (defun gnus-group-fetch-charter (group)
3573 "Fetch the charter for the current group.
3574 If given a prefix argument, prompt for a group."
3576 (list (or (when current-prefix-arg
3577 (completing-read "Group: " gnus-active-hashtb))
3578 (gnus-group-group-name)
3579 gnus-newsgroup-name)))
3581 (error "No group name given"))
3583 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3585 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3586 (setq hierarchy (match-string 1 name))
3587 (if (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3588 (browse-url (eval url))
3589 (gnus-group-fetch-control group)))))
3591 (defun gnus-group-fetch-control (group)
3592 "Fetch the archived control messages for the current group.
3593 If given a prefix argument, prompt for a group."
3595 (list (or (when current-prefix-arg
3596 (completing-read "Group: " gnus-active-hashtb))
3597 (gnus-group-group-name)
3598 gnus-newsgroup-name)))
3600 (error "No group name given"))
3601 (let ((name (gnus-group-real-name group))
3603 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3604 (setq hierarchy (match-string 1 name))
3605 (if gnus-group-fetch-control-use-browse-url
3606 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3607 hierarchy "/" name ".Z"))
3608 (let ((enable-local-variables nil))
3609 (gnus-group-read-ephemeral-group
3611 `(nndoc ,group (nndoc-address
3612 ,(find-file-noselect
3613 (concat "/ftp@ftp.isc.org:/usenet/control/"
3614 hierarchy "/" name ".Z")))
3615 (nndoc-article-type mbox)) t nil nil))))))
3617 (defun gnus-group-describe-group (force &optional group)
3618 "Display a description of the current newsgroup."
3619 (interactive (list current-prefix-arg (gnus-group-group-name)))
3620 (let* ((method (gnus-find-method-for-group group))
3621 (mname (gnus-group-prefixed-name "" method))
3624 gnus-description-hashtb)
3625 (gnus-sethash mname nil gnus-description-hashtb))
3627 (error "No group name given"))
3628 (when (or (and gnus-description-hashtb
3629 ;; We check whether this group's method has been
3630 ;; queried for a description file.
3631 (gnus-gethash mname gnus-description-hashtb))
3632 (setq desc (gnus-group-get-description group))
3633 (gnus-read-descriptions-file method))
3635 (or desc (gnus-gethash group gnus-description-hashtb)
3636 "No description available")))))
3638 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3639 (defun gnus-group-describe-all-groups (&optional force)
3640 "Pop up a buffer with descriptions of all newsgroups."
3643 (setq gnus-description-hashtb nil))
3644 (when (not (or gnus-description-hashtb
3645 (gnus-read-all-descriptions-files)))
3646 (error "Couldn't request descriptions file"))
3647 (let ((buffer-read-only nil)
3653 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3654 (insert (format " *: %-20s %s\n"
3655 (gnus-group-name-decode
3656 (symbol-name group) charset)
3657 (gnus-group-name-decode
3658 (symbol-value group) charset))))
3659 (gnus-add-text-properties
3660 b (1+ b) (list 'gnus-group group
3661 'gnus-unread t 'gnus-marked nil
3662 'gnus-level (1+ gnus-level-subscribed))))
3663 gnus-description-hashtb)
3664 (goto-char (point-min))
3665 (gnus-group-position-point)))
3667 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3668 (defun gnus-group-apropos (regexp &optional search-description)
3669 "List all newsgroups that have names that match a regexp."
3670 (interactive "sGnus apropos (regexp): ")
3672 (obuf (current-buffer))
3674 ;; Go through all newsgroups that are known to Gnus.
3677 (and (symbol-name group)
3678 (string-match regexp (symbol-name group))
3679 (symbol-value group)
3680 (push (symbol-name group) groups)))
3682 ;; Also go through all descriptions that are known to Gnus.
3683 (when search-description
3686 (and (string-match regexp (symbol-value group))
3687 (push (symbol-name group) groups)))
3688 gnus-description-hashtb))
3690 (gnus-message 3 "No groups matched \"%s\"." regexp)
3691 ;; Print out all the groups.
3693 (pop-to-buffer "*Gnus Help*")
3694 (buffer-disable-undo)
3696 (setq groups (sort groups 'string<))
3698 ;; Groups may be entered twice into the list of groups.
3699 (when (not (string= (car groups) prev))
3700 (setq prev (car groups))
3701 (let ((charset (gnus-group-name-charset nil prev)))
3702 (insert (gnus-group-name-decode prev charset) "\n")
3703 (when (and gnus-description-hashtb
3704 (setq des (gnus-gethash (car groups)
3705 gnus-description-hashtb)))
3706 (insert " " (gnus-group-name-decode des charset) "\n"))))
3707 (setq groups (cdr groups)))
3708 (goto-char (point-min))))
3709 (pop-to-buffer obuf)))
3711 (defun gnus-group-description-apropos (regexp)
3712 "List all newsgroups that have names or descriptions that match a regexp."
3713 (interactive "sGnus description apropos (regexp): ")
3714 (when (not (or gnus-description-hashtb
3715 (gnus-read-all-descriptions-files)))
3716 (error "Couldn't request descriptions file"))
3717 (gnus-group-apropos regexp t))
3719 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3720 (defun gnus-group-list-matching (level regexp &optional all lowest)
3721 "List all groups with unread articles that match REGEXP.
3722 If the prefix LEVEL is non-nil, it should be a number that says which
3723 level to cut off listing groups.
3724 If ALL, also list groups with no unread articles.
3725 If LOWEST, don't list groups with level lower than LOWEST.
3727 This command may read the active file."
3728 (interactive "P\nsList newsgroups matching: ")
3729 ;; First make sure active file has been read.
3731 (> (prefix-numeric-value level) gnus-level-killed))
3732 (gnus-get-killed-groups))
3733 (funcall gnus-group-prepare-function
3734 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3735 (goto-char (point-min))
3736 (gnus-group-position-point))
3738 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3739 "List all groups that match REGEXP.
3740 If the prefix LEVEL is non-nil, it should be a number that says which
3741 level to cut off listing groups.
3742 If LOWEST, don't list groups with level lower than LOWEST."
3743 (interactive "P\nsList newsgroups matching: ")
3745 (setq level (prefix-numeric-value level)))
3746 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3748 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3749 (defun gnus-group-save-newsrc (&optional force)
3750 "Save the Gnus startup files.
3751 If FORCE, force saving whether it is necessary or not."
3753 (gnus-save-newsrc-file force))
3755 (defun gnus-group-restart (&optional arg)
3756 "Force Gnus to read the .newsrc file."
3758 (when (gnus-yes-or-no-p
3759 (format "Are you sure you want to restart Gnus? "))
3760 (gnus-save-newsrc-file)
3764 (defun gnus-group-read-init-file ()
3765 "Read the Gnus elisp init file."
3767 (gnus-read-init-file)
3768 (gnus-message 5 "Read %s" gnus-init-file))
3770 (defun gnus-group-check-bogus-groups (&optional silent)
3771 "Check bogus newsgroups.
3772 If given a prefix, don't ask for confirmation before removing a bogus
3775 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3776 (gnus-group-list-groups))
3778 (defun gnus-group-find-new-groups (&optional arg)
3779 "Search for new groups and add them.
3780 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3781 With 1 C-u, use the `ask-server' method to query the server for new
3783 With 2 C-u's, use most complete method possible to query the server
3784 for new groups, and subscribe the new groups as zombies."
3786 (gnus-find-new-newsgroups (or arg 1))
3787 (gnus-group-list-groups))
3789 (defun gnus-group-edit-global-kill (&optional article group)
3790 "Edit the global kill file.
3791 If GROUP, edit that local kill file instead."
3793 (setq gnus-current-kill-article article)
3794 (gnus-kill-file-edit-file group)
3797 (substitute-command-keys
3798 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3799 (if group "local" "global")))))
3801 (defun gnus-group-edit-local-kill (article group)
3802 "Edit a local kill file."
3803 (interactive (list nil (gnus-group-group-name)))
3804 (gnus-group-edit-global-kill article group))
3806 (defun gnus-group-force-update ()
3807 "Update `.newsrc' file."
3809 (gnus-save-newsrc-file))
3811 (defun gnus-group-suspend ()
3812 "Suspend the current Gnus session.
3813 In fact, cleanup buffers except for group mode buffer.
3814 The hook gnus-suspend-gnus-hook is called before actually suspending."
3816 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3817 (gnus-offer-save-summaries)
3818 ;; Kill Gnus buffers except for group mode buffer.
3819 (let ((group-buf (get-buffer gnus-group-buffer)))
3820 (mapcar (lambda (buf)
3821 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3825 (eq major-mode 'message-mode))))
3826 (gnus-kill-buffer buf)))
3828 (gnus-kill-gnus-frames)
3830 (bury-buffer group-buf)
3831 (delete-windows-on group-buf t))))
3833 (defun gnus-group-clear-dribble ()
3834 "Clear all information from the dribble buffer."
3836 (gnus-dribble-clear)
3837 (gnus-message 7 "Cleared dribble buffer"))
3839 (defun gnus-group-exit ()
3840 "Quit reading news after updating .newsrc.eld and .newsrc.
3841 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3844 (or noninteractive ;For gnus-batch-kill
3845 (not gnus-interactive-exit) ;Without confirmation
3847 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3848 (gnus-run-hooks 'gnus-exit-gnus-hook)
3849 ;; Offer to save data from non-quitted summary buffers.
3850 (gnus-offer-save-summaries)
3851 ;; Save the newsrc file(s).
3852 (gnus-save-newsrc-file)
3854 (gnus-close-backends)
3855 ;; Reset everything.
3857 ;; Allow the user to do things after cleaning up.
3858 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3860 (defun gnus-group-quit ()
3861 "Quit reading news without updating .newsrc.eld or .newsrc.
3862 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3864 (when (or noninteractive ;For gnus-batch-kill
3865 (zerop (buffer-size))
3866 (not (gnus-server-opened gnus-select-method))
3868 (not gnus-current-startup-file)
3870 (format "Quit reading news without saving %s? "
3871 (file-name-nondirectory gnus-current-startup-file))))
3872 (gnus-run-hooks 'gnus-exit-gnus-hook)
3873 (gnus-configure-windows 'group t)
3874 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3875 (not (zerop (save-excursion
3876 (set-buffer gnus-dribble-buffer)
3879 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3881 (gnus-close-backends)
3883 (gnus-kill-buffer gnus-group-buffer)
3884 ;; Allow the user to do things after cleaning up.
3885 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3887 (defun gnus-group-describe-briefly ()
3888 "Give a one line description of the group mode commands."
3890 (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")))
3892 (defun gnus-group-browse-foreign-server (method)
3893 "Browse a foreign news server.
3894 If called interactively, this function will ask for a select method
3895 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3896 If not, METHOD should be a list where the first element is the method
3897 and the second element is the address."
3899 (list (let ((how (completing-read
3901 (append gnus-valid-select-methods gnus-server-alist)
3902 nil t (cons "nntp" 0) 'gnus-method-history)))
3903 ;; We either got a backend name or a virtual server name.
3904 ;; If the first, we also need an address.
3905 (if (assoc how gnus-valid-select-methods)
3907 ;; Suggested by mapjph@bath.ac.uk.
3910 (mapcar (lambda (server) (list server))
3911 gnus-secondary-servers)))
3912 ;; We got a server name.
3914 (gnus-browse-foreign-server method))
3916 (defun gnus-group-set-info (info &optional method-only-group part)
3917 (when (or info part)
3918 (let* ((entry (gnus-gethash
3919 (or method-only-group (gnus-info-group info))
3920 gnus-newsrc-hashtb))
3922 (info (if method-only-group (nth 2 entry) info))
3924 (when method-only-group
3926 (error "Trying to change non-existent group %s" method-only-group))
3927 ;; We have received parts of the actual group info - either the
3928 ;; select method or the group parameters. We first check
3929 ;; whether we have to extend the info, and if so, do that.
3930 (let ((len (length info))
3931 (total (if (eq part 'method) 5 6)))
3933 (setcdr (nthcdr (1- len) info)
3934 (make-list (- total len) nil)))
3935 ;; Then we enter the new info.
3936 (setcar (nthcdr (1- total) info) part-info)))
3938 ;; This is a new group, so we just create it.
3940 (set-buffer gnus-group-buffer)
3941 (setq method (gnus-info-method info))
3942 (when (gnus-server-equal method "native")
3945 (set-buffer gnus-group-buffer)
3947 ;; It's a foreign group...
3948 (gnus-group-make-group
3949 (gnus-group-real-name (gnus-info-group info))
3950 (if (stringp method) method
3951 (prin1-to-string (car method)))
3953 (nth 1 (gnus-info-method info))))
3954 ;; It's a native group.
3955 (gnus-group-make-group (gnus-info-group info))))
3956 (gnus-message 6 "Note: New group created")
3958 (gnus-gethash (gnus-group-prefixed-name
3959 (gnus-group-real-name (gnus-info-group info))
3960 (or (gnus-info-method info) gnus-select-method))
3961 gnus-newsrc-hashtb))))
3962 ;; Whether it was a new group or not, we now have the entry, so we
3963 ;; can do the update.
3966 (setcar (nthcdr 2 entry) info)
3967 (when (and (not (eq (car entry) t))
3968 (gnus-active (gnus-info-group info)))
3969 (setcar entry (length
3970 (gnus-list-of-unread-articles (car info))))))
3971 (error "No such group: %s" (gnus-info-group info))))))
3973 (defun gnus-group-set-method-info (group select-method)
3974 (gnus-group-set-info select-method group 'method))
3976 (defun gnus-group-set-params-info (group params)
3977 (gnus-group-set-info params group 'params))
3979 (defun gnus-add-marked-articles (group type articles &optional info force)
3980 ;; Add ARTICLES of TYPE to the info of GROUP.
3981 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3982 ;; add, but replace marked articles of TYPE with ARTICLES.
3983 (let ((info (or info (gnus-get-info group)))
3986 (and (not (setq marked (nthcdr 3 info)))
3988 (setcdr (nthcdr 2 info)
3989 (list (list (cons type (gnus-compress-sequence
3991 (and (not (setq m (assq type (car marked))))
3994 (cons (cons type (gnus-compress-sequence articles t) )
3998 (setcar (nthcdr 3 info)
3999 (gnus-delete-alist type (car marked)))
4000 (setcdr m (gnus-compress-sequence articles t)))
4001 (setcdr m (gnus-compress-sequence
4002 (sort (nconc (gnus-uncompress-range (cdr m))
4003 (copy-sequence articles)) '<) t))))))
4005 (defun gnus-add-mark (group mark article)
4006 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4007 (let ((buffer (gnus-summary-buffer-name group)))
4008 (if (gnus-buffer-live-p buffer)
4010 (set-buffer (get-buffer buffer))
4011 (gnus-summary-add-mark article mark))
4012 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4016 ;;; Group timestamps
4019 (defun gnus-group-set-timestamp ()
4020 "Change the timestamp of the current group to the current time.
4021 This function can be used in hooks like `gnus-select-group-hook'
4022 or `gnus-group-catchup-group-hook'."
4023 (when gnus-newsgroup-name
4024 (let ((time (current-time)))
4025 (setcdr (cdr time) nil)
4026 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4028 (defsubst gnus-group-timestamp (group)
4029 "Return the timestamp for GROUP."
4030 (gnus-group-get-parameter group 'timestamp t))
4032 (defun gnus-group-timestamp-delta (group)
4033 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4034 (let* ((time (or (gnus-group-timestamp group)
4036 (delta (subtract-time (current-time) time)))
4037 (+ (* (nth 0 delta) 65536.0)
4040 (defun gnus-group-timestamp-string (group)
4041 "Return a string of the timestamp for GROUP."
4042 (let ((time (gnus-group-timestamp group)))
4045 (gnus-time-iso8601 time))))
4047 (defun gnus-group-list-cached (level &optional lowest)
4048 "List all groups with cached articles.
4049 If the prefix LEVEL is non-nil, it should be a number that says which
4050 level to cut off listing groups.
4051 If LOWEST, don't list groups with level lower than LOWEST.
4053 This command may read the active file."
4056 (setq level (prefix-numeric-value level)))
4057 (when (or (not level) (>= level gnus-level-zombie))
4059 (funcall gnus-group-prepare-function
4060 (or level gnus-level-subscribed)
4062 (let ((marks (gnus-info-marks info)))
4063 (assq 'cache marks)))
4066 (or (gnus-gethash group
4067 gnus-cache-active-hashtb)
4068 ;; Cache active file might use "."
4071 (mapconcat 'identity
4072 (split-string group ":")
4074 gnus-cache-active-hashtb))))
4075 (goto-char (point-min))
4076 (gnus-group-position-point))
4078 (defun gnus-group-list-dormant (level &optional lowest)
4079 "List all groups with dormant articles.
4080 If the prefix LEVEL is non-nil, it should be a number that says which
4081 level to cut off listing groups.
4082 If LOWEST, don't list groups with level lower than LOWEST.
4084 This command may read the active file."
4087 (setq level (prefix-numeric-value level)))
4088 (when (or (not level) (>= level gnus-level-zombie))
4090 (funcall gnus-group-prepare-function
4091 (or level gnus-level-subscribed)
4093 (let ((marks (gnus-info-marks info)))
4094 (assq 'dormant marks)))
4097 (goto-char (point-min))
4098 (gnus-group-position-point))
4100 (defun gnus-group-listed-groups ()
4101 "Return a list of listed groups."
4103 (goto-char (point-min))
4104 (while (setq point (text-property-not-all (point) (point-max)
4107 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4111 (defun gnus-group-list-plus (&optional args)
4112 "List groups plus the current selection."
4114 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4115 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4117 (push last-command-event unread-command-events)
4118 (if (featurep 'xemacs)
4119 (push (make-event 'key-press '(key ?A)) unread-command-events)
4120 (push ?A unread-command-events))
4121 (let (gnus-pick-mode keys)
4122 (setq keys (if (featurep 'xemacs)
4123 (events-to-keys (read-key-sequence nil))
4124 (read-key-sequence nil)))
4125 (setq func (lookup-key (current-local-map) keys)))
4129 (call-interactively func))))
4131 (defun gnus-group-list-flush (&optional args)
4132 "Flush groups from the current selection."
4134 (let ((gnus-group-list-option 'flush))
4135 (gnus-group-list-plus args)))
4137 (defun gnus-group-list-limit (&optional args)
4138 "List groups limited within the current selection."
4140 (let ((gnus-group-list-option 'limit))
4141 (gnus-group-list-plus args)))
4143 (defun gnus-group-mark-article-read (group article)
4144 "Mark ARTICLE read."
4145 (let ((buffer (gnus-summary-buffer-name group))
4146 (mark gnus-read-mark)
4148 (if (get-buffer buffer)
4149 (with-current-buffer buffer
4150 (setq active gnus-newsgroup-active)
4151 (gnus-activate-group group)
4152 (when gnus-newsgroup-prepared
4153 (when (and gnus-newsgroup-auto-expire
4154 (memq mark gnus-auto-expirable-marks))
4155 (setq mark gnus-expirable-mark))
4156 (setq mark (gnus-request-update-mark
4157 group article mark))
4158 (gnus-mark-article-as-read article mark)
4159 (setq gnus-newsgroup-active (gnus-active group))
4161 (setq n (1+ (cdr active)))
4162 (while (<= n (cdr gnus-newsgroup-active))
4163 (unless (eq n article)
4164 (push n gnus-newsgroup-unselected))
4166 (setq gnus-newsgroup-unselected
4167 (nreverse gnus-newsgroup-unselected)))))
4168 (gnus-activate-group group)
4169 (gnus-group-make-articles-read group
4171 (when (gnus-group-auto-expirable-p group)
4172 (gnus-add-marked-articles
4173 group 'expire (list article))))))
4175 (provide 'gnus-group)
4177 ;;; gnus-group.el ends here