1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
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 (defcustom gnus-group-archive-directory
43 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
44 "*The address of the (ding) archives."
45 :group 'gnus-group-foreign
48 (defcustom gnus-group-recent-archive-directory
49 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
50 "*The address of the most recent (ding) articles."
51 :group 'gnus-group-foreign
54 (defcustom gnus-no-groups-message "No gnus is bad news"
55 "*Message displayed by Gnus when no groups are available."
59 (defcustom gnus-keep-same-level nil
60 "*Non-nil means that the next newsgroup after the current will be on the same level.
61 When you type, for instance, `n' after reading the last article in the
62 current newsgroup, you will go to the next newsgroup. If this variable
63 is nil, the next newsgroup will be the next from the group
65 If this variable is non-nil, Gnus will either put you in the
66 next newsgroup with the same level, or, if no such newsgroup is
67 available, the next newsgroup with the lowest possible level higher
68 than the current level.
69 If this variable is `best', Gnus will make the next newsgroup the one
71 :group 'gnus-group-levels
72 :type '(choice (const nil)
74 (sexp :tag "other" t)))
76 (defcustom gnus-group-goto-unread t
77 "*If non-nil, movement commands will go to the next unread and subscribed group."
78 :link '(custom-manual "(gnus)Group Maneuvering")
79 :group 'gnus-group-various
82 (defcustom gnus-goto-next-group-when-activating t
83 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
84 :link '(custom-manual "(gnus)Scanning New Messages")
85 :group 'gnus-group-various
88 (defcustom gnus-permanently-visible-groups nil
89 "*Regexp to match groups that should always be listed in the group buffer.
90 This means that they will still be listed even when there are no
91 unread articles in the groups.
93 If nil, no groups are permanently visible."
94 :group 'gnus-group-listing
95 :type '(choice regexp (const nil)))
97 (defcustom gnus-list-groups-with-ticked-articles t
98 "*If non-nil, list groups that have only ticked articles.
99 If nil, only list groups that have unread articles."
100 :group 'gnus-group-listing
103 (defcustom gnus-group-default-list-level gnus-level-subscribed
104 "*Default listing level.
105 Ignored if `gnus-group-use-permanent-levels' is non-nil."
106 :group 'gnus-group-listing
109 (defcustom gnus-group-list-inactive-groups t
110 "*If non-nil, inactive groups will be listed."
111 :group 'gnus-group-listing
112 :group 'gnus-group-levels
115 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
116 "*Function used for sorting the group buffer.
117 This function will be called with group info entries as the arguments
118 for the groups to be sorted. Pre-made functions include
119 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
120 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
121 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
122 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
124 This variable can also be a list of sorting functions. In that case,
125 the most significant sort function should be the last function in the
127 :group 'gnus-group-listing
128 :link '(custom-manual "(gnus)Sorting Groups")
129 :type '(radio (function-item gnus-group-sort-by-alphabet)
130 (function-item gnus-group-sort-by-real-name)
131 (function-item gnus-group-sort-by-unread)
132 (function-item gnus-group-sort-by-level)
133 (function-item gnus-group-sort-by-score)
134 (function-item gnus-group-sort-by-method)
135 (function-item gnus-group-sort-by-server)
136 (function-item gnus-group-sort-by-rank)
137 (function :tag "other" nil)))
139 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
140 "*Format of group lines.
141 It works along the same lines as a normal formatting string,
142 with some simple extensions.
144 %M Only marked articles (character, \"*\" or \" \")
145 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
146 %L Level of subscribedness (integer)
147 %N Number of unread articles (integer)
148 %I Number of dormant articles (integer)
149 %i Number of ticked and dormant (integer)
150 %T Number of ticked articles (integer)
151 %R Number of read articles (integer)
152 %t Estimated total number of articles (integer)
153 %y Number of unread, unticked articles (integer)
154 %G Group name (string)
155 %g Qualified group name (string)
156 %D Group description (string)
157 %s Select method (string)
158 %o Moderated group (char, \"m\")
159 %p Process mark (char)
160 %O Moderated group (string, \"(m)\" or \"\")
161 %P Topic indentation (string)
162 %m Whether there is new(ish) mail in the group (char, \"%\")
163 %l Whether there are GroupLens predictions for this group (string)
164 %n Select from where (string)
165 %z A string that look like `<%s:%n>' if a foreign select method is used
166 %d The date the group was last entered.
167 %E Icon as defined by `gnus-group-icon-list'.
168 %u User defined specifier. The next character in the format string should
169 be a letter. Gnus will call the function gnus-user-format-function-X,
170 where X is the letter following %u. The function will be passed the
171 current header as argument. The function should return a string, which
172 will be inserted into the buffer just like information from any other
175 Text between %( and %) will be highlighted with `gnus-mouse-face' when
176 the mouse point move inside the area. There can only be one such area.
178 Note that this format specification is not always respected. For
179 reasons of efficiency, when listing killed groups, this specification
180 is ignored altogether. If the spec is changed considerably, your
181 output may end up looking strange when listing both alive and killed
184 If you use %o or %O, reading the active file will be slower and quite
185 a bit of extra memory will be used. %D will also worsen performance.
186 Also note that if you change the format specification to include any
187 of these specs, you must probably re-start Gnus to see them go into
189 :group 'gnus-group-visual
192 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
193 "*The format specification for the group mode line.
194 It works along the same lines as a normal formatting string,
195 with some simple extensions:
197 %S The native news server.
198 %M The native select method.
199 %: \":\" if %S isn't \"\"."
200 :group 'gnus-group-visual
203 (defcustom gnus-group-mode-hook nil
204 "Hook for Gnus group mode."
205 :group 'gnus-group-various
206 :options '(gnus-topic-mode)
209 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
210 (when (featurep 'xemacs)
211 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
212 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
214 (defcustom gnus-group-menu-hook nil
215 "Hook run after the creation of the group mode menu."
216 :group 'gnus-group-various
219 (defcustom gnus-group-catchup-group-hook nil
220 "Hook run when catching up a group from the group buffer."
221 :group 'gnus-group-various
222 :link '(custom-manual "(gnus)Group Data")
225 (defcustom gnus-group-update-group-hook nil
226 "Hook called when updating group lines."
227 :group 'gnus-group-visual
230 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
231 "*A function that is called to generate the group buffer.
232 The function is called with three arguments: The first is a number;
233 all group with a level less or equal to that number should be listed,
234 if the second is non-nil, empty groups should also be displayed. If
235 the third is non-nil, it is a number. No groups with a level lower
236 than this number should be displayed.
238 The only current function implemented is `gnus-group-prepare-flat'."
239 :group 'gnus-group-listing
242 (defcustom gnus-group-prepare-hook nil
243 "Hook called after the group buffer has been generated.
244 If you want to modify the group buffer, you can use this hook."
245 :group 'gnus-group-listing
248 (defcustom gnus-suspend-gnus-hook nil
249 "Hook called when suspending (not exiting) Gnus."
253 (defcustom gnus-exit-gnus-hook nil
254 "Hook called when exiting Gnus."
258 (defcustom gnus-after-exiting-gnus-hook nil
259 "Hook called after exiting Gnus."
263 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
264 "Hook called when a group line is changed.
265 The hook will not be called if `gnus-visual' is nil.
267 The default function `gnus-group-highlight-line' will
268 highlight the line according to the `gnus-group-highlight'
270 :group 'gnus-group-visual
273 (defcustom gnus-useful-groups
274 '(("(ding) mailing list mirrored at sunsite.auc.dk"
276 (nntp "sunsite.auc.dk"
277 (nntp-address "sunsite.auc.dk")))
280 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
284 (nndoc-article-type mbox)
285 (eval `(nndoc-address
286 ,(let ((file (nnheader-find-etc-directory
289 (error "Couldn't find doc group"))
291 "*Alist of useful group-server pairs."
292 :group 'gnus-group-listing
293 :type '(repeat (list (string :tag "Description")
295 (sexp :tag "Method"))))
297 (defcustom gnus-group-highlight
299 ((and (= unread 0) (not mailp) (eq level 1)) .
300 gnus-group-news-1-empty-face)
301 ((and (not mailp) (eq level 1)) .
302 gnus-group-news-1-face)
303 ((and (= unread 0) (not mailp) (eq level 2)) .
304 gnus-group-news-2-empty-face)
305 ((and (not mailp) (eq level 2)) .
306 gnus-group-news-2-face)
307 ((and (= unread 0) (not mailp) (eq level 3)) .
308 gnus-group-news-3-empty-face)
309 ((and (not mailp) (eq level 3)) .
310 gnus-group-news-3-face)
311 ((and (= unread 0) (not mailp) (eq level 4)) .
312 gnus-group-news-4-empty-face)
313 ((and (not mailp) (eq level 4)) .
314 gnus-group-news-4-face)
315 ((and (= unread 0) (not mailp) (eq level 5)) .
316 gnus-group-news-5-empty-face)
317 ((and (not mailp) (eq level 5)) .
318 gnus-group-news-5-face)
319 ((and (= unread 0) (not mailp) (eq level 6)) .
320 gnus-group-news-6-empty-face)
321 ((and (not mailp) (eq level 6)) .
322 gnus-group-news-6-face)
323 ((and (= unread 0) (not mailp)) .
324 gnus-group-news-low-empty-face)
326 gnus-group-news-low-face)
328 ((and (= unread 0) (eq level 1)) .
329 gnus-group-mail-1-empty-face)
331 gnus-group-mail-1-face)
332 ((and (= unread 0) (eq level 2)) .
333 gnus-group-mail-2-empty-face)
335 gnus-group-mail-2-face)
336 ((and (= unread 0) (eq level 3)) .
337 gnus-group-mail-3-empty-face)
339 gnus-group-mail-3-face)
341 gnus-group-mail-low-empty-face)
343 gnus-group-mail-low-face))
344 "*Controls the highlighting of group buffer lines.
346 Below is a list of `Form'/`Face' pairs. When deciding how a a
347 particular group line should be displayed, each form is
348 evaluated. The content of the face field after the first true form is
349 used. You can change how those group lines are displayed by
350 editing the face field.
352 It is also possible to change and add form fields, but currently that
353 requires an understanding of Lisp expressions. Hopefully this will
354 change in a future release. For now, you can use the following
355 variables in the Lisp expression:
357 group: The name of the group.
358 unread: The number of unread articles in the group.
359 method: The select method used.
360 mailp: Whether it's a mail group or not.
361 level: The level of the group.
362 score: The score of the group.
363 ticked: The number of ticked articles."
364 :group 'gnus-group-visual
365 :type '(repeat (cons (sexp :tag "Form") face)))
367 (defcustom gnus-new-mail-mark ?%
368 "Mark used for groups with new mail."
369 :group 'gnus-group-visual
372 (defgroup gnus-group-icons nil
373 "Add Icons to your group buffer. "
374 :group 'gnus-group-visual)
376 (defcustom gnus-group-icon-list
378 "*Controls the insertion of icons into group buffer lines.
380 Below is a list of `Form'/`File' pairs. When deciding how a
381 particular group line should be displayed, each form is evaluated.
382 The icon from the file field after the first true form is used. You
383 can change how those group lines are displayed by editing the file
384 field. The File will either be found in the
385 `gnus-group-glyph-directory' or by designating absolute path to the
388 It is also possible to change and add form fields, but currently that
389 requires an understanding of Lisp expressions. Hopefully this will
390 change in a future release. For now, you can use the following
391 variables in the Lisp expression:
393 group: The name of the group.
394 unread: The number of unread articles in the group.
395 method: The select method used.
396 mailp: Whether it's a mail group or not.
397 newsp: Whether it's a news group or not
398 level: The level of the group.
399 score: The score of the group.
400 ticked: The number of ticked articles."
401 :group 'gnus-group-icons
402 :type '(repeat (cons (sexp :tag "Form") file)))
404 (defcustom gnus-group-name-charset-method-alist nil
405 "*Alist of method and the charset for group names.
408 (((nntp \"news.com.cn\") . cn-gb-2312))
412 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
414 (defcustom gnus-group-name-charset-group-alist nil
415 "*Alist of group regexp and the charset for group names.
418 ((\"\\.com\\.cn:\" . cn-gb-2312))
421 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
423 (defcustom gnus-group-jump-to-group-prompt nil
424 "Default prompt for `gnus-group-jump-to-group'.
425 If non-nil, the value should be a string, e.g. \"nnml:\",
426 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
427 in the minibuffer prompt."
428 :group 'gnus-group-various
429 :type '(choice (string :tag "Prompt string")
430 (const :tag "Empty" nil)))
432 (defvar gnus-group-listing-limit 1000
433 "*A limit of the number of groups when listing.
434 If the number of groups is larger than the limit, list them in a
437 ;;; Internal variables
439 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
440 "Function for sorting the group buffer.")
442 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
443 "Function for sorting the selected groups in the group buffer.")
445 (defvar gnus-group-indentation-function nil)
446 (defvar gnus-goto-missing-group-function nil)
447 (defvar gnus-group-update-group-function nil)
448 (defvar gnus-group-goto-next-group-function nil
449 "Function to override finding the next group after listing groups.")
451 (defvar gnus-group-edit-buffer nil)
453 (defvar gnus-group-line-format-alist
454 `((?M gnus-tmp-marked-mark ?c)
455 (?S gnus-tmp-subscribed ?c)
456 (?L gnus-tmp-level ?d)
457 (?N (cond ((eq number t) "*" )
461 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
462 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
464 (?R gnus-tmp-number-of-read ?s)
465 (?t gnus-tmp-number-total ?d)
466 (?y gnus-tmp-number-of-unread ?s)
467 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
468 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
469 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
470 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
471 (?g gnus-tmp-group ?s)
472 (?G gnus-tmp-qualified-group ?s)
473 (?c (gnus-short-group-name gnus-tmp-group) ?s)
474 (?D gnus-tmp-newsgroup-description ?s)
475 (?o gnus-tmp-moderated ?c)
476 (?O gnus-tmp-moderated-string ?s)
477 (?p gnus-tmp-process-marked ?c)
478 (?s gnus-tmp-news-server ?s)
479 (?n gnus-tmp-news-method ?s)
480 (?P gnus-group-indentation ?s)
481 (?E gnus-tmp-group-icon ?s)
482 (?l gnus-tmp-grouplens ?s)
483 (?z gnus-tmp-news-method-string ?s)
484 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
485 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
486 (?u gnus-tmp-user-defined ?s)))
488 (defvar gnus-group-mode-line-format-alist
489 `((?S gnus-tmp-news-server ?s)
490 (?M gnus-tmp-news-method ?s)
491 (?u gnus-tmp-user-defined ?s)
492 (?: gnus-tmp-colon ?s)))
494 (defvar gnus-topic-topology nil
495 "The complete topic hierarchy.")
497 (defvar gnus-topic-alist nil
498 "The complete topic-group alist.")
500 (defvar gnus-group-marked nil)
502 (defvar gnus-group-list-mode nil)
505 (defvar gnus-group-icon-cache nil)
507 (defvar gnus-group-listed-groups nil)
508 (defvar gnus-group-list-option nil)
514 (put 'gnus-group-mode 'mode-class 'special)
517 (gnus-define-keys gnus-group-mode-map
518 " " gnus-group-read-group
519 "=" gnus-group-select-group
520 "\r" gnus-group-select-group
521 "\M-\r" gnus-group-quick-select-group
522 "\M- " gnus-group-visible-select-group
523 [(meta control return)] gnus-group-select-group-ephemerally
524 "j" gnus-group-jump-to-group
525 "n" gnus-group-next-unread-group
526 "p" gnus-group-prev-unread-group
527 "\177" gnus-group-prev-unread-group
528 [delete] gnus-group-prev-unread-group
529 [backspace] gnus-group-prev-unread-group
530 "N" gnus-group-next-group
531 "P" gnus-group-prev-group
532 "\M-n" gnus-group-next-unread-group-same-level
533 "\M-p" gnus-group-prev-unread-group-same-level
534 "," gnus-group-best-unread-group
535 "." gnus-group-first-unread-group
536 "u" gnus-group-unsubscribe-current-group
537 "U" gnus-group-unsubscribe-group
538 "c" gnus-group-catchup-current
539 "C" gnus-group-catchup-current-all
540 "\M-c" gnus-group-clear-data
541 "l" gnus-group-list-groups
542 "L" gnus-group-list-all-groups
544 "g" gnus-group-get-new-news
545 "\M-g" gnus-group-get-new-news-this-group
546 "R" gnus-group-restart
547 "r" gnus-group-read-init-file
548 "B" gnus-group-browse-foreign-server
549 "b" gnus-group-check-bogus-groups
550 "F" gnus-group-find-new-groups
551 "\C-c\C-d" gnus-group-describe-group
552 "\M-d" gnus-group-describe-all-groups
553 "\C-c\C-a" gnus-group-apropos
554 "\C-c\M-\C-a" gnus-group-description-apropos
555 "a" gnus-group-post-news
556 "\ek" gnus-group-edit-local-kill
557 "\eK" gnus-group-edit-global-kill
558 "\C-k" gnus-group-kill-group
559 "\C-y" gnus-group-yank-group
560 "\C-w" gnus-group-kill-region
561 "\C-x\C-t" gnus-group-transpose-groups
562 "\C-c\C-l" gnus-group-list-killed
563 "\C-c\C-x" gnus-group-expire-articles
564 "\C-c\M-\C-x" gnus-group-expire-all-groups
566 "s" gnus-group-save-newsrc
567 "z" gnus-group-suspend
570 "?" gnus-group-describe-briefly
571 "\C-c\C-i" gnus-info-find-node
572 "\M-e" gnus-group-edit-group-method
573 "^" gnus-group-enter-server-mode
574 gnus-mouse-2 gnus-mouse-pick-group
575 "<" beginning-of-buffer
578 "\C-c\C-s" gnus-group-sort-groups
580 "\C-c\M-g" gnus-activate-all-groups
581 "\M-&" gnus-group-universal-argument
582 "#" gnus-group-mark-group
583 "\M-#" gnus-group-unmark-group)
585 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
586 "m" gnus-group-mark-group
587 "u" gnus-group-unmark-group
588 "w" gnus-group-mark-region
589 "b" gnus-group-mark-buffer
590 "r" gnus-group-mark-regexp
591 "U" gnus-group-unmark-all-groups)
593 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
594 "d" gnus-group-make-directory-group
595 "h" gnus-group-make-help-group
596 "u" gnus-group-make-useful-group
597 "a" gnus-group-make-archive-group
598 "k" gnus-group-make-kiboze-group
599 "l" gnus-group-nnimap-edit-acl
600 "m" gnus-group-make-group
601 "E" gnus-group-edit-group
602 "e" gnus-group-edit-group-method
603 "p" gnus-group-edit-group-parameters
604 "v" gnus-group-add-to-virtual
605 "V" gnus-group-make-empty-virtual
606 "D" gnus-group-enter-directory
607 "f" gnus-group-make-doc-group
608 "w" gnus-group-make-web-group
609 "r" gnus-group-rename-group
610 "c" gnus-group-customize
611 "x" gnus-group-nnimap-expunge
612 "\177" gnus-group-delete-group
613 [delete] gnus-group-delete-group)
615 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
616 "b" gnus-group-brew-soup
617 "w" gnus-soup-save-areas
618 "s" gnus-soup-send-replies
619 "p" gnus-soup-pack-packet
620 "r" nnsoup-pack-replies)
622 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
623 "s" gnus-group-sort-groups
624 "a" gnus-group-sort-groups-by-alphabet
625 "u" gnus-group-sort-groups-by-unread
626 "l" gnus-group-sort-groups-by-level
627 "v" gnus-group-sort-groups-by-score
628 "r" gnus-group-sort-groups-by-rank
629 "m" gnus-group-sort-groups-by-method)
631 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
632 "s" gnus-group-sort-selected-groups
633 "a" gnus-group-sort-selected-groups-by-alphabet
634 "u" gnus-group-sort-selected-groups-by-unread
635 "l" gnus-group-sort-selected-groups-by-level
636 "v" gnus-group-sort-selected-groups-by-score
637 "r" gnus-group-sort-selected-groups-by-rank
638 "m" gnus-group-sort-selected-groups-by-method)
640 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
641 "k" gnus-group-list-killed
642 "z" gnus-group-list-zombies
643 "s" gnus-group-list-groups
644 "u" gnus-group-list-all-groups
645 "A" gnus-group-list-active
646 "a" gnus-group-apropos
647 "d" gnus-group-description-apropos
648 "m" gnus-group-list-matching
649 "M" gnus-group-list-all-matching
650 "l" gnus-group-list-level
651 "c" gnus-group-list-cached
652 "?" gnus-group-list-dormant)
654 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
655 "k" gnus-group-list-limit
656 "z" gnus-group-list-limit
657 "s" gnus-group-list-limit
658 "u" gnus-group-list-limit
659 "A" gnus-group-list-limit
660 "m" gnus-group-list-limit
661 "M" gnus-group-list-limit
662 "l" gnus-group-list-limit
663 "c" gnus-group-list-limit
664 "?" gnus-group-list-limit)
666 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
667 "k" gnus-group-list-flush
668 "z" gnus-group-list-flush
669 "s" gnus-group-list-flush
670 "u" gnus-group-list-flush
671 "A" gnus-group-list-flush
672 "m" gnus-group-list-flush
673 "M" gnus-group-list-flush
674 "l" gnus-group-list-flush
675 "c" gnus-group-list-flush
676 "?" gnus-group-list-flush)
678 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
679 "k" gnus-group-list-plus
680 "z" gnus-group-list-plus
681 "s" gnus-group-list-plus
682 "u" gnus-group-list-plus
683 "A" gnus-group-list-plus
684 "m" gnus-group-list-plus
685 "M" gnus-group-list-plus
686 "l" gnus-group-list-plus
687 "c" gnus-group-list-plus
688 "?" gnus-group-list-plus)
690 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
691 "f" gnus-score-flush-cache)
693 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
694 "d" gnus-group-describe-group
695 "f" gnus-group-fetch-faq
698 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
699 "l" gnus-group-set-current-level
700 "t" gnus-group-unsubscribe-current-group
701 "s" gnus-group-unsubscribe-group
702 "k" gnus-group-kill-group
703 "y" gnus-group-yank-group
704 "w" gnus-group-kill-region
705 "\C-k" gnus-group-kill-level
706 "z" gnus-group-kill-all-zombies))
708 (defun gnus-group-make-menu-bar ()
709 (gnus-turn-off-edit-menu 'group)
710 (unless (boundp 'gnus-group-reading-menu)
713 gnus-group-reading-menu gnus-group-mode-map ""
715 ["Read" gnus-group-read-group (gnus-group-group-name)]
716 ["Select" gnus-group-select-group (gnus-group-group-name)]
717 ["See old articles" (gnus-group-select-group 'all)
718 :keys "C-u SPC" :active (gnus-group-group-name)]
719 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
720 ,@(if (featurep 'xemacs) nil
721 '(:help "Mark unread articles in the current group as read"))]
722 ["Catch up all articles" gnus-group-catchup-current-all
723 (gnus-group-group-name)]
724 ["Check for new articles" gnus-group-get-new-news-this-group
725 :active (gnus-group-group-name)
726 ,@(if (featurep 'xemacs) nil
727 '(:help "Check for new messages in current group"))]
728 ["Toggle subscription" gnus-group-unsubscribe-current-group
729 (gnus-group-group-name)]
730 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
731 ,@(if (featurep 'xemacs) nil
732 '(:help "Kill (remove) current group"))]
733 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
734 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
735 ,@(if (featurep 'xemacs) nil
736 '(:help "Display description of the current group"))]
737 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
738 ;; Actually one should check, if any of the marked groups gives t for
739 ;; (gnus-check-backend-function 'request-expire-articles ...)
740 ["Expire articles" gnus-group-expire-articles
741 (or (and (gnus-group-group-name)
742 (gnus-check-backend-function
743 'request-expire-articles
744 (gnus-group-group-name))) gnus-group-marked)]
745 ["Set group level" gnus-group-set-current-level
746 (gnus-group-group-name)]
747 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
748 ["Customize" gnus-group-customize (gnus-group-group-name)]
750 ["Parameters" gnus-group-edit-group-parameters
751 (gnus-group-group-name)]
752 ["Select method" gnus-group-edit-group-method
753 (gnus-group-group-name)]
754 ["Info" gnus-group-edit-group (gnus-group-group-name)]
755 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
756 ["Global kill file" gnus-group-edit-global-kill t])))
759 gnus-group-group-menu gnus-group-mode-map ""
762 ["List unread subscribed groups" gnus-group-list-groups t]
763 ["List (un)subscribed groups" gnus-group-list-all-groups t]
764 ["List killed groups" gnus-group-list-killed gnus-killed-list]
765 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
766 ["List level..." gnus-group-list-level t]
767 ["Describe all groups" gnus-group-describe-all-groups t]
768 ["Group apropos..." gnus-group-apropos t]
769 ["Group and description apropos..." gnus-group-description-apropos t]
770 ["List groups matching..." gnus-group-list-matching t]
771 ["List all groups matching..." gnus-group-list-all-matching t]
772 ["List active file" gnus-group-list-active t]
773 ["List groups with cached" gnus-group-list-cached t]
774 ["List groups with dormant" gnus-group-list-dormant t])
776 ["Default sort" gnus-group-sort-groups t]
777 ["Sort by method" gnus-group-sort-groups-by-method t]
778 ["Sort by rank" gnus-group-sort-groups-by-rank t]
779 ["Sort by score" gnus-group-sort-groups-by-score t]
780 ["Sort by level" gnus-group-sort-groups-by-level t]
781 ["Sort by unread" gnus-group-sort-groups-by-unread t]
782 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
783 ("Sort process/prefixed"
784 ["Default sort" gnus-group-sort-selected-groups
785 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
786 ["Sort by method" gnus-group-sort-selected-groups-by-method
787 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
788 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
789 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
790 ["Sort by score" gnus-group-sort-selected-groups-by-score
791 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
792 ["Sort by level" gnus-group-sort-selected-groups-by-level
793 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
794 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
795 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
796 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
797 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
799 ["Mark group" gnus-group-mark-group
800 (and (gnus-group-group-name)
801 (not (memq (gnus-group-group-name) gnus-group-marked)))]
802 ["Unmark group" gnus-group-unmark-group
803 (and (gnus-group-group-name)
804 (memq (gnus-group-group-name) gnus-group-marked))]
805 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
806 ["Mark regexp..." gnus-group-mark-regexp t]
807 ["Mark region" gnus-group-mark-region t]
808 ["Mark buffer" gnus-group-mark-buffer t]
809 ["Execute command" gnus-group-universal-argument
810 (or gnus-group-marked (gnus-group-group-name))])
812 ["Subscribe to a group" gnus-group-unsubscribe-group t]
813 ["Kill all newsgroups in region" gnus-group-kill-region t]
814 ["Kill all zombie groups" gnus-group-kill-all-zombies
816 ["Kill all groups on level..." gnus-group-kill-level t])
818 ["Make a foreign group" gnus-group-make-group t]
819 ["Add a directory group" gnus-group-make-directory-group t]
820 ["Add the help group" gnus-group-make-help-group t]
821 ["Add the archive group" gnus-group-make-archive-group t]
822 ["Make a doc group" gnus-group-make-doc-group t]
823 ["Make a web group" gnus-group-make-web-group t]
824 ["Make a kiboze group" gnus-group-make-kiboze-group t]
825 ["Make a virtual group" gnus-group-make-empty-virtual t]
826 ["Add a group to a virtual" gnus-group-add-to-virtual t]
827 ["Rename group" gnus-group-rename-group
828 (gnus-check-backend-function
829 'request-rename-group (gnus-group-group-name))]
830 ["Delete group" gnus-group-delete-group
831 (gnus-check-backend-function
832 'request-delete-group (gnus-group-group-name))])
834 ["Next" gnus-group-next-group t]
835 ["Previous" gnus-group-prev-group t]
836 ["Next unread" gnus-group-next-unread-group t]
837 ["Previous unread" gnus-group-prev-unread-group t]
838 ["Next unread same level" gnus-group-next-unread-group-same-level t]
839 ["Previous unread same level"
840 gnus-group-prev-unread-group-same-level t]
841 ["Jump to group" gnus-group-jump-to-group t]
842 ["First unread group" gnus-group-first-unread-group t]
843 ["Best unread group" gnus-group-best-unread-group t])
844 ["Delete bogus groups" gnus-group-check-bogus-groups t]
845 ["Find new newsgroups" gnus-group-find-new-groups t]
846 ["Transpose" gnus-group-transpose-groups
847 (gnus-group-group-name)]
848 ["Read a directory as a group..." gnus-group-enter-directory t]))
851 gnus-group-misc-menu gnus-group-mode-map ""
854 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
855 ["Send replies" gnus-soup-send-replies
856 (fboundp 'gnus-soup-pack-packet)]
857 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
858 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
859 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
860 ["Send a mail" gnus-group-mail t]
861 ["Post an article..." gnus-group-post-news t]
862 ["Check for new news" gnus-group-get-new-news
863 ,@(if (featurep 'xemacs) '(t)
864 '(:help "Get newly arrived articles"))
866 ["Activate all groups" gnus-activate-all-groups t]
867 ["Restart Gnus" gnus-group-restart t]
868 ["Read init file" gnus-group-read-init-file t]
869 ["Browse foreign server" gnus-group-browse-foreign-server t]
870 ["Enter server buffer" gnus-group-enter-server-mode t]
871 ["Expire all expirable articles" gnus-group-expire-all-groups t]
872 ["Generate any kiboze groups" nnkiboze-generate-groups t]
873 ["Gnus version" gnus-version t]
874 ["Save .newsrc files" gnus-group-save-newsrc t]
875 ["Suspend Gnus" gnus-group-suspend t]
876 ["Clear dribble buffer" gnus-group-clear-dribble t]
877 ["Read manual" gnus-info-find-node t]
878 ["Flush score cache" gnus-score-flush-cache t]
879 ["Toggle topics" gnus-topic-mode t]
880 ["Send a bug report" gnus-bug t]
881 ["Exit from Gnus" gnus-group-exit
882 ,@(if (featurep 'xemacs) '(t)
883 '(:help "Quit reading news"))]
884 ["Exit without saving" gnus-group-quit t]))
886 (gnus-run-hooks 'gnus-group-menu-hook)))
888 (defvar gnus-group-toolbar-map nil)
890 ;; Emacs 21 tool bar. Should be no-op otherwise.
891 (defun gnus-group-make-tool-bar ()
892 (if (and (fboundp 'tool-bar-add-item-from-menu)
893 (default-value 'tool-bar-mode)
894 (not gnus-group-toolbar-map))
895 (setq gnus-group-toolbar-map
896 (let ((tool-bar-map (make-sparse-keymap))
897 (load-path (mm-image-load-path)))
898 (tool-bar-add-item-from-menu
899 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
900 (tool-bar-add-item-from-menu
901 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
902 (tool-bar-add-item-from-menu
903 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
904 (tool-bar-add-item-from-menu
905 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
906 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
907 :help "Subscribe to the current group")
908 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
910 :help "Unsubscribe from the current group")
911 (tool-bar-add-item-from-menu
912 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
914 (if gnus-group-toolbar-map
915 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
917 (defun gnus-group-mode ()
918 "Major mode for reading news.
920 All normal editing commands are switched off.
921 \\<gnus-group-mode-map>
922 The group buffer lists (some of) the groups available. For instance,
923 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
924 lists all zombie groups.
926 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
927 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
929 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
931 The following commands are available:
933 \\{gnus-group-mode-map}"
935 (kill-all-local-variables)
936 (when (gnus-visual-p 'group-menu 'menu)
937 (gnus-group-make-menu-bar)
938 (gnus-group-make-tool-bar))
939 (gnus-simplify-mode-line)
940 (setq major-mode 'gnus-group-mode)
941 (setq mode-name "Group")
942 (gnus-group-set-mode-line)
943 (setq mode-line-process nil)
944 (use-local-map gnus-group-mode-map)
945 (buffer-disable-undo)
946 (setq truncate-lines t)
947 (setq buffer-read-only t)
948 (gnus-set-default-directory)
949 (gnus-update-format-specifications nil 'group 'group-mode)
950 (gnus-update-group-mark-positions)
955 (gnus-run-hooks 'gnus-group-mode-hook))
957 (defun gnus-update-group-mark-positions ()
959 (let ((gnus-process-mark ?\200)
960 (gnus-group-marked '("dummy.group"))
961 (gnus-active-hashtb (make-vector 10 0))
963 (gnus-set-active "dummy.group" '(0 . 0))
964 (gnus-set-work-buffer)
965 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
966 (goto-char (point-min))
967 (setq gnus-group-mark-positions
968 (list (cons 'process (and (search-forward "\200" nil t)
971 (defun gnus-mouse-pick-group (e)
972 "Enter the group under the mouse pointer."
975 (gnus-group-read-group nil))
977 ;; Look at LEVEL and find out what the level is really supposed to be.
978 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
979 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
980 (defun gnus-group-default-level (&optional level number-or-nil)
982 (gnus-group-use-permanent-levels
983 (or (setq gnus-group-use-permanent-levels
984 (or level (if (numberp gnus-group-use-permanent-levels)
985 gnus-group-use-permanent-levels
986 (or gnus-group-default-list-level
987 gnus-level-subscribed))))
988 gnus-group-default-list-level gnus-level-subscribed))
992 (or level gnus-group-default-list-level gnus-level-subscribed))))
994 (defun gnus-group-setup-buffer ()
995 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
996 (unless (eq major-mode 'gnus-group-mode)
999 (gnus-carpal-setup-buffer 'group))))
1001 (defsubst gnus-group-name-charset (method group)
1003 (setq method (gnus-find-method-for-group group)))
1004 (let ((item (assoc method gnus-group-name-charset-method-alist))
1005 (alist gnus-group-name-charset-group-alist)
1009 (while (setq item (pop alist))
1010 (if (string-match (car item) group)
1012 result (cdr item))))
1015 (defsubst gnus-group-name-decode (string charset)
1016 (if (and string charset (featurep 'mule))
1017 (mm-decode-coding-string string charset)
1020 (defun gnus-group-decoded-name (string)
1021 (let ((charset (gnus-group-name-charset nil string)))
1022 (gnus-group-name-decode string charset)))
1024 (defun gnus-group-list-groups (&optional level unread lowest)
1025 "List newsgroups with level LEVEL or lower that have unread articles.
1026 Default is all subscribed groups.
1027 If argument UNREAD is non-nil, groups with no unread articles are also
1030 Also see the `gnus-group-use-permanent-levels' variable."
1032 (list (if current-prefix-arg
1033 (prefix-numeric-value current-prefix-arg)
1035 (gnus-group-default-level nil t)
1036 gnus-group-default-list-level
1037 gnus-level-subscribed))))
1039 (setq level (car gnus-group-list-mode)
1040 unread (cdr gnus-group-list-mode)))
1041 (setq level (gnus-group-default-level level))
1042 (gnus-group-setup-buffer)
1043 (gnus-update-format-specifications nil 'group 'group-mode)
1044 (let ((case-fold-search nil)
1045 (props (text-properties-at (gnus-point-at-bol)))
1046 (empty (= (point-min) (point-max)))
1047 (group (gnus-group-group-name))
1049 (set-buffer gnus-group-buffer)
1050 (setq number (funcall gnus-group-prepare-function level unread lowest))
1051 (when (or (and (numberp number)
1053 (zerop (buffer-size)))
1054 ;; No groups in the buffer.
1055 (gnus-message 5 gnus-no-groups-message))
1056 ;; We have some groups displayed.
1057 (goto-char (point-max))
1058 (when (or (not gnus-group-goto-next-group-function)
1059 (not (funcall gnus-group-goto-next-group-function
1063 (goto-char (point-min)))
1065 ;; Go to the first group with unread articles.
1066 (gnus-group-search-forward t))
1068 ;; Find the right group to put point on. If the current group
1069 ;; has disappeared in the new listing, try to find the next
1070 ;; one. If no next one can be found, just leave point at the
1071 ;; first newsgroup in the buffer.
1072 (when (not (gnus-goto-char
1074 (point-min) (point-max)
1075 'gnus-group (gnus-intern-safe
1076 group gnus-active-hashtb))))
1077 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1079 (not (gnus-goto-char
1081 (point-min) (point-max) 'gnus-group
1083 (caar newsrc) gnus-active-hashtb)))))
1084 (setq newsrc (cdr newsrc)))
1086 (goto-char (point-max))
1087 (forward-line -1)))))))
1088 ;; Adjust cursor point.
1089 (gnus-group-position-point)))
1091 (defun gnus-group-list-level (level &optional all)
1092 "List groups on LEVEL.
1093 If ALL (the prefix), also list groups that have no unread articles."
1094 (interactive "nList groups on level: \nP")
1095 (gnus-group-list-groups level all level))
1097 (defun gnus-group-prepare-logic (group test)
1098 (or (and gnus-group-listed-groups
1099 (null gnus-group-list-option)
1100 (member group gnus-group-listed-groups))
1102 ((null gnus-group-listed-groups) test)
1103 ((null gnus-group-list-option) test)
1104 (t (and (member group gnus-group-listed-groups)
1105 (if (eq gnus-group-list-option 'flush)
1109 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1110 "List all newsgroups with unread articles of level LEVEL or lower.
1111 If PREDICATE is a function, list groups that the function returns non-nil;
1112 if it is t, list groups that have no unread articles.
1113 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1114 If REGEXP is a function, list dead groups that the function returns non-nil;
1115 if it is a string, only list groups matching REGEXP."
1116 (set-buffer gnus-group-buffer)
1117 (let ((buffer-read-only nil)
1118 (newsrc (cdr gnus-newsrc-alist))
1119 (lowest (or lowest 1))
1120 (not-in-list (and gnus-group-listed-groups
1121 (copy-sequence gnus-group-listed-groups)))
1122 info clevel unread group params)
1124 (when (or (< lowest gnus-level-zombie)
1125 gnus-group-listed-groups)
1126 ;; List living groups.
1128 (setq info (car newsrc)
1129 group (gnus-info-group info)
1130 params (gnus-info-params info)
1132 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1134 (setq not-in-list (delete group not-in-list)))
1136 (gnus-group-prepare-logic
1138 (and unread ; This group might be unchecked
1139 (or (not (stringp regexp))
1140 (string-match regexp group))
1141 (<= (setq clevel (gnus-info-level info)) level)
1144 ((functionp predicate)
1145 (funcall predicate info))
1146 (predicate t) ; We list all groups?
1149 (if (eq unread t) ; Unactivated?
1150 gnus-group-list-inactive-groups
1151 ; We list unactivated
1153 ; We list groups with unread articles
1154 (and gnus-list-groups-with-ticked-articles
1155 (cdr (assq 'tick (gnus-info-marks info))))
1156 ; And groups with tickeds
1157 ;; Check for permanent visibility.
1158 (and gnus-permanently-visible-groups
1159 (string-match gnus-permanently-visible-groups group))
1160 (memq 'visible params)
1161 (cdr (assq 'visible params)))))))
1162 (gnus-group-insert-group-line
1163 group (gnus-info-level info)
1164 (gnus-info-marks info) unread (gnus-info-method info)))))
1166 ;; List dead groups.
1167 (if (or gnus-group-listed-groups
1168 (and (>= level gnus-level-zombie)
1169 (<= lowest gnus-level-zombie)))
1170 (gnus-group-prepare-flat-list-dead
1171 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1172 gnus-level-zombie ?Z
1175 (dolist (group gnus-zombie-list)
1176 (setq not-in-list (delete group not-in-list))))
1177 (if (or gnus-group-listed-groups
1178 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1179 (gnus-group-prepare-flat-list-dead
1182 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1183 gnus-level-killed ?K regexp))
1185 (gnus-group-set-mode-line)
1186 (setq gnus-group-list-mode (cons level predicate))
1187 (gnus-run-hooks 'gnus-group-prepare-hook)
1190 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1191 ;; List zombies and killed lists somewhat faster, which was
1192 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1193 ;; this by ignoring the group format specification altogether.
1195 (if (> (length groups) gnus-group-listing-limit)
1197 (setq group (pop groups))
1198 (when (gnus-group-prepare-logic
1201 (and (stringp regexp) (string-match regexp group))
1202 (and (functionp regexp) (funcall regexp group))))
1203 (gnus-add-text-properties
1204 (point) (prog1 (1+ (point))
1205 (insert " " mark " *: "
1206 (gnus-group-decoded-name group)
1208 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1210 'gnus-level level))))
1212 (setq group (pop groups))
1213 (when (gnus-group-prepare-logic
1216 (and (stringp regexp) (string-match regexp group))
1217 (and (functionp regexp) (funcall regexp group))))
1218 (gnus-group-insert-group-line
1220 (let ((active (gnus-active group)))
1222 (if (zerop (cdr active))
1224 (- (1+ (cdr active)) (car active)))
1226 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1228 (defun gnus-group-update-group-line ()
1229 "Update the current line in the group buffer."
1230 (let* ((buffer-read-only nil)
1231 (group (gnus-group-group-name))
1232 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1233 gnus-group-indentation)
1236 (not (gnus-ephemeral-group-p group))
1238 (concat "(gnus-group-set-info '"
1239 (gnus-prin1-to-string (nth 2 entry))
1241 (setq gnus-group-indentation (gnus-group-group-indentation))
1243 (gnus-group-insert-group-line-info group)
1245 (gnus-group-position-point))))
1247 (defun gnus-group-insert-group-line-info (group)
1248 "Insert GROUP on the current line."
1249 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1250 (gnus-group-indentation (gnus-group-group-indentation))
1254 ;; (Un)subscribed group.
1255 (setq info (nth 2 entry))
1256 (gnus-group-insert-group-line
1257 group (gnus-info-level info) (gnus-info-marks info)
1258 (or (car entry) t) (gnus-info-method info)))
1259 ;; This group is dead.
1260 (gnus-group-insert-group-line
1262 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1264 (if (setq active (gnus-active group))
1265 (if (zerop (cdr active))
1267 (- (1+ (cdr active)) (car active)))
1269 (gnus-method-simplify (gnus-find-method-for-group group))))))
1271 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1272 gnus-tmp-marked number
1274 "Insert a group line in the group buffer."
1275 (let* ((gnus-tmp-method
1276 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1277 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1279 (gnus-tmp-active (gnus-active gnus-tmp-group))
1280 (gnus-tmp-number-total
1282 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1284 (gnus-tmp-number-of-unread
1285 (if (numberp number) (int-to-string (max 0 number))
1287 (gnus-tmp-number-of-read
1288 (if (numberp number)
1289 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1291 (gnus-tmp-subscribed
1292 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1293 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1294 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1296 (gnus-tmp-qualified-group
1297 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1298 group-name-charset))
1299 (gnus-tmp-newsgroup-description
1300 (if gnus-description-hashtb
1301 (or (gnus-group-name-decode
1302 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1303 group-name-charset) "")
1306 (if (and gnus-moderated-hashtb
1307 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1309 (gnus-tmp-moderated-string
1310 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1311 (gnus-tmp-group-icon "==&&==")
1312 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1313 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1314 (gnus-tmp-news-method-string
1316 (format "(%s:%s)" (car gnus-tmp-method)
1317 (cadr gnus-tmp-method)) ""))
1318 (gnus-tmp-marked-mark
1319 (if (and (numberp number)
1321 (cdr (assq 'tick gnus-tmp-marked)))
1323 (gnus-tmp-process-marked
1324 (if (member gnus-tmp-group gnus-group-marked)
1325 gnus-process-mark ? ))
1327 (or (and gnus-use-grouplens
1328 (bbb-grouplens-group-p gnus-tmp-group))
1330 (buffer-read-only nil)
1331 header gnus-tmp-header) ; passed as parameter to user-funcs.
1333 (gnus-add-text-properties
1337 (eval gnus-group-line-format-spec))
1338 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1339 gnus-unread ,(if (numberp number)
1340 (string-to-int gnus-tmp-number-of-unread)
1342 gnus-marked ,gnus-tmp-marked-mark
1343 gnus-indentation ,gnus-group-indentation
1344 gnus-level ,gnus-tmp-level))
1346 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1347 (gnus-run-hooks 'gnus-group-update-hook))
1349 ;; Allow XEmacs to remove front-sticky text properties.
1350 (gnus-group-remove-excess-properties)))
1352 (defun gnus-group-highlight-line ()
1353 "Highlight the current line according to `gnus-group-highlight'."
1354 (let* ((list gnus-group-highlight)
1356 (end (progn (end-of-line) (point)))
1357 ;; now find out where the line starts and leave point there.
1358 (beg (progn (beginning-of-line) (point)))
1359 (group (gnus-group-group-name))
1360 (entry (gnus-group-entry group))
1361 (unread (if (numberp (car entry)) (car entry) 0))
1362 (active (gnus-active group))
1363 (total (if active (1+ (- (cdr active) (car active))) 0))
1364 (info (nth 2 entry))
1365 (method (gnus-server-get-method group (gnus-info-method info)))
1366 (marked (gnus-info-marks info))
1367 (mailp (memq 'mail (assoc (symbol-name
1368 (car (or method gnus-select-method)))
1369 gnus-valid-select-methods)))
1370 (level (or (gnus-info-level info) gnus-level-killed))
1371 (score (or (gnus-info-score info) 0))
1372 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1373 (group-age (gnus-group-timestamp-delta group))
1374 (inhibit-read-only t))
1375 ;; Eval the cars of the lists until we find a match.
1377 (not (eval (caar list))))
1378 (setq list (cdr list)))
1379 (let ((face (cdar list)))
1380 (unless (eq face (get-text-property beg 'face))
1381 (gnus-put-text-property-excluding-characters-with-faces
1383 (setq face (if (boundp face) (symbol-value face) face)))
1384 (gnus-extent-start-open beg)))
1387 (defun gnus-group-update-group (group &optional visible-only)
1388 "Update all lines where GROUP appear.
1389 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1391 ;; Can't use `save-excursion' here, so we do it manually.
1392 (let ((buf (current-buffer))
1394 (set-buffer gnus-group-buffer)
1395 (setq mark (point-marker))
1396 ;; The buffer may be narrowed.
1399 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1401 found buffer-read-only)
1402 ;; Enter the current status into the dribble buffer.
1403 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1405 (not (gnus-ephemeral-group-p group)))
1407 (concat "(gnus-group-set-info '"
1408 (gnus-prin1-to-string (nth 2 entry))
1410 ;; Find all group instances. If topics are in use, each group
1411 ;; may be listed in more than once.
1412 (while (setq loc (text-property-any
1413 loc (point-max) 'gnus-group ident))
1416 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1418 (gnus-group-insert-group-line-info group)
1421 (gnus-run-hooks 'gnus-group-update-group-hook)))
1422 (setq loc (1+ loc)))
1423 (unless (or found visible-only)
1424 ;; No such line in the buffer, find out where it's supposed to
1425 ;; go, and insert it there (or at the end of the buffer).
1426 (if gnus-goto-missing-group-function
1427 (funcall gnus-goto-missing-group-function group)
1428 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1429 (while (and entry (car entry)
1433 (point-min) (point-max)
1434 'gnus-group (gnus-intern-safe
1435 (caar entry) gnus-active-hashtb)))))
1436 (setq entry (cdr entry)))
1437 (or entry (goto-char (point-max)))))
1438 ;; Finally insert the line.
1439 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1440 (gnus-group-insert-group-line-info group)
1443 (gnus-run-hooks 'gnus-group-update-group-hook))))
1444 (when gnus-group-update-group-function
1445 (funcall gnus-group-update-group-function group))
1446 (gnus-group-set-mode-line)))
1448 (set-marker mark nil)
1451 (defun gnus-group-set-mode-line ()
1452 "Update the mode line in the group buffer."
1453 (when (memq 'group gnus-updated-mode-lines)
1454 ;; Yes, we want to keep this mode line updated.
1456 (set-buffer gnus-group-buffer)
1457 (let* ((gformat (or gnus-group-mode-line-format-spec
1458 (gnus-set-format 'group-mode)))
1459 (gnus-tmp-news-server (cadr gnus-select-method))
1460 (gnus-tmp-news-method (car gnus-select-method))
1461 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1463 gnus-tmp-header ;Dummy binding for user-defined formats
1464 ;; Get the resulting string.
1466 (and gnus-dribble-buffer
1467 (buffer-name gnus-dribble-buffer)
1468 (buffer-modified-p gnus-dribble-buffer)
1470 (set-buffer gnus-dribble-buffer)
1471 (not (zerop (buffer-size))))))
1472 (mode-string (eval gformat)))
1473 ;; Say whether the dribble buffer has been modified.
1474 (setq mode-line-modified
1475 (if modified (car gnus-mode-line-modified)
1476 (cdr gnus-mode-line-modified)))
1477 ;; If the line is too long, we chop it off.
1478 (when (> (length mode-string) max-len)
1479 (setq mode-string (substring mode-string 0 (- max-len 4))))
1481 (setq mode-line-buffer-identification
1482 (gnus-mode-line-buffer-identification
1483 (list mode-string)))
1484 (set-buffer-modified-p modified))))))
1486 (defun gnus-group-group-name ()
1487 "Get the name of the newsgroup on the current line."
1488 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1490 (symbol-name group))))
1492 (defun gnus-group-group-level ()
1493 "Get the level of the newsgroup on the current line."
1494 (get-text-property (gnus-point-at-bol) 'gnus-level))
1496 (defun gnus-group-group-indentation ()
1497 "Get the indentation of the newsgroup on the current line."
1498 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1499 (and gnus-group-indentation-function
1500 (funcall gnus-group-indentation-function))
1503 (defun gnus-group-group-unread ()
1504 "Get the number of unread articles of the newsgroup on the current line."
1505 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1507 (defun gnus-group-new-mail (group)
1508 (if (nnmail-new-mail-p (gnus-group-real-name group))
1512 (defun gnus-group-level (group)
1513 "Return the estimated level of GROUP."
1514 (or (gnus-info-level (gnus-get-info group))
1515 (and (member group gnus-zombie-list) gnus-level-zombie)
1518 (defun gnus-group-search-forward (&optional backward all level first-too)
1519 "Find the next newsgroup with unread articles.
1520 If BACKWARD is non-nil, find the previous newsgroup instead.
1521 If ALL is non-nil, just find any newsgroup.
1522 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1524 If FIRST-TOO, the current line is also eligible as a target."
1525 (let ((way (if backward -1 1))
1526 (low gnus-level-killed)
1529 (if (and backward (progn (beginning-of-line)) (bobp))
1538 (get-text-property (point) 'gnus-group)
1542 (get-text-property (point) 'gnus-unread)))
1543 (and (numberp unread) (> unread 0)))
1544 (setq lev (get-text-property (point)
1546 (<= lev gnus-level-subscribed)))
1548 (and (setq lev (get-text-property (point)
1557 (zerop (forward-line way)))))
1559 (progn (gnus-group-position-point) t)
1560 (goto-char (or pos beg))
1563 ;;; Gnus group mode commands
1567 (defun gnus-group-mark-line-p ()
1570 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1571 (eq (char-after) gnus-process-mark)))
1573 (defun gnus-group-mark-group (n &optional unmark no-advance)
1574 "Mark the current group."
1576 (let ((buffer-read-only nil)
1580 (when (setq group (gnus-group-group-name))
1581 ;; Go to the mark position.
1583 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1584 (subst-char-in-region
1585 (point) (1+ (point)) (char-after)
1588 (setq gnus-group-marked (delete group gnus-group-marked))
1590 (setq gnus-group-marked
1591 (cons group (delete group gnus-group-marked)))
1592 gnus-process-mark)))
1594 (gnus-group-next-group 1))
1596 (gnus-summary-position-point)
1599 (defun gnus-group-unmark-group (n)
1600 "Remove the mark from the current group."
1602 (gnus-group-mark-group n 'unmark)
1603 (gnus-group-position-point))
1605 (defun gnus-group-unmark-all-groups ()
1606 "Unmark all groups."
1608 (let ((groups gnus-group-marked))
1611 (gnus-group-remove-mark (pop groups)))))
1612 (gnus-group-position-point))
1614 (defun gnus-group-mark-region (unmark beg end)
1615 "Mark all groups between point and mark.
1616 If UNMARK, remove the mark instead."
1617 (interactive "P\nr")
1618 (let ((num (count-lines beg end)))
1621 (- num (gnus-group-mark-group num unmark)))))
1623 (defun gnus-group-mark-buffer (&optional unmark)
1624 "Mark all groups in the buffer.
1625 If UNMARK, remove the mark instead."
1627 (gnus-group-mark-region unmark (point-min) (point-max)))
1629 (defun gnus-group-mark-regexp (regexp)
1630 "Mark all groups that match some regexp."
1631 (interactive "sMark (regexp): ")
1632 (let ((alist (cdr gnus-newsrc-alist))
1635 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1636 (gnus-group-set-mark group))))
1637 (gnus-group-position-point))
1639 (defun gnus-group-remove-mark (group &optional test-marked)
1640 "Remove the process mark from GROUP and move point there.
1641 Return nil if the group isn't displayed."
1642 (if (gnus-group-goto-group group nil test-marked)
1644 (gnus-group-mark-group 1 'unmark t)
1646 (setq gnus-group-marked
1647 (delete group gnus-group-marked))
1650 (defun gnus-group-set-mark (group)
1651 "Set the process mark on GROUP."
1652 (if (gnus-group-goto-group group)
1654 (gnus-group-mark-group 1 nil t))
1655 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1657 (defun gnus-group-universal-argument (arg &optional groups func)
1658 "Perform any command on all groups according to the process/prefix convention."
1660 (if (eq (setq func (or func
1663 (substitute-command-keys
1664 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1666 (gnus-error 1 "Undefined key")
1667 (gnus-group-iterate arg
1669 (command-execute func))))
1670 (gnus-group-position-point))
1672 (defun gnus-group-process-prefix (n)
1673 "Return a list of groups to work on.
1674 Take into consideration N (the prefix) and the list of marked groups."
1677 (setq n (prefix-numeric-value n))
1678 ;; There is a prefix, so we return a list of the N next
1680 (let ((way (if (< n 0) -1 1))
1685 (if (setq group (gnus-group-group-name))
1686 (push group groups))
1688 (gnus-group-next-group way)))
1690 ((gnus-region-active-p)
1691 ;; Work on the region between point and mark.
1692 (let ((max (max (point) (mark)))
1695 (goto-char (min (point) (mark)))
1698 (push (gnus-group-group-name) groups)
1699 (zerop (gnus-group-next-group 1))
1701 (nreverse groups))))
1703 ;; No prefix, but a list of marked articles.
1704 (reverse gnus-group-marked))
1706 ;; Neither marked articles or a prefix, so we return the
1708 (let ((group (gnus-group-group-name)))
1709 (and group (list group))))))
1711 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1712 ;;; imagine why I went through these contortions...
1714 (let ((function (make-symbol "gnus-group-iterate-function"))
1715 (window (make-symbol "gnus-group-iterate-window"))
1716 (groups (make-symbol "gnus-group-iterate-groups"))
1717 (group (make-symbol "gnus-group-iterate-group")))
1719 `(defun gnus-group-iterate (arg ,function)
1720 "Iterate FUNCTION over all process/prefixed groups.
1721 FUNCTION will be called with the group name as the parameter
1722 and with point over the group in question."
1723 (let ((,groups (gnus-group-process-prefix arg))
1724 (,window (selected-window))
1727 (setq ,group (car ,groups)
1728 ,groups (cdr ,groups))
1729 (select-window ,window)
1730 (gnus-group-remove-mark ,group)
1731 (save-selected-window
1733 (funcall ,function ,group)))))))))
1735 (put 'gnus-group-iterate 'lisp-indent-function 1)
1737 ;; Selecting groups.
1739 (defun gnus-group-read-group (&optional all no-article group select-articles)
1740 "Read news in this newsgroup.
1741 If the prefix argument ALL is non-nil, already read articles become
1742 readable. IF ALL is a number, fetch this number of articles. If the
1743 optional argument NO-ARTICLE is non-nil, no article will be
1744 auto-selected upon group entry. If GROUP is non-nil, fetch that
1747 (let ((no-display (eq all 0))
1748 (group (or group (gnus-group-group-name)))
1749 number active marked entry)
1753 (error "No group on current line"))
1754 (setq marked (gnus-info-marks
1755 (nth 2 (setq entry (gnus-gethash
1756 group gnus-newsrc-hashtb)))))
1757 ;; This group might be a dead group. In that case we have to get
1758 ;; the number of unread articles from `gnus-active-hashtb'.
1760 (cond ((numberp all) all)
1762 ((setq active (gnus-active group))
1763 (- (1+ (cdr active)) (car active)))))
1764 (gnus-summary-read-group
1765 group (or all (and (numberp number)
1766 (zerop (+ number (gnus-range-length
1767 (cdr (assq 'tick marked)))
1769 (cdr (assq 'dormant marked)))))))
1770 no-article nil no-display nil select-articles)))
1772 (defun gnus-group-select-group (&optional all)
1773 "Select this newsgroup.
1774 No article is selected automatically.
1775 If ALL is non-nil, already read articles become readable.
1776 If ALL is a number, fetch this number of articles."
1778 (gnus-group-read-group all t))
1780 (defun gnus-group-quick-select-group (&optional all)
1781 "Select the current group \"quickly\".
1782 This means that no highlighting or scoring will be performed.
1783 If ALL (the prefix argument) is 0, don't even generate the summary
1786 This might be useful if you want to toggle threading
1787 before entering the group."
1789 (require 'gnus-score)
1791 gnus-score-find-score-files-function
1792 gnus-home-score-file
1793 gnus-apply-kill-hook
1794 gnus-summary-expunge-below)
1795 (gnus-group-read-group all t)))
1797 (defun gnus-group-visible-select-group (&optional all)
1798 "Select the current group without hiding any articles."
1800 (let ((gnus-inhibit-limiting t))
1801 (gnus-group-read-group all t)))
1803 (defun gnus-group-select-group-ephemerally ()
1804 "Select the current group without doing any processing whatsoever.
1805 You will actually be entered into a group that's a copy of
1806 the current group; no changes you make while in this group will
1809 (require 'gnus-score)
1811 gnus-score-find-score-files-function gnus-apply-kill-hook
1812 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1813 gnus-summary-mode-hook gnus-select-group-hook
1814 (group (gnus-group-group-name))
1815 (method (gnus-find-method-for-group group)))
1816 (gnus-group-read-ephemeral-group
1817 (gnus-group-prefixed-name group method) method)))
1820 (defun gnus-fetch-group (group)
1821 "Start Gnus if necessary and enter GROUP.
1822 Returns whether the fetching was successful or not."
1823 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1824 (unless (get-buffer gnus-group-buffer)
1826 (gnus-group-read-group nil nil group))
1829 (defun gnus-fetch-group-other-frame (group)
1830 "Pop up a frame and enter GROUP."
1832 (let ((window (get-buffer-window gnus-group-buffer)))
1834 (select-frame (window-frame window)))
1835 ((= (length (frame-list)) 1)
1836 (select-frame (make-frame)))
1839 (gnus-fetch-group group))
1841 (defvar gnus-ephemeral-group-server 0)
1843 ;; Enter a group that is not in the group buffer. Non-nil is returned
1844 ;; if selection was successful.
1845 (defun gnus-group-read-ephemeral-group (group method &optional activate
1846 quit-config request-only
1848 "Read GROUP from METHOD as an ephemeral group.
1849 If ACTIVATE, request the group first.
1850 If QUIT-CONFIG, use that window configuration when exiting from the
1852 If REQUEST-ONLY, don't actually read the group; just request it.
1853 If SELECT-ARTICLES, only select those articles.
1855 Return the name of the group if selection was successful."
1856 ;; Transform the select method into a unique server.
1857 (when (stringp method)
1858 (setq method (gnus-server-to-method method)))
1860 `(,(car method) ,(concat (cadr method) "-ephemeral")
1861 (,(intern (format "%s-address" (car method))) ,(cadr method))
1863 (let ((group (if (gnus-group-foreign-p group) group
1864 (gnus-group-prefixed-name group method))))
1868 ,gnus-level-default-subscribed nil nil ,method
1870 ,(if quit-config quit-config
1871 (cons gnus-summary-buffer
1872 gnus-current-window-configuration))))))
1874 (push method gnus-ephemeral-servers)
1875 (set-buffer gnus-group-buffer)
1876 (unless (gnus-check-server method)
1877 (error "Unable to contact server: %s" (gnus-status-message method)))
1879 (gnus-activate-group group 'scan)
1880 (unless (gnus-request-group group)
1881 (error "Couldn't request group: %s"
1882 (nnheader-get-report (car method)))))
1886 (when (gnus-group-read-group t t group select-articles)
1890 (message "Quit reading the ephemeral group")
1893 (defun gnus-group-jump-to-group (group)
1894 "Jump to newsgroup GROUP."
1896 (list (completing-read
1897 "Group: " gnus-active-hashtb nil
1898 (gnus-read-active-file-p)
1899 gnus-group-jump-to-group-prompt
1900 'gnus-group-history)))
1902 (when (equal group "")
1903 (error "Empty group name"))
1905 (unless (gnus-ephemeral-group-p group)
1906 ;; Either go to the line in the group buffer...
1907 (unless (gnus-group-goto-group group)
1908 ;; ... or insert the line.
1909 (gnus-group-update-group group)
1910 (gnus-group-goto-group group)))
1911 ;; Adjust cursor point.
1912 (gnus-group-position-point))
1914 (defun gnus-group-goto-group (group &optional far test-marked)
1915 "Goto to newsgroup GROUP.
1916 If FAR, it is likely that the group is not on the current line.
1917 If TEST-MARKED, the line must be marked."
1921 ;; It's quite likely that we are on the right line, so
1922 ;; we check the current line first.
1924 (eq (get-text-property (point) 'gnus-group)
1925 (gnus-intern-safe group gnus-active-hashtb))
1926 (or (not test-marked) (gnus-group-mark-line-p)))
1928 ;; Previous and next line are also likely, so we check them as well.
1932 (and (eq (get-text-property (point) 'gnus-group)
1933 (gnus-intern-safe group gnus-active-hashtb))
1934 (or (not test-marked) (gnus-group-mark-line-p)))))
1940 (and (eq (get-text-property (point) 'gnus-group)
1941 (gnus-intern-safe group gnus-active-hashtb))
1942 (or (not test-marked) (gnus-group-mark-line-p)))))
1946 (goto-char (point-min))
1948 (while (and (not found)
1953 (gnus-intern-safe group gnus-active-hashtb))))
1954 (if (gnus-group-mark-line-p)
1959 ;; Search through the entire buffer.
1962 (point-min) (point-max)
1963 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1965 (defun gnus-group-next-group (n &optional silent)
1966 "Go to next N'th newsgroup.
1967 If N is negative, search backward instead.
1968 Returns the difference between N and the number of skips actually
1971 (gnus-group-next-unread-group n t nil silent))
1973 (defun gnus-group-next-unread-group (n &optional all level silent)
1974 "Go to next N'th unread newsgroup.
1975 If N is negative, search backward instead.
1976 If ALL is non-nil, choose any newsgroup, unread or not.
1977 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1978 such group can be found, the next group with a level higher than
1980 Returns the difference between N and the number of skips actually
1983 (let ((backward (< n 0))
1986 (gnus-group-search-forward
1987 backward (or (not gnus-group-goto-unread) all) level))
1991 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1992 (if level " on this level or higher" "")))
1995 (defun gnus-group-prev-group (n)
1996 "Go to previous N'th newsgroup.
1997 Returns the difference between N and the number of skips actually
2000 (gnus-group-next-unread-group (- n) t))
2002 (defun gnus-group-prev-unread-group (n)
2003 "Go to previous N'th unread newsgroup.
2004 Returns the difference between N and the number of skips actually
2007 (gnus-group-next-unread-group (- n)))
2009 (defun gnus-group-next-unread-group-same-level (n)
2010 "Go to next N'th unread newsgroup on the same level.
2011 If N is negative, search backward instead.
2012 Returns the difference between N and the number of skips actually
2015 (gnus-group-next-unread-group n t (gnus-group-group-level))
2016 (gnus-group-position-point))
2018 (defun gnus-group-prev-unread-group-same-level (n)
2019 "Go to next N'th unread newsgroup on the same level.
2020 Returns the difference between N and the number of skips actually
2023 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2024 (gnus-group-position-point))
2026 (defun gnus-group-best-unread-group (&optional exclude-group)
2027 "Go to the group with the highest level.
2028 If EXCLUDE-GROUP, do not go to that group."
2030 (goto-char (point-min))
2034 (setq unread (get-text-property (point) 'gnus-unread))
2035 (when (and (numberp unread) (> unread 0))
2036 (when (and (get-text-property (point) 'gnus-level)
2037 (< (get-text-property (point) 'gnus-level) best)
2038 (or (not exclude-group)
2039 (not (equal exclude-group (gnus-group-group-name)))))
2040 (setq best (get-text-property (point) 'gnus-level))
2041 (setq best-point (point))))
2044 (goto-char best-point))
2045 (gnus-summary-position-point)
2046 (and best-point (gnus-group-group-name))))
2048 (defun gnus-group-first-unread-group ()
2049 "Go to the first group with unread articles."
2052 (let ((opoint (point))
2054 (goto-char (point-min))
2055 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2056 (and (numberp unread) ; Not a topic.
2057 (not (zerop unread))) ; Has unread articles.
2058 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2061 nil)) ; Not success.
2062 (gnus-group-position-point)))
2064 (defun gnus-group-enter-server-mode ()
2065 "Jump to the server buffer."
2067 (gnus-enter-server-buffer))
2069 (defun gnus-group-make-group (name &optional method address args)
2070 "Add a new newsgroup.
2071 The user will be prompted for a NAME, for a select METHOD, and an
2075 (gnus-read-group "Group name: ")
2076 (gnus-read-method "From method: ")))
2078 (when (stringp method)
2079 (setq method (or (gnus-server-to-method method) method)))
2080 (let* ((meth (gnus-method-simplify
2082 (not (gnus-server-equal method gnus-select-method)))
2083 (if address (list (intern method) address)
2085 (nname (if method (gnus-group-prefixed-name name meth) name))
2087 (when (gnus-gethash nname gnus-newsrc-hashtb)
2088 (error "Group %s already exists" nname))
2089 ;; Subscribe to the new group.
2090 (gnus-group-change-level
2091 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2092 gnus-level-default-subscribed gnus-level-killed
2093 (and (gnus-group-group-name)
2094 (gnus-gethash (gnus-group-group-name)
2095 gnus-newsrc-hashtb))
2098 (gnus-set-active nname (cons 1 0))
2099 (unless (gnus-ephemeral-group-p name)
2101 (concat "(gnus-group-set-info '"
2102 (gnus-prin1-to-string (cdr info)) ")")))
2104 (gnus-group-insert-group-line-info nname)
2106 (gnus-group-position-point)
2108 ;; Load the backend and try to make the backend create
2109 ;; the group as well.
2110 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2112 gnus-valid-select-methods)
2114 (gnus-check-server meth)
2115 (when (gnus-check-backend-function 'request-create-group nname)
2116 (gnus-request-create-group nname nil args))
2119 (defun gnus-group-delete-groups (&optional arg)
2120 "Delete the current group. Only meaningful with editable groups."
2122 (let ((n (length (gnus-group-process-prefix arg))))
2123 (when (gnus-yes-or-no-p
2125 "Delete this 1 group? "
2126 (format "Delete these %d groups? " n)))
2127 (gnus-group-iterate arg
2129 (gnus-group-delete-group group nil t))))))
2131 (defun gnus-group-delete-group (group &optional force no-prompt)
2132 "Delete the current group. Only meaningful with editable groups.
2133 If FORCE (the prefix) is non-nil, all the articles in the group will
2134 be deleted. This is \"deleted\" as in \"removed forever from the face
2135 of the Earth\". There is no undo. The user will be prompted before
2136 doing the deletion."
2138 (list (gnus-group-group-name)
2139 current-prefix-arg))
2141 (error "No group to rename"))
2142 (unless (gnus-check-backend-function 'request-delete-group group)
2143 (error "This backend does not support group deletion"))
2145 (if (and (not no-prompt)
2146 (not (gnus-yes-or-no-p
2148 "Do you really want to delete %s%s? "
2149 group (if force " and all its contents" "")))))
2151 (gnus-message 6 "Deleting group %s..." group)
2152 (if (not (gnus-request-delete-group group force))
2153 (gnus-error 3 "Couldn't delete group %s" group)
2154 (gnus-message 6 "Deleting group %s...done" group)
2155 (gnus-group-goto-group group)
2156 (gnus-group-kill-group 1 t)
2157 (gnus-sethash group nil gnus-active-hashtb)
2159 (gnus-group-position-point)))
2161 (defun gnus-group-rename-group (group new-name)
2162 "Rename group from GROUP to NEW-NAME.
2163 When used interactively, GROUP is the group under point
2164 and NEW-NAME will be prompted for."
2167 (gnus-group-group-name)
2169 (unless (gnus-check-backend-function
2170 'request-rename-group (gnus-group-group-name))
2171 (error "This backend does not support renaming groups"))
2172 (gnus-read-group "Rename group to: "
2173 (gnus-group-real-name (gnus-group-group-name))))))
2175 (unless (gnus-check-backend-function 'request-rename-group group)
2176 (error "This backend does not support renaming groups"))
2178 (error "No group to rename"))
2179 (when (equal (gnus-group-real-name group) new-name)
2180 (error "Can't rename to the same name"))
2182 ;; We find the proper prefixed name.
2184 (if (gnus-group-native-p group)
2188 (gnus-group-prefixed-name
2189 (gnus-group-real-name new-name)
2190 (gnus-info-method (gnus-get-info group)))))
2192 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2195 (gnus-group-goto-group group)
2196 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2197 (gnus-request-rename-group group new-name))))
2198 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2199 ;; We rename the group internally by killing it...
2200 (gnus-group-kill-group)
2201 ;; ... changing its name ...
2202 (setcar (cdar gnus-list-of-killed-groups) new-name)
2203 ;; ... and then yanking it. Magic!
2204 (gnus-group-yank-group)
2205 (gnus-set-active new-name (gnus-active group))
2206 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2208 (setq gnus-killed-list (delete group gnus-killed-list))
2209 (gnus-set-active group nil)
2210 (gnus-dribble-touch)
2211 (gnus-group-position-point)))
2213 (defun gnus-group-edit-group (group &optional part)
2214 "Edit the group on the current line."
2215 (interactive (list (gnus-group-group-name)))
2216 (let ((part (or part 'info))
2219 (error "No group on current line"))
2220 (unless (setq info (gnus-get-info group))
2221 (error "Killed group; can't be edited"))
2223 (gnus-close-group group))
2225 ;; Find the proper form to edit.
2226 (cond ((eq part 'method)
2227 (or (gnus-info-method info) "native"))
2229 (gnus-info-params info))
2231 ;; The proper documentation.
2233 "Editing the %s for `%s'."
2235 ((eq part 'method) "select method")
2236 ((eq part 'params) "group parameters")
2238 (gnus-group-decoded-name group))
2240 (gnus-group-edit-group-done ',part ,group form)))))
2242 (defun gnus-group-edit-group-method (group)
2243 "Edit the select method of GROUP."
2244 (interactive (list (gnus-group-group-name)))
2245 (gnus-group-edit-group group 'method))
2247 (defun gnus-group-edit-group-parameters (group)
2248 "Edit the group parameters of GROUP."
2249 (interactive (list (gnus-group-group-name)))
2250 (gnus-group-edit-group group 'params))
2252 (defun gnus-group-edit-group-done (part group form)
2254 (let* ((method (cond ((eq part 'info) (nth 4 form))
2255 ((eq part 'method) form)
2257 (info (cond ((eq part 'info) form)
2258 ((eq part 'method) (gnus-get-info group))
2261 (if (or (not method)
2263 gnus-select-method method))
2264 (gnus-group-real-name (car info))
2265 (gnus-group-prefixed-name
2266 (gnus-group-real-name (car info)) method))
2268 (when (and new-group
2269 (not (equal new-group group)))
2270 (when (gnus-group-goto-group group)
2271 (gnus-group-kill-group 1))
2272 (gnus-activate-group new-group))
2274 (if (not (and info new-group))
2275 (gnus-group-set-info form (or new-group group) part)
2276 (setq info (gnus-copy-sequence info))
2277 (setcar info new-group)
2278 (unless (gnus-server-equal method "native")
2279 (unless (nthcdr 3 info)
2280 (nconc info (list nil nil)))
2281 (unless (nthcdr 4 info)
2282 (nconc info (list nil)))
2283 (gnus-info-set-method info method))
2284 (gnus-group-set-info info))
2285 (gnus-group-update-group (or new-group group))
2286 (gnus-group-position-point)))
2288 (defun gnus-group-make-useful-group (group method)
2289 "Create one of the groups described in `gnus-useful-groups'."
2291 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2293 gnus-useful-groups)))
2294 (list (cadr entry) (caddr entry))))
2295 (setq method (gnus-copy-sequence method))
2297 (while (setq entry (memq (assq 'eval method) method))
2298 (setcar entry (eval (cadar entry)))))
2299 (gnus-group-make-group group method))
2301 (defun gnus-group-make-help-group ()
2302 "Create the Gnus documentation group."
2304 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2305 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2306 (when (gnus-gethash name gnus-newsrc-hashtb)
2307 (error "Documentation group already exists"))
2309 (gnus-message 1 "Couldn't find doc group")
2310 (gnus-group-make-group
2311 (gnus-group-real-name name)
2312 (list 'nndoc "gnus-help"
2313 (list 'nndoc-address file)
2314 (list 'nndoc-article-type 'mbox)))))
2315 (gnus-group-position-point))
2317 (defun gnus-group-make-doc-group (file type)
2318 "Create a group that uses a single file as the source."
2320 (list (read-file-name "File name: ")
2321 (and current-prefix-arg 'ask)))
2322 (when (eq type 'ask)
2327 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2329 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2330 ((= char ?b) 'babyl)
2331 ((= char ?d) 'digest)
2332 ((= char ?f) 'forward)
2334 ((= char ?g) 'guess)
2335 (t (setq err (format "%c unknown. " char))
2338 (let* ((file (expand-file-name file))
2339 (name (gnus-generate-new-group-name
2340 (gnus-group-prefixed-name
2341 (file-name-nondirectory file) '(nndoc "")))))
2342 (gnus-group-make-group
2343 (gnus-group-real-name name)
2345 (list 'nndoc-address file)
2346 (list 'nndoc-article-type (or type 'guess))))))
2348 (defvar nnweb-type-definition)
2349 (defvar gnus-group-web-type-history nil)
2350 (defvar gnus-group-web-search-history nil)
2351 (defun gnus-group-make-web-group (&optional solid)
2352 "Create an ephemeral nnweb group.
2353 If SOLID (the prefix), create a solid group."
2357 (if solid (gnus-read-group "Group name: ")
2358 (message-unique-id)))
2359 (default-type (or (car gnus-group-web-type-history)
2360 (symbol-name (caar nnweb-type-definition))))
2364 (format "Search engine type (default %s): " default-type)
2365 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2366 nnweb-type-definition)
2367 nil t nil 'gnus-group-web-type-history)
2372 (cons (or (car gnus-group-web-search-history) "") 0)
2373 'gnus-group-web-search-history))
2375 `(nnweb ,group (nnweb-search ,search)
2376 (nnweb-type ,(intern type))
2377 (nnweb-ephemeral-p t))))
2379 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2380 (gnus-group-read-ephemeral-group
2382 (cons (current-buffer)
2383 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2385 (defvar nnwarchive-type-definition)
2386 (defvar gnus-group-warchive-type-history nil)
2387 (defvar gnus-group-warchive-login-history nil)
2388 (defvar gnus-group-warchive-address-history nil)
2390 (defun gnus-group-make-warchive-group ()
2391 "Create a nnwarchive group."
2393 (require 'nnwarchive)
2394 (let* ((group (gnus-read-group "Group name: "))
2395 (default-type (or (car gnus-group-warchive-type-history)
2396 (symbol-name (caar nnwarchive-type-definition))))
2400 (format "Warchive type (default %s): " default-type)
2401 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2402 nnwarchive-type-definition)
2403 nil t nil 'gnus-group-warchive-type-history)
2405 (address (read-string "Warchive address: "
2406 nil 'gnus-group-warchive-address-history))
2407 (default-login (or (car gnus-group-warchive-login-history)
2412 (format "Warchive login (default %s): " user-mail-address)
2413 default-login 'gnus-group-warchive-login-history)
2416 `(nnwarchive ,address
2417 (nnwarchive-type ,(intern type))
2418 (nnwarchive-login ,login))))
2419 (gnus-group-make-group group method)))
2421 (defun gnus-group-make-archive-group (&optional all)
2422 "Create the (ding) Gnus archive group of the most recent articles.
2423 Given a prefix, create a full group."
2425 (let ((group (gnus-group-prefixed-name
2426 (if all "ding.archives" "ding.recent") '(nndir ""))))
2427 (when (gnus-gethash group gnus-newsrc-hashtb)
2428 (error "Archive group already exists"))
2429 (gnus-group-make-group
2430 (gnus-group-real-name group)
2431 (list 'nndir (if all "hpc" "edu")
2432 (list 'nndir-directory
2433 (if all gnus-group-archive-directory
2434 gnus-group-recent-archive-directory))))
2435 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2437 (defun gnus-group-make-directory-group (dir)
2438 "Create an nndir group.
2439 The user will be prompted for a directory. The contents of this
2440 directory will be used as a newsgroup. The directory should contain
2441 mail messages or news articles in files that have numeric names."
2443 (list (read-file-name "Create group from directory: ")))
2444 (unless (file-exists-p dir)
2445 (error "No such directory"))
2446 (unless (file-directory-p dir)
2447 (error "Not a directory"))
2451 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2453 (gnus-group-prefixed-name
2454 (expand-file-name ext dir)
2456 (setq ext (format "<%d>" (setq i (1+ i)))))
2457 (gnus-group-make-group
2458 (gnus-group-real-name group)
2459 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2461 (eval-when-compile (defvar nnkiboze-score-file))
2462 (defun gnus-group-make-kiboze-group (group address scores)
2463 "Create an nnkiboze group.
2464 The user will be prompted for a name, a regexp to match groups, and
2465 score file entries for articles to include in the group."
2468 (read-string "nnkiboze group name: ")
2469 (read-string "Source groups (regexp): ")
2470 (let ((headers (mapcar (lambda (group) (list group))
2471 '("subject" "from" "number" "date" "message-id"
2472 "references" "chars" "lines" "xref"
2473 "followup" "all" "body" "head")))
2474 scores header regexp regexps)
2475 (while (not (equal "" (setq header (completing-read
2476 "Match on header: " headers nil t))))
2478 (while (not (equal "" (setq regexp (read-string
2479 (format "Match on %s (regexp): "
2481 (push (list regexp nil nil 'r) regexps))
2482 (push (cons header regexps) scores))
2484 (gnus-group-make-group group "nnkiboze" address)
2485 (let* ((nnkiboze-current-group group)
2486 (score-file (car (nnkiboze-score-file "")))
2487 (score-dir (file-name-directory score-file)))
2488 (unless (file-exists-p score-dir)
2489 (make-directory score-dir))
2490 (with-temp-file score-file
2491 (let (emacs-lisp-mode-hook)
2492 (pp scores (current-buffer))))))
2494 (defun gnus-group-add-to-virtual (n vgroup)
2495 "Add the current group to a virtual group."
2497 (list current-prefix-arg
2498 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2500 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2501 (error "%s is not an nnvirtual group" vgroup))
2502 (gnus-close-group vgroup)
2503 (let* ((groups (gnus-group-process-prefix n))
2504 (method (gnus-info-method (gnus-get-info vgroup))))
2505 (setcar (cdr method)
2507 (nth 1 method) "\\|"
2510 (gnus-group-remove-mark s)
2511 (concat "\\(^" (regexp-quote s) "$\\)"))
2513 (gnus-group-position-point))
2515 (defun gnus-group-make-empty-virtual (group)
2516 "Create a new, fresh, empty virtual group."
2517 (interactive "sCreate new, empty virtual group: ")
2518 (let* ((method (list 'nnvirtual "^$"))
2519 (pgroup (gnus-group-prefixed-name group method)))
2520 ;; Check whether it exists already.
2521 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2522 (error "Group %s already exists" pgroup))
2523 ;; Subscribe the new group after the group on the current line.
2524 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2525 (gnus-group-update-group pgroup)
2527 (gnus-group-position-point)))
2529 (defun gnus-group-enter-directory (dir)
2530 "Enter an ephemeral nneething group."
2531 (interactive "DDirectory to read: ")
2532 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2533 (leaf (gnus-group-prefixed-name
2534 (file-name-nondirectory (directory-file-name dir))
2536 (name (gnus-generate-new-group-name leaf)))
2537 (unless (gnus-group-read-ephemeral-group
2539 (cons (current-buffer)
2540 (if (eq major-mode 'gnus-summary-mode)
2542 (error "Couldn't enter %s" dir))))
2545 (autoload 'nnimap-expunge "nnimap")
2546 (autoload 'nnimap-acl-get "nnimap")
2547 (autoload 'nnimap-acl-edit "nnimap"))
2549 (defun gnus-group-nnimap-expunge (group)
2550 "Expunge deleted articles in current nnimap GROUP."
2551 (interactive (list (gnus-group-group-name)))
2552 (let ((mailbox (gnus-group-real-name group)) method)
2554 (error "No group on current line"))
2555 (unless (gnus-get-info group)
2556 (error "Killed group; can't be edited"))
2557 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2558 (error "%s is not an nnimap group" group))
2559 (nnimap-expunge mailbox (cadr method))))
2561 (defun gnus-group-nnimap-edit-acl (group)
2562 "Edit the Access Control List of current nnimap GROUP."
2563 (interactive (list (gnus-group-group-name)))
2564 (let ((mailbox (gnus-group-real-name group)) method acl)
2566 (error "No group on current line"))
2567 (unless (gnus-get-info group)
2568 (error "Killed group; can't be edited"))
2569 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2570 (error "%s is not an nnimap group" group))
2571 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2572 (error "Server does not support ACL's"))
2573 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2575 An access control list is a list of (identifier . rights) elements.
2577 The identifier string specifies the corresponding user. The
2578 identifier \"anyone\" is reserved to refer to the universal identity.
2580 Rights is a string listing a (possibly empty) set of alphanumeric
2581 characters, each character listing a set of operations which is being
2582 controlled. Letters are reserved for ``standard'' rights, listed
2583 below. Digits are reserved for implementation or site defined rights.
2585 l - lookup (mailbox is visible to LIST/LSUB commands)
2586 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2587 SEARCH, COPY from mailbox)
2588 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2589 w - write (STORE flags other than \\SEEN and \\DELETED)
2590 i - insert (perform APPEND, COPY into mailbox)
2591 p - post (send mail to submission address for mailbox,
2592 not enforced by IMAP4 itself)
2593 c - create and delete mailbox (CREATE new sub-mailboxes in any
2594 implementation-defined hierarchy, RENAME or DELETE mailbox)
2595 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2596 a - administer (perform SETACL)" group)
2599 ,mailbox ',method ',acl form)))))
2601 ;; Group sorting commands
2602 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2604 (defun gnus-group-sort-groups (func &optional reverse)
2605 "Sort the group buffer according to FUNC.
2606 When used interactively, the sorting function used will be
2607 determined by the `gnus-group-sort-function' variable.
2608 If REVERSE (the prefix), reverse the sorting order."
2609 (interactive (list gnus-group-sort-function current-prefix-arg))
2610 (funcall gnus-group-sort-alist-function
2611 (gnus-make-sort-function func) reverse)
2612 (gnus-group-list-groups)
2613 (gnus-dribble-touch))
2615 (defun gnus-group-sort-flat (func reverse)
2616 ;; We peel off the dummy group from the alist.
2618 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2619 (pop gnus-newsrc-alist))
2621 (setq gnus-newsrc-alist
2622 (sort gnus-newsrc-alist func))
2624 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2625 ;; Regenerate the hash table.
2626 (gnus-make-hashtable-from-newsrc-alist)))
2628 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2629 "Sort the group buffer alphabetically by group name.
2630 If REVERSE, sort in reverse order."
2632 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2634 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2635 "Sort the group buffer by number of unread articles.
2636 If REVERSE, sort in reverse order."
2638 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2640 (defun gnus-group-sort-groups-by-level (&optional reverse)
2641 "Sort the group buffer by group level.
2642 If REVERSE, sort in reverse order."
2644 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2646 (defun gnus-group-sort-groups-by-score (&optional reverse)
2647 "Sort the group buffer by group score.
2648 If REVERSE, sort in reverse order."
2650 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2652 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2653 "Sort the group buffer by group rank.
2654 If REVERSE, sort in reverse order."
2656 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2658 (defun gnus-group-sort-groups-by-method (&optional reverse)
2659 "Sort the group buffer alphabetically by backend name.
2660 If REVERSE, sort in reverse order."
2662 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2664 (defun gnus-group-sort-groups-by-server (&optional reverse)
2665 "Sort the group buffer alphabetically by server name.
2666 If REVERSE, sort in reverse order."
2668 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2670 ;;; Selected group sorting.
2672 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2673 "Sort the process/prefixed groups."
2674 (interactive (list current-prefix-arg gnus-group-sort-function))
2675 (let ((groups (gnus-group-process-prefix n)))
2676 (funcall gnus-group-sort-selected-function
2677 groups (gnus-make-sort-function func) reverse)
2678 (gnus-group-list-groups)))
2680 (defun gnus-group-sort-selected-flat (groups func reverse)
2681 (let (entries infos)
2682 ;; First find all the group entries for these groups.
2684 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2686 ;; Then sort the infos.
2690 (lambda (entry) (car entry))
2691 (setq entries (nreverse entries)))
2694 (setq infos (nreverse infos)))
2695 ;; Go through all the infos and replace the old entries
2696 ;; with the new infos.
2698 (setcar (car entries) (pop infos))
2700 ;; Update the hashtable.
2701 (gnus-make-hashtable-from-newsrc-alist)))
2703 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2704 "Sort the group buffer alphabetically by group name.
2705 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2706 sort in reverse order."
2707 (interactive (gnus-interactive "P\ny"))
2708 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2710 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2711 "Sort the group buffer by number of unread articles.
2712 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2713 sort in reverse order."
2714 (interactive (gnus-interactive "P\ny"))
2715 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2717 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2718 "Sort the group buffer by group level.
2719 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2720 sort in reverse order."
2721 (interactive (gnus-interactive "P\ny"))
2722 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2724 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2725 "Sort the group buffer by group score.
2726 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2727 sort in reverse order."
2728 (interactive (gnus-interactive "P\ny"))
2729 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2731 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2732 "Sort the group buffer by group rank.
2733 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2734 sort in reverse order."
2735 (interactive (gnus-interactive "P\ny"))
2736 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2738 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2739 "Sort the group buffer alphabetically by backend name.
2740 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2741 sort in reverse order."
2742 (interactive (gnus-interactive "P\ny"))
2743 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2745 ;;; Sorting predicates.
2747 (defun gnus-group-sort-by-alphabet (info1 info2)
2748 "Sort alphabetically."
2749 (string< (gnus-info-group info1) (gnus-info-group info2)))
2751 (defun gnus-group-sort-by-real-name (info1 info2)
2752 "Sort alphabetically on real (unprefixed) names."
2753 (string< (gnus-group-real-name (gnus-info-group info1))
2754 (gnus-group-real-name (gnus-info-group info2))))
2756 (defun gnus-group-sort-by-unread (info1 info2)
2757 "Sort by number of unread articles."
2758 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2759 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2760 (< (or (and (numberp n1) n1) 0)
2761 (or (and (numberp n2) n2) 0))))
2763 (defun gnus-group-sort-by-level (info1 info2)
2765 (< (gnus-info-level info1) (gnus-info-level info2)))
2767 (defun gnus-group-sort-by-method (info1 info2)
2768 "Sort alphabetically by backend name."
2769 (string< (symbol-name (car (gnus-find-method-for-group
2770 (gnus-info-group info1) info1)))
2771 (symbol-name (car (gnus-find-method-for-group
2772 (gnus-info-group info2) info2)))))
2774 (defun gnus-group-sort-by-server (info1 info2)
2775 "Sort alphabetically by server name."
2776 (string< (gnus-method-to-server-name
2777 (gnus-find-method-for-group
2778 (gnus-info-group info1) info1))
2779 (gnus-method-to-server-name
2780 (gnus-find-method-for-group
2781 (gnus-info-group info2) info2))))
2783 (defun gnus-group-sort-by-score (info1 info2)
2784 "Sort by group score."
2785 (> (gnus-info-score info1) (gnus-info-score info2)))
2787 (defun gnus-group-sort-by-rank (info1 info2)
2788 "Sort by level and score."
2789 (let ((level1 (gnus-info-level info1))
2790 (level2 (gnus-info-level info2)))
2791 (or (< level1 level2)
2792 (and (= level1 level2)
2793 (> (gnus-info-score info1) (gnus-info-score info2))))))
2797 (defun gnus-group-clear-data (&optional arg)
2798 "Clear all marks and read ranges from the current group."
2800 (gnus-group-iterate arg
2803 (gnus-info-clear-data (setq info (gnus-get-info group)))
2804 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2805 (when (gnus-group-goto-group group)
2806 (gnus-group-update-group-line))))))
2808 (defun gnus-group-clear-data-on-native-groups ()
2809 "Clear all marks and read ranges from all native groups."
2811 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2812 (let ((alist (cdr gnus-newsrc-alist))
2814 (while (setq info (pop alist))
2815 (when (gnus-group-native-p (gnus-info-group info))
2816 (gnus-info-clear-data info)))
2817 (gnus-get-unread-articles)
2818 (gnus-dribble-touch)
2819 (when (gnus-y-or-n-p
2820 "Move the cache away to avoid problems in the future? ")
2821 (call-interactively 'gnus-cache-move-cache)))))
2823 (defun gnus-info-clear-data (info)
2824 "Clear all marks and read ranges from INFO."
2825 (let ((group (gnus-info-group info)))
2828 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2829 (gnus-info-set-read ',info ',(gnus-info-read info))
2830 (when (gnus-group-goto-group ,group)
2831 (gnus-group-update-group-line))))
2832 (gnus-info-set-read info nil)
2833 (when (gnus-info-marks info)
2834 (gnus-info-set-marks info nil))))
2836 ;; Group catching up.
2838 (defun gnus-group-catchup-current (&optional n all)
2839 "Mark all unread articles in the current newsgroup as read.
2840 If prefix argument N is numeric, the next N newsgroups will be
2841 caught up. If ALL is non-nil, marked articles will also be marked as
2842 read. Cross references (Xref: header) of articles are ignored.
2843 The number of newsgroups that this function was unable to catch
2846 (let ((groups (gnus-group-process-prefix n))
2849 (unless groups (error "No groups selected"))
2851 (or (not gnus-interactive-catchup) ;Without confirmation?
2856 "Do you really want to mark all articles in %s as read? "
2857 "Mark all unread articles in %s as read? ")
2858 (if (= (length groups) 1)
2860 (format "these %d groups" (length groups)))))))
2862 (while (setq group (pop groups))
2863 (gnus-group-remove-mark group)
2864 ;; Virtual groups have to be given special treatment.
2865 (let ((method (gnus-find-method-for-group group)))
2866 (when (eq 'nnvirtual (car method))
2867 (nnvirtual-catchup-group
2868 (gnus-group-real-name group) (nth 1 method) all)))
2869 (if (>= (gnus-group-level group) gnus-level-zombie)
2870 (gnus-message 2 "Dead groups can't be caught up")
2872 (gnus-group-goto-group group)
2873 (gnus-group-catchup group all))
2874 (gnus-group-update-group-line)
2875 (setq ret (1+ ret)))))
2876 (gnus-group-next-unread-group 1)
2879 (defun gnus-group-catchup-current-all (&optional n)
2880 "Mark all articles in current newsgroup as read.
2881 Cross references (Xref: header) of articles are ignored."
2883 (gnus-group-catchup-current n 'all))
2885 (defun gnus-group-catchup (group &optional all)
2886 "Mark all articles in GROUP as read.
2887 If ALL is non-nil, all articles are marked as read.
2888 The return value is the number of articles that were marked as read,
2889 or nil if no action could be taken."
2890 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2892 ;; Remove entries for this group.
2893 (nnmail-purge-split-history (gnus-group-real-name group))
2894 ;; Do the updating only if the newsgroup isn't killed.
2895 (if (not (numberp (car entry)))
2896 (gnus-message 1 "Can't catch up %s; non-active group" group)
2897 ;; Do auto-expirable marks if that's required.
2898 (when (gnus-group-auto-expirable-p group)
2899 (gnus-add-marked-articles
2900 group 'expire (gnus-list-of-unread-articles group))
2902 (let ((marks (nth 3 (nth 2 entry))))
2903 (gnus-add-marked-articles
2904 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2905 (gnus-add-marked-articles
2906 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2908 (gnus-update-read-articles group nil)
2909 ;; Also nix out the lists of marks and dormants.
2911 (gnus-add-marked-articles group 'tick nil nil 'force)
2912 (gnus-add-marked-articles group 'dormant nil nil 'force))
2913 (let ((gnus-newsgroup-name group))
2914 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2917 (defun gnus-group-expire-articles (&optional n)
2918 "Expire all expirable articles in the current newsgroup."
2920 (let ((groups (gnus-group-process-prefix n))
2923 (error "No groups to expire"))
2924 (while (setq group (pop groups))
2925 (gnus-group-remove-mark group)
2926 (gnus-group-expire-articles-1 group)
2927 (gnus-dribble-touch)
2928 (gnus-group-position-point))))
2930 (defun gnus-group-expire-articles-1 (group)
2931 (when (gnus-check-backend-function 'request-expire-articles group)
2932 (gnus-message 6 "Expiring articles in %s..." group)
2933 (let* ((info (gnus-get-info group))
2934 (expirable (if (gnus-group-total-expirable-p group)
2935 (cons nil (gnus-list-of-read-articles group))
2936 (assq 'expire (gnus-info-marks info))))
2937 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2938 (nnmail-expiry-target
2939 (or (gnus-group-find-parameter group 'expiry-target)
2940 nnmail-expiry-target)))
2942 (gnus-check-group group)
2945 (gnus-compress-sequence
2947 ;; We set the expiry variables to the group
2949 (let ((nnmail-expiry-wait-function nil)
2950 (nnmail-expiry-wait expiry-wait))
2951 (gnus-request-expire-articles
2952 (gnus-uncompress-sequence (cdr expirable)) group))
2953 ;; Just expire using the normal expiry values.
2954 (gnus-request-expire-articles
2955 (gnus-uncompress-sequence (cdr expirable)) group))))
2956 (gnus-close-group group))
2957 (gnus-message 6 "Expiring articles in %s...done" group)
2958 ;; Return the list of un-expired articles.
2961 (defun gnus-group-expire-all-groups ()
2962 "Expire all expirable articles in all newsgroups."
2965 (gnus-message 5 "Expiring...")
2966 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2967 (cdr gnus-newsrc-alist))))
2968 (gnus-group-expire-articles nil)))
2969 (gnus-group-position-point)
2970 (gnus-message 5 "Expiring...done"))
2972 (defun gnus-group-set-current-level (n level)
2973 "Set the level of the next N groups to LEVEL."
2978 (let ((s (read-string
2979 (format "Level (default %s): "
2980 (or (gnus-group-group-level)
2981 gnus-level-default-subscribed)))))
2982 (if (string-match "^\\s-*$" s)
2983 (int-to-string (or (gnus-group-group-level)
2984 gnus-level-default-subscribed))
2986 (unless (and (>= level 1) (<= level gnus-level-killed))
2987 (error "Invalid level: %d" level))
2988 (let ((groups (gnus-group-process-prefix n))
2990 (while (setq group (pop groups))
2991 (gnus-group-remove-mark group)
2992 (gnus-message 6 "Changed level of %s from %d to %d"
2993 group (or (gnus-group-group-level) gnus-level-killed)
2995 (gnus-group-change-level
2996 group level (or (gnus-group-group-level) gnus-level-killed))
2997 (gnus-group-update-group-line)))
2998 (gnus-group-position-point))
3000 (defun gnus-group-unsubscribe (&optional n)
3001 "Unsubscribe the current group."
3003 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3005 (defun gnus-group-subscribe (&optional n)
3006 "Subscribe the current group."
3008 (gnus-group-unsubscribe-current-group n 'subscribe))
3010 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3011 "Toggle subscription of the current group.
3012 If given numerical prefix, toggle the N next groups."
3014 (let ((groups (gnus-group-process-prefix n))
3017 (setq group (car groups)
3018 groups (cdr groups))
3019 (gnus-group-remove-mark group)
3020 (gnus-group-unsubscribe-group
3023 ((eq do-sub 'unsubscribe)
3024 gnus-level-default-unsubscribed)
3025 ((eq do-sub 'subscribe)
3026 gnus-level-default-subscribed)
3027 ((<= (gnus-group-group-level) gnus-level-subscribed)
3028 gnus-level-default-unsubscribed)
3030 gnus-level-default-subscribed))
3032 (gnus-group-update-group-line))
3033 (gnus-group-next-group 1)))
3035 (defun gnus-group-unsubscribe-group (group &optional level silent)
3036 "Toggle subscription to GROUP.
3037 Killed newsgroups are subscribed. If SILENT, don't try to update the
3040 (list (completing-read
3041 "Group: " gnus-active-hashtb nil
3042 (gnus-read-active-file-p)
3044 'gnus-group-history)))
3045 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3047 ((string-match "^[ \t]*$" group)
3048 (error "Empty group name"))
3050 ;; Toggle subscription flag.
3051 (gnus-group-change-level
3052 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3053 gnus-level-subscribed)
3054 (1+ gnus-level-subscribed)
3055 gnus-level-default-subscribed)))
3057 (gnus-group-update-group group)))
3058 ((and (stringp group)
3059 (or (not (gnus-read-active-file-p))
3060 (gnus-active group)))
3061 ;; Add new newsgroup.
3062 (gnus-group-change-level
3064 (if level level gnus-level-default-subscribed)
3065 (or (and (member group gnus-zombie-list)
3068 (when (gnus-group-group-name)
3069 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3071 (gnus-group-update-group group)))
3072 (t (error "No such newsgroup: %s" group)))
3073 (gnus-group-position-point)))
3075 (defun gnus-group-transpose-groups (n)
3076 "Move the current newsgroup up N places.
3077 If given a negative prefix, move down instead. The difference between
3078 N and the number of steps taken is returned."
3080 (unless (gnus-group-group-name)
3081 (error "No group on current line"))
3082 (gnus-group-kill-group 1)
3084 (forward-line (- n))
3085 (gnus-group-yank-group)
3086 (gnus-group-position-point)))
3088 (defun gnus-group-kill-all-zombies (&optional dummy)
3089 "Kill all zombie newsgroups.
3090 The optional DUMMY should always be nil."
3091 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3093 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3094 (setq gnus-zombie-list nil)
3095 (gnus-dribble-touch)
3096 (gnus-group-list-groups)))
3098 (defun gnus-group-kill-region (begin end)
3099 "Kill newsgroups in current region (excluding current point).
3100 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3115 (beginning-of-line) ;Important when LINES < 1
3116 (gnus-group-kill-group lines)))
3118 (defun gnus-group-kill-group (&optional n discard)
3119 "Kill the next N groups.
3120 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3121 However, only groups that were alive can be yanked; already killed
3122 groups or zombie groups can't be yanked.
3123 The return value is the name of the group that was killed, or a list
3126 (let ((buffer-read-only nil)
3127 (groups (gnus-group-process-prefix n))
3128 group entry level out)
3129 (if (< (length groups) 10)
3130 ;; This is faster when there are few groups.
3132 (push (setq group (pop groups)) out)
3133 (gnus-group-remove-mark group)
3134 (setq level (gnus-group-group-level))
3136 (when (and (not discard)
3137 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3140 (gnus-group-goto-group ,(gnus-group-group-name))
3141 (gnus-group-yank-group)))
3142 (push (cons (car entry) (nth 2 entry))
3143 gnus-list-of-killed-groups))
3144 (gnus-group-change-level
3145 (if entry entry group) gnus-level-killed (if entry nil level))
3146 (message "Killed group %s" group))
3147 ;; If there are lots and lots of groups to be killed, we use
3148 ;; this thing instead.
3150 (setq groups (nreverse groups))
3152 (gnus-group-remove-mark (setq group (pop groups)))
3154 (push group gnus-killed-list)
3155 (setq gnus-newsrc-alist
3156 (delq (assoc group gnus-newsrc-alist)
3158 (when gnus-group-change-level-function
3159 (funcall gnus-group-change-level-function
3160 group gnus-level-killed 3))
3162 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3163 (push (cons (car entry) (nth 2 entry))
3164 gnus-list-of-killed-groups)
3165 (setcdr (cdr entry) (cdddr entry)))
3166 ((member group gnus-zombie-list)
3167 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3168 ;; There may be more than one instance displayed.
3169 (while (gnus-group-goto-group group)
3170 (gnus-delete-line)))
3171 (gnus-make-hashtable-from-newsrc-alist)))
3173 (gnus-group-position-point)
3174 (if (< (length out) 2) (car out) (nreverse out))))
3176 (defun gnus-group-yank-group (&optional arg)
3177 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3178 The numeric ARG specifies how many newsgroups are to be yanked. The
3179 name of the newsgroup yanked is returned, or (if several groups are
3180 yanked) a list of yanked groups is returned."
3182 (setq arg (or arg 1))
3183 (let (info group prev out)
3184 (while (>= (decf arg) 0)
3185 (when (not (setq info (pop gnus-list-of-killed-groups)))
3186 (error "No more newsgroups to yank"))
3187 (push (setq group (nth 1 info)) out)
3188 ;; Find which newsgroup to insert this one before - search
3189 ;; backward until something suitable is found. If there are no
3190 ;; other newsgroups in this buffer, just make this newsgroup the
3192 (setq prev (gnus-group-group-name))
3193 (gnus-group-change-level
3194 info (gnus-info-level (cdr info)) gnus-level-killed
3195 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3197 (gnus-group-insert-group-line-info group)
3199 `(when (gnus-group-goto-group ,group)
3200 (gnus-group-kill-group 1))))
3202 (gnus-group-position-point)
3203 (if (< (length out) 2) (car out) (nreverse out))))
3205 (defun gnus-group-kill-level (level)
3206 "Kill all groups that is on a certain LEVEL."
3207 (interactive "nKill all groups on level: ")
3209 ((= level gnus-level-zombie)
3210 (setq gnus-killed-list
3211 (nconc gnus-zombie-list gnus-killed-list))
3212 (setq gnus-zombie-list nil))
3213 ((and (< level gnus-level-zombie)
3215 (or gnus-expert-user
3218 "Do you really want to kill all groups on level %d? "
3220 (let* ((prev gnus-newsrc-alist)
3223 (if (= (gnus-info-level (car alist)) level)
3225 (push (gnus-info-group (car alist)) gnus-killed-list)
3226 (setcdr prev (cdr alist)))
3228 (setq alist (cdr alist)))
3229 (gnus-make-hashtable-from-newsrc-alist)
3230 (gnus-group-list-groups)))
3232 (error "Can't kill; invalid level: %d" level))))
3234 (defun gnus-group-list-all-groups (&optional arg)
3235 "List all newsgroups with level ARG or lower.
3236 Default is gnus-level-unsubscribed, which lists all subscribed and most
3237 unsubscribed groups."
3239 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3241 ;; Redefine this to list ALL killed groups if prefix arg used.
3242 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3243 (defun gnus-group-list-killed (&optional arg)
3244 "List all killed newsgroups in the group buffer.
3245 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3246 entail asking the server for the groups."
3248 ;; Find all possible killed newsgroups if arg.
3250 (gnus-get-killed-groups))
3251 (if (not gnus-killed-list)
3252 (gnus-message 6 "No killed groups")
3253 (let (gnus-group-list-mode)
3254 (funcall gnus-group-prepare-function
3255 gnus-level-killed t gnus-level-killed))
3256 (goto-char (point-min)))
3257 (gnus-group-position-point))
3259 (defun gnus-group-list-zombies ()
3260 "List all zombie newsgroups in the group buffer."
3262 (if (not gnus-zombie-list)
3263 (gnus-message 6 "No zombie groups")
3264 (let (gnus-group-list-mode)
3265 (funcall gnus-group-prepare-function
3266 gnus-level-zombie t gnus-level-zombie))
3267 (goto-char (point-min)))
3268 (gnus-group-position-point))
3270 (defun gnus-group-list-active ()
3271 "List all groups that are available from the server(s)."
3273 ;; First we make sure that we have really read the active file.
3274 (unless (gnus-read-active-file-p)
3275 (let ((gnus-read-active-file t)
3276 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3277 (gnus-read-active-file)))
3278 ;; Find all groups and sort them.
3286 (push (symbol-name sym) list)))
3290 (buffer-read-only nil)
3294 (setq group (pop groups))
3295 (gnus-add-text-properties
3296 (point) (prog1 (1+ (point))
3298 (gnus-group-decoded-name group)
3300 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3302 'gnus-level (inline (gnus-group-level group)))))
3303 (goto-char (point-min))))
3305 (defun gnus-activate-all-groups (level)
3306 "Activate absolutely all groups."
3307 (interactive (list gnus-level-unsubscribed))
3308 (let ((gnus-activate-level level)
3309 (gnus-activate-foreign-newsgroups level))
3310 (gnus-group-get-new-news)))
3312 (defun gnus-group-get-new-news (&optional arg)
3313 "Get newly arrived articles.
3314 If ARG is a number, it specifies which levels you are interested in
3315 re-scanning. If ARG is non-nil and not a number, this will force
3316 \"hard\" re-reading of the active files from all servers."
3319 (let ((gnus-inhibit-demon t)
3320 ;; Binding this variable will inhibit multiple fetchings
3321 ;; of the same mail source.
3322 (nnmail-fetched-sources (list t)))
3323 (gnus-run-hooks 'gnus-get-new-news-hook)
3325 ;; Read any slave files.
3327 (gnus-master-read-slave-newsrc))
3329 ;; We might read in new NoCeM messages here.
3330 (when (and gnus-use-nocem
3332 (gnus-nocem-scan-groups))
3333 ;; If ARG is not a number, then we read the active file.
3334 (when (and arg (not (numberp arg)))
3335 (let ((gnus-read-active-file t))
3336 (gnus-read-active-file))
3339 ;; If the user wants it, we scan for new groups.
3340 (when (eq gnus-check-new-newsgroups 'always)
3341 (gnus-find-new-newsgroups)))
3343 (setq arg (gnus-group-default-level arg t))
3344 (if (and gnus-read-active-file (not arg))
3346 (gnus-read-active-file)
3347 (gnus-get-unread-articles arg))
3348 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3349 (gnus-get-unread-articles arg)))
3350 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3351 (gnus-group-list-groups (and (numberp arg)
3352 (max (car gnus-group-list-mode) arg)))))
3354 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3355 "Check for newly arrived news in the current group (and the N-1 next groups).
3356 The difference between N and the number of newsgroup checked is returned.
3357 If N is negative, this group and the N-1 previous groups will be checked."
3359 (let* ((groups (gnus-group-process-prefix n))
3360 (ret (if (numberp n) (- n (length groups)) 0))
3364 (gnus-inhibit-demon t)
3365 ;; Binding this variable will inhibit multiple fetchings
3366 ;; of the same mail source.
3367 (nnmail-fetched-sources (list t)))
3368 (gnus-run-hooks 'gnus-get-new-news-hook)
3369 (while (setq group (pop groups))
3370 (gnus-group-remove-mark group)
3371 ;; Bypass any previous denials from the server.
3372 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3373 (if (gnus-activate-group group (if dont-scan nil 'scan))
3375 (gnus-get-unread-articles-in-group
3376 (gnus-get-info group) (gnus-active group) t)
3377 (unless (gnus-virtual-group-p group)
3378 (gnus-close-group group))
3380 (gnus-agent-save-group-info
3381 method (gnus-group-real-name group) (gnus-active group)))
3382 (gnus-group-update-group group))
3383 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3385 (gnus-error 3 "Server denied access")
3386 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3389 (when gnus-goto-next-group-when-activating
3390 (gnus-group-next-unread-group 1 t))
3391 (gnus-summary-position-point)
3394 (defun gnus-group-fetch-faq (group &optional faq-dir)
3395 "Fetch the FAQ for the current group.
3396 If given a prefix argument, prompt for the FAQ dir
3400 (gnus-group-group-name)
3401 (when current-prefix-arg
3403 "Faq dir: " (and (listp gnus-group-faq-directory)
3405 gnus-group-faq-directory))))))
3407 (error "No group name given"))
3408 (let ((dirs (or faq-dir gnus-group-faq-directory))
3410 (unless (listp dirs)
3411 (setq dirs (list dirs)))
3412 (while (and (not found)
3413 (setq dir (pop dirs)))
3414 (let ((name (gnus-group-real-name group)))
3415 (setq file (expand-file-name name dir)))
3416 (if (not (file-exists-p file))
3417 (gnus-message 1 "No such file: %s" file)
3418 (let ((enable-local-variables nil))
3422 (defun gnus-group-describe-group (force &optional group)
3423 "Display a description of the current newsgroup."
3424 (interactive (list current-prefix-arg (gnus-group-group-name)))
3425 (let* ((method (gnus-find-method-for-group group))
3426 (mname (gnus-group-prefixed-name "" method))
3429 gnus-description-hashtb)
3430 (gnus-sethash mname nil gnus-description-hashtb))
3432 (error "No group name given"))
3433 (when (or (and gnus-description-hashtb
3434 ;; We check whether this group's method has been
3435 ;; queried for a description file.
3436 (gnus-gethash mname gnus-description-hashtb))
3437 (setq desc (gnus-group-get-description group))
3438 (gnus-read-descriptions-file method))
3440 (or desc (gnus-gethash group gnus-description-hashtb)
3441 "No description available")))))
3443 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3444 (defun gnus-group-describe-all-groups (&optional force)
3445 "Pop up a buffer with descriptions of all newsgroups."
3448 (setq gnus-description-hashtb nil))
3449 (when (not (or gnus-description-hashtb
3450 (gnus-read-all-descriptions-files)))
3451 (error "Couldn't request descriptions file"))
3452 (let ((buffer-read-only nil)
3458 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3459 (insert (format " *: %-20s %s\n"
3460 (gnus-group-name-decode
3461 (symbol-name group) charset)
3462 (gnus-group-name-decode
3463 (symbol-value group) charset))))
3464 (gnus-add-text-properties
3465 b (1+ b) (list 'gnus-group group
3466 'gnus-unread t 'gnus-marked nil
3467 'gnus-level (1+ gnus-level-subscribed))))
3468 gnus-description-hashtb)
3469 (goto-char (point-min))
3470 (gnus-group-position-point)))
3472 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3473 (defun gnus-group-apropos (regexp &optional search-description)
3474 "List all newsgroups that have names that match a regexp."
3475 (interactive "sGnus apropos (regexp): ")
3477 (obuf (current-buffer))
3479 ;; Go through all newsgroups that are known to Gnus.
3482 (and (symbol-name group)
3483 (string-match regexp (symbol-name group))
3484 (symbol-value group)
3485 (push (symbol-name group) groups)))
3487 ;; Also go through all descriptions that are known to Gnus.
3488 (when search-description
3491 (and (string-match regexp (symbol-value group))
3492 (push (symbol-name group) groups)))
3493 gnus-description-hashtb))
3495 (gnus-message 3 "No groups matched \"%s\"." regexp)
3496 ;; Print out all the groups.
3498 (pop-to-buffer "*Gnus Help*")
3499 (buffer-disable-undo)
3501 (setq groups (sort groups 'string<))
3503 ;; Groups may be entered twice into the list of groups.
3504 (when (not (string= (car groups) prev))
3505 (setq prev (car groups))
3506 (let ((charset (gnus-group-name-charset nil prev)))
3507 (insert (gnus-group-name-decode prev charset) "\n")
3508 (when (and gnus-description-hashtb
3509 (setq des (gnus-gethash (car groups)
3510 gnus-description-hashtb)))
3511 (insert " " (gnus-group-name-decode des charset) "\n"))))
3512 (setq groups (cdr groups)))
3513 (goto-char (point-min))))
3514 (pop-to-buffer obuf)))
3516 (defun gnus-group-description-apropos (regexp)
3517 "List all newsgroups that have names or descriptions that match a regexp."
3518 (interactive "sGnus description apropos (regexp): ")
3519 (when (not (or gnus-description-hashtb
3520 (gnus-read-all-descriptions-files)))
3521 (error "Couldn't request descriptions file"))
3522 (gnus-group-apropos regexp t))
3524 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3525 (defun gnus-group-list-matching (level regexp &optional all lowest)
3526 "List all groups with unread articles that match REGEXP.
3527 If the prefix LEVEL is non-nil, it should be a number that says which
3528 level to cut off listing groups.
3529 If ALL, also list groups with no unread articles.
3530 If LOWEST, don't list groups with level lower than LOWEST.
3532 This command may read the active file."
3533 (interactive "P\nsList newsgroups matching: ")
3534 ;; First make sure active file has been read.
3536 (> (prefix-numeric-value level) gnus-level-killed))
3537 (gnus-get-killed-groups))
3538 (funcall gnus-group-prepare-function
3539 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3540 (goto-char (point-min))
3541 (gnus-group-position-point))
3543 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3544 "List all groups that match REGEXP.
3545 If the prefix LEVEL is non-nil, it should be a number that says which
3546 level to cut off listing groups.
3547 If LOWEST, don't list groups with level lower than LOWEST."
3548 (interactive "P\nsList newsgroups matching: ")
3550 (setq level (prefix-numeric-value level)))
3551 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3553 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3554 (defun gnus-group-save-newsrc (&optional force)
3555 "Save the Gnus startup files.
3556 If FORCE, force saving whether it is necessary or not."
3558 (gnus-save-newsrc-file force))
3560 (defun gnus-group-restart (&optional arg)
3561 "Force Gnus to read the .newsrc file."
3563 (when (gnus-yes-or-no-p
3564 (format "Are you sure you want to restart Gnus? "))
3565 (gnus-save-newsrc-file)
3569 (defun gnus-group-read-init-file ()
3570 "Read the Gnus elisp init file."
3572 (gnus-read-init-file)
3573 (gnus-message 5 "Read %s" gnus-init-file))
3575 (defun gnus-group-check-bogus-groups (&optional silent)
3576 "Check bogus newsgroups.
3577 If given a prefix, don't ask for confirmation before removing a bogus
3580 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3581 (gnus-group-list-groups))
3583 (defun gnus-group-find-new-groups (&optional arg)
3584 "Search for new groups and add them.
3585 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3586 With 1 C-u, use the `ask-server' method to query the server for new
3588 With 2 C-u's, use most complete method possible to query the server
3589 for new groups, and subscribe the new groups as zombies."
3591 (gnus-find-new-newsgroups (or arg 1))
3592 (gnus-group-list-groups))
3594 (defun gnus-group-edit-global-kill (&optional article group)
3595 "Edit the global kill file.
3596 If GROUP, edit that local kill file instead."
3598 (setq gnus-current-kill-article article)
3599 (gnus-kill-file-edit-file group)
3602 (substitute-command-keys
3603 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3604 (if group "local" "global")))))
3606 (defun gnus-group-edit-local-kill (article group)
3607 "Edit a local kill file."
3608 (interactive (list nil (gnus-group-group-name)))
3609 (gnus-group-edit-global-kill article group))
3611 (defun gnus-group-force-update ()
3612 "Update `.newsrc' file."
3614 (gnus-save-newsrc-file))
3616 (defun gnus-group-suspend ()
3617 "Suspend the current Gnus session.
3618 In fact, cleanup buffers except for group mode buffer.
3619 The hook gnus-suspend-gnus-hook is called before actually suspending."
3621 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3622 (gnus-offer-save-summaries)
3623 ;; Kill Gnus buffers except for group mode buffer.
3624 (let ((group-buf (get-buffer gnus-group-buffer)))
3625 (mapcar (lambda (buf)
3626 (unless (member buf (list group-buf gnus-dribble-buffer))
3627 (gnus-kill-buffer buf)))
3629 (gnus-kill-gnus-frames)
3631 (bury-buffer group-buf)
3632 (delete-windows-on group-buf t))))
3634 (defun gnus-group-clear-dribble ()
3635 "Clear all information from the dribble buffer."
3637 (gnus-dribble-clear)
3638 (gnus-message 7 "Cleared dribble buffer"))
3640 (defun gnus-group-exit ()
3641 "Quit reading news after updating .newsrc.eld and .newsrc.
3642 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3645 (or noninteractive ;For gnus-batch-kill
3646 (not gnus-interactive-exit) ;Without confirmation
3648 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3649 (gnus-run-hooks 'gnus-exit-gnus-hook)
3650 ;; Offer to save data from non-quitted summary buffers.
3651 (gnus-offer-save-summaries)
3652 ;; Save the newsrc file(s).
3653 (gnus-save-newsrc-file)
3655 (gnus-close-backends)
3656 ;; Reset everything.
3658 ;; Allow the user to do things after cleaning up.
3659 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3661 (defun gnus-group-quit ()
3662 "Quit reading news without updating .newsrc.eld or .newsrc.
3663 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3665 (when (or noninteractive ;For gnus-batch-kill
3666 (zerop (buffer-size))
3667 (not (gnus-server-opened gnus-select-method))
3669 (not gnus-current-startup-file)
3671 (format "Quit reading news without saving %s? "
3672 (file-name-nondirectory gnus-current-startup-file))))
3673 (gnus-run-hooks 'gnus-exit-gnus-hook)
3674 (gnus-configure-windows 'group t)
3676 (gnus-close-backends)
3678 (gnus-kill-buffer gnus-group-buffer)
3679 ;; Allow the user to do things after cleaning up.
3680 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3682 (defun gnus-group-describe-briefly ()
3683 "Give a one line description of the group mode commands."
3685 (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")))
3687 (defun gnus-group-browse-foreign-server (method)
3688 "Browse a foreign news server.
3689 If called interactively, this function will ask for a select method
3690 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3691 If not, METHOD should be a list where the first element is the method
3692 and the second element is the address."
3694 (list (let ((how (completing-read
3696 (append gnus-valid-select-methods gnus-server-alist)
3697 nil t (cons "nntp" 0) 'gnus-method-history)))
3698 ;; We either got a backend name or a virtual server name.
3699 ;; If the first, we also need an address.
3700 (if (assoc how gnus-valid-select-methods)
3702 ;; Suggested by mapjph@bath.ac.uk.
3705 (mapcar (lambda (server) (list server))
3706 gnus-secondary-servers)))
3707 ;; We got a server name.
3709 (gnus-browse-foreign-server method))
3711 (defun gnus-group-set-info (info &optional method-only-group part)
3712 (when (or info part)
3713 (let* ((entry (gnus-gethash
3714 (or method-only-group (gnus-info-group info))
3715 gnus-newsrc-hashtb))
3717 (info (if method-only-group (nth 2 entry) info))
3719 (when method-only-group
3721 (error "Trying to change non-existent group %s" method-only-group))
3722 ;; We have received parts of the actual group info - either the
3723 ;; select method or the group parameters. We first check
3724 ;; whether we have to extend the info, and if so, do that.
3725 (let ((len (length info))
3726 (total (if (eq part 'method) 5 6)))
3728 (setcdr (nthcdr (1- len) info)
3729 (make-list (- total len) nil)))
3730 ;; Then we enter the new info.
3731 (setcar (nthcdr (1- total) info) part-info)))
3733 ;; This is a new group, so we just create it.
3735 (set-buffer gnus-group-buffer)
3736 (setq method (gnus-info-method info))
3737 (when (gnus-server-equal method "native")
3740 (set-buffer gnus-group-buffer)
3742 ;; It's a foreign group...
3743 (gnus-group-make-group
3744 (gnus-group-real-name (gnus-info-group info))
3745 (if (stringp method) method
3746 (prin1-to-string (car method)))
3748 (nth 1 (gnus-info-method info))))
3749 ;; It's a native group.
3750 (gnus-group-make-group (gnus-info-group info))))
3751 (gnus-message 6 "Note: New group created")
3753 (gnus-gethash (gnus-group-prefixed-name
3754 (gnus-group-real-name (gnus-info-group info))
3755 (or (gnus-info-method info) gnus-select-method))
3756 gnus-newsrc-hashtb))))
3757 ;; Whether it was a new group or not, we now have the entry, so we
3758 ;; can do the update.
3761 (setcar (nthcdr 2 entry) info)
3762 (when (and (not (eq (car entry) t))
3763 (gnus-active (gnus-info-group info)))
3764 (setcar entry (length
3765 (gnus-list-of-unread-articles (car info))))))
3766 (error "No such group: %s" (gnus-info-group info))))))
3768 (defun gnus-group-set-method-info (group select-method)
3769 (gnus-group-set-info select-method group 'method))
3771 (defun gnus-group-set-params-info (group params)
3772 (gnus-group-set-info params group 'params))
3774 (defun gnus-add-marked-articles (group type articles &optional info force)
3775 ;; Add ARTICLES of TYPE to the info of GROUP.
3776 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3777 ;; add, but replace marked articles of TYPE with ARTICLES.
3778 (let ((info (or info (gnus-get-info group)))
3781 (and (not (setq marked (nthcdr 3 info)))
3783 (setcdr (nthcdr 2 info)
3784 (list (list (cons type (gnus-compress-sequence
3786 (and (not (setq m (assq type (car marked))))
3789 (cons (cons type (gnus-compress-sequence articles t) )
3793 (setcar (nthcdr 3 info)
3794 (gnus-delete-alist type (car marked)))
3795 (setcdr m (gnus-compress-sequence articles t)))
3796 (setcdr m (gnus-compress-sequence
3797 (sort (nconc (gnus-uncompress-range (cdr m))
3798 (copy-sequence articles)) '<) t))))))
3800 (defun gnus-add-mark (group mark article)
3801 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3802 (let ((buffer (gnus-summary-buffer-name group)))
3803 (if (gnus-buffer-live-p buffer)
3805 (set-buffer (get-buffer buffer))
3806 (gnus-summary-add-mark article mark))
3807 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3811 ;;; Group timestamps
3814 (defun gnus-group-set-timestamp ()
3815 "Change the timestamp of the current group to the current time.
3816 This function can be used in hooks like `gnus-select-group-hook'
3817 or `gnus-group-catchup-group-hook'."
3818 (when gnus-newsgroup-name
3819 (let ((time (current-time)))
3820 (setcdr (cdr time) nil)
3821 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3823 (defsubst gnus-group-timestamp (group)
3824 "Return the timestamp for GROUP."
3825 (gnus-group-get-parameter group 'timestamp t))
3827 (defun gnus-group-timestamp-delta (group)
3828 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3829 (let* ((time (or (gnus-group-timestamp group)
3831 (delta (subtract-time (current-time) time)))
3832 (+ (* (nth 0 delta) 65536.0)
3835 (defun gnus-group-timestamp-string (group)
3836 "Return a string of the timestamp for GROUP."
3837 (let ((time (gnus-group-timestamp group)))
3840 (gnus-time-iso8601 time))))
3842 (defun gnus-group-list-cached (level &optional lowest)
3843 "List all groups with cached articles.
3844 If the prefix LEVEL is non-nil, it should be a number that says which
3845 level to cut off listing groups.
3846 If LOWEST, don't list groups with level lower than LOWEST.
3848 This command may read the active file."
3851 (setq level (prefix-numeric-value level)))
3852 (when (or (not level) (>= level gnus-level-zombie))
3854 (funcall gnus-group-prepare-function
3855 (or level gnus-level-subscribed)
3857 (let ((marks (gnus-info-marks info)))
3858 (assq 'cache marks)))
3861 (or (gnus-gethash group
3862 gnus-cache-active-hashtb)
3863 ;; Cache active file might use "."
3866 (mapconcat 'identity
3867 (split-string group ":")
3869 gnus-cache-active-hashtb))))
3870 (goto-char (point-min))
3871 (gnus-group-position-point))
3873 (defun gnus-group-list-dormant (level &optional lowest)
3874 "List all groups with dormant articles.
3875 If the prefix LEVEL is non-nil, it should be a number that says which
3876 level to cut off listing groups.
3877 If LOWEST, don't list groups with level lower than LOWEST.
3879 This command may read the active file."
3882 (setq level (prefix-numeric-value level)))
3883 (when (or (not level) (>= level gnus-level-zombie))
3885 (funcall gnus-group-prepare-function
3886 (or level gnus-level-subscribed)
3888 (let ((marks (gnus-info-marks info)))
3889 (assq 'dormant marks)))
3892 (goto-char (point-min))
3893 (gnus-group-position-point))
3895 (defun gnus-group-listed-groups ()
3896 "Return a list of listed groups."
3898 (goto-char (point-min))
3899 (while (setq point (text-property-not-all (point) (point-max)
3902 (push (symbol-name (get-text-property point 'gnus-group)) groups)
3906 (defun gnus-group-list-plus (&optional args)
3907 "List groups plus the current selection."
3909 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
3910 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
3912 (push last-command-event unread-command-events)
3913 (if (featurep 'xemacs)
3914 (push (make-event 'key-press '(key ?A)) unread-command-events)
3915 (push ?A unread-command-events))
3916 (let (gnus-pick-mode keys)
3917 (setq keys (if (featurep 'xemacs)
3918 (events-to-keys (read-key-sequence nil))
3919 (read-key-sequence nil)))
3920 (setq func (lookup-key (current-local-map) keys)))
3924 (call-interactively func))))
3926 (defun gnus-group-list-flush (&optional args)
3927 "Flush groups from the current selection."
3929 (let ((gnus-group-list-option 'flush))
3930 (gnus-group-list-plus args)))
3932 (defun gnus-group-list-limit (&optional args)
3933 "List groups limited within the current selection."
3935 (let ((gnus-group-list-option 'limit))
3936 (gnus-group-list-plus args)))
3938 (defun gnus-group-mark-article-read (group article)
3939 "Mark ARTICLE read."
3940 (gnus-activate-group group)
3941 (let ((buffer (gnus-summary-buffer-name group))
3942 (mark gnus-read-mark))
3946 (with-current-buffer buffer
3947 (when gnus-newsgroup-prepared
3948 (when (and gnus-newsgroup-auto-expire
3949 (memq mark gnus-auto-expirable-marks))
3950 (setq mark gnus-expirable-mark))
3951 (setq mark (gnus-request-update-mark
3952 group article mark))
3953 (gnus-mark-article-as-read article mark)
3954 (setq gnus-newsgroup-active (gnus-active group))
3956 (gnus-group-make-articles-read group
3958 (when (gnus-group-auto-expirable-p group)
3959 (gnus-add-marked-articles
3960 group 'expire (list article))))))
3962 (provide 'gnus-group)
3964 ;;; gnus-group.el ends here