1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (defcustom gnus-group-archive-directory
42 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
43 "*The address of the (ding) archives."
44 :group 'gnus-group-foreign
47 (defcustom gnus-group-recent-archive-directory
48 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
49 "*The address of the most recent (ding) articles."
50 :group 'gnus-group-foreign
53 (defcustom gnus-no-groups-message "No gnus is bad news"
54 "*Message displayed by Gnus when no groups are available."
58 (defcustom gnus-keep-same-level nil
59 "*Non-nil means that the next newsgroup after the current will be on the same level.
60 When you type, for instance, `n' after reading the last article in the
61 current newsgroup, you will go to the next newsgroup. If this variable
62 is nil, the next newsgroup will be the next from the group
64 If this variable is non-nil, Gnus will either put you in the
65 next newsgroup with the same level, or, if no such newsgroup is
66 available, the next newsgroup with the lowest possible level higher
67 than the current level.
68 If this variable is `best', Gnus will make the next newsgroup the one
70 :group 'gnus-group-levels
71 :type '(choice (const nil)
73 (sexp :tag "other" t)))
75 (defcustom gnus-group-goto-unread t
76 "*If non-nil, movement commands will go to the next unread and subscribed group."
77 :link '(custom-manual "(gnus)Group Maneuvering")
78 :group 'gnus-group-various
81 (defcustom gnus-goto-next-group-when-activating t
82 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
83 :link '(custom-manual "(gnus)Scanning New Messages")
84 :group 'gnus-group-various
87 (defcustom gnus-permanently-visible-groups nil
88 "*Regexp to match groups that should always be listed in the group buffer.
89 This means that they will still be listed even when there are no
90 unread articles in the groups.
92 If nil, no groups are permanently visible."
93 :group 'gnus-group-listing
94 :type '(choice regexp (const nil)))
96 (defcustom gnus-list-groups-with-ticked-articles t
97 "*If non-nil, list groups that have only ticked articles.
98 If nil, only list groups that have unread articles."
99 :group 'gnus-group-listing
102 (defcustom gnus-group-default-list-level gnus-level-subscribed
103 "*Default listing level.
104 Ignored if `gnus-group-use-permanent-levels' is non-nil."
105 :group 'gnus-group-listing
108 (defcustom gnus-group-list-inactive-groups t
109 "*If non-nil, inactive groups will be listed."
110 :group 'gnus-group-listing
111 :group 'gnus-group-levels
114 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
115 "*Function used for sorting the group buffer.
116 This function will be called with group info entries as the arguments
117 for the groups to be sorted. Pre-made functions include
118 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
119 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
120 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
121 `gnus-group-sort-by-rank'.
123 This variable can also be a list of sorting functions. In that case,
124 the most significant sort function should be the last function in the
126 :group 'gnus-group-listing
127 :link '(custom-manual "(gnus)Sorting Groups")
128 :type '(radio (function-item gnus-group-sort-by-alphabet)
129 (function-item gnus-group-sort-by-real-name)
130 (function-item gnus-group-sort-by-unread)
131 (function-item gnus-group-sort-by-level)
132 (function-item gnus-group-sort-by-score)
133 (function-item gnus-group-sort-by-method)
134 (function-item gnus-group-sort-by-rank)
135 (function :tag "other" nil)))
137 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
138 "*Format of group lines.
139 It works along the same lines as a normal formatting string,
140 with some simple extensions.
142 %M Only marked articles (character, \"*\" or \" \")
143 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
144 %L Level of subscribedness (integer)
145 %N Number of unread articles (integer)
146 %I Number of dormant articles (integer)
147 %i Number of ticked and dormant (integer)
148 %T Number of ticked articles (integer)
149 %R Number of read articles (integer)
150 %t Estimated total number of articles (integer)
151 %y Number of unread, unticked articles (integer)
152 %G Group name (string)
153 %g Qualified group name (string)
154 %D Group description (string)
155 %s Select method (string)
156 %o Moderated group (char, \"m\")
157 %p Process mark (char)
158 %O Moderated group (string, \"(m)\" or \"\")
159 %P Topic indentation (string)
160 %m Whether there is new(ish) mail in the group (char, \"%\")
161 %w Number of new(ish) mails in the group (integer)
162 %l Whether there are GroupLens predictions for this group (string)
163 %n Select from where (string)
164 %z A string that look like `<%s:%n>' if a foreign select method is used
165 %d The date the group was last entered.
166 %E Icon as defined by `gnus-group-icon-list'.
167 %u User defined specifier. The next character in the format string should
168 be a letter. Gnus will call the function gnus-user-format-function-X,
169 where X is the letter following %u. The function will be passed the
170 current header as argument. The function should return a string, which
171 will be inserted into the buffer just like information from any other
174 Text between %( and %) will be highlighted with `gnus-mouse-face' when
175 the mouse point move inside the area. There can only be one such area.
177 Note that this format specification is not always respected. For
178 reasons of efficiency, when listing killed groups, this specification
179 is ignored altogether. If the spec is changed considerably, your
180 output may end up looking strange when listing both alive and killed
183 If you use %o or %O, reading the active file will be slower and quite
184 a bit of extra memory will be used. %D will also worsen performance.
185 Also note that if you change the format specification to include any
186 of these specs, you must probably re-start Gnus to see them go into
188 :group 'gnus-group-visual
191 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
192 "*The format specification for the group mode line.
193 It works along the same lines as a normal formatting string,
194 with some simple extensions:
196 %S The native news server.
197 %M The native select method.
198 %: \":\" if %S isn't \"\"."
199 :group 'gnus-group-visual
202 (defcustom gnus-group-mode-hook nil
203 "Hook for Gnus group mode."
204 :group 'gnus-group-various
205 :options '(gnus-topic-mode)
208 (defcustom gnus-group-menu-hook nil
209 "Hook run after the creation of the group mode menu."
210 :group 'gnus-group-various
213 (defcustom gnus-group-catchup-group-hook nil
214 "Hook run when catching up a group from the group buffer."
215 :group 'gnus-group-various
216 :link '(custom-manual "(gnus)Group Data")
219 (defcustom gnus-group-update-group-hook nil
220 "Hook called when updating group lines."
221 :group 'gnus-group-visual
224 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
225 "*A function that is called to generate the group buffer.
226 The function is called with three arguments: The first is a number;
227 all group with a level less or equal to that number should be listed,
228 if the second is non-nil, empty groups should also be displayed. If
229 the third is non-nil, it is a number. No groups with a level lower
230 than this number should be displayed.
232 The only current function implemented is `gnus-group-prepare-flat'."
233 :group 'gnus-group-listing
236 (defcustom gnus-group-prepare-hook nil
237 "Hook called after the group buffer has been generated.
238 If you want to modify the group buffer, you can use this hook."
239 :group 'gnus-group-listing
242 (defcustom gnus-suspend-gnus-hook nil
243 "Hook called when suspending (not exiting) Gnus."
247 (defcustom gnus-exit-gnus-hook nil
248 "Hook called when exiting Gnus."
252 (defcustom gnus-after-exiting-gnus-hook nil
253 "Hook called after exiting Gnus."
257 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
258 "Hook called when a group line is changed.
259 The hook will not be called if `gnus-visual' is nil.
261 The default function `gnus-group-highlight-line' will
262 highlight the line according to the `gnus-group-highlight'
264 :group 'gnus-group-visual
267 (defcustom gnus-useful-groups
268 '(("(ding) mailing list mirrored at sunsite.auc.dk"
270 (nntp "sunsite.auc.dk"
271 (nntp-address "sunsite.auc.dk")))
274 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
278 (nndoc-article-type mbox)
279 (eval `(nndoc-address
280 ,(let ((file (nnheader-find-etc-directory
283 (error "Couldn't find doc group"))
285 "*Alist of useful group-server pairs."
286 :group 'gnus-group-listing
287 :type '(repeat (list (string :tag "Description")
289 (sexp :tag "Method"))))
291 (defcustom gnus-group-highlight
293 ((and (= unread 0) (not mailp) (eq level 1)) .
294 gnus-group-news-1-empty-face)
295 ((and (not mailp) (eq level 1)) .
296 gnus-group-news-1-face)
297 ((and (= unread 0) (not mailp) (eq level 2)) .
298 gnus-group-news-2-empty-face)
299 ((and (not mailp) (eq level 2)) .
300 gnus-group-news-2-face)
301 ((and (= unread 0) (not mailp) (eq level 3)) .
302 gnus-group-news-3-empty-face)
303 ((and (not mailp) (eq level 3)) .
304 gnus-group-news-3-face)
305 ((and (= unread 0) (not mailp) (eq level 4)) .
306 gnus-group-news-4-empty-face)
307 ((and (not mailp) (eq level 4)) .
308 gnus-group-news-4-face)
309 ((and (= unread 0) (not mailp) (eq level 5)) .
310 gnus-group-news-5-empty-face)
311 ((and (not mailp) (eq level 5)) .
312 gnus-group-news-5-face)
313 ((and (= unread 0) (not mailp) (eq level 6)) .
314 gnus-group-news-6-empty-face)
315 ((and (not mailp) (eq level 6)) .
316 gnus-group-news-6-face)
317 ((and (= unread 0) (not mailp)) .
318 gnus-group-news-low-empty-face)
320 gnus-group-news-low-face)
322 ((and (= unread 0) (eq level 1)) .
323 gnus-group-mail-1-empty-face)
325 gnus-group-mail-1-face)
326 ((and (= unread 0) (eq level 2)) .
327 gnus-group-mail-2-empty-face)
329 gnus-group-mail-2-face)
330 ((and (= unread 0) (eq level 3)) .
331 gnus-group-mail-3-empty-face)
333 gnus-group-mail-3-face)
335 gnus-group-mail-low-empty-face)
337 gnus-group-mail-low-face))
338 "*Controls the highlighting of group buffer lines.
340 Below is a list of `Form'/`Face' pairs. When deciding how a a
341 particular group line should be displayed, each form is
342 evaluated. The content of the face field after the first true form is
343 used. You can change how those group lines are displayed by
344 editing the face field.
346 It is also possible to change and add form fields, but currently that
347 requires an understanding of Lisp expressions. Hopefully this will
348 change in a future release. For now, you can use the following
349 variables in the Lisp expression:
351 group: The name of the group.
352 unread: The number of unread articles in the group.
353 method: The select method used.
354 mailp: Whether it's a mail group or not.
355 level: The level of the group.
356 score: The score of the group.
357 ticked: The number of ticked articles."
358 :group 'gnus-group-visual
359 :type '(repeat (cons (sexp :tag "Form") face)))
361 (defcustom gnus-new-mail-mark ?%
362 "Mark used for groups with new mail."
363 :group 'gnus-group-visual
366 (defgroup gnus-group-icons nil
367 "Add Icons to your group buffer. "
368 :group 'gnus-group-visual)
370 (defcustom gnus-group-icon-list
372 "*Controls the insertion of icons into group buffer lines.
374 Below is a list of `Form'/`File' pairs. When deciding how a
375 particular group line should be displayed, each form is evaluated.
376 The icon from the file field after the first true form is used. You
377 can change how those group lines are displayed by editing the file
378 field. The File will either be found in the
379 `gnus-group-glyph-directory' or by designating absolute path to the
382 It is also possible to change and add form fields, but currently that
383 requires an understanding of Lisp expressions. Hopefully this will
384 change in a future release. For now, you can use the following
385 variables in the Lisp expression:
387 group: The name of the group.
388 unread: The number of unread articles in the group.
389 method: The select method used.
390 mailp: Whether it's a mail group or not.
391 newsp: Whether it's a news group or not
392 level: The level of the group.
393 score: The score of the group.
394 ticked: The number of ticked articles."
395 :group 'gnus-group-icons
396 :type '(repeat (cons (sexp :tag "Form") file)))
398 (defcustom gnus-group-name-charset-method-alist nil
399 "*Alist of method and the charset for group names.
402 (((nntp \"news.com.cn\") . cn-gb-2312))
405 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
407 (defcustom gnus-group-name-charset-group-alist nil
408 "*Alist of group regexp and the charset for group names.
411 ((\"\\.com\\.cn:\" . cn-gb-2312))
414 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
416 ;;; Internal variables
418 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
419 "Function for sorting the group buffer.")
421 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
422 "Function for sorting the selected groups in the group buffer.")
424 (defvar gnus-group-indentation-function nil)
425 (defvar gnus-goto-missing-group-function nil)
426 (defvar gnus-group-update-group-function nil)
427 (defvar gnus-group-goto-next-group-function nil
428 "Function to override finding the next group after listing groups.")
430 (defvar gnus-group-edit-buffer nil)
432 (defvar gnus-group-line-format-alist
433 `((?M gnus-tmp-marked-mark ?c)
434 (?S gnus-tmp-subscribed ?c)
435 (?L gnus-tmp-level ?d)
436 (?N (cond ((eq number t) "*" )
440 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
441 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
443 (?R gnus-tmp-number-of-read ?s)
444 (?t gnus-tmp-number-total ?d)
445 (?y gnus-tmp-number-of-unread ?s)
446 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
447 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
448 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
449 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
450 (?g gnus-tmp-group ?s)
451 (?G gnus-tmp-qualified-group ?s)
452 (?c (gnus-short-group-name gnus-tmp-group) ?s)
453 (?D gnus-tmp-newsgroup-description ?s)
454 (?o gnus-tmp-moderated ?c)
455 (?O gnus-tmp-moderated-string ?s)
456 (?p gnus-tmp-process-marked ?c)
457 (?s gnus-tmp-news-server ?s)
458 (?n gnus-tmp-news-method ?s)
459 (?P gnus-group-indentation ?s)
460 (?E gnus-tmp-group-icon ?s)
461 (?l gnus-tmp-grouplens ?s)
462 (?z gnus-tmp-news-method-string ?s)
463 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
464 (?w (if (gnus-news-group-p gnus-tmp-group)
468 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
471 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
472 (?u gnus-tmp-user-defined ?s)))
474 (defvar gnus-group-mode-line-format-alist
475 `((?S gnus-tmp-news-server ?s)
476 (?M gnus-tmp-news-method ?s)
477 (?u gnus-tmp-user-defined ?s)
478 (?: gnus-tmp-colon ?s)))
480 (defvar gnus-topic-topology nil
481 "The complete topic hierarchy.")
483 (defvar gnus-topic-alist nil
484 "The complete topic-group alist.")
486 (defvar gnus-group-marked nil)
488 (defvar gnus-group-list-mode nil)
491 (defvar gnus-group-icon-cache nil)
497 (put 'gnus-group-mode 'mode-class 'special)
500 (gnus-define-keys gnus-group-mode-map
501 " " gnus-group-read-group
502 "=" gnus-group-select-group
503 "\r" gnus-group-select-group
504 "\M-\r" gnus-group-quick-select-group
505 "\M- " gnus-group-visible-select-group
506 [(meta control return)] gnus-group-select-group-ephemerally
507 "j" gnus-group-jump-to-group
508 "n" gnus-group-next-unread-group
509 "p" gnus-group-prev-unread-group
510 "\177" gnus-group-prev-unread-group
511 [delete] gnus-group-prev-unread-group
512 [backspace] gnus-group-prev-unread-group
513 "N" gnus-group-next-group
514 "P" gnus-group-prev-group
515 "\M-n" gnus-group-next-unread-group-same-level
516 "\M-p" gnus-group-prev-unread-group-same-level
517 "," gnus-group-best-unread-group
518 "." gnus-group-first-unread-group
519 "u" gnus-group-unsubscribe-current-group
520 "U" gnus-group-unsubscribe-group
521 "c" gnus-group-catchup-current
522 "C" gnus-group-catchup-current-all
523 "\M-c" gnus-group-clear-data
524 "l" gnus-group-list-groups
525 "L" gnus-group-list-all-groups
527 "g" gnus-group-get-new-news
528 "\M-g" gnus-group-get-new-news-this-group
529 "R" gnus-group-restart
530 "r" gnus-group-read-init-file
531 "B" gnus-group-browse-foreign-server
532 "b" gnus-group-check-bogus-groups
533 "F" gnus-group-find-new-groups
534 "\C-c\C-d" gnus-group-describe-group
535 "\M-d" gnus-group-describe-all-groups
536 "\C-c\C-a" gnus-group-apropos
537 "\C-c\M-\C-a" gnus-group-description-apropos
538 "a" gnus-group-post-news
539 "\ek" gnus-group-edit-local-kill
540 "\eK" gnus-group-edit-global-kill
541 "\C-k" gnus-group-kill-group
542 "\C-y" gnus-group-yank-group
543 "\C-w" gnus-group-kill-region
544 "\C-x\C-t" gnus-group-transpose-groups
545 "\C-c\C-l" gnus-group-list-killed
546 "\C-c\C-x" gnus-group-expire-articles
547 "\C-c\M-\C-x" gnus-group-expire-all-groups
549 "s" gnus-group-save-newsrc
550 "z" gnus-group-suspend
553 "?" gnus-group-describe-briefly
554 "\C-c\C-i" gnus-info-find-node
555 "\M-e" gnus-group-edit-group-method
556 "^" gnus-group-enter-server-mode
557 gnus-mouse-2 gnus-mouse-pick-group
558 "<" beginning-of-buffer
561 "\C-c\C-s" gnus-group-sort-groups
563 "\C-c\M-g" gnus-activate-all-groups
564 "\M-&" gnus-group-universal-argument
565 "#" gnus-group-mark-group
566 "\M-#" gnus-group-unmark-group)
568 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
569 "m" gnus-group-mark-group
570 "u" gnus-group-unmark-group
571 "w" gnus-group-mark-region
572 "b" gnus-group-mark-buffer
573 "r" gnus-group-mark-regexp
574 "U" gnus-group-unmark-all-groups)
576 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
577 "d" gnus-group-make-directory-group
578 "h" gnus-group-make-help-group
579 "u" gnus-group-make-useful-group
580 "a" gnus-group-make-archive-group
581 "k" gnus-group-make-kiboze-group
582 "l" gnus-group-nnimap-edit-acl
583 "m" gnus-group-make-group
584 "E" gnus-group-edit-group
585 "e" gnus-group-edit-group-method
586 "p" gnus-group-edit-group-parameters
587 "v" gnus-group-add-to-virtual
588 "V" gnus-group-make-empty-virtual
589 "D" gnus-group-enter-directory
590 "f" gnus-group-make-doc-group
591 "w" gnus-group-make-web-group
592 "r" gnus-group-rename-group
593 "c" gnus-group-customize
594 "x" gnus-group-nnimap-expunge
595 "\177" gnus-group-delete-group
596 [delete] gnus-group-delete-group)
598 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
599 "b" gnus-group-brew-soup
600 "w" gnus-soup-save-areas
601 "s" gnus-soup-send-replies
602 "p" gnus-soup-pack-packet
603 "r" nnsoup-pack-replies)
605 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
606 "s" gnus-group-sort-groups
607 "a" gnus-group-sort-groups-by-alphabet
608 "u" gnus-group-sort-groups-by-unread
609 "l" gnus-group-sort-groups-by-level
610 "v" gnus-group-sort-groups-by-score
611 "r" gnus-group-sort-groups-by-rank
612 "m" gnus-group-sort-groups-by-method)
614 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
615 "s" gnus-group-sort-selected-groups
616 "a" gnus-group-sort-selected-groups-by-alphabet
617 "u" gnus-group-sort-selected-groups-by-unread
618 "l" gnus-group-sort-selected-groups-by-level
619 "v" gnus-group-sort-selected-groups-by-score
620 "r" gnus-group-sort-selected-groups-by-rank
621 "m" gnus-group-sort-selected-groups-by-method)
623 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
624 "k" gnus-group-list-killed
625 "z" gnus-group-list-zombies
626 "s" gnus-group-list-groups
627 "u" gnus-group-list-all-groups
628 "A" gnus-group-list-active
629 "a" gnus-group-apropos
630 "d" gnus-group-description-apropos
631 "m" gnus-group-list-matching
632 "M" gnus-group-list-all-matching
633 "l" gnus-group-list-level
634 "c" gnus-group-list-cached
635 "?" gnus-group-list-dormant)
637 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
638 "f" gnus-score-flush-cache)
640 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
641 "d" gnus-group-describe-group
642 "f" gnus-group-fetch-faq
645 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
646 "l" gnus-group-set-current-level
647 "t" gnus-group-unsubscribe-current-group
648 "s" gnus-group-unsubscribe-group
649 "k" gnus-group-kill-group
650 "y" gnus-group-yank-group
651 "w" gnus-group-kill-region
652 "\C-k" gnus-group-kill-level
653 "z" gnus-group-kill-all-zombies))
655 (defun gnus-group-make-menu-bar ()
656 (gnus-turn-off-edit-menu 'group)
657 (unless (boundp 'gnus-group-reading-menu)
660 gnus-group-reading-menu gnus-group-mode-map ""
662 ["Read" gnus-group-read-group (gnus-group-group-name)]
663 ["Select" gnus-group-select-group (gnus-group-group-name)]
664 ["See old articles" (gnus-group-select-group 'all)
665 :keys "C-u SPC" :active (gnus-group-group-name)]
666 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
667 ["Catch up all articles" gnus-group-catchup-current-all
668 (gnus-group-group-name)]
669 ["Check for new articles" gnus-group-get-new-news-this-group
670 (gnus-group-group-name)]
671 ["Toggle subscription" gnus-group-unsubscribe-current-group
672 (gnus-group-group-name)]
673 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
674 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
675 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
676 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
677 ;; Actually one should check, if any of the marked groups gives t for
678 ;; (gnus-check-backend-function 'request-expire-articles ...)
679 ["Expire articles" gnus-group-expire-articles
680 (or (and (gnus-group-group-name)
681 (gnus-check-backend-function
682 'request-expire-articles
683 (gnus-group-group-name))) gnus-group-marked)]
684 ["Set group level" gnus-group-set-current-level
685 (gnus-group-group-name)]
686 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
687 ["Customize" gnus-group-customize (gnus-group-group-name)]
689 ["Parameters" gnus-group-edit-group-parameters
690 (gnus-group-group-name)]
691 ["Select method" gnus-group-edit-group-method
692 (gnus-group-group-name)]
693 ["Info" gnus-group-edit-group (gnus-group-group-name)]
694 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
695 ["Global kill file" gnus-group-edit-global-kill t])))
698 gnus-group-group-menu gnus-group-mode-map ""
701 ["List unread subscribed groups" gnus-group-list-groups t]
702 ["List (un)subscribed groups" gnus-group-list-all-groups t]
703 ["List killed groups" gnus-group-list-killed gnus-killed-list]
704 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
705 ["List level..." gnus-group-list-level t]
706 ["Describe all groups" gnus-group-describe-all-groups t]
707 ["Group apropos..." gnus-group-apropos t]
708 ["Group and description apropos..." gnus-group-description-apropos t]
709 ["List groups matching..." gnus-group-list-matching t]
710 ["List all groups matching..." gnus-group-list-all-matching t]
711 ["List active file" gnus-group-list-active t]
712 ["List groups with cached" gnus-group-list-cached t]
713 ["List groups with dormant" gnus-group-list-dormant t])
715 ["Default sort" gnus-group-sort-groups t]
716 ["Sort by method" gnus-group-sort-groups-by-method t]
717 ["Sort by rank" gnus-group-sort-groups-by-rank t]
718 ["Sort by score" gnus-group-sort-groups-by-score t]
719 ["Sort by level" gnus-group-sort-groups-by-level t]
720 ["Sort by unread" gnus-group-sort-groups-by-unread t]
721 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
722 ("Sort process/prefixed"
723 ["Default sort" gnus-group-sort-selected-groups
724 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
725 ["Sort by method" gnus-group-sort-selected-groups-by-method
726 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
727 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
728 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
729 ["Sort by score" gnus-group-sort-selected-groups-by-score
730 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
731 ["Sort by level" gnus-group-sort-selected-groups-by-level
732 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
733 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
734 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
735 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
736 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
738 ["Mark group" gnus-group-mark-group
739 (and (gnus-group-group-name)
740 (not (memq (gnus-group-group-name) gnus-group-marked)))]
741 ["Unmark group" gnus-group-unmark-group
742 (and (gnus-group-group-name)
743 (memq (gnus-group-group-name) gnus-group-marked))]
744 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
745 ["Mark regexp..." gnus-group-mark-regexp t]
746 ["Mark region" gnus-group-mark-region t]
747 ["Mark buffer" gnus-group-mark-buffer t]
748 ["Execute command" gnus-group-universal-argument
749 (or gnus-group-marked (gnus-group-group-name))])
751 ["Subscribe to a group" gnus-group-unsubscribe-group t]
752 ["Kill all newsgroups in region" gnus-group-kill-region t]
753 ["Kill all zombie groups" gnus-group-kill-all-zombies
755 ["Kill all groups on level..." gnus-group-kill-level t])
757 ["Make a foreign group" gnus-group-make-group t]
758 ["Add a directory group" gnus-group-make-directory-group t]
759 ["Add the help group" gnus-group-make-help-group t]
760 ["Add the archive group" gnus-group-make-archive-group t]
761 ["Make a doc group" gnus-group-make-doc-group t]
762 ["Make a web group" gnus-group-make-web-group t]
763 ["Make a kiboze group" gnus-group-make-kiboze-group t]
764 ["Make a virtual group" gnus-group-make-empty-virtual t]
765 ["Add a group to a virtual" gnus-group-add-to-virtual t]
766 ["Rename group" gnus-group-rename-group
767 (gnus-check-backend-function
768 'request-rename-group (gnus-group-group-name))]
769 ["Delete group" gnus-group-delete-group
770 (gnus-check-backend-function
771 'request-delete-group (gnus-group-group-name))])
773 ["Next" gnus-group-next-group t]
774 ["Previous" gnus-group-prev-group t]
775 ["Next unread" gnus-group-next-unread-group t]
776 ["Previous unread" gnus-group-prev-unread-group t]
777 ["Next unread same level" gnus-group-next-unread-group-same-level t]
778 ["Previous unread same level"
779 gnus-group-prev-unread-group-same-level t]
780 ["Jump to group" gnus-group-jump-to-group t]
781 ["First unread group" gnus-group-first-unread-group t]
782 ["Best unread group" gnus-group-best-unread-group t])
783 ["Delete bogus groups" gnus-group-check-bogus-groups t]
784 ["Find new newsgroups" gnus-group-find-new-groups t]
785 ["Transpose" gnus-group-transpose-groups
786 (gnus-group-group-name)]
787 ["Read a directory as a group..." gnus-group-enter-directory t]))
790 gnus-group-misc-menu gnus-group-mode-map ""
793 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
794 ["Send replies" gnus-soup-send-replies
795 (fboundp 'gnus-soup-pack-packet)]
796 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
797 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
798 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
799 ["Send a mail" gnus-group-mail t]
800 ["Post an article..." gnus-group-post-news t]
801 ["Check for new news" gnus-group-get-new-news t]
802 ["Activate all groups" gnus-activate-all-groups t]
803 ["Restart Gnus" gnus-group-restart t]
804 ["Read init file" gnus-group-read-init-file t]
805 ["Browse foreign server" gnus-group-browse-foreign-server t]
806 ["Enter server buffer" gnus-group-enter-server-mode t]
807 ["Expire all expirable articles" gnus-group-expire-all-groups t]
808 ["Generate any kiboze groups" nnkiboze-generate-groups t]
809 ["Gnus version" gnus-version t]
810 ["Save .newsrc files" gnus-group-save-newsrc t]
811 ["Suspend Gnus" gnus-group-suspend t]
812 ["Clear dribble buffer" gnus-group-clear-dribble t]
813 ["Read manual" gnus-info-find-node t]
814 ["Flush score cache" gnus-score-flush-cache t]
815 ["Toggle topics" gnus-topic-mode t]
816 ["Send a bug report" gnus-bug t]
817 ["Exit from Gnus" gnus-group-exit t]
818 ["Exit without saving" gnus-group-quit t]))
820 (gnus-run-hooks 'gnus-group-menu-hook)))
822 (defun gnus-group-mode ()
823 "Major mode for reading news.
825 All normal editing commands are switched off.
826 \\<gnus-group-mode-map>
827 The group buffer lists (some of) the groups available. For instance,
828 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
829 lists all zombie groups.
831 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
832 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
834 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
836 The following commands are available:
838 \\{gnus-group-mode-map}"
840 (when (gnus-visual-p 'group-menu 'menu)
841 (gnus-group-make-menu-bar))
842 (kill-all-local-variables)
843 (gnus-simplify-mode-line)
844 (setq major-mode 'gnus-group-mode)
845 (setq mode-name "Group")
846 (gnus-group-set-mode-line)
847 (setq mode-line-process nil)
848 (use-local-map gnus-group-mode-map)
849 (buffer-disable-undo)
850 (setq truncate-lines t)
851 (setq buffer-read-only t)
852 (gnus-set-default-directory)
853 (gnus-update-format-specifications nil 'group 'group-mode)
854 (gnus-update-group-mark-positions)
859 (gnus-run-hooks 'gnus-group-mode-hook))
861 (defun gnus-update-group-mark-positions ()
863 (let ((gnus-process-mark ?\200)
864 (gnus-group-marked '("dummy.group"))
865 (gnus-active-hashtb (make-vector 10 0))
867 (gnus-set-active "dummy.group" '(0 . 0))
868 (gnus-set-work-buffer)
869 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
870 (goto-char (point-min))
871 (setq gnus-group-mark-positions
872 (list (cons 'process (and (search-forward "\200" nil t)
875 (defun gnus-mouse-pick-group (e)
876 "Enter the group under the mouse pointer."
879 (gnus-group-read-group nil))
881 ;; Look at LEVEL and find out what the level is really supposed to be.
882 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
883 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
884 (defun gnus-group-default-level (&optional level number-or-nil)
886 (gnus-group-use-permanent-levels
887 (or (setq gnus-group-use-permanent-levels
888 (or level (if (numberp gnus-group-use-permanent-levels)
889 gnus-group-use-permanent-levels
890 (or gnus-group-default-list-level
891 gnus-level-subscribed))))
892 gnus-group-default-list-level gnus-level-subscribed))
896 (or level gnus-group-default-list-level gnus-level-subscribed))))
898 (defun gnus-group-setup-buffer ()
899 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
900 (unless (eq major-mode 'gnus-group-mode)
903 (gnus-carpal-setup-buffer 'group))))
905 (defsubst gnus-group-name-charset (method group)
907 (setq method (gnus-find-method-for-group group)))
908 (let ((item (assoc method gnus-group-name-charset-method-alist))
909 (alist gnus-group-name-charset-group-alist)
913 (while (setq item (pop alist))
914 (if (string-match (car item) group)
919 (defsubst gnus-group-name-decode (string charset)
920 (if (and string charset (featurep 'mule))
921 (decode-coding-string string charset)
924 (defun gnus-group-decoded-name (string)
925 (let ((charset (gnus-group-name-charset nil string)))
926 (gnus-group-name-decode string charset)))
928 (defun gnus-group-list-groups (&optional level unread lowest)
929 "List newsgroups with level LEVEL or lower that have unread articles.
930 Default is all subscribed groups.
931 If argument UNREAD is non-nil, groups with no unread articles are also
934 Also see the `gnus-group-use-permanent-levels' variable."
936 (list (if current-prefix-arg
937 (prefix-numeric-value current-prefix-arg)
939 (gnus-group-default-level nil t)
940 gnus-group-default-list-level
941 gnus-level-subscribed))))
943 (setq level (car gnus-group-list-mode)
944 unread (cdr gnus-group-list-mode)))
945 (setq level (gnus-group-default-level level))
946 (gnus-group-setup-buffer)
947 (gnus-update-format-specifications nil 'group 'group-mode)
948 (let ((case-fold-search nil)
949 (props (text-properties-at (gnus-point-at-bol)))
950 (empty (= (point-min) (point-max)))
951 (group (gnus-group-group-name))
953 (set-buffer gnus-group-buffer)
954 (setq number (funcall gnus-group-prepare-function level unread lowest))
955 (when (or (and (numberp number)
957 (zerop (buffer-size)))
958 ;; No groups in the buffer.
959 (gnus-message 5 gnus-no-groups-message))
960 ;; We have some groups displayed.
961 (goto-char (point-max))
962 (when (or (not gnus-group-goto-next-group-function)
963 (not (funcall gnus-group-goto-next-group-function
967 (goto-char (point-min)))
969 ;; Go to the first group with unread articles.
970 (gnus-group-search-forward t))
972 ;; Find the right group to put point on. If the current group
973 ;; has disappeared in the new listing, try to find the next
974 ;; one. If no next one can be found, just leave point at the
975 ;; first newsgroup in the buffer.
976 (when (not (gnus-goto-char
978 (point-min) (point-max)
979 'gnus-group (gnus-intern-safe
980 group gnus-active-hashtb))))
981 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
985 (point-min) (point-max) 'gnus-group
987 (caar newsrc) gnus-active-hashtb)))))
988 (setq newsrc (cdr newsrc)))
990 (goto-char (point-max))
991 (forward-line -1)))))))
992 ;; Adjust cursor point.
993 (gnus-group-position-point)))
995 (defun gnus-group-list-level (level &optional all)
996 "List groups on LEVEL.
997 If ALL (the prefix), also list groups that have no unread articles."
998 (interactive "nList groups on level: \nP")
999 (gnus-group-list-groups level all level))
1001 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
1002 "List all newsgroups with unread articles of level LEVEL or lower.
1003 If ALL is non-nil, list groups that have no unread articles.
1004 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1005 If REGEXP, only list groups matching REGEXP."
1006 (set-buffer gnus-group-buffer)
1007 (let ((buffer-read-only nil)
1008 (newsrc (cdr gnus-newsrc-alist))
1009 (lowest (or lowest 1))
1010 info clevel unread group params)
1012 (when (< lowest gnus-level-zombie)
1013 ;; List living groups.
1015 (setq info (car newsrc)
1016 group (gnus-info-group info)
1017 params (gnus-info-params info)
1019 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1020 (and unread ; This group might be unchecked
1022 (string-match regexp group))
1023 (<= (setq clevel (gnus-info-level info)) level)
1025 (or all ; We list all groups?
1026 (if (eq unread t) ; Unactivated?
1027 gnus-group-list-inactive-groups ; We list unactivated
1028 (> unread 0)) ; We list groups with unread articles
1029 (and gnus-list-groups-with-ticked-articles
1030 (cdr (assq 'tick (gnus-info-marks info))))
1031 ; And groups with tickeds
1032 ;; Check for permanent visibility.
1033 (and gnus-permanently-visible-groups
1034 (string-match gnus-permanently-visible-groups
1036 (memq 'visible params)
1037 (cdr (assq 'visible params)))
1038 (gnus-group-insert-group-line
1039 group (gnus-info-level info)
1040 (gnus-info-marks info) unread (gnus-info-method info)))))
1042 ;; List dead groups.
1043 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
1044 (gnus-group-prepare-flat-list-dead
1045 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1046 gnus-level-zombie ?Z
1048 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
1049 (gnus-group-prepare-flat-list-dead
1050 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1051 gnus-level-killed ?K regexp))
1053 (gnus-group-set-mode-line)
1054 (setq gnus-group-list-mode (cons level all))
1055 (gnus-run-hooks 'gnus-group-prepare-hook)
1058 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1059 ;; List zombies and killed lists somewhat faster, which was
1060 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1061 ;; this by ignoring the group format specification altogether.
1064 ;; This loop is used when listing groups that match some
1067 (setq group (pop groups))
1068 (when (string-match regexp group)
1069 (gnus-add-text-properties
1070 (point) (prog1 (1+ (point))
1071 (insert " " mark " *: "
1072 (gnus-group-name-decode group
1073 (gnus-group-name-charset
1076 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1078 'gnus-level level))))
1079 ;; This loop is used when listing all groups.
1081 (setq group (pop groups))
1082 (gnus-add-text-properties
1083 (point) (prog1 (1+ (point))
1084 (insert " " mark " *: "
1085 (gnus-group-name-decode group
1086 (gnus-group-name-charset
1089 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1091 'gnus-level level))))))
1093 (defun gnus-group-update-group-line ()
1094 "Update the current line in the group buffer."
1095 (let* ((buffer-read-only nil)
1096 (group (gnus-group-group-name))
1097 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1098 gnus-group-indentation)
1101 (not (gnus-ephemeral-group-p group))
1103 (concat "(gnus-group-set-info '"
1104 (gnus-prin1-to-string (nth 2 entry))
1106 (setq gnus-group-indentation (gnus-group-group-indentation))
1108 (gnus-group-insert-group-line-info group)
1110 (gnus-group-position-point))))
1112 (defun gnus-group-insert-group-line-info (group)
1113 "Insert GROUP on the current line."
1114 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1115 (gnus-group-indentation (gnus-group-group-indentation))
1119 ;; (Un)subscribed group.
1120 (setq info (nth 2 entry))
1121 (gnus-group-insert-group-line
1122 group (gnus-info-level info) (gnus-info-marks info)
1123 (or (car entry) t) (gnus-info-method info)))
1124 ;; This group is dead.
1125 (gnus-group-insert-group-line
1127 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1129 (if (setq active (gnus-active group))
1130 (if (zerop (cdr active))
1132 (- (1+ (cdr active)) (car active)))
1136 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1137 gnus-tmp-marked number
1139 "Insert a group line in the group buffer."
1140 (let* ((gnus-tmp-method
1141 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1142 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1144 (gnus-tmp-active (gnus-active gnus-tmp-group))
1145 (gnus-tmp-number-total
1147 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1149 (gnus-tmp-number-of-unread
1150 (if (numberp number) (int-to-string (max 0 number))
1152 (gnus-tmp-number-of-read
1153 (if (numberp number)
1154 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1156 (gnus-tmp-subscribed
1157 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1158 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1159 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1161 (gnus-tmp-qualified-group
1162 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1163 group-name-charset))
1164 (gnus-tmp-newsgroup-description
1165 (if gnus-description-hashtb
1166 (or (gnus-group-name-decode
1167 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1168 group-name-charset) "")
1171 (if (and gnus-moderated-hashtb
1172 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1174 (gnus-tmp-moderated-string
1175 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1176 (gnus-tmp-group-icon "==&&==")
1177 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1178 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1179 (gnus-tmp-news-method-string
1181 (format "(%s:%s)" (car gnus-tmp-method)
1182 (cadr gnus-tmp-method)) ""))
1183 (gnus-tmp-marked-mark
1184 (if (and (numberp number)
1186 (cdr (assq 'tick gnus-tmp-marked)))
1188 (gnus-tmp-process-marked
1189 (if (member gnus-tmp-group gnus-group-marked)
1190 gnus-process-mark ? ))
1192 (or (and gnus-use-grouplens
1193 (bbb-grouplens-group-p gnus-tmp-group))
1195 (buffer-read-only nil)
1196 header gnus-tmp-header) ; passed as parameter to user-funcs.
1198 (gnus-add-text-properties
1202 (eval gnus-group-line-format-spec))
1203 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1204 gnus-unread ,(if (numberp number)
1205 (string-to-int gnus-tmp-number-of-unread)
1207 gnus-marked ,gnus-tmp-marked-mark
1208 gnus-indentation ,gnus-group-indentation
1209 gnus-level ,gnus-tmp-level))
1211 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1212 (gnus-run-hooks 'gnus-group-update-hook))
1214 ;; Allow XEmacs to remove front-sticky text properties.
1215 (gnus-group-remove-excess-properties)))
1217 (defun gnus-group-highlight-line ()
1218 "Highlight the current line according to `gnus-group-highlight'."
1219 (let* ((list gnus-group-highlight)
1221 (end (progn (end-of-line) (point)))
1222 ;; now find out where the line starts and leave point there.
1223 (beg (progn (beginning-of-line) (point)))
1224 (group (gnus-group-group-name))
1225 (entry (gnus-group-entry group))
1226 (unread (if (numberp (car entry)) (car entry) 0))
1227 (active (gnus-active group))
1228 (total (if active (1+ (- (cdr active) (car active))) 0))
1229 (info (nth 2 entry))
1230 (method (gnus-server-get-method group (gnus-info-method info)))
1231 (marked (gnus-info-marks info))
1232 (mailp (memq 'mail (assoc (symbol-name
1233 (car (or method gnus-select-method)))
1234 gnus-valid-select-methods)))
1235 (level (or (gnus-info-level info) gnus-level-killed))
1236 (score (or (gnus-info-score info) 0))
1237 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1238 (group-age (gnus-group-timestamp-delta group))
1239 (inhibit-read-only t))
1240 ;; Eval the cars of the lists until we find a match.
1242 (not (eval (caar list))))
1243 (setq list (cdr list)))
1244 (let ((face (cdar list)))
1245 (unless (eq face (get-text-property beg 'face))
1246 (gnus-put-text-property-excluding-characters-with-faces
1248 (setq face (if (boundp face) (symbol-value face) face)))
1249 (gnus-extent-start-open beg)))
1252 (defun gnus-group-update-group (group &optional visible-only)
1253 "Update all lines where GROUP appear.
1254 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1256 ;; Can't use `save-excursion' here, so we do it manually.
1257 (let ((buf (current-buffer))
1259 (set-buffer gnus-group-buffer)
1260 (setq mark (point-marker))
1261 ;; The buffer may be narrowed.
1264 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1266 found buffer-read-only)
1267 ;; Enter the current status into the dribble buffer.
1268 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1270 (not (gnus-ephemeral-group-p group)))
1272 (concat "(gnus-group-set-info '"
1273 (gnus-prin1-to-string (nth 2 entry))
1275 ;; Find all group instances. If topics are in use, each group
1276 ;; may be listed in more than once.
1277 (while (setq loc (text-property-any
1278 loc (point-max) 'gnus-group ident))
1281 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1283 (gnus-group-insert-group-line-info group)
1286 (gnus-run-hooks 'gnus-group-update-group-hook)))
1287 (setq loc (1+ loc)))
1288 (unless (or found visible-only)
1289 ;; No such line in the buffer, find out where it's supposed to
1290 ;; go, and insert it there (or at the end of the buffer).
1291 (if gnus-goto-missing-group-function
1292 (funcall gnus-goto-missing-group-function group)
1293 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1294 (while (and entry (car entry)
1298 (point-min) (point-max)
1299 'gnus-group (gnus-intern-safe
1300 (caar entry) gnus-active-hashtb)))))
1301 (setq entry (cdr entry)))
1302 (or entry (goto-char (point-max)))))
1303 ;; Finally insert the line.
1304 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1305 (gnus-group-insert-group-line-info group)
1308 (gnus-run-hooks 'gnus-group-update-group-hook))))
1309 (when gnus-group-update-group-function
1310 (funcall gnus-group-update-group-function group))
1311 (gnus-group-set-mode-line)))
1313 (set-marker mark nil)
1316 (defun gnus-group-set-mode-line ()
1317 "Update the mode line in the group buffer."
1318 (when (memq 'group gnus-updated-mode-lines)
1319 ;; Yes, we want to keep this mode line updated.
1321 (set-buffer gnus-group-buffer)
1322 (let* ((gformat (or gnus-group-mode-line-format-spec
1323 (gnus-set-format 'group-mode)))
1324 (gnus-tmp-news-server (cadr gnus-select-method))
1325 (gnus-tmp-news-method (car gnus-select-method))
1326 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1328 gnus-tmp-header ;Dummy binding for user-defined formats
1329 ;; Get the resulting string.
1331 (and gnus-dribble-buffer
1332 (buffer-name gnus-dribble-buffer)
1333 (buffer-modified-p gnus-dribble-buffer)
1335 (set-buffer gnus-dribble-buffer)
1336 (not (zerop (buffer-size))))))
1337 (mode-string (eval gformat)))
1338 ;; Say whether the dribble buffer has been modified.
1339 (setq mode-line-modified
1340 (if modified (car gnus-mode-line-modified)
1341 (cdr gnus-mode-line-modified)))
1342 ;; If the line is too long, we chop it off.
1343 (when (> (length mode-string) max-len)
1344 (setq mode-string (substring mode-string 0 (- max-len 4))))
1346 (setq mode-line-buffer-identification
1347 (gnus-mode-line-buffer-identification
1348 (list mode-string)))
1349 (set-buffer-modified-p modified))))))
1351 (defun gnus-group-group-name ()
1352 "Get the name of the newsgroup on the current line."
1353 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1355 (symbol-name group))))
1357 (defun gnus-group-group-level ()
1358 "Get the level of the newsgroup on the current line."
1359 (get-text-property (gnus-point-at-bol) 'gnus-level))
1361 (defun gnus-group-group-indentation ()
1362 "Get the indentation of the newsgroup on the current line."
1363 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1364 (and gnus-group-indentation-function
1365 (funcall gnus-group-indentation-function))
1368 (defun gnus-group-group-unread ()
1369 "Get the number of unread articles of the newsgroup on the current line."
1370 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1372 (defun gnus-group-new-mail (group)
1373 (if (nnmail-new-mail-p (gnus-group-real-name group))
1377 (defun gnus-group-level (group)
1378 "Return the estimated level of GROUP."
1379 (or (gnus-info-level (gnus-get-info group))
1380 (and (member group gnus-zombie-list) gnus-level-zombie)
1383 (defun gnus-group-search-forward (&optional backward all level first-too)
1384 "Find the next newsgroup with unread articles.
1385 If BACKWARD is non-nil, find the previous newsgroup instead.
1386 If ALL is non-nil, just find any newsgroup.
1387 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1389 If FIRST-TOO, the current line is also eligible as a target."
1390 (let ((way (if backward -1 1))
1391 (low gnus-level-killed)
1394 (if (and backward (progn (beginning-of-line)) (bobp))
1403 (get-text-property (point) 'gnus-group)
1407 (get-text-property (point) 'gnus-unread)))
1408 (and (numberp unread) (> unread 0)))
1409 (setq lev (get-text-property (point)
1411 (<= lev gnus-level-subscribed)))
1413 (and (setq lev (get-text-property (point)
1422 (zerop (forward-line way)))))
1424 (progn (gnus-group-position-point) t)
1425 (goto-char (or pos beg))
1428 ;;; Gnus group mode commands
1432 (defun gnus-group-mark-line-p ()
1435 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1436 (eq (char-after) gnus-process-mark)))
1438 (defun gnus-group-mark-group (n &optional unmark no-advance)
1439 "Mark the current group."
1441 (let ((buffer-read-only nil)
1445 (when (setq group (gnus-group-group-name))
1446 ;; Go to the mark position.
1448 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1449 (subst-char-in-region
1450 (point) (1+ (point)) (char-after)
1453 (setq gnus-group-marked (delete group gnus-group-marked))
1455 (setq gnus-group-marked
1456 (cons group (delete group gnus-group-marked)))
1457 gnus-process-mark)))
1459 (gnus-group-next-group 1))
1461 (gnus-summary-position-point)
1464 (defun gnus-group-unmark-group (n)
1465 "Remove the mark from the current group."
1467 (gnus-group-mark-group n 'unmark)
1468 (gnus-group-position-point))
1470 (defun gnus-group-unmark-all-groups ()
1471 "Unmark all groups."
1473 (let ((groups gnus-group-marked))
1476 (gnus-group-remove-mark (pop groups)))))
1477 (gnus-group-position-point))
1479 (defun gnus-group-mark-region (unmark beg end)
1480 "Mark all groups between point and mark.
1481 If UNMARK, remove the mark instead."
1482 (interactive "P\nr")
1483 (let ((num (count-lines beg end)))
1486 (- num (gnus-group-mark-group num unmark)))))
1488 (defun gnus-group-mark-buffer (&optional unmark)
1489 "Mark all groups in the buffer.
1490 If UNMARK, remove the mark instead."
1492 (gnus-group-mark-region unmark (point-min) (point-max)))
1494 (defun gnus-group-mark-regexp (regexp)
1495 "Mark all groups that match some regexp."
1496 (interactive "sMark (regexp): ")
1497 (let ((alist (cdr gnus-newsrc-alist))
1500 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1501 (gnus-group-set-mark group))))
1502 (gnus-group-position-point))
1504 (defun gnus-group-remove-mark (group &optional test-marked)
1505 "Remove the process mark from GROUP and move point there.
1506 Return nil if the group isn't displayed."
1507 (if (gnus-group-goto-group group nil test-marked)
1509 (gnus-group-mark-group 1 'unmark t)
1511 (setq gnus-group-marked
1512 (delete group gnus-group-marked))
1515 (defun gnus-group-set-mark (group)
1516 "Set the process mark on GROUP."
1517 (if (gnus-group-goto-group group)
1519 (gnus-group-mark-group 1 nil t))
1520 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1522 (defun gnus-group-universal-argument (arg &optional groups func)
1523 "Perform any command on all groups according to the process/prefix convention."
1525 (if (eq (setq func (or func
1528 (substitute-command-keys
1529 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1531 (gnus-error 1 "Undefined key")
1532 (gnus-group-iterate arg
1534 (command-execute func))))
1535 (gnus-group-position-point))
1537 (defun gnus-group-process-prefix (n)
1538 "Return a list of groups to work on.
1539 Take into consideration N (the prefix) and the list of marked groups."
1542 (setq n (prefix-numeric-value n))
1543 ;; There is a prefix, so we return a list of the N next
1545 (let ((way (if (< n 0) -1 1))
1550 (if (setq group (gnus-group-group-name))
1551 (push group groups))
1553 (gnus-group-next-group way)))
1555 ((gnus-region-active-p)
1556 ;; Work on the region between point and mark.
1557 (let ((max (max (point) (mark)))
1560 (goto-char (min (point) (mark)))
1563 (push (gnus-group-group-name) groups)
1564 (zerop (gnus-group-next-group 1))
1566 (nreverse groups))))
1568 ;; No prefix, but a list of marked articles.
1569 (reverse gnus-group-marked))
1571 ;; Neither marked articles or a prefix, so we return the
1573 (let ((group (gnus-group-group-name)))
1574 (and group (list group))))))
1576 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1577 ;;; imagine why I went through these contortions...
1579 (let ((function (make-symbol "gnus-group-iterate-function"))
1580 (window (make-symbol "gnus-group-iterate-window"))
1581 (groups (make-symbol "gnus-group-iterate-groups"))
1582 (group (make-symbol "gnus-group-iterate-group")))
1584 `(defun gnus-group-iterate (arg ,function)
1585 "Iterate FUNCTION over all process/prefixed groups.
1586 FUNCTION will be called with the group name as the parameter
1587 and with point over the group in question."
1588 (let ((,groups (gnus-group-process-prefix arg))
1589 (,window (selected-window))
1592 (setq ,group (car ,groups)
1593 ,groups (cdr ,groups))
1594 (select-window ,window)
1595 (gnus-group-remove-mark ,group)
1596 (save-selected-window
1598 (funcall ,function ,group)))))))))
1600 (put 'gnus-group-iterate 'lisp-indent-function 1)
1602 ;; Selecting groups.
1604 (defun gnus-group-read-group (&optional all no-article group select-articles)
1605 "Read news in this newsgroup.
1606 If the prefix argument ALL is non-nil, already read articles become
1607 readable. IF ALL is a number, fetch this number of articles. If the
1608 optional argument NO-ARTICLE is non-nil, no article will be
1609 auto-selected upon group entry. If GROUP is non-nil, fetch that
1612 (let ((no-display (eq all 0))
1613 (group (or group (gnus-group-group-name)))
1614 number active marked entry)
1618 (error "No group on current line"))
1619 (setq marked (gnus-info-marks
1620 (nth 2 (setq entry (gnus-gethash
1621 group gnus-newsrc-hashtb)))))
1622 ;; This group might be a dead group. In that case we have to get
1623 ;; the number of unread articles from `gnus-active-hashtb'.
1625 (cond ((numberp all) all)
1627 ((setq active (gnus-active group))
1628 (- (1+ (cdr active)) (car active)))))
1629 (gnus-summary-read-group
1630 group (or all (and (numberp number)
1631 (zerop (+ number (gnus-range-length
1632 (cdr (assq 'tick marked)))
1634 (cdr (assq 'dormant marked)))))))
1635 no-article nil no-display nil select-articles)))
1637 (defun gnus-group-select-group (&optional all)
1638 "Select this newsgroup.
1639 No article is selected automatically.
1640 If ALL is non-nil, already read articles become readable.
1641 If ALL is a number, fetch this number of articles."
1643 (gnus-group-read-group all t))
1645 (defun gnus-group-quick-select-group (&optional all)
1646 "Select the current group \"quickly\".
1647 This means that no highlighting or scoring will be performed.
1648 If ALL (the prefix argument) is 0, don't even generate the summary
1651 This might be useful if you want to toggle threading
1652 before entering the group."
1654 (require 'gnus-score)
1656 gnus-score-find-score-files-function
1657 gnus-home-score-file
1658 gnus-apply-kill-hook
1659 gnus-summary-expunge-below)
1660 (gnus-group-read-group all t)))
1662 (defun gnus-group-visible-select-group (&optional all)
1663 "Select the current group without hiding any articles."
1665 (let ((gnus-inhibit-limiting t))
1666 (gnus-group-read-group all t)))
1668 (defun gnus-group-select-group-ephemerally ()
1669 "Select the current group without doing any processing whatsoever.
1670 You will actually be entered into a group that's a copy of
1671 the current group; no changes you make while in this group will
1674 (require 'gnus-score)
1676 gnus-score-find-score-files-function gnus-apply-kill-hook
1677 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1678 gnus-summary-mode-hook gnus-select-group-hook
1679 (group (gnus-group-group-name))
1680 (method (gnus-find-method-for-group group)))
1681 (gnus-group-read-ephemeral-group
1682 (gnus-group-prefixed-name group method) method)))
1685 (defun gnus-fetch-group (group)
1686 "Start Gnus if necessary and enter GROUP.
1687 Returns whether the fetching was successful or not."
1688 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1689 (unless (get-buffer gnus-group-buffer)
1691 (gnus-group-read-group nil nil group))
1694 (defun gnus-fetch-group-other-frame (group)
1695 "Pop up a frame and enter GROUP."
1697 (let ((window (get-buffer-window gnus-group-buffer)))
1699 (select-frame (window-frame window)))
1700 ((= (length (frame-list)) 1)
1701 (select-frame (make-frame)))
1704 (gnus-fetch-group group))
1706 (defvar gnus-ephemeral-group-server 0)
1708 ;; Enter a group that is not in the group buffer. Non-nil is returned
1709 ;; if selection was successful.
1710 (defun gnus-group-read-ephemeral-group (group method &optional activate
1711 quit-config request-only
1713 "Read GROUP from METHOD as an ephemeral group.
1714 If ACTIVATE, request the group first.
1715 If QUIT-CONFIG, use that window configuration when exiting from the
1717 If REQUEST-ONLY, don't actually read the group; just request it.
1718 If SELECT-ARTICLES, only select those articles.
1720 Return the name of the group if selection was successful."
1721 ;; Transform the select method into a unique server.
1722 (when (stringp method)
1723 (setq method (gnus-server-to-method method)))
1725 `(,(car method) ,(concat (cadr method) "-ephemeral")
1726 (,(intern (format "%s-address" (car method))) ,(cadr method))
1728 (let ((group (if (gnus-group-foreign-p group) group
1729 (gnus-group-prefixed-name group method))))
1733 ,gnus-level-default-subscribed nil nil ,method
1735 ,(if quit-config quit-config
1736 (cons gnus-summary-buffer
1737 gnus-current-window-configuration))))))
1739 (push method gnus-ephemeral-servers)
1740 (set-buffer gnus-group-buffer)
1741 (unless (gnus-check-server method)
1742 (error "Unable to contact server: %s" (gnus-status-message method)))
1744 (gnus-activate-group group 'scan)
1745 (unless (gnus-request-group group)
1746 (error "Couldn't request group: %s"
1747 (nnheader-get-report (car method)))))
1751 (when (gnus-group-read-group t t group select-articles)
1756 (defun gnus-group-jump-to-group (group)
1757 "Jump to newsgroup GROUP."
1759 (list (completing-read
1760 "Group: " gnus-active-hashtb nil
1761 (gnus-read-active-file-p)
1763 'gnus-group-history)))
1765 (when (equal group "")
1766 (error "Empty group name"))
1768 (unless (gnus-ephemeral-group-p group)
1769 ;; Either go to the line in the group buffer...
1770 (unless (gnus-group-goto-group group)
1771 ;; ... or insert the line.
1772 (gnus-group-update-group group)
1773 (gnus-group-goto-group group)))
1774 ;; Adjust cursor point.
1775 (gnus-group-position-point))
1777 (defun gnus-group-goto-group (group &optional far test-marked)
1778 "Goto to newsgroup GROUP.
1779 If FAR, it is likely that the group is not on the current line.
1780 If TEST-MARKED, the line must be marked."
1784 ;; It's quite likely that we are on the right line, so
1785 ;; we check the current line first.
1787 (eq (get-text-property (point) 'gnus-group)
1788 (gnus-intern-safe group gnus-active-hashtb))
1789 (or (not test-marked) (gnus-group-mark-line-p)))
1791 ;; Previous and next line are also likely, so we check them as well.
1795 (and (eq (get-text-property (point) 'gnus-group)
1796 (gnus-intern-safe group gnus-active-hashtb))
1797 (or (not test-marked) (gnus-group-mark-line-p)))))
1803 (and (eq (get-text-property (point) 'gnus-group)
1804 (gnus-intern-safe group gnus-active-hashtb))
1805 (or (not test-marked) (gnus-group-mark-line-p)))))
1809 (goto-char (point-min))
1811 (while (and (not found)
1816 (gnus-intern-safe group gnus-active-hashtb))))
1817 (if (gnus-group-mark-line-p)
1822 ;; Search through the entire buffer.
1825 (point-min) (point-max)
1826 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1828 (defun gnus-group-next-group (n &optional silent)
1829 "Go to next N'th newsgroup.
1830 If N is negative, search backward instead.
1831 Returns the difference between N and the number of skips actually
1834 (gnus-group-next-unread-group n t nil silent))
1836 (defun gnus-group-next-unread-group (n &optional all level silent)
1837 "Go to next N'th unread newsgroup.
1838 If N is negative, search backward instead.
1839 If ALL is non-nil, choose any newsgroup, unread or not.
1840 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1841 such group can be found, the next group with a level higher than
1843 Returns the difference between N and the number of skips actually
1846 (let ((backward (< n 0))
1849 (gnus-group-search-forward
1850 backward (or (not gnus-group-goto-unread) all) level))
1854 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1855 (if level " on this level or higher" "")))
1858 (defun gnus-group-prev-group (n)
1859 "Go to previous N'th newsgroup.
1860 Returns the difference between N and the number of skips actually
1863 (gnus-group-next-unread-group (- n) t))
1865 (defun gnus-group-prev-unread-group (n)
1866 "Go to previous N'th unread newsgroup.
1867 Returns the difference between N and the number of skips actually
1870 (gnus-group-next-unread-group (- n)))
1872 (defun gnus-group-next-unread-group-same-level (n)
1873 "Go to next N'th unread newsgroup on the same level.
1874 If N is negative, search backward instead.
1875 Returns the difference between N and the number of skips actually
1878 (gnus-group-next-unread-group n t (gnus-group-group-level))
1879 (gnus-group-position-point))
1881 (defun gnus-group-prev-unread-group-same-level (n)
1882 "Go to next N'th unread newsgroup on the same level.
1883 Returns the difference between N and the number of skips actually
1886 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1887 (gnus-group-position-point))
1889 (defun gnus-group-best-unread-group (&optional exclude-group)
1890 "Go to the group with the highest level.
1891 If EXCLUDE-GROUP, do not go to that group."
1893 (goto-char (point-min))
1897 (setq unread (get-text-property (point) 'gnus-unread))
1898 (when (and (numberp unread) (> unread 0))
1899 (when (and (get-text-property (point) 'gnus-level)
1900 (< (get-text-property (point) 'gnus-level) best)
1901 (or (not exclude-group)
1902 (not (equal exclude-group (gnus-group-group-name)))))
1903 (setq best (get-text-property (point) 'gnus-level))
1904 (setq best-point (point))))
1907 (goto-char best-point))
1908 (gnus-summary-position-point)
1909 (and best-point (gnus-group-group-name))))
1911 (defun gnus-group-first-unread-group ()
1912 "Go to the first group with unread articles."
1915 (let ((opoint (point))
1917 (goto-char (point-min))
1918 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1919 (and (numberp unread) ; Not a topic.
1920 (not (zerop unread))) ; Has unread articles.
1921 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1924 nil)) ; Not success.
1925 (gnus-group-position-point)))
1927 (defun gnus-group-enter-server-mode ()
1928 "Jump to the server buffer."
1930 (gnus-enter-server-buffer))
1932 (defun gnus-group-make-group (name &optional method address args)
1933 "Add a new newsgroup.
1934 The user will be prompted for a NAME, for a select METHOD, and an
1938 (gnus-read-group "Group name: ")
1939 (gnus-read-method "From method: ")))
1941 (when (stringp method)
1942 (setq method (or (gnus-server-to-method method) method)))
1943 (let* ((meth (gnus-method-simplify
1945 (not (gnus-server-equal method gnus-select-method)))
1946 (if address (list (intern method) address)
1948 (nname (if method (gnus-group-prefixed-name name meth) name))
1950 (when (gnus-gethash nname gnus-newsrc-hashtb)
1951 (error "Group %s already exists" nname))
1952 ;; Subscribe to the new group.
1953 (gnus-group-change-level
1954 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1955 gnus-level-default-subscribed gnus-level-killed
1956 (and (gnus-group-group-name)
1957 (gnus-gethash (gnus-group-group-name)
1958 gnus-newsrc-hashtb))
1961 (gnus-set-active nname (cons 1 0))
1962 (unless (gnus-ephemeral-group-p name)
1964 (concat "(gnus-group-set-info '"
1965 (gnus-prin1-to-string (cdr info)) ")")))
1967 (gnus-group-insert-group-line-info nname)
1969 (gnus-group-position-point)
1971 ;; Load the backend and try to make the backend create
1972 ;; the group as well.
1973 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1975 gnus-valid-select-methods)
1977 (gnus-check-server meth)
1978 (when (gnus-check-backend-function 'request-create-group nname)
1979 (gnus-request-create-group nname nil args))
1982 (defun gnus-group-delete-groups (&optional arg)
1983 "Delete the current group. Only meaningful with editable groups."
1985 (let ((n (length (gnus-group-process-prefix arg))))
1986 (when (gnus-yes-or-no-p
1988 "Delete this 1 group? "
1989 (format "Delete these %d groups? " n)))
1990 (gnus-group-iterate arg
1992 (gnus-group-delete-group group nil t))))))
1994 (defun gnus-group-delete-group (group &optional force no-prompt)
1995 "Delete the current group. Only meaningful with editable groups.
1996 If FORCE (the prefix) is non-nil, all the articles in the group will
1997 be deleted. This is \"deleted\" as in \"removed forever from the face
1998 of the Earth\". There is no undo. The user will be prompted before
1999 doing the deletion."
2001 (list (gnus-group-group-name)
2002 current-prefix-arg))
2004 (error "No group to rename"))
2005 (unless (gnus-check-backend-function 'request-delete-group group)
2006 (error "This backend does not support group deletion"))
2008 (if (and (not no-prompt)
2009 (not (gnus-yes-or-no-p
2011 "Do you really want to delete %s%s? "
2012 group (if force " and all its contents" "")))))
2014 (gnus-message 6 "Deleting group %s..." group)
2015 (if (not (gnus-request-delete-group group force))
2016 (gnus-error 3 "Couldn't delete group %s" group)
2017 (gnus-message 6 "Deleting group %s...done" group)
2018 (gnus-group-goto-group group)
2019 (gnus-group-kill-group 1 t)
2020 (gnus-sethash group nil gnus-active-hashtb)
2022 (gnus-group-position-point)))
2024 (defun gnus-group-rename-group (group new-name)
2025 "Rename group from GROUP to NEW-NAME.
2026 When used interactively, GROUP is the group under point
2027 and NEW-NAME will be prompted for."
2030 (gnus-group-group-name)
2032 (unless (gnus-check-backend-function
2033 'request-rename-group (gnus-group-group-name))
2034 (error "This backend does not support renaming groups"))
2035 (gnus-read-group "Rename group to: "
2036 (gnus-group-real-name (gnus-group-group-name))))))
2038 (unless (gnus-check-backend-function 'request-rename-group group)
2039 (error "This backend does not support renaming groups"))
2041 (error "No group to rename"))
2042 (when (equal (gnus-group-real-name group) new-name)
2043 (error "Can't rename to the same name"))
2045 ;; We find the proper prefixed name.
2047 (if (gnus-group-native-p group)
2051 (gnus-group-prefixed-name
2052 (gnus-group-real-name new-name)
2053 (gnus-info-method (gnus-get-info group)))))
2055 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2058 (gnus-group-goto-group group)
2059 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2060 (gnus-request-rename-group group new-name))))
2061 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2062 ;; We rename the group internally by killing it...
2063 (gnus-group-kill-group)
2064 ;; ... changing its name ...
2065 (setcar (cdar gnus-list-of-killed-groups) new-name)
2066 ;; ... and then yanking it. Magic!
2067 (gnus-group-yank-group)
2068 (gnus-set-active new-name (gnus-active group))
2069 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2071 (setq gnus-killed-list (delete group gnus-killed-list))
2072 (gnus-set-active group nil)
2073 (gnus-dribble-touch)
2074 (gnus-group-position-point)))
2076 (defun gnus-group-edit-group (group &optional part)
2077 "Edit the group on the current line."
2078 (interactive (list (gnus-group-group-name)))
2079 (let ((part (or part 'info))
2082 (error "No group on current line"))
2083 (unless (setq info (gnus-get-info group))
2084 (error "Killed group; can't be edited"))
2086 (gnus-close-group group))
2088 ;; Find the proper form to edit.
2089 (cond ((eq part 'method)
2090 (or (gnus-info-method info) "native"))
2092 (gnus-info-params info))
2094 ;; The proper documentation.
2096 "Editing the %s for `%s'."
2098 ((eq part 'method) "select method")
2099 ((eq part 'params) "group parameters")
2101 (gnus-group-decoded-name group))
2103 (gnus-group-edit-group-done ',part ,group form)))))
2105 (defun gnus-group-edit-group-method (group)
2106 "Edit the select method of GROUP."
2107 (interactive (list (gnus-group-group-name)))
2108 (gnus-group-edit-group group 'method))
2110 (defun gnus-group-edit-group-parameters (group)
2111 "Edit the group parameters of GROUP."
2112 (interactive (list (gnus-group-group-name)))
2113 (gnus-group-edit-group group 'params))
2115 (defun gnus-group-edit-group-done (part group form)
2117 (let* ((method (cond ((eq part 'info) (nth 4 form))
2118 ((eq part 'method) form)
2120 (info (cond ((eq part 'info) form)
2121 ((eq part 'method) (gnus-get-info group))
2124 (if (or (not method)
2126 gnus-select-method method))
2127 (gnus-group-real-name (car info))
2128 (gnus-group-prefixed-name
2129 (gnus-group-real-name (car info)) method))
2131 (when (and new-group
2132 (not (equal new-group group)))
2133 (when (gnus-group-goto-group group)
2134 (gnus-group-kill-group 1))
2135 (gnus-activate-group new-group))
2137 (if (not (and info new-group))
2138 (gnus-group-set-info form (or new-group group) part)
2139 (setq info (gnus-copy-sequence info))
2140 (setcar info new-group)
2141 (unless (gnus-server-equal method "native")
2142 (unless (nthcdr 3 info)
2143 (nconc info (list nil nil)))
2144 (unless (nthcdr 4 info)
2145 (nconc info (list nil)))
2146 (gnus-info-set-method info method))
2147 (gnus-group-set-info info))
2148 (gnus-group-update-group (or new-group group))
2149 (gnus-group-position-point)))
2151 (defun gnus-group-make-useful-group (group method)
2152 "Create one of the groups described in `gnus-useful-groups'."
2154 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2156 gnus-useful-groups)))
2157 (list (cadr entry) (caddr entry))))
2158 (setq method (gnus-copy-sequence method))
2160 (while (setq entry (memq (assq 'eval method) method))
2161 (setcar entry (eval (cadar entry)))))
2162 (gnus-group-make-group group method))
2164 (defun gnus-group-make-help-group ()
2165 "Create the Gnus documentation group."
2167 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2168 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2169 (when (gnus-gethash name gnus-newsrc-hashtb)
2170 (error "Documentation group already exists"))
2172 (gnus-message 1 "Couldn't find doc group")
2173 (gnus-group-make-group
2174 (gnus-group-real-name name)
2175 (list 'nndoc "gnus-help"
2176 (list 'nndoc-address file)
2177 (list 'nndoc-article-type 'mbox)))))
2178 (gnus-group-position-point))
2180 (defun gnus-group-make-doc-group (file type)
2181 "Create a group that uses a single file as the source."
2183 (list (read-file-name "File name: ")
2184 (and current-prefix-arg 'ask)))
2185 (when (eq type 'ask)
2190 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2192 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2193 ((= char ?b) 'babyl)
2194 ((= char ?d) 'digest)
2195 ((= char ?f) 'forward)
2197 ((= char ?g) 'guess)
2198 (t (setq err (format "%c unknown. " char))
2201 (let* ((file (expand-file-name file))
2202 (name (gnus-generate-new-group-name
2203 (gnus-group-prefixed-name
2204 (file-name-nondirectory file) '(nndoc "")))))
2205 (gnus-group-make-group
2206 (gnus-group-real-name name)
2208 (list 'nndoc-address file)
2209 (list 'nndoc-article-type (or type 'guess))))))
2211 (defvar nnweb-type-definition)
2212 (defvar gnus-group-web-type-history nil)
2213 (defvar gnus-group-web-search-history nil)
2214 (defun gnus-group-make-web-group (&optional solid)
2215 "Create an ephemeral nnweb group.
2216 If SOLID (the prefix), create a solid group."
2220 (if solid (gnus-read-group "Group name: ")
2221 (message-unique-id)))
2222 (default-type (or (car gnus-group-web-type-history)
2223 (symbol-name (caar nnweb-type-definition))))
2227 (format "Search engine type (default %s): " default-type)
2228 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2229 nnweb-type-definition)
2230 nil t nil 'gnus-group-web-type-history)
2235 (cons (or (car gnus-group-web-search-history) "") 0)
2236 'gnus-group-web-search-history))
2238 `(nnweb ,group (nnweb-search ,search)
2239 (nnweb-type ,(intern type))
2240 (nnweb-ephemeral-p t))))
2242 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2243 (gnus-group-read-ephemeral-group
2245 (cons (current-buffer)
2246 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2248 (defvar nnwarchive-type-definition)
2249 (defvar gnus-group-warchive-type-history nil)
2250 (defvar gnus-group-warchive-login-history nil)
2251 (defvar gnus-group-warchive-address-history nil)
2253 (defun gnus-group-make-warchive-group ()
2254 "Create a nnwarchive group."
2256 (require 'nnwarchive)
2257 (let* ((group (gnus-read-group "Group name: "))
2258 (default-type (or (car gnus-group-warchive-type-history)
2259 (symbol-name (caar nnwarchive-type-definition))))
2263 (format "Warchive type (default %s): " default-type)
2264 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2265 nnwarchive-type-definition)
2266 nil t nil 'gnus-group-warchive-type-history)
2268 (address (read-string "Warchive address: "
2269 nil 'gnus-group-warchive-address-history))
2270 (default-login (or (car gnus-group-warchive-login-history)
2275 (format "Warchive login (default %s): " user-mail-address)
2276 default-login 'gnus-group-warchive-login-history)
2279 `(nnwarchive ,address
2280 (nnwarchive-type ,(intern type))
2281 (nnwarchive-login ,login))))
2282 (gnus-group-make-group group method)))
2284 (defvar nnshimbun-type-definition)
2285 (defvar gnus-group-shimbun-server-history nil)
2287 (defun gnus-group-make-shimbun-group ()
2288 "Create a nnshimbun group."
2290 (require 'nnshimbun)
2291 (let* ((minibuffer-setup-hook (append minibuffer-setup-hook
2292 '(beginning-of-line)))
2293 (server (completing-read
2295 (mapcar (lambda (elem) (list (car elem)))
2296 nnshimbun-type-definition)
2298 (or (car gnus-group-shimbun-server-history)
2299 (caar nnshimbun-type-definition))
2300 'gnus-group-shimbun-server-history))
2301 (group (completing-read
2303 (mapcar (lambda (elem) (list elem))
2305 (cdr (assoc server nnshimbun-type-definition)))))
2307 (nnshimbun-pre-fetch-article nil))
2308 (gnus-group-make-group group `(nnshimbun ,server))))
2310 (defun gnus-group-make-archive-group (&optional all)
2311 "Create the (ding) Gnus archive group of the most recent articles.
2312 Given a prefix, create a full group."
2314 (let ((group (gnus-group-prefixed-name
2315 (if all "ding.archives" "ding.recent") '(nndir ""))))
2316 (when (gnus-gethash group gnus-newsrc-hashtb)
2317 (error "Archive group already exists"))
2318 (gnus-group-make-group
2319 (gnus-group-real-name group)
2320 (list 'nndir (if all "hpc" "edu")
2321 (list 'nndir-directory
2322 (if all gnus-group-archive-directory
2323 gnus-group-recent-archive-directory))))
2324 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2326 (defun gnus-group-make-directory-group (dir)
2327 "Create an nndir group.
2328 The user will be prompted for a directory. The contents of this
2329 directory will be used as a newsgroup. The directory should contain
2330 mail messages or news articles in files that have numeric names."
2332 (list (read-file-name "Create group from directory: ")))
2333 (unless (file-exists-p dir)
2334 (error "No such directory"))
2335 (unless (file-directory-p dir)
2336 (error "Not a directory"))
2340 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2342 (gnus-group-prefixed-name
2343 (concat (file-name-as-directory (directory-file-name dir))
2346 (setq ext (format "<%d>" (setq i (1+ i)))))
2347 (gnus-group-make-group
2348 (gnus-group-real-name group)
2349 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2351 (defun gnus-group-make-kiboze-group (group address scores)
2352 "Create an nnkiboze group.
2353 The user will be prompted for a name, a regexp to match groups, and
2354 score file entries for articles to include in the group."
2357 (read-string "nnkiboze group name: ")
2358 (read-string "Source groups (regexp): ")
2359 (let ((headers (mapcar (lambda (group) (list group))
2360 '("subject" "from" "number" "date" "message-id"
2361 "references" "chars" "lines" "xref"
2362 "followup" "all" "body" "head")))
2363 scores header regexp regexps)
2364 (while (not (equal "" (setq header (completing-read
2365 "Match on header: " headers nil t))))
2367 (while (not (equal "" (setq regexp (read-string
2368 (format "Match on %s (regexp): "
2370 (push (list regexp nil nil 'r) regexps))
2371 (push (cons header regexps) scores))
2373 (gnus-group-make-group group "nnkiboze" address)
2374 (let* ((nnkiboze-current-group group)
2375 (score-file (car (nnkiboze-score-file "")))
2376 (score-dir (file-name-directory score-file)))
2377 (unless (file-exists-p score-dir)
2378 (make-directory score-dir))
2379 (with-temp-file score-file
2380 (let (emacs-lisp-mode-hook)
2381 (pp scores (current-buffer))))))
2383 (defun gnus-group-add-to-virtual (n vgroup)
2384 "Add the current group to a virtual group."
2386 (list current-prefix-arg
2387 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2389 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2390 (error "%s is not an nnvirtual group" vgroup))
2391 (gnus-close-group vgroup)
2392 (let* ((groups (gnus-group-process-prefix n))
2393 (method (gnus-info-method (gnus-get-info vgroup))))
2394 (setcar (cdr method)
2396 (nth 1 method) "\\|"
2399 (gnus-group-remove-mark s)
2400 (concat "\\(^" (regexp-quote s) "$\\)"))
2402 (gnus-group-position-point))
2404 (defun gnus-group-make-empty-virtual (group)
2405 "Create a new, fresh, empty virtual group."
2406 (interactive "sCreate new, empty virtual group: ")
2407 (let* ((method (list 'nnvirtual "^$"))
2408 (pgroup (gnus-group-prefixed-name group method)))
2409 ;; Check whether it exists already.
2410 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2411 (error "Group %s already exists" pgroup))
2412 ;; Subscribe the new group after the group on the current line.
2413 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2414 (gnus-group-update-group pgroup)
2416 (gnus-group-position-point)))
2418 (defun gnus-group-enter-directory (dir)
2419 "Enter an ephemeral nneething group."
2420 (interactive "DDirectory to read: ")
2421 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2422 (leaf (gnus-group-prefixed-name
2423 (file-name-nondirectory (directory-file-name dir))
2425 (name (gnus-generate-new-group-name leaf)))
2426 (unless (gnus-group-read-ephemeral-group
2428 (cons (current-buffer)
2429 (if (eq major-mode 'gnus-summary-mode)
2431 (error "Couldn't enter %s" dir))))
2434 (autoload 'nnimap-expunge "nnimap")
2435 (autoload 'nnimap-acl-get "nnimap")
2436 (autoload 'nnimap-acl-edit "nnimap"))
2438 (defun gnus-group-nnimap-expunge (group)
2439 "Expunge deleted articles in current nnimap GROUP."
2440 (interactive (list (gnus-group-group-name)))
2441 (let ((mailbox (gnus-group-real-name group)) method)
2443 (error "No group on current line"))
2444 (unless (gnus-get-info group)
2445 (error "Killed group; can't be edited"))
2446 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2447 (error "%s is not an nnimap group" group))
2448 (nnimap-expunge mailbox (cadr method))))
2450 (defun gnus-group-nnimap-edit-acl (group)
2451 "Edit the Access Control List of current nnimap GROUP."
2452 (interactive (list (gnus-group-group-name)))
2453 (let ((mailbox (gnus-group-real-name group)) method acl)
2455 (error "No group on current line"))
2456 (unless (gnus-get-info group)
2457 (error "Killed group; can't be edited"))
2458 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2459 (error "%s is not an nnimap group" group))
2460 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2461 (error "Server does not support ACL's"))
2462 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2464 An access control list is a list of (identifier . rights) elements.
2466 The identifier string specifies the corresponding user. The
2467 identifier \"anyone\" is reserved to refer to the universal identity.
2469 Rights is a string listing a (possibly empty) set of alphanumeric
2470 characters, each character listing a set of operations which is being
2471 controlled. Letters are reserved for ``standard'' rights, listed
2472 below. Digits are reserved for implementation or site defined rights.
2474 l - lookup (mailbox is visible to LIST/LSUB commands)
2475 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2476 SEARCH, COPY from mailbox)
2477 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2478 w - write (STORE flags other than \\SEEN and \\DELETED)
2479 i - insert (perform APPEND, COPY into mailbox)
2480 p - post (send mail to submission address for mailbox,
2481 not enforced by IMAP4 itself)
2482 c - create and delete mailbox (CREATE new sub-mailboxes in any
2483 implementation-defined hierarchy, RENAME or DELETE mailbox)
2484 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2485 a - administer (perform SETACL)" group)
2488 ,mailbox ',method ',acl form)))))
2490 ;; Group sorting commands
2491 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2493 (defun gnus-group-sort-groups (func &optional reverse)
2494 "Sort the group buffer according to FUNC.
2495 When used interactively, the sorting function used will be
2496 determined by the `gnus-group-sort-function' variable.
2497 If REVERSE (the prefix), reverse the sorting order."
2498 (interactive (list gnus-group-sort-function current-prefix-arg))
2499 (funcall gnus-group-sort-alist-function
2500 (gnus-make-sort-function func) reverse)
2501 (gnus-group-list-groups)
2502 (gnus-dribble-touch))
2504 (defun gnus-group-sort-flat (func reverse)
2505 ;; We peel off the dummy group from the alist.
2507 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2508 (pop gnus-newsrc-alist))
2510 (setq gnus-newsrc-alist
2511 (sort gnus-newsrc-alist func))
2513 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2514 ;; Regenerate the hash table.
2515 (gnus-make-hashtable-from-newsrc-alist)))
2517 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2518 "Sort the group buffer alphabetically by group name.
2519 If REVERSE, sort in reverse order."
2521 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2523 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2524 "Sort the group buffer by number of unread articles.
2525 If REVERSE, sort in reverse order."
2527 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2529 (defun gnus-group-sort-groups-by-level (&optional reverse)
2530 "Sort the group buffer by group level.
2531 If REVERSE, sort in reverse order."
2533 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2535 (defun gnus-group-sort-groups-by-score (&optional reverse)
2536 "Sort the group buffer by group score.
2537 If REVERSE, sort in reverse order."
2539 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2541 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2542 "Sort the group buffer by group rank.
2543 If REVERSE, sort in reverse order."
2545 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2547 (defun gnus-group-sort-groups-by-method (&optional reverse)
2548 "Sort the group buffer alphabetically by backend name.
2549 If REVERSE, sort in reverse order."
2551 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2553 ;;; Selected group sorting.
2555 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2556 "Sort the process/prefixed groups."
2557 (interactive (list current-prefix-arg gnus-group-sort-function))
2558 (let ((groups (gnus-group-process-prefix n)))
2559 (funcall gnus-group-sort-selected-function
2560 groups (gnus-make-sort-function func) reverse)
2561 (gnus-group-list-groups)))
2563 (defun gnus-group-sort-selected-flat (groups func reverse)
2564 (let (entries infos)
2565 ;; First find all the group entries for these groups.
2567 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2569 ;; Then sort the infos.
2573 (lambda (entry) (car entry))
2574 (setq entries (nreverse entries)))
2577 (setq infos (nreverse infos)))
2578 ;; Go through all the infos and replace the old entries
2579 ;; with the new infos.
2581 (setcar (car entries) (pop infos))
2583 ;; Update the hashtable.
2584 (gnus-make-hashtable-from-newsrc-alist)))
2586 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2587 "Sort the group buffer alphabetically by group name.
2588 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2589 sort in reverse order."
2590 (interactive (gnus-interactive "P\ny"))
2591 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2593 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2594 "Sort the group buffer by number of unread articles.
2595 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2596 sort in reverse order."
2597 (interactive (gnus-interactive "P\ny"))
2598 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2600 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2601 "Sort the group buffer by group level.
2602 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2603 sort in reverse order."
2604 (interactive (gnus-interactive "P\ny"))
2605 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2607 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2608 "Sort the group buffer by group score.
2609 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2610 sort in reverse order."
2611 (interactive (gnus-interactive "P\ny"))
2612 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2614 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2615 "Sort the group buffer by group rank.
2616 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2617 sort in reverse order."
2618 (interactive (gnus-interactive "P\ny"))
2619 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2621 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2622 "Sort the group buffer alphabetically by backend name.
2623 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2624 sort in reverse order."
2625 (interactive (gnus-interactive "P\ny"))
2626 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2628 ;;; Sorting predicates.
2630 (defun gnus-group-sort-by-alphabet (info1 info2)
2631 "Sort alphabetically."
2632 (string< (gnus-info-group info1) (gnus-info-group info2)))
2634 (defun gnus-group-sort-by-real-name (info1 info2)
2635 "Sort alphabetically on real (unprefixed) names."
2636 (string< (gnus-group-real-name (gnus-info-group info1))
2637 (gnus-group-real-name (gnus-info-group info2))))
2639 (defun gnus-group-sort-by-unread (info1 info2)
2640 "Sort by number of unread articles."
2641 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2642 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2643 (< (or (and (numberp n1) n1) 0)
2644 (or (and (numberp n2) n2) 0))))
2646 (defun gnus-group-sort-by-level (info1 info2)
2648 (< (gnus-info-level info1) (gnus-info-level info2)))
2650 (defun gnus-group-sort-by-method (info1 info2)
2651 "Sort alphabetically by backend name."
2652 (string< (symbol-name (car (gnus-find-method-for-group
2653 (gnus-info-group info1) info1)))
2654 (symbol-name (car (gnus-find-method-for-group
2655 (gnus-info-group info2) info2)))))
2657 (defun gnus-group-sort-by-score (info1 info2)
2658 "Sort by group score."
2659 (< (gnus-info-score info1) (gnus-info-score info2)))
2661 (defun gnus-group-sort-by-rank (info1 info2)
2662 "Sort by level and score."
2663 (let ((level1 (gnus-info-level info1))
2664 (level2 (gnus-info-level info2)))
2665 (or (< level1 level2)
2666 (and (= level1 level2)
2667 (> (gnus-info-score info1) (gnus-info-score info2))))))
2671 (defun gnus-group-clear-data (&optional arg)
2672 "Clear all marks and read ranges from the current group."
2674 (gnus-group-iterate arg
2677 (gnus-info-clear-data (setq info (gnus-get-info group)))
2678 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2679 (when (gnus-group-goto-group group)
2680 (gnus-group-update-group-line))))))
2682 (defun gnus-group-clear-data-on-native-groups ()
2683 "Clear all marks and read ranges from all native groups."
2685 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2686 (let ((alist (cdr gnus-newsrc-alist))
2688 (while (setq info (pop alist))
2689 (when (gnus-group-native-p (gnus-info-group info))
2690 (gnus-info-clear-data info)))
2691 (gnus-get-unread-articles)
2692 (gnus-dribble-touch)
2693 (when (gnus-y-or-n-p
2694 "Move the cache away to avoid problems in the future? ")
2695 (call-interactively 'gnus-cache-move-cache)))))
2697 (defun gnus-info-clear-data (info)
2698 "Clear all marks and read ranges from INFO."
2699 (let ((group (gnus-info-group info)))
2702 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2703 (gnus-info-set-read ',info ',(gnus-info-read info))
2704 (when (gnus-group-goto-group ,group)
2705 (gnus-group-update-group-line))))
2706 (gnus-info-set-read info nil)
2707 (when (gnus-info-marks info)
2708 (gnus-info-set-marks info nil))))
2710 ;; Group catching up.
2712 (defun gnus-group-catchup-current (&optional n all)
2713 "Mark all unread articles in the current newsgroup as read.
2714 If prefix argument N is numeric, the next N newsgroups will be
2715 caught up. If ALL is non-nil, marked articles will also be marked as
2716 read. Cross references (Xref: header) of articles are ignored.
2717 The number of newsgroups that this function was unable to catch
2720 (let ((groups (gnus-group-process-prefix n))
2723 (unless groups (error "No groups selected"))
2725 (or (not gnus-interactive-catchup) ;Without confirmation?
2730 "Do you really want to mark all articles in %s as read? "
2731 "Mark all unread articles in %s as read? ")
2732 (if (= (length groups) 1)
2734 (format "these %d groups" (length groups)))))))
2736 (while (setq group (pop groups))
2737 (gnus-group-remove-mark group)
2738 ;; Virtual groups have to be given special treatment.
2739 (let ((method (gnus-find-method-for-group group)))
2740 (when (eq 'nnvirtual (car method))
2741 (nnvirtual-catchup-group
2742 (gnus-group-real-name group) (nth 1 method) all)))
2743 (if (>= (gnus-group-level group) gnus-level-zombie)
2744 (gnus-message 2 "Dead groups can't be caught up")
2746 (gnus-group-goto-group group)
2747 (gnus-group-catchup group all))
2748 (gnus-group-update-group-line)
2749 (setq ret (1+ ret)))))
2750 (gnus-group-next-unread-group 1)
2753 (defun gnus-group-catchup-current-all (&optional n)
2754 "Mark all articles in current newsgroup as read.
2755 Cross references (Xref: header) of articles are ignored."
2757 (gnus-group-catchup-current n 'all))
2759 (defun gnus-group-catchup (group &optional all)
2760 "Mark all articles in GROUP as read.
2761 If ALL is non-nil, all articles are marked as read.
2762 The return value is the number of articles that were marked as read,
2763 or nil if no action could be taken."
2764 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2766 ;; Remove entries for this group.
2767 (nnmail-purge-split-history (gnus-group-real-name group))
2768 ;; Do the updating only if the newsgroup isn't killed.
2769 (if (not (numberp (car entry)))
2770 (gnus-message 1 "Can't catch up %s; non-active group" group)
2771 ;; Do auto-expirable marks if that's required.
2772 (when (gnus-group-auto-expirable-p group)
2773 (gnus-add-marked-articles
2774 group 'expire (gnus-list-of-unread-articles group))
2776 (let ((marks (nth 3 (nth 2 entry))))
2777 (gnus-add-marked-articles
2778 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2779 (gnus-add-marked-articles
2780 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2782 (gnus-update-read-articles group nil)
2783 ;; Also nix out the lists of marks and dormants.
2785 (gnus-add-marked-articles group 'tick nil nil 'force)
2786 (gnus-add-marked-articles group 'dormant nil nil 'force))
2787 (let ((gnus-newsgroup-name group))
2788 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2791 (defun gnus-group-expire-articles (&optional n)
2792 "Expire all expirable articles in the current newsgroup."
2794 (let ((groups (gnus-group-process-prefix n))
2797 (error "No groups to expire"))
2798 (while (setq group (pop groups))
2799 (gnus-group-remove-mark group)
2800 (gnus-group-expire-articles-1 group)
2801 (gnus-dribble-touch)
2802 (gnus-group-position-point))))
2804 (defun gnus-group-expire-articles-1 (group)
2805 (when (gnus-check-backend-function 'request-expire-articles group)
2806 (gnus-message 6 "Expiring articles in %s..." group)
2807 (let* ((info (gnus-get-info group))
2808 (expirable (if (gnus-group-total-expirable-p group)
2809 (cons nil (gnus-list-of-read-articles group))
2810 (assq 'expire (gnus-info-marks info))))
2811 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2812 (nnmail-expiry-target
2813 (or (gnus-group-find-parameter group 'expiry-target)
2814 nnmail-expiry-target)))
2816 (gnus-check-group group)
2819 (gnus-compress-sequence
2821 ;; We set the expiry variables to the group
2823 (let ((nnmail-expiry-wait-function nil)
2824 (nnmail-expiry-wait expiry-wait))
2825 (gnus-request-expire-articles
2826 (gnus-uncompress-sequence (cdr expirable)) group))
2827 ;; Just expire using the normal expiry values.
2828 (gnus-request-expire-articles
2829 (gnus-uncompress-sequence (cdr expirable)) group))))
2830 (gnus-close-group group))
2831 (gnus-message 6 "Expiring articles in %s...done" group)
2832 ;; Return the list of un-expired articles.
2835 (defun gnus-group-expire-all-groups ()
2836 "Expire all expirable articles in all newsgroups."
2839 (gnus-message 5 "Expiring...")
2840 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2841 (cdr gnus-newsrc-alist))))
2842 (gnus-group-expire-articles nil)))
2843 (gnus-group-position-point)
2844 (gnus-message 5 "Expiring...done"))
2846 (defun gnus-group-set-current-level (n level)
2847 "Set the level of the next N groups to LEVEL."
2852 (let ((s (read-string
2853 (format "Level (default %s): "
2854 (or (gnus-group-group-level)
2855 gnus-level-default-subscribed)))))
2856 (if (string-match "^\\s-*$" s)
2857 (int-to-string (or (gnus-group-group-level)
2858 gnus-level-default-subscribed))
2860 (unless (and (>= level 1) (<= level gnus-level-killed))
2861 (error "Invalid level: %d" level))
2862 (let ((groups (gnus-group-process-prefix n))
2864 (while (setq group (pop groups))
2865 (gnus-group-remove-mark group)
2866 (gnus-message 6 "Changed level of %s from %d to %d"
2867 group (or (gnus-group-group-level) gnus-level-killed)
2869 (gnus-group-change-level
2870 group level (or (gnus-group-group-level) gnus-level-killed))
2871 (gnus-group-update-group-line)))
2872 (gnus-group-position-point))
2874 (defun gnus-group-unsubscribe (&optional n)
2875 "Unsubscribe the current group."
2877 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2879 (defun gnus-group-subscribe (&optional n)
2880 "Subscribe the current group."
2882 (gnus-group-unsubscribe-current-group n 'subscribe))
2884 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2885 "Toggle subscription of the current group.
2886 If given numerical prefix, toggle the N next groups."
2888 (let ((groups (gnus-group-process-prefix n))
2891 (setq group (car groups)
2892 groups (cdr groups))
2893 (gnus-group-remove-mark group)
2894 (gnus-group-unsubscribe-group
2897 ((eq do-sub 'unsubscribe)
2898 gnus-level-default-unsubscribed)
2899 ((eq do-sub 'subscribe)
2900 gnus-level-default-subscribed)
2901 ((<= (gnus-group-group-level) gnus-level-subscribed)
2902 gnus-level-default-unsubscribed)
2904 gnus-level-default-subscribed))
2906 (gnus-group-update-group-line))
2907 (gnus-group-next-group 1)))
2909 (defun gnus-group-unsubscribe-group (group &optional level silent)
2910 "Toggle subscription to GROUP.
2911 Killed newsgroups are subscribed. If SILENT, don't try to update the
2914 (list (completing-read
2915 "Group: " gnus-active-hashtb nil
2916 (gnus-read-active-file-p)
2918 'gnus-group-history)))
2919 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2921 ((string-match "^[ \t]*$" group)
2922 (error "Empty group name"))
2924 ;; Toggle subscription flag.
2925 (gnus-group-change-level
2926 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2927 gnus-level-subscribed)
2928 (1+ gnus-level-subscribed)
2929 gnus-level-default-subscribed)))
2931 (gnus-group-update-group group)))
2932 ((and (stringp group)
2933 (or (not (gnus-read-active-file-p))
2934 (gnus-active group)))
2935 ;; Add new newsgroup.
2936 (gnus-group-change-level
2938 (if level level gnus-level-default-subscribed)
2939 (or (and (member group gnus-zombie-list)
2942 (when (gnus-group-group-name)
2943 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2945 (gnus-group-update-group group)))
2946 (t (error "No such newsgroup: %s" group)))
2947 (gnus-group-position-point)))
2949 (defun gnus-group-transpose-groups (n)
2950 "Move the current newsgroup up N places.
2951 If given a negative prefix, move down instead. The difference between
2952 N and the number of steps taken is returned."
2954 (unless (gnus-group-group-name)
2955 (error "No group on current line"))
2956 (gnus-group-kill-group 1)
2958 (forward-line (- n))
2959 (gnus-group-yank-group)
2960 (gnus-group-position-point)))
2962 (defun gnus-group-kill-all-zombies (&optional dummy)
2963 "Kill all zombie newsgroups.
2964 The optional DUMMY should always be nil."
2965 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2967 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2968 (setq gnus-zombie-list nil)
2969 (gnus-dribble-touch)
2970 (gnus-group-list-groups)))
2972 (defun gnus-group-kill-region (begin end)
2973 "Kill newsgroups in current region (excluding current point).
2974 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2989 (beginning-of-line) ;Important when LINES < 1
2990 (gnus-group-kill-group lines)))
2992 (defun gnus-group-kill-group (&optional n discard)
2993 "Kill the next N groups.
2994 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2995 However, only groups that were alive can be yanked; already killed
2996 groups or zombie groups can't be yanked.
2997 The return value is the name of the group that was killed, or a list
3000 (let ((buffer-read-only nil)
3001 (groups (gnus-group-process-prefix n))
3002 group entry level out)
3003 (if (< (length groups) 10)
3004 ;; This is faster when there are few groups.
3006 (push (setq group (pop groups)) out)
3007 (gnus-group-remove-mark group)
3008 (setq level (gnus-group-group-level))
3010 (when (and (not discard)
3011 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3014 (gnus-group-goto-group ,(gnus-group-group-name))
3015 (gnus-group-yank-group)))
3016 (push (cons (car entry) (nth 2 entry))
3017 gnus-list-of-killed-groups))
3018 (gnus-group-change-level
3019 (if entry entry group) gnus-level-killed (if entry nil level))
3020 (message "Killed group %s" group))
3021 ;; If there are lots and lots of groups to be killed, we use
3022 ;; this thing instead.
3024 (setq groups (nreverse groups))
3026 (gnus-group-remove-mark (setq group (pop groups)))
3028 (push group gnus-killed-list)
3029 (setq gnus-newsrc-alist
3030 (delq (assoc group gnus-newsrc-alist)
3032 (when gnus-group-change-level-function
3033 (funcall gnus-group-change-level-function
3034 group gnus-level-killed 3))
3036 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3037 (push (cons (car entry) (nth 2 entry))
3038 gnus-list-of-killed-groups)
3039 (setcdr (cdr entry) (cdddr entry)))
3040 ((member group gnus-zombie-list)
3041 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3042 ;; There may be more than one instance displayed.
3043 (while (gnus-group-goto-group group)
3044 (gnus-delete-line)))
3045 (gnus-make-hashtable-from-newsrc-alist)))
3047 (gnus-group-position-point)
3048 (if (< (length out) 2) (car out) (nreverse out))))
3050 (defun gnus-group-yank-group (&optional arg)
3051 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3052 The numeric ARG specifies how many newsgroups are to be yanked. The
3053 name of the newsgroup yanked is returned, or (if several groups are
3054 yanked) a list of yanked groups is returned."
3056 (setq arg (or arg 1))
3057 (let (info group prev out)
3058 (while (>= (decf arg) 0)
3059 (when (not (setq info (pop gnus-list-of-killed-groups)))
3060 (error "No more newsgroups to yank"))
3061 (push (setq group (nth 1 info)) out)
3062 ;; Find which newsgroup to insert this one before - search
3063 ;; backward until something suitable is found. If there are no
3064 ;; other newsgroups in this buffer, just make this newsgroup the
3066 (setq prev (gnus-group-group-name))
3067 (gnus-group-change-level
3068 info (gnus-info-level (cdr info)) gnus-level-killed
3069 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3071 (gnus-group-insert-group-line-info group)
3073 `(when (gnus-group-goto-group ,group)
3074 (gnus-group-kill-group 1))))
3076 (gnus-group-position-point)
3077 (if (< (length out) 2) (car out) (nreverse out))))
3079 (defun gnus-group-kill-level (level)
3080 "Kill all groups that is on a certain LEVEL."
3081 (interactive "nKill all groups on level: ")
3083 ((= level gnus-level-zombie)
3084 (setq gnus-killed-list
3085 (nconc gnus-zombie-list gnus-killed-list))
3086 (setq gnus-zombie-list nil))
3087 ((and (< level gnus-level-zombie)
3089 (or gnus-expert-user
3092 "Do you really want to kill all groups on level %d? "
3094 (let* ((prev gnus-newsrc-alist)
3097 (if (= (gnus-info-level (car alist)) level)
3099 (push (gnus-info-group (car alist)) gnus-killed-list)
3100 (setcdr prev (cdr alist)))
3102 (setq alist (cdr alist)))
3103 (gnus-make-hashtable-from-newsrc-alist)
3104 (gnus-group-list-groups)))
3106 (error "Can't kill; invalid level: %d" level))))
3108 (defun gnus-group-list-all-groups (&optional arg)
3109 "List all newsgroups with level ARG or lower.
3110 Default is gnus-level-unsubscribed, which lists all subscribed and most
3111 unsubscribed groups."
3113 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3115 ;; Redefine this to list ALL killed groups if prefix arg used.
3116 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3117 (defun gnus-group-list-killed (&optional arg)
3118 "List all killed newsgroups in the group buffer.
3119 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3120 entail asking the server for the groups."
3122 ;; Find all possible killed newsgroups if arg.
3124 (gnus-get-killed-groups))
3125 (if (not gnus-killed-list)
3126 (gnus-message 6 "No killed groups")
3127 (let (gnus-group-list-mode)
3128 (funcall gnus-group-prepare-function
3129 gnus-level-killed t gnus-level-killed))
3130 (goto-char (point-min)))
3131 (gnus-group-position-point))
3133 (defun gnus-group-list-zombies ()
3134 "List all zombie newsgroups in the group buffer."
3136 (if (not gnus-zombie-list)
3137 (gnus-message 6 "No zombie groups")
3138 (let (gnus-group-list-mode)
3139 (funcall gnus-group-prepare-function
3140 gnus-level-zombie t gnus-level-zombie))
3141 (goto-char (point-min)))
3142 (gnus-group-position-point))
3144 (defun gnus-group-list-active ()
3145 "List all groups that are available from the server(s)."
3147 ;; First we make sure that we have really read the active file.
3148 (unless (gnus-read-active-file-p)
3149 (let ((gnus-read-active-file t)
3150 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3151 (gnus-read-active-file)))
3152 ;; Find all groups and sort them.
3160 (push (symbol-name sym) list)))
3164 (buffer-read-only nil)
3168 (setq group (pop groups))
3169 (gnus-add-text-properties
3170 (point) (prog1 (1+ (point))
3172 (gnus-group-name-decode group
3173 (gnus-group-name-charset
3176 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3178 'gnus-level (inline (gnus-group-level group)))))
3179 (goto-char (point-min))))
3181 (defun gnus-activate-all-groups (level)
3182 "Activate absolutely all groups."
3183 (interactive (list gnus-level-unsubscribed))
3184 (let ((gnus-activate-level level)
3185 (gnus-activate-foreign-newsgroups level))
3186 (gnus-group-get-new-news)))
3188 (defun gnus-group-get-new-news (&optional arg)
3189 "Get newly arrived articles.
3190 If ARG is a number, it specifies which levels you are interested in
3191 re-scanning. If ARG is non-nil and not a number, this will force
3192 \"hard\" re-reading of the active files from all servers."
3195 (let ((gnus-inhibit-demon t)
3196 ;; Binding this variable will inhibit multiple fetchings
3197 ;; of the same mail source.
3198 (nnmail-fetched-sources (list t)))
3199 (gnus-run-hooks 'gnus-get-new-news-hook)
3201 ;; Read any slave files.
3203 (gnus-master-read-slave-newsrc))
3205 ;; We might read in new NoCeM messages here.
3206 (when (and gnus-use-nocem
3208 (gnus-nocem-scan-groups))
3209 ;; If ARG is not a number, then we read the active file.
3210 (when (and arg (not (numberp arg)))
3211 (let ((gnus-read-active-file t))
3212 (gnus-read-active-file))
3215 ;; If the user wants it, we scan for new groups.
3216 (when (eq gnus-check-new-newsgroups 'always)
3217 (gnus-find-new-newsgroups)))
3219 (setq arg (gnus-group-default-level arg t))
3220 (if (and gnus-read-active-file (not arg))
3222 (gnus-read-active-file)
3223 (gnus-get-unread-articles arg))
3224 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3225 (gnus-get-unread-articles arg)))
3226 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3227 (gnus-group-list-groups (and (numberp arg)
3228 (max (car gnus-group-list-mode) arg)))))
3230 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3231 "Check for newly arrived news in the current group (and the N-1 next groups).
3232 The difference between N and the number of newsgroup checked is returned.
3233 If N is negative, this group and the N-1 previous groups will be checked."
3235 (let* ((groups (gnus-group-process-prefix n))
3236 (ret (if (numberp n) (- n (length groups)) 0))
3240 (gnus-inhibit-demon t)
3241 ;; Binding this variable will inhibit multiple fetchings
3242 ;; of the same mail source.
3243 (nnmail-fetched-sources (list t)))
3244 (gnus-run-hooks 'gnus-get-new-news-hook)
3245 (while (setq group (pop groups))
3246 (gnus-group-remove-mark group)
3247 ;; Bypass any previous denials from the server.
3248 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3249 (if (gnus-activate-group group (if dont-scan nil 'scan))
3251 (gnus-get-unread-articles-in-group
3252 (gnus-get-info group) (gnus-active group) t)
3253 (unless (gnus-virtual-group-p group)
3254 (gnus-close-group group))
3256 (gnus-agent-save-group-info
3257 method (gnus-group-real-name group) (gnus-active group)))
3258 (gnus-group-update-group group))
3259 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3261 (gnus-error 3 "Server denied access")
3262 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3265 (when gnus-goto-next-group-when-activating
3266 (gnus-group-next-unread-group 1 t))
3267 (gnus-summary-position-point)
3270 (defun gnus-group-fetch-faq (group &optional faq-dir)
3271 "Fetch the FAQ for the current group.
3272 If given a prefix argument, prompt for the FAQ dir
3276 (gnus-group-group-name)
3277 (when current-prefix-arg
3279 "Faq dir: " (and (listp gnus-group-faq-directory)
3280 (mapcar (lambda (file) (list file))
3281 gnus-group-faq-directory))))))
3283 (error "No group name given"))
3284 (let ((dirs (or faq-dir gnus-group-faq-directory))
3286 (unless (listp dirs)
3287 (setq dirs (list dirs)))
3288 (while (and (not found)
3289 (setq dir (pop dirs)))
3290 (let ((name (gnus-group-real-name group)))
3291 (setq file (concat (file-name-as-directory dir) name)))
3292 (if (not (file-exists-p file))
3293 (gnus-message 1 "No such file: %s" file)
3294 (let ((enable-local-variables nil))
3298 (defun gnus-group-describe-group (force &optional group)
3299 "Display a description of the current newsgroup."
3300 (interactive (list current-prefix-arg (gnus-group-group-name)))
3301 (let* ((method (gnus-find-method-for-group group))
3302 (mname (gnus-group-prefixed-name "" method))
3305 gnus-description-hashtb)
3306 (gnus-sethash mname nil gnus-description-hashtb))
3308 (error "No group name given"))
3309 (when (or (and gnus-description-hashtb
3310 ;; We check whether this group's method has been
3311 ;; queried for a description file.
3312 (gnus-gethash mname gnus-description-hashtb))
3313 (setq desc (gnus-group-get-description group))
3314 (gnus-read-descriptions-file method))
3316 (or desc (gnus-gethash group gnus-description-hashtb)
3317 "No description available")))))
3319 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3320 (defun gnus-group-describe-all-groups (&optional force)
3321 "Pop up a buffer with descriptions of all newsgroups."
3324 (setq gnus-description-hashtb nil))
3325 (when (not (or gnus-description-hashtb
3326 (gnus-read-all-descriptions-files)))
3327 (error "Couldn't request descriptions file"))
3328 (let ((buffer-read-only nil)
3334 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3335 (insert (format " *: %-20s %s\n"
3336 (gnus-group-name-decode
3337 (symbol-name group) charset)
3338 (gnus-group-name-decode
3339 (symbol-value group) charset))))
3340 (gnus-add-text-properties
3341 b (1+ b) (list 'gnus-group group
3342 'gnus-unread t 'gnus-marked nil
3343 'gnus-level (1+ gnus-level-subscribed))))
3344 gnus-description-hashtb)
3345 (goto-char (point-min))
3346 (gnus-group-position-point)))
3348 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3349 (defun gnus-group-apropos (regexp &optional search-description)
3350 "List all newsgroups that have names that match a regexp."
3351 (interactive "sGnus apropos (regexp): ")
3353 (obuf (current-buffer))
3355 ;; Go through all newsgroups that are known to Gnus.
3358 (and (symbol-name group)
3359 (string-match regexp (symbol-name group))
3360 (symbol-value group)
3361 (push (symbol-name group) groups)))
3363 ;; Also go through all descriptions that are known to Gnus.
3364 (when search-description
3367 (and (string-match regexp (symbol-value group))
3368 (push (symbol-name group) groups)))
3369 gnus-description-hashtb))
3371 (gnus-message 3 "No groups matched \"%s\"." regexp)
3372 ;; Print out all the groups.
3374 (pop-to-buffer "*Gnus Help*")
3375 (buffer-disable-undo)
3377 (setq groups (sort groups 'string<))
3379 ;; Groups may be entered twice into the list of groups.
3380 (when (not (string= (car groups) prev))
3381 (setq prev (car groups))
3382 (let ((charset (gnus-group-name-charset nil prev)))
3383 (insert (gnus-group-name-decode prev charset) "\n")
3384 (when (and gnus-description-hashtb
3385 (setq des (gnus-gethash (car groups)
3386 gnus-description-hashtb)))
3387 (insert " " (gnus-group-name-decode des charset) "\n"))))
3388 (setq groups (cdr groups)))
3389 (goto-char (point-min))))
3390 (pop-to-buffer obuf)))
3392 (defun gnus-group-description-apropos (regexp)
3393 "List all newsgroups that have names or descriptions that match a regexp."
3394 (interactive "sGnus description apropos (regexp): ")
3395 (when (not (or gnus-description-hashtb
3396 (gnus-read-all-descriptions-files)))
3397 (error "Couldn't request descriptions file"))
3398 (gnus-group-apropos regexp t))
3400 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3401 (defun gnus-group-list-matching (level regexp &optional all lowest)
3402 "List all groups with unread articles that match REGEXP.
3403 If the prefix LEVEL is non-nil, it should be a number that says which
3404 level to cut off listing groups.
3405 If ALL, also list groups with no unread articles.
3406 If LOWEST, don't list groups with level lower than LOWEST.
3408 This command may read the active file."
3409 (interactive "P\nsList newsgroups matching: ")
3410 ;; First make sure active file has been read.
3412 (> (prefix-numeric-value level) gnus-level-killed))
3413 (gnus-get-killed-groups))
3414 (gnus-group-prepare-flat
3415 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3416 (goto-char (point-min))
3417 (gnus-group-position-point))
3419 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3420 "List all groups that match REGEXP.
3421 If the prefix LEVEL is non-nil, it should be a number that says which
3422 level to cut off listing groups.
3423 If LOWEST, don't list groups with level lower than LOWEST."
3424 (interactive "P\nsList newsgroups matching: ")
3426 (setq level (prefix-numeric-value level)))
3427 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3429 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3430 (defun gnus-group-save-newsrc (&optional force)
3431 "Save the Gnus startup files.
3432 If FORCE, force saving whether it is necessary or not."
3434 (gnus-save-newsrc-file force))
3436 (defun gnus-group-restart (&optional arg)
3437 "Force Gnus to read the .newsrc file."
3439 (when (gnus-yes-or-no-p
3440 (format "Are you sure you want to restart Gnus? "))
3441 (gnus-save-newsrc-file)
3445 (defun gnus-group-read-init-file ()
3446 "Read the Gnus elisp init file."
3448 (gnus-read-init-file)
3449 (gnus-message 5 "Read %s" gnus-init-file))
3451 (defun gnus-group-check-bogus-groups (&optional silent)
3452 "Check bogus newsgroups.
3453 If given a prefix, don't ask for confirmation before removing a bogus
3456 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3457 (gnus-group-list-groups))
3459 (defun gnus-group-find-new-groups (&optional arg)
3460 "Search for new groups and add them.
3461 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3462 With 1 C-u, use the `ask-server' method to query the server for new
3464 With 2 C-u's, use most complete method possible to query the server
3465 for new groups, and subscribe the new groups as zombies."
3467 (gnus-find-new-newsgroups (or arg 1))
3468 (gnus-group-list-groups))
3470 (defun gnus-group-edit-global-kill (&optional article group)
3471 "Edit the global kill file.
3472 If GROUP, edit that local kill file instead."
3474 (setq gnus-current-kill-article article)
3475 (gnus-kill-file-edit-file group)
3478 (substitute-command-keys
3479 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3480 (if group "local" "global")))))
3482 (defun gnus-group-edit-local-kill (article group)
3483 "Edit a local kill file."
3484 (interactive (list nil (gnus-group-group-name)))
3485 (gnus-group-edit-global-kill article group))
3487 (defun gnus-group-force-update ()
3488 "Update `.newsrc' file."
3490 (gnus-save-newsrc-file))
3492 (defun gnus-group-suspend ()
3493 "Suspend the current Gnus session.
3494 In fact, cleanup buffers except for group mode buffer.
3495 The hook gnus-suspend-gnus-hook is called before actually suspending."
3497 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3498 ;; Kill Gnus buffers except for group mode buffer.
3499 (let ((group-buf (get-buffer gnus-group-buffer)))
3500 (mapcar (lambda (buf)
3501 (unless (member buf (list group-buf gnus-dribble-buffer))
3504 (gnus-kill-gnus-frames)
3506 (bury-buffer group-buf)
3507 (delete-windows-on group-buf t))))
3509 (defun gnus-group-clear-dribble ()
3510 "Clear all information from the dribble buffer."
3512 (gnus-dribble-clear)
3513 (gnus-message 7 "Cleared dribble buffer"))
3515 (defun gnus-group-exit ()
3516 "Quit reading news after updating .newsrc.eld and .newsrc.
3517 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3520 (or noninteractive ;For gnus-batch-kill
3521 (not gnus-interactive-exit) ;Without confirmation
3523 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3524 (gnus-run-hooks 'gnus-exit-gnus-hook)
3525 ;; Offer to save data from non-quitted summary buffers.
3526 (gnus-offer-save-summaries)
3527 ;; Save the newsrc file(s).
3528 (gnus-save-newsrc-file)
3530 (gnus-close-backends)
3531 ;; Reset everything.
3533 ;; Allow the user to do things after cleaning up.
3534 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3536 (defun gnus-group-quit ()
3537 "Quit reading news without updating .newsrc.eld or .newsrc.
3538 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3540 (when (or noninteractive ;For gnus-batch-kill
3541 (zerop (buffer-size))
3542 (not (gnus-server-opened gnus-select-method))
3544 (not gnus-current-startup-file)
3546 (format "Quit reading news without saving %s? "
3547 (file-name-nondirectory gnus-current-startup-file))))
3548 (gnus-run-hooks 'gnus-exit-gnus-hook)
3549 (gnus-configure-windows 'group t)
3551 (gnus-close-backends)
3553 (gnus-kill-buffer gnus-group-buffer)
3554 ;; Allow the user to do things after cleaning up.
3555 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3557 (defun gnus-group-describe-briefly ()
3558 "Give a one line description of the group mode commands."
3560 (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")))
3562 (defun gnus-group-browse-foreign-server (method)
3563 "Browse a foreign news server.
3564 If called interactively, this function will ask for a select method
3565 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3566 If not, METHOD should be a list where the first element is the method
3567 and the second element is the address."
3569 (list (let ((how (completing-read
3571 (append gnus-valid-select-methods gnus-server-alist)
3572 nil t (cons "nntp" 0) 'gnus-method-history)))
3573 ;; We either got a backend name or a virtual server name.
3574 ;; If the first, we also need an address.
3575 (if (assoc how gnus-valid-select-methods)
3577 ;; Suggested by mapjph@bath.ac.uk.
3580 (mapcar (lambda (server) (list server))
3581 gnus-secondary-servers)))
3582 ;; We got a server name.
3584 (gnus-browse-foreign-server method))
3586 (defun gnus-group-set-info (info &optional method-only-group part)
3587 (when (or info part)
3588 (let* ((entry (gnus-gethash
3589 (or method-only-group (gnus-info-group info))
3590 gnus-newsrc-hashtb))
3592 (info (if method-only-group (nth 2 entry) info))
3594 (when method-only-group
3596 (error "Trying to change non-existent group %s" method-only-group))
3597 ;; We have received parts of the actual group info - either the
3598 ;; select method or the group parameters. We first check
3599 ;; whether we have to extend the info, and if so, do that.
3600 (let ((len (length info))
3601 (total (if (eq part 'method) 5 6)))
3603 (setcdr (nthcdr (1- len) info)
3604 (make-list (- total len) nil)))
3605 ;; Then we enter the new info.
3606 (setcar (nthcdr (1- total) info) part-info)))
3608 ;; This is a new group, so we just create it.
3610 (set-buffer gnus-group-buffer)
3611 (setq method (gnus-info-method info))
3612 (when (gnus-server-equal method "native")
3615 (set-buffer gnus-group-buffer)
3617 ;; It's a foreign group...
3618 (gnus-group-make-group
3619 (gnus-group-real-name (gnus-info-group info))
3620 (if (stringp method) method
3621 (prin1-to-string (car method)))
3623 (nth 1 (gnus-info-method info))))
3624 ;; It's a native group.
3625 (gnus-group-make-group (gnus-info-group info))))
3626 (gnus-message 6 "Note: New group created")
3628 (gnus-gethash (gnus-group-prefixed-name
3629 (gnus-group-real-name (gnus-info-group info))
3630 (or (gnus-info-method info) gnus-select-method))
3631 gnus-newsrc-hashtb))))
3632 ;; Whether it was a new group or not, we now have the entry, so we
3633 ;; can do the update.
3636 (setcar (nthcdr 2 entry) info)
3637 (when (and (not (eq (car entry) t))
3638 (gnus-active (gnus-info-group info)))
3639 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3640 (error "No such group: %s" (gnus-info-group info))))))
3642 (defun gnus-group-set-method-info (group select-method)
3643 (gnus-group-set-info select-method group 'method))
3645 (defun gnus-group-set-params-info (group params)
3646 (gnus-group-set-info params group 'params))
3648 (defun gnus-add-marked-articles (group type articles &optional info force)
3649 ;; Add ARTICLES of TYPE to the info of GROUP.
3650 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3651 ;; add, but replace marked articles of TYPE with ARTICLES.
3652 (let ((info (or info (gnus-get-info group)))
3655 (and (not (setq marked (nthcdr 3 info)))
3657 (setcdr (nthcdr 2 info)
3658 (list (list (cons type (gnus-compress-sequence
3660 (and (not (setq m (assq type (car marked))))
3663 (cons (cons type (gnus-compress-sequence articles t) )
3667 (setcar (nthcdr 3 info)
3668 (gnus-delete-alist type (car marked)))
3669 (setcdr m (gnus-compress-sequence articles t)))
3670 (setcdr m (gnus-compress-sequence
3671 (sort (nconc (gnus-uncompress-range (cdr m))
3672 (copy-sequence articles)) '<) t))))))
3675 ;;; Group timestamps
3678 (defun gnus-group-set-timestamp ()
3679 "Change the timestamp of the current group to the current time.
3680 This function can be used in hooks like `gnus-select-group-hook'
3681 or `gnus-group-catchup-group-hook'."
3682 (when gnus-newsgroup-name
3683 (let ((time (current-time)))
3684 (setcdr (cdr time) nil)
3685 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3687 (defsubst gnus-group-timestamp (group)
3688 "Return the timestamp for GROUP."
3689 (gnus-group-get-parameter group 'timestamp t))
3691 (defun gnus-group-timestamp-delta (group)
3692 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3693 (let* ((time (or (gnus-group-timestamp group)
3695 (delta (subtract-time (current-time) time)))
3696 (+ (* (nth 0 delta) 65536.0)
3699 (defun gnus-group-timestamp-string (group)
3700 "Return a string of the timestamp for GROUP."
3701 (let ((time (gnus-group-timestamp group)))
3704 (gnus-time-iso8601 time))))
3706 (defun gnus-group-prepare-flat-list-dead-predicate
3707 (groups level mark predicate)
3710 ;; This loop is used when listing groups that match some
3712 (while (setq group (pop groups))
3713 (when (funcall predicate group)
3714 (gnus-add-text-properties
3715 (point) (prog1 (1+ (point))
3716 (insert " " mark " *: "
3717 (gnus-group-name-decode group
3718 (gnus-group-name-charset
3721 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3723 'gnus-level level)))))))
3725 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest
3727 "List all newsgroups with unread articles of level LEVEL or lower.
3728 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3729 If PREDICATE, only list groups which PREDICATE returns non-nil.
3730 If DEAD-PREDICATE, list dead groups which DEAD-PREDICATE returns non-nil."
3731 (set-buffer gnus-group-buffer)
3732 (let ((buffer-read-only nil)
3733 (newsrc (cdr gnus-newsrc-alist))
3734 (lowest (or lowest 1))
3735 info clevel unread group params)
3737 ;; List living groups.
3739 (setq info (car newsrc)
3740 group (gnus-info-group info)
3741 params (gnus-info-params info)
3743 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3744 (and unread ; This group might be unchecked
3745 (funcall predicate info)
3746 (<= (setq clevel (gnus-info-level info)) level)
3748 (gnus-group-insert-group-line
3749 group (gnus-info-level info)
3750 (gnus-info-marks info) unread (gnus-info-method info))))
3752 ;; List dead groups.
3753 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3754 (gnus-group-prepare-flat-list-dead-predicate
3755 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3756 gnus-level-zombie ?Z
3758 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3759 (gnus-group-prepare-flat-list-dead-predicate
3760 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3761 gnus-level-killed ?K dead-predicate))
3763 (gnus-group-set-mode-line)
3764 (setq gnus-group-list-mode (cons level t))
3765 (gnus-run-hooks 'gnus-group-prepare-hook)
3768 (defun gnus-group-list-cached (level &optional lowest)
3769 "List all groups with cached articles.
3770 If the prefix LEVEL is non-nil, it should be a number that says which
3771 level to cut off listing groups.
3772 If LOWEST, don't list groups with level lower than LOWEST.
3774 This command may read the active file."
3777 (setq level (prefix-numeric-value level)))
3778 (when (or (not level) (>= level gnus-level-zombie))
3780 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3782 (let ((marks (gnus-info-marks info)))
3783 (assq 'cache marks)))
3786 (or (gnus-gethash group
3787 gnus-cache-active-hashtb)
3788 ;; Cache active file might use "."
3791 (mapconcat 'identity
3792 (split-string group ":")
3794 gnus-cache-active-hashtb))))
3795 (goto-char (point-min))
3796 (gnus-group-position-point))
3798 (defun gnus-group-list-dormant (level &optional lowest)
3799 "List all groups with dormant articles.
3800 If the prefix LEVEL is non-nil, it should be a number that says which
3801 level to cut off listing groups.
3802 If LOWEST, don't list groups with level lower than LOWEST.
3804 This command may read the active file."
3807 (setq level (prefix-numeric-value level)))
3808 (when (or (not level) (>= level gnus-level-zombie))
3810 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3812 (let ((marks (gnus-info-marks info)))
3813 (assq 'dormant marks)))
3815 (goto-char (point-min))
3816 (gnus-group-position-point))
3818 (provide 'gnus-group)
3820 ;;; gnus-group.el ends here