1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
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))
41 (defcustom gnus-group-archive-directory
42 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
43 "*The address of the (ding) archives."
44 :group 'gnus-group-foreign
47 (defcustom gnus-group-recent-archive-directory
48 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
49 "*The address of the most recent (ding) articles."
50 :group 'gnus-group-foreign
53 (defcustom gnus-no-groups-message "No gnus is bad news"
54 "*Message displayed by Gnus when no groups are available."
58 (defcustom gnus-keep-same-level nil
59 "*Non-nil means that the next newsgroup after the current will be on the same level.
60 When you type, for instance, `n' after reading the last article in the
61 current newsgroup, you will go to the next newsgroup. If this variable
62 is nil, the next newsgroup will be the next from the group
64 If this variable is non-nil, Gnus will either put you in the
65 next newsgroup with the same level, or, if no such newsgroup is
66 available, the next newsgroup with the lowest possible level higher
67 than the current level.
68 If this variable is `best', Gnus will make the next newsgroup the one
70 :group 'gnus-group-levels
71 :type '(choice (const nil)
73 (sexp :tag "other" t)))
75 (defcustom gnus-group-goto-unread t
76 "*If non-nil, movement commands will go to the next unread and subscribed group."
77 :link '(custom-manual "(gnus)Group Maneuvering")
78 :group 'gnus-group-various
81 (defcustom gnus-goto-next-group-when-activating t
82 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
83 :link '(custom-manual "(gnus)Scanning New Messages")
84 :group 'gnus-group-various
87 (defcustom gnus-permanently-visible-groups nil
88 "*Regexp to match groups that should always be listed in the group buffer.
89 This means that they will still be listed even when there are no
90 unread articles in the groups.
92 If nil, no groups are permanently visible."
93 :group 'gnus-group-listing
94 :type '(choice regexp (const nil)))
96 (defcustom gnus-list-groups-with-ticked-articles t
97 "*If non-nil, list groups that have only ticked articles.
98 If nil, only list groups that have unread articles."
99 :group 'gnus-group-listing
102 (defcustom gnus-group-default-list-level gnus-level-subscribed
103 "*Default listing level.
104 Ignored if `gnus-group-use-permanent-levels' is non-nil."
105 :group 'gnus-group-listing
108 (defcustom gnus-group-list-inactive-groups t
109 "*If non-nil, inactive groups will be listed."
110 :group 'gnus-group-listing
111 :group 'gnus-group-levels
114 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
115 "*Function used for sorting the group buffer.
116 This function will be called with group info entries as the arguments
117 for the groups to be sorted. Pre-made functions include
118 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
119 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
120 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
121 `gnus-group-sort-by-rank'.
123 This variable can also be a list of sorting functions. In that case,
124 the most significant sort function should be the last function in the
126 :group 'gnus-group-listing
127 :link '(custom-manual "(gnus)Sorting Groups")
128 :type '(radio (function-item gnus-group-sort-by-alphabet)
129 (function-item gnus-group-sort-by-real-name)
130 (function-item gnus-group-sort-by-unread)
131 (function-item gnus-group-sort-by-level)
132 (function-item gnus-group-sort-by-score)
133 (function-item gnus-group-sort-by-method)
134 (function-item gnus-group-sort-by-rank)
135 (function :tag "other" nil)))
137 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
138 "*Format of group lines.
139 It works along the same lines as a normal formatting string,
140 with some simple extensions.
142 %M Only marked articles (character, \"*\" or \" \")
143 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
144 %L Level of subscribedness (integer)
145 %N Number of unread articles (integer)
146 %I Number of dormant articles (integer)
147 %i Number of ticked and dormant (integer)
148 %T Number of ticked articles (integer)
149 %R Number of read articles (integer)
150 %t Estimated total number of articles (integer)
151 %y Number of unread, unticked articles (integer)
152 %G Group name (string)
153 %g Qualified group name (string)
154 %D Group description (string)
155 %s Select method (string)
156 %o Moderated group (char, \"m\")
157 %p Process mark (char)
158 %O Moderated group (string, \"(m)\" or \"\")
159 %P Topic indentation (string)
160 %m Whether there is new(ish) mail in the group (char, \"%\")
161 %l Whether there are GroupLens predictions for this group (string)
162 %n Select from where (string)
163 %z A string that look like `<%s:%n>' if a foreign select method is used
164 %d The date the group was last entered.
165 %E Icon as defined by `gnus-group-icon-list'.
166 %u User defined specifier. The next character in the format string should
167 be a letter. Gnus will call the function gnus-user-format-function-X,
168 where X is the letter following %u. The function will be passed the
169 current header as argument. The function should return a string, which
170 will be inserted into the buffer just like information from any other
173 Text between %( and %) will be highlighted with `gnus-mouse-face' when
174 the mouse point move inside the area. There can only be one such area.
176 Note that this format specification is not always respected. For
177 reasons of efficiency, when listing killed groups, this specification
178 is ignored altogether. If the spec is changed considerably, your
179 output may end up looking strange when listing both alive and killed
182 If you use %o or %O, reading the active file will be slower and quite
183 a bit of extra memory will be used. %D will also worsen performance.
184 Also note that if you change the format specification to include any
185 of these specs, you must probably re-start Gnus to see them go into
187 :group 'gnus-group-visual
190 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
191 "*The format specification for the group mode line.
192 It works along the same lines as a normal formatting string,
193 with some simple extensions:
195 %S The native news server.
196 %M The native select method.
197 %: \":\" if %S isn't \"\"."
198 :group 'gnus-group-visual
201 (defcustom gnus-group-mode-hook nil
202 "Hook for Gnus group mode."
203 :group 'gnus-group-various
204 :options '(gnus-topic-mode)
207 (defcustom gnus-group-menu-hook nil
208 "Hook run after the creation of the group mode menu."
209 :group 'gnus-group-various
212 (defcustom gnus-group-catchup-group-hook nil
213 "Hook run when catching up a group from the group buffer."
214 :group 'gnus-group-various
215 :link '(custom-manual "(gnus)Group Data")
218 (defcustom gnus-group-update-group-hook nil
219 "Hook called when updating group lines."
220 :group 'gnus-group-visual
223 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
224 "*A function that is called to generate the group buffer.
225 The function is called with three arguments: The first is a number;
226 all group with a level less or equal to that number should be listed,
227 if the second is non-nil, empty groups should also be displayed. If
228 the third is non-nil, it is a number. No groups with a level lower
229 than this number should be displayed.
231 The only current function implemented is `gnus-group-prepare-flat'."
232 :group 'gnus-group-listing
235 (defcustom gnus-group-prepare-hook nil
236 "Hook called after the group buffer has been generated.
237 If you want to modify the group buffer, you can use this hook."
238 :group 'gnus-group-listing
241 (defcustom gnus-suspend-gnus-hook nil
242 "Hook called when suspending (not exiting) Gnus."
246 (defcustom gnus-exit-gnus-hook nil
247 "Hook called when exiting Gnus."
251 (defcustom gnus-after-exiting-gnus-hook nil
252 "Hook called after exiting Gnus."
256 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
257 "Hook called when a group line is changed.
258 The hook will not be called if `gnus-visual' is nil.
260 The default function `gnus-group-highlight-line' will
261 highlight the line according to the `gnus-group-highlight'
263 :group 'gnus-group-visual
266 (defcustom gnus-useful-groups
267 '(("(ding) mailing list mirrored at sunsite.auc.dk"
269 (nntp "sunsite.auc.dk"
270 (nntp-address "sunsite.auc.dk")))
273 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
277 (nndoc-article-type mbox)
278 (eval `(nndoc-address
279 ,(let ((file (nnheader-find-etc-directory
282 (error "Couldn't find doc group"))
284 "*Alist of useful group-server pairs."
285 :group 'gnus-group-listing
286 :type '(repeat (list (string :tag "Description")
288 (sexp :tag "Method"))))
290 (defcustom gnus-group-highlight
292 ((and (= unread 0) (not mailp) (eq level 1)) .
293 gnus-group-news-1-empty-face)
294 ((and (not mailp) (eq level 1)) .
295 gnus-group-news-1-face)
296 ((and (= unread 0) (not mailp) (eq level 2)) .
297 gnus-group-news-2-empty-face)
298 ((and (not mailp) (eq level 2)) .
299 gnus-group-news-2-face)
300 ((and (= unread 0) (not mailp) (eq level 3)) .
301 gnus-group-news-3-empty-face)
302 ((and (not mailp) (eq level 3)) .
303 gnus-group-news-3-face)
304 ((and (= unread 0) (not mailp) (eq level 4)) .
305 gnus-group-news-4-empty-face)
306 ((and (not mailp) (eq level 4)) .
307 gnus-group-news-4-face)
308 ((and (= unread 0) (not mailp) (eq level 5)) .
309 gnus-group-news-5-empty-face)
310 ((and (not mailp) (eq level 5)) .
311 gnus-group-news-5-face)
312 ((and (= unread 0) (not mailp) (eq level 6)) .
313 gnus-group-news-6-empty-face)
314 ((and (not mailp) (eq level 6)) .
315 gnus-group-news-6-face)
316 ((and (= unread 0) (not mailp)) .
317 gnus-group-news-low-empty-face)
319 gnus-group-news-low-face)
321 ((and (= unread 0) (eq level 1)) .
322 gnus-group-mail-1-empty-face)
324 gnus-group-mail-1-face)
325 ((and (= unread 0) (eq level 2)) .
326 gnus-group-mail-2-empty-face)
328 gnus-group-mail-2-face)
329 ((and (= unread 0) (eq level 3)) .
330 gnus-group-mail-3-empty-face)
332 gnus-group-mail-3-face)
334 gnus-group-mail-low-empty-face)
336 gnus-group-mail-low-face))
337 "*Controls the highlighting of group buffer lines.
339 Below is a list of `Form'/`Face' pairs. When deciding how a a
340 particular group line should be displayed, each form is
341 evaluated. The content of the face field after the first true form is
342 used. You can change how those group lines are displayed by
343 editing the face field.
345 It is also possible to change and add form fields, but currently that
346 requires an understanding of Lisp expressions. Hopefully this will
347 change in a future release. For now, you can use the following
348 variables in the Lisp expression:
350 group: The name of the group.
351 unread: The number of unread articles in the group.
352 method: The select method used.
353 mailp: Whether it's a mail group or not.
354 level: The level of the group.
355 score: The score of the group.
356 ticked: The number of ticked articles."
357 :group 'gnus-group-visual
358 :type '(repeat (cons (sexp :tag "Form") face)))
360 (defcustom gnus-new-mail-mark ?%
361 "Mark used for groups with new mail."
362 :group 'gnus-group-visual
365 (defgroup gnus-group-icons nil
366 "Add Icons to your group buffer. "
367 :group 'gnus-group-visual)
369 (defcustom gnus-group-icon-list
371 "*Controls the insertion of icons into group buffer lines.
373 Below is a list of `Form'/`File' pairs. When deciding how a
374 particular group line should be displayed, each form is evaluated.
375 The icon from the file field after the first true form is used. You
376 can change how those group lines are displayed by editing the file
377 field. The File will either be found in the
378 `gnus-group-glyph-directory' or by designating absolute path to the
381 It is also possible to change and add form fields, but currently that
382 requires an understanding of Lisp expressions. Hopefully this will
383 change in a future release. For now, you can use the following
384 variables in the Lisp expression:
386 group: The name of the group.
387 unread: The number of unread articles in the group.
388 method: The select method used.
389 mailp: Whether it's a mail group or not.
390 newsp: Whether it's a news group or not
391 level: The level of the group.
392 score: The score of the group.
393 ticked: The number of ticked articles."
394 :group 'gnus-group-icons
395 :type '(repeat (cons (sexp :tag "Form") file)))
397 ;;; Internal variables
399 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
400 "Function for sorting the group buffer.")
402 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
403 "Function for sorting the selected groups in the group buffer.")
405 (defvar gnus-group-indentation-function nil)
406 (defvar gnus-goto-missing-group-function nil)
407 (defvar gnus-group-update-group-function nil)
408 (defvar gnus-group-goto-next-group-function nil
409 "Function to override finding the next group after listing groups.")
411 (defvar gnus-group-edit-buffer nil)
413 (defvar gnus-group-line-format-alist
414 `((?M gnus-tmp-marked-mark ?c)
415 (?S gnus-tmp-subscribed ?c)
416 (?L gnus-tmp-level ?d)
417 (?N (cond ((eq number t) "*" )
421 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
422 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
424 (?R gnus-tmp-number-of-read ?s)
425 (?t gnus-tmp-number-total ?d)
426 (?y gnus-tmp-number-of-unread ?s)
427 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
428 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
429 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
430 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
431 (?g gnus-tmp-group ?s)
432 (?G gnus-tmp-qualified-group ?s)
433 (?c (gnus-short-group-name gnus-tmp-group) ?s)
434 (?D gnus-tmp-newsgroup-description ?s)
435 (?o gnus-tmp-moderated ?c)
436 (?O gnus-tmp-moderated-string ?s)
437 (?p gnus-tmp-process-marked ?c)
438 (?s gnus-tmp-news-server ?s)
439 (?n gnus-tmp-news-method ?s)
440 (?P gnus-group-indentation ?s)
441 (?E gnus-tmp-group-icon ?s)
442 (?l gnus-tmp-grouplens ?s)
443 (?z gnus-tmp-news-method-string ?s)
444 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
445 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
446 (?u gnus-tmp-user-defined ?s)))
448 (defvar gnus-group-mode-line-format-alist
449 `((?S gnus-tmp-news-server ?s)
450 (?M gnus-tmp-news-method ?s)
451 (?u gnus-tmp-user-defined ?s)
452 (?: gnus-tmp-colon ?s)))
454 (defvar gnus-topic-topology nil
455 "The complete topic hierarchy.")
457 (defvar gnus-topic-alist nil
458 "The complete topic-group alist.")
460 (defvar gnus-group-marked nil)
462 (defvar gnus-group-list-mode nil)
465 (defvar gnus-group-icon-cache nil)
466 (defvar gnus-group-running-xemacs (string-match "XEmacs" emacs-version))
472 (put 'gnus-group-mode 'mode-class 'special)
475 (gnus-define-keys gnus-group-mode-map
476 " " gnus-group-read-group
477 "=" gnus-group-select-group
478 "\r" gnus-group-select-group
479 "\M-\r" gnus-group-quick-select-group
480 [(meta control return)] gnus-group-select-group-ephemerally
481 "j" gnus-group-jump-to-group
482 "n" gnus-group-next-unread-group
483 "p" gnus-group-prev-unread-group
484 "\177" gnus-group-prev-unread-group
485 [delete] gnus-group-prev-unread-group
486 [backspace] gnus-group-prev-unread-group
487 "N" gnus-group-next-group
488 "P" gnus-group-prev-group
489 "\M-n" gnus-group-next-unread-group-same-level
490 "\M-p" gnus-group-prev-unread-group-same-level
491 "," gnus-group-best-unread-group
492 "." gnus-group-first-unread-group
493 "u" gnus-group-unsubscribe-current-group
494 "U" gnus-group-unsubscribe-group
495 "c" gnus-group-catchup-current
496 "C" gnus-group-catchup-current-all
497 "\M-c" gnus-group-clear-data
498 "l" gnus-group-list-groups
499 "L" gnus-group-list-all-groups
501 "g" gnus-group-get-new-news
502 "\M-g" gnus-group-get-new-news-this-group
503 "R" gnus-group-restart
504 "r" gnus-group-read-init-file
505 "B" gnus-group-browse-foreign-server
506 "b" gnus-group-check-bogus-groups
507 "F" gnus-group-find-new-groups
508 "\C-c\C-d" gnus-group-describe-group
509 "\M-d" gnus-group-describe-all-groups
510 "\C-c\C-a" gnus-group-apropos
511 "\C-c\M-\C-a" gnus-group-description-apropos
512 "a" gnus-group-post-news
513 "\ek" gnus-group-edit-local-kill
514 "\eK" gnus-group-edit-global-kill
515 "\C-k" gnus-group-kill-group
516 "\C-y" gnus-group-yank-group
517 "\C-w" gnus-group-kill-region
518 "\C-x\C-t" gnus-group-transpose-groups
519 "\C-c\C-l" gnus-group-list-killed
520 "\C-c\C-x" gnus-group-expire-articles
521 "\C-c\M-\C-x" gnus-group-expire-all-groups
523 "s" gnus-group-save-newsrc
524 "z" gnus-group-suspend
527 "?" gnus-group-describe-briefly
528 "\C-c\C-i" gnus-info-find-node
529 "\M-e" gnus-group-edit-group-method
530 "^" gnus-group-enter-server-mode
531 gnus-mouse-2 gnus-mouse-pick-group
532 "<" beginning-of-buffer
535 "\C-c\C-s" gnus-group-sort-groups
537 "\C-c\M-g" gnus-activate-all-groups
538 "\M-&" gnus-group-universal-argument
539 "#" gnus-group-mark-group
540 "\M-#" gnus-group-unmark-group)
542 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
543 "m" gnus-group-mark-group
544 "u" gnus-group-unmark-group
545 "w" gnus-group-mark-region
546 "b" gnus-group-mark-buffer
547 "r" gnus-group-mark-regexp
548 "U" gnus-group-unmark-all-groups)
550 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
551 "d" gnus-group-make-directory-group
552 "h" gnus-group-make-help-group
553 "u" gnus-group-make-useful-group
554 "a" gnus-group-make-archive-group
555 "k" gnus-group-make-kiboze-group
556 "l" gnus-group-nnimap-edit-acl
557 "m" gnus-group-make-group
558 "E" gnus-group-edit-group
559 "e" gnus-group-edit-group-method
560 "p" gnus-group-edit-group-parameters
561 "v" gnus-group-add-to-virtual
562 "V" gnus-group-make-empty-virtual
563 "D" gnus-group-enter-directory
564 "f" gnus-group-make-doc-group
565 "w" gnus-group-make-web-group
566 "r" gnus-group-rename-group
567 "c" gnus-group-customize
568 "x" gnus-group-nnimap-expunge
569 "\177" gnus-group-delete-group
570 [delete] gnus-group-delete-group)
572 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
573 "b" gnus-group-brew-soup
574 "w" gnus-soup-save-areas
575 "s" gnus-soup-send-replies
576 "p" gnus-soup-pack-packet
577 "r" nnsoup-pack-replies)
579 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
580 "s" gnus-group-sort-groups
581 "a" gnus-group-sort-groups-by-alphabet
582 "u" gnus-group-sort-groups-by-unread
583 "l" gnus-group-sort-groups-by-level
584 "v" gnus-group-sort-groups-by-score
585 "r" gnus-group-sort-groups-by-rank
586 "m" gnus-group-sort-groups-by-method)
588 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
589 "s" gnus-group-sort-selected-groups
590 "a" gnus-group-sort-selected-groups-by-alphabet
591 "u" gnus-group-sort-selected-groups-by-unread
592 "l" gnus-group-sort-selected-groups-by-level
593 "v" gnus-group-sort-selected-groups-by-score
594 "r" gnus-group-sort-selected-groups-by-rank
595 "m" gnus-group-sort-selected-groups-by-method)
597 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
598 "k" gnus-group-list-killed
599 "z" gnus-group-list-zombies
600 "s" gnus-group-list-groups
601 "u" gnus-group-list-all-groups
602 "A" gnus-group-list-active
603 "a" gnus-group-apropos
604 "d" gnus-group-description-apropos
605 "m" gnus-group-list-matching
606 "M" gnus-group-list-all-matching
607 "l" gnus-group-list-level
608 "c" gnus-group-list-cached)
610 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
611 "f" gnus-score-flush-cache)
613 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
614 "d" gnus-group-describe-group
615 "f" gnus-group-fetch-faq
618 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
619 "l" gnus-group-set-current-level
620 "t" gnus-group-unsubscribe-current-group
621 "s" gnus-group-unsubscribe-group
622 "k" gnus-group-kill-group
623 "y" gnus-group-yank-group
624 "w" gnus-group-kill-region
625 "\C-k" gnus-group-kill-level
626 "z" gnus-group-kill-all-zombies))
628 (defun gnus-group-make-menu-bar ()
629 (gnus-turn-off-edit-menu 'group)
630 (unless (boundp 'gnus-group-reading-menu)
633 gnus-group-reading-menu gnus-group-mode-map ""
635 ["Read" gnus-group-read-group (gnus-group-group-name)]
636 ["Select" gnus-group-select-group (gnus-group-group-name)]
637 ["See old articles" (gnus-group-select-group 'all)
638 :keys "C-u SPC" :active (gnus-group-group-name)]
639 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
640 ["Catch up all articles" gnus-group-catchup-current-all
641 (gnus-group-group-name)]
642 ["Check for new articles" gnus-group-get-new-news-this-group
643 (gnus-group-group-name)]
644 ["Toggle subscription" gnus-group-unsubscribe-current-group
645 (gnus-group-group-name)]
646 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
647 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
648 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
649 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
650 ;; Actually one should check, if any of the marked groups gives t for
651 ;; (gnus-check-backend-function 'request-expire-articles ...)
652 ["Expire articles" gnus-group-expire-articles
653 (or (and (gnus-group-group-name)
654 (gnus-check-backend-function
655 'request-expire-articles
656 (gnus-group-group-name))) gnus-group-marked)]
657 ["Set group level" gnus-group-set-current-level
658 (gnus-group-group-name)]
659 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
660 ["Customize" gnus-group-customize (gnus-group-group-name)]
662 ["Parameters" gnus-group-edit-group-parameters
663 (gnus-group-group-name)]
664 ["Select method" gnus-group-edit-group-method
665 (gnus-group-group-name)]
666 ["Info" gnus-group-edit-group (gnus-group-group-name)]
667 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
668 ["Global kill file" gnus-group-edit-global-kill t])))
671 gnus-group-group-menu gnus-group-mode-map ""
674 ["List unread subscribed groups" gnus-group-list-groups t]
675 ["List (un)subscribed groups" gnus-group-list-all-groups t]
676 ["List killed groups" gnus-group-list-killed gnus-killed-list]
677 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
678 ["List level..." gnus-group-list-level t]
679 ["Describe all groups" gnus-group-describe-all-groups t]
680 ["Group apropos..." gnus-group-apropos t]
681 ["Group and description apropos..." gnus-group-description-apropos t]
682 ["List groups matching..." gnus-group-list-matching t]
683 ["List all groups matching..." gnus-group-list-all-matching t]
684 ["List active file" gnus-group-list-active t]
685 ["List groups with cached" gnus-group-list-cached t])
687 ["Default sort" gnus-group-sort-groups t]
688 ["Sort by method" gnus-group-sort-groups-by-method t]
689 ["Sort by rank" gnus-group-sort-groups-by-rank t]
690 ["Sort by score" gnus-group-sort-groups-by-score t]
691 ["Sort by level" gnus-group-sort-groups-by-level t]
692 ["Sort by unread" gnus-group-sort-groups-by-unread t]
693 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
694 ("Sort process/prefixed"
695 ["Default sort" gnus-group-sort-selected-groups
696 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
697 ["Sort by method" gnus-group-sort-selected-groups-by-method
698 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
699 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
700 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
701 ["Sort by score" gnus-group-sort-selected-groups-by-score
702 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
703 ["Sort by level" gnus-group-sort-selected-groups-by-level
704 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
705 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
706 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
707 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
708 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
710 ["Mark group" gnus-group-mark-group
711 (and (gnus-group-group-name)
712 (not (memq (gnus-group-group-name) gnus-group-marked)))]
713 ["Unmark group" gnus-group-unmark-group
714 (and (gnus-group-group-name)
715 (memq (gnus-group-group-name) gnus-group-marked))]
716 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
717 ["Mark regexp..." gnus-group-mark-regexp t]
718 ["Mark region" gnus-group-mark-region t]
719 ["Mark buffer" gnus-group-mark-buffer t]
720 ["Execute command" gnus-group-universal-argument
721 (or gnus-group-marked (gnus-group-group-name))])
723 ["Subscribe to a group" gnus-group-unsubscribe-group t]
724 ["Kill all newsgroups in region" gnus-group-kill-region t]
725 ["Kill all zombie groups" gnus-group-kill-all-zombies
727 ["Kill all groups on level..." gnus-group-kill-level t])
729 ["Make a foreign group" gnus-group-make-group t]
730 ["Add a directory group" gnus-group-make-directory-group t]
731 ["Add the help group" gnus-group-make-help-group t]
732 ["Add the archive group" gnus-group-make-archive-group t]
733 ["Make a doc group" gnus-group-make-doc-group t]
734 ["Make a web group" gnus-group-make-web-group t]
735 ["Make a kiboze group" gnus-group-make-kiboze-group t]
736 ["Make a virtual group" gnus-group-make-empty-virtual t]
737 ["Add a group to a virtual" gnus-group-add-to-virtual t]
738 ["Rename group" gnus-group-rename-group
739 (gnus-check-backend-function
740 'request-rename-group (gnus-group-group-name))]
741 ["Delete group" gnus-group-delete-group
742 (gnus-check-backend-function
743 'request-delete-group (gnus-group-group-name))])
745 ["Next" gnus-group-next-group t]
746 ["Previous" gnus-group-prev-group t]
747 ["Next unread" gnus-group-next-unread-group t]
748 ["Previous unread" gnus-group-prev-unread-group t]
749 ["Next unread same level" gnus-group-next-unread-group-same-level t]
750 ["Previous unread same level"
751 gnus-group-prev-unread-group-same-level t]
752 ["Jump to group" gnus-group-jump-to-group t]
753 ["First unread group" gnus-group-first-unread-group t]
754 ["Best unread group" gnus-group-best-unread-group t])
755 ["Delete bogus groups" gnus-group-check-bogus-groups t]
756 ["Find new newsgroups" gnus-group-find-new-groups t]
757 ["Transpose" gnus-group-transpose-groups
758 (gnus-group-group-name)]
759 ["Read a directory as a group..." gnus-group-enter-directory t]))
762 gnus-group-misc-menu gnus-group-mode-map ""
765 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
766 ["Send replies" gnus-soup-send-replies
767 (fboundp 'gnus-soup-pack-packet)]
768 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
769 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
770 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
771 ["Send a mail" gnus-group-mail t]
772 ["Post an article..." gnus-group-post-news t]
773 ["Check for new news" gnus-group-get-new-news t]
774 ["Activate all groups" gnus-activate-all-groups t]
775 ["Restart Gnus" gnus-group-restart t]
776 ["Read init file" gnus-group-read-init-file t]
777 ["Browse foreign server" gnus-group-browse-foreign-server t]
778 ["Enter server buffer" gnus-group-enter-server-mode t]
779 ["Expire all expirable articles" gnus-group-expire-all-groups t]
780 ["Generate any kiboze groups" nnkiboze-generate-groups t]
781 ["Gnus version" gnus-version t]
782 ["Save .newsrc files" gnus-group-save-newsrc t]
783 ["Suspend Gnus" gnus-group-suspend t]
784 ["Clear dribble buffer" gnus-group-clear-dribble t]
785 ["Read manual" gnus-info-find-node t]
786 ["Flush score cache" gnus-score-flush-cache t]
787 ["Toggle topics" gnus-topic-mode t]
788 ["Send a bug report" gnus-bug t]
789 ["Exit from Gnus" gnus-group-exit t]
790 ["Exit without saving" gnus-group-quit t]))
792 (gnus-run-hooks 'gnus-group-menu-hook)))
794 (defun gnus-group-mode ()
795 "Major mode for reading news.
797 All normal editing commands are switched off.
798 \\<gnus-group-mode-map>
799 The group buffer lists (some of) the groups available. For instance,
800 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
801 lists all zombie groups.
803 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
804 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
806 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
808 The following commands are available:
810 \\{gnus-group-mode-map}"
812 (when (gnus-visual-p 'group-menu 'menu)
813 (gnus-group-make-menu-bar))
814 (kill-all-local-variables)
815 (gnus-simplify-mode-line)
816 (setq major-mode 'gnus-group-mode)
817 (setq mode-name "Group")
818 (gnus-group-set-mode-line)
819 (setq mode-line-process nil)
820 (use-local-map gnus-group-mode-map)
821 (buffer-disable-undo)
822 (setq truncate-lines t)
823 (setq buffer-read-only t)
824 (gnus-set-default-directory)
825 (gnus-update-format-specifications nil 'group 'group-mode)
826 (gnus-update-group-mark-positions)
831 (gnus-run-hooks 'gnus-group-mode-hook))
833 (defun gnus-update-group-mark-positions ()
835 (let ((gnus-process-mark ?\200)
836 (gnus-group-marked '("dummy.group"))
837 (gnus-active-hashtb (make-vector 10 0))
839 (gnus-set-active "dummy.group" '(0 . 0))
840 (gnus-set-work-buffer)
841 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
842 (goto-char (point-min))
843 (setq gnus-group-mark-positions
844 (list (cons 'process (and (search-forward "\200" nil t)
847 (defun gnus-mouse-pick-group (e)
848 "Enter the group under the mouse pointer."
851 (gnus-group-read-group nil))
853 ;; Look at LEVEL and find out what the level is really supposed to be.
854 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
855 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
856 (defun gnus-group-default-level (&optional level number-or-nil)
858 (gnus-group-use-permanent-levels
859 (or (setq gnus-group-use-permanent-levels
860 (or level (if (numberp gnus-group-use-permanent-levels)
861 gnus-group-use-permanent-levels
862 (or gnus-group-default-list-level
863 gnus-level-subscribed))))
864 gnus-group-default-list-level gnus-level-subscribed))
868 (or level gnus-group-default-list-level gnus-level-subscribed))))
870 (defun gnus-group-setup-buffer ()
871 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
872 (unless (eq major-mode 'gnus-group-mode)
875 (gnus-carpal-setup-buffer 'group))))
877 (defun gnus-group-list-groups (&optional level unread lowest)
878 "List newsgroups with level LEVEL or lower that have unread articles.
879 Default is all subscribed groups.
880 If argument UNREAD is non-nil, groups with no unread articles are also
883 Also see the `gnus-group-use-permanent-levels' variable."
885 (list (if current-prefix-arg
886 (prefix-numeric-value current-prefix-arg)
888 (gnus-group-default-level nil t)
889 gnus-group-default-list-level
890 gnus-level-subscribed))))
892 (setq level (car gnus-group-list-mode)
893 unread (cdr gnus-group-list-mode)))
894 (setq level (gnus-group-default-level level))
895 (gnus-group-setup-buffer)
896 (gnus-update-format-specifications nil 'group 'group-mode)
897 (let ((case-fold-search nil)
898 (props (text-properties-at (gnus-point-at-bol)))
899 (empty (= (point-min) (point-max)))
900 (group (gnus-group-group-name))
902 (set-buffer gnus-group-buffer)
903 (setq number (funcall gnus-group-prepare-function level unread lowest))
904 (when (or (and (numberp number)
906 (zerop (buffer-size)))
907 ;; No groups in the buffer.
908 (gnus-message 5 gnus-no-groups-message))
909 ;; We have some groups displayed.
910 (goto-char (point-max))
911 (when (or (not gnus-group-goto-next-group-function)
912 (not (funcall gnus-group-goto-next-group-function
916 (goto-char (point-min)))
918 ;; Go to the first group with unread articles.
919 (gnus-group-search-forward t))
921 ;; Find the right group to put point on. If the current group
922 ;; has disappeared in the new listing, try to find the next
923 ;; one. If no next one can be found, just leave point at the
924 ;; first newsgroup in the buffer.
925 (when (not (gnus-goto-char
927 (point-min) (point-max)
928 'gnus-group (gnus-intern-safe
929 group gnus-active-hashtb))))
930 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
934 (point-min) (point-max) 'gnus-group
936 (caar newsrc) gnus-active-hashtb)))))
937 (setq newsrc (cdr newsrc)))
939 (goto-char (point-max))
940 (forward-line -1)))))))
941 ;; Adjust cursor point.
942 (gnus-group-position-point)))
944 (defun gnus-group-list-level (level &optional all)
945 "List groups on LEVEL.
946 If ALL (the prefix), also list groups that have no unread articles."
947 (interactive "nList groups on level: \nP")
948 (gnus-group-list-groups level all level))
950 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
951 "List all newsgroups with unread articles of level LEVEL or lower.
952 If ALL is non-nil, list groups that have no unread articles.
953 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
954 If REGEXP, only list groups matching REGEXP."
955 (set-buffer gnus-group-buffer)
956 (let ((buffer-read-only nil)
957 (newsrc (cdr gnus-newsrc-alist))
958 (lowest (or lowest 1))
959 info clevel unread group params)
961 (when (< lowest gnus-level-zombie)
962 ;; List living groups.
964 (setq info (car newsrc)
965 group (gnus-info-group info)
966 params (gnus-info-params info)
968 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
969 (and unread ; This group might be unchecked
971 (string-match regexp group))
972 (<= (setq clevel (gnus-info-level info)) level)
974 (or all ; We list all groups?
975 (if (eq unread t) ; Unactivated?
976 gnus-group-list-inactive-groups ; We list unactivated
977 (> unread 0)) ; We list groups with unread articles
978 (and gnus-list-groups-with-ticked-articles
979 (cdr (assq 'tick (gnus-info-marks info))))
980 ; And groups with tickeds
981 ;; Check for permanent visibility.
982 (and gnus-permanently-visible-groups
983 (string-match gnus-permanently-visible-groups
985 (memq 'visible params)
986 (cdr (assq 'visible params)))
987 (gnus-group-insert-group-line
988 group (gnus-info-level info)
989 (gnus-info-marks info) unread (gnus-info-method info)))))
992 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
993 (gnus-group-prepare-flat-list-dead
994 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
997 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
998 (gnus-group-prepare-flat-list-dead
999 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1000 gnus-level-killed ?K regexp))
1002 (gnus-group-set-mode-line)
1003 (setq gnus-group-list-mode (cons level all))
1004 (gnus-run-hooks 'gnus-group-prepare-hook)
1007 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1008 ;; List zombies and killed lists somewhat faster, which was
1009 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1010 ;; this by ignoring the group format specification altogether.
1013 ;; This loop is used when listing groups that match some
1016 (setq group (pop groups))
1017 (when (string-match regexp group)
1018 (gnus-add-text-properties
1019 (point) (prog1 (1+ (point))
1020 (insert " " mark " *: " group "\n"))
1021 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1023 'gnus-level level))))
1024 ;; This loop is used when listing all groups.
1026 (gnus-add-text-properties
1027 (point) (prog1 (1+ (point))
1028 (insert " " mark " *: "
1029 (setq group (pop groups)) "\n"))
1030 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1032 'gnus-level level))))))
1034 (defun gnus-group-update-group-line ()
1035 "Update the current line in the group buffer."
1036 (let* ((buffer-read-only nil)
1037 (group (gnus-group-group-name))
1038 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1039 gnus-group-indentation)
1042 (not (gnus-ephemeral-group-p group))
1044 (concat "(gnus-group-set-info '"
1045 (gnus-prin1-to-string (nth 2 entry))
1047 (setq gnus-group-indentation (gnus-group-group-indentation))
1049 (gnus-group-insert-group-line-info group)
1051 (gnus-group-position-point))))
1053 (defun gnus-group-insert-group-line-info (group)
1054 "Insert GROUP on the current line."
1055 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1056 (gnus-group-indentation (gnus-group-group-indentation))
1060 ;; (Un)subscribed group.
1061 (setq info (nth 2 entry))
1062 (gnus-group-insert-group-line
1063 group (gnus-info-level info) (gnus-info-marks info)
1064 (or (car entry) t) (gnus-info-method info)))
1065 ;; This group is dead.
1066 (gnus-group-insert-group-line
1068 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1070 (if (setq active (gnus-active group))
1071 (if (zerop (cdr active))
1073 (- (1+ (cdr active)) (car active)))
1077 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1078 gnus-tmp-marked number
1080 "Insert a group line in the group buffer."
1081 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1082 (gnus-tmp-number-total
1084 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1086 (gnus-tmp-number-of-unread
1087 (if (numberp number) (int-to-string (max 0 number))
1089 (gnus-tmp-number-of-read
1090 (if (numberp number)
1091 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1093 (gnus-tmp-subscribed
1094 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1095 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1096 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1098 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1099 (gnus-tmp-newsgroup-description
1100 (if gnus-description-hashtb
1101 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1104 (if (and gnus-moderated-hashtb
1105 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1107 (gnus-tmp-moderated-string
1108 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1109 (gnus-tmp-group-icon "==&&==")
1111 (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) ;
1112 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1113 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1114 (gnus-tmp-news-method-string
1116 (format "(%s:%s)" (car gnus-tmp-method)
1117 (cadr gnus-tmp-method)) ""))
1118 (gnus-tmp-marked-mark
1119 (if (and (numberp number)
1121 (cdr (assq 'tick gnus-tmp-marked)))
1123 (gnus-tmp-process-marked
1124 (if (member gnus-tmp-group gnus-group-marked)
1125 gnus-process-mark ? ))
1127 (or (and gnus-use-grouplens
1128 (bbb-grouplens-group-p gnus-tmp-group))
1130 (buffer-read-only nil)
1131 header gnus-tmp-header) ; passed as parameter to user-funcs.
1133 (gnus-add-text-properties
1137 (eval gnus-group-line-format-spec))
1138 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1139 gnus-unread ,(if (numberp number)
1140 (string-to-int gnus-tmp-number-of-unread)
1142 gnus-marked ,gnus-tmp-marked-mark
1143 gnus-indentation ,gnus-group-indentation
1144 gnus-level ,gnus-tmp-level))
1146 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1147 (gnus-run-hooks 'gnus-group-update-hook)
1149 ;; Allow XEmacs to remove front-sticky text properties.
1150 (gnus-group-remove-excess-properties)))
1152 (defun gnus-group-highlight-line ()
1153 "Highlight the current line according to `gnus-group-highlight'."
1154 (let* ((list gnus-group-highlight)
1156 (end (progn (end-of-line) (point)))
1157 ;; now find out where the line starts and leave point there.
1158 (beg (progn (beginning-of-line) (point)))
1159 (group (gnus-group-group-name))
1160 (entry (gnus-group-entry group))
1161 (unread (if (numberp (car entry)) (car entry) 0))
1162 (active (gnus-active group))
1163 (total (if active (1+ (- (cdr active) (car active))) 0))
1164 (info (nth 2 entry))
1165 (method (gnus-server-get-method group (gnus-info-method info)))
1166 (marked (gnus-info-marks info))
1167 (mailp (memq 'mail (assoc (symbol-name
1168 (car (or method gnus-select-method)))
1169 gnus-valid-select-methods)))
1170 (level (or (gnus-info-level info) gnus-level-killed))
1171 (score (or (gnus-info-score info) 0))
1172 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1173 (group-age (gnus-group-timestamp-delta group))
1174 (inhibit-read-only t))
1175 ;; Eval the cars of the lists until we find a match.
1177 (not (eval (caar list))))
1178 (setq list (cdr list)))
1179 (let ((face (cdar list)))
1180 (unless (eq face (get-text-property beg 'face))
1181 (gnus-put-text-property-excluding-characters-with-faces
1183 (setq face (if (boundp face) (symbol-value face) face)))
1184 (gnus-extent-start-open beg)))
1187 (defun gnus-group-update-group (group &optional visible-only)
1188 "Update all lines where GROUP appear.
1189 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1191 ;; Can't use `save-excursion' here, so we do it manually.
1192 (let ((buf (current-buffer))
1194 (set-buffer gnus-group-buffer)
1195 (setq mark (point-marker))
1196 ;; The buffer may be narrowed.
1199 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1201 found buffer-read-only)
1202 ;; Enter the current status into the dribble buffer.
1203 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1205 (not (gnus-ephemeral-group-p group)))
1207 (concat "(gnus-group-set-info '"
1208 (gnus-prin1-to-string (nth 2 entry))
1210 ;; Find all group instances. If topics are in use, each group
1211 ;; may be listed in more than once.
1212 (while (setq loc (text-property-any
1213 loc (point-max) 'gnus-group ident))
1216 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1218 (gnus-group-insert-group-line-info group)
1221 (gnus-run-hooks 'gnus-group-update-group-hook)))
1222 (setq loc (1+ loc)))
1223 (unless (or found visible-only)
1224 ;; No such line in the buffer, find out where it's supposed to
1225 ;; go, and insert it there (or at the end of the buffer).
1226 (if gnus-goto-missing-group-function
1227 (funcall gnus-goto-missing-group-function group)
1228 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1229 (while (and entry (car entry)
1233 (point-min) (point-max)
1234 'gnus-group (gnus-intern-safe
1235 (caar entry) gnus-active-hashtb)))))
1236 (setq entry (cdr entry)))
1237 (or entry (goto-char (point-max)))))
1238 ;; Finally insert the line.
1239 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1240 (gnus-group-insert-group-line-info group)
1243 (gnus-run-hooks 'gnus-group-update-group-hook))))
1244 (when gnus-group-update-group-function
1245 (funcall gnus-group-update-group-function group))
1246 (gnus-group-set-mode-line)))
1248 (set-marker mark nil)
1251 (defun gnus-group-set-mode-line ()
1252 "Update the mode line in the group buffer."
1253 (when (memq 'group gnus-updated-mode-lines)
1254 ;; Yes, we want to keep this mode line updated.
1256 (set-buffer gnus-group-buffer)
1257 (let* ((gformat (or gnus-group-mode-line-format-spec
1258 (gnus-set-format 'group-mode)))
1259 (gnus-tmp-news-server (cadr gnus-select-method))
1260 (gnus-tmp-news-method (car gnus-select-method))
1261 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1263 gnus-tmp-header ;Dummy binding for user-defined formats
1264 ;; Get the resulting string.
1266 (and gnus-dribble-buffer
1267 (buffer-name gnus-dribble-buffer)
1268 (buffer-modified-p gnus-dribble-buffer)
1270 (set-buffer gnus-dribble-buffer)
1271 (not (zerop (buffer-size))))))
1272 (mode-string (eval gformat)))
1273 ;; Say whether the dribble buffer has been modified.
1274 (setq mode-line-modified
1275 (if modified (car gnus-mode-line-modified)
1276 (cdr gnus-mode-line-modified)))
1277 ;; If the line is too long, we chop it off.
1278 (when (> (length mode-string) max-len)
1279 (setq mode-string (substring mode-string 0 (- max-len 4))))
1281 (setq mode-line-buffer-identification
1282 (gnus-mode-line-buffer-identification
1283 (list mode-string)))
1284 (set-buffer-modified-p modified))))))
1286 (defun gnus-group-group-name ()
1287 "Get the name of the newsgroup on the current line."
1288 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1290 (symbol-name group))))
1292 (defun gnus-group-group-level ()
1293 "Get the level of the newsgroup on the current line."
1294 (get-text-property (gnus-point-at-bol) 'gnus-level))
1296 (defun gnus-group-group-indentation ()
1297 "Get the indentation of the newsgroup on the current line."
1298 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1299 (and gnus-group-indentation-function
1300 (funcall gnus-group-indentation-function))
1303 (defun gnus-group-group-unread ()
1304 "Get the number of unread articles of the newsgroup on the current line."
1305 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1307 (defun gnus-group-new-mail (group)
1308 (if (nnmail-new-mail-p (gnus-group-real-name group))
1312 (defun gnus-group-level (group)
1313 "Return the estimated level of GROUP."
1314 (or (gnus-info-level (gnus-get-info group))
1315 (and (member group gnus-zombie-list) gnus-level-zombie)
1318 (defun gnus-group-search-forward (&optional backward all level first-too)
1319 "Find the next newsgroup with unread articles.
1320 If BACKWARD is non-nil, find the previous newsgroup instead.
1321 If ALL is non-nil, just find any newsgroup.
1322 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1324 If FIRST-TOO, the current line is also eligible as a target."
1325 (let ((way (if backward -1 1))
1326 (low gnus-level-killed)
1329 (if (and backward (progn (beginning-of-line)) (bobp))
1338 (get-text-property (point) 'gnus-group)
1342 (get-text-property (point) 'gnus-unread)))
1343 (and (numberp unread) (> unread 0)))
1344 (setq lev (get-text-property (point)
1346 (<= lev gnus-level-subscribed)))
1348 (and (setq lev (get-text-property (point)
1357 (zerop (forward-line way)))))
1359 (progn (gnus-group-position-point) t)
1360 (goto-char (or pos beg))
1363 ;;; Gnus group mode commands
1367 (defun gnus-group-mark-group (n &optional unmark no-advance)
1368 "Mark the current group."
1370 (let ((buffer-read-only nil)
1374 (when (setq group (gnus-group-group-name))
1375 ;; Go to the mark position.
1377 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1378 (subst-char-in-region
1379 (point) (1+ (point)) (char-after)
1382 (setq gnus-group-marked (delete group gnus-group-marked))
1384 (setq gnus-group-marked
1385 (cons group (delete group gnus-group-marked)))
1386 gnus-process-mark)))
1388 (gnus-group-next-group 1))
1390 (gnus-summary-position-point)
1393 (defun gnus-group-unmark-group (n)
1394 "Remove the mark from the current group."
1396 (gnus-group-mark-group n 'unmark)
1397 (gnus-group-position-point))
1399 (defun gnus-group-unmark-all-groups ()
1400 "Unmark all groups."
1402 (let ((groups gnus-group-marked))
1405 (gnus-group-remove-mark (pop groups)))))
1406 (gnus-group-position-point))
1408 (defun gnus-group-mark-region (unmark beg end)
1409 "Mark all groups between point and mark.
1410 If UNMARK, remove the mark instead."
1411 (interactive "P\nr")
1412 (let ((num (count-lines beg end)))
1415 (- num (gnus-group-mark-group num unmark)))))
1417 (defun gnus-group-mark-buffer (&optional unmark)
1418 "Mark all groups in the buffer.
1419 If UNMARK, remove the mark instead."
1421 (gnus-group-mark-region unmark (point-min) (point-max)))
1423 (defun gnus-group-mark-regexp (regexp)
1424 "Mark all groups that match some regexp."
1425 (interactive "sMark (regexp): ")
1426 (let ((alist (cdr gnus-newsrc-alist))
1429 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1430 (gnus-group-set-mark group))))
1431 (gnus-group-position-point))
1433 (defun gnus-group-remove-mark (group)
1434 "Remove the process mark from GROUP and move point there.
1435 Return nil if the group isn't displayed."
1436 (if (gnus-group-goto-group group)
1438 (gnus-group-mark-group 1 'unmark t)
1440 (setq gnus-group-marked
1441 (delete group gnus-group-marked))
1444 (defun gnus-group-set-mark (group)
1445 "Set the process mark on GROUP."
1446 (if (gnus-group-goto-group group)
1448 (gnus-group-mark-group 1 nil t))
1449 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1451 (defun gnus-group-universal-argument (arg &optional groups func)
1452 "Perform any command on all groups according to the process/prefix convention."
1454 (if (eq (setq func (or func
1457 (substitute-command-keys
1458 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1460 (gnus-error 1 "Undefined key")
1461 (gnus-group-iterate arg
1463 (command-execute func))))
1464 (gnus-group-position-point))
1466 (defun gnus-group-process-prefix (n)
1467 "Return a list of groups to work on.
1468 Take into consideration N (the prefix) and the list of marked groups."
1471 (setq n (prefix-numeric-value n))
1472 ;; There is a prefix, so we return a list of the N next
1474 (let ((way (if (< n 0) -1 1))
1479 (if (setq group (gnus-group-group-name))
1480 (push group groups))
1482 (gnus-group-next-group way)))
1484 ((gnus-region-active-p)
1485 ;; Work on the region between point and mark.
1486 (let ((max (max (point) (mark)))
1489 (goto-char (min (point) (mark)))
1492 (push (gnus-group-group-name) groups)
1493 (zerop (gnus-group-next-group 1))
1495 (nreverse groups))))
1497 ;; No prefix, but a list of marked articles.
1498 (reverse gnus-group-marked))
1500 ;; Neither marked articles or a prefix, so we return the
1502 (let ((group (gnus-group-group-name)))
1503 (and group (list group))))))
1505 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1506 ;;; imagine why I went through these contortions...
1508 (let ((function (make-symbol "gnus-group-iterate-function"))
1509 (window (make-symbol "gnus-group-iterate-window"))
1510 (groups (make-symbol "gnus-group-iterate-groups"))
1511 (group (make-symbol "gnus-group-iterate-group")))
1513 `(defun gnus-group-iterate (arg ,function)
1514 "Iterate FUNCTION over all process/prefixed groups.
1515 FUNCTION will be called with the group name as the paremeter
1516 and with point over the group in question."
1517 (let ((,groups (gnus-group-process-prefix arg))
1518 (,window (selected-window))
1520 (while (setq ,group (pop ,groups))
1521 (select-window ,window)
1522 (gnus-group-remove-mark ,group)
1523 (save-selected-window
1525 (funcall ,function ,group)))))))))
1527 (put 'gnus-group-iterate 'lisp-indent-function 1)
1529 ;; Selecting groups.
1531 (defun gnus-group-read-group (&optional all no-article group select-articles)
1532 "Read news in this newsgroup.
1533 If the prefix argument ALL is non-nil, already read articles become
1534 readable. IF ALL is a number, fetch this number of articles. If the
1535 optional argument NO-ARTICLE is non-nil, no article will be
1536 auto-selected upon group entry. If GROUP is non-nil, fetch that
1539 (let ((no-display (eq all 0))
1540 (group (or group (gnus-group-group-name)))
1541 number active marked entry)
1545 (error "No group on current line"))
1546 (setq marked (gnus-info-marks
1547 (nth 2 (setq entry (gnus-gethash
1548 group gnus-newsrc-hashtb)))))
1549 ;; This group might be a dead group. In that case we have to get
1550 ;; the number of unread articles from `gnus-active-hashtb'.
1552 (cond ((numberp all) all)
1554 ((setq active (gnus-active group))
1555 (- (1+ (cdr active)) (car active)))))
1556 (gnus-summary-read-group
1557 group (or all (and (numberp number)
1558 (zerop (+ number (gnus-range-length
1559 (cdr (assq 'tick marked)))
1561 (cdr (assq 'dormant marked)))))))
1562 no-article nil no-display nil select-articles)))
1564 (defun gnus-group-select-group (&optional all)
1565 "Select this newsgroup.
1566 No article is selected automatically.
1567 If ALL is non-nil, already read articles become readable.
1568 If ALL is a number, fetch this number of articles."
1570 (gnus-group-read-group all t))
1572 (defun gnus-group-quick-select-group (&optional all)
1573 "Select the current group \"quickly\".
1574 This means that no highlighting or scoring will be performed.
1575 If ALL (the prefix argument) is 0, don't even generate the summary
1578 This might be useful if you want to toggle threading
1579 before entering the group."
1581 (require 'gnus-score)
1583 gnus-score-find-score-files-function
1584 gnus-home-score-file
1585 gnus-apply-kill-hook
1586 gnus-summary-expunge-below)
1587 (gnus-group-read-group all t)))
1589 (defun gnus-group-visible-select-group (&optional all)
1590 "Select the current group without hiding any articles."
1592 (let ((gnus-inhibit-limiting t))
1593 (gnus-group-read-group all t)))
1595 (defun gnus-group-select-group-ephemerally ()
1596 "Select the current group without doing any processing whatsoever.
1597 You will actually be entered into a group that's a copy of
1598 the current group; no changes you make while in this group will
1601 (require 'gnus-score)
1603 gnus-score-find-score-files-function gnus-apply-kill-hook
1604 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1605 gnus-summary-mode-hook gnus-select-group-hook
1606 (group (gnus-group-group-name))
1607 (method (gnus-find-method-for-group group)))
1608 (gnus-group-read-ephemeral-group
1609 (gnus-group-prefixed-name group method) method)))
1612 (defun gnus-fetch-group (group)
1613 "Start Gnus if necessary and enter GROUP.
1614 Returns whether the fetching was successful or not."
1615 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1616 (unless (get-buffer gnus-group-buffer)
1618 (gnus-group-read-group nil nil group))
1621 (defun gnus-fetch-group-other-frame (group)
1622 "Pop up a frame and enter GROUP."
1624 (let ((window (get-buffer-window gnus-group-buffer)))
1626 (select-frame (window-frame window)))
1627 ((= (length (frame-list)) 1)
1628 (select-frame (make-frame)))
1631 (gnus-fetch-group group))
1633 (defvar gnus-ephemeral-group-server 0)
1635 ;; Enter a group that is not in the group buffer. Non-nil is returned
1636 ;; if selection was successful.
1637 (defun gnus-group-read-ephemeral-group (group method &optional activate
1638 quit-config request-only
1640 "Read GROUP from METHOD as an ephemeral group.
1641 If ACTIVATE, request the group first.
1642 If QUIT-CONFIG, use that window configuration when exiting from the
1644 If REQUEST-ONLY, don't actually read the group; just request it.
1645 If SELECT-ARTICLES, only select those articles.
1647 Return the name of the group if selection was successful."
1648 ;; Transform the select method into a unique server.
1649 (when (stringp method)
1650 (setq method (gnus-server-to-method method)))
1652 `(,(car method) ,(concat (cadr method) "-ephemeral")
1653 (,(intern (format "%s-address" (car method))) ,(cadr method))
1655 (let ((group (if (gnus-group-foreign-p group) group
1656 (gnus-group-prefixed-name group method))))
1660 ,gnus-level-default-subscribed nil nil ,method
1662 ,(if quit-config quit-config
1663 (cons gnus-summary-buffer
1664 gnus-current-window-configuration))))))
1666 (push method gnus-ephemeral-servers)
1667 (set-buffer gnus-group-buffer)
1668 (unless (gnus-check-server method)
1669 (error "Unable to contact server: %s" (gnus-status-message method)))
1671 (gnus-activate-group group 'scan)
1672 (unless (gnus-request-group group)
1673 (error "Couldn't request group: %s"
1674 (nnheader-get-report (car method)))))
1678 (when (gnus-group-read-group t t group select-articles)
1683 (defun gnus-group-jump-to-group (group)
1684 "Jump to newsgroup GROUP."
1686 (list (completing-read
1687 "Group: " gnus-active-hashtb nil
1688 (gnus-read-active-file-p)
1690 'gnus-group-history)))
1692 (when (equal group "")
1693 (error "Empty group name"))
1695 (unless (gnus-ephemeral-group-p group)
1696 ;; Either go to the line in the group buffer...
1697 (unless (gnus-group-goto-group group)
1698 ;; ... or insert the line.
1699 (gnus-group-update-group group)
1700 (gnus-group-goto-group group)))
1701 ;; Adjust cursor point.
1702 (gnus-group-position-point))
1704 (defun gnus-group-goto-group (group &optional far)
1705 "Goto to newsgroup GROUP.
1706 If FAR, it is likely that the group is not on the current line."
1711 (point-min) (point-max)
1712 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1715 ;; It's quite likely that we are on the right line, so
1716 ;; we check the current line first.
1717 ((eq (get-text-property (point) 'gnus-group)
1718 (gnus-intern-safe group gnus-active-hashtb))
1720 ;; Previous and next line are also likely, so we check them as well.
1723 (eq (get-text-property (point) 'gnus-group)
1724 (gnus-intern-safe group gnus-active-hashtb)))
1729 (eq (get-text-property (point) 'gnus-group)
1730 (gnus-intern-safe group gnus-active-hashtb)))
1734 ;; Search through the entire buffer.
1737 (point-min) (point-max)
1738 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1740 (defun gnus-group-next-group (n &optional silent)
1741 "Go to next N'th newsgroup.
1742 If N is negative, search backward instead.
1743 Returns the difference between N and the number of skips actually
1746 (gnus-group-next-unread-group n t nil silent))
1748 (defun gnus-group-next-unread-group (n &optional all level silent)
1749 "Go to next N'th unread newsgroup.
1750 If N is negative, search backward instead.
1751 If ALL is non-nil, choose any newsgroup, unread or not.
1752 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1753 such group can be found, the next group with a level higher than
1755 Returns the difference between N and the number of skips actually
1758 (let ((backward (< n 0))
1761 (gnus-group-search-forward
1762 backward (or (not gnus-group-goto-unread) all) level))
1766 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1767 (if level " on this level or higher" "")))
1770 (defun gnus-group-prev-group (n)
1771 "Go to previous N'th newsgroup.
1772 Returns the difference between N and the number of skips actually
1775 (gnus-group-next-unread-group (- n) t))
1777 (defun gnus-group-prev-unread-group (n)
1778 "Go to previous N'th unread newsgroup.
1779 Returns the difference between N and the number of skips actually
1782 (gnus-group-next-unread-group (- n)))
1784 (defun gnus-group-next-unread-group-same-level (n)
1785 "Go to next N'th unread newsgroup on the same level.
1786 If N is negative, search backward instead.
1787 Returns the difference between N and the number of skips actually
1790 (gnus-group-next-unread-group n t (gnus-group-group-level))
1791 (gnus-group-position-point))
1793 (defun gnus-group-prev-unread-group-same-level (n)
1794 "Go to next N'th unread newsgroup on the same level.
1795 Returns the difference between N and the number of skips actually
1798 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1799 (gnus-group-position-point))
1801 (defun gnus-group-best-unread-group (&optional exclude-group)
1802 "Go to the group with the highest level.
1803 If EXCLUDE-GROUP, do not go to that group."
1805 (goto-char (point-min))
1809 (setq unread (get-text-property (point) 'gnus-unread))
1810 (when (and (numberp unread) (> unread 0))
1811 (when (and (get-text-property (point) 'gnus-level)
1812 (< (get-text-property (point) 'gnus-level) best)
1813 (or (not exclude-group)
1814 (not (equal exclude-group (gnus-group-group-name)))))
1815 (setq best (get-text-property (point) 'gnus-level))
1816 (setq best-point (point))))
1819 (goto-char best-point))
1820 (gnus-summary-position-point)
1821 (and best-point (gnus-group-group-name))))
1823 (defun gnus-group-first-unread-group ()
1824 "Go to the first group with unread articles."
1827 (let ((opoint (point))
1829 (goto-char (point-min))
1830 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1831 (and (numberp unread) ; Not a topic.
1832 (not (zerop unread))) ; Has unread articles.
1833 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1836 nil)) ; Not success.
1837 (gnus-group-position-point)))
1839 (defun gnus-group-enter-server-mode ()
1840 "Jump to the server buffer."
1842 (gnus-enter-server-buffer))
1844 (defun gnus-group-make-group (name &optional method address args)
1845 "Add a new newsgroup.
1846 The user will be prompted for a NAME, for a select METHOD, and an
1850 (gnus-read-group "Group name: ")
1851 (gnus-read-method "From method: ")))
1853 (when (stringp method)
1854 (setq method (or (gnus-server-to-method method) method)))
1855 (let* ((meth (gnus-method-simplify
1857 (not (gnus-server-equal method gnus-select-method)))
1858 (if address (list (intern method) address)
1860 (nname (if method (gnus-group-prefixed-name name meth) name))
1862 (when (gnus-gethash nname gnus-newsrc-hashtb)
1863 (error "Group %s already exists" nname))
1864 ;; Subscribe to the new group.
1865 (gnus-group-change-level
1866 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1867 gnus-level-default-subscribed gnus-level-killed
1868 (and (gnus-group-group-name)
1869 (gnus-gethash (gnus-group-group-name)
1870 gnus-newsrc-hashtb))
1873 (gnus-set-active nname (cons 1 0))
1874 (unless (gnus-ephemeral-group-p name)
1876 (concat "(gnus-group-set-info '"
1877 (gnus-prin1-to-string (cdr info)) ")")))
1879 (gnus-group-insert-group-line-info nname)
1881 (gnus-group-position-point)
1883 ;; Load the backend and try to make the backend create
1884 ;; the group as well.
1885 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1887 gnus-valid-select-methods)
1889 (gnus-check-server meth)
1890 (when (gnus-check-backend-function 'request-create-group nname)
1891 (gnus-request-create-group nname nil args))
1894 (defun gnus-group-delete-groups (&optional arg)
1895 "Delete the current group. Only meaningful with editable groups."
1897 (let ((n (length (gnus-group-process-prefix arg))))
1898 (when (gnus-yes-or-no-p
1900 "Delete this 1 group? "
1901 (format "Delete these %d groups? " n)))
1902 (gnus-group-iterate arg
1904 (gnus-group-delete-group group nil t))))))
1906 (defun gnus-group-delete-group (group &optional force no-prompt)
1907 "Delete the current group. Only meaningful with editable groups.
1908 If FORCE (the prefix) is non-nil, all the articles in the group will
1909 be deleted. This is \"deleted\" as in \"removed forever from the face
1910 of the Earth\". There is no undo. The user will be prompted before
1911 doing the deletion."
1913 (list (gnus-group-group-name)
1914 current-prefix-arg))
1916 (error "No group to rename"))
1917 (unless (gnus-check-backend-function 'request-delete-group group)
1918 (error "This backend does not support group deletion"))
1920 (if (and (not no-prompt)
1921 (not (gnus-yes-or-no-p
1923 "Do you really want to delete %s%s? "
1924 group (if force " and all its contents" "")))))
1926 (gnus-message 6 "Deleting group %s..." group)
1927 (if (not (gnus-request-delete-group group force))
1928 (gnus-error 3 "Couldn't delete group %s" group)
1929 (gnus-message 6 "Deleting group %s...done" group)
1930 (gnus-group-goto-group group)
1931 (gnus-group-kill-group 1 t)
1932 (gnus-sethash group nil gnus-active-hashtb)
1934 (gnus-group-position-point)))
1936 (defun gnus-group-rename-group (group new-name)
1937 "Rename group from GROUP to NEW-NAME.
1938 When used interactively, GROUP is the group under point
1939 and NEW-NAME will be prompted for."
1942 (gnus-group-group-name)
1944 (unless (gnus-check-backend-function
1945 'request-rename-group (gnus-group-group-name))
1946 (error "This backend does not support renaming groups"))
1947 (gnus-read-group "Rename group to: "
1948 (gnus-group-real-name (gnus-group-group-name))))))
1950 (unless (gnus-check-backend-function 'request-rename-group group)
1951 (error "This backend does not support renaming groups"))
1953 (error "No group to rename"))
1954 (when (equal (gnus-group-real-name group) new-name)
1955 (error "Can't rename to the same name"))
1957 ;; We find the proper prefixed name.
1959 (if (gnus-group-native-p group)
1963 (gnus-group-prefixed-name
1964 (gnus-group-real-name new-name)
1965 (gnus-info-method (gnus-get-info group)))))
1967 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1969 (if (not (gnus-request-rename-group group new-name))
1970 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1971 ;; We rename the group internally by killing it...
1972 (gnus-group-goto-group group)
1973 (gnus-group-kill-group)
1974 ;; ... changing its name ...
1975 (setcar (cdar gnus-list-of-killed-groups) new-name)
1976 ;; ... and then yanking it. Magic!
1977 (gnus-group-yank-group)
1978 (gnus-set-active new-name (gnus-active group))
1979 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1981 (setq gnus-killed-list (delete group gnus-killed-list))
1982 (gnus-set-active group nil)
1983 (gnus-dribble-touch)
1984 (gnus-group-position-point)))
1986 (defun gnus-group-edit-group (group &optional part)
1987 "Edit the group on the current line."
1988 (interactive (list (gnus-group-group-name)))
1989 (let ((part (or part 'info))
1992 (error "No group on current line"))
1993 (unless (setq info (gnus-get-info group))
1994 (error "Killed group; can't be edited"))
1996 (gnus-close-group group))
1998 ;; Find the proper form to edit.
1999 (cond ((eq part 'method)
2000 (or (gnus-info-method info) "native"))
2002 (gnus-info-params info))
2004 ;; The proper documentation.
2006 "Editing the %s for `%s'."
2008 ((eq part 'method) "select method")
2009 ((eq part 'params) "group parameters")
2013 (gnus-group-edit-group-done ',part ,group form)))))
2015 (defun gnus-group-edit-group-method (group)
2016 "Edit the select method of GROUP."
2017 (interactive (list (gnus-group-group-name)))
2018 (gnus-group-edit-group group 'method))
2020 (defun gnus-group-edit-group-parameters (group)
2021 "Edit the group parameters of GROUP."
2022 (interactive (list (gnus-group-group-name)))
2023 (gnus-group-edit-group group 'params))
2025 (defun gnus-group-edit-group-done (part group form)
2027 (let* ((method (cond ((eq part 'info) (nth 4 form))
2028 ((eq part 'method) form)
2030 (info (cond ((eq part 'info) form)
2031 ((eq part 'method) (gnus-get-info group))
2034 (if (or (not method)
2036 gnus-select-method method))
2037 (gnus-group-real-name (car info))
2038 (gnus-group-prefixed-name
2039 (gnus-group-real-name (car info)) method))
2041 (when (and new-group
2042 (not (equal new-group group)))
2043 (when (gnus-group-goto-group group)
2044 (gnus-group-kill-group 1))
2045 (gnus-activate-group new-group))
2047 (if (not (and info new-group))
2048 (gnus-group-set-info form (or new-group group) part)
2049 (setq info (gnus-copy-sequence info))
2050 (setcar info new-group)
2051 (unless (gnus-server-equal method "native")
2052 (unless (nthcdr 3 info)
2053 (nconc info (list nil nil)))
2054 (unless (nthcdr 4 info)
2055 (nconc info (list nil)))
2056 (gnus-info-set-method info method))
2057 (gnus-group-set-info info))
2058 (gnus-group-update-group (or new-group group))
2059 (gnus-group-position-point)))
2061 (defun gnus-group-make-useful-group (group method)
2062 "Create one of the groups described in `gnus-useful-groups'."
2064 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2066 gnus-useful-groups)))
2067 (list (cadr entry) (caddr entry))))
2068 (setq method (gnus-copy-sequence method))
2070 (while (setq entry (memq (assq 'eval method) method))
2071 (setcar entry (eval (cadar entry)))))
2072 (gnus-group-make-group group method))
2074 (defun gnus-group-make-help-group ()
2075 "Create the Gnus documentation group."
2077 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2078 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2079 (when (gnus-gethash name gnus-newsrc-hashtb)
2080 (error "Documentation group already exists"))
2082 (gnus-message 1 "Couldn't find doc group")
2083 (gnus-group-make-group
2084 (gnus-group-real-name name)
2085 (list 'nndoc "gnus-help"
2086 (list 'nndoc-address file)
2087 (list 'nndoc-article-type 'mbox)))))
2088 (gnus-group-position-point))
2090 (defun gnus-group-make-doc-group (file type)
2091 "Create a group that uses a single file as the source."
2093 (list (read-file-name "File name: ")
2094 (and current-prefix-arg 'ask)))
2095 (when (eq type 'ask)
2100 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2102 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2103 ((= char ?b) 'babyl)
2104 ((= char ?d) 'digest)
2105 ((= char ?f) 'forward)
2107 ((= char ?g) 'guess)
2108 (t (setq err (format "%c unknown. " char))
2111 (let* ((file (expand-file-name file))
2112 (name (gnus-generate-new-group-name
2113 (gnus-group-prefixed-name
2114 (file-name-nondirectory file) '(nndoc "")))))
2115 (gnus-group-make-group
2116 (gnus-group-real-name name)
2118 (list 'nndoc-address file)
2119 (list 'nndoc-article-type (or type 'guess))))))
2121 (defvar nnweb-type-definition)
2122 (defvar gnus-group-web-type-history nil)
2123 (defvar gnus-group-web-search-history nil)
2124 (defun gnus-group-make-web-group (&optional solid)
2125 "Create an ephemeral nnweb group.
2126 If SOLID (the prefix), create a solid group."
2130 (if solid (gnus-read-group "Group name: ")
2131 (message-unique-id)))
2132 (default-type (or (car gnus-group-web-type-history)
2133 (symbol-name (caar nnweb-type-definition))))
2137 (format "Search engine type (default %s): " default-type)
2138 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2139 nnweb-type-definition)
2140 nil t nil 'gnus-group-web-type-history)
2145 (cons (or (car gnus-group-web-search-history) "") 0)
2146 'gnus-group-web-search-history))
2148 `(nnweb ,group (nnweb-search ,search)
2149 (nnweb-type ,(intern type))
2150 (nnweb-ephemeral-p t))))
2152 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2153 (gnus-group-read-ephemeral-group
2155 (cons (current-buffer)
2156 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2158 (defvar nnwarchive-type-definition)
2159 (defvar gnus-group-warchive-type-history nil)
2160 (defvar gnus-group-warchive-login-history nil)
2161 (defvar gnus-group-warchive-address-history nil)
2163 (defun gnus-group-make-warchive-group ()
2164 "Create a nnwarchive group."
2166 (require 'nnwarchive)
2167 (let* ((group (gnus-read-group "Group name: "))
2168 (default-type (or (car gnus-group-warchive-type-history)
2169 (symbol-name (caar nnwarchive-type-definition))))
2173 (format "Warchive type (default %s): " default-type)
2174 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2175 nnwarchive-type-definition)
2176 nil t nil 'gnus-group-warchive-type-history)
2178 (address (read-string "Warchive address: "
2179 nil 'gnus-group-warchive-address-history))
2180 (default-login (or (car gnus-group-warchive-login-history)
2185 (format "Warchive login (default %s): " user-mail-address)
2186 default-login 'gnus-group-warchive-login-history)
2189 `(nnwarchive ,address
2190 (nnwarchive-type ,(intern type))
2191 (nnwarchive-login ,login))))
2192 (gnus-group-make-group group method)))
2194 (defun gnus-group-make-archive-group (&optional all)
2195 "Create the (ding) Gnus archive group of the most recent articles.
2196 Given a prefix, create a full group."
2198 (let ((group (gnus-group-prefixed-name
2199 (if all "ding.archives" "ding.recent") '(nndir ""))))
2200 (when (gnus-gethash group gnus-newsrc-hashtb)
2201 (error "Archive group already exists"))
2202 (gnus-group-make-group
2203 (gnus-group-real-name group)
2204 (list 'nndir (if all "hpc" "edu")
2205 (list 'nndir-directory
2206 (if all gnus-group-archive-directory
2207 gnus-group-recent-archive-directory))))
2208 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2210 (defun gnus-group-make-directory-group (dir)
2211 "Create an nndir group.
2212 The user will be prompted for a directory. The contents of this
2213 directory will be used as a newsgroup. The directory should contain
2214 mail messages or news articles in files that have numeric names."
2216 (list (read-file-name "Create group from directory: ")))
2217 (unless (file-exists-p dir)
2218 (error "No such directory"))
2219 (unless (file-directory-p dir)
2220 (error "Not a directory"))
2224 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2226 (gnus-group-prefixed-name
2227 (concat (file-name-as-directory (directory-file-name dir))
2230 (setq ext (format "<%d>" (setq i (1+ i)))))
2231 (gnus-group-make-group
2232 (gnus-group-real-name group)
2233 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2235 (defun gnus-group-make-kiboze-group (group address scores)
2236 "Create an nnkiboze group.
2237 The user will be prompted for a name, a regexp to match groups, and
2238 score file entries for articles to include in the group."
2241 (read-string "nnkiboze group name: ")
2242 (read-string "Source groups (regexp): ")
2243 (let ((headers (mapcar (lambda (group) (list group))
2244 '("subject" "from" "number" "date" "message-id"
2245 "references" "chars" "lines" "xref"
2246 "followup" "all" "body" "head")))
2247 scores header regexp regexps)
2248 (while (not (equal "" (setq header (completing-read
2249 "Match on header: " headers nil t))))
2251 (while (not (equal "" (setq regexp (read-string
2252 (format "Match on %s (string): "
2254 (push (list regexp nil nil 'r) regexps))
2255 (push (cons header regexps) scores))
2257 (gnus-group-make-group group "nnkiboze" address)
2258 (with-temp-file (gnus-score-file-name (concat "nnkiboze:" group))
2259 (let (emacs-lisp-mode-hook)
2260 (pp scores (current-buffer)))))
2262 (defun gnus-group-add-to-virtual (n vgroup)
2263 "Add the current group to a virtual group."
2265 (list current-prefix-arg
2266 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2268 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2269 (error "%s is not an nnvirtual group" vgroup))
2270 (gnus-close-group vgroup)
2271 (let* ((groups (gnus-group-process-prefix n))
2272 (method (gnus-info-method (gnus-get-info vgroup))))
2273 (setcar (cdr method)
2275 (nth 1 method) "\\|"
2278 (gnus-group-remove-mark s)
2279 (concat "\\(^" (regexp-quote s) "$\\)"))
2281 (gnus-group-position-point))
2283 (defun gnus-group-make-empty-virtual (group)
2284 "Create a new, fresh, empty virtual group."
2285 (interactive "sCreate new, empty virtual group: ")
2286 (let* ((method (list 'nnvirtual "^$"))
2287 (pgroup (gnus-group-prefixed-name group method)))
2288 ;; Check whether it exists already.
2289 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2290 (error "Group %s already exists" pgroup))
2291 ;; Subscribe the new group after the group on the current line.
2292 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2293 (gnus-group-update-group pgroup)
2295 (gnus-group-position-point)))
2297 (defun gnus-group-enter-directory (dir)
2298 "Enter an ephemeral nneething group."
2299 (interactive "DDirectory to read: ")
2300 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2301 (leaf (gnus-group-prefixed-name
2302 (file-name-nondirectory (directory-file-name dir))
2304 (name (gnus-generate-new-group-name leaf)))
2305 (unless (gnus-group-read-ephemeral-group
2307 (cons (current-buffer)
2308 (if (eq major-mode 'gnus-summary-mode)
2310 (error "Couldn't enter %s" dir))))
2313 (autoload 'nnimap-expunge "nnimap")
2314 (autoload 'nnimap-acl-get "nnimap")
2315 (autoload 'nnimap-acl-edit "nnimap"))
2317 (defun gnus-group-nnimap-expunge (group)
2318 "Expunge deleted articles in current nnimap GROUP."
2319 (interactive (list (gnus-group-group-name)))
2320 (let ((mailbox (gnus-group-real-name group)) method)
2322 (error "No group on current line"))
2323 (unless (gnus-get-info group)
2324 (error "Killed group; can't be edited"))
2325 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2326 (error "%s is not an nnimap group" group))
2327 (nnimap-expunge mailbox (cadr method))))
2329 (defun gnus-group-nnimap-edit-acl (group)
2330 "Edit the Access Control List of current nnimap GROUP."
2331 (interactive (list (gnus-group-group-name)))
2332 (let ((mailbox (gnus-group-real-name group)) method acl)
2334 (error "No group on current line"))
2335 (unless (gnus-get-info group)
2336 (error "Killed group; can't be edited"))
2337 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2338 (error "%s is not an nnimap group" group))
2339 (gnus-edit-form (setq acl (nnimap-acl-get mailbox (cadr method)))
2340 (format "Editing the access control list for `%s'.
2342 An access control list is a list of (identifier . rights) elements.
2344 The identifier string specifies the corresponding user. The
2345 identifier \"anyone\" is reserved to refer to the universal identity.
2347 Rights is a string listing a (possibly empty) set of alphanumeric
2348 characters, each character listing a set of operations which is being
2349 controlled. Letters are reserved for ``standard'' rights, listed
2350 below. Digits are reserved for implementation or site defined rights.
2352 l - lookup (mailbox is visible to LIST/LSUB commands)
2353 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2354 SEARCH, COPY from mailbox)
2355 s - keep seen/unseen information across sessions (STORE SEEN flag)
2356 w - write (STORE flags other than SEEN and DELETED)
2357 i - insert (perform APPEND, COPY into mailbox)
2358 p - post (send mail to submission address for mailbox,
2359 not enforced by IMAP4 itself)
2360 c - create (CREATE new sub-mailboxes in any implementation-defined
2362 d - delete (STORE DELETED flag, perform EXPUNGE)
2363 a - administer (perform SETACL)" group)
2366 ,mailbox ',method ',acl form)))))
2368 ;; Group sorting commands
2369 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2371 (defun gnus-group-sort-groups (func &optional reverse)
2372 "Sort the group buffer according to FUNC.
2373 When used interactively, the sorting function used will be
2374 determined by the `gnus-group-sort-function' variable.
2375 If REVERSE (the prefix), reverse the sorting order."
2376 (interactive (list gnus-group-sort-function current-prefix-arg))
2377 (funcall gnus-group-sort-alist-function
2378 (gnus-make-sort-function func) reverse)
2379 (gnus-group-list-groups)
2380 (gnus-dribble-touch))
2382 (defun gnus-group-sort-flat (func reverse)
2383 ;; We peel off the dummy group from the alist.
2385 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2386 (pop gnus-newsrc-alist))
2388 (setq gnus-newsrc-alist
2389 (sort gnus-newsrc-alist func))
2391 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2392 ;; Regenerate the hash table.
2393 (gnus-make-hashtable-from-newsrc-alist)))
2395 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2396 "Sort the group buffer alphabetically by group name.
2397 If REVERSE, sort in reverse order."
2399 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2401 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2402 "Sort the group buffer by number of unread articles.
2403 If REVERSE, sort in reverse order."
2405 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2407 (defun gnus-group-sort-groups-by-level (&optional reverse)
2408 "Sort the group buffer by group level.
2409 If REVERSE, sort in reverse order."
2411 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2413 (defun gnus-group-sort-groups-by-score (&optional reverse)
2414 "Sort the group buffer by group score.
2415 If REVERSE, sort in reverse order."
2417 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2419 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2420 "Sort the group buffer by group rank.
2421 If REVERSE, sort in reverse order."
2423 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2425 (defun gnus-group-sort-groups-by-method (&optional reverse)
2426 "Sort the group buffer alphabetically by backend name.
2427 If REVERSE, sort in reverse order."
2429 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2431 ;;; Selected group sorting.
2433 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2434 "Sort the process/prefixed groups."
2435 (interactive (list current-prefix-arg gnus-group-sort-function))
2436 (let ((groups (gnus-group-process-prefix n)))
2437 (funcall gnus-group-sort-selected-function
2438 groups (gnus-make-sort-function func) reverse)
2439 (gnus-group-list-groups)))
2441 (defun gnus-group-sort-selected-flat (groups func reverse)
2442 (let (entries infos)
2443 ;; First find all the group entries for these groups.
2445 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2447 ;; Then sort the infos.
2451 (lambda (entry) (car entry))
2452 (setq entries (nreverse entries)))
2455 (setq infos (nreverse infos)))
2456 ;; Go through all the infos and replace the old entries
2457 ;; with the new infos.
2459 (setcar (car entries) (pop infos))
2461 ;; Update the hashtable.
2462 (gnus-make-hashtable-from-newsrc-alist)))
2464 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2465 "Sort the group buffer alphabetically by group name.
2466 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2467 sort in reverse order."
2468 (interactive (gnus-interactive "P\ny"))
2469 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2471 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2472 "Sort the group buffer by number of unread articles.
2473 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2474 sort in reverse order."
2475 (interactive (gnus-interactive "P\ny"))
2476 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2478 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2479 "Sort the group buffer by group level.
2480 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2481 sort in reverse order."
2482 (interactive (gnus-interactive "P\ny"))
2483 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2485 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2486 "Sort the group buffer by group score.
2487 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2488 sort in reverse order."
2489 (interactive (gnus-interactive "P\ny"))
2490 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2492 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2493 "Sort the group buffer by group rank.
2494 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2495 sort in reverse order."
2496 (interactive (gnus-interactive "P\ny"))
2497 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2499 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2500 "Sort the group buffer alphabetically by backend name.
2501 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2502 sort in reverse order."
2503 (interactive (gnus-interactive "P\ny"))
2504 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2506 ;;; Sorting predicates.
2508 (defun gnus-group-sort-by-alphabet (info1 info2)
2509 "Sort alphabetically."
2510 (string< (gnus-info-group info1) (gnus-info-group info2)))
2512 (defun gnus-group-sort-by-real-name (info1 info2)
2513 "Sort alphabetically on real (unprefixed) names."
2514 (string< (gnus-group-real-name (gnus-info-group info1))
2515 (gnus-group-real-name (gnus-info-group info2))))
2517 (defun gnus-group-sort-by-unread (info1 info2)
2518 "Sort by number of unread articles."
2519 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2520 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2521 (< (or (and (numberp n1) n1) 0)
2522 (or (and (numberp n2) n2) 0))))
2524 (defun gnus-group-sort-by-level (info1 info2)
2526 (< (gnus-info-level info1) (gnus-info-level info2)))
2528 (defun gnus-group-sort-by-method (info1 info2)
2529 "Sort alphabetically by backend name."
2530 (string< (symbol-name (car (gnus-find-method-for-group
2531 (gnus-info-group info1) info1)))
2532 (symbol-name (car (gnus-find-method-for-group
2533 (gnus-info-group info2) info2)))))
2535 (defun gnus-group-sort-by-score (info1 info2)
2536 "Sort by group score."
2537 (< (gnus-info-score info1) (gnus-info-score info2)))
2539 (defun gnus-group-sort-by-rank (info1 info2)
2540 "Sort by level and score."
2541 (let ((level1 (gnus-info-level info1))
2542 (level2 (gnus-info-level info2)))
2543 (or (< level1 level2)
2544 (and (= level1 level2)
2545 (> (gnus-info-score info1) (gnus-info-score info2))))))
2549 (defun gnus-group-clear-data (&optional arg)
2550 "Clear all marks and read ranges from the current group."
2552 (gnus-group-iterate arg
2555 (gnus-info-clear-data (setq info (gnus-get-info group)))
2556 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2557 (when (gnus-group-goto-group group)
2558 (gnus-group-update-group-line))))))
2560 (defun gnus-group-clear-data-on-native-groups ()
2561 "Clear all marks and read ranges from all native groups."
2563 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2564 (let ((alist (cdr gnus-newsrc-alist))
2566 (while (setq info (pop alist))
2567 (when (gnus-group-native-p (gnus-info-group info))
2568 (gnus-info-clear-data info)))
2569 (gnus-get-unread-articles)
2570 (gnus-dribble-touch)
2571 (when (gnus-y-or-n-p
2572 "Move the cache away to avoid problems in the future? ")
2573 (call-interactively 'gnus-cache-move-cache)))))
2575 (defun gnus-info-clear-data (info)
2576 "Clear all marks and read ranges from INFO."
2577 (let ((group (gnus-info-group info)))
2580 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2581 (gnus-info-set-read ',info ',(gnus-info-read info))
2582 (when (gnus-group-goto-group ,group)
2583 (gnus-group-update-group-line))))
2584 (gnus-info-set-read info nil)
2585 (when (gnus-info-marks info)
2586 (gnus-info-set-marks info nil))))
2588 ;; Group catching up.
2590 (defun gnus-group-catchup-current (&optional n all)
2591 "Mark all unread articles in the current newsgroup as read.
2592 If prefix argument N is numeric, the next N newsgroups will be
2593 caught up. If ALL is non-nil, marked articles will also be marked as
2594 read. Cross references (Xref: header) of articles are ignored.
2595 The number of newsgroups that this function was unable to catch
2598 (let ((groups (gnus-group-process-prefix n))
2601 (unless groups (error "No groups selected"))
2603 (or (not gnus-interactive-catchup) ;Without confirmation?
2608 "Do you really want to mark all articles in %s as read? "
2609 "Mark all unread articles in %s as read? ")
2610 (if (= (length groups) 1)
2612 (format "these %d groups" (length groups)))))))
2614 (while (setq group (pop groups))
2615 (gnus-group-remove-mark group)
2616 ;; Virtual groups have to be given special treatment.
2617 (let ((method (gnus-find-method-for-group group)))
2618 (when (eq 'nnvirtual (car method))
2619 (nnvirtual-catchup-group
2620 (gnus-group-real-name group) (nth 1 method) all)))
2621 (if (>= (gnus-group-level group) gnus-level-zombie)
2622 (gnus-message 2 "Dead groups can't be caught up")
2624 (gnus-group-goto-group group)
2625 (gnus-group-catchup group all))
2626 (gnus-group-update-group-line)
2627 (setq ret (1+ ret)))))
2628 (gnus-group-next-unread-group 1)
2631 (defun gnus-group-catchup-current-all (&optional n)
2632 "Mark all articles in current newsgroup as read.
2633 Cross references (Xref: header) of articles are ignored."
2635 (gnus-group-catchup-current n 'all))
2637 (defun gnus-group-catchup (group &optional all)
2638 "Mark all articles in GROUP as read.
2639 If ALL is non-nil, all articles are marked as read.
2640 The return value is the number of articles that were marked as read,
2641 or nil if no action could be taken."
2642 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2644 ;; Remove entries for this group.
2645 (nnmail-purge-split-history (gnus-group-real-name group))
2646 ;; Do the updating only if the newsgroup isn't killed.
2647 (if (not (numberp (car entry)))
2648 (gnus-message 1 "Can't catch up %s; non-active group" group)
2649 ;; Do auto-expirable marks if that's required.
2650 (when (gnus-group-auto-expirable-p group)
2651 (gnus-add-marked-articles
2652 group 'expire (gnus-list-of-unread-articles group))
2654 (let ((marks (nth 3 (nth 2 entry))))
2655 (gnus-add-marked-articles
2656 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2657 (gnus-add-marked-articles
2658 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2660 (gnus-update-read-articles group nil)
2661 ;; Also nix out the lists of marks and dormants.
2663 (gnus-add-marked-articles group 'tick nil nil 'force)
2664 (gnus-add-marked-articles group 'dormant nil nil 'force))
2665 (let ((gnus-newsgroup-name group))
2666 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2669 (defun gnus-group-expire-articles (&optional n)
2670 "Expire all expirable articles in the current newsgroup."
2672 (let ((groups (gnus-group-process-prefix n))
2675 (error "No groups to expire"))
2676 (while (setq group (pop groups))
2677 (gnus-group-remove-mark group)
2678 (gnus-group-expire-articles-1 group)
2679 (gnus-dribble-touch)
2680 (gnus-group-position-point))))
2682 (defun gnus-group-expire-articles-1 (group)
2683 (when (gnus-check-backend-function 'request-expire-articles group)
2684 (gnus-message 6 "Expiring articles in %s..." group)
2685 (let* ((info (gnus-get-info group))
2686 (expirable (if (gnus-group-total-expirable-p group)
2687 (cons nil (gnus-list-of-read-articles group))
2688 (assq 'expire (gnus-info-marks info))))
2689 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2690 (nnmail-expiry-target
2691 (or (gnus-group-find-parameter group 'expiry-target)
2692 nnmail-expiry-target)))
2696 (gnus-compress-sequence
2698 ;; We set the expiry variables to the group
2700 (let ((nnmail-expiry-wait-function nil)
2701 (nnmail-expiry-wait expiry-wait))
2702 (gnus-request-expire-articles
2703 (gnus-uncompress-sequence (cdr expirable)) group))
2704 ;; Just expire using the normal expiry values.
2705 (gnus-request-expire-articles
2706 (gnus-uncompress-sequence (cdr expirable)) group))))
2707 (gnus-close-group group))
2708 (gnus-message 6 "Expiring articles in %s...done" group))))
2710 (defun gnus-group-expire-all-groups ()
2711 "Expire all expirable articles in all newsgroups."
2714 (gnus-message 5 "Expiring...")
2715 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2716 (cdr gnus-newsrc-alist))))
2717 (gnus-group-expire-articles nil)))
2718 (gnus-group-position-point)
2719 (gnus-message 5 "Expiring...done"))
2721 (defun gnus-group-set-current-level (n level)
2722 "Set the level of the next N groups to LEVEL."
2727 (let ((s (read-string
2728 (format "Level (default %s): "
2729 (or (gnus-group-group-level)
2730 gnus-level-default-subscribed)))))
2731 (if (string-match "^\\s-*$" s)
2732 (int-to-string (or (gnus-group-group-level)
2733 gnus-level-default-subscribed))
2735 (unless (and (>= level 1) (<= level gnus-level-killed))
2736 (error "Invalid level: %d" level))
2737 (let ((groups (gnus-group-process-prefix n))
2739 (while (setq group (pop groups))
2740 (gnus-group-remove-mark group)
2741 (gnus-message 6 "Changed level of %s from %d to %d"
2742 group (or (gnus-group-group-level) gnus-level-killed)
2744 (gnus-group-change-level
2745 group level (or (gnus-group-group-level) gnus-level-killed))
2746 (gnus-group-update-group-line)))
2747 (gnus-group-position-point))
2749 (defun gnus-group-unsubscribe (&optional n)
2750 "Unsubscribe the current group."
2752 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2754 (defun gnus-group-subscribe (&optional n)
2755 "Subscribe the current group."
2757 (gnus-group-unsubscribe-current-group n 'subscribe))
2759 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2760 "Toggle subscription of the current group.
2761 If given numerical prefix, toggle the N next groups."
2763 (let ((groups (gnus-group-process-prefix n))
2766 (setq group (car groups)
2767 groups (cdr groups))
2768 (gnus-group-remove-mark group)
2769 (gnus-group-unsubscribe-group
2772 ((eq do-sub 'unsubscribe)
2773 gnus-level-default-unsubscribed)
2774 ((eq do-sub 'subscribe)
2775 gnus-level-default-subscribed)
2776 ((<= (gnus-group-group-level) gnus-level-subscribed)
2777 gnus-level-default-unsubscribed)
2779 gnus-level-default-subscribed))
2781 (gnus-group-update-group-line))
2782 (gnus-group-next-group 1)))
2784 (defun gnus-group-unsubscribe-group (group &optional level silent)
2785 "Toggle subscription to GROUP.
2786 Killed newsgroups are subscribed. If SILENT, don't try to update the
2789 (list (completing-read
2790 "Group: " gnus-active-hashtb nil
2791 (gnus-read-active-file-p)
2793 'gnus-group-history)))
2794 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2796 ((string-match "^[ \t]*$" group)
2797 (error "Empty group name"))
2799 ;; Toggle subscription flag.
2800 (gnus-group-change-level
2801 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2802 gnus-level-subscribed)
2803 (1+ gnus-level-subscribed)
2804 gnus-level-default-subscribed)))
2806 (gnus-group-update-group group)))
2807 ((and (stringp group)
2808 (or (not (gnus-read-active-file-p))
2809 (gnus-active group)))
2810 ;; Add new newsgroup.
2811 (gnus-group-change-level
2813 (if level level gnus-level-default-subscribed)
2814 (or (and (member group gnus-zombie-list)
2817 (when (gnus-group-group-name)
2818 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2820 (gnus-group-update-group group)))
2821 (t (error "No such newsgroup: %s" group)))
2822 (gnus-group-position-point)))
2824 (defun gnus-group-transpose-groups (n)
2825 "Move the current newsgroup up N places.
2826 If given a negative prefix, move down instead. The difference between
2827 N and the number of steps taken is returned."
2829 (unless (gnus-group-group-name)
2830 (error "No group on current line"))
2831 (gnus-group-kill-group 1)
2833 (forward-line (- n))
2834 (gnus-group-yank-group)
2835 (gnus-group-position-point)))
2837 (defun gnus-group-kill-all-zombies (&optional dummy)
2838 "Kill all zombie newsgroups.
2839 The optional DUMMY should always be nil."
2840 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2842 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2843 (setq gnus-zombie-list nil)
2844 (gnus-dribble-touch)
2845 (gnus-group-list-groups)))
2847 (defun gnus-group-kill-region (begin end)
2848 "Kill newsgroups in current region (excluding current point).
2849 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2864 (beginning-of-line) ;Important when LINES < 1
2865 (gnus-group-kill-group lines)))
2867 (defun gnus-group-kill-group (&optional n discard)
2868 "Kill the next N groups.
2869 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2870 However, only groups that were alive can be yanked; already killed
2871 groups or zombie groups can't be yanked.
2872 The return value is the name of the group that was killed, or a list
2875 (let ((buffer-read-only nil)
2876 (groups (gnus-group-process-prefix n))
2877 group entry level out)
2878 (if (< (length groups) 10)
2879 ;; This is faster when there are few groups.
2881 (push (setq group (pop groups)) out)
2882 (gnus-group-remove-mark group)
2883 (setq level (gnus-group-group-level))
2885 (when (and (not discard)
2886 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2889 (gnus-group-goto-group ,(gnus-group-group-name))
2890 (gnus-group-yank-group)))
2891 (push (cons (car entry) (nth 2 entry))
2892 gnus-list-of-killed-groups))
2893 (gnus-group-change-level
2894 (if entry entry group) gnus-level-killed (if entry nil level))
2895 (message "Killed group %s" group))
2896 ;; If there are lots and lots of groups to be killed, we use
2897 ;; this thing instead.
2899 (setq groups (nreverse groups))
2901 (gnus-group-remove-mark (setq group (pop groups)))
2903 (push group gnus-killed-list)
2904 (setq gnus-newsrc-alist
2905 (delq (assoc group gnus-newsrc-alist)
2907 (when gnus-group-change-level-function
2908 (funcall gnus-group-change-level-function
2909 group gnus-level-killed 3))
2911 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2912 (push (cons (car entry) (nth 2 entry))
2913 gnus-list-of-killed-groups)
2914 (setcdr (cdr entry) (cdddr entry)))
2915 ((member group gnus-zombie-list)
2916 (setq gnus-zombie-list (delete group gnus-zombie-list))))
2917 ;; There may be more than one instance displayed.
2918 (while (gnus-group-goto-group group)
2919 (gnus-delete-line)))
2920 (gnus-make-hashtable-from-newsrc-alist)))
2922 (gnus-group-position-point)
2923 (if (< (length out) 2) (car out) (nreverse out))))
2925 (defun gnus-group-yank-group (&optional arg)
2926 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
2927 The numeric ARG specifies how many newsgroups are to be yanked. The
2928 name of the newsgroup yanked is returned, or (if several groups are
2929 yanked) a list of yanked groups is returned."
2931 (setq arg (or arg 1))
2932 (let (info group prev out)
2933 (while (>= (decf arg) 0)
2934 (when (not (setq info (pop gnus-list-of-killed-groups)))
2935 (error "No more newsgroups to yank"))
2936 (push (setq group (nth 1 info)) out)
2937 ;; Find which newsgroup to insert this one before - search
2938 ;; backward until something suitable is found. If there are no
2939 ;; other newsgroups in this buffer, just make this newsgroup the
2941 (setq prev (gnus-group-group-name))
2942 (gnus-group-change-level
2943 info (gnus-info-level (cdr info)) gnus-level-killed
2944 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2946 (gnus-group-insert-group-line-info group)
2948 `(when (gnus-group-goto-group ,group)
2949 (gnus-group-kill-group 1))))
2951 (gnus-group-position-point)
2952 (if (< (length out) 2) (car out) (nreverse out))))
2954 (defun gnus-group-kill-level (level)
2955 "Kill all groups that is on a certain LEVEL."
2956 (interactive "nKill all groups on level: ")
2958 ((= level gnus-level-zombie)
2959 (setq gnus-killed-list
2960 (nconc gnus-zombie-list gnus-killed-list))
2961 (setq gnus-zombie-list nil))
2962 ((and (< level gnus-level-zombie)
2964 (or gnus-expert-user
2967 "Do you really want to kill all groups on level %d? "
2969 (let* ((prev gnus-newsrc-alist)
2972 (if (= (gnus-info-level (car alist)) level)
2974 (push (gnus-info-group (car alist)) gnus-killed-list)
2975 (setcdr prev (cdr alist)))
2977 (setq alist (cdr alist)))
2978 (gnus-make-hashtable-from-newsrc-alist)
2979 (gnus-group-list-groups)))
2981 (error "Can't kill; invalid level: %d" level))))
2983 (defun gnus-group-list-all-groups (&optional arg)
2984 "List all newsgroups with level ARG or lower.
2985 Default is gnus-level-unsubscribed, which lists all subscribed and most
2986 unsubscribed groups."
2988 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2990 ;; Redefine this to list ALL killed groups if prefix arg used.
2991 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2992 (defun gnus-group-list-killed (&optional arg)
2993 "List all killed newsgroups in the group buffer.
2994 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2995 entail asking the server for the groups."
2997 ;; Find all possible killed newsgroups if arg.
2999 (gnus-get-killed-groups))
3000 (if (not gnus-killed-list)
3001 (gnus-message 6 "No killed groups")
3002 (let (gnus-group-list-mode)
3003 (funcall gnus-group-prepare-function
3004 gnus-level-killed t gnus-level-killed))
3005 (goto-char (point-min)))
3006 (gnus-group-position-point))
3008 (defun gnus-group-list-zombies ()
3009 "List all zombie newsgroups in the group buffer."
3011 (if (not gnus-zombie-list)
3012 (gnus-message 6 "No zombie groups")
3013 (let (gnus-group-list-mode)
3014 (funcall gnus-group-prepare-function
3015 gnus-level-zombie t gnus-level-zombie))
3016 (goto-char (point-min)))
3017 (gnus-group-position-point))
3019 (defun gnus-group-list-active ()
3020 "List all groups that are available from the server(s)."
3022 ;; First we make sure that we have really read the active file.
3023 (unless (gnus-read-active-file-p)
3024 (let ((gnus-read-active-file t)
3025 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3026 (gnus-read-active-file)))
3027 ;; Find all groups and sort them.
3035 (push (symbol-name sym) list)))
3039 (buffer-read-only nil)
3043 (gnus-add-text-properties
3044 (point) (prog1 (1+ (point))
3046 (setq group (pop groups)) "\n"))
3047 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3049 'gnus-level (inline (gnus-group-level group)))))
3050 (goto-char (point-min))))
3052 (defun gnus-activate-all-groups (level)
3053 "Activate absolutely all groups."
3054 (interactive (list gnus-level-unsubscribed))
3055 (let ((gnus-activate-level level)
3056 (gnus-activate-foreign-newsgroups level))
3057 (gnus-group-get-new-news)))
3059 (defun gnus-group-get-new-news (&optional arg)
3060 "Get newly arrived articles.
3061 If ARG is a number, it specifies which levels you are interested in
3062 re-scanning. If ARG is non-nil and not a number, this will force
3063 \"hard\" re-reading of the active files from all servers."
3066 (let ((gnus-inhibit-demon t)
3067 ;; Binding this variable will inhibit multiple fetchings
3068 ;; of the same mail source.
3069 (nnmail-fetched-sources (list t)))
3070 (gnus-run-hooks 'gnus-get-new-news-hook)
3072 ;; Read any slave files.
3074 (gnus-master-read-slave-newsrc))
3076 ;; We might read in new NoCeM messages here.
3077 (when (and gnus-use-nocem
3079 (gnus-nocem-scan-groups))
3080 ;; If ARG is not a number, then we read the active file.
3081 (when (and arg (not (numberp arg)))
3082 (let ((gnus-read-active-file t))
3083 (gnus-read-active-file))
3086 ;; If the user wants it, we scan for new groups.
3087 (when (eq gnus-check-new-newsgroups 'always)
3088 (gnus-find-new-newsgroups)))
3090 (setq arg (gnus-group-default-level arg t))
3091 (if (and gnus-read-active-file (not arg))
3093 (gnus-read-active-file)
3094 (gnus-get-unread-articles arg))
3095 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3096 (gnus-get-unread-articles arg)))
3097 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3098 (gnus-group-list-groups (and (numberp arg)
3099 (max (car gnus-group-list-mode) arg)))))
3101 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3102 "Check for newly arrived news in the current group (and the N-1 next groups).
3103 The difference between N and the number of newsgroup checked is returned.
3104 If N is negative, this group and the N-1 previous groups will be checked."
3106 (let* ((groups (gnus-group-process-prefix n))
3107 (ret (if (numberp n) (- n (length groups)) 0))
3111 (gnus-inhibit-demon t)
3112 ;; Binding this variable will inhibit multiple fetchings
3113 ;; of the same mail source.
3114 (nnmail-fetched-sources (list t)))
3115 (gnus-run-hooks 'gnus-get-new-news-hook)
3116 (while (setq group (pop groups))
3117 (gnus-group-remove-mark group)
3118 ;; Bypass any previous denials from the server.
3119 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3120 (if (gnus-activate-group group (if dont-scan nil 'scan))
3122 (gnus-get-unread-articles-in-group
3123 (gnus-get-info group) (gnus-active group) t)
3124 (unless (gnus-virtual-group-p group)
3125 (gnus-close-group group))
3127 (gnus-agent-save-group-info
3128 method (gnus-group-real-name group) (gnus-active group)))
3129 (gnus-group-update-group group))
3130 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3132 (gnus-error 3 "Server denied access")
3133 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3136 (when gnus-goto-next-group-when-activating
3137 (gnus-group-next-unread-group 1 t))
3138 (gnus-summary-position-point)
3141 (defun gnus-group-fetch-faq (group &optional faq-dir)
3142 "Fetch the FAQ for the current group.
3143 If given a prefix argument, prompt for the FAQ dir
3147 (gnus-group-group-name)
3148 (when current-prefix-arg
3150 "Faq dir: " (and (listp gnus-group-faq-directory)
3151 (mapcar (lambda (file) (list file))
3152 gnus-group-faq-directory))))))
3154 (error "No group name given"))
3155 (let ((dirs (or faq-dir gnus-group-faq-directory))
3157 (unless (listp dirs)
3158 (setq dirs (list dirs)))
3159 (while (and (not found)
3160 (setq dir (pop dirs)))
3161 (let ((name (gnus-group-real-name group)))
3162 (setq file (concat (file-name-as-directory dir) name)))
3163 (if (not (file-exists-p file))
3164 (gnus-message 1 "No such file: %s" file)
3165 (let ((enable-local-variables nil))
3169 (defun gnus-group-describe-group (force &optional group)
3170 "Display a description of the current newsgroup."
3171 (interactive (list current-prefix-arg (gnus-group-group-name)))
3172 (let* ((method (gnus-find-method-for-group group))
3173 (mname (gnus-group-prefixed-name "" method))
3176 gnus-description-hashtb)
3177 (gnus-sethash mname nil gnus-description-hashtb))
3179 (error "No group name given"))
3180 (when (or (and gnus-description-hashtb
3181 ;; We check whether this group's method has been
3182 ;; queried for a description file.
3183 (gnus-gethash mname gnus-description-hashtb))
3184 (setq desc (gnus-group-get-description group))
3185 (gnus-read-descriptions-file method))
3187 (or desc (gnus-gethash group gnus-description-hashtb)
3188 "No description available")))))
3190 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3191 (defun gnus-group-describe-all-groups (&optional force)
3192 "Pop up a buffer with descriptions of all newsgroups."
3195 (setq gnus-description-hashtb nil))
3196 (when (not (or gnus-description-hashtb
3197 (gnus-read-all-descriptions-files)))
3198 (error "Couldn't request descriptions file"))
3199 (let ((buffer-read-only nil)
3205 (insert (format " *: %-20s %s\n" (symbol-name group)
3206 (symbol-value group)))
3207 (gnus-add-text-properties
3208 b (1+ b) (list 'gnus-group group
3209 'gnus-unread t 'gnus-marked nil
3210 'gnus-level (1+ gnus-level-subscribed))))
3211 gnus-description-hashtb)
3212 (goto-char (point-min))
3213 (gnus-group-position-point)))
3215 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3216 (defun gnus-group-apropos (regexp &optional search-description)
3217 "List all newsgroups that have names that match a regexp."
3218 (interactive "sGnus apropos (regexp): ")
3220 (obuf (current-buffer))
3222 ;; Go through all newsgroups that are known to Gnus.
3225 (and (symbol-name group)
3226 (string-match regexp (symbol-name group))
3227 (symbol-value group)
3228 (push (symbol-name group) groups)))
3230 ;; Also go through all descriptions that are known to Gnus.
3231 (when search-description
3234 (and (string-match regexp (symbol-value group))
3235 (push (symbol-name group) groups)))
3236 gnus-description-hashtb))
3238 (gnus-message 3 "No groups matched \"%s\"." regexp)
3239 ;; Print out all the groups.
3241 (pop-to-buffer "*Gnus Help*")
3242 (buffer-disable-undo)
3244 (setq groups (sort groups 'string<))
3246 ;; Groups may be entered twice into the list of groups.
3247 (when (not (string= (car groups) prev))
3248 (insert (setq prev (car groups)) "\n")
3249 (when (and gnus-description-hashtb
3250 (setq des (gnus-gethash (car groups)
3251 gnus-description-hashtb)))
3252 (insert " " des "\n")))
3253 (setq groups (cdr groups)))
3254 (goto-char (point-min))))
3255 (pop-to-buffer obuf)))
3257 (defun gnus-group-description-apropos (regexp)
3258 "List all newsgroups that have names or descriptions that match a regexp."
3259 (interactive "sGnus description apropos (regexp): ")
3260 (when (not (or gnus-description-hashtb
3261 (gnus-read-all-descriptions-files)))
3262 (error "Couldn't request descriptions file"))
3263 (gnus-group-apropos regexp t))
3265 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3266 (defun gnus-group-list-matching (level regexp &optional all lowest)
3267 "List all groups with unread articles that match REGEXP.
3268 If the prefix LEVEL is non-nil, it should be a number that says which
3269 level to cut off listing groups.
3270 If ALL, also list groups with no unread articles.
3271 If LOWEST, don't list groups with level lower than LOWEST.
3273 This command may read the active file."
3274 (interactive "P\nsList newsgroups matching: ")
3275 ;; First make sure active file has been read.
3277 (> (prefix-numeric-value level) gnus-level-killed))
3278 (gnus-get-killed-groups))
3279 (gnus-group-prepare-flat
3280 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3281 (goto-char (point-min))
3282 (gnus-group-position-point))
3284 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3285 "List all groups that match REGEXP.
3286 If the prefix LEVEL is non-nil, it should be a number that says which
3287 level to cut off listing groups.
3288 If LOWEST, don't list groups with level lower than LOWEST."
3289 (interactive "P\nsList newsgroups matching: ")
3291 (setq level (prefix-numeric-value level)))
3292 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3294 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3295 (defun gnus-group-save-newsrc (&optional force)
3296 "Save the Gnus startup files.
3297 If FORCE, force saving whether it is necessary or not."
3299 (gnus-save-newsrc-file force))
3301 (defun gnus-group-restart (&optional arg)
3302 "Force Gnus to read the .newsrc file."
3304 (when (gnus-yes-or-no-p
3305 (format "Are you sure you want to restart Gnus? "))
3306 (gnus-save-newsrc-file)
3310 (defun gnus-group-read-init-file ()
3311 "Read the Gnus elisp init file."
3313 (gnus-read-init-file)
3314 (gnus-message 5 "Read %s" gnus-init-file))
3316 (defun gnus-group-check-bogus-groups (&optional silent)
3317 "Check bogus newsgroups.
3318 If given a prefix, don't ask for confirmation before removing a bogus
3321 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3322 (gnus-group-list-groups))
3324 (defun gnus-group-find-new-groups (&optional arg)
3325 "Search for new groups and add them.
3326 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3327 With 1 C-u, use the `ask-server' method to query the server for new
3329 With 2 C-u's, use most complete method possible to query the server
3330 for new groups, and subscribe the new groups as zombies."
3332 (gnus-find-new-newsgroups (or arg 1))
3333 (gnus-group-list-groups))
3335 (defun gnus-group-edit-global-kill (&optional article group)
3336 "Edit the global kill file.
3337 If GROUP, edit that local kill file instead."
3339 (setq gnus-current-kill-article article)
3340 (gnus-kill-file-edit-file group)
3343 (substitute-command-keys
3344 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3345 (if group "local" "global")))))
3347 (defun gnus-group-edit-local-kill (article group)
3348 "Edit a local kill file."
3349 (interactive (list nil (gnus-group-group-name)))
3350 (gnus-group-edit-global-kill article group))
3352 (defun gnus-group-force-update ()
3353 "Update `.newsrc' file."
3355 (gnus-save-newsrc-file))
3357 (defun gnus-group-suspend ()
3358 "Suspend the current Gnus session.
3359 In fact, cleanup buffers except for group mode buffer.
3360 The hook gnus-suspend-gnus-hook is called before actually suspending."
3362 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3363 ;; Kill Gnus buffers except for group mode buffer.
3364 (let ((group-buf (get-buffer gnus-group-buffer)))
3365 (mapcar (lambda (buf)
3366 (unless (member buf (list group-buf gnus-dribble-buffer))
3369 (gnus-kill-gnus-frames)
3371 (bury-buffer group-buf)
3372 (delete-windows-on group-buf t))))
3374 (defun gnus-group-clear-dribble ()
3375 "Clear all information from the dribble buffer."
3377 (gnus-dribble-clear)
3378 (gnus-message 7 "Cleared dribble buffer"))
3380 (defun gnus-group-exit ()
3381 "Quit reading news after updating .newsrc.eld and .newsrc.
3382 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3385 (or noninteractive ;For gnus-batch-kill
3386 (not gnus-interactive-exit) ;Without confirmation
3388 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3389 (gnus-run-hooks 'gnus-exit-gnus-hook)
3390 ;; Offer to save data from non-quitted summary buffers.
3391 (gnus-offer-save-summaries)
3392 ;; Save the newsrc file(s).
3393 (gnus-save-newsrc-file)
3395 (gnus-close-backends)
3396 ;; Reset everything.
3398 ;; Allow the user to do things after cleaning up.
3399 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3401 (defun gnus-group-quit ()
3402 "Quit reading news without updating .newsrc.eld or .newsrc.
3403 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3405 (when (or noninteractive ;For gnus-batch-kill
3406 (zerop (buffer-size))
3407 (not (gnus-server-opened gnus-select-method))
3409 (not gnus-current-startup-file)
3411 (format "Quit reading news without saving %s? "
3412 (file-name-nondirectory gnus-current-startup-file))))
3413 (gnus-run-hooks 'gnus-exit-gnus-hook)
3414 (gnus-configure-windows 'group t)
3416 (gnus-close-backends)
3418 (gnus-kill-buffer gnus-group-buffer)
3419 ;; Allow the user to do things after cleaning up.
3420 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3422 (defun gnus-group-describe-briefly ()
3423 "Give a one line description of the group mode commands."
3425 (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")))
3427 (defun gnus-group-browse-foreign-server (method)
3428 "Browse a foreign news server.
3429 If called interactively, this function will ask for a select method
3430 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3431 If not, METHOD should be a list where the first element is the method
3432 and the second element is the address."
3434 (list (let ((how (completing-read
3436 (append gnus-valid-select-methods gnus-server-alist)
3437 nil t (cons "nntp" 0) 'gnus-method-history)))
3438 ;; We either got a backend name or a virtual server name.
3439 ;; If the first, we also need an address.
3440 (if (assoc how gnus-valid-select-methods)
3442 ;; Suggested by mapjph@bath.ac.uk.
3445 (mapcar (lambda (server) (list server))
3446 gnus-secondary-servers)))
3447 ;; We got a server name.
3449 (gnus-browse-foreign-server method))
3451 (defun gnus-group-set-info (info &optional method-only-group part)
3452 (when (or info part)
3453 (let* ((entry (gnus-gethash
3454 (or method-only-group (gnus-info-group info))
3455 gnus-newsrc-hashtb))
3457 (info (if method-only-group (nth 2 entry) info))
3459 (when method-only-group
3461 (error "Trying to change non-existent group %s" method-only-group))
3462 ;; We have received parts of the actual group info - either the
3463 ;; select method or the group parameters. We first check
3464 ;; whether we have to extend the info, and if so, do that.
3465 (let ((len (length info))
3466 (total (if (eq part 'method) 5 6)))
3468 (setcdr (nthcdr (1- len) info)
3469 (make-list (- total len) nil)))
3470 ;; Then we enter the new info.
3471 (setcar (nthcdr (1- total) info) part-info)))
3473 ;; This is a new group, so we just create it.
3475 (set-buffer gnus-group-buffer)
3476 (setq method (gnus-info-method info))
3477 (when (gnus-server-equal method "native")
3480 (set-buffer gnus-group-buffer)
3482 ;; It's a foreign group...
3483 (gnus-group-make-group
3484 (gnus-group-real-name (gnus-info-group info))
3485 (if (stringp method) method
3486 (prin1-to-string (car method)))
3488 (nth 1 (gnus-info-method info))))
3489 ;; It's a native group.
3490 (gnus-group-make-group (gnus-info-group info))))
3491 (gnus-message 6 "Note: New group created")
3493 (gnus-gethash (gnus-group-prefixed-name
3494 (gnus-group-real-name (gnus-info-group info))
3495 (or (gnus-info-method info) gnus-select-method))
3496 gnus-newsrc-hashtb))))
3497 ;; Whether it was a new group or not, we now have the entry, so we
3498 ;; can do the update.
3501 (setcar (nthcdr 2 entry) info)
3502 (when (and (not (eq (car entry) t))
3503 (gnus-active (gnus-info-group info)))
3504 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3505 (error "No such group: %s" (gnus-info-group info))))))
3507 (defun gnus-group-set-method-info (group select-method)
3508 (gnus-group-set-info select-method group 'method))
3510 (defun gnus-group-set-params-info (group params)
3511 (gnus-group-set-info params group 'params))
3513 (defun gnus-add-marked-articles (group type articles &optional info force)
3514 ;; Add ARTICLES of TYPE to the info of GROUP.
3515 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3516 ;; add, but replace marked articles of TYPE with ARTICLES.
3517 (let ((info (or info (gnus-get-info group)))
3520 (and (not (setq marked (nthcdr 3 info)))
3522 (setcdr (nthcdr 2 info)
3523 (list (list (cons type (gnus-compress-sequence
3525 (and (not (setq m (assq type (car marked))))
3528 (cons (cons type (gnus-compress-sequence articles t) )
3532 (setcar (nthcdr 3 info)
3533 (gnus-delete-alist type (car marked)))
3534 (setcdr m (gnus-compress-sequence articles t)))
3535 (setcdr m (gnus-compress-sequence
3536 (sort (nconc (gnus-uncompress-range (cdr m))
3537 (copy-sequence articles)) '<) t))))))
3540 ;;; Group timestamps
3543 (defun gnus-group-set-timestamp ()
3544 "Change the timestamp of the current group to the current time.
3545 This function can be used in hooks like `gnus-select-group-hook'
3546 or `gnus-group-catchup-group-hook'."
3547 (when gnus-newsgroup-name
3548 (let ((time (current-time)))
3549 (setcdr (cdr time) nil)
3550 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3552 (defsubst gnus-group-timestamp (group)
3553 "Return the timestamp for GROUP."
3554 (gnus-group-get-parameter group 'timestamp t))
3556 (defun gnus-group-timestamp-delta (group)
3557 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3558 (let* ((time (or (gnus-group-timestamp group)
3560 (delta (subtract-time (current-time) time)))
3561 (+ (* (nth 0 delta) 65536.0)
3564 (defun gnus-group-timestamp-string (group)
3565 "Return a string of the timestamp for GROUP."
3566 (let ((time (gnus-group-timestamp group)))
3569 (gnus-time-iso8601 time))))
3571 (defun gnus-group-prepare-flat-list-dead-predicate
3572 (groups level mark predicate)
3575 ;; This loop is used when listing groups that match some
3577 (while (setq group (pop groups))
3578 (when (funcall predicate group)
3579 (gnus-add-text-properties
3580 (point) (prog1 (1+ (point))
3581 (insert " " mark " *: " group "\n"))
3582 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3584 'gnus-level level)))))))
3586 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest
3588 "List all newsgroups with unread articles of level LEVEL or lower.
3589 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3590 If PREDICATE, only list groups which PREDICATE returns non-nil.
3591 If DEAD-PREDICATE, list dead groups which DEAD-PREDICATE returns non-nil."
3592 (set-buffer gnus-group-buffer)
3593 (let ((buffer-read-only nil)
3594 (newsrc (cdr gnus-newsrc-alist))
3595 (lowest (or lowest 1))
3596 info clevel unread group params)
3598 ;; List living groups.
3600 (setq info (car newsrc)
3601 group (gnus-info-group info)
3602 params (gnus-info-params info)
3604 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3605 (and unread ; This group might be unchecked
3606 (funcall predicate info)
3607 (<= (setq clevel (gnus-info-level info)) level)
3609 (gnus-group-insert-group-line
3610 group (gnus-info-level info)
3611 (gnus-info-marks info) unread (gnus-info-method info))))
3613 ;; List dead groups.
3614 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3615 (gnus-group-prepare-flat-list-dead-predicate
3616 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3617 gnus-level-zombie ?Z
3619 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3620 (gnus-group-prepare-flat-list-dead-predicate
3621 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3622 gnus-level-killed ?K dead-predicate))
3624 (gnus-group-set-mode-line)
3625 (setq gnus-group-list-mode (cons level t))
3626 (gnus-run-hooks 'gnus-group-prepare-hook)
3629 (defun gnus-group-list-cached (level &optional lowest)
3630 "List all groups with cached articles.
3631 If the prefix LEVEL is non-nil, it should be a number that says which
3632 level to cut off listing groups.
3633 If LOWEST, don't list groups with level lower than LOWEST.
3635 This command may read the active file."
3638 (setq level (prefix-numeric-value level)))
3639 (when (or (not level) (>= level gnus-level-zombie))
3641 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3643 (let ((marks (gnus-info-marks info)))
3644 (assq 'cache marks)))
3647 (or (gnus-gethash group
3648 gnus-cache-active-hashtb)
3649 ;; Cache active file might use "."
3652 (subst-char-in-string ?: ?. group)
3653 gnus-cache-active-hashtb))))
3654 (goto-char (point-min))
3655 (gnus-group-position-point))
3657 (provide 'gnus-group)
3659 ;;; gnus-group.el ends here