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)
1755 (message "Quit reading the ephemeral group")
1758 (defun gnus-group-jump-to-group (group)
1759 "Jump to newsgroup GROUP."
1761 (list (completing-read
1762 "Group: " gnus-active-hashtb nil
1763 (gnus-read-active-file-p)
1765 'gnus-group-history)))
1767 (when (equal group "")
1768 (error "Empty group name"))
1770 (unless (gnus-ephemeral-group-p group)
1771 ;; Either go to the line in the group buffer...
1772 (unless (gnus-group-goto-group group)
1773 ;; ... or insert the line.
1774 (gnus-group-update-group group)
1775 (gnus-group-goto-group group)))
1776 ;; Adjust cursor point.
1777 (gnus-group-position-point))
1779 (defun gnus-group-goto-group (group &optional far test-marked)
1780 "Goto to newsgroup GROUP.
1781 If FAR, it is likely that the group is not on the current line.
1782 If TEST-MARKED, the line must be marked."
1786 ;; It's quite likely that we are on the right line, so
1787 ;; we check the current line first.
1789 (eq (get-text-property (point) 'gnus-group)
1790 (gnus-intern-safe group gnus-active-hashtb))
1791 (or (not test-marked) (gnus-group-mark-line-p)))
1793 ;; Previous and next line are also likely, so we check them as well.
1797 (and (eq (get-text-property (point) 'gnus-group)
1798 (gnus-intern-safe group gnus-active-hashtb))
1799 (or (not test-marked) (gnus-group-mark-line-p)))))
1805 (and (eq (get-text-property (point) 'gnus-group)
1806 (gnus-intern-safe group gnus-active-hashtb))
1807 (or (not test-marked) (gnus-group-mark-line-p)))))
1811 (goto-char (point-min))
1813 (while (and (not found)
1818 (gnus-intern-safe group gnus-active-hashtb))))
1819 (if (gnus-group-mark-line-p)
1824 ;; Search through the entire buffer.
1827 (point-min) (point-max)
1828 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1830 (defun gnus-group-next-group (n &optional silent)
1831 "Go to next N'th newsgroup.
1832 If N is negative, search backward instead.
1833 Returns the difference between N and the number of skips actually
1836 (gnus-group-next-unread-group n t nil silent))
1838 (defun gnus-group-next-unread-group (n &optional all level silent)
1839 "Go to next N'th unread newsgroup.
1840 If N is negative, search backward instead.
1841 If ALL is non-nil, choose any newsgroup, unread or not.
1842 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1843 such group can be found, the next group with a level higher than
1845 Returns the difference between N and the number of skips actually
1848 (let ((backward (< n 0))
1851 (gnus-group-search-forward
1852 backward (or (not gnus-group-goto-unread) all) level))
1856 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1857 (if level " on this level or higher" "")))
1860 (defun gnus-group-prev-group (n)
1861 "Go to previous N'th newsgroup.
1862 Returns the difference between N and the number of skips actually
1865 (gnus-group-next-unread-group (- n) t))
1867 (defun gnus-group-prev-unread-group (n)
1868 "Go to previous N'th unread newsgroup.
1869 Returns the difference between N and the number of skips actually
1872 (gnus-group-next-unread-group (- n)))
1874 (defun gnus-group-next-unread-group-same-level (n)
1875 "Go to next N'th unread newsgroup on the same level.
1876 If N is negative, search backward instead.
1877 Returns the difference between N and the number of skips actually
1880 (gnus-group-next-unread-group n t (gnus-group-group-level))
1881 (gnus-group-position-point))
1883 (defun gnus-group-prev-unread-group-same-level (n)
1884 "Go to next N'th unread newsgroup on the same level.
1885 Returns the difference between N and the number of skips actually
1888 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1889 (gnus-group-position-point))
1891 (defun gnus-group-best-unread-group (&optional exclude-group)
1892 "Go to the group with the highest level.
1893 If EXCLUDE-GROUP, do not go to that group."
1895 (goto-char (point-min))
1899 (setq unread (get-text-property (point) 'gnus-unread))
1900 (when (and (numberp unread) (> unread 0))
1901 (when (and (get-text-property (point) 'gnus-level)
1902 (< (get-text-property (point) 'gnus-level) best)
1903 (or (not exclude-group)
1904 (not (equal exclude-group (gnus-group-group-name)))))
1905 (setq best (get-text-property (point) 'gnus-level))
1906 (setq best-point (point))))
1909 (goto-char best-point))
1910 (gnus-summary-position-point)
1911 (and best-point (gnus-group-group-name))))
1913 (defun gnus-group-first-unread-group ()
1914 "Go to the first group with unread articles."
1917 (let ((opoint (point))
1919 (goto-char (point-min))
1920 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1921 (and (numberp unread) ; Not a topic.
1922 (not (zerop unread))) ; Has unread articles.
1923 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1926 nil)) ; Not success.
1927 (gnus-group-position-point)))
1929 (defun gnus-group-enter-server-mode ()
1930 "Jump to the server buffer."
1932 (gnus-enter-server-buffer))
1934 (defun gnus-group-make-group (name &optional method address args)
1935 "Add a new newsgroup.
1936 The user will be prompted for a NAME, for a select METHOD, and an
1940 (gnus-read-group "Group name: ")
1941 (gnus-read-method "From method: ")))
1943 (when (stringp method)
1944 (setq method (or (gnus-server-to-method method) method)))
1945 (let* ((meth (gnus-method-simplify
1947 (not (gnus-server-equal method gnus-select-method)))
1948 (if address (list (intern method) address)
1950 (nname (if method (gnus-group-prefixed-name name meth) name))
1952 (when (gnus-gethash nname gnus-newsrc-hashtb)
1953 (error "Group %s already exists" nname))
1954 ;; Subscribe to the new group.
1955 (gnus-group-change-level
1956 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1957 gnus-level-default-subscribed gnus-level-killed
1958 (and (gnus-group-group-name)
1959 (gnus-gethash (gnus-group-group-name)
1960 gnus-newsrc-hashtb))
1963 (gnus-set-active nname (cons 1 0))
1964 (unless (gnus-ephemeral-group-p name)
1966 (concat "(gnus-group-set-info '"
1967 (gnus-prin1-to-string (cdr info)) ")")))
1969 (gnus-group-insert-group-line-info nname)
1971 (gnus-group-position-point)
1973 ;; Load the backend and try to make the backend create
1974 ;; the group as well.
1975 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1977 gnus-valid-select-methods)
1979 (gnus-check-server meth)
1980 (when (gnus-check-backend-function 'request-create-group nname)
1981 (gnus-request-create-group nname nil args))
1984 (defun gnus-group-delete-groups (&optional arg)
1985 "Delete the current group. Only meaningful with editable groups."
1987 (let ((n (length (gnus-group-process-prefix arg))))
1988 (when (gnus-yes-or-no-p
1990 "Delete this 1 group? "
1991 (format "Delete these %d groups? " n)))
1992 (gnus-group-iterate arg
1994 (gnus-group-delete-group group nil t))))))
1996 (defun gnus-group-delete-group (group &optional force no-prompt)
1997 "Delete the current group. Only meaningful with editable groups.
1998 If FORCE (the prefix) is non-nil, all the articles in the group will
1999 be deleted. This is \"deleted\" as in \"removed forever from the face
2000 of the Earth\". There is no undo. The user will be prompted before
2001 doing the deletion."
2003 (list (gnus-group-group-name)
2004 current-prefix-arg))
2006 (error "No group to rename"))
2007 (unless (gnus-check-backend-function 'request-delete-group group)
2008 (error "This backend does not support group deletion"))
2010 (if (and (not no-prompt)
2011 (not (gnus-yes-or-no-p
2013 "Do you really want to delete %s%s? "
2014 group (if force " and all its contents" "")))))
2016 (gnus-message 6 "Deleting group %s..." group)
2017 (if (not (gnus-request-delete-group group force))
2018 (gnus-error 3 "Couldn't delete group %s" group)
2019 (gnus-message 6 "Deleting group %s...done" group)
2020 (gnus-group-goto-group group)
2021 (gnus-group-kill-group 1 t)
2022 (gnus-sethash group nil gnus-active-hashtb)
2024 (gnus-group-position-point)))
2026 (defun gnus-group-rename-group (group new-name)
2027 "Rename group from GROUP to NEW-NAME.
2028 When used interactively, GROUP is the group under point
2029 and NEW-NAME will be prompted for."
2032 (gnus-group-group-name)
2034 (unless (gnus-check-backend-function
2035 'request-rename-group (gnus-group-group-name))
2036 (error "This backend does not support renaming groups"))
2037 (gnus-read-group "Rename group to: "
2038 (gnus-group-real-name (gnus-group-group-name))))))
2040 (unless (gnus-check-backend-function 'request-rename-group group)
2041 (error "This backend does not support renaming groups"))
2043 (error "No group to rename"))
2044 (when (equal (gnus-group-real-name group) new-name)
2045 (error "Can't rename to the same name"))
2047 ;; We find the proper prefixed name.
2049 (if (gnus-group-native-p group)
2053 (gnus-group-prefixed-name
2054 (gnus-group-real-name new-name)
2055 (gnus-info-method (gnus-get-info group)))))
2057 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2060 (gnus-group-goto-group group)
2061 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2062 (gnus-request-rename-group group new-name))))
2063 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2064 ;; We rename the group internally by killing it...
2065 (gnus-group-kill-group)
2066 ;; ... changing its name ...
2067 (setcar (cdar gnus-list-of-killed-groups) new-name)
2068 ;; ... and then yanking it. Magic!
2069 (gnus-group-yank-group)
2070 (gnus-set-active new-name (gnus-active group))
2071 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2073 (setq gnus-killed-list (delete group gnus-killed-list))
2074 (gnus-set-active group nil)
2075 (gnus-dribble-touch)
2076 (gnus-group-position-point)))
2078 (defun gnus-group-edit-group (group &optional part)
2079 "Edit the group on the current line."
2080 (interactive (list (gnus-group-group-name)))
2081 (let ((part (or part 'info))
2084 (error "No group on current line"))
2085 (unless (setq info (gnus-get-info group))
2086 (error "Killed group; can't be edited"))
2088 (gnus-close-group group))
2090 ;; Find the proper form to edit.
2091 (cond ((eq part 'method)
2092 (or (gnus-info-method info) "native"))
2094 (gnus-info-params info))
2096 ;; The proper documentation.
2098 "Editing the %s for `%s'."
2100 ((eq part 'method) "select method")
2101 ((eq part 'params) "group parameters")
2103 (gnus-group-decoded-name group))
2105 (gnus-group-edit-group-done ',part ,group form)))))
2107 (defun gnus-group-edit-group-method (group)
2108 "Edit the select method of GROUP."
2109 (interactive (list (gnus-group-group-name)))
2110 (gnus-group-edit-group group 'method))
2112 (defun gnus-group-edit-group-parameters (group)
2113 "Edit the group parameters of GROUP."
2114 (interactive (list (gnus-group-group-name)))
2115 (gnus-group-edit-group group 'params))
2117 (defun gnus-group-edit-group-done (part group form)
2119 (let* ((method (cond ((eq part 'info) (nth 4 form))
2120 ((eq part 'method) form)
2122 (info (cond ((eq part 'info) form)
2123 ((eq part 'method) (gnus-get-info group))
2126 (if (or (not method)
2128 gnus-select-method method))
2129 (gnus-group-real-name (car info))
2130 (gnus-group-prefixed-name
2131 (gnus-group-real-name (car info)) method))
2133 (when (and new-group
2134 (not (equal new-group group)))
2135 (when (gnus-group-goto-group group)
2136 (gnus-group-kill-group 1))
2137 (gnus-activate-group new-group))
2139 (if (not (and info new-group))
2140 (gnus-group-set-info form (or new-group group) part)
2141 (setq info (gnus-copy-sequence info))
2142 (setcar info new-group)
2143 (unless (gnus-server-equal method "native")
2144 (unless (nthcdr 3 info)
2145 (nconc info (list nil nil)))
2146 (unless (nthcdr 4 info)
2147 (nconc info (list nil)))
2148 (gnus-info-set-method info method))
2149 (gnus-group-set-info info))
2150 (gnus-group-update-group (or new-group group))
2151 (gnus-group-position-point)))
2153 (defun gnus-group-make-useful-group (group method)
2154 "Create one of the groups described in `gnus-useful-groups'."
2156 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2158 gnus-useful-groups)))
2159 (list (cadr entry) (caddr entry))))
2160 (setq method (gnus-copy-sequence method))
2162 (while (setq entry (memq (assq 'eval method) method))
2163 (setcar entry (eval (cadar entry)))))
2164 (gnus-group-make-group group method))
2166 (defun gnus-group-make-help-group ()
2167 "Create the Gnus documentation group."
2169 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2170 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2171 (when (gnus-gethash name gnus-newsrc-hashtb)
2172 (error "Documentation group already exists"))
2174 (gnus-message 1 "Couldn't find doc group")
2175 (gnus-group-make-group
2176 (gnus-group-real-name name)
2177 (list 'nndoc "gnus-help"
2178 (list 'nndoc-address file)
2179 (list 'nndoc-article-type 'mbox)))))
2180 (gnus-group-position-point))
2182 (defun gnus-group-make-doc-group (file type)
2183 "Create a group that uses a single file as the source."
2185 (list (read-file-name "File name: ")
2186 (and current-prefix-arg 'ask)))
2187 (when (eq type 'ask)
2192 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2194 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2195 ((= char ?b) 'babyl)
2196 ((= char ?d) 'digest)
2197 ((= char ?f) 'forward)
2199 ((= char ?g) 'guess)
2200 (t (setq err (format "%c unknown. " char))
2203 (let* ((file (expand-file-name file))
2204 (name (gnus-generate-new-group-name
2205 (gnus-group-prefixed-name
2206 (file-name-nondirectory file) '(nndoc "")))))
2207 (gnus-group-make-group
2208 (gnus-group-real-name name)
2210 (list 'nndoc-address file)
2211 (list 'nndoc-article-type (or type 'guess))))))
2213 (defvar nnweb-type-definition)
2214 (defvar gnus-group-web-type-history nil)
2215 (defvar gnus-group-web-search-history nil)
2216 (defun gnus-group-make-web-group (&optional solid)
2217 "Create an ephemeral nnweb group.
2218 If SOLID (the prefix), create a solid group."
2222 (if solid (gnus-read-group "Group name: ")
2223 (message-unique-id)))
2224 (default-type (or (car gnus-group-web-type-history)
2225 (symbol-name (caar nnweb-type-definition))))
2229 (format "Search engine type (default %s): " default-type)
2230 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2231 nnweb-type-definition)
2232 nil t nil 'gnus-group-web-type-history)
2237 (cons (or (car gnus-group-web-search-history) "") 0)
2238 'gnus-group-web-search-history))
2240 `(nnweb ,group (nnweb-search ,search)
2241 (nnweb-type ,(intern type))
2242 (nnweb-ephemeral-p t))))
2244 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2245 (gnus-group-read-ephemeral-group
2247 (cons (current-buffer)
2248 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2250 (defvar nnwarchive-type-definition)
2251 (defvar gnus-group-warchive-type-history nil)
2252 (defvar gnus-group-warchive-login-history nil)
2253 (defvar gnus-group-warchive-address-history nil)
2255 (defun gnus-group-make-warchive-group ()
2256 "Create a nnwarchive group."
2258 (require 'nnwarchive)
2259 (let* ((group (gnus-read-group "Group name: "))
2260 (default-type (or (car gnus-group-warchive-type-history)
2261 (symbol-name (caar nnwarchive-type-definition))))
2265 (format "Warchive type (default %s): " default-type)
2266 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2267 nnwarchive-type-definition)
2268 nil t nil 'gnus-group-warchive-type-history)
2270 (address (read-string "Warchive address: "
2271 nil 'gnus-group-warchive-address-history))
2272 (default-login (or (car gnus-group-warchive-login-history)
2277 (format "Warchive login (default %s): " user-mail-address)
2278 default-login 'gnus-group-warchive-login-history)
2281 `(nnwarchive ,address
2282 (nnwarchive-type ,(intern type))
2283 (nnwarchive-login ,login))))
2284 (gnus-group-make-group group method)))
2286 (defvar nnshimbun-type-definition)
2287 (defvar gnus-group-shimbun-server-history nil)
2289 (defun gnus-group-make-shimbun-group ()
2290 "Create a nnshimbun group."
2292 (require 'nnshimbun)
2293 (let* ((minibuffer-setup-hook (append minibuffer-setup-hook
2294 '(beginning-of-line)))
2295 (server (completing-read
2297 (mapcar (lambda (elem) (list (car elem)))
2298 nnshimbun-type-definition)
2300 (or (car gnus-group-shimbun-server-history)
2301 (caar nnshimbun-type-definition))
2302 'gnus-group-shimbun-server-history))
2303 (group (completing-read
2305 (mapcar (lambda (elem) (list elem))
2307 (cdr (assoc server nnshimbun-type-definition)))))
2309 (nnshimbun-pre-fetch-article nil))
2310 (gnus-group-make-group group `(nnshimbun ,server))))
2312 (defun gnus-group-make-archive-group (&optional all)
2313 "Create the (ding) Gnus archive group of the most recent articles.
2314 Given a prefix, create a full group."
2316 (let ((group (gnus-group-prefixed-name
2317 (if all "ding.archives" "ding.recent") '(nndir ""))))
2318 (when (gnus-gethash group gnus-newsrc-hashtb)
2319 (error "Archive group already exists"))
2320 (gnus-group-make-group
2321 (gnus-group-real-name group)
2322 (list 'nndir (if all "hpc" "edu")
2323 (list 'nndir-directory
2324 (if all gnus-group-archive-directory
2325 gnus-group-recent-archive-directory))))
2326 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2328 (defun gnus-group-make-directory-group (dir)
2329 "Create an nndir group.
2330 The user will be prompted for a directory. The contents of this
2331 directory will be used as a newsgroup. The directory should contain
2332 mail messages or news articles in files that have numeric names."
2334 (list (read-file-name "Create group from directory: ")))
2335 (unless (file-exists-p dir)
2336 (error "No such directory"))
2337 (unless (file-directory-p dir)
2338 (error "Not a directory"))
2342 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2344 (gnus-group-prefixed-name
2345 (concat (file-name-as-directory (directory-file-name dir))
2348 (setq ext (format "<%d>" (setq i (1+ i)))))
2349 (gnus-group-make-group
2350 (gnus-group-real-name group)
2351 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2353 (defun gnus-group-make-kiboze-group (group address scores)
2354 "Create an nnkiboze group.
2355 The user will be prompted for a name, a regexp to match groups, and
2356 score file entries for articles to include in the group."
2359 (read-string "nnkiboze group name: ")
2360 (read-string "Source groups (regexp): ")
2361 (let ((headers (mapcar (lambda (group) (list group))
2362 '("subject" "from" "number" "date" "message-id"
2363 "references" "chars" "lines" "xref"
2364 "followup" "all" "body" "head")))
2365 scores header regexp regexps)
2366 (while (not (equal "" (setq header (completing-read
2367 "Match on header: " headers nil t))))
2369 (while (not (equal "" (setq regexp (read-string
2370 (format "Match on %s (regexp): "
2372 (push (list regexp nil nil 'r) regexps))
2373 (push (cons header regexps) scores))
2375 (gnus-group-make-group group "nnkiboze" address)
2376 (let* ((nnkiboze-current-group group)
2377 (score-file (car (nnkiboze-score-file "")))
2378 (score-dir (file-name-directory score-file)))
2379 (unless (file-exists-p score-dir)
2380 (make-directory score-dir))
2381 (with-temp-file score-file
2382 (let (emacs-lisp-mode-hook)
2383 (pp scores (current-buffer))))))
2385 (defun gnus-group-add-to-virtual (n vgroup)
2386 "Add the current group to a virtual group."
2388 (list current-prefix-arg
2389 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2391 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2392 (error "%s is not an nnvirtual group" vgroup))
2393 (gnus-close-group vgroup)
2394 (let* ((groups (gnus-group-process-prefix n))
2395 (method (gnus-info-method (gnus-get-info vgroup))))
2396 (setcar (cdr method)
2398 (nth 1 method) "\\|"
2401 (gnus-group-remove-mark s)
2402 (concat "\\(^" (regexp-quote s) "$\\)"))
2404 (gnus-group-position-point))
2406 (defun gnus-group-make-empty-virtual (group)
2407 "Create a new, fresh, empty virtual group."
2408 (interactive "sCreate new, empty virtual group: ")
2409 (let* ((method (list 'nnvirtual "^$"))
2410 (pgroup (gnus-group-prefixed-name group method)))
2411 ;; Check whether it exists already.
2412 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2413 (error "Group %s already exists" pgroup))
2414 ;; Subscribe the new group after the group on the current line.
2415 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2416 (gnus-group-update-group pgroup)
2418 (gnus-group-position-point)))
2420 (defun gnus-group-enter-directory (dir)
2421 "Enter an ephemeral nneething group."
2422 (interactive "DDirectory to read: ")
2423 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2424 (leaf (gnus-group-prefixed-name
2425 (file-name-nondirectory (directory-file-name dir))
2427 (name (gnus-generate-new-group-name leaf)))
2428 (unless (gnus-group-read-ephemeral-group
2430 (cons (current-buffer)
2431 (if (eq major-mode 'gnus-summary-mode)
2433 (error "Couldn't enter %s" dir))))
2436 (autoload 'nnimap-expunge "nnimap")
2437 (autoload 'nnimap-acl-get "nnimap")
2438 (autoload 'nnimap-acl-edit "nnimap"))
2440 (defun gnus-group-nnimap-expunge (group)
2441 "Expunge deleted articles in current nnimap GROUP."
2442 (interactive (list (gnus-group-group-name)))
2443 (let ((mailbox (gnus-group-real-name group)) method)
2445 (error "No group on current line"))
2446 (unless (gnus-get-info group)
2447 (error "Killed group; can't be edited"))
2448 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2449 (error "%s is not an nnimap group" group))
2450 (nnimap-expunge mailbox (cadr method))))
2452 (defun gnus-group-nnimap-edit-acl (group)
2453 "Edit the Access Control List of current nnimap GROUP."
2454 (interactive (list (gnus-group-group-name)))
2455 (let ((mailbox (gnus-group-real-name group)) method acl)
2457 (error "No group on current line"))
2458 (unless (gnus-get-info group)
2459 (error "Killed group; can't be edited"))
2460 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2461 (error "%s is not an nnimap group" group))
2462 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2463 (error "Server does not support ACL's"))
2464 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2466 An access control list is a list of (identifier . rights) elements.
2468 The identifier string specifies the corresponding user. The
2469 identifier \"anyone\" is reserved to refer to the universal identity.
2471 Rights is a string listing a (possibly empty) set of alphanumeric
2472 characters, each character listing a set of operations which is being
2473 controlled. Letters are reserved for ``standard'' rights, listed
2474 below. Digits are reserved for implementation or site defined rights.
2476 l - lookup (mailbox is visible to LIST/LSUB commands)
2477 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2478 SEARCH, COPY from mailbox)
2479 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2480 w - write (STORE flags other than \\SEEN and \\DELETED)
2481 i - insert (perform APPEND, COPY into mailbox)
2482 p - post (send mail to submission address for mailbox,
2483 not enforced by IMAP4 itself)
2484 c - create and delete mailbox (CREATE new sub-mailboxes in any
2485 implementation-defined hierarchy, RENAME or DELETE mailbox)
2486 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2487 a - administer (perform SETACL)" group)
2490 ,mailbox ',method ',acl form)))))
2492 ;; Group sorting commands
2493 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2495 (defun gnus-group-sort-groups (func &optional reverse)
2496 "Sort the group buffer according to FUNC.
2497 When used interactively, the sorting function used will be
2498 determined by the `gnus-group-sort-function' variable.
2499 If REVERSE (the prefix), reverse the sorting order."
2500 (interactive (list gnus-group-sort-function current-prefix-arg))
2501 (funcall gnus-group-sort-alist-function
2502 (gnus-make-sort-function func) reverse)
2503 (gnus-group-list-groups)
2504 (gnus-dribble-touch))
2506 (defun gnus-group-sort-flat (func reverse)
2507 ;; We peel off the dummy group from the alist.
2509 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2510 (pop gnus-newsrc-alist))
2512 (setq gnus-newsrc-alist
2513 (sort gnus-newsrc-alist func))
2515 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2516 ;; Regenerate the hash table.
2517 (gnus-make-hashtable-from-newsrc-alist)))
2519 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2520 "Sort the group buffer alphabetically by group name.
2521 If REVERSE, sort in reverse order."
2523 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2525 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2526 "Sort the group buffer by number of unread articles.
2527 If REVERSE, sort in reverse order."
2529 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2531 (defun gnus-group-sort-groups-by-level (&optional reverse)
2532 "Sort the group buffer by group level.
2533 If REVERSE, sort in reverse order."
2535 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2537 (defun gnus-group-sort-groups-by-score (&optional reverse)
2538 "Sort the group buffer by group score.
2539 If REVERSE, sort in reverse order."
2541 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2543 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2544 "Sort the group buffer by group rank.
2545 If REVERSE, sort in reverse order."
2547 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2549 (defun gnus-group-sort-groups-by-method (&optional reverse)
2550 "Sort the group buffer alphabetically by backend name.
2551 If REVERSE, sort in reverse order."
2553 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2555 ;;; Selected group sorting.
2557 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2558 "Sort the process/prefixed groups."
2559 (interactive (list current-prefix-arg gnus-group-sort-function))
2560 (let ((groups (gnus-group-process-prefix n)))
2561 (funcall gnus-group-sort-selected-function
2562 groups (gnus-make-sort-function func) reverse)
2563 (gnus-group-list-groups)))
2565 (defun gnus-group-sort-selected-flat (groups func reverse)
2566 (let (entries infos)
2567 ;; First find all the group entries for these groups.
2569 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2571 ;; Then sort the infos.
2575 (lambda (entry) (car entry))
2576 (setq entries (nreverse entries)))
2579 (setq infos (nreverse infos)))
2580 ;; Go through all the infos and replace the old entries
2581 ;; with the new infos.
2583 (setcar (car entries) (pop infos))
2585 ;; Update the hashtable.
2586 (gnus-make-hashtable-from-newsrc-alist)))
2588 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2589 "Sort the group buffer alphabetically by group name.
2590 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2591 sort in reverse order."
2592 (interactive (gnus-interactive "P\ny"))
2593 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2595 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2596 "Sort the group buffer by number of unread articles.
2597 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2598 sort in reverse order."
2599 (interactive (gnus-interactive "P\ny"))
2600 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2602 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2603 "Sort the group buffer by group level.
2604 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2605 sort in reverse order."
2606 (interactive (gnus-interactive "P\ny"))
2607 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2609 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2610 "Sort the group buffer by group score.
2611 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2612 sort in reverse order."
2613 (interactive (gnus-interactive "P\ny"))
2614 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2616 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2617 "Sort the group buffer by group rank.
2618 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2619 sort in reverse order."
2620 (interactive (gnus-interactive "P\ny"))
2621 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2623 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2624 "Sort the group buffer alphabetically by backend name.
2625 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2626 sort in reverse order."
2627 (interactive (gnus-interactive "P\ny"))
2628 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2630 ;;; Sorting predicates.
2632 (defun gnus-group-sort-by-alphabet (info1 info2)
2633 "Sort alphabetically."
2634 (string< (gnus-info-group info1) (gnus-info-group info2)))
2636 (defun gnus-group-sort-by-real-name (info1 info2)
2637 "Sort alphabetically on real (unprefixed) names."
2638 (string< (gnus-group-real-name (gnus-info-group info1))
2639 (gnus-group-real-name (gnus-info-group info2))))
2641 (defun gnus-group-sort-by-unread (info1 info2)
2642 "Sort by number of unread articles."
2643 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2644 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2645 (< (or (and (numberp n1) n1) 0)
2646 (or (and (numberp n2) n2) 0))))
2648 (defun gnus-group-sort-by-level (info1 info2)
2650 (< (gnus-info-level info1) (gnus-info-level info2)))
2652 (defun gnus-group-sort-by-method (info1 info2)
2653 "Sort alphabetically by backend name."
2654 (string< (symbol-name (car (gnus-find-method-for-group
2655 (gnus-info-group info1) info1)))
2656 (symbol-name (car (gnus-find-method-for-group
2657 (gnus-info-group info2) info2)))))
2659 (defun gnus-group-sort-by-score (info1 info2)
2660 "Sort by group score."
2661 (< (gnus-info-score info1) (gnus-info-score info2)))
2663 (defun gnus-group-sort-by-rank (info1 info2)
2664 "Sort by level and score."
2665 (let ((level1 (gnus-info-level info1))
2666 (level2 (gnus-info-level info2)))
2667 (or (< level1 level2)
2668 (and (= level1 level2)
2669 (> (gnus-info-score info1) (gnus-info-score info2))))))
2673 (defun gnus-group-clear-data (&optional arg)
2674 "Clear all marks and read ranges from the current group."
2676 (gnus-group-iterate arg
2679 (gnus-info-clear-data (setq info (gnus-get-info group)))
2680 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2681 (when (gnus-group-goto-group group)
2682 (gnus-group-update-group-line))))))
2684 (defun gnus-group-clear-data-on-native-groups ()
2685 "Clear all marks and read ranges from all native groups."
2687 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2688 (let ((alist (cdr gnus-newsrc-alist))
2690 (while (setq info (pop alist))
2691 (when (gnus-group-native-p (gnus-info-group info))
2692 (gnus-info-clear-data info)))
2693 (gnus-get-unread-articles)
2694 (gnus-dribble-touch)
2695 (when (gnus-y-or-n-p
2696 "Move the cache away to avoid problems in the future? ")
2697 (call-interactively 'gnus-cache-move-cache)))))
2699 (defun gnus-info-clear-data (info)
2700 "Clear all marks and read ranges from INFO."
2701 (let ((group (gnus-info-group info)))
2704 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2705 (gnus-info-set-read ',info ',(gnus-info-read info))
2706 (when (gnus-group-goto-group ,group)
2707 (gnus-group-update-group-line))))
2708 (gnus-info-set-read info nil)
2709 (when (gnus-info-marks info)
2710 (gnus-info-set-marks info nil))))
2712 ;; Group catching up.
2714 (defun gnus-group-catchup-current (&optional n all)
2715 "Mark all unread articles in the current newsgroup as read.
2716 If prefix argument N is numeric, the next N newsgroups will be
2717 caught up. If ALL is non-nil, marked articles will also be marked as
2718 read. Cross references (Xref: header) of articles are ignored.
2719 The number of newsgroups that this function was unable to catch
2722 (let ((groups (gnus-group-process-prefix n))
2725 (unless groups (error "No groups selected"))
2727 (or (not gnus-interactive-catchup) ;Without confirmation?
2732 "Do you really want to mark all articles in %s as read? "
2733 "Mark all unread articles in %s as read? ")
2734 (if (= (length groups) 1)
2736 (format "these %d groups" (length groups)))))))
2738 (while (setq group (pop groups))
2739 (gnus-group-remove-mark group)
2740 ;; Virtual groups have to be given special treatment.
2741 (let ((method (gnus-find-method-for-group group)))
2742 (when (eq 'nnvirtual (car method))
2743 (nnvirtual-catchup-group
2744 (gnus-group-real-name group) (nth 1 method) all)))
2745 (if (>= (gnus-group-level group) gnus-level-zombie)
2746 (gnus-message 2 "Dead groups can't be caught up")
2748 (gnus-group-goto-group group)
2749 (gnus-group-catchup group all))
2750 (gnus-group-update-group-line)
2751 (setq ret (1+ ret)))))
2752 (gnus-group-next-unread-group 1)
2755 (defun gnus-group-catchup-current-all (&optional n)
2756 "Mark all articles in current newsgroup as read.
2757 Cross references (Xref: header) of articles are ignored."
2759 (gnus-group-catchup-current n 'all))
2761 (defun gnus-group-catchup (group &optional all)
2762 "Mark all articles in GROUP as read.
2763 If ALL is non-nil, all articles are marked as read.
2764 The return value is the number of articles that were marked as read,
2765 or nil if no action could be taken."
2766 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2768 ;; Remove entries for this group.
2769 (nnmail-purge-split-history (gnus-group-real-name group))
2770 ;; Do the updating only if the newsgroup isn't killed.
2771 (if (not (numberp (car entry)))
2772 (gnus-message 1 "Can't catch up %s; non-active group" group)
2773 ;; Do auto-expirable marks if that's required.
2774 (when (gnus-group-auto-expirable-p group)
2775 (gnus-add-marked-articles
2776 group 'expire (gnus-list-of-unread-articles group))
2778 (let ((marks (nth 3 (nth 2 entry))))
2779 (gnus-add-marked-articles
2780 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2781 (gnus-add-marked-articles
2782 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2784 (gnus-update-read-articles group nil)
2785 ;; Also nix out the lists of marks and dormants.
2787 (gnus-add-marked-articles group 'tick nil nil 'force)
2788 (gnus-add-marked-articles group 'dormant nil nil 'force))
2789 (let ((gnus-newsgroup-name group))
2790 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2793 (defun gnus-group-expire-articles (&optional n)
2794 "Expire all expirable articles in the current newsgroup."
2796 (let ((groups (gnus-group-process-prefix n))
2799 (error "No groups to expire"))
2800 (while (setq group (pop groups))
2801 (gnus-group-remove-mark group)
2802 (gnus-group-expire-articles-1 group)
2803 (gnus-dribble-touch)
2804 (gnus-group-position-point))))
2806 (defun gnus-group-expire-articles-1 (group)
2807 (when (gnus-check-backend-function 'request-expire-articles group)
2808 (gnus-message 6 "Expiring articles in %s..." group)
2809 (let* ((info (gnus-get-info group))
2810 (expirable (if (gnus-group-total-expirable-p group)
2811 (cons nil (gnus-list-of-read-articles group))
2812 (assq 'expire (gnus-info-marks info))))
2813 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2814 (nnmail-expiry-target
2815 (or (gnus-group-find-parameter group 'expiry-target)
2816 nnmail-expiry-target)))
2818 (gnus-check-group group)
2821 (gnus-compress-sequence
2823 ;; We set the expiry variables to the group
2825 (let ((nnmail-expiry-wait-function nil)
2826 (nnmail-expiry-wait expiry-wait))
2827 (gnus-request-expire-articles
2828 (gnus-uncompress-sequence (cdr expirable)) group))
2829 ;; Just expire using the normal expiry values.
2830 (gnus-request-expire-articles
2831 (gnus-uncompress-sequence (cdr expirable)) group))))
2832 (gnus-close-group group))
2833 (gnus-message 6 "Expiring articles in %s...done" group)
2834 ;; Return the list of un-expired articles.
2837 (defun gnus-group-expire-all-groups ()
2838 "Expire all expirable articles in all newsgroups."
2841 (gnus-message 5 "Expiring...")
2842 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2843 (cdr gnus-newsrc-alist))))
2844 (gnus-group-expire-articles nil)))
2845 (gnus-group-position-point)
2846 (gnus-message 5 "Expiring...done"))
2848 (defun gnus-group-set-current-level (n level)
2849 "Set the level of the next N groups to LEVEL."
2854 (let ((s (read-string
2855 (format "Level (default %s): "
2856 (or (gnus-group-group-level)
2857 gnus-level-default-subscribed)))))
2858 (if (string-match "^\\s-*$" s)
2859 (int-to-string (or (gnus-group-group-level)
2860 gnus-level-default-subscribed))
2862 (unless (and (>= level 1) (<= level gnus-level-killed))
2863 (error "Invalid level: %d" level))
2864 (let ((groups (gnus-group-process-prefix n))
2866 (while (setq group (pop groups))
2867 (gnus-group-remove-mark group)
2868 (gnus-message 6 "Changed level of %s from %d to %d"
2869 group (or (gnus-group-group-level) gnus-level-killed)
2871 (gnus-group-change-level
2872 group level (or (gnus-group-group-level) gnus-level-killed))
2873 (gnus-group-update-group-line)))
2874 (gnus-group-position-point))
2876 (defun gnus-group-unsubscribe (&optional n)
2877 "Unsubscribe the current group."
2879 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2881 (defun gnus-group-subscribe (&optional n)
2882 "Subscribe the current group."
2884 (gnus-group-unsubscribe-current-group n 'subscribe))
2886 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2887 "Toggle subscription of the current group.
2888 If given numerical prefix, toggle the N next groups."
2890 (let ((groups (gnus-group-process-prefix n))
2893 (setq group (car groups)
2894 groups (cdr groups))
2895 (gnus-group-remove-mark group)
2896 (gnus-group-unsubscribe-group
2899 ((eq do-sub 'unsubscribe)
2900 gnus-level-default-unsubscribed)
2901 ((eq do-sub 'subscribe)
2902 gnus-level-default-subscribed)
2903 ((<= (gnus-group-group-level) gnus-level-subscribed)
2904 gnus-level-default-unsubscribed)
2906 gnus-level-default-subscribed))
2908 (gnus-group-update-group-line))
2909 (gnus-group-next-group 1)))
2911 (defun gnus-group-unsubscribe-group (group &optional level silent)
2912 "Toggle subscription to GROUP.
2913 Killed newsgroups are subscribed. If SILENT, don't try to update the
2916 (list (completing-read
2917 "Group: " gnus-active-hashtb nil
2918 (gnus-read-active-file-p)
2920 'gnus-group-history)))
2921 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2923 ((string-match "^[ \t]*$" group)
2924 (error "Empty group name"))
2926 ;; Toggle subscription flag.
2927 (gnus-group-change-level
2928 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2929 gnus-level-subscribed)
2930 (1+ gnus-level-subscribed)
2931 gnus-level-default-subscribed)))
2933 (gnus-group-update-group group)))
2934 ((and (stringp group)
2935 (or (not (gnus-read-active-file-p))
2936 (gnus-active group)))
2937 ;; Add new newsgroup.
2938 (gnus-group-change-level
2940 (if level level gnus-level-default-subscribed)
2941 (or (and (member group gnus-zombie-list)
2944 (when (gnus-group-group-name)
2945 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2947 (gnus-group-update-group group)))
2948 (t (error "No such newsgroup: %s" group)))
2949 (gnus-group-position-point)))
2951 (defun gnus-group-transpose-groups (n)
2952 "Move the current newsgroup up N places.
2953 If given a negative prefix, move down instead. The difference between
2954 N and the number of steps taken is returned."
2956 (unless (gnus-group-group-name)
2957 (error "No group on current line"))
2958 (gnus-group-kill-group 1)
2960 (forward-line (- n))
2961 (gnus-group-yank-group)
2962 (gnus-group-position-point)))
2964 (defun gnus-group-kill-all-zombies (&optional dummy)
2965 "Kill all zombie newsgroups.
2966 The optional DUMMY should always be nil."
2967 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2969 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2970 (setq gnus-zombie-list nil)
2971 (gnus-dribble-touch)
2972 (gnus-group-list-groups)))
2974 (defun gnus-group-kill-region (begin end)
2975 "Kill newsgroups in current region (excluding current point).
2976 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2991 (beginning-of-line) ;Important when LINES < 1
2992 (gnus-group-kill-group lines)))
2994 (defun gnus-group-kill-group (&optional n discard)
2995 "Kill the next N groups.
2996 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2997 However, only groups that were alive can be yanked; already killed
2998 groups or zombie groups can't be yanked.
2999 The return value is the name of the group that was killed, or a list
3002 (let ((buffer-read-only nil)
3003 (groups (gnus-group-process-prefix n))
3004 group entry level out)
3005 (if (< (length groups) 10)
3006 ;; This is faster when there are few groups.
3008 (push (setq group (pop groups)) out)
3009 (gnus-group-remove-mark group)
3010 (setq level (gnus-group-group-level))
3012 (when (and (not discard)
3013 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3016 (gnus-group-goto-group ,(gnus-group-group-name))
3017 (gnus-group-yank-group)))
3018 (push (cons (car entry) (nth 2 entry))
3019 gnus-list-of-killed-groups))
3020 (gnus-group-change-level
3021 (if entry entry group) gnus-level-killed (if entry nil level))
3022 (message "Killed group %s" group))
3023 ;; If there are lots and lots of groups to be killed, we use
3024 ;; this thing instead.
3026 (setq groups (nreverse groups))
3028 (gnus-group-remove-mark (setq group (pop groups)))
3030 (push group gnus-killed-list)
3031 (setq gnus-newsrc-alist
3032 (delq (assoc group gnus-newsrc-alist)
3034 (when gnus-group-change-level-function
3035 (funcall gnus-group-change-level-function
3036 group gnus-level-killed 3))
3038 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3039 (push (cons (car entry) (nth 2 entry))
3040 gnus-list-of-killed-groups)
3041 (setcdr (cdr entry) (cdddr entry)))
3042 ((member group gnus-zombie-list)
3043 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3044 ;; There may be more than one instance displayed.
3045 (while (gnus-group-goto-group group)
3046 (gnus-delete-line)))
3047 (gnus-make-hashtable-from-newsrc-alist)))
3049 (gnus-group-position-point)
3050 (if (< (length out) 2) (car out) (nreverse out))))
3052 (defun gnus-group-yank-group (&optional arg)
3053 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3054 The numeric ARG specifies how many newsgroups are to be yanked. The
3055 name of the newsgroup yanked is returned, or (if several groups are
3056 yanked) a list of yanked groups is returned."
3058 (setq arg (or arg 1))
3059 (let (info group prev out)
3060 (while (>= (decf arg) 0)
3061 (when (not (setq info (pop gnus-list-of-killed-groups)))
3062 (error "No more newsgroups to yank"))
3063 (push (setq group (nth 1 info)) out)
3064 ;; Find which newsgroup to insert this one before - search
3065 ;; backward until something suitable is found. If there are no
3066 ;; other newsgroups in this buffer, just make this newsgroup the
3068 (setq prev (gnus-group-group-name))
3069 (gnus-group-change-level
3070 info (gnus-info-level (cdr info)) gnus-level-killed
3071 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3073 (gnus-group-insert-group-line-info group)
3075 `(when (gnus-group-goto-group ,group)
3076 (gnus-group-kill-group 1))))
3078 (gnus-group-position-point)
3079 (if (< (length out) 2) (car out) (nreverse out))))
3081 (defun gnus-group-kill-level (level)
3082 "Kill all groups that is on a certain LEVEL."
3083 (interactive "nKill all groups on level: ")
3085 ((= level gnus-level-zombie)
3086 (setq gnus-killed-list
3087 (nconc gnus-zombie-list gnus-killed-list))
3088 (setq gnus-zombie-list nil))
3089 ((and (< level gnus-level-zombie)
3091 (or gnus-expert-user
3094 "Do you really want to kill all groups on level %d? "
3096 (let* ((prev gnus-newsrc-alist)
3099 (if (= (gnus-info-level (car alist)) level)
3101 (push (gnus-info-group (car alist)) gnus-killed-list)
3102 (setcdr prev (cdr alist)))
3104 (setq alist (cdr alist)))
3105 (gnus-make-hashtable-from-newsrc-alist)
3106 (gnus-group-list-groups)))
3108 (error "Can't kill; invalid level: %d" level))))
3110 (defun gnus-group-list-all-groups (&optional arg)
3111 "List all newsgroups with level ARG or lower.
3112 Default is gnus-level-unsubscribed, which lists all subscribed and most
3113 unsubscribed groups."
3115 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3117 ;; Redefine this to list ALL killed groups if prefix arg used.
3118 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3119 (defun gnus-group-list-killed (&optional arg)
3120 "List all killed newsgroups in the group buffer.
3121 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3122 entail asking the server for the groups."
3124 ;; Find all possible killed newsgroups if arg.
3126 (gnus-get-killed-groups))
3127 (if (not gnus-killed-list)
3128 (gnus-message 6 "No killed groups")
3129 (let (gnus-group-list-mode)
3130 (funcall gnus-group-prepare-function
3131 gnus-level-killed t gnus-level-killed))
3132 (goto-char (point-min)))
3133 (gnus-group-position-point))
3135 (defun gnus-group-list-zombies ()
3136 "List all zombie newsgroups in the group buffer."
3138 (if (not gnus-zombie-list)
3139 (gnus-message 6 "No zombie groups")
3140 (let (gnus-group-list-mode)
3141 (funcall gnus-group-prepare-function
3142 gnus-level-zombie t gnus-level-zombie))
3143 (goto-char (point-min)))
3144 (gnus-group-position-point))
3146 (defun gnus-group-list-active ()
3147 "List all groups that are available from the server(s)."
3149 ;; First we make sure that we have really read the active file.
3150 (unless (gnus-read-active-file-p)
3151 (let ((gnus-read-active-file t)
3152 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3153 (gnus-read-active-file)))
3154 ;; Find all groups and sort them.
3162 (push (symbol-name sym) list)))
3166 (buffer-read-only nil)
3170 (setq group (pop groups))
3171 (gnus-add-text-properties
3172 (point) (prog1 (1+ (point))
3174 (gnus-group-name-decode group
3175 (gnus-group-name-charset
3178 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3180 'gnus-level (inline (gnus-group-level group)))))
3181 (goto-char (point-min))))
3183 (defun gnus-activate-all-groups (level)
3184 "Activate absolutely all groups."
3185 (interactive (list gnus-level-unsubscribed))
3186 (let ((gnus-activate-level level)
3187 (gnus-activate-foreign-newsgroups level))
3188 (gnus-group-get-new-news)))
3190 (defun gnus-group-get-new-news (&optional arg)
3191 "Get newly arrived articles.
3192 If ARG is a number, it specifies which levels you are interested in
3193 re-scanning. If ARG is non-nil and not a number, this will force
3194 \"hard\" re-reading of the active files from all servers."
3197 (let ((gnus-inhibit-demon t)
3198 ;; Binding this variable will inhibit multiple fetchings
3199 ;; of the same mail source.
3200 (nnmail-fetched-sources (list t)))
3201 (gnus-run-hooks 'gnus-get-new-news-hook)
3203 ;; Read any slave files.
3205 (gnus-master-read-slave-newsrc))
3207 ;; We might read in new NoCeM messages here.
3208 (when (and gnus-use-nocem
3210 (gnus-nocem-scan-groups))
3211 ;; If ARG is not a number, then we read the active file.
3212 (when (and arg (not (numberp arg)))
3213 (let ((gnus-read-active-file t))
3214 (gnus-read-active-file))
3217 ;; If the user wants it, we scan for new groups.
3218 (when (eq gnus-check-new-newsgroups 'always)
3219 (gnus-find-new-newsgroups)))
3221 (setq arg (gnus-group-default-level arg t))
3222 (if (and gnus-read-active-file (not arg))
3224 (gnus-read-active-file)
3225 (gnus-get-unread-articles arg))
3226 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3227 (gnus-get-unread-articles arg)))
3228 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3229 (gnus-group-list-groups (and (numberp arg)
3230 (max (car gnus-group-list-mode) arg))))
3232 (when (and gnus-agent (not (interactive-p)))
3233 (gnus-agent-toggle-plugged gnus-plugged)))
3235 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3236 "Check for newly arrived news in the current group (and the N-1 next groups).
3237 The difference between N and the number of newsgroup checked is returned.
3238 If N is negative, this group and the N-1 previous groups will be checked."
3240 (let* ((groups (gnus-group-process-prefix n))
3241 (ret (if (numberp n) (- n (length groups)) 0))
3245 (gnus-inhibit-demon t)
3246 ;; Binding this variable will inhibit multiple fetchings
3247 ;; of the same mail source.
3248 (nnmail-fetched-sources (list t)))
3249 (gnus-run-hooks 'gnus-get-new-news-hook)
3250 (while (setq group (pop groups))
3251 (gnus-group-remove-mark group)
3252 ;; Bypass any previous denials from the server.
3253 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3254 (if (gnus-activate-group group (if dont-scan nil 'scan))
3256 (gnus-get-unread-articles-in-group
3257 (gnus-get-info group) (gnus-active group) t)
3258 (unless (gnus-virtual-group-p group)
3259 (gnus-close-group group))
3261 (gnus-agent-save-group-info
3262 method (gnus-group-real-name group) (gnus-active group)))
3263 (gnus-group-update-group group))
3264 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3266 (gnus-error 3 "Server denied access")
3267 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3270 (when gnus-goto-next-group-when-activating
3271 (gnus-group-next-unread-group 1 t))
3272 (gnus-summary-position-point)
3275 (defun gnus-group-fetch-faq (group &optional faq-dir)
3276 "Fetch the FAQ for the current group.
3277 If given a prefix argument, prompt for the FAQ dir
3281 (gnus-group-group-name)
3282 (when current-prefix-arg
3284 "Faq dir: " (and (listp gnus-group-faq-directory)
3285 (mapcar (lambda (file) (list file))
3286 gnus-group-faq-directory))))))
3288 (error "No group name given"))
3289 (let ((dirs (or faq-dir gnus-group-faq-directory))
3291 (unless (listp dirs)
3292 (setq dirs (list dirs)))
3293 (while (and (not found)
3294 (setq dir (pop dirs)))
3295 (let ((name (gnus-group-real-name group)))
3296 (setq file (concat (file-name-as-directory dir) name)))
3297 (if (not (file-exists-p file))
3298 (gnus-message 1 "No such file: %s" file)
3299 (let ((enable-local-variables nil))
3303 (defun gnus-group-describe-group (force &optional group)
3304 "Display a description of the current newsgroup."
3305 (interactive (list current-prefix-arg (gnus-group-group-name)))
3306 (let* ((method (gnus-find-method-for-group group))
3307 (mname (gnus-group-prefixed-name "" method))
3310 gnus-description-hashtb)
3311 (gnus-sethash mname nil gnus-description-hashtb))
3313 (error "No group name given"))
3314 (when (or (and gnus-description-hashtb
3315 ;; We check whether this group's method has been
3316 ;; queried for a description file.
3317 (gnus-gethash mname gnus-description-hashtb))
3318 (setq desc (gnus-group-get-description group))
3319 (gnus-read-descriptions-file method))
3321 (or desc (gnus-gethash group gnus-description-hashtb)
3322 "No description available")))))
3324 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3325 (defun gnus-group-describe-all-groups (&optional force)
3326 "Pop up a buffer with descriptions of all newsgroups."
3329 (setq gnus-description-hashtb nil))
3330 (when (not (or gnus-description-hashtb
3331 (gnus-read-all-descriptions-files)))
3332 (error "Couldn't request descriptions file"))
3333 (let ((buffer-read-only nil)
3339 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3340 (insert (format " *: %-20s %s\n"
3341 (gnus-group-name-decode
3342 (symbol-name group) charset)
3343 (gnus-group-name-decode
3344 (symbol-value group) charset))))
3345 (gnus-add-text-properties
3346 b (1+ b) (list 'gnus-group group
3347 'gnus-unread t 'gnus-marked nil
3348 'gnus-level (1+ gnus-level-subscribed))))
3349 gnus-description-hashtb)
3350 (goto-char (point-min))
3351 (gnus-group-position-point)))
3353 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3354 (defun gnus-group-apropos (regexp &optional search-description)
3355 "List all newsgroups that have names that match a regexp."
3356 (interactive "sGnus apropos (regexp): ")
3358 (obuf (current-buffer))
3360 ;; Go through all newsgroups that are known to Gnus.
3363 (and (symbol-name group)
3364 (string-match regexp (symbol-name group))
3365 (symbol-value group)
3366 (push (symbol-name group) groups)))
3368 ;; Also go through all descriptions that are known to Gnus.
3369 (when search-description
3372 (and (string-match regexp (symbol-value group))
3373 (push (symbol-name group) groups)))
3374 gnus-description-hashtb))
3376 (gnus-message 3 "No groups matched \"%s\"." regexp)
3377 ;; Print out all the groups.
3379 (pop-to-buffer "*Gnus Help*")
3380 (buffer-disable-undo)
3382 (setq groups (sort groups 'string<))
3384 ;; Groups may be entered twice into the list of groups.
3385 (when (not (string= (car groups) prev))
3386 (setq prev (car groups))
3387 (let ((charset (gnus-group-name-charset nil prev)))
3388 (insert (gnus-group-name-decode prev charset) "\n")
3389 (when (and gnus-description-hashtb
3390 (setq des (gnus-gethash (car groups)
3391 gnus-description-hashtb)))
3392 (insert " " (gnus-group-name-decode des charset) "\n"))))
3393 (setq groups (cdr groups)))
3394 (goto-char (point-min))))
3395 (pop-to-buffer obuf)))
3397 (defun gnus-group-description-apropos (regexp)
3398 "List all newsgroups that have names or descriptions that match a regexp."
3399 (interactive "sGnus description apropos (regexp): ")
3400 (when (not (or gnus-description-hashtb
3401 (gnus-read-all-descriptions-files)))
3402 (error "Couldn't request descriptions file"))
3403 (gnus-group-apropos regexp t))
3405 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3406 (defun gnus-group-list-matching (level regexp &optional all lowest)
3407 "List all groups with unread articles that match REGEXP.
3408 If the prefix LEVEL is non-nil, it should be a number that says which
3409 level to cut off listing groups.
3410 If ALL, also list groups with no unread articles.
3411 If LOWEST, don't list groups with level lower than LOWEST.
3413 This command may read the active file."
3414 (interactive "P\nsList newsgroups matching: ")
3415 ;; First make sure active file has been read.
3417 (> (prefix-numeric-value level) gnus-level-killed))
3418 (gnus-get-killed-groups))
3419 (gnus-group-prepare-flat
3420 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3421 (goto-char (point-min))
3422 (gnus-group-position-point))
3424 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3425 "List all groups that match REGEXP.
3426 If the prefix LEVEL is non-nil, it should be a number that says which
3427 level to cut off listing groups.
3428 If LOWEST, don't list groups with level lower than LOWEST."
3429 (interactive "P\nsList newsgroups matching: ")
3431 (setq level (prefix-numeric-value level)))
3432 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3434 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3435 (defun gnus-group-save-newsrc (&optional force)
3436 "Save the Gnus startup files.
3437 If FORCE, force saving whether it is necessary or not."
3439 (gnus-save-newsrc-file force))
3441 (defun gnus-group-restart (&optional arg)
3442 "Force Gnus to read the .newsrc file."
3444 (when (gnus-yes-or-no-p
3445 (format "Are you sure you want to restart Gnus? "))
3446 (gnus-save-newsrc-file)
3450 (defun gnus-group-read-init-file ()
3451 "Read the Gnus elisp init file."
3453 (gnus-read-init-file)
3454 (gnus-message 5 "Read %s" gnus-init-file))
3456 (defun gnus-group-check-bogus-groups (&optional silent)
3457 "Check bogus newsgroups.
3458 If given a prefix, don't ask for confirmation before removing a bogus
3461 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3462 (gnus-group-list-groups))
3464 (defun gnus-group-find-new-groups (&optional arg)
3465 "Search for new groups and add them.
3466 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3467 With 1 C-u, use the `ask-server' method to query the server for new
3469 With 2 C-u's, use most complete method possible to query the server
3470 for new groups, and subscribe the new groups as zombies."
3472 (gnus-find-new-newsgroups (or arg 1))
3473 (gnus-group-list-groups))
3475 (defun gnus-group-edit-global-kill (&optional article group)
3476 "Edit the global kill file.
3477 If GROUP, edit that local kill file instead."
3479 (setq gnus-current-kill-article article)
3480 (gnus-kill-file-edit-file group)
3483 (substitute-command-keys
3484 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3485 (if group "local" "global")))))
3487 (defun gnus-group-edit-local-kill (article group)
3488 "Edit a local kill file."
3489 (interactive (list nil (gnus-group-group-name)))
3490 (gnus-group-edit-global-kill article group))
3492 (defun gnus-group-force-update ()
3493 "Update `.newsrc' file."
3495 (gnus-save-newsrc-file))
3497 (defun gnus-group-suspend ()
3498 "Suspend the current Gnus session.
3499 In fact, cleanup buffers except for group mode buffer.
3500 The hook gnus-suspend-gnus-hook is called before actually suspending."
3502 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3503 ;; Kill Gnus buffers except for group mode buffer.
3504 (let ((group-buf (get-buffer gnus-group-buffer)))
3505 (mapcar (lambda (buf)
3506 (unless (member buf (list group-buf gnus-dribble-buffer))
3509 (gnus-kill-gnus-frames)
3511 (bury-buffer group-buf)
3512 (delete-windows-on group-buf t))))
3514 (defun gnus-group-clear-dribble ()
3515 "Clear all information from the dribble buffer."
3517 (gnus-dribble-clear)
3518 (gnus-message 7 "Cleared dribble buffer"))
3520 (defun gnus-group-exit ()
3521 "Quit reading news after updating .newsrc.eld and .newsrc.
3522 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3525 (or noninteractive ;For gnus-batch-kill
3526 (not gnus-interactive-exit) ;Without confirmation
3528 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3529 (gnus-run-hooks 'gnus-exit-gnus-hook)
3530 ;; Offer to save data from non-quitted summary buffers.
3531 (gnus-offer-save-summaries)
3532 ;; Save the newsrc file(s).
3533 (gnus-save-newsrc-file)
3535 (gnus-close-backends)
3536 ;; Reset everything.
3538 ;; Allow the user to do things after cleaning up.
3539 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3541 (defun gnus-group-quit ()
3542 "Quit reading news without updating .newsrc.eld or .newsrc.
3543 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3545 (when (or noninteractive ;For gnus-batch-kill
3546 (zerop (buffer-size))
3547 (not (gnus-server-opened gnus-select-method))
3549 (not gnus-current-startup-file)
3551 (format "Quit reading news without saving %s? "
3552 (file-name-nondirectory gnus-current-startup-file))))
3553 (gnus-run-hooks 'gnus-exit-gnus-hook)
3554 (gnus-configure-windows 'group t)
3556 (gnus-close-backends)
3558 (gnus-kill-buffer gnus-group-buffer)
3559 ;; Allow the user to do things after cleaning up.
3560 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3562 (defun gnus-group-describe-briefly ()
3563 "Give a one line description of the group mode commands."
3565 (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")))
3567 (defun gnus-group-browse-foreign-server (method)
3568 "Browse a foreign news server.
3569 If called interactively, this function will ask for a select method
3570 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3571 If not, METHOD should be a list where the first element is the method
3572 and the second element is the address."
3574 (list (let ((how (completing-read
3576 (append gnus-valid-select-methods gnus-server-alist)
3577 nil t (cons "nntp" 0) 'gnus-method-history)))
3578 ;; We either got a backend name or a virtual server name.
3579 ;; If the first, we also need an address.
3580 (if (assoc how gnus-valid-select-methods)
3582 ;; Suggested by mapjph@bath.ac.uk.
3585 (mapcar (lambda (server) (list server))
3586 gnus-secondary-servers)))
3587 ;; We got a server name.
3589 (gnus-browse-foreign-server method))
3591 (defun gnus-group-set-info (info &optional method-only-group part)
3592 (when (or info part)
3593 (let* ((entry (gnus-gethash
3594 (or method-only-group (gnus-info-group info))
3595 gnus-newsrc-hashtb))
3597 (info (if method-only-group (nth 2 entry) info))
3599 (when method-only-group
3601 (error "Trying to change non-existent group %s" method-only-group))
3602 ;; We have received parts of the actual group info - either the
3603 ;; select method or the group parameters. We first check
3604 ;; whether we have to extend the info, and if so, do that.
3605 (let ((len (length info))
3606 (total (if (eq part 'method) 5 6)))
3608 (setcdr (nthcdr (1- len) info)
3609 (make-list (- total len) nil)))
3610 ;; Then we enter the new info.
3611 (setcar (nthcdr (1- total) info) part-info)))
3613 ;; This is a new group, so we just create it.
3615 (set-buffer gnus-group-buffer)
3616 (setq method (gnus-info-method info))
3617 (when (gnus-server-equal method "native")
3620 (set-buffer gnus-group-buffer)
3622 ;; It's a foreign group...
3623 (gnus-group-make-group
3624 (gnus-group-real-name (gnus-info-group info))
3625 (if (stringp method) method
3626 (prin1-to-string (car method)))
3628 (nth 1 (gnus-info-method info))))
3629 ;; It's a native group.
3630 (gnus-group-make-group (gnus-info-group info))))
3631 (gnus-message 6 "Note: New group created")
3633 (gnus-gethash (gnus-group-prefixed-name
3634 (gnus-group-real-name (gnus-info-group info))
3635 (or (gnus-info-method info) gnus-select-method))
3636 gnus-newsrc-hashtb))))
3637 ;; Whether it was a new group or not, we now have the entry, so we
3638 ;; can do the update.
3641 (setcar (nthcdr 2 entry) info)
3642 (when (and (not (eq (car entry) t))
3643 (gnus-active (gnus-info-group info)))
3644 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3645 (error "No such group: %s" (gnus-info-group info))))))
3647 (defun gnus-group-set-method-info (group select-method)
3648 (gnus-group-set-info select-method group 'method))
3650 (defun gnus-group-set-params-info (group params)
3651 (gnus-group-set-info params group 'params))
3653 (defun gnus-add-marked-articles (group type articles &optional info force)
3654 ;; Add ARTICLES of TYPE to the info of GROUP.
3655 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3656 ;; add, but replace marked articles of TYPE with ARTICLES.
3657 (let ((info (or info (gnus-get-info group)))
3660 (and (not (setq marked (nthcdr 3 info)))
3662 (setcdr (nthcdr 2 info)
3663 (list (list (cons type (gnus-compress-sequence
3665 (and (not (setq m (assq type (car marked))))
3668 (cons (cons type (gnus-compress-sequence articles t) )
3672 (setcar (nthcdr 3 info)
3673 (gnus-delete-alist type (car marked)))
3674 (setcdr m (gnus-compress-sequence articles t)))
3675 (setcdr m (gnus-compress-sequence
3676 (sort (nconc (gnus-uncompress-range (cdr m))
3677 (copy-sequence articles)) '<) t))))))
3680 ;;; Group timestamps
3683 (defun gnus-group-set-timestamp ()
3684 "Change the timestamp of the current group to the current time.
3685 This function can be used in hooks like `gnus-select-group-hook'
3686 or `gnus-group-catchup-group-hook'."
3687 (when gnus-newsgroup-name
3688 (let ((time (current-time)))
3689 (setcdr (cdr time) nil)
3690 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3692 (defsubst gnus-group-timestamp (group)
3693 "Return the timestamp for GROUP."
3694 (gnus-group-get-parameter group 'timestamp t))
3696 (defun gnus-group-timestamp-delta (group)
3697 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3698 (let* ((time (or (gnus-group-timestamp group)
3700 (delta (subtract-time (current-time) time)))
3701 (+ (* (nth 0 delta) 65536.0)
3704 (defun gnus-group-timestamp-string (group)
3705 "Return a string of the timestamp for GROUP."
3706 (let ((time (gnus-group-timestamp group)))
3709 (gnus-time-iso8601 time))))
3711 (defun gnus-group-prepare-flat-list-dead-predicate
3712 (groups level mark predicate)
3715 ;; This loop is used when listing groups that match some
3717 (while (setq group (pop groups))
3718 (when (funcall predicate group)
3719 (gnus-add-text-properties
3720 (point) (prog1 (1+ (point))
3721 (insert " " mark " *: "
3722 (gnus-group-name-decode group
3723 (gnus-group-name-charset
3726 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3728 'gnus-level level)))))))
3730 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest
3732 "List all newsgroups with unread articles of level LEVEL or lower.
3733 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3734 If PREDICATE, only list groups which PREDICATE returns non-nil.
3735 If DEAD-PREDICATE, list dead groups which DEAD-PREDICATE returns non-nil."
3736 (set-buffer gnus-group-buffer)
3737 (let ((buffer-read-only nil)
3738 (newsrc (cdr gnus-newsrc-alist))
3739 (lowest (or lowest 1))
3740 info clevel unread group params)
3742 ;; List living groups.
3744 (setq info (car newsrc)
3745 group (gnus-info-group info)
3746 params (gnus-info-params info)
3748 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3749 (and unread ; This group might be unchecked
3750 (funcall predicate info)
3751 (<= (setq clevel (gnus-info-level info)) level)
3753 (gnus-group-insert-group-line
3754 group (gnus-info-level info)
3755 (gnus-info-marks info) unread (gnus-info-method info))))
3757 ;; List dead groups.
3758 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3759 (gnus-group-prepare-flat-list-dead-predicate
3760 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3761 gnus-level-zombie ?Z
3763 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3764 (gnus-group-prepare-flat-list-dead-predicate
3765 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3766 gnus-level-killed ?K dead-predicate))
3768 (gnus-group-set-mode-line)
3769 (setq gnus-group-list-mode (cons level t))
3770 (gnus-run-hooks 'gnus-group-prepare-hook)
3773 (defun gnus-group-list-cached (level &optional lowest)
3774 "List all groups with cached articles.
3775 If the prefix LEVEL is non-nil, it should be a number that says which
3776 level to cut off listing groups.
3777 If LOWEST, don't list groups with level lower than LOWEST.
3779 This command may read the active file."
3782 (setq level (prefix-numeric-value level)))
3783 (when (or (not level) (>= level gnus-level-zombie))
3785 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3787 (let ((marks (gnus-info-marks info)))
3788 (assq 'cache marks)))
3791 (or (gnus-gethash group
3792 gnus-cache-active-hashtb)
3793 ;; Cache active file might use "."
3796 (mapconcat 'identity
3797 (split-string group ":")
3799 gnus-cache-active-hashtb))))
3800 (goto-char (point-min))
3801 (gnus-group-position-point))
3803 (defun gnus-group-list-dormant (level &optional lowest)
3804 "List all groups with dormant articles.
3805 If the prefix LEVEL is non-nil, it should be a number that says which
3806 level to cut off listing groups.
3807 If LOWEST, don't list groups with level lower than LOWEST.
3809 This command may read the active file."
3812 (setq level (prefix-numeric-value level)))
3813 (when (or (not level) (>= level gnus-level-zombie))
3815 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3817 (let ((marks (gnus-info-marks info)))
3818 (assq 'dormant marks)))
3820 (goto-char (point-min))
3821 (gnus-group-position-point))
3823 (provide 'gnus-group)
3825 ;;; gnus-group.el ends here