1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
37 (defgroup gnus-group nil
41 (defcustom gnus-group-archive-directory
42 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
43 "*The address of the (ding) archives."
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."
53 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
54 (defcustom gnus-no-groups-message "No news is horrible news"
55 "*Message displayed by Gnus when no groups are available."
59 (defcustom gnus-keep-same-level nil
60 "*Non-nil means that the next newsgroup after the current will be on the same level.
61 When you type, for instance, `n' after reading the last article in the
62 current newsgroup, you will go to the next newsgroup. If this variable
63 is nil, the next newsgroup will be the next from the group
65 If this variable is non-nil, Gnus will either put you in the
66 next newsgroup with the same level, or, if no such newsgroup is
67 available, the next newsgroup with the lowest possible level higher
68 than the current level.
69 If this variable is `best', Gnus will make the next newsgroup the one
72 :type '(choice (const nil)
74 (sexp :tag "other" t)))
76 (defcustom gnus-group-goto-unread t
77 "*If non-nil, movement commands will go to the next unread and subscribed group."
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."
86 (defcustom gnus-permanently-visible-groups nil
87 "*Regexp to match groups that should always be listed in the group buffer.
88 This means that they will still be listed when there are no unread
89 articles in the groups."
93 (defcustom gnus-list-groups-with-ticked-articles t
94 "*If non-nil, list groups that have only ticked articles.
95 If nil, only list groups that have unread articles."
99 (defcustom gnus-group-default-list-level gnus-level-subscribed
100 "*Default listing level.
101 Ignored if `gnus-group-use-permanent-levels' is non-nil."
105 (defcustom gnus-group-list-inactive-groups t
106 "*If non-nil, inactive groups will be listed."
110 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
111 "*Function used for sorting the group buffer.
112 This function will be called with group info entries as the arguments
113 for the groups to be sorted. Pre-made functions include
114 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
115 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
116 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
117 `gnus-group-sort-by-rank'.
119 This variable can also be a list of sorting functions. In that case,
120 the most significant sort function should be the last function in the
123 :type '(radio (function-item gnus-group-sort-by-alphabet)
124 (function-item gnus-group-sort-by-real-name)
125 (function-item gnus-group-sort-by-unread)
126 (function-item gnus-group-sort-by-level)
127 (function-item gnus-group-sort-by-score)
128 (function-item gnus-group-sort-by-method)
129 (function-item gnus-group-sort-by-rank)
130 (function :tag "other" nil)))
132 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
133 "*Format of group lines.
134 It works along the same lines as a normal formatting string,
135 with some simple extensions.
137 %M Only marked articles (character, \"*\" or \" \")
138 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
139 %L Level of subscribedness (integer)
140 %N Number of unread articles (integer)
141 %I Number of dormant articles (integer)
142 %i Number of ticked and dormant (integer)
143 %T Number of ticked articles (integer)
144 %R Number of read articles (integer)
145 %t Estimated total number of articles (integer)
146 %y Number of unread, unticked articles (integer)
147 %G Group name (string)
148 %g Qualified group name (string)
149 %D Group description (string)
150 %s Select method (string)
151 %o Moderated group (char, \"m\")
152 %p Process mark (char)
153 %O Moderated group (string, \"(m)\" or \"\")
154 %P Topic indentation (string)
155 %m Whether there is new(ish) mail in the group (char, \"%\")
156 %l Whether there are GroupLens predictions for this group (string)
157 %n Select from where (string)
158 %z A string that look like `<%s:%n>' if a foreign select method is used
159 ?d The date the group was last entered.
160 %u User defined specifier. The next character in the format string should
161 be a letter. Gnus will call the function gnus-user-format-function-X,
162 where X is the letter following %u. The function will be passed the
163 current header as argument. The function should return a string, which
164 will be inserted into the buffer just like information from any other
167 Text between %( and %) will be highlighted with `gnus-mouse-face' when
168 the mouse point move inside the area. There can only be one such area.
170 Note that this format specification is not always respected. For
171 reasons of efficiency, when listing killed groups, this specification
172 is ignored altogether. If the spec is changed considerably, your
173 output may end up looking strange when listing both alive and killed
176 If you use %o or %O, reading the active file will be slower and quite
177 a bit of extra memory will be used. %D will also worsen performance.
178 Also note that if you change the format specification to include any
179 of these specs, you must probably re-start Gnus to see them go into
184 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
185 "*The format specification for the group mode line.
186 It works along the same lines as a normal formatting string,
187 with some simple extensions:
189 %S The native news server.
190 %M The native select method.
191 %: \":\" if %S isn't \"\"."
195 (defcustom gnus-group-mode-hook nil
196 "Hook for Gnus group mode."
200 (defcustom gnus-group-menu-hook nil
201 "Hook run after the creation of the group mode menu."
205 (defcustom gnus-group-catchup-group-hook nil
206 "Hook run when catching up a group from the group buffer."
210 (defcustom gnus-group-update-group-hook nil
211 "Hook called when updating group lines."
215 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
216 "*A function that is called to generate the group buffer.
217 The function is called with three arguments: The first is a number;
218 all group with a level less or equal to that number should be listed,
219 if the second is non-nil, empty groups should also be displayed. If
220 the third is non-nil, it is a number. No groups with a level lower
221 than this number should be displayed.
223 The only current function implemented is `gnus-group-prepare-flat'."
227 (defcustom gnus-group-prepare-hook nil
228 "Hook called after the group buffer has been generated.
229 If you want to modify the group buffer, you can use this hook."
233 (defcustom gnus-suspend-gnus-hook nil
234 "Hook called when suspending (not exiting) Gnus."
238 (defcustom gnus-exit-gnus-hook nil
239 "Hook called when exiting Gnus."
243 (defcustom gnus-after-exiting-gnus-hook nil
244 "Hook called after exiting Gnus."
248 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
249 "Hook called when a group line is changed.
250 The hook will not be called if `gnus-visual' is nil.
252 The default function `gnus-group-highlight-line' will
253 highlight the line according to the `gnus-group-highlight'
258 (defcustom gnus-useful-groups
259 `(("(ding) mailing list mirrored at sunsite.auc.dk"
261 (nntp "sunsite.auc.dk"
262 (nntp-address "sunsite.auc.dk")))
266 (nndoc-article-type mbox)
267 (eval `(nndoc-address
268 ,(let ((file (nnheader-find-etc-directory
271 (error "Couldn't find doc group"))
273 "Alist of useful group-server pairs."
275 :type '(repeat (list (string :tag "Description")
277 (sexp :tag "Method"))))
279 (defface gnus-group-news-1-face
282 (:foreground "PaleTurquoise" :bold t))
285 (:foreground "ForestGreen" :bold t))
288 "Level 1 newsgroup face.")
290 (defface gnus-group-news-1-empty-face
293 (:foreground "PaleTurquoise"))
296 (:foreground "ForestGreen"))
299 "Level 1 empty newsgroup face.")
301 (defface gnus-group-news-2-face
304 (:foreground "turquoise" :bold t))
307 (:foreground "CadetBlue4" :bold t))
310 "Level 2 newsgroup face.")
312 (defface gnus-group-news-2-empty-face
315 (:foreground "turquoise"))
318 (:foreground "CadetBlue4"))
321 "Level 2 empty newsgroup face.")
323 (defface gnus-group-news-3-face
332 "Level 3 newsgroup face.")
334 (defface gnus-group-news-3-empty-face
343 "Level 3 empty newsgroup face.")
345 (defface gnus-group-news-low-face
348 (:foreground "DarkTurquoise" :bold t))
351 (:foreground "DarkGreen" :bold t))
354 "Low level newsgroup face.")
356 (defface gnus-group-news-low-empty-face
359 (:foreground "DarkTurquoise"))
362 (:foreground "DarkGreen"))
365 "Low level empty newsgroup face.")
367 (defface gnus-group-mail-1-face
370 (:foreground "aquamarine1" :bold t))
373 (:foreground "DeepPink3" :bold t))
376 "Level 1 mailgroup face.")
378 (defface gnus-group-mail-1-empty-face
381 (:foreground "aquamarine1"))
384 (:foreground "DeepPink3"))
386 (:italic t :bold t)))
387 "Level 1 empty mailgroup face.")
389 (defface gnus-group-mail-2-face
392 (:foreground "aquamarine2" :bold t))
395 (:foreground "HotPink3" :bold t))
398 "Level 2 mailgroup face.")
400 (defface gnus-group-mail-2-empty-face
403 (:foreground "aquamarine2"))
406 (:foreground "HotPink3"))
409 "Level 2 empty mailgroup face.")
411 (defface gnus-group-mail-3-face
414 (:foreground "aquamarine3" :bold t))
417 (:foreground "magenta4" :bold t))
420 "Level 3 mailgroup face.")
422 (defface gnus-group-mail-3-empty-face
425 (:foreground "aquamarine3"))
428 (:foreground "magenta4"))
431 "Level 3 empty mailgroup face.")
433 (defface gnus-group-mail-low-face
436 (:foreground "aquamarine4" :bold t))
439 (:foreground "DeepPink4" :bold t))
442 "Low level mailgroup face.")
444 (defface gnus-group-mail-low-empty-face
447 (:foreground "aquamarine4"))
450 (:foreground "DeepPink4"))
453 "Low level empty mailgroup face.")
455 (defcustom gnus-group-highlight
457 ((and (= unread 0) (not mailp) (eq level 1)) .
458 gnus-group-news-1-empty-face)
459 ((and (not mailp) (eq level 1)) .
460 gnus-group-news-1-face)
461 ((and (= unread 0) (not mailp) (eq level 2)) .
462 gnus-group-news-2-empty-face)
463 ((and (not mailp) (eq level 2)) .
464 gnus-group-news-2-face)
465 ((and (= unread 0) (not mailp) (eq level 3)) .
466 gnus-group-news-3-empty-face)
467 ((and (not mailp) (eq level 3)) .
468 gnus-group-news-3-face)
469 ((and (= unread 0) (not mailp)) .
470 gnus-group-news-low-empty-face)
472 gnus-group-news-low-face)
474 ((and (= unread 0) (eq level 1)) .
475 gnus-group-mail-1-empty-face)
477 gnus-group-mail-1-face)
478 ((and (= unread 0) (eq level 2)) .
479 gnus-group-mail-2-empty-face)
481 gnus-group-mail-2-face)
482 ((and (= unread 0) (eq level 3)) .
483 gnus-group-mail-3-empty-face)
485 gnus-group-mail-3-face)
487 gnus-group-mail-low-empty-face)
489 gnus-group-mail-low-face))
490 "Controls the highlighting of group buffer lines.
492 Below is a list of `Form'/`Face' pairs. When deciding how a a
493 particular group line should be displayed, each form is
494 evaluated. The content of the face field after the first true form is
495 used. You can change how those group lines are displayed by
496 editing the face field.
498 It is also possible to change and add form fields, but currently that
499 requires an understanding of Lisp expressions. Hopefully this will
500 change in a future release. For now, you can use the following
501 variables in the Lisp expression:
503 group: The name of the group.
504 unread: The number of unread articles in the group.
505 method: The select method used.
506 mailp: Whether it's a mail group or not.
507 level: The level of the group.
508 score: The score of the group.
509 ticked: The number of ticked articles."
511 :type '(repeat (cons (sexp :tag "Form") face)))
513 (defcustom gnus-new-mail-mark ?%
514 "Mark used for groups with new mail."
518 ;;; Internal variables
520 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
521 "Function for sorting the group buffer.")
523 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
524 "Function for sorting the selected groups in the group buffer.")
526 (defvar gnus-group-indentation-function nil)
527 (defvar gnus-goto-missing-group-function nil)
528 (defvar gnus-group-update-group-function nil)
529 (defvar gnus-group-goto-next-group-function nil
530 "Function to override finding the next group after listing groups.")
532 (defvar gnus-group-edit-buffer nil)
534 (defvar gnus-group-line-format-alist
535 `((?M gnus-tmp-marked-mark ?c)
536 (?S gnus-tmp-subscribed ?c)
537 (?L gnus-tmp-level ?d)
538 (?N (cond ((eq number t) "*" )
542 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
543 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
545 (?R gnus-tmp-number-of-read ?s)
546 (?t gnus-tmp-number-total ?d)
547 (?y gnus-tmp-number-of-unread ?s)
548 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
549 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
550 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
551 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
552 (?g gnus-tmp-group ?s)
553 (?G gnus-tmp-qualified-group ?s)
554 (?c (gnus-short-group-name gnus-tmp-group) ?s)
555 (?D gnus-tmp-newsgroup-description ?s)
556 (?o gnus-tmp-moderated ?c)
557 (?O gnus-tmp-moderated-string ?s)
558 (?p gnus-tmp-process-marked ?c)
559 (?s gnus-tmp-news-server ?s)
560 (?n gnus-tmp-news-method ?s)
561 (?P gnus-group-indentation ?s)
562 (?l gnus-tmp-grouplens ?s)
563 (?z gnus-tmp-news-method-string ?s)
564 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
565 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
566 (?u gnus-tmp-user-defined ?s)))
568 (defvar gnus-group-mode-line-format-alist
569 `((?S gnus-tmp-news-server ?s)
570 (?M gnus-tmp-news-method ?s)
571 (?u gnus-tmp-user-defined ?s)
572 (?: gnus-tmp-colon ?s)))
574 (defvar gnus-topic-topology nil
575 "The complete topic hierarchy.")
577 (defvar gnus-topic-alist nil
578 "The complete topic-group alist.")
580 (defvar gnus-group-marked nil)
582 (defvar gnus-group-list-mode nil)
588 (put 'gnus-group-mode 'mode-class 'special)
591 (gnus-define-keys gnus-group-mode-map
592 " " gnus-group-read-group
593 "=" gnus-group-select-group
594 "\r" gnus-group-select-group
595 "\M-\r" gnus-group-quick-select-group
596 "j" gnus-group-jump-to-group
597 "n" gnus-group-next-unread-group
598 "p" gnus-group-prev-unread-group
599 "\177" gnus-group-prev-unread-group
600 [delete] gnus-group-prev-unread-group
601 "N" gnus-group-next-group
602 "P" gnus-group-prev-group
603 "\M-n" gnus-group-next-unread-group-same-level
604 "\M-p" gnus-group-prev-unread-group-same-level
605 "," gnus-group-best-unread-group
606 "." gnus-group-first-unread-group
607 "u" gnus-group-unsubscribe-current-group
608 "U" gnus-group-unsubscribe-group
609 "c" gnus-group-catchup-current
610 "C" gnus-group-catchup-current-all
611 "\M-c" gnus-group-clear-data
612 "l" gnus-group-list-groups
613 "L" gnus-group-list-all-groups
615 "g" gnus-group-get-new-news
616 "\M-g" gnus-group-get-new-news-this-group
617 "R" gnus-group-restart
618 "r" gnus-group-read-init-file
619 "B" gnus-group-browse-foreign-server
620 "b" gnus-group-check-bogus-groups
621 "F" gnus-find-new-newsgroups
622 "\C-c\C-d" gnus-group-describe-group
623 "\M-d" gnus-group-describe-all-groups
624 "\C-c\C-a" gnus-group-apropos
625 "\C-c\M-\C-a" gnus-group-description-apropos
626 "a" gnus-group-post-news
627 "\ek" gnus-group-edit-local-kill
628 "\eK" gnus-group-edit-global-kill
629 "\C-k" gnus-group-kill-group
630 "\C-y" gnus-group-yank-group
631 "\C-w" gnus-group-kill-region
632 "\C-x\C-t" gnus-group-transpose-groups
633 "\C-c\C-l" gnus-group-list-killed
634 "\C-c\C-x" gnus-group-expire-articles
635 "\C-c\M-\C-x" gnus-group-expire-all-groups
637 "s" gnus-group-save-newsrc
638 "z" gnus-group-suspend
641 "?" gnus-group-describe-briefly
642 "\C-c\C-i" gnus-info-find-node
643 "\M-e" gnus-group-edit-group-method
644 "^" gnus-group-enter-server-mode
645 gnus-mouse-2 gnus-mouse-pick-group
646 "<" beginning-of-buffer
649 "\C-c\C-s" gnus-group-sort-groups
651 "\C-c\M-g" gnus-activate-all-groups
652 "\M-&" gnus-group-universal-argument
653 "#" gnus-group-mark-group
654 "\M-#" gnus-group-unmark-group)
656 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
657 "m" gnus-group-mark-group
658 "u" gnus-group-unmark-group
659 "w" gnus-group-mark-region
660 "m" gnus-group-mark-buffer
661 "r" gnus-group-mark-regexp
662 "U" gnus-group-unmark-all-groups)
664 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
665 "d" gnus-group-make-directory-group
666 "h" gnus-group-make-help-group
667 "u" gnus-group-make-useful-group
668 "a" gnus-group-make-archive-group
669 "k" gnus-group-make-kiboze-group
670 "m" gnus-group-make-group
671 "E" gnus-group-edit-group
672 "e" gnus-group-edit-group-method
673 "p" gnus-group-edit-group-parameters
674 "v" gnus-group-add-to-virtual
675 "V" gnus-group-make-empty-virtual
676 "D" gnus-group-enter-directory
677 "f" gnus-group-make-doc-group
678 "w" gnus-group-make-web-group
679 "r" gnus-group-rename-group
680 "c" gnus-group-customize
681 "\177" gnus-group-delete-group
682 [delete] gnus-group-delete-group)
684 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
685 "b" gnus-group-brew-soup
686 "w" gnus-soup-save-areas
687 "s" gnus-soup-send-replies
688 "p" gnus-soup-pack-packet
689 "r" nnsoup-pack-replies)
691 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
692 "s" gnus-group-sort-groups
693 "a" gnus-group-sort-groups-by-alphabet
694 "u" gnus-group-sort-groups-by-unread
695 "l" gnus-group-sort-groups-by-level
696 "v" gnus-group-sort-groups-by-score
697 "r" gnus-group-sort-groups-by-rank
698 "m" gnus-group-sort-groups-by-method)
700 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
701 "s" gnus-group-sort-selected-groups
702 "a" gnus-group-sort-selected-groups-by-alphabet
703 "u" gnus-group-sort-selected-groups-by-unread
704 "l" gnus-group-sort-selected-groups-by-level
705 "v" gnus-group-sort-selected-groups-by-score
706 "r" gnus-group-sort-selected-groups-by-rank
707 "m" gnus-group-sort-selected-groups-by-method)
709 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
710 "k" gnus-group-list-killed
711 "z" gnus-group-list-zombies
712 "s" gnus-group-list-groups
713 "u" gnus-group-list-all-groups
714 "A" gnus-group-list-active
715 "a" gnus-group-apropos
716 "d" gnus-group-description-apropos
717 "m" gnus-group-list-matching
718 "M" gnus-group-list-all-matching
719 "l" gnus-group-list-level)
721 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
722 "f" gnus-score-flush-cache)
724 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
725 "d" gnus-group-describe-group
726 "f" gnus-group-fetch-faq)
728 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
729 "l" gnus-group-set-current-level
730 "t" gnus-group-unsubscribe-current-group
731 "s" gnus-group-unsubscribe-group
732 "k" gnus-group-kill-group
733 "y" gnus-group-yank-group
734 "w" gnus-group-kill-region
735 "\C-k" gnus-group-kill-level
736 "z" gnus-group-kill-all-zombies))
738 (defun gnus-group-make-menu-bar ()
739 (gnus-turn-off-edit-menu 'group)
740 (unless (boundp 'gnus-group-reading-menu)
743 gnus-group-reading-menu gnus-group-mode-map ""
745 ["Read" gnus-group-read-group (gnus-group-group-name)]
746 ["Select" gnus-group-select-group (gnus-group-group-name)]
747 ["See old articles" (gnus-group-select-group 'all)
748 :keys "C-u SPC" :active (gnus-group-group-name)]
749 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
750 ["Catch up all articles" gnus-group-catchup-current-all
751 (gnus-group-group-name)]
752 ["Check for new articles" gnus-group-get-new-news-this-group
753 (gnus-group-group-name)]
754 ["Toggle subscription" gnus-group-unsubscribe-current-group
755 (gnus-group-group-name)]
756 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
757 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
758 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
759 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
760 ["Edit kill file" gnus-group-edit-local-kill
761 (gnus-group-group-name)]
762 ;; Actually one should check, if any of the marked groups gives t for
763 ;; (gnus-check-backend-function 'request-expire-articles ...)
764 ["Expire articles" gnus-group-expire-articles
765 (or (and (gnus-group-group-name)
766 (gnus-check-backend-function
767 'request-expire-articles
768 (gnus-group-group-name))) gnus-group-marked)]
769 ["Set group level" gnus-group-set-current-level
770 (gnus-group-group-name)]
771 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
775 gnus-group-group-menu gnus-group-mode-map ""
778 ["List unread subscribed groups" gnus-group-list-groups t]
779 ["List (un)subscribed groups" gnus-group-list-all-groups t]
780 ["List killed groups" gnus-group-list-killed gnus-killed-list]
781 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
782 ["List level..." gnus-group-list-level t]
783 ["Describe all groups" gnus-group-describe-all-groups t]
784 ["Group apropos..." gnus-group-apropos t]
785 ["Group and description apropos..." gnus-group-description-apropos t]
786 ["List groups matching..." gnus-group-list-matching t]
787 ["List all groups matching..." gnus-group-list-all-matching t]
788 ["List active file" gnus-group-list-active t])
790 ["Default sort" gnus-group-sort-groups t]
791 ["Sort by method" gnus-group-sort-groups-by-method t]
792 ["Sort by rank" gnus-group-sort-groups-by-rank t]
793 ["Sort by score" gnus-group-sort-groups-by-score t]
794 ["Sort by level" gnus-group-sort-groups-by-level t]
795 ["Sort by unread" gnus-group-sort-groups-by-unread t]
796 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
797 ("Sort process/prefixed"
798 ["Default sort" gnus-group-sort-selected-groups
799 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
800 ["Sort by method" gnus-group-sort-selected-groups-by-method
801 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
802 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
803 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
804 ["Sort by score" gnus-group-sort-selected-groups-by-score
805 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
806 ["Sort by level" gnus-group-sort-selected-groups-by-level
807 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
808 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
809 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
810 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
811 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
813 ["Mark group" gnus-group-mark-group
814 (and (gnus-group-group-name)
815 (not (memq (gnus-group-group-name) gnus-group-marked)))]
816 ["Unmark group" gnus-group-unmark-group
817 (and (gnus-group-group-name)
818 (memq (gnus-group-group-name) gnus-group-marked))]
819 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
820 ["Mark regexp..." gnus-group-mark-regexp t]
821 ["Mark region" gnus-group-mark-region t]
822 ["Mark buffer" gnus-group-mark-buffer t]
823 ["Execute command" gnus-group-universal-argument
824 (or gnus-group-marked (gnus-group-group-name))])
826 ["Subscribe to a group" gnus-group-unsubscribe-group t]
827 ["Kill all newsgroups in region" gnus-group-kill-region t]
828 ["Kill all zombie groups" gnus-group-kill-all-zombies
830 ["Kill all groups on level..." gnus-group-kill-level t])
832 ["Make a foreign group" gnus-group-make-group t]
833 ["Add a directory group" gnus-group-make-directory-group t]
834 ["Add the help group" gnus-group-make-help-group t]
835 ["Add the archive group" gnus-group-make-archive-group t]
836 ["Make a doc group" gnus-group-make-doc-group t]
837 ["Make a web group" gnus-group-make-web-group t]
838 ["Make a kiboze group" gnus-group-make-kiboze-group t]
839 ["Make a virtual group" gnus-group-make-empty-virtual t]
840 ["Add a group to a virtual" gnus-group-add-to-virtual t]
841 ["Rename group" gnus-group-rename-group
842 (gnus-check-backend-function
843 'request-rename-group (gnus-group-group-name))]
844 ["Delete group" gnus-group-delete-group
845 (gnus-check-backend-function
846 'request-delete-group (gnus-group-group-name))])
848 ["Parameters" gnus-group-edit-group-parameters
849 (gnus-group-group-name)]
850 ["Select method" gnus-group-edit-group-method
851 (gnus-group-group-name)]
852 ["Info" gnus-group-edit-group (gnus-group-group-name)])
854 ["Flush cache" gnus-score-flush-cache t])
856 ["Next" gnus-group-next-group t]
857 ["Previous" gnus-group-prev-group t]
858 ["Next unread" gnus-group-next-unread-group t]
859 ["Previous unread" gnus-group-prev-unread-group t]
860 ["Next unread same level" gnus-group-next-unread-group-same-level t]
861 ["Previous unread same level"
862 gnus-group-prev-unread-group-same-level t]
863 ["Jump to group" gnus-group-jump-to-group t]
864 ["First unread group" gnus-group-first-unread-group t]
865 ["Best unread group" gnus-group-best-unread-group t])
866 ["Transpose" gnus-group-transpose-groups
867 (gnus-group-group-name)]
868 ["Read a directory as a group..." gnus-group-enter-directory t]
872 gnus-group-misc-menu gnus-group-mode-map ""
874 ["Send a bug report" gnus-bug t]
875 ["Customize" gnus-group-customize t]
876 ["Send a mail" gnus-group-mail t]
877 ["Post an article..." gnus-group-post-news t]
878 ["Check for new news" gnus-group-get-new-news t]
879 ["Activate all groups" gnus-activate-all-groups t]
880 ["Delete bogus groups" gnus-group-check-bogus-groups t]
881 ["Find new newsgroups" gnus-find-new-newsgroups t]
882 ["Restart Gnus" gnus-group-restart t]
883 ["Read init file" gnus-group-read-init-file t]
884 ["Browse foreign server" gnus-group-browse-foreign-server t]
885 ["Enter server buffer" gnus-group-enter-server-mode t]
886 ["Expire all expirable articles" gnus-group-expire-all-groups t]
887 ["Generate any kiboze groups" nnkiboze-generate-groups t]
888 ["Gnus version" gnus-version t]
889 ["Save .newsrc files" gnus-group-save-newsrc t]
890 ["Suspend Gnus" gnus-group-suspend t]
891 ["Clear dribble buffer" gnus-group-clear-dribble t]
892 ["Edit global kill file" gnus-group-edit-global-kill t]
893 ["Read manual" gnus-info-find-node t]
894 ["Toggle topics" gnus-topic-mode t]
896 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
897 ["Send replies" gnus-soup-send-replies
898 (fboundp 'gnus-soup-pack-packet)]
899 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
900 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
901 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
902 ["Exit from Gnus" gnus-group-exit t]
903 ["Exit without saving" gnus-group-quit t]
906 (run-hooks 'gnus-group-menu-hook)
909 (defun gnus-group-mode ()
910 "Major mode for reading news.
912 All normal editing commands are switched off.
913 \\<gnus-group-mode-map>
914 The group buffer lists (some of) the groups available. For instance,
915 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
916 lists all zombie groups.
918 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
919 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
921 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
923 The following commands are available:
925 \\{gnus-group-mode-map}"
927 (when (and menu-bar-mode
928 (gnus-visual-p 'group-menu 'menu))
929 (gnus-group-make-menu-bar))
930 (kill-all-local-variables)
931 (gnus-simplify-mode-line)
932 (setq major-mode 'gnus-group-mode)
933 (setq mode-name "Group")
934 (gnus-group-set-mode-line)
935 (setq mode-line-process nil)
936 (use-local-map gnus-group-mode-map)
937 (buffer-disable-undo (current-buffer))
938 (setq truncate-lines t)
939 (setq buffer-read-only t)
940 (gnus-set-default-directory)
941 (gnus-update-format-specifications nil 'group 'group-mode)
942 (gnus-update-group-mark-positions)
943 (gnus-make-local-hook 'post-command-hook)
944 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
947 (run-hooks 'gnus-group-mode-hook))
949 (defun gnus-update-group-mark-positions ()
951 (let ((gnus-process-mark 128)
952 (gnus-group-marked '("dummy.group"))
953 (gnus-active-hashtb (make-vector 10 0)))
954 (gnus-set-active "dummy.group" '(0 . 0))
955 (gnus-set-work-buffer)
956 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
957 (goto-char (point-min))
958 (setq gnus-group-mark-positions
959 (list (cons 'process (and (search-forward "\200" nil t)
962 (defun gnus-clear-inboxes-moved ()
963 (setq nnmail-moved-inboxes nil))
965 (defun gnus-mouse-pick-group (e)
966 "Enter the group under the mouse pointer."
969 (gnus-group-read-group nil))
971 ;; Look at LEVEL and find out what the level is really supposed to be.
972 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
973 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
974 (defun gnus-group-default-level (&optional level number-or-nil)
976 (gnus-group-use-permanent-levels
977 (or (setq gnus-group-use-permanent-levels
978 (or level (if (numberp gnus-group-use-permanent-levels)
979 gnus-group-use-permanent-levels
980 (or gnus-group-default-list-level
981 gnus-level-subscribed))))
982 gnus-group-default-list-level gnus-level-subscribed))
986 (or level gnus-group-default-list-level gnus-level-subscribed))))
988 (defun gnus-group-setup-buffer ()
989 (switch-to-buffer gnus-group-buffer)
990 (unless (eq major-mode 'gnus-group-mode)
991 (gnus-add-current-to-buffer-list)
994 (gnus-carpal-setup-buffer 'group))))
996 (defun gnus-group-list-groups (&optional level unread lowest)
997 "List newsgroups with level LEVEL or lower that have unread articles.
998 Default is all subscribed groups.
999 If argument UNREAD is non-nil, groups with no unread articles are also
1002 (list (if current-prefix-arg
1003 (prefix-numeric-value current-prefix-arg)
1005 (gnus-group-default-level nil t)
1006 gnus-group-default-list-level
1007 gnus-level-subscribed))))
1008 ;; Just do this here, for no particular good reason.
1009 (gnus-clear-inboxes-moved)
1011 (setq level (car gnus-group-list-mode)
1012 unread (cdr gnus-group-list-mode)))
1013 (setq level (gnus-group-default-level level))
1014 (gnus-group-setup-buffer) ;May call from out of group buffer
1015 (gnus-update-format-specifications nil 'group 'group-mode)
1016 (let ((case-fold-search nil)
1017 (props (text-properties-at (gnus-point-at-bol)))
1018 (group (gnus-group-group-name)))
1019 (set-buffer gnus-group-buffer)
1020 (funcall gnus-group-prepare-function level unread lowest)
1021 (if (zerop (buffer-size))
1022 (gnus-message 5 gnus-no-groups-message)
1023 (goto-char (point-max))
1024 (when (or (not gnus-group-goto-next-group-function)
1025 (not (funcall gnus-group-goto-next-group-function
1028 ;; Go to the first group with unread articles.
1029 (gnus-group-search-forward t)
1030 ;; Find the right group to put point on. If the current group
1031 ;; has disappeared in the new listing, try to find the next
1032 ;; one. If no next one can be found, just leave point at the
1033 ;; first newsgroup in the buffer.
1034 (when (not (gnus-goto-char
1036 (point-min) (point-max)
1037 'gnus-group (gnus-intern-safe
1038 group gnus-active-hashtb))))
1039 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1041 (not (gnus-goto-char
1043 (point-min) (point-max) 'gnus-group
1045 (caar newsrc) gnus-active-hashtb)))))
1046 (setq newsrc (cdr newsrc)))
1048 (goto-char (point-max))
1049 (forward-line -1))))))
1050 ;; Adjust cursor point.
1051 (gnus-group-position-point))))
1053 (defun gnus-group-list-level (level &optional all)
1054 "List groups on LEVEL.
1055 If ALL (the prefix), also list groups that have no unread articles."
1056 (interactive "nList groups on level: \nP")
1057 (gnus-group-list-groups level all level))
1059 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
1060 "List all newsgroups with unread articles of level LEVEL or lower.
1061 If ALL is non-nil, list groups that have no unread articles.
1062 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1063 If REGEXP, only list groups matching REGEXP."
1064 (set-buffer gnus-group-buffer)
1065 (let ((buffer-read-only nil)
1066 (newsrc (cdr gnus-newsrc-alist))
1067 (lowest (or lowest 1))
1068 info clevel unread group params)
1070 (when (< lowest gnus-level-zombie)
1071 ;; List living groups.
1073 (setq info (car newsrc)
1074 group (gnus-info-group info)
1075 params (gnus-info-params info)
1077 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1078 (and unread ; This group might be bogus
1080 (string-match regexp group))
1081 (<= (setq clevel (gnus-info-level info)) level)
1083 (or all ; We list all groups?
1084 (if (eq unread t) ; Unactivated?
1085 gnus-group-list-inactive-groups ; We list unactivated
1086 (> unread 0)) ; We list groups with unread articles
1087 (and gnus-list-groups-with-ticked-articles
1088 (cdr (assq 'tick (gnus-info-marks info))))
1089 ; And groups with tickeds
1090 ;; Check for permanent visibility.
1091 (and gnus-permanently-visible-groups
1092 (string-match gnus-permanently-visible-groups
1094 (memq 'visible params)
1095 (cdr (assq 'visible params)))
1096 (gnus-group-insert-group-line
1097 group (gnus-info-level info)
1098 (gnus-info-marks info) unread (gnus-info-method info)))))
1100 ;; List dead groups.
1101 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
1102 (gnus-group-prepare-flat-list-dead
1103 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1104 gnus-level-zombie ?Z
1106 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
1107 (gnus-group-prepare-flat-list-dead
1108 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1109 gnus-level-killed ?K regexp))
1111 (gnus-group-set-mode-line)
1112 (setq gnus-group-list-mode (cons level all))
1113 (run-hooks 'gnus-group-prepare-hook)))
1115 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1116 ;; List zombies and killed lists somewhat faster, which was
1117 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1118 ;; this by ignoring the group format specification altogether.
1121 ;; This loop is used when listing groups that match some
1124 (setq group (pop groups))
1125 (when (string-match regexp group)
1126 (gnus-add-text-properties
1127 (point) (prog1 (1+ (point))
1128 (insert " " mark " *: " group "\n"))
1129 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1131 'gnus-level level))))
1132 ;; This loop is used when listing all groups.
1134 (gnus-add-text-properties
1135 (point) (prog1 (1+ (point))
1136 (insert " " mark " *: "
1137 (setq group (pop groups)) "\n"))
1138 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1140 'gnus-level level))))))
1142 (defun gnus-group-update-group-line ()
1143 "Update the current line in the group buffer."
1144 (let* ((buffer-read-only nil)
1145 (group (gnus-group-group-name))
1146 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1147 gnus-group-indentation)
1150 (not (gnus-ephemeral-group-p group))
1152 (concat "(gnus-group-set-info '"
1153 (gnus-prin1-to-string (nth 2 entry))
1155 (setq gnus-group-indentation (gnus-group-group-indentation))
1157 (gnus-group-insert-group-line-info group)
1159 (gnus-group-position-point))))
1161 (defun gnus-group-insert-group-line-info (group)
1162 "Insert GROUP on the current line."
1163 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1164 (gnus-group-indentation (gnus-group-group-indentation))
1168 ;; (Un)subscribed group.
1169 (setq info (nth 2 entry))
1170 (gnus-group-insert-group-line
1171 group (gnus-info-level info) (gnus-info-marks info)
1172 (or (car entry) t) (gnus-info-method info)))
1173 ;; This group is dead.
1174 (gnus-group-insert-group-line
1176 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1178 (if (setq active (gnus-active group))
1179 (- (1+ (cdr active)) (car active)) 0)
1182 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1183 gnus-tmp-marked number
1185 "Insert a group line in the group buffer."
1186 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1187 (gnus-tmp-number-total
1189 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1191 (gnus-tmp-number-of-unread
1192 (if (numberp number) (int-to-string (max 0 number))
1194 (gnus-tmp-number-of-read
1195 (if (numberp number)
1196 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1198 (gnus-tmp-subscribed
1199 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1200 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1201 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1203 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1204 (gnus-tmp-newsgroup-description
1205 (if gnus-description-hashtb
1206 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1209 (if (and gnus-moderated-hashtb
1210 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1212 (gnus-tmp-moderated-string
1213 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1215 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1216 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1217 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1218 (gnus-tmp-news-method-string
1220 (format "(%s:%s)" (car gnus-tmp-method)
1221 (cadr gnus-tmp-method)) ""))
1222 (gnus-tmp-marked-mark
1223 (if (and (numberp number)
1225 (cdr (assq 'tick gnus-tmp-marked)))
1227 (gnus-tmp-process-marked
1228 (if (member gnus-tmp-group gnus-group-marked)
1229 gnus-process-mark ? ))
1231 (or (and gnus-use-grouplens
1232 (bbb-grouplens-group-p gnus-tmp-group))
1234 (buffer-read-only nil)
1235 header gnus-tmp-header) ; passed as parameter to user-funcs.
1237 (gnus-add-text-properties
1241 (eval gnus-group-line-format-spec))
1242 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1243 gnus-unread ,(if (numberp number)
1244 (string-to-int gnus-tmp-number-of-unread)
1246 gnus-marked ,gnus-tmp-marked-mark
1247 gnus-indentation ,gnus-group-indentation
1248 gnus-level ,gnus-tmp-level))
1249 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1251 (run-hooks 'gnus-group-update-hook)
1253 ;; Allow XEmacs to remove front-sticky text properties.
1254 (gnus-group-remove-excess-properties)))
1256 (defun gnus-group-highlight-line ()
1257 "Highlight the current line according to `gnus-group-highlight'."
1258 (let* ((list gnus-group-highlight)
1260 (end (progn (end-of-line) (point)))
1261 ;; now find out where the line starts and leave point there.
1262 (beg (progn (beginning-of-line) (point)))
1263 (group (gnus-group-group-name))
1264 (entry (gnus-group-entry group))
1265 (unread (if (numberp (car entry)) (car entry) 0))
1266 (active (gnus-active group))
1267 (total (if active (1+ (- (cdr active) (car active))) 0))
1268 (info (nth 2 entry))
1269 (method (gnus-server-get-method group (gnus-info-method info)))
1270 (marked (gnus-info-marks info))
1271 (mailp (memq 'mail (assoc (symbol-name
1272 (car (or method gnus-select-method)))
1273 gnus-valid-select-methods)))
1274 (level (or (gnus-info-level info) 9))
1275 (score (or (gnus-info-score info) 0))
1276 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1277 (inhibit-read-only t))
1278 ;; Eval the cars of the lists until we find a match.
1280 (not (eval (caar list))))
1281 (setq list (cdr list)))
1282 (let ((face (cdar list)))
1283 (unless (eq face (get-text-property beg 'face))
1284 (gnus-put-text-property
1286 (setq face (if (boundp face) (symbol-value face) face)))
1287 (gnus-extent-start-open beg)))
1290 (defun gnus-group-update-group (group &optional visible-only)
1291 "Update all lines where GROUP appear.
1292 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1295 (set-buffer gnus-group-buffer)
1296 ;; The buffer may be narrowed.
1299 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1301 found buffer-read-only)
1302 ;; Enter the current status into the dribble buffer.
1303 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1304 (when (and entry (not (gnus-ephemeral-group-p group)))
1306 (concat "(gnus-group-set-info '"
1307 (gnus-prin1-to-string (nth 2 entry))
1309 ;; Find all group instances. If topics are in use, each group
1310 ;; may be listed in more than once.
1311 (while (setq loc (text-property-any
1312 loc (point-max) 'gnus-group ident))
1315 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1317 (gnus-group-insert-group-line-info group)
1320 (run-hooks 'gnus-group-update-group-hook)))
1321 (setq loc (1+ loc)))
1322 (unless (or found visible-only)
1323 ;; No such line in the buffer, find out where it's supposed to
1324 ;; go, and insert it there (or at the end of the buffer).
1325 (if gnus-goto-missing-group-function
1326 (funcall gnus-goto-missing-group-function group)
1327 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1328 (while (and entry (car entry)
1332 (point-min) (point-max)
1333 'gnus-group (gnus-intern-safe
1334 (caar entry) gnus-active-hashtb)))))
1335 (setq entry (cdr entry)))
1336 (or entry (goto-char (point-max)))))
1337 ;; Finally insert the line.
1338 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1339 (gnus-group-insert-group-line-info group)
1342 (run-hooks 'gnus-group-update-group-hook))))
1343 (when gnus-group-update-group-function
1344 (funcall gnus-group-update-group-function group))
1345 (gnus-group-set-mode-line)))))
1347 (defun gnus-group-set-mode-line ()
1348 "Update the mode line in the group buffer."
1349 (when (memq 'group gnus-updated-mode-lines)
1350 ;; Yes, we want to keep this mode line updated.
1352 (set-buffer gnus-group-buffer)
1353 (let* ((gformat (or gnus-group-mode-line-format-spec
1354 (setq gnus-group-mode-line-format-spec
1356 gnus-group-mode-line-format
1357 gnus-group-mode-line-format-alist))))
1358 (gnus-tmp-news-server (cadr gnus-select-method))
1359 (gnus-tmp-news-method (car gnus-select-method))
1360 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1362 gnus-tmp-header ;Dummy binding for user-defined formats
1363 ;; Get the resulting string.
1365 (and gnus-dribble-buffer
1366 (buffer-name gnus-dribble-buffer)
1367 (buffer-modified-p gnus-dribble-buffer)
1369 (set-buffer gnus-dribble-buffer)
1370 (not (zerop (buffer-size))))))
1371 (mode-string (eval gformat)))
1372 ;; Say whether the dribble buffer has been modified.
1373 (setq mode-line-modified
1374 (if modified "---*- " "----- "))
1375 ;; If the line is too long, we chop it off.
1376 (when (> (length mode-string) max-len)
1377 (setq mode-string (substring mode-string 0 (- max-len 4))))
1379 (setq mode-line-buffer-identification
1380 (gnus-mode-line-buffer-identification
1381 (list mode-string)))
1382 (set-buffer-modified-p modified))))))
1384 (defun gnus-group-group-name ()
1385 "Get the name of the newsgroup on the current line."
1386 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1387 (and group (symbol-name group))))
1389 (defun gnus-group-group-level ()
1390 "Get the level of the newsgroup on the current line."
1391 (get-text-property (gnus-point-at-bol) 'gnus-level))
1393 (defun gnus-group-group-indentation ()
1394 "Get the indentation of the newsgroup on the current line."
1395 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1396 (and gnus-group-indentation-function
1397 (funcall gnus-group-indentation-function))
1400 (defun gnus-group-group-unread ()
1401 "Get the number of unread articles of the newsgroup on the current line."
1402 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1404 (defun gnus-group-new-mail (group)
1405 (if (nnmail-new-mail-p (gnus-group-real-name group))
1409 (defun gnus-group-search-forward (&optional backward all level first-too)
1410 "Find the next newsgroup with unread articles.
1411 If BACKWARD is non-nil, find the previous newsgroup instead.
1412 If ALL is non-nil, just find any newsgroup.
1413 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1415 If FIRST-TOO, the current line is also eligible as a target."
1416 (let ((way (if backward -1 1))
1417 (low gnus-level-killed)
1420 (if (and backward (progn (beginning-of-line)) (bobp))
1431 (get-text-property (point) 'gnus-unread)))
1432 (and (numberp unread) (> unread 0)))
1433 (setq lev (get-text-property (point)
1435 (<= lev gnus-level-subscribed)))
1437 (and (setq lev (get-text-property (point)
1446 (zerop (forward-line way)))))
1448 (progn (gnus-group-position-point) t)
1449 (goto-char (or pos beg))
1452 ;;; Gnus group mode commands
1456 (defun gnus-group-mark-group (n &optional unmark no-advance)
1457 "Mark the current group."
1459 (let ((buffer-read-only nil)
1463 (when (setq group (gnus-group-group-name))
1464 ;; Go to the mark position.
1466 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1467 (subst-char-in-region
1468 (point) (1+ (point)) (following-char)
1471 (setq gnus-group-marked (delete group gnus-group-marked))
1473 (setq gnus-group-marked
1474 (cons group (delete group gnus-group-marked)))
1475 gnus-process-mark)))
1477 (gnus-group-next-group 1))
1479 (gnus-summary-position-point)
1482 (defun gnus-group-unmark-group (n)
1483 "Remove the mark from the current group."
1485 (gnus-group-mark-group n 'unmark)
1486 (gnus-group-position-point))
1488 (defun gnus-group-unmark-all-groups ()
1489 "Unmark all groups."
1491 (let ((groups gnus-group-marked))
1494 (gnus-group-remove-mark (pop groups)))))
1495 (gnus-group-position-point))
1497 (defun gnus-group-mark-region (unmark beg end)
1498 "Mark all groups between point and mark.
1499 If UNMARK, remove the mark instead."
1500 (interactive "P\nr")
1501 (let ((num (count-lines beg end)))
1504 (- num (gnus-group-mark-group num unmark)))))
1506 (defun gnus-group-mark-buffer (&optional unmark)
1507 "Mark all groups in the buffer.
1508 If UNMARK, remove the mark instead."
1510 (gnus-group-mark-region unmark (point-min) (point-max)))
1512 (defun gnus-group-mark-regexp (regexp)
1513 "Mark all groups that match some regexp."
1514 (interactive "sMark (regexp): ")
1515 (let ((alist (cdr gnus-newsrc-alist))
1518 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1519 (gnus-group-set-mark group))))
1520 (gnus-group-position-point))
1522 (defun gnus-group-remove-mark (group)
1523 "Remove the process mark from GROUP and move point there.
1524 Return nil if the group isn't displayed."
1525 (if (gnus-group-goto-group group)
1527 (gnus-group-mark-group 1 'unmark t)
1529 (setq gnus-group-marked
1530 (delete group gnus-group-marked))
1533 (defun gnus-group-set-mark (group)
1534 "Set the process mark on GROUP."
1535 (if (gnus-group-goto-group group)
1537 (gnus-group-mark-group 1 nil t))
1538 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1540 (defun gnus-group-universal-argument (arg &optional groups func)
1541 "Perform any command on all groups according to the process/prefix convention."
1543 (if (eq (setq func (or func
1546 (substitute-command-keys
1547 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1549 (gnus-error 1 "Undefined key")
1550 (gnus-group-iterate arg
1552 (command-execute func))))
1553 (gnus-group-position-point))
1555 (defun gnus-group-process-prefix (n)
1556 "Return a list of groups to work on.
1557 Take into consideration N (the prefix) and the list of marked groups."
1560 (setq n (prefix-numeric-value n))
1561 ;; There is a prefix, so we return a list of the N next
1563 (let ((way (if (< n 0) -1 1))
1568 (setq group (gnus-group-group-name)))
1571 (gnus-group-next-group way)))
1573 ((and (boundp 'transient-mark-mode)
1575 (boundp 'mark-active)
1577 ;; Work on the region between point and mark.
1578 (let ((max (max (point) (mark)))
1581 (goto-char (min (point) (mark)))
1584 (push (gnus-group-group-name) groups)
1585 (zerop (gnus-group-next-group 1))
1587 (nreverse groups))))
1589 ;; No prefix, but a list of marked articles.
1590 (reverse gnus-group-marked))
1592 ;; Neither marked articles or a prefix, so we return the
1594 (let ((group (gnus-group-group-name)))
1595 (and group (list group))))))
1597 (defun gnus-group-iterate (arg function)
1598 "Iterate FUNCTION over all process/prefixed groups.
1599 FUNCTION will be called with the group name as the paremeter
1600 and with point over the group in question."
1601 (let ((groups (gnus-group-process-prefix arg))
1603 (while (setq group (pop groups))
1604 (gnus-group-remove-mark group)
1605 (funcall function group))))
1607 (put 'gnus-group-iterate 'lisp-indent-function 1)
1609 ;; Selecting groups.
1611 (defun gnus-group-read-group (&optional all no-article group)
1612 "Read news in this newsgroup.
1613 If the prefix argument ALL is non-nil, already read articles become
1614 readable. IF ALL is a number, fetch this number of articles. If the
1615 optional argument NO-ARTICLE is non-nil, no article will be
1616 auto-selected upon group entry. If GROUP is non-nil, fetch that
1619 (let ((no-display (eq all 0))
1620 (group (or group (gnus-group-group-name)))
1621 number active marked entry)
1625 (error "No group on current line"))
1626 (setq marked (gnus-info-marks
1627 (nth 2 (setq entry (gnus-gethash
1628 group gnus-newsrc-hashtb)))))
1629 ;; This group might be a dead group. In that case we have to get
1630 ;; the number of unread articles from `gnus-active-hashtb'.
1632 (cond ((numberp all) all)
1634 ((setq active (gnus-active group))
1635 (- (1+ (cdr active)) (car active)))))
1636 (gnus-summary-read-group
1637 group (or all (and (numberp number)
1638 (zerop (+ number (gnus-range-length
1639 (cdr (assq 'tick marked)))
1641 (cdr (assq 'dormant marked)))))))
1642 no-article nil no-display)))
1644 (defun gnus-group-select-group (&optional all)
1645 "Select this newsgroup.
1646 No article is selected automatically.
1647 If ALL is non-nil, already read articles become readable.
1648 If ALL is a number, fetch this number of articles."
1650 (gnus-group-read-group all t))
1652 (defun gnus-group-quick-select-group (&optional all)
1653 "Select the current group \"quickly\".
1654 This means that no highlighting or scoring will be performed.
1655 If ALL (the prefix argument) is 0, don't even generate the summary
1658 (require 'gnus-score)
1660 gnus-score-find-score-files-function
1661 gnus-apply-kill-hook
1662 gnus-summary-expunge-below)
1663 (gnus-group-read-group all t)))
1665 (defun gnus-group-visible-select-group (&optional all)
1666 "Select the current group without hiding any articles."
1668 (let ((gnus-inhibit-limiting t))
1669 (gnus-group-read-group all t)))
1672 (defun gnus-fetch-group (group)
1673 "Start Gnus if necessary and enter GROUP.
1674 Returns whether the fetching was successful or not."
1675 (interactive "sGroup name: ")
1676 (unless (get-buffer gnus-group-buffer)
1678 (gnus-group-read-group nil nil group))
1680 ;; Enter a group that is not in the group buffer. Non-nil is returned
1681 ;; if selection was successful.
1682 (defun gnus-group-read-ephemeral-group (group method &optional activate
1683 quit-config request-only)
1684 "Read GROUP from METHOD as an ephemeral group.
1685 If ACTIVATE, request the group first.
1686 If QUIT-CONFIG, use that window configuration when exiting from the
1688 If REQUEST-ONLY, don't actually read the group; just request it.
1690 Return the name of the group is selection was successful."
1691 (let ((group (if (gnus-group-foreign-p group) group
1692 (gnus-group-prefixed-name group method))))
1696 ,gnus-level-default-subscribed nil nil ,method
1698 ,(if quit-config quit-config
1699 (cons gnus-summary-buffer
1700 gnus-current-window-configuration))))))
1702 (set-buffer gnus-group-buffer)
1703 (unless (gnus-check-server method)
1704 (error "Unable to contact server: %s" (gnus-status-message method)))
1706 (gnus-activate-group group 'scan)
1707 (unless (gnus-request-group group)
1708 (error "Couldn't request group: %s"
1709 (nnheader-get-report (car method)))))
1713 (when (gnus-group-read-group t t group)
1718 (defun gnus-group-jump-to-group (group)
1719 "Jump to newsgroup GROUP."
1721 (list (completing-read
1722 "Group: " gnus-active-hashtb nil
1723 (gnus-read-active-file-p)
1725 'gnus-group-history)))
1727 (when (equal group "")
1728 (error "Empty group name"))
1730 (unless (gnus-ephemeral-group-p group)
1731 ;; Either go to the line in the group buffer...
1732 (unless (gnus-group-goto-group group)
1733 ;; ... or insert the line.
1734 (gnus-group-update-group group)
1735 (gnus-group-goto-group group)))
1736 ;; Adjust cursor point.
1737 (gnus-group-position-point))
1739 (defun gnus-group-goto-group (group &optional far)
1740 "Goto to newsgroup GROUP.
1741 If FAR, it is likely that the group is not on the current line."
1746 (point-min) (point-max)
1747 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1750 ;; It's quite likely that we are on the right line, so
1751 ;; we check the current line first.
1752 ((eq (get-text-property (point) 'gnus-group)
1753 (gnus-intern-safe group gnus-active-hashtb))
1755 ;; Previous and next line are also likely, so we check them as well.
1758 (eq (get-text-property (point) 'gnus-group)
1759 (gnus-intern-safe group gnus-active-hashtb)))
1764 (eq (get-text-property (point) 'gnus-group)
1765 (gnus-intern-safe group gnus-active-hashtb)))
1769 ;; Search through the entire buffer.
1772 (point-min) (point-max)
1773 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1775 (defun gnus-group-next-group (n &optional silent)
1776 "Go to next N'th newsgroup.
1777 If N is negative, search backward instead.
1778 Returns the difference between N and the number of skips actually
1781 (gnus-group-next-unread-group n t nil silent))
1783 (defun gnus-group-next-unread-group (n &optional all level silent)
1784 "Go to next N'th unread newsgroup.
1785 If N is negative, search backward instead.
1786 If ALL is non-nil, choose any newsgroup, unread or not.
1787 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1788 such group can be found, the next group with a level higher than
1790 Returns the difference between N and the number of skips actually
1793 (let ((backward (< n 0))
1796 (gnus-group-search-forward
1797 backward (or (not gnus-group-goto-unread) all) level))
1801 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1802 (if level " on this level or higher" "")))
1805 (defun gnus-group-prev-group (n)
1806 "Go to previous N'th newsgroup.
1807 Returns the difference between N and the number of skips actually
1810 (gnus-group-next-unread-group (- n) t))
1812 (defun gnus-group-prev-unread-group (n)
1813 "Go to previous N'th unread newsgroup.
1814 Returns the difference between N and the number of skips actually
1817 (gnus-group-next-unread-group (- n)))
1819 (defun gnus-group-next-unread-group-same-level (n)
1820 "Go to next N'th unread newsgroup on the same level.
1821 If N is negative, search backward instead.
1822 Returns the difference between N and the number of skips actually
1825 (gnus-group-next-unread-group n t (gnus-group-group-level))
1826 (gnus-group-position-point))
1828 (defun gnus-group-prev-unread-group-same-level (n)
1829 "Go to next N'th unread newsgroup on the same level.
1830 Returns the difference between N and the number of skips actually
1833 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1834 (gnus-group-position-point))
1836 (defun gnus-group-best-unread-group (&optional exclude-group)
1837 "Go to the group with the highest level.
1838 If EXCLUDE-GROUP, do not go to that group."
1840 (goto-char (point-min))
1844 (setq unread (get-text-property (point) 'gnus-unread))
1845 (when (and (numberp unread) (> unread 0))
1846 (when (and (get-text-property (point) 'gnus-level)
1847 (< (get-text-property (point) 'gnus-level) best)
1848 (or (not exclude-group)
1849 (not (equal exclude-group (gnus-group-group-name)))))
1850 (setq best (get-text-property (point) 'gnus-level))
1851 (setq best-point (point))))
1854 (goto-char best-point))
1855 (gnus-summary-position-point)
1856 (and best-point (gnus-group-group-name))))
1858 (defun gnus-group-first-unread-group ()
1859 "Go to the first group with unread articles."
1862 (let ((opoint (point))
1864 (goto-char (point-min))
1865 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1866 (and (numberp unread) ; Not a topic.
1867 (not (zerop unread))) ; Has unread articles.
1868 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1871 nil)) ; Not success.
1872 (gnus-group-position-point)))
1874 (defun gnus-group-enter-server-mode ()
1875 "Jump to the server buffer."
1877 (gnus-enter-server-buffer))
1879 (defun gnus-group-make-group (name &optional method address args)
1880 "Add a new newsgroup.
1881 The user will be prompted for a NAME, for a select METHOD, and an
1885 (gnus-read-group "Group name: ")
1886 (gnus-read-method "From method: ")))
1888 (let* ((meth (when (and method
1889 (not (gnus-server-equal method gnus-select-method)))
1890 (if address (list (intern method) address)
1892 (nname (if method (gnus-group-prefixed-name name meth) name))
1894 (when (gnus-gethash nname gnus-newsrc-hashtb)
1895 (error "Group %s already exists" nname))
1896 ;; Subscribe to the new group.
1897 (gnus-group-change-level
1898 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1899 gnus-level-default-subscribed gnus-level-killed
1900 (and (gnus-group-group-name)
1901 (gnus-gethash (gnus-group-group-name)
1902 gnus-newsrc-hashtb))
1905 (gnus-set-active nname (cons 1 0))
1906 (unless (gnus-ephemeral-group-p name)
1908 (concat "(gnus-group-set-info '"
1909 (gnus-prin1-to-string (cdr info)) ")")))
1911 (gnus-group-insert-group-line-info nname)
1913 (gnus-group-position-point)
1915 ;; Load the backend and try to make the backend create
1916 ;; the group as well.
1917 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1919 gnus-valid-select-methods)
1921 (gnus-check-server meth)
1922 (when (gnus-check-backend-function 'request-create-group nname)
1923 (gnus-request-create-group nname nil args))
1926 (defun gnus-group-delete-group (group &optional force)
1927 "Delete the current group. Only meaningful with mail groups.
1928 If FORCE (the prefix) is non-nil, all the articles in the group will
1929 be deleted. This is \"deleted\" as in \"removed forever from the face
1930 of the Earth\". There is no undo. The user will be prompted before
1931 doing the deletion."
1933 (list (gnus-group-group-name)
1934 current-prefix-arg))
1936 (error "No group to rename"))
1937 (unless (gnus-check-backend-function 'request-delete-group group)
1938 (error "This backend does not support group deletion"))
1940 (if (not (gnus-yes-or-no-p
1942 "Do you really want to delete %s%s? "
1943 group (if force " and all its contents" ""))))
1945 (gnus-message 6 "Deleting group %s..." group)
1946 (if (not (gnus-request-delete-group group force))
1947 (gnus-error 3 "Couldn't delete group %s" group)
1948 (gnus-message 6 "Deleting group %s...done" group)
1949 (gnus-group-goto-group group)
1950 (gnus-group-kill-group 1 t)
1951 (gnus-sethash group nil gnus-active-hashtb)
1953 (gnus-group-position-point)))
1955 (defun gnus-group-rename-group (group new-name)
1956 "Rename group from GROUP to NEW-NAME.
1957 When used interactively, GROUP is the group under point
1958 and NEW-NAME will be prompted for."
1961 (gnus-group-group-name)
1963 (unless (gnus-check-backend-function
1964 'request-rename-group (gnus-group-group-name))
1965 (error "This backend does not support renaming groups"))
1966 (read-string "New group name: " (gnus-group-group-name)))))
1968 (unless (gnus-check-backend-function 'request-rename-group group)
1969 (error "This backend does not support renaming groups"))
1971 (error "No group to rename"))
1972 (when (string-match "^[ \t]*$" new-name)
1973 (error "Not a valid group name"))
1974 (when (equal group new-name)
1975 (error "Can't rename to the same name"))
1977 ;; We find the proper prefixed name.
1979 (if (equal (gnus-group-real-name new-name) new-name)
1983 (gnus-group-prefixed-name
1984 (gnus-group-real-name new-name)
1985 (gnus-info-method (gnus-get-info group)))))
1987 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1989 (if (not (gnus-request-rename-group group new-name))
1990 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1991 ;; We rename the group internally by killing it...
1992 (gnus-group-goto-group group)
1993 (gnus-group-kill-group)
1994 ;; ... changing its name ...
1995 (setcar (cdar gnus-list-of-killed-groups) new-name)
1996 ;; ... and then yanking it. Magic!
1997 (gnus-group-yank-group)
1998 (gnus-set-active new-name (gnus-active group))
1999 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2001 (gnus-group-position-point)))
2003 (defun gnus-group-edit-group (group &optional part)
2004 "Edit the group on the current line."
2005 (interactive (list (gnus-group-group-name)))
2006 (let ((part (or part 'info))
2009 (error "No group on current line"))
2010 (unless (setq info (gnus-get-info group))
2011 (error "Killed group; can't be edited"))
2013 ;; Find the proper form to edit.
2014 (cond ((eq part 'method)
2015 (or (gnus-info-method info) "native"))
2017 (gnus-info-params info))
2019 ;; The proper documentation.
2023 ((eq part 'method) "select method")
2024 ((eq part 'params) "group parameters")
2027 (gnus-group-edit-group-done ',part ,group form)))))
2029 (defun gnus-group-edit-group-method (group)
2030 "Edit the select method of GROUP."
2031 (interactive (list (gnus-group-group-name)))
2032 (gnus-group-edit-group group 'method))
2034 (defun gnus-group-edit-group-parameters (group)
2035 "Edit the group parameters of GROUP."
2036 (interactive (list (gnus-group-group-name)))
2037 (gnus-group-edit-group group 'params))
2039 (defun gnus-group-edit-group-done (part group form)
2041 (let* ((method (cond ((eq part 'info) (nth 4 form))
2042 ((eq part 'method) form)
2044 (info (cond ((eq part 'info) form)
2045 ((eq part 'method) (gnus-get-info group))
2048 (if (or (not method)
2050 gnus-select-method method))
2051 (gnus-group-real-name (car info))
2052 (gnus-group-prefixed-name
2053 (gnus-group-real-name (car info)) method))
2055 (when (and new-group
2056 (not (equal new-group group)))
2057 (when (gnus-group-goto-group group)
2058 (gnus-group-kill-group 1))
2059 (gnus-activate-group new-group))
2061 (if (not (and info new-group))
2062 (gnus-group-set-info form (or new-group group) part)
2063 (setq info (gnus-copy-sequence info))
2064 (setcar info new-group)
2065 (unless (gnus-server-equal method "native")
2066 (unless (nthcdr 3 info)
2067 (nconc info (list nil nil)))
2068 (unless (nthcdr 4 info)
2069 (nconc info (list nil)))
2070 (gnus-info-set-method info method))
2071 (gnus-group-set-info info))
2072 (gnus-group-update-group (or new-group group))
2073 (gnus-group-position-point)))
2075 (defun gnus-group-make-useful-group (group method)
2077 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2079 gnus-useful-groups)))
2080 (list (cadr entry) (caddr entry))))
2081 (setq method (gnus-copy-sequence method))
2083 (while (setq entry (memq (assq 'eval method) method))
2084 (setcar entry (eval (cadar entry)))))
2085 (gnus-group-make-group group method))
2087 (defun gnus-group-make-help-group ()
2088 "Create the Gnus documentation group."
2090 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2091 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
2093 (when (gnus-gethash name gnus-newsrc-hashtb)
2094 (error "Documentation group already exists"))
2096 (gnus-message 1 "Couldn't find doc group")
2097 (gnus-group-make-group
2098 (gnus-group-real-name name)
2099 (list 'nndoc "gnus-help"
2100 (list 'nndoc-address file)
2101 (list 'nndoc-article-type 'mbox)))))
2102 (gnus-group-position-point))
2104 (defun gnus-group-make-doc-group (file type)
2105 "Create a group that uses a single file as the source."
2107 (list (read-file-name "File name: ")
2108 (and current-prefix-arg 'ask)))
2109 (when (eq type 'ask)
2114 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2116 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2117 ((= char ?b) 'babyl)
2118 ((= char ?d) 'digest)
2119 ((= char ?f) 'forward)
2121 (t (setq err (format "%c unknown. " char))
2124 (let* ((file (expand-file-name file))
2125 (name (gnus-generate-new-group-name
2126 (gnus-group-prefixed-name
2127 (file-name-nondirectory file) '(nndoc "")))))
2128 (gnus-group-make-group
2129 (gnus-group-real-name name)
2131 (list 'nndoc-address file)
2132 (list 'nndoc-article-type (or type 'guess))))))
2134 (defvar nnweb-type-definition)
2135 (defvar gnus-group-web-type-history nil)
2136 (defvar gnus-group-web-search-history nil)
2137 (defun gnus-group-make-web-group (&optional solid)
2138 "Create an ephemeral nnweb group.
2139 If SOLID (the prefix), create a solid group."
2143 (if solid (gnus-read-group "Group name: ")
2144 (message-unique-id)))
2147 "Search engine type: "
2148 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2149 nnweb-type-definition)
2150 nil t (cons (or (car gnus-group-web-type-history)
2151 (symbol-name (caar nnweb-type-definition)))
2153 'gnus-group-web-type-history))
2157 (cons (or (car gnus-group-web-search-history) "") 0)
2158 'gnus-group-web-search-history))
2160 `(nnweb ,group (nnweb-search ,search)
2161 (nnweb-type ,(intern type))
2162 (nnweb-ephemeral-p t))))
2164 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2165 (gnus-group-read-ephemeral-group
2167 (cons (current-buffer)
2168 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2170 (defun gnus-group-make-archive-group (&optional all)
2171 "Create the (ding) Gnus archive group of the most recent articles.
2172 Given a prefix, create a full group."
2174 (let ((group (gnus-group-prefixed-name
2175 (if all "ding.archives" "ding.recent") '(nndir ""))))
2176 (when (gnus-gethash group gnus-newsrc-hashtb)
2177 (error "Archive group already exists"))
2178 (gnus-group-make-group
2179 (gnus-group-real-name group)
2180 (list 'nndir (if all "hpc" "edu")
2181 (list 'nndir-directory
2182 (if all gnus-group-archive-directory
2183 gnus-group-recent-archive-directory))))
2184 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
2186 (defun gnus-group-make-directory-group (dir)
2187 "Create an nndir group.
2188 The user will be prompted for a directory. The contents of this
2189 directory will be used as a newsgroup. The directory should contain
2190 mail messages or news articles in files that have numeric names."
2192 (list (read-file-name "Create group from directory: ")))
2193 (unless (file-exists-p dir)
2194 (error "No such directory"))
2195 (unless (file-directory-p dir)
2196 (error "Not a directory"))
2200 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2202 (gnus-group-prefixed-name
2203 (concat (file-name-as-directory (directory-file-name dir))
2206 (setq ext (format "<%d>" (setq i (1+ i)))))
2207 (gnus-group-make-group
2208 (gnus-group-real-name group)
2209 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2211 (defun gnus-group-make-kiboze-group (group address scores)
2212 "Create an nnkiboze group.
2213 The user will be prompted for a name, a regexp to match groups, and
2214 score file entries for articles to include in the group."
2217 (read-string "nnkiboze group name: ")
2218 (read-string "Source groups (regexp): ")
2219 (let ((headers (mapcar (lambda (group) (list group))
2220 '("subject" "from" "number" "date" "message-id"
2221 "references" "chars" "lines" "xref"
2222 "followup" "all" "body" "head")))
2223 scores header regexp regexps)
2224 (while (not (equal "" (setq header (completing-read
2225 "Match on header: " headers nil t))))
2227 (while (not (equal "" (setq regexp (read-string
2228 (format "Match on %s (string): "
2230 (push (list regexp nil nil 'r) regexps))
2231 (push (cons header regexps) scores))
2233 (gnus-group-make-group group "nnkiboze" address)
2234 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
2235 (let (emacs-lisp-mode-hook)
2236 (pp scores (current-buffer)))))
2238 (defun gnus-group-add-to-virtual (n vgroup)
2239 "Add the current group to a virtual group."
2241 (list current-prefix-arg
2242 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2244 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2245 (error "%s is not an nnvirtual group" vgroup))
2246 (let* ((groups (gnus-group-process-prefix n))
2247 (method (gnus-info-method (gnus-get-info vgroup))))
2248 (setcar (cdr method)
2250 (nth 1 method) "\\|"
2253 (gnus-group-remove-mark s)
2254 (concat "\\(^" (regexp-quote s) "$\\)"))
2256 (gnus-group-position-point))
2258 (defun gnus-group-make-empty-virtual (group)
2259 "Create a new, fresh, empty virtual group."
2260 (interactive "sCreate new, empty virtual group: ")
2261 (let* ((method (list 'nnvirtual "^$"))
2262 (pgroup (gnus-group-prefixed-name group method)))
2263 ;; Check whether it exists already.
2264 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2265 (error "Group %s already exists." pgroup))
2266 ;; Subscribe the new group after the group on the current line.
2267 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2268 (gnus-group-update-group pgroup)
2270 (gnus-group-position-point)))
2272 (defun gnus-group-enter-directory (dir)
2273 "Enter an ephemeral nneething group."
2274 (interactive "DDirectory to read: ")
2275 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2276 (leaf (gnus-group-prefixed-name
2277 (file-name-nondirectory (directory-file-name dir))
2279 (name (gnus-generate-new-group-name leaf)))
2280 (unless (gnus-group-read-ephemeral-group
2282 (cons (current-buffer)
2283 (if (eq major-mode 'gnus-summary-mode)
2285 (error "Couldn't enter %s" dir))))
2287 ;; Group sorting commands
2288 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2290 (defun gnus-group-sort-groups (func &optional reverse)
2291 "Sort the group buffer according to FUNC.
2292 If REVERSE, reverse the sorting order."
2293 (interactive (list gnus-group-sort-function current-prefix-arg))
2294 (funcall gnus-group-sort-alist-function
2295 (gnus-make-sort-function func) reverse)
2296 (gnus-group-list-groups))
2298 (defun gnus-group-sort-flat (func reverse)
2299 ;; We peel off the dummy group from the alist.
2301 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
2302 (pop gnus-newsrc-alist))
2304 (setq gnus-newsrc-alist
2305 (sort gnus-newsrc-alist func))
2307 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2308 ;; Regenerate the hash table.
2309 (gnus-make-hashtable-from-newsrc-alist)))
2311 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2312 "Sort the group buffer alphabetically by group name.
2313 If REVERSE, sort in reverse order."
2315 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2317 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2318 "Sort the group buffer by number of unread articles.
2319 If REVERSE, sort in reverse order."
2321 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2323 (defun gnus-group-sort-groups-by-level (&optional reverse)
2324 "Sort the group buffer by group level.
2325 If REVERSE, sort in reverse order."
2327 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2329 (defun gnus-group-sort-groups-by-score (&optional reverse)
2330 "Sort the group buffer by group score.
2331 If REVERSE, sort in reverse order."
2333 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2335 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2336 "Sort the group buffer by group rank.
2337 If REVERSE, sort in reverse order."
2339 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2341 (defun gnus-group-sort-groups-by-method (&optional reverse)
2342 "Sort the group buffer alphabetically by backend name.
2343 If REVERSE, sort in reverse order."
2345 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2347 ;;; Selected group sorting.
2349 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2350 "Sort the process/prefixed groups."
2351 (interactive (list current-prefix-arg gnus-group-sort-function))
2352 (let ((groups (gnus-group-process-prefix n)))
2353 (funcall gnus-group-sort-selected-function
2354 groups (gnus-make-sort-function func) reverse)
2355 (gnus-group-list-groups)))
2357 (defun gnus-group-sort-selected-flat (groups func reverse)
2358 (let (entries infos)
2359 ;; First find all the group entries for these groups.
2361 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2363 ;; Then sort the infos.
2367 (lambda (entry) (car entry))
2368 (setq entries (nreverse entries)))
2371 (setq infos (nreverse infos)))
2372 ;; Go through all the infos and replace the old entries
2373 ;; with the new infos.
2375 (setcar entries (pop infos))
2377 ;; Update the hashtable.
2378 (gnus-make-hashtable-from-newsrc-alist)))
2380 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2381 "Sort the group buffer alphabetically by group name.
2382 If REVERSE, sort in reverse order."
2384 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2386 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2387 "Sort the group buffer by number of unread articles.
2388 If REVERSE, sort in reverse order."
2390 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2392 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2393 "Sort the group buffer by group level.
2394 If REVERSE, sort in reverse order."
2396 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2398 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2399 "Sort the group buffer by group score.
2400 If REVERSE, sort in reverse order."
2402 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2404 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2405 "Sort the group buffer by group rank.
2406 If REVERSE, sort in reverse order."
2408 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2410 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2411 "Sort the group buffer alphabetically by backend name.
2412 If REVERSE, sort in reverse order."
2414 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2416 ;;; Sorting predicates.
2418 (defun gnus-group-sort-by-alphabet (info1 info2)
2419 "Sort alphabetically."
2420 (string< (gnus-info-group info1) (gnus-info-group info2)))
2422 (defun gnus-group-sort-by-real-name (info1 info2)
2423 "Sort alphabetically on real (unprefixed) names."
2424 (string< (gnus-group-real-name (gnus-info-group info1))
2425 (gnus-group-real-name (gnus-info-group info2))))
2427 (defun gnus-group-sort-by-unread (info1 info2)
2428 "Sort by number of unread articles."
2429 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2430 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2431 (< (or (and (numberp n1) n1) 0)
2432 (or (and (numberp n2) n2) 0))))
2434 (defun gnus-group-sort-by-level (info1 info2)
2436 (< (gnus-info-level info1) (gnus-info-level info2)))
2438 (defun gnus-group-sort-by-method (info1 info2)
2439 "Sort alphabetically by backend name."
2440 (string< (symbol-name (car (gnus-find-method-for-group
2441 (gnus-info-group info1) info1)))
2442 (symbol-name (car (gnus-find-method-for-group
2443 (gnus-info-group info2) info2)))))
2445 (defun gnus-group-sort-by-score (info1 info2)
2446 "Sort by group score."
2447 (< (gnus-info-score info1) (gnus-info-score info2)))
2449 (defun gnus-group-sort-by-rank (info1 info2)
2450 "Sort by level and score."
2451 (let ((level1 (gnus-info-level info1))
2452 (level2 (gnus-info-level info2)))
2453 (or (< level1 level2)
2454 (and (= level1 level2)
2455 (> (gnus-info-score info1) (gnus-info-score info2))))))
2459 (defun gnus-group-clear-data (&optional arg)
2460 "Clear all marks and read ranges from the current group."
2462 (gnus-group-iterate arg
2465 (gnus-info-clear-data (setq info (gnus-get-info group)))
2466 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2467 (when (gnus-group-goto-group group)
2468 (gnus-group-update-group-line))))))
2470 (defun gnus-group-clear-data-on-native-groups ()
2471 "Clear all marks and read ranges from all native groups."
2473 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2474 (let ((alist (cdr gnus-newsrc-alist))
2476 (while (setq info (pop alist))
2477 (when (gnus-group-native-p (gnus-info-group info))
2478 (gnus-info-clear-data info)))
2479 (gnus-get-unread-articles)
2480 (gnus-dribble-enter ""))))
2482 (defun gnus-info-clear-data (info)
2483 "Clear all marks and read ranges from INFO."
2484 (let ((group (gnus-info-group info)))
2487 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2488 (gnus-info-set-read ,info ,(gnus-info-read info))
2489 (when (gnus-group-goto-group ,group)
2490 (gnus-group-update-group-line))))
2491 (gnus-info-set-read info nil)
2492 (when (gnus-info-marks info)
2493 (gnus-info-set-marks info nil))))
2495 ;; Group catching up.
2497 (defun gnus-group-catchup-current (&optional n all)
2498 "Mark all articles not marked as unread in current newsgroup as read.
2499 If prefix argument N is numeric, the ARG next newsgroups will be
2500 caught up. If ALL is non-nil, marked articles will also be marked as
2501 read. Cross references (Xref: header) of articles are ignored.
2502 The difference between N and actual number of newsgroups that were
2503 caught up is returned."
2505 (unless (gnus-group-group-name)
2506 (error "No group on the current line"))
2507 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2511 "Do you really want to mark all articles as read? "
2512 "Mark all unread articles as read? "))))
2514 (let ((groups (gnus-group-process-prefix n))
2517 ;; Virtual groups have to be given special treatment.
2518 (let ((method (gnus-find-method-for-group (car groups))))
2519 (when (eq 'nnvirtual (car method))
2520 (nnvirtual-catchup-group
2521 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2522 (gnus-group-remove-mark (car groups))
2523 (if (>= (gnus-group-group-level) gnus-level-zombie)
2524 (gnus-message 2 "Dead groups can't be caught up")
2526 (gnus-group-goto-group (car groups))
2527 (gnus-group-catchup (car groups) all))
2528 (gnus-group-update-group-line)
2529 (setq ret (1+ ret))))
2530 (setq groups (cdr groups)))
2531 (gnus-group-next-unread-group 1)
2534 (defun gnus-group-catchup-current-all (&optional n)
2535 "Mark all articles in current newsgroup as read.
2536 Cross references (Xref: header) of articles are ignored."
2538 (gnus-group-catchup-current n 'all))
2540 (defun gnus-group-catchup (group &optional all)
2541 "Mark all articles in GROUP as read.
2542 If ALL is non-nil, all articles are marked as read.
2543 The return value is the number of articles that were marked as read,
2544 or nil if no action could be taken."
2545 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2547 ;; Do the updating only if the newsgroup isn't killed.
2548 (if (not (numberp (car entry)))
2549 (gnus-message 1 "Can't catch up %s; non-active group" group)
2550 ;; Do auto-expirable marks if that's required.
2551 (when (gnus-group-auto-expirable-p group)
2552 (gnus-add-marked-articles
2553 group 'expire (gnus-list-of-unread-articles group))
2555 (let ((marks (nth 3 (nth 2 entry))))
2556 (gnus-add-marked-articles
2557 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2558 (gnus-add-marked-articles
2559 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2561 (gnus-update-read-articles group nil)
2562 ;; Also nix out the lists of marks and dormants.
2564 (gnus-add-marked-articles group 'tick nil nil 'force)
2565 (gnus-add-marked-articles group 'dormant nil nil 'force))
2566 (run-hooks 'gnus-group-catchup-group-hook)
2569 (defun gnus-group-expire-articles (&optional n)
2570 "Expire all expirable articles in the current newsgroup."
2572 (let ((groups (gnus-group-process-prefix n))
2575 (error "No groups to expire"))
2576 (while (setq group (pop groups))
2577 (gnus-group-remove-mark group)
2578 (when (gnus-check-backend-function 'request-expire-articles group)
2579 (gnus-message 6 "Expiring articles in %s..." group)
2580 (let* ((info (gnus-get-info group))
2581 (expirable (if (gnus-group-total-expirable-p group)
2582 (cons nil (gnus-list-of-read-articles group))
2583 (assq 'expire (gnus-info-marks info))))
2584 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2588 (gnus-compress-sequence
2590 ;; We set the expiry variables to the group
2592 (let ((nnmail-expiry-wait-function nil)
2593 (nnmail-expiry-wait expiry-wait))
2594 (gnus-request-expire-articles
2595 (gnus-uncompress-sequence (cdr expirable)) group))
2596 ;; Just expire using the normal expiry values.
2597 (gnus-request-expire-articles
2598 (gnus-uncompress-sequence (cdr expirable)) group))))
2599 (gnus-close-group group))
2600 (gnus-message 6 "Expiring articles in %s...done" group)))
2601 (gnus-group-position-point))))
2603 (defun gnus-group-expire-all-groups ()
2604 "Expire all expirable articles in all newsgroups."
2607 (gnus-message 5 "Expiring...")
2608 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2609 (cdr gnus-newsrc-alist))))
2610 (gnus-group-expire-articles nil)))
2611 (gnus-group-position-point)
2612 (gnus-message 5 "Expiring...done"))
2614 (defun gnus-group-set-current-level (n level)
2615 "Set the level of the next N groups to LEVEL."
2620 (let ((s (read-string
2621 (format "Level (default %s): "
2622 (or (gnus-group-group-level)
2623 gnus-level-default-subscribed)))))
2624 (if (string-match "^\\s-*$" s)
2625 (int-to-string (or (gnus-group-group-level)
2626 gnus-level-default-subscribed))
2628 (unless (and (>= level 1) (<= level gnus-level-killed))
2629 (error "Illegal level: %d" level))
2630 (let ((groups (gnus-group-process-prefix n))
2632 (while (setq group (pop groups))
2633 (gnus-group-remove-mark group)
2634 (gnus-message 6 "Changed level of %s from %d to %d"
2635 group (or (gnus-group-group-level) gnus-level-killed)
2637 (gnus-group-change-level
2638 group level (or (gnus-group-group-level) gnus-level-killed))
2639 (gnus-group-update-group-line)))
2640 (gnus-group-position-point))
2642 (defun gnus-group-unsubscribe (&optional n)
2643 "Unsubscribe the current group."
2645 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2647 (defun gnus-group-subscribe (&optional n)
2648 "Unsubscribe the current group."
2650 (gnus-group-unsubscribe-current-group n 'subscribe))
2652 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2653 "Toggle subscription of the current group.
2654 If given numerical prefix, toggle the N next groups."
2656 (let ((groups (gnus-group-process-prefix n))
2659 (setq group (car groups)
2660 groups (cdr groups))
2661 (gnus-group-remove-mark group)
2662 (gnus-group-unsubscribe-group
2665 ((eq do-sub 'unsubscribe)
2666 gnus-level-default-unsubscribed)
2667 ((eq do-sub 'subscribe)
2668 gnus-level-default-subscribed)
2669 ((<= (gnus-group-group-level) gnus-level-subscribed)
2670 gnus-level-default-unsubscribed)
2672 gnus-level-default-subscribed))
2674 (gnus-group-update-group-line))
2675 (gnus-group-next-group 1)))
2677 (defun gnus-group-unsubscribe-group (group &optional level silent)
2678 "Toggle subscription to GROUP.
2679 Killed newsgroups are subscribed. If SILENT, don't try to update the
2682 (list (completing-read
2683 "Group: " gnus-active-hashtb nil
2684 (gnus-read-active-file-p)
2686 'gnus-group-history)))
2687 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2689 ((string-match "^[ \t]$" group)
2690 (error "Empty group name"))
2692 ;; Toggle subscription flag.
2693 (gnus-group-change-level
2694 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2695 gnus-level-subscribed)
2696 (1+ gnus-level-subscribed)
2697 gnus-level-default-subscribed)))
2699 (gnus-group-update-group group)))
2700 ((and (stringp group)
2701 (or (not (gnus-read-active-file-p))
2702 (gnus-active group)))
2703 ;; Add new newsgroup.
2704 (gnus-group-change-level
2706 (if level level gnus-level-default-subscribed)
2707 (or (and (member group gnus-zombie-list)
2710 (when (gnus-group-group-name)
2711 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2713 (gnus-group-update-group group)))
2714 (t (error "No such newsgroup: %s" group)))
2715 (gnus-group-position-point)))
2717 (defun gnus-group-transpose-groups (n)
2718 "Move the current newsgroup up N places.
2719 If given a negative prefix, move down instead. The difference between
2720 N and the number of steps taken is returned."
2722 (unless (gnus-group-group-name)
2723 (error "No group on current line"))
2724 (gnus-group-kill-group 1)
2726 (forward-line (- n))
2727 (gnus-group-yank-group)
2728 (gnus-group-position-point)))
2730 (defun gnus-group-kill-all-zombies ()
2731 "Kill all zombie newsgroups."
2733 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2734 (setq gnus-zombie-list nil)
2735 (gnus-group-list-groups))
2737 (defun gnus-group-kill-region (begin end)
2738 "Kill newsgroups in current region (excluding current point).
2739 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2754 (beginning-of-line) ;Important when LINES < 1
2755 (gnus-group-kill-group lines)))
2757 (defun gnus-group-kill-group (&optional n discard)
2758 "Kill the next N groups.
2759 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2760 However, only groups that were alive can be yanked; already killed
2761 groups or zombie groups can't be yanked.
2762 The return value is the name of the group that was killed, or a list
2765 (let ((buffer-read-only nil)
2766 (groups (gnus-group-process-prefix n))
2767 group entry level out)
2768 (if (< (length groups) 10)
2769 ;; This is faster when there are few groups.
2771 (push (setq group (pop groups)) out)
2772 (gnus-group-remove-mark group)
2773 (setq level (gnus-group-group-level))
2775 (when (and (not discard)
2776 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2779 (gnus-group-goto-group ,(gnus-group-group-name))
2780 (gnus-group-yank-group)))
2781 (push (cons (car entry) (nth 2 entry))
2782 gnus-list-of-killed-groups))
2783 (gnus-group-change-level
2784 (if entry entry group) gnus-level-killed (if entry nil level)))
2785 ;; If there are lots and lots of groups to be killed, we use
2786 ;; this thing instead.
2788 (setq groups (nreverse groups))
2790 (gnus-group-remove-mark (setq group (pop groups)))
2792 (push group gnus-killed-list)
2793 (setq gnus-newsrc-alist
2794 (delq (assoc group gnus-newsrc-alist)
2796 (when gnus-group-change-level-function
2797 (funcall gnus-group-change-level-function group 9 3))
2799 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2800 (push (cons (car entry) (nth 2 entry))
2801 gnus-list-of-killed-groups)
2802 (setcdr (cdr entry) (cdddr entry)))
2803 ((member group gnus-zombie-list)
2804 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2805 (gnus-make-hashtable-from-newsrc-alist)))
2807 (gnus-group-position-point)
2808 (if (< (length out) 2) (car out) (nreverse out))))
2810 (defun gnus-group-yank-group (&optional arg)
2811 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2812 inserting it before the current newsgroup. The numeric ARG specifies
2813 how many newsgroups are to be yanked. The name of the newsgroup yanked
2814 is returned, or (if several groups are yanked) a list of yanked groups
2817 (setq arg (or arg 1))
2818 (let (info group prev out)
2819 (while (>= (decf arg) 0)
2820 (when (not (setq info (pop gnus-list-of-killed-groups)))
2821 (error "No more newsgroups to yank"))
2822 (push (setq group (nth 1 info)) out)
2823 ;; Find which newsgroup to insert this one before - search
2824 ;; backward until something suitable is found. If there are no
2825 ;; other newsgroups in this buffer, just make this newsgroup the
2827 (setq prev (gnus-group-group-name))
2828 (gnus-group-change-level
2829 info (gnus-info-level (cdr info)) gnus-level-killed
2830 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2832 (gnus-group-insert-group-line-info group)
2834 `(when (gnus-group-goto-group ,group)
2835 (gnus-group-kill-group 1))))
2837 (gnus-group-position-point)
2838 (if (< (length out) 2) (car out) (nreverse out))))
2840 (defun gnus-group-kill-level (level)
2841 "Kill all groups that is on a certain LEVEL."
2842 (interactive "nKill all groups on level: ")
2844 ((= level gnus-level-zombie)
2845 (setq gnus-killed-list
2846 (nconc gnus-zombie-list gnus-killed-list))
2847 (setq gnus-zombie-list nil))
2848 ((and (< level gnus-level-zombie)
2850 (or gnus-expert-user
2853 "Do you really want to kill all groups on level %d? "
2855 (let* ((prev gnus-newsrc-alist)
2858 (if (= (gnus-info-level (car alist)) level)
2860 (push (gnus-info-group (car alist)) gnus-killed-list)
2861 (setcdr prev (cdr alist)))
2863 (setq alist (cdr alist)))
2864 (gnus-make-hashtable-from-newsrc-alist)
2865 (gnus-group-list-groups)))
2867 (error "Can't kill; illegal level: %d" level))))
2869 (defun gnus-group-list-all-groups (&optional arg)
2870 "List all newsgroups with level ARG or lower.
2871 Default is gnus-level-unsubscribed, which lists all subscribed and most
2872 unsubscribed groups."
2874 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2876 ;; Redefine this to list ALL killed groups if prefix arg used.
2877 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2878 (defun gnus-group-list-killed (&optional arg)
2879 "List all killed newsgroups in the group buffer.
2880 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2881 entail asking the server for the groups."
2883 ;; Find all possible killed newsgroups if arg.
2885 (gnus-get-killed-groups))
2886 (if (not gnus-killed-list)
2887 (gnus-message 6 "No killed groups")
2888 (let (gnus-group-list-mode)
2889 (funcall gnus-group-prepare-function
2890 gnus-level-killed t gnus-level-killed))
2891 (goto-char (point-min)))
2892 (gnus-group-position-point))
2894 (defun gnus-group-list-zombies ()
2895 "List all zombie newsgroups in the group buffer."
2897 (if (not gnus-zombie-list)
2898 (gnus-message 6 "No zombie groups")
2899 (let (gnus-group-list-mode)
2900 (funcall gnus-group-prepare-function
2901 gnus-level-zombie t gnus-level-zombie))
2902 (goto-char (point-min)))
2903 (gnus-group-position-point))
2905 (defun gnus-group-list-active ()
2906 "List all groups that are available from the server(s)."
2908 ;; First we make sure that we have really read the active file.
2909 (unless (gnus-read-active-file-p)
2910 (let ((gnus-read-active-file t))
2911 (gnus-read-active-file)))
2912 ;; Find all groups and sort them.
2920 (push (symbol-name sym) list)))
2924 (buffer-read-only nil))
2927 (gnus-group-insert-group-line-info (pop groups)))
2928 (goto-char (point-min))))
2930 (defun gnus-activate-all-groups (level)
2931 "Activate absolutely all groups."
2932 (interactive (list 7))
2933 (let ((gnus-activate-level level)
2934 (gnus-activate-foreign-newsgroups level))
2935 (gnus-group-get-new-news)))
2937 (defun gnus-group-get-new-news (&optional arg)
2938 "Get newly arrived articles.
2939 If ARG is a number, it specifies which levels you are interested in
2940 re-scanning. If ARG is non-nil and not a number, this will force
2941 \"hard\" re-reading of the active files from all servers."
2943 (run-hooks 'gnus-get-new-news-hook)
2945 ;; Read any slave files.
2947 (gnus-master-read-slave-newsrc))
2949 ;; We might read in new NoCeM messages here.
2950 (when (and gnus-use-nocem
2952 (gnus-nocem-scan-groups))
2953 ;; If ARG is not a number, then we read the active file.
2954 (when (and arg (not (numberp arg)))
2955 (let ((gnus-read-active-file t))
2956 (gnus-read-active-file))
2959 (setq arg (gnus-group-default-level arg t))
2960 (if (and gnus-read-active-file (not arg))
2962 (gnus-read-active-file)
2963 (gnus-get-unread-articles arg))
2964 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2965 (gnus-get-unread-articles arg)))
2966 (run-hooks 'gnus-after-getting-new-news-hook)
2967 (gnus-group-list-groups))
2969 (defun gnus-group-get-new-news-this-group (&optional n)
2970 "Check for newly arrived news in the current group (and the N-1 next groups).
2971 The difference between N and the number of newsgroup checked is returned.
2972 If N is negative, this group and the N-1 previous groups will be checked."
2974 (let* ((groups (gnus-group-process-prefix n))
2975 (ret (if (numberp n) (- n (length groups)) 0))
2979 (while (setq group (pop groups))
2980 (gnus-group-remove-mark group)
2981 ;; Bypass any previous denials from the server.
2982 (gnus-remove-denial (gnus-find-method-for-group group))
2983 (if (gnus-activate-group group 'scan)
2985 (gnus-get-unread-articles-in-group
2986 (gnus-get-info group) (gnus-active group) t)
2987 (unless (gnus-virtual-group-p group)
2988 (gnus-close-group group))
2989 (gnus-group-update-group group))
2990 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2992 (gnus-error 3 "Server denied access")
2993 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2996 (when gnus-goto-next-group-when-activating
2997 (gnus-group-next-unread-group 1 t))
2998 (gnus-summary-position-point)
3001 (defun gnus-group-fetch-faq (group &optional faq-dir)
3002 "Fetch the FAQ for the current group.
3003 If given a prefix argument, prompt for the FAQ dir
3007 (gnus-group-group-name)
3008 (cond (current-prefix-arg
3010 "Faq dir: " (and (listp gnus-group-faq-directory)
3011 (mapcar (lambda (file) (list file))
3012 gnus-group-faq-directory)))))))
3014 (error "No group name given"))
3015 (let ((dirs (or faq-dir gnus-group-faq-directory))
3017 (unless (listp dirs)
3018 (setq dirs (list dirs)))
3019 (while (and (not found)
3020 (setq dir (pop dirs)))
3021 (setq file (concat (file-name-as-directory dir)
3022 (gnus-group-real-name group)))
3023 (if (not (file-exists-p file))
3024 (gnus-message 1 "No such file: %s" file)
3028 (defun gnus-group-describe-group (force &optional group)
3029 "Display a description of the current newsgroup."
3030 (interactive (list current-prefix-arg (gnus-group-group-name)))
3031 (let* ((method (gnus-find-method-for-group group))
3032 (mname (gnus-group-prefixed-name "" method))
3035 gnus-description-hashtb)
3036 (gnus-sethash mname nil gnus-description-hashtb))
3038 (error "No group name given"))
3039 (when (or (and gnus-description-hashtb
3040 ;; We check whether this group's method has been
3041 ;; queried for a description file.
3042 (gnus-gethash mname gnus-description-hashtb))
3043 (setq desc (gnus-group-get-description group))
3044 (gnus-read-descriptions-file method))
3046 (or desc (gnus-gethash group gnus-description-hashtb)
3047 "No description available")))))
3049 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3050 (defun gnus-group-describe-all-groups (&optional force)
3051 "Pop up a buffer with descriptions of all newsgroups."
3054 (setq gnus-description-hashtb nil))
3055 (when (not (or gnus-description-hashtb
3056 (gnus-read-all-descriptions-files)))
3057 (error "Couldn't request descriptions file"))
3058 (let ((buffer-read-only nil)
3064 (insert (format " *: %-20s %s\n" (symbol-name group)
3065 (symbol-value group)))
3066 (gnus-add-text-properties
3067 b (1+ b) (list 'gnus-group group
3068 'gnus-unread t 'gnus-marked nil
3069 'gnus-level (1+ gnus-level-subscribed))))
3070 gnus-description-hashtb)
3071 (goto-char (point-min))
3072 (gnus-group-position-point)))
3074 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3075 (defun gnus-group-apropos (regexp &optional search-description)
3076 "List all newsgroups that have names that match a regexp."
3077 (interactive "sGnus apropos (regexp): ")
3079 (obuf (current-buffer))
3081 ;; Go through all newsgroups that are known to Gnus.
3084 (and (symbol-name group)
3085 (string-match regexp (symbol-name group))
3086 (push (symbol-name group) groups)))
3088 ;; Also go through all descriptions that are known to Gnus.
3089 (when search-description
3092 (and (string-match regexp (symbol-value group))
3093 (gnus-active (symbol-name group))
3094 (push (symbol-name group) groups)))
3095 gnus-description-hashtb))
3097 (gnus-message 3 "No groups matched \"%s\"." regexp)
3098 ;; Print out all the groups.
3100 (pop-to-buffer "*Gnus Help*")
3101 (buffer-disable-undo (current-buffer))
3103 (setq groups (sort groups 'string<))
3105 ;; Groups may be entered twice into the list of groups.
3106 (when (not (string= (car groups) prev))
3107 (insert (setq prev (car groups)) "\n")
3108 (when (and gnus-description-hashtb
3109 (setq des (gnus-gethash (car groups)
3110 gnus-description-hashtb)))
3111 (insert " " des "\n")))
3112 (setq groups (cdr groups)))
3113 (goto-char (point-min))))
3114 (pop-to-buffer obuf)))
3116 (defun gnus-group-description-apropos (regexp)
3117 "List all newsgroups that have names or descriptions that match a regexp."
3118 (interactive "sGnus description apropos (regexp): ")
3119 (when (not (or gnus-description-hashtb
3120 (gnus-read-all-descriptions-files)))
3121 (error "Couldn't request descriptions file"))
3122 (gnus-group-apropos regexp t))
3124 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3125 (defun gnus-group-list-matching (level regexp &optional all lowest)
3126 "List all groups with unread articles that match REGEXP.
3127 If the prefix LEVEL is non-nil, it should be a number that says which
3128 level to cut off listing groups.
3129 If ALL, also list groups with no unread articles.
3130 If LOWEST, don't list groups with level lower than LOWEST.
3132 This command may read the active file."
3133 (interactive "P\nsList newsgroups matching: ")
3134 ;; First make sure active file has been read.
3136 (> (prefix-numeric-value level) gnus-level-killed))
3137 (gnus-get-killed-groups))
3138 (gnus-group-prepare-flat (or level gnus-level-subscribed)
3139 all (or lowest 1) regexp)
3140 (goto-char (point-min))
3141 (gnus-group-position-point))
3143 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3144 "List all groups that match REGEXP.
3145 If the prefix LEVEL is non-nil, it should be a number that says which
3146 level to cut off listing groups.
3147 If LOWEST, don't list groups with level lower than LOWEST."
3148 (interactive "P\nsList newsgroups matching: ")
3149 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3151 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3152 (defun gnus-group-save-newsrc (&optional force)
3153 "Save the Gnus startup files.
3154 If FORCE, force saving whether it is necessary or not."
3156 (gnus-save-newsrc-file force))
3158 (defun gnus-group-restart (&optional arg)
3159 "Force Gnus to read the .newsrc file."
3161 (when (gnus-yes-or-no-p
3162 (format "Are you sure you want to restart Gnus? "))
3163 (gnus-save-newsrc-file)
3164 (gnus-setup-news 'force)
3165 (gnus-group-list-groups arg)))
3167 (defun gnus-group-read-init-file ()
3168 "Read the Gnus elisp init file."
3170 (gnus-read-init-file))
3172 (defun gnus-group-check-bogus-groups (&optional silent)
3173 "Check bogus newsgroups.
3174 If given a prefix, don't ask for confirmation before removing a bogus
3177 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3178 (gnus-group-list-groups))
3180 (defun gnus-group-edit-global-kill (&optional article group)
3181 "Edit the global kill file.
3182 If GROUP, edit that local kill file instead."
3184 (setq gnus-current-kill-article article)
3185 (gnus-kill-file-edit-file group)
3188 (substitute-command-keys
3189 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3190 (if group "local" "global")))))
3192 (defun gnus-group-edit-local-kill (article group)
3193 "Edit a local kill file."
3194 (interactive (list nil (gnus-group-group-name)))
3195 (gnus-group-edit-global-kill article group))
3197 (defun gnus-group-force-update ()
3198 "Update `.newsrc' file."
3200 (gnus-save-newsrc-file))
3202 (defun gnus-group-suspend ()
3203 "Suspend the current Gnus session.
3204 In fact, cleanup buffers except for group mode buffer.
3205 The hook gnus-suspend-gnus-hook is called before actually suspending."
3207 (run-hooks 'gnus-suspend-gnus-hook)
3208 ;; Kill Gnus buffers except for group mode buffer.
3209 (let* ((group-buf (get-buffer gnus-group-buffer))
3210 ;; Do this on a separate list in case the user does a ^G before we finish
3212 (delete group-buf (delete gnus-dribble-buffer
3213 (append gnus-buffer-list nil)))))
3214 (while gnus-buffer-list
3215 (gnus-kill-buffer (pop gnus-buffer-list)))
3216 (gnus-kill-gnus-frames)
3218 (setq gnus-buffer-list (list group-buf))
3219 (bury-buffer group-buf)
3220 (delete-windows-on group-buf t))))
3222 (defun gnus-group-clear-dribble ()
3223 "Clear all information from the dribble buffer."
3225 (gnus-dribble-clear)
3226 (gnus-message 7 "Cleared dribble buffer"))
3228 (defun gnus-group-exit ()
3229 "Quit reading news after updating .newsrc.eld and .newsrc.
3230 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3233 (or noninteractive ;For gnus-batch-kill
3234 (not gnus-interactive-exit) ;Without confirmation
3236 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3237 (run-hooks 'gnus-exit-gnus-hook)
3238 ;; Offer to save data from non-quitted summary buffers.
3239 (gnus-offer-save-summaries)
3240 ;; Save the newsrc file(s).
3241 (gnus-save-newsrc-file)
3243 (gnus-close-backends)
3244 ;; Reset everything.
3246 ;; Allow the user to do things after cleaning up.
3247 (run-hooks 'gnus-after-exiting-gnus-hook)))
3249 (defun gnus-group-quit ()
3250 "Quit reading news without updating .newsrc.eld or .newsrc.
3251 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3253 (when (or noninteractive ;For gnus-batch-kill
3254 (zerop (buffer-size))
3255 (not (gnus-server-opened gnus-select-method))
3257 (not gnus-current-startup-file)
3259 (format "Quit reading news without saving %s? "
3260 (file-name-nondirectory gnus-current-startup-file))))
3261 (run-hooks 'gnus-exit-gnus-hook)
3262 (gnus-configure-windows 'group t)
3264 (gnus-close-backends)
3266 (gnus-kill-buffer gnus-group-buffer)
3267 ;; Allow the user to do things after cleaning up.
3268 (run-hooks 'gnus-after-exiting-gnus-hook)))
3270 (defun gnus-group-describe-briefly ()
3271 "Give a one line description of the group mode commands."
3273 (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")))
3275 (defun gnus-group-browse-foreign-server (method)
3276 "Browse a foreign news server.
3277 If called interactively, this function will ask for a select method
3278 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3279 If not, METHOD should be a list where the first element is the method
3280 and the second element is the address."
3282 (list (let ((how (completing-read
3284 (append gnus-valid-select-methods gnus-server-alist)
3285 nil t (cons "nntp" 0) 'gnus-method-history)))
3286 ;; We either got a backend name or a virtual server name.
3287 ;; If the first, we also need an address.
3288 (if (assoc how gnus-valid-select-methods)
3290 ;; Suggested by mapjph@bath.ac.uk.
3293 (mapcar (lambda (server) (list server))
3294 gnus-secondary-servers)))
3295 ;; We got a server name, so we find the method.
3296 (gnus-server-to-method how)))))
3297 (gnus-browse-foreign-server method))
3299 (defun gnus-group-set-info (info &optional method-only-group part)
3300 (let* ((entry (gnus-gethash
3301 (or method-only-group (gnus-info-group info))
3302 gnus-newsrc-hashtb))
3304 (info (if method-only-group (nth 2 entry) info))
3306 (when method-only-group
3308 (error "Trying to change non-existent group %s" method-only-group))
3309 ;; We have received parts of the actual group info - either the
3310 ;; select method or the group parameters. We first check
3311 ;; whether we have to extend the info, and if so, do that.
3312 (let ((len (length info))
3313 (total (if (eq part 'method) 5 6)))
3315 (setcdr (nthcdr (1- len) info)
3316 (make-list (- total len) nil)))
3317 ;; Then we enter the new info.
3318 (setcar (nthcdr (1- total) info) part-info)))
3320 ;; This is a new group, so we just create it.
3322 (set-buffer gnus-group-buffer)
3323 (setq method (gnus-info-method info))
3324 (when (gnus-server-equal method "native")
3327 (set-buffer gnus-group-buffer)
3329 ;; It's a foreign group...
3330 (gnus-group-make-group
3331 (gnus-group-real-name (gnus-info-group info))
3332 (if (stringp method) method
3333 (prin1-to-string (car method)))
3335 (nth 1 (gnus-info-method info))))
3336 ;; It's a native group.
3337 (gnus-group-make-group (gnus-info-group info))))
3338 (gnus-message 6 "Note: New group created")
3340 (gnus-gethash (gnus-group-prefixed-name
3341 (gnus-group-real-name (gnus-info-group info))
3342 (or (gnus-info-method info) gnus-select-method))
3343 gnus-newsrc-hashtb))))
3344 ;; Whether it was a new group or not, we now have the entry, so we
3345 ;; can do the update.
3348 (setcar (nthcdr 2 entry) info)
3349 (when (and (not (eq (car entry) t))
3350 (gnus-active (gnus-info-group info)))
3351 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3352 (error "No such group: %s" (gnus-info-group info)))))
3354 (defun gnus-group-set-method-info (group select-method)
3355 (gnus-group-set-info select-method group 'method))
3357 (defun gnus-group-set-params-info (group params)
3358 (gnus-group-set-info params group 'params))
3360 (defun gnus-add-marked-articles (group type articles &optional info force)
3361 ;; Add ARTICLES of TYPE to the info of GROUP.
3362 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3363 ;; add, but replace marked articles of TYPE with ARTICLES.
3364 (let ((info (or info (gnus-get-info group)))
3365 (uncompressed '(score bookmark killed))
3368 (and (not (setq marked (nthcdr 3 info)))
3370 (setcdr (nthcdr 2 info)
3371 (list (list (cons type (gnus-compress-sequence
3373 (and (not (setq m (assq type (car marked))))
3376 (cons (cons type (gnus-compress-sequence articles t) )
3380 (setcar (nthcdr 3 info)
3381 (delq (assq type (car marked)) (car marked)))
3382 (setcdr m (gnus-compress-sequence articles t)))
3383 (setcdr m (gnus-compress-sequence
3384 (sort (nconc (gnus-uncompress-range (cdr m))
3385 (copy-sequence articles)) '<) t))))))
3388 ;;; Group timestamps
3391 (defun gnus-group-set-timestamp ()
3392 "Change the timestamp of the current group to the current time.
3393 This function can be used in hooks like `gnus-select-group-hook'."
3394 (let ((time (current-time)))
3395 (setcdr (cdr time) nil)
3396 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time)))
3398 (defsubst gnus-group-timestamp (group)
3399 "Return the timestamp for GROUP."
3400 (gnus-group-get-parameter group 'timestamp))
3402 (defun gnus-group-timestamp-string (group)
3403 "Return a string of the timestamp for GROUP."
3404 (let ((time (gnus-group-timestamp group)))
3407 (gnus-time-iso8601 time))))
3409 (provide 'gnus-group)
3411 ;;; gnus-group.el ends here