1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %U Number of unseen articles (integer)
160 %t Estimated total number of articles (integer)
161 %y Number of unread, unticked articles (integer)
162 %G Group name (string)
163 %g Qualified group name (string)
164 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
165 %C Group comment (string)
166 %D Group description (string)
167 %s Select method (string)
168 %o Moderated group (char, \"m\")
169 %p Process mark (char)
170 %B Whether a summary buffer for the group is open (char, \"*\")
171 %O Moderated group (string, \"(m)\" or \"\")
172 %P Topic indentation (string)
173 %m Whether there is new(ish) mail in the group (char, \"%\")
174 %l Whether there are GroupLens predictions for this group (string)
175 %n Select from where (string)
176 %z A string that look like `<%s:%n>' if a foreign select method is used
177 %d The date the group was last entered.
178 %E Icon as defined by `gnus-group-icon-list'.
179 %u User defined specifier. The next character in the format string should
180 be a letter. Gnus will call the function gnus-user-format-function-X,
181 where X is the letter following %u. The function will be passed a
182 single dummy parameter as argument.. The function should return a
183 string, which will be inserted into the buffer just like information
184 from any other group specifier.
186 Note that this format specification is not always respected. For
187 reasons of efficiency, when listing killed groups, this specification
188 is ignored altogether. If the spec is changed considerably, your
189 output may end up looking strange when listing both alive and killed
192 If you use %o or %O, reading the active file will be slower and quite
193 a bit of extra memory will be used. %D will also worsen performance.
194 Also note that if you change the format specification to include any
195 of these specs, you must probably re-start Gnus to see them go into
198 General format specifiers can also be used.
199 See Info node `(gnus)Formatting Variables'."
200 :link '(custom-manual "(gnus)Formatting Variables")
201 :group 'gnus-group-visual
204 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
205 "*The format specification for the group mode line.
206 It works along the same lines as a normal formatting string,
207 with some simple extensions:
209 %S The native news server.
210 %M The native select method.
211 %: \":\" if %S isn't \"\"."
212 :group 'gnus-group-visual
215 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
216 (when (featurep 'xemacs)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
218 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
220 (defcustom gnus-group-menu-hook nil
221 "Hook run after the creation of the group mode menu."
222 :group 'gnus-group-various
225 (defcustom gnus-group-catchup-group-hook nil
226 "Hook run when catching up a group from the group buffer."
227 :group 'gnus-group-various
228 :link '(custom-manual "(gnus)Group Data")
231 (defcustom gnus-group-update-group-hook nil
232 "Hook called when updating group lines."
233 :group 'gnus-group-visual
236 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
237 "*A function that is called to generate the group buffer.
238 The function is called with three arguments: The first is a number;
239 all group with a level less or equal to that number should be listed,
240 if the second is non-nil, empty groups should also be displayed. If
241 the third is non-nil, it is a number. No groups with a level lower
242 than this number should be displayed.
244 The only current function implemented is `gnus-group-prepare-flat'."
245 :group 'gnus-group-listing
248 (defcustom gnus-group-prepare-hook nil
249 "Hook called after the group buffer has been generated.
250 If you want to modify the group buffer, you can use this hook."
251 :group 'gnus-group-listing
254 (defcustom gnus-suspend-gnus-hook nil
255 "Hook called when suspending (not exiting) Gnus."
259 (defcustom gnus-exit-gnus-hook nil
260 "Hook called when exiting Gnus."
264 (defcustom gnus-after-exiting-gnus-hook nil
265 "Hook called after exiting Gnus."
269 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
270 "Hook called when a group line is changed.
271 The hook will not be called if `gnus-visual' is nil.
273 The default function `gnus-group-highlight-line' will
274 highlight the line according to the `gnus-group-highlight'
276 :group 'gnus-group-visual
279 (defcustom gnus-useful-groups
280 '(("(ding) mailing list mirrored at sunsite.auc.dk"
282 (nntp "sunsite.auc.dk"
283 (nntp-address "sunsite.auc.dk")))
286 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
290 (nndoc-article-type mbox)
291 (eval `(nndoc-address
292 ,(let ((file (nnheader-find-etc-directory
295 (error "Couldn't find doc group"))
297 "*Alist of useful group-server pairs."
298 :group 'gnus-group-listing
299 :type '(repeat (list (string :tag "Description")
301 (sexp :tag "Method"))))
303 (defcustom gnus-group-highlight
305 ((and mailp (= unread 0) (eq level 1)) .
306 gnus-group-mail-1-empty-face)
307 ((and mailp (eq level 1)) .
308 gnus-group-mail-1-face)
309 ((and mailp (= unread 0) (eq level 2)) .
310 gnus-group-mail-2-empty-face)
311 ((and mailp (eq level 2)) .
312 gnus-group-mail-2-face)
313 ((and mailp (= unread 0) (eq level 3)) .
314 gnus-group-mail-3-empty-face)
315 ((and mailp (eq level 3)) .
316 gnus-group-mail-3-face)
317 ((and mailp (= unread 0)) .
318 gnus-group-mail-low-empty-face)
320 gnus-group-mail-low-face)
322 ((and (= unread 0) (eq level 1)) .
323 gnus-group-news-1-empty-face)
324 ((and (eq level 1)) .
325 gnus-group-news-1-face)
326 ((and (= unread 0) (eq level 2)) .
327 gnus-group-news-2-empty-face)
328 ((and (eq level 2)) .
329 gnus-group-news-2-face)
330 ((and (= unread 0) (eq level 3)) .
331 gnus-group-news-3-empty-face)
332 ((and (eq level 3)) .
333 gnus-group-news-3-face)
334 ((and (= unread 0) (eq level 4)) .
335 gnus-group-news-4-empty-face)
336 ((and (eq level 4)) .
337 gnus-group-news-4-face)
338 ((and (= unread 0) (eq level 5)) .
339 gnus-group-news-5-empty-face)
340 ((and (eq level 5)) .
341 gnus-group-news-5-face)
342 ((and (= unread 0) (eq level 6)) .
343 gnus-group-news-6-empty-face)
344 ((and (eq level 6)) .
345 gnus-group-news-6-face)
346 ((and (= unread 0)) .
347 gnus-group-news-low-empty-face)
349 gnus-group-news-low-face))
350 "*Controls the highlighting of group buffer lines.
352 Below is a list of `Form'/`Face' pairs. When deciding how a a
353 particular group line should be displayed, each form is
354 evaluated. The content of the face field after the first true form is
355 used. You can change how those group lines are displayed by
356 editing the face field.
358 It is also possible to change and add form fields, but currently that
359 requires an understanding of Lisp expressions. Hopefully this will
360 change in a future release. For now, you can use the following
361 variables in the Lisp expression:
363 group: The name of the group.
364 unread: The number of unread articles in the group.
365 method: The select method used.
366 mailp: Whether it's a mail group or not.
367 level: The level of the group.
368 score: The score of the group.
369 ticked: The number of ticked articles."
370 :group 'gnus-group-visual
371 :type '(repeat (cons (sexp :tag "Form") face)))
373 (defcustom gnus-new-mail-mark ?%
374 "Mark used for groups with new mail."
375 :group 'gnus-group-visual
378 (defgroup gnus-group-icons nil
379 "Add Icons to your group buffer. "
380 :group 'gnus-group-visual)
382 (defcustom gnus-group-icon-list
384 "*Controls the insertion of icons into group buffer lines.
386 Below is a list of `Form'/`File' pairs. When deciding how a
387 particular group line should be displayed, each form is evaluated.
388 The icon from the file field after the first true form is used. You
389 can change how those group lines are displayed by editing the file
390 field. The File will either be found in the
391 `gnus-group-glyph-directory' or by designating absolute path to the
394 It is also possible to change and add form fields, but currently that
395 requires an understanding of Lisp expressions. Hopefully this will
396 change in a future release. For now, you can use the following
397 variables in the Lisp expression:
399 group: The name of the group.
400 unread: The number of unread articles in the group.
401 method: The select method used.
402 mailp: Whether it's a mail group or not.
403 newsp: Whether it's a news group or not
404 level: The level of the group.
405 score: The score of the group.
406 ticked: The number of ticked articles."
407 :group 'gnus-group-icons
408 :type '(repeat (cons (sexp :tag "Form") file)))
410 (defcustom gnus-group-name-charset-method-alist nil
411 "Alist of method and the charset for group names.
414 (((nntp \"news.com.cn\") . cn-gb-2312))"
417 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
419 (defcustom gnus-group-name-charset-group-alist
420 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
421 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
424 "Alist of group regexp and the charset for group names.
427 ((\"\\.com\\.cn:\" . cn-gb-2312))"
429 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
431 (defcustom gnus-group-jump-to-group-prompt nil
432 "Default prompt for `gnus-group-jump-to-group'.
433 If non-nil, the value should be a string, e.g. \"nnml:\",
434 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
435 in the minibuffer prompt."
436 :group 'gnus-group-various
437 :type '(choice (string :tag "Prompt string")
438 (const :tag "Empty" nil)))
440 (defvar gnus-group-listing-limit 1000
441 "*A limit of the number of groups when listing.
442 If the number of groups is larger than the limit, list them in a
445 ;;; Internal variables
447 (defvar gnus-group-is-exiting-p nil)
448 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
449 "Function for sorting the group buffer.")
451 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
452 "Function for sorting the selected groups in the group buffer.")
454 (defvar gnus-group-indentation-function nil)
455 (defvar gnus-goto-missing-group-function nil)
456 (defvar gnus-group-update-group-function nil)
457 (defvar gnus-group-goto-next-group-function nil
458 "Function to override finding the next group after listing groups.")
460 (defvar gnus-group-edit-buffer nil)
462 (defvar gnus-group-line-format-alist
463 `((?M gnus-tmp-marked-mark ?c)
464 (?S gnus-tmp-subscribed ?c)
465 (?L gnus-tmp-level ?d)
466 (?N (cond ((eq number t) "*" )
470 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
471 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
473 (?R gnus-tmp-number-of-read ?s)
474 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?s)
475 (?t gnus-tmp-number-total ?d)
476 (?y gnus-tmp-number-of-unread ?s)
477 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
478 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
479 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
480 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
481 (?g gnus-tmp-group ?s)
482 (?G gnus-tmp-qualified-group ?s)
483 (?c (gnus-short-group-name gnus-tmp-group) ?s)
484 (?C gnus-tmp-comment ?s)
485 (?D gnus-tmp-newsgroup-description ?s)
486 (?o gnus-tmp-moderated ?c)
487 (?O gnus-tmp-moderated-string ?s)
488 (?p gnus-tmp-process-marked ?c)
489 (?s gnus-tmp-news-server ?s)
490 (?n gnus-tmp-news-method ?s)
491 (?P gnus-group-indentation ?s)
492 (?E gnus-tmp-group-icon ?s)
493 (?B gnus-tmp-summary-live ?c)
494 (?l gnus-tmp-grouplens ?s)
495 (?z gnus-tmp-news-method-string ?s)
496 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
497 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
498 (?u gnus-tmp-user-defined ?s)))
500 (defvar gnus-group-mode-line-format-alist
501 `((?S gnus-tmp-news-server ?s)
502 (?M gnus-tmp-news-method ?s)
503 (?u gnus-tmp-user-defined ?s)
504 (?: gnus-tmp-colon ?s)))
506 (defvar gnus-topic-topology nil
507 "The complete topic hierarchy.")
509 (defvar gnus-topic-alist nil
510 "The complete topic-group alist.")
512 (defvar gnus-group-marked nil)
514 (defvar gnus-group-list-mode nil)
517 (defvar gnus-group-icon-cache nil)
519 (defvar gnus-group-listed-groups nil)
520 (defvar gnus-group-list-option nil)
526 (put 'gnus-group-mode 'mode-class 'special)
529 (gnus-define-keys gnus-group-mode-map
530 " " gnus-group-read-group
531 "=" gnus-group-select-group
532 "\r" gnus-group-select-group
533 "\M-\r" gnus-group-quick-select-group
534 "\M- " gnus-group-visible-select-group
535 [(meta control return)] gnus-group-select-group-ephemerally
536 "j" gnus-group-jump-to-group
537 "n" gnus-group-next-unread-group
538 "p" gnus-group-prev-unread-group
539 "\177" gnus-group-prev-unread-group
540 [delete] gnus-group-prev-unread-group
541 [backspace] gnus-group-prev-unread-group
542 "N" gnus-group-next-group
543 "P" gnus-group-prev-group
544 "\M-n" gnus-group-next-unread-group-same-level
545 "\M-p" gnus-group-prev-unread-group-same-level
546 "," gnus-group-best-unread-group
547 "." gnus-group-first-unread-group
548 "u" gnus-group-unsubscribe-current-group
549 "U" gnus-group-unsubscribe-group
550 "c" gnus-group-catchup-current
551 "C" gnus-group-catchup-current-all
552 "\M-c" gnus-group-clear-data
553 "l" gnus-group-list-groups
554 "L" gnus-group-list-all-groups
557 "g" gnus-group-get-new-news
558 "\M-g" gnus-group-get-new-news-this-group
559 "R" gnus-group-restart
560 "r" gnus-group-read-init-file
561 "B" gnus-group-browse-foreign-server
562 "b" gnus-group-check-bogus-groups
563 "F" gnus-group-find-new-groups
564 "\C-c\C-d" gnus-group-describe-group
565 "\M-d" gnus-group-describe-all-groups
566 "\C-c\C-a" gnus-group-apropos
567 "\C-c\M-\C-a" gnus-group-description-apropos
568 "a" gnus-group-post-news
569 "\ek" gnus-group-edit-local-kill
570 "\eK" gnus-group-edit-global-kill
571 "\C-k" gnus-group-kill-group
572 "\C-y" gnus-group-yank-group
573 "\C-w" gnus-group-kill-region
574 "\C-x\C-t" gnus-group-transpose-groups
575 "\C-c\C-l" gnus-group-list-killed
576 "\C-c\C-x" gnus-group-expire-articles
577 "\C-c\M-\C-x" gnus-group-expire-all-groups
579 "s" gnus-group-save-newsrc
580 "z" gnus-group-suspend
583 "?" gnus-group-describe-briefly
584 "\C-c\C-i" gnus-info-find-node
585 "\M-e" gnus-group-edit-group-method
586 "^" gnus-group-enter-server-mode
587 gnus-mouse-2 gnus-mouse-pick-group
588 "<" beginning-of-buffer
591 "\C-c\C-s" gnus-group-sort-groups
593 "\C-c\M-g" gnus-activate-all-groups
594 "\M-&" gnus-group-universal-argument
595 "#" gnus-group-mark-group
596 "\M-#" gnus-group-unmark-group)
598 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
599 "m" gnus-group-mark-group
600 "u" gnus-group-unmark-group
601 "w" gnus-group-mark-region
602 "b" gnus-group-mark-buffer
603 "r" gnus-group-mark-regexp
604 "U" gnus-group-unmark-all-groups)
606 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
607 "u" gnus-sieve-update
608 "g" gnus-sieve-generate)
610 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
611 "d" gnus-group-make-directory-group
612 "h" gnus-group-make-help-group
613 "u" gnus-group-make-useful-group
614 "a" gnus-group-make-archive-group
615 "k" gnus-group-make-kiboze-group
616 "l" gnus-group-nnimap-edit-acl
617 "m" gnus-group-make-group
618 "E" gnus-group-edit-group
619 "e" gnus-group-edit-group-method
620 "p" gnus-group-edit-group-parameters
621 "v" gnus-group-add-to-virtual
622 "V" gnus-group-make-empty-virtual
623 "D" gnus-group-enter-directory
624 "f" gnus-group-make-doc-group
625 "w" gnus-group-make-web-group
626 "r" gnus-group-rename-group
627 "c" gnus-group-customize
628 "x" gnus-group-nnimap-expunge
629 "\177" gnus-group-delete-group
630 [delete] gnus-group-delete-group)
632 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
633 "b" gnus-group-brew-soup
634 "w" gnus-soup-save-areas
635 "s" gnus-soup-send-replies
636 "p" gnus-soup-pack-packet
637 "r" nnsoup-pack-replies)
639 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
640 "s" gnus-group-sort-groups
641 "a" gnus-group-sort-groups-by-alphabet
642 "u" gnus-group-sort-groups-by-unread
643 "l" gnus-group-sort-groups-by-level
644 "v" gnus-group-sort-groups-by-score
645 "r" gnus-group-sort-groups-by-rank
646 "m" gnus-group-sort-groups-by-method
647 "n" gnus-group-sort-groups-by-real-name)
649 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
650 "s" gnus-group-sort-selected-groups
651 "a" gnus-group-sort-selected-groups-by-alphabet
652 "u" gnus-group-sort-selected-groups-by-unread
653 "l" gnus-group-sort-selected-groups-by-level
654 "v" gnus-group-sort-selected-groups-by-score
655 "r" gnus-group-sort-selected-groups-by-rank
656 "m" gnus-group-sort-selected-groups-by-method
657 "n" gnus-group-sort-selected-groups-by-real-name)
659 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
660 "k" gnus-group-list-killed
661 "z" gnus-group-list-zombies
662 "s" gnus-group-list-groups
663 "u" gnus-group-list-all-groups
664 "A" gnus-group-list-active
665 "a" gnus-group-apropos
666 "d" gnus-group-description-apropos
667 "m" gnus-group-list-matching
668 "M" gnus-group-list-all-matching
669 "l" gnus-group-list-level
670 "c" gnus-group-list-cached
671 "?" gnus-group-list-dormant)
673 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
674 "k" gnus-group-list-limit
675 "z" gnus-group-list-limit
676 "s" gnus-group-list-limit
677 "u" gnus-group-list-limit
678 "A" gnus-group-list-limit
679 "m" gnus-group-list-limit
680 "M" gnus-group-list-limit
681 "l" gnus-group-list-limit
682 "c" gnus-group-list-limit
683 "?" gnus-group-list-limit)
685 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
686 "k" gnus-group-list-flush
687 "z" gnus-group-list-flush
688 "s" gnus-group-list-flush
689 "u" gnus-group-list-flush
690 "A" gnus-group-list-flush
691 "m" gnus-group-list-flush
692 "M" gnus-group-list-flush
693 "l" gnus-group-list-flush
694 "c" gnus-group-list-flush
695 "?" gnus-group-list-flush)
697 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
698 "k" gnus-group-list-plus
699 "z" gnus-group-list-plus
700 "s" gnus-group-list-plus
701 "u" gnus-group-list-plus
702 "A" gnus-group-list-plus
703 "m" gnus-group-list-plus
704 "M" gnus-group-list-plus
705 "l" gnus-group-list-plus
706 "c" gnus-group-list-plus
707 "?" gnus-group-list-plus)
709 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
710 "f" gnus-score-flush-cache)
712 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
713 "c" gnus-group-fetch-charter
714 "C" gnus-group-fetch-control
715 "d" gnus-group-describe-group
716 "f" gnus-group-fetch-faq
719 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
720 "l" gnus-group-set-current-level
721 "t" gnus-group-unsubscribe-current-group
722 "s" gnus-group-unsubscribe-group
723 "k" gnus-group-kill-group
724 "y" gnus-group-yank-group
725 "w" gnus-group-kill-region
726 "\C-k" gnus-group-kill-level
727 "z" gnus-group-kill-all-zombies))
729 (defun gnus-group-make-menu-bar ()
730 (gnus-turn-off-edit-menu 'group)
731 (unless (boundp 'gnus-group-reading-menu)
734 gnus-group-reading-menu gnus-group-mode-map ""
736 ["Read" gnus-group-read-group (gnus-group-group-name)]
737 ["Select" gnus-group-select-group (gnus-group-group-name)]
738 ["See old articles" (gnus-group-select-group 'all)
739 :keys "C-u SPC" :active (gnus-group-group-name)]
740 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
741 ,@(if (featurep 'xemacs) nil
742 '(:help "Mark unread articles in the current group as read"))]
743 ["Catch up all articles" gnus-group-catchup-current-all
744 (gnus-group-group-name)]
745 ["Check for new articles" gnus-group-get-new-news-this-group
746 :active (gnus-group-group-name)
747 ,@(if (featurep 'xemacs) nil
748 '(:help "Check for new messages in current group"))]
749 ["Toggle subscription" gnus-group-unsubscribe-current-group
750 (gnus-group-group-name)]
751 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
752 ,@(if (featurep 'xemacs) nil
753 '(:help "Kill (remove) current group"))]
754 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
755 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
756 ,@(if (featurep 'xemacs) nil
757 '(:help "Display description of the current group"))]
758 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
759 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
760 ,@(if (featurep 'xemacs) nil
761 '(:help "Display the charter of the current group"))]
762 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
763 ,@(if (featurep 'xemacs) nil
764 '(:help "Display the archived control message for the current group"))]
765 ;; Actually one should check, if any of the marked groups gives t for
766 ;; (gnus-check-backend-function 'request-expire-articles ...)
767 ["Expire articles" gnus-group-expire-articles
768 (or (and (gnus-group-group-name)
769 (gnus-check-backend-function
770 'request-expire-articles
771 (gnus-group-group-name))) gnus-group-marked)]
772 ["Set group level..." gnus-group-set-current-level
773 (gnus-group-group-name)]
774 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
775 ["Customize" gnus-group-customize (gnus-group-group-name)]
777 ["Parameters" gnus-group-edit-group-parameters
778 (gnus-group-group-name)]
779 ["Select method" gnus-group-edit-group-method
780 (gnus-group-group-name)]
781 ["Info" gnus-group-edit-group (gnus-group-group-name)]
782 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
783 ["Global kill file" gnus-group-edit-global-kill t])))
786 gnus-group-group-menu gnus-group-mode-map ""
789 ["List unread subscribed groups" gnus-group-list-groups t]
790 ["List (un)subscribed groups" gnus-group-list-all-groups t]
791 ["List killed groups" gnus-group-list-killed gnus-killed-list]
792 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
793 ["List level..." gnus-group-list-level t]
794 ["Describe all groups" gnus-group-describe-all-groups t]
795 ["Group apropos..." gnus-group-apropos t]
796 ["Group and description apropos..." gnus-group-description-apropos t]
797 ["List groups matching..." gnus-group-list-matching t]
798 ["List all groups matching..." gnus-group-list-all-matching t]
799 ["List active file" gnus-group-list-active t]
800 ["List groups with cached" gnus-group-list-cached t]
801 ["List groups with dormant" gnus-group-list-dormant t])
803 ["Default sort" gnus-group-sort-groups t]
804 ["Sort by method" gnus-group-sort-groups-by-method t]
805 ["Sort by rank" gnus-group-sort-groups-by-rank t]
806 ["Sort by score" gnus-group-sort-groups-by-score t]
807 ["Sort by level" gnus-group-sort-groups-by-level t]
808 ["Sort by unread" gnus-group-sort-groups-by-unread t]
809 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
810 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
811 ("Sort process/prefixed"
812 ["Default sort" gnus-group-sort-selected-groups
813 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
814 ["Sort by method" gnus-group-sort-selected-groups-by-method
815 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
816 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
817 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
818 ["Sort by score" gnus-group-sort-selected-groups-by-score
819 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
820 ["Sort by level" gnus-group-sort-selected-groups-by-level
821 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
822 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
823 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
824 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
825 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
826 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
827 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
829 ["Mark group" gnus-group-mark-group
830 (and (gnus-group-group-name)
831 (not (memq (gnus-group-group-name) gnus-group-marked)))]
832 ["Unmark group" gnus-group-unmark-group
833 (and (gnus-group-group-name)
834 (memq (gnus-group-group-name) gnus-group-marked))]
835 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
836 ["Mark regexp..." gnus-group-mark-regexp t]
837 ["Mark region" gnus-group-mark-region t]
838 ["Mark buffer" gnus-group-mark-buffer t]
839 ["Execute command" gnus-group-universal-argument
840 (or gnus-group-marked (gnus-group-group-name))])
842 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
843 ["Kill all newsgroups in region" gnus-group-kill-region t]
844 ["Kill all zombie groups" gnus-group-kill-all-zombies
846 ["Kill all groups on level..." gnus-group-kill-level t])
848 ["Make a foreign group..." gnus-group-make-group t]
849 ["Add a directory group..." gnus-group-make-directory-group t]
850 ["Add the help group" gnus-group-make-help-group t]
851 ["Add the archive group" gnus-group-make-archive-group t]
852 ["Make a doc group..." gnus-group-make-doc-group t]
853 ["Make a web group..." gnus-group-make-web-group t]
854 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
855 ["Make a virtual group..." gnus-group-make-empty-virtual t]
856 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
857 ["Rename group..." gnus-group-rename-group
858 (gnus-check-backend-function
859 'request-rename-group (gnus-group-group-name))]
860 ["Delete group" gnus-group-delete-group
861 (gnus-check-backend-function
862 'request-delete-group (gnus-group-group-name))])
864 ["Next" gnus-group-next-group t]
865 ["Previous" gnus-group-prev-group t]
866 ["Next unread" gnus-group-next-unread-group t]
867 ["Previous unread" gnus-group-prev-unread-group t]
868 ["Next unread same level" gnus-group-next-unread-group-same-level t]
869 ["Previous unread same level"
870 gnus-group-prev-unread-group-same-level t]
871 ["Jump to group..." gnus-group-jump-to-group t]
872 ["First unread group" gnus-group-first-unread-group t]
873 ["Best unread group" gnus-group-best-unread-group t])
875 ["Generate" gnus-sieve-generate t]
876 ["Generate and update" gnus-sieve-update t])
877 ["Delete bogus groups" gnus-group-check-bogus-groups t]
878 ["Find new newsgroups" gnus-group-find-new-groups t]
879 ["Transpose" gnus-group-transpose-groups
880 (gnus-group-group-name)]
881 ["Read a directory as a group..." gnus-group-enter-directory t]))
884 gnus-group-misc-menu gnus-group-mode-map ""
887 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
888 ["Send replies" gnus-soup-send-replies
889 (fboundp 'gnus-soup-pack-packet)]
890 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
891 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
892 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
893 ["Send a mail" gnus-group-mail t]
894 ["Send a message (mail or news)" gnus-group-post-news t]
895 ["Create a local message" gnus-group-news t]
896 ["Check for new news" gnus-group-get-new-news
897 ,@(if (featurep 'xemacs) '(t)
898 '(:help "Get newly arrived articles"))
900 ["Send queued messages" gnus-delay-send-queue
901 ,@(if (featurep 'xemacs) '(t)
902 '(:help "Send all messages that are scheduled to be sent now"))
904 ["Activate all groups" gnus-activate-all-groups t]
905 ["Restart Gnus" gnus-group-restart t]
906 ["Read init file" gnus-group-read-init-file t]
907 ["Browse foreign server..." gnus-group-browse-foreign-server t]
908 ["Enter server buffer" gnus-group-enter-server-mode t]
909 ["Expire all expirable articles" gnus-group-expire-all-groups t]
910 ["Generate any kiboze groups" nnkiboze-generate-groups t]
911 ["Gnus version" gnus-version t]
912 ["Save .newsrc files" gnus-group-save-newsrc t]
913 ["Suspend Gnus" gnus-group-suspend t]
914 ["Clear dribble buffer" gnus-group-clear-dribble t]
915 ["Read manual" gnus-info-find-node t]
916 ["Flush score cache" gnus-score-flush-cache t]
917 ["Toggle topics" gnus-topic-mode t]
918 ["Send a bug report" gnus-bug t]
919 ["Exit from Gnus" gnus-group-exit
920 ,@(if (featurep 'xemacs) '(t)
921 '(:help "Quit reading news"))]
922 ["Exit without saving" gnus-group-quit t]))
924 (gnus-run-hooks 'gnus-group-menu-hook)))
926 (defvar gnus-group-toolbar-map nil)
928 ;; Emacs 21 tool bar. Should be no-op otherwise.
929 (defun gnus-group-make-tool-bar ()
931 (condition-case nil (require 'tool-bar) (error nil))
932 (fboundp 'tool-bar-add-item-from-menu)
933 (default-value 'tool-bar-mode)
934 (not gnus-group-toolbar-map))
935 (setq gnus-group-toolbar-map
936 (let ((tool-bar-map (make-sparse-keymap))
937 (load-path (mm-image-load-path)))
938 (tool-bar-add-item-from-menu
939 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
940 (tool-bar-add-item-from-menu
941 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
942 (tool-bar-add-item-from-menu
943 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
944 (tool-bar-add-item-from-menu
945 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
946 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
947 :help "Subscribe to the current group")
948 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
950 :help "Unsubscribe from the current group")
951 (tool-bar-add-item-from-menu
952 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
954 (if gnus-group-toolbar-map
955 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
957 (defun gnus-group-mode ()
958 "Major mode for reading news.
960 All normal editing commands are switched off.
961 \\<gnus-group-mode-map>
962 The group buffer lists (some of) the groups available. For instance,
963 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
964 lists all zombie groups.
966 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
967 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
969 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
971 The following commands are available:
973 \\{gnus-group-mode-map}"
975 (kill-all-local-variables)
976 (when (gnus-visual-p 'group-menu 'menu)
977 (gnus-group-make-menu-bar)
978 (gnus-group-make-tool-bar))
979 (gnus-simplify-mode-line)
980 (setq major-mode 'gnus-group-mode)
981 (setq mode-name "Group")
982 (gnus-group-set-mode-line)
983 (setq mode-line-process nil)
984 (use-local-map gnus-group-mode-map)
985 (buffer-disable-undo)
986 (setq truncate-lines t)
987 (setq buffer-read-only t)
988 (gnus-set-default-directory)
989 (gnus-update-format-specifications nil 'group 'group-mode)
990 (gnus-update-group-mark-positions)
995 (gnus-run-hooks 'gnus-group-mode-hook))
997 (defun gnus-update-group-mark-positions ()
999 (let ((gnus-process-mark ?\200)
1000 (gnus-group-update-hook nil)
1001 (gnus-group-marked '("dummy.group"))
1002 (gnus-active-hashtb (make-vector 10 0))
1004 (gnus-set-active "dummy.group" '(0 . 0))
1005 (gnus-set-work-buffer)
1006 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1007 (goto-char (point-min))
1008 (setq gnus-group-mark-positions
1009 (list (cons 'process (and (search-forward "\200" nil t)
1010 (- (point) 2))))))))
1012 (defun gnus-mouse-pick-group (e)
1013 "Enter the group under the mouse pointer."
1016 (gnus-group-read-group nil))
1018 ;; Look at LEVEL and find out what the level is really supposed to be.
1019 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1020 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1021 (defun gnus-group-default-level (&optional level number-or-nil)
1023 (gnus-group-use-permanent-levels
1024 (or (setq gnus-group-use-permanent-levels
1025 (or level (if (numberp gnus-group-use-permanent-levels)
1026 gnus-group-use-permanent-levels
1027 (or gnus-group-default-list-level
1028 gnus-level-subscribed))))
1029 gnus-group-default-list-level gnus-level-subscribed))
1033 (or level gnus-group-default-list-level gnus-level-subscribed))))
1035 (defun gnus-group-setup-buffer ()
1036 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1037 (unless (eq major-mode 'gnus-group-mode)
1040 (gnus-carpal-setup-buffer 'group))))
1042 (defun gnus-group-name-charset (method group)
1044 (setq method (gnus-find-method-for-group group)))
1045 (let ((item (assoc method gnus-group-name-charset-method-alist))
1046 (alist gnus-group-name-charset-group-alist)
1050 (while (setq item (pop alist))
1051 (if (string-match (car item) group)
1053 result (cdr item))))
1056 (defun gnus-group-name-decode (string charset)
1057 (if (and string charset (featurep 'mule))
1058 (mm-decode-coding-string string charset)
1061 (defun gnus-group-decoded-name (string)
1062 (let ((charset (gnus-group-name-charset nil string)))
1063 (gnus-group-name-decode string charset)))
1065 (defun gnus-group-list-groups (&optional level unread lowest)
1066 "List newsgroups with level LEVEL or lower that have unread articles.
1067 Default is all subscribed groups.
1068 If argument UNREAD is non-nil, groups with no unread articles are also
1071 Also see the `gnus-group-use-permanent-levels' variable."
1073 (list (if current-prefix-arg
1074 (prefix-numeric-value current-prefix-arg)
1076 (gnus-group-default-level nil t)
1077 gnus-group-default-list-level
1078 gnus-level-subscribed))))
1080 (setq level (car gnus-group-list-mode)
1081 unread (cdr gnus-group-list-mode)))
1082 (setq level (gnus-group-default-level level))
1083 (gnus-group-setup-buffer)
1084 (gnus-update-format-specifications nil 'group 'group-mode)
1085 (let ((case-fold-search nil)
1086 (props (text-properties-at (gnus-point-at-bol)))
1087 (empty (= (point-min) (point-max)))
1088 (group (gnus-group-group-name))
1090 (set-buffer gnus-group-buffer)
1091 (setq number (funcall gnus-group-prepare-function level unread lowest))
1092 (when (or (and (numberp number)
1094 (zerop (buffer-size)))
1095 ;; No groups in the buffer.
1096 (gnus-message 5 gnus-no-groups-message))
1097 ;; We have some groups displayed.
1098 (goto-char (point-max))
1099 (when (or (not gnus-group-goto-next-group-function)
1100 (not (funcall gnus-group-goto-next-group-function
1104 (goto-char (point-min)))
1106 ;; Go to the first group with unread articles.
1107 (gnus-group-search-forward t))
1109 ;; Find the right group to put point on. If the current group
1110 ;; has disappeared in the new listing, try to find the next
1111 ;; one. If no next one can be found, just leave point at the
1112 ;; first newsgroup in the buffer.
1113 (when (not (gnus-goto-char
1115 (point-min) (point-max)
1116 'gnus-group (gnus-intern-safe
1117 group gnus-active-hashtb))))
1118 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1120 (not (gnus-goto-char
1122 (point-min) (point-max) 'gnus-group
1124 (caar newsrc) gnus-active-hashtb)))))
1125 (setq newsrc (cdr newsrc)))
1127 (goto-char (point-max))
1128 (forward-line -1)))))))
1129 ;; Adjust cursor point.
1130 (gnus-group-position-point)))
1132 (defun gnus-group-list-level (level &optional all)
1133 "List groups on LEVEL.
1134 If ALL (the prefix), also list groups that have no unread articles."
1135 (interactive "nList groups on level: \nP")
1136 (gnus-group-list-groups level all level))
1138 (defun gnus-group-prepare-logic (group test)
1139 (or (and gnus-group-listed-groups
1140 (null gnus-group-list-option)
1141 (member group gnus-group-listed-groups))
1143 ((null gnus-group-listed-groups) test)
1144 ((null gnus-group-list-option) test)
1145 (t (and (member group gnus-group-listed-groups)
1146 (if (eq gnus-group-list-option 'flush)
1150 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1151 "List all newsgroups with unread articles of level LEVEL or lower.
1152 If PREDICATE is a function, list groups that the function returns non-nil;
1153 if it is t, list groups that have no unread articles.
1154 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1155 If REGEXP is a function, list dead groups that the function returns non-nil;
1156 if it is a string, only list groups matching REGEXP."
1157 (set-buffer gnus-group-buffer)
1158 (let ((buffer-read-only nil)
1159 (newsrc (cdr gnus-newsrc-alist))
1160 (lowest (or lowest 1))
1161 (not-in-list (and gnus-group-listed-groups
1162 (copy-sequence gnus-group-listed-groups)))
1163 info clevel unread group params)
1165 (when (or (< lowest gnus-level-zombie)
1166 gnus-group-listed-groups)
1167 ;; List living groups.
1169 (setq info (car newsrc)
1170 group (gnus-info-group info)
1171 params (gnus-info-params info)
1173 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1175 (setq not-in-list (delete group not-in-list)))
1176 (when (gnus-group-prepare-logic
1178 (and unread ; This group might be unchecked
1179 (or (not (stringp regexp))
1180 (string-match regexp group))
1181 (<= (setq clevel (gnus-info-level info)) level)
1184 ((functionp predicate)
1185 (funcall predicate info))
1186 (predicate t) ; We list all groups?
1189 (if (eq unread t) ; Unactivated?
1190 gnus-group-list-inactive-groups
1191 ; We list unactivated
1193 ; We list groups with unread articles
1194 (and gnus-list-groups-with-ticked-articles
1195 (cdr (assq 'tick (gnus-info-marks info))))
1196 ; And groups with tickeds
1197 ;; Check for permanent visibility.
1198 (and gnus-permanently-visible-groups
1199 (string-match gnus-permanently-visible-groups
1201 (memq 'visible params)
1202 (cdr (assq 'visible params)))))))
1203 (gnus-group-insert-group-line
1204 group (gnus-info-level info)
1205 (gnus-info-marks info) unread (gnus-info-method info)))))
1207 ;; List dead groups.
1208 (when (or gnus-group-listed-groups
1209 (and (>= level gnus-level-zombie)
1210 (<= lowest gnus-level-zombie)))
1211 (gnus-group-prepare-flat-list-dead
1212 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1213 gnus-level-zombie ?Z
1216 (dolist (group gnus-zombie-list)
1217 (setq not-in-list (delete group not-in-list))))
1218 (when (or gnus-group-listed-groups
1219 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1220 (gnus-group-prepare-flat-list-dead
1223 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1224 gnus-level-killed ?K regexp))
1226 (gnus-group-set-mode-line)
1227 (setq gnus-group-list-mode (cons level predicate))
1228 (gnus-run-hooks 'gnus-group-prepare-hook)
1231 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1232 ;; List zombies and killed lists somewhat faster, which was
1233 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1234 ;; this by ignoring the group format specification altogether.
1236 (if (> (length groups) gnus-group-listing-limit)
1238 (setq group (pop groups))
1239 (when (gnus-group-prepare-logic
1242 (and (stringp regexp) (string-match regexp group))
1243 (and (functionp regexp) (funcall regexp group))))
1244 (gnus-add-text-properties
1245 (point) (prog1 (1+ (point))
1246 (insert " " mark " *: "
1247 (gnus-group-decoded-name group)
1249 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1251 'gnus-level level))))
1253 (setq group (pop groups))
1254 (when (gnus-group-prepare-logic
1257 (and (stringp regexp) (string-match regexp group))
1258 (and (functionp regexp) (funcall regexp group))))
1259 (gnus-group-insert-group-line
1261 (let ((active (gnus-active group)))
1263 (if (zerop (cdr active))
1265 (- (1+ (cdr active)) (car active)))
1267 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1269 (defun gnus-group-update-group-line ()
1270 "Update the current line in the group buffer."
1271 (let* ((buffer-read-only nil)
1272 (group (gnus-group-group-name))
1273 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1274 gnus-group-indentation)
1277 (not (gnus-ephemeral-group-p group))
1279 (concat "(gnus-group-set-info '"
1280 (gnus-prin1-to-string (nth 2 entry))
1282 (setq gnus-group-indentation (gnus-group-group-indentation))
1284 (gnus-group-insert-group-line-info group)
1286 (gnus-group-position-point))))
1288 (defun gnus-group-insert-group-line-info (group)
1289 "Insert GROUP on the current line."
1290 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1291 (gnus-group-indentation (gnus-group-group-indentation))
1295 ;; (Un)subscribed group.
1296 (setq info (nth 2 entry))
1297 (gnus-group-insert-group-line
1298 group (gnus-info-level info) (gnus-info-marks info)
1299 (or (car entry) t) (gnus-info-method info)))
1300 ;; This group is dead.
1301 (gnus-group-insert-group-line
1303 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1305 (if (setq active (gnus-active group))
1306 (if (zerop (cdr active))
1308 (- (1+ (cdr active)) (car active)))
1310 (gnus-method-simplify (gnus-find-method-for-group group))))))
1312 (defun gnus-number-of-unseen-articles-in-group (group)
1313 (let* ((info (nth 2 (gnus-group-entry group)))
1314 (marked (gnus-info-marks info))
1315 (seen (cdr (assq 'seen marked)))
1316 (active (gnus-active group)))
1319 (length (gnus-uncompress-range
1320 (gnus-range-difference
1321 (gnus-range-difference (list active) (gnus-info-read info))
1324 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1325 gnus-tmp-marked number
1327 "Insert a group line in the group buffer."
1328 (let* ((gnus-tmp-method
1329 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1330 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1332 (gnus-tmp-active (gnus-active gnus-tmp-group))
1333 (gnus-tmp-number-total
1335 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1337 (gnus-tmp-number-of-unread
1338 (if (numberp number) (int-to-string (max 0 number))
1340 (gnus-tmp-number-of-read
1341 (if (numberp number)
1342 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1344 (gnus-tmp-subscribed
1345 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1346 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1347 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1349 (gnus-tmp-qualified-group
1350 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1351 group-name-charset))
1353 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1355 (gnus-tmp-newsgroup-description
1356 (if gnus-description-hashtb
1357 (or (gnus-group-name-decode
1358 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1359 group-name-charset) "")
1362 (if (and gnus-moderated-hashtb
1363 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1365 (gnus-tmp-moderated-string
1366 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1367 (gnus-tmp-group-icon "==&&==")
1368 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1369 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1370 (gnus-tmp-news-method-string
1372 (format "(%s:%s)" (car gnus-tmp-method)
1373 (cadr gnus-tmp-method)) ""))
1374 (gnus-tmp-marked-mark
1375 (if (and (numberp number)
1377 (cdr (assq 'tick gnus-tmp-marked)))
1379 (gnus-tmp-summary-live
1380 (if (and (not gnus-group-is-exiting-p)
1381 (gnus-buffer-live-p (gnus-summary-buffer-name
1384 (gnus-tmp-process-marked
1385 (if (member gnus-tmp-group gnus-group-marked)
1386 gnus-process-mark ? ))
1388 (or (and gnus-use-grouplens
1389 (bbb-grouplens-group-p gnus-tmp-group))
1391 (buffer-read-only nil)
1392 header gnus-tmp-header) ; passed as parameter to user-funcs.
1394 (gnus-add-text-properties
1398 (let ((gnus-tmp-group (gnus-group-name-decode
1399 gnus-tmp-group group-name-charset)))
1400 (eval gnus-group-line-format-spec)))
1401 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1402 gnus-unread ,(if (numberp number)
1403 (string-to-int gnus-tmp-number-of-unread)
1405 gnus-marked ,gnus-tmp-marked-mark
1406 gnus-indentation ,gnus-group-indentation
1407 gnus-level ,gnus-tmp-level))
1409 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1410 (gnus-run-hooks 'gnus-group-update-hook))
1412 ;; Allow XEmacs to remove front-sticky text properties.
1413 (gnus-group-remove-excess-properties)))
1415 (defun gnus-group-highlight-line ()
1416 "Highlight the current line according to `gnus-group-highlight'."
1417 (let* ((list gnus-group-highlight)
1419 (end (progn (end-of-line) (point)))
1420 ;; now find out where the line starts and leave point there.
1421 (beg (progn (beginning-of-line) (point)))
1422 (group (gnus-group-group-name))
1423 (entry (gnus-group-entry group))
1424 (unread (if (numberp (car entry)) (car entry) 0))
1425 (active (gnus-active group))
1426 (total (if active (1+ (- (cdr active) (car active))) 0))
1427 (info (nth 2 entry))
1428 (method (gnus-server-get-method group (gnus-info-method info)))
1429 (marked (gnus-info-marks info))
1430 (mailp (apply 'append
1433 (memq x (assoc (symbol-name
1434 (car (or method gnus-select-method)))
1435 gnus-valid-select-methods)))
1436 '(mail post-mail))))
1437 (level (or (gnus-info-level info) gnus-level-killed))
1438 (score (or (gnus-info-score info) 0))
1439 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1440 (group-age (gnus-group-timestamp-delta group))
1441 (inhibit-read-only t))
1442 ;; Eval the cars of the lists until we find a match.
1444 (not (eval (caar list))))
1445 (setq list (cdr list)))
1446 (let ((face (cdar list)))
1447 (unless (eq face (get-text-property beg 'face))
1448 (gnus-put-text-property-excluding-characters-with-faces
1450 (setq face (if (boundp face) (symbol-value face) face)))
1451 (gnus-extent-start-open beg)))
1454 (defun gnus-group-update-group (group &optional visible-only)
1455 "Update all lines where GROUP appear.
1456 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1458 ;; Can't use `save-excursion' here, so we do it manually.
1459 (let ((buf (current-buffer))
1461 (set-buffer gnus-group-buffer)
1462 (setq mark (point-marker))
1463 ;; The buffer may be narrowed.
1466 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1468 found buffer-read-only)
1469 ;; Enter the current status into the dribble buffer.
1470 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1472 (not (gnus-ephemeral-group-p group)))
1474 (concat "(gnus-group-set-info '"
1475 (gnus-prin1-to-string (nth 2 entry))
1477 ;; Find all group instances. If topics are in use, each group
1478 ;; may be listed in more than once.
1479 (while (setq loc (text-property-any
1480 loc (point-max) 'gnus-group ident))
1483 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1485 (gnus-group-insert-group-line-info group)
1488 (gnus-run-hooks 'gnus-group-update-group-hook)))
1489 (setq loc (1+ loc)))
1490 (unless (or found visible-only)
1491 ;; No such line in the buffer, find out where it's supposed to
1492 ;; go, and insert it there (or at the end of the buffer).
1493 (if gnus-goto-missing-group-function
1494 (funcall gnus-goto-missing-group-function group)
1495 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1496 (while (and entry (car entry)
1500 (point-min) (point-max)
1501 'gnus-group (gnus-intern-safe
1502 (caar entry) gnus-active-hashtb)))))
1503 (setq entry (cdr entry)))
1504 (or entry (goto-char (point-max)))))
1505 ;; Finally insert the line.
1506 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1507 (gnus-group-insert-group-line-info group)
1510 (gnus-run-hooks 'gnus-group-update-group-hook))))
1511 (when gnus-group-update-group-function
1512 (funcall gnus-group-update-group-function group))
1513 (gnus-group-set-mode-line)))
1515 (set-marker mark nil)
1518 (defun gnus-group-set-mode-line ()
1519 "Update the mode line in the group buffer."
1520 (when (memq 'group gnus-updated-mode-lines)
1521 ;; Yes, we want to keep this mode line updated.
1523 (set-buffer gnus-group-buffer)
1524 (let* ((gformat (or gnus-group-mode-line-format-spec
1525 (gnus-set-format 'group-mode)))
1526 (gnus-tmp-news-server (cadr gnus-select-method))
1527 (gnus-tmp-news-method (car gnus-select-method))
1528 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1530 gnus-tmp-header ;Dummy binding for user-defined formats
1531 ;; Get the resulting string.
1533 (and gnus-dribble-buffer
1534 (buffer-name gnus-dribble-buffer)
1535 (buffer-modified-p gnus-dribble-buffer)
1537 (set-buffer gnus-dribble-buffer)
1538 (not (zerop (buffer-size))))))
1539 (mode-string (eval gformat)))
1540 ;; Say whether the dribble buffer has been modified.
1541 (setq mode-line-modified
1542 (if modified (car gnus-mode-line-modified)
1543 (cdr gnus-mode-line-modified)))
1544 ;; If the line is too long, we chop it off.
1545 (when (> (length mode-string) max-len)
1546 (setq mode-string (substring mode-string 0 (- max-len 4))))
1548 (setq mode-line-buffer-identification
1549 (gnus-mode-line-buffer-identification
1550 (list mode-string)))
1551 (set-buffer-modified-p modified))))))
1553 (defun gnus-group-group-name ()
1554 "Get the name of the newsgroup on the current line."
1555 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1557 (symbol-name group))))
1559 (defun gnus-group-group-level ()
1560 "Get the level of the newsgroup on the current line."
1561 (get-text-property (gnus-point-at-bol) 'gnus-level))
1563 (defun gnus-group-group-indentation ()
1564 "Get the indentation of the newsgroup on the current line."
1565 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1566 (and gnus-group-indentation-function
1567 (funcall gnus-group-indentation-function))
1570 (defun gnus-group-group-unread ()
1571 "Get the number of unread articles of the newsgroup on the current line."
1572 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1574 (defun gnus-group-new-mail (group)
1575 (if (nnmail-new-mail-p (gnus-group-real-name group))
1579 (defun gnus-group-level (group)
1580 "Return the estimated level of GROUP."
1581 (or (gnus-info-level (gnus-get-info group))
1582 (and (member group gnus-zombie-list) gnus-level-zombie)
1585 (defun gnus-group-search-forward (&optional backward all level first-too)
1586 "Find the next newsgroup with unread articles.
1587 If BACKWARD is non-nil, find the previous newsgroup instead.
1588 If ALL is non-nil, just find any newsgroup.
1589 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1591 If FIRST-TOO, the current line is also eligible as a target."
1592 (let ((way (if backward -1 1))
1593 (low gnus-level-killed)
1596 (if (and backward (progn (beginning-of-line)) (bobp))
1605 (get-text-property (point) 'gnus-group)
1609 (get-text-property (point) 'gnus-unread)))
1610 (and (numberp unread) (> unread 0)))
1611 (setq lev (get-text-property (point)
1613 (<= lev gnus-level-subscribed)))
1615 (and (setq lev (get-text-property (point)
1624 (zerop (forward-line way)))))
1626 (progn (gnus-group-position-point) t)
1627 (goto-char (or pos beg))
1630 ;;; Gnus group mode commands
1634 (defun gnus-group-mark-line-p ()
1637 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1638 (eq (char-after) gnus-process-mark)))
1640 (defun gnus-group-mark-group (n &optional unmark no-advance)
1641 "Mark the current group."
1643 (let ((buffer-read-only nil)
1647 (when (setq group (gnus-group-group-name))
1648 ;; Go to the mark position.
1650 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1651 (subst-char-in-region
1652 (point) (1+ (point)) (char-after)
1655 (setq gnus-group-marked (delete group gnus-group-marked))
1657 (setq gnus-group-marked
1658 (cons group (delete group gnus-group-marked)))
1659 gnus-process-mark)))
1661 (gnus-group-next-group 1))
1663 (gnus-summary-position-point)
1666 (defun gnus-group-unmark-group (n)
1667 "Remove the mark from the current group."
1669 (gnus-group-mark-group n 'unmark)
1670 (gnus-group-position-point))
1672 (defun gnus-group-unmark-all-groups ()
1673 "Unmark all groups."
1675 (let ((groups gnus-group-marked))
1678 (gnus-group-remove-mark (pop groups)))))
1679 (gnus-group-position-point))
1681 (defun gnus-group-mark-region (unmark beg end)
1682 "Mark all groups between point and mark.
1683 If UNMARK, remove the mark instead."
1684 (interactive "P\nr")
1685 (let ((num (count-lines beg end)))
1688 (- num (gnus-group-mark-group num unmark)))))
1690 (defun gnus-group-mark-buffer (&optional unmark)
1691 "Mark all groups in the buffer.
1692 If UNMARK, remove the mark instead."
1694 (gnus-group-mark-region unmark (point-min) (point-max)))
1696 (defun gnus-group-mark-regexp (regexp)
1697 "Mark all groups that match some regexp."
1698 (interactive "sMark (regexp): ")
1699 (let ((alist (cdr gnus-newsrc-alist))
1702 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1703 (gnus-group-set-mark group))))
1704 (gnus-group-position-point))
1706 (defun gnus-group-remove-mark (group &optional test-marked)
1707 "Remove the process mark from GROUP and move point there.
1708 Return nil if the group isn't displayed."
1709 (if (gnus-group-goto-group group nil test-marked)
1711 (gnus-group-mark-group 1 'unmark t)
1713 (setq gnus-group-marked
1714 (delete group gnus-group-marked))
1717 (defun gnus-group-set-mark (group)
1718 "Set the process mark on GROUP."
1719 (if (gnus-group-goto-group group)
1721 (gnus-group-mark-group 1 nil t))
1722 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1724 (defun gnus-group-universal-argument (arg &optional groups func)
1725 "Perform any command on all groups according to the process/prefix convention."
1727 (if (eq (setq func (or func
1730 (substitute-command-keys
1731 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1733 (gnus-error 1 "Undefined key")
1734 (gnus-group-iterate arg
1736 (command-execute func))))
1737 (gnus-group-position-point))
1739 (defun gnus-group-process-prefix (n)
1740 "Return a list of groups to work on.
1741 Take into consideration N (the prefix) and the list of marked groups."
1744 (setq n (prefix-numeric-value n))
1745 ;; There is a prefix, so we return a list of the N next
1747 (let ((way (if (< n 0) -1 1))
1752 (if (setq group (gnus-group-group-name))
1753 (push group groups))
1755 (gnus-group-next-group way)))
1757 ((and (gnus-region-active-p) (mark))
1758 ;; Work on the region between point and mark.
1759 (let ((max (max (point) (mark)))
1762 (goto-char (min (point) (mark)))
1765 (push (gnus-group-group-name) groups)
1766 (zerop (gnus-group-next-group 1))
1768 (nreverse groups))))
1770 ;; No prefix, but a list of marked articles.
1771 (reverse gnus-group-marked))
1773 ;; Neither marked articles or a prefix, so we return the
1775 (let ((group (gnus-group-group-name)))
1776 (and group (list group))))))
1778 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1779 ;;; imagine why I went through these contortions...
1781 (let ((function (make-symbol "gnus-group-iterate-function"))
1782 (window (make-symbol "gnus-group-iterate-window"))
1783 (groups (make-symbol "gnus-group-iterate-groups"))
1784 (group (make-symbol "gnus-group-iterate-group")))
1786 `(defun gnus-group-iterate (arg ,function)
1787 "Iterate FUNCTION over all process/prefixed groups.
1788 FUNCTION will be called with the group name as the parameter
1789 and with point over the group in question."
1790 (let ((,groups (gnus-group-process-prefix arg))
1791 (,window (selected-window))
1794 (setq ,group (car ,groups)
1795 ,groups (cdr ,groups))
1796 (select-window ,window)
1797 (gnus-group-remove-mark ,group)
1798 (save-selected-window
1800 (funcall ,function ,group)))))))))
1802 (put 'gnus-group-iterate 'lisp-indent-function 1)
1804 ;; Selecting groups.
1806 (defun gnus-group-read-group (&optional all no-article group select-articles)
1807 "Read news in this newsgroup.
1808 If the prefix argument ALL is non-nil, already read articles become
1809 readable. IF ALL is a number, fetch this number of articles. If the
1810 optional argument NO-ARTICLE is non-nil, no article will be
1811 auto-selected upon group entry. If GROUP is non-nil, fetch that
1814 (let ((no-display (eq all 0))
1815 (group (or group (gnus-group-group-name)))
1816 number active marked entry)
1820 (error "No group on current line"))
1821 (setq marked (gnus-info-marks
1822 (nth 2 (setq entry (gnus-gethash
1823 group gnus-newsrc-hashtb)))))
1824 ;; This group might be a dead group. In that case we have to get
1825 ;; the number of unread articles from `gnus-active-hashtb'.
1827 (cond ((numberp all) all)
1829 ((setq active (gnus-active group))
1830 (- (1+ (cdr active)) (car active)))))
1831 (gnus-summary-read-group
1832 group (or all (and (numberp number)
1833 (zerop (+ number (gnus-range-length
1834 (cdr (assq 'tick marked)))
1836 (cdr (assq 'dormant marked)))))))
1837 no-article nil no-display nil select-articles)))
1839 (defun gnus-group-select-group (&optional all)
1840 "Select this newsgroup.
1841 No article is selected automatically.
1842 If the group is opened, just switch the summary buffer.
1843 If ALL is non-nil, already read articles become readable.
1844 If ALL is a number, fetch this number of articles."
1846 (gnus-group-read-group all t))
1848 (defun gnus-group-quick-select-group (&optional all)
1849 "Select the current group \"quickly\".
1850 This means that no highlighting or scoring will be performed.
1851 If ALL (the prefix argument) is 0, don't even generate the summary
1854 This might be useful if you want to toggle threading
1855 before entering the group."
1857 (require 'gnus-score)
1859 gnus-score-find-score-files-function
1860 gnus-home-score-file
1861 gnus-apply-kill-hook
1862 gnus-summary-expunge-below)
1863 (gnus-group-read-group all t)))
1865 (defun gnus-group-visible-select-group (&optional all)
1866 "Select the current group without hiding any articles."
1868 (let ((gnus-inhibit-limiting t))
1869 (gnus-group-read-group all t)))
1871 (defun gnus-group-select-group-ephemerally ()
1872 "Select the current group without doing any processing whatsoever.
1873 You will actually be entered into a group that's a copy of
1874 the current group; no changes you make while in this group will
1877 (require 'gnus-score)
1879 gnus-score-find-score-files-function gnus-apply-kill-hook
1880 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1881 gnus-summary-mode-hook gnus-select-group-hook
1882 (group (gnus-group-group-name))
1883 (method (gnus-find-method-for-group group)))
1884 (gnus-group-read-ephemeral-group
1885 (gnus-group-prefixed-name group method) method)))
1888 (defun gnus-fetch-group (group &optional articles)
1889 "Start Gnus if necessary and enter GROUP.
1890 Returns whether the fetching was successful or not."
1891 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1892 (unless (get-buffer gnus-group-buffer)
1894 (gnus-group-read-group articles nil group))
1897 (defun gnus-fetch-group-other-frame (group)
1898 "Pop up a frame and enter GROUP."
1900 (let ((window (get-buffer-window gnus-group-buffer)))
1902 (select-frame (window-frame window)))
1903 ((= (length (frame-list)) 1)
1904 (select-frame (make-frame)))
1907 (gnus-fetch-group group))
1909 (defvar gnus-ephemeral-group-server 0)
1911 ;; Enter a group that is not in the group buffer. Non-nil is returned
1912 ;; if selection was successful.
1913 (defun gnus-group-read-ephemeral-group (group method &optional activate
1914 quit-config request-only
1917 "Read GROUP from METHOD as an ephemeral group.
1918 If ACTIVATE, request the group first.
1919 If QUIT-CONFIG, use that window configuration when exiting from the
1921 If REQUEST-ONLY, don't actually read the group; just request it.
1922 If SELECT-ARTICLES, only select those articles.
1923 If PARAMETERS, use those as the group parameters.
1925 Return the name of the group if selection was successful."
1926 ;; Transform the select method into a unique server.
1927 (when (stringp method)
1928 (setq method (gnus-server-to-method method)))
1930 `(,(car method) ,(concat (cadr method) "-ephemeral")
1931 (,(intern (format "%s-address" (car method))) ,(cadr method))
1933 (let ((group (if (gnus-group-foreign-p group) group
1934 (gnus-group-prefixed-name (gnus-group-real-name group)
1939 ,gnus-level-default-subscribed nil nil ,method
1942 (cons 'quit-config quit-config)
1944 (cons gnus-summary-buffer
1945 gnus-current-window-configuration)))
1948 (push method gnus-ephemeral-servers)
1949 (set-buffer gnus-group-buffer)
1950 (unless (gnus-check-server method)
1951 (error "Unable to contact server: %s" (gnus-status-message method)))
1953 (gnus-activate-group group 'scan)
1954 (unless (gnus-request-group group)
1955 (error "Couldn't request group: %s"
1956 (nnheader-get-report (car method)))))
1960 (when (gnus-group-read-group t t group select-articles)
1964 (message "Quit reading the ephemeral group")
1967 (defun gnus-group-jump-to-group (group)
1968 "Jump to newsgroup GROUP."
1970 (list (mm-string-make-unibyte
1972 "Group: " gnus-active-hashtb nil
1973 (gnus-read-active-file-p)
1974 gnus-group-jump-to-group-prompt
1975 'gnus-group-history))))
1977 (when (equal group "")
1978 (error "Empty group name"))
1980 (unless (gnus-ephemeral-group-p group)
1981 ;; Either go to the line in the group buffer...
1982 (unless (gnus-group-goto-group group)
1983 ;; ... or insert the line.
1984 (gnus-group-update-group group)
1985 (gnus-group-goto-group group)))
1986 ;; Adjust cursor point.
1987 (gnus-group-position-point))
1989 (defun gnus-group-goto-group (group &optional far test-marked)
1990 "Goto to newsgroup GROUP.
1991 If FAR, it is likely that the group is not on the current line.
1992 If TEST-MARKED, the line must be marked."
1996 ;; It's quite likely that we are on the right line, so
1997 ;; we check the current line first.
1999 (eq (get-text-property (point) 'gnus-group)
2000 (gnus-intern-safe group gnus-active-hashtb))
2001 (or (not test-marked) (gnus-group-mark-line-p)))
2003 ;; Previous and next line are also likely, so we check them as well.
2007 (and (eq (get-text-property (point) 'gnus-group)
2008 (gnus-intern-safe group gnus-active-hashtb))
2009 (or (not test-marked) (gnus-group-mark-line-p)))))
2015 (and (eq (get-text-property (point) 'gnus-group)
2016 (gnus-intern-safe group gnus-active-hashtb))
2017 (or (not test-marked) (gnus-group-mark-line-p)))))
2021 (goto-char (point-min))
2023 (while (and (not found)
2028 (gnus-intern-safe group gnus-active-hashtb))))
2029 (if (gnus-group-mark-line-p)
2034 ;; Search through the entire buffer.
2037 (point-min) (point-max)
2038 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2040 (defun gnus-group-next-group (n &optional silent)
2041 "Go to next N'th newsgroup.
2042 If N is negative, search backward instead.
2043 Returns the difference between N and the number of skips actually
2046 (gnus-group-next-unread-group n t nil silent))
2048 (defun gnus-group-next-unread-group (n &optional all level silent)
2049 "Go to next N'th unread newsgroup.
2050 If N is negative, search backward instead.
2051 If ALL is non-nil, choose any newsgroup, unread or not.
2052 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2053 such group can be found, the next group with a level higher than
2055 Returns the difference between N and the number of skips actually
2058 (let ((backward (< n 0))
2061 (gnus-group-search-forward
2062 backward (or (not gnus-group-goto-unread) all) level))
2066 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2067 (if level " on this level or higher" "")))
2070 (defun gnus-group-prev-group (n)
2071 "Go to previous N'th newsgroup.
2072 Returns the difference between N and the number of skips actually
2075 (gnus-group-next-unread-group (- n) t))
2077 (defun gnus-group-prev-unread-group (n)
2078 "Go to previous N'th unread newsgroup.
2079 Returns the difference between N and the number of skips actually
2082 (gnus-group-next-unread-group (- n)))
2084 (defun gnus-group-next-unread-group-same-level (n)
2085 "Go to next N'th unread newsgroup on the same level.
2086 If N is negative, search backward instead.
2087 Returns the difference between N and the number of skips actually
2090 (gnus-group-next-unread-group n t (gnus-group-group-level))
2091 (gnus-group-position-point))
2093 (defun gnus-group-prev-unread-group-same-level (n)
2094 "Go to next N'th unread newsgroup on the same level.
2095 Returns the difference between N and the number of skips actually
2098 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2099 (gnus-group-position-point))
2101 (defun gnus-group-best-unread-group (&optional exclude-group)
2102 "Go to the group with the highest level.
2103 If EXCLUDE-GROUP, do not go to that group."
2105 (goto-char (point-min))
2109 (setq unread (get-text-property (point) 'gnus-unread))
2110 (when (and (numberp unread) (> unread 0))
2111 (when (and (get-text-property (point) 'gnus-level)
2112 (< (get-text-property (point) 'gnus-level) best)
2113 (or (not exclude-group)
2114 (not (equal exclude-group (gnus-group-group-name)))))
2115 (setq best (get-text-property (point) 'gnus-level))
2116 (setq best-point (point))))
2119 (goto-char best-point))
2120 (gnus-group-position-point)
2121 (and best-point (gnus-group-group-name))))
2123 (defun gnus-group-first-unread-group ()
2124 "Go to the first group with unread articles."
2127 (let ((opoint (point))
2129 (goto-char (point-min))
2130 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2131 (and (numberp unread) ; Not a topic.
2132 (not (zerop unread))) ; Has unread articles.
2133 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2136 nil)) ; Not success.
2137 (gnus-group-position-point)))
2139 (defun gnus-group-enter-server-mode ()
2140 "Jump to the server buffer."
2142 (gnus-enter-server-buffer))
2144 (defun gnus-group-make-group (name &optional method address args)
2145 "Add a new newsgroup.
2146 The user will be prompted for a NAME, for a select METHOD, and an
2150 (gnus-read-group "Group name: ")
2151 (gnus-read-method "From method: ")))
2153 (when (stringp method)
2154 (setq method (or (gnus-server-to-method method) method)))
2155 (let* ((meth (gnus-method-simplify
2157 (not (gnus-server-equal method gnus-select-method)))
2158 (if address (list (intern method) address)
2160 (nname (if method (gnus-group-prefixed-name name meth) name))
2162 (when (gnus-gethash nname gnus-newsrc-hashtb)
2163 (error "Group %s already exists" nname))
2164 ;; Subscribe to the new group.
2165 (gnus-group-change-level
2166 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2167 gnus-level-default-subscribed gnus-level-killed
2168 (and (gnus-group-group-name)
2169 (gnus-gethash (gnus-group-group-name)
2170 gnus-newsrc-hashtb))
2173 (gnus-set-active nname (cons 1 0))
2174 (unless (gnus-ephemeral-group-p name)
2176 (concat "(gnus-group-set-info '"
2177 (gnus-prin1-to-string (cdr info)) ")")))
2179 (gnus-group-insert-group-line-info nname)
2181 (gnus-group-position-point)
2183 ;; Load the backend and try to make the backend create
2184 ;; the group as well.
2185 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2187 gnus-valid-select-methods)
2189 (gnus-check-server meth)
2190 (when (gnus-check-backend-function 'request-create-group nname)
2191 (gnus-request-create-group nname nil args))
2194 (defun gnus-group-delete-groups (&optional arg)
2195 "Delete the current group. Only meaningful with editable groups."
2197 (let ((n (length (gnus-group-process-prefix arg))))
2198 (when (gnus-yes-or-no-p
2200 "Delete this 1 group? "
2201 (format "Delete these %d groups? " n)))
2202 (gnus-group-iterate arg
2204 (gnus-group-delete-group group nil t))))))
2206 (defun gnus-group-delete-group (group &optional force no-prompt)
2207 "Delete the current group. Only meaningful with editable groups.
2208 If FORCE (the prefix) is non-nil, all the articles in the group will
2209 be deleted. This is \"deleted\" as in \"removed forever from the face
2210 of the Earth\". There is no undo. The user will be prompted before
2211 doing the deletion."
2213 (list (gnus-group-group-name)
2214 current-prefix-arg))
2216 (error "No group to delete"))
2217 (unless (gnus-check-backend-function 'request-delete-group group)
2218 (error "This backend does not support group deletion"))
2220 (if (and (not no-prompt)
2221 (not (gnus-yes-or-no-p
2223 "Do you really want to delete %s%s? "
2224 group (if force " and all its contents" "")))))
2226 (gnus-message 6 "Deleting group %s..." group)
2227 (if (not (gnus-request-delete-group group force))
2228 (gnus-error 3 "Couldn't delete group %s" group)
2229 (gnus-message 6 "Deleting group %s...done" group)
2230 (gnus-group-goto-group group)
2231 (gnus-group-kill-group 1 t)
2232 (gnus-sethash group nil gnus-active-hashtb)
2233 (when (and (boundp 'gnus-cache-active-hashtb)
2234 gnus-cache-active-hashtb)
2235 (gnus-sethash group nil gnus-cache-active-hashtb)
2236 (setq gnus-cache-active-altered t))
2238 (gnus-group-position-point)))
2240 (defun gnus-group-rename-group (group new-name)
2241 "Rename group from GROUP to NEW-NAME.
2242 When used interactively, GROUP is the group under point
2243 and NEW-NAME will be prompted for."
2246 (gnus-group-group-name)
2248 (unless (gnus-check-backend-function
2249 'request-rename-group (gnus-group-group-name))
2250 (error "This backend does not support renaming groups"))
2251 (gnus-read-group "Rename group to: "
2252 (gnus-group-real-name (gnus-group-group-name))))))
2254 (unless (gnus-check-backend-function 'request-rename-group group)
2255 (error "This backend does not support renaming groups"))
2257 (error "No group to rename"))
2258 (when (equal (gnus-group-real-name group) new-name)
2259 (error "Can't rename to the same name"))
2261 ;; We find the proper prefixed name.
2263 (if (gnus-group-native-p group)
2267 (gnus-group-prefixed-name
2268 (gnus-group-real-name new-name)
2269 (gnus-info-method (gnus-get-info group)))))
2271 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2274 (gnus-group-goto-group group)
2275 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2276 (gnus-request-rename-group group new-name))))
2277 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2278 ;; We rename the group internally by killing it...
2279 (gnus-group-kill-group)
2280 ;; ... changing its name ...
2281 (setcar (cdar gnus-list-of-killed-groups) new-name)
2282 ;; ... and then yanking it. Magic!
2283 (gnus-group-yank-group)
2284 (gnus-set-active new-name (gnus-active group))
2285 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2287 (setq gnus-killed-list (delete group gnus-killed-list))
2288 (gnus-set-active group nil)
2289 (gnus-dribble-touch)
2290 (gnus-group-position-point)))
2292 (defun gnus-group-edit-group (group &optional part)
2293 "Edit the group on the current line."
2294 (interactive (list (gnus-group-group-name)))
2295 (let ((part (or part 'info))
2298 (error "No group on current line"))
2299 (unless (setq info (gnus-get-info group))
2300 (error "Killed group; can't be edited"))
2302 (gnus-close-group group))
2304 ;; Find the proper form to edit.
2305 (cond ((eq part 'method)
2306 (or (gnus-info-method info) "native"))
2308 (gnus-info-params info))
2310 ;; The proper documentation.
2312 "Editing the %s for `%s'."
2314 ((eq part 'method) "select method")
2315 ((eq part 'params) "group parameters")
2317 (gnus-group-decoded-name group))
2319 (gnus-group-edit-group-done ',part ,group form)))
2322 (gnus-create-info-command
2325 "(gnus)Select Methods")
2327 "(gnus)Group Parameters")
2329 "(gnus)Group Info"))))))
2331 (defun gnus-group-edit-group-method (group)
2332 "Edit the select method of GROUP."
2333 (interactive (list (gnus-group-group-name)))
2334 (gnus-group-edit-group group 'method))
2336 (defun gnus-group-edit-group-parameters (group)
2337 "Edit the group parameters of GROUP."
2338 (interactive (list (gnus-group-group-name)))
2339 (gnus-group-edit-group group 'params))
2341 (defun gnus-group-edit-group-done (part group form)
2343 (let* ((method (cond ((eq part 'info) (nth 4 form))
2344 ((eq part 'method) form)
2346 (info (cond ((eq part 'info) form)
2347 ((eq part 'method) (gnus-get-info group))
2350 (if (or (not method)
2352 gnus-select-method method))
2353 (gnus-group-real-name (car info))
2354 (gnus-group-prefixed-name
2355 (gnus-group-real-name (car info)) method))
2357 (when (and new-group
2358 (not (equal new-group group)))
2359 (when (gnus-group-goto-group group)
2360 (gnus-group-kill-group 1))
2361 (gnus-activate-group new-group))
2363 (if (not (and info new-group))
2364 (gnus-group-set-info form (or new-group group) part)
2365 (setq info (gnus-copy-sequence info))
2366 (setcar info new-group)
2367 (unless (gnus-server-equal method "native")
2368 (unless (nthcdr 3 info)
2369 (nconc info (list nil nil)))
2370 (unless (nthcdr 4 info)
2371 (nconc info (list nil)))
2372 (gnus-info-set-method info method))
2373 (gnus-group-set-info info))
2374 (gnus-group-update-group (or new-group group))
2375 (gnus-group-position-point)))
2377 (defun gnus-group-make-useful-group (group method)
2378 "Create one of the groups described in `gnus-useful-groups'."
2380 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2382 gnus-useful-groups)))
2383 (list (cadr entry) (caddr entry))))
2384 (setq method (gnus-copy-sequence method))
2386 (while (setq entry (memq (assq 'eval method) method))
2387 (setcar entry (eval (cadar entry)))))
2388 (gnus-group-make-group group method))
2390 (defun gnus-group-make-help-group (&optional noerror)
2391 "Create the Gnus documentation group.
2392 Optional argument NOERROR modifies the behavior of this function when the
2393 group already exists:
2394 - if not given, and error is signaled,
2395 - if t, stay silent,
2396 - if anything else, just print a message."
2398 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2399 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2400 (if (gnus-gethash name gnus-newsrc-hashtb)
2401 (cond ((eq noerror nil)
2402 (error "Documentation group already exists"))
2407 (gnus-message 1 "Documentation group already exists")))
2410 (gnus-message 1 "Couldn't find doc group")
2411 (gnus-group-make-group
2412 (gnus-group-real-name name)
2413 (list 'nndoc "gnus-help"
2414 (list 'nndoc-address file)
2415 (list 'nndoc-article-type 'mbox))))
2417 (gnus-group-position-point))
2419 (defun gnus-group-make-doc-group (file type)
2420 "Create a group that uses a single file as the source."
2422 (list (read-file-name "File name: ")
2423 (and current-prefix-arg 'ask)))
2424 (when (eq type 'ask)
2429 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2431 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2432 ((= char ?b) 'babyl)
2433 ((= char ?d) 'digest)
2434 ((= char ?f) 'forward)
2436 ((= char ?g) 'guess)
2437 (t (setq err (format "%c unknown. " char))
2440 (let* ((file (expand-file-name file))
2441 (name (gnus-generate-new-group-name
2442 (gnus-group-prefixed-name
2443 (file-name-nondirectory file) '(nndoc "")))))
2444 (gnus-group-make-group
2445 (gnus-group-real-name name)
2447 (list 'nndoc-address file)
2448 (list 'nndoc-article-type (or type 'guess))))))
2450 (defvar nnweb-type-definition)
2451 (defvar gnus-group-web-type-history nil)
2452 (defvar gnus-group-web-search-history nil)
2453 (defun gnus-group-make-web-group (&optional solid)
2454 "Create an ephemeral nnweb group.
2455 If SOLID (the prefix), create a solid group."
2459 (if solid (gnus-read-group "Group name: ")
2460 (message-unique-id)))
2461 (default-type (or (car gnus-group-web-type-history)
2462 (symbol-name (caar nnweb-type-definition))))
2466 (format "Search engine type (default %s): " default-type)
2467 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2468 nnweb-type-definition)
2469 nil t nil 'gnus-group-web-type-history)
2474 (cons (or (car gnus-group-web-search-history) "") 0)
2475 'gnus-group-web-search-history))
2477 `(nnweb ,group (nnweb-search ,search)
2478 (nnweb-type ,(intern type))
2479 (nnweb-ephemeral-p t))))
2481 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2482 (gnus-group-read-ephemeral-group
2484 (cons (current-buffer)
2485 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2487 (defvar nnwarchive-type-definition)
2488 (defvar gnus-group-warchive-type-history nil)
2489 (defvar gnus-group-warchive-login-history nil)
2490 (defvar gnus-group-warchive-address-history nil)
2492 (defun gnus-group-make-warchive-group ()
2493 "Create a nnwarchive group."
2495 (require 'nnwarchive)
2496 (let* ((group (gnus-read-group "Group name: "))
2497 (default-type (or (car gnus-group-warchive-type-history)
2498 (symbol-name (caar nnwarchive-type-definition))))
2502 (format "Warchive type (default %s): " default-type)
2503 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2504 nnwarchive-type-definition)
2505 nil t nil 'gnus-group-warchive-type-history)
2507 (address (read-string "Warchive address: "
2508 nil 'gnus-group-warchive-address-history))
2509 (default-login (or (car gnus-group-warchive-login-history)
2514 (format "Warchive login (default %s): " user-mail-address)
2515 default-login 'gnus-group-warchive-login-history)
2518 `(nnwarchive ,address
2519 (nnwarchive-type ,(intern type))
2520 (nnwarchive-login ,login))))
2521 (gnus-group-make-group group method)))
2523 (defun gnus-group-make-archive-group (&optional all)
2524 "Create the (ding) Gnus archive group of the most recent articles.
2525 Given a prefix, create a full group."
2527 (let ((group (gnus-group-prefixed-name
2528 (if all "ding.archives" "ding.recent") '(nndir ""))))
2529 (when (gnus-gethash group gnus-newsrc-hashtb)
2530 (error "Archive group already exists"))
2531 (gnus-group-make-group
2532 (gnus-group-real-name group)
2533 (list 'nndir (if all "hpc" "edu")
2534 (list 'nndir-directory
2535 (if all gnus-group-archive-directory
2536 gnus-group-recent-archive-directory))))
2537 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2539 (defun gnus-group-make-directory-group (dir)
2540 "Create an nndir group.
2541 The user will be prompted for a directory. The contents of this
2542 directory will be used as a newsgroup. The directory should contain
2543 mail messages or news articles in files that have numeric names."
2545 (list (read-file-name "Create group from directory: ")))
2546 (unless (file-exists-p dir)
2547 (error "No such directory"))
2548 (unless (file-directory-p dir)
2549 (error "Not a directory"))
2553 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2555 (gnus-group-prefixed-name
2556 (expand-file-name ext dir)
2558 (setq ext (format "<%d>" (setq i (1+ i)))))
2559 (gnus-group-make-group
2560 (gnus-group-real-name group)
2561 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2563 (eval-when-compile (defvar nnkiboze-score-file))
2564 (defun gnus-group-make-kiboze-group (group address scores)
2565 "Create an nnkiboze group.
2566 The user will be prompted for a name, a regexp to match groups, and
2567 score file entries for articles to include in the group."
2570 (read-string "nnkiboze group name: ")
2571 (read-string "Source groups (regexp): ")
2572 (let ((headers (mapcar (lambda (group) (list group))
2573 '("subject" "from" "number" "date" "message-id"
2574 "references" "chars" "lines" "xref"
2575 "followup" "all" "body" "head")))
2576 scores header regexp regexps)
2577 (while (not (equal "" (setq header (completing-read
2578 "Match on header: " headers nil t))))
2580 (while (not (equal "" (setq regexp (read-string
2581 (format "Match on %s (regexp): "
2583 (push (list regexp nil nil 'r) regexps))
2584 (push (cons header regexps) scores))
2586 (gnus-group-make-group group "nnkiboze" address)
2587 (let* ((nnkiboze-current-group group)
2588 (score-file (car (nnkiboze-score-file "")))
2589 (score-dir (file-name-directory score-file)))
2590 (unless (file-exists-p score-dir)
2591 (make-directory score-dir))
2592 (with-temp-file score-file
2593 (let (emacs-lisp-mode-hook)
2594 (pp scores (current-buffer))))))
2596 (defun gnus-group-add-to-virtual (n vgroup)
2597 "Add the current group to a virtual group."
2599 (list current-prefix-arg
2600 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2602 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2603 (error "%s is not an nnvirtual group" vgroup))
2604 (gnus-close-group vgroup)
2605 (let* ((groups (gnus-group-process-prefix n))
2606 (method (gnus-info-method (gnus-get-info vgroup))))
2607 (setcar (cdr method)
2609 (nth 1 method) "\\|"
2612 (gnus-group-remove-mark s)
2613 (concat "\\(^" (regexp-quote s) "$\\)"))
2615 (gnus-group-position-point))
2617 (defun gnus-group-make-empty-virtual (group)
2618 "Create a new, fresh, empty virtual group."
2619 (interactive "sCreate new, empty virtual group: ")
2620 (let* ((method (list 'nnvirtual "^$"))
2621 (pgroup (gnus-group-prefixed-name group method)))
2622 ;; Check whether it exists already.
2623 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2624 (error "Group %s already exists" pgroup))
2625 ;; Subscribe the new group after the group on the current line.
2626 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2627 (gnus-group-update-group pgroup)
2629 (gnus-group-position-point)))
2631 (defun gnus-group-enter-directory (dir)
2632 "Enter an ephemeral nneething group."
2633 (interactive "DDirectory to read: ")
2634 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2635 (leaf (gnus-group-prefixed-name
2636 (file-name-nondirectory (directory-file-name dir))
2638 (name (gnus-generate-new-group-name leaf)))
2639 (unless (gnus-group-read-ephemeral-group
2641 (cons (current-buffer)
2642 (if (eq major-mode 'gnus-summary-mode)
2644 (error "Couldn't enter %s" dir))))
2647 (autoload 'nnimap-expunge "nnimap")
2648 (autoload 'nnimap-acl-get "nnimap")
2649 (autoload 'nnimap-acl-edit "nnimap"))
2651 (defun gnus-group-nnimap-expunge (group)
2652 "Expunge deleted articles in current nnimap GROUP."
2653 (interactive (list (gnus-group-group-name)))
2654 (let ((mailbox (gnus-group-real-name group)) method)
2656 (error "No group on current line"))
2657 (unless (gnus-get-info group)
2658 (error "Killed group; can't be edited"))
2659 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2660 (error "%s is not an nnimap group" group))
2661 (nnimap-expunge mailbox (cadr method))))
2663 (defun gnus-group-nnimap-edit-acl (group)
2664 "Edit the Access Control List of current nnimap GROUP."
2665 (interactive (list (gnus-group-group-name)))
2666 (let ((mailbox (gnus-group-real-name group)) method acl)
2668 (error "No group on current line"))
2669 (unless (gnus-get-info group)
2670 (error "Killed group; can't be edited"))
2671 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2672 (error "%s is not an nnimap group" group))
2673 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2674 (error "Server does not support ACL's"))
2675 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2677 An access control list is a list of (identifier . rights) elements.
2679 The identifier string specifies the corresponding user. The
2680 identifier \"anyone\" is reserved to refer to the universal identity.
2682 Rights is a string listing a (possibly empty) set of alphanumeric
2683 characters, each character listing a set of operations which is being
2684 controlled. Letters are reserved for ``standard'' rights, listed
2685 below. Digits are reserved for implementation or site defined rights.
2687 l - lookup (mailbox is visible to LIST/LSUB commands)
2688 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2689 SEARCH, COPY from mailbox)
2690 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2691 w - write (STORE flags other than \\SEEN and \\DELETED)
2692 i - insert (perform APPEND, COPY into mailbox)
2693 p - post (send mail to submission address for mailbox,
2694 not enforced by IMAP4 itself)
2695 c - create and delete mailbox (CREATE new sub-mailboxes in any
2696 implementation-defined hierarchy, RENAME or DELETE mailbox)
2697 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2698 a - administer (perform SETACL)" group)
2701 ,mailbox ',method ',acl form)))))
2703 ;; Group sorting commands
2704 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2706 (defun gnus-group-sort-groups (func &optional reverse)
2707 "Sort the group buffer according to FUNC.
2708 When used interactively, the sorting function used will be
2709 determined by the `gnus-group-sort-function' variable.
2710 If REVERSE (the prefix), reverse the sorting order."
2711 (interactive (list gnus-group-sort-function current-prefix-arg))
2712 (funcall gnus-group-sort-alist-function
2713 (gnus-make-sort-function func) reverse)
2714 (gnus-group-unmark-all-groups)
2715 (gnus-group-list-groups)
2716 (gnus-dribble-touch))
2718 (defun gnus-group-sort-flat (func reverse)
2719 ;; We peel off the dummy group from the alist.
2721 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2722 (pop gnus-newsrc-alist))
2724 (setq gnus-newsrc-alist
2725 (sort gnus-newsrc-alist func))
2727 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2728 ;; Regenerate the hash table.
2729 (gnus-make-hashtable-from-newsrc-alist)))
2731 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2732 "Sort the group buffer alphabetically by group name.
2733 If REVERSE, sort in reverse order."
2735 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2737 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2738 "Sort the group buffer alphabetically by real (unprefixed) group name.
2739 If REVERSE, sort in reverse order."
2741 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2743 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2744 "Sort the group buffer by number of unread articles.
2745 If REVERSE, sort in reverse order."
2747 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2749 (defun gnus-group-sort-groups-by-level (&optional reverse)
2750 "Sort the group buffer by group level.
2751 If REVERSE, sort in reverse order."
2753 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2755 (defun gnus-group-sort-groups-by-score (&optional reverse)
2756 "Sort the group buffer by group score.
2757 If REVERSE, sort in reverse order."
2759 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2761 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2762 "Sort the group buffer by group rank.
2763 If REVERSE, sort in reverse order."
2765 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2767 (defun gnus-group-sort-groups-by-method (&optional reverse)
2768 "Sort the group buffer alphabetically by backend name.
2769 If REVERSE, sort in reverse order."
2771 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2773 (defun gnus-group-sort-groups-by-server (&optional reverse)
2774 "Sort the group buffer alphabetically by server name.
2775 If REVERSE, sort in reverse order."
2777 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2779 ;;; Selected group sorting.
2781 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2782 "Sort the process/prefixed groups."
2783 (interactive (list current-prefix-arg gnus-group-sort-function))
2784 (let ((groups (gnus-group-process-prefix n)))
2785 (funcall gnus-group-sort-selected-function
2786 groups (gnus-make-sort-function func) reverse)
2787 (gnus-group-unmark-all-groups)
2788 (gnus-group-list-groups)
2789 (gnus-dribble-touch)))
2791 (defun gnus-group-sort-selected-flat (groups func reverse)
2792 (let (entries infos)
2793 ;; First find all the group entries for these groups.
2795 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2797 ;; Then sort the infos.
2801 (lambda (entry) (car entry))
2802 (setq entries (nreverse entries)))
2805 (setq infos (nreverse infos)))
2806 ;; Go through all the infos and replace the old entries
2807 ;; with the new infos.
2809 (setcar (car entries) (pop infos))
2811 ;; Update the hashtable.
2812 (gnus-make-hashtable-from-newsrc-alist)))
2814 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2815 "Sort the group buffer alphabetically by group name.
2816 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2817 sort in reverse order."
2818 (interactive (gnus-interactive "P\ny"))
2819 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2821 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2822 "Sort the group buffer alphabetically by real group name.
2823 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2824 sort in reverse order."
2825 (interactive (gnus-interactive "P\ny"))
2826 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2828 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2829 "Sort the group buffer by number of unread articles.
2830 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2831 sort in reverse order."
2832 (interactive (gnus-interactive "P\ny"))
2833 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2835 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2836 "Sort the group buffer by group level.
2837 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2838 sort in reverse order."
2839 (interactive (gnus-interactive "P\ny"))
2840 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2842 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2843 "Sort the group buffer by group score.
2844 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2845 sort in reverse order."
2846 (interactive (gnus-interactive "P\ny"))
2847 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2849 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2850 "Sort the group buffer by group rank.
2851 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2852 sort in reverse order."
2853 (interactive (gnus-interactive "P\ny"))
2854 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2856 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2857 "Sort the group buffer alphabetically by backend name.
2858 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2859 sort in reverse order."
2860 (interactive (gnus-interactive "P\ny"))
2861 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2863 ;;; Sorting predicates.
2865 (defun gnus-group-sort-by-alphabet (info1 info2)
2866 "Sort alphabetically."
2867 (string< (gnus-info-group info1) (gnus-info-group info2)))
2869 (defun gnus-group-sort-by-real-name (info1 info2)
2870 "Sort alphabetically on real (unprefixed) names."
2871 (string< (gnus-group-real-name (gnus-info-group info1))
2872 (gnus-group-real-name (gnus-info-group info2))))
2874 (defun gnus-group-sort-by-unread (info1 info2)
2875 "Sort by number of unread articles."
2876 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2877 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2878 (< (or (and (numberp n1) n1) 0)
2879 (or (and (numberp n2) n2) 0))))
2881 (defun gnus-group-sort-by-level (info1 info2)
2883 (< (gnus-info-level info1) (gnus-info-level info2)))
2885 (defun gnus-group-sort-by-method (info1 info2)
2886 "Sort alphabetically by backend name."
2887 (string< (car (gnus-find-method-for-group
2888 (gnus-info-group info1) info1))
2889 (car (gnus-find-method-for-group
2890 (gnus-info-group info2) info2))))
2892 (defun gnus-group-sort-by-server (info1 info2)
2893 "Sort alphabetically by server name."
2894 (string< (gnus-method-to-full-server-name
2895 (gnus-find-method-for-group
2896 (gnus-info-group info1) info1))
2897 (gnus-method-to-full-server-name
2898 (gnus-find-method-for-group
2899 (gnus-info-group info2) info2))))
2901 (defun gnus-group-sort-by-score (info1 info2)
2902 "Sort by group score."
2903 (> (gnus-info-score info1) (gnus-info-score info2)))
2905 (defun gnus-group-sort-by-rank (info1 info2)
2906 "Sort by level and score."
2907 (let ((level1 (gnus-info-level info1))
2908 (level2 (gnus-info-level info2)))
2909 (or (< level1 level2)
2910 (and (= level1 level2)
2911 (> (gnus-info-score info1) (gnus-info-score info2))))))
2915 (defun gnus-group-clear-data (&optional arg)
2916 "Clear all marks and read ranges from the current group."
2918 (gnus-group-iterate arg
2921 (gnus-info-clear-data (setq info (gnus-get-info group)))
2922 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2923 (when (gnus-group-goto-group group)
2924 (gnus-group-update-group-line))))))
2926 (defun gnus-group-clear-data-on-native-groups ()
2927 "Clear all marks and read ranges from all native groups."
2929 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2930 (let ((alist (cdr gnus-newsrc-alist))
2932 (while (setq info (pop alist))
2933 (when (gnus-group-native-p (gnus-info-group info))
2934 (gnus-info-clear-data info)))
2935 (gnus-get-unread-articles)
2936 (gnus-dribble-touch)
2937 (when (gnus-y-or-n-p
2938 "Move the cache away to avoid problems in the future? ")
2939 (call-interactively 'gnus-cache-move-cache)))))
2941 (defun gnus-info-clear-data (info)
2942 "Clear all marks and read ranges from INFO."
2943 (let ((group (gnus-info-group info))
2945 (dolist (el (gnus-info-marks info))
2946 (push `(,(cdr el) add (,(car el))) action))
2947 (push `(,(gnus-info-read info) add (read)) action)
2950 (gnus-request-set-mark ,group ',action)
2951 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2952 (gnus-info-set-read ',info ',(gnus-info-read info))
2953 (when (gnus-group-goto-group ,group)
2954 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2955 (gnus-group-update-group-line))))
2956 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2958 (gnus-request-set-mark group action)
2959 (gnus-info-set-read info nil)
2960 (when (gnus-info-marks info)
2961 (gnus-info-set-marks info nil))))
2963 ;; Group catching up.
2965 (defun gnus-group-catchup-current (&optional n all)
2966 "Mark all unread articles in the current newsgroup as read.
2967 If prefix argument N is numeric, the next N newsgroups will be
2968 caught up. If ALL is non-nil, marked articles will also be marked as
2969 read. Cross references (Xref: header) of articles are ignored.
2970 The number of newsgroups that this function was unable to catch
2973 (let ((groups (gnus-group-process-prefix n))
2976 (unless groups (error "No groups selected"))
2978 (or (not gnus-interactive-catchup) ;Without confirmation?
2983 "Do you really want to mark all articles in %s as read? "
2984 "Mark all unread articles in %s as read? ")
2985 (if (= (length groups) 1)
2987 (format "these %d groups" (length groups)))))))
2989 (while (setq group (pop groups))
2990 (gnus-group-remove-mark group)
2991 ;; Virtual groups have to be given special treatment.
2992 (let ((method (gnus-find-method-for-group group)))
2993 (when (eq 'nnvirtual (car method))
2994 (nnvirtual-catchup-group
2995 (gnus-group-real-name group) (nth 1 method) all)))
2996 (if (>= (gnus-group-level group) gnus-level-zombie)
2997 (gnus-message 2 "Dead groups can't be caught up")
2999 (gnus-group-goto-group group)
3000 (gnus-group-catchup group all))
3001 (gnus-group-update-group-line)
3002 (setq ret (1+ ret)))))
3003 (gnus-group-next-unread-group 1)
3006 (defun gnus-group-catchup-current-all (&optional n)
3007 "Mark all articles in current newsgroup as read.
3008 Cross references (Xref: header) of articles are ignored."
3010 (gnus-group-catchup-current n 'all))
3012 (defun gnus-group-catchup (group &optional all)
3013 "Mark all articles in GROUP as read.
3014 If ALL is non-nil, all articles are marked as read.
3015 The return value is the number of articles that were marked as read,
3016 or nil if no action could be taken."
3017 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3019 (marks (nth 3 (nth 2 entry)))
3020 (unread (gnus-list-of-unread-articles group)))
3021 ;; Remove entries for this group.
3022 (nnmail-purge-split-history (gnus-group-real-name group))
3023 ;; Do the updating only if the newsgroup isn't killed.
3024 (if (not (numberp (car entry)))
3025 (gnus-message 1 "Can't catch up %s; non-active group" group)
3026 (gnus-update-read-articles group nil)
3028 ;; Nix out the lists of marks and dormants.
3029 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3031 (list (cdr (assq 'dormant marks))
3033 (setq unread (gnus-uncompress-range
3034 (gnus-range-add (gnus-range-add
3035 unread (cdr (assq 'dormant marks)))
3036 (cdr (assq 'tick marks)))))
3037 (gnus-add-marked-articles group 'tick nil nil 'force)
3038 (gnus-add-marked-articles group 'dormant nil nil 'force))
3039 ;; Do auto-expirable marks if that's required.
3040 (when (gnus-group-auto-expirable-p group)
3041 (gnus-add-marked-articles group 'expire unread)
3042 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3043 (let ((gnus-newsgroup-name group))
3044 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3047 (defun gnus-group-expire-articles (&optional n)
3048 "Expire all expirable articles in the current newsgroup.
3049 Uses the process/prefix convention."
3051 (let ((groups (gnus-group-process-prefix n))
3054 (error "No groups to expire"))
3055 (while (setq group (pop groups))
3056 (gnus-group-remove-mark group)
3057 (gnus-group-expire-articles-1 group)
3058 (gnus-dribble-touch)
3059 (gnus-group-position-point))))
3061 (defun gnus-group-expire-articles-1 (group)
3062 (when (gnus-check-backend-function 'request-expire-articles group)
3063 (gnus-message 6 "Expiring articles in %s..." group)
3064 (let* ((info (gnus-get-info group))
3065 (expirable (if (gnus-group-total-expirable-p group)
3066 (cons nil (gnus-list-of-read-articles group))
3067 (assq 'expire (gnus-info-marks info))))
3068 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3069 (nnmail-expiry-target
3070 (or (gnus-group-find-parameter group 'expiry-target)
3071 nnmail-expiry-target)))
3073 (gnus-check-group group)
3076 (gnus-compress-sequence
3078 ;; We set the expiry variables to the group
3080 (let ((nnmail-expiry-wait-function nil)
3081 (nnmail-expiry-wait expiry-wait))
3082 (gnus-request-expire-articles
3083 (gnus-uncompress-sequence (cdr expirable)) group))
3084 ;; Just expire using the normal expiry values.
3085 (gnus-request-expire-articles
3086 (gnus-uncompress-sequence (cdr expirable)) group))))
3087 (gnus-close-group group))
3088 (gnus-message 6 "Expiring articles in %s...done" group)
3089 ;; Return the list of un-expired articles.
3092 (defun gnus-group-expire-all-groups ()
3093 "Expire all expirable articles in all newsgroups."
3096 (gnus-message 5 "Expiring...")
3097 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3098 (cdr gnus-newsrc-alist))))
3099 (gnus-group-expire-articles nil)))
3100 (gnus-group-position-point)
3101 (gnus-message 5 "Expiring...done"))
3103 (defun gnus-group-set-current-level (n level)
3104 "Set the level of the next N groups to LEVEL."
3109 (let ((s (read-string
3110 (format "Level (default %s): "
3111 (or (gnus-group-group-level)
3112 gnus-level-default-subscribed)))))
3113 (if (string-match "^\\s-*$" s)
3114 (int-to-string (or (gnus-group-group-level)
3115 gnus-level-default-subscribed))
3117 (unless (and (>= level 1) (<= level gnus-level-killed))
3118 (error "Invalid level: %d" level))
3119 (let ((groups (gnus-group-process-prefix n))
3121 (while (setq group (pop groups))
3122 (gnus-group-remove-mark group)
3123 (gnus-message 6 "Changed level of %s from %d to %d"
3124 group (or (gnus-group-group-level) gnus-level-killed)
3126 (gnus-group-change-level
3127 group level (or (gnus-group-group-level) gnus-level-killed))
3128 (gnus-group-update-group-line)))
3129 (gnus-group-position-point))
3131 (defun gnus-group-unsubscribe (&optional n)
3132 "Unsubscribe the current group."
3134 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3136 (defun gnus-group-subscribe (&optional n)
3137 "Subscribe the current group."
3139 (gnus-group-unsubscribe-current-group n 'subscribe))
3141 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3142 "Toggle subscription of the current group.
3143 If given numerical prefix, toggle the N next groups."
3145 (let ((groups (gnus-group-process-prefix n))
3148 (setq group (car groups)
3149 groups (cdr groups))
3150 (gnus-group-remove-mark group)
3151 (gnus-group-unsubscribe-group
3154 ((eq do-sub 'unsubscribe)
3155 gnus-level-default-unsubscribed)
3156 ((eq do-sub 'subscribe)
3157 gnus-level-default-subscribed)
3158 ((<= (gnus-group-group-level) gnus-level-subscribed)
3159 gnus-level-default-unsubscribed)
3161 gnus-level-default-subscribed))
3163 (gnus-group-update-group-line))
3164 (gnus-group-next-group 1)))
3166 (defun gnus-group-unsubscribe-group (group &optional level silent)
3167 "Toggle subscription to GROUP.
3168 Killed newsgroups are subscribed. If SILENT, don't try to update the
3171 (list (completing-read
3172 "Group: " gnus-active-hashtb nil
3173 (gnus-read-active-file-p)
3175 'gnus-group-history)))
3176 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3178 ((string-match "^[ \t]*$" group)
3179 (error "Empty group name"))
3181 ;; Toggle subscription flag.
3182 (gnus-group-change-level
3183 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3184 gnus-level-subscribed)
3185 (1+ gnus-level-subscribed)
3186 gnus-level-default-subscribed)))
3188 (gnus-group-update-group group)))
3189 ((and (stringp group)
3190 (or (not (gnus-read-active-file-p))
3191 (gnus-active group)))
3192 ;; Add new newsgroup.
3193 (gnus-group-change-level
3195 (if level level gnus-level-default-subscribed)
3196 (or (and (member group gnus-zombie-list)
3199 (when (gnus-group-group-name)
3200 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3202 (gnus-group-update-group group)))
3203 (t (error "No such newsgroup: %s" group)))
3204 (gnus-group-position-point)))
3206 (defun gnus-group-transpose-groups (n)
3207 "Move the current newsgroup up N places.
3208 If given a negative prefix, move down instead. The difference between
3209 N and the number of steps taken is returned."
3211 (unless (gnus-group-group-name)
3212 (error "No group on current line"))
3213 (gnus-group-kill-group 1)
3215 (forward-line (- n))
3216 (gnus-group-yank-group)
3217 (gnus-group-position-point)))
3219 (defun gnus-group-kill-all-zombies (&optional dummy)
3220 "Kill all zombie newsgroups.
3221 The optional DUMMY should always be nil."
3222 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3224 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3225 (setq gnus-zombie-list nil)
3226 (gnus-dribble-touch)
3227 (gnus-group-list-groups)))
3229 (defun gnus-group-kill-region (begin end)
3230 "Kill newsgroups in current region (excluding current point).
3231 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3246 (beginning-of-line) ;Important when LINES < 1
3247 (gnus-group-kill-group lines)))
3249 (defun gnus-group-kill-group (&optional n discard)
3250 "Kill the next N groups.
3251 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3252 However, only groups that were alive can be yanked; already killed
3253 groups or zombie groups can't be yanked.
3254 The return value is the name of the group that was killed, or a list
3257 (let ((buffer-read-only nil)
3258 (groups (gnus-group-process-prefix n))
3259 group entry level out)
3260 (if (< (length groups) 10)
3261 ;; This is faster when there are few groups.
3263 (push (setq group (pop groups)) out)
3264 (gnus-group-remove-mark group)
3265 (setq level (gnus-group-group-level))
3267 (when (and (not discard)
3268 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3271 (gnus-group-goto-group ,(gnus-group-group-name))
3272 (gnus-group-yank-group)))
3273 (push (cons (car entry) (nth 2 entry))
3274 gnus-list-of-killed-groups))
3275 (gnus-group-change-level
3276 (if entry entry group) gnus-level-killed (if entry nil level))
3277 (message "Killed group %s" group))
3278 ;; If there are lots and lots of groups to be killed, we use
3279 ;; this thing instead.
3281 (setq groups (nreverse groups))
3283 (gnus-group-remove-mark (setq group (pop groups)))
3285 (push group gnus-killed-list)
3286 (setq gnus-newsrc-alist
3287 (delq (assoc group gnus-newsrc-alist)
3289 (when gnus-group-change-level-function
3290 (funcall gnus-group-change-level-function
3291 group gnus-level-killed 3))
3293 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3294 (push (cons (car entry) (nth 2 entry))
3295 gnus-list-of-killed-groups)
3296 (setcdr (cdr entry) (cdddr entry)))
3297 ((member group gnus-zombie-list)
3298 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3299 ;; There may be more than one instance displayed.
3300 (while (gnus-group-goto-group group)
3301 (gnus-delete-line)))
3302 (gnus-make-hashtable-from-newsrc-alist)))
3304 (gnus-group-position-point)
3305 (if (< (length out) 2) (car out) (nreverse out))))
3307 (defun gnus-group-yank-group (&optional arg)
3308 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3309 The numeric ARG specifies how many newsgroups are to be yanked. The
3310 name of the newsgroup yanked is returned, or (if several groups are
3311 yanked) a list of yanked groups is returned."
3313 (setq arg (or arg 1))
3314 (let (info group prev out)
3315 (while (>= (decf arg) 0)
3316 (when (not (setq info (pop gnus-list-of-killed-groups)))
3317 (error "No more newsgroups to yank"))
3318 (push (setq group (nth 1 info)) out)
3319 ;; Find which newsgroup to insert this one before - search
3320 ;; backward until something suitable is found. If there are no
3321 ;; other newsgroups in this buffer, just make this newsgroup the
3323 (setq prev (gnus-group-group-name))
3324 (gnus-group-change-level
3325 info (gnus-info-level (cdr info)) gnus-level-killed
3326 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3328 (gnus-group-insert-group-line-info group)
3330 `(when (gnus-group-goto-group ,group)
3331 (gnus-group-kill-group 1))))
3333 (gnus-group-position-point)
3334 (if (< (length out) 2) (car out) (nreverse out))))
3336 (defun gnus-group-kill-level (level)
3337 "Kill all groups that is on a certain LEVEL."
3338 (interactive "nKill all groups on level: ")
3340 ((= level gnus-level-zombie)
3341 (setq gnus-killed-list
3342 (nconc gnus-zombie-list gnus-killed-list))
3343 (setq gnus-zombie-list nil))
3344 ((and (< level gnus-level-zombie)
3346 (or gnus-expert-user
3349 "Do you really want to kill all groups on level %d? "
3351 (let* ((prev gnus-newsrc-alist)
3354 (if (= (gnus-info-level (car alist)) level)
3356 (push (gnus-info-group (car alist)) gnus-killed-list)
3357 (setcdr prev (cdr alist)))
3359 (setq alist (cdr alist)))
3360 (gnus-make-hashtable-from-newsrc-alist)
3361 (gnus-group-list-groups)))
3363 (error "Can't kill; invalid level: %d" level))))
3365 (defun gnus-group-list-all-groups (&optional arg)
3366 "List all newsgroups with level ARG or lower.
3367 Default is gnus-level-unsubscribed, which lists all subscribed and most
3368 unsubscribed groups."
3370 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3372 ;; Redefine this to list ALL killed groups if prefix arg used.
3373 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3374 (defun gnus-group-list-killed (&optional arg)
3375 "List all killed newsgroups in the group buffer.
3376 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3377 entail asking the server for the groups."
3379 ;; Find all possible killed newsgroups if arg.
3381 (gnus-get-killed-groups))
3382 (if (not gnus-killed-list)
3383 (gnus-message 6 "No killed groups")
3384 (let (gnus-group-list-mode)
3385 (funcall gnus-group-prepare-function
3386 gnus-level-killed t gnus-level-killed))
3387 (goto-char (point-min)))
3388 (gnus-group-position-point))
3390 (defun gnus-group-list-zombies ()
3391 "List all zombie newsgroups in the group buffer."
3393 (if (not gnus-zombie-list)
3394 (gnus-message 6 "No zombie groups")
3395 (let (gnus-group-list-mode)
3396 (funcall gnus-group-prepare-function
3397 gnus-level-zombie t gnus-level-zombie))
3398 (goto-char (point-min)))
3399 (gnus-group-position-point))
3401 (defun gnus-group-list-active ()
3402 "List all groups that are available from the server(s)."
3404 ;; First we make sure that we have really read the active file.
3405 (unless (gnus-read-active-file-p)
3406 (let ((gnus-read-active-file t)
3407 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3408 (gnus-read-active-file)))
3409 ;; Find all groups and sort them.
3417 (push (symbol-name sym) list)))
3421 (buffer-read-only nil)
3425 (setq group (pop groups))
3426 (gnus-add-text-properties
3427 (point) (prog1 (1+ (point))
3429 (gnus-group-decoded-name group)
3431 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3433 'gnus-level (inline (gnus-group-level group)))))
3434 (goto-char (point-min))))
3436 (defun gnus-activate-all-groups (level)
3437 "Activate absolutely all groups."
3438 (interactive (list gnus-level-unsubscribed))
3439 (let ((gnus-activate-level level)
3440 (gnus-activate-foreign-newsgroups level))
3441 (gnus-group-get-new-news)))
3443 (defun gnus-group-get-new-news (&optional arg)
3444 "Get newly arrived articles.
3445 If ARG is a number, it specifies which levels you are interested in
3446 re-scanning. If ARG is non-nil and not a number, this will force
3447 \"hard\" re-reading of the active files from all servers."
3450 (let ((gnus-inhibit-demon t)
3451 ;; Binding this variable will inhibit multiple fetchings
3452 ;; of the same mail source.
3453 (nnmail-fetched-sources (list t)))
3454 (gnus-run-hooks 'gnus-get-new-news-hook)
3456 ;; Read any slave files.
3458 (gnus-master-read-slave-newsrc))
3460 ;; We might read in new NoCeM messages here.
3461 (when (and gnus-use-nocem
3463 (gnus-nocem-scan-groups))
3464 ;; If ARG is not a number, then we read the active file.
3465 (when (and arg (not (numberp arg)))
3466 (let ((gnus-read-active-file t))
3467 (gnus-read-active-file))
3470 ;; If the user wants it, we scan for new groups.
3471 (when (eq gnus-check-new-newsgroups 'always)
3472 (gnus-find-new-newsgroups)))
3474 (setq arg (gnus-group-default-level arg t))
3475 (if (and gnus-read-active-file (not arg))
3477 (gnus-read-active-file)
3478 (gnus-get-unread-articles arg))
3479 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3480 (gnus-get-unread-articles arg)))
3481 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3482 (gnus-group-list-groups (and (numberp arg)
3483 (max (car gnus-group-list-mode) arg)))))
3485 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3486 "Check for newly arrived news in the current group (and the N-1 next groups).
3487 The difference between N and the number of newsgroup checked is returned.
3488 If N is negative, this group and the N-1 previous groups will be checked."
3490 (let* ((groups (gnus-group-process-prefix n))
3491 (ret (if (numberp n) (- n (length groups)) 0))
3495 (gnus-inhibit-demon t)
3496 ;; Binding this variable will inhibit multiple fetchings
3497 ;; of the same mail source.
3498 (nnmail-fetched-sources (list t)))
3499 (gnus-run-hooks 'gnus-get-new-news-hook)
3500 (while (setq group (pop groups))
3501 (gnus-group-remove-mark group)
3502 ;; Bypass any previous denials from the server.
3503 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3504 (if (gnus-activate-group group (if dont-scan nil 'scan))
3506 (gnus-get-unread-articles-in-group
3507 (gnus-get-info group) (gnus-active group) t)
3508 (unless (gnus-virtual-group-p group)
3509 (gnus-close-group group))
3511 (gnus-agent-save-group-info
3512 method (gnus-group-real-name group) (gnus-active group)))
3513 (gnus-group-update-group group))
3514 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3516 (gnus-error 3 "Server denied access")
3517 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3520 (when gnus-goto-next-group-when-activating
3521 (gnus-group-next-unread-group 1 t))
3522 (gnus-summary-position-point)
3525 (defun gnus-group-fetch-faq (group &optional faq-dir)
3526 "Fetch the FAQ for the current group.
3527 If given a prefix argument, prompt for the FAQ dir
3531 (gnus-group-group-name)
3532 (when current-prefix-arg
3534 "FAQ dir: " (and (listp gnus-group-faq-directory)
3536 gnus-group-faq-directory))))))
3538 (error "No group name given"))
3539 (let ((dirs (or faq-dir gnus-group-faq-directory))
3541 (unless (listp dirs)
3542 (setq dirs (list dirs)))
3543 (while (and (not found)
3544 (setq dir (pop dirs)))
3545 (let ((name (gnus-group-real-name group)))
3546 (setq file (expand-file-name name dir)))
3547 (if (not (file-exists-p file))
3548 (gnus-message 1 "No such file: %s" file)
3549 (let ((enable-local-variables nil))
3553 (defun gnus-group-fetch-charter (group)
3554 "Fetch the charter for the current group.
3555 If given a prefix argument, prompt for a group."
3557 (list (or (when current-prefix-arg
3558 (completing-read "Group: " gnus-active-hashtb))
3559 (gnus-group-group-name)
3560 gnus-newsgroup-name)))
3562 (error "No group name given"))
3564 (condition-case nil (require 'url-http) (error nil))
3565 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3567 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3568 (setq hierarchy (match-string 1 name))
3569 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3570 (if (fboundp 'url-http-file-exists-p)
3571 (url-http-file-exists-p (eval url))
3573 (browse-url (eval url))
3574 (setq url (concat "http://" hierarchy
3575 ".news-admin.org/charters/" name))
3576 (if (and (fboundp 'url-http-file-exists-p)
3577 (url-http-file-exists-p url))
3579 (gnus-group-fetch-control group))))))
3581 (defun gnus-group-fetch-control (group)
3582 "Fetch the archived control messages for the current group.
3583 If given a prefix argument, prompt for a group."
3585 (list (or (when current-prefix-arg
3586 (completing-read "Group: " gnus-active-hashtb))
3587 (gnus-group-group-name)
3588 gnus-newsgroup-name)))
3590 (error "No group name given"))
3591 (let ((name (gnus-group-real-name group))
3593 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3594 (setq hierarchy (match-string 1 name))
3595 (if gnus-group-fetch-control-use-browse-url
3596 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3597 hierarchy "/" name ".Z"))
3598 (let ((enable-local-variables nil))
3599 (gnus-group-read-ephemeral-group
3601 `(nndoc ,group (nndoc-address
3602 ,(find-file-noselect
3603 (concat "/ftp@ftp.isc.org:/usenet/control/"
3604 hierarchy "/" name ".Z")))
3605 (nndoc-article-type mbox)) t nil nil))))))
3607 (defun gnus-group-describe-group (force &optional group)
3608 "Display a description of the current newsgroup."
3609 (interactive (list current-prefix-arg (gnus-group-group-name)))
3610 (let* ((method (gnus-find-method-for-group group))
3611 (mname (gnus-group-prefixed-name "" method))
3614 gnus-description-hashtb)
3615 (gnus-sethash mname nil gnus-description-hashtb))
3617 (error "No group name given"))
3618 (when (or (and gnus-description-hashtb
3619 ;; We check whether this group's method has been
3620 ;; queried for a description file.
3621 (gnus-gethash mname gnus-description-hashtb))
3622 (setq desc (gnus-group-get-description group))
3623 (gnus-read-descriptions-file method))
3625 (or desc (gnus-gethash group gnus-description-hashtb)
3626 "No description available")))))
3628 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3629 (defun gnus-group-describe-all-groups (&optional force)
3630 "Pop up a buffer with descriptions of all newsgroups."
3633 (setq gnus-description-hashtb nil))
3634 (when (not (or gnus-description-hashtb
3635 (gnus-read-all-descriptions-files)))
3636 (error "Couldn't request descriptions file"))
3637 (let ((buffer-read-only nil)
3643 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3644 (insert (format " *: %-20s %s\n"
3645 (gnus-group-name-decode
3646 (symbol-name group) charset)
3647 (gnus-group-name-decode
3648 (symbol-value group) charset))))
3649 (gnus-add-text-properties
3650 b (1+ b) (list 'gnus-group group
3651 'gnus-unread t 'gnus-marked nil
3652 'gnus-level (1+ gnus-level-subscribed))))
3653 gnus-description-hashtb)
3654 (goto-char (point-min))
3655 (gnus-group-position-point)))
3657 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3658 (defun gnus-group-apropos (regexp &optional search-description)
3659 "List all newsgroups that have names that match a regexp."
3660 (interactive "sGnus apropos (regexp): ")
3662 (obuf (current-buffer))
3664 ;; Go through all newsgroups that are known to Gnus.
3667 (and (symbol-name group)
3668 (string-match regexp (symbol-name group))
3669 (symbol-value group)
3670 (push (symbol-name group) groups)))
3672 ;; Also go through all descriptions that are known to Gnus.
3673 (when search-description
3676 (and (string-match regexp (symbol-value group))
3677 (push (symbol-name group) groups)))
3678 gnus-description-hashtb))
3680 (gnus-message 3 "No groups matched \"%s\"." regexp)
3681 ;; Print out all the groups.
3683 (pop-to-buffer "*Gnus Help*")
3684 (buffer-disable-undo)
3686 (setq groups (sort groups 'string<))
3688 ;; Groups may be entered twice into the list of groups.
3689 (when (not (string= (car groups) prev))
3690 (setq prev (car groups))
3691 (let ((charset (gnus-group-name-charset nil prev)))
3692 (insert (gnus-group-name-decode prev charset) "\n")
3693 (when (and gnus-description-hashtb
3694 (setq des (gnus-gethash (car groups)
3695 gnus-description-hashtb)))
3696 (insert " " (gnus-group-name-decode des charset) "\n"))))
3697 (setq groups (cdr groups)))
3698 (goto-char (point-min))))
3699 (pop-to-buffer obuf)))
3701 (defun gnus-group-description-apropos (regexp)
3702 "List all newsgroups that have names or descriptions that match a regexp."
3703 (interactive "sGnus description apropos (regexp): ")
3704 (when (not (or gnus-description-hashtb
3705 (gnus-read-all-descriptions-files)))
3706 (error "Couldn't request descriptions file"))
3707 (gnus-group-apropos regexp t))
3709 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3710 (defun gnus-group-list-matching (level regexp &optional all lowest)
3711 "List all groups with unread articles that match REGEXP.
3712 If the prefix LEVEL is non-nil, it should be a number that says which
3713 level to cut off listing groups.
3714 If ALL, also list groups with no unread articles.
3715 If LOWEST, don't list groups with level lower than LOWEST.
3717 This command may read the active file."
3718 (interactive "P\nsList newsgroups matching: ")
3719 ;; First make sure active file has been read.
3721 (> (prefix-numeric-value level) gnus-level-killed))
3722 (gnus-get-killed-groups))
3723 (funcall gnus-group-prepare-function
3724 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3725 (goto-char (point-min))
3726 (gnus-group-position-point))
3728 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3729 "List all groups that match REGEXP.
3730 If the prefix LEVEL is non-nil, it should be a number that says which
3731 level to cut off listing groups.
3732 If LOWEST, don't list groups with level lower than LOWEST."
3733 (interactive "P\nsList newsgroups matching: ")
3735 (setq level (prefix-numeric-value level)))
3736 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3738 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3739 (defun gnus-group-save-newsrc (&optional force)
3740 "Save the Gnus startup files.
3741 If FORCE, force saving whether it is necessary or not."
3743 (gnus-save-newsrc-file force))
3745 (defun gnus-group-restart (&optional arg)
3746 "Force Gnus to read the .newsrc file."
3748 (when (gnus-yes-or-no-p
3749 (format "Are you sure you want to restart Gnus? "))
3750 (gnus-save-newsrc-file)
3754 (defun gnus-group-read-init-file ()
3755 "Read the Gnus elisp init file."
3757 (gnus-read-init-file)
3758 (gnus-message 5 "Read %s" gnus-init-file))
3760 (defun gnus-group-check-bogus-groups (&optional silent)
3761 "Check bogus newsgroups.
3762 If given a prefix, don't ask for confirmation before removing a bogus
3765 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3766 (gnus-group-list-groups))
3768 (defun gnus-group-find-new-groups (&optional arg)
3769 "Search for new groups and add them.
3770 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3771 With 1 C-u, use the `ask-server' method to query the server for new
3773 With 2 C-u's, use most complete method possible to query the server
3774 for new groups, and subscribe the new groups as zombies."
3776 (gnus-find-new-newsgroups (or arg 1))
3777 (gnus-group-list-groups))
3779 (defun gnus-group-edit-global-kill (&optional article group)
3780 "Edit the global kill file.
3781 If GROUP, edit that local kill file instead."
3783 (setq gnus-current-kill-article article)
3784 (gnus-kill-file-edit-file group)
3787 (substitute-command-keys
3788 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3789 (if group "local" "global")))))
3791 (defun gnus-group-edit-local-kill (article group)
3792 "Edit a local kill file."
3793 (interactive (list nil (gnus-group-group-name)))
3794 (gnus-group-edit-global-kill article group))
3796 (defun gnus-group-force-update ()
3797 "Update `.newsrc' file."
3799 (gnus-save-newsrc-file))
3801 (defun gnus-group-suspend ()
3802 "Suspend the current Gnus session.
3803 In fact, cleanup buffers except for group mode buffer.
3804 The hook gnus-suspend-gnus-hook is called before actually suspending."
3806 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3807 (gnus-offer-save-summaries)
3808 ;; Kill Gnus buffers except for group mode buffer.
3809 (let ((group-buf (get-buffer gnus-group-buffer)))
3810 (mapcar (lambda (buf)
3811 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3815 (eq major-mode 'message-mode))))
3816 (gnus-kill-buffer buf)))
3818 (gnus-kill-gnus-frames)
3820 (bury-buffer group-buf)
3821 (delete-windows-on group-buf t))))
3823 (defun gnus-group-clear-dribble ()
3824 "Clear all information from the dribble buffer."
3826 (gnus-dribble-clear)
3827 (gnus-message 7 "Cleared dribble buffer"))
3829 (defun gnus-group-exit ()
3830 "Quit reading news after updating .newsrc.eld and .newsrc.
3831 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3834 (or noninteractive ;For gnus-batch-kill
3835 (not gnus-interactive-exit) ;Without confirmation
3837 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3838 (gnus-run-hooks 'gnus-exit-gnus-hook)
3839 ;; Offer to save data from non-quitted summary buffers.
3840 (gnus-offer-save-summaries)
3841 ;; Save the newsrc file(s).
3842 (gnus-save-newsrc-file)
3844 (gnus-close-backends)
3845 ;; Reset everything.
3847 ;; Allow the user to do things after cleaning up.
3848 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3850 (defun gnus-group-quit ()
3851 "Quit reading news without updating .newsrc.eld or .newsrc.
3852 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3854 (when (or noninteractive ;For gnus-batch-kill
3855 (zerop (buffer-size))
3856 (not (gnus-server-opened gnus-select-method))
3858 (not gnus-current-startup-file)
3860 (format "Quit reading news without saving %s? "
3861 (file-name-nondirectory gnus-current-startup-file))))
3862 (gnus-run-hooks 'gnus-exit-gnus-hook)
3863 (gnus-configure-windows 'group t)
3864 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3865 (not (zerop (save-excursion
3866 (set-buffer gnus-dribble-buffer)
3869 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3871 (gnus-close-backends)
3873 (gnus-kill-buffer gnus-group-buffer)
3874 ;; Allow the user to do things after cleaning up.
3875 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3877 (defun gnus-group-describe-briefly ()
3878 "Give a one line description of the group mode commands."
3880 (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")))
3882 (defun gnus-group-browse-foreign-server (method)
3883 "Browse a foreign news server.
3884 If called interactively, this function will ask for a select method
3885 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3886 If not, METHOD should be a list where the first element is the method
3887 and the second element is the address."
3889 (list (let ((how (completing-read
3891 (append gnus-valid-select-methods gnus-server-alist)
3892 nil t (cons "nntp" 0) 'gnus-method-history)))
3893 ;; We either got a backend name or a virtual server name.
3894 ;; If the first, we also need an address.
3895 (if (assoc how gnus-valid-select-methods)
3897 ;; Suggested by mapjph@bath.ac.uk.
3900 (mapcar (lambda (server) (list server))
3901 gnus-secondary-servers)))
3902 ;; We got a server name.
3904 (gnus-browse-foreign-server method))
3906 (defun gnus-group-set-info (info &optional method-only-group part)
3907 (when (or info part)
3908 (let* ((entry (gnus-gethash
3909 (or method-only-group (gnus-info-group info))
3910 gnus-newsrc-hashtb))
3912 (info (if method-only-group (nth 2 entry) info))
3914 (when method-only-group
3916 (error "Trying to change non-existent group %s" method-only-group))
3917 ;; We have received parts of the actual group info - either the
3918 ;; select method or the group parameters. We first check
3919 ;; whether we have to extend the info, and if so, do that.
3920 (let ((len (length info))
3921 (total (if (eq part 'method) 5 6)))
3923 (setcdr (nthcdr (1- len) info)
3924 (make-list (- total len) nil)))
3925 ;; Then we enter the new info.
3926 (setcar (nthcdr (1- total) info) part-info)))
3928 ;; This is a new group, so we just create it.
3930 (set-buffer gnus-group-buffer)
3931 (setq method (gnus-info-method info))
3932 (when (gnus-server-equal method "native")
3935 (set-buffer gnus-group-buffer)
3937 ;; It's a foreign group...
3938 (gnus-group-make-group
3939 (gnus-group-real-name (gnus-info-group info))
3940 (if (stringp method) method
3941 (prin1-to-string (car method)))
3943 (nth 1 (gnus-info-method info))))
3944 ;; It's a native group.
3945 (gnus-group-make-group (gnus-info-group info))))
3946 (gnus-message 6 "Note: New group created")
3948 (gnus-gethash (gnus-group-prefixed-name
3949 (gnus-group-real-name (gnus-info-group info))
3950 (or (gnus-info-method info) gnus-select-method))
3951 gnus-newsrc-hashtb))))
3952 ;; Whether it was a new group or not, we now have the entry, so we
3953 ;; can do the update.
3956 (setcar (nthcdr 2 entry) info)
3957 (when (and (not (eq (car entry) t))
3958 (gnus-active (gnus-info-group info)))
3959 (setcar entry (length
3960 (gnus-list-of-unread-articles (car info))))))
3961 (error "No such group: %s" (gnus-info-group info))))))
3963 (defun gnus-group-set-method-info (group select-method)
3964 (gnus-group-set-info select-method group 'method))
3966 (defun gnus-group-set-params-info (group params)
3967 (gnus-group-set-info params group 'params))
3969 (defun gnus-add-marked-articles (group type articles &optional info force)
3970 ;; Add ARTICLES of TYPE to the info of GROUP.
3971 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3972 ;; add, but replace marked articles of TYPE with ARTICLES.
3973 (let ((info (or info (gnus-get-info group)))
3976 (and (not (setq marked (nthcdr 3 info)))
3978 (setcdr (nthcdr 2 info)
3979 (list (list (cons type (gnus-compress-sequence
3981 (and (not (setq m (assq type (car marked))))
3984 (cons (cons type (gnus-compress-sequence articles t) )
3988 (setcar (nthcdr 3 info)
3989 (gnus-delete-alist type (car marked)))
3990 (setcdr m (gnus-compress-sequence articles t)))
3991 (setcdr m (gnus-compress-sequence
3992 (sort (nconc (gnus-uncompress-range (cdr m))
3993 (copy-sequence articles)) '<) t))))))
3995 (defun gnus-add-mark (group mark article)
3996 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3997 (let ((buffer (gnus-summary-buffer-name group)))
3998 (if (gnus-buffer-live-p buffer)
4000 (set-buffer (get-buffer buffer))
4001 (gnus-summary-add-mark article mark))
4002 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4006 ;;; Group timestamps
4009 (defun gnus-group-set-timestamp ()
4010 "Change the timestamp of the current group to the current time.
4011 This function can be used in hooks like `gnus-select-group-hook'
4012 or `gnus-group-catchup-group-hook'."
4013 (when gnus-newsgroup-name
4014 (let ((time (current-time)))
4015 (setcdr (cdr time) nil)
4016 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4018 (defsubst gnus-group-timestamp (group)
4019 "Return the timestamp for GROUP."
4020 (gnus-group-get-parameter group 'timestamp t))
4022 (defun gnus-group-timestamp-delta (group)
4023 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4024 (let* ((time (or (gnus-group-timestamp group)
4026 (delta (subtract-time (current-time) time)))
4027 (+ (* (nth 0 delta) 65536.0)
4030 (defun gnus-group-timestamp-string (group)
4031 "Return a string of the timestamp for GROUP."
4032 (let ((time (gnus-group-timestamp group)))
4035 (gnus-time-iso8601 time))))
4037 (defun gnus-group-list-cached (level &optional lowest)
4038 "List all groups with cached articles.
4039 If the prefix LEVEL is non-nil, it should be a number that says which
4040 level to cut off listing groups.
4041 If LOWEST, don't list groups with level lower than LOWEST.
4043 This command may read the active file."
4046 (setq level (prefix-numeric-value level)))
4047 (when (or (not level) (>= level gnus-level-zombie))
4049 (funcall gnus-group-prepare-function
4050 (or level gnus-level-subscribed)
4052 (let ((marks (gnus-info-marks info)))
4053 (assq 'cache marks)))
4056 (or (gnus-gethash group
4057 gnus-cache-active-hashtb)
4058 ;; Cache active file might use "."
4061 (mapconcat 'identity
4062 (split-string group ":")
4064 gnus-cache-active-hashtb))))
4065 (goto-char (point-min))
4066 (gnus-group-position-point))
4068 (defun gnus-group-list-dormant (level &optional lowest)
4069 "List all groups with dormant articles.
4070 If the prefix LEVEL is non-nil, it should be a number that says which
4071 level to cut off listing groups.
4072 If LOWEST, don't list groups with level lower than LOWEST.
4074 This command may read the active file."
4077 (setq level (prefix-numeric-value level)))
4078 (when (or (not level) (>= level gnus-level-zombie))
4080 (funcall gnus-group-prepare-function
4081 (or level gnus-level-subscribed)
4083 (let ((marks (gnus-info-marks info)))
4084 (assq 'dormant marks)))
4087 (goto-char (point-min))
4088 (gnus-group-position-point))
4090 (defun gnus-group-listed-groups ()
4091 "Return a list of listed groups."
4093 (goto-char (point-min))
4094 (while (setq point (text-property-not-all (point) (point-max)
4097 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4101 (defun gnus-group-list-plus (&optional args)
4102 "List groups plus the current selection."
4104 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4105 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4107 (push last-command-event unread-command-events)
4108 (if (featurep 'xemacs)
4109 (push (make-event 'key-press '(key ?A)) unread-command-events)
4110 (push ?A unread-command-events))
4111 (let (gnus-pick-mode keys)
4112 (setq keys (if (featurep 'xemacs)
4113 (events-to-keys (read-key-sequence nil))
4114 (read-key-sequence nil)))
4115 (setq func (lookup-key (current-local-map) keys)))
4119 (call-interactively func))))
4121 (defun gnus-group-list-flush (&optional args)
4122 "Flush groups from the current selection."
4124 (let ((gnus-group-list-option 'flush))
4125 (gnus-group-list-plus args)))
4127 (defun gnus-group-list-limit (&optional args)
4128 "List groups limited within the current selection."
4130 (let ((gnus-group-list-option 'limit))
4131 (gnus-group-list-plus args)))
4133 (defun gnus-group-mark-article-read (group article)
4134 "Mark ARTICLE read."
4135 (let ((buffer (gnus-summary-buffer-name group))
4136 (mark gnus-read-mark)
4138 (if (get-buffer buffer)
4139 (with-current-buffer buffer
4140 (setq active gnus-newsgroup-active)
4141 (gnus-activate-group group)
4142 (when gnus-newsgroup-prepared
4143 (when (and gnus-newsgroup-auto-expire
4144 (memq mark gnus-auto-expirable-marks))
4145 (setq mark gnus-expirable-mark))
4146 (setq mark (gnus-request-update-mark
4147 group article mark))
4148 (gnus-mark-article-as-read article mark)
4149 (setq gnus-newsgroup-active (gnus-active group))
4151 (setq n (1+ (cdr active)))
4152 (while (<= n (cdr gnus-newsgroup-active))
4153 (unless (eq n article)
4154 (push n gnus-newsgroup-unselected))
4156 (setq gnus-newsgroup-unselected
4157 (nreverse gnus-newsgroup-unselected)))))
4158 (gnus-activate-group group)
4159 (gnus-group-make-articles-read group (list article))
4160 (when (gnus-group-auto-expirable-p group)
4161 (gnus-add-marked-articles
4162 group 'expire (list article))))))
4164 (provide 'gnus-group)
4166 ;;; gnus-group.el ends here