1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%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 (completing-read
1957 "Group: " gnus-active-hashtb nil
1958 (gnus-read-active-file-p)
1959 gnus-group-jump-to-group-prompt
1960 'gnus-group-history)))
1962 (when (equal group "")
1963 (error "Empty group name"))
1965 (unless (gnus-ephemeral-group-p group)
1966 ;; Either go to the line in the group buffer...
1967 (unless (gnus-group-goto-group group)
1968 ;; ... or insert the line.
1969 (gnus-group-update-group group)
1970 (gnus-group-goto-group group)))
1971 ;; Adjust cursor point.
1972 (gnus-group-position-point))
1974 (defun gnus-group-goto-group (group &optional far test-marked)
1975 "Goto to newsgroup GROUP.
1976 If FAR, it is likely that the group is not on the current line.
1977 If TEST-MARKED, the line must be marked."
1981 ;; It's quite likely that we are on the right line, so
1982 ;; we check the current line first.
1984 (eq (get-text-property (point) 'gnus-group)
1985 (gnus-intern-safe group gnus-active-hashtb))
1986 (or (not test-marked) (gnus-group-mark-line-p)))
1988 ;; Previous and next line are also likely, so we check them as well.
1992 (and (eq (get-text-property (point) 'gnus-group)
1993 (gnus-intern-safe group gnus-active-hashtb))
1994 (or (not test-marked) (gnus-group-mark-line-p)))))
2000 (and (eq (get-text-property (point) 'gnus-group)
2001 (gnus-intern-safe group gnus-active-hashtb))
2002 (or (not test-marked) (gnus-group-mark-line-p)))))
2006 (goto-char (point-min))
2008 (while (and (not found)
2013 (gnus-intern-safe group gnus-active-hashtb))))
2014 (if (gnus-group-mark-line-p)
2019 ;; Search through the entire buffer.
2022 (point-min) (point-max)
2023 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2025 (defun gnus-group-next-group (n &optional silent)
2026 "Go to next N'th newsgroup.
2027 If N is negative, search backward instead.
2028 Returns the difference between N and the number of skips actually
2031 (gnus-group-next-unread-group n t nil silent))
2033 (defun gnus-group-next-unread-group (n &optional all level silent)
2034 "Go to next N'th unread newsgroup.
2035 If N is negative, search backward instead.
2036 If ALL is non-nil, choose any newsgroup, unread or not.
2037 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2038 such group can be found, the next group with a level higher than
2040 Returns the difference between N and the number of skips actually
2043 (let ((backward (< n 0))
2046 (gnus-group-search-forward
2047 backward (or (not gnus-group-goto-unread) all) level))
2051 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2052 (if level " on this level or higher" "")))
2055 (defun gnus-group-prev-group (n)
2056 "Go to previous N'th newsgroup.
2057 Returns the difference between N and the number of skips actually
2060 (gnus-group-next-unread-group (- n) t))
2062 (defun gnus-group-prev-unread-group (n)
2063 "Go to previous N'th unread newsgroup.
2064 Returns the difference between N and the number of skips actually
2067 (gnus-group-next-unread-group (- n)))
2069 (defun gnus-group-next-unread-group-same-level (n)
2070 "Go to next N'th unread newsgroup on the same level.
2071 If N is negative, search backward instead.
2072 Returns the difference between N and the number of skips actually
2075 (gnus-group-next-unread-group n t (gnus-group-group-level))
2076 (gnus-group-position-point))
2078 (defun gnus-group-prev-unread-group-same-level (n)
2079 "Go to next N'th unread newsgroup on the same level.
2080 Returns the difference between N and the number of skips actually
2083 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2084 (gnus-group-position-point))
2086 (defun gnus-group-best-unread-group (&optional exclude-group)
2087 "Go to the group with the highest level.
2088 If EXCLUDE-GROUP, do not go to that group."
2090 (goto-char (point-min))
2094 (setq unread (get-text-property (point) 'gnus-unread))
2095 (when (and (numberp unread) (> unread 0))
2096 (when (and (get-text-property (point) 'gnus-level)
2097 (< (get-text-property (point) 'gnus-level) best)
2098 (or (not exclude-group)
2099 (not (equal exclude-group (gnus-group-group-name)))))
2100 (setq best (get-text-property (point) 'gnus-level))
2101 (setq best-point (point))))
2104 (goto-char best-point))
2105 (gnus-group-position-point)
2106 (and best-point (gnus-group-group-name))))
2108 (defun gnus-group-first-unread-group ()
2109 "Go to the first group with unread articles."
2112 (let ((opoint (point))
2114 (goto-char (point-min))
2115 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2116 (and (numberp unread) ; Not a topic.
2117 (not (zerop unread))) ; Has unread articles.
2118 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2121 nil)) ; Not success.
2122 (gnus-group-position-point)))
2124 (defun gnus-group-enter-server-mode ()
2125 "Jump to the server buffer."
2127 (gnus-enter-server-buffer))
2129 (defun gnus-group-make-group (name &optional method address args)
2130 "Add a new newsgroup.
2131 The user will be prompted for a NAME, for a select METHOD, and an
2135 (gnus-read-group "Group name: ")
2136 (gnus-read-method "From method: ")))
2138 (when (stringp method)
2139 (setq method (or (gnus-server-to-method method) method)))
2140 (let* ((meth (gnus-method-simplify
2142 (not (gnus-server-equal method gnus-select-method)))
2143 (if address (list (intern method) address)
2145 (nname (if method (gnus-group-prefixed-name name meth) name))
2147 (when (gnus-gethash nname gnus-newsrc-hashtb)
2148 (error "Group %s already exists" nname))
2149 ;; Subscribe to the new group.
2150 (gnus-group-change-level
2151 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2152 gnus-level-default-subscribed gnus-level-killed
2153 (and (gnus-group-group-name)
2154 (gnus-gethash (gnus-group-group-name)
2155 gnus-newsrc-hashtb))
2158 (gnus-set-active nname (cons 1 0))
2159 (unless (gnus-ephemeral-group-p name)
2161 (concat "(gnus-group-set-info '"
2162 (gnus-prin1-to-string (cdr info)) ")")))
2164 (gnus-group-insert-group-line-info nname)
2166 (gnus-group-position-point)
2168 ;; Load the backend and try to make the backend create
2169 ;; the group as well.
2170 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2172 gnus-valid-select-methods)
2174 (gnus-check-server meth)
2175 (when (gnus-check-backend-function 'request-create-group nname)
2176 (gnus-request-create-group nname nil args))
2179 (defun gnus-group-delete-groups (&optional arg)
2180 "Delete the current group. Only meaningful with editable groups."
2182 (let ((n (length (gnus-group-process-prefix arg))))
2183 (when (gnus-yes-or-no-p
2185 "Delete this 1 group? "
2186 (format "Delete these %d groups? " n)))
2187 (gnus-group-iterate arg
2189 (gnus-group-delete-group group nil t))))))
2191 (defun gnus-group-delete-group (group &optional force no-prompt)
2192 "Delete the current group. Only meaningful with editable groups.
2193 If FORCE (the prefix) is non-nil, all the articles in the group will
2194 be deleted. This is \"deleted\" as in \"removed forever from the face
2195 of the Earth\". There is no undo. The user will be prompted before
2196 doing the deletion."
2198 (list (gnus-group-group-name)
2199 current-prefix-arg))
2201 (error "No group to delete"))
2202 (unless (gnus-check-backend-function 'request-delete-group group)
2203 (error "This backend does not support group deletion"))
2205 (if (and (not no-prompt)
2206 (not (gnus-yes-or-no-p
2208 "Do you really want to delete %s%s? "
2209 group (if force " and all its contents" "")))))
2211 (gnus-message 6 "Deleting group %s..." group)
2212 (if (not (gnus-request-delete-group group force))
2213 (gnus-error 3 "Couldn't delete group %s" group)
2214 (gnus-message 6 "Deleting group %s...done" group)
2215 (gnus-group-goto-group group)
2216 (gnus-group-kill-group 1 t)
2217 (gnus-sethash group nil gnus-active-hashtb)
2218 (when (and (boundp 'gnus-cache-active-hashtb)
2219 gnus-cache-active-hashtb)
2220 (gnus-sethash group nil gnus-cache-active-hashtb)
2221 (setq gnus-cache-active-altered t))
2223 (gnus-group-position-point)))
2225 (defun gnus-group-rename-group (group new-name)
2226 "Rename group from GROUP to NEW-NAME.
2227 When used interactively, GROUP is the group under point
2228 and NEW-NAME will be prompted for."
2231 (gnus-group-group-name)
2233 (unless (gnus-check-backend-function
2234 'request-rename-group (gnus-group-group-name))
2235 (error "This backend does not support renaming groups"))
2236 (gnus-read-group "Rename group to: "
2237 (gnus-group-real-name (gnus-group-group-name))))))
2239 (unless (gnus-check-backend-function 'request-rename-group group)
2240 (error "This backend does not support renaming groups"))
2242 (error "No group to rename"))
2243 (when (equal (gnus-group-real-name group) new-name)
2244 (error "Can't rename to the same name"))
2246 ;; We find the proper prefixed name.
2248 (if (gnus-group-native-p group)
2252 (gnus-group-prefixed-name
2253 (gnus-group-real-name new-name)
2254 (gnus-info-method (gnus-get-info group)))))
2256 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2259 (gnus-group-goto-group group)
2260 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2261 (gnus-request-rename-group group new-name))))
2262 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2263 ;; We rename the group internally by killing it...
2264 (gnus-group-kill-group)
2265 ;; ... changing its name ...
2266 (setcar (cdar gnus-list-of-killed-groups) new-name)
2267 ;; ... and then yanking it. Magic!
2268 (gnus-group-yank-group)
2269 (gnus-set-active new-name (gnus-active group))
2270 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2272 (setq gnus-killed-list (delete group gnus-killed-list))
2273 (gnus-set-active group nil)
2274 (gnus-dribble-touch)
2275 (gnus-group-position-point)))
2277 (defun gnus-group-edit-group (group &optional part)
2278 "Edit the group on the current line."
2279 (interactive (list (gnus-group-group-name)))
2280 (let ((part (or part 'info))
2283 (error "No group on current line"))
2284 (unless (setq info (gnus-get-info group))
2285 (error "Killed group; can't be edited"))
2287 (gnus-close-group group))
2289 ;; Find the proper form to edit.
2290 (cond ((eq part 'method)
2291 (or (gnus-info-method info) "native"))
2293 (gnus-info-params info))
2295 ;; The proper documentation.
2297 "Editing the %s for `%s'."
2299 ((eq part 'method) "select method")
2300 ((eq part 'params) "group parameters")
2302 (gnus-group-decoded-name group))
2304 (gnus-group-edit-group-done ',part ,group form)))
2307 (gnus-create-info-command
2310 "(gnus)Select Methods")
2312 "(gnus)Group Parameters")
2314 "(gnus)Group Info"))))))
2316 (defun gnus-group-edit-group-method (group)
2317 "Edit the select method of GROUP."
2318 (interactive (list (gnus-group-group-name)))
2319 (gnus-group-edit-group group 'method))
2321 (defun gnus-group-edit-group-parameters (group)
2322 "Edit the group parameters of GROUP."
2323 (interactive (list (gnus-group-group-name)))
2324 (gnus-group-edit-group group 'params))
2326 (defun gnus-group-edit-group-done (part group form)
2328 (let* ((method (cond ((eq part 'info) (nth 4 form))
2329 ((eq part 'method) form)
2331 (info (cond ((eq part 'info) form)
2332 ((eq part 'method) (gnus-get-info group))
2335 (if (or (not method)
2337 gnus-select-method method))
2338 (gnus-group-real-name (car info))
2339 (gnus-group-prefixed-name
2340 (gnus-group-real-name (car info)) method))
2342 (when (and new-group
2343 (not (equal new-group group)))
2344 (when (gnus-group-goto-group group)
2345 (gnus-group-kill-group 1))
2346 (gnus-activate-group new-group))
2348 (if (not (and info new-group))
2349 (gnus-group-set-info form (or new-group group) part)
2350 (setq info (gnus-copy-sequence info))
2351 (setcar info new-group)
2352 (unless (gnus-server-equal method "native")
2353 (unless (nthcdr 3 info)
2354 (nconc info (list nil nil)))
2355 (unless (nthcdr 4 info)
2356 (nconc info (list nil)))
2357 (gnus-info-set-method info method))
2358 (gnus-group-set-info info))
2359 (gnus-group-update-group (or new-group group))
2360 (gnus-group-position-point)))
2362 (defun gnus-group-make-useful-group (group method)
2363 "Create one of the groups described in `gnus-useful-groups'."
2365 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2367 gnus-useful-groups)))
2368 (list (cadr entry) (caddr entry))))
2369 (setq method (gnus-copy-sequence method))
2371 (while (setq entry (memq (assq 'eval method) method))
2372 (setcar entry (eval (cadar entry)))))
2373 (gnus-group-make-group group method))
2375 (defun gnus-group-make-help-group (&optional noerror)
2376 "Create the Gnus documentation group.
2377 Optional argument NOERROR modifies the behavior of this function when the
2378 group already exists:
2379 - if not given, and error is signaled,
2380 - if t, stay silent,
2381 - if anything else, just print a message."
2383 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2384 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2385 (if (gnus-gethash name gnus-newsrc-hashtb)
2386 (cond ((eq noerror nil)
2387 (error "Documentation group already exists"))
2392 (gnus-message 1 "Documentation group already exists")))
2395 (gnus-message 1 "Couldn't find doc group")
2396 (gnus-group-make-group
2397 (gnus-group-real-name name)
2398 (list 'nndoc "gnus-help"
2399 (list 'nndoc-address file)
2400 (list 'nndoc-article-type 'mbox))))
2402 (gnus-group-position-point))
2404 (defun gnus-group-make-doc-group (file type)
2405 "Create a group that uses a single file as the source."
2407 (list (read-file-name "File name: ")
2408 (and current-prefix-arg 'ask)))
2409 (when (eq type 'ask)
2414 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2416 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2417 ((= char ?b) 'babyl)
2418 ((= char ?d) 'digest)
2419 ((= char ?f) 'forward)
2421 ((= char ?g) 'guess)
2422 (t (setq err (format "%c unknown. " char))
2425 (let* ((file (expand-file-name file))
2426 (name (gnus-generate-new-group-name
2427 (gnus-group-prefixed-name
2428 (file-name-nondirectory file) '(nndoc "")))))
2429 (gnus-group-make-group
2430 (gnus-group-real-name name)
2432 (list 'nndoc-address file)
2433 (list 'nndoc-article-type (or type 'guess))))))
2435 (defvar nnweb-type-definition)
2436 (defvar gnus-group-web-type-history nil)
2437 (defvar gnus-group-web-search-history nil)
2438 (defun gnus-group-make-web-group (&optional solid)
2439 "Create an ephemeral nnweb group.
2440 If SOLID (the prefix), create a solid group."
2444 (if solid (gnus-read-group "Group name: ")
2445 (message-unique-id)))
2446 (default-type (or (car gnus-group-web-type-history)
2447 (symbol-name (caar nnweb-type-definition))))
2451 (format "Search engine type (default %s): " default-type)
2452 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2453 nnweb-type-definition)
2454 nil t nil 'gnus-group-web-type-history)
2459 (cons (or (car gnus-group-web-search-history) "") 0)
2460 'gnus-group-web-search-history))
2462 `(nnweb ,group (nnweb-search ,search)
2463 (nnweb-type ,(intern type))
2464 (nnweb-ephemeral-p t))))
2466 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2467 (gnus-group-read-ephemeral-group
2469 (cons (current-buffer)
2470 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2472 (defvar nnwarchive-type-definition)
2473 (defvar gnus-group-warchive-type-history nil)
2474 (defvar gnus-group-warchive-login-history nil)
2475 (defvar gnus-group-warchive-address-history nil)
2477 (defun gnus-group-make-warchive-group ()
2478 "Create a nnwarchive group."
2480 (require 'nnwarchive)
2481 (let* ((group (gnus-read-group "Group name: "))
2482 (default-type (or (car gnus-group-warchive-type-history)
2483 (symbol-name (caar nnwarchive-type-definition))))
2487 (format "Warchive type (default %s): " default-type)
2488 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2489 nnwarchive-type-definition)
2490 nil t nil 'gnus-group-warchive-type-history)
2492 (address (read-string "Warchive address: "
2493 nil 'gnus-group-warchive-address-history))
2494 (default-login (or (car gnus-group-warchive-login-history)
2499 (format "Warchive login (default %s): " user-mail-address)
2500 default-login 'gnus-group-warchive-login-history)
2503 `(nnwarchive ,address
2504 (nnwarchive-type ,(intern type))
2505 (nnwarchive-login ,login))))
2506 (gnus-group-make-group group method)))
2508 (defun gnus-group-make-archive-group (&optional all)
2509 "Create the (ding) Gnus archive group of the most recent articles.
2510 Given a prefix, create a full group."
2512 (let ((group (gnus-group-prefixed-name
2513 (if all "ding.archives" "ding.recent") '(nndir ""))))
2514 (when (gnus-gethash group gnus-newsrc-hashtb)
2515 (error "Archive group already exists"))
2516 (gnus-group-make-group
2517 (gnus-group-real-name group)
2518 (list 'nndir (if all "hpc" "edu")
2519 (list 'nndir-directory
2520 (if all gnus-group-archive-directory
2521 gnus-group-recent-archive-directory))))
2522 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2524 (defun gnus-group-make-directory-group (dir)
2525 "Create an nndir group.
2526 The user will be prompted for a directory. The contents of this
2527 directory will be used as a newsgroup. The directory should contain
2528 mail messages or news articles in files that have numeric names."
2530 (list (read-file-name "Create group from directory: ")))
2531 (unless (file-exists-p dir)
2532 (error "No such directory"))
2533 (unless (file-directory-p dir)
2534 (error "Not a directory"))
2538 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2540 (gnus-group-prefixed-name
2541 (expand-file-name ext dir)
2543 (setq ext (format "<%d>" (setq i (1+ i)))))
2544 (gnus-group-make-group
2545 (gnus-group-real-name group)
2546 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2548 (eval-when-compile (defvar nnkiboze-score-file))
2549 (defun gnus-group-make-kiboze-group (group address scores)
2550 "Create an nnkiboze group.
2551 The user will be prompted for a name, a regexp to match groups, and
2552 score file entries for articles to include in the group."
2555 (read-string "nnkiboze group name: ")
2556 (read-string "Source groups (regexp): ")
2557 (let ((headers (mapcar (lambda (group) (list group))
2558 '("subject" "from" "number" "date" "message-id"
2559 "references" "chars" "lines" "xref"
2560 "followup" "all" "body" "head")))
2561 scores header regexp regexps)
2562 (while (not (equal "" (setq header (completing-read
2563 "Match on header: " headers nil t))))
2565 (while (not (equal "" (setq regexp (read-string
2566 (format "Match on %s (regexp): "
2568 (push (list regexp nil nil 'r) regexps))
2569 (push (cons header regexps) scores))
2571 (gnus-group-make-group group "nnkiboze" address)
2572 (let* ((nnkiboze-current-group group)
2573 (score-file (car (nnkiboze-score-file "")))
2574 (score-dir (file-name-directory score-file)))
2575 (unless (file-exists-p score-dir)
2576 (make-directory score-dir))
2577 (with-temp-file score-file
2578 (let (emacs-lisp-mode-hook)
2579 (pp scores (current-buffer))))))
2581 (defun gnus-group-add-to-virtual (n vgroup)
2582 "Add the current group to a virtual group."
2584 (list current-prefix-arg
2585 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2587 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2588 (error "%s is not an nnvirtual group" vgroup))
2589 (gnus-close-group vgroup)
2590 (let* ((groups (gnus-group-process-prefix n))
2591 (method (gnus-info-method (gnus-get-info vgroup))))
2592 (setcar (cdr method)
2594 (nth 1 method) "\\|"
2597 (gnus-group-remove-mark s)
2598 (concat "\\(^" (regexp-quote s) "$\\)"))
2600 (gnus-group-position-point))
2602 (defun gnus-group-make-empty-virtual (group)
2603 "Create a new, fresh, empty virtual group."
2604 (interactive "sCreate new, empty virtual group: ")
2605 (let* ((method (list 'nnvirtual "^$"))
2606 (pgroup (gnus-group-prefixed-name group method)))
2607 ;; Check whether it exists already.
2608 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2609 (error "Group %s already exists" pgroup))
2610 ;; Subscribe the new group after the group on the current line.
2611 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2612 (gnus-group-update-group pgroup)
2614 (gnus-group-position-point)))
2616 (defun gnus-group-enter-directory (dir)
2617 "Enter an ephemeral nneething group."
2618 (interactive "DDirectory to read: ")
2619 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2620 (leaf (gnus-group-prefixed-name
2621 (file-name-nondirectory (directory-file-name dir))
2623 (name (gnus-generate-new-group-name leaf)))
2624 (unless (gnus-group-read-ephemeral-group
2626 (cons (current-buffer)
2627 (if (eq major-mode 'gnus-summary-mode)
2629 (error "Couldn't enter %s" dir))))
2632 (autoload 'nnimap-expunge "nnimap")
2633 (autoload 'nnimap-acl-get "nnimap")
2634 (autoload 'nnimap-acl-edit "nnimap"))
2636 (defun gnus-group-nnimap-expunge (group)
2637 "Expunge deleted articles in current nnimap GROUP."
2638 (interactive (list (gnus-group-group-name)))
2639 (let ((mailbox (gnus-group-real-name group)) method)
2641 (error "No group on current line"))
2642 (unless (gnus-get-info group)
2643 (error "Killed group; can't be edited"))
2644 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2645 (error "%s is not an nnimap group" group))
2646 (nnimap-expunge mailbox (cadr method))))
2648 (defun gnus-group-nnimap-edit-acl (group)
2649 "Edit the Access Control List of current nnimap GROUP."
2650 (interactive (list (gnus-group-group-name)))
2651 (let ((mailbox (gnus-group-real-name group)) method acl)
2653 (error "No group on current line"))
2654 (unless (gnus-get-info group)
2655 (error "Killed group; can't be edited"))
2656 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2657 (error "%s is not an nnimap group" group))
2658 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2659 (error "Server does not support ACL's"))
2660 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2662 An access control list is a list of (identifier . rights) elements.
2664 The identifier string specifies the corresponding user. The
2665 identifier \"anyone\" is reserved to refer to the universal identity.
2667 Rights is a string listing a (possibly empty) set of alphanumeric
2668 characters, each character listing a set of operations which is being
2669 controlled. Letters are reserved for ``standard'' rights, listed
2670 below. Digits are reserved for implementation or site defined rights.
2672 l - lookup (mailbox is visible to LIST/LSUB commands)
2673 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2674 SEARCH, COPY from mailbox)
2675 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2676 w - write (STORE flags other than \\SEEN and \\DELETED)
2677 i - insert (perform APPEND, COPY into mailbox)
2678 p - post (send mail to submission address for mailbox,
2679 not enforced by IMAP4 itself)
2680 c - create and delete mailbox (CREATE new sub-mailboxes in any
2681 implementation-defined hierarchy, RENAME or DELETE mailbox)
2682 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2683 a - administer (perform SETACL)" group)
2686 ,mailbox ',method ',acl form)))))
2688 ;; Group sorting commands
2689 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2691 (defun gnus-group-sort-groups (func &optional reverse)
2692 "Sort the group buffer according to FUNC.
2693 When used interactively, the sorting function used will be
2694 determined by the `gnus-group-sort-function' variable.
2695 If REVERSE (the prefix), reverse the sorting order."
2696 (interactive (list gnus-group-sort-function current-prefix-arg))
2697 (funcall gnus-group-sort-alist-function
2698 (gnus-make-sort-function func) reverse)
2699 (gnus-group-unmark-all-groups)
2700 (gnus-group-list-groups)
2701 (gnus-dribble-touch))
2703 (defun gnus-group-sort-flat (func reverse)
2704 ;; We peel off the dummy group from the alist.
2706 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2707 (pop gnus-newsrc-alist))
2709 (setq gnus-newsrc-alist
2710 (sort gnus-newsrc-alist func))
2712 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2713 ;; Regenerate the hash table.
2714 (gnus-make-hashtable-from-newsrc-alist)))
2716 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2717 "Sort the group buffer alphabetically by group name.
2718 If REVERSE, sort in reverse order."
2720 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2722 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2723 "Sort the group buffer alphabetically by real (unprefixed) group name.
2724 If REVERSE, sort in reverse order."
2726 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2728 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2729 "Sort the group buffer by number of unread articles.
2730 If REVERSE, sort in reverse order."
2732 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2734 (defun gnus-group-sort-groups-by-level (&optional reverse)
2735 "Sort the group buffer by group level.
2736 If REVERSE, sort in reverse order."
2738 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2740 (defun gnus-group-sort-groups-by-score (&optional reverse)
2741 "Sort the group buffer by group score.
2742 If REVERSE, sort in reverse order."
2744 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2746 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2747 "Sort the group buffer by group rank.
2748 If REVERSE, sort in reverse order."
2750 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2752 (defun gnus-group-sort-groups-by-method (&optional reverse)
2753 "Sort the group buffer alphabetically by backend name.
2754 If REVERSE, sort in reverse order."
2756 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2758 (defun gnus-group-sort-groups-by-server (&optional reverse)
2759 "Sort the group buffer alphabetically by server name.
2760 If REVERSE, sort in reverse order."
2762 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2764 ;;; Selected group sorting.
2766 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2767 "Sort the process/prefixed groups."
2768 (interactive (list current-prefix-arg gnus-group-sort-function))
2769 (let ((groups (gnus-group-process-prefix n)))
2770 (funcall gnus-group-sort-selected-function
2771 groups (gnus-make-sort-function func) reverse)
2772 (gnus-group-unmark-all-groups)
2773 (gnus-group-list-groups)
2774 (gnus-dribble-touch)))
2776 (defun gnus-group-sort-selected-flat (groups func reverse)
2777 (let (entries infos)
2778 ;; First find all the group entries for these groups.
2780 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2782 ;; Then sort the infos.
2786 (lambda (entry) (car entry))
2787 (setq entries (nreverse entries)))
2790 (setq infos (nreverse infos)))
2791 ;; Go through all the infos and replace the old entries
2792 ;; with the new infos.
2794 (setcar (car entries) (pop infos))
2796 ;; Update the hashtable.
2797 (gnus-make-hashtable-from-newsrc-alist)))
2799 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2800 "Sort the group buffer alphabetically by group name.
2801 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2802 sort in reverse order."
2803 (interactive (gnus-interactive "P\ny"))
2804 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2806 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2807 "Sort the group buffer alphabetically by real group name.
2808 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2809 sort in reverse order."
2810 (interactive (gnus-interactive "P\ny"))
2811 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2813 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2814 "Sort the group buffer by number of unread articles.
2815 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2816 sort in reverse order."
2817 (interactive (gnus-interactive "P\ny"))
2818 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2820 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2821 "Sort the group buffer by group level.
2822 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2823 sort in reverse order."
2824 (interactive (gnus-interactive "P\ny"))
2825 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2827 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2828 "Sort the group buffer by group score.
2829 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2830 sort in reverse order."
2831 (interactive (gnus-interactive "P\ny"))
2832 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2834 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2835 "Sort the group buffer by group rank.
2836 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2837 sort in reverse order."
2838 (interactive (gnus-interactive "P\ny"))
2839 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2841 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2842 "Sort the group buffer alphabetically by backend name.
2843 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2844 sort in reverse order."
2845 (interactive (gnus-interactive "P\ny"))
2846 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2848 ;;; Sorting predicates.
2850 (defun gnus-group-sort-by-alphabet (info1 info2)
2851 "Sort alphabetically."
2852 (string< (gnus-info-group info1) (gnus-info-group info2)))
2854 (defun gnus-group-sort-by-real-name (info1 info2)
2855 "Sort alphabetically on real (unprefixed) names."
2856 (string< (gnus-group-real-name (gnus-info-group info1))
2857 (gnus-group-real-name (gnus-info-group info2))))
2859 (defun gnus-group-sort-by-unread (info1 info2)
2860 "Sort by number of unread articles."
2861 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2862 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2863 (< (or (and (numberp n1) n1) 0)
2864 (or (and (numberp n2) n2) 0))))
2866 (defun gnus-group-sort-by-level (info1 info2)
2868 (< (gnus-info-level info1) (gnus-info-level info2)))
2870 (defun gnus-group-sort-by-method (info1 info2)
2871 "Sort alphabetically by backend name."
2872 (string< (car (gnus-find-method-for-group
2873 (gnus-info-group info1) info1))
2874 (car (gnus-find-method-for-group
2875 (gnus-info-group info2) info2))))
2877 (defun gnus-group-sort-by-server (info1 info2)
2878 "Sort alphabetically by server name."
2879 (string< (gnus-method-to-full-server-name
2880 (gnus-find-method-for-group
2881 (gnus-info-group info1) info1))
2882 (gnus-method-to-full-server-name
2883 (gnus-find-method-for-group
2884 (gnus-info-group info2) info2))))
2886 (defun gnus-group-sort-by-score (info1 info2)
2887 "Sort by group score."
2888 (> (gnus-info-score info1) (gnus-info-score info2)))
2890 (defun gnus-group-sort-by-rank (info1 info2)
2891 "Sort by level and score."
2892 (let ((level1 (gnus-info-level info1))
2893 (level2 (gnus-info-level info2)))
2894 (or (< level1 level2)
2895 (and (= level1 level2)
2896 (> (gnus-info-score info1) (gnus-info-score info2))))))
2900 (defun gnus-group-clear-data (&optional arg)
2901 "Clear all marks and read ranges from the current group."
2903 (gnus-group-iterate arg
2906 (gnus-info-clear-data (setq info (gnus-get-info group)))
2907 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2908 (when (gnus-group-goto-group group)
2909 (gnus-group-update-group-line))))))
2911 (defun gnus-group-clear-data-on-native-groups ()
2912 "Clear all marks and read ranges from all native groups."
2914 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2915 (let ((alist (cdr gnus-newsrc-alist))
2917 (while (setq info (pop alist))
2918 (when (gnus-group-native-p (gnus-info-group info))
2919 (gnus-info-clear-data info)))
2920 (gnus-get-unread-articles)
2921 (gnus-dribble-touch)
2922 (when (gnus-y-or-n-p
2923 "Move the cache away to avoid problems in the future? ")
2924 (call-interactively 'gnus-cache-move-cache)))))
2926 (defun gnus-info-clear-data (info)
2927 "Clear all marks and read ranges from INFO."
2928 (let ((group (gnus-info-group info))
2930 (dolist (el (gnus-info-marks info))
2931 (push `(,(cdr el) add (,(car el))) action))
2932 (push `(,(gnus-info-read info) add (read)) action)
2935 (gnus-request-set-mark ,group ',action)
2936 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2937 (gnus-info-set-read ',info ',(gnus-info-read info))
2938 (when (gnus-group-goto-group ,group)
2939 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2940 (gnus-group-update-group-line))))
2941 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2943 (gnus-request-set-mark group action)
2944 (gnus-info-set-read info nil)
2945 (when (gnus-info-marks info)
2946 (gnus-info-set-marks info nil))))
2948 ;; Group catching up.
2950 (defun gnus-group-catchup-current (&optional n all)
2951 "Mark all unread articles in the current newsgroup as read.
2952 If prefix argument N is numeric, the next N newsgroups will be
2953 caught up. If ALL is non-nil, marked articles will also be marked as
2954 read. Cross references (Xref: header) of articles are ignored.
2955 The number of newsgroups that this function was unable to catch
2958 (let ((groups (gnus-group-process-prefix n))
2961 (unless groups (error "No groups selected"))
2963 (or (not gnus-interactive-catchup) ;Without confirmation?
2968 "Do you really want to mark all articles in %s as read? "
2969 "Mark all unread articles in %s as read? ")
2970 (if (= (length groups) 1)
2972 (format "these %d groups" (length groups)))))))
2974 (while (setq group (pop groups))
2975 (gnus-group-remove-mark group)
2976 ;; Virtual groups have to be given special treatment.
2977 (let ((method (gnus-find-method-for-group group)))
2978 (when (eq 'nnvirtual (car method))
2979 (nnvirtual-catchup-group
2980 (gnus-group-real-name group) (nth 1 method) all)))
2981 (if (>= (gnus-group-level group) gnus-level-zombie)
2982 (gnus-message 2 "Dead groups can't be caught up")
2984 (gnus-group-goto-group group)
2985 (gnus-group-catchup group all))
2986 (gnus-group-update-group-line)
2987 (setq ret (1+ ret)))))
2988 (gnus-group-next-unread-group 1)
2991 (defun gnus-group-catchup-current-all (&optional n)
2992 "Mark all articles in current newsgroup as read.
2993 Cross references (Xref: header) of articles are ignored."
2995 (gnus-group-catchup-current n 'all))
2997 (defun gnus-group-catchup (group &optional all)
2998 "Mark all articles in GROUP as read.
2999 If ALL is non-nil, all articles are marked as read.
3000 The return value is the number of articles that were marked as read,
3001 or nil if no action could be taken."
3002 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3004 (marks (nth 3 (nth 2 entry)))
3005 (unread (gnus-list-of-unread-articles group)))
3006 ;; Remove entries for this group.
3007 (nnmail-purge-split-history (gnus-group-real-name group))
3008 ;; Do the updating only if the newsgroup isn't killed.
3009 (if (not (numberp (car entry)))
3010 (gnus-message 1 "Can't catch up %s; non-active group" group)
3011 (gnus-update-read-articles group nil)
3013 ;; Nix out the lists of marks and dormants.
3014 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3016 (list (cdr (assq 'dormant marks))
3018 (setq unread (gnus-uncompress-range
3019 (gnus-range-add (gnus-range-add
3020 unread (cdr (assq 'dormant marks)))
3021 (cdr (assq 'tick marks)))))
3022 (gnus-add-marked-articles group 'tick nil nil 'force)
3023 (gnus-add-marked-articles group 'dormant nil nil 'force))
3024 ;; Do auto-expirable marks if that's required.
3025 (when (gnus-group-auto-expirable-p group)
3026 (gnus-add-marked-articles group 'expire unread)
3027 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3028 (let ((gnus-newsgroup-name group))
3029 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3032 (defun gnus-group-expire-articles (&optional n)
3033 "Expire all expirable articles in the current newsgroup."
3035 (let ((groups (gnus-group-process-prefix n))
3038 (error "No groups to expire"))
3039 (while (setq group (pop groups))
3040 (gnus-group-remove-mark group)
3041 (gnus-group-expire-articles-1 group)
3042 (gnus-dribble-touch)
3043 (gnus-group-position-point))))
3045 (defun gnus-group-expire-articles-1 (group)
3046 (when (gnus-check-backend-function 'request-expire-articles group)
3047 (gnus-message 6 "Expiring articles in %s..." group)
3048 (let* ((info (gnus-get-info group))
3049 (expirable (if (gnus-group-total-expirable-p group)
3050 (cons nil (gnus-list-of-read-articles group))
3051 (assq 'expire (gnus-info-marks info))))
3052 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3053 (nnmail-expiry-target
3054 (or (gnus-group-find-parameter group 'expiry-target)
3055 nnmail-expiry-target)))
3057 (gnus-check-group group)
3060 (gnus-compress-sequence
3062 ;; We set the expiry variables to the group
3064 (let ((nnmail-expiry-wait-function nil)
3065 (nnmail-expiry-wait expiry-wait))
3066 (gnus-request-expire-articles
3067 (gnus-uncompress-sequence (cdr expirable)) group))
3068 ;; Just expire using the normal expiry values.
3069 (gnus-request-expire-articles
3070 (gnus-uncompress-sequence (cdr expirable)) group))))
3071 (gnus-close-group group))
3072 (gnus-message 6 "Expiring articles in %s...done" group)
3073 ;; Return the list of un-expired articles.
3076 (defun gnus-group-expire-all-groups ()
3077 "Expire all expirable articles in all newsgroups."
3080 (gnus-message 5 "Expiring...")
3081 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3082 (cdr gnus-newsrc-alist))))
3083 (gnus-group-expire-articles nil)))
3084 (gnus-group-position-point)
3085 (gnus-message 5 "Expiring...done"))
3087 (defun gnus-group-set-current-level (n level)
3088 "Set the level of the next N groups to LEVEL."
3093 (let ((s (read-string
3094 (format "Level (default %s): "
3095 (or (gnus-group-group-level)
3096 gnus-level-default-subscribed)))))
3097 (if (string-match "^\\s-*$" s)
3098 (int-to-string (or (gnus-group-group-level)
3099 gnus-level-default-subscribed))
3101 (unless (and (>= level 1) (<= level gnus-level-killed))
3102 (error "Invalid level: %d" level))
3103 (let ((groups (gnus-group-process-prefix n))
3105 (while (setq group (pop groups))
3106 (gnus-group-remove-mark group)
3107 (gnus-message 6 "Changed level of %s from %d to %d"
3108 group (or (gnus-group-group-level) gnus-level-killed)
3110 (gnus-group-change-level
3111 group level (or (gnus-group-group-level) gnus-level-killed))
3112 (gnus-group-update-group-line)))
3113 (gnus-group-position-point))
3115 (defun gnus-group-unsubscribe (&optional n)
3116 "Unsubscribe the current group."
3118 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3120 (defun gnus-group-subscribe (&optional n)
3121 "Subscribe the current group."
3123 (gnus-group-unsubscribe-current-group n 'subscribe))
3125 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3126 "Toggle subscription of the current group.
3127 If given numerical prefix, toggle the N next groups."
3129 (let ((groups (gnus-group-process-prefix n))
3132 (setq group (car groups)
3133 groups (cdr groups))
3134 (gnus-group-remove-mark group)
3135 (gnus-group-unsubscribe-group
3138 ((eq do-sub 'unsubscribe)
3139 gnus-level-default-unsubscribed)
3140 ((eq do-sub 'subscribe)
3141 gnus-level-default-subscribed)
3142 ((<= (gnus-group-group-level) gnus-level-subscribed)
3143 gnus-level-default-unsubscribed)
3145 gnus-level-default-subscribed))
3147 (gnus-group-update-group-line))
3148 (gnus-group-next-group 1)))
3150 (defun gnus-group-unsubscribe-group (group &optional level silent)
3151 "Toggle subscription to GROUP.
3152 Killed newsgroups are subscribed. If SILENT, don't try to update the
3155 (list (completing-read
3156 "Group: " gnus-active-hashtb nil
3157 (gnus-read-active-file-p)
3159 'gnus-group-history)))
3160 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3162 ((string-match "^[ \t]*$" group)
3163 (error "Empty group name"))
3165 ;; Toggle subscription flag.
3166 (gnus-group-change-level
3167 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3168 gnus-level-subscribed)
3169 (1+ gnus-level-subscribed)
3170 gnus-level-default-subscribed)))
3172 (gnus-group-update-group group)))
3173 ((and (stringp group)
3174 (or (not (gnus-read-active-file-p))
3175 (gnus-active group)))
3176 ;; Add new newsgroup.
3177 (gnus-group-change-level
3179 (if level level gnus-level-default-subscribed)
3180 (or (and (member group gnus-zombie-list)
3183 (when (gnus-group-group-name)
3184 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3186 (gnus-group-update-group group)))
3187 (t (error "No such newsgroup: %s" group)))
3188 (gnus-group-position-point)))
3190 (defun gnus-group-transpose-groups (n)
3191 "Move the current newsgroup up N places.
3192 If given a negative prefix, move down instead. The difference between
3193 N and the number of steps taken is returned."
3195 (unless (gnus-group-group-name)
3196 (error "No group on current line"))
3197 (gnus-group-kill-group 1)
3199 (forward-line (- n))
3200 (gnus-group-yank-group)
3201 (gnus-group-position-point)))
3203 (defun gnus-group-kill-all-zombies (&optional dummy)
3204 "Kill all zombie newsgroups.
3205 The optional DUMMY should always be nil."
3206 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3208 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3209 (setq gnus-zombie-list nil)
3210 (gnus-dribble-touch)
3211 (gnus-group-list-groups)))
3213 (defun gnus-group-kill-region (begin end)
3214 "Kill newsgroups in current region (excluding current point).
3215 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3230 (beginning-of-line) ;Important when LINES < 1
3231 (gnus-group-kill-group lines)))
3233 (defun gnus-group-kill-group (&optional n discard)
3234 "Kill the next N groups.
3235 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3236 However, only groups that were alive can be yanked; already killed
3237 groups or zombie groups can't be yanked.
3238 The return value is the name of the group that was killed, or a list
3241 (let ((buffer-read-only nil)
3242 (groups (gnus-group-process-prefix n))
3243 group entry level out)
3244 (if (< (length groups) 10)
3245 ;; This is faster when there are few groups.
3247 (push (setq group (pop groups)) out)
3248 (gnus-group-remove-mark group)
3249 (setq level (gnus-group-group-level))
3251 (when (and (not discard)
3252 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3255 (gnus-group-goto-group ,(gnus-group-group-name))
3256 (gnus-group-yank-group)))
3257 (push (cons (car entry) (nth 2 entry))
3258 gnus-list-of-killed-groups))
3259 (gnus-group-change-level
3260 (if entry entry group) gnus-level-killed (if entry nil level))
3261 (message "Killed group %s" group))
3262 ;; If there are lots and lots of groups to be killed, we use
3263 ;; this thing instead.
3265 (setq groups (nreverse groups))
3267 (gnus-group-remove-mark (setq group (pop groups)))
3269 (push group gnus-killed-list)
3270 (setq gnus-newsrc-alist
3271 (delq (assoc group gnus-newsrc-alist)
3273 (when gnus-group-change-level-function
3274 (funcall gnus-group-change-level-function
3275 group gnus-level-killed 3))
3277 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3278 (push (cons (car entry) (nth 2 entry))
3279 gnus-list-of-killed-groups)
3280 (setcdr (cdr entry) (cdddr entry)))
3281 ((member group gnus-zombie-list)
3282 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3283 ;; There may be more than one instance displayed.
3284 (while (gnus-group-goto-group group)
3285 (gnus-delete-line)))
3286 (gnus-make-hashtable-from-newsrc-alist)))
3288 (gnus-group-position-point)
3289 (if (< (length out) 2) (car out) (nreverse out))))
3291 (defun gnus-group-yank-group (&optional arg)
3292 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3293 The numeric ARG specifies how many newsgroups are to be yanked. The
3294 name of the newsgroup yanked is returned, or (if several groups are
3295 yanked) a list of yanked groups is returned."
3297 (setq arg (or arg 1))
3298 (let (info group prev out)
3299 (while (>= (decf arg) 0)
3300 (when (not (setq info (pop gnus-list-of-killed-groups)))
3301 (error "No more newsgroups to yank"))
3302 (push (setq group (nth 1 info)) out)
3303 ;; Find which newsgroup to insert this one before - search
3304 ;; backward until something suitable is found. If there are no
3305 ;; other newsgroups in this buffer, just make this newsgroup the
3307 (setq prev (gnus-group-group-name))
3308 (gnus-group-change-level
3309 info (gnus-info-level (cdr info)) gnus-level-killed
3310 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3312 (gnus-group-insert-group-line-info group)
3314 `(when (gnus-group-goto-group ,group)
3315 (gnus-group-kill-group 1))))
3317 (gnus-group-position-point)
3318 (if (< (length out) 2) (car out) (nreverse out))))
3320 (defun gnus-group-kill-level (level)
3321 "Kill all groups that is on a certain LEVEL."
3322 (interactive "nKill all groups on level: ")
3324 ((= level gnus-level-zombie)
3325 (setq gnus-killed-list
3326 (nconc gnus-zombie-list gnus-killed-list))
3327 (setq gnus-zombie-list nil))
3328 ((and (< level gnus-level-zombie)
3330 (or gnus-expert-user
3333 "Do you really want to kill all groups on level %d? "
3335 (let* ((prev gnus-newsrc-alist)
3338 (if (= (gnus-info-level (car alist)) level)
3340 (push (gnus-info-group (car alist)) gnus-killed-list)
3341 (setcdr prev (cdr alist)))
3343 (setq alist (cdr alist)))
3344 (gnus-make-hashtable-from-newsrc-alist)
3345 (gnus-group-list-groups)))
3347 (error "Can't kill; invalid level: %d" level))))
3349 (defun gnus-group-list-all-groups (&optional arg)
3350 "List all newsgroups with level ARG or lower.
3351 Default is gnus-level-unsubscribed, which lists all subscribed and most
3352 unsubscribed groups."
3354 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3356 ;; Redefine this to list ALL killed groups if prefix arg used.
3357 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3358 (defun gnus-group-list-killed (&optional arg)
3359 "List all killed newsgroups in the group buffer.
3360 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3361 entail asking the server for the groups."
3363 ;; Find all possible killed newsgroups if arg.
3365 (gnus-get-killed-groups))
3366 (if (not gnus-killed-list)
3367 (gnus-message 6 "No killed groups")
3368 (let (gnus-group-list-mode)
3369 (funcall gnus-group-prepare-function
3370 gnus-level-killed t gnus-level-killed))
3371 (goto-char (point-min)))
3372 (gnus-group-position-point))
3374 (defun gnus-group-list-zombies ()
3375 "List all zombie newsgroups in the group buffer."
3377 (if (not gnus-zombie-list)
3378 (gnus-message 6 "No zombie groups")
3379 (let (gnus-group-list-mode)
3380 (funcall gnus-group-prepare-function
3381 gnus-level-zombie t gnus-level-zombie))
3382 (goto-char (point-min)))
3383 (gnus-group-position-point))
3385 (defun gnus-group-list-active ()
3386 "List all groups that are available from the server(s)."
3388 ;; First we make sure that we have really read the active file.
3389 (unless (gnus-read-active-file-p)
3390 (let ((gnus-read-active-file t)
3391 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3392 (gnus-read-active-file)))
3393 ;; Find all groups and sort them.
3401 (push (symbol-name sym) list)))
3405 (buffer-read-only nil)
3409 (setq group (pop groups))
3410 (gnus-add-text-properties
3411 (point) (prog1 (1+ (point))
3413 (gnus-group-decoded-name group)
3415 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3417 'gnus-level (inline (gnus-group-level group)))))
3418 (goto-char (point-min))))
3420 (defun gnus-activate-all-groups (level)
3421 "Activate absolutely all groups."
3422 (interactive (list gnus-level-unsubscribed))
3423 (let ((gnus-activate-level level)
3424 (gnus-activate-foreign-newsgroups level))
3425 (gnus-group-get-new-news)))
3427 (defun gnus-group-get-new-news (&optional arg)
3428 "Get newly arrived articles.
3429 If ARG is a number, it specifies which levels you are interested in
3430 re-scanning. If ARG is non-nil and not a number, this will force
3431 \"hard\" re-reading of the active files from all servers."
3434 (let ((gnus-inhibit-demon t)
3435 ;; Binding this variable will inhibit multiple fetchings
3436 ;; of the same mail source.
3437 (nnmail-fetched-sources (list t)))
3438 (gnus-run-hooks 'gnus-get-new-news-hook)
3440 ;; Read any slave files.
3442 (gnus-master-read-slave-newsrc))
3444 ;; We might read in new NoCeM messages here.
3445 (when (and gnus-use-nocem
3447 (gnus-nocem-scan-groups))
3448 ;; If ARG is not a number, then we read the active file.
3449 (when (and arg (not (numberp arg)))
3450 (let ((gnus-read-active-file t))
3451 (gnus-read-active-file))
3454 ;; If the user wants it, we scan for new groups.
3455 (when (eq gnus-check-new-newsgroups 'always)
3456 (gnus-find-new-newsgroups)))
3458 (setq arg (gnus-group-default-level arg t))
3459 (if (and gnus-read-active-file (not arg))
3461 (gnus-read-active-file)
3462 (gnus-get-unread-articles arg))
3463 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3464 (gnus-get-unread-articles arg)))
3465 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3466 (gnus-group-list-groups (and (numberp arg)
3467 (max (car gnus-group-list-mode) arg)))))
3469 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3470 "Check for newly arrived news in the current group (and the N-1 next groups).
3471 The difference between N and the number of newsgroup checked is returned.
3472 If N is negative, this group and the N-1 previous groups will be checked."
3474 (let* ((groups (gnus-group-process-prefix n))
3475 (ret (if (numberp n) (- n (length groups)) 0))
3479 (gnus-inhibit-demon t)
3480 ;; Binding this variable will inhibit multiple fetchings
3481 ;; of the same mail source.
3482 (nnmail-fetched-sources (list t)))
3483 (gnus-run-hooks 'gnus-get-new-news-hook)
3484 (while (setq group (pop groups))
3485 (gnus-group-remove-mark group)
3486 ;; Bypass any previous denials from the server.
3487 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3488 (if (gnus-activate-group group (if dont-scan nil 'scan))
3490 (gnus-get-unread-articles-in-group
3491 (gnus-get-info group) (gnus-active group) t)
3492 (unless (gnus-virtual-group-p group)
3493 (gnus-close-group group))
3495 (gnus-agent-save-group-info
3496 method (gnus-group-real-name group) (gnus-active group)))
3497 (gnus-group-update-group group))
3498 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3500 (gnus-error 3 "Server denied access")
3501 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3504 (when gnus-goto-next-group-when-activating
3505 (gnus-group-next-unread-group 1 t))
3506 (gnus-summary-position-point)
3509 (defun gnus-group-fetch-faq (group &optional faq-dir)
3510 "Fetch the FAQ for the current group.
3511 If given a prefix argument, prompt for the FAQ dir
3515 (gnus-group-group-name)
3516 (when current-prefix-arg
3518 "FAQ dir: " (and (listp gnus-group-faq-directory)
3520 gnus-group-faq-directory))))))
3522 (error "No group name given"))
3523 (let ((dirs (or faq-dir gnus-group-faq-directory))
3525 (unless (listp dirs)
3526 (setq dirs (list dirs)))
3527 (while (and (not found)
3528 (setq dir (pop dirs)))
3529 (let ((name (gnus-group-real-name group)))
3530 (setq file (expand-file-name name dir)))
3531 (if (not (file-exists-p file))
3532 (gnus-message 1 "No such file: %s" file)
3533 (let ((enable-local-variables nil))
3537 (defun gnus-group-fetch-charter (group)
3538 "Fetch the charter for the current group.
3539 If given a prefix argument, prompt for a group."
3541 (list (or (when current-prefix-arg
3542 (completing-read "Group: " gnus-active-hashtb))
3543 (gnus-group-group-name)
3544 gnus-newsgroup-name)))
3546 (error "No group name given"))
3548 (condition-case nil (require 'url-http) (error nil))
3549 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3551 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3552 (setq hierarchy (match-string 1 name))
3553 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3554 (if (fboundp 'url-http-file-exists-p)
3555 (url-http-file-exists-p (eval url))
3557 (browse-url (eval url))
3558 (setq url (concat "http://" hierarchy
3559 ".news-admin.org/charters/" name))
3560 (if (and (fboundp 'url-http-file-exists-p)
3561 (url-http-file-exists-p url))
3563 (gnus-group-fetch-control group))))))
3565 (defun gnus-group-fetch-control (group)
3566 "Fetch the archived control messages for the current group.
3567 If given a prefix argument, prompt for a group."
3569 (list (or (when current-prefix-arg
3570 (completing-read "Group: " gnus-active-hashtb))
3571 (gnus-group-group-name)
3572 gnus-newsgroup-name)))
3574 (error "No group name given"))
3575 (let ((name (gnus-group-real-name group))
3577 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3578 (setq hierarchy (match-string 1 name))
3579 (if gnus-group-fetch-control-use-browse-url
3580 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3581 hierarchy "/" name ".Z"))
3582 (let ((enable-local-variables nil))
3583 (gnus-group-read-ephemeral-group
3585 `(nndoc ,group (nndoc-address
3586 ,(find-file-noselect
3587 (concat "/ftp@ftp.isc.org:/usenet/control/"
3588 hierarchy "/" name ".Z")))
3589 (nndoc-article-type mbox)) t nil nil))))))
3591 (defun gnus-group-describe-group (force &optional group)
3592 "Display a description of the current newsgroup."
3593 (interactive (list current-prefix-arg (gnus-group-group-name)))
3594 (let* ((method (gnus-find-method-for-group group))
3595 (mname (gnus-group-prefixed-name "" method))
3598 gnus-description-hashtb)
3599 (gnus-sethash mname nil gnus-description-hashtb))
3601 (error "No group name given"))
3602 (when (or (and gnus-description-hashtb
3603 ;; We check whether this group's method has been
3604 ;; queried for a description file.
3605 (gnus-gethash mname gnus-description-hashtb))
3606 (setq desc (gnus-group-get-description group))
3607 (gnus-read-descriptions-file method))
3609 (or desc (gnus-gethash group gnus-description-hashtb)
3610 "No description available")))))
3612 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3613 (defun gnus-group-describe-all-groups (&optional force)
3614 "Pop up a buffer with descriptions of all newsgroups."
3617 (setq gnus-description-hashtb nil))
3618 (when (not (or gnus-description-hashtb
3619 (gnus-read-all-descriptions-files)))
3620 (error "Couldn't request descriptions file"))
3621 (let ((buffer-read-only nil)
3627 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3628 (insert (format " *: %-20s %s\n"
3629 (gnus-group-name-decode
3630 (symbol-name group) charset)
3631 (gnus-group-name-decode
3632 (symbol-value group) charset))))
3633 (gnus-add-text-properties
3634 b (1+ b) (list 'gnus-group group
3635 'gnus-unread t 'gnus-marked nil
3636 'gnus-level (1+ gnus-level-subscribed))))
3637 gnus-description-hashtb)
3638 (goto-char (point-min))
3639 (gnus-group-position-point)))
3641 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3642 (defun gnus-group-apropos (regexp &optional search-description)
3643 "List all newsgroups that have names that match a regexp."
3644 (interactive "sGnus apropos (regexp): ")
3646 (obuf (current-buffer))
3648 ;; Go through all newsgroups that are known to Gnus.
3651 (and (symbol-name group)
3652 (string-match regexp (symbol-name group))
3653 (symbol-value group)
3654 (push (symbol-name group) groups)))
3656 ;; Also go through all descriptions that are known to Gnus.
3657 (when search-description
3660 (and (string-match regexp (symbol-value group))
3661 (push (symbol-name group) groups)))
3662 gnus-description-hashtb))
3664 (gnus-message 3 "No groups matched \"%s\"." regexp)
3665 ;; Print out all the groups.
3667 (pop-to-buffer "*Gnus Help*")
3668 (buffer-disable-undo)
3670 (setq groups (sort groups 'string<))
3672 ;; Groups may be entered twice into the list of groups.
3673 (when (not (string= (car groups) prev))
3674 (setq prev (car groups))
3675 (let ((charset (gnus-group-name-charset nil prev)))
3676 (insert (gnus-group-name-decode prev charset) "\n")
3677 (when (and gnus-description-hashtb
3678 (setq des (gnus-gethash (car groups)
3679 gnus-description-hashtb)))
3680 (insert " " (gnus-group-name-decode des charset) "\n"))))
3681 (setq groups (cdr groups)))
3682 (goto-char (point-min))))
3683 (pop-to-buffer obuf)))
3685 (defun gnus-group-description-apropos (regexp)
3686 "List all newsgroups that have names or descriptions that match a regexp."
3687 (interactive "sGnus description apropos (regexp): ")
3688 (when (not (or gnus-description-hashtb
3689 (gnus-read-all-descriptions-files)))
3690 (error "Couldn't request descriptions file"))
3691 (gnus-group-apropos regexp t))
3693 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3694 (defun gnus-group-list-matching (level regexp &optional all lowest)
3695 "List all groups with unread articles that match REGEXP.
3696 If the prefix LEVEL is non-nil, it should be a number that says which
3697 level to cut off listing groups.
3698 If ALL, also list groups with no unread articles.
3699 If LOWEST, don't list groups with level lower than LOWEST.
3701 This command may read the active file."
3702 (interactive "P\nsList newsgroups matching: ")
3703 ;; First make sure active file has been read.
3705 (> (prefix-numeric-value level) gnus-level-killed))
3706 (gnus-get-killed-groups))
3707 (funcall gnus-group-prepare-function
3708 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3709 (goto-char (point-min))
3710 (gnus-group-position-point))
3712 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3713 "List all groups that match REGEXP.
3714 If the prefix LEVEL is non-nil, it should be a number that says which
3715 level to cut off listing groups.
3716 If LOWEST, don't list groups with level lower than LOWEST."
3717 (interactive "P\nsList newsgroups matching: ")
3719 (setq level (prefix-numeric-value level)))
3720 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3722 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3723 (defun gnus-group-save-newsrc (&optional force)
3724 "Save the Gnus startup files.
3725 If FORCE, force saving whether it is necessary or not."
3727 (gnus-save-newsrc-file force))
3729 (defun gnus-group-restart (&optional arg)
3730 "Force Gnus to read the .newsrc file."
3732 (when (gnus-yes-or-no-p
3733 (format "Are you sure you want to restart Gnus? "))
3734 (gnus-save-newsrc-file)
3738 (defun gnus-group-read-init-file ()
3739 "Read the Gnus elisp init file."
3741 (gnus-read-init-file)
3742 (gnus-message 5 "Read %s" gnus-init-file))
3744 (defun gnus-group-check-bogus-groups (&optional silent)
3745 "Check bogus newsgroups.
3746 If given a prefix, don't ask for confirmation before removing a bogus
3749 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3750 (gnus-group-list-groups))
3752 (defun gnus-group-find-new-groups (&optional arg)
3753 "Search for new groups and add them.
3754 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3755 With 1 C-u, use the `ask-server' method to query the server for new
3757 With 2 C-u's, use most complete method possible to query the server
3758 for new groups, and subscribe the new groups as zombies."
3760 (gnus-find-new-newsgroups (or arg 1))
3761 (gnus-group-list-groups))
3763 (defun gnus-group-edit-global-kill (&optional article group)
3764 "Edit the global kill file.
3765 If GROUP, edit that local kill file instead."
3767 (setq gnus-current-kill-article article)
3768 (gnus-kill-file-edit-file group)
3771 (substitute-command-keys
3772 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3773 (if group "local" "global")))))
3775 (defun gnus-group-edit-local-kill (article group)
3776 "Edit a local kill file."
3777 (interactive (list nil (gnus-group-group-name)))
3778 (gnus-group-edit-global-kill article group))
3780 (defun gnus-group-force-update ()
3781 "Update `.newsrc' file."
3783 (gnus-save-newsrc-file))
3785 (defun gnus-group-suspend ()
3786 "Suspend the current Gnus session.
3787 In fact, cleanup buffers except for group mode buffer.
3788 The hook gnus-suspend-gnus-hook is called before actually suspending."
3790 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3791 (gnus-offer-save-summaries)
3792 ;; Kill Gnus buffers except for group mode buffer.
3793 (let ((group-buf (get-buffer gnus-group-buffer)))
3794 (mapcar (lambda (buf)
3795 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3799 (eq major-mode 'message-mode))))
3800 (gnus-kill-buffer buf)))
3802 (gnus-kill-gnus-frames)
3804 (bury-buffer group-buf)
3805 (delete-windows-on group-buf t))))
3807 (defun gnus-group-clear-dribble ()
3808 "Clear all information from the dribble buffer."
3810 (gnus-dribble-clear)
3811 (gnus-message 7 "Cleared dribble buffer"))
3813 (defun gnus-group-exit ()
3814 "Quit reading news after updating .newsrc.eld and .newsrc.
3815 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3818 (or noninteractive ;For gnus-batch-kill
3819 (not gnus-interactive-exit) ;Without confirmation
3821 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3822 (gnus-run-hooks 'gnus-exit-gnus-hook)
3823 ;; Offer to save data from non-quitted summary buffers.
3824 (gnus-offer-save-summaries)
3825 ;; Save the newsrc file(s).
3826 (gnus-save-newsrc-file)
3828 (gnus-close-backends)
3829 ;; Reset everything.
3831 ;; Allow the user to do things after cleaning up.
3832 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3834 (defun gnus-group-quit ()
3835 "Quit reading news without updating .newsrc.eld or .newsrc.
3836 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3838 (when (or noninteractive ;For gnus-batch-kill
3839 (zerop (buffer-size))
3840 (not (gnus-server-opened gnus-select-method))
3842 (not gnus-current-startup-file)
3844 (format "Quit reading news without saving %s? "
3845 (file-name-nondirectory gnus-current-startup-file))))
3846 (gnus-run-hooks 'gnus-exit-gnus-hook)
3847 (gnus-configure-windows 'group t)
3848 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3849 (not (zerop (save-excursion
3850 (set-buffer gnus-dribble-buffer)
3853 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3855 (gnus-close-backends)
3857 (gnus-kill-buffer gnus-group-buffer)
3858 ;; Allow the user to do things after cleaning up.
3859 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3861 (defun gnus-group-describe-briefly ()
3862 "Give a one line description of the group mode commands."
3864 (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")))
3866 (defun gnus-group-browse-foreign-server (method)
3867 "Browse a foreign news server.
3868 If called interactively, this function will ask for a select method
3869 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3870 If not, METHOD should be a list where the first element is the method
3871 and the second element is the address."
3873 (list (let ((how (completing-read
3875 (append gnus-valid-select-methods gnus-server-alist)
3876 nil t (cons "nntp" 0) 'gnus-method-history)))
3877 ;; We either got a backend name or a virtual server name.
3878 ;; If the first, we also need an address.
3879 (if (assoc how gnus-valid-select-methods)
3881 ;; Suggested by mapjph@bath.ac.uk.
3884 (mapcar (lambda (server) (list server))
3885 gnus-secondary-servers)))
3886 ;; We got a server name.
3888 (gnus-browse-foreign-server method))
3890 (defun gnus-group-set-info (info &optional method-only-group part)
3891 (when (or info part)
3892 (let* ((entry (gnus-gethash
3893 (or method-only-group (gnus-info-group info))
3894 gnus-newsrc-hashtb))
3896 (info (if method-only-group (nth 2 entry) info))
3898 (when method-only-group
3900 (error "Trying to change non-existent group %s" method-only-group))
3901 ;; We have received parts of the actual group info - either the
3902 ;; select method or the group parameters. We first check
3903 ;; whether we have to extend the info, and if so, do that.
3904 (let ((len (length info))
3905 (total (if (eq part 'method) 5 6)))
3907 (setcdr (nthcdr (1- len) info)
3908 (make-list (- total len) nil)))
3909 ;; Then we enter the new info.
3910 (setcar (nthcdr (1- total) info) part-info)))
3912 ;; This is a new group, so we just create it.
3914 (set-buffer gnus-group-buffer)
3915 (setq method (gnus-info-method info))
3916 (when (gnus-server-equal method "native")
3919 (set-buffer gnus-group-buffer)
3921 ;; It's a foreign group...
3922 (gnus-group-make-group
3923 (gnus-group-real-name (gnus-info-group info))
3924 (if (stringp method) method
3925 (prin1-to-string (car method)))
3927 (nth 1 (gnus-info-method info))))
3928 ;; It's a native group.
3929 (gnus-group-make-group (gnus-info-group info))))
3930 (gnus-message 6 "Note: New group created")
3932 (gnus-gethash (gnus-group-prefixed-name
3933 (gnus-group-real-name (gnus-info-group info))
3934 (or (gnus-info-method info) gnus-select-method))
3935 gnus-newsrc-hashtb))))
3936 ;; Whether it was a new group or not, we now have the entry, so we
3937 ;; can do the update.
3940 (setcar (nthcdr 2 entry) info)
3941 (when (and (not (eq (car entry) t))
3942 (gnus-active (gnus-info-group info)))
3943 (setcar entry (length
3944 (gnus-list-of-unread-articles (car info))))))
3945 (error "No such group: %s" (gnus-info-group info))))))
3947 (defun gnus-group-set-method-info (group select-method)
3948 (gnus-group-set-info select-method group 'method))
3950 (defun gnus-group-set-params-info (group params)
3951 (gnus-group-set-info params group 'params))
3953 (defun gnus-add-marked-articles (group type articles &optional info force)
3954 ;; Add ARTICLES of TYPE to the info of GROUP.
3955 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3956 ;; add, but replace marked articles of TYPE with ARTICLES.
3957 (let ((info (or info (gnus-get-info group)))
3960 (and (not (setq marked (nthcdr 3 info)))
3962 (setcdr (nthcdr 2 info)
3963 (list (list (cons type (gnus-compress-sequence
3965 (and (not (setq m (assq type (car marked))))
3968 (cons (cons type (gnus-compress-sequence articles t) )
3972 (setcar (nthcdr 3 info)
3973 (gnus-delete-alist type (car marked)))
3974 (setcdr m (gnus-compress-sequence articles t)))
3975 (setcdr m (gnus-compress-sequence
3976 (sort (nconc (gnus-uncompress-range (cdr m))
3977 (copy-sequence articles)) '<) t))))))
3979 (defun gnus-add-mark (group mark article)
3980 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3981 (let ((buffer (gnus-summary-buffer-name group)))
3982 (if (gnus-buffer-live-p buffer)
3984 (set-buffer (get-buffer buffer))
3985 (gnus-summary-add-mark article mark))
3986 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3990 ;;; Group timestamps
3993 (defun gnus-group-set-timestamp ()
3994 "Change the timestamp of the current group to the current time.
3995 This function can be used in hooks like `gnus-select-group-hook'
3996 or `gnus-group-catchup-group-hook'."
3997 (when gnus-newsgroup-name
3998 (let ((time (current-time)))
3999 (setcdr (cdr time) nil)
4000 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4002 (defsubst gnus-group-timestamp (group)
4003 "Return the timestamp for GROUP."
4004 (gnus-group-get-parameter group 'timestamp t))
4006 (defun gnus-group-timestamp-delta (group)
4007 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4008 (let* ((time (or (gnus-group-timestamp group)
4010 (delta (subtract-time (current-time) time)))
4011 (+ (* (nth 0 delta) 65536.0)
4014 (defun gnus-group-timestamp-string (group)
4015 "Return a string of the timestamp for GROUP."
4016 (let ((time (gnus-group-timestamp group)))
4019 (gnus-time-iso8601 time))))
4021 (defun gnus-group-list-cached (level &optional lowest)
4022 "List all groups with cached articles.
4023 If the prefix LEVEL is non-nil, it should be a number that says which
4024 level to cut off listing groups.
4025 If LOWEST, don't list groups with level lower than LOWEST.
4027 This command may read the active file."
4030 (setq level (prefix-numeric-value level)))
4031 (when (or (not level) (>= level gnus-level-zombie))
4033 (funcall gnus-group-prepare-function
4034 (or level gnus-level-subscribed)
4036 (let ((marks (gnus-info-marks info)))
4037 (assq 'cache marks)))
4040 (or (gnus-gethash group
4041 gnus-cache-active-hashtb)
4042 ;; Cache active file might use "."
4045 (mapconcat 'identity
4046 (split-string group ":")
4048 gnus-cache-active-hashtb))))
4049 (goto-char (point-min))
4050 (gnus-group-position-point))
4052 (defun gnus-group-list-dormant (level &optional lowest)
4053 "List all groups with dormant articles.
4054 If the prefix LEVEL is non-nil, it should be a number that says which
4055 level to cut off listing groups.
4056 If LOWEST, don't list groups with level lower than LOWEST.
4058 This command may read the active file."
4061 (setq level (prefix-numeric-value level)))
4062 (when (or (not level) (>= level gnus-level-zombie))
4064 (funcall gnus-group-prepare-function
4065 (or level gnus-level-subscribed)
4067 (let ((marks (gnus-info-marks info)))
4068 (assq 'dormant marks)))
4071 (goto-char (point-min))
4072 (gnus-group-position-point))
4074 (defun gnus-group-listed-groups ()
4075 "Return a list of listed groups."
4077 (goto-char (point-min))
4078 (while (setq point (text-property-not-all (point) (point-max)
4081 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4085 (defun gnus-group-list-plus (&optional args)
4086 "List groups plus the current selection."
4088 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4089 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4091 (push last-command-event unread-command-events)
4092 (if (featurep 'xemacs)
4093 (push (make-event 'key-press '(key ?A)) unread-command-events)
4094 (push ?A unread-command-events))
4095 (let (gnus-pick-mode keys)
4096 (setq keys (if (featurep 'xemacs)
4097 (events-to-keys (read-key-sequence nil))
4098 (read-key-sequence nil)))
4099 (setq func (lookup-key (current-local-map) keys)))
4103 (call-interactively func))))
4105 (defun gnus-group-list-flush (&optional args)
4106 "Flush groups from the current selection."
4108 (let ((gnus-group-list-option 'flush))
4109 (gnus-group-list-plus args)))
4111 (defun gnus-group-list-limit (&optional args)
4112 "List groups limited within the current selection."
4114 (let ((gnus-group-list-option 'limit))
4115 (gnus-group-list-plus args)))
4117 (defun gnus-group-mark-article-read (group article)
4118 "Mark ARTICLE read."
4119 (let ((buffer (gnus-summary-buffer-name group))
4120 (mark gnus-read-mark)
4122 (if (get-buffer buffer)
4123 (with-current-buffer buffer
4124 (setq active gnus-newsgroup-active)
4125 (gnus-activate-group group)
4126 (when gnus-newsgroup-prepared
4127 (when (and gnus-newsgroup-auto-expire
4128 (memq mark gnus-auto-expirable-marks))
4129 (setq mark gnus-expirable-mark))
4130 (setq mark (gnus-request-update-mark
4131 group article mark))
4132 (gnus-mark-article-as-read article mark)
4133 (setq gnus-newsgroup-active (gnus-active group))
4135 (setq n (1+ (cdr active)))
4136 (while (<= n (cdr gnus-newsgroup-active))
4137 (unless (eq n article)
4138 (push n gnus-newsgroup-unselected))
4140 (setq gnus-newsgroup-unselected
4141 (nreverse gnus-newsgroup-unselected)))))
4142 (gnus-activate-group group)
4143 (gnus-group-make-articles-read group (list article))
4144 (when (gnus-group-auto-expirable-p group)
4145 (gnus-add-marked-articles
4146 group 'expire (list article))))))
4148 (provide 'gnus-group)
4150 ;;; gnus-group.el ends here