1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996-2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
40 (defcustom gnus-group-archive-directory
41 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
42 "*The address of the (ding) archives."
43 :group 'gnus-group-foreign
46 (defcustom gnus-group-recent-archive-directory
47 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
48 "*The address of the most recent (ding) articles."
49 :group 'gnus-group-foreign
52 (defcustom gnus-no-groups-message "No gnus is bad news"
53 "*Message displayed by Gnus when no groups are available."
57 (defcustom gnus-keep-same-level nil
58 "*Non-nil means that the next newsgroup after the current will be on the same level.
59 When you type, for instance, `n' after reading the last article in the
60 current newsgroup, you will go to the next newsgroup. If this variable
61 is nil, the next newsgroup will be the next from the group
63 If this variable is non-nil, Gnus will either put you in the
64 next newsgroup with the same level, or, if no such newsgroup is
65 available, the next newsgroup with the lowest possible level higher
66 than the current level.
67 If this variable is `best', Gnus will make the next newsgroup the one
69 :group 'gnus-group-levels
70 :type '(choice (const nil)
72 (sexp :tag "other" t)))
74 (defcustom gnus-group-goto-unread t
75 "*If non-nil, movement commands will go to the next unread and subscribed group."
76 :link '(custom-manual "(gnus)Group Maneuvering")
77 :group 'gnus-group-various
80 (defcustom gnus-goto-next-group-when-activating t
81 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
82 :link '(custom-manual "(gnus)Scanning New Messages")
83 :group 'gnus-group-various
86 (defcustom gnus-permanently-visible-groups nil
87 "*Regexp to match groups that should always be listed in the group buffer.
88 This means that they will still be listed even when there are no
89 unread articles in the groups.
91 If nil, no groups are permanently visible."
92 :group 'gnus-group-listing
93 :type '(choice regexp (const nil)))
95 (defcustom gnus-list-groups-with-ticked-articles t
96 "*If non-nil, list groups that have only ticked articles.
97 If nil, only list groups that have unread articles."
98 :group 'gnus-group-listing
101 (defcustom gnus-group-default-list-level gnus-level-subscribed
102 "*Default listing level.
103 Ignored if `gnus-group-use-permanent-levels' is non-nil."
104 :group 'gnus-group-listing
107 (defcustom gnus-group-list-inactive-groups t
108 "*If non-nil, inactive groups will be listed."
109 :group 'gnus-group-listing
110 :group 'gnus-group-levels
113 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
114 "*Function used for sorting the group buffer.
115 This function will be called with group info entries as the arguments
116 for the groups to be sorted. Pre-made functions include
117 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
118 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
119 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
120 `gnus-group-sort-by-rank'.
122 This variable can also be a list of sorting functions. In that case,
123 the most significant sort function should be the last function in the
125 :group 'gnus-group-listing
126 :link '(custom-manual "(gnus)Sorting Groups")
127 :type '(radio (function-item gnus-group-sort-by-alphabet)
128 (function-item gnus-group-sort-by-real-name)
129 (function-item gnus-group-sort-by-unread)
130 (function-item gnus-group-sort-by-level)
131 (function-item gnus-group-sort-by-score)
132 (function-item gnus-group-sort-by-method)
133 (function-item gnus-group-sort-by-rank)
134 (function :tag "other" nil)))
136 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
137 "*Format of group lines.
138 It works along the same lines as a normal formatting string,
139 with some simple extensions.
141 %M Only marked articles (character, \"*\" or \" \")
142 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
143 %L Level of subscribedness (integer)
144 %N Number of unread articles (integer)
145 %I Number of dormant articles (integer)
146 %i Number of ticked and dormant (integer)
147 %T Number of ticked articles (integer)
148 %R Number of read articles (integer)
149 %t Estimated total number of articles (integer)
150 %y Number of unread, unticked articles (integer)
151 %G Group name (string)
152 %g Qualified group name (string)
153 %D Group description (string)
154 %s Select method (string)
155 %o Moderated group (char, \"m\")
156 %p Process mark (char)
157 %O Moderated group (string, \"(m)\" or \"\")
158 %P Topic indentation (string)
159 %m Whether there is new(ish) mail in the group (char, \"%\")
160 %l Whether there are GroupLens predictions for this group (string)
161 %n Select from where (string)
162 %z A string that look like `<%s:%n>' if a foreign select method is used
163 %d The date the group was last entered.
164 %E Icon as defined by `gnus-group-icon-list'.
165 %u User defined specifier. The next character in the format string should
166 be a letter. Gnus will call the function gnus-user-format-function-X,
167 where X is the letter following %u. The function will be passed the
168 current header as argument. The function should return a string, which
169 will be inserted into the buffer just like information from any other
172 Text between %( and %) will be highlighted with `gnus-mouse-face' when
173 the mouse point move inside the area. There can only be one such area.
175 Note that this format specification is not always respected. For
176 reasons of efficiency, when listing killed groups, this specification
177 is ignored altogether. If the spec is changed considerably, your
178 output may end up looking strange when listing both alive and killed
181 If you use %o or %O, reading the active file will be slower and quite
182 a bit of extra memory will be used. %D will also worsen performance.
183 Also note that if you change the format specification to include any
184 of these specs, you must probably re-start Gnus to see them go into
186 :group 'gnus-group-visual
189 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
190 "*The format specification for the group mode line.
191 It works along the same lines as a normal formatting string,
192 with some simple extensions:
194 %S The native news server.
195 %M The native select method.
196 %: \":\" if %S isn't \"\"."
197 :group 'gnus-group-visual
200 (defcustom gnus-group-mode-hook nil
201 "Hook for Gnus group mode."
202 :group 'gnus-group-various
203 :options '(gnus-topic-mode)
206 (defcustom gnus-group-menu-hook nil
207 "Hook run after the creation of the group mode menu."
208 :group 'gnus-group-various
211 (defcustom gnus-group-catchup-group-hook nil
212 "Hook run when catching up a group from the group buffer."
213 :group 'gnus-group-various
214 :link '(custom-manual "(gnus)Group Data")
217 (defcustom gnus-group-update-group-hook nil
218 "Hook called when updating group lines."
219 :group 'gnus-group-visual
222 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
223 "*A function that is called to generate the group buffer.
224 The function is called with three arguments: The first is a number;
225 all group with a level less or equal to that number should be listed,
226 if the second is non-nil, empty groups should also be displayed. If
227 the third is non-nil, it is a number. No groups with a level lower
228 than this number should be displayed.
230 The only current function implemented is `gnus-group-prepare-flat'."
231 :group 'gnus-group-listing
234 (defcustom gnus-group-prepare-hook nil
235 "Hook called after the group buffer has been generated.
236 If you want to modify the group buffer, you can use this hook."
237 :group 'gnus-group-listing
240 (defcustom gnus-suspend-gnus-hook nil
241 "Hook called when suspending (not exiting) Gnus."
245 (defcustom gnus-exit-gnus-hook nil
246 "Hook called when exiting Gnus."
250 (defcustom gnus-after-exiting-gnus-hook nil
251 "Hook called after exiting Gnus."
255 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
256 "Hook called when a group line is changed.
257 The hook will not be called if `gnus-visual' is nil.
259 The default function `gnus-group-highlight-line' will
260 highlight the line according to the `gnus-group-highlight'
262 :group 'gnus-group-visual
265 (defcustom gnus-useful-groups
266 '(("(ding) mailing list mirrored at sunsite.auc.dk"
268 (nntp "sunsite.auc.dk"
269 (nntp-address "sunsite.auc.dk")))
272 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
276 (nndoc-article-type mbox)
277 (eval `(nndoc-address
278 ,(let ((file (nnheader-find-etc-directory
281 (error "Couldn't find doc group"))
283 "*Alist of useful group-server pairs."
284 :group 'gnus-group-listing
285 :type '(repeat (list (string :tag "Description")
287 (sexp :tag "Method"))))
289 (defcustom gnus-group-highlight
291 ((and (= unread 0) (not mailp) (eq level 1)) .
292 gnus-group-news-1-empty-face)
293 ((and (not mailp) (eq level 1)) .
294 gnus-group-news-1-face)
295 ((and (= unread 0) (not mailp) (eq level 2)) .
296 gnus-group-news-2-empty-face)
297 ((and (not mailp) (eq level 2)) .
298 gnus-group-news-2-face)
299 ((and (= unread 0) (not mailp) (eq level 3)) .
300 gnus-group-news-3-empty-face)
301 ((and (not mailp) (eq level 3)) .
302 gnus-group-news-3-face)
303 ((and (= unread 0) (not mailp) (eq level 4)) .
304 gnus-group-news-4-empty-face)
305 ((and (not mailp) (eq level 4)) .
306 gnus-group-news-4-face)
307 ((and (= unread 0) (not mailp) (eq level 5)) .
308 gnus-group-news-5-empty-face)
309 ((and (not mailp) (eq level 5)) .
310 gnus-group-news-5-face)
311 ((and (= unread 0) (not mailp) (eq level 6)) .
312 gnus-group-news-6-empty-face)
313 ((and (not mailp) (eq level 6)) .
314 gnus-group-news-6-face)
315 ((and (= unread 0) (not mailp)) .
316 gnus-group-news-low-empty-face)
318 gnus-group-news-low-face)
320 ((and (= unread 0) (eq level 1)) .
321 gnus-group-mail-1-empty-face)
323 gnus-group-mail-1-face)
324 ((and (= unread 0) (eq level 2)) .
325 gnus-group-mail-2-empty-face)
327 gnus-group-mail-2-face)
328 ((and (= unread 0) (eq level 3)) .
329 gnus-group-mail-3-empty-face)
331 gnus-group-mail-3-face)
333 gnus-group-mail-low-empty-face)
335 gnus-group-mail-low-face))
336 "*Controls the highlighting of group buffer lines.
338 Below is a list of `Form'/`Face' pairs. When deciding how a a
339 particular group line should be displayed, each form is
340 evaluated. The content of the face field after the first true form is
341 used. You can change how those group lines are displayed by
342 editing the face field.
344 It is also possible to change and add form fields, but currently that
345 requires an understanding of Lisp expressions. Hopefully this will
346 change in a future release. For now, you can use the following
347 variables in the Lisp expression:
349 group: The name of the group.
350 unread: The number of unread articles in the group.
351 method: The select method used.
352 mailp: Whether it's a mail group or not.
353 level: The level of the group.
354 score: The score of the group.
355 ticked: The number of ticked articles."
356 :group 'gnus-group-visual
357 :type '(repeat (cons (sexp :tag "Form") face)))
359 (defcustom gnus-new-mail-mark ?%
360 "Mark used for groups with new mail."
361 :group 'gnus-group-visual
364 (defgroup gnus-group-icons nil
365 "Add Icons to your group buffer. "
366 :group 'gnus-group-visual)
368 (defcustom gnus-group-icon-list
370 "*Controls the insertion of icons into group buffer lines.
372 Below is a list of `Form'/`File' pairs. When deciding how a
373 particular group line should be displayed, each form is evaluated.
374 The icon from the file field after the first true form is used. You
375 can change how those group lines are displayed by editing the file
376 field. The File will either be found in the
377 `gnus-group-glyph-directory' or by designating absolute path to the
380 It is also possible to change and add form fields, but currently that
381 requires an understanding of Lisp expressions. Hopefully this will
382 change in a future release. For now, you can use the following
383 variables in the Lisp expression:
385 group: The name of the group.
386 unread: The number of unread articles in the group.
387 method: The select method used.
388 mailp: Whether it's a mail group or not.
389 newsp: Whether it's a news group or not
390 level: The level of the group.
391 score: The score of the group.
392 ticked: The number of ticked articles."
393 :group 'gnus-group-icons
394 :type '(repeat (cons (sexp :tag "Form") file)))
396 (defcustom gnus-group-glyph-directory gnus-xmas-glyph-directory
397 "*Directory where gnus group icons are located.
398 Defaults to `gnus-xmas-glyph-directory'."
399 :group 'gnus-group-icons
403 ;;; Internal variables
405 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
406 "Function for sorting the group buffer.")
408 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
409 "Function for sorting the selected groups in the group buffer.")
411 (defvar gnus-group-indentation-function nil)
412 (defvar gnus-goto-missing-group-function nil)
413 (defvar gnus-group-update-group-function nil)
414 (defvar gnus-group-goto-next-group-function nil
415 "Function to override finding the next group after listing groups.")
417 (defvar gnus-group-edit-buffer nil)
419 (defvar gnus-group-line-format-alist
420 `((?M gnus-tmp-marked-mark ?c)
421 (?S gnus-tmp-subscribed ?c)
422 (?L gnus-tmp-level ?d)
423 (?N (cond ((eq number t) "*" )
427 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
428 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
430 (?R gnus-tmp-number-of-read ?s)
431 (?t gnus-tmp-number-total ?d)
432 (?y gnus-tmp-number-of-unread ?s)
433 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
434 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
435 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
436 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
437 (?g gnus-tmp-group ?s)
438 (?G gnus-tmp-qualified-group ?s)
439 (?c (gnus-short-group-name gnus-tmp-group) ?s)
440 (?D gnus-tmp-newsgroup-description ?s)
441 (?o gnus-tmp-moderated ?c)
442 (?O gnus-tmp-moderated-string ?s)
443 (?p gnus-tmp-process-marked ?c)
444 (?s gnus-tmp-news-server ?s)
445 (?n gnus-tmp-news-method ?s)
446 (?P gnus-group-indentation ?s)
447 (?E gnus-tmp-group-icon ?s)
448 (?l gnus-tmp-grouplens ?s)
449 (?z gnus-tmp-news-method-string ?s)
450 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
451 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
452 (?u gnus-tmp-user-defined ?s)))
454 (defvar gnus-group-mode-line-format-alist
455 `((?S gnus-tmp-news-server ?s)
456 (?M gnus-tmp-news-method ?s)
457 (?u gnus-tmp-user-defined ?s)
458 (?: gnus-tmp-colon ?s)))
460 (defvar gnus-topic-topology nil
461 "The complete topic hierarchy.")
463 (defvar gnus-topic-alist nil
464 "The complete topic-group alist.")
466 (defvar gnus-group-marked nil)
468 (defvar gnus-group-list-mode nil)
471 (defvar gnus-group-icon-cache nil)
472 (defvar gnus-group-running-xemacs (string-match "XEmacs" emacs-version))
478 (put 'gnus-group-mode 'mode-class 'special)
481 (gnus-define-keys gnus-group-mode-map
482 " " gnus-group-read-group
483 "=" gnus-group-select-group
484 "\r" gnus-group-select-group
485 "\M-\r" gnus-group-quick-select-group
486 [(meta control return)] gnus-group-select-group-ephemerally
487 "j" gnus-group-jump-to-group
488 "n" gnus-group-next-unread-group
489 "p" gnus-group-prev-unread-group
490 "\177" gnus-group-prev-unread-group
491 [delete] gnus-group-prev-unread-group
492 [backspace] gnus-group-prev-unread-group
493 "N" gnus-group-next-group
494 "P" gnus-group-prev-group
495 "\M-n" gnus-group-next-unread-group-same-level
496 "\M-p" gnus-group-prev-unread-group-same-level
497 "," gnus-group-best-unread-group
498 "." gnus-group-first-unread-group
499 "u" gnus-group-unsubscribe-current-group
500 "U" gnus-group-unsubscribe-group
501 "c" gnus-group-catchup-current
502 "C" gnus-group-catchup-current-all
503 "\M-c" gnus-group-clear-data
504 "l" gnus-group-list-groups
505 "L" gnus-group-list-all-groups
507 "g" gnus-group-get-new-news
508 "\M-g" gnus-group-get-new-news-this-group
509 "R" gnus-group-restart
510 "r" gnus-group-read-init-file
511 "B" gnus-group-browse-foreign-server
512 "b" gnus-group-check-bogus-groups
513 "F" gnus-group-find-new-groups
514 "\C-c\C-d" gnus-group-describe-group
515 "\M-d" gnus-group-describe-all-groups
516 "\C-c\C-a" gnus-group-apropos
517 "\C-c\M-\C-a" gnus-group-description-apropos
518 "a" gnus-group-post-news
519 "\ek" gnus-group-edit-local-kill
520 "\eK" gnus-group-edit-global-kill
521 "\C-k" gnus-group-kill-group
522 "\C-y" gnus-group-yank-group
523 "\C-w" gnus-group-kill-region
524 "\C-x\C-t" gnus-group-transpose-groups
525 "\C-c\C-l" gnus-group-list-killed
526 "\C-c\C-x" gnus-group-expire-articles
527 "\C-c\M-\C-x" gnus-group-expire-all-groups
529 "s" gnus-group-save-newsrc
530 "z" gnus-group-suspend
533 "?" gnus-group-describe-briefly
534 "\C-c\C-i" gnus-info-find-node
535 "\M-e" gnus-group-edit-group-method
536 "^" gnus-group-enter-server-mode
537 gnus-mouse-2 gnus-mouse-pick-group
538 "<" beginning-of-buffer
541 "\C-c\C-s" gnus-group-sort-groups
543 "\C-c\M-g" gnus-activate-all-groups
544 "\M-&" gnus-group-universal-argument
545 "#" gnus-group-mark-group
546 "\M-#" gnus-group-unmark-group)
548 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
549 "m" gnus-group-mark-group
550 "u" gnus-group-unmark-group
551 "w" gnus-group-mark-region
552 "b" gnus-group-mark-buffer
553 "r" gnus-group-mark-regexp
554 "U" gnus-group-unmark-all-groups)
556 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
557 "d" gnus-group-make-directory-group
558 "h" gnus-group-make-help-group
559 "u" gnus-group-make-useful-group
560 "a" gnus-group-make-archive-group
561 "k" gnus-group-make-kiboze-group
562 "l" gnus-group-nnimap-edit-acl
563 "m" gnus-group-make-group
564 "E" gnus-group-edit-group
565 "e" gnus-group-edit-group-method
566 "p" gnus-group-edit-group-parameters
567 "v" gnus-group-add-to-virtual
568 "V" gnus-group-make-empty-virtual
569 "D" gnus-group-enter-directory
570 "f" gnus-group-make-doc-group
571 "w" gnus-group-make-web-group
572 "r" gnus-group-rename-group
573 "c" gnus-group-customize
574 "x" gnus-group-nnimap-expunge
575 "\177" gnus-group-delete-group
576 [delete] gnus-group-delete-group)
578 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
579 "b" gnus-group-brew-soup
580 "w" gnus-soup-save-areas
581 "s" gnus-soup-send-replies
582 "p" gnus-soup-pack-packet
583 "r" nnsoup-pack-replies)
585 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
586 "s" gnus-group-sort-groups
587 "a" gnus-group-sort-groups-by-alphabet
588 "u" gnus-group-sort-groups-by-unread
589 "l" gnus-group-sort-groups-by-level
590 "v" gnus-group-sort-groups-by-score
591 "r" gnus-group-sort-groups-by-rank
592 "m" gnus-group-sort-groups-by-method)
594 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
595 "s" gnus-group-sort-selected-groups
596 "a" gnus-group-sort-selected-groups-by-alphabet
597 "u" gnus-group-sort-selected-groups-by-unread
598 "l" gnus-group-sort-selected-groups-by-level
599 "v" gnus-group-sort-selected-groups-by-score
600 "r" gnus-group-sort-selected-groups-by-rank
601 "m" gnus-group-sort-selected-groups-by-method)
603 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
604 "k" gnus-group-list-killed
605 "z" gnus-group-list-zombies
606 "s" gnus-group-list-groups
607 "u" gnus-group-list-all-groups
608 "A" gnus-group-list-active
609 "a" gnus-group-apropos
610 "d" gnus-group-description-apropos
611 "m" gnus-group-list-matching
612 "M" gnus-group-list-all-matching
613 "l" gnus-group-list-level
614 "c" gnus-group-list-cached)
616 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
617 "f" gnus-score-flush-cache)
619 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
620 "d" gnus-group-describe-group
621 "f" gnus-group-fetch-faq
624 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
625 "l" gnus-group-set-current-level
626 "t" gnus-group-unsubscribe-current-group
627 "s" gnus-group-unsubscribe-group
628 "k" gnus-group-kill-group
629 "y" gnus-group-yank-group
630 "w" gnus-group-kill-region
631 "\C-k" gnus-group-kill-level
632 "z" gnus-group-kill-all-zombies))
634 (defun gnus-group-make-menu-bar ()
635 (gnus-turn-off-edit-menu 'group)
636 (unless (boundp 'gnus-group-reading-menu)
639 gnus-group-reading-menu gnus-group-mode-map ""
641 ["Read" gnus-group-read-group (gnus-group-group-name)]
642 ["Select" gnus-group-select-group (gnus-group-group-name)]
643 ["See old articles" (gnus-group-select-group 'all)
644 :keys "C-u SPC" :active (gnus-group-group-name)]
645 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
646 ["Catch up all articles" gnus-group-catchup-current-all
647 (gnus-group-group-name)]
648 ["Check for new articles" gnus-group-get-new-news-this-group
649 (gnus-group-group-name)]
650 ["Toggle subscription" gnus-group-unsubscribe-current-group
651 (gnus-group-group-name)]
652 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
653 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
654 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
655 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
656 ;; Actually one should check, if any of the marked groups gives t for
657 ;; (gnus-check-backend-function 'request-expire-articles ...)
658 ["Expire articles" gnus-group-expire-articles
659 (or (and (gnus-group-group-name)
660 (gnus-check-backend-function
661 'request-expire-articles
662 (gnus-group-group-name))) gnus-group-marked)]
663 ["Set group level" gnus-group-set-current-level
664 (gnus-group-group-name)]
665 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
666 ["Customize" gnus-group-customize (gnus-group-group-name)]
668 ["Parameters" gnus-group-edit-group-parameters
669 (gnus-group-group-name)]
670 ["Select method" gnus-group-edit-group-method
671 (gnus-group-group-name)]
672 ["Info" gnus-group-edit-group (gnus-group-group-name)]
673 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
674 ["Global kill file" gnus-group-edit-global-kill t])))
677 gnus-group-group-menu gnus-group-mode-map ""
680 ["List unread subscribed groups" gnus-group-list-groups t]
681 ["List (un)subscribed groups" gnus-group-list-all-groups t]
682 ["List killed groups" gnus-group-list-killed gnus-killed-list]
683 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
684 ["List level..." gnus-group-list-level t]
685 ["Describe all groups" gnus-group-describe-all-groups t]
686 ["Group apropos..." gnus-group-apropos t]
687 ["Group and description apropos..." gnus-group-description-apropos t]
688 ["List groups matching..." gnus-group-list-matching t]
689 ["List all groups matching..." gnus-group-list-all-matching t]
690 ["List active file" gnus-group-list-active t]
691 ["List groups with cached" gnus-group-list-cached t])
693 ["Default sort" gnus-group-sort-groups t]
694 ["Sort by method" gnus-group-sort-groups-by-method t]
695 ["Sort by rank" gnus-group-sort-groups-by-rank t]
696 ["Sort by score" gnus-group-sort-groups-by-score t]
697 ["Sort by level" gnus-group-sort-groups-by-level t]
698 ["Sort by unread" gnus-group-sort-groups-by-unread t]
699 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
700 ("Sort process/prefixed"
701 ["Default sort" gnus-group-sort-selected-groups
702 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
703 ["Sort by method" gnus-group-sort-selected-groups-by-method
704 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
705 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
706 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
707 ["Sort by score" gnus-group-sort-selected-groups-by-score
708 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
709 ["Sort by level" gnus-group-sort-selected-groups-by-level
710 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
711 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
712 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
713 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
714 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
716 ["Mark group" gnus-group-mark-group
717 (and (gnus-group-group-name)
718 (not (memq (gnus-group-group-name) gnus-group-marked)))]
719 ["Unmark group" gnus-group-unmark-group
720 (and (gnus-group-group-name)
721 (memq (gnus-group-group-name) gnus-group-marked))]
722 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
723 ["Mark regexp..." gnus-group-mark-regexp t]
724 ["Mark region" gnus-group-mark-region t]
725 ["Mark buffer" gnus-group-mark-buffer t]
726 ["Execute command" gnus-group-universal-argument
727 (or gnus-group-marked (gnus-group-group-name))])
729 ["Subscribe to a group" gnus-group-unsubscribe-group t]
730 ["Kill all newsgroups in region" gnus-group-kill-region t]
731 ["Kill all zombie groups" gnus-group-kill-all-zombies
733 ["Kill all groups on level..." gnus-group-kill-level t])
735 ["Make a foreign group" gnus-group-make-group t]
736 ["Add a directory group" gnus-group-make-directory-group t]
737 ["Add the help group" gnus-group-make-help-group t]
738 ["Add the archive group" gnus-group-make-archive-group t]
739 ["Make a doc group" gnus-group-make-doc-group t]
740 ["Make a web group" gnus-group-make-web-group t]
741 ["Make a kiboze group" gnus-group-make-kiboze-group t]
742 ["Make a virtual group" gnus-group-make-empty-virtual t]
743 ["Add a group to a virtual" gnus-group-add-to-virtual t]
744 ["Rename group" gnus-group-rename-group
745 (gnus-check-backend-function
746 'request-rename-group (gnus-group-group-name))]
747 ["Delete group" gnus-group-delete-group
748 (gnus-check-backend-function
749 'request-delete-group (gnus-group-group-name))])
751 ["Next" gnus-group-next-group t]
752 ["Previous" gnus-group-prev-group t]
753 ["Next unread" gnus-group-next-unread-group t]
754 ["Previous unread" gnus-group-prev-unread-group t]
755 ["Next unread same level" gnus-group-next-unread-group-same-level t]
756 ["Previous unread same level"
757 gnus-group-prev-unread-group-same-level t]
758 ["Jump to group" gnus-group-jump-to-group t]
759 ["First unread group" gnus-group-first-unread-group t]
760 ["Best unread group" gnus-group-best-unread-group t])
761 ["Delete bogus groups" gnus-group-check-bogus-groups t]
762 ["Find new newsgroups" gnus-group-find-new-groups t]
763 ["Transpose" gnus-group-transpose-groups
764 (gnus-group-group-name)]
765 ["Read a directory as a group..." gnus-group-enter-directory t]))
768 gnus-group-misc-menu gnus-group-mode-map ""
771 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
772 ["Send replies" gnus-soup-send-replies
773 (fboundp 'gnus-soup-pack-packet)]
774 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
775 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
776 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
777 ["Send a mail" gnus-group-mail t]
778 ["Post an article..." gnus-group-post-news t]
779 ["Check for new news" gnus-group-get-new-news t]
780 ["Activate all groups" gnus-activate-all-groups t]
781 ["Restart Gnus" gnus-group-restart t]
782 ["Read init file" gnus-group-read-init-file t]
783 ["Browse foreign server" gnus-group-browse-foreign-server t]
784 ["Enter server buffer" gnus-group-enter-server-mode t]
785 ["Expire all expirable articles" gnus-group-expire-all-groups t]
786 ["Generate any kiboze groups" nnkiboze-generate-groups t]
787 ["Gnus version" gnus-version t]
788 ["Save .newsrc files" gnus-group-save-newsrc t]
789 ["Suspend Gnus" gnus-group-suspend t]
790 ["Clear dribble buffer" gnus-group-clear-dribble t]
791 ["Read manual" gnus-info-find-node t]
792 ["Flush score cache" gnus-score-flush-cache t]
793 ["Toggle topics" gnus-topic-mode t]
794 ["Send a bug report" gnus-bug t]
795 ["Exit from Gnus" gnus-group-exit t]
796 ["Exit without saving" gnus-group-quit t]))
798 (gnus-run-hooks 'gnus-group-menu-hook)))
800 (defun gnus-group-mode ()
801 "Major mode for reading news.
803 All normal editing commands are switched off.
804 \\<gnus-group-mode-map>
805 The group buffer lists (some of) the groups available. For instance,
806 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
807 lists all zombie groups.
809 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
810 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
812 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
814 The following commands are available:
816 \\{gnus-group-mode-map}"
818 (when (gnus-visual-p 'group-menu 'menu)
819 (gnus-group-make-menu-bar))
820 (kill-all-local-variables)
821 (gnus-simplify-mode-line)
822 (setq major-mode 'gnus-group-mode)
823 (setq mode-name "Group")
824 (gnus-group-set-mode-line)
825 (setq mode-line-process nil)
826 (use-local-map gnus-group-mode-map)
827 (buffer-disable-undo)
828 (setq truncate-lines t)
829 (setq buffer-read-only t)
830 (gnus-set-default-directory)
831 (gnus-update-format-specifications nil 'group 'group-mode)
832 (gnus-update-group-mark-positions)
837 (gnus-run-hooks 'gnus-group-mode-hook))
839 (defun gnus-update-group-mark-positions ()
841 (let ((gnus-process-mark ?\200)
842 (gnus-group-marked '("dummy.group"))
843 (gnus-active-hashtb (make-vector 10 0))
845 (gnus-set-active "dummy.group" '(0 . 0))
846 (gnus-set-work-buffer)
847 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
848 (goto-char (point-min))
849 (setq gnus-group-mark-positions
850 (list (cons 'process (and (search-forward "\200" nil t)
853 (defun gnus-mouse-pick-group (e)
854 "Enter the group under the mouse pointer."
857 (gnus-group-read-group nil))
859 ;; Look at LEVEL and find out what the level is really supposed to be.
860 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
861 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
862 (defun gnus-group-default-level (&optional level number-or-nil)
864 (gnus-group-use-permanent-levels
865 (or (setq gnus-group-use-permanent-levels
866 (or level (if (numberp gnus-group-use-permanent-levels)
867 gnus-group-use-permanent-levels
868 (or gnus-group-default-list-level
869 gnus-level-subscribed))))
870 gnus-group-default-list-level gnus-level-subscribed))
874 (or level gnus-group-default-list-level gnus-level-subscribed))))
876 (defun gnus-group-setup-buffer ()
877 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
878 (unless (eq major-mode 'gnus-group-mode)
881 (gnus-carpal-setup-buffer 'group))))
883 (defun gnus-group-list-groups (&optional level unread lowest)
884 "List newsgroups with level LEVEL or lower that have unread articles.
885 Default is all subscribed groups.
886 If argument UNREAD is non-nil, groups with no unread articles are also
889 Also see the `gnus-group-use-permanent-levels' variable."
891 (list (if current-prefix-arg
892 (prefix-numeric-value current-prefix-arg)
894 (gnus-group-default-level nil t)
895 gnus-group-default-list-level
896 gnus-level-subscribed))))
898 (setq level (car gnus-group-list-mode)
899 unread (cdr gnus-group-list-mode)))
900 (setq level (gnus-group-default-level level))
901 (gnus-group-setup-buffer)
902 (gnus-update-format-specifications nil 'group 'group-mode)
903 (let ((case-fold-search nil)
904 (props (text-properties-at (gnus-point-at-bol)))
905 (empty (= (point-min) (point-max)))
906 (group (gnus-group-group-name))
908 (set-buffer gnus-group-buffer)
909 (setq number (funcall gnus-group-prepare-function level unread lowest))
910 (when (or (and (numberp number)
912 (zerop (buffer-size)))
913 ;; No groups in the buffer.
914 (gnus-message 5 gnus-no-groups-message))
915 ;; We have some groups displayed.
916 (goto-char (point-max))
917 (when (or (not gnus-group-goto-next-group-function)
918 (not (funcall gnus-group-goto-next-group-function
922 (goto-char (point-min)))
924 ;; Go to the first group with unread articles.
925 (gnus-group-search-forward t))
927 ;; Find the right group to put point on. If the current group
928 ;; has disappeared in the new listing, try to find the next
929 ;; one. If no next one can be found, just leave point at the
930 ;; first newsgroup in the buffer.
931 (when (not (gnus-goto-char
933 (point-min) (point-max)
934 'gnus-group (gnus-intern-safe
935 group gnus-active-hashtb))))
936 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
940 (point-min) (point-max) 'gnus-group
942 (caar newsrc) gnus-active-hashtb)))))
943 (setq newsrc (cdr newsrc)))
945 (goto-char (point-max))
946 (forward-line -1)))))))
947 ;; Adjust cursor point.
948 (gnus-group-position-point)))
950 (defun gnus-group-list-level (level &optional all)
951 "List groups on LEVEL.
952 If ALL (the prefix), also list groups that have no unread articles."
953 (interactive "nList groups on level: \nP")
954 (gnus-group-list-groups level all level))
956 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
957 "List all newsgroups with unread articles of level LEVEL or lower.
958 If ALL is non-nil, list groups that have no unread articles.
959 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
960 If REGEXP, only list groups matching REGEXP."
961 (set-buffer gnus-group-buffer)
962 (let ((buffer-read-only nil)
963 (newsrc (cdr gnus-newsrc-alist))
964 (lowest (or lowest 1))
965 info clevel unread group params)
967 (when (< lowest gnus-level-zombie)
968 ;; List living groups.
970 (setq info (car newsrc)
971 group (gnus-info-group info)
972 params (gnus-info-params info)
974 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
975 (and unread ; This group might be unchecked
977 (string-match regexp group))
978 (<= (setq clevel (gnus-info-level info)) level)
980 (or all ; We list all groups?
981 (if (eq unread t) ; Unactivated?
982 gnus-group-list-inactive-groups ; We list unactivated
983 (> unread 0)) ; We list groups with unread articles
984 (and gnus-list-groups-with-ticked-articles
985 (cdr (assq 'tick (gnus-info-marks info))))
986 ; And groups with tickeds
987 ;; Check for permanent visibility.
988 (and gnus-permanently-visible-groups
989 (string-match gnus-permanently-visible-groups
991 (memq 'visible params)
992 (cdr (assq 'visible params)))
993 (gnus-group-insert-group-line
994 group (gnus-info-level info)
995 (gnus-info-marks info) unread (gnus-info-method info)))))
998 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
999 (gnus-group-prepare-flat-list-dead
1000 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1001 gnus-level-zombie ?Z
1003 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
1004 (gnus-group-prepare-flat-list-dead
1005 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1006 gnus-level-killed ?K regexp))
1008 (gnus-group-set-mode-line)
1009 (setq gnus-group-list-mode (cons level all))
1010 (gnus-run-hooks 'gnus-group-prepare-hook)
1013 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1014 ;; List zombies and killed lists somewhat faster, which was
1015 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1016 ;; this by ignoring the group format specification altogether.
1019 ;; This loop is used when listing groups that match some
1022 (setq group (pop groups))
1023 (when (string-match regexp group)
1024 (gnus-add-text-properties
1025 (point) (prog1 (1+ (point))
1026 (insert " " mark " *: " group "\n"))
1027 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1029 'gnus-level level))))
1030 ;; This loop is used when listing all groups.
1032 (gnus-add-text-properties
1033 (point) (prog1 (1+ (point))
1034 (insert " " mark " *: "
1035 (setq group (pop groups)) "\n"))
1036 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1038 'gnus-level level))))))
1040 (defun gnus-group-update-group-line ()
1041 "Update the current line in the group buffer."
1042 (let* ((buffer-read-only nil)
1043 (group (gnus-group-group-name))
1044 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1045 gnus-group-indentation)
1048 (not (gnus-ephemeral-group-p group))
1050 (concat "(gnus-group-set-info '"
1051 (gnus-prin1-to-string (nth 2 entry))
1053 (setq gnus-group-indentation (gnus-group-group-indentation))
1055 (gnus-group-insert-group-line-info group)
1057 (gnus-group-position-point))))
1059 (defun gnus-group-insert-group-line-info (group)
1060 "Insert GROUP on the current line."
1061 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1062 (gnus-group-indentation (gnus-group-group-indentation))
1066 ;; (Un)subscribed group.
1067 (setq info (nth 2 entry))
1068 (gnus-group-insert-group-line
1069 group (gnus-info-level info) (gnus-info-marks info)
1070 (or (car entry) t) (gnus-info-method info)))
1071 ;; This group is dead.
1072 (gnus-group-insert-group-line
1074 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1076 (if (setq active (gnus-active group))
1077 (if (zerop (cdr active))
1079 (- (1+ (cdr active)) (car active)))
1083 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1084 gnus-tmp-marked number
1086 "Insert a group line in the group buffer."
1087 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1088 (gnus-tmp-number-total
1090 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1092 (gnus-tmp-number-of-unread
1093 (if (numberp number) (int-to-string (max 0 number))
1095 (gnus-tmp-number-of-read
1096 (if (numberp number)
1097 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1099 (gnus-tmp-subscribed
1100 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1101 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1102 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1104 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1105 (gnus-tmp-newsgroup-description
1106 (if gnus-description-hashtb
1107 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1110 (if (and gnus-moderated-hashtb
1111 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1113 (gnus-tmp-moderated-string
1114 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1115 (gnus-tmp-group-icon "==&&==")
1117 (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) ;
1118 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1119 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1120 (gnus-tmp-news-method-string
1122 (format "(%s:%s)" (car gnus-tmp-method)
1123 (cadr gnus-tmp-method)) ""))
1124 (gnus-tmp-marked-mark
1125 (if (and (numberp number)
1127 (cdr (assq 'tick gnus-tmp-marked)))
1129 (gnus-tmp-process-marked
1130 (if (member gnus-tmp-group gnus-group-marked)
1131 gnus-process-mark ? ))
1133 (or (and gnus-use-grouplens
1134 (bbb-grouplens-group-p gnus-tmp-group))
1136 (buffer-read-only nil)
1137 header gnus-tmp-header) ; passed as parameter to user-funcs.
1139 (gnus-add-text-properties
1143 (eval gnus-group-line-format-spec))
1144 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1145 gnus-unread ,(if (numberp number)
1146 (string-to-int gnus-tmp-number-of-unread)
1148 gnus-marked ,gnus-tmp-marked-mark
1149 gnus-indentation ,gnus-group-indentation
1150 gnus-level ,gnus-tmp-level))
1152 (gnus-group-add-icon)
1153 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1154 (gnus-run-hooks 'gnus-group-update-hook)
1156 ;; Allow XEmacs to remove front-sticky text properties.
1157 (gnus-group-remove-excess-properties)))
1159 (defun gnus-group-add-icon ()
1160 "Add an icon to the current line according to `gnus-group-icon-list'."
1162 (end (progn (end-of-line) (point)))
1163 ;; now find out where the line starts and leave point there.
1164 (beg (progn (beginning-of-line) (point))))
1166 (narrow-to-region beg end)
1168 (when (search-forward "==&&==" nil t)
1169 (let* ((group (gnus-group-group-name))
1170 (entry (gnus-group-entry group))
1171 (unread (if (numberp (car entry)) (car entry) 0))
1172 (active (gnus-active group))
1173 (total (if active (1+ (- (cdr active) (car active))) 0))
1174 (info (nth 2 entry))
1175 (method (gnus-server-get-method group (gnus-info-method info)))
1176 (marked (gnus-info-marks info))
1177 (mailp (memq 'mail (assoc (symbol-name
1178 (car (or method gnus-select-method)))
1179 gnus-valid-select-methods)))
1180 (level (or (gnus-info-level info) gnus-level-killed))
1181 (score (or (gnus-info-score info) 0))
1182 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1183 (group-age (gnus-group-timestamp-delta group))
1184 (inhibit-read-only t)
1185 (list gnus-group-icon-list)
1186 (mystart (match-beginning 0))
1187 (myend (match-end 0)))
1188 (goto-char (point-min))
1190 (not (eval (caar list))))
1191 (setq list (cdr list)))
1193 (let* ((file (cdar list))
1194 (glyph (gnus-group-icon-create-glyph
1195 (buffer-substring mystart myend)
1199 (mapcar 'delete-annotation (annotations-at myend))
1200 (let ((ext (make-extent mystart myend))
1201 (ant (make-annotation glyph myend 'text)))
1202 ;; set text extent params
1203 (set-extent-property ext 'end-open t)
1204 (set-extent-property ext 'start-open t)
1205 (set-extent-property ext 'invisible t)))
1206 (delete-region mystart myend)))
1207 (delete-region mystart myend))))
1211 (defun gnus-group-icon-create-glyph (substring pixmap)
1212 "Create a glyph for insertion into a group line."
1214 gnus-group-running-xemacs
1216 (cdr-safe (assoc pixmap gnus-group-icon-cache))
1217 (let* ((glyph (make-glyph
1220 (expand-file-name pixmap gnus-group-glyph-directory))
1222 (expand-file-name pixmap gnus-group-glyph-directory))
1223 (cons 'tty substring)))))
1224 (setq gnus-group-icon-cache
1225 (cons (cons pixmap glyph) gnus-group-icon-cache))
1226 (set-glyph-face glyph 'default)
1229 (defun gnus-group-highlight-line ()
1230 "Highlight the current line according to `gnus-group-highlight'."
1231 (let* ((list gnus-group-highlight)
1233 (end (progn (end-of-line) (point)))
1234 ;; now find out where the line starts and leave point there.
1235 (beg (progn (beginning-of-line) (point)))
1236 (group (gnus-group-group-name))
1237 (entry (gnus-group-entry group))
1238 (unread (if (numberp (car entry)) (car entry) 0))
1239 (active (gnus-active group))
1240 (total (if active (1+ (- (cdr active) (car active))) 0))
1241 (info (nth 2 entry))
1242 (method (gnus-server-get-method group (gnus-info-method info)))
1243 (marked (gnus-info-marks info))
1244 (mailp (memq 'mail (assoc (symbol-name
1245 (car (or method gnus-select-method)))
1246 gnus-valid-select-methods)))
1247 (level (or (gnus-info-level info) gnus-level-killed))
1248 (score (or (gnus-info-score info) 0))
1249 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1250 (group-age (gnus-group-timestamp-delta group))
1251 (inhibit-read-only t))
1252 ;; Eval the cars of the lists until we find a match.
1254 (not (eval (caar list))))
1255 (setq list (cdr list)))
1256 (let ((face (cdar list)))
1257 (unless (eq face (get-text-property beg 'face))
1258 (gnus-put-text-property-excluding-characters-with-faces
1260 (setq face (if (boundp face) (symbol-value face) face)))
1261 (gnus-extent-start-open beg)))
1264 (defun gnus-group-update-group (group &optional visible-only)
1265 "Update all lines where GROUP appear.
1266 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1268 ;; Can't use `save-excursion' here, so we do it manually.
1269 (let ((buf (current-buffer))
1271 (set-buffer gnus-group-buffer)
1272 (setq mark (point-marker))
1273 ;; The buffer may be narrowed.
1276 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1278 found buffer-read-only)
1279 ;; Enter the current status into the dribble buffer.
1280 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1282 (not (gnus-ephemeral-group-p group)))
1284 (concat "(gnus-group-set-info '"
1285 (gnus-prin1-to-string (nth 2 entry))
1287 ;; Find all group instances. If topics are in use, each group
1288 ;; may be listed in more than once.
1289 (while (setq loc (text-property-any
1290 loc (point-max) 'gnus-group ident))
1293 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1295 (gnus-group-insert-group-line-info group)
1298 (gnus-run-hooks 'gnus-group-update-group-hook)))
1299 (setq loc (1+ loc)))
1300 (unless (or found visible-only)
1301 ;; No such line in the buffer, find out where it's supposed to
1302 ;; go, and insert it there (or at the end of the buffer).
1303 (if gnus-goto-missing-group-function
1304 (funcall gnus-goto-missing-group-function group)
1305 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1306 (while (and entry (car entry)
1310 (point-min) (point-max)
1311 'gnus-group (gnus-intern-safe
1312 (caar entry) gnus-active-hashtb)))))
1313 (setq entry (cdr entry)))
1314 (or entry (goto-char (point-max)))))
1315 ;; Finally insert the line.
1316 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1317 (gnus-group-insert-group-line-info group)
1320 (gnus-run-hooks 'gnus-group-update-group-hook))))
1321 (when gnus-group-update-group-function
1322 (funcall gnus-group-update-group-function group))
1323 (gnus-group-set-mode-line)))
1325 (set-marker mark nil)
1328 (defun gnus-group-set-mode-line ()
1329 "Update the mode line in the group buffer."
1330 (when (memq 'group gnus-updated-mode-lines)
1331 ;; Yes, we want to keep this mode line updated.
1333 (set-buffer gnus-group-buffer)
1334 (let* ((gformat (or gnus-group-mode-line-format-spec
1335 (gnus-set-format 'group-mode)))
1336 (gnus-tmp-news-server (cadr gnus-select-method))
1337 (gnus-tmp-news-method (car gnus-select-method))
1338 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1340 gnus-tmp-header ;Dummy binding for user-defined formats
1341 ;; Get the resulting string.
1343 (and gnus-dribble-buffer
1344 (buffer-name gnus-dribble-buffer)
1345 (buffer-modified-p gnus-dribble-buffer)
1347 (set-buffer gnus-dribble-buffer)
1348 (not (zerop (buffer-size))))))
1349 (mode-string (eval gformat)))
1350 ;; Say whether the dribble buffer has been modified.
1351 (setq mode-line-modified
1352 (if modified (car gnus-mode-line-modified)
1353 (cdr gnus-mode-line-modified)))
1354 ;; If the line is too long, we chop it off.
1355 (when (> (length mode-string) max-len)
1356 (setq mode-string (substring mode-string 0 (- max-len 4))))
1358 (setq mode-line-buffer-identification
1359 (gnus-mode-line-buffer-identification
1360 (list mode-string)))
1361 (set-buffer-modified-p modified))))))
1363 (defun gnus-group-group-name ()
1364 "Get the name of the newsgroup on the current line."
1365 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1367 (symbol-name group))))
1369 (defun gnus-group-group-level ()
1370 "Get the level of the newsgroup on the current line."
1371 (get-text-property (gnus-point-at-bol) 'gnus-level))
1373 (defun gnus-group-group-indentation ()
1374 "Get the indentation of the newsgroup on the current line."
1375 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1376 (and gnus-group-indentation-function
1377 (funcall gnus-group-indentation-function))
1380 (defun gnus-group-group-unread ()
1381 "Get the number of unread articles of the newsgroup on the current line."
1382 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1384 (defun gnus-group-new-mail (group)
1385 (if (nnmail-new-mail-p (gnus-group-real-name group))
1389 (defun gnus-group-level (group)
1390 "Return the estimated level of GROUP."
1391 (or (gnus-info-level (gnus-get-info group))
1392 (and (member group gnus-zombie-list) gnus-level-zombie)
1395 (defun gnus-group-search-forward (&optional backward all level first-too)
1396 "Find the next newsgroup with unread articles.
1397 If BACKWARD is non-nil, find the previous newsgroup instead.
1398 If ALL is non-nil, just find any newsgroup.
1399 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1401 If FIRST-TOO, the current line is also eligible as a target."
1402 (let ((way (if backward -1 1))
1403 (low gnus-level-killed)
1406 (if (and backward (progn (beginning-of-line)) (bobp))
1415 (get-text-property (point) 'gnus-group)
1419 (get-text-property (point) 'gnus-unread)))
1420 (and (numberp unread) (> unread 0)))
1421 (setq lev (get-text-property (point)
1423 (<= lev gnus-level-subscribed)))
1425 (and (setq lev (get-text-property (point)
1434 (zerop (forward-line way)))))
1436 (progn (gnus-group-position-point) t)
1437 (goto-char (or pos beg))
1440 ;;; Gnus group mode commands
1444 (defun gnus-group-mark-group (n &optional unmark no-advance)
1445 "Mark the current group."
1447 (let ((buffer-read-only nil)
1451 (when (setq group (gnus-group-group-name))
1452 ;; Go to the mark position.
1454 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1455 (subst-char-in-region
1456 (point) (1+ (point)) (char-after)
1459 (setq gnus-group-marked (delete group gnus-group-marked))
1461 (setq gnus-group-marked
1462 (cons group (delete group gnus-group-marked)))
1463 gnus-process-mark)))
1465 (gnus-group-next-group 1))
1467 (gnus-summary-position-point)
1470 (defun gnus-group-unmark-group (n)
1471 "Remove the mark from the current group."
1473 (gnus-group-mark-group n 'unmark)
1474 (gnus-group-position-point))
1476 (defun gnus-group-unmark-all-groups ()
1477 "Unmark all groups."
1479 (let ((groups gnus-group-marked))
1482 (gnus-group-remove-mark (pop groups)))))
1483 (gnus-group-position-point))
1485 (defun gnus-group-mark-region (unmark beg end)
1486 "Mark all groups between point and mark.
1487 If UNMARK, remove the mark instead."
1488 (interactive "P\nr")
1489 (let ((num (count-lines beg end)))
1492 (- num (gnus-group-mark-group num unmark)))))
1494 (defun gnus-group-mark-buffer (&optional unmark)
1495 "Mark all groups in the buffer.
1496 If UNMARK, remove the mark instead."
1498 (gnus-group-mark-region unmark (point-min) (point-max)))
1500 (defun gnus-group-mark-regexp (regexp)
1501 "Mark all groups that match some regexp."
1502 (interactive "sMark (regexp): ")
1503 (let ((alist (cdr gnus-newsrc-alist))
1506 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1507 (gnus-group-set-mark group))))
1508 (gnus-group-position-point))
1510 (defun gnus-group-remove-mark (group)
1511 "Remove the process mark from GROUP and move point there.
1512 Return nil if the group isn't displayed."
1513 (if (gnus-group-goto-group group)
1515 (gnus-group-mark-group 1 'unmark t)
1517 (setq gnus-group-marked
1518 (delete group gnus-group-marked))
1521 (defun gnus-group-set-mark (group)
1522 "Set the process mark on GROUP."
1523 (if (gnus-group-goto-group group)
1525 (gnus-group-mark-group 1 nil t))
1526 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1528 (defun gnus-group-universal-argument (arg &optional groups func)
1529 "Perform any command on all groups according to the process/prefix convention."
1531 (if (eq (setq func (or func
1534 (substitute-command-keys
1535 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1537 (gnus-error 1 "Undefined key")
1538 (gnus-group-iterate arg
1540 (command-execute func))))
1541 (gnus-group-position-point))
1543 (defun gnus-group-process-prefix (n)
1544 "Return a list of groups to work on.
1545 Take into consideration N (the prefix) and the list of marked groups."
1548 (setq n (prefix-numeric-value n))
1549 ;; There is a prefix, so we return a list of the N next
1551 (let ((way (if (< n 0) -1 1))
1556 (if (setq group (gnus-group-group-name))
1557 (push group groups))
1559 (gnus-group-next-group way)))
1561 ((gnus-region-active-p)
1562 ;; Work on the region between point and mark.
1563 (let ((max (max (point) (mark)))
1566 (goto-char (min (point) (mark)))
1569 (push (gnus-group-group-name) groups)
1570 (zerop (gnus-group-next-group 1))
1572 (nreverse groups))))
1574 ;; No prefix, but a list of marked articles.
1575 (reverse gnus-group-marked))
1577 ;; Neither marked articles or a prefix, so we return the
1579 (let ((group (gnus-group-group-name)))
1580 (and group (list group))))))
1582 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1583 ;;; imagine why I went through these contortions...
1585 (let ((function (make-symbol "gnus-group-iterate-function"))
1586 (window (make-symbol "gnus-group-iterate-window"))
1587 (groups (make-symbol "gnus-group-iterate-groups"))
1588 (group (make-symbol "gnus-group-iterate-group")))
1590 `(defun gnus-group-iterate (arg ,function)
1591 "Iterate FUNCTION over all process/prefixed groups.
1592 FUNCTION will be called with the group name as the paremeter
1593 and with point over the group in question."
1594 (let ((,groups (gnus-group-process-prefix arg))
1595 (,window (selected-window))
1597 (while (setq ,group (pop ,groups))
1598 (select-window ,window)
1599 (gnus-group-remove-mark ,group)
1600 (save-selected-window
1602 (funcall ,function ,group)))))))))
1604 (put 'gnus-group-iterate 'lisp-indent-function 1)
1606 ;; Selecting groups.
1608 (defun gnus-group-read-group (&optional all no-article group select-articles)
1609 "Read news in this newsgroup.
1610 If the prefix argument ALL is non-nil, already read articles become
1611 readable. IF ALL is a number, fetch this number of articles. If the
1612 optional argument NO-ARTICLE is non-nil, no article will be
1613 auto-selected upon group entry. If GROUP is non-nil, fetch that
1616 (let ((no-display (eq all 0))
1617 (group (or group (gnus-group-group-name)))
1618 number active marked entry)
1622 (error "No group on current line"))
1623 (setq marked (gnus-info-marks
1624 (nth 2 (setq entry (gnus-gethash
1625 group gnus-newsrc-hashtb)))))
1626 ;; This group might be a dead group. In that case we have to get
1627 ;; the number of unread articles from `gnus-active-hashtb'.
1629 (cond ((numberp all) all)
1631 ((setq active (gnus-active group))
1632 (- (1+ (cdr active)) (car active)))))
1633 (gnus-summary-read-group
1634 group (or all (and (numberp number)
1635 (zerop (+ number (gnus-range-length
1636 (cdr (assq 'tick marked)))
1638 (cdr (assq 'dormant marked)))))))
1639 no-article nil no-display nil select-articles)))
1641 (defun gnus-group-select-group (&optional all)
1642 "Select this newsgroup.
1643 No article is selected automatically.
1644 If ALL is non-nil, already read articles become readable.
1645 If ALL is a number, fetch this number of articles."
1647 (gnus-group-read-group all t))
1649 (defun gnus-group-quick-select-group (&optional all)
1650 "Select the current group \"quickly\".
1651 This means that no highlighting or scoring will be performed.
1652 If ALL (the prefix argument) is 0, don't even generate the summary
1655 This might be useful if you want to toggle threading
1656 before entering the group."
1658 (require 'gnus-score)
1660 gnus-score-find-score-files-function
1661 gnus-home-score-file
1662 gnus-apply-kill-hook
1663 gnus-summary-expunge-below)
1664 (gnus-group-read-group all t)))
1666 (defun gnus-group-visible-select-group (&optional all)
1667 "Select the current group without hiding any articles."
1669 (let ((gnus-inhibit-limiting t))
1670 (gnus-group-read-group all t)))
1672 (defun gnus-group-select-group-ephemerally ()
1673 "Select the current group without doing any processing whatsoever.
1674 You will actually be entered into a group that's a copy of
1675 the current group; no changes you make while in this group will
1678 (require 'gnus-score)
1680 gnus-score-find-score-files-function gnus-apply-kill-hook
1681 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1682 gnus-summary-mode-hook gnus-select-group-hook
1683 (group (gnus-group-group-name))
1684 (method (gnus-find-method-for-group group)))
1685 (gnus-group-read-ephemeral-group
1686 (gnus-group-prefixed-name group method) method)))
1689 (defun gnus-fetch-group (group)
1690 "Start Gnus if necessary and enter GROUP.
1691 Returns whether the fetching was successful or not."
1692 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1693 (unless (get-buffer gnus-group-buffer)
1695 (gnus-group-read-group nil nil group))
1698 (defun gnus-fetch-group-other-frame (group)
1699 "Pop up a frame and enter GROUP."
1701 (let ((window (get-buffer-window gnus-group-buffer)))
1703 (select-frame (window-frame window)))
1704 ((= (length (frame-list)) 1)
1705 (select-frame (make-frame)))
1708 (gnus-fetch-group group))
1710 (defvar gnus-ephemeral-group-server 0)
1712 ;; Enter a group that is not in the group buffer. Non-nil is returned
1713 ;; if selection was successful.
1714 (defun gnus-group-read-ephemeral-group (group method &optional activate
1715 quit-config request-only
1717 "Read GROUP from METHOD as an ephemeral group.
1718 If ACTIVATE, request the group first.
1719 If QUIT-CONFIG, use that window configuration when exiting from the
1721 If REQUEST-ONLY, don't actually read the group; just request it.
1722 If SELECT-ARTICLES, only select those articles.
1724 Return the name of the group if selection was successful."
1725 ;; Transform the select method into a unique server.
1726 (when (stringp method)
1727 (setq method (gnus-server-to-method method)))
1729 `(,(car method) ,(concat (cadr method) "-ephemeral")
1730 (,(intern (format "%s-address" (car method))) ,(cadr method))
1732 (let ((group (if (gnus-group-foreign-p group) group
1733 (gnus-group-prefixed-name group method))))
1737 ,gnus-level-default-subscribed nil nil ,method
1739 ,(if quit-config quit-config
1740 (cons gnus-summary-buffer
1741 gnus-current-window-configuration))))))
1743 (push method gnus-ephemeral-servers)
1744 (set-buffer gnus-group-buffer)
1745 (unless (gnus-check-server method)
1746 (error "Unable to contact server: %s" (gnus-status-message method)))
1748 (gnus-activate-group group 'scan)
1749 (unless (gnus-request-group group)
1750 (error "Couldn't request group: %s"
1751 (nnheader-get-report (car method)))))
1755 (when (gnus-group-read-group t t group select-articles)
1760 (defun gnus-group-jump-to-group (group)
1761 "Jump to newsgroup GROUP."
1763 (list (completing-read
1764 "Group: " gnus-active-hashtb nil
1765 (gnus-read-active-file-p)
1767 'gnus-group-history)))
1769 (when (equal group "")
1770 (error "Empty group name"))
1772 (unless (gnus-ephemeral-group-p group)
1773 ;; Either go to the line in the group buffer...
1774 (unless (gnus-group-goto-group group)
1775 ;; ... or insert the line.
1776 (gnus-group-update-group group)
1777 (gnus-group-goto-group group)))
1778 ;; Adjust cursor point.
1779 (gnus-group-position-point))
1781 (defun gnus-group-goto-group (group &optional far)
1782 "Goto to newsgroup GROUP.
1783 If FAR, it is likely that the group is not on the current line."
1788 (point-min) (point-max)
1789 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1792 ;; It's quite likely that we are on the right line, so
1793 ;; we check the current line first.
1794 ((eq (get-text-property (point) 'gnus-group)
1795 (gnus-intern-safe group gnus-active-hashtb))
1797 ;; Previous and next line are also likely, so we check them as well.
1800 (eq (get-text-property (point) 'gnus-group)
1801 (gnus-intern-safe group gnus-active-hashtb)))
1806 (eq (get-text-property (point) 'gnus-group)
1807 (gnus-intern-safe group gnus-active-hashtb)))
1811 ;; Search through the entire buffer.
1814 (point-min) (point-max)
1815 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1817 (defun gnus-group-next-group (n &optional silent)
1818 "Go to next N'th newsgroup.
1819 If N is negative, search backward instead.
1820 Returns the difference between N and the number of skips actually
1823 (gnus-group-next-unread-group n t nil silent))
1825 (defun gnus-group-next-unread-group (n &optional all level silent)
1826 "Go to next N'th unread newsgroup.
1827 If N is negative, search backward instead.
1828 If ALL is non-nil, choose any newsgroup, unread or not.
1829 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1830 such group can be found, the next group with a level higher than
1832 Returns the difference between N and the number of skips actually
1835 (let ((backward (< n 0))
1838 (gnus-group-search-forward
1839 backward (or (not gnus-group-goto-unread) all) level))
1843 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1844 (if level " on this level or higher" "")))
1847 (defun gnus-group-prev-group (n)
1848 "Go to previous N'th newsgroup.
1849 Returns the difference between N and the number of skips actually
1852 (gnus-group-next-unread-group (- n) t))
1854 (defun gnus-group-prev-unread-group (n)
1855 "Go to previous N'th unread newsgroup.
1856 Returns the difference between N and the number of skips actually
1859 (gnus-group-next-unread-group (- n)))
1861 (defun gnus-group-next-unread-group-same-level (n)
1862 "Go to next N'th unread newsgroup on the same level.
1863 If N is negative, search backward instead.
1864 Returns the difference between N and the number of skips actually
1867 (gnus-group-next-unread-group n t (gnus-group-group-level))
1868 (gnus-group-position-point))
1870 (defun gnus-group-prev-unread-group-same-level (n)
1871 "Go to next N'th unread newsgroup on the same level.
1872 Returns the difference between N and the number of skips actually
1875 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1876 (gnus-group-position-point))
1878 (defun gnus-group-best-unread-group (&optional exclude-group)
1879 "Go to the group with the highest level.
1880 If EXCLUDE-GROUP, do not go to that group."
1882 (goto-char (point-min))
1886 (setq unread (get-text-property (point) 'gnus-unread))
1887 (when (and (numberp unread) (> unread 0))
1888 (when (and (get-text-property (point) 'gnus-level)
1889 (< (get-text-property (point) 'gnus-level) best)
1890 (or (not exclude-group)
1891 (not (equal exclude-group (gnus-group-group-name)))))
1892 (setq best (get-text-property (point) 'gnus-level))
1893 (setq best-point (point))))
1896 (goto-char best-point))
1897 (gnus-summary-position-point)
1898 (and best-point (gnus-group-group-name))))
1900 (defun gnus-group-first-unread-group ()
1901 "Go to the first group with unread articles."
1904 (let ((opoint (point))
1906 (goto-char (point-min))
1907 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1908 (and (numberp unread) ; Not a topic.
1909 (not (zerop unread))) ; Has unread articles.
1910 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1913 nil)) ; Not success.
1914 (gnus-group-position-point)))
1916 (defun gnus-group-enter-server-mode ()
1917 "Jump to the server buffer."
1919 (gnus-enter-server-buffer))
1921 (defun gnus-group-make-group (name &optional method address args)
1922 "Add a new newsgroup.
1923 The user will be prompted for a NAME, for a select METHOD, and an
1927 (gnus-read-group "Group name: ")
1928 (gnus-read-method "From method: ")))
1930 (when (stringp method)
1931 (setq method (or (gnus-server-to-method method) method)))
1932 (let* ((meth (gnus-method-simplify
1934 (not (gnus-server-equal method gnus-select-method)))
1935 (if address (list (intern method) address)
1937 (nname (if method (gnus-group-prefixed-name name meth) name))
1939 (when (gnus-gethash nname gnus-newsrc-hashtb)
1940 (error "Group %s already exists" nname))
1941 ;; Subscribe to the new group.
1942 (gnus-group-change-level
1943 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1944 gnus-level-default-subscribed gnus-level-killed
1945 (and (gnus-group-group-name)
1946 (gnus-gethash (gnus-group-group-name)
1947 gnus-newsrc-hashtb))
1950 (gnus-set-active nname (cons 1 0))
1951 (unless (gnus-ephemeral-group-p name)
1953 (concat "(gnus-group-set-info '"
1954 (gnus-prin1-to-string (cdr info)) ")")))
1956 (gnus-group-insert-group-line-info nname)
1958 (gnus-group-position-point)
1960 ;; Load the backend and try to make the backend create
1961 ;; the group as well.
1962 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1964 gnus-valid-select-methods)
1966 (gnus-check-server meth)
1967 (when (gnus-check-backend-function 'request-create-group nname)
1968 (gnus-request-create-group nname nil args))
1971 (defun gnus-group-delete-groups (&optional arg)
1972 "Delete the current group. Only meaningful with editable groups."
1974 (let ((n (length (gnus-group-process-prefix arg))))
1975 (when (gnus-yes-or-no-p
1977 "Delete this 1 group? "
1978 (format "Delete these %d groups? " n)))
1979 (gnus-group-iterate arg
1981 (gnus-group-delete-group group nil t))))))
1983 (defun gnus-group-delete-group (group &optional force no-prompt)
1984 "Delete the current group. Only meaningful with editable groups.
1985 If FORCE (the prefix) is non-nil, all the articles in the group will
1986 be deleted. This is \"deleted\" as in \"removed forever from the face
1987 of the Earth\". There is no undo. The user will be prompted before
1988 doing the deletion."
1990 (list (gnus-group-group-name)
1991 current-prefix-arg))
1993 (error "No group to rename"))
1994 (unless (gnus-check-backend-function 'request-delete-group group)
1995 (error "This backend does not support group deletion"))
1997 (if (and (not no-prompt)
1998 (not (gnus-yes-or-no-p
2000 "Do you really want to delete %s%s? "
2001 group (if force " and all its contents" "")))))
2003 (gnus-message 6 "Deleting group %s..." group)
2004 (if (not (gnus-request-delete-group group force))
2005 (gnus-error 3 "Couldn't delete group %s" group)
2006 (gnus-message 6 "Deleting group %s...done" group)
2007 (gnus-group-goto-group group)
2008 (gnus-group-kill-group 1 t)
2009 (gnus-sethash group nil gnus-active-hashtb)
2011 (gnus-group-position-point)))
2013 (defun gnus-group-rename-group (group new-name)
2014 "Rename group from GROUP to NEW-NAME.
2015 When used interactively, GROUP is the group under point
2016 and NEW-NAME will be prompted for."
2019 (gnus-group-group-name)
2021 (unless (gnus-check-backend-function
2022 'request-rename-group (gnus-group-group-name))
2023 (error "This backend does not support renaming groups"))
2024 (gnus-read-group "Rename group to: "
2025 (gnus-group-real-name (gnus-group-group-name))))))
2027 (unless (gnus-check-backend-function 'request-rename-group group)
2028 (error "This backend does not support renaming groups"))
2030 (error "No group to rename"))
2031 (when (equal (gnus-group-real-name group) new-name)
2032 (error "Can't rename to the same name"))
2034 ;; We find the proper prefixed name.
2036 (if (gnus-group-native-p group)
2040 (gnus-group-prefixed-name
2041 (gnus-group-real-name new-name)
2042 (gnus-info-method (gnus-get-info group)))))
2044 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2046 (if (not (gnus-request-rename-group group new-name))
2047 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2048 ;; We rename the group internally by killing it...
2049 (gnus-group-goto-group group)
2050 (gnus-group-kill-group)
2051 ;; ... changing its name ...
2052 (setcar (cdar gnus-list-of-killed-groups) new-name)
2053 ;; ... and then yanking it. Magic!
2054 (gnus-group-yank-group)
2055 (gnus-set-active new-name (gnus-active group))
2056 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2058 (setq gnus-killed-list (delete group gnus-killed-list))
2059 (gnus-set-active group nil)
2060 (gnus-dribble-touch)
2061 (gnus-group-position-point)))
2063 (defun gnus-group-edit-group (group &optional part)
2064 "Edit the group on the current line."
2065 (interactive (list (gnus-group-group-name)))
2066 (let ((part (or part 'info))
2069 (error "No group on current line"))
2070 (unless (setq info (gnus-get-info group))
2071 (error "Killed group; can't be edited"))
2073 (gnus-close-group group))
2075 ;; Find the proper form to edit.
2076 (cond ((eq part 'method)
2077 (or (gnus-info-method info) "native"))
2079 (gnus-info-params info))
2081 ;; The proper documentation.
2083 "Editing the %s for `%s'."
2085 ((eq part 'method) "select method")
2086 ((eq part 'params) "group parameters")
2090 (gnus-group-edit-group-done ',part ,group form)))))
2092 (defun gnus-group-edit-group-method (group)
2093 "Edit the select method of GROUP."
2094 (interactive (list (gnus-group-group-name)))
2095 (gnus-group-edit-group group 'method))
2097 (defun gnus-group-edit-group-parameters (group)
2098 "Edit the group parameters of GROUP."
2099 (interactive (list (gnus-group-group-name)))
2100 (gnus-group-edit-group group 'params))
2102 (defun gnus-group-edit-group-done (part group form)
2104 (let* ((method (cond ((eq part 'info) (nth 4 form))
2105 ((eq part 'method) form)
2107 (info (cond ((eq part 'info) form)
2108 ((eq part 'method) (gnus-get-info group))
2111 (if (or (not method)
2113 gnus-select-method method))
2114 (gnus-group-real-name (car info))
2115 (gnus-group-prefixed-name
2116 (gnus-group-real-name (car info)) method))
2118 (when (and new-group
2119 (not (equal new-group group)))
2120 (when (gnus-group-goto-group group)
2121 (gnus-group-kill-group 1))
2122 (gnus-activate-group new-group))
2124 (if (not (and info new-group))
2125 (gnus-group-set-info form (or new-group group) part)
2126 (setq info (gnus-copy-sequence info))
2127 (setcar info new-group)
2128 (unless (gnus-server-equal method "native")
2129 (unless (nthcdr 3 info)
2130 (nconc info (list nil nil)))
2131 (unless (nthcdr 4 info)
2132 (nconc info (list nil)))
2133 (gnus-info-set-method info method))
2134 (gnus-group-set-info info))
2135 (gnus-group-update-group (or new-group group))
2136 (gnus-group-position-point)))
2138 (defun gnus-group-make-useful-group (group method)
2139 "Create one of the groups described in `gnus-useful-groups'."
2141 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2143 gnus-useful-groups)))
2144 (list (cadr entry) (caddr entry))))
2145 (setq method (gnus-copy-sequence method))
2147 (while (setq entry (memq (assq 'eval method) method))
2148 (setcar entry (eval (cadar entry)))))
2149 (gnus-group-make-group group method))
2151 (defun gnus-group-make-help-group ()
2152 "Create the Gnus documentation group."
2154 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2155 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2156 (when (gnus-gethash name gnus-newsrc-hashtb)
2157 (error "Documentation group already exists"))
2159 (gnus-message 1 "Couldn't find doc group")
2160 (gnus-group-make-group
2161 (gnus-group-real-name name)
2162 (list 'nndoc "gnus-help"
2163 (list 'nndoc-address file)
2164 (list 'nndoc-article-type 'mbox)))))
2165 (gnus-group-position-point))
2167 (defun gnus-group-make-doc-group (file type)
2168 "Create a group that uses a single file as the source."
2170 (list (read-file-name "File name: ")
2171 (and current-prefix-arg 'ask)))
2172 (when (eq type 'ask)
2177 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2179 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2180 ((= char ?b) 'babyl)
2181 ((= char ?d) 'digest)
2182 ((= char ?f) 'forward)
2184 ((= char ?g) 'guess)
2185 (t (setq err (format "%c unknown. " char))
2188 (let* ((file (expand-file-name file))
2189 (name (gnus-generate-new-group-name
2190 (gnus-group-prefixed-name
2191 (file-name-nondirectory file) '(nndoc "")))))
2192 (gnus-group-make-group
2193 (gnus-group-real-name name)
2195 (list 'nndoc-address file)
2196 (list 'nndoc-article-type (or type 'guess))))))
2198 (defvar nnweb-type-definition)
2199 (defvar gnus-group-web-type-history nil)
2200 (defvar gnus-group-web-search-history nil)
2201 (defun gnus-group-make-web-group (&optional solid)
2202 "Create an ephemeral nnweb group.
2203 If SOLID (the prefix), create a solid group."
2207 (if solid (gnus-read-group "Group name: ")
2208 (message-unique-id)))
2209 (default-type (or (car gnus-group-web-type-history)
2210 (symbol-name (caar nnweb-type-definition))))
2214 (format "Search engine type (default %s): " default-type)
2215 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2216 nnweb-type-definition)
2217 nil t nil 'gnus-group-web-type-history)
2222 (cons (or (car gnus-group-web-search-history) "") 0)
2223 'gnus-group-web-search-history))
2225 `(nnweb ,group (nnweb-search ,search)
2226 (nnweb-type ,(intern type))
2227 (nnweb-ephemeral-p t))))
2229 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2230 (gnus-group-read-ephemeral-group
2232 (cons (current-buffer)
2233 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2235 (defvar nnwarchive-type-definition)
2236 (defvar gnus-group-warchive-type-history nil)
2237 (defvar gnus-group-warchive-login-history nil)
2238 (defvar gnus-group-warchive-address-history nil)
2240 (defun gnus-group-make-warchive-group ()
2241 "Create a nnwarchive group."
2243 (require 'nnwarchive)
2244 (let* ((group (gnus-read-group "Group name: "))
2245 (default-type (or (car gnus-group-warchive-type-history)
2246 (symbol-name (caar nnwarchive-type-definition))))
2250 (format "Warchive type (default %s): " default-type)
2251 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2252 nnwarchive-type-definition)
2253 nil t nil 'gnus-group-warchive-type-history)
2255 (address (read-string "Warchive address: "
2256 nil 'gnus-group-warchive-address-history))
2257 (default-login (or (car gnus-group-warchive-login-history)
2262 (format "Warchive login (default %s): " user-mail-address)
2263 default-login 'gnus-group-warchive-login-history)
2266 `(nnwarchive ,address
2267 (nnwarchive-type ,(intern type))
2268 (nnwarchive-login ,login))))
2269 (gnus-group-make-group group method)))
2271 (defun gnus-group-make-archive-group (&optional all)
2272 "Create the (ding) Gnus archive group of the most recent articles.
2273 Given a prefix, create a full group."
2275 (let ((group (gnus-group-prefixed-name
2276 (if all "ding.archives" "ding.recent") '(nndir ""))))
2277 (when (gnus-gethash group gnus-newsrc-hashtb)
2278 (error "Archive group already exists"))
2279 (gnus-group-make-group
2280 (gnus-group-real-name group)
2281 (list 'nndir (if all "hpc" "edu")
2282 (list 'nndir-directory
2283 (if all gnus-group-archive-directory
2284 gnus-group-recent-archive-directory))))
2285 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2287 (defun gnus-group-make-directory-group (dir)
2288 "Create an nndir group.
2289 The user will be prompted for a directory. The contents of this
2290 directory will be used as a newsgroup. The directory should contain
2291 mail messages or news articles in files that have numeric names."
2293 (list (read-file-name "Create group from directory: ")))
2294 (unless (file-exists-p dir)
2295 (error "No such directory"))
2296 (unless (file-directory-p dir)
2297 (error "Not a directory"))
2301 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2303 (gnus-group-prefixed-name
2304 (concat (file-name-as-directory (directory-file-name dir))
2307 (setq ext (format "<%d>" (setq i (1+ i)))))
2308 (gnus-group-make-group
2309 (gnus-group-real-name group)
2310 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2312 (defun gnus-group-make-kiboze-group (group address scores)
2313 "Create an nnkiboze group.
2314 The user will be prompted for a name, a regexp to match groups, and
2315 score file entries for articles to include in the group."
2318 (read-string "nnkiboze group name: ")
2319 (read-string "Source groups (regexp): ")
2320 (let ((headers (mapcar (lambda (group) (list group))
2321 '("subject" "from" "number" "date" "message-id"
2322 "references" "chars" "lines" "xref"
2323 "followup" "all" "body" "head")))
2324 scores header regexp regexps)
2325 (while (not (equal "" (setq header (completing-read
2326 "Match on header: " headers nil t))))
2328 (while (not (equal "" (setq regexp (read-string
2329 (format "Match on %s (string): "
2331 (push (list regexp nil nil 'r) regexps))
2332 (push (cons header regexps) scores))
2334 (gnus-group-make-group group "nnkiboze" address)
2335 (with-temp-file (gnus-score-file-name (concat "nnkiboze:" group))
2336 (let (emacs-lisp-mode-hook)
2337 (pp scores (current-buffer)))))
2339 (defun gnus-group-add-to-virtual (n vgroup)
2340 "Add the current group to a virtual group."
2342 (list current-prefix-arg
2343 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2345 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2346 (error "%s is not an nnvirtual group" vgroup))
2347 (gnus-close-group vgroup)
2348 (let* ((groups (gnus-group-process-prefix n))
2349 (method (gnus-info-method (gnus-get-info vgroup))))
2350 (setcar (cdr method)
2352 (nth 1 method) "\\|"
2355 (gnus-group-remove-mark s)
2356 (concat "\\(^" (regexp-quote s) "$\\)"))
2358 (gnus-group-position-point))
2360 (defun gnus-group-make-empty-virtual (group)
2361 "Create a new, fresh, empty virtual group."
2362 (interactive "sCreate new, empty virtual group: ")
2363 (let* ((method (list 'nnvirtual "^$"))
2364 (pgroup (gnus-group-prefixed-name group method)))
2365 ;; Check whether it exists already.
2366 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2367 (error "Group %s already exists" pgroup))
2368 ;; Subscribe the new group after the group on the current line.
2369 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2370 (gnus-group-update-group pgroup)
2372 (gnus-group-position-point)))
2374 (defun gnus-group-enter-directory (dir)
2375 "Enter an ephemeral nneething group."
2376 (interactive "DDirectory to read: ")
2377 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2378 (leaf (gnus-group-prefixed-name
2379 (file-name-nondirectory (directory-file-name dir))
2381 (name (gnus-generate-new-group-name leaf)))
2382 (unless (gnus-group-read-ephemeral-group
2384 (cons (current-buffer)
2385 (if (eq major-mode 'gnus-summary-mode)
2387 (error "Couldn't enter %s" dir))))
2390 (autoload 'nnimap-expunge "nnimap")
2391 (autoload 'nnimap-acl-get "nnimap")
2392 (autoload 'nnimap-acl-edit "nnimap"))
2394 (defun gnus-group-nnimap-expunge (group)
2395 "Expunge deleted articles in current nnimap GROUP."
2396 (interactive (list (gnus-group-group-name)))
2397 (let ((mailbox (gnus-group-real-name group)) method)
2399 (error "No group on current line"))
2400 (unless (gnus-get-info group)
2401 (error "Killed group; can't be edited"))
2402 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2403 (error "%s is not an nnimap group" group))
2404 (nnimap-expunge mailbox (cadr method))))
2406 (defun gnus-group-nnimap-edit-acl (group)
2407 "Edit the Access Control List of current nnimap GROUP."
2408 (interactive (list (gnus-group-group-name)))
2409 (let ((mailbox (gnus-group-real-name group)) method acl)
2411 (error "No group on current line"))
2412 (unless (gnus-get-info group)
2413 (error "Killed group; can't be edited"))
2414 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2415 (error "%s is not an nnimap group" group))
2416 (gnus-edit-form (setq acl (nnimap-acl-get mailbox (cadr method)))
2417 (format "Editing the access control list for `%s'.
2419 An access control list is a list of (identifier . rights) elements.
2421 The identifier string specifies the corresponding user. The
2422 identifier \"anyone\" is reserved to refer to the universal identity.
2424 Rights is a string listing a (possibly empty) set of alphanumeric
2425 characters, each character listing a set of operations which is being
2426 controlled. Letters are reserved for ``standard'' rights, listed
2427 below. Digits are reserved for implementation or site defined rights.
2429 l - lookup (mailbox is visible to LIST/LSUB commands)
2430 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2431 SEARCH, COPY from mailbox)
2432 s - keep seen/unseen information across sessions (STORE SEEN flag)
2433 w - write (STORE flags other than SEEN and DELETED)
2434 i - insert (perform APPEND, COPY into mailbox)
2435 p - post (send mail to submission address for mailbox,
2436 not enforced by IMAP4 itself)
2437 c - create (CREATE new sub-mailboxes in any implementation-defined
2439 d - delete (STORE DELETED flag, perform EXPUNGE)
2440 a - administer (perform SETACL)" group)
2443 ,mailbox ',method ',acl form)))))
2445 ;; Group sorting commands
2446 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2448 (defun gnus-group-sort-groups (func &optional reverse)
2449 "Sort the group buffer according to FUNC.
2450 When used interactively, the sorting function used will be
2451 determined by the `gnus-group-sort-function' variable.
2452 If REVERSE (the prefix), reverse the sorting order."
2453 (interactive (list gnus-group-sort-function current-prefix-arg))
2454 (funcall gnus-group-sort-alist-function
2455 (gnus-make-sort-function func) reverse)
2456 (gnus-group-list-groups)
2457 (gnus-dribble-touch))
2459 (defun gnus-group-sort-flat (func reverse)
2460 ;; We peel off the dummy group from the alist.
2462 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2463 (pop gnus-newsrc-alist))
2465 (setq gnus-newsrc-alist
2466 (sort gnus-newsrc-alist func))
2468 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2469 ;; Regenerate the hash table.
2470 (gnus-make-hashtable-from-newsrc-alist)))
2472 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2473 "Sort the group buffer alphabetically by group name.
2474 If REVERSE, sort in reverse order."
2476 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2478 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2479 "Sort the group buffer by number of unread articles.
2480 If REVERSE, sort in reverse order."
2482 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2484 (defun gnus-group-sort-groups-by-level (&optional reverse)
2485 "Sort the group buffer by group level.
2486 If REVERSE, sort in reverse order."
2488 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2490 (defun gnus-group-sort-groups-by-score (&optional reverse)
2491 "Sort the group buffer by group score.
2492 If REVERSE, sort in reverse order."
2494 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2496 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2497 "Sort the group buffer by group rank.
2498 If REVERSE, sort in reverse order."
2500 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2502 (defun gnus-group-sort-groups-by-method (&optional reverse)
2503 "Sort the group buffer alphabetically by backend name.
2504 If REVERSE, sort in reverse order."
2506 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2508 ;;; Selected group sorting.
2510 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2511 "Sort the process/prefixed groups."
2512 (interactive (list current-prefix-arg gnus-group-sort-function))
2513 (let ((groups (gnus-group-process-prefix n)))
2514 (funcall gnus-group-sort-selected-function
2515 groups (gnus-make-sort-function func) reverse)
2516 (gnus-group-list-groups)))
2518 (defun gnus-group-sort-selected-flat (groups func reverse)
2519 (let (entries infos)
2520 ;; First find all the group entries for these groups.
2522 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2524 ;; Then sort the infos.
2528 (lambda (entry) (car entry))
2529 (setq entries (nreverse entries)))
2532 (setq infos (nreverse infos)))
2533 ;; Go through all the infos and replace the old entries
2534 ;; with the new infos.
2536 (setcar (car entries) (pop infos))
2538 ;; Update the hashtable.
2539 (gnus-make-hashtable-from-newsrc-alist)))
2541 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2542 "Sort the group buffer alphabetically by group name.
2543 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2544 sort in reverse order."
2545 (interactive (gnus-interactive "P\ny"))
2546 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2548 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2549 "Sort the group buffer by number of unread articles.
2550 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2551 sort in reverse order."
2552 (interactive (gnus-interactive "P\ny"))
2553 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2555 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2556 "Sort the group buffer by group level.
2557 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2558 sort in reverse order."
2559 (interactive (gnus-interactive "P\ny"))
2560 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2562 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2563 "Sort the group buffer by group score.
2564 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2565 sort in reverse order."
2566 (interactive (gnus-interactive "P\ny"))
2567 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2569 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2570 "Sort the group buffer by group rank.
2571 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2572 sort in reverse order."
2573 (interactive (gnus-interactive "P\ny"))
2574 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2576 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2577 "Sort the group buffer alphabetically by backend name.
2578 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2579 sort in reverse order."
2580 (interactive (gnus-interactive "P\ny"))
2581 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2583 ;;; Sorting predicates.
2585 (defun gnus-group-sort-by-alphabet (info1 info2)
2586 "Sort alphabetically."
2587 (string< (gnus-info-group info1) (gnus-info-group info2)))
2589 (defun gnus-group-sort-by-real-name (info1 info2)
2590 "Sort alphabetically on real (unprefixed) names."
2591 (string< (gnus-group-real-name (gnus-info-group info1))
2592 (gnus-group-real-name (gnus-info-group info2))))
2594 (defun gnus-group-sort-by-unread (info1 info2)
2595 "Sort by number of unread articles."
2596 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2597 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2598 (< (or (and (numberp n1) n1) 0)
2599 (or (and (numberp n2) n2) 0))))
2601 (defun gnus-group-sort-by-level (info1 info2)
2603 (< (gnus-info-level info1) (gnus-info-level info2)))
2605 (defun gnus-group-sort-by-method (info1 info2)
2606 "Sort alphabetically by backend name."
2607 (string< (symbol-name (car (gnus-find-method-for-group
2608 (gnus-info-group info1) info1)))
2609 (symbol-name (car (gnus-find-method-for-group
2610 (gnus-info-group info2) info2)))))
2612 (defun gnus-group-sort-by-score (info1 info2)
2613 "Sort by group score."
2614 (< (gnus-info-score info1) (gnus-info-score info2)))
2616 (defun gnus-group-sort-by-rank (info1 info2)
2617 "Sort by level and score."
2618 (let ((level1 (gnus-info-level info1))
2619 (level2 (gnus-info-level info2)))
2620 (or (< level1 level2)
2621 (and (= level1 level2)
2622 (> (gnus-info-score info1) (gnus-info-score info2))))))
2626 (defun gnus-group-clear-data (&optional arg)
2627 "Clear all marks and read ranges from the current group."
2629 (gnus-group-iterate arg
2632 (gnus-info-clear-data (setq info (gnus-get-info group)))
2633 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2634 (when (gnus-group-goto-group group)
2635 (gnus-group-update-group-line))))))
2637 (defun gnus-group-clear-data-on-native-groups ()
2638 "Clear all marks and read ranges from all native groups."
2640 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2641 (let ((alist (cdr gnus-newsrc-alist))
2643 (while (setq info (pop alist))
2644 (when (gnus-group-native-p (gnus-info-group info))
2645 (gnus-info-clear-data info)))
2646 (gnus-get-unread-articles)
2647 (gnus-dribble-touch)
2648 (when (gnus-y-or-n-p
2649 "Move the cache away to avoid problems in the future? ")
2650 (call-interactively 'gnus-cache-move-cache)))))
2652 (defun gnus-info-clear-data (info)
2653 "Clear all marks and read ranges from INFO."
2654 (let ((group (gnus-info-group info)))
2657 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2658 (gnus-info-set-read ',info ',(gnus-info-read info))
2659 (when (gnus-group-goto-group ,group)
2660 (gnus-group-update-group-line))))
2661 (gnus-info-set-read info nil)
2662 (when (gnus-info-marks info)
2663 (gnus-info-set-marks info nil))))
2665 ;; Group catching up.
2667 (defun gnus-group-catchup-current (&optional n all)
2668 "Mark all articles not marked as unread in current newsgroup as read.
2669 If prefix argument N is numeric, the next N newsgroups will be
2670 caught up. If ALL is non-nil, marked articles will also be marked as
2671 read. Cross references (Xref: header) of articles are ignored.
2672 The number of newsgroups that this function was unable to catch
2675 (let ((groups (gnus-group-process-prefix n))
2678 (unless groups (error "No groups selected"))
2680 (or (not gnus-interactive-catchup) ;Without confirmation?
2685 "Do you really want to mark all articles in %s as read? "
2686 "Mark all unread articles in %s as read? ")
2687 (if (= (length groups) 1)
2689 (format "these %d groups" (length groups)))))))
2691 (while (setq group (pop groups))
2692 (gnus-group-remove-mark group)
2693 ;; Virtual groups have to be given special treatment.
2694 (let ((method (gnus-find-method-for-group group)))
2695 (when (eq 'nnvirtual (car method))
2696 (nnvirtual-catchup-group
2697 (gnus-group-real-name group) (nth 1 method) all)))
2698 (if (>= (gnus-group-level group) gnus-level-zombie)
2699 (gnus-message 2 "Dead groups can't be caught up")
2701 (gnus-group-goto-group group)
2702 (gnus-group-catchup group all))
2703 (gnus-group-update-group-line)
2704 (setq ret (1+ ret)))))
2705 (gnus-group-next-unread-group 1)
2708 (defun gnus-group-catchup-current-all (&optional n)
2709 "Mark all articles in current newsgroup as read.
2710 Cross references (Xref: header) of articles are ignored."
2712 (gnus-group-catchup-current n 'all))
2714 (defun gnus-group-catchup (group &optional all)
2715 "Mark all articles in GROUP as read.
2716 If ALL is non-nil, all articles are marked as read.
2717 The return value is the number of articles that were marked as read,
2718 or nil if no action could be taken."
2719 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2721 ;; Remove entries for this group.
2722 (nnmail-purge-split-history (gnus-group-real-name group))
2723 ;; Do the updating only if the newsgroup isn't killed.
2724 (if (not (numberp (car entry)))
2725 (gnus-message 1 "Can't catch up %s; non-active group" group)
2726 ;; Do auto-expirable marks if that's required.
2727 (when (gnus-group-auto-expirable-p group)
2728 (gnus-add-marked-articles
2729 group 'expire (gnus-list-of-unread-articles group))
2731 (let ((marks (nth 3 (nth 2 entry))))
2732 (gnus-add-marked-articles
2733 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2734 (gnus-add-marked-articles
2735 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2737 (gnus-update-read-articles group nil)
2738 ;; Also nix out the lists of marks and dormants.
2740 (gnus-add-marked-articles group 'tick nil nil 'force)
2741 (gnus-add-marked-articles group 'dormant nil nil 'force))
2742 (let ((gnus-newsgroup-name group))
2743 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2746 (defun gnus-group-expire-articles (&optional n)
2747 "Expire all expirable articles in the current newsgroup."
2749 (let ((groups (gnus-group-process-prefix n))
2752 (error "No groups to expire"))
2753 (while (setq group (pop groups))
2754 (gnus-group-remove-mark group)
2755 (gnus-group-expire-articles-1 group)
2756 (gnus-dribble-touch)
2757 (gnus-group-position-point))))
2759 (defun gnus-group-expire-articles-1 (group)
2760 (when (gnus-check-backend-function 'request-expire-articles group)
2761 (gnus-message 6 "Expiring articles in %s..." group)
2762 (let* ((info (gnus-get-info group))
2763 (expirable (if (gnus-group-total-expirable-p group)
2764 (cons nil (gnus-list-of-read-articles group))
2765 (assq 'expire (gnus-info-marks info))))
2766 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2767 (nnmail-expiry-target
2768 (or (gnus-group-find-parameter group 'expiry-target)
2769 nnmail-expiry-target)))
2773 (gnus-compress-sequence
2775 ;; We set the expiry variables to the group
2777 (let ((nnmail-expiry-wait-function nil)
2778 (nnmail-expiry-wait expiry-wait))
2779 (gnus-request-expire-articles
2780 (gnus-uncompress-sequence (cdr expirable)) group))
2781 ;; Just expire using the normal expiry values.
2782 (gnus-request-expire-articles
2783 (gnus-uncompress-sequence (cdr expirable)) group))))
2784 (gnus-close-group group))
2785 (gnus-message 6 "Expiring articles in %s...done" group))))
2787 (defun gnus-group-expire-all-groups ()
2788 "Expire all expirable articles in all newsgroups."
2791 (gnus-message 5 "Expiring...")
2792 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2793 (cdr gnus-newsrc-alist))))
2794 (gnus-group-expire-articles nil)))
2795 (gnus-group-position-point)
2796 (gnus-message 5 "Expiring...done"))
2798 (defun gnus-group-set-current-level (n level)
2799 "Set the level of the next N groups to LEVEL."
2804 (let ((s (read-string
2805 (format "Level (default %s): "
2806 (or (gnus-group-group-level)
2807 gnus-level-default-subscribed)))))
2808 (if (string-match "^\\s-*$" s)
2809 (int-to-string (or (gnus-group-group-level)
2810 gnus-level-default-subscribed))
2812 (unless (and (>= level 1) (<= level gnus-level-killed))
2813 (error "Invalid level: %d" level))
2814 (let ((groups (gnus-group-process-prefix n))
2816 (while (setq group (pop groups))
2817 (gnus-group-remove-mark group)
2818 (gnus-message 6 "Changed level of %s from %d to %d"
2819 group (or (gnus-group-group-level) gnus-level-killed)
2821 (gnus-group-change-level
2822 group level (or (gnus-group-group-level) gnus-level-killed))
2823 (gnus-group-update-group-line)))
2824 (gnus-group-position-point))
2826 (defun gnus-group-unsubscribe (&optional n)
2827 "Unsubscribe the current group."
2829 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2831 (defun gnus-group-subscribe (&optional n)
2832 "Subscribe the current group."
2834 (gnus-group-unsubscribe-current-group n 'subscribe))
2836 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2837 "Toggle subscription of the current group.
2838 If given numerical prefix, toggle the N next groups."
2840 (let ((groups (gnus-group-process-prefix n))
2843 (setq group (car groups)
2844 groups (cdr groups))
2845 (gnus-group-remove-mark group)
2846 (gnus-group-unsubscribe-group
2849 ((eq do-sub 'unsubscribe)
2850 gnus-level-default-unsubscribed)
2851 ((eq do-sub 'subscribe)
2852 gnus-level-default-subscribed)
2853 ((<= (gnus-group-group-level) gnus-level-subscribed)
2854 gnus-level-default-unsubscribed)
2856 gnus-level-default-subscribed))
2858 (gnus-group-update-group-line))
2859 (gnus-group-next-group 1)))
2861 (defun gnus-group-unsubscribe-group (group &optional level silent)
2862 "Toggle subscription to GROUP.
2863 Killed newsgroups are subscribed. If SILENT, don't try to update the
2866 (list (completing-read
2867 "Group: " gnus-active-hashtb nil
2868 (gnus-read-active-file-p)
2870 'gnus-group-history)))
2871 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2873 ((string-match "^[ \t]*$" group)
2874 (error "Empty group name"))
2876 ;; Toggle subscription flag.
2877 (gnus-group-change-level
2878 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2879 gnus-level-subscribed)
2880 (1+ gnus-level-subscribed)
2881 gnus-level-default-subscribed)))
2883 (gnus-group-update-group group)))
2884 ((and (stringp group)
2885 (or (not (gnus-read-active-file-p))
2886 (gnus-active group)))
2887 ;; Add new newsgroup.
2888 (gnus-group-change-level
2890 (if level level gnus-level-default-subscribed)
2891 (or (and (member group gnus-zombie-list)
2894 (when (gnus-group-group-name)
2895 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2897 (gnus-group-update-group group)))
2898 (t (error "No such newsgroup: %s" group)))
2899 (gnus-group-position-point)))
2901 (defun gnus-group-transpose-groups (n)
2902 "Move the current newsgroup up N places.
2903 If given a negative prefix, move down instead. The difference between
2904 N and the number of steps taken is returned."
2906 (unless (gnus-group-group-name)
2907 (error "No group on current line"))
2908 (gnus-group-kill-group 1)
2910 (forward-line (- n))
2911 (gnus-group-yank-group)
2912 (gnus-group-position-point)))
2914 (defun gnus-group-kill-all-zombies (&optional dummy)
2915 "Kill all zombie newsgroups.
2916 The optional DUMMY should always be nil."
2917 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2919 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2920 (setq gnus-zombie-list nil)
2921 (gnus-dribble-touch)
2922 (gnus-group-list-groups)))
2924 (defun gnus-group-kill-region (begin end)
2925 "Kill newsgroups in current region (excluding current point).
2926 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2941 (beginning-of-line) ;Important when LINES < 1
2942 (gnus-group-kill-group lines)))
2944 (defun gnus-group-kill-group (&optional n discard)
2945 "Kill the next N groups.
2946 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2947 However, only groups that were alive can be yanked; already killed
2948 groups or zombie groups can't be yanked.
2949 The return value is the name of the group that was killed, or a list
2952 (let ((buffer-read-only nil)
2953 (groups (gnus-group-process-prefix n))
2954 group entry level out)
2955 (if (< (length groups) 10)
2956 ;; This is faster when there are few groups.
2958 (push (setq group (pop groups)) out)
2959 (gnus-group-remove-mark group)
2960 (setq level (gnus-group-group-level))
2962 (when (and (not discard)
2963 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2966 (gnus-group-goto-group ,(gnus-group-group-name))
2967 (gnus-group-yank-group)))
2968 (push (cons (car entry) (nth 2 entry))
2969 gnus-list-of-killed-groups))
2970 (gnus-group-change-level
2971 (if entry entry group) gnus-level-killed (if entry nil level))
2972 (message "Killed group %s" group))
2973 ;; If there are lots and lots of groups to be killed, we use
2974 ;; this thing instead.
2976 (setq groups (nreverse groups))
2978 (gnus-group-remove-mark (setq group (pop groups)))
2980 (push group gnus-killed-list)
2981 (setq gnus-newsrc-alist
2982 (delq (assoc group gnus-newsrc-alist)
2984 (when gnus-group-change-level-function
2985 (funcall gnus-group-change-level-function
2986 group gnus-level-killed 3))
2988 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2989 (push (cons (car entry) (nth 2 entry))
2990 gnus-list-of-killed-groups)
2991 (setcdr (cdr entry) (cdddr entry)))
2992 ((member group gnus-zombie-list)
2993 (setq gnus-zombie-list (delete group gnus-zombie-list))))
2994 ;; There may be more than one instance displayed.
2995 (while (gnus-group-goto-group group)
2996 (gnus-delete-line)))
2997 (gnus-make-hashtable-from-newsrc-alist)))
2999 (gnus-group-position-point)
3000 (if (< (length out) 2) (car out) (nreverse out))))
3002 (defun gnus-group-yank-group (&optional arg)
3003 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3004 The numeric ARG specifies how many newsgroups are to be yanked. The
3005 name of the newsgroup yanked is returned, or (if several groups are
3006 yanked) a list of yanked groups is returned."
3008 (setq arg (or arg 1))
3009 (let (info group prev out)
3010 (while (>= (decf arg) 0)
3011 (when (not (setq info (pop gnus-list-of-killed-groups)))
3012 (error "No more newsgroups to yank"))
3013 (push (setq group (nth 1 info)) out)
3014 ;; Find which newsgroup to insert this one before - search
3015 ;; backward until something suitable is found. If there are no
3016 ;; other newsgroups in this buffer, just make this newsgroup the
3018 (setq prev (gnus-group-group-name))
3019 (gnus-group-change-level
3020 info (gnus-info-level (cdr info)) gnus-level-killed
3021 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3023 (gnus-group-insert-group-line-info group)
3025 `(when (gnus-group-goto-group ,group)
3026 (gnus-group-kill-group 1))))
3028 (gnus-group-position-point)
3029 (if (< (length out) 2) (car out) (nreverse out))))
3031 (defun gnus-group-kill-level (level)
3032 "Kill all groups that is on a certain LEVEL."
3033 (interactive "nKill all groups on level: ")
3035 ((= level gnus-level-zombie)
3036 (setq gnus-killed-list
3037 (nconc gnus-zombie-list gnus-killed-list))
3038 (setq gnus-zombie-list nil))
3039 ((and (< level gnus-level-zombie)
3041 (or gnus-expert-user
3044 "Do you really want to kill all groups on level %d? "
3046 (let* ((prev gnus-newsrc-alist)
3049 (if (= (gnus-info-level (car alist)) level)
3051 (push (gnus-info-group (car alist)) gnus-killed-list)
3052 (setcdr prev (cdr alist)))
3054 (setq alist (cdr alist)))
3055 (gnus-make-hashtable-from-newsrc-alist)
3056 (gnus-group-list-groups)))
3058 (error "Can't kill; invalid level: %d" level))))
3060 (defun gnus-group-list-all-groups (&optional arg)
3061 "List all newsgroups with level ARG or lower.
3062 Default is gnus-level-unsubscribed, which lists all subscribed and most
3063 unsubscribed groups."
3065 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3067 ;; Redefine this to list ALL killed groups if prefix arg used.
3068 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3069 (defun gnus-group-list-killed (&optional arg)
3070 "List all killed newsgroups in the group buffer.
3071 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3072 entail asking the server for the groups."
3074 ;; Find all possible killed newsgroups if arg.
3076 (gnus-get-killed-groups))
3077 (if (not gnus-killed-list)
3078 (gnus-message 6 "No killed groups")
3079 (let (gnus-group-list-mode)
3080 (funcall gnus-group-prepare-function
3081 gnus-level-killed t gnus-level-killed))
3082 (goto-char (point-min)))
3083 (gnus-group-position-point))
3085 (defun gnus-group-list-zombies ()
3086 "List all zombie newsgroups in the group buffer."
3088 (if (not gnus-zombie-list)
3089 (gnus-message 6 "No zombie groups")
3090 (let (gnus-group-list-mode)
3091 (funcall gnus-group-prepare-function
3092 gnus-level-zombie t gnus-level-zombie))
3093 (goto-char (point-min)))
3094 (gnus-group-position-point))
3096 (defun gnus-group-list-active ()
3097 "List all groups that are available from the server(s)."
3099 ;; First we make sure that we have really read the active file.
3100 (unless (gnus-read-active-file-p)
3101 (let ((gnus-read-active-file t)
3102 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3103 (gnus-read-active-file)))
3104 ;; Find all groups and sort them.
3112 (push (symbol-name sym) list)))
3116 (buffer-read-only nil)
3120 (gnus-add-text-properties
3121 (point) (prog1 (1+ (point))
3123 (setq group (pop groups)) "\n"))
3124 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3126 'gnus-level (inline (gnus-group-level group)))))
3127 (goto-char (point-min))))
3129 (defun gnus-activate-all-groups (level)
3130 "Activate absolutely all groups."
3131 (interactive (list gnus-level-unsubscribed))
3132 (let ((gnus-activate-level level)
3133 (gnus-activate-foreign-newsgroups level))
3134 (gnus-group-get-new-news)))
3136 (defun gnus-group-get-new-news (&optional arg)
3137 "Get newly arrived articles.
3138 If ARG is a number, it specifies which levels you are interested in
3139 re-scanning. If ARG is non-nil and not a number, this will force
3140 \"hard\" re-reading of the active files from all servers."
3143 (let ((gnus-inhibit-demon t)
3144 ;; Binding this variable will inhibit multiple fetchings
3145 ;; of the same mail source.
3146 (nnmail-fetched-sources (list t)))
3147 (gnus-run-hooks 'gnus-get-new-news-hook)
3149 ;; Read any slave files.
3151 (gnus-master-read-slave-newsrc))
3153 ;; We might read in new NoCeM messages here.
3154 (when (and gnus-use-nocem
3156 (gnus-nocem-scan-groups))
3157 ;; If ARG is not a number, then we read the active file.
3158 (when (and arg (not (numberp arg)))
3159 (let ((gnus-read-active-file t))
3160 (gnus-read-active-file))
3163 ;; If the user wants it, we scan for new groups.
3164 (when (eq gnus-check-new-newsgroups 'always)
3165 (gnus-find-new-newsgroups)))
3167 (setq arg (gnus-group-default-level arg t))
3168 (if (and gnus-read-active-file (not arg))
3170 (gnus-read-active-file)
3171 (gnus-get-unread-articles arg))
3172 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3173 (gnus-get-unread-articles arg)))
3174 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3175 (gnus-group-list-groups (and (numberp arg)
3176 (max (car gnus-group-list-mode) arg)))))
3178 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3179 "Check for newly arrived news in the current group (and the N-1 next groups).
3180 The difference between N and the number of newsgroup checked is returned.
3181 If N is negative, this group and the N-1 previous groups will be checked."
3183 (let* ((groups (gnus-group-process-prefix n))
3184 (ret (if (numberp n) (- n (length groups)) 0))
3188 (gnus-inhibit-demon t)
3189 ;; Binding this variable will inhibit multiple fetchings
3190 ;; of the same mail source.
3191 (nnmail-fetched-sources (list t)))
3192 (gnus-run-hooks 'gnus-get-new-news-hook)
3193 (while (setq group (pop groups))
3194 (gnus-group-remove-mark group)
3195 ;; Bypass any previous denials from the server.
3196 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3197 (if (gnus-activate-group group (if dont-scan nil 'scan))
3199 (gnus-get-unread-articles-in-group
3200 (gnus-get-info group) (gnus-active group) t)
3201 (unless (gnus-virtual-group-p group)
3202 (gnus-close-group group))
3204 (gnus-agent-save-group-info
3205 method (gnus-group-real-name group) (gnus-active group)))
3206 (gnus-group-update-group group))
3207 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3209 (gnus-error 3 "Server denied access")
3210 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3213 (when gnus-goto-next-group-when-activating
3214 (gnus-group-next-unread-group 1 t))
3215 (gnus-summary-position-point)
3218 (defun gnus-group-fetch-faq (group &optional faq-dir)
3219 "Fetch the FAQ for the current group.
3220 If given a prefix argument, prompt for the FAQ dir
3224 (gnus-group-group-name)
3225 (when current-prefix-arg
3227 "Faq dir: " (and (listp gnus-group-faq-directory)
3228 (mapcar (lambda (file) (list file))
3229 gnus-group-faq-directory))))))
3231 (error "No group name given"))
3232 (let ((dirs (or faq-dir gnus-group-faq-directory))
3234 (unless (listp dirs)
3235 (setq dirs (list dirs)))
3236 (while (and (not found)
3237 (setq dir (pop dirs)))
3238 (let ((name (gnus-group-real-name group)))
3239 (setq file (concat (file-name-as-directory dir) name)))
3240 (if (not (file-exists-p file))
3241 (gnus-message 1 "No such file: %s" file)
3242 (let ((enable-local-variables nil))
3246 (defun gnus-group-describe-group (force &optional group)
3247 "Display a description of the current newsgroup."
3248 (interactive (list current-prefix-arg (gnus-group-group-name)))
3249 (let* ((method (gnus-find-method-for-group group))
3250 (mname (gnus-group-prefixed-name "" method))
3253 gnus-description-hashtb)
3254 (gnus-sethash mname nil gnus-description-hashtb))
3256 (error "No group name given"))
3257 (when (or (and gnus-description-hashtb
3258 ;; We check whether this group's method has been
3259 ;; queried for a description file.
3260 (gnus-gethash mname gnus-description-hashtb))
3261 (setq desc (gnus-group-get-description group))
3262 (gnus-read-descriptions-file method))
3264 (or desc (gnus-gethash group gnus-description-hashtb)
3265 "No description available")))))
3267 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3268 (defun gnus-group-describe-all-groups (&optional force)
3269 "Pop up a buffer with descriptions of all newsgroups."
3272 (setq gnus-description-hashtb nil))
3273 (when (not (or gnus-description-hashtb
3274 (gnus-read-all-descriptions-files)))
3275 (error "Couldn't request descriptions file"))
3276 (let ((buffer-read-only nil)
3282 (insert (format " *: %-20s %s\n" (symbol-name group)
3283 (symbol-value group)))
3284 (gnus-add-text-properties
3285 b (1+ b) (list 'gnus-group group
3286 'gnus-unread t 'gnus-marked nil
3287 'gnus-level (1+ gnus-level-subscribed))))
3288 gnus-description-hashtb)
3289 (goto-char (point-min))
3290 (gnus-group-position-point)))
3292 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3293 (defun gnus-group-apropos (regexp &optional search-description)
3294 "List all newsgroups that have names that match a regexp."
3295 (interactive "sGnus apropos (regexp): ")
3297 (obuf (current-buffer))
3299 ;; Go through all newsgroups that are known to Gnus.
3302 (and (symbol-name group)
3303 (string-match regexp (symbol-name group))
3304 (symbol-value group)
3305 (push (symbol-name group) groups)))
3307 ;; Also go through all descriptions that are known to Gnus.
3308 (when search-description
3311 (and (string-match regexp (symbol-value group))
3312 (push (symbol-name group) groups)))
3313 gnus-description-hashtb))
3315 (gnus-message 3 "No groups matched \"%s\"." regexp)
3316 ;; Print out all the groups.
3318 (pop-to-buffer "*Gnus Help*")
3319 (buffer-disable-undo)
3321 (setq groups (sort groups 'string<))
3323 ;; Groups may be entered twice into the list of groups.
3324 (when (not (string= (car groups) prev))
3325 (insert (setq prev (car groups)) "\n")
3326 (when (and gnus-description-hashtb
3327 (setq des (gnus-gethash (car groups)
3328 gnus-description-hashtb)))
3329 (insert " " des "\n")))
3330 (setq groups (cdr groups)))
3331 (goto-char (point-min))))
3332 (pop-to-buffer obuf)))
3334 (defun gnus-group-description-apropos (regexp)
3335 "List all newsgroups that have names or descriptions that match a regexp."
3336 (interactive "sGnus description apropos (regexp): ")
3337 (when (not (or gnus-description-hashtb
3338 (gnus-read-all-descriptions-files)))
3339 (error "Couldn't request descriptions file"))
3340 (gnus-group-apropos regexp t))
3342 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3343 (defun gnus-group-list-matching (level regexp &optional all lowest)
3344 "List all groups with unread articles that match REGEXP.
3345 If the prefix LEVEL is non-nil, it should be a number that says which
3346 level to cut off listing groups.
3347 If ALL, also list groups with no unread articles.
3348 If LOWEST, don't list groups with level lower than LOWEST.
3350 This command may read the active file."
3351 (interactive "P\nsList newsgroups matching: ")
3352 ;; First make sure active file has been read.
3354 (> (prefix-numeric-value level) gnus-level-killed))
3355 (gnus-get-killed-groups))
3356 (gnus-group-prepare-flat
3357 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3358 (goto-char (point-min))
3359 (gnus-group-position-point))
3361 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3362 "List all groups that match REGEXP.
3363 If the prefix LEVEL is non-nil, it should be a number that says which
3364 level to cut off listing groups.
3365 If LOWEST, don't list groups with level lower than LOWEST."
3366 (interactive "P\nsList newsgroups matching: ")
3368 (setq level (prefix-numeric-value level)))
3369 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3371 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3372 (defun gnus-group-save-newsrc (&optional force)
3373 "Save the Gnus startup files.
3374 If FORCE, force saving whether it is necessary or not."
3376 (gnus-save-newsrc-file force))
3378 (defun gnus-group-restart (&optional arg)
3379 "Force Gnus to read the .newsrc file."
3381 (when (gnus-yes-or-no-p
3382 (format "Are you sure you want to restart Gnus? "))
3383 (gnus-save-newsrc-file)
3387 (defun gnus-group-read-init-file ()
3388 "Read the Gnus elisp init file."
3390 (gnus-read-init-file)
3391 (gnus-message 5 "Read %s" gnus-init-file))
3393 (defun gnus-group-check-bogus-groups (&optional silent)
3394 "Check bogus newsgroups.
3395 If given a prefix, don't ask for confirmation before removing a bogus
3398 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3399 (gnus-group-list-groups))
3401 (defun gnus-group-find-new-groups (&optional arg)
3402 "Search for new groups and add them.
3403 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3404 With 1 C-u, use the `ask-server' method to query the server for new
3406 With 2 C-u's, use most complete method possible to query the server
3407 for new groups, and subscribe the new groups as zombies."
3409 (gnus-find-new-newsgroups (or arg 1))
3410 (gnus-group-list-groups))
3412 (defun gnus-group-edit-global-kill (&optional article group)
3413 "Edit the global kill file.
3414 If GROUP, edit that local kill file instead."
3416 (setq gnus-current-kill-article article)
3417 (gnus-kill-file-edit-file group)
3420 (substitute-command-keys
3421 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3422 (if group "local" "global")))))
3424 (defun gnus-group-edit-local-kill (article group)
3425 "Edit a local kill file."
3426 (interactive (list nil (gnus-group-group-name)))
3427 (gnus-group-edit-global-kill article group))
3429 (defun gnus-group-force-update ()
3430 "Update `.newsrc' file."
3432 (gnus-save-newsrc-file))
3434 (defun gnus-group-suspend ()
3435 "Suspend the current Gnus session.
3436 In fact, cleanup buffers except for group mode buffer.
3437 The hook gnus-suspend-gnus-hook is called before actually suspending."
3439 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3440 ;; Kill Gnus buffers except for group mode buffer.
3441 (let ((group-buf (get-buffer gnus-group-buffer)))
3442 (mapcar (lambda (buf)
3443 (unless (member buf (list group-buf gnus-dribble-buffer))
3446 (gnus-kill-gnus-frames)
3448 (bury-buffer group-buf)
3449 (delete-windows-on group-buf t))))
3451 (defun gnus-group-clear-dribble ()
3452 "Clear all information from the dribble buffer."
3454 (gnus-dribble-clear)
3455 (gnus-message 7 "Cleared dribble buffer"))
3457 (defun gnus-group-exit ()
3458 "Quit reading news after updating .newsrc.eld and .newsrc.
3459 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3462 (or noninteractive ;For gnus-batch-kill
3463 (not gnus-interactive-exit) ;Without confirmation
3465 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3466 (gnus-run-hooks 'gnus-exit-gnus-hook)
3467 ;; Offer to save data from non-quitted summary buffers.
3468 (gnus-offer-save-summaries)
3469 ;; Save the newsrc file(s).
3470 (gnus-save-newsrc-file)
3472 (gnus-close-backends)
3473 ;; Reset everything.
3475 ;; Allow the user to do things after cleaning up.
3476 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3478 (defun gnus-group-quit ()
3479 "Quit reading news without updating .newsrc.eld or .newsrc.
3480 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3482 (when (or noninteractive ;For gnus-batch-kill
3483 (zerop (buffer-size))
3484 (not (gnus-server-opened gnus-select-method))
3486 (not gnus-current-startup-file)
3488 (format "Quit reading news without saving %s? "
3489 (file-name-nondirectory gnus-current-startup-file))))
3490 (gnus-run-hooks 'gnus-exit-gnus-hook)
3491 (gnus-configure-windows 'group t)
3493 (gnus-close-backends)
3495 (gnus-kill-buffer gnus-group-buffer)
3496 ;; Allow the user to do things after cleaning up.
3497 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3499 (defun gnus-group-describe-briefly ()
3500 "Give a one line description of the group mode commands."
3502 (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")))
3504 (defun gnus-group-browse-foreign-server (method)
3505 "Browse a foreign news server.
3506 If called interactively, this function will ask for a select method
3507 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3508 If not, METHOD should be a list where the first element is the method
3509 and the second element is the address."
3511 (list (let ((how (completing-read
3513 (append gnus-valid-select-methods gnus-server-alist)
3514 nil t (cons "nntp" 0) 'gnus-method-history)))
3515 ;; We either got a backend name or a virtual server name.
3516 ;; If the first, we also need an address.
3517 (if (assoc how gnus-valid-select-methods)
3519 ;; Suggested by mapjph@bath.ac.uk.
3522 (mapcar (lambda (server) (list server))
3523 gnus-secondary-servers)))
3524 ;; We got a server name.
3526 (gnus-browse-foreign-server method))
3528 (defun gnus-group-set-info (info &optional method-only-group part)
3529 (when (or info part)
3530 (let* ((entry (gnus-gethash
3531 (or method-only-group (gnus-info-group info))
3532 gnus-newsrc-hashtb))
3534 (info (if method-only-group (nth 2 entry) info))
3536 (when method-only-group
3538 (error "Trying to change non-existent group %s" method-only-group))
3539 ;; We have received parts of the actual group info - either the
3540 ;; select method or the group parameters. We first check
3541 ;; whether we have to extend the info, and if so, do that.
3542 (let ((len (length info))
3543 (total (if (eq part 'method) 5 6)))
3545 (setcdr (nthcdr (1- len) info)
3546 (make-list (- total len) nil)))
3547 ;; Then we enter the new info.
3548 (setcar (nthcdr (1- total) info) part-info)))
3550 ;; This is a new group, so we just create it.
3552 (set-buffer gnus-group-buffer)
3553 (setq method (gnus-info-method info))
3554 (when (gnus-server-equal method "native")
3557 (set-buffer gnus-group-buffer)
3559 ;; It's a foreign group...
3560 (gnus-group-make-group
3561 (gnus-group-real-name (gnus-info-group info))
3562 (if (stringp method) method
3563 (prin1-to-string (car method)))
3565 (nth 1 (gnus-info-method info))))
3566 ;; It's a native group.
3567 (gnus-group-make-group (gnus-info-group info))))
3568 (gnus-message 6 "Note: New group created")
3570 (gnus-gethash (gnus-group-prefixed-name
3571 (gnus-group-real-name (gnus-info-group info))
3572 (or (gnus-info-method info) gnus-select-method))
3573 gnus-newsrc-hashtb))))
3574 ;; Whether it was a new group or not, we now have the entry, so we
3575 ;; can do the update.
3578 (setcar (nthcdr 2 entry) info)
3579 (when (and (not (eq (car entry) t))
3580 (gnus-active (gnus-info-group info)))
3581 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3582 (error "No such group: %s" (gnus-info-group info))))))
3584 (defun gnus-group-set-method-info (group select-method)
3585 (gnus-group-set-info select-method group 'method))
3587 (defun gnus-group-set-params-info (group params)
3588 (gnus-group-set-info params group 'params))
3590 (defun gnus-add-marked-articles (group type articles &optional info force)
3591 ;; Add ARTICLES of TYPE to the info of GROUP.
3592 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3593 ;; add, but replace marked articles of TYPE with ARTICLES.
3594 (let ((info (or info (gnus-get-info group)))
3597 (and (not (setq marked (nthcdr 3 info)))
3599 (setcdr (nthcdr 2 info)
3600 (list (list (cons type (gnus-compress-sequence
3602 (and (not (setq m (assq type (car marked))))
3605 (cons (cons type (gnus-compress-sequence articles t) )
3609 (setcar (nthcdr 3 info)
3610 (gnus-delete-alist type (car marked)))
3611 (setcdr m (gnus-compress-sequence articles t)))
3612 (setcdr m (gnus-compress-sequence
3613 (sort (nconc (gnus-uncompress-range (cdr m))
3614 (copy-sequence articles)) '<) t))))))
3617 ;;; Group timestamps
3620 (defun gnus-group-set-timestamp ()
3621 "Change the timestamp of the current group to the current time.
3622 This function can be used in hooks like `gnus-select-group-hook'
3623 or `gnus-group-catchup-group-hook'."
3624 (when gnus-newsgroup-name
3625 (let ((time (current-time)))
3626 (setcdr (cdr time) nil)
3627 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3629 (defsubst gnus-group-timestamp (group)
3630 "Return the timestamp for GROUP."
3631 (gnus-group-get-parameter group 'timestamp t))
3633 (defun gnus-group-timestamp-delta (group)
3634 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3635 (let* ((time (or (gnus-group-timestamp group)
3637 (delta (subtract-time (current-time) time)))
3638 (+ (* (nth 0 delta) 65536.0)
3641 (defun gnus-group-timestamp-string (group)
3642 "Return a string of the timestamp for GROUP."
3643 (let ((time (gnus-group-timestamp group)))
3646 (gnus-time-iso8601 time))))
3648 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest)
3649 "List all newsgroups with unread articles of level LEVEL or lower.
3650 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3651 If PREDICATE, only list groups which PREDICATE returns non-nil."
3652 (set-buffer gnus-group-buffer)
3653 (let ((buffer-read-only nil)
3654 (newsrc (cdr gnus-newsrc-alist))
3655 (lowest (or lowest 1))
3656 info clevel unread group params)
3658 ;; List living groups.
3660 (setq info (car newsrc)
3661 group (gnus-info-group info)
3662 params (gnus-info-params info)
3664 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3665 (and unread ; This group might be unchecked
3666 (funcall predicate info)
3667 (<= (setq clevel (gnus-info-level info)) level)
3669 (gnus-group-insert-group-line
3670 group (gnus-info-level info)
3671 (gnus-info-marks info) unread (gnus-info-method info))))
3673 (gnus-group-set-mode-line)
3674 (setq gnus-group-list-mode (cons level t))
3675 (gnus-run-hooks 'gnus-group-prepare-hook)
3678 (defun gnus-group-list-cached (level &optional lowest)
3679 "List all groups with cached articles.
3680 If the prefix LEVEL is non-nil, it should be a number that says which
3681 level to cut off listing groups.
3682 If LOWEST, don't list groups with level lower than LOWEST.
3684 This command may read the active file."
3687 (setq level (prefix-numeric-value level)))
3688 (gnus-group-prepare-flat-predicate (or level gnus-level-killed)
3690 (let ((marks (gnus-info-marks info)))
3691 (assq 'cache marks)))
3693 (goto-char (point-min))
3694 (gnus-group-position-point))
3696 (provide 'gnus-group)
3698 ;;; gnus-group.el ends here