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."
198 :options '(gnus-topic-mode)
201 (defcustom gnus-group-menu-hook nil
202 "Hook run after the creation of the group mode menu."
206 (defcustom gnus-group-catchup-group-hook nil
207 "Hook run when catching up a group from the group buffer."
211 (defcustom gnus-group-update-group-hook nil
212 "Hook called when updating group lines."
216 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
217 "*A function that is called to generate the group buffer.
218 The function is called with three arguments: The first is a number;
219 all group with a level less or equal to that number should be listed,
220 if the second is non-nil, empty groups should also be displayed. If
221 the third is non-nil, it is a number. No groups with a level lower
222 than this number should be displayed.
224 The only current function implemented is `gnus-group-prepare-flat'."
228 (defcustom gnus-group-prepare-hook nil
229 "Hook called after the group buffer has been generated.
230 If you want to modify the group buffer, you can use this hook."
234 (defcustom gnus-suspend-gnus-hook nil
235 "Hook called when suspending (not exiting) Gnus."
239 (defcustom gnus-exit-gnus-hook nil
240 "Hook called when exiting Gnus."
244 (defcustom gnus-after-exiting-gnus-hook nil
245 "Hook called after exiting Gnus."
249 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
250 "Hook called when a group line is changed.
251 The hook will not be called if `gnus-visual' is nil.
253 The default function `gnus-group-highlight-line' will
254 highlight the line according to the `gnus-group-highlight'
259 (defcustom gnus-useful-groups
260 `(("(ding) mailing list mirrored at sunsite.auc.dk"
262 (nntp "sunsite.auc.dk"
263 (nntp-address "sunsite.auc.dk")))
267 (nndoc-article-type mbox)
268 (eval `(nndoc-address
269 ,(let ((file (nnheader-find-etc-directory
272 (error "Couldn't find doc group"))
274 "Alist of useful group-server pairs."
276 :type '(repeat (list (string :tag "Description")
278 (sexp :tag "Method"))))
280 (defface gnus-group-news-1-face
283 (:foreground "PaleTurquoise" :bold t))
286 (:foreground "ForestGreen" :bold t))
289 "Level 1 newsgroup face.")
291 (defface gnus-group-news-1-empty-face
294 (:foreground "PaleTurquoise"))
297 (:foreground "ForestGreen"))
300 "Level 1 empty newsgroup face.")
302 (defface gnus-group-news-2-face
305 (:foreground "turquoise" :bold t))
308 (:foreground "CadetBlue4" :bold t))
311 "Level 2 newsgroup face.")
313 (defface gnus-group-news-2-empty-face
316 (:foreground "turquoise"))
319 (:foreground "CadetBlue4"))
322 "Level 2 empty newsgroup face.")
324 (defface gnus-group-news-3-face
333 "Level 3 newsgroup face.")
335 (defface gnus-group-news-3-empty-face
344 "Level 3 empty newsgroup face.")
346 (defface gnus-group-news-low-face
349 (:foreground "DarkTurquoise" :bold t))
352 (:foreground "DarkGreen" :bold t))
355 "Low level newsgroup face.")
357 (defface gnus-group-news-low-empty-face
360 (:foreground "DarkTurquoise"))
363 (:foreground "DarkGreen"))
366 "Low level empty newsgroup face.")
368 (defface gnus-group-mail-1-face
371 (:foreground "aquamarine1" :bold t))
374 (:foreground "DeepPink3" :bold t))
377 "Level 1 mailgroup face.")
379 (defface gnus-group-mail-1-empty-face
382 (:foreground "aquamarine1"))
385 (:foreground "DeepPink3"))
387 (:italic t :bold t)))
388 "Level 1 empty mailgroup face.")
390 (defface gnus-group-mail-2-face
393 (:foreground "aquamarine2" :bold t))
396 (:foreground "HotPink3" :bold t))
399 "Level 2 mailgroup face.")
401 (defface gnus-group-mail-2-empty-face
404 (:foreground "aquamarine2"))
407 (:foreground "HotPink3"))
410 "Level 2 empty mailgroup face.")
412 (defface gnus-group-mail-3-face
415 (:foreground "aquamarine3" :bold t))
418 (:foreground "magenta4" :bold t))
421 "Level 3 mailgroup face.")
423 (defface gnus-group-mail-3-empty-face
426 (:foreground "aquamarine3"))
429 (:foreground "magenta4"))
432 "Level 3 empty mailgroup face.")
434 (defface gnus-group-mail-low-face
437 (:foreground "aquamarine4" :bold t))
440 (:foreground "DeepPink4" :bold t))
443 "Low level mailgroup face.")
445 (defface gnus-group-mail-low-empty-face
448 (:foreground "aquamarine4"))
451 (:foreground "DeepPink4"))
454 "Low level empty mailgroup face.")
456 (defcustom gnus-group-highlight
458 ((and (= unread 0) (not mailp) (eq level 1)) .
459 gnus-group-news-1-empty-face)
460 ((and (not mailp) (eq level 1)) .
461 gnus-group-news-1-face)
462 ((and (= unread 0) (not mailp) (eq level 2)) .
463 gnus-group-news-2-empty-face)
464 ((and (not mailp) (eq level 2)) .
465 gnus-group-news-2-face)
466 ((and (= unread 0) (not mailp) (eq level 3)) .
467 gnus-group-news-3-empty-face)
468 ((and (not mailp) (eq level 3)) .
469 gnus-group-news-3-face)
470 ((and (= unread 0) (not mailp)) .
471 gnus-group-news-low-empty-face)
473 gnus-group-news-low-face)
475 ((and (= unread 0) (eq level 1)) .
476 gnus-group-mail-1-empty-face)
478 gnus-group-mail-1-face)
479 ((and (= unread 0) (eq level 2)) .
480 gnus-group-mail-2-empty-face)
482 gnus-group-mail-2-face)
483 ((and (= unread 0) (eq level 3)) .
484 gnus-group-mail-3-empty-face)
486 gnus-group-mail-3-face)
488 gnus-group-mail-low-empty-face)
490 gnus-group-mail-low-face))
491 "Controls the highlighting of group buffer lines.
493 Below is a list of `Form'/`Face' pairs. When deciding how a a
494 particular group line should be displayed, each form is
495 evaluated. The content of the face field after the first true form is
496 used. You can change how those group lines are displayed by
497 editing the face field.
499 It is also possible to change and add form fields, but currently that
500 requires an understanding of Lisp expressions. Hopefully this will
501 change in a future release. For now, you can use the following
502 variables in the Lisp expression:
504 group: The name of the group.
505 unread: The number of unread articles in the group.
506 method: The select method used.
507 mailp: Whether it's a mail group or not.
508 level: The level of the group.
509 score: The score of the group.
510 ticked: The number of ticked articles."
512 :type '(repeat (cons (sexp :tag "Form") face)))
514 (defcustom gnus-new-mail-mark ?%
515 "Mark used for groups with new mail."
519 ;;; Internal variables
521 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
522 "Function for sorting the group buffer.")
524 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
525 "Function for sorting the selected groups in the group buffer.")
527 (defvar gnus-group-indentation-function nil)
528 (defvar gnus-goto-missing-group-function nil)
529 (defvar gnus-group-update-group-function nil)
530 (defvar gnus-group-goto-next-group-function nil
531 "Function to override finding the next group after listing groups.")
533 (defvar gnus-group-edit-buffer nil)
535 (defvar gnus-group-line-format-alist
536 `((?M gnus-tmp-marked-mark ?c)
537 (?S gnus-tmp-subscribed ?c)
538 (?L gnus-tmp-level ?d)
539 (?N (cond ((eq number t) "*" )
543 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
544 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
546 (?R gnus-tmp-number-of-read ?s)
547 (?t gnus-tmp-number-total ?d)
548 (?y gnus-tmp-number-of-unread ?s)
549 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
550 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
551 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
552 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
553 (?g gnus-tmp-group ?s)
554 (?G gnus-tmp-qualified-group ?s)
555 (?c (gnus-short-group-name gnus-tmp-group) ?s)
556 (?D gnus-tmp-newsgroup-description ?s)
557 (?o gnus-tmp-moderated ?c)
558 (?O gnus-tmp-moderated-string ?s)
559 (?p gnus-tmp-process-marked ?c)
560 (?s gnus-tmp-news-server ?s)
561 (?n gnus-tmp-news-method ?s)
562 (?P gnus-group-indentation ?s)
563 (?l gnus-tmp-grouplens ?s)
564 (?z gnus-tmp-news-method-string ?s)
565 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
566 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
567 (?u gnus-tmp-user-defined ?s)))
569 (defvar gnus-group-mode-line-format-alist
570 `((?S gnus-tmp-news-server ?s)
571 (?M gnus-tmp-news-method ?s)
572 (?u gnus-tmp-user-defined ?s)
573 (?: gnus-tmp-colon ?s)))
575 (defvar gnus-topic-topology nil
576 "The complete topic hierarchy.")
578 (defvar gnus-topic-alist nil
579 "The complete topic-group alist.")
581 (defvar gnus-group-marked nil)
583 (defvar gnus-group-list-mode nil)
589 (put 'gnus-group-mode 'mode-class 'special)
592 (gnus-define-keys gnus-group-mode-map
593 " " gnus-group-read-group
594 "=" gnus-group-select-group
595 "\r" gnus-group-select-group
596 "\M-\r" gnus-group-quick-select-group
597 "j" gnus-group-jump-to-group
598 "n" gnus-group-next-unread-group
599 "p" gnus-group-prev-unread-group
600 "\177" gnus-group-prev-unread-group
601 [delete] gnus-group-prev-unread-group
602 "N" gnus-group-next-group
603 "P" gnus-group-prev-group
604 "\M-n" gnus-group-next-unread-group-same-level
605 "\M-p" gnus-group-prev-unread-group-same-level
606 "," gnus-group-best-unread-group
607 "." gnus-group-first-unread-group
608 "u" gnus-group-unsubscribe-current-group
609 "U" gnus-group-unsubscribe-group
610 "c" gnus-group-catchup-current
611 "C" gnus-group-catchup-current-all
612 "\M-c" gnus-group-clear-data
613 "l" gnus-group-list-groups
614 "L" gnus-group-list-all-groups
616 "g" gnus-group-get-new-news
617 "\M-g" gnus-group-get-new-news-this-group
618 "R" gnus-group-restart
619 "r" gnus-group-read-init-file
620 "B" gnus-group-browse-foreign-server
621 "b" gnus-group-check-bogus-groups
622 "F" gnus-find-new-newsgroups
623 "\C-c\C-d" gnus-group-describe-group
624 "\M-d" gnus-group-describe-all-groups
625 "\C-c\C-a" gnus-group-apropos
626 "\C-c\M-\C-a" gnus-group-description-apropos
627 "a" gnus-group-post-news
628 "\ek" gnus-group-edit-local-kill
629 "\eK" gnus-group-edit-global-kill
630 "\C-k" gnus-group-kill-group
631 "\C-y" gnus-group-yank-group
632 "\C-w" gnus-group-kill-region
633 "\C-x\C-t" gnus-group-transpose-groups
634 "\C-c\C-l" gnus-group-list-killed
635 "\C-c\C-x" gnus-group-expire-articles
636 "\C-c\M-\C-x" gnus-group-expire-all-groups
638 "s" gnus-group-save-newsrc
639 "z" gnus-group-suspend
642 "?" gnus-group-describe-briefly
643 "\C-c\C-i" gnus-info-find-node
644 "\M-e" gnus-group-edit-group-method
645 "^" gnus-group-enter-server-mode
646 gnus-mouse-2 gnus-mouse-pick-group
647 "<" beginning-of-buffer
650 "\C-c\C-s" gnus-group-sort-groups
652 "\C-c\M-g" gnus-activate-all-groups
653 "\M-&" gnus-group-universal-argument
654 "#" gnus-group-mark-group
655 "\M-#" gnus-group-unmark-group)
657 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
658 "m" gnus-group-mark-group
659 "u" gnus-group-unmark-group
660 "w" gnus-group-mark-region
661 "m" gnus-group-mark-buffer
662 "r" gnus-group-mark-regexp
663 "U" gnus-group-unmark-all-groups)
665 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
666 "d" gnus-group-make-directory-group
667 "h" gnus-group-make-help-group
668 "u" gnus-group-make-useful-group
669 "a" gnus-group-make-archive-group
670 "k" gnus-group-make-kiboze-group
671 "m" gnus-group-make-group
672 "E" gnus-group-edit-group
673 "e" gnus-group-edit-group-method
674 "p" gnus-group-edit-group-parameters
675 "v" gnus-group-add-to-virtual
676 "V" gnus-group-make-empty-virtual
677 "D" gnus-group-enter-directory
678 "f" gnus-group-make-doc-group
679 "w" gnus-group-make-web-group
680 "r" gnus-group-rename-group
681 "c" gnus-group-customize
682 "\177" gnus-group-delete-group
683 [delete] gnus-group-delete-group)
685 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
686 "b" gnus-group-brew-soup
687 "w" gnus-soup-save-areas
688 "s" gnus-soup-send-replies
689 "p" gnus-soup-pack-packet
690 "r" nnsoup-pack-replies)
692 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
693 "s" gnus-group-sort-groups
694 "a" gnus-group-sort-groups-by-alphabet
695 "u" gnus-group-sort-groups-by-unread
696 "l" gnus-group-sort-groups-by-level
697 "v" gnus-group-sort-groups-by-score
698 "r" gnus-group-sort-groups-by-rank
699 "m" gnus-group-sort-groups-by-method)
701 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
702 "s" gnus-group-sort-selected-groups
703 "a" gnus-group-sort-selected-groups-by-alphabet
704 "u" gnus-group-sort-selected-groups-by-unread
705 "l" gnus-group-sort-selected-groups-by-level
706 "v" gnus-group-sort-selected-groups-by-score
707 "r" gnus-group-sort-selected-groups-by-rank
708 "m" gnus-group-sort-selected-groups-by-method)
710 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
711 "k" gnus-group-list-killed
712 "z" gnus-group-list-zombies
713 "s" gnus-group-list-groups
714 "u" gnus-group-list-all-groups
715 "A" gnus-group-list-active
716 "a" gnus-group-apropos
717 "d" gnus-group-description-apropos
718 "m" gnus-group-list-matching
719 "M" gnus-group-list-all-matching
720 "l" gnus-group-list-level)
722 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
723 "f" gnus-score-flush-cache)
725 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
726 "d" gnus-group-describe-group
727 "f" gnus-group-fetch-faq)
729 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
730 "l" gnus-group-set-current-level
731 "t" gnus-group-unsubscribe-current-group
732 "s" gnus-group-unsubscribe-group
733 "k" gnus-group-kill-group
734 "y" gnus-group-yank-group
735 "w" gnus-group-kill-region
736 "\C-k" gnus-group-kill-level
737 "z" gnus-group-kill-all-zombies))
739 (defun gnus-group-make-menu-bar ()
740 (gnus-turn-off-edit-menu 'group)
741 (unless (boundp 'gnus-group-reading-menu)
744 gnus-group-reading-menu gnus-group-mode-map ""
746 ["Read" gnus-group-read-group (gnus-group-group-name)]
747 ["Select" gnus-group-select-group (gnus-group-group-name)]
748 ["See old articles" (gnus-group-select-group 'all)
749 :keys "C-u SPC" :active (gnus-group-group-name)]
750 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
751 ["Catch up all articles" gnus-group-catchup-current-all
752 (gnus-group-group-name)]
753 ["Check for new articles" gnus-group-get-new-news-this-group
754 (gnus-group-group-name)]
755 ["Toggle subscription" gnus-group-unsubscribe-current-group
756 (gnus-group-group-name)]
757 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
758 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
759 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
760 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
761 ["Edit kill file" gnus-group-edit-local-kill
762 (gnus-group-group-name)]
763 ;; Actually one should check, if any of the marked groups gives t for
764 ;; (gnus-check-backend-function 'request-expire-articles ...)
765 ["Expire articles" gnus-group-expire-articles
766 (or (and (gnus-group-group-name)
767 (gnus-check-backend-function
768 'request-expire-articles
769 (gnus-group-group-name))) gnus-group-marked)]
770 ["Set group level" gnus-group-set-current-level
771 (gnus-group-group-name)]
772 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
776 gnus-group-group-menu gnus-group-mode-map ""
779 ["List unread subscribed groups" gnus-group-list-groups t]
780 ["List (un)subscribed groups" gnus-group-list-all-groups t]
781 ["List killed groups" gnus-group-list-killed gnus-killed-list]
782 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
783 ["List level..." gnus-group-list-level t]
784 ["Describe all groups" gnus-group-describe-all-groups t]
785 ["Group apropos..." gnus-group-apropos t]
786 ["Group and description apropos..." gnus-group-description-apropos t]
787 ["List groups matching..." gnus-group-list-matching t]
788 ["List all groups matching..." gnus-group-list-all-matching t]
789 ["List active file" gnus-group-list-active t])
791 ["Default sort" gnus-group-sort-groups t]
792 ["Sort by method" gnus-group-sort-groups-by-method t]
793 ["Sort by rank" gnus-group-sort-groups-by-rank t]
794 ["Sort by score" gnus-group-sort-groups-by-score t]
795 ["Sort by level" gnus-group-sort-groups-by-level t]
796 ["Sort by unread" gnus-group-sort-groups-by-unread t]
797 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
798 ("Sort process/prefixed"
799 ["Default sort" gnus-group-sort-selected-groups
800 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
801 ["Sort by method" gnus-group-sort-selected-groups-by-method
802 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
803 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
804 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
805 ["Sort by score" gnus-group-sort-selected-groups-by-score
806 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
807 ["Sort by level" gnus-group-sort-selected-groups-by-level
808 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
809 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
810 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
811 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
812 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
814 ["Mark group" gnus-group-mark-group
815 (and (gnus-group-group-name)
816 (not (memq (gnus-group-group-name) gnus-group-marked)))]
817 ["Unmark group" gnus-group-unmark-group
818 (and (gnus-group-group-name)
819 (memq (gnus-group-group-name) gnus-group-marked))]
820 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
821 ["Mark regexp..." gnus-group-mark-regexp t]
822 ["Mark region" gnus-group-mark-region t]
823 ["Mark buffer" gnus-group-mark-buffer t]
824 ["Execute command" gnus-group-universal-argument
825 (or gnus-group-marked (gnus-group-group-name))])
827 ["Subscribe to a group" gnus-group-unsubscribe-group t]
828 ["Kill all newsgroups in region" gnus-group-kill-region t]
829 ["Kill all zombie groups" gnus-group-kill-all-zombies
831 ["Kill all groups on level..." gnus-group-kill-level t])
833 ["Make a foreign group" gnus-group-make-group t]
834 ["Add a directory group" gnus-group-make-directory-group t]
835 ["Add the help group" gnus-group-make-help-group t]
836 ["Add the archive group" gnus-group-make-archive-group t]
837 ["Make a doc group" gnus-group-make-doc-group t]
838 ["Make a web group" gnus-group-make-web-group t]
839 ["Make a kiboze group" gnus-group-make-kiboze-group t]
840 ["Make a virtual group" gnus-group-make-empty-virtual t]
841 ["Add a group to a virtual" gnus-group-add-to-virtual t]
842 ["Rename group" gnus-group-rename-group
843 (gnus-check-backend-function
844 'request-rename-group (gnus-group-group-name))]
845 ["Delete group" gnus-group-delete-group
846 (gnus-check-backend-function
847 'request-delete-group (gnus-group-group-name))])
849 ["Parameters" gnus-group-edit-group-parameters
850 (gnus-group-group-name)]
851 ["Select method" gnus-group-edit-group-method
852 (gnus-group-group-name)]
853 ["Info" gnus-group-edit-group (gnus-group-group-name)])
855 ["Flush cache" gnus-score-flush-cache t])
857 ["Next" gnus-group-next-group t]
858 ["Previous" gnus-group-prev-group t]
859 ["Next unread" gnus-group-next-unread-group t]
860 ["Previous unread" gnus-group-prev-unread-group t]
861 ["Next unread same level" gnus-group-next-unread-group-same-level t]
862 ["Previous unread same level"
863 gnus-group-prev-unread-group-same-level t]
864 ["Jump to group" gnus-group-jump-to-group t]
865 ["First unread group" gnus-group-first-unread-group t]
866 ["Best unread group" gnus-group-best-unread-group t])
867 ["Transpose" gnus-group-transpose-groups
868 (gnus-group-group-name)]
869 ["Read a directory as a group..." gnus-group-enter-directory t]
873 gnus-group-misc-menu gnus-group-mode-map ""
875 ["Send a bug report" gnus-bug t]
876 ["Customize" gnus-group-customize t]
877 ["Send a mail" gnus-group-mail t]
878 ["Post an article..." gnus-group-post-news t]
879 ["Check for new news" gnus-group-get-new-news t]
880 ["Activate all groups" gnus-activate-all-groups t]
881 ["Delete bogus groups" gnus-group-check-bogus-groups t]
882 ["Find new newsgroups" gnus-find-new-newsgroups t]
883 ["Restart Gnus" gnus-group-restart t]
884 ["Read init file" gnus-group-read-init-file t]
885 ["Browse foreign server" gnus-group-browse-foreign-server t]
886 ["Enter server buffer" gnus-group-enter-server-mode t]
887 ["Expire all expirable articles" gnus-group-expire-all-groups t]
888 ["Generate any kiboze groups" nnkiboze-generate-groups t]
889 ["Gnus version" gnus-version t]
890 ["Save .newsrc files" gnus-group-save-newsrc t]
891 ["Suspend Gnus" gnus-group-suspend t]
892 ["Clear dribble buffer" gnus-group-clear-dribble t]
893 ["Edit global kill file" gnus-group-edit-global-kill t]
894 ["Read manual" gnus-info-find-node t]
895 ["Toggle topics" gnus-topic-mode t]
897 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
898 ["Send replies" gnus-soup-send-replies
899 (fboundp 'gnus-soup-pack-packet)]
900 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
901 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
902 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
903 ["Exit from Gnus" gnus-group-exit t]
904 ["Exit without saving" gnus-group-quit t]
907 (run-hooks 'gnus-group-menu-hook)
910 (defun gnus-group-mode ()
911 "Major mode for reading news.
913 All normal editing commands are switched off.
914 \\<gnus-group-mode-map>
915 The group buffer lists (some of) the groups available. For instance,
916 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
917 lists all zombie groups.
919 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
920 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
922 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
924 The following commands are available:
926 \\{gnus-group-mode-map}"
928 (when (and menu-bar-mode
929 (gnus-visual-p 'group-menu 'menu))
930 (gnus-group-make-menu-bar))
931 (kill-all-local-variables)
932 (gnus-simplify-mode-line)
933 (setq major-mode 'gnus-group-mode)
934 (setq mode-name "Group")
935 (gnus-group-set-mode-line)
936 (setq mode-line-process nil)
937 (use-local-map gnus-group-mode-map)
938 (buffer-disable-undo (current-buffer))
939 (setq truncate-lines t)
940 (setq buffer-read-only t)
941 (gnus-set-default-directory)
942 (gnus-update-format-specifications nil 'group 'group-mode)
943 (gnus-update-group-mark-positions)
944 (gnus-make-local-hook 'post-command-hook)
945 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
948 (run-hooks 'gnus-group-mode-hook))
950 (defun gnus-update-group-mark-positions ()
952 (let ((gnus-process-mark 128)
953 (gnus-group-marked '("dummy.group"))
954 (gnus-active-hashtb (make-vector 10 0)))
955 (gnus-set-active "dummy.group" '(0 . 0))
956 (gnus-set-work-buffer)
957 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
958 (goto-char (point-min))
959 (setq gnus-group-mark-positions
960 (list (cons 'process (and (search-forward "\200" nil t)
963 (defun gnus-clear-inboxes-moved ()
964 (setq nnmail-moved-inboxes nil))
966 (defun gnus-mouse-pick-group (e)
967 "Enter the group under the mouse pointer."
970 (gnus-group-read-group nil))
972 ;; Look at LEVEL and find out what the level is really supposed to be.
973 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
974 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
975 (defun gnus-group-default-level (&optional level number-or-nil)
977 (gnus-group-use-permanent-levels
978 (or (setq gnus-group-use-permanent-levels
979 (or level (if (numberp gnus-group-use-permanent-levels)
980 gnus-group-use-permanent-levels
981 (or gnus-group-default-list-level
982 gnus-level-subscribed))))
983 gnus-group-default-list-level gnus-level-subscribed))
987 (or level gnus-group-default-list-level gnus-level-subscribed))))
989 (defun gnus-group-setup-buffer ()
990 (switch-to-buffer gnus-group-buffer)
991 (unless (eq major-mode 'gnus-group-mode)
992 (gnus-add-current-to-buffer-list)
995 (gnus-carpal-setup-buffer 'group))))
997 (defun gnus-group-list-groups (&optional level unread lowest)
998 "List newsgroups with level LEVEL or lower that have unread articles.
999 Default is all subscribed groups.
1000 If argument UNREAD is non-nil, groups with no unread articles are also
1003 (list (if current-prefix-arg
1004 (prefix-numeric-value current-prefix-arg)
1006 (gnus-group-default-level nil t)
1007 gnus-group-default-list-level
1008 gnus-level-subscribed))))
1009 ;; Just do this here, for no particular good reason.
1010 (gnus-clear-inboxes-moved)
1012 (setq level (car gnus-group-list-mode)
1013 unread (cdr gnus-group-list-mode)))
1014 (setq level (gnus-group-default-level level))
1015 (gnus-group-setup-buffer) ;May call from out of group buffer
1016 (gnus-update-format-specifications nil 'group 'group-mode)
1017 (let ((case-fold-search nil)
1018 (props (text-properties-at (gnus-point-at-bol)))
1019 (group (gnus-group-group-name)))
1020 (set-buffer gnus-group-buffer)
1021 (funcall gnus-group-prepare-function level unread lowest)
1022 (if (zerop (buffer-size))
1023 (gnus-message 5 gnus-no-groups-message)
1024 (goto-char (point-max))
1025 (when (or (not gnus-group-goto-next-group-function)
1026 (not (funcall gnus-group-goto-next-group-function
1029 ;; Go to the first group with unread articles.
1030 (gnus-group-search-forward t)
1031 ;; Find the right group to put point on. If the current group
1032 ;; has disappeared in the new listing, try to find the next
1033 ;; one. If no next one can be found, just leave point at the
1034 ;; first newsgroup in the buffer.
1035 (when (not (gnus-goto-char
1037 (point-min) (point-max)
1038 'gnus-group (gnus-intern-safe
1039 group gnus-active-hashtb))))
1040 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1042 (not (gnus-goto-char
1044 (point-min) (point-max) 'gnus-group
1046 (caar newsrc) gnus-active-hashtb)))))
1047 (setq newsrc (cdr newsrc)))
1049 (goto-char (point-max))
1050 (forward-line -1))))))
1051 ;; Adjust cursor point.
1052 (gnus-group-position-point))))
1054 (defun gnus-group-list-level (level &optional all)
1055 "List groups on LEVEL.
1056 If ALL (the prefix), also list groups that have no unread articles."
1057 (interactive "nList groups on level: \nP")
1058 (gnus-group-list-groups level all level))
1060 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
1061 "List all newsgroups with unread articles of level LEVEL or lower.
1062 If ALL is non-nil, list groups that have no unread articles.
1063 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1064 If REGEXP, only list groups matching REGEXP."
1065 (set-buffer gnus-group-buffer)
1066 (let ((buffer-read-only nil)
1067 (newsrc (cdr gnus-newsrc-alist))
1068 (lowest (or lowest 1))
1069 info clevel unread group params)
1071 (when (< lowest gnus-level-zombie)
1072 ;; List living groups.
1074 (setq info (car newsrc)
1075 group (gnus-info-group info)
1076 params (gnus-info-params info)
1078 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1079 (and unread ; This group might be bogus
1081 (string-match regexp group))
1082 (<= (setq clevel (gnus-info-level info)) level)
1084 (or all ; We list all groups?
1085 (if (eq unread t) ; Unactivated?
1086 gnus-group-list-inactive-groups ; We list unactivated
1087 (> unread 0)) ; We list groups with unread articles
1088 (and gnus-list-groups-with-ticked-articles
1089 (cdr (assq 'tick (gnus-info-marks info))))
1090 ; And groups with tickeds
1091 ;; Check for permanent visibility.
1092 (and gnus-permanently-visible-groups
1093 (string-match gnus-permanently-visible-groups
1095 (memq 'visible params)
1096 (cdr (assq 'visible params)))
1097 (gnus-group-insert-group-line
1098 group (gnus-info-level info)
1099 (gnus-info-marks info) unread (gnus-info-method info)))))
1101 ;; List dead groups.
1102 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
1103 (gnus-group-prepare-flat-list-dead
1104 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1105 gnus-level-zombie ?Z
1107 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
1108 (gnus-group-prepare-flat-list-dead
1109 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1110 gnus-level-killed ?K regexp))
1112 (gnus-group-set-mode-line)
1113 (setq gnus-group-list-mode (cons level all))
1114 (run-hooks 'gnus-group-prepare-hook)))
1116 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1117 ;; List zombies and killed lists somewhat faster, which was
1118 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1119 ;; this by ignoring the group format specification altogether.
1122 ;; This loop is used when listing groups that match some
1125 (setq group (pop groups))
1126 (when (string-match regexp group)
1127 (gnus-add-text-properties
1128 (point) (prog1 (1+ (point))
1129 (insert " " mark " *: " group "\n"))
1130 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1132 'gnus-level level))))
1133 ;; This loop is used when listing all groups.
1135 (gnus-add-text-properties
1136 (point) (prog1 (1+ (point))
1137 (insert " " mark " *: "
1138 (setq group (pop groups)) "\n"))
1139 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1141 'gnus-level level))))))
1143 (defun gnus-group-update-group-line ()
1144 "Update the current line in the group buffer."
1145 (let* ((buffer-read-only nil)
1146 (group (gnus-group-group-name))
1147 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1148 gnus-group-indentation)
1151 (not (gnus-ephemeral-group-p group))
1153 (concat "(gnus-group-set-info '"
1154 (gnus-prin1-to-string (nth 2 entry))
1156 (setq gnus-group-indentation (gnus-group-group-indentation))
1158 (gnus-group-insert-group-line-info group)
1160 (gnus-group-position-point))))
1162 (defun gnus-group-insert-group-line-info (group)
1163 "Insert GROUP on the current line."
1164 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1165 (gnus-group-indentation (gnus-group-group-indentation))
1169 ;; (Un)subscribed group.
1170 (setq info (nth 2 entry))
1171 (gnus-group-insert-group-line
1172 group (gnus-info-level info) (gnus-info-marks info)
1173 (or (car entry) t) (gnus-info-method info)))
1174 ;; This group is dead.
1175 (gnus-group-insert-group-line
1177 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1179 (if (setq active (gnus-active group))
1180 (- (1+ (cdr active)) (car active)) 0)
1183 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1184 gnus-tmp-marked number
1186 "Insert a group line in the group buffer."
1187 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1188 (gnus-tmp-number-total
1190 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1192 (gnus-tmp-number-of-unread
1193 (if (numberp number) (int-to-string (max 0 number))
1195 (gnus-tmp-number-of-read
1196 (if (numberp number)
1197 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1199 (gnus-tmp-subscribed
1200 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1201 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1202 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1204 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1205 (gnus-tmp-newsgroup-description
1206 (if gnus-description-hashtb
1207 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1210 (if (and gnus-moderated-hashtb
1211 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1213 (gnus-tmp-moderated-string
1214 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1216 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1217 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1218 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1219 (gnus-tmp-news-method-string
1221 (format "(%s:%s)" (car gnus-tmp-method)
1222 (cadr gnus-tmp-method)) ""))
1223 (gnus-tmp-marked-mark
1224 (if (and (numberp number)
1226 (cdr (assq 'tick gnus-tmp-marked)))
1228 (gnus-tmp-process-marked
1229 (if (member gnus-tmp-group gnus-group-marked)
1230 gnus-process-mark ? ))
1232 (or (and gnus-use-grouplens
1233 (bbb-grouplens-group-p gnus-tmp-group))
1235 (buffer-read-only nil)
1236 header gnus-tmp-header) ; passed as parameter to user-funcs.
1238 (gnus-add-text-properties
1242 (eval gnus-group-line-format-spec))
1243 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1244 gnus-unread ,(if (numberp number)
1245 (string-to-int gnus-tmp-number-of-unread)
1247 gnus-marked ,gnus-tmp-marked-mark
1248 gnus-indentation ,gnus-group-indentation
1249 gnus-level ,gnus-tmp-level))
1250 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1252 (run-hooks 'gnus-group-update-hook)
1254 ;; Allow XEmacs to remove front-sticky text properties.
1255 (gnus-group-remove-excess-properties)))
1257 (defun gnus-group-highlight-line ()
1258 "Highlight the current line according to `gnus-group-highlight'."
1259 (let* ((list gnus-group-highlight)
1261 (end (progn (end-of-line) (point)))
1262 ;; now find out where the line starts and leave point there.
1263 (beg (progn (beginning-of-line) (point)))
1264 (group (gnus-group-group-name))
1265 (entry (gnus-group-entry group))
1266 (unread (if (numberp (car entry)) (car entry) 0))
1267 (active (gnus-active group))
1268 (total (if active (1+ (- (cdr active) (car active))) 0))
1269 (info (nth 2 entry))
1270 (method (gnus-server-get-method group (gnus-info-method info)))
1271 (marked (gnus-info-marks info))
1272 (mailp (memq 'mail (assoc (symbol-name
1273 (car (or method gnus-select-method)))
1274 gnus-valid-select-methods)))
1275 (level (or (gnus-info-level info) 9))
1276 (score (or (gnus-info-score info) 0))
1277 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1278 (group-age (gnus-group-timestamp-delta group))
1279 (inhibit-read-only t))
1280 ;; Eval the cars of the lists until we find a match.
1282 (not (eval (caar list))))
1283 (setq list (cdr list)))
1284 (let ((face (cdar list)))
1285 (unless (eq face (get-text-property beg 'face))
1286 (gnus-put-text-property
1288 (setq face (if (boundp face) (symbol-value face) face)))
1289 (gnus-extent-start-open beg)))
1292 (defun gnus-group-update-group (group &optional visible-only)
1293 "Update all lines where GROUP appear.
1294 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1297 (set-buffer gnus-group-buffer)
1298 ;; The buffer may be narrowed.
1301 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1303 found buffer-read-only)
1304 ;; Enter the current status into the dribble buffer.
1305 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1306 (when (and entry (not (gnus-ephemeral-group-p group)))
1308 (concat "(gnus-group-set-info '"
1309 (gnus-prin1-to-string (nth 2 entry))
1311 ;; Find all group instances. If topics are in use, each group
1312 ;; may be listed in more than once.
1313 (while (setq loc (text-property-any
1314 loc (point-max) 'gnus-group ident))
1317 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1319 (gnus-group-insert-group-line-info group)
1322 (run-hooks 'gnus-group-update-group-hook)))
1323 (setq loc (1+ loc)))
1324 (unless (or found visible-only)
1325 ;; No such line in the buffer, find out where it's supposed to
1326 ;; go, and insert it there (or at the end of the buffer).
1327 (if gnus-goto-missing-group-function
1328 (funcall gnus-goto-missing-group-function group)
1329 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1330 (while (and entry (car entry)
1334 (point-min) (point-max)
1335 'gnus-group (gnus-intern-safe
1336 (caar entry) gnus-active-hashtb)))))
1337 (setq entry (cdr entry)))
1338 (or entry (goto-char (point-max)))))
1339 ;; Finally insert the line.
1340 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1341 (gnus-group-insert-group-line-info group)
1344 (run-hooks 'gnus-group-update-group-hook))))
1345 (when gnus-group-update-group-function
1346 (funcall gnus-group-update-group-function group))
1347 (gnus-group-set-mode-line)))))
1349 (defun gnus-group-set-mode-line ()
1350 "Update the mode line in the group buffer."
1351 (when (memq 'group gnus-updated-mode-lines)
1352 ;; Yes, we want to keep this mode line updated.
1354 (set-buffer gnus-group-buffer)
1355 (let* ((gformat (or gnus-group-mode-line-format-spec
1356 (setq gnus-group-mode-line-format-spec
1358 gnus-group-mode-line-format
1359 gnus-group-mode-line-format-alist))))
1360 (gnus-tmp-news-server (cadr gnus-select-method))
1361 (gnus-tmp-news-method (car gnus-select-method))
1362 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1364 gnus-tmp-header ;Dummy binding for user-defined formats
1365 ;; Get the resulting string.
1367 (and gnus-dribble-buffer
1368 (buffer-name gnus-dribble-buffer)
1369 (buffer-modified-p gnus-dribble-buffer)
1371 (set-buffer gnus-dribble-buffer)
1372 (not (zerop (buffer-size))))))
1373 (mode-string (eval gformat)))
1374 ;; Say whether the dribble buffer has been modified.
1375 (setq mode-line-modified
1376 (if modified "---*- " "----- "))
1377 ;; If the line is too long, we chop it off.
1378 (when (> (length mode-string) max-len)
1379 (setq mode-string (substring mode-string 0 (- max-len 4))))
1381 (setq mode-line-buffer-identification
1382 (gnus-mode-line-buffer-identification
1383 (list mode-string)))
1384 (set-buffer-modified-p modified))))))
1386 (defun gnus-group-group-name ()
1387 "Get the name of the newsgroup on the current line."
1388 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1389 (and group (symbol-name group))))
1391 (defun gnus-group-group-level ()
1392 "Get the level of the newsgroup on the current line."
1393 (get-text-property (gnus-point-at-bol) 'gnus-level))
1395 (defun gnus-group-group-indentation ()
1396 "Get the indentation of the newsgroup on the current line."
1397 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1398 (and gnus-group-indentation-function
1399 (funcall gnus-group-indentation-function))
1402 (defun gnus-group-group-unread ()
1403 "Get the number of unread articles of the newsgroup on the current line."
1404 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1406 (defun gnus-group-new-mail (group)
1407 (if (nnmail-new-mail-p (gnus-group-real-name group))
1411 (defun gnus-group-search-forward (&optional backward all level first-too)
1412 "Find the next newsgroup with unread articles.
1413 If BACKWARD is non-nil, find the previous newsgroup instead.
1414 If ALL is non-nil, just find any newsgroup.
1415 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1417 If FIRST-TOO, the current line is also eligible as a target."
1418 (let ((way (if backward -1 1))
1419 (low gnus-level-killed)
1422 (if (and backward (progn (beginning-of-line)) (bobp))
1433 (get-text-property (point) 'gnus-unread)))
1434 (and (numberp unread) (> unread 0)))
1435 (setq lev (get-text-property (point)
1437 (<= lev gnus-level-subscribed)))
1439 (and (setq lev (get-text-property (point)
1448 (zerop (forward-line way)))))
1450 (progn (gnus-group-position-point) t)
1451 (goto-char (or pos beg))
1454 ;;; Gnus group mode commands
1458 (defun gnus-group-mark-group (n &optional unmark no-advance)
1459 "Mark the current group."
1461 (let ((buffer-read-only nil)
1465 (when (setq group (gnus-group-group-name))
1466 ;; Go to the mark position.
1468 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1469 (subst-char-in-region
1470 (point) (1+ (point)) (following-char)
1473 (setq gnus-group-marked (delete group gnus-group-marked))
1475 (setq gnus-group-marked
1476 (cons group (delete group gnus-group-marked)))
1477 gnus-process-mark)))
1479 (gnus-group-next-group 1))
1481 (gnus-summary-position-point)
1484 (defun gnus-group-unmark-group (n)
1485 "Remove the mark from the current group."
1487 (gnus-group-mark-group n 'unmark)
1488 (gnus-group-position-point))
1490 (defun gnus-group-unmark-all-groups ()
1491 "Unmark all groups."
1493 (let ((groups gnus-group-marked))
1496 (gnus-group-remove-mark (pop groups)))))
1497 (gnus-group-position-point))
1499 (defun gnus-group-mark-region (unmark beg end)
1500 "Mark all groups between point and mark.
1501 If UNMARK, remove the mark instead."
1502 (interactive "P\nr")
1503 (let ((num (count-lines beg end)))
1506 (- num (gnus-group-mark-group num unmark)))))
1508 (defun gnus-group-mark-buffer (&optional unmark)
1509 "Mark all groups in the buffer.
1510 If UNMARK, remove the mark instead."
1512 (gnus-group-mark-region unmark (point-min) (point-max)))
1514 (defun gnus-group-mark-regexp (regexp)
1515 "Mark all groups that match some regexp."
1516 (interactive "sMark (regexp): ")
1517 (let ((alist (cdr gnus-newsrc-alist))
1520 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1521 (gnus-group-set-mark group))))
1522 (gnus-group-position-point))
1524 (defun gnus-group-remove-mark (group)
1525 "Remove the process mark from GROUP and move point there.
1526 Return nil if the group isn't displayed."
1527 (if (gnus-group-goto-group group)
1529 (gnus-group-mark-group 1 'unmark t)
1531 (setq gnus-group-marked
1532 (delete group gnus-group-marked))
1535 (defun gnus-group-set-mark (group)
1536 "Set the process mark on GROUP."
1537 (if (gnus-group-goto-group group)
1539 (gnus-group-mark-group 1 nil t))
1540 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1542 (defun gnus-group-universal-argument (arg &optional groups func)
1543 "Perform any command on all groups according to the process/prefix convention."
1545 (if (eq (setq func (or func
1548 (substitute-command-keys
1549 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1551 (gnus-error 1 "Undefined key")
1552 (gnus-group-iterate arg
1554 (command-execute func))))
1555 (gnus-group-position-point))
1557 (defun gnus-group-process-prefix (n)
1558 "Return a list of groups to work on.
1559 Take into consideration N (the prefix) and the list of marked groups."
1562 (setq n (prefix-numeric-value n))
1563 ;; There is a prefix, so we return a list of the N next
1565 (let ((way (if (< n 0) -1 1))
1570 (setq group (gnus-group-group-name)))
1573 (gnus-group-next-group way)))
1575 ((and (boundp 'transient-mark-mode)
1577 (boundp 'mark-active)
1579 ;; Work on the region between point and mark.
1580 (let ((max (max (point) (mark)))
1583 (goto-char (min (point) (mark)))
1586 (push (gnus-group-group-name) groups)
1587 (zerop (gnus-group-next-group 1))
1589 (nreverse groups))))
1591 ;; No prefix, but a list of marked articles.
1592 (reverse gnus-group-marked))
1594 ;; Neither marked articles or a prefix, so we return the
1596 (let ((group (gnus-group-group-name)))
1597 (and group (list group))))))
1599 (defun gnus-group-iterate (arg function)
1600 "Iterate FUNCTION over all process/prefixed groups.
1601 FUNCTION will be called with the group name as the paremeter
1602 and with point over the group in question."
1603 (let ((groups (gnus-group-process-prefix arg))
1605 (while (setq group (pop groups))
1606 (gnus-group-remove-mark group)
1607 (funcall function group))))
1609 (put 'gnus-group-iterate 'lisp-indent-function 1)
1611 ;; Selecting groups.
1613 (defun gnus-group-read-group (&optional all no-article group)
1614 "Read news in this newsgroup.
1615 If the prefix argument ALL is non-nil, already read articles become
1616 readable. IF ALL is a number, fetch this number of articles. If the
1617 optional argument NO-ARTICLE is non-nil, no article will be
1618 auto-selected upon group entry. If GROUP is non-nil, fetch that
1621 (let ((no-display (eq all 0))
1622 (group (or group (gnus-group-group-name)))
1623 number active marked entry)
1627 (error "No group on current line"))
1628 (setq marked (gnus-info-marks
1629 (nth 2 (setq entry (gnus-gethash
1630 group gnus-newsrc-hashtb)))))
1631 ;; This group might be a dead group. In that case we have to get
1632 ;; the number of unread articles from `gnus-active-hashtb'.
1634 (cond ((numberp all) all)
1636 ((setq active (gnus-active group))
1637 (- (1+ (cdr active)) (car active)))))
1638 (gnus-summary-read-group
1639 group (or all (and (numberp number)
1640 (zerop (+ number (gnus-range-length
1641 (cdr (assq 'tick marked)))
1643 (cdr (assq 'dormant marked)))))))
1644 no-article nil no-display)))
1646 (defun gnus-group-select-group (&optional all)
1647 "Select this newsgroup.
1648 No article is selected automatically.
1649 If ALL is non-nil, already read articles become readable.
1650 If ALL is a number, fetch this number of articles."
1652 (gnus-group-read-group all t))
1654 (defun gnus-group-quick-select-group (&optional all)
1655 "Select the current group \"quickly\".
1656 This means that no highlighting or scoring will be performed.
1657 If ALL (the prefix argument) is 0, don't even generate the summary
1660 (require 'gnus-score)
1662 gnus-score-find-score-files-function
1663 gnus-apply-kill-hook
1664 gnus-summary-expunge-below)
1665 (gnus-group-read-group all t)))
1667 (defun gnus-group-visible-select-group (&optional all)
1668 "Select the current group without hiding any articles."
1670 (let ((gnus-inhibit-limiting t))
1671 (gnus-group-read-group all t)))
1674 (defun gnus-fetch-group (group)
1675 "Start Gnus if necessary and enter GROUP.
1676 Returns whether the fetching was successful or not."
1677 (interactive "sGroup name: ")
1678 (unless (get-buffer gnus-group-buffer)
1680 (gnus-group-read-group nil nil group))
1682 ;; Enter a group that is not in the group buffer. Non-nil is returned
1683 ;; if selection was successful.
1684 (defun gnus-group-read-ephemeral-group (group method &optional activate
1685 quit-config request-only)
1686 "Read GROUP from METHOD as an ephemeral group.
1687 If ACTIVATE, request the group first.
1688 If QUIT-CONFIG, use that window configuration when exiting from the
1690 If REQUEST-ONLY, don't actually read the group; just request it.
1692 Return the name of the group is selection was successful."
1693 (let ((group (if (gnus-group-foreign-p group) group
1694 (gnus-group-prefixed-name group method))))
1698 ,gnus-level-default-subscribed nil nil ,method
1700 ,(if quit-config quit-config
1701 (cons gnus-summary-buffer
1702 gnus-current-window-configuration))))))
1704 (set-buffer gnus-group-buffer)
1705 (unless (gnus-check-server method)
1706 (error "Unable to contact server: %s" (gnus-status-message method)))
1708 (gnus-activate-group group 'scan)
1709 (unless (gnus-request-group group)
1710 (error "Couldn't request group: %s"
1711 (nnheader-get-report (car method)))))
1715 (when (gnus-group-read-group t t group)
1720 (defun gnus-group-jump-to-group (group)
1721 "Jump to newsgroup GROUP."
1723 (list (completing-read
1724 "Group: " gnus-active-hashtb nil
1725 (gnus-read-active-file-p)
1727 'gnus-group-history)))
1729 (when (equal group "")
1730 (error "Empty group name"))
1732 (unless (gnus-ephemeral-group-p group)
1733 ;; Either go to the line in the group buffer...
1734 (unless (gnus-group-goto-group group)
1735 ;; ... or insert the line.
1736 (gnus-group-update-group group)
1737 (gnus-group-goto-group group)))
1738 ;; Adjust cursor point.
1739 (gnus-group-position-point))
1741 (defun gnus-group-goto-group (group &optional far)
1742 "Goto to newsgroup GROUP.
1743 If FAR, it is likely that the group is not on the current line."
1748 (point-min) (point-max)
1749 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1752 ;; It's quite likely that we are on the right line, so
1753 ;; we check the current line first.
1754 ((eq (get-text-property (point) 'gnus-group)
1755 (gnus-intern-safe group gnus-active-hashtb))
1757 ;; Previous and next line are also likely, so we check them as well.
1760 (eq (get-text-property (point) 'gnus-group)
1761 (gnus-intern-safe group gnus-active-hashtb)))
1766 (eq (get-text-property (point) 'gnus-group)
1767 (gnus-intern-safe group gnus-active-hashtb)))
1771 ;; Search through the entire buffer.
1774 (point-min) (point-max)
1775 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1777 (defun gnus-group-next-group (n &optional silent)
1778 "Go to next N'th newsgroup.
1779 If N is negative, search backward instead.
1780 Returns the difference between N and the number of skips actually
1783 (gnus-group-next-unread-group n t nil silent))
1785 (defun gnus-group-next-unread-group (n &optional all level silent)
1786 "Go to next N'th unread newsgroup.
1787 If N is negative, search backward instead.
1788 If ALL is non-nil, choose any newsgroup, unread or not.
1789 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1790 such group can be found, the next group with a level higher than
1792 Returns the difference between N and the number of skips actually
1795 (let ((backward (< n 0))
1798 (gnus-group-search-forward
1799 backward (or (not gnus-group-goto-unread) all) level))
1803 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1804 (if level " on this level or higher" "")))
1807 (defun gnus-group-prev-group (n)
1808 "Go to previous N'th newsgroup.
1809 Returns the difference between N and the number of skips actually
1812 (gnus-group-next-unread-group (- n) t))
1814 (defun gnus-group-prev-unread-group (n)
1815 "Go to previous N'th unread newsgroup.
1816 Returns the difference between N and the number of skips actually
1819 (gnus-group-next-unread-group (- n)))
1821 (defun gnus-group-next-unread-group-same-level (n)
1822 "Go to next N'th unread newsgroup on the same level.
1823 If N is negative, search backward instead.
1824 Returns the difference between N and the number of skips actually
1827 (gnus-group-next-unread-group n t (gnus-group-group-level))
1828 (gnus-group-position-point))
1830 (defun gnus-group-prev-unread-group-same-level (n)
1831 "Go to next N'th unread newsgroup on the same level.
1832 Returns the difference between N and the number of skips actually
1835 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1836 (gnus-group-position-point))
1838 (defun gnus-group-best-unread-group (&optional exclude-group)
1839 "Go to the group with the highest level.
1840 If EXCLUDE-GROUP, do not go to that group."
1842 (goto-char (point-min))
1846 (setq unread (get-text-property (point) 'gnus-unread))
1847 (when (and (numberp unread) (> unread 0))
1848 (when (and (get-text-property (point) 'gnus-level)
1849 (< (get-text-property (point) 'gnus-level) best)
1850 (or (not exclude-group)
1851 (not (equal exclude-group (gnus-group-group-name)))))
1852 (setq best (get-text-property (point) 'gnus-level))
1853 (setq best-point (point))))
1856 (goto-char best-point))
1857 (gnus-summary-position-point)
1858 (and best-point (gnus-group-group-name))))
1860 (defun gnus-group-first-unread-group ()
1861 "Go to the first group with unread articles."
1864 (let ((opoint (point))
1866 (goto-char (point-min))
1867 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1868 (and (numberp unread) ; Not a topic.
1869 (not (zerop unread))) ; Has unread articles.
1870 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1873 nil)) ; Not success.
1874 (gnus-group-position-point)))
1876 (defun gnus-group-enter-server-mode ()
1877 "Jump to the server buffer."
1879 (gnus-enter-server-buffer))
1881 (defun gnus-group-make-group (name &optional method address args)
1882 "Add a new newsgroup.
1883 The user will be prompted for a NAME, for a select METHOD, and an
1887 (gnus-read-group "Group name: ")
1888 (gnus-read-method "From method: ")))
1890 (let* ((meth (when (and method
1891 (not (gnus-server-equal method gnus-select-method)))
1892 (if address (list (intern method) address)
1894 (nname (if method (gnus-group-prefixed-name name meth) name))
1896 (when (gnus-gethash nname gnus-newsrc-hashtb)
1897 (error "Group %s already exists" nname))
1898 ;; Subscribe to the new group.
1899 (gnus-group-change-level
1900 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1901 gnus-level-default-subscribed gnus-level-killed
1902 (and (gnus-group-group-name)
1903 (gnus-gethash (gnus-group-group-name)
1904 gnus-newsrc-hashtb))
1907 (gnus-set-active nname (cons 1 0))
1908 (unless (gnus-ephemeral-group-p name)
1910 (concat "(gnus-group-set-info '"
1911 (gnus-prin1-to-string (cdr info)) ")")))
1913 (gnus-group-insert-group-line-info nname)
1915 (gnus-group-position-point)
1917 ;; Load the backend and try to make the backend create
1918 ;; the group as well.
1919 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1921 gnus-valid-select-methods)
1923 (gnus-check-server meth)
1924 (when (gnus-check-backend-function 'request-create-group nname)
1925 (gnus-request-create-group nname nil args))
1928 (defun gnus-group-delete-group (group &optional force)
1929 "Delete the current group. Only meaningful with mail groups.
1930 If FORCE (the prefix) is non-nil, all the articles in the group will
1931 be deleted. This is \"deleted\" as in \"removed forever from the face
1932 of the Earth\". There is no undo. The user will be prompted before
1933 doing the deletion."
1935 (list (gnus-group-group-name)
1936 current-prefix-arg))
1938 (error "No group to rename"))
1939 (unless (gnus-check-backend-function 'request-delete-group group)
1940 (error "This backend does not support group deletion"))
1942 (if (not (gnus-yes-or-no-p
1944 "Do you really want to delete %s%s? "
1945 group (if force " and all its contents" ""))))
1947 (gnus-message 6 "Deleting group %s..." group)
1948 (if (not (gnus-request-delete-group group force))
1949 (gnus-error 3 "Couldn't delete group %s" group)
1950 (gnus-message 6 "Deleting group %s...done" group)
1951 (gnus-group-goto-group group)
1952 (gnus-group-kill-group 1 t)
1953 (gnus-sethash group nil gnus-active-hashtb)
1955 (gnus-group-position-point)))
1957 (defun gnus-group-rename-group (group new-name)
1958 "Rename group from GROUP to NEW-NAME.
1959 When used interactively, GROUP is the group under point
1960 and NEW-NAME will be prompted for."
1963 (gnus-group-group-name)
1965 (unless (gnus-check-backend-function
1966 'request-rename-group (gnus-group-group-name))
1967 (error "This backend does not support renaming groups"))
1968 (read-string "New group name: " (gnus-group-group-name)))))
1970 (unless (gnus-check-backend-function 'request-rename-group group)
1971 (error "This backend does not support renaming groups"))
1973 (error "No group to rename"))
1974 (when (string-match "^[ \t]*$" new-name)
1975 (error "Not a valid group name"))
1976 (when (equal group new-name)
1977 (error "Can't rename to the same name"))
1979 ;; We find the proper prefixed name.
1981 (if (equal (gnus-group-real-name new-name) new-name)
1985 (gnus-group-prefixed-name
1986 (gnus-group-real-name new-name)
1987 (gnus-info-method (gnus-get-info group)))))
1989 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1991 (if (not (gnus-request-rename-group group new-name))
1992 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1993 ;; We rename the group internally by killing it...
1994 (gnus-group-goto-group group)
1995 (gnus-group-kill-group)
1996 ;; ... changing its name ...
1997 (setcar (cdar gnus-list-of-killed-groups) new-name)
1998 ;; ... and then yanking it. Magic!
1999 (gnus-group-yank-group)
2000 (gnus-set-active new-name (gnus-active group))
2001 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2003 (gnus-group-position-point)))
2005 (defun gnus-group-edit-group (group &optional part)
2006 "Edit the group on the current line."
2007 (interactive (list (gnus-group-group-name)))
2008 (let ((part (or part 'info))
2011 (error "No group on current line"))
2012 (unless (setq info (gnus-get-info group))
2013 (error "Killed group; can't be edited"))
2015 ;; Find the proper form to edit.
2016 (cond ((eq part 'method)
2017 (or (gnus-info-method info) "native"))
2019 (gnus-info-params info))
2021 ;; The proper documentation.
2025 ((eq part 'method) "select method")
2026 ((eq part 'params) "group parameters")
2029 (gnus-group-edit-group-done ',part ,group form)))))
2031 (defun gnus-group-edit-group-method (group)
2032 "Edit the select method of GROUP."
2033 (interactive (list (gnus-group-group-name)))
2034 (gnus-group-edit-group group 'method))
2036 (defun gnus-group-edit-group-parameters (group)
2037 "Edit the group parameters of GROUP."
2038 (interactive (list (gnus-group-group-name)))
2039 (gnus-group-edit-group group 'params))
2041 (defun gnus-group-edit-group-done (part group form)
2043 (let* ((method (cond ((eq part 'info) (nth 4 form))
2044 ((eq part 'method) form)
2046 (info (cond ((eq part 'info) form)
2047 ((eq part 'method) (gnus-get-info group))
2050 (if (or (not method)
2052 gnus-select-method method))
2053 (gnus-group-real-name (car info))
2054 (gnus-group-prefixed-name
2055 (gnus-group-real-name (car info)) method))
2057 (when (and new-group
2058 (not (equal new-group group)))
2059 (when (gnus-group-goto-group group)
2060 (gnus-group-kill-group 1))
2061 (gnus-activate-group new-group))
2063 (if (not (and info new-group))
2064 (gnus-group-set-info form (or new-group group) part)
2065 (setq info (gnus-copy-sequence info))
2066 (setcar info new-group)
2067 (unless (gnus-server-equal method "native")
2068 (unless (nthcdr 3 info)
2069 (nconc info (list nil nil)))
2070 (unless (nthcdr 4 info)
2071 (nconc info (list nil)))
2072 (gnus-info-set-method info method))
2073 (gnus-group-set-info info))
2074 (gnus-group-update-group (or new-group group))
2075 (gnus-group-position-point)))
2077 (defun gnus-group-make-useful-group (group method)
2079 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2081 gnus-useful-groups)))
2082 (list (cadr entry) (caddr entry))))
2083 (setq method (gnus-copy-sequence method))
2085 (while (setq entry (memq (assq 'eval method) method))
2086 (setcar entry (eval (cadar entry)))))
2087 (gnus-group-make-group group method))
2089 (defun gnus-group-make-help-group ()
2090 "Create the Gnus documentation group."
2092 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2093 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
2095 (when (gnus-gethash name gnus-newsrc-hashtb)
2096 (error "Documentation group already exists"))
2098 (gnus-message 1 "Couldn't find doc group")
2099 (gnus-group-make-group
2100 (gnus-group-real-name name)
2101 (list 'nndoc "gnus-help"
2102 (list 'nndoc-address file)
2103 (list 'nndoc-article-type 'mbox)))))
2104 (gnus-group-position-point))
2106 (defun gnus-group-make-doc-group (file type)
2107 "Create a group that uses a single file as the source."
2109 (list (read-file-name "File name: ")
2110 (and current-prefix-arg 'ask)))
2111 (when (eq type 'ask)
2116 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2118 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2119 ((= char ?b) 'babyl)
2120 ((= char ?d) 'digest)
2121 ((= char ?f) 'forward)
2123 (t (setq err (format "%c unknown. " char))
2126 (let* ((file (expand-file-name file))
2127 (name (gnus-generate-new-group-name
2128 (gnus-group-prefixed-name
2129 (file-name-nondirectory file) '(nndoc "")))))
2130 (gnus-group-make-group
2131 (gnus-group-real-name name)
2133 (list 'nndoc-address file)
2134 (list 'nndoc-article-type (or type 'guess))))))
2136 (defvar nnweb-type-definition)
2137 (defvar gnus-group-web-type-history nil)
2138 (defvar gnus-group-web-search-history nil)
2139 (defun gnus-group-make-web-group (&optional solid)
2140 "Create an ephemeral nnweb group.
2141 If SOLID (the prefix), create a solid group."
2145 (if solid (gnus-read-group "Group name: ")
2146 (message-unique-id)))
2149 "Search engine type: "
2150 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2151 nnweb-type-definition)
2152 nil t (cons (or (car gnus-group-web-type-history)
2153 (symbol-name (caar nnweb-type-definition)))
2155 'gnus-group-web-type-history))
2159 (cons (or (car gnus-group-web-search-history) "") 0)
2160 'gnus-group-web-search-history))
2162 `(nnweb ,group (nnweb-search ,search)
2163 (nnweb-type ,(intern type))
2164 (nnweb-ephemeral-p t))))
2166 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2167 (gnus-group-read-ephemeral-group
2169 (cons (current-buffer)
2170 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2172 (defun gnus-group-make-archive-group (&optional all)
2173 "Create the (ding) Gnus archive group of the most recent articles.
2174 Given a prefix, create a full group."
2176 (let ((group (gnus-group-prefixed-name
2177 (if all "ding.archives" "ding.recent") '(nndir ""))))
2178 (when (gnus-gethash group gnus-newsrc-hashtb)
2179 (error "Archive group already exists"))
2180 (gnus-group-make-group
2181 (gnus-group-real-name group)
2182 (list 'nndir (if all "hpc" "edu")
2183 (list 'nndir-directory
2184 (if all gnus-group-archive-directory
2185 gnus-group-recent-archive-directory))))
2186 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
2188 (defun gnus-group-make-directory-group (dir)
2189 "Create an nndir group.
2190 The user will be prompted for a directory. The contents of this
2191 directory will be used as a newsgroup. The directory should contain
2192 mail messages or news articles in files that have numeric names."
2194 (list (read-file-name "Create group from directory: ")))
2195 (unless (file-exists-p dir)
2196 (error "No such directory"))
2197 (unless (file-directory-p dir)
2198 (error "Not a directory"))
2202 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2204 (gnus-group-prefixed-name
2205 (concat (file-name-as-directory (directory-file-name dir))
2208 (setq ext (format "<%d>" (setq i (1+ i)))))
2209 (gnus-group-make-group
2210 (gnus-group-real-name group)
2211 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2213 (defun gnus-group-make-kiboze-group (group address scores)
2214 "Create an nnkiboze group.
2215 The user will be prompted for a name, a regexp to match groups, and
2216 score file entries for articles to include in the group."
2219 (read-string "nnkiboze group name: ")
2220 (read-string "Source groups (regexp): ")
2221 (let ((headers (mapcar (lambda (group) (list group))
2222 '("subject" "from" "number" "date" "message-id"
2223 "references" "chars" "lines" "xref"
2224 "followup" "all" "body" "head")))
2225 scores header regexp regexps)
2226 (while (not (equal "" (setq header (completing-read
2227 "Match on header: " headers nil t))))
2229 (while (not (equal "" (setq regexp (read-string
2230 (format "Match on %s (string): "
2232 (push (list regexp nil nil 'r) regexps))
2233 (push (cons header regexps) scores))
2235 (gnus-group-make-group group "nnkiboze" address)
2236 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
2237 (let (emacs-lisp-mode-hook)
2238 (pp scores (current-buffer)))))
2240 (defun gnus-group-add-to-virtual (n vgroup)
2241 "Add the current group to a virtual group."
2243 (list current-prefix-arg
2244 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2246 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2247 (error "%s is not an nnvirtual group" vgroup))
2248 (let* ((groups (gnus-group-process-prefix n))
2249 (method (gnus-info-method (gnus-get-info vgroup))))
2250 (setcar (cdr method)
2252 (nth 1 method) "\\|"
2255 (gnus-group-remove-mark s)
2256 (concat "\\(^" (regexp-quote s) "$\\)"))
2258 (gnus-group-position-point))
2260 (defun gnus-group-make-empty-virtual (group)
2261 "Create a new, fresh, empty virtual group."
2262 (interactive "sCreate new, empty virtual group: ")
2263 (let* ((method (list 'nnvirtual "^$"))
2264 (pgroup (gnus-group-prefixed-name group method)))
2265 ;; Check whether it exists already.
2266 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2267 (error "Group %s already exists." pgroup))
2268 ;; Subscribe the new group after the group on the current line.
2269 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2270 (gnus-group-update-group pgroup)
2272 (gnus-group-position-point)))
2274 (defun gnus-group-enter-directory (dir)
2275 "Enter an ephemeral nneething group."
2276 (interactive "DDirectory to read: ")
2277 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2278 (leaf (gnus-group-prefixed-name
2279 (file-name-nondirectory (directory-file-name dir))
2281 (name (gnus-generate-new-group-name leaf)))
2282 (unless (gnus-group-read-ephemeral-group
2284 (cons (current-buffer)
2285 (if (eq major-mode 'gnus-summary-mode)
2287 (error "Couldn't enter %s" dir))))
2289 ;; Group sorting commands
2290 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2292 (defun gnus-group-sort-groups (func &optional reverse)
2293 "Sort the group buffer according to FUNC.
2294 If REVERSE, reverse the sorting order."
2295 (interactive (list gnus-group-sort-function current-prefix-arg))
2296 (funcall gnus-group-sort-alist-function
2297 (gnus-make-sort-function func) reverse)
2298 (gnus-group-list-groups))
2300 (defun gnus-group-sort-flat (func reverse)
2301 ;; We peel off the dummy group from the alist.
2303 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
2304 (pop gnus-newsrc-alist))
2306 (setq gnus-newsrc-alist
2307 (sort gnus-newsrc-alist func))
2309 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2310 ;; Regenerate the hash table.
2311 (gnus-make-hashtable-from-newsrc-alist)))
2313 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2314 "Sort the group buffer alphabetically by group name.
2315 If REVERSE, sort in reverse order."
2317 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2319 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2320 "Sort the group buffer by number of unread articles.
2321 If REVERSE, sort in reverse order."
2323 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2325 (defun gnus-group-sort-groups-by-level (&optional reverse)
2326 "Sort the group buffer by group level.
2327 If REVERSE, sort in reverse order."
2329 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2331 (defun gnus-group-sort-groups-by-score (&optional reverse)
2332 "Sort the group buffer by group score.
2333 If REVERSE, sort in reverse order."
2335 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2337 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2338 "Sort the group buffer by group rank.
2339 If REVERSE, sort in reverse order."
2341 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2343 (defun gnus-group-sort-groups-by-method (&optional reverse)
2344 "Sort the group buffer alphabetically by backend name.
2345 If REVERSE, sort in reverse order."
2347 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2349 ;;; Selected group sorting.
2351 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2352 "Sort the process/prefixed groups."
2353 (interactive (list current-prefix-arg gnus-group-sort-function))
2354 (let ((groups (gnus-group-process-prefix n)))
2355 (funcall gnus-group-sort-selected-function
2356 groups (gnus-make-sort-function func) reverse)
2357 (gnus-group-list-groups)))
2359 (defun gnus-group-sort-selected-flat (groups func reverse)
2360 (let (entries infos)
2361 ;; First find all the group entries for these groups.
2363 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2365 ;; Then sort the infos.
2369 (lambda (entry) (car entry))
2370 (setq entries (nreverse entries)))
2373 (setq infos (nreverse infos)))
2374 ;; Go through all the infos and replace the old entries
2375 ;; with the new infos.
2377 (setcar entries (pop infos))
2379 ;; Update the hashtable.
2380 (gnus-make-hashtable-from-newsrc-alist)))
2382 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2383 "Sort the group buffer alphabetically by group name.
2384 If REVERSE, sort in reverse order."
2386 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2388 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2389 "Sort the group buffer by number of unread articles.
2390 If REVERSE, sort in reverse order."
2392 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2394 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2395 "Sort the group buffer by group level.
2396 If REVERSE, sort in reverse order."
2398 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2400 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2401 "Sort the group buffer by group score.
2402 If REVERSE, sort in reverse order."
2404 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2406 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2407 "Sort the group buffer by group rank.
2408 If REVERSE, sort in reverse order."
2410 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2412 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2413 "Sort the group buffer alphabetically by backend name.
2414 If REVERSE, sort in reverse order."
2416 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2418 ;;; Sorting predicates.
2420 (defun gnus-group-sort-by-alphabet (info1 info2)
2421 "Sort alphabetically."
2422 (string< (gnus-info-group info1) (gnus-info-group info2)))
2424 (defun gnus-group-sort-by-real-name (info1 info2)
2425 "Sort alphabetically on real (unprefixed) names."
2426 (string< (gnus-group-real-name (gnus-info-group info1))
2427 (gnus-group-real-name (gnus-info-group info2))))
2429 (defun gnus-group-sort-by-unread (info1 info2)
2430 "Sort by number of unread articles."
2431 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2432 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2433 (< (or (and (numberp n1) n1) 0)
2434 (or (and (numberp n2) n2) 0))))
2436 (defun gnus-group-sort-by-level (info1 info2)
2438 (< (gnus-info-level info1) (gnus-info-level info2)))
2440 (defun gnus-group-sort-by-method (info1 info2)
2441 "Sort alphabetically by backend name."
2442 (string< (symbol-name (car (gnus-find-method-for-group
2443 (gnus-info-group info1) info1)))
2444 (symbol-name (car (gnus-find-method-for-group
2445 (gnus-info-group info2) info2)))))
2447 (defun gnus-group-sort-by-score (info1 info2)
2448 "Sort by group score."
2449 (< (gnus-info-score info1) (gnus-info-score info2)))
2451 (defun gnus-group-sort-by-rank (info1 info2)
2452 "Sort by level and score."
2453 (let ((level1 (gnus-info-level info1))
2454 (level2 (gnus-info-level info2)))
2455 (or (< level1 level2)
2456 (and (= level1 level2)
2457 (> (gnus-info-score info1) (gnus-info-score info2))))))
2461 (defun gnus-group-clear-data (&optional arg)
2462 "Clear all marks and read ranges from the current group."
2464 (gnus-group-iterate arg
2467 (gnus-info-clear-data (setq info (gnus-get-info group)))
2468 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2469 (when (gnus-group-goto-group group)
2470 (gnus-group-update-group-line))))))
2472 (defun gnus-group-clear-data-on-native-groups ()
2473 "Clear all marks and read ranges from all native groups."
2475 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2476 (let ((alist (cdr gnus-newsrc-alist))
2478 (while (setq info (pop alist))
2479 (when (gnus-group-native-p (gnus-info-group info))
2480 (gnus-info-clear-data info)))
2481 (gnus-get-unread-articles)
2482 (gnus-dribble-enter ""))))
2484 (defun gnus-info-clear-data (info)
2485 "Clear all marks and read ranges from INFO."
2486 (let ((group (gnus-info-group info)))
2489 (gnus-info-set-marks ',info ',(gnus-info-marks info))
2490 (gnus-info-set-read ',info ',(gnus-info-read info))
2491 (when (gnus-group-goto-group ,group)
2492 (gnus-group-update-group-line))))
2493 (gnus-info-set-read info nil)
2494 (when (gnus-info-marks info)
2495 (gnus-info-set-marks info nil))))
2497 ;; Group catching up.
2499 (defun gnus-group-catchup-current (&optional n all)
2500 "Mark all articles not marked as unread in current newsgroup as read.
2501 If prefix argument N is numeric, the ARG next newsgroups will be
2502 caught up. If ALL is non-nil, marked articles will also be marked as
2503 read. Cross references (Xref: header) of articles are ignored.
2504 The difference between N and actual number of newsgroups that were
2505 caught up is returned."
2507 (unless (gnus-group-group-name)
2508 (error "No group on the current line"))
2509 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2513 "Do you really want to mark all articles as read? "
2514 "Mark all unread articles as read? "))))
2516 (let ((groups (gnus-group-process-prefix n))
2519 ;; Virtual groups have to be given special treatment.
2520 (let ((method (gnus-find-method-for-group (car groups))))
2521 (when (eq 'nnvirtual (car method))
2522 (nnvirtual-catchup-group
2523 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2524 (gnus-group-remove-mark (car groups))
2525 (if (>= (gnus-group-group-level) gnus-level-zombie)
2526 (gnus-message 2 "Dead groups can't be caught up")
2528 (gnus-group-goto-group (car groups))
2529 (gnus-group-catchup (car groups) all))
2530 (gnus-group-update-group-line)
2531 (setq ret (1+ ret))))
2532 (setq groups (cdr groups)))
2533 (gnus-group-next-unread-group 1)
2536 (defun gnus-group-catchup-current-all (&optional n)
2537 "Mark all articles in current newsgroup as read.
2538 Cross references (Xref: header) of articles are ignored."
2540 (gnus-group-catchup-current n 'all))
2542 (defun gnus-group-catchup (group &optional all)
2543 "Mark all articles in GROUP as read.
2544 If ALL is non-nil, all articles are marked as read.
2545 The return value is the number of articles that were marked as read,
2546 or nil if no action could be taken."
2547 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2549 ;; Do the updating only if the newsgroup isn't killed.
2550 (if (not (numberp (car entry)))
2551 (gnus-message 1 "Can't catch up %s; non-active group" group)
2552 ;; Do auto-expirable marks if that's required.
2553 (when (gnus-group-auto-expirable-p group)
2554 (gnus-add-marked-articles
2555 group 'expire (gnus-list-of-unread-articles group))
2557 (let ((marks (nth 3 (nth 2 entry))))
2558 (gnus-add-marked-articles
2559 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2560 (gnus-add-marked-articles
2561 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2563 (gnus-update-read-articles group nil)
2564 ;; Also nix out the lists of marks and dormants.
2566 (gnus-add-marked-articles group 'tick nil nil 'force)
2567 (gnus-add-marked-articles group 'dormant nil nil 'force))
2568 (run-hooks 'gnus-group-catchup-group-hook)
2571 (defun gnus-group-expire-articles (&optional n)
2572 "Expire all expirable articles in the current newsgroup."
2574 (let ((groups (gnus-group-process-prefix n))
2577 (error "No groups to expire"))
2578 (while (setq group (pop groups))
2579 (gnus-group-remove-mark group)
2580 (when (gnus-check-backend-function 'request-expire-articles group)
2581 (gnus-message 6 "Expiring articles in %s..." group)
2582 (let* ((info (gnus-get-info group))
2583 (expirable (if (gnus-group-total-expirable-p group)
2584 (cons nil (gnus-list-of-read-articles group))
2585 (assq 'expire (gnus-info-marks info))))
2586 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2590 (gnus-compress-sequence
2592 ;; We set the expiry variables to the group
2594 (let ((nnmail-expiry-wait-function nil)
2595 (nnmail-expiry-wait expiry-wait))
2596 (gnus-request-expire-articles
2597 (gnus-uncompress-sequence (cdr expirable)) group))
2598 ;; Just expire using the normal expiry values.
2599 (gnus-request-expire-articles
2600 (gnus-uncompress-sequence (cdr expirable)) group))))
2601 (gnus-close-group group))
2602 (gnus-message 6 "Expiring articles in %s...done" group)))
2603 (gnus-group-position-point))))
2605 (defun gnus-group-expire-all-groups ()
2606 "Expire all expirable articles in all newsgroups."
2609 (gnus-message 5 "Expiring...")
2610 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2611 (cdr gnus-newsrc-alist))))
2612 (gnus-group-expire-articles nil)))
2613 (gnus-group-position-point)
2614 (gnus-message 5 "Expiring...done"))
2616 (defun gnus-group-set-current-level (n level)
2617 "Set the level of the next N groups to LEVEL."
2622 (let ((s (read-string
2623 (format "Level (default %s): "
2624 (or (gnus-group-group-level)
2625 gnus-level-default-subscribed)))))
2626 (if (string-match "^\\s-*$" s)
2627 (int-to-string (or (gnus-group-group-level)
2628 gnus-level-default-subscribed))
2630 (unless (and (>= level 1) (<= level gnus-level-killed))
2631 (error "Illegal level: %d" level))
2632 (let ((groups (gnus-group-process-prefix n))
2634 (while (setq group (pop groups))
2635 (gnus-group-remove-mark group)
2636 (gnus-message 6 "Changed level of %s from %d to %d"
2637 group (or (gnus-group-group-level) gnus-level-killed)
2639 (gnus-group-change-level
2640 group level (or (gnus-group-group-level) gnus-level-killed))
2641 (gnus-group-update-group-line)))
2642 (gnus-group-position-point))
2644 (defun gnus-group-unsubscribe (&optional n)
2645 "Unsubscribe the current group."
2647 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2649 (defun gnus-group-subscribe (&optional n)
2650 "Unsubscribe the current group."
2652 (gnus-group-unsubscribe-current-group n 'subscribe))
2654 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2655 "Toggle subscription of the current group.
2656 If given numerical prefix, toggle the N next groups."
2658 (let ((groups (gnus-group-process-prefix n))
2661 (setq group (car groups)
2662 groups (cdr groups))
2663 (gnus-group-remove-mark group)
2664 (gnus-group-unsubscribe-group
2667 ((eq do-sub 'unsubscribe)
2668 gnus-level-default-unsubscribed)
2669 ((eq do-sub 'subscribe)
2670 gnus-level-default-subscribed)
2671 ((<= (gnus-group-group-level) gnus-level-subscribed)
2672 gnus-level-default-unsubscribed)
2674 gnus-level-default-subscribed))
2676 (gnus-group-update-group-line))
2677 (gnus-group-next-group 1)))
2679 (defun gnus-group-unsubscribe-group (group &optional level silent)
2680 "Toggle subscription to GROUP.
2681 Killed newsgroups are subscribed. If SILENT, don't try to update the
2684 (list (completing-read
2685 "Group: " gnus-active-hashtb nil
2686 (gnus-read-active-file-p)
2688 'gnus-group-history)))
2689 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2691 ((string-match "^[ \t]$" group)
2692 (error "Empty group name"))
2694 ;; Toggle subscription flag.
2695 (gnus-group-change-level
2696 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2697 gnus-level-subscribed)
2698 (1+ gnus-level-subscribed)
2699 gnus-level-default-subscribed)))
2701 (gnus-group-update-group group)))
2702 ((and (stringp group)
2703 (or (not (gnus-read-active-file-p))
2704 (gnus-active group)))
2705 ;; Add new newsgroup.
2706 (gnus-group-change-level
2708 (if level level gnus-level-default-subscribed)
2709 (or (and (member group gnus-zombie-list)
2712 (when (gnus-group-group-name)
2713 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2715 (gnus-group-update-group group)))
2716 (t (error "No such newsgroup: %s" group)))
2717 (gnus-group-position-point)))
2719 (defun gnus-group-transpose-groups (n)
2720 "Move the current newsgroup up N places.
2721 If given a negative prefix, move down instead. The difference between
2722 N and the number of steps taken is returned."
2724 (unless (gnus-group-group-name)
2725 (error "No group on current line"))
2726 (gnus-group-kill-group 1)
2728 (forward-line (- n))
2729 (gnus-group-yank-group)
2730 (gnus-group-position-point)))
2732 (defun gnus-group-kill-all-zombies ()
2733 "Kill all zombie newsgroups."
2735 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2736 (setq gnus-zombie-list nil)
2737 (gnus-group-list-groups))
2739 (defun gnus-group-kill-region (begin end)
2740 "Kill newsgroups in current region (excluding current point).
2741 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2756 (beginning-of-line) ;Important when LINES < 1
2757 (gnus-group-kill-group lines)))
2759 (defun gnus-group-kill-group (&optional n discard)
2760 "Kill the next N groups.
2761 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2762 However, only groups that were alive can be yanked; already killed
2763 groups or zombie groups can't be yanked.
2764 The return value is the name of the group that was killed, or a list
2767 (let ((buffer-read-only nil)
2768 (groups (gnus-group-process-prefix n))
2769 group entry level out)
2770 (if (< (length groups) 10)
2771 ;; This is faster when there are few groups.
2773 (push (setq group (pop groups)) out)
2774 (gnus-group-remove-mark group)
2775 (setq level (gnus-group-group-level))
2777 (when (and (not discard)
2778 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2781 (gnus-group-goto-group ,(gnus-group-group-name))
2782 (gnus-group-yank-group)))
2783 (push (cons (car entry) (nth 2 entry))
2784 gnus-list-of-killed-groups))
2785 (gnus-group-change-level
2786 (if entry entry group) gnus-level-killed (if entry nil level)))
2787 ;; If there are lots and lots of groups to be killed, we use
2788 ;; this thing instead.
2790 (setq groups (nreverse groups))
2792 (gnus-group-remove-mark (setq group (pop groups)))
2794 (push group gnus-killed-list)
2795 (setq gnus-newsrc-alist
2796 (delq (assoc group gnus-newsrc-alist)
2798 (when gnus-group-change-level-function
2799 (funcall gnus-group-change-level-function group 9 3))
2801 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2802 (push (cons (car entry) (nth 2 entry))
2803 gnus-list-of-killed-groups)
2804 (setcdr (cdr entry) (cdddr entry)))
2805 ((member group gnus-zombie-list)
2806 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2807 (gnus-make-hashtable-from-newsrc-alist)))
2809 (gnus-group-position-point)
2810 (if (< (length out) 2) (car out) (nreverse out))))
2812 (defun gnus-group-yank-group (&optional arg)
2813 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2814 inserting it before the current newsgroup. The numeric ARG specifies
2815 how many newsgroups are to be yanked. The name of the newsgroup yanked
2816 is returned, or (if several groups are yanked) a list of yanked groups
2819 (setq arg (or arg 1))
2820 (let (info group prev out)
2821 (while (>= (decf arg) 0)
2822 (when (not (setq info (pop gnus-list-of-killed-groups)))
2823 (error "No more newsgroups to yank"))
2824 (push (setq group (nth 1 info)) out)
2825 ;; Find which newsgroup to insert this one before - search
2826 ;; backward until something suitable is found. If there are no
2827 ;; other newsgroups in this buffer, just make this newsgroup the
2829 (setq prev (gnus-group-group-name))
2830 (gnus-group-change-level
2831 info (gnus-info-level (cdr info)) gnus-level-killed
2832 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2834 (gnus-group-insert-group-line-info group)
2836 `(when (gnus-group-goto-group ,group)
2837 (gnus-group-kill-group 1))))
2839 (gnus-group-position-point)
2840 (if (< (length out) 2) (car out) (nreverse out))))
2842 (defun gnus-group-kill-level (level)
2843 "Kill all groups that is on a certain LEVEL."
2844 (interactive "nKill all groups on level: ")
2846 ((= level gnus-level-zombie)
2847 (setq gnus-killed-list
2848 (nconc gnus-zombie-list gnus-killed-list))
2849 (setq gnus-zombie-list nil))
2850 ((and (< level gnus-level-zombie)
2852 (or gnus-expert-user
2855 "Do you really want to kill all groups on level %d? "
2857 (let* ((prev gnus-newsrc-alist)
2860 (if (= (gnus-info-level (car alist)) level)
2862 (push (gnus-info-group (car alist)) gnus-killed-list)
2863 (setcdr prev (cdr alist)))
2865 (setq alist (cdr alist)))
2866 (gnus-make-hashtable-from-newsrc-alist)
2867 (gnus-group-list-groups)))
2869 (error "Can't kill; illegal level: %d" level))))
2871 (defun gnus-group-list-all-groups (&optional arg)
2872 "List all newsgroups with level ARG or lower.
2873 Default is gnus-level-unsubscribed, which lists all subscribed and most
2874 unsubscribed groups."
2876 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2878 ;; Redefine this to list ALL killed groups if prefix arg used.
2879 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2880 (defun gnus-group-list-killed (&optional arg)
2881 "List all killed newsgroups in the group buffer.
2882 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2883 entail asking the server for the groups."
2885 ;; Find all possible killed newsgroups if arg.
2887 (gnus-get-killed-groups))
2888 (if (not gnus-killed-list)
2889 (gnus-message 6 "No killed groups")
2890 (let (gnus-group-list-mode)
2891 (funcall gnus-group-prepare-function
2892 gnus-level-killed t gnus-level-killed))
2893 (goto-char (point-min)))
2894 (gnus-group-position-point))
2896 (defun gnus-group-list-zombies ()
2897 "List all zombie newsgroups in the group buffer."
2899 (if (not gnus-zombie-list)
2900 (gnus-message 6 "No zombie groups")
2901 (let (gnus-group-list-mode)
2902 (funcall gnus-group-prepare-function
2903 gnus-level-zombie t gnus-level-zombie))
2904 (goto-char (point-min)))
2905 (gnus-group-position-point))
2907 (defun gnus-group-list-active ()
2908 "List all groups that are available from the server(s)."
2910 ;; First we make sure that we have really read the active file.
2911 (unless (gnus-read-active-file-p)
2912 (let ((gnus-read-active-file t))
2913 (gnus-read-active-file)))
2914 ;; Find all groups and sort them.
2922 (push (symbol-name sym) list)))
2926 (buffer-read-only nil))
2929 (gnus-group-insert-group-line-info (pop groups)))
2930 (goto-char (point-min))))
2932 (defun gnus-activate-all-groups (level)
2933 "Activate absolutely all groups."
2934 (interactive (list 7))
2935 (let ((gnus-activate-level level)
2936 (gnus-activate-foreign-newsgroups level))
2937 (gnus-group-get-new-news)))
2939 (defun gnus-group-get-new-news (&optional arg)
2940 "Get newly arrived articles.
2941 If ARG is a number, it specifies which levels you are interested in
2942 re-scanning. If ARG is non-nil and not a number, this will force
2943 \"hard\" re-reading of the active files from all servers."
2945 (run-hooks 'gnus-get-new-news-hook)
2947 ;; Read any slave files.
2949 (gnus-master-read-slave-newsrc))
2951 ;; We might read in new NoCeM messages here.
2952 (when (and gnus-use-nocem
2954 (gnus-nocem-scan-groups))
2955 ;; If ARG is not a number, then we read the active file.
2956 (when (and arg (not (numberp arg)))
2957 (let ((gnus-read-active-file t))
2958 (gnus-read-active-file))
2961 (setq arg (gnus-group-default-level arg t))
2962 (if (and gnus-read-active-file (not arg))
2964 (gnus-read-active-file)
2965 (gnus-get-unread-articles arg))
2966 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2967 (gnus-get-unread-articles arg)))
2968 (run-hooks 'gnus-after-getting-new-news-hook)
2969 (gnus-group-list-groups))
2971 (defun gnus-group-get-new-news-this-group (&optional n)
2972 "Check for newly arrived news in the current group (and the N-1 next groups).
2973 The difference between N and the number of newsgroup checked is returned.
2974 If N is negative, this group and the N-1 previous groups will be checked."
2976 (let* ((groups (gnus-group-process-prefix n))
2977 (ret (if (numberp n) (- n (length groups)) 0))
2981 (while (setq group (pop groups))
2982 (gnus-group-remove-mark group)
2983 ;; Bypass any previous denials from the server.
2984 (gnus-remove-denial (gnus-find-method-for-group group))
2985 (if (gnus-activate-group group 'scan)
2987 (gnus-get-unread-articles-in-group
2988 (gnus-get-info group) (gnus-active group) t)
2989 (unless (gnus-virtual-group-p group)
2990 (gnus-close-group group))
2991 (gnus-group-update-group group))
2992 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2994 (gnus-error 3 "Server denied access")
2995 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2998 (when gnus-goto-next-group-when-activating
2999 (gnus-group-next-unread-group 1 t))
3000 (gnus-summary-position-point)
3003 (defun gnus-group-fetch-faq (group &optional faq-dir)
3004 "Fetch the FAQ for the current group.
3005 If given a prefix argument, prompt for the FAQ dir
3009 (gnus-group-group-name)
3010 (cond (current-prefix-arg
3012 "Faq dir: " (and (listp gnus-group-faq-directory)
3013 (mapcar (lambda (file) (list file))
3014 gnus-group-faq-directory)))))))
3016 (error "No group name given"))
3017 (let ((dirs (or faq-dir gnus-group-faq-directory))
3019 (unless (listp dirs)
3020 (setq dirs (list dirs)))
3021 (while (and (not found)
3022 (setq dir (pop dirs)))
3023 (setq file (concat (file-name-as-directory dir)
3024 (gnus-group-real-name group)))
3025 (if (not (file-exists-p file))
3026 (gnus-message 1 "No such file: %s" file)
3030 (defun gnus-group-describe-group (force &optional group)
3031 "Display a description of the current newsgroup."
3032 (interactive (list current-prefix-arg (gnus-group-group-name)))
3033 (let* ((method (gnus-find-method-for-group group))
3034 (mname (gnus-group-prefixed-name "" method))
3037 gnus-description-hashtb)
3038 (gnus-sethash mname nil gnus-description-hashtb))
3040 (error "No group name given"))
3041 (when (or (and gnus-description-hashtb
3042 ;; We check whether this group's method has been
3043 ;; queried for a description file.
3044 (gnus-gethash mname gnus-description-hashtb))
3045 (setq desc (gnus-group-get-description group))
3046 (gnus-read-descriptions-file method))
3048 (or desc (gnus-gethash group gnus-description-hashtb)
3049 "No description available")))))
3051 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3052 (defun gnus-group-describe-all-groups (&optional force)
3053 "Pop up a buffer with descriptions of all newsgroups."
3056 (setq gnus-description-hashtb nil))
3057 (when (not (or gnus-description-hashtb
3058 (gnus-read-all-descriptions-files)))
3059 (error "Couldn't request descriptions file"))
3060 (let ((buffer-read-only nil)
3066 (insert (format " *: %-20s %s\n" (symbol-name group)
3067 (symbol-value group)))
3068 (gnus-add-text-properties
3069 b (1+ b) (list 'gnus-group group
3070 'gnus-unread t 'gnus-marked nil
3071 'gnus-level (1+ gnus-level-subscribed))))
3072 gnus-description-hashtb)
3073 (goto-char (point-min))
3074 (gnus-group-position-point)))
3076 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3077 (defun gnus-group-apropos (regexp &optional search-description)
3078 "List all newsgroups that have names that match a regexp."
3079 (interactive "sGnus apropos (regexp): ")
3081 (obuf (current-buffer))
3083 ;; Go through all newsgroups that are known to Gnus.
3086 (and (symbol-name group)
3087 (string-match regexp (symbol-name group))
3088 (push (symbol-name group) groups)))
3090 ;; Also go through all descriptions that are known to Gnus.
3091 (when search-description
3094 (and (string-match regexp (symbol-value group))
3095 (gnus-active (symbol-name group))
3096 (push (symbol-name group) groups)))
3097 gnus-description-hashtb))
3099 (gnus-message 3 "No groups matched \"%s\"." regexp)
3100 ;; Print out all the groups.
3102 (pop-to-buffer "*Gnus Help*")
3103 (buffer-disable-undo (current-buffer))
3105 (setq groups (sort groups 'string<))
3107 ;; Groups may be entered twice into the list of groups.
3108 (when (not (string= (car groups) prev))
3109 (insert (setq prev (car groups)) "\n")
3110 (when (and gnus-description-hashtb
3111 (setq des (gnus-gethash (car groups)
3112 gnus-description-hashtb)))
3113 (insert " " des "\n")))
3114 (setq groups (cdr groups)))
3115 (goto-char (point-min))))
3116 (pop-to-buffer obuf)))
3118 (defun gnus-group-description-apropos (regexp)
3119 "List all newsgroups that have names or descriptions that match a regexp."
3120 (interactive "sGnus description apropos (regexp): ")
3121 (when (not (or gnus-description-hashtb
3122 (gnus-read-all-descriptions-files)))
3123 (error "Couldn't request descriptions file"))
3124 (gnus-group-apropos regexp t))
3126 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3127 (defun gnus-group-list-matching (level regexp &optional all lowest)
3128 "List all groups with unread articles that match REGEXP.
3129 If the prefix LEVEL is non-nil, it should be a number that says which
3130 level to cut off listing groups.
3131 If ALL, also list groups with no unread articles.
3132 If LOWEST, don't list groups with level lower than LOWEST.
3134 This command may read the active file."
3135 (interactive "P\nsList newsgroups matching: ")
3136 ;; First make sure active file has been read.
3138 (> (prefix-numeric-value level) gnus-level-killed))
3139 (gnus-get-killed-groups))
3140 (gnus-group-prepare-flat (or level gnus-level-subscribed)
3141 all (or lowest 1) regexp)
3142 (goto-char (point-min))
3143 (gnus-group-position-point))
3145 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3146 "List all groups that match REGEXP.
3147 If the prefix LEVEL is non-nil, it should be a number that says which
3148 level to cut off listing groups.
3149 If LOWEST, don't list groups with level lower than LOWEST."
3150 (interactive "P\nsList newsgroups matching: ")
3151 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3153 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3154 (defun gnus-group-save-newsrc (&optional force)
3155 "Save the Gnus startup files.
3156 If FORCE, force saving whether it is necessary or not."
3158 (gnus-save-newsrc-file force))
3160 (defun gnus-group-restart (&optional arg)
3161 "Force Gnus to read the .newsrc file."
3163 (when (gnus-yes-or-no-p
3164 (format "Are you sure you want to restart Gnus? "))
3165 (gnus-save-newsrc-file)
3166 (gnus-setup-news 'force)
3167 (gnus-group-list-groups arg)))
3169 (defun gnus-group-read-init-file ()
3170 "Read the Gnus elisp init file."
3172 (gnus-read-init-file))
3174 (defun gnus-group-check-bogus-groups (&optional silent)
3175 "Check bogus newsgroups.
3176 If given a prefix, don't ask for confirmation before removing a bogus
3179 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3180 (gnus-group-list-groups))
3182 (defun gnus-group-edit-global-kill (&optional article group)
3183 "Edit the global kill file.
3184 If GROUP, edit that local kill file instead."
3186 (setq gnus-current-kill-article article)
3187 (gnus-kill-file-edit-file group)
3190 (substitute-command-keys
3191 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3192 (if group "local" "global")))))
3194 (defun gnus-group-edit-local-kill (article group)
3195 "Edit a local kill file."
3196 (interactive (list nil (gnus-group-group-name)))
3197 (gnus-group-edit-global-kill article group))
3199 (defun gnus-group-force-update ()
3200 "Update `.newsrc' file."
3202 (gnus-save-newsrc-file))
3204 (defun gnus-group-suspend ()
3205 "Suspend the current Gnus session.
3206 In fact, cleanup buffers except for group mode buffer.
3207 The hook gnus-suspend-gnus-hook is called before actually suspending."
3209 (run-hooks 'gnus-suspend-gnus-hook)
3210 ;; Kill Gnus buffers except for group mode buffer.
3211 (let* ((group-buf (get-buffer gnus-group-buffer))
3212 ;; Do this on a separate list in case the user does a ^G before we finish
3214 (delete group-buf (delete gnus-dribble-buffer
3215 (append gnus-buffer-list nil)))))
3216 (while gnus-buffer-list
3217 (gnus-kill-buffer (pop gnus-buffer-list)))
3218 (gnus-kill-gnus-frames)
3220 (setq gnus-buffer-list (list group-buf))
3221 (bury-buffer group-buf)
3222 (delete-windows-on group-buf t))))
3224 (defun gnus-group-clear-dribble ()
3225 "Clear all information from the dribble buffer."
3227 (gnus-dribble-clear)
3228 (gnus-message 7 "Cleared dribble buffer"))
3230 (defun gnus-group-exit ()
3231 "Quit reading news after updating .newsrc.eld and .newsrc.
3232 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3235 (or noninteractive ;For gnus-batch-kill
3236 (not gnus-interactive-exit) ;Without confirmation
3238 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3239 (run-hooks 'gnus-exit-gnus-hook)
3240 ;; Offer to save data from non-quitted summary buffers.
3241 (gnus-offer-save-summaries)
3242 ;; Save the newsrc file(s).
3243 (gnus-save-newsrc-file)
3245 (gnus-close-backends)
3246 ;; Reset everything.
3248 ;; Allow the user to do things after cleaning up.
3249 (run-hooks 'gnus-after-exiting-gnus-hook)))
3251 (defun gnus-group-quit ()
3252 "Quit reading news without updating .newsrc.eld or .newsrc.
3253 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3255 (when (or noninteractive ;For gnus-batch-kill
3256 (zerop (buffer-size))
3257 (not (gnus-server-opened gnus-select-method))
3259 (not gnus-current-startup-file)
3261 (format "Quit reading news without saving %s? "
3262 (file-name-nondirectory gnus-current-startup-file))))
3263 (run-hooks 'gnus-exit-gnus-hook)
3264 (gnus-configure-windows 'group t)
3266 (gnus-close-backends)
3268 (gnus-kill-buffer gnus-group-buffer)
3269 ;; Allow the user to do things after cleaning up.
3270 (run-hooks 'gnus-after-exiting-gnus-hook)))
3272 (defun gnus-group-describe-briefly ()
3273 "Give a one line description of the group mode commands."
3275 (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")))
3277 (defun gnus-group-browse-foreign-server (method)
3278 "Browse a foreign news server.
3279 If called interactively, this function will ask for a select method
3280 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3281 If not, METHOD should be a list where the first element is the method
3282 and the second element is the address."
3284 (list (let ((how (completing-read
3286 (append gnus-valid-select-methods gnus-server-alist)
3287 nil t (cons "nntp" 0) 'gnus-method-history)))
3288 ;; We either got a backend name or a virtual server name.
3289 ;; If the first, we also need an address.
3290 (if (assoc how gnus-valid-select-methods)
3292 ;; Suggested by mapjph@bath.ac.uk.
3295 (mapcar (lambda (server) (list server))
3296 gnus-secondary-servers)))
3297 ;; We got a server name, so we find the method.
3298 (gnus-server-to-method how)))))
3299 (gnus-browse-foreign-server method))
3301 (defun gnus-group-set-info (info &optional method-only-group part)
3302 (let* ((entry (gnus-gethash
3303 (or method-only-group (gnus-info-group info))
3304 gnus-newsrc-hashtb))
3306 (info (if method-only-group (nth 2 entry) info))
3308 (when method-only-group
3310 (error "Trying to change non-existent group %s" method-only-group))
3311 ;; We have received parts of the actual group info - either the
3312 ;; select method or the group parameters. We first check
3313 ;; whether we have to extend the info, and if so, do that.
3314 (let ((len (length info))
3315 (total (if (eq part 'method) 5 6)))
3317 (setcdr (nthcdr (1- len) info)
3318 (make-list (- total len) nil)))
3319 ;; Then we enter the new info.
3320 (setcar (nthcdr (1- total) info) part-info)))
3322 ;; This is a new group, so we just create it.
3324 (set-buffer gnus-group-buffer)
3325 (setq method (gnus-info-method info))
3326 (when (gnus-server-equal method "native")
3329 (set-buffer gnus-group-buffer)
3331 ;; It's a foreign group...
3332 (gnus-group-make-group
3333 (gnus-group-real-name (gnus-info-group info))
3334 (if (stringp method) method
3335 (prin1-to-string (car method)))
3337 (nth 1 (gnus-info-method info))))
3338 ;; It's a native group.
3339 (gnus-group-make-group (gnus-info-group info))))
3340 (gnus-message 6 "Note: New group created")
3342 (gnus-gethash (gnus-group-prefixed-name
3343 (gnus-group-real-name (gnus-info-group info))
3344 (or (gnus-info-method info) gnus-select-method))
3345 gnus-newsrc-hashtb))))
3346 ;; Whether it was a new group or not, we now have the entry, so we
3347 ;; can do the update.
3350 (setcar (nthcdr 2 entry) info)
3351 (when (and (not (eq (car entry) t))
3352 (gnus-active (gnus-info-group info)))
3353 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3354 (error "No such group: %s" (gnus-info-group info)))))
3356 (defun gnus-group-set-method-info (group select-method)
3357 (gnus-group-set-info select-method group 'method))
3359 (defun gnus-group-set-params-info (group params)
3360 (gnus-group-set-info params group 'params))
3362 (defun gnus-add-marked-articles (group type articles &optional info force)
3363 ;; Add ARTICLES of TYPE to the info of GROUP.
3364 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3365 ;; add, but replace marked articles of TYPE with ARTICLES.
3366 (let ((info (or info (gnus-get-info group)))
3367 (uncompressed '(score bookmark killed))
3370 (and (not (setq marked (nthcdr 3 info)))
3372 (setcdr (nthcdr 2 info)
3373 (list (list (cons type (gnus-compress-sequence
3375 (and (not (setq m (assq type (car marked))))
3378 (cons (cons type (gnus-compress-sequence articles t) )
3382 (setcar (nthcdr 3 info)
3383 (delq (assq type (car marked)) (car marked)))
3384 (setcdr m (gnus-compress-sequence articles t)))
3385 (setcdr m (gnus-compress-sequence
3386 (sort (nconc (gnus-uncompress-range (cdr m))
3387 (copy-sequence articles)) '<) t))))))
3390 ;;; Group timestamps
3393 (defun gnus-group-set-timestamp ()
3394 "Change the timestamp of the current group to the current time.
3395 This function can be used in hooks like `gnus-select-group-hook'
3396 or `gnus-group-catchup-group-hook'."
3397 (let ((time (current-time)))
3398 (setcdr (cdr time) nil)
3399 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time)))
3401 (defsubst gnus-group-timestamp (group)
3402 "Return the timestamp for GROUP."
3403 (gnus-group-get-parameter group 'timestamp))
3405 (defun gnus-group-timestamp-delta (group)
3406 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3407 (let* ((time (or (gnus-group-timestamp group)
3409 (delta (gnus-time-minus (current-time) time)))
3410 (+ (* (nth 0 delta) 65536.0)
3413 (defun gnus-group-timestamp-string (group)
3414 "Return a string of the timestamp for GROUP."
3415 (let ((time (gnus-group-timestamp group)))
3418 (gnus-time-iso8601 time))))
3420 (provide 'gnus-group)
3422 ;;; gnus-group.el ends here