1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (defcustom gnus-group-archive-directory
42 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
43 "*The address of the (ding) archives."
44 :group 'gnus-group-foreign
47 (defcustom gnus-group-recent-archive-directory
48 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
49 "*The address of the most recent (ding) articles."
50 :group 'gnus-group-foreign
53 (defcustom gnus-no-groups-message "No gnus is bad news"
54 "*Message displayed by Gnus when no groups are available."
58 (defcustom gnus-keep-same-level nil
59 "*Non-nil means that the next newsgroup after the current will be on the same level.
60 When you type, for instance, `n' after reading the last article in the
61 current newsgroup, you will go to the next newsgroup. If this variable
62 is nil, the next newsgroup will be the next from the group
64 If this variable is non-nil, Gnus will either put you in the
65 next newsgroup with the same level, or, if no such newsgroup is
66 available, the next newsgroup with the lowest possible level higher
67 than the current level.
68 If this variable is `best', Gnus will make the next newsgroup the one
70 :group 'gnus-group-levels
71 :type '(choice (const nil)
73 (sexp :tag "other" t)))
75 (defcustom gnus-group-goto-unread t
76 "*If non-nil, movement commands will go to the next unread and subscribed group."
77 :link '(custom-manual "(gnus)Group Maneuvering")
78 :group 'gnus-group-various
81 (defcustom gnus-goto-next-group-when-activating t
82 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
83 :link '(custom-manual "(gnus)Scanning New Messages")
84 :group 'gnus-group-various
87 (defcustom gnus-permanently-visible-groups nil
88 "*Regexp to match groups that should always be listed in the group buffer.
89 This means that they will still be listed even when there are no
90 unread articles in the groups.
92 If nil, no groups are permanently visible."
93 :group 'gnus-group-listing
94 :type '(choice regexp (const nil)))
96 (defcustom gnus-list-groups-with-ticked-articles t
97 "*If non-nil, list groups that have only ticked articles.
98 If nil, only list groups that have unread articles."
99 :group 'gnus-group-listing
102 (defcustom gnus-group-default-list-level gnus-level-subscribed
103 "*Default listing level.
104 Ignored if `gnus-group-use-permanent-levels' is non-nil."
105 :group 'gnus-group-listing
108 (defcustom gnus-group-list-inactive-groups t
109 "*If non-nil, inactive groups will be listed."
110 :group 'gnus-group-listing
111 :group 'gnus-group-levels
114 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
115 "*Function used for sorting the group buffer.
116 This function will be called with group info entries as the arguments
117 for the groups to be sorted. Pre-made functions include
118 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
119 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
120 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
121 `gnus-group-sort-by-rank'.
123 This variable can also be a list of sorting functions. In that case,
124 the most significant sort function should be the last function in the
126 :group 'gnus-group-listing
127 :link '(custom-manual "(gnus)Sorting Groups")
128 :type '(radio (function-item gnus-group-sort-by-alphabet)
129 (function-item gnus-group-sort-by-real-name)
130 (function-item gnus-group-sort-by-unread)
131 (function-item gnus-group-sort-by-level)
132 (function-item gnus-group-sort-by-score)
133 (function-item gnus-group-sort-by-method)
134 (function-item gnus-group-sort-by-rank)
135 (function :tag "other" nil)))
137 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
138 "*Format of group lines.
139 It works along the same lines as a normal formatting string,
140 with some simple extensions.
142 %M Only marked articles (character, \"*\" or \" \")
143 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
144 %L Level of subscribedness (integer)
145 %N Number of unread articles (integer)
146 %I Number of dormant articles (integer)
147 %i Number of ticked and dormant (integer)
148 %T Number of ticked articles (integer)
149 %R Number of read articles (integer)
150 %t Estimated total number of articles (integer)
151 %y Number of unread, unticked articles (integer)
152 %G Group name (string)
153 %g Qualified group name (string)
154 %D Group description (string)
155 %s Select method (string)
156 %o Moderated group (char, \"m\")
157 %p Process mark (char)
158 %O Moderated group (string, \"(m)\" or \"\")
159 %P Topic indentation (string)
160 %m Whether there is new(ish) mail in the group (char, \"%\")
161 %l Whether there are GroupLens predictions for this group (string)
162 %n Select from where (string)
163 %z A string that look like `<%s:%n>' if a foreign select method is used
164 %d The date the group was last entered.
165 %E Icon as defined by `gnus-group-icon-list'.
166 %u User defined specifier. The next character in the format string should
167 be a letter. Gnus will call the function gnus-user-format-function-X,
168 where X is the letter following %u. The function will be passed the
169 current header as argument. The function should return a string, which
170 will be inserted into the buffer just like information from any other
173 Text between %( and %) will be highlighted with `gnus-mouse-face' when
174 the mouse point move inside the area. There can only be one such area.
176 Note that this format specification is not always respected. For
177 reasons of efficiency, when listing killed groups, this specification
178 is ignored altogether. If the spec is changed considerably, your
179 output may end up looking strange when listing both alive and killed
182 If you use %o or %O, reading the active file will be slower and quite
183 a bit of extra memory will be used. %D will also worsen performance.
184 Also note that if you change the format specification to include any
185 of these specs, you must probably re-start Gnus to see them go into
187 :group 'gnus-group-visual
190 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
191 "*The format specification for the group mode line.
192 It works along the same lines as a normal formatting string,
193 with some simple extensions:
195 %S The native news server.
196 %M The native select method.
197 %: \":\" if %S isn't \"\"."
198 :group 'gnus-group-visual
201 (defcustom gnus-group-mode-hook nil
202 "Hook for Gnus group mode."
203 :group 'gnus-group-various
204 :options '(gnus-topic-mode)
207 (defcustom gnus-group-menu-hook nil
208 "Hook run after the creation of the group mode menu."
209 :group 'gnus-group-various
212 (defcustom gnus-group-catchup-group-hook nil
213 "Hook run when catching up a group from the group buffer."
214 :group 'gnus-group-various
215 :link '(custom-manual "(gnus)Group Data")
218 (defcustom gnus-group-update-group-hook nil
219 "Hook called when updating group lines."
220 :group 'gnus-group-visual
223 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
224 "*A function that is called to generate the group buffer.
225 The function is called with three arguments: The first is a number;
226 all group with a level less or equal to that number should be listed,
227 if the second is non-nil, empty groups should also be displayed. If
228 the third is non-nil, it is a number. No groups with a level lower
229 than this number should be displayed.
231 The only current function implemented is `gnus-group-prepare-flat'."
232 :group 'gnus-group-listing
235 (defcustom gnus-group-prepare-hook nil
236 "Hook called after the group buffer has been generated.
237 If you want to modify the group buffer, you can use this hook."
238 :group 'gnus-group-listing
241 (defcustom gnus-suspend-gnus-hook nil
242 "Hook called when suspending (not exiting) Gnus."
246 (defcustom gnus-exit-gnus-hook nil
247 "Hook called when exiting Gnus."
251 (defcustom gnus-after-exiting-gnus-hook nil
252 "Hook called after exiting Gnus."
256 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
257 "Hook called when a group line is changed.
258 The hook will not be called if `gnus-visual' is nil.
260 The default function `gnus-group-highlight-line' will
261 highlight the line according to the `gnus-group-highlight'
263 :group 'gnus-group-visual
266 (defcustom gnus-useful-groups
267 '(("(ding) mailing list mirrored at sunsite.auc.dk"
269 (nntp "sunsite.auc.dk"
270 (nntp-address "sunsite.auc.dk")))
273 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
277 (nndoc-article-type mbox)
278 (eval `(nndoc-address
279 ,(let ((file (nnheader-find-etc-directory
282 (error "Couldn't find doc group"))
284 "*Alist of useful group-server pairs."
285 :group 'gnus-group-listing
286 :type '(repeat (list (string :tag "Description")
288 (sexp :tag "Method"))))
290 (defcustom gnus-group-highlight
292 ((and (= unread 0) (not mailp) (eq level 1)) .
293 gnus-group-news-1-empty-face)
294 ((and (not mailp) (eq level 1)) .
295 gnus-group-news-1-face)
296 ((and (= unread 0) (not mailp) (eq level 2)) .
297 gnus-group-news-2-empty-face)
298 ((and (not mailp) (eq level 2)) .
299 gnus-group-news-2-face)
300 ((and (= unread 0) (not mailp) (eq level 3)) .
301 gnus-group-news-3-empty-face)
302 ((and (not mailp) (eq level 3)) .
303 gnus-group-news-3-face)
304 ((and (= unread 0) (not mailp) (eq level 4)) .
305 gnus-group-news-4-empty-face)
306 ((and (not mailp) (eq level 4)) .
307 gnus-group-news-4-face)
308 ((and (= unread 0) (not mailp) (eq level 5)) .
309 gnus-group-news-5-empty-face)
310 ((and (not mailp) (eq level 5)) .
311 gnus-group-news-5-face)
312 ((and (= unread 0) (not mailp) (eq level 6)) .
313 gnus-group-news-6-empty-face)
314 ((and (not mailp) (eq level 6)) .
315 gnus-group-news-6-face)
316 ((and (= unread 0) (not mailp)) .
317 gnus-group-news-low-empty-face)
319 gnus-group-news-low-face)
321 ((and (= unread 0) (eq level 1)) .
322 gnus-group-mail-1-empty-face)
324 gnus-group-mail-1-face)
325 ((and (= unread 0) (eq level 2)) .
326 gnus-group-mail-2-empty-face)
328 gnus-group-mail-2-face)
329 ((and (= unread 0) (eq level 3)) .
330 gnus-group-mail-3-empty-face)
332 gnus-group-mail-3-face)
334 gnus-group-mail-low-empty-face)
336 gnus-group-mail-low-face))
337 "*Controls the highlighting of group buffer lines.
339 Below is a list of `Form'/`Face' pairs. When deciding how a a
340 particular group line should be displayed, each form is
341 evaluated. The content of the face field after the first true form is
342 used. You can change how those group lines are displayed by
343 editing the face field.
345 It is also possible to change and add form fields, but currently that
346 requires an understanding of Lisp expressions. Hopefully this will
347 change in a future release. For now, you can use the following
348 variables in the Lisp expression:
350 group: The name of the group.
351 unread: The number of unread articles in the group.
352 method: The select method used.
353 mailp: Whether it's a mail group or not.
354 level: The level of the group.
355 score: The score of the group.
356 ticked: The number of ticked articles."
357 :group 'gnus-group-visual
358 :type '(repeat (cons (sexp :tag "Form") face)))
360 (defcustom gnus-new-mail-mark ?%
361 "Mark used for groups with new mail."
362 :group 'gnus-group-visual
365 (defgroup gnus-group-icons nil
366 "Add Icons to your group buffer. "
367 :group 'gnus-group-visual)
369 (defcustom gnus-group-icon-list
371 "*Controls the insertion of icons into group buffer lines.
373 Below is a list of `Form'/`File' pairs. When deciding how a
374 particular group line should be displayed, each form is evaluated.
375 The icon from the file field after the first true form is used. You
376 can change how those group lines are displayed by editing the file
377 field. The File will either be found in the
378 `gnus-group-glyph-directory' or by designating absolute path to the
381 It is also possible to change and add form fields, but currently that
382 requires an understanding of Lisp expressions. Hopefully this will
383 change in a future release. For now, you can use the following
384 variables in the Lisp expression:
386 group: The name of the group.
387 unread: The number of unread articles in the group.
388 method: The select method used.
389 mailp: Whether it's a mail group or not.
390 newsp: Whether it's a news group or not
391 level: The level of the group.
392 score: The score of the group.
393 ticked: The number of ticked articles."
394 :group 'gnus-group-icons
395 :type '(repeat (cons (sexp :tag "Form") file)))
397 (defcustom gnus-group-name-charset-method-alist nil
398 "*Alist of method and the charset for group names.
401 (((nntp \"news.com.cn\") . cn-gb-2312))
404 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
406 (defcustom gnus-group-name-charset-group-alist nil
407 "*Alist of group regexp and the charset for group names.
410 ((\"\\.com\\.cn:\" . cn-gb-2312))
413 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
415 ;;; Internal variables
417 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
418 "Function for sorting the group buffer.")
420 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
421 "Function for sorting the selected groups in the group buffer.")
423 (defvar gnus-group-indentation-function nil)
424 (defvar gnus-goto-missing-group-function nil)
425 (defvar gnus-group-update-group-function nil)
426 (defvar gnus-group-goto-next-group-function nil
427 "Function to override finding the next group after listing groups.")
429 (defvar gnus-group-edit-buffer nil)
431 (defvar gnus-group-line-format-alist
432 `((?M gnus-tmp-marked-mark ?c)
433 (?S gnus-tmp-subscribed ?c)
434 (?L gnus-tmp-level ?d)
435 (?N (cond ((eq number t) "*" )
439 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
440 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
442 (?R gnus-tmp-number-of-read ?s)
443 (?t gnus-tmp-number-total ?d)
444 (?y gnus-tmp-number-of-unread ?s)
445 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
446 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
447 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
448 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
449 (?g gnus-tmp-group ?s)
450 (?G gnus-tmp-qualified-group ?s)
451 (?c (gnus-short-group-name gnus-tmp-group) ?s)
452 (?D gnus-tmp-newsgroup-description ?s)
453 (?o gnus-tmp-moderated ?c)
454 (?O gnus-tmp-moderated-string ?s)
455 (?p gnus-tmp-process-marked ?c)
456 (?s gnus-tmp-news-server ?s)
457 (?n gnus-tmp-news-method ?s)
458 (?P gnus-group-indentation ?s)
459 (?E gnus-tmp-group-icon ?s)
460 (?l gnus-tmp-grouplens ?s)
461 (?z gnus-tmp-news-method-string ?s)
462 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
463 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
464 (?u gnus-tmp-user-defined ?s)))
466 (defvar gnus-group-mode-line-format-alist
467 `((?S gnus-tmp-news-server ?s)
468 (?M gnus-tmp-news-method ?s)
469 (?u gnus-tmp-user-defined ?s)
470 (?: gnus-tmp-colon ?s)))
472 (defvar gnus-topic-topology nil
473 "The complete topic hierarchy.")
475 (defvar gnus-topic-alist nil
476 "The complete topic-group alist.")
478 (defvar gnus-group-marked nil)
480 (defvar gnus-group-list-mode nil)
483 (defvar gnus-group-icon-cache nil)
484 (defvar gnus-group-running-xemacs (string-match "XEmacs" emacs-version))
490 (put 'gnus-group-mode 'mode-class 'special)
493 (gnus-define-keys gnus-group-mode-map
494 " " gnus-group-read-group
495 "=" gnus-group-select-group
496 "\r" gnus-group-select-group
497 "\M-\r" gnus-group-quick-select-group
498 "\M- " gnus-group-visible-select-group
499 [(meta control return)] gnus-group-select-group-ephemerally
500 "j" gnus-group-jump-to-group
501 "n" gnus-group-next-unread-group
502 "p" gnus-group-prev-unread-group
503 "\177" gnus-group-prev-unread-group
504 [delete] gnus-group-prev-unread-group
505 [backspace] gnus-group-prev-unread-group
506 "N" gnus-group-next-group
507 "P" gnus-group-prev-group
508 "\M-n" gnus-group-next-unread-group-same-level
509 "\M-p" gnus-group-prev-unread-group-same-level
510 "," gnus-group-best-unread-group
511 "." gnus-group-first-unread-group
512 "u" gnus-group-unsubscribe-current-group
513 "U" gnus-group-unsubscribe-group
514 "c" gnus-group-catchup-current
515 "C" gnus-group-catchup-current-all
516 "\M-c" gnus-group-clear-data
517 "l" gnus-group-list-groups
518 "L" gnus-group-list-all-groups
520 "g" gnus-group-get-new-news
521 "\M-g" gnus-group-get-new-news-this-group
522 "R" gnus-group-restart
523 "r" gnus-group-read-init-file
524 "B" gnus-group-browse-foreign-server
525 "b" gnus-group-check-bogus-groups
526 "F" gnus-group-find-new-groups
527 "\C-c\C-d" gnus-group-describe-group
528 "\M-d" gnus-group-describe-all-groups
529 "\C-c\C-a" gnus-group-apropos
530 "\C-c\M-\C-a" gnus-group-description-apropos
531 "a" gnus-group-post-news
532 "\ek" gnus-group-edit-local-kill
533 "\eK" gnus-group-edit-global-kill
534 "\C-k" gnus-group-kill-group
535 "\C-y" gnus-group-yank-group
536 "\C-w" gnus-group-kill-region
537 "\C-x\C-t" gnus-group-transpose-groups
538 "\C-c\C-l" gnus-group-list-killed
539 "\C-c\C-x" gnus-group-expire-articles
540 "\C-c\M-\C-x" gnus-group-expire-all-groups
542 "s" gnus-group-save-newsrc
543 "z" gnus-group-suspend
546 "?" gnus-group-describe-briefly
547 "\C-c\C-i" gnus-info-find-node
548 "\M-e" gnus-group-edit-group-method
549 "^" gnus-group-enter-server-mode
550 gnus-mouse-2 gnus-mouse-pick-group
551 "<" beginning-of-buffer
554 "\C-c\C-s" gnus-group-sort-groups
556 "\C-c\M-g" gnus-activate-all-groups
557 "\M-&" gnus-group-universal-argument
558 "#" gnus-group-mark-group
559 "\M-#" gnus-group-unmark-group)
561 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
562 "m" gnus-group-mark-group
563 "u" gnus-group-unmark-group
564 "w" gnus-group-mark-region
565 "b" gnus-group-mark-buffer
566 "r" gnus-group-mark-regexp
567 "U" gnus-group-unmark-all-groups)
569 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
570 "d" gnus-group-make-directory-group
571 "h" gnus-group-make-help-group
572 "u" gnus-group-make-useful-group
573 "a" gnus-group-make-archive-group
574 "k" gnus-group-make-kiboze-group
575 "l" gnus-group-nnimap-edit-acl
576 "m" gnus-group-make-group
577 "E" gnus-group-edit-group
578 "e" gnus-group-edit-group-method
579 "p" gnus-group-edit-group-parameters
580 "v" gnus-group-add-to-virtual
581 "V" gnus-group-make-empty-virtual
582 "D" gnus-group-enter-directory
583 "f" gnus-group-make-doc-group
584 "w" gnus-group-make-web-group
585 "r" gnus-group-rename-group
586 "c" gnus-group-customize
587 "x" gnus-group-nnimap-expunge
588 "\177" gnus-group-delete-group
589 [delete] gnus-group-delete-group)
591 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
592 "b" gnus-group-brew-soup
593 "w" gnus-soup-save-areas
594 "s" gnus-soup-send-replies
595 "p" gnus-soup-pack-packet
596 "r" nnsoup-pack-replies)
598 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
599 "s" gnus-group-sort-groups
600 "a" gnus-group-sort-groups-by-alphabet
601 "u" gnus-group-sort-groups-by-unread
602 "l" gnus-group-sort-groups-by-level
603 "v" gnus-group-sort-groups-by-score
604 "r" gnus-group-sort-groups-by-rank
605 "m" gnus-group-sort-groups-by-method)
607 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
608 "s" gnus-group-sort-selected-groups
609 "a" gnus-group-sort-selected-groups-by-alphabet
610 "u" gnus-group-sort-selected-groups-by-unread
611 "l" gnus-group-sort-selected-groups-by-level
612 "v" gnus-group-sort-selected-groups-by-score
613 "r" gnus-group-sort-selected-groups-by-rank
614 "m" gnus-group-sort-selected-groups-by-method)
616 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
617 "k" gnus-group-list-killed
618 "z" gnus-group-list-zombies
619 "s" gnus-group-list-groups
620 "u" gnus-group-list-all-groups
621 "A" gnus-group-list-active
622 "a" gnus-group-apropos
623 "d" gnus-group-description-apropos
624 "m" gnus-group-list-matching
625 "M" gnus-group-list-all-matching
626 "l" gnus-group-list-level
627 "c" gnus-group-list-cached
628 "?" gnus-group-list-dormant)
630 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
631 "f" gnus-score-flush-cache)
633 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
634 "d" gnus-group-describe-group
635 "f" gnus-group-fetch-faq
638 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
639 "l" gnus-group-set-current-level
640 "t" gnus-group-unsubscribe-current-group
641 "s" gnus-group-unsubscribe-group
642 "k" gnus-group-kill-group
643 "y" gnus-group-yank-group
644 "w" gnus-group-kill-region
645 "\C-k" gnus-group-kill-level
646 "z" gnus-group-kill-all-zombies))
648 (defun gnus-group-make-menu-bar ()
649 (gnus-turn-off-edit-menu 'group)
650 (unless (boundp 'gnus-group-reading-menu)
653 gnus-group-reading-menu gnus-group-mode-map ""
655 ["Read" gnus-group-read-group (gnus-group-group-name)]
656 ["Select" gnus-group-select-group (gnus-group-group-name)]
657 ["See old articles" (gnus-group-select-group 'all)
658 :keys "C-u SPC" :active (gnus-group-group-name)]
659 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
660 ["Catch up all articles" gnus-group-catchup-current-all
661 (gnus-group-group-name)]
662 ["Check for new articles" gnus-group-get-new-news-this-group
663 (gnus-group-group-name)]
664 ["Toggle subscription" gnus-group-unsubscribe-current-group
665 (gnus-group-group-name)]
666 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
667 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
668 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
669 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
670 ;; Actually one should check, if any of the marked groups gives t for
671 ;; (gnus-check-backend-function 'request-expire-articles ...)
672 ["Expire articles" gnus-group-expire-articles
673 (or (and (gnus-group-group-name)
674 (gnus-check-backend-function
675 'request-expire-articles
676 (gnus-group-group-name))) gnus-group-marked)]
677 ["Set group level" gnus-group-set-current-level
678 (gnus-group-group-name)]
679 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
680 ["Customize" gnus-group-customize (gnus-group-group-name)]
682 ["Parameters" gnus-group-edit-group-parameters
683 (gnus-group-group-name)]
684 ["Select method" gnus-group-edit-group-method
685 (gnus-group-group-name)]
686 ["Info" gnus-group-edit-group (gnus-group-group-name)]
687 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
688 ["Global kill file" gnus-group-edit-global-kill t])))
691 gnus-group-group-menu gnus-group-mode-map ""
694 ["List unread subscribed groups" gnus-group-list-groups t]
695 ["List (un)subscribed groups" gnus-group-list-all-groups t]
696 ["List killed groups" gnus-group-list-killed gnus-killed-list]
697 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
698 ["List level..." gnus-group-list-level t]
699 ["Describe all groups" gnus-group-describe-all-groups t]
700 ["Group apropos..." gnus-group-apropos t]
701 ["Group and description apropos..." gnus-group-description-apropos t]
702 ["List groups matching..." gnus-group-list-matching t]
703 ["List all groups matching..." gnus-group-list-all-matching t]
704 ["List active file" gnus-group-list-active t]
705 ["List groups with cached" gnus-group-list-cached t]
706 ["List groups with dormant" gnus-group-list-dormant t])
708 ["Default sort" gnus-group-sort-groups t]
709 ["Sort by method" gnus-group-sort-groups-by-method t]
710 ["Sort by rank" gnus-group-sort-groups-by-rank t]
711 ["Sort by score" gnus-group-sort-groups-by-score t]
712 ["Sort by level" gnus-group-sort-groups-by-level t]
713 ["Sort by unread" gnus-group-sort-groups-by-unread t]
714 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
715 ("Sort process/prefixed"
716 ["Default sort" gnus-group-sort-selected-groups
717 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
718 ["Sort by method" gnus-group-sort-selected-groups-by-method
719 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
720 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
721 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
722 ["Sort by score" gnus-group-sort-selected-groups-by-score
723 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
724 ["Sort by level" gnus-group-sort-selected-groups-by-level
725 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
726 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
727 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
728 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
729 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
731 ["Mark group" gnus-group-mark-group
732 (and (gnus-group-group-name)
733 (not (memq (gnus-group-group-name) gnus-group-marked)))]
734 ["Unmark group" gnus-group-unmark-group
735 (and (gnus-group-group-name)
736 (memq (gnus-group-group-name) gnus-group-marked))]
737 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
738 ["Mark regexp..." gnus-group-mark-regexp t]
739 ["Mark region" gnus-group-mark-region t]
740 ["Mark buffer" gnus-group-mark-buffer t]
741 ["Execute command" gnus-group-universal-argument
742 (or gnus-group-marked (gnus-group-group-name))])
744 ["Subscribe to a group" gnus-group-unsubscribe-group t]
745 ["Kill all newsgroups in region" gnus-group-kill-region t]
746 ["Kill all zombie groups" gnus-group-kill-all-zombies
748 ["Kill all groups on level..." gnus-group-kill-level t])
750 ["Make a foreign group" gnus-group-make-group t]
751 ["Add a directory group" gnus-group-make-directory-group t]
752 ["Add the help group" gnus-group-make-help-group t]
753 ["Add the archive group" gnus-group-make-archive-group t]
754 ["Make a doc group" gnus-group-make-doc-group t]
755 ["Make a web group" gnus-group-make-web-group t]
756 ["Make a kiboze group" gnus-group-make-kiboze-group t]
757 ["Make a virtual group" gnus-group-make-empty-virtual t]
758 ["Add a group to a virtual" gnus-group-add-to-virtual t]
759 ["Rename group" gnus-group-rename-group
760 (gnus-check-backend-function
761 'request-rename-group (gnus-group-group-name))]
762 ["Delete group" gnus-group-delete-group
763 (gnus-check-backend-function
764 'request-delete-group (gnus-group-group-name))])
766 ["Next" gnus-group-next-group t]
767 ["Previous" gnus-group-prev-group t]
768 ["Next unread" gnus-group-next-unread-group t]
769 ["Previous unread" gnus-group-prev-unread-group t]
770 ["Next unread same level" gnus-group-next-unread-group-same-level t]
771 ["Previous unread same level"
772 gnus-group-prev-unread-group-same-level t]
773 ["Jump to group" gnus-group-jump-to-group t]
774 ["First unread group" gnus-group-first-unread-group t]
775 ["Best unread group" gnus-group-best-unread-group t])
776 ["Delete bogus groups" gnus-group-check-bogus-groups t]
777 ["Find new newsgroups" gnus-group-find-new-groups t]
778 ["Transpose" gnus-group-transpose-groups
779 (gnus-group-group-name)]
780 ["Read a directory as a group..." gnus-group-enter-directory t]))
783 gnus-group-misc-menu gnus-group-mode-map ""
786 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
787 ["Send replies" gnus-soup-send-replies
788 (fboundp 'gnus-soup-pack-packet)]
789 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
790 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
791 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
792 ["Send a mail" gnus-group-mail t]
793 ["Post an article..." gnus-group-post-news t]
794 ["Check for new news" gnus-group-get-new-news t]
795 ["Activate all groups" gnus-activate-all-groups t]
796 ["Restart Gnus" gnus-group-restart t]
797 ["Read init file" gnus-group-read-init-file t]
798 ["Browse foreign server" gnus-group-browse-foreign-server t]
799 ["Enter server buffer" gnus-group-enter-server-mode t]
800 ["Expire all expirable articles" gnus-group-expire-all-groups t]
801 ["Generate any kiboze groups" nnkiboze-generate-groups t]
802 ["Gnus version" gnus-version t]
803 ["Save .newsrc files" gnus-group-save-newsrc t]
804 ["Suspend Gnus" gnus-group-suspend t]
805 ["Clear dribble buffer" gnus-group-clear-dribble t]
806 ["Read manual" gnus-info-find-node t]
807 ["Flush score cache" gnus-score-flush-cache t]
808 ["Toggle topics" gnus-topic-mode t]
809 ["Send a bug report" gnus-bug t]
810 ["Exit from Gnus" gnus-group-exit t]
811 ["Exit without saving" gnus-group-quit t]))
813 (gnus-run-hooks 'gnus-group-menu-hook)))
815 (defun gnus-group-mode ()
816 "Major mode for reading news.
818 All normal editing commands are switched off.
819 \\<gnus-group-mode-map>
820 The group buffer lists (some of) the groups available. For instance,
821 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
822 lists all zombie groups.
824 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
825 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
827 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
829 The following commands are available:
831 \\{gnus-group-mode-map}"
833 (when (gnus-visual-p 'group-menu 'menu)
834 (gnus-group-make-menu-bar))
835 (kill-all-local-variables)
836 (gnus-simplify-mode-line)
837 (setq major-mode 'gnus-group-mode)
838 (setq mode-name "Group")
839 (gnus-group-set-mode-line)
840 (setq mode-line-process nil)
841 (use-local-map gnus-group-mode-map)
842 (buffer-disable-undo)
843 (setq truncate-lines t)
844 (setq buffer-read-only t)
845 (gnus-set-default-directory)
846 (gnus-update-format-specifications nil 'group 'group-mode)
847 (gnus-update-group-mark-positions)
852 (gnus-run-hooks 'gnus-group-mode-hook))
854 (defun gnus-update-group-mark-positions ()
856 (let ((gnus-process-mark ?\200)
857 (gnus-group-marked '("dummy.group"))
858 (gnus-active-hashtb (make-vector 10 0))
860 (gnus-set-active "dummy.group" '(0 . 0))
861 (gnus-set-work-buffer)
862 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
863 (goto-char (point-min))
864 (setq gnus-group-mark-positions
865 (list (cons 'process (and (search-forward "\200" nil t)
868 (defun gnus-mouse-pick-group (e)
869 "Enter the group under the mouse pointer."
872 (gnus-group-read-group nil))
874 ;; Look at LEVEL and find out what the level is really supposed to be.
875 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
876 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
877 (defun gnus-group-default-level (&optional level number-or-nil)
879 (gnus-group-use-permanent-levels
880 (or (setq gnus-group-use-permanent-levels
881 (or level (if (numberp gnus-group-use-permanent-levels)
882 gnus-group-use-permanent-levels
883 (or gnus-group-default-list-level
884 gnus-level-subscribed))))
885 gnus-group-default-list-level gnus-level-subscribed))
889 (or level gnus-group-default-list-level gnus-level-subscribed))))
891 (defun gnus-group-setup-buffer ()
892 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
893 (unless (eq major-mode 'gnus-group-mode)
896 (gnus-carpal-setup-buffer 'group))))
898 (defsubst gnus-group-name-charset (method group)
900 (setq method (gnus-find-method-for-group group)))
901 (let ((item (assoc method gnus-group-name-charset-method-alist))
902 (alist gnus-group-name-charset-group-alist)
906 (while (setq item (pop alist))
907 (if (string-match (car item) group)
912 (defsubst gnus-group-name-decode (string charset)
913 (if (and string charset (featurep 'mule))
914 (mm-decode-coding-string string charset)
917 (defun gnus-group-decoded-name (string)
918 (let ((charset (gnus-group-name-charset nil string)))
919 (gnus-group-name-decode string charset)))
921 (defun gnus-group-list-groups (&optional level unread lowest)
922 "List newsgroups with level LEVEL or lower that have unread articles.
923 Default is all subscribed groups.
924 If argument UNREAD is non-nil, groups with no unread articles are also
927 Also see the `gnus-group-use-permanent-levels' variable."
929 (list (if current-prefix-arg
930 (prefix-numeric-value current-prefix-arg)
932 (gnus-group-default-level nil t)
933 gnus-group-default-list-level
934 gnus-level-subscribed))))
936 (setq level (car gnus-group-list-mode)
937 unread (cdr gnus-group-list-mode)))
938 (setq level (gnus-group-default-level level))
939 (gnus-group-setup-buffer)
940 (gnus-update-format-specifications nil 'group 'group-mode)
941 (let ((case-fold-search nil)
942 (props (text-properties-at (gnus-point-at-bol)))
943 (empty (= (point-min) (point-max)))
944 (group (gnus-group-group-name))
946 (set-buffer gnus-group-buffer)
947 (setq number (funcall gnus-group-prepare-function level unread lowest))
948 (when (or (and (numberp number)
950 (zerop (buffer-size)))
951 ;; No groups in the buffer.
952 (gnus-message 5 gnus-no-groups-message))
953 ;; We have some groups displayed.
954 (goto-char (point-max))
955 (when (or (not gnus-group-goto-next-group-function)
956 (not (funcall gnus-group-goto-next-group-function
960 (goto-char (point-min)))
962 ;; Go to the first group with unread articles.
963 (gnus-group-search-forward t))
965 ;; Find the right group to put point on. If the current group
966 ;; has disappeared in the new listing, try to find the next
967 ;; one. If no next one can be found, just leave point at the
968 ;; first newsgroup in the buffer.
969 (when (not (gnus-goto-char
971 (point-min) (point-max)
972 'gnus-group (gnus-intern-safe
973 group gnus-active-hashtb))))
974 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
978 (point-min) (point-max) 'gnus-group
980 (caar newsrc) gnus-active-hashtb)))))
981 (setq newsrc (cdr newsrc)))
983 (goto-char (point-max))
984 (forward-line -1)))))))
985 ;; Adjust cursor point.
986 (gnus-group-position-point)))
988 (defun gnus-group-list-level (level &optional all)
989 "List groups on LEVEL.
990 If ALL (the prefix), also list groups that have no unread articles."
991 (interactive "nList groups on level: \nP")
992 (gnus-group-list-groups level all level))
994 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
995 "List all newsgroups with unread articles of level LEVEL or lower.
996 If ALL is non-nil, list groups that have no unread articles.
997 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
998 If REGEXP, only list groups matching REGEXP."
999 (set-buffer gnus-group-buffer)
1000 (let ((buffer-read-only nil)
1001 (newsrc (cdr gnus-newsrc-alist))
1002 (lowest (or lowest 1))
1003 info clevel unread group params)
1005 (when (< lowest gnus-level-zombie)
1006 ;; List living groups.
1008 (setq info (car newsrc)
1009 group (gnus-info-group info)
1010 params (gnus-info-params info)
1012 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1013 (and unread ; This group might be unchecked
1015 (string-match regexp group))
1016 (<= (setq clevel (gnus-info-level info)) level)
1018 (or all ; We list all groups?
1019 (if (eq unread t) ; Unactivated?
1020 gnus-group-list-inactive-groups ; We list unactivated
1021 (> unread 0)) ; We list groups with unread articles
1022 (and gnus-list-groups-with-ticked-articles
1023 (cdr (assq 'tick (gnus-info-marks info))))
1024 ; And groups with tickeds
1025 ;; Check for permanent visibility.
1026 (and gnus-permanently-visible-groups
1027 (string-match gnus-permanently-visible-groups
1029 (memq 'visible params)
1030 (cdr (assq 'visible params)))
1031 (gnus-group-insert-group-line
1032 group (gnus-info-level info)
1033 (gnus-info-marks info) unread (gnus-info-method info)))))
1035 ;; List dead groups.
1036 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
1037 (gnus-group-prepare-flat-list-dead
1038 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1039 gnus-level-zombie ?Z
1041 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
1042 (gnus-group-prepare-flat-list-dead
1043 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1044 gnus-level-killed ?K regexp))
1046 (gnus-group-set-mode-line)
1047 (setq gnus-group-list-mode (cons level all))
1048 (gnus-run-hooks 'gnus-group-prepare-hook)
1051 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1052 ;; List zombies and killed lists somewhat faster, which was
1053 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1054 ;; this by ignoring the group format specification altogether.
1057 ;; This loop is used when listing groups that match some
1060 (setq group (pop groups))
1061 (when (string-match regexp group)
1062 (gnus-add-text-properties
1063 (point) (prog1 (1+ (point))
1064 (insert " " mark " *: "
1065 (gnus-group-name-decode group
1066 (gnus-group-name-charset
1069 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1071 'gnus-level level))))
1072 ;; This loop is used when listing all groups.
1074 (setq group (pop groups))
1075 (gnus-add-text-properties
1076 (point) (prog1 (1+ (point))
1077 (insert " " mark " *: "
1078 (gnus-group-name-decode group
1079 (gnus-group-name-charset
1082 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1084 'gnus-level level))))))
1086 (defun gnus-group-update-group-line ()
1087 "Update the current line in the group buffer."
1088 (let* ((buffer-read-only nil)
1089 (group (gnus-group-group-name))
1090 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1091 gnus-group-indentation)
1094 (not (gnus-ephemeral-group-p group))
1096 (concat "(gnus-group-set-info '"
1097 (gnus-prin1-to-string (nth 2 entry))
1099 (setq gnus-group-indentation (gnus-group-group-indentation))
1101 (gnus-group-insert-group-line-info group)
1103 (gnus-group-position-point))))
1105 (defun gnus-group-insert-group-line-info (group)
1106 "Insert GROUP on the current line."
1107 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1108 (gnus-group-indentation (gnus-group-group-indentation))
1112 ;; (Un)subscribed group.
1113 (setq info (nth 2 entry))
1114 (gnus-group-insert-group-line
1115 group (gnus-info-level info) (gnus-info-marks info)
1116 (or (car entry) t) (gnus-info-method info)))
1117 ;; This group is dead.
1118 (gnus-group-insert-group-line
1120 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1122 (if (setq active (gnus-active group))
1123 (if (zerop (cdr active))
1125 (- (1+ (cdr active)) (car active)))
1129 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1130 gnus-tmp-marked number
1132 "Insert a group line in the group buffer."
1133 (let* ((gnus-tmp-method
1134 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1135 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1137 (gnus-tmp-active (gnus-active gnus-tmp-group))
1138 (gnus-tmp-number-total
1140 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1142 (gnus-tmp-number-of-unread
1143 (if (numberp number) (int-to-string (max 0 number))
1145 (gnus-tmp-number-of-read
1146 (if (numberp number)
1147 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1149 (gnus-tmp-subscribed
1150 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1151 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1152 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1154 (gnus-tmp-qualified-group
1155 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1156 group-name-charset))
1157 (gnus-tmp-newsgroup-description
1158 (if gnus-description-hashtb
1159 (or (gnus-group-name-decode
1160 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1161 group-name-charset) "")
1164 (if (and gnus-moderated-hashtb
1165 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1167 (gnus-tmp-moderated-string
1168 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1169 (gnus-tmp-group-icon "==&&==")
1170 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1171 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1172 (gnus-tmp-news-method-string
1174 (format "(%s:%s)" (car gnus-tmp-method)
1175 (cadr gnus-tmp-method)) ""))
1176 (gnus-tmp-marked-mark
1177 (if (and (numberp number)
1179 (cdr (assq 'tick gnus-tmp-marked)))
1181 (gnus-tmp-process-marked
1182 (if (member gnus-tmp-group gnus-group-marked)
1183 gnus-process-mark ? ))
1185 (or (and gnus-use-grouplens
1186 (bbb-grouplens-group-p gnus-tmp-group))
1188 (buffer-read-only nil)
1189 header gnus-tmp-header) ; passed as parameter to user-funcs.
1191 (gnus-add-text-properties
1195 (eval gnus-group-line-format-spec))
1196 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1197 gnus-unread ,(if (numberp number)
1198 (string-to-int gnus-tmp-number-of-unread)
1200 gnus-marked ,gnus-tmp-marked-mark
1201 gnus-indentation ,gnus-group-indentation
1202 gnus-level ,gnus-tmp-level))
1204 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1205 (gnus-run-hooks 'gnus-group-update-hook)
1207 ;; Allow XEmacs to remove front-sticky text properties.
1208 (gnus-group-remove-excess-properties)))
1210 (defun gnus-group-highlight-line ()
1211 "Highlight the current line according to `gnus-group-highlight'."
1212 (let* ((list gnus-group-highlight)
1214 (end (progn (end-of-line) (point)))
1215 ;; now find out where the line starts and leave point there.
1216 (beg (progn (beginning-of-line) (point)))
1217 (group (gnus-group-group-name))
1218 (entry (gnus-group-entry group))
1219 (unread (if (numberp (car entry)) (car entry) 0))
1220 (active (gnus-active group))
1221 (total (if active (1+ (- (cdr active) (car active))) 0))
1222 (info (nth 2 entry))
1223 (method (gnus-server-get-method group (gnus-info-method info)))
1224 (marked (gnus-info-marks info))
1225 (mailp (memq 'mail (assoc (symbol-name
1226 (car (or method gnus-select-method)))
1227 gnus-valid-select-methods)))
1228 (level (or (gnus-info-level info) gnus-level-killed))
1229 (score (or (gnus-info-score info) 0))
1230 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1231 (group-age (gnus-group-timestamp-delta group))
1232 (inhibit-read-only t))
1233 ;; Eval the cars of the lists until we find a match.
1235 (not (eval (caar list))))
1236 (setq list (cdr list)))
1237 (let ((face (cdar list)))
1238 (unless (eq face (get-text-property beg 'face))
1239 (gnus-put-text-property-excluding-characters-with-faces
1241 (setq face (if (boundp face) (symbol-value face) face)))
1242 (gnus-extent-start-open beg)))
1245 (defun gnus-group-update-group (group &optional visible-only)
1246 "Update all lines where GROUP appear.
1247 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1249 ;; Can't use `save-excursion' here, so we do it manually.
1250 (let ((buf (current-buffer))
1252 (set-buffer gnus-group-buffer)
1253 (setq mark (point-marker))
1254 ;; The buffer may be narrowed.
1257 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1259 found buffer-read-only)
1260 ;; Enter the current status into the dribble buffer.
1261 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1263 (not (gnus-ephemeral-group-p group)))
1265 (concat "(gnus-group-set-info '"
1266 (gnus-prin1-to-string (nth 2 entry))
1268 ;; Find all group instances. If topics are in use, each group
1269 ;; may be listed in more than once.
1270 (while (setq loc (text-property-any
1271 loc (point-max) 'gnus-group ident))
1274 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1276 (gnus-group-insert-group-line-info group)
1279 (gnus-run-hooks 'gnus-group-update-group-hook)))
1280 (setq loc (1+ loc)))
1281 (unless (or found visible-only)
1282 ;; No such line in the buffer, find out where it's supposed to
1283 ;; go, and insert it there (or at the end of the buffer).
1284 (if gnus-goto-missing-group-function
1285 (funcall gnus-goto-missing-group-function group)
1286 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1287 (while (and entry (car entry)
1291 (point-min) (point-max)
1292 'gnus-group (gnus-intern-safe
1293 (caar entry) gnus-active-hashtb)))))
1294 (setq entry (cdr entry)))
1295 (or entry (goto-char (point-max)))))
1296 ;; Finally insert the line.
1297 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1298 (gnus-group-insert-group-line-info group)
1301 (gnus-run-hooks 'gnus-group-update-group-hook))))
1302 (when gnus-group-update-group-function
1303 (funcall gnus-group-update-group-function group))
1304 (gnus-group-set-mode-line)))
1306 (set-marker mark nil)
1309 (defun gnus-group-set-mode-line ()
1310 "Update the mode line in the group buffer."
1311 (when (memq 'group gnus-updated-mode-lines)
1312 ;; Yes, we want to keep this mode line updated.
1314 (set-buffer gnus-group-buffer)
1315 (let* ((gformat (or gnus-group-mode-line-format-spec
1316 (gnus-set-format 'group-mode)))
1317 (gnus-tmp-news-server (cadr gnus-select-method))
1318 (gnus-tmp-news-method (car gnus-select-method))
1319 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1321 gnus-tmp-header ;Dummy binding for user-defined formats
1322 ;; Get the resulting string.
1324 (and gnus-dribble-buffer
1325 (buffer-name gnus-dribble-buffer)
1326 (buffer-modified-p gnus-dribble-buffer)
1328 (set-buffer gnus-dribble-buffer)
1329 (not (zerop (buffer-size))))))
1330 (mode-string (eval gformat)))
1331 ;; Say whether the dribble buffer has been modified.
1332 (setq mode-line-modified
1333 (if modified (car gnus-mode-line-modified)
1334 (cdr gnus-mode-line-modified)))
1335 ;; If the line is too long, we chop it off.
1336 (when (> (length mode-string) max-len)
1337 (setq mode-string (substring mode-string 0 (- max-len 4))))
1339 (setq mode-line-buffer-identification
1340 (gnus-mode-line-buffer-identification
1341 (list mode-string)))
1342 (set-buffer-modified-p modified))))))
1344 (defun gnus-group-group-name ()
1345 "Get the name of the newsgroup on the current line."
1346 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1348 (symbol-name group))))
1350 (defun gnus-group-group-level ()
1351 "Get the level of the newsgroup on the current line."
1352 (get-text-property (gnus-point-at-bol) 'gnus-level))
1354 (defun gnus-group-group-indentation ()
1355 "Get the indentation of the newsgroup on the current line."
1356 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1357 (and gnus-group-indentation-function
1358 (funcall gnus-group-indentation-function))
1361 (defun gnus-group-group-unread ()
1362 "Get the number of unread articles of the newsgroup on the current line."
1363 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1365 (defun gnus-group-new-mail (group)
1366 (if (nnmail-new-mail-p (gnus-group-real-name group))
1370 (defun gnus-group-level (group)
1371 "Return the estimated level of GROUP."
1372 (or (gnus-info-level (gnus-get-info group))
1373 (and (member group gnus-zombie-list) gnus-level-zombie)
1376 (defun gnus-group-search-forward (&optional backward all level first-too)
1377 "Find the next newsgroup with unread articles.
1378 If BACKWARD is non-nil, find the previous newsgroup instead.
1379 If ALL is non-nil, just find any newsgroup.
1380 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1382 If FIRST-TOO, the current line is also eligible as a target."
1383 (let ((way (if backward -1 1))
1384 (low gnus-level-killed)
1387 (if (and backward (progn (beginning-of-line)) (bobp))
1396 (get-text-property (point) 'gnus-group)
1400 (get-text-property (point) 'gnus-unread)))
1401 (and (numberp unread) (> unread 0)))
1402 (setq lev (get-text-property (point)
1404 (<= lev gnus-level-subscribed)))
1406 (and (setq lev (get-text-property (point)
1415 (zerop (forward-line way)))))
1417 (progn (gnus-group-position-point) t)
1418 (goto-char (or pos beg))
1421 ;;; Gnus group mode commands
1425 (defun gnus-group-mark-line-p ()
1428 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1429 (eq (char-after) gnus-process-mark)))
1431 (defun gnus-group-mark-group (n &optional unmark no-advance)
1432 "Mark the current group."
1434 (let ((buffer-read-only nil)
1438 (when (setq group (gnus-group-group-name))
1439 ;; Go to the mark position.
1441 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1442 (subst-char-in-region
1443 (point) (1+ (point)) (char-after)
1446 (setq gnus-group-marked (delete group gnus-group-marked))
1448 (setq gnus-group-marked
1449 (cons group (delete group gnus-group-marked)))
1450 gnus-process-mark)))
1452 (gnus-group-next-group 1))
1454 (gnus-summary-position-point)
1457 (defun gnus-group-unmark-group (n)
1458 "Remove the mark from the current group."
1460 (gnus-group-mark-group n 'unmark)
1461 (gnus-group-position-point))
1463 (defun gnus-group-unmark-all-groups ()
1464 "Unmark all groups."
1466 (let ((groups gnus-group-marked))
1469 (gnus-group-remove-mark (pop groups)))))
1470 (gnus-group-position-point))
1472 (defun gnus-group-mark-region (unmark beg end)
1473 "Mark all groups between point and mark.
1474 If UNMARK, remove the mark instead."
1475 (interactive "P\nr")
1476 (let ((num (count-lines beg end)))
1479 (- num (gnus-group-mark-group num unmark)))))
1481 (defun gnus-group-mark-buffer (&optional unmark)
1482 "Mark all groups in the buffer.
1483 If UNMARK, remove the mark instead."
1485 (gnus-group-mark-region unmark (point-min) (point-max)))
1487 (defun gnus-group-mark-regexp (regexp)
1488 "Mark all groups that match some regexp."
1489 (interactive "sMark (regexp): ")
1490 (let ((alist (cdr gnus-newsrc-alist))
1493 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1494 (gnus-group-set-mark group))))
1495 (gnus-group-position-point))
1497 (defun gnus-group-remove-mark (group &optional test-marked)
1498 "Remove the process mark from GROUP and move point there.
1499 Return nil if the group isn't displayed."
1500 (if (gnus-group-goto-group group nil test-marked)
1502 (gnus-group-mark-group 1 'unmark t)
1504 (setq gnus-group-marked
1505 (delete group gnus-group-marked))
1508 (defun gnus-group-set-mark (group)
1509 "Set the process mark on GROUP."
1510 (if (gnus-group-goto-group group)
1512 (gnus-group-mark-group 1 nil t))
1513 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1515 (defun gnus-group-universal-argument (arg &optional groups func)
1516 "Perform any command on all groups according to the process/prefix convention."
1518 (if (eq (setq func (or func
1521 (substitute-command-keys
1522 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1524 (gnus-error 1 "Undefined key")
1525 (gnus-group-iterate arg
1527 (command-execute func))))
1528 (gnus-group-position-point))
1530 (defun gnus-group-process-prefix (n)
1531 "Return a list of groups to work on.
1532 Take into consideration N (the prefix) and the list of marked groups."
1535 (setq n (prefix-numeric-value n))
1536 ;; There is a prefix, so we return a list of the N next
1538 (let ((way (if (< n 0) -1 1))
1543 (if (setq group (gnus-group-group-name))
1544 (push group groups))
1546 (gnus-group-next-group way)))
1548 ((gnus-region-active-p)
1549 ;; Work on the region between point and mark.
1550 (let ((max (max (point) (mark)))
1553 (goto-char (min (point) (mark)))
1556 (push (gnus-group-group-name) groups)
1557 (zerop (gnus-group-next-group 1))
1559 (nreverse groups))))
1561 ;; No prefix, but a list of marked articles.
1562 (reverse gnus-group-marked))
1564 ;; Neither marked articles or a prefix, so we return the
1566 (let ((group (gnus-group-group-name)))
1567 (and group (list group))))))
1569 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1570 ;;; imagine why I went through these contortions...
1572 (let ((function (make-symbol "gnus-group-iterate-function"))
1573 (window (make-symbol "gnus-group-iterate-window"))
1574 (groups (make-symbol "gnus-group-iterate-groups"))
1575 (group (make-symbol "gnus-group-iterate-group")))
1577 `(defun gnus-group-iterate (arg ,function)
1578 "Iterate FUNCTION over all process/prefixed groups.
1579 FUNCTION will be called with the group name as the parameter
1580 and with point over the group in question."
1581 (let ((,groups (gnus-group-process-prefix arg))
1582 (,window (selected-window))
1584 (while (setq ,group (pop ,groups))
1585 (select-window ,window)
1586 (gnus-group-remove-mark ,group)
1587 (save-selected-window
1589 (funcall ,function ,group)))))))))
1591 (put 'gnus-group-iterate 'lisp-indent-function 1)
1593 ;; Selecting groups.
1595 (defun gnus-group-read-group (&optional all no-article group select-articles)
1596 "Read news in this newsgroup.
1597 If the prefix argument ALL is non-nil, already read articles become
1598 readable. IF ALL is a number, fetch this number of articles. If the
1599 optional argument NO-ARTICLE is non-nil, no article will be
1600 auto-selected upon group entry. If GROUP is non-nil, fetch that
1603 (let ((no-display (eq all 0))
1604 (group (or group (gnus-group-group-name)))
1605 number active marked entry)
1609 (error "No group on current line"))
1610 (setq marked (gnus-info-marks
1611 (nth 2 (setq entry (gnus-gethash
1612 group gnus-newsrc-hashtb)))))
1613 ;; This group might be a dead group. In that case we have to get
1614 ;; the number of unread articles from `gnus-active-hashtb'.
1616 (cond ((numberp all) all)
1618 ((setq active (gnus-active group))
1619 (- (1+ (cdr active)) (car active)))))
1620 (gnus-summary-read-group
1621 group (or all (and (numberp number)
1622 (zerop (+ number (gnus-range-length
1623 (cdr (assq 'tick marked)))
1625 (cdr (assq 'dormant marked)))))))
1626 no-article nil no-display nil select-articles)))
1628 (defun gnus-group-select-group (&optional all)
1629 "Select this newsgroup.
1630 No article is selected automatically.
1631 If ALL is non-nil, already read articles become readable.
1632 If ALL is a number, fetch this number of articles."
1634 (gnus-group-read-group all t))
1636 (defun gnus-group-quick-select-group (&optional all)
1637 "Select the current group \"quickly\".
1638 This means that no highlighting or scoring will be performed.
1639 If ALL (the prefix argument) is 0, don't even generate the summary
1642 This might be useful if you want to toggle threading
1643 before entering the group."
1645 (require 'gnus-score)
1647 gnus-score-find-score-files-function
1648 gnus-home-score-file
1649 gnus-apply-kill-hook
1650 gnus-summary-expunge-below)
1651 (gnus-group-read-group all t)))
1653 (defun gnus-group-visible-select-group (&optional all)
1654 "Select the current group without hiding any articles."
1656 (let ((gnus-inhibit-limiting t))
1657 (gnus-group-read-group all t)))
1659 (defun gnus-group-select-group-ephemerally ()
1660 "Select the current group without doing any processing whatsoever.
1661 You will actually be entered into a group that's a copy of
1662 the current group; no changes you make while in this group will
1665 (require 'gnus-score)
1667 gnus-score-find-score-files-function gnus-apply-kill-hook
1668 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1669 gnus-summary-mode-hook gnus-select-group-hook
1670 (group (gnus-group-group-name))
1671 (method (gnus-find-method-for-group group)))
1672 (gnus-group-read-ephemeral-group
1673 (gnus-group-prefixed-name group method) method)))
1676 (defun gnus-fetch-group (group)
1677 "Start Gnus if necessary and enter GROUP.
1678 Returns whether the fetching was successful or not."
1679 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1680 (unless (get-buffer gnus-group-buffer)
1682 (gnus-group-read-group nil nil group))
1685 (defun gnus-fetch-group-other-frame (group)
1686 "Pop up a frame and enter GROUP."
1688 (let ((window (get-buffer-window gnus-group-buffer)))
1690 (select-frame (window-frame window)))
1691 ((= (length (frame-list)) 1)
1692 (select-frame (make-frame)))
1695 (gnus-fetch-group group))
1697 (defvar gnus-ephemeral-group-server 0)
1699 ;; Enter a group that is not in the group buffer. Non-nil is returned
1700 ;; if selection was successful.
1701 (defun gnus-group-read-ephemeral-group (group method &optional activate
1702 quit-config request-only
1704 "Read GROUP from METHOD as an ephemeral group.
1705 If ACTIVATE, request the group first.
1706 If QUIT-CONFIG, use that window configuration when exiting from the
1708 If REQUEST-ONLY, don't actually read the group; just request it.
1709 If SELECT-ARTICLES, only select those articles.
1711 Return the name of the group if selection was successful."
1712 ;; Transform the select method into a unique server.
1713 (when (stringp method)
1714 (setq method (gnus-server-to-method method)))
1716 `(,(car method) ,(concat (cadr method) "-ephemeral")
1717 (,(intern (format "%s-address" (car method))) ,(cadr method))
1719 (let ((group (if (gnus-group-foreign-p group) group
1720 (gnus-group-prefixed-name group method))))
1724 ,gnus-level-default-subscribed nil nil ,method
1726 ,(if quit-config quit-config
1727 (cons gnus-summary-buffer
1728 gnus-current-window-configuration))))))
1730 (push method gnus-ephemeral-servers)
1731 (set-buffer gnus-group-buffer)
1732 (unless (gnus-check-server method)
1733 (error "Unable to contact server: %s" (gnus-status-message method)))
1735 (gnus-activate-group group 'scan)
1736 (unless (gnus-request-group group)
1737 (error "Couldn't request group: %s"
1738 (nnheader-get-report (car method)))))
1742 (when (gnus-group-read-group t t group select-articles)
1747 (defun gnus-group-jump-to-group (group)
1748 "Jump to newsgroup GROUP."
1750 (list (completing-read
1751 "Group: " gnus-active-hashtb nil
1752 (gnus-read-active-file-p)
1754 'gnus-group-history)))
1756 (when (equal group "")
1757 (error "Empty group name"))
1759 (unless (gnus-ephemeral-group-p group)
1760 ;; Either go to the line in the group buffer...
1761 (unless (gnus-group-goto-group group)
1762 ;; ... or insert the line.
1763 (gnus-group-update-group group)
1764 (gnus-group-goto-group group)))
1765 ;; Adjust cursor point.
1766 (gnus-group-position-point))
1768 (defun gnus-group-goto-group (group &optional far test-marked)
1769 "Goto to newsgroup GROUP.
1770 If FAR, it is likely that the group is not on the current line.
1771 If TEST-MARKED, the line must be marked."
1775 ;; It's quite likely that we are on the right line, so
1776 ;; we check the current line first.
1778 (eq (get-text-property (point) 'gnus-group)
1779 (gnus-intern-safe group gnus-active-hashtb))
1780 (or (not test-marked) (gnus-group-mark-line-p)))
1782 ;; Previous and next line are also likely, so we check them as well.
1786 (and (eq (get-text-property (point) 'gnus-group)
1787 (gnus-intern-safe group gnus-active-hashtb))
1788 (or (not test-marked) (gnus-group-mark-line-p)))))
1794 (and (eq (get-text-property (point) 'gnus-group)
1795 (gnus-intern-safe group gnus-active-hashtb))
1796 (or (not test-marked) (gnus-group-mark-line-p)))))
1800 (goto-char (point-min))
1802 (while (and (not found)
1807 (gnus-intern-safe group gnus-active-hashtb))))
1808 (if (gnus-group-mark-line-p)
1813 ;; Search through the entire buffer.
1816 (point-min) (point-max)
1817 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1819 (defun gnus-group-next-group (n &optional silent)
1820 "Go to next N'th newsgroup.
1821 If N is negative, search backward instead.
1822 Returns the difference between N and the number of skips actually
1825 (gnus-group-next-unread-group n t nil silent))
1827 (defun gnus-group-next-unread-group (n &optional all level silent)
1828 "Go to next N'th unread newsgroup.
1829 If N is negative, search backward instead.
1830 If ALL is non-nil, choose any newsgroup, unread or not.
1831 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1832 such group can be found, the next group with a level higher than
1834 Returns the difference between N and the number of skips actually
1837 (let ((backward (< n 0))
1840 (gnus-group-search-forward
1841 backward (or (not gnus-group-goto-unread) all) level))
1845 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1846 (if level " on this level or higher" "")))
1849 (defun gnus-group-prev-group (n)
1850 "Go to previous N'th newsgroup.
1851 Returns the difference between N and the number of skips actually
1854 (gnus-group-next-unread-group (- n) t))
1856 (defun gnus-group-prev-unread-group (n)
1857 "Go to previous N'th unread newsgroup.
1858 Returns the difference between N and the number of skips actually
1861 (gnus-group-next-unread-group (- n)))
1863 (defun gnus-group-next-unread-group-same-level (n)
1864 "Go to next N'th unread newsgroup on the same level.
1865 If N is negative, search backward instead.
1866 Returns the difference between N and the number of skips actually
1869 (gnus-group-next-unread-group n t (gnus-group-group-level))
1870 (gnus-group-position-point))
1872 (defun gnus-group-prev-unread-group-same-level (n)
1873 "Go to next N'th unread newsgroup on the same level.
1874 Returns the difference between N and the number of skips actually
1877 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1878 (gnus-group-position-point))
1880 (defun gnus-group-best-unread-group (&optional exclude-group)
1881 "Go to the group with the highest level.
1882 If EXCLUDE-GROUP, do not go to that group."
1884 (goto-char (point-min))
1888 (setq unread (get-text-property (point) 'gnus-unread))
1889 (when (and (numberp unread) (> unread 0))
1890 (when (and (get-text-property (point) 'gnus-level)
1891 (< (get-text-property (point) 'gnus-level) best)
1892 (or (not exclude-group)
1893 (not (equal exclude-group (gnus-group-group-name)))))
1894 (setq best (get-text-property (point) 'gnus-level))
1895 (setq best-point (point))))
1898 (goto-char best-point))
1899 (gnus-summary-position-point)
1900 (and best-point (gnus-group-group-name))))
1902 (defun gnus-group-first-unread-group ()
1903 "Go to the first group with unread articles."
1906 (let ((opoint (point))
1908 (goto-char (point-min))
1909 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1910 (and (numberp unread) ; Not a topic.
1911 (not (zerop unread))) ; Has unread articles.
1912 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1915 nil)) ; Not success.
1916 (gnus-group-position-point)))
1918 (defun gnus-group-enter-server-mode ()
1919 "Jump to the server buffer."
1921 (gnus-enter-server-buffer))
1923 (defun gnus-group-make-group (name &optional method address args)
1924 "Add a new newsgroup.
1925 The user will be prompted for a NAME, for a select METHOD, and an
1929 (gnus-read-group "Group name: ")
1930 (gnus-read-method "From method: ")))
1932 (when (stringp method)
1933 (setq method (or (gnus-server-to-method method) method)))
1934 (let* ((meth (gnus-method-simplify
1936 (not (gnus-server-equal method gnus-select-method)))
1937 (if address (list (intern method) address)
1939 (nname (if method (gnus-group-prefixed-name name meth) name))
1941 (when (gnus-gethash nname gnus-newsrc-hashtb)
1942 (error "Group %s already exists" nname))
1943 ;; Subscribe to the new group.
1944 (gnus-group-change-level
1945 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1946 gnus-level-default-subscribed gnus-level-killed
1947 (and (gnus-group-group-name)
1948 (gnus-gethash (gnus-group-group-name)
1949 gnus-newsrc-hashtb))
1952 (gnus-set-active nname (cons 1 0))
1953 (unless (gnus-ephemeral-group-p name)
1955 (concat "(gnus-group-set-info '"
1956 (gnus-prin1-to-string (cdr info)) ")")))
1958 (gnus-group-insert-group-line-info nname)
1960 (gnus-group-position-point)
1962 ;; Load the backend and try to make the backend create
1963 ;; the group as well.
1964 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1966 gnus-valid-select-methods)
1968 (gnus-check-server meth)
1969 (when (gnus-check-backend-function 'request-create-group nname)
1970 (gnus-request-create-group nname nil args))
1973 (defun gnus-group-delete-groups (&optional arg)
1974 "Delete the current group. Only meaningful with editable groups."
1976 (let ((n (length (gnus-group-process-prefix arg))))
1977 (when (gnus-yes-or-no-p
1979 "Delete this 1 group? "
1980 (format "Delete these %d groups? " n)))
1981 (gnus-group-iterate arg
1983 (gnus-group-delete-group group nil t))))))
1985 (defun gnus-group-delete-group (group &optional force no-prompt)
1986 "Delete the current group. Only meaningful with editable groups.
1987 If FORCE (the prefix) is non-nil, all the articles in the group will
1988 be deleted. This is \"deleted\" as in \"removed forever from the face
1989 of the Earth\". There is no undo. The user will be prompted before
1990 doing the deletion."
1992 (list (gnus-group-group-name)
1993 current-prefix-arg))
1995 (error "No group to rename"))
1996 (unless (gnus-check-backend-function 'request-delete-group group)
1997 (error "This backend does not support group deletion"))
1999 (if (and (not no-prompt)
2000 (not (gnus-yes-or-no-p
2002 "Do you really want to delete %s%s? "
2003 group (if force " and all its contents" "")))))
2005 (gnus-message 6 "Deleting group %s..." group)
2006 (if (not (gnus-request-delete-group group force))
2007 (gnus-error 3 "Couldn't delete group %s" group)
2008 (gnus-message 6 "Deleting group %s...done" group)
2009 (gnus-group-goto-group group)
2010 (gnus-group-kill-group 1 t)
2011 (gnus-sethash group nil gnus-active-hashtb)
2013 (gnus-group-position-point)))
2015 (defun gnus-group-rename-group (group new-name)
2016 "Rename group from GROUP to NEW-NAME.
2017 When used interactively, GROUP is the group under point
2018 and NEW-NAME will be prompted for."
2021 (gnus-group-group-name)
2023 (unless (gnus-check-backend-function
2024 'request-rename-group (gnus-group-group-name))
2025 (error "This backend does not support renaming groups"))
2026 (gnus-read-group "Rename group to: "
2027 (gnus-group-real-name (gnus-group-group-name))))))
2029 (unless (gnus-check-backend-function 'request-rename-group group)
2030 (error "This backend does not support renaming groups"))
2032 (error "No group to rename"))
2033 (when (equal (gnus-group-real-name group) new-name)
2034 (error "Can't rename to the same name"))
2036 ;; We find the proper prefixed name.
2038 (if (gnus-group-native-p group)
2042 (gnus-group-prefixed-name
2043 (gnus-group-real-name new-name)
2044 (gnus-info-method (gnus-get-info group)))))
2046 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2048 (if (not (gnus-request-rename-group group new-name))
2049 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2050 ;; We rename the group internally by killing it...
2051 (gnus-group-goto-group group)
2052 (gnus-group-kill-group)
2053 ;; ... changing its name ...
2054 (setcar (cdar gnus-list-of-killed-groups) new-name)
2055 ;; ... and then yanking it. Magic!
2056 (gnus-group-yank-group)
2057 (gnus-set-active new-name (gnus-active group))
2058 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2060 (setq gnus-killed-list (delete group gnus-killed-list))
2061 (gnus-set-active group nil)
2062 (gnus-dribble-touch)
2063 (gnus-group-position-point)))
2065 (defun gnus-group-edit-group (group &optional part)
2066 "Edit the group on the current line."
2067 (interactive (list (gnus-group-group-name)))
2068 (let ((part (or part 'info))
2071 (error "No group on current line"))
2072 (unless (setq info (gnus-get-info group))
2073 (error "Killed group; can't be edited"))
2075 (gnus-close-group group))
2077 ;; Find the proper form to edit.
2078 (cond ((eq part 'method)
2079 (or (gnus-info-method info) "native"))
2081 (gnus-info-params info))
2083 ;; The proper documentation.
2085 "Editing the %s for `%s'."
2087 ((eq part 'method) "select method")
2088 ((eq part 'params) "group parameters")
2090 (gnus-group-decoded-name group))
2092 (gnus-group-edit-group-done ',part ,group form)))))
2094 (defun gnus-group-edit-group-method (group)
2095 "Edit the select method of GROUP."
2096 (interactive (list (gnus-group-group-name)))
2097 (gnus-group-edit-group group 'method))
2099 (defun gnus-group-edit-group-parameters (group)
2100 "Edit the group parameters of GROUP."
2101 (interactive (list (gnus-group-group-name)))
2102 (gnus-group-edit-group group 'params))
2104 (defun gnus-group-edit-group-done (part group form)
2106 (let* ((method (cond ((eq part 'info) (nth 4 form))
2107 ((eq part 'method) form)
2109 (info (cond ((eq part 'info) form)
2110 ((eq part 'method) (gnus-get-info group))
2113 (if (or (not method)
2115 gnus-select-method method))
2116 (gnus-group-real-name (car info))
2117 (gnus-group-prefixed-name
2118 (gnus-group-real-name (car info)) method))
2120 (when (and new-group
2121 (not (equal new-group group)))
2122 (when (gnus-group-goto-group group)
2123 (gnus-group-kill-group 1))
2124 (gnus-activate-group new-group))
2126 (if (not (and info new-group))
2127 (gnus-group-set-info form (or new-group group) part)
2128 (setq info (gnus-copy-sequence info))
2129 (setcar info new-group)
2130 (unless (gnus-server-equal method "native")
2131 (unless (nthcdr 3 info)
2132 (nconc info (list nil nil)))
2133 (unless (nthcdr 4 info)
2134 (nconc info (list nil)))
2135 (gnus-info-set-method info method))
2136 (gnus-group-set-info info))
2137 (gnus-group-update-group (or new-group group))
2138 (gnus-group-position-point)))
2140 (defun gnus-group-make-useful-group (group method)
2141 "Create one of the groups described in `gnus-useful-groups'."
2143 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2145 gnus-useful-groups)))
2146 (list (cadr entry) (caddr entry))))
2147 (setq method (gnus-copy-sequence method))
2149 (while (setq entry (memq (assq 'eval method) method))
2150 (setcar entry (eval (cadar entry)))))
2151 (gnus-group-make-group group method))
2153 (defun gnus-group-make-help-group ()
2154 "Create the Gnus documentation group."
2156 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2157 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2158 (when (gnus-gethash name gnus-newsrc-hashtb)
2159 (error "Documentation group already exists"))
2161 (gnus-message 1 "Couldn't find doc group")
2162 (gnus-group-make-group
2163 (gnus-group-real-name name)
2164 (list 'nndoc "gnus-help"
2165 (list 'nndoc-address file)
2166 (list 'nndoc-article-type 'mbox)))))
2167 (gnus-group-position-point))
2169 (defun gnus-group-make-doc-group (file type)
2170 "Create a group that uses a single file as the source."
2172 (list (read-file-name "File name: ")
2173 (and current-prefix-arg 'ask)))
2174 (when (eq type 'ask)
2179 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2181 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2182 ((= char ?b) 'babyl)
2183 ((= char ?d) 'digest)
2184 ((= char ?f) 'forward)
2186 ((= char ?g) 'guess)
2187 (t (setq err (format "%c unknown. " char))
2190 (let* ((file (expand-file-name file))
2191 (name (gnus-generate-new-group-name
2192 (gnus-group-prefixed-name
2193 (file-name-nondirectory file) '(nndoc "")))))
2194 (gnus-group-make-group
2195 (gnus-group-real-name name)
2197 (list 'nndoc-address file)
2198 (list 'nndoc-article-type (or type 'guess))))))
2200 (defvar nnweb-type-definition)
2201 (defvar gnus-group-web-type-history nil)
2202 (defvar gnus-group-web-search-history nil)
2203 (defun gnus-group-make-web-group (&optional solid)
2204 "Create an ephemeral nnweb group.
2205 If SOLID (the prefix), create a solid group."
2209 (if solid (gnus-read-group "Group name: ")
2210 (message-unique-id)))
2211 (default-type (or (car gnus-group-web-type-history)
2212 (symbol-name (caar nnweb-type-definition))))
2216 (format "Search engine type (default %s): " default-type)
2217 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2218 nnweb-type-definition)
2219 nil t nil 'gnus-group-web-type-history)
2224 (cons (or (car gnus-group-web-search-history) "") 0)
2225 'gnus-group-web-search-history))
2227 `(nnweb ,group (nnweb-search ,search)
2228 (nnweb-type ,(intern type))
2229 (nnweb-ephemeral-p t))))
2231 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2232 (gnus-group-read-ephemeral-group
2234 (cons (current-buffer)
2235 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2237 (defvar nnwarchive-type-definition)
2238 (defvar gnus-group-warchive-type-history nil)
2239 (defvar gnus-group-warchive-login-history nil)
2240 (defvar gnus-group-warchive-address-history nil)
2242 (defun gnus-group-make-warchive-group ()
2243 "Create a nnwarchive group."
2245 (require 'nnwarchive)
2246 (let* ((group (gnus-read-group "Group name: "))
2247 (default-type (or (car gnus-group-warchive-type-history)
2248 (symbol-name (caar nnwarchive-type-definition))))
2252 (format "Warchive type (default %s): " default-type)
2253 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2254 nnwarchive-type-definition)
2255 nil t nil 'gnus-group-warchive-type-history)
2257 (address (read-string "Warchive address: "
2258 nil 'gnus-group-warchive-address-history))
2259 (default-login (or (car gnus-group-warchive-login-history)
2264 (format "Warchive login (default %s): " user-mail-address)
2265 default-login 'gnus-group-warchive-login-history)
2268 `(nnwarchive ,address
2269 (nnwarchive-type ,(intern type))
2270 (nnwarchive-login ,login))))
2271 (gnus-group-make-group group method)))
2273 (defun gnus-group-make-archive-group (&optional all)
2274 "Create the (ding) Gnus archive group of the most recent articles.
2275 Given a prefix, create a full group."
2277 (let ((group (gnus-group-prefixed-name
2278 (if all "ding.archives" "ding.recent") '(nndir ""))))
2279 (when (gnus-gethash group gnus-newsrc-hashtb)
2280 (error "Archive group already exists"))
2281 (gnus-group-make-group
2282 (gnus-group-real-name group)
2283 (list 'nndir (if all "hpc" "edu")
2284 (list 'nndir-directory
2285 (if all gnus-group-archive-directory
2286 gnus-group-recent-archive-directory))))
2287 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2289 (defun gnus-group-make-directory-group (dir)
2290 "Create an nndir group.
2291 The user will be prompted for a directory. The contents of this
2292 directory will be used as a newsgroup. The directory should contain
2293 mail messages or news articles in files that have numeric names."
2295 (list (read-file-name "Create group from directory: ")))
2296 (unless (file-exists-p dir)
2297 (error "No such directory"))
2298 (unless (file-directory-p dir)
2299 (error "Not a directory"))
2303 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2305 (gnus-group-prefixed-name
2306 (concat (file-name-as-directory (directory-file-name dir))
2309 (setq ext (format "<%d>" (setq i (1+ i)))))
2310 (gnus-group-make-group
2311 (gnus-group-real-name group)
2312 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2314 (defun gnus-group-make-kiboze-group (group address scores)
2315 "Create an nnkiboze group.
2316 The user will be prompted for a name, a regexp to match groups, and
2317 score file entries for articles to include in the group."
2320 (read-string "nnkiboze group name: ")
2321 (read-string "Source groups (regexp): ")
2322 (let ((headers (mapcar (lambda (group) (list group))
2323 '("subject" "from" "number" "date" "message-id"
2324 "references" "chars" "lines" "xref"
2325 "followup" "all" "body" "head")))
2326 scores header regexp regexps)
2327 (while (not (equal "" (setq header (completing-read
2328 "Match on header: " headers nil t))))
2330 (while (not (equal "" (setq regexp (read-string
2331 (format "Match on %s (string): "
2333 (push (list regexp nil nil 'r) regexps))
2334 (push (cons header regexps) scores))
2336 (gnus-group-make-group group "nnkiboze" address)
2337 (with-temp-file (gnus-score-file-name (concat "nnkiboze:" group))
2338 (let (emacs-lisp-mode-hook)
2339 (pp scores (current-buffer)))))
2341 (defun gnus-group-add-to-virtual (n vgroup)
2342 "Add the current group to a virtual group."
2344 (list current-prefix-arg
2345 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2347 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2348 (error "%s is not an nnvirtual group" vgroup))
2349 (gnus-close-group vgroup)
2350 (let* ((groups (gnus-group-process-prefix n))
2351 (method (gnus-info-method (gnus-get-info vgroup))))
2352 (setcar (cdr method)
2354 (nth 1 method) "\\|"
2357 (gnus-group-remove-mark s)
2358 (concat "\\(^" (regexp-quote s) "$\\)"))
2360 (gnus-group-position-point))
2362 (defun gnus-group-make-empty-virtual (group)
2363 "Create a new, fresh, empty virtual group."
2364 (interactive "sCreate new, empty virtual group: ")
2365 (let* ((method (list 'nnvirtual "^$"))
2366 (pgroup (gnus-group-prefixed-name group method)))
2367 ;; Check whether it exists already.
2368 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2369 (error "Group %s already exists" pgroup))
2370 ;; Subscribe the new group after the group on the current line.
2371 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2372 (gnus-group-update-group pgroup)
2374 (gnus-group-position-point)))
2376 (defun gnus-group-enter-directory (dir)
2377 "Enter an ephemeral nneething group."
2378 (interactive "DDirectory to read: ")
2379 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2380 (leaf (gnus-group-prefixed-name
2381 (file-name-nondirectory (directory-file-name dir))
2383 (name (gnus-generate-new-group-name leaf)))
2384 (unless (gnus-group-read-ephemeral-group
2386 (cons (current-buffer)
2387 (if (eq major-mode 'gnus-summary-mode)
2389 (error "Couldn't enter %s" dir))))
2392 (autoload 'nnimap-expunge "nnimap")
2393 (autoload 'nnimap-acl-get "nnimap")
2394 (autoload 'nnimap-acl-edit "nnimap"))
2396 (defun gnus-group-nnimap-expunge (group)
2397 "Expunge deleted articles in current nnimap GROUP."
2398 (interactive (list (gnus-group-group-name)))
2399 (let ((mailbox (gnus-group-real-name group)) method)
2401 (error "No group on current line"))
2402 (unless (gnus-get-info group)
2403 (error "Killed group; can't be edited"))
2404 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2405 (error "%s is not an nnimap group" group))
2406 (nnimap-expunge mailbox (cadr method))))
2408 (defun gnus-group-nnimap-edit-acl (group)
2409 "Edit the Access Control List of current nnimap GROUP."
2410 (interactive (list (gnus-group-group-name)))
2411 (let ((mailbox (gnus-group-real-name group)) method acl)
2413 (error "No group on current line"))
2414 (unless (gnus-get-info group)
2415 (error "Killed group; can't be edited"))
2416 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2417 (error "%s is not an nnimap group" group))
2418 (gnus-edit-form (setq acl (nnimap-acl-get mailbox (cadr method)))
2419 (format "Editing the access control list for `%s'.
2421 An access control list is a list of (identifier . rights) elements.
2423 The identifier string specifies the corresponding user. The
2424 identifier \"anyone\" is reserved to refer to the universal identity.
2426 Rights is a string listing a (possibly empty) set of alphanumeric
2427 characters, each character listing a set of operations which is being
2428 controlled. Letters are reserved for ``standard'' rights, listed
2429 below. Digits are reserved for implementation or site defined rights.
2431 l - lookup (mailbox is visible to LIST/LSUB commands)
2432 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2433 SEARCH, COPY from mailbox)
2434 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2435 w - write (STORE flags other than \\SEEN and \\DELETED)
2436 i - insert (perform APPEND, COPY into mailbox)
2437 p - post (send mail to submission address for mailbox,
2438 not enforced by IMAP4 itself)
2439 c - create and delete mailbox (CREATE new sub-mailboxes in any
2440 implementation-defined hierarchy, RENAME or DELETE mailbox)
2441 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2442 a - administer (perform SETACL)" group)
2445 ,mailbox ',method ',acl form)))))
2447 ;; Group sorting commands
2448 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2450 (defun gnus-group-sort-groups (func &optional reverse)
2451 "Sort the group buffer according to FUNC.
2452 When used interactively, the sorting function used will be
2453 determined by the `gnus-group-sort-function' variable.
2454 If REVERSE (the prefix), reverse the sorting order."
2455 (interactive (list gnus-group-sort-function current-prefix-arg))
2456 (funcall gnus-group-sort-alist-function
2457 (gnus-make-sort-function func) reverse)
2458 (gnus-group-list-groups)
2459 (gnus-dribble-touch))
2461 (defun gnus-group-sort-flat (func reverse)
2462 ;; We peel off the dummy group from the alist.
2464 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2465 (pop gnus-newsrc-alist))
2467 (setq gnus-newsrc-alist
2468 (sort gnus-newsrc-alist func))
2470 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2471 ;; Regenerate the hash table.
2472 (gnus-make-hashtable-from-newsrc-alist)))
2474 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2475 "Sort the group buffer alphabetically by group name.
2476 If REVERSE, sort in reverse order."
2478 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2480 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2481 "Sort the group buffer by number of unread articles.
2482 If REVERSE, sort in reverse order."
2484 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2486 (defun gnus-group-sort-groups-by-level (&optional reverse)
2487 "Sort the group buffer by group level.
2488 If REVERSE, sort in reverse order."
2490 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2492 (defun gnus-group-sort-groups-by-score (&optional reverse)
2493 "Sort the group buffer by group score.
2494 If REVERSE, sort in reverse order."
2496 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2498 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2499 "Sort the group buffer by group rank.
2500 If REVERSE, sort in reverse order."
2502 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2504 (defun gnus-group-sort-groups-by-method (&optional reverse)
2505 "Sort the group buffer alphabetically by backend name.
2506 If REVERSE, sort in reverse order."
2508 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2510 ;;; Selected group sorting.
2512 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2513 "Sort the process/prefixed groups."
2514 (interactive (list current-prefix-arg gnus-group-sort-function))
2515 (let ((groups (gnus-group-process-prefix n)))
2516 (funcall gnus-group-sort-selected-function
2517 groups (gnus-make-sort-function func) reverse)
2518 (gnus-group-list-groups)))
2520 (defun gnus-group-sort-selected-flat (groups func reverse)
2521 (let (entries infos)
2522 ;; First find all the group entries for these groups.
2524 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2526 ;; Then sort the infos.
2530 (lambda (entry) (car entry))
2531 (setq entries (nreverse entries)))
2534 (setq infos (nreverse infos)))
2535 ;; Go through all the infos and replace the old entries
2536 ;; with the new infos.
2538 (setcar (car entries) (pop infos))
2540 ;; Update the hashtable.
2541 (gnus-make-hashtable-from-newsrc-alist)))
2543 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2544 "Sort the group buffer alphabetically by group name.
2545 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2546 sort in reverse order."
2547 (interactive (gnus-interactive "P\ny"))
2548 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2550 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2551 "Sort the group buffer by number of unread articles.
2552 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2553 sort in reverse order."
2554 (interactive (gnus-interactive "P\ny"))
2555 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2557 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2558 "Sort the group buffer by group level.
2559 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2560 sort in reverse order."
2561 (interactive (gnus-interactive "P\ny"))
2562 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2564 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2565 "Sort the group buffer by group score.
2566 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2567 sort in reverse order."
2568 (interactive (gnus-interactive "P\ny"))
2569 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2571 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2572 "Sort the group buffer by group rank.
2573 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2574 sort in reverse order."
2575 (interactive (gnus-interactive "P\ny"))
2576 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2578 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2579 "Sort the group buffer alphabetically by backend name.
2580 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2581 sort in reverse order."
2582 (interactive (gnus-interactive "P\ny"))
2583 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2585 ;;; Sorting predicates.
2587 (defun gnus-group-sort-by-alphabet (info1 info2)
2588 "Sort alphabetically."
2589 (string< (gnus-info-group info1) (gnus-info-group info2)))
2591 (defun gnus-group-sort-by-real-name (info1 info2)
2592 "Sort alphabetically on real (unprefixed) names."
2593 (string< (gnus-group-real-name (gnus-info-group info1))
2594 (gnus-group-real-name (gnus-info-group info2))))
2596 (defun gnus-group-sort-by-unread (info1 info2)
2597 "Sort by number of unread articles."
2598 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2599 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2600 (< (or (and (numberp n1) n1) 0)
2601 (or (and (numberp n2) n2) 0))))
2603 (defun gnus-group-sort-by-level (info1 info2)
2605 (< (gnus-info-level info1) (gnus-info-level info2)))
2607 (defun gnus-group-sort-by-method (info1 info2)
2608 "Sort alphabetically by backend name."
2609 (string< (symbol-name (car (gnus-find-method-for-group
2610 (gnus-info-group info1) info1)))
2611 (symbol-name (car (gnus-find-method-for-group
2612 (gnus-info-group info2) info2)))))
2614 (defun gnus-group-sort-by-score (info1 info2)
2615 "Sort by group score."
2616 (< (gnus-info-score info1) (gnus-info-score info2)))
2618 (defun gnus-group-sort-by-rank (info1 info2)
2619 "Sort by level and score."
2620 (let ((level1 (gnus-info-level info1))
2621 (level2 (gnus-info-level info2)))
2622 (or (< level1 level2)
2623 (and (= level1 level2)
2624 (> (gnus-info-score info1) (gnus-info-score info2))))))
2628 (defun gnus-group-clear-data (&optional arg)
2629 "Clear all marks and read ranges from the current group."
2631 (gnus-group-iterate arg
2634 (gnus-info-clear-data (setq info (gnus-get-info group)))
2635 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2636 (when (gnus-group-goto-group group)
2637 (gnus-group-update-group-line))))))
2639 (defun gnus-group-clear-data-on-native-groups ()
2640 "Clear all marks and read ranges from all native groups."
2642 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2643 (let ((alist (cdr gnus-newsrc-alist))
2645 (while (setq info (pop alist))
2646 (when (gnus-group-native-p (gnus-info-group info))
2647 (gnus-info-clear-data info)))
2648 (gnus-get-unread-articles)
2649 (gnus-dribble-touch)
2650 (when (gnus-y-or-n-p
2651 "Move the cache away to avoid problems in the future? ")
2652 (call-interactively 'gnus-cache-move-cache)))))
2654 (defun gnus-info-clear-data (info)
2655 "Clear all marks and read ranges from INFO."
2656 (let ((group (gnus-info-group info)))
2659 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2660 (gnus-info-set-read ',info ',(gnus-info-read info))
2661 (when (gnus-group-goto-group ,group)
2662 (gnus-group-update-group-line))))
2663 (gnus-info-set-read info nil)
2664 (when (gnus-info-marks info)
2665 (gnus-info-set-marks info nil))))
2667 ;; Group catching up.
2669 (defun gnus-group-catchup-current (&optional n all)
2670 "Mark all unread articles in the current newsgroup as read.
2671 If prefix argument N is numeric, the next N newsgroups will be
2672 caught up. If ALL is non-nil, marked articles will also be marked as
2673 read. Cross references (Xref: header) of articles are ignored.
2674 The number of newsgroups that this function was unable to catch
2677 (let ((groups (gnus-group-process-prefix n))
2680 (unless groups (error "No groups selected"))
2682 (or (not gnus-interactive-catchup) ;Without confirmation?
2687 "Do you really want to mark all articles in %s as read? "
2688 "Mark all unread articles in %s as read? ")
2689 (if (= (length groups) 1)
2691 (format "these %d groups" (length groups)))))))
2693 (while (setq group (pop groups))
2694 (gnus-group-remove-mark group)
2695 ;; Virtual groups have to be given special treatment.
2696 (let ((method (gnus-find-method-for-group group)))
2697 (when (eq 'nnvirtual (car method))
2698 (nnvirtual-catchup-group
2699 (gnus-group-real-name group) (nth 1 method) all)))
2700 (if (>= (gnus-group-level group) gnus-level-zombie)
2701 (gnus-message 2 "Dead groups can't be caught up")
2703 (gnus-group-goto-group group)
2704 (gnus-group-catchup group all))
2705 (gnus-group-update-group-line)
2706 (setq ret (1+ ret)))))
2707 (gnus-group-next-unread-group 1)
2710 (defun gnus-group-catchup-current-all (&optional n)
2711 "Mark all articles in current newsgroup as read.
2712 Cross references (Xref: header) of articles are ignored."
2714 (gnus-group-catchup-current n 'all))
2716 (defun gnus-group-catchup (group &optional all)
2717 "Mark all articles in GROUP as read.
2718 If ALL is non-nil, all articles are marked as read.
2719 The return value is the number of articles that were marked as read,
2720 or nil if no action could be taken."
2721 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2723 ;; Remove entries for this group.
2724 (nnmail-purge-split-history (gnus-group-real-name group))
2725 ;; Do the updating only if the newsgroup isn't killed.
2726 (if (not (numberp (car entry)))
2727 (gnus-message 1 "Can't catch up %s; non-active group" group)
2728 ;; Do auto-expirable marks if that's required.
2729 (when (gnus-group-auto-expirable-p group)
2730 (gnus-add-marked-articles
2731 group 'expire (gnus-list-of-unread-articles group))
2733 (let ((marks (nth 3 (nth 2 entry))))
2734 (gnus-add-marked-articles
2735 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2736 (gnus-add-marked-articles
2737 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2739 (gnus-update-read-articles group nil)
2740 ;; Also nix out the lists of marks and dormants.
2742 (gnus-add-marked-articles group 'tick nil nil 'force)
2743 (gnus-add-marked-articles group 'dormant nil nil 'force))
2744 (let ((gnus-newsgroup-name group))
2745 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2748 (defun gnus-group-expire-articles (&optional n)
2749 "Expire all expirable articles in the current newsgroup."
2751 (let ((groups (gnus-group-process-prefix n))
2754 (error "No groups to expire"))
2755 (while (setq group (pop groups))
2756 (gnus-group-remove-mark group)
2757 (gnus-group-expire-articles-1 group)
2758 (gnus-dribble-touch)
2759 (gnus-group-position-point))))
2761 (defun gnus-group-expire-articles-1 (group)
2762 (when (gnus-check-backend-function 'request-expire-articles group)
2763 (gnus-message 6 "Expiring articles in %s..." group)
2764 (let* ((info (gnus-get-info group))
2765 (expirable (if (gnus-group-total-expirable-p group)
2766 (cons nil (gnus-list-of-read-articles group))
2767 (assq 'expire (gnus-info-marks info))))
2768 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2769 (nnmail-expiry-target
2770 (or (gnus-group-find-parameter group 'expiry-target)
2771 nnmail-expiry-target)))
2773 (gnus-check-group group)
2776 (gnus-compress-sequence
2778 ;; We set the expiry variables to the group
2780 (let ((nnmail-expiry-wait-function nil)
2781 (nnmail-expiry-wait expiry-wait))
2782 (gnus-request-expire-articles
2783 (gnus-uncompress-sequence (cdr expirable)) group))
2784 ;; Just expire using the normal expiry values.
2785 (gnus-request-expire-articles
2786 (gnus-uncompress-sequence (cdr expirable)) group))))
2787 (gnus-close-group group))
2788 (gnus-message 6 "Expiring articles in %s...done" group))))
2790 (defun gnus-group-expire-all-groups ()
2791 "Expire all expirable articles in all newsgroups."
2794 (gnus-message 5 "Expiring...")
2795 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2796 (cdr gnus-newsrc-alist))))
2797 (gnus-group-expire-articles nil)))
2798 (gnus-group-position-point)
2799 (gnus-message 5 "Expiring...done"))
2801 (defun gnus-group-set-current-level (n level)
2802 "Set the level of the next N groups to LEVEL."
2807 (let ((s (read-string
2808 (format "Level (default %s): "
2809 (or (gnus-group-group-level)
2810 gnus-level-default-subscribed)))))
2811 (if (string-match "^\\s-*$" s)
2812 (int-to-string (or (gnus-group-group-level)
2813 gnus-level-default-subscribed))
2815 (unless (and (>= level 1) (<= level gnus-level-killed))
2816 (error "Invalid level: %d" level))
2817 (let ((groups (gnus-group-process-prefix n))
2819 (while (setq group (pop groups))
2820 (gnus-group-remove-mark group)
2821 (gnus-message 6 "Changed level of %s from %d to %d"
2822 group (or (gnus-group-group-level) gnus-level-killed)
2824 (gnus-group-change-level
2825 group level (or (gnus-group-group-level) gnus-level-killed))
2826 (gnus-group-update-group-line)))
2827 (gnus-group-position-point))
2829 (defun gnus-group-unsubscribe (&optional n)
2830 "Unsubscribe the current group."
2832 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2834 (defun gnus-group-subscribe (&optional n)
2835 "Subscribe the current group."
2837 (gnus-group-unsubscribe-current-group n 'subscribe))
2839 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2840 "Toggle subscription of the current group.
2841 If given numerical prefix, toggle the N next groups."
2843 (let ((groups (gnus-group-process-prefix n))
2846 (setq group (car groups)
2847 groups (cdr groups))
2848 (gnus-group-remove-mark group)
2849 (gnus-group-unsubscribe-group
2852 ((eq do-sub 'unsubscribe)
2853 gnus-level-default-unsubscribed)
2854 ((eq do-sub 'subscribe)
2855 gnus-level-default-subscribed)
2856 ((<= (gnus-group-group-level) gnus-level-subscribed)
2857 gnus-level-default-unsubscribed)
2859 gnus-level-default-subscribed))
2861 (gnus-group-update-group-line))
2862 (gnus-group-next-group 1)))
2864 (defun gnus-group-unsubscribe-group (group &optional level silent)
2865 "Toggle subscription to GROUP.
2866 Killed newsgroups are subscribed. If SILENT, don't try to update the
2869 (list (completing-read
2870 "Group: " gnus-active-hashtb nil
2871 (gnus-read-active-file-p)
2873 'gnus-group-history)))
2874 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2876 ((string-match "^[ \t]*$" group)
2877 (error "Empty group name"))
2879 ;; Toggle subscription flag.
2880 (gnus-group-change-level
2881 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2882 gnus-level-subscribed)
2883 (1+ gnus-level-subscribed)
2884 gnus-level-default-subscribed)))
2886 (gnus-group-update-group group)))
2887 ((and (stringp group)
2888 (or (not (gnus-read-active-file-p))
2889 (gnus-active group)))
2890 ;; Add new newsgroup.
2891 (gnus-group-change-level
2893 (if level level gnus-level-default-subscribed)
2894 (or (and (member group gnus-zombie-list)
2897 (when (gnus-group-group-name)
2898 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2900 (gnus-group-update-group group)))
2901 (t (error "No such newsgroup: %s" group)))
2902 (gnus-group-position-point)))
2904 (defun gnus-group-transpose-groups (n)
2905 "Move the current newsgroup up N places.
2906 If given a negative prefix, move down instead. The difference between
2907 N and the number of steps taken is returned."
2909 (unless (gnus-group-group-name)
2910 (error "No group on current line"))
2911 (gnus-group-kill-group 1)
2913 (forward-line (- n))
2914 (gnus-group-yank-group)
2915 (gnus-group-position-point)))
2917 (defun gnus-group-kill-all-zombies (&optional dummy)
2918 "Kill all zombie newsgroups.
2919 The optional DUMMY should always be nil."
2920 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2922 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2923 (setq gnus-zombie-list nil)
2924 (gnus-dribble-touch)
2925 (gnus-group-list-groups)))
2927 (defun gnus-group-kill-region (begin end)
2928 "Kill newsgroups in current region (excluding current point).
2929 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2944 (beginning-of-line) ;Important when LINES < 1
2945 (gnus-group-kill-group lines)))
2947 (defun gnus-group-kill-group (&optional n discard)
2948 "Kill the next N groups.
2949 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2950 However, only groups that were alive can be yanked; already killed
2951 groups or zombie groups can't be yanked.
2952 The return value is the name of the group that was killed, or a list
2955 (let ((buffer-read-only nil)
2956 (groups (gnus-group-process-prefix n))
2957 group entry level out)
2958 (if (< (length groups) 10)
2959 ;; This is faster when there are few groups.
2961 (push (setq group (pop groups)) out)
2962 (gnus-group-remove-mark group)
2963 (setq level (gnus-group-group-level))
2965 (when (and (not discard)
2966 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2969 (gnus-group-goto-group ,(gnus-group-group-name))
2970 (gnus-group-yank-group)))
2971 (push (cons (car entry) (nth 2 entry))
2972 gnus-list-of-killed-groups))
2973 (gnus-group-change-level
2974 (if entry entry group) gnus-level-killed (if entry nil level))
2975 (message "Killed group %s" group))
2976 ;; If there are lots and lots of groups to be killed, we use
2977 ;; this thing instead.
2979 (setq groups (nreverse groups))
2981 (gnus-group-remove-mark (setq group (pop groups)))
2983 (push group gnus-killed-list)
2984 (setq gnus-newsrc-alist
2985 (delq (assoc group gnus-newsrc-alist)
2987 (when gnus-group-change-level-function
2988 (funcall gnus-group-change-level-function
2989 group gnus-level-killed 3))
2991 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2992 (push (cons (car entry) (nth 2 entry))
2993 gnus-list-of-killed-groups)
2994 (setcdr (cdr entry) (cdddr entry)))
2995 ((member group gnus-zombie-list)
2996 (setq gnus-zombie-list (delete group gnus-zombie-list))))
2997 ;; There may be more than one instance displayed.
2998 (while (gnus-group-goto-group group)
2999 (gnus-delete-line)))
3000 (gnus-make-hashtable-from-newsrc-alist)))
3002 (gnus-group-position-point)
3003 (if (< (length out) 2) (car out) (nreverse out))))
3005 (defun gnus-group-yank-group (&optional arg)
3006 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3007 The numeric ARG specifies how many newsgroups are to be yanked. The
3008 name of the newsgroup yanked is returned, or (if several groups are
3009 yanked) a list of yanked groups is returned."
3011 (setq arg (or arg 1))
3012 (let (info group prev out)
3013 (while (>= (decf arg) 0)
3014 (when (not (setq info (pop gnus-list-of-killed-groups)))
3015 (error "No more newsgroups to yank"))
3016 (push (setq group (nth 1 info)) out)
3017 ;; Find which newsgroup to insert this one before - search
3018 ;; backward until something suitable is found. If there are no
3019 ;; other newsgroups in this buffer, just make this newsgroup the
3021 (setq prev (gnus-group-group-name))
3022 (gnus-group-change-level
3023 info (gnus-info-level (cdr info)) gnus-level-killed
3024 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3026 (gnus-group-insert-group-line-info group)
3028 `(when (gnus-group-goto-group ,group)
3029 (gnus-group-kill-group 1))))
3031 (gnus-group-position-point)
3032 (if (< (length out) 2) (car out) (nreverse out))))
3034 (defun gnus-group-kill-level (level)
3035 "Kill all groups that is on a certain LEVEL."
3036 (interactive "nKill all groups on level: ")
3038 ((= level gnus-level-zombie)
3039 (setq gnus-killed-list
3040 (nconc gnus-zombie-list gnus-killed-list))
3041 (setq gnus-zombie-list nil))
3042 ((and (< level gnus-level-zombie)
3044 (or gnus-expert-user
3047 "Do you really want to kill all groups on level %d? "
3049 (let* ((prev gnus-newsrc-alist)
3052 (if (= (gnus-info-level (car alist)) level)
3054 (push (gnus-info-group (car alist)) gnus-killed-list)
3055 (setcdr prev (cdr alist)))
3057 (setq alist (cdr alist)))
3058 (gnus-make-hashtable-from-newsrc-alist)
3059 (gnus-group-list-groups)))
3061 (error "Can't kill; invalid level: %d" level))))
3063 (defun gnus-group-list-all-groups (&optional arg)
3064 "List all newsgroups with level ARG or lower.
3065 Default is gnus-level-unsubscribed, which lists all subscribed and most
3066 unsubscribed groups."
3068 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3070 ;; Redefine this to list ALL killed groups if prefix arg used.
3071 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3072 (defun gnus-group-list-killed (&optional arg)
3073 "List all killed newsgroups in the group buffer.
3074 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3075 entail asking the server for the groups."
3077 ;; Find all possible killed newsgroups if arg.
3079 (gnus-get-killed-groups))
3080 (if (not gnus-killed-list)
3081 (gnus-message 6 "No killed groups")
3082 (let (gnus-group-list-mode)
3083 (funcall gnus-group-prepare-function
3084 gnus-level-killed t gnus-level-killed))
3085 (goto-char (point-min)))
3086 (gnus-group-position-point))
3088 (defun gnus-group-list-zombies ()
3089 "List all zombie newsgroups in the group buffer."
3091 (if (not gnus-zombie-list)
3092 (gnus-message 6 "No zombie groups")
3093 (let (gnus-group-list-mode)
3094 (funcall gnus-group-prepare-function
3095 gnus-level-zombie t gnus-level-zombie))
3096 (goto-char (point-min)))
3097 (gnus-group-position-point))
3099 (defun gnus-group-list-active ()
3100 "List all groups that are available from the server(s)."
3102 ;; First we make sure that we have really read the active file.
3103 (unless (gnus-read-active-file-p)
3104 (let ((gnus-read-active-file t)
3105 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3106 (gnus-read-active-file)))
3107 ;; Find all groups and sort them.
3115 (push (symbol-name sym) list)))
3119 (buffer-read-only nil)
3123 (setq group (pop groups))
3124 (gnus-add-text-properties
3125 (point) (prog1 (1+ (point))
3127 (gnus-group-name-decode group
3128 (gnus-group-name-charset
3131 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3133 'gnus-level (inline (gnus-group-level group)))))
3134 (goto-char (point-min))))
3136 (defun gnus-activate-all-groups (level)
3137 "Activate absolutely all groups."
3138 (interactive (list gnus-level-unsubscribed))
3139 (let ((gnus-activate-level level)
3140 (gnus-activate-foreign-newsgroups level))
3141 (gnus-group-get-new-news)))
3143 (defun gnus-group-get-new-news (&optional arg)
3144 "Get newly arrived articles.
3145 If ARG is a number, it specifies which levels you are interested in
3146 re-scanning. If ARG is non-nil and not a number, this will force
3147 \"hard\" re-reading of the active files from all servers."
3150 (let ((gnus-inhibit-demon t)
3151 ;; Binding this variable will inhibit multiple fetchings
3152 ;; of the same mail source.
3153 (nnmail-fetched-sources (list t)))
3154 (gnus-run-hooks 'gnus-get-new-news-hook)
3156 ;; Read any slave files.
3158 (gnus-master-read-slave-newsrc))
3160 ;; We might read in new NoCeM messages here.
3161 (when (and gnus-use-nocem
3163 (gnus-nocem-scan-groups))
3164 ;; If ARG is not a number, then we read the active file.
3165 (when (and arg (not (numberp arg)))
3166 (let ((gnus-read-active-file t))
3167 (gnus-read-active-file))
3170 ;; If the user wants it, we scan for new groups.
3171 (when (eq gnus-check-new-newsgroups 'always)
3172 (gnus-find-new-newsgroups)))
3174 (setq arg (gnus-group-default-level arg t))
3175 (if (and gnus-read-active-file (not arg))
3177 (gnus-read-active-file)
3178 (gnus-get-unread-articles arg))
3179 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3180 (gnus-get-unread-articles arg)))
3181 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3182 (gnus-group-list-groups (and (numberp arg)
3183 (max (car gnus-group-list-mode) arg)))))
3185 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3186 "Check for newly arrived news in the current group (and the N-1 next groups).
3187 The difference between N and the number of newsgroup checked is returned.
3188 If N is negative, this group and the N-1 previous groups will be checked."
3190 (let* ((groups (gnus-group-process-prefix n))
3191 (ret (if (numberp n) (- n (length groups)) 0))
3195 (gnus-inhibit-demon t)
3196 ;; Binding this variable will inhibit multiple fetchings
3197 ;; of the same mail source.
3198 (nnmail-fetched-sources (list t)))
3199 (gnus-run-hooks 'gnus-get-new-news-hook)
3200 (while (setq group (pop groups))
3201 (gnus-group-remove-mark group)
3202 ;; Bypass any previous denials from the server.
3203 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3204 (if (gnus-activate-group group (if dont-scan nil 'scan))
3206 (gnus-get-unread-articles-in-group
3207 (gnus-get-info group) (gnus-active group) t)
3208 (unless (gnus-virtual-group-p group)
3209 (gnus-close-group group))
3211 (gnus-agent-save-group-info
3212 method (gnus-group-real-name group) (gnus-active group)))
3213 (gnus-group-update-group group))
3214 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3216 (gnus-error 3 "Server denied access")
3217 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3220 (when gnus-goto-next-group-when-activating
3221 (gnus-group-next-unread-group 1 t))
3222 (gnus-summary-position-point)
3225 (defun gnus-group-fetch-faq (group &optional faq-dir)
3226 "Fetch the FAQ for the current group.
3227 If given a prefix argument, prompt for the FAQ dir
3231 (gnus-group-group-name)
3232 (when current-prefix-arg
3234 "Faq dir: " (and (listp gnus-group-faq-directory)
3235 (mapcar (lambda (file) (list file))
3236 gnus-group-faq-directory))))))
3238 (error "No group name given"))
3239 (let ((dirs (or faq-dir gnus-group-faq-directory))
3241 (unless (listp dirs)
3242 (setq dirs (list dirs)))
3243 (while (and (not found)
3244 (setq dir (pop dirs)))
3245 (let ((name (gnus-group-real-name group)))
3246 (setq file (concat (file-name-as-directory dir) name)))
3247 (if (not (file-exists-p file))
3248 (gnus-message 1 "No such file: %s" file)
3249 (let ((enable-local-variables nil))
3253 (defun gnus-group-describe-group (force &optional group)
3254 "Display a description of the current newsgroup."
3255 (interactive (list current-prefix-arg (gnus-group-group-name)))
3256 (let* ((method (gnus-find-method-for-group group))
3257 (mname (gnus-group-prefixed-name "" method))
3260 gnus-description-hashtb)
3261 (gnus-sethash mname nil gnus-description-hashtb))
3263 (error "No group name given"))
3264 (when (or (and gnus-description-hashtb
3265 ;; We check whether this group's method has been
3266 ;; queried for a description file.
3267 (gnus-gethash mname gnus-description-hashtb))
3268 (setq desc (gnus-group-get-description group))
3269 (gnus-read-descriptions-file method))
3271 (or desc (gnus-gethash group gnus-description-hashtb)
3272 "No description available")))))
3274 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3275 (defun gnus-group-describe-all-groups (&optional force)
3276 "Pop up a buffer with descriptions of all newsgroups."
3279 (setq gnus-description-hashtb nil))
3280 (when (not (or gnus-description-hashtb
3281 (gnus-read-all-descriptions-files)))
3282 (error "Couldn't request descriptions file"))
3283 (let ((buffer-read-only nil)
3289 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3290 (insert (format " *: %-20s %s\n"
3291 (gnus-group-name-decode
3292 (symbol-name group) charset)
3293 (gnus-group-name-decode
3294 (symbol-value group) charset))))
3295 (gnus-add-text-properties
3296 b (1+ b) (list 'gnus-group group
3297 'gnus-unread t 'gnus-marked nil
3298 'gnus-level (1+ gnus-level-subscribed))))
3299 gnus-description-hashtb)
3300 (goto-char (point-min))
3301 (gnus-group-position-point)))
3303 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3304 (defun gnus-group-apropos (regexp &optional search-description)
3305 "List all newsgroups that have names that match a regexp."
3306 (interactive "sGnus apropos (regexp): ")
3308 (obuf (current-buffer))
3310 ;; Go through all newsgroups that are known to Gnus.
3313 (and (symbol-name group)
3314 (string-match regexp (symbol-name group))
3315 (symbol-value group)
3316 (push (symbol-name group) groups)))
3318 ;; Also go through all descriptions that are known to Gnus.
3319 (when search-description
3322 (and (string-match regexp (symbol-value group))
3323 (push (symbol-name group) groups)))
3324 gnus-description-hashtb))
3326 (gnus-message 3 "No groups matched \"%s\"." regexp)
3327 ;; Print out all the groups.
3329 (pop-to-buffer "*Gnus Help*")
3330 (buffer-disable-undo)
3332 (setq groups (sort groups 'string<))
3334 ;; Groups may be entered twice into the list of groups.
3335 (when (not (string= (car groups) prev))
3336 (setq prev (car groups))
3337 (let ((charset (gnus-group-name-charset nil prev)))
3338 (insert (gnus-group-name-decode prev charset) "\n")
3339 (when (and gnus-description-hashtb
3340 (setq des (gnus-gethash (car groups)
3341 gnus-description-hashtb)))
3342 (insert " " (gnus-group-name-decode des charset) "\n"))))
3343 (setq groups (cdr groups)))
3344 (goto-char (point-min))))
3345 (pop-to-buffer obuf)))
3347 (defun gnus-group-description-apropos (regexp)
3348 "List all newsgroups that have names or descriptions that match a regexp."
3349 (interactive "sGnus description apropos (regexp): ")
3350 (when (not (or gnus-description-hashtb
3351 (gnus-read-all-descriptions-files)))
3352 (error "Couldn't request descriptions file"))
3353 (gnus-group-apropos regexp t))
3355 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3356 (defun gnus-group-list-matching (level regexp &optional all lowest)
3357 "List all groups with unread articles that match REGEXP.
3358 If the prefix LEVEL is non-nil, it should be a number that says which
3359 level to cut off listing groups.
3360 If ALL, also list groups with no unread articles.
3361 If LOWEST, don't list groups with level lower than LOWEST.
3363 This command may read the active file."
3364 (interactive "P\nsList newsgroups matching: ")
3365 ;; First make sure active file has been read.
3367 (> (prefix-numeric-value level) gnus-level-killed))
3368 (gnus-get-killed-groups))
3369 (gnus-group-prepare-flat
3370 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3371 (goto-char (point-min))
3372 (gnus-group-position-point))
3374 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3375 "List all groups that match REGEXP.
3376 If the prefix LEVEL is non-nil, it should be a number that says which
3377 level to cut off listing groups.
3378 If LOWEST, don't list groups with level lower than LOWEST."
3379 (interactive "P\nsList newsgroups matching: ")
3381 (setq level (prefix-numeric-value level)))
3382 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3384 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3385 (defun gnus-group-save-newsrc (&optional force)
3386 "Save the Gnus startup files.
3387 If FORCE, force saving whether it is necessary or not."
3389 (gnus-save-newsrc-file force))
3391 (defun gnus-group-restart (&optional arg)
3392 "Force Gnus to read the .newsrc file."
3394 (when (gnus-yes-or-no-p
3395 (format "Are you sure you want to restart Gnus? "))
3396 (gnus-save-newsrc-file)
3400 (defun gnus-group-read-init-file ()
3401 "Read the Gnus elisp init file."
3403 (gnus-read-init-file)
3404 (gnus-message 5 "Read %s" gnus-init-file))
3406 (defun gnus-group-check-bogus-groups (&optional silent)
3407 "Check bogus newsgroups.
3408 If given a prefix, don't ask for confirmation before removing a bogus
3411 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3412 (gnus-group-list-groups))
3414 (defun gnus-group-find-new-groups (&optional arg)
3415 "Search for new groups and add them.
3416 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3417 With 1 C-u, use the `ask-server' method to query the server for new
3419 With 2 C-u's, use most complete method possible to query the server
3420 for new groups, and subscribe the new groups as zombies."
3422 (gnus-find-new-newsgroups (or arg 1))
3423 (gnus-group-list-groups))
3425 (defun gnus-group-edit-global-kill (&optional article group)
3426 "Edit the global kill file.
3427 If GROUP, edit that local kill file instead."
3429 (setq gnus-current-kill-article article)
3430 (gnus-kill-file-edit-file group)
3433 (substitute-command-keys
3434 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3435 (if group "local" "global")))))
3437 (defun gnus-group-edit-local-kill (article group)
3438 "Edit a local kill file."
3439 (interactive (list nil (gnus-group-group-name)))
3440 (gnus-group-edit-global-kill article group))
3442 (defun gnus-group-force-update ()
3443 "Update `.newsrc' file."
3445 (gnus-save-newsrc-file))
3447 (defun gnus-group-suspend ()
3448 "Suspend the current Gnus session.
3449 In fact, cleanup buffers except for group mode buffer.
3450 The hook gnus-suspend-gnus-hook is called before actually suspending."
3452 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3453 ;; Kill Gnus buffers except for group mode buffer.
3454 (let ((group-buf (get-buffer gnus-group-buffer)))
3455 (mapcar (lambda (buf)
3456 (unless (member buf (list group-buf gnus-dribble-buffer))
3459 (gnus-kill-gnus-frames)
3461 (bury-buffer group-buf)
3462 (delete-windows-on group-buf t))))
3464 (defun gnus-group-clear-dribble ()
3465 "Clear all information from the dribble buffer."
3467 (gnus-dribble-clear)
3468 (gnus-message 7 "Cleared dribble buffer"))
3470 (defun gnus-group-exit ()
3471 "Quit reading news after updating .newsrc.eld and .newsrc.
3472 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3475 (or noninteractive ;For gnus-batch-kill
3476 (not gnus-interactive-exit) ;Without confirmation
3478 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3479 (gnus-run-hooks 'gnus-exit-gnus-hook)
3480 ;; Offer to save data from non-quitted summary buffers.
3481 (gnus-offer-save-summaries)
3482 ;; Save the newsrc file(s).
3483 (gnus-save-newsrc-file)
3485 (gnus-close-backends)
3486 ;; Reset everything.
3488 ;; Allow the user to do things after cleaning up.
3489 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3491 (defun gnus-group-quit ()
3492 "Quit reading news without updating .newsrc.eld or .newsrc.
3493 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3495 (when (or noninteractive ;For gnus-batch-kill
3496 (zerop (buffer-size))
3497 (not (gnus-server-opened gnus-select-method))
3499 (not gnus-current-startup-file)
3501 (format "Quit reading news without saving %s? "
3502 (file-name-nondirectory gnus-current-startup-file))))
3503 (gnus-run-hooks 'gnus-exit-gnus-hook)
3504 (gnus-configure-windows 'group t)
3506 (gnus-close-backends)
3508 (gnus-kill-buffer gnus-group-buffer)
3509 ;; Allow the user to do things after cleaning up.
3510 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3512 (defun gnus-group-describe-briefly ()
3513 "Give a one line description of the group mode commands."
3515 (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")))
3517 (defun gnus-group-browse-foreign-server (method)
3518 "Browse a foreign news server.
3519 If called interactively, this function will ask for a select method
3520 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3521 If not, METHOD should be a list where the first element is the method
3522 and the second element is the address."
3524 (list (let ((how (completing-read
3526 (append gnus-valid-select-methods gnus-server-alist)
3527 nil t (cons "nntp" 0) 'gnus-method-history)))
3528 ;; We either got a backend name or a virtual server name.
3529 ;; If the first, we also need an address.
3530 (if (assoc how gnus-valid-select-methods)
3532 ;; Suggested by mapjph@bath.ac.uk.
3535 (mapcar (lambda (server) (list server))
3536 gnus-secondary-servers)))
3537 ;; We got a server name.
3539 (gnus-browse-foreign-server method))
3541 (defun gnus-group-set-info (info &optional method-only-group part)
3542 (when (or info part)
3543 (let* ((entry (gnus-gethash
3544 (or method-only-group (gnus-info-group info))
3545 gnus-newsrc-hashtb))
3547 (info (if method-only-group (nth 2 entry) info))
3549 (when method-only-group
3551 (error "Trying to change non-existent group %s" method-only-group))
3552 ;; We have received parts of the actual group info - either the
3553 ;; select method or the group parameters. We first check
3554 ;; whether we have to extend the info, and if so, do that.
3555 (let ((len (length info))
3556 (total (if (eq part 'method) 5 6)))
3558 (setcdr (nthcdr (1- len) info)
3559 (make-list (- total len) nil)))
3560 ;; Then we enter the new info.
3561 (setcar (nthcdr (1- total) info) part-info)))
3563 ;; This is a new group, so we just create it.
3565 (set-buffer gnus-group-buffer)
3566 (setq method (gnus-info-method info))
3567 (when (gnus-server-equal method "native")
3570 (set-buffer gnus-group-buffer)
3572 ;; It's a foreign group...
3573 (gnus-group-make-group
3574 (gnus-group-real-name (gnus-info-group info))
3575 (if (stringp method) method
3576 (prin1-to-string (car method)))
3578 (nth 1 (gnus-info-method info))))
3579 ;; It's a native group.
3580 (gnus-group-make-group (gnus-info-group info))))
3581 (gnus-message 6 "Note: New group created")
3583 (gnus-gethash (gnus-group-prefixed-name
3584 (gnus-group-real-name (gnus-info-group info))
3585 (or (gnus-info-method info) gnus-select-method))
3586 gnus-newsrc-hashtb))))
3587 ;; Whether it was a new group or not, we now have the entry, so we
3588 ;; can do the update.
3591 (setcar (nthcdr 2 entry) info)
3592 (when (and (not (eq (car entry) t))
3593 (gnus-active (gnus-info-group info)))
3594 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3595 (error "No such group: %s" (gnus-info-group info))))))
3597 (defun gnus-group-set-method-info (group select-method)
3598 (gnus-group-set-info select-method group 'method))
3600 (defun gnus-group-set-params-info (group params)
3601 (gnus-group-set-info params group 'params))
3603 (defun gnus-add-marked-articles (group type articles &optional info force)
3604 ;; Add ARTICLES of TYPE to the info of GROUP.
3605 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3606 ;; add, but replace marked articles of TYPE with ARTICLES.
3607 (let ((info (or info (gnus-get-info group)))
3610 (and (not (setq marked (nthcdr 3 info)))
3612 (setcdr (nthcdr 2 info)
3613 (list (list (cons type (gnus-compress-sequence
3615 (and (not (setq m (assq type (car marked))))
3618 (cons (cons type (gnus-compress-sequence articles t) )
3622 (setcar (nthcdr 3 info)
3623 (gnus-delete-alist type (car marked)))
3624 (setcdr m (gnus-compress-sequence articles t)))
3625 (setcdr m (gnus-compress-sequence
3626 (sort (nconc (gnus-uncompress-range (cdr m))
3627 (copy-sequence articles)) '<) t))))))
3630 ;;; Group timestamps
3633 (defun gnus-group-set-timestamp ()
3634 "Change the timestamp of the current group to the current time.
3635 This function can be used in hooks like `gnus-select-group-hook'
3636 or `gnus-group-catchup-group-hook'."
3637 (when gnus-newsgroup-name
3638 (let ((time (current-time)))
3639 (setcdr (cdr time) nil)
3640 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3642 (defsubst gnus-group-timestamp (group)
3643 "Return the timestamp for GROUP."
3644 (gnus-group-get-parameter group 'timestamp t))
3646 (defun gnus-group-timestamp-delta (group)
3647 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3648 (let* ((time (or (gnus-group-timestamp group)
3650 (delta (subtract-time (current-time) time)))
3651 (+ (* (nth 0 delta) 65536.0)
3654 (defun gnus-group-timestamp-string (group)
3655 "Return a string of the timestamp for GROUP."
3656 (let ((time (gnus-group-timestamp group)))
3659 (gnus-time-iso8601 time))))
3661 (defun gnus-group-prepare-flat-list-dead-predicate
3662 (groups level mark predicate)
3665 ;; This loop is used when listing groups that match some
3667 (while (setq group (pop groups))
3668 (when (funcall predicate group)
3669 (gnus-add-text-properties
3670 (point) (prog1 (1+ (point))
3671 (insert " " mark " *: "
3672 (gnus-group-name-decode group
3673 (gnus-group-name-charset
3676 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3678 'gnus-level level)))))))
3680 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest
3682 "List all newsgroups with unread articles of level LEVEL or lower.
3683 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3684 If PREDICATE, only list groups which PREDICATE returns non-nil.
3685 If DEAD-PREDICATE, list dead groups which DEAD-PREDICATE returns non-nil."
3686 (set-buffer gnus-group-buffer)
3687 (let ((buffer-read-only nil)
3688 (newsrc (cdr gnus-newsrc-alist))
3689 (lowest (or lowest 1))
3690 info clevel unread group params)
3692 ;; List living groups.
3694 (setq info (car newsrc)
3695 group (gnus-info-group info)
3696 params (gnus-info-params info)
3698 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3699 (and unread ; This group might be unchecked
3700 (funcall predicate info)
3701 (<= (setq clevel (gnus-info-level info)) level)
3703 (gnus-group-insert-group-line
3704 group (gnus-info-level info)
3705 (gnus-info-marks info) unread (gnus-info-method info))))
3707 ;; List dead groups.
3708 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3709 (gnus-group-prepare-flat-list-dead-predicate
3710 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3711 gnus-level-zombie ?Z
3713 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3714 (gnus-group-prepare-flat-list-dead-predicate
3715 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3716 gnus-level-killed ?K dead-predicate))
3718 (gnus-group-set-mode-line)
3719 (setq gnus-group-list-mode (cons level t))
3720 (gnus-run-hooks 'gnus-group-prepare-hook)
3723 (defun gnus-group-list-cached (level &optional lowest)
3724 "List all groups with cached articles.
3725 If the prefix LEVEL is non-nil, it should be a number that says which
3726 level to cut off listing groups.
3727 If LOWEST, don't list groups with level lower than LOWEST.
3729 This command may read the active file."
3732 (setq level (prefix-numeric-value level)))
3733 (when (or (not level) (>= level gnus-level-zombie))
3735 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3737 (let ((marks (gnus-info-marks info)))
3738 (assq 'cache marks)))
3741 (or (gnus-gethash group
3742 gnus-cache-active-hashtb)
3743 ;; Cache active file might use "."
3746 (mapconcat 'identity
3747 (split-string group ":")
3749 gnus-cache-active-hashtb))))
3750 (goto-char (point-min))
3751 (gnus-group-position-point))
3753 (defun gnus-group-list-dormant (level &optional lowest)
3754 "List all groups with dormant articles.
3755 If the prefix LEVEL is non-nil, it should be a number that says which
3756 level to cut off listing groups.
3757 If LOWEST, don't list groups with level lower than LOWEST.
3759 This command may read the active file."
3762 (setq level (prefix-numeric-value level)))
3763 (when (or (not level) (>= level gnus-level-zombie))
3765 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3767 (let ((marks (gnus-info-marks info)))
3768 (assq 'dormant marks)))
3770 (goto-char (point-min))
3771 (gnus-group-position-point))
3773 (provide 'gnus-group)
3775 ;;; gnus-group.el ends here