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 %t Estimated total number of articles (integer)
160 %y Number of unread, unticked articles (integer)
161 %G Group name (string)
162 %g Qualified group name (string)
163 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
164 %C Group comment (string)
165 %D Group description (string)
166 %s Select method (string)
167 %o Moderated group (char, \"m\")
168 %p Process mark (char)
169 %B Whether a summary buffer for the group is open (char, \"*\")
170 %O Moderated group (string, \"(m)\" or \"\")
171 %P Topic indentation (string)
172 %m Whether there is new(ish) mail in the group (char, \"%\")
173 %l Whether there are GroupLens predictions for this group (string)
174 %n Select from where (string)
175 %z A string that look like `<%s:%n>' if a foreign select method is used
176 %d The date the group was last entered.
177 %E Icon as defined by `gnus-group-icon-list'.
178 %u User defined specifier. The next character in the format string should
179 be a letter. Gnus will call the function gnus-user-format-function-X,
180 where X is the letter following %u. The function will be passed a
181 single dummy parameter as argument.. The function should return a
182 string, which will be inserted into the buffer just like information
183 from any other group specifier.
185 Note that this format specification is not always respected. For
186 reasons of efficiency, when listing killed groups, this specification
187 is ignored altogether. If the spec is changed considerably, your
188 output may end up looking strange when listing both alive and killed
191 If you use %o or %O, reading the active file will be slower and quite
192 a bit of extra memory will be used. %D will also worsen performance.
193 Also note that if you change the format specification to include any
194 of these specs, you must probably re-start Gnus to see them go into
197 General format specifiers can also be used.
198 See Info node `(gnus)Formatting Variables'."
199 :link '(custom-manual "(gnus)Formatting Variables")
200 :group 'gnus-group-visual
203 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
204 "*The format specification for the group mode line.
205 It works along the same lines as a normal formatting string,
206 with some simple extensions:
208 %S The native news server.
209 %M The native select method.
210 %: \":\" if %S isn't \"\"."
211 :group 'gnus-group-visual
214 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
215 (when (featurep 'xemacs)
216 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
219 (defcustom gnus-group-menu-hook nil
220 "Hook run after the creation of the group mode menu."
221 :group 'gnus-group-various
224 (defcustom gnus-group-catchup-group-hook nil
225 "Hook run when catching up a group from the group buffer."
226 :group 'gnus-group-various
227 :link '(custom-manual "(gnus)Group Data")
230 (defcustom gnus-group-update-group-hook nil
231 "Hook called when updating group lines."
232 :group 'gnus-group-visual
235 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
236 "*A function that is called to generate the group buffer.
237 The function is called with three arguments: The first is a number;
238 all group with a level less or equal to that number should be listed,
239 if the second is non-nil, empty groups should also be displayed. If
240 the third is non-nil, it is a number. No groups with a level lower
241 than this number should be displayed.
243 The only current function implemented is `gnus-group-prepare-flat'."
244 :group 'gnus-group-listing
247 (defcustom gnus-group-prepare-hook nil
248 "Hook called after the group buffer has been generated.
249 If you want to modify the group buffer, you can use this hook."
250 :group 'gnus-group-listing
253 (defcustom gnus-suspend-gnus-hook nil
254 "Hook called when suspending (not exiting) Gnus."
258 (defcustom gnus-exit-gnus-hook nil
259 "Hook called when exiting Gnus."
263 (defcustom gnus-after-exiting-gnus-hook nil
264 "Hook called after exiting Gnus."
268 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
269 "Hook called when a group line is changed.
270 The hook will not be called if `gnus-visual' is nil.
272 The default function `gnus-group-highlight-line' will
273 highlight the line according to the `gnus-group-highlight'
275 :group 'gnus-group-visual
278 (defcustom gnus-useful-groups
279 '(("(ding) mailing list mirrored at sunsite.auc.dk"
281 (nntp "sunsite.auc.dk"
282 (nntp-address "sunsite.auc.dk")))
285 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
289 (nndoc-article-type mbox)
290 (eval `(nndoc-address
291 ,(let ((file (nnheader-find-etc-directory
294 (error "Couldn't find doc group"))
296 "*Alist of useful group-server pairs."
297 :group 'gnus-group-listing
298 :type '(repeat (list (string :tag "Description")
300 (sexp :tag "Method"))))
302 (defcustom gnus-group-highlight
304 ((and mailp (= unread 0) (eq level 1)) .
305 gnus-group-mail-1-empty-face)
306 ((and mailp (eq level 1)) .
307 gnus-group-mail-1-face)
308 ((and mailp (= unread 0) (eq level 2)) .
309 gnus-group-mail-2-empty-face)
310 ((and mailp (eq level 2)) .
311 gnus-group-mail-2-face)
312 ((and mailp (= unread 0) (eq level 3)) .
313 gnus-group-mail-3-empty-face)
314 ((and mailp (eq level 3)) .
315 gnus-group-mail-3-face)
316 ((and mailp (= unread 0)) .
317 gnus-group-mail-low-empty-face)
319 gnus-group-mail-low-face)
321 ((and (= unread 0) (eq level 1)) .
322 gnus-group-news-1-empty-face)
323 ((and (eq level 1)) .
324 gnus-group-news-1-face)
325 ((and (= unread 0) (eq level 2)) .
326 gnus-group-news-2-empty-face)
327 ((and (eq level 2)) .
328 gnus-group-news-2-face)
329 ((and (= unread 0) (eq level 3)) .
330 gnus-group-news-3-empty-face)
331 ((and (eq level 3)) .
332 gnus-group-news-3-face)
333 ((and (= unread 0) (eq level 4)) .
334 gnus-group-news-4-empty-face)
335 ((and (eq level 4)) .
336 gnus-group-news-4-face)
337 ((and (= unread 0) (eq level 5)) .
338 gnus-group-news-5-empty-face)
339 ((and (eq level 5)) .
340 gnus-group-news-5-face)
341 ((and (= unread 0) (eq level 6)) .
342 gnus-group-news-6-empty-face)
343 ((and (eq level 6)) .
344 gnus-group-news-6-face)
345 ((and (= unread 0)) .
346 gnus-group-news-low-empty-face)
348 gnus-group-news-low-face))
349 "*Controls the highlighting of group buffer lines.
351 Below is a list of `Form'/`Face' pairs. When deciding how a a
352 particular group line should be displayed, each form is
353 evaluated. The content of the face field after the first true form is
354 used. You can change how those group lines are displayed by
355 editing the face field.
357 It is also possible to change and add form fields, but currently that
358 requires an understanding of Lisp expressions. Hopefully this will
359 change in a future release. For now, you can use the following
360 variables in the Lisp expression:
362 group: The name of the group.
363 unread: The number of unread articles in the group.
364 method: The select method used.
365 mailp: Whether it's a mail group or not.
366 level: The level of the group.
367 score: The score of the group.
368 ticked: The number of ticked articles."
369 :group 'gnus-group-visual
370 :type '(repeat (cons (sexp :tag "Form") face)))
372 (defcustom gnus-new-mail-mark ?%
373 "Mark used for groups with new mail."
374 :group 'gnus-group-visual
377 (defgroup gnus-group-icons nil
378 "Add Icons to your group buffer. "
379 :group 'gnus-group-visual)
381 (defcustom gnus-group-icon-list
383 "*Controls the insertion of icons into group buffer lines.
385 Below is a list of `Form'/`File' pairs. When deciding how a
386 particular group line should be displayed, each form is evaluated.
387 The icon from the file field after the first true form is used. You
388 can change how those group lines are displayed by editing the file
389 field. The File will either be found in the
390 `gnus-group-glyph-directory' or by designating absolute path to the
393 It is also possible to change and add form fields, but currently that
394 requires an understanding of Lisp expressions. Hopefully this will
395 change in a future release. For now, you can use the following
396 variables in the Lisp expression:
398 group: The name of the group.
399 unread: The number of unread articles in the group.
400 method: The select method used.
401 mailp: Whether it's a mail group or not.
402 newsp: Whether it's a news group or not
403 level: The level of the group.
404 score: The score of the group.
405 ticked: The number of ticked articles."
406 :group 'gnus-group-icons
407 :type '(repeat (cons (sexp :tag "Form") file)))
409 (defcustom gnus-group-name-charset-method-alist nil
410 "Alist of method and the charset for group names.
413 (((nntp \"news.com.cn\") . cn-gb-2312))"
416 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
418 (defcustom gnus-group-name-charset-group-alist
419 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
420 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
423 "Alist of group regexp and the charset for group names.
426 ((\"\\.com\\.cn:\" . cn-gb-2312))"
428 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
430 (defcustom gnus-group-jump-to-group-prompt nil
431 "Default prompt for `gnus-group-jump-to-group'.
432 If non-nil, the value should be a string, e.g. \"nnml:\",
433 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
434 in the minibuffer prompt."
435 :group 'gnus-group-various
436 :type '(choice (string :tag "Prompt string")
437 (const :tag "Empty" nil)))
439 (defvar gnus-group-listing-limit 1000
440 "*A limit of the number of groups when listing.
441 If the number of groups is larger than the limit, list them in a
444 ;;; Internal variables
446 (defvar gnus-group-is-exiting-p nil)
447 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
448 "Function for sorting the group buffer.")
450 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
451 "Function for sorting the selected groups in the group buffer.")
453 (defvar gnus-group-indentation-function nil)
454 (defvar gnus-goto-missing-group-function nil)
455 (defvar gnus-group-update-group-function nil)
456 (defvar gnus-group-goto-next-group-function nil
457 "Function to override finding the next group after listing groups.")
459 (defvar gnus-group-edit-buffer nil)
461 (defvar gnus-group-line-format-alist
462 `((?M gnus-tmp-marked-mark ?c)
463 (?S gnus-tmp-subscribed ?c)
464 (?L gnus-tmp-level ?d)
465 (?N (cond ((eq number t) "*" )
469 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
470 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
472 (?R gnus-tmp-number-of-read ?s)
473 (?t gnus-tmp-number-total ?d)
474 (?y gnus-tmp-number-of-unread ?s)
475 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
476 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
477 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
478 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
479 (?g gnus-tmp-group ?s)
480 (?G gnus-tmp-qualified-group ?s)
481 (?c (gnus-short-group-name gnus-tmp-group) ?s)
482 (?C gnus-tmp-comment ?s)
483 (?D gnus-tmp-newsgroup-description ?s)
484 (?o gnus-tmp-moderated ?c)
485 (?O gnus-tmp-moderated-string ?s)
486 (?p gnus-tmp-process-marked ?c)
487 (?s gnus-tmp-news-server ?s)
488 (?n gnus-tmp-news-method ?s)
489 (?P gnus-group-indentation ?s)
490 (?E gnus-tmp-group-icon ?s)
491 (?B gnus-tmp-summary-live ?c)
492 (?l gnus-tmp-grouplens ?s)
493 (?z gnus-tmp-news-method-string ?s)
494 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
495 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
496 (?u gnus-tmp-user-defined ?s)))
498 (defvar gnus-group-mode-line-format-alist
499 `((?S gnus-tmp-news-server ?s)
500 (?M gnus-tmp-news-method ?s)
501 (?u gnus-tmp-user-defined ?s)
502 (?: gnus-tmp-colon ?s)))
504 (defvar gnus-topic-topology nil
505 "The complete topic hierarchy.")
507 (defvar gnus-topic-alist nil
508 "The complete topic-group alist.")
510 (defvar gnus-group-marked nil)
512 (defvar gnus-group-list-mode nil)
515 (defvar gnus-group-icon-cache nil)
517 (defvar gnus-group-listed-groups nil)
518 (defvar gnus-group-list-option nil)
524 (put 'gnus-group-mode 'mode-class 'special)
527 (gnus-define-keys gnus-group-mode-map
528 " " gnus-group-read-group
529 "=" gnus-group-select-group
530 "\r" gnus-group-select-group
531 "\M-\r" gnus-group-quick-select-group
532 "\M- " gnus-group-visible-select-group
533 [(meta control return)] gnus-group-select-group-ephemerally
534 "j" gnus-group-jump-to-group
535 "n" gnus-group-next-unread-group
536 "p" gnus-group-prev-unread-group
537 "\177" gnus-group-prev-unread-group
538 [delete] gnus-group-prev-unread-group
539 [backspace] gnus-group-prev-unread-group
540 "N" gnus-group-next-group
541 "P" gnus-group-prev-group
542 "\M-n" gnus-group-next-unread-group-same-level
543 "\M-p" gnus-group-prev-unread-group-same-level
544 "," gnus-group-best-unread-group
545 "." gnus-group-first-unread-group
546 "u" gnus-group-unsubscribe-current-group
547 "U" gnus-group-unsubscribe-group
548 "c" gnus-group-catchup-current
549 "C" gnus-group-catchup-current-all
550 "\M-c" gnus-group-clear-data
551 "l" gnus-group-list-groups
552 "L" gnus-group-list-all-groups
555 "g" gnus-group-get-new-news
556 "\M-g" gnus-group-get-new-news-this-group
557 "R" gnus-group-restart
558 "r" gnus-group-read-init-file
559 "B" gnus-group-browse-foreign-server
560 "b" gnus-group-check-bogus-groups
561 "F" gnus-group-find-new-groups
562 "\C-c\C-d" gnus-group-describe-group
563 "\M-d" gnus-group-describe-all-groups
564 "\C-c\C-a" gnus-group-apropos
565 "\C-c\M-\C-a" gnus-group-description-apropos
566 "a" gnus-group-post-news
567 "\ek" gnus-group-edit-local-kill
568 "\eK" gnus-group-edit-global-kill
569 "\C-k" gnus-group-kill-group
570 "\C-y" gnus-group-yank-group
571 "\C-w" gnus-group-kill-region
572 "\C-x\C-t" gnus-group-transpose-groups
573 "\C-c\C-l" gnus-group-list-killed
574 "\C-c\C-x" gnus-group-expire-articles
575 "\C-c\M-\C-x" gnus-group-expire-all-groups
577 "s" gnus-group-save-newsrc
578 "z" gnus-group-suspend
581 "?" gnus-group-describe-briefly
582 "\C-c\C-i" gnus-info-find-node
583 "\M-e" gnus-group-edit-group-method
584 "^" gnus-group-enter-server-mode
585 gnus-mouse-2 gnus-mouse-pick-group
586 "<" beginning-of-buffer
589 "\C-c\C-s" gnus-group-sort-groups
591 "\C-c\M-g" gnus-activate-all-groups
592 "\M-&" gnus-group-universal-argument
593 "#" gnus-group-mark-group
594 "\M-#" gnus-group-unmark-group)
596 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
597 "m" gnus-group-mark-group
598 "u" gnus-group-unmark-group
599 "w" gnus-group-mark-region
600 "b" gnus-group-mark-buffer
601 "r" gnus-group-mark-regexp
602 "U" gnus-group-unmark-all-groups)
604 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
605 "u" gnus-sieve-update
606 "g" gnus-sieve-generate)
608 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
609 "d" gnus-group-make-directory-group
610 "h" gnus-group-make-help-group
611 "u" gnus-group-make-useful-group
612 "a" gnus-group-make-archive-group
613 "k" gnus-group-make-kiboze-group
614 "l" gnus-group-nnimap-edit-acl
615 "m" gnus-group-make-group
616 "E" gnus-group-edit-group
617 "e" gnus-group-edit-group-method
618 "p" gnus-group-edit-group-parameters
619 "v" gnus-group-add-to-virtual
620 "V" gnus-group-make-empty-virtual
621 "D" gnus-group-enter-directory
622 "f" gnus-group-make-doc-group
623 "w" gnus-group-make-web-group
624 "r" gnus-group-rename-group
625 "c" gnus-group-customize
626 "x" gnus-group-nnimap-expunge
627 "\177" gnus-group-delete-group
628 [delete] gnus-group-delete-group)
630 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
631 "b" gnus-group-brew-soup
632 "w" gnus-soup-save-areas
633 "s" gnus-soup-send-replies
634 "p" gnus-soup-pack-packet
635 "r" nnsoup-pack-replies)
637 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
638 "s" gnus-group-sort-groups
639 "a" gnus-group-sort-groups-by-alphabet
640 "u" gnus-group-sort-groups-by-unread
641 "l" gnus-group-sort-groups-by-level
642 "v" gnus-group-sort-groups-by-score
643 "r" gnus-group-sort-groups-by-rank
644 "m" gnus-group-sort-groups-by-method
645 "n" gnus-group-sort-groups-by-real-name)
647 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
648 "s" gnus-group-sort-selected-groups
649 "a" gnus-group-sort-selected-groups-by-alphabet
650 "u" gnus-group-sort-selected-groups-by-unread
651 "l" gnus-group-sort-selected-groups-by-level
652 "v" gnus-group-sort-selected-groups-by-score
653 "r" gnus-group-sort-selected-groups-by-rank
654 "m" gnus-group-sort-selected-groups-by-method
655 "n" gnus-group-sort-selected-groups-by-real-name)
657 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
658 "k" gnus-group-list-killed
659 "z" gnus-group-list-zombies
660 "s" gnus-group-list-groups
661 "u" gnus-group-list-all-groups
662 "A" gnus-group-list-active
663 "a" gnus-group-apropos
664 "d" gnus-group-description-apropos
665 "m" gnus-group-list-matching
666 "M" gnus-group-list-all-matching
667 "l" gnus-group-list-level
668 "c" gnus-group-list-cached
669 "?" gnus-group-list-dormant)
671 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
672 "k" gnus-group-list-limit
673 "z" gnus-group-list-limit
674 "s" gnus-group-list-limit
675 "u" gnus-group-list-limit
676 "A" gnus-group-list-limit
677 "m" gnus-group-list-limit
678 "M" gnus-group-list-limit
679 "l" gnus-group-list-limit
680 "c" gnus-group-list-limit
681 "?" gnus-group-list-limit)
683 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
684 "k" gnus-group-list-flush
685 "z" gnus-group-list-flush
686 "s" gnus-group-list-flush
687 "u" gnus-group-list-flush
688 "A" gnus-group-list-flush
689 "m" gnus-group-list-flush
690 "M" gnus-group-list-flush
691 "l" gnus-group-list-flush
692 "c" gnus-group-list-flush
693 "?" gnus-group-list-flush)
695 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
696 "k" gnus-group-list-plus
697 "z" gnus-group-list-plus
698 "s" gnus-group-list-plus
699 "u" gnus-group-list-plus
700 "A" gnus-group-list-plus
701 "m" gnus-group-list-plus
702 "M" gnus-group-list-plus
703 "l" gnus-group-list-plus
704 "c" gnus-group-list-plus
705 "?" gnus-group-list-plus)
707 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
708 "f" gnus-score-flush-cache)
710 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
711 "c" gnus-group-fetch-charter
712 "C" gnus-group-fetch-control
713 "d" gnus-group-describe-group
714 "f" gnus-group-fetch-faq
717 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
718 "l" gnus-group-set-current-level
719 "t" gnus-group-unsubscribe-current-group
720 "s" gnus-group-unsubscribe-group
721 "k" gnus-group-kill-group
722 "y" gnus-group-yank-group
723 "w" gnus-group-kill-region
724 "\C-k" gnus-group-kill-level
725 "z" gnus-group-kill-all-zombies))
727 (defun gnus-group-make-menu-bar ()
728 (gnus-turn-off-edit-menu 'group)
729 (unless (boundp 'gnus-group-reading-menu)
732 gnus-group-reading-menu gnus-group-mode-map ""
734 ["Read" gnus-group-read-group (gnus-group-group-name)]
735 ["Select" gnus-group-select-group (gnus-group-group-name)]
736 ["See old articles" (gnus-group-select-group 'all)
737 :keys "C-u SPC" :active (gnus-group-group-name)]
738 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
739 ,@(if (featurep 'xemacs) nil
740 '(:help "Mark unread articles in the current group as read"))]
741 ["Catch up all articles" gnus-group-catchup-current-all
742 (gnus-group-group-name)]
743 ["Check for new articles" gnus-group-get-new-news-this-group
744 :active (gnus-group-group-name)
745 ,@(if (featurep 'xemacs) nil
746 '(:help "Check for new messages in current group"))]
747 ["Toggle subscription" gnus-group-unsubscribe-current-group
748 (gnus-group-group-name)]
749 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
750 ,@(if (featurep 'xemacs) nil
751 '(:help "Kill (remove) current group"))]
752 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
753 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
754 ,@(if (featurep 'xemacs) nil
755 '(:help "Display description of the current group"))]
756 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
757 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
758 ,@(if (featurep 'xemacs) nil
759 '(:help "Display the charter of the current group"))]
760 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
761 ,@(if (featurep 'xemacs) nil
762 '(:help "Display the archived control message for the current group"))]
763 ;; Actually one should check, if any of the marked groups gives t for
764 ;; (gnus-check-backend-function 'request-expire-articles ...)
765 ["Expire articles" gnus-group-expire-articles
766 (or (and (gnus-group-group-name)
767 (gnus-check-backend-function
768 'request-expire-articles
769 (gnus-group-group-name))) gnus-group-marked)]
770 ["Set group level..." gnus-group-set-current-level
771 (gnus-group-group-name)]
772 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
773 ["Customize" gnus-group-customize (gnus-group-group-name)]
775 ["Parameters" gnus-group-edit-group-parameters
776 (gnus-group-group-name)]
777 ["Select method" gnus-group-edit-group-method
778 (gnus-group-group-name)]
779 ["Info" gnus-group-edit-group (gnus-group-group-name)]
780 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
781 ["Global kill file" gnus-group-edit-global-kill t])))
784 gnus-group-group-menu gnus-group-mode-map ""
787 ["List unread subscribed groups" gnus-group-list-groups t]
788 ["List (un)subscribed groups" gnus-group-list-all-groups t]
789 ["List killed groups" gnus-group-list-killed gnus-killed-list]
790 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
791 ["List level..." gnus-group-list-level t]
792 ["Describe all groups" gnus-group-describe-all-groups t]
793 ["Group apropos..." gnus-group-apropos t]
794 ["Group and description apropos..." gnus-group-description-apropos t]
795 ["List groups matching..." gnus-group-list-matching t]
796 ["List all groups matching..." gnus-group-list-all-matching t]
797 ["List active file" gnus-group-list-active t]
798 ["List groups with cached" gnus-group-list-cached t]
799 ["List groups with dormant" gnus-group-list-dormant t])
801 ["Default sort" gnus-group-sort-groups t]
802 ["Sort by method" gnus-group-sort-groups-by-method t]
803 ["Sort by rank" gnus-group-sort-groups-by-rank t]
804 ["Sort by score" gnus-group-sort-groups-by-score t]
805 ["Sort by level" gnus-group-sort-groups-by-level t]
806 ["Sort by unread" gnus-group-sort-groups-by-unread t]
807 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
808 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
809 ("Sort process/prefixed"
810 ["Default sort" gnus-group-sort-selected-groups
811 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
812 ["Sort by method" gnus-group-sort-selected-groups-by-method
813 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
814 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
815 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
816 ["Sort by score" gnus-group-sort-selected-groups-by-score
817 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
818 ["Sort by level" gnus-group-sort-selected-groups-by-level
819 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
820 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
821 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
822 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
823 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
824 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
825 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
827 ["Mark group" gnus-group-mark-group
828 (and (gnus-group-group-name)
829 (not (memq (gnus-group-group-name) gnus-group-marked)))]
830 ["Unmark group" gnus-group-unmark-group
831 (and (gnus-group-group-name)
832 (memq (gnus-group-group-name) gnus-group-marked))]
833 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
834 ["Mark regexp..." gnus-group-mark-regexp t]
835 ["Mark region" gnus-group-mark-region t]
836 ["Mark buffer" gnus-group-mark-buffer t]
837 ["Execute command" gnus-group-universal-argument
838 (or gnus-group-marked (gnus-group-group-name))])
840 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
841 ["Kill all newsgroups in region" gnus-group-kill-region t]
842 ["Kill all zombie groups" gnus-group-kill-all-zombies
844 ["Kill all groups on level..." gnus-group-kill-level t])
846 ["Make a foreign group..." gnus-group-make-group t]
847 ["Add a directory group..." gnus-group-make-directory-group t]
848 ["Add the help group" gnus-group-make-help-group t]
849 ["Add the archive group" gnus-group-make-archive-group t]
850 ["Make a doc group..." gnus-group-make-doc-group t]
851 ["Make a web group..." gnus-group-make-web-group t]
852 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
853 ["Make a virtual group..." gnus-group-make-empty-virtual t]
854 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
855 ["Rename group..." gnus-group-rename-group
856 (gnus-check-backend-function
857 'request-rename-group (gnus-group-group-name))]
858 ["Delete group" gnus-group-delete-group
859 (gnus-check-backend-function
860 'request-delete-group (gnus-group-group-name))])
862 ["Next" gnus-group-next-group t]
863 ["Previous" gnus-group-prev-group t]
864 ["Next unread" gnus-group-next-unread-group t]
865 ["Previous unread" gnus-group-prev-unread-group t]
866 ["Next unread same level" gnus-group-next-unread-group-same-level t]
867 ["Previous unread same level"
868 gnus-group-prev-unread-group-same-level t]
869 ["Jump to group..." gnus-group-jump-to-group t]
870 ["First unread group" gnus-group-first-unread-group t]
871 ["Best unread group" gnus-group-best-unread-group t])
873 ["Generate" gnus-sieve-generate t]
874 ["Generate and update" gnus-sieve-update t])
875 ["Delete bogus groups" gnus-group-check-bogus-groups t]
876 ["Find new newsgroups" gnus-group-find-new-groups t]
877 ["Transpose" gnus-group-transpose-groups
878 (gnus-group-group-name)]
879 ["Read a directory as a group..." gnus-group-enter-directory t]))
882 gnus-group-misc-menu gnus-group-mode-map ""
885 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
886 ["Send replies" gnus-soup-send-replies
887 (fboundp 'gnus-soup-pack-packet)]
888 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
889 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
890 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
891 ["Send a mail" gnus-group-mail t]
892 ["Send a message (mail or news)" gnus-group-post-news t]
893 ["Create a local message" gnus-group-news t]
894 ["Check for new news" gnus-group-get-new-news
895 ,@(if (featurep 'xemacs) '(t)
896 '(:help "Get newly arrived articles"))
898 ["Send queued messages" gnus-delay-send-queue
899 ,@(if (featurep 'xemacs) '(t)
900 '(:help "Send all messages that are scheduled to be sent now"))
902 ["Activate all groups" gnus-activate-all-groups t]
903 ["Restart Gnus" gnus-group-restart t]
904 ["Read init file" gnus-group-read-init-file t]
905 ["Browse foreign server..." gnus-group-browse-foreign-server t]
906 ["Enter server buffer" gnus-group-enter-server-mode t]
907 ["Expire all expirable articles" gnus-group-expire-all-groups t]
908 ["Generate any kiboze groups" nnkiboze-generate-groups t]
909 ["Gnus version" gnus-version t]
910 ["Save .newsrc files" gnus-group-save-newsrc t]
911 ["Suspend Gnus" gnus-group-suspend t]
912 ["Clear dribble buffer" gnus-group-clear-dribble t]
913 ["Read manual" gnus-info-find-node t]
914 ["Flush score cache" gnus-score-flush-cache t]
915 ["Toggle topics" gnus-topic-mode t]
916 ["Send a bug report" gnus-bug t]
917 ["Exit from Gnus" gnus-group-exit
918 ,@(if (featurep 'xemacs) '(t)
919 '(:help "Quit reading news"))]
920 ["Exit without saving" gnus-group-quit t]))
922 (gnus-run-hooks 'gnus-group-menu-hook)))
924 (defvar gnus-group-toolbar-map nil)
926 ;; Emacs 21 tool bar. Should be no-op otherwise.
927 (defun gnus-group-make-tool-bar ()
929 (condition-case nil (require 'tool-bar) (error nil))
930 (fboundp 'tool-bar-add-item-from-menu)
931 (default-value 'tool-bar-mode)
932 (not gnus-group-toolbar-map))
933 (setq gnus-group-toolbar-map
934 (let ((tool-bar-map (make-sparse-keymap))
935 (load-path (mm-image-load-path)))
936 (tool-bar-add-item-from-menu
937 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
938 (tool-bar-add-item-from-menu
939 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
940 (tool-bar-add-item-from-menu
941 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
942 (tool-bar-add-item-from-menu
943 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
944 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
945 :help "Subscribe to the current group")
946 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
948 :help "Unsubscribe from the current group")
949 (tool-bar-add-item-from-menu
950 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
952 (if gnus-group-toolbar-map
953 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
955 (defun gnus-group-mode ()
956 "Major mode for reading news.
958 All normal editing commands are switched off.
959 \\<gnus-group-mode-map>
960 The group buffer lists (some of) the groups available. For instance,
961 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
962 lists all zombie groups.
964 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
965 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
967 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
969 The following commands are available:
971 \\{gnus-group-mode-map}"
973 (kill-all-local-variables)
974 (when (gnus-visual-p 'group-menu 'menu)
975 (gnus-group-make-menu-bar)
976 (gnus-group-make-tool-bar))
977 (gnus-simplify-mode-line)
978 (setq major-mode 'gnus-group-mode)
979 (setq mode-name "Group")
980 (gnus-group-set-mode-line)
981 (setq mode-line-process nil)
982 (use-local-map gnus-group-mode-map)
983 (buffer-disable-undo)
984 (setq truncate-lines t)
985 (setq buffer-read-only t)
986 (gnus-set-default-directory)
987 (gnus-update-format-specifications nil 'group 'group-mode)
988 (gnus-update-group-mark-positions)
993 (gnus-run-hooks 'gnus-group-mode-hook))
995 (defun gnus-update-group-mark-positions ()
997 (let ((gnus-process-mark ?\200)
998 (gnus-group-update-hook nil)
999 (gnus-group-marked '("dummy.group"))
1000 (gnus-active-hashtb (make-vector 10 0))
1002 (gnus-set-active "dummy.group" '(0 . 0))
1003 (gnus-set-work-buffer)
1004 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1005 (goto-char (point-min))
1006 (setq gnus-group-mark-positions
1007 (list (cons 'process (and (search-forward "\200" nil t)
1008 (- (point) 2))))))))
1010 (defun gnus-mouse-pick-group (e)
1011 "Enter the group under the mouse pointer."
1014 (gnus-group-read-group nil))
1016 ;; Look at LEVEL and find out what the level is really supposed to be.
1017 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1018 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1019 (defun gnus-group-default-level (&optional level number-or-nil)
1021 (gnus-group-use-permanent-levels
1022 (or (setq gnus-group-use-permanent-levels
1023 (or level (if (numberp gnus-group-use-permanent-levels)
1024 gnus-group-use-permanent-levels
1025 (or gnus-group-default-list-level
1026 gnus-level-subscribed))))
1027 gnus-group-default-list-level gnus-level-subscribed))
1031 (or level gnus-group-default-list-level gnus-level-subscribed))))
1033 (defun gnus-group-setup-buffer ()
1034 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1035 (unless (eq major-mode 'gnus-group-mode)
1038 (gnus-carpal-setup-buffer 'group))))
1040 (defun gnus-group-name-charset (method group)
1042 (setq method (gnus-find-method-for-group group)))
1043 (let ((item (assoc method gnus-group-name-charset-method-alist))
1044 (alist gnus-group-name-charset-group-alist)
1048 (while (setq item (pop alist))
1049 (if (string-match (car item) group)
1051 result (cdr item))))
1054 (defun gnus-group-name-decode (string charset)
1055 (if (and string charset (featurep 'mule))
1056 (mm-decode-coding-string string charset)
1059 (defun gnus-group-decoded-name (string)
1060 (let ((charset (gnus-group-name-charset nil string)))
1061 (gnus-group-name-decode string charset)))
1063 (defun gnus-group-list-groups (&optional level unread lowest)
1064 "List newsgroups with level LEVEL or lower that have unread articles.
1065 Default is all subscribed groups.
1066 If argument UNREAD is non-nil, groups with no unread articles are also
1069 Also see the `gnus-group-use-permanent-levels' variable."
1071 (list (if current-prefix-arg
1072 (prefix-numeric-value current-prefix-arg)
1074 (gnus-group-default-level nil t)
1075 gnus-group-default-list-level
1076 gnus-level-subscribed))))
1078 (setq level (car gnus-group-list-mode)
1079 unread (cdr gnus-group-list-mode)))
1080 (setq level (gnus-group-default-level level))
1081 (gnus-group-setup-buffer)
1082 (gnus-update-format-specifications nil 'group 'group-mode)
1083 (let ((case-fold-search nil)
1084 (props (text-properties-at (gnus-point-at-bol)))
1085 (empty (= (point-min) (point-max)))
1086 (group (gnus-group-group-name))
1088 (set-buffer gnus-group-buffer)
1089 (setq number (funcall gnus-group-prepare-function level unread lowest))
1090 (when (or (and (numberp number)
1092 (zerop (buffer-size)))
1093 ;; No groups in the buffer.
1094 (gnus-message 5 gnus-no-groups-message))
1095 ;; We have some groups displayed.
1096 (goto-char (point-max))
1097 (when (or (not gnus-group-goto-next-group-function)
1098 (not (funcall gnus-group-goto-next-group-function
1102 (goto-char (point-min)))
1104 ;; Go to the first group with unread articles.
1105 (gnus-group-search-forward t))
1107 ;; Find the right group to put point on. If the current group
1108 ;; has disappeared in the new listing, try to find the next
1109 ;; one. If no next one can be found, just leave point at the
1110 ;; first newsgroup in the buffer.
1111 (when (not (gnus-goto-char
1113 (point-min) (point-max)
1114 'gnus-group (gnus-intern-safe
1115 group gnus-active-hashtb))))
1116 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1118 (not (gnus-goto-char
1120 (point-min) (point-max) 'gnus-group
1122 (caar newsrc) gnus-active-hashtb)))))
1123 (setq newsrc (cdr newsrc)))
1125 (goto-char (point-max))
1126 (forward-line -1)))))))
1127 ;; Adjust cursor point.
1128 (gnus-group-position-point)))
1130 (defun gnus-group-list-level (level &optional all)
1131 "List groups on LEVEL.
1132 If ALL (the prefix), also list groups that have no unread articles."
1133 (interactive "nList groups on level: \nP")
1134 (gnus-group-list-groups level all level))
1136 (defun gnus-group-prepare-logic (group test)
1137 (or (and gnus-group-listed-groups
1138 (null gnus-group-list-option)
1139 (member group gnus-group-listed-groups))
1141 ((null gnus-group-listed-groups) test)
1142 ((null gnus-group-list-option) test)
1143 (t (and (member group gnus-group-listed-groups)
1144 (if (eq gnus-group-list-option 'flush)
1148 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1149 "List all newsgroups with unread articles of level LEVEL or lower.
1150 If PREDICATE is a function, list groups that the function returns non-nil;
1151 if it is t, list groups that have no unread articles.
1152 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1153 If REGEXP is a function, list dead groups that the function returns non-nil;
1154 if it is a string, only list groups matching REGEXP."
1155 (set-buffer gnus-group-buffer)
1156 (let ((buffer-read-only nil)
1157 (newsrc (cdr gnus-newsrc-alist))
1158 (lowest (or lowest 1))
1159 (not-in-list (and gnus-group-listed-groups
1160 (copy-sequence gnus-group-listed-groups)))
1161 info clevel unread group params)
1163 (when (or (< lowest gnus-level-zombie)
1164 gnus-group-listed-groups)
1165 ;; List living groups.
1167 (setq info (car newsrc)
1168 group (gnus-info-group info)
1169 params (gnus-info-params info)
1171 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1173 (setq not-in-list (delete group not-in-list)))
1174 (when (gnus-group-prepare-logic
1176 (and unread ; This group might be unchecked
1177 (or (not (stringp regexp))
1178 (string-match regexp group))
1179 (<= (setq clevel (gnus-info-level info)) level)
1182 ((functionp predicate)
1183 (funcall predicate info))
1184 (predicate t) ; We list all groups?
1187 (if (eq unread t) ; Unactivated?
1188 gnus-group-list-inactive-groups
1189 ; We list unactivated
1191 ; We list groups with unread articles
1192 (and gnus-list-groups-with-ticked-articles
1193 (cdr (assq 'tick (gnus-info-marks info))))
1194 ; And groups with tickeds
1195 ;; Check for permanent visibility.
1196 (and gnus-permanently-visible-groups
1197 (string-match gnus-permanently-visible-groups
1199 (memq 'visible params)
1200 (cdr (assq 'visible params)))))))
1201 (gnus-group-insert-group-line
1202 group (gnus-info-level info)
1203 (gnus-info-marks info) unread (gnus-info-method info)))))
1205 ;; List dead groups.
1206 (when (or gnus-group-listed-groups
1207 (and (>= level gnus-level-zombie)
1208 (<= lowest gnus-level-zombie)))
1209 (gnus-group-prepare-flat-list-dead
1210 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1211 gnus-level-zombie ?Z
1214 (dolist (group gnus-zombie-list)
1215 (setq not-in-list (delete group not-in-list))))
1216 (when (or gnus-group-listed-groups
1217 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1218 (gnus-group-prepare-flat-list-dead
1221 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1222 gnus-level-killed ?K regexp))
1224 (gnus-group-set-mode-line)
1225 (setq gnus-group-list-mode (cons level predicate))
1226 (gnus-run-hooks 'gnus-group-prepare-hook)
1229 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1230 ;; List zombies and killed lists somewhat faster, which was
1231 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1232 ;; this by ignoring the group format specification altogether.
1234 (if (> (length groups) gnus-group-listing-limit)
1236 (setq group (pop groups))
1237 (when (gnus-group-prepare-logic
1240 (and (stringp regexp) (string-match regexp group))
1241 (and (functionp regexp) (funcall regexp group))))
1242 (gnus-add-text-properties
1243 (point) (prog1 (1+ (point))
1244 (insert " " mark " *: "
1245 (gnus-group-decoded-name group)
1247 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1249 'gnus-level level))))
1251 (setq group (pop groups))
1252 (when (gnus-group-prepare-logic
1255 (and (stringp regexp) (string-match regexp group))
1256 (and (functionp regexp) (funcall regexp group))))
1257 (gnus-group-insert-group-line
1259 (let ((active (gnus-active group)))
1261 (if (zerop (cdr active))
1263 (- (1+ (cdr active)) (car active)))
1265 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1267 (defun gnus-group-update-group-line ()
1268 "Update the current line in the group buffer."
1269 (let* ((buffer-read-only nil)
1270 (group (gnus-group-group-name))
1271 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1272 gnus-group-indentation)
1275 (not (gnus-ephemeral-group-p group))
1277 (concat "(gnus-group-set-info '"
1278 (gnus-prin1-to-string (nth 2 entry))
1280 (setq gnus-group-indentation (gnus-group-group-indentation))
1282 (gnus-group-insert-group-line-info group)
1284 (gnus-group-position-point))))
1286 (defun gnus-group-insert-group-line-info (group)
1287 "Insert GROUP on the current line."
1288 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1289 (gnus-group-indentation (gnus-group-group-indentation))
1293 ;; (Un)subscribed group.
1294 (setq info (nth 2 entry))
1295 (gnus-group-insert-group-line
1296 group (gnus-info-level info) (gnus-info-marks info)
1297 (or (car entry) t) (gnus-info-method info)))
1298 ;; This group is dead.
1299 (gnus-group-insert-group-line
1301 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1303 (if (setq active (gnus-active group))
1304 (if (zerop (cdr active))
1306 (- (1+ (cdr active)) (car active)))
1308 (gnus-method-simplify (gnus-find-method-for-group group))))))
1310 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1311 gnus-tmp-marked number
1313 "Insert a group line in the group buffer."
1314 (let* ((gnus-tmp-method
1315 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1316 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1318 (gnus-tmp-active (gnus-active gnus-tmp-group))
1319 (gnus-tmp-number-total
1321 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1323 (gnus-tmp-number-of-unread
1324 (if (numberp number) (int-to-string (max 0 number))
1326 (gnus-tmp-number-of-read
1327 (if (numberp number)
1328 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1330 (gnus-tmp-subscribed
1331 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1332 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1333 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1335 (gnus-tmp-qualified-group
1336 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1337 group-name-charset))
1339 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1341 (gnus-tmp-newsgroup-description
1342 (if gnus-description-hashtb
1343 (or (gnus-group-name-decode
1344 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1345 group-name-charset) "")
1348 (if (and gnus-moderated-hashtb
1349 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1351 (gnus-tmp-moderated-string
1352 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1353 (gnus-tmp-group-icon "==&&==")
1354 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1355 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1356 (gnus-tmp-news-method-string
1358 (format "(%s:%s)" (car gnus-tmp-method)
1359 (cadr gnus-tmp-method)) ""))
1360 (gnus-tmp-marked-mark
1361 (if (and (numberp number)
1363 (cdr (assq 'tick gnus-tmp-marked)))
1365 (gnus-tmp-summary-live
1366 (if (and (not gnus-group-is-exiting-p)
1367 (gnus-buffer-live-p (gnus-summary-buffer-name
1370 (gnus-tmp-process-marked
1371 (if (member gnus-tmp-group gnus-group-marked)
1372 gnus-process-mark ? ))
1374 (or (and gnus-use-grouplens
1375 (bbb-grouplens-group-p gnus-tmp-group))
1377 (buffer-read-only nil)
1378 header gnus-tmp-header) ; passed as parameter to user-funcs.
1380 (gnus-add-text-properties
1384 (let ((gnus-tmp-group (gnus-group-name-decode
1385 gnus-tmp-group group-name-charset)))
1386 (eval gnus-group-line-format-spec)))
1387 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1388 gnus-unread ,(if (numberp number)
1389 (string-to-int gnus-tmp-number-of-unread)
1391 gnus-marked ,gnus-tmp-marked-mark
1392 gnus-indentation ,gnus-group-indentation
1393 gnus-level ,gnus-tmp-level))
1395 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1396 (gnus-run-hooks 'gnus-group-update-hook))
1398 ;; Allow XEmacs to remove front-sticky text properties.
1399 (gnus-group-remove-excess-properties)))
1401 (defun gnus-group-highlight-line ()
1402 "Highlight the current line according to `gnus-group-highlight'."
1403 (let* ((list gnus-group-highlight)
1405 (end (progn (end-of-line) (point)))
1406 ;; now find out where the line starts and leave point there.
1407 (beg (progn (beginning-of-line) (point)))
1408 (group (gnus-group-group-name))
1409 (entry (gnus-group-entry group))
1410 (unread (if (numberp (car entry)) (car entry) 0))
1411 (active (gnus-active group))
1412 (total (if active (1+ (- (cdr active) (car active))) 0))
1413 (info (nth 2 entry))
1414 (method (gnus-server-get-method group (gnus-info-method info)))
1415 (marked (gnus-info-marks info))
1416 (mailp (apply 'append
1419 (memq x (assoc (symbol-name
1420 (car (or method gnus-select-method)))
1421 gnus-valid-select-methods)))
1422 '(mail post-mail))))
1423 (level (or (gnus-info-level info) gnus-level-killed))
1424 (score (or (gnus-info-score info) 0))
1425 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1426 (group-age (gnus-group-timestamp-delta group))
1427 (inhibit-read-only t))
1428 ;; Eval the cars of the lists until we find a match.
1430 (not (eval (caar list))))
1431 (setq list (cdr list)))
1432 (let ((face (cdar list)))
1433 (unless (eq face (get-text-property beg 'face))
1434 (gnus-put-text-property-excluding-characters-with-faces
1436 (setq face (if (boundp face) (symbol-value face) face)))
1437 (gnus-extent-start-open beg)))
1440 (defun gnus-group-update-group (group &optional visible-only)
1441 "Update all lines where GROUP appear.
1442 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1444 ;; Can't use `save-excursion' here, so we do it manually.
1445 (let ((buf (current-buffer))
1447 (set-buffer gnus-group-buffer)
1448 (setq mark (point-marker))
1449 ;; The buffer may be narrowed.
1452 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1454 found buffer-read-only)
1455 ;; Enter the current status into the dribble buffer.
1456 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1458 (not (gnus-ephemeral-group-p group)))
1460 (concat "(gnus-group-set-info '"
1461 (gnus-prin1-to-string (nth 2 entry))
1463 ;; Find all group instances. If topics are in use, each group
1464 ;; may be listed in more than once.
1465 (while (setq loc (text-property-any
1466 loc (point-max) 'gnus-group ident))
1469 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1471 (gnus-group-insert-group-line-info group)
1474 (gnus-run-hooks 'gnus-group-update-group-hook)))
1475 (setq loc (1+ loc)))
1476 (unless (or found visible-only)
1477 ;; No such line in the buffer, find out where it's supposed to
1478 ;; go, and insert it there (or at the end of the buffer).
1479 (if gnus-goto-missing-group-function
1480 (funcall gnus-goto-missing-group-function group)
1481 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1482 (while (and entry (car entry)
1486 (point-min) (point-max)
1487 'gnus-group (gnus-intern-safe
1488 (caar entry) gnus-active-hashtb)))))
1489 (setq entry (cdr entry)))
1490 (or entry (goto-char (point-max)))))
1491 ;; Finally insert the line.
1492 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1493 (gnus-group-insert-group-line-info group)
1496 (gnus-run-hooks 'gnus-group-update-group-hook))))
1497 (when gnus-group-update-group-function
1498 (funcall gnus-group-update-group-function group))
1499 (gnus-group-set-mode-line)))
1501 (set-marker mark nil)
1504 (defun gnus-group-set-mode-line ()
1505 "Update the mode line in the group buffer."
1506 (when (memq 'group gnus-updated-mode-lines)
1507 ;; Yes, we want to keep this mode line updated.
1509 (set-buffer gnus-group-buffer)
1510 (let* ((gformat (or gnus-group-mode-line-format-spec
1511 (gnus-set-format 'group-mode)))
1512 (gnus-tmp-news-server (cadr gnus-select-method))
1513 (gnus-tmp-news-method (car gnus-select-method))
1514 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1516 gnus-tmp-header ;Dummy binding for user-defined formats
1517 ;; Get the resulting string.
1519 (and gnus-dribble-buffer
1520 (buffer-name gnus-dribble-buffer)
1521 (buffer-modified-p gnus-dribble-buffer)
1523 (set-buffer gnus-dribble-buffer)
1524 (not (zerop (buffer-size))))))
1525 (mode-string (eval gformat)))
1526 ;; Say whether the dribble buffer has been modified.
1527 (setq mode-line-modified
1528 (if modified (car gnus-mode-line-modified)
1529 (cdr gnus-mode-line-modified)))
1530 ;; If the line is too long, we chop it off.
1531 (when (> (length mode-string) max-len)
1532 (setq mode-string (substring mode-string 0 (- max-len 4))))
1534 (setq mode-line-buffer-identification
1535 (gnus-mode-line-buffer-identification
1536 (list mode-string)))
1537 (set-buffer-modified-p modified))))))
1539 (defun gnus-group-group-name ()
1540 "Get the name of the newsgroup on the current line."
1541 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1543 (symbol-name group))))
1545 (defun gnus-group-group-level ()
1546 "Get the level of the newsgroup on the current line."
1547 (get-text-property (gnus-point-at-bol) 'gnus-level))
1549 (defun gnus-group-group-indentation ()
1550 "Get the indentation of the newsgroup on the current line."
1551 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1552 (and gnus-group-indentation-function
1553 (funcall gnus-group-indentation-function))
1556 (defun gnus-group-group-unread ()
1557 "Get the number of unread articles of the newsgroup on the current line."
1558 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1560 (defun gnus-group-new-mail (group)
1561 (if (nnmail-new-mail-p (gnus-group-real-name group))
1565 (defun gnus-group-level (group)
1566 "Return the estimated level of GROUP."
1567 (or (gnus-info-level (gnus-get-info group))
1568 (and (member group gnus-zombie-list) gnus-level-zombie)
1571 (defun gnus-group-search-forward (&optional backward all level first-too)
1572 "Find the next newsgroup with unread articles.
1573 If BACKWARD is non-nil, find the previous newsgroup instead.
1574 If ALL is non-nil, just find any newsgroup.
1575 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1577 If FIRST-TOO, the current line is also eligible as a target."
1578 (let ((way (if backward -1 1))
1579 (low gnus-level-killed)
1582 (if (and backward (progn (beginning-of-line)) (bobp))
1591 (get-text-property (point) 'gnus-group)
1595 (get-text-property (point) 'gnus-unread)))
1596 (and (numberp unread) (> unread 0)))
1597 (setq lev (get-text-property (point)
1599 (<= lev gnus-level-subscribed)))
1601 (and (setq lev (get-text-property (point)
1610 (zerop (forward-line way)))))
1612 (progn (gnus-group-position-point) t)
1613 (goto-char (or pos beg))
1616 ;;; Gnus group mode commands
1620 (defun gnus-group-mark-line-p ()
1623 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1624 (eq (char-after) gnus-process-mark)))
1626 (defun gnus-group-mark-group (n &optional unmark no-advance)
1627 "Mark the current group."
1629 (let ((buffer-read-only nil)
1633 (when (setq group (gnus-group-group-name))
1634 ;; Go to the mark position.
1636 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1637 (subst-char-in-region
1638 (point) (1+ (point)) (char-after)
1641 (setq gnus-group-marked (delete group gnus-group-marked))
1643 (setq gnus-group-marked
1644 (cons group (delete group gnus-group-marked)))
1645 gnus-process-mark)))
1647 (gnus-group-next-group 1))
1649 (gnus-summary-position-point)
1652 (defun gnus-group-unmark-group (n)
1653 "Remove the mark from the current group."
1655 (gnus-group-mark-group n 'unmark)
1656 (gnus-group-position-point))
1658 (defun gnus-group-unmark-all-groups ()
1659 "Unmark all groups."
1661 (let ((groups gnus-group-marked))
1664 (gnus-group-remove-mark (pop groups)))))
1665 (gnus-group-position-point))
1667 (defun gnus-group-mark-region (unmark beg end)
1668 "Mark all groups between point and mark.
1669 If UNMARK, remove the mark instead."
1670 (interactive "P\nr")
1671 (let ((num (count-lines beg end)))
1674 (- num (gnus-group-mark-group num unmark)))))
1676 (defun gnus-group-mark-buffer (&optional unmark)
1677 "Mark all groups in the buffer.
1678 If UNMARK, remove the mark instead."
1680 (gnus-group-mark-region unmark (point-min) (point-max)))
1682 (defun gnus-group-mark-regexp (regexp)
1683 "Mark all groups that match some regexp."
1684 (interactive "sMark (regexp): ")
1685 (let ((alist (cdr gnus-newsrc-alist))
1688 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1689 (gnus-group-set-mark group))))
1690 (gnus-group-position-point))
1692 (defun gnus-group-remove-mark (group &optional test-marked)
1693 "Remove the process mark from GROUP and move point there.
1694 Return nil if the group isn't displayed."
1695 (if (gnus-group-goto-group group nil test-marked)
1697 (gnus-group-mark-group 1 'unmark t)
1699 (setq gnus-group-marked
1700 (delete group gnus-group-marked))
1703 (defun gnus-group-set-mark (group)
1704 "Set the process mark on GROUP."
1705 (if (gnus-group-goto-group group)
1707 (gnus-group-mark-group 1 nil t))
1708 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1710 (defun gnus-group-universal-argument (arg &optional groups func)
1711 "Perform any command on all groups according to the process/prefix convention."
1713 (if (eq (setq func (or func
1716 (substitute-command-keys
1717 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1719 (gnus-error 1 "Undefined key")
1720 (gnus-group-iterate arg
1722 (command-execute func))))
1723 (gnus-group-position-point))
1725 (defun gnus-group-process-prefix (n)
1726 "Return a list of groups to work on.
1727 Take into consideration N (the prefix) and the list of marked groups."
1730 (setq n (prefix-numeric-value n))
1731 ;; There is a prefix, so we return a list of the N next
1733 (let ((way (if (< n 0) -1 1))
1738 (if (setq group (gnus-group-group-name))
1739 (push group groups))
1741 (gnus-group-next-group way)))
1743 ((and (gnus-region-active-p) (mark))
1744 ;; Work on the region between point and mark.
1745 (let ((max (max (point) (mark)))
1748 (goto-char (min (point) (mark)))
1751 (push (gnus-group-group-name) groups)
1752 (zerop (gnus-group-next-group 1))
1754 (nreverse groups))))
1756 ;; No prefix, but a list of marked articles.
1757 (reverse gnus-group-marked))
1759 ;; Neither marked articles or a prefix, so we return the
1761 (let ((group (gnus-group-group-name)))
1762 (and group (list group))))))
1764 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1765 ;;; imagine why I went through these contortions...
1767 (let ((function (make-symbol "gnus-group-iterate-function"))
1768 (window (make-symbol "gnus-group-iterate-window"))
1769 (groups (make-symbol "gnus-group-iterate-groups"))
1770 (group (make-symbol "gnus-group-iterate-group")))
1772 `(defun gnus-group-iterate (arg ,function)
1773 "Iterate FUNCTION over all process/prefixed groups.
1774 FUNCTION will be called with the group name as the parameter
1775 and with point over the group in question."
1776 (let ((,groups (gnus-group-process-prefix arg))
1777 (,window (selected-window))
1780 (setq ,group (car ,groups)
1781 ,groups (cdr ,groups))
1782 (select-window ,window)
1783 (gnus-group-remove-mark ,group)
1784 (save-selected-window
1786 (funcall ,function ,group)))))))))
1788 (put 'gnus-group-iterate 'lisp-indent-function 1)
1790 ;; Selecting groups.
1792 (defun gnus-group-read-group (&optional all no-article group select-articles)
1793 "Read news in this newsgroup.
1794 If the prefix argument ALL is non-nil, already read articles become
1795 readable. IF ALL is a number, fetch this number of articles. If the
1796 optional argument NO-ARTICLE is non-nil, no article will be
1797 auto-selected upon group entry. If GROUP is non-nil, fetch that
1800 (let ((no-display (eq all 0))
1801 (group (or group (gnus-group-group-name)))
1802 number active marked entry)
1806 (error "No group on current line"))
1807 (setq marked (gnus-info-marks
1808 (nth 2 (setq entry (gnus-gethash
1809 group gnus-newsrc-hashtb)))))
1810 ;; This group might be a dead group. In that case we have to get
1811 ;; the number of unread articles from `gnus-active-hashtb'.
1813 (cond ((numberp all) all)
1815 ((setq active (gnus-active group))
1816 (- (1+ (cdr active)) (car active)))))
1817 (gnus-summary-read-group
1818 group (or all (and (numberp number)
1819 (zerop (+ number (gnus-range-length
1820 (cdr (assq 'tick marked)))
1822 (cdr (assq 'dormant marked)))))))
1823 no-article nil no-display nil select-articles)))
1825 (defun gnus-group-select-group (&optional all)
1826 "Select this newsgroup.
1827 No article is selected automatically.
1828 If the group is opened, just switch the summary buffer.
1829 If ALL is non-nil, already read articles become readable.
1830 If ALL is a number, fetch this number of articles."
1832 (gnus-group-read-group all t))
1834 (defun gnus-group-quick-select-group (&optional all)
1835 "Select the current group \"quickly\".
1836 This means that no highlighting or scoring will be performed.
1837 If ALL (the prefix argument) is 0, don't even generate the summary
1840 This might be useful if you want to toggle threading
1841 before entering the group."
1843 (require 'gnus-score)
1845 gnus-score-find-score-files-function
1846 gnus-home-score-file
1847 gnus-apply-kill-hook
1848 gnus-summary-expunge-below)
1849 (gnus-group-read-group all t)))
1851 (defun gnus-group-visible-select-group (&optional all)
1852 "Select the current group without hiding any articles."
1854 (let ((gnus-inhibit-limiting t))
1855 (gnus-group-read-group all t)))
1857 (defun gnus-group-select-group-ephemerally ()
1858 "Select the current group without doing any processing whatsoever.
1859 You will actually be entered into a group that's a copy of
1860 the current group; no changes you make while in this group will
1863 (require 'gnus-score)
1865 gnus-score-find-score-files-function gnus-apply-kill-hook
1866 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1867 gnus-summary-mode-hook gnus-select-group-hook
1868 (group (gnus-group-group-name))
1869 (method (gnus-find-method-for-group group)))
1870 (gnus-group-read-ephemeral-group
1871 (gnus-group-prefixed-name group method) method)))
1874 (defun gnus-fetch-group (group &optional articles)
1875 "Start Gnus if necessary and enter GROUP.
1876 Returns whether the fetching was successful or not."
1877 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1878 (unless (get-buffer gnus-group-buffer)
1880 (gnus-group-read-group articles nil group))
1883 (defun gnus-fetch-group-other-frame (group)
1884 "Pop up a frame and enter GROUP."
1886 (let ((window (get-buffer-window gnus-group-buffer)))
1888 (select-frame (window-frame window)))
1889 ((= (length (frame-list)) 1)
1890 (select-frame (make-frame)))
1893 (gnus-fetch-group group))
1895 (defvar gnus-ephemeral-group-server 0)
1897 ;; Enter a group that is not in the group buffer. Non-nil is returned
1898 ;; if selection was successful.
1899 (defun gnus-group-read-ephemeral-group (group method &optional activate
1900 quit-config request-only
1903 "Read GROUP from METHOD as an ephemeral group.
1904 If ACTIVATE, request the group first.
1905 If QUIT-CONFIG, use that window configuration when exiting from the
1907 If REQUEST-ONLY, don't actually read the group; just request it.
1908 If SELECT-ARTICLES, only select those articles.
1909 If PARAMETERS, use those as the group parameters.
1911 Return the name of the group if selection was successful."
1912 ;; Transform the select method into a unique server.
1913 (when (stringp method)
1914 (setq method (gnus-server-to-method method)))
1916 `(,(car method) ,(concat (cadr method) "-ephemeral")
1917 (,(intern (format "%s-address" (car method))) ,(cadr method))
1919 (let ((group (if (gnus-group-foreign-p group) group
1920 (gnus-group-prefixed-name (gnus-group-real-name group)
1925 ,gnus-level-default-subscribed nil nil ,method
1928 (cons 'quit-config quit-config)
1930 (cons gnus-summary-buffer
1931 gnus-current-window-configuration)))
1934 (push method gnus-ephemeral-servers)
1935 (set-buffer gnus-group-buffer)
1936 (unless (gnus-check-server method)
1937 (error "Unable to contact server: %s" (gnus-status-message method)))
1939 (gnus-activate-group group 'scan)
1940 (unless (gnus-request-group group)
1941 (error "Couldn't request group: %s"
1942 (nnheader-get-report (car method)))))
1946 (when (gnus-group-read-group t t group select-articles)
1950 (message "Quit reading the ephemeral group")
1953 (defun gnus-group-jump-to-group (group)
1954 "Jump to newsgroup GROUP."
1956 (list (mm-string-make-unibyte
1958 "Group: " gnus-active-hashtb nil
1959 (gnus-read-active-file-p)
1960 gnus-group-jump-to-group-prompt
1961 'gnus-group-history))))
1963 (when (equal group "")
1964 (error "Empty group name"))
1966 (unless (gnus-ephemeral-group-p group)
1967 ;; Either go to the line in the group buffer...
1968 (unless (gnus-group-goto-group group)
1969 ;; ... or insert the line.
1970 (gnus-group-update-group group)
1971 (gnus-group-goto-group group)))
1972 ;; Adjust cursor point.
1973 (gnus-group-position-point))
1975 (defun gnus-group-goto-group (group &optional far test-marked)
1976 "Goto to newsgroup GROUP.
1977 If FAR, it is likely that the group is not on the current line.
1978 If TEST-MARKED, the line must be marked."
1982 ;; It's quite likely that we are on the right line, so
1983 ;; we check the current line first.
1985 (eq (get-text-property (point) 'gnus-group)
1986 (gnus-intern-safe group gnus-active-hashtb))
1987 (or (not test-marked) (gnus-group-mark-line-p)))
1989 ;; Previous and next line are also likely, so we check them as well.
1993 (and (eq (get-text-property (point) 'gnus-group)
1994 (gnus-intern-safe group gnus-active-hashtb))
1995 (or (not test-marked) (gnus-group-mark-line-p)))))
2001 (and (eq (get-text-property (point) 'gnus-group)
2002 (gnus-intern-safe group gnus-active-hashtb))
2003 (or (not test-marked) (gnus-group-mark-line-p)))))
2007 (goto-char (point-min))
2009 (while (and (not found)
2014 (gnus-intern-safe group gnus-active-hashtb))))
2015 (if (gnus-group-mark-line-p)
2020 ;; Search through the entire buffer.
2023 (point-min) (point-max)
2024 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2026 (defun gnus-group-next-group (n &optional silent)
2027 "Go to next N'th newsgroup.
2028 If N is negative, search backward instead.
2029 Returns the difference between N and the number of skips actually
2032 (gnus-group-next-unread-group n t nil silent))
2034 (defun gnus-group-next-unread-group (n &optional all level silent)
2035 "Go to next N'th unread newsgroup.
2036 If N is negative, search backward instead.
2037 If ALL is non-nil, choose any newsgroup, unread or not.
2038 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2039 such group can be found, the next group with a level higher than
2041 Returns the difference between N and the number of skips actually
2044 (let ((backward (< n 0))
2047 (gnus-group-search-forward
2048 backward (or (not gnus-group-goto-unread) all) level))
2052 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2053 (if level " on this level or higher" "")))
2056 (defun gnus-group-prev-group (n)
2057 "Go to previous N'th newsgroup.
2058 Returns the difference between N and the number of skips actually
2061 (gnus-group-next-unread-group (- n) t))
2063 (defun gnus-group-prev-unread-group (n)
2064 "Go to previous N'th unread newsgroup.
2065 Returns the difference between N and the number of skips actually
2068 (gnus-group-next-unread-group (- n)))
2070 (defun gnus-group-next-unread-group-same-level (n)
2071 "Go to next N'th unread newsgroup on the same level.
2072 If N is negative, search backward instead.
2073 Returns the difference between N and the number of skips actually
2076 (gnus-group-next-unread-group n t (gnus-group-group-level))
2077 (gnus-group-position-point))
2079 (defun gnus-group-prev-unread-group-same-level (n)
2080 "Go to next N'th unread newsgroup on the same level.
2081 Returns the difference between N and the number of skips actually
2084 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2085 (gnus-group-position-point))
2087 (defun gnus-group-best-unread-group (&optional exclude-group)
2088 "Go to the group with the highest level.
2089 If EXCLUDE-GROUP, do not go to that group."
2091 (goto-char (point-min))
2095 (setq unread (get-text-property (point) 'gnus-unread))
2096 (when (and (numberp unread) (> unread 0))
2097 (when (and (get-text-property (point) 'gnus-level)
2098 (< (get-text-property (point) 'gnus-level) best)
2099 (or (not exclude-group)
2100 (not (equal exclude-group (gnus-group-group-name)))))
2101 (setq best (get-text-property (point) 'gnus-level))
2102 (setq best-point (point))))
2105 (goto-char best-point))
2106 (gnus-group-position-point)
2107 (and best-point (gnus-group-group-name))))
2109 (defun gnus-group-first-unread-group ()
2110 "Go to the first group with unread articles."
2113 (let ((opoint (point))
2115 (goto-char (point-min))
2116 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2117 (and (numberp unread) ; Not a topic.
2118 (not (zerop unread))) ; Has unread articles.
2119 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2122 nil)) ; Not success.
2123 (gnus-group-position-point)))
2125 (defun gnus-group-enter-server-mode ()
2126 "Jump to the server buffer."
2128 (gnus-enter-server-buffer))
2130 (defun gnus-group-make-group (name &optional method address args)
2131 "Add a new newsgroup.
2132 The user will be prompted for a NAME, for a select METHOD, and an
2136 (gnus-read-group "Group name: ")
2137 (gnus-read-method "From method: ")))
2139 (when (stringp method)
2140 (setq method (or (gnus-server-to-method method) method)))
2141 (let* ((meth (gnus-method-simplify
2143 (not (gnus-server-equal method gnus-select-method)))
2144 (if address (list (intern method) address)
2146 (nname (if method (gnus-group-prefixed-name name meth) name))
2148 (when (gnus-gethash nname gnus-newsrc-hashtb)
2149 (error "Group %s already exists" nname))
2150 ;; Subscribe to the new group.
2151 (gnus-group-change-level
2152 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2153 gnus-level-default-subscribed gnus-level-killed
2154 (and (gnus-group-group-name)
2155 (gnus-gethash (gnus-group-group-name)
2156 gnus-newsrc-hashtb))
2159 (gnus-set-active nname (cons 1 0))
2160 (unless (gnus-ephemeral-group-p name)
2162 (concat "(gnus-group-set-info '"
2163 (gnus-prin1-to-string (cdr info)) ")")))
2165 (gnus-group-insert-group-line-info nname)
2167 (gnus-group-position-point)
2169 ;; Load the backend and try to make the backend create
2170 ;; the group as well.
2171 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2173 gnus-valid-select-methods)
2175 (gnus-check-server meth)
2176 (when (gnus-check-backend-function 'request-create-group nname)
2177 (gnus-request-create-group nname nil args))
2180 (defun gnus-group-delete-groups (&optional arg)
2181 "Delete the current group. Only meaningful with editable groups."
2183 (let ((n (length (gnus-group-process-prefix arg))))
2184 (when (gnus-yes-or-no-p
2186 "Delete this 1 group? "
2187 (format "Delete these %d groups? " n)))
2188 (gnus-group-iterate arg
2190 (gnus-group-delete-group group nil t))))))
2192 (defun gnus-group-delete-group (group &optional force no-prompt)
2193 "Delete the current group. Only meaningful with editable groups.
2194 If FORCE (the prefix) is non-nil, all the articles in the group will
2195 be deleted. This is \"deleted\" as in \"removed forever from the face
2196 of the Earth\". There is no undo. The user will be prompted before
2197 doing the deletion."
2199 (list (gnus-group-group-name)
2200 current-prefix-arg))
2202 (error "No group to delete"))
2203 (unless (gnus-check-backend-function 'request-delete-group group)
2204 (error "This backend does not support group deletion"))
2206 (if (and (not no-prompt)
2207 (not (gnus-yes-or-no-p
2209 "Do you really want to delete %s%s? "
2210 group (if force " and all its contents" "")))))
2212 (gnus-message 6 "Deleting group %s..." group)
2213 (if (not (gnus-request-delete-group group force))
2214 (gnus-error 3 "Couldn't delete group %s" group)
2215 (gnus-message 6 "Deleting group %s...done" group)
2216 (gnus-group-goto-group group)
2217 (gnus-group-kill-group 1 t)
2218 (gnus-sethash group nil gnus-active-hashtb)
2219 (when (and (boundp 'gnus-cache-active-hashtb)
2220 gnus-cache-active-hashtb)
2221 (gnus-sethash group nil gnus-cache-active-hashtb)
2222 (setq gnus-cache-active-altered t))
2224 (gnus-group-position-point)))
2226 (defun gnus-group-rename-group (group new-name)
2227 "Rename group from GROUP to NEW-NAME.
2228 When used interactively, GROUP is the group under point
2229 and NEW-NAME will be prompted for."
2232 (gnus-group-group-name)
2234 (unless (gnus-check-backend-function
2235 'request-rename-group (gnus-group-group-name))
2236 (error "This backend does not support renaming groups"))
2237 (gnus-read-group "Rename group to: "
2238 (gnus-group-real-name (gnus-group-group-name))))))
2240 (unless (gnus-check-backend-function 'request-rename-group group)
2241 (error "This backend does not support renaming groups"))
2243 (error "No group to rename"))
2244 (when (equal (gnus-group-real-name group) new-name)
2245 (error "Can't rename to the same name"))
2247 ;; We find the proper prefixed name.
2249 (if (gnus-group-native-p group)
2253 (gnus-group-prefixed-name
2254 (gnus-group-real-name new-name)
2255 (gnus-info-method (gnus-get-info group)))))
2257 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2260 (gnus-group-goto-group group)
2261 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2262 (gnus-request-rename-group group new-name))))
2263 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2264 ;; We rename the group internally by killing it...
2265 (gnus-group-kill-group)
2266 ;; ... changing its name ...
2267 (setcar (cdar gnus-list-of-killed-groups) new-name)
2268 ;; ... and then yanking it. Magic!
2269 (gnus-group-yank-group)
2270 (gnus-set-active new-name (gnus-active group))
2271 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2273 (setq gnus-killed-list (delete group gnus-killed-list))
2274 (gnus-set-active group nil)
2275 (gnus-dribble-touch)
2276 (gnus-group-position-point)))
2278 (defun gnus-group-edit-group (group &optional part)
2279 "Edit the group on the current line."
2280 (interactive (list (gnus-group-group-name)))
2281 (let ((part (or part 'info))
2284 (error "No group on current line"))
2285 (unless (setq info (gnus-get-info group))
2286 (error "Killed group; can't be edited"))
2288 (gnus-close-group group))
2290 ;; Find the proper form to edit.
2291 (cond ((eq part 'method)
2292 (or (gnus-info-method info) "native"))
2294 (gnus-info-params info))
2296 ;; The proper documentation.
2298 "Editing the %s for `%s'."
2300 ((eq part 'method) "select method")
2301 ((eq part 'params) "group parameters")
2303 (gnus-group-decoded-name group))
2305 (gnus-group-edit-group-done ',part ,group form)))
2308 (gnus-create-info-command
2311 "(gnus)Select Methods")
2313 "(gnus)Group Parameters")
2315 "(gnus)Group Info"))))))
2317 (defun gnus-group-edit-group-method (group)
2318 "Edit the select method of GROUP."
2319 (interactive (list (gnus-group-group-name)))
2320 (gnus-group-edit-group group 'method))
2322 (defun gnus-group-edit-group-parameters (group)
2323 "Edit the group parameters of GROUP."
2324 (interactive (list (gnus-group-group-name)))
2325 (gnus-group-edit-group group 'params))
2327 (defun gnus-group-edit-group-done (part group form)
2329 (let* ((method (cond ((eq part 'info) (nth 4 form))
2330 ((eq part 'method) form)
2332 (info (cond ((eq part 'info) form)
2333 ((eq part 'method) (gnus-get-info group))
2336 (if (or (not method)
2338 gnus-select-method method))
2339 (gnus-group-real-name (car info))
2340 (gnus-group-prefixed-name
2341 (gnus-group-real-name (car info)) method))
2343 (when (and new-group
2344 (not (equal new-group group)))
2345 (when (gnus-group-goto-group group)
2346 (gnus-group-kill-group 1))
2347 (gnus-activate-group new-group))
2349 (if (not (and info new-group))
2350 (gnus-group-set-info form (or new-group group) part)
2351 (setq info (gnus-copy-sequence info))
2352 (setcar info new-group)
2353 (unless (gnus-server-equal method "native")
2354 (unless (nthcdr 3 info)
2355 (nconc info (list nil nil)))
2356 (unless (nthcdr 4 info)
2357 (nconc info (list nil)))
2358 (gnus-info-set-method info method))
2359 (gnus-group-set-info info))
2360 (gnus-group-update-group (or new-group group))
2361 (gnus-group-position-point)))
2363 (defun gnus-group-make-useful-group (group method)
2364 "Create one of the groups described in `gnus-useful-groups'."
2366 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2368 gnus-useful-groups)))
2369 (list (cadr entry) (caddr entry))))
2370 (setq method (gnus-copy-sequence method))
2372 (while (setq entry (memq (assq 'eval method) method))
2373 (setcar entry (eval (cadar entry)))))
2374 (gnus-group-make-group group method))
2376 (defun gnus-group-make-help-group (&optional noerror)
2377 "Create the Gnus documentation group.
2378 Optional argument NOERROR modifies the behavior of this function when the
2379 group already exists:
2380 - if not given, and error is signaled,
2381 - if t, stay silent,
2382 - if anything else, just print a message."
2384 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2385 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2386 (if (gnus-gethash name gnus-newsrc-hashtb)
2387 (cond ((eq noerror nil)
2388 (error "Documentation group already exists"))
2393 (gnus-message 1 "Documentation group already exists")))
2396 (gnus-message 1 "Couldn't find doc group")
2397 (gnus-group-make-group
2398 (gnus-group-real-name name)
2399 (list 'nndoc "gnus-help"
2400 (list 'nndoc-address file)
2401 (list 'nndoc-article-type 'mbox))))
2403 (gnus-group-position-point))
2405 (defun gnus-group-make-doc-group (file type)
2406 "Create a group that uses a single file as the source."
2408 (list (read-file-name "File name: ")
2409 (and current-prefix-arg 'ask)))
2410 (when (eq type 'ask)
2415 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2417 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2418 ((= char ?b) 'babyl)
2419 ((= char ?d) 'digest)
2420 ((= char ?f) 'forward)
2422 ((= char ?g) 'guess)
2423 (t (setq err (format "%c unknown. " char))
2426 (let* ((file (expand-file-name file))
2427 (name (gnus-generate-new-group-name
2428 (gnus-group-prefixed-name
2429 (file-name-nondirectory file) '(nndoc "")))))
2430 (gnus-group-make-group
2431 (gnus-group-real-name name)
2433 (list 'nndoc-address file)
2434 (list 'nndoc-article-type (or type 'guess))))))
2436 (defvar nnweb-type-definition)
2437 (defvar gnus-group-web-type-history nil)
2438 (defvar gnus-group-web-search-history nil)
2439 (defun gnus-group-make-web-group (&optional solid)
2440 "Create an ephemeral nnweb group.
2441 If SOLID (the prefix), create a solid group."
2445 (if solid (gnus-read-group "Group name: ")
2446 (message-unique-id)))
2447 (default-type (or (car gnus-group-web-type-history)
2448 (symbol-name (caar nnweb-type-definition))))
2452 (format "Search engine type (default %s): " default-type)
2453 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2454 nnweb-type-definition)
2455 nil t nil 'gnus-group-web-type-history)
2460 (cons (or (car gnus-group-web-search-history) "") 0)
2461 'gnus-group-web-search-history))
2463 `(nnweb ,group (nnweb-search ,search)
2464 (nnweb-type ,(intern type))
2465 (nnweb-ephemeral-p t))))
2467 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2468 (gnus-group-read-ephemeral-group
2470 (cons (current-buffer)
2471 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2473 (defvar nnwarchive-type-definition)
2474 (defvar gnus-group-warchive-type-history nil)
2475 (defvar gnus-group-warchive-login-history nil)
2476 (defvar gnus-group-warchive-address-history nil)
2478 (defun gnus-group-make-warchive-group ()
2479 "Create a nnwarchive group."
2481 (require 'nnwarchive)
2482 (let* ((group (gnus-read-group "Group name: "))
2483 (default-type (or (car gnus-group-warchive-type-history)
2484 (symbol-name (caar nnwarchive-type-definition))))
2488 (format "Warchive type (default %s): " default-type)
2489 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2490 nnwarchive-type-definition)
2491 nil t nil 'gnus-group-warchive-type-history)
2493 (address (read-string "Warchive address: "
2494 nil 'gnus-group-warchive-address-history))
2495 (default-login (or (car gnus-group-warchive-login-history)
2500 (format "Warchive login (default %s): " user-mail-address)
2501 default-login 'gnus-group-warchive-login-history)
2504 `(nnwarchive ,address
2505 (nnwarchive-type ,(intern type))
2506 (nnwarchive-login ,login))))
2507 (gnus-group-make-group group method)))
2509 (defun gnus-group-make-archive-group (&optional all)
2510 "Create the (ding) Gnus archive group of the most recent articles.
2511 Given a prefix, create a full group."
2513 (let ((group (gnus-group-prefixed-name
2514 (if all "ding.archives" "ding.recent") '(nndir ""))))
2515 (when (gnus-gethash group gnus-newsrc-hashtb)
2516 (error "Archive group already exists"))
2517 (gnus-group-make-group
2518 (gnus-group-real-name group)
2519 (list 'nndir (if all "hpc" "edu")
2520 (list 'nndir-directory
2521 (if all gnus-group-archive-directory
2522 gnus-group-recent-archive-directory))))
2523 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2525 (defun gnus-group-make-directory-group (dir)
2526 "Create an nndir group.
2527 The user will be prompted for a directory. The contents of this
2528 directory will be used as a newsgroup. The directory should contain
2529 mail messages or news articles in files that have numeric names."
2531 (list (read-file-name "Create group from directory: ")))
2532 (unless (file-exists-p dir)
2533 (error "No such directory"))
2534 (unless (file-directory-p dir)
2535 (error "Not a directory"))
2539 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2541 (gnus-group-prefixed-name
2542 (expand-file-name ext dir)
2544 (setq ext (format "<%d>" (setq i (1+ i)))))
2545 (gnus-group-make-group
2546 (gnus-group-real-name group)
2547 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2549 (eval-when-compile (defvar nnkiboze-score-file))
2550 (defun gnus-group-make-kiboze-group (group address scores)
2551 "Create an nnkiboze group.
2552 The user will be prompted for a name, a regexp to match groups, and
2553 score file entries for articles to include in the group."
2556 (read-string "nnkiboze group name: ")
2557 (read-string "Source groups (regexp): ")
2558 (let ((headers (mapcar (lambda (group) (list group))
2559 '("subject" "from" "number" "date" "message-id"
2560 "references" "chars" "lines" "xref"
2561 "followup" "all" "body" "head")))
2562 scores header regexp regexps)
2563 (while (not (equal "" (setq header (completing-read
2564 "Match on header: " headers nil t))))
2566 (while (not (equal "" (setq regexp (read-string
2567 (format "Match on %s (regexp): "
2569 (push (list regexp nil nil 'r) regexps))
2570 (push (cons header regexps) scores))
2572 (gnus-group-make-group group "nnkiboze" address)
2573 (let* ((nnkiboze-current-group group)
2574 (score-file (car (nnkiboze-score-file "")))
2575 (score-dir (file-name-directory score-file)))
2576 (unless (file-exists-p score-dir)
2577 (make-directory score-dir))
2578 (with-temp-file score-file
2579 (let (emacs-lisp-mode-hook)
2580 (pp scores (current-buffer))))))
2582 (defun gnus-group-add-to-virtual (n vgroup)
2583 "Add the current group to a virtual group."
2585 (list current-prefix-arg
2586 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2588 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2589 (error "%s is not an nnvirtual group" vgroup))
2590 (gnus-close-group vgroup)
2591 (let* ((groups (gnus-group-process-prefix n))
2592 (method (gnus-info-method (gnus-get-info vgroup))))
2593 (setcar (cdr method)
2595 (nth 1 method) "\\|"
2598 (gnus-group-remove-mark s)
2599 (concat "\\(^" (regexp-quote s) "$\\)"))
2601 (gnus-group-position-point))
2603 (defun gnus-group-make-empty-virtual (group)
2604 "Create a new, fresh, empty virtual group."
2605 (interactive "sCreate new, empty virtual group: ")
2606 (let* ((method (list 'nnvirtual "^$"))
2607 (pgroup (gnus-group-prefixed-name group method)))
2608 ;; Check whether it exists already.
2609 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2610 (error "Group %s already exists" pgroup))
2611 ;; Subscribe the new group after the group on the current line.
2612 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2613 (gnus-group-update-group pgroup)
2615 (gnus-group-position-point)))
2617 (defun gnus-group-enter-directory (dir)
2618 "Enter an ephemeral nneething group."
2619 (interactive "DDirectory to read: ")
2620 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2621 (leaf (gnus-group-prefixed-name
2622 (file-name-nondirectory (directory-file-name dir))
2624 (name (gnus-generate-new-group-name leaf)))
2625 (unless (gnus-group-read-ephemeral-group
2627 (cons (current-buffer)
2628 (if (eq major-mode 'gnus-summary-mode)
2630 (error "Couldn't enter %s" dir))))
2633 (autoload 'nnimap-expunge "nnimap")
2634 (autoload 'nnimap-acl-get "nnimap")
2635 (autoload 'nnimap-acl-edit "nnimap"))
2637 (defun gnus-group-nnimap-expunge (group)
2638 "Expunge deleted articles in current nnimap GROUP."
2639 (interactive (list (gnus-group-group-name)))
2640 (let ((mailbox (gnus-group-real-name group)) method)
2642 (error "No group on current line"))
2643 (unless (gnus-get-info group)
2644 (error "Killed group; can't be edited"))
2645 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2646 (error "%s is not an nnimap group" group))
2647 (nnimap-expunge mailbox (cadr method))))
2649 (defun gnus-group-nnimap-edit-acl (group)
2650 "Edit the Access Control List of current nnimap GROUP."
2651 (interactive (list (gnus-group-group-name)))
2652 (let ((mailbox (gnus-group-real-name group)) method acl)
2654 (error "No group on current line"))
2655 (unless (gnus-get-info group)
2656 (error "Killed group; can't be edited"))
2657 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2658 (error "%s is not an nnimap group" group))
2659 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2660 (error "Server does not support ACL's"))
2661 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2663 An access control list is a list of (identifier . rights) elements.
2665 The identifier string specifies the corresponding user. The
2666 identifier \"anyone\" is reserved to refer to the universal identity.
2668 Rights is a string listing a (possibly empty) set of alphanumeric
2669 characters, each character listing a set of operations which is being
2670 controlled. Letters are reserved for ``standard'' rights, listed
2671 below. Digits are reserved for implementation or site defined rights.
2673 l - lookup (mailbox is visible to LIST/LSUB commands)
2674 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2675 SEARCH, COPY from mailbox)
2676 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2677 w - write (STORE flags other than \\SEEN and \\DELETED)
2678 i - insert (perform APPEND, COPY into mailbox)
2679 p - post (send mail to submission address for mailbox,
2680 not enforced by IMAP4 itself)
2681 c - create and delete mailbox (CREATE new sub-mailboxes in any
2682 implementation-defined hierarchy, RENAME or DELETE mailbox)
2683 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2684 a - administer (perform SETACL)" group)
2687 ,mailbox ',method ',acl form)))))
2689 ;; Group sorting commands
2690 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2692 (defun gnus-group-sort-groups (func &optional reverse)
2693 "Sort the group buffer according to FUNC.
2694 When used interactively, the sorting function used will be
2695 determined by the `gnus-group-sort-function' variable.
2696 If REVERSE (the prefix), reverse the sorting order."
2697 (interactive (list gnus-group-sort-function current-prefix-arg))
2698 (funcall gnus-group-sort-alist-function
2699 (gnus-make-sort-function func) reverse)
2700 (gnus-group-unmark-all-groups)
2701 (gnus-group-list-groups)
2702 (gnus-dribble-touch))
2704 (defun gnus-group-sort-flat (func reverse)
2705 ;; We peel off the dummy group from the alist.
2707 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2708 (pop gnus-newsrc-alist))
2710 (setq gnus-newsrc-alist
2711 (sort gnus-newsrc-alist func))
2713 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2714 ;; Regenerate the hash table.
2715 (gnus-make-hashtable-from-newsrc-alist)))
2717 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2718 "Sort the group buffer alphabetically by group name.
2719 If REVERSE, sort in reverse order."
2721 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2723 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2724 "Sort the group buffer alphabetically by real (unprefixed) group name.
2725 If REVERSE, sort in reverse order."
2727 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2729 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2730 "Sort the group buffer by number of unread articles.
2731 If REVERSE, sort in reverse order."
2733 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2735 (defun gnus-group-sort-groups-by-level (&optional reverse)
2736 "Sort the group buffer by group level.
2737 If REVERSE, sort in reverse order."
2739 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2741 (defun gnus-group-sort-groups-by-score (&optional reverse)
2742 "Sort the group buffer by group score.
2743 If REVERSE, sort in reverse order."
2745 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2747 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2748 "Sort the group buffer by group rank.
2749 If REVERSE, sort in reverse order."
2751 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2753 (defun gnus-group-sort-groups-by-method (&optional reverse)
2754 "Sort the group buffer alphabetically by backend name.
2755 If REVERSE, sort in reverse order."
2757 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2759 (defun gnus-group-sort-groups-by-server (&optional reverse)
2760 "Sort the group buffer alphabetically by server name.
2761 If REVERSE, sort in reverse order."
2763 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2765 ;;; Selected group sorting.
2767 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2768 "Sort the process/prefixed groups."
2769 (interactive (list current-prefix-arg gnus-group-sort-function))
2770 (let ((groups (gnus-group-process-prefix n)))
2771 (funcall gnus-group-sort-selected-function
2772 groups (gnus-make-sort-function func) reverse)
2773 (gnus-group-unmark-all-groups)
2774 (gnus-group-list-groups)
2775 (gnus-dribble-touch)))
2777 (defun gnus-group-sort-selected-flat (groups func reverse)
2778 (let (entries infos)
2779 ;; First find all the group entries for these groups.
2781 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2783 ;; Then sort the infos.
2787 (lambda (entry) (car entry))
2788 (setq entries (nreverse entries)))
2791 (setq infos (nreverse infos)))
2792 ;; Go through all the infos and replace the old entries
2793 ;; with the new infos.
2795 (setcar (car entries) (pop infos))
2797 ;; Update the hashtable.
2798 (gnus-make-hashtable-from-newsrc-alist)))
2800 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2801 "Sort the group buffer alphabetically by group name.
2802 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2803 sort in reverse order."
2804 (interactive (gnus-interactive "P\ny"))
2805 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2807 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2808 "Sort the group buffer alphabetically by real group name.
2809 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2810 sort in reverse order."
2811 (interactive (gnus-interactive "P\ny"))
2812 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2814 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2815 "Sort the group buffer by number of unread articles.
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-unread reverse))
2821 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2822 "Sort the group buffer by group level.
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-level reverse))
2828 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2829 "Sort the group buffer by group score.
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-score reverse))
2835 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2836 "Sort the group buffer by group rank.
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-rank reverse))
2842 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2843 "Sort the group buffer alphabetically by backend name.
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-method reverse))
2849 ;;; Sorting predicates.
2851 (defun gnus-group-sort-by-alphabet (info1 info2)
2852 "Sort alphabetically."
2853 (string< (gnus-info-group info1) (gnus-info-group info2)))
2855 (defun gnus-group-sort-by-real-name (info1 info2)
2856 "Sort alphabetically on real (unprefixed) names."
2857 (string< (gnus-group-real-name (gnus-info-group info1))
2858 (gnus-group-real-name (gnus-info-group info2))))
2860 (defun gnus-group-sort-by-unread (info1 info2)
2861 "Sort by number of unread articles."
2862 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2863 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2864 (< (or (and (numberp n1) n1) 0)
2865 (or (and (numberp n2) n2) 0))))
2867 (defun gnus-group-sort-by-level (info1 info2)
2869 (< (gnus-info-level info1) (gnus-info-level info2)))
2871 (defun gnus-group-sort-by-method (info1 info2)
2872 "Sort alphabetically by backend name."
2873 (string< (car (gnus-find-method-for-group
2874 (gnus-info-group info1) info1))
2875 (car (gnus-find-method-for-group
2876 (gnus-info-group info2) info2))))
2878 (defun gnus-group-sort-by-server (info1 info2)
2879 "Sort alphabetically by server name."
2880 (string< (gnus-method-to-full-server-name
2881 (gnus-find-method-for-group
2882 (gnus-info-group info1) info1))
2883 (gnus-method-to-full-server-name
2884 (gnus-find-method-for-group
2885 (gnus-info-group info2) info2))))
2887 (defun gnus-group-sort-by-score (info1 info2)
2888 "Sort by group score."
2889 (> (gnus-info-score info1) (gnus-info-score info2)))
2891 (defun gnus-group-sort-by-rank (info1 info2)
2892 "Sort by level and score."
2893 (let ((level1 (gnus-info-level info1))
2894 (level2 (gnus-info-level info2)))
2895 (or (< level1 level2)
2896 (and (= level1 level2)
2897 (> (gnus-info-score info1) (gnus-info-score info2))))))
2901 (defun gnus-group-clear-data (&optional arg)
2902 "Clear all marks and read ranges from the current group."
2904 (gnus-group-iterate arg
2907 (gnus-info-clear-data (setq info (gnus-get-info group)))
2908 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2909 (when (gnus-group-goto-group group)
2910 (gnus-group-update-group-line))))))
2912 (defun gnus-group-clear-data-on-native-groups ()
2913 "Clear all marks and read ranges from all native groups."
2915 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2916 (let ((alist (cdr gnus-newsrc-alist))
2918 (while (setq info (pop alist))
2919 (when (gnus-group-native-p (gnus-info-group info))
2920 (gnus-info-clear-data info)))
2921 (gnus-get-unread-articles)
2922 (gnus-dribble-touch)
2923 (when (gnus-y-or-n-p
2924 "Move the cache away to avoid problems in the future? ")
2925 (call-interactively 'gnus-cache-move-cache)))))
2927 (defun gnus-info-clear-data (info)
2928 "Clear all marks and read ranges from INFO."
2929 (let ((group (gnus-info-group info))
2931 (dolist (el (gnus-info-marks info))
2932 (push `(,(cdr el) add (,(car el))) action))
2933 (push `(,(gnus-info-read info) add (read)) action)
2936 (gnus-request-set-mark ,group ',action)
2937 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2938 (gnus-info-set-read ',info ',(gnus-info-read info))
2939 (when (gnus-group-goto-group ,group)
2940 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2941 (gnus-group-update-group-line))))
2942 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2944 (gnus-request-set-mark group action)
2945 (gnus-info-set-read info nil)
2946 (when (gnus-info-marks info)
2947 (gnus-info-set-marks info nil))))
2949 ;; Group catching up.
2951 (defun gnus-group-catchup-current (&optional n all)
2952 "Mark all unread articles in the current newsgroup as read.
2953 If prefix argument N is numeric, the next N newsgroups will be
2954 caught up. If ALL is non-nil, marked articles will also be marked as
2955 read. Cross references (Xref: header) of articles are ignored.
2956 The number of newsgroups that this function was unable to catch
2959 (let ((groups (gnus-group-process-prefix n))
2962 (unless groups (error "No groups selected"))
2964 (or (not gnus-interactive-catchup) ;Without confirmation?
2969 "Do you really want to mark all articles in %s as read? "
2970 "Mark all unread articles in %s as read? ")
2971 (if (= (length groups) 1)
2973 (format "these %d groups" (length groups)))))))
2975 (while (setq group (pop groups))
2976 (gnus-group-remove-mark group)
2977 ;; Virtual groups have to be given special treatment.
2978 (let ((method (gnus-find-method-for-group group)))
2979 (when (eq 'nnvirtual (car method))
2980 (nnvirtual-catchup-group
2981 (gnus-group-real-name group) (nth 1 method) all)))
2982 (if (>= (gnus-group-level group) gnus-level-zombie)
2983 (gnus-message 2 "Dead groups can't be caught up")
2985 (gnus-group-goto-group group)
2986 (gnus-group-catchup group all))
2987 (gnus-group-update-group-line)
2988 (setq ret (1+ ret)))))
2989 (gnus-group-next-unread-group 1)
2992 (defun gnus-group-catchup-current-all (&optional n)
2993 "Mark all articles in current newsgroup as read.
2994 Cross references (Xref: header) of articles are ignored."
2996 (gnus-group-catchup-current n 'all))
2998 (defun gnus-group-catchup (group &optional all)
2999 "Mark all articles in GROUP as read.
3000 If ALL is non-nil, all articles are marked as read.
3001 The return value is the number of articles that were marked as read,
3002 or nil if no action could be taken."
3003 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3005 (marks (nth 3 (nth 2 entry)))
3006 (unread (gnus-list-of-unread-articles group)))
3007 ;; Remove entries for this group.
3008 (nnmail-purge-split-history (gnus-group-real-name group))
3009 ;; Do the updating only if the newsgroup isn't killed.
3010 (if (not (numberp (car entry)))
3011 (gnus-message 1 "Can't catch up %s; non-active group" group)
3012 (gnus-update-read-articles group nil)
3014 ;; Nix out the lists of marks and dormants.
3015 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3017 (list (cdr (assq 'dormant marks))
3019 (setq unread (gnus-uncompress-range
3020 (gnus-range-add (gnus-range-add
3021 unread (cdr (assq 'dormant marks)))
3022 (cdr (assq 'tick marks)))))
3023 (gnus-add-marked-articles group 'tick nil nil 'force)
3024 (gnus-add-marked-articles group 'dormant nil nil 'force))
3025 ;; Do auto-expirable marks if that's required.
3026 (when (gnus-group-auto-expirable-p group)
3027 (gnus-add-marked-articles group 'expire unread)
3028 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3029 (let ((gnus-newsgroup-name group))
3030 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3033 (defun gnus-group-expire-articles (&optional n)
3034 "Expire all expirable articles in the current newsgroup."
3036 (let ((groups (gnus-group-process-prefix n))
3039 (error "No groups to expire"))
3040 (while (setq group (pop groups))
3041 (gnus-group-remove-mark group)
3042 (gnus-group-expire-articles-1 group)
3043 (gnus-dribble-touch)
3044 (gnus-group-position-point))))
3046 (defun gnus-group-expire-articles-1 (group)
3047 (when (gnus-check-backend-function 'request-expire-articles group)
3048 (gnus-message 6 "Expiring articles in %s..." group)
3049 (let* ((info (gnus-get-info group))
3050 (expirable (if (gnus-group-total-expirable-p group)
3051 (cons nil (gnus-list-of-read-articles group))
3052 (assq 'expire (gnus-info-marks info))))
3053 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3054 (nnmail-expiry-target
3055 (or (gnus-group-find-parameter group 'expiry-target)
3056 nnmail-expiry-target)))
3058 (gnus-check-group group)
3061 (gnus-compress-sequence
3063 ;; We set the expiry variables to the group
3065 (let ((nnmail-expiry-wait-function nil)
3066 (nnmail-expiry-wait expiry-wait))
3067 (gnus-request-expire-articles
3068 (gnus-uncompress-sequence (cdr expirable)) group))
3069 ;; Just expire using the normal expiry values.
3070 (gnus-request-expire-articles
3071 (gnus-uncompress-sequence (cdr expirable)) group))))
3072 (gnus-close-group group))
3073 (gnus-message 6 "Expiring articles in %s...done" group)
3074 ;; Return the list of un-expired articles.
3077 (defun gnus-group-expire-all-groups ()
3078 "Expire all expirable articles in all newsgroups."
3081 (gnus-message 5 "Expiring...")
3082 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3083 (cdr gnus-newsrc-alist))))
3084 (gnus-group-expire-articles nil)))
3085 (gnus-group-position-point)
3086 (gnus-message 5 "Expiring...done"))
3088 (defun gnus-group-set-current-level (n level)
3089 "Set the level of the next N groups to LEVEL."
3094 (let ((s (read-string
3095 (format "Level (default %s): "
3096 (or (gnus-group-group-level)
3097 gnus-level-default-subscribed)))))
3098 (if (string-match "^\\s-*$" s)
3099 (int-to-string (or (gnus-group-group-level)
3100 gnus-level-default-subscribed))
3102 (unless (and (>= level 1) (<= level gnus-level-killed))
3103 (error "Invalid level: %d" level))
3104 (let ((groups (gnus-group-process-prefix n))
3106 (while (setq group (pop groups))
3107 (gnus-group-remove-mark group)
3108 (gnus-message 6 "Changed level of %s from %d to %d"
3109 group (or (gnus-group-group-level) gnus-level-killed)
3111 (gnus-group-change-level
3112 group level (or (gnus-group-group-level) gnus-level-killed))
3113 (gnus-group-update-group-line)))
3114 (gnus-group-position-point))
3116 (defun gnus-group-unsubscribe (&optional n)
3117 "Unsubscribe the current group."
3119 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3121 (defun gnus-group-subscribe (&optional n)
3122 "Subscribe the current group."
3124 (gnus-group-unsubscribe-current-group n 'subscribe))
3126 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3127 "Toggle subscription of the current group.
3128 If given numerical prefix, toggle the N next groups."
3130 (let ((groups (gnus-group-process-prefix n))
3133 (setq group (car groups)
3134 groups (cdr groups))
3135 (gnus-group-remove-mark group)
3136 (gnus-group-unsubscribe-group
3139 ((eq do-sub 'unsubscribe)
3140 gnus-level-default-unsubscribed)
3141 ((eq do-sub 'subscribe)
3142 gnus-level-default-subscribed)
3143 ((<= (gnus-group-group-level) gnus-level-subscribed)
3144 gnus-level-default-unsubscribed)
3146 gnus-level-default-subscribed))
3148 (gnus-group-update-group-line))
3149 (gnus-group-next-group 1)))
3151 (defun gnus-group-unsubscribe-group (group &optional level silent)
3152 "Toggle subscription to GROUP.
3153 Killed newsgroups are subscribed. If SILENT, don't try to update the
3156 (list (completing-read
3157 "Group: " gnus-active-hashtb nil
3158 (gnus-read-active-file-p)
3160 'gnus-group-history)))
3161 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3163 ((string-match "^[ \t]*$" group)
3164 (error "Empty group name"))
3166 ;; Toggle subscription flag.
3167 (gnus-group-change-level
3168 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3169 gnus-level-subscribed)
3170 (1+ gnus-level-subscribed)
3171 gnus-level-default-subscribed)))
3173 (gnus-group-update-group group)))
3174 ((and (stringp group)
3175 (or (not (gnus-read-active-file-p))
3176 (gnus-active group)))
3177 ;; Add new newsgroup.
3178 (gnus-group-change-level
3180 (if level level gnus-level-default-subscribed)
3181 (or (and (member group gnus-zombie-list)
3184 (when (gnus-group-group-name)
3185 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3187 (gnus-group-update-group group)))
3188 (t (error "No such newsgroup: %s" group)))
3189 (gnus-group-position-point)))
3191 (defun gnus-group-transpose-groups (n)
3192 "Move the current newsgroup up N places.
3193 If given a negative prefix, move down instead. The difference between
3194 N and the number of steps taken is returned."
3196 (unless (gnus-group-group-name)
3197 (error "No group on current line"))
3198 (gnus-group-kill-group 1)
3200 (forward-line (- n))
3201 (gnus-group-yank-group)
3202 (gnus-group-position-point)))
3204 (defun gnus-group-kill-all-zombies (&optional dummy)
3205 "Kill all zombie newsgroups.
3206 The optional DUMMY should always be nil."
3207 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3209 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3210 (setq gnus-zombie-list nil)
3211 (gnus-dribble-touch)
3212 (gnus-group-list-groups)))
3214 (defun gnus-group-kill-region (begin end)
3215 "Kill newsgroups in current region (excluding current point).
3216 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3231 (beginning-of-line) ;Important when LINES < 1
3232 (gnus-group-kill-group lines)))
3234 (defun gnus-group-kill-group (&optional n discard)
3235 "Kill the next N groups.
3236 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3237 However, only groups that were alive can be yanked; already killed
3238 groups or zombie groups can't be yanked.
3239 The return value is the name of the group that was killed, or a list
3242 (let ((buffer-read-only nil)
3243 (groups (gnus-group-process-prefix n))
3244 group entry level out)
3245 (if (< (length groups) 10)
3246 ;; This is faster when there are few groups.
3248 (push (setq group (pop groups)) out)
3249 (gnus-group-remove-mark group)
3250 (setq level (gnus-group-group-level))
3252 (when (and (not discard)
3253 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3256 (gnus-group-goto-group ,(gnus-group-group-name))
3257 (gnus-group-yank-group)))
3258 (push (cons (car entry) (nth 2 entry))
3259 gnus-list-of-killed-groups))
3260 (gnus-group-change-level
3261 (if entry entry group) gnus-level-killed (if entry nil level))
3262 (message "Killed group %s" group))
3263 ;; If there are lots and lots of groups to be killed, we use
3264 ;; this thing instead.
3266 (setq groups (nreverse groups))
3268 (gnus-group-remove-mark (setq group (pop groups)))
3270 (push group gnus-killed-list)
3271 (setq gnus-newsrc-alist
3272 (delq (assoc group gnus-newsrc-alist)
3274 (when gnus-group-change-level-function
3275 (funcall gnus-group-change-level-function
3276 group gnus-level-killed 3))
3278 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3279 (push (cons (car entry) (nth 2 entry))
3280 gnus-list-of-killed-groups)
3281 (setcdr (cdr entry) (cdddr entry)))
3282 ((member group gnus-zombie-list)
3283 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3284 ;; There may be more than one instance displayed.
3285 (while (gnus-group-goto-group group)
3286 (gnus-delete-line)))
3287 (gnus-make-hashtable-from-newsrc-alist)))
3289 (gnus-group-position-point)
3290 (if (< (length out) 2) (car out) (nreverse out))))
3292 (defun gnus-group-yank-group (&optional arg)
3293 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3294 The numeric ARG specifies how many newsgroups are to be yanked. The
3295 name of the newsgroup yanked is returned, or (if several groups are
3296 yanked) a list of yanked groups is returned."
3298 (setq arg (or arg 1))
3299 (let (info group prev out)
3300 (while (>= (decf arg) 0)
3301 (when (not (setq info (pop gnus-list-of-killed-groups)))
3302 (error "No more newsgroups to yank"))
3303 (push (setq group (nth 1 info)) out)
3304 ;; Find which newsgroup to insert this one before - search
3305 ;; backward until something suitable is found. If there are no
3306 ;; other newsgroups in this buffer, just make this newsgroup the
3308 (setq prev (gnus-group-group-name))
3309 (gnus-group-change-level
3310 info (gnus-info-level (cdr info)) gnus-level-killed
3311 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3313 (gnus-group-insert-group-line-info group)
3315 `(when (gnus-group-goto-group ,group)
3316 (gnus-group-kill-group 1))))
3318 (gnus-group-position-point)
3319 (if (< (length out) 2) (car out) (nreverse out))))
3321 (defun gnus-group-kill-level (level)
3322 "Kill all groups that is on a certain LEVEL."
3323 (interactive "nKill all groups on level: ")
3325 ((= level gnus-level-zombie)
3326 (setq gnus-killed-list
3327 (nconc gnus-zombie-list gnus-killed-list))
3328 (setq gnus-zombie-list nil))
3329 ((and (< level gnus-level-zombie)
3331 (or gnus-expert-user
3334 "Do you really want to kill all groups on level %d? "
3336 (let* ((prev gnus-newsrc-alist)
3339 (if (= (gnus-info-level (car alist)) level)
3341 (push (gnus-info-group (car alist)) gnus-killed-list)
3342 (setcdr prev (cdr alist)))
3344 (setq alist (cdr alist)))
3345 (gnus-make-hashtable-from-newsrc-alist)
3346 (gnus-group-list-groups)))
3348 (error "Can't kill; invalid level: %d" level))))
3350 (defun gnus-group-list-all-groups (&optional arg)
3351 "List all newsgroups with level ARG or lower.
3352 Default is gnus-level-unsubscribed, which lists all subscribed and most
3353 unsubscribed groups."
3355 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3357 ;; Redefine this to list ALL killed groups if prefix arg used.
3358 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3359 (defun gnus-group-list-killed (&optional arg)
3360 "List all killed newsgroups in the group buffer.
3361 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3362 entail asking the server for the groups."
3364 ;; Find all possible killed newsgroups if arg.
3366 (gnus-get-killed-groups))
3367 (if (not gnus-killed-list)
3368 (gnus-message 6 "No killed groups")
3369 (let (gnus-group-list-mode)
3370 (funcall gnus-group-prepare-function
3371 gnus-level-killed t gnus-level-killed))
3372 (goto-char (point-min)))
3373 (gnus-group-position-point))
3375 (defun gnus-group-list-zombies ()
3376 "List all zombie newsgroups in the group buffer."
3378 (if (not gnus-zombie-list)
3379 (gnus-message 6 "No zombie groups")
3380 (let (gnus-group-list-mode)
3381 (funcall gnus-group-prepare-function
3382 gnus-level-zombie t gnus-level-zombie))
3383 (goto-char (point-min)))
3384 (gnus-group-position-point))
3386 (defun gnus-group-list-active ()
3387 "List all groups that are available from the server(s)."
3389 ;; First we make sure that we have really read the active file.
3390 (unless (gnus-read-active-file-p)
3391 (let ((gnus-read-active-file t)
3392 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3393 (gnus-read-active-file)))
3394 ;; Find all groups and sort them.
3402 (push (symbol-name sym) list)))
3406 (buffer-read-only nil)
3410 (setq group (pop groups))
3411 (gnus-add-text-properties
3412 (point) (prog1 (1+ (point))
3414 (gnus-group-decoded-name group)
3416 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3418 'gnus-level (inline (gnus-group-level group)))))
3419 (goto-char (point-min))))
3421 (defun gnus-activate-all-groups (level)
3422 "Activate absolutely all groups."
3423 (interactive (list gnus-level-unsubscribed))
3424 (let ((gnus-activate-level level)
3425 (gnus-activate-foreign-newsgroups level))
3426 (gnus-group-get-new-news)))
3428 (defun gnus-group-get-new-news (&optional arg)
3429 "Get newly arrived articles.
3430 If ARG is a number, it specifies which levels you are interested in
3431 re-scanning. If ARG is non-nil and not a number, this will force
3432 \"hard\" re-reading of the active files from all servers."
3435 (let ((gnus-inhibit-demon t)
3436 ;; Binding this variable will inhibit multiple fetchings
3437 ;; of the same mail source.
3438 (nnmail-fetched-sources (list t)))
3439 (gnus-run-hooks 'gnus-get-new-news-hook)
3441 ;; Read any slave files.
3443 (gnus-master-read-slave-newsrc))
3445 ;; We might read in new NoCeM messages here.
3446 (when (and gnus-use-nocem
3448 (gnus-nocem-scan-groups))
3449 ;; If ARG is not a number, then we read the active file.
3450 (when (and arg (not (numberp arg)))
3451 (let ((gnus-read-active-file t))
3452 (gnus-read-active-file))
3455 ;; If the user wants it, we scan for new groups.
3456 (when (eq gnus-check-new-newsgroups 'always)
3457 (gnus-find-new-newsgroups)))
3459 (setq arg (gnus-group-default-level arg t))
3460 (if (and gnus-read-active-file (not arg))
3462 (gnus-read-active-file)
3463 (gnus-get-unread-articles arg))
3464 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3465 (gnus-get-unread-articles arg)))
3466 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3467 (gnus-group-list-groups (and (numberp arg)
3468 (max (car gnus-group-list-mode) arg)))))
3470 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3471 "Check for newly arrived news in the current group (and the N-1 next groups).
3472 The difference between N and the number of newsgroup checked is returned.
3473 If N is negative, this group and the N-1 previous groups will be checked."
3475 (let* ((groups (gnus-group-process-prefix n))
3476 (ret (if (numberp n) (- n (length groups)) 0))
3480 (gnus-inhibit-demon t)
3481 ;; Binding this variable will inhibit multiple fetchings
3482 ;; of the same mail source.
3483 (nnmail-fetched-sources (list t)))
3484 (gnus-run-hooks 'gnus-get-new-news-hook)
3485 (while (setq group (pop groups))
3486 (gnus-group-remove-mark group)
3487 ;; Bypass any previous denials from the server.
3488 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3489 (if (gnus-activate-group group (if dont-scan nil 'scan))
3491 (gnus-get-unread-articles-in-group
3492 (gnus-get-info group) (gnus-active group) t)
3493 (unless (gnus-virtual-group-p group)
3494 (gnus-close-group group))
3496 (gnus-agent-save-group-info
3497 method (gnus-group-real-name group) (gnus-active group)))
3498 (gnus-group-update-group group))
3499 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3501 (gnus-error 3 "Server denied access")
3502 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3505 (when gnus-goto-next-group-when-activating
3506 (gnus-group-next-unread-group 1 t))
3507 (gnus-summary-position-point)
3510 (defun gnus-group-fetch-faq (group &optional faq-dir)
3511 "Fetch the FAQ for the current group.
3512 If given a prefix argument, prompt for the FAQ dir
3516 (gnus-group-group-name)
3517 (when current-prefix-arg
3519 "FAQ dir: " (and (listp gnus-group-faq-directory)
3521 gnus-group-faq-directory))))))
3523 (error "No group name given"))
3524 (let ((dirs (or faq-dir gnus-group-faq-directory))
3526 (unless (listp dirs)
3527 (setq dirs (list dirs)))
3528 (while (and (not found)
3529 (setq dir (pop dirs)))
3530 (let ((name (gnus-group-real-name group)))
3531 (setq file (expand-file-name name dir)))
3532 (if (not (file-exists-p file))
3533 (gnus-message 1 "No such file: %s" file)
3534 (let ((enable-local-variables nil))
3538 (defun gnus-group-fetch-charter (group)
3539 "Fetch the charter for the current group.
3540 If given a prefix argument, prompt for a group."
3542 (list (or (when current-prefix-arg
3543 (completing-read "Group: " gnus-active-hashtb))
3544 (gnus-group-group-name)
3545 gnus-newsgroup-name)))
3547 (error "No group name given"))
3549 (condition-case nil (require 'url-http) (error nil))
3550 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3552 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3553 (setq hierarchy (match-string 1 name))
3554 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3555 (if (fboundp 'url-http-file-exists-p)
3556 (url-http-file-exists-p (eval url))
3558 (browse-url (eval url))
3559 (setq url (concat "http://" hierarchy
3560 ".news-admin.org/charters/" name))
3561 (if (and (fboundp 'url-http-file-exists-p)
3562 (url-http-file-exists-p url))
3564 (gnus-group-fetch-control group))))))
3566 (defun gnus-group-fetch-control (group)
3567 "Fetch the archived control messages for the current group.
3568 If given a prefix argument, prompt for a group."
3570 (list (or (when current-prefix-arg
3571 (completing-read "Group: " gnus-active-hashtb))
3572 (gnus-group-group-name)
3573 gnus-newsgroup-name)))
3575 (error "No group name given"))
3576 (let ((name (gnus-group-real-name group))
3578 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3579 (setq hierarchy (match-string 1 name))
3580 (if gnus-group-fetch-control-use-browse-url
3581 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3582 hierarchy "/" name ".Z"))
3583 (let ((enable-local-variables nil))
3584 (gnus-group-read-ephemeral-group
3586 `(nndoc ,group (nndoc-address
3587 ,(find-file-noselect
3588 (concat "/ftp@ftp.isc.org:/usenet/control/"
3589 hierarchy "/" name ".Z")))
3590 (nndoc-article-type mbox)) t nil nil))))))
3592 (defun gnus-group-describe-group (force &optional group)
3593 "Display a description of the current newsgroup."
3594 (interactive (list current-prefix-arg (gnus-group-group-name)))
3595 (let* ((method (gnus-find-method-for-group group))
3596 (mname (gnus-group-prefixed-name "" method))
3599 gnus-description-hashtb)
3600 (gnus-sethash mname nil gnus-description-hashtb))
3602 (error "No group name given"))
3603 (when (or (and gnus-description-hashtb
3604 ;; We check whether this group's method has been
3605 ;; queried for a description file.
3606 (gnus-gethash mname gnus-description-hashtb))
3607 (setq desc (gnus-group-get-description group))
3608 (gnus-read-descriptions-file method))
3610 (or desc (gnus-gethash group gnus-description-hashtb)
3611 "No description available")))))
3613 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3614 (defun gnus-group-describe-all-groups (&optional force)
3615 "Pop up a buffer with descriptions of all newsgroups."
3618 (setq gnus-description-hashtb nil))
3619 (when (not (or gnus-description-hashtb
3620 (gnus-read-all-descriptions-files)))
3621 (error "Couldn't request descriptions file"))
3622 (let ((buffer-read-only nil)
3628 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3629 (insert (format " *: %-20s %s\n"
3630 (gnus-group-name-decode
3631 (symbol-name group) charset)
3632 (gnus-group-name-decode
3633 (symbol-value group) charset))))
3634 (gnus-add-text-properties
3635 b (1+ b) (list 'gnus-group group
3636 'gnus-unread t 'gnus-marked nil
3637 'gnus-level (1+ gnus-level-subscribed))))
3638 gnus-description-hashtb)
3639 (goto-char (point-min))
3640 (gnus-group-position-point)))
3642 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3643 (defun gnus-group-apropos (regexp &optional search-description)
3644 "List all newsgroups that have names that match a regexp."
3645 (interactive "sGnus apropos (regexp): ")
3647 (obuf (current-buffer))
3649 ;; Go through all newsgroups that are known to Gnus.
3652 (and (symbol-name group)
3653 (string-match regexp (symbol-name group))
3654 (symbol-value group)
3655 (push (symbol-name group) groups)))
3657 ;; Also go through all descriptions that are known to Gnus.
3658 (when search-description
3661 (and (string-match regexp (symbol-value group))
3662 (push (symbol-name group) groups)))
3663 gnus-description-hashtb))
3665 (gnus-message 3 "No groups matched \"%s\"." regexp)
3666 ;; Print out all the groups.
3668 (pop-to-buffer "*Gnus Help*")
3669 (buffer-disable-undo)
3671 (setq groups (sort groups 'string<))
3673 ;; Groups may be entered twice into the list of groups.
3674 (when (not (string= (car groups) prev))
3675 (setq prev (car groups))
3676 (let ((charset (gnus-group-name-charset nil prev)))
3677 (insert (gnus-group-name-decode prev charset) "\n")
3678 (when (and gnus-description-hashtb
3679 (setq des (gnus-gethash (car groups)
3680 gnus-description-hashtb)))
3681 (insert " " (gnus-group-name-decode des charset) "\n"))))
3682 (setq groups (cdr groups)))
3683 (goto-char (point-min))))
3684 (pop-to-buffer obuf)))
3686 (defun gnus-group-description-apropos (regexp)
3687 "List all newsgroups that have names or descriptions that match a regexp."
3688 (interactive "sGnus description apropos (regexp): ")
3689 (when (not (or gnus-description-hashtb
3690 (gnus-read-all-descriptions-files)))
3691 (error "Couldn't request descriptions file"))
3692 (gnus-group-apropos regexp t))
3694 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3695 (defun gnus-group-list-matching (level regexp &optional all lowest)
3696 "List all groups with unread articles that match REGEXP.
3697 If the prefix LEVEL is non-nil, it should be a number that says which
3698 level to cut off listing groups.
3699 If ALL, also list groups with no unread articles.
3700 If LOWEST, don't list groups with level lower than LOWEST.
3702 This command may read the active file."
3703 (interactive "P\nsList newsgroups matching: ")
3704 ;; First make sure active file has been read.
3706 (> (prefix-numeric-value level) gnus-level-killed))
3707 (gnus-get-killed-groups))
3708 (funcall gnus-group-prepare-function
3709 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3710 (goto-char (point-min))
3711 (gnus-group-position-point))
3713 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3714 "List all groups that match REGEXP.
3715 If the prefix LEVEL is non-nil, it should be a number that says which
3716 level to cut off listing groups.
3717 If LOWEST, don't list groups with level lower than LOWEST."
3718 (interactive "P\nsList newsgroups matching: ")
3720 (setq level (prefix-numeric-value level)))
3721 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3723 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3724 (defun gnus-group-save-newsrc (&optional force)
3725 "Save the Gnus startup files.
3726 If FORCE, force saving whether it is necessary or not."
3728 (gnus-save-newsrc-file force))
3730 (defun gnus-group-restart (&optional arg)
3731 "Force Gnus to read the .newsrc file."
3733 (when (gnus-yes-or-no-p
3734 (format "Are you sure you want to restart Gnus? "))
3735 (gnus-save-newsrc-file)
3739 (defun gnus-group-read-init-file ()
3740 "Read the Gnus elisp init file."
3742 (gnus-read-init-file)
3743 (gnus-message 5 "Read %s" gnus-init-file))
3745 (defun gnus-group-check-bogus-groups (&optional silent)
3746 "Check bogus newsgroups.
3747 If given a prefix, don't ask for confirmation before removing a bogus
3750 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3751 (gnus-group-list-groups))
3753 (defun gnus-group-find-new-groups (&optional arg)
3754 "Search for new groups and add them.
3755 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3756 With 1 C-u, use the `ask-server' method to query the server for new
3758 With 2 C-u's, use most complete method possible to query the server
3759 for new groups, and subscribe the new groups as zombies."
3761 (gnus-find-new-newsgroups (or arg 1))
3762 (gnus-group-list-groups))
3764 (defun gnus-group-edit-global-kill (&optional article group)
3765 "Edit the global kill file.
3766 If GROUP, edit that local kill file instead."
3768 (setq gnus-current-kill-article article)
3769 (gnus-kill-file-edit-file group)
3772 (substitute-command-keys
3773 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3774 (if group "local" "global")))))
3776 (defun gnus-group-edit-local-kill (article group)
3777 "Edit a local kill file."
3778 (interactive (list nil (gnus-group-group-name)))
3779 (gnus-group-edit-global-kill article group))
3781 (defun gnus-group-force-update ()
3782 "Update `.newsrc' file."
3784 (gnus-save-newsrc-file))
3786 (defun gnus-group-suspend ()
3787 "Suspend the current Gnus session.
3788 In fact, cleanup buffers except for group mode buffer.
3789 The hook gnus-suspend-gnus-hook is called before actually suspending."
3791 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3792 (gnus-offer-save-summaries)
3793 ;; Kill Gnus buffers except for group mode buffer.
3794 (let ((group-buf (get-buffer gnus-group-buffer)))
3795 (mapcar (lambda (buf)
3796 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3800 (eq major-mode 'message-mode))))
3801 (gnus-kill-buffer buf)))
3803 (gnus-kill-gnus-frames)
3805 (bury-buffer group-buf)
3806 (delete-windows-on group-buf t))))
3808 (defun gnus-group-clear-dribble ()
3809 "Clear all information from the dribble buffer."
3811 (gnus-dribble-clear)
3812 (gnus-message 7 "Cleared dribble buffer"))
3814 (defun gnus-group-exit ()
3815 "Quit reading news after updating .newsrc.eld and .newsrc.
3816 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3819 (or noninteractive ;For gnus-batch-kill
3820 (not gnus-interactive-exit) ;Without confirmation
3822 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3823 (gnus-run-hooks 'gnus-exit-gnus-hook)
3824 ;; Offer to save data from non-quitted summary buffers.
3825 (gnus-offer-save-summaries)
3826 ;; Save the newsrc file(s).
3827 (gnus-save-newsrc-file)
3829 (gnus-close-backends)
3830 ;; Reset everything.
3832 ;; Allow the user to do things after cleaning up.
3833 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3835 (defun gnus-group-quit ()
3836 "Quit reading news without updating .newsrc.eld or .newsrc.
3837 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3839 (when (or noninteractive ;For gnus-batch-kill
3840 (zerop (buffer-size))
3841 (not (gnus-server-opened gnus-select-method))
3843 (not gnus-current-startup-file)
3845 (format "Quit reading news without saving %s? "
3846 (file-name-nondirectory gnus-current-startup-file))))
3847 (gnus-run-hooks 'gnus-exit-gnus-hook)
3848 (gnus-configure-windows 'group t)
3849 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3850 (not (zerop (save-excursion
3851 (set-buffer gnus-dribble-buffer)
3854 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3856 (gnus-close-backends)
3858 (gnus-kill-buffer gnus-group-buffer)
3859 ;; Allow the user to do things after cleaning up.
3860 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3862 (defun gnus-group-describe-briefly ()
3863 "Give a one line description of the group mode commands."
3865 (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")))
3867 (defun gnus-group-browse-foreign-server (method)
3868 "Browse a foreign news server.
3869 If called interactively, this function will ask for a select method
3870 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3871 If not, METHOD should be a list where the first element is the method
3872 and the second element is the address."
3874 (list (let ((how (completing-read
3876 (append gnus-valid-select-methods gnus-server-alist)
3877 nil t (cons "nntp" 0) 'gnus-method-history)))
3878 ;; We either got a backend name or a virtual server name.
3879 ;; If the first, we also need an address.
3880 (if (assoc how gnus-valid-select-methods)
3882 ;; Suggested by mapjph@bath.ac.uk.
3885 (mapcar (lambda (server) (list server))
3886 gnus-secondary-servers)))
3887 ;; We got a server name.
3889 (gnus-browse-foreign-server method))
3891 (defun gnus-group-set-info (info &optional method-only-group part)
3892 (when (or info part)
3893 (let* ((entry (gnus-gethash
3894 (or method-only-group (gnus-info-group info))
3895 gnus-newsrc-hashtb))
3897 (info (if method-only-group (nth 2 entry) info))
3899 (when method-only-group
3901 (error "Trying to change non-existent group %s" method-only-group))
3902 ;; We have received parts of the actual group info - either the
3903 ;; select method or the group parameters. We first check
3904 ;; whether we have to extend the info, and if so, do that.
3905 (let ((len (length info))
3906 (total (if (eq part 'method) 5 6)))
3908 (setcdr (nthcdr (1- len) info)
3909 (make-list (- total len) nil)))
3910 ;; Then we enter the new info.
3911 (setcar (nthcdr (1- total) info) part-info)))
3913 ;; This is a new group, so we just create it.
3915 (set-buffer gnus-group-buffer)
3916 (setq method (gnus-info-method info))
3917 (when (gnus-server-equal method "native")
3920 (set-buffer gnus-group-buffer)
3922 ;; It's a foreign group...
3923 (gnus-group-make-group
3924 (gnus-group-real-name (gnus-info-group info))
3925 (if (stringp method) method
3926 (prin1-to-string (car method)))
3928 (nth 1 (gnus-info-method info))))
3929 ;; It's a native group.
3930 (gnus-group-make-group (gnus-info-group info))))
3931 (gnus-message 6 "Note: New group created")
3933 (gnus-gethash (gnus-group-prefixed-name
3934 (gnus-group-real-name (gnus-info-group info))
3935 (or (gnus-info-method info) gnus-select-method))
3936 gnus-newsrc-hashtb))))
3937 ;; Whether it was a new group or not, we now have the entry, so we
3938 ;; can do the update.
3941 (setcar (nthcdr 2 entry) info)
3942 (when (and (not (eq (car entry) t))
3943 (gnus-active (gnus-info-group info)))
3944 (setcar entry (length
3945 (gnus-list-of-unread-articles (car info))))))
3946 (error "No such group: %s" (gnus-info-group info))))))
3948 (defun gnus-group-set-method-info (group select-method)
3949 (gnus-group-set-info select-method group 'method))
3951 (defun gnus-group-set-params-info (group params)
3952 (gnus-group-set-info params group 'params))
3954 (defun gnus-add-marked-articles (group type articles &optional info force)
3955 ;; Add ARTICLES of TYPE to the info of GROUP.
3956 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3957 ;; add, but replace marked articles of TYPE with ARTICLES.
3958 (let ((info (or info (gnus-get-info group)))
3961 (and (not (setq marked (nthcdr 3 info)))
3963 (setcdr (nthcdr 2 info)
3964 (list (list (cons type (gnus-compress-sequence
3966 (and (not (setq m (assq type (car marked))))
3969 (cons (cons type (gnus-compress-sequence articles t) )
3973 (setcar (nthcdr 3 info)
3974 (gnus-delete-alist type (car marked)))
3975 (setcdr m (gnus-compress-sequence articles t)))
3976 (setcdr m (gnus-compress-sequence
3977 (sort (nconc (gnus-uncompress-range (cdr m))
3978 (copy-sequence articles)) '<) t))))))
3980 (defun gnus-add-mark (group mark article)
3981 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3982 (let ((buffer (gnus-summary-buffer-name group)))
3983 (if (gnus-buffer-live-p buffer)
3985 (set-buffer (get-buffer buffer))
3986 (gnus-summary-add-mark article mark))
3987 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3991 ;;; Group timestamps
3994 (defun gnus-group-set-timestamp ()
3995 "Change the timestamp of the current group to the current time.
3996 This function can be used in hooks like `gnus-select-group-hook'
3997 or `gnus-group-catchup-group-hook'."
3998 (when gnus-newsgroup-name
3999 (let ((time (current-time)))
4000 (setcdr (cdr time) nil)
4001 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4003 (defsubst gnus-group-timestamp (group)
4004 "Return the timestamp for GROUP."
4005 (gnus-group-get-parameter group 'timestamp t))
4007 (defun gnus-group-timestamp-delta (group)
4008 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4009 (let* ((time (or (gnus-group-timestamp group)
4011 (delta (subtract-time (current-time) time)))
4012 (+ (* (nth 0 delta) 65536.0)
4015 (defun gnus-group-timestamp-string (group)
4016 "Return a string of the timestamp for GROUP."
4017 (let ((time (gnus-group-timestamp group)))
4020 (gnus-time-iso8601 time))))
4022 (defun gnus-group-list-cached (level &optional lowest)
4023 "List all groups with cached articles.
4024 If the prefix LEVEL is non-nil, it should be a number that says which
4025 level to cut off listing groups.
4026 If LOWEST, don't list groups with level lower than LOWEST.
4028 This command may read the active file."
4031 (setq level (prefix-numeric-value level)))
4032 (when (or (not level) (>= level gnus-level-zombie))
4034 (funcall gnus-group-prepare-function
4035 (or level gnus-level-subscribed)
4037 (let ((marks (gnus-info-marks info)))
4038 (assq 'cache marks)))
4041 (or (gnus-gethash group
4042 gnus-cache-active-hashtb)
4043 ;; Cache active file might use "."
4046 (mapconcat 'identity
4047 (split-string group ":")
4049 gnus-cache-active-hashtb))))
4050 (goto-char (point-min))
4051 (gnus-group-position-point))
4053 (defun gnus-group-list-dormant (level &optional lowest)
4054 "List all groups with dormant articles.
4055 If the prefix LEVEL is non-nil, it should be a number that says which
4056 level to cut off listing groups.
4057 If LOWEST, don't list groups with level lower than LOWEST.
4059 This command may read the active file."
4062 (setq level (prefix-numeric-value level)))
4063 (when (or (not level) (>= level gnus-level-zombie))
4065 (funcall gnus-group-prepare-function
4066 (or level gnus-level-subscribed)
4068 (let ((marks (gnus-info-marks info)))
4069 (assq 'dormant marks)))
4072 (goto-char (point-min))
4073 (gnus-group-position-point))
4075 (defun gnus-group-listed-groups ()
4076 "Return a list of listed groups."
4078 (goto-char (point-min))
4079 (while (setq point (text-property-not-all (point) (point-max)
4082 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4086 (defun gnus-group-list-plus (&optional args)
4087 "List groups plus the current selection."
4089 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4090 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4092 (push last-command-event unread-command-events)
4093 (if (featurep 'xemacs)
4094 (push (make-event 'key-press '(key ?A)) unread-command-events)
4095 (push ?A unread-command-events))
4096 (let (gnus-pick-mode keys)
4097 (setq keys (if (featurep 'xemacs)
4098 (events-to-keys (read-key-sequence nil))
4099 (read-key-sequence nil)))
4100 (setq func (lookup-key (current-local-map) keys)))
4104 (call-interactively func))))
4106 (defun gnus-group-list-flush (&optional args)
4107 "Flush groups from the current selection."
4109 (let ((gnus-group-list-option 'flush))
4110 (gnus-group-list-plus args)))
4112 (defun gnus-group-list-limit (&optional args)
4113 "List groups limited within the current selection."
4115 (let ((gnus-group-list-option 'limit))
4116 (gnus-group-list-plus args)))
4118 (defun gnus-group-mark-article-read (group article)
4119 "Mark ARTICLE read."
4120 (let ((buffer (gnus-summary-buffer-name group))
4121 (mark gnus-read-mark)
4123 (if (get-buffer buffer)
4124 (with-current-buffer buffer
4125 (setq active gnus-newsgroup-active)
4126 (gnus-activate-group group)
4127 (when gnus-newsgroup-prepared
4128 (when (and gnus-newsgroup-auto-expire
4129 (memq mark gnus-auto-expirable-marks))
4130 (setq mark gnus-expirable-mark))
4131 (setq mark (gnus-request-update-mark
4132 group article mark))
4133 (gnus-mark-article-as-read article mark)
4134 (setq gnus-newsgroup-active (gnus-active group))
4136 (setq n (1+ (cdr active)))
4137 (while (<= n (cdr gnus-newsgroup-active))
4138 (unless (eq n article)
4139 (push n gnus-newsgroup-unselected))
4141 (setq gnus-newsgroup-unselected
4142 (nreverse gnus-newsgroup-unselected)))))
4143 (gnus-activate-group group)
4144 (gnus-group-make-articles-read group (list article))
4145 (when (gnus-group-auto-expirable-p group)
4146 (gnus-add-marked-articles
4147 group 'expire (list article))))))
4149 (provide 'gnus-group)
4151 ;;; gnus-group.el ends here