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 %u User defined specifier. The next character in the format string should
165 be a letter. Gnus will call the function gnus-user-format-function-X,
166 where X is the letter following %u. The function will be passed the
167 current header as argument. The function should return a string, which
168 will be inserted into the buffer just like information from any other
171 Text between %( and %) will be highlighted with `gnus-mouse-face' when
172 the mouse point move inside the area. There can only be one such area.
174 Note that this format specification is not always respected. For
175 reasons of efficiency, when listing killed groups, this specification
176 is ignored altogether. If the spec is changed considerably, your
177 output may end up looking strange when listing both alive and killed
180 If you use %o or %O, reading the active file will be slower and quite
181 a bit of extra memory will be used. %D will also worsen performance.
182 Also note that if you change the format specification to include any
183 of these specs, you must probably re-start Gnus to see them go into
185 :group 'gnus-group-visual
188 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
189 "*The format specification for the group mode line.
190 It works along the same lines as a normal formatting string,
191 with some simple extensions:
193 %S The native news server.
194 %M The native select method.
195 %: \":\" if %S isn't \"\"."
196 :group 'gnus-group-visual
199 (defcustom gnus-group-mode-hook nil
200 "Hook for Gnus group mode."
201 :group 'gnus-group-various
202 :options '(gnus-topic-mode)
205 (defcustom gnus-group-menu-hook nil
206 "Hook run after the creation of the group mode menu."
207 :group 'gnus-group-various
210 (defcustom gnus-group-catchup-group-hook nil
211 "Hook run when catching up a group from the group buffer."
212 :group 'gnus-group-various
213 :link '(custom-manual "(gnus)Group Data")
216 (defcustom gnus-group-update-group-hook nil
217 "Hook called when updating group lines."
218 :group 'gnus-group-visual
221 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
222 "*A function that is called to generate the group buffer.
223 The function is called with three arguments: The first is a number;
224 all group with a level less or equal to that number should be listed,
225 if the second is non-nil, empty groups should also be displayed. If
226 the third is non-nil, it is a number. No groups with a level lower
227 than this number should be displayed.
229 The only current function implemented is `gnus-group-prepare-flat'."
230 :group 'gnus-group-listing
233 (defcustom gnus-group-prepare-hook nil
234 "Hook called after the group buffer has been generated.
235 If you want to modify the group buffer, you can use this hook."
236 :group 'gnus-group-listing
239 (defcustom gnus-suspend-gnus-hook nil
240 "Hook called when suspending (not exiting) Gnus."
244 (defcustom gnus-exit-gnus-hook nil
245 "Hook called when exiting Gnus."
249 (defcustom gnus-after-exiting-gnus-hook nil
250 "Hook called after exiting Gnus."
254 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
255 "Hook called when a group line is changed.
256 The hook will not be called if `gnus-visual' is nil.
258 The default function `gnus-group-highlight-line' will
259 highlight the line according to the `gnus-group-highlight'
261 :group 'gnus-group-visual
264 (defcustom gnus-useful-groups
265 '(("(ding) mailing list mirrored at sunsite.auc.dk"
267 (nntp "sunsite.auc.dk"
268 (nntp-address "sunsite.auc.dk")))
271 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
275 (nndoc-article-type mbox)
276 (eval `(nndoc-address
277 ,(let ((file (nnheader-find-etc-directory
280 (error "Couldn't find doc group"))
282 "*Alist of useful group-server pairs."
283 :group 'gnus-group-listing
284 :type '(repeat (list (string :tag "Description")
286 (sexp :tag "Method"))))
288 (defcustom gnus-group-highlight
290 ((and (= unread 0) (not mailp) (eq level 1)) .
291 gnus-group-news-1-empty-face)
292 ((and (not mailp) (eq level 1)) .
293 gnus-group-news-1-face)
294 ((and (= unread 0) (not mailp) (eq level 2)) .
295 gnus-group-news-2-empty-face)
296 ((and (not mailp) (eq level 2)) .
297 gnus-group-news-2-face)
298 ((and (= unread 0) (not mailp) (eq level 3)) .
299 gnus-group-news-3-empty-face)
300 ((and (not mailp) (eq level 3)) .
301 gnus-group-news-3-face)
302 ((and (= unread 0) (not mailp) (eq level 4)) .
303 gnus-group-news-4-empty-face)
304 ((and (not mailp) (eq level 4)) .
305 gnus-group-news-4-face)
306 ((and (= unread 0) (not mailp) (eq level 5)) .
307 gnus-group-news-5-empty-face)
308 ((and (not mailp) (eq level 5)) .
309 gnus-group-news-5-face)
310 ((and (= unread 0) (not mailp) (eq level 6)) .
311 gnus-group-news-6-empty-face)
312 ((and (not mailp) (eq level 6)) .
313 gnus-group-news-6-face)
314 ((and (= unread 0) (not mailp)) .
315 gnus-group-news-low-empty-face)
317 gnus-group-news-low-face)
319 ((and (= unread 0) (eq level 1)) .
320 gnus-group-mail-1-empty-face)
322 gnus-group-mail-1-face)
323 ((and (= unread 0) (eq level 2)) .
324 gnus-group-mail-2-empty-face)
326 gnus-group-mail-2-face)
327 ((and (= unread 0) (eq level 3)) .
328 gnus-group-mail-3-empty-face)
330 gnus-group-mail-3-face)
332 gnus-group-mail-low-empty-face)
334 gnus-group-mail-low-face))
335 "*Controls the highlighting of group buffer lines.
337 Below is a list of `Form'/`Face' pairs. When deciding how a a
338 particular group line should be displayed, each form is
339 evaluated. The content of the face field after the first true form is
340 used. You can change how those group lines are displayed by
341 editing the face field.
343 It is also possible to change and add form fields, but currently that
344 requires an understanding of Lisp expressions. Hopefully this will
345 change in a future release. For now, you can use the following
346 variables in the Lisp expression:
348 group: The name of the group.
349 unread: The number of unread articles in the group.
350 method: The select method used.
351 mailp: Whether it's a mail group or not.
352 level: The level of the group.
353 score: The score of the group.
354 ticked: The number of ticked articles."
355 :group 'gnus-group-visual
356 :type '(repeat (cons (sexp :tag "Form") face)))
358 (defcustom gnus-new-mail-mark ?%
359 "Mark used for groups with new mail."
360 :group 'gnus-group-visual
363 ;;; Internal variables
365 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
366 "Function for sorting the group buffer.")
368 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
369 "Function for sorting the selected groups in the group buffer.")
371 (defvar gnus-group-indentation-function nil)
372 (defvar gnus-goto-missing-group-function nil)
373 (defvar gnus-group-update-group-function nil)
374 (defvar gnus-group-goto-next-group-function nil
375 "Function to override finding the next group after listing groups.")
377 (defvar gnus-group-edit-buffer nil)
379 (defvar gnus-group-line-format-alist
380 `((?M gnus-tmp-marked-mark ?c)
381 (?S gnus-tmp-subscribed ?c)
382 (?L gnus-tmp-level ?d)
383 (?N (cond ((eq number t) "*" )
387 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
388 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
390 (?R gnus-tmp-number-of-read ?s)
391 (?t gnus-tmp-number-total ?d)
392 (?y gnus-tmp-number-of-unread ?s)
393 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
394 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
395 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
396 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
397 (?g gnus-tmp-group ?s)
398 (?G gnus-tmp-qualified-group ?s)
399 (?c (gnus-short-group-name gnus-tmp-group) ?s)
400 (?D gnus-tmp-newsgroup-description ?s)
401 (?o gnus-tmp-moderated ?c)
402 (?O gnus-tmp-moderated-string ?s)
403 (?p gnus-tmp-process-marked ?c)
404 (?s gnus-tmp-news-server ?s)
405 (?n gnus-tmp-news-method ?s)
406 (?P gnus-group-indentation ?s)
407 (?l gnus-tmp-grouplens ?s)
408 (?z gnus-tmp-news-method-string ?s)
409 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
410 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
411 (?u gnus-tmp-user-defined ?s)))
413 (defvar gnus-group-mode-line-format-alist
414 `((?S gnus-tmp-news-server ?s)
415 (?M gnus-tmp-news-method ?s)
416 (?u gnus-tmp-user-defined ?s)
417 (?: gnus-tmp-colon ?s)))
419 (defvar gnus-topic-topology nil
420 "The complete topic hierarchy.")
422 (defvar gnus-topic-alist nil
423 "The complete topic-group alist.")
425 (defvar gnus-group-marked nil)
427 (defvar gnus-group-list-mode nil)
433 (put 'gnus-group-mode 'mode-class 'special)
436 (gnus-define-keys gnus-group-mode-map
437 " " gnus-group-read-group
438 "=" gnus-group-select-group
439 "\r" gnus-group-select-group
440 "\M-\r" gnus-group-quick-select-group
441 [(meta control return)] gnus-group-select-group-ephemerally
442 "j" gnus-group-jump-to-group
443 "n" gnus-group-next-unread-group
444 "p" gnus-group-prev-unread-group
445 "\177" gnus-group-prev-unread-group
446 [delete] gnus-group-prev-unread-group
447 [backspace] gnus-group-prev-unread-group
448 "N" gnus-group-next-group
449 "P" gnus-group-prev-group
450 "\M-n" gnus-group-next-unread-group-same-level
451 "\M-p" gnus-group-prev-unread-group-same-level
452 "," gnus-group-best-unread-group
453 "." gnus-group-first-unread-group
454 "u" gnus-group-unsubscribe-current-group
455 "U" gnus-group-unsubscribe-group
456 "c" gnus-group-catchup-current
457 "C" gnus-group-catchup-current-all
458 "\M-c" gnus-group-clear-data
459 "l" gnus-group-list-groups
460 "L" gnus-group-list-all-groups
462 "g" gnus-group-get-new-news
463 "\M-g" gnus-group-get-new-news-this-group
464 "R" gnus-group-restart
465 "r" gnus-group-read-init-file
466 "B" gnus-group-browse-foreign-server
467 "b" gnus-group-check-bogus-groups
468 "F" gnus-group-find-new-groups
469 "\C-c\C-d" gnus-group-describe-group
470 "\M-d" gnus-group-describe-all-groups
471 "\C-c\C-a" gnus-group-apropos
472 "\C-c\M-\C-a" gnus-group-description-apropos
473 "a" gnus-group-post-news
474 "\ek" gnus-group-edit-local-kill
475 "\eK" gnus-group-edit-global-kill
476 "\C-k" gnus-group-kill-group
477 "\C-y" gnus-group-yank-group
478 "\C-w" gnus-group-kill-region
479 "\C-x\C-t" gnus-group-transpose-groups
480 "\C-c\C-l" gnus-group-list-killed
481 "\C-c\C-x" gnus-group-expire-articles
482 "\C-c\M-\C-x" gnus-group-expire-all-groups
484 "s" gnus-group-save-newsrc
485 "z" gnus-group-suspend
488 "?" gnus-group-describe-briefly
489 "\C-c\C-i" gnus-info-find-node
490 "\M-e" gnus-group-edit-group-method
491 "^" gnus-group-enter-server-mode
492 gnus-mouse-2 gnus-mouse-pick-group
493 "<" beginning-of-buffer
496 "\C-c\C-s" gnus-group-sort-groups
498 "\C-c\M-g" gnus-activate-all-groups
499 "\M-&" gnus-group-universal-argument
500 "#" gnus-group-mark-group
501 "\M-#" gnus-group-unmark-group)
503 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
504 "m" gnus-group-mark-group
505 "u" gnus-group-unmark-group
506 "w" gnus-group-mark-region
507 "b" gnus-group-mark-buffer
508 "r" gnus-group-mark-regexp
509 "U" gnus-group-unmark-all-groups)
511 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
512 "d" gnus-group-make-directory-group
513 "h" gnus-group-make-help-group
514 "u" gnus-group-make-useful-group
515 "a" gnus-group-make-archive-group
516 "k" gnus-group-make-kiboze-group
517 "l" gnus-group-nnimap-edit-acl
518 "m" gnus-group-make-group
519 "E" gnus-group-edit-group
520 "e" gnus-group-edit-group-method
521 "p" gnus-group-edit-group-parameters
522 "v" gnus-group-add-to-virtual
523 "V" gnus-group-make-empty-virtual
524 "D" gnus-group-enter-directory
525 "f" gnus-group-make-doc-group
526 "w" gnus-group-make-web-group
527 "r" gnus-group-rename-group
528 "c" gnus-group-customize
529 "x" gnus-group-nnimap-expunge
530 "\177" gnus-group-delete-group
531 [delete] gnus-group-delete-group)
533 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
534 "b" gnus-group-brew-soup
535 "w" gnus-soup-save-areas
536 "s" gnus-soup-send-replies
537 "p" gnus-soup-pack-packet
538 "r" nnsoup-pack-replies)
540 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
541 "s" gnus-group-sort-groups
542 "a" gnus-group-sort-groups-by-alphabet
543 "u" gnus-group-sort-groups-by-unread
544 "l" gnus-group-sort-groups-by-level
545 "v" gnus-group-sort-groups-by-score
546 "r" gnus-group-sort-groups-by-rank
547 "m" gnus-group-sort-groups-by-method)
549 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
550 "s" gnus-group-sort-selected-groups
551 "a" gnus-group-sort-selected-groups-by-alphabet
552 "u" gnus-group-sort-selected-groups-by-unread
553 "l" gnus-group-sort-selected-groups-by-level
554 "v" gnus-group-sort-selected-groups-by-score
555 "r" gnus-group-sort-selected-groups-by-rank
556 "m" gnus-group-sort-selected-groups-by-method)
558 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
559 "k" gnus-group-list-killed
560 "z" gnus-group-list-zombies
561 "s" gnus-group-list-groups
562 "u" gnus-group-list-all-groups
563 "A" gnus-group-list-active
564 "a" gnus-group-apropos
565 "d" gnus-group-description-apropos
566 "m" gnus-group-list-matching
567 "M" gnus-group-list-all-matching
568 "l" gnus-group-list-level
569 "c" gnus-group-list-cached)
571 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
572 "f" gnus-score-flush-cache)
574 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
575 "d" gnus-group-describe-group
576 "f" gnus-group-fetch-faq
579 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
580 "l" gnus-group-set-current-level
581 "t" gnus-group-unsubscribe-current-group
582 "s" gnus-group-unsubscribe-group
583 "k" gnus-group-kill-group
584 "y" gnus-group-yank-group
585 "w" gnus-group-kill-region
586 "\C-k" gnus-group-kill-level
587 "z" gnus-group-kill-all-zombies))
589 (defun gnus-group-make-menu-bar ()
590 (gnus-turn-off-edit-menu 'group)
591 (unless (boundp 'gnus-group-reading-menu)
594 gnus-group-reading-menu gnus-group-mode-map ""
596 ["Read" gnus-group-read-group (gnus-group-group-name)]
597 ["Select" gnus-group-select-group (gnus-group-group-name)]
598 ["See old articles" (gnus-group-select-group 'all)
599 :keys "C-u SPC" :active (gnus-group-group-name)]
600 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
601 ["Catch up all articles" gnus-group-catchup-current-all
602 (gnus-group-group-name)]
603 ["Check for new articles" gnus-group-get-new-news-this-group
604 (gnus-group-group-name)]
605 ["Toggle subscription" gnus-group-unsubscribe-current-group
606 (gnus-group-group-name)]
607 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
608 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
609 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
610 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
611 ;; Actually one should check, if any of the marked groups gives t for
612 ;; (gnus-check-backend-function 'request-expire-articles ...)
613 ["Expire articles" gnus-group-expire-articles
614 (or (and (gnus-group-group-name)
615 (gnus-check-backend-function
616 'request-expire-articles
617 (gnus-group-group-name))) gnus-group-marked)]
618 ["Set group level" gnus-group-set-current-level
619 (gnus-group-group-name)]
620 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
621 ["Customize" gnus-group-customize (gnus-group-group-name)]
623 ["Parameters" gnus-group-edit-group-parameters
624 (gnus-group-group-name)]
625 ["Select method" gnus-group-edit-group-method
626 (gnus-group-group-name)]
627 ["Info" gnus-group-edit-group (gnus-group-group-name)]
628 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
629 ["Global kill file" gnus-group-edit-global-kill t])))
632 gnus-group-group-menu gnus-group-mode-map ""
635 ["List unread subscribed groups" gnus-group-list-groups t]
636 ["List (un)subscribed groups" gnus-group-list-all-groups t]
637 ["List killed groups" gnus-group-list-killed gnus-killed-list]
638 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
639 ["List level..." gnus-group-list-level t]
640 ["Describe all groups" gnus-group-describe-all-groups t]
641 ["Group apropos..." gnus-group-apropos t]
642 ["Group and description apropos..." gnus-group-description-apropos t]
643 ["List groups matching..." gnus-group-list-matching t]
644 ["List all groups matching..." gnus-group-list-all-matching t]
645 ["List active file" gnus-group-list-active t]
646 ["List groups with cached" gnus-group-list-cached t])
648 ["Default sort" gnus-group-sort-groups t]
649 ["Sort by method" gnus-group-sort-groups-by-method t]
650 ["Sort by rank" gnus-group-sort-groups-by-rank t]
651 ["Sort by score" gnus-group-sort-groups-by-score t]
652 ["Sort by level" gnus-group-sort-groups-by-level t]
653 ["Sort by unread" gnus-group-sort-groups-by-unread t]
654 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
655 ("Sort process/prefixed"
656 ["Default sort" gnus-group-sort-selected-groups
657 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
658 ["Sort by method" gnus-group-sort-selected-groups-by-method
659 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
660 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
661 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
662 ["Sort by score" gnus-group-sort-selected-groups-by-score
663 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
664 ["Sort by level" gnus-group-sort-selected-groups-by-level
665 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
666 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
667 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
668 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
669 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
671 ["Mark group" gnus-group-mark-group
672 (and (gnus-group-group-name)
673 (not (memq (gnus-group-group-name) gnus-group-marked)))]
674 ["Unmark group" gnus-group-unmark-group
675 (and (gnus-group-group-name)
676 (memq (gnus-group-group-name) gnus-group-marked))]
677 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
678 ["Mark regexp..." gnus-group-mark-regexp t]
679 ["Mark region" gnus-group-mark-region t]
680 ["Mark buffer" gnus-group-mark-buffer t]
681 ["Execute command" gnus-group-universal-argument
682 (or gnus-group-marked (gnus-group-group-name))])
684 ["Subscribe to a group" gnus-group-unsubscribe-group t]
685 ["Kill all newsgroups in region" gnus-group-kill-region t]
686 ["Kill all zombie groups" gnus-group-kill-all-zombies
688 ["Kill all groups on level..." gnus-group-kill-level t])
690 ["Make a foreign group" gnus-group-make-group t]
691 ["Add a directory group" gnus-group-make-directory-group t]
692 ["Add the help group" gnus-group-make-help-group t]
693 ["Add the archive group" gnus-group-make-archive-group t]
694 ["Make a doc group" gnus-group-make-doc-group t]
695 ["Make a web group" gnus-group-make-web-group t]
696 ["Make a kiboze group" gnus-group-make-kiboze-group t]
697 ["Make a virtual group" gnus-group-make-empty-virtual t]
698 ["Add a group to a virtual" gnus-group-add-to-virtual t]
699 ["Rename group" gnus-group-rename-group
700 (gnus-check-backend-function
701 'request-rename-group (gnus-group-group-name))]
702 ["Delete group" gnus-group-delete-group
703 (gnus-check-backend-function
704 'request-delete-group (gnus-group-group-name))])
706 ["Next" gnus-group-next-group t]
707 ["Previous" gnus-group-prev-group t]
708 ["Next unread" gnus-group-next-unread-group t]
709 ["Previous unread" gnus-group-prev-unread-group t]
710 ["Next unread same level" gnus-group-next-unread-group-same-level t]
711 ["Previous unread same level"
712 gnus-group-prev-unread-group-same-level t]
713 ["Jump to group" gnus-group-jump-to-group t]
714 ["First unread group" gnus-group-first-unread-group t]
715 ["Best unread group" gnus-group-best-unread-group t])
716 ["Delete bogus groups" gnus-group-check-bogus-groups t]
717 ["Find new newsgroups" gnus-group-find-new-groups t]
718 ["Transpose" gnus-group-transpose-groups
719 (gnus-group-group-name)]
720 ["Read a directory as a group..." gnus-group-enter-directory t]))
723 gnus-group-misc-menu gnus-group-mode-map ""
726 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
727 ["Send replies" gnus-soup-send-replies
728 (fboundp 'gnus-soup-pack-packet)]
729 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
730 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
731 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
732 ["Send a mail" gnus-group-mail t]
733 ["Post an article..." gnus-group-post-news t]
734 ["Check for new news" gnus-group-get-new-news t]
735 ["Activate all groups" gnus-activate-all-groups t]
736 ["Restart Gnus" gnus-group-restart t]
737 ["Read init file" gnus-group-read-init-file t]
738 ["Browse foreign server" gnus-group-browse-foreign-server t]
739 ["Enter server buffer" gnus-group-enter-server-mode t]
740 ["Expire all expirable articles" gnus-group-expire-all-groups t]
741 ["Generate any kiboze groups" nnkiboze-generate-groups t]
742 ["Gnus version" gnus-version t]
743 ["Save .newsrc files" gnus-group-save-newsrc t]
744 ["Suspend Gnus" gnus-group-suspend t]
745 ["Clear dribble buffer" gnus-group-clear-dribble t]
746 ["Read manual" gnus-info-find-node t]
747 ["Flush score cache" gnus-score-flush-cache t]
748 ["Toggle topics" gnus-topic-mode t]
749 ["Send a bug report" gnus-bug t]
750 ["Exit from Gnus" gnus-group-exit t]
751 ["Exit without saving" gnus-group-quit t]))
753 (gnus-run-hooks 'gnus-group-menu-hook)))
755 (defun gnus-group-mode ()
756 "Major mode for reading news.
758 All normal editing commands are switched off.
759 \\<gnus-group-mode-map>
760 The group buffer lists (some of) the groups available. For instance,
761 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
762 lists all zombie groups.
764 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
765 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
767 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
769 The following commands are available:
771 \\{gnus-group-mode-map}"
773 (when (gnus-visual-p 'group-menu 'menu)
774 (gnus-group-make-menu-bar))
775 (kill-all-local-variables)
776 (gnus-simplify-mode-line)
777 (setq major-mode 'gnus-group-mode)
778 (setq mode-name "Group")
779 (gnus-group-set-mode-line)
780 (setq mode-line-process nil)
781 (use-local-map gnus-group-mode-map)
782 (buffer-disable-undo)
783 (setq truncate-lines t)
784 (setq buffer-read-only t)
785 (gnus-set-default-directory)
786 (gnus-update-format-specifications nil 'group 'group-mode)
787 (gnus-update-group-mark-positions)
792 (gnus-run-hooks 'gnus-group-mode-hook))
794 (defun gnus-update-group-mark-positions ()
796 (let ((gnus-process-mark ?\200)
797 (gnus-group-marked '("dummy.group"))
798 (gnus-active-hashtb (make-vector 10 0))
800 (gnus-set-active "dummy.group" '(0 . 0))
801 (gnus-set-work-buffer)
802 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
803 (goto-char (point-min))
804 (setq gnus-group-mark-positions
805 (list (cons 'process (and (search-forward "\200" nil t)
808 (defun gnus-mouse-pick-group (e)
809 "Enter the group under the mouse pointer."
812 (gnus-group-read-group nil))
814 ;; Look at LEVEL and find out what the level is really supposed to be.
815 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
816 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
817 (defun gnus-group-default-level (&optional level number-or-nil)
819 (gnus-group-use-permanent-levels
820 (or (setq gnus-group-use-permanent-levels
821 (or level (if (numberp gnus-group-use-permanent-levels)
822 gnus-group-use-permanent-levels
823 (or gnus-group-default-list-level
824 gnus-level-subscribed))))
825 gnus-group-default-list-level gnus-level-subscribed))
829 (or level gnus-group-default-list-level gnus-level-subscribed))))
831 (defun gnus-group-setup-buffer ()
832 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
833 (unless (eq major-mode 'gnus-group-mode)
836 (gnus-carpal-setup-buffer 'group))))
838 (defun gnus-group-list-groups (&optional level unread lowest)
839 "List newsgroups with level LEVEL or lower that have unread articles.
840 Default is all subscribed groups.
841 If argument UNREAD is non-nil, groups with no unread articles are also
844 Also see the `gnus-group-use-permanent-levels' variable."
846 (list (if current-prefix-arg
847 (prefix-numeric-value current-prefix-arg)
849 (gnus-group-default-level nil t)
850 gnus-group-default-list-level
851 gnus-level-subscribed))))
853 (setq level (car gnus-group-list-mode)
854 unread (cdr gnus-group-list-mode)))
855 (setq level (gnus-group-default-level level))
856 (gnus-group-setup-buffer)
857 (gnus-update-format-specifications nil 'group 'group-mode)
858 (let ((case-fold-search nil)
859 (props (text-properties-at (gnus-point-at-bol)))
860 (empty (= (point-min) (point-max)))
861 (group (gnus-group-group-name))
863 (set-buffer gnus-group-buffer)
864 (setq number (funcall gnus-group-prepare-function level unread lowest))
865 (when (or (and (numberp number)
867 (zerop (buffer-size)))
868 ;; No groups in the buffer.
869 (gnus-message 5 gnus-no-groups-message))
870 ;; We have some groups displayed.
871 (goto-char (point-max))
872 (when (or (not gnus-group-goto-next-group-function)
873 (not (funcall gnus-group-goto-next-group-function
877 (goto-char (point-min)))
879 ;; Go to the first group with unread articles.
880 (gnus-group-search-forward t))
882 ;; Find the right group to put point on. If the current group
883 ;; has disappeared in the new listing, try to find the next
884 ;; one. If no next one can be found, just leave point at the
885 ;; first newsgroup in the buffer.
886 (when (not (gnus-goto-char
888 (point-min) (point-max)
889 'gnus-group (gnus-intern-safe
890 group gnus-active-hashtb))))
891 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
895 (point-min) (point-max) 'gnus-group
897 (caar newsrc) gnus-active-hashtb)))))
898 (setq newsrc (cdr newsrc)))
900 (goto-char (point-max))
901 (forward-line -1)))))))
902 ;; Adjust cursor point.
903 (gnus-group-position-point)))
905 (defun gnus-group-list-level (level &optional all)
906 "List groups on LEVEL.
907 If ALL (the prefix), also list groups that have no unread articles."
908 (interactive "nList groups on level: \nP")
909 (gnus-group-list-groups level all level))
911 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
912 "List all newsgroups with unread articles of level LEVEL or lower.
913 If ALL is non-nil, list groups that have no unread articles.
914 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
915 If REGEXP, only list groups matching REGEXP."
916 (set-buffer gnus-group-buffer)
917 (let ((buffer-read-only nil)
918 (newsrc (cdr gnus-newsrc-alist))
919 (lowest (or lowest 1))
920 info clevel unread group params)
922 (when (< lowest gnus-level-zombie)
923 ;; List living groups.
925 (setq info (car newsrc)
926 group (gnus-info-group info)
927 params (gnus-info-params info)
929 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
930 (and unread ; This group might be unchecked
932 (string-match regexp group))
933 (<= (setq clevel (gnus-info-level info)) level)
935 (or all ; We list all groups?
936 (if (eq unread t) ; Unactivated?
937 gnus-group-list-inactive-groups ; We list unactivated
938 (> unread 0)) ; We list groups with unread articles
939 (and gnus-list-groups-with-ticked-articles
940 (cdr (assq 'tick (gnus-info-marks info))))
941 ; And groups with tickeds
942 ;; Check for permanent visibility.
943 (and gnus-permanently-visible-groups
944 (string-match gnus-permanently-visible-groups
946 (memq 'visible params)
947 (cdr (assq 'visible params)))
948 (gnus-group-insert-group-line
949 group (gnus-info-level info)
950 (gnus-info-marks info) unread (gnus-info-method info)))))
953 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
954 (gnus-group-prepare-flat-list-dead
955 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
958 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
959 (gnus-group-prepare-flat-list-dead
960 (setq gnus-killed-list (sort gnus-killed-list 'string<))
961 gnus-level-killed ?K regexp))
963 (gnus-group-set-mode-line)
964 (setq gnus-group-list-mode (cons level all))
965 (gnus-run-hooks 'gnus-group-prepare-hook)
968 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
969 ;; List zombies and killed lists somewhat faster, which was
970 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
971 ;; this by ignoring the group format specification altogether.
974 ;; This loop is used when listing groups that match some
977 (setq group (pop groups))
978 (when (string-match regexp group)
979 (gnus-add-text-properties
980 (point) (prog1 (1+ (point))
981 (insert " " mark " *: " group "\n"))
982 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
984 'gnus-level level))))
985 ;; This loop is used when listing all groups.
987 (gnus-add-text-properties
988 (point) (prog1 (1+ (point))
989 (insert " " mark " *: "
990 (setq group (pop groups)) "\n"))
991 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
993 'gnus-level level))))))
995 (defun gnus-group-update-group-line ()
996 "Update the current line in the group buffer."
997 (let* ((buffer-read-only nil)
998 (group (gnus-group-group-name))
999 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1000 gnus-group-indentation)
1003 (not (gnus-ephemeral-group-p group))
1005 (concat "(gnus-group-set-info '"
1006 (gnus-prin1-to-string (nth 2 entry))
1008 (setq gnus-group-indentation (gnus-group-group-indentation))
1010 (gnus-group-insert-group-line-info group)
1012 (gnus-group-position-point))))
1014 (defun gnus-group-insert-group-line-info (group)
1015 "Insert GROUP on the current line."
1016 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1017 (gnus-group-indentation (gnus-group-group-indentation))
1021 ;; (Un)subscribed group.
1022 (setq info (nth 2 entry))
1023 (gnus-group-insert-group-line
1024 group (gnus-info-level info) (gnus-info-marks info)
1025 (or (car entry) t) (gnus-info-method info)))
1026 ;; This group is dead.
1027 (gnus-group-insert-group-line
1029 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1031 (if (setq active (gnus-active group))
1032 (if (zerop (cdr active))
1034 (- (1+ (cdr active)) (car active)))
1038 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1039 gnus-tmp-marked number
1041 "Insert a group line in the group buffer."
1042 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1043 (gnus-tmp-number-total
1045 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1047 (gnus-tmp-number-of-unread
1048 (if (numberp number) (int-to-string (max 0 number))
1050 (gnus-tmp-number-of-read
1051 (if (numberp number)
1052 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1054 (gnus-tmp-subscribed
1055 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1056 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1057 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1059 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1060 (gnus-tmp-newsgroup-description
1061 (if gnus-description-hashtb
1062 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1065 (if (and gnus-moderated-hashtb
1066 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1068 (gnus-tmp-moderated-string
1069 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1071 (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) ;
1072 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1073 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1074 (gnus-tmp-news-method-string
1076 (format "(%s:%s)" (car gnus-tmp-method)
1077 (cadr gnus-tmp-method)) ""))
1078 (gnus-tmp-marked-mark
1079 (if (and (numberp number)
1081 (cdr (assq 'tick gnus-tmp-marked)))
1083 (gnus-tmp-process-marked
1084 (if (member gnus-tmp-group gnus-group-marked)
1085 gnus-process-mark ? ))
1087 (or (and gnus-use-grouplens
1088 (bbb-grouplens-group-p gnus-tmp-group))
1090 (buffer-read-only nil)
1091 header gnus-tmp-header) ; passed as parameter to user-funcs.
1093 (gnus-add-text-properties
1097 (eval gnus-group-line-format-spec))
1098 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1099 gnus-unread ,(if (numberp number)
1100 (string-to-int gnus-tmp-number-of-unread)
1102 gnus-marked ,gnus-tmp-marked-mark
1103 gnus-indentation ,gnus-group-indentation
1104 gnus-level ,gnus-tmp-level))
1105 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1107 (gnus-run-hooks 'gnus-group-update-hook)
1109 ;; Allow XEmacs to remove front-sticky text properties.
1110 (gnus-group-remove-excess-properties)))
1112 (defun gnus-group-highlight-line ()
1113 "Highlight the current line according to `gnus-group-highlight'."
1114 (let* ((list gnus-group-highlight)
1116 (end (progn (end-of-line) (point)))
1117 ;; now find out where the line starts and leave point there.
1118 (beg (progn (beginning-of-line) (point)))
1119 (group (gnus-group-group-name))
1120 (entry (gnus-group-entry group))
1121 (unread (if (numberp (car entry)) (car entry) 0))
1122 (active (gnus-active group))
1123 (total (if active (1+ (- (cdr active) (car active))) 0))
1124 (info (nth 2 entry))
1125 (method (gnus-server-get-method group (gnus-info-method info)))
1126 (marked (gnus-info-marks info))
1127 (mailp (memq 'mail (assoc (symbol-name
1128 (car (or method gnus-select-method)))
1129 gnus-valid-select-methods)))
1130 (level (or (gnus-info-level info) gnus-level-killed))
1131 (score (or (gnus-info-score info) 0))
1132 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1133 (group-age (gnus-group-timestamp-delta group))
1134 (inhibit-read-only t))
1135 ;; Eval the cars of the lists until we find a match.
1137 (not (eval (caar list))))
1138 (setq list (cdr list)))
1139 (let ((face (cdar list)))
1140 (unless (eq face (get-text-property beg 'face))
1141 (gnus-put-text-property-excluding-characters-with-faces
1143 (setq face (if (boundp face) (symbol-value face) face)))
1144 (gnus-extent-start-open beg)))
1147 (defun gnus-group-update-group (group &optional visible-only)
1148 "Update all lines where GROUP appear.
1149 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1151 ;; Can't use `save-excursion' here, so we do it manually.
1152 (let ((buf (current-buffer))
1154 (set-buffer gnus-group-buffer)
1155 (setq mark (point-marker))
1156 ;; The buffer may be narrowed.
1159 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1161 found buffer-read-only)
1162 ;; Enter the current status into the dribble buffer.
1163 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1165 (not (gnus-ephemeral-group-p group)))
1167 (concat "(gnus-group-set-info '"
1168 (gnus-prin1-to-string (nth 2 entry))
1170 ;; Find all group instances. If topics are in use, each group
1171 ;; may be listed in more than once.
1172 (while (setq loc (text-property-any
1173 loc (point-max) 'gnus-group ident))
1176 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1178 (gnus-group-insert-group-line-info group)
1181 (gnus-run-hooks 'gnus-group-update-group-hook)))
1182 (setq loc (1+ loc)))
1183 (unless (or found visible-only)
1184 ;; No such line in the buffer, find out where it's supposed to
1185 ;; go, and insert it there (or at the end of the buffer).
1186 (if gnus-goto-missing-group-function
1187 (funcall gnus-goto-missing-group-function group)
1188 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1189 (while (and entry (car entry)
1193 (point-min) (point-max)
1194 'gnus-group (gnus-intern-safe
1195 (caar entry) gnus-active-hashtb)))))
1196 (setq entry (cdr entry)))
1197 (or entry (goto-char (point-max)))))
1198 ;; Finally insert the line.
1199 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1200 (gnus-group-insert-group-line-info group)
1203 (gnus-run-hooks 'gnus-group-update-group-hook))))
1204 (when gnus-group-update-group-function
1205 (funcall gnus-group-update-group-function group))
1206 (gnus-group-set-mode-line)))
1208 (set-marker mark nil)
1211 (defun gnus-group-set-mode-line ()
1212 "Update the mode line in the group buffer."
1213 (when (memq 'group gnus-updated-mode-lines)
1214 ;; Yes, we want to keep this mode line updated.
1216 (set-buffer gnus-group-buffer)
1217 (let* ((gformat (or gnus-group-mode-line-format-spec
1218 (gnus-set-format 'group-mode)))
1219 (gnus-tmp-news-server (cadr gnus-select-method))
1220 (gnus-tmp-news-method (car gnus-select-method))
1221 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1223 gnus-tmp-header ;Dummy binding for user-defined formats
1224 ;; Get the resulting string.
1226 (and gnus-dribble-buffer
1227 (buffer-name gnus-dribble-buffer)
1228 (buffer-modified-p gnus-dribble-buffer)
1230 (set-buffer gnus-dribble-buffer)
1231 (not (zerop (buffer-size))))))
1232 (mode-string (eval gformat)))
1233 ;; Say whether the dribble buffer has been modified.
1234 (setq mode-line-modified
1235 (if modified (car gnus-mode-line-modified)
1236 (cdr gnus-mode-line-modified)))
1237 ;; If the line is too long, we chop it off.
1238 (when (> (length mode-string) max-len)
1239 (setq mode-string (substring mode-string 0 (- max-len 4))))
1241 (setq mode-line-buffer-identification
1242 (gnus-mode-line-buffer-identification
1243 (list mode-string)))
1244 (set-buffer-modified-p modified))))))
1246 (defun gnus-group-group-name ()
1247 "Get the name of the newsgroup on the current line."
1248 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1250 (symbol-name group))))
1252 (defun gnus-group-group-level ()
1253 "Get the level of the newsgroup on the current line."
1254 (get-text-property (gnus-point-at-bol) 'gnus-level))
1256 (defun gnus-group-group-indentation ()
1257 "Get the indentation of the newsgroup on the current line."
1258 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1259 (and gnus-group-indentation-function
1260 (funcall gnus-group-indentation-function))
1263 (defun gnus-group-group-unread ()
1264 "Get the number of unread articles of the newsgroup on the current line."
1265 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1267 (defun gnus-group-new-mail (group)
1268 (if (nnmail-new-mail-p (gnus-group-real-name group))
1272 (defun gnus-group-level (group)
1273 "Return the estimated level of GROUP."
1274 (or (gnus-info-level (gnus-get-info group))
1275 (and (member group gnus-zombie-list) gnus-level-zombie)
1278 (defun gnus-group-search-forward (&optional backward all level first-too)
1279 "Find the next newsgroup with unread articles.
1280 If BACKWARD is non-nil, find the previous newsgroup instead.
1281 If ALL is non-nil, just find any newsgroup.
1282 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1284 If FIRST-TOO, the current line is also eligible as a target."
1285 (let ((way (if backward -1 1))
1286 (low gnus-level-killed)
1289 (if (and backward (progn (beginning-of-line)) (bobp))
1298 (get-text-property (point) 'gnus-group)
1302 (get-text-property (point) 'gnus-unread)))
1303 (and (numberp unread) (> unread 0)))
1304 (setq lev (get-text-property (point)
1306 (<= lev gnus-level-subscribed)))
1308 (and (setq lev (get-text-property (point)
1317 (zerop (forward-line way)))))
1319 (progn (gnus-group-position-point) t)
1320 (goto-char (or pos beg))
1323 ;;; Gnus group mode commands
1327 (defun gnus-group-mark-group (n &optional unmark no-advance)
1328 "Mark the current group."
1330 (let ((buffer-read-only nil)
1334 (when (setq group (gnus-group-group-name))
1335 ;; Go to the mark position.
1337 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1338 (subst-char-in-region
1339 (point) (1+ (point)) (char-after)
1342 (setq gnus-group-marked (delete group gnus-group-marked))
1344 (setq gnus-group-marked
1345 (cons group (delete group gnus-group-marked)))
1346 gnus-process-mark)))
1348 (gnus-group-next-group 1))
1350 (gnus-summary-position-point)
1353 (defun gnus-group-unmark-group (n)
1354 "Remove the mark from the current group."
1356 (gnus-group-mark-group n 'unmark)
1357 (gnus-group-position-point))
1359 (defun gnus-group-unmark-all-groups ()
1360 "Unmark all groups."
1362 (let ((groups gnus-group-marked))
1365 (gnus-group-remove-mark (pop groups)))))
1366 (gnus-group-position-point))
1368 (defun gnus-group-mark-region (unmark beg end)
1369 "Mark all groups between point and mark.
1370 If UNMARK, remove the mark instead."
1371 (interactive "P\nr")
1372 (let ((num (count-lines beg end)))
1375 (- num (gnus-group-mark-group num unmark)))))
1377 (defun gnus-group-mark-buffer (&optional unmark)
1378 "Mark all groups in the buffer.
1379 If UNMARK, remove the mark instead."
1381 (gnus-group-mark-region unmark (point-min) (point-max)))
1383 (defun gnus-group-mark-regexp (regexp)
1384 "Mark all groups that match some regexp."
1385 (interactive "sMark (regexp): ")
1386 (let ((alist (cdr gnus-newsrc-alist))
1389 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1390 (gnus-group-set-mark group))))
1391 (gnus-group-position-point))
1393 (defun gnus-group-remove-mark (group)
1394 "Remove the process mark from GROUP and move point there.
1395 Return nil if the group isn't displayed."
1396 (if (gnus-group-goto-group group)
1398 (gnus-group-mark-group 1 'unmark t)
1400 (setq gnus-group-marked
1401 (delete group gnus-group-marked))
1404 (defun gnus-group-set-mark (group)
1405 "Set the process mark on GROUP."
1406 (if (gnus-group-goto-group group)
1408 (gnus-group-mark-group 1 nil t))
1409 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1411 (defun gnus-group-universal-argument (arg &optional groups func)
1412 "Perform any command on all groups according to the process/prefix convention."
1414 (if (eq (setq func (or func
1417 (substitute-command-keys
1418 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1420 (gnus-error 1 "Undefined key")
1421 (gnus-group-iterate arg
1423 (command-execute func))))
1424 (gnus-group-position-point))
1426 (defun gnus-group-process-prefix (n)
1427 "Return a list of groups to work on.
1428 Take into consideration N (the prefix) and the list of marked groups."
1431 (setq n (prefix-numeric-value n))
1432 ;; There is a prefix, so we return a list of the N next
1434 (let ((way (if (< n 0) -1 1))
1439 (if (setq group (gnus-group-group-name))
1440 (push group groups))
1442 (gnus-group-next-group way)))
1444 ((gnus-region-active-p)
1445 ;; Work on the region between point and mark.
1446 (let ((max (max (point) (mark)))
1449 (goto-char (min (point) (mark)))
1452 (push (gnus-group-group-name) groups)
1453 (zerop (gnus-group-next-group 1))
1455 (nreverse groups))))
1457 ;; No prefix, but a list of marked articles.
1458 (reverse gnus-group-marked))
1460 ;; Neither marked articles or a prefix, so we return the
1462 (let ((group (gnus-group-group-name)))
1463 (and group (list group))))))
1465 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1466 ;;; imagine why I went through these contortions...
1468 (let ((function (make-symbol "gnus-group-iterate-function"))
1469 (window (make-symbol "gnus-group-iterate-window"))
1470 (groups (make-symbol "gnus-group-iterate-groups"))
1471 (group (make-symbol "gnus-group-iterate-group")))
1473 `(defun gnus-group-iterate (arg ,function)
1474 "Iterate FUNCTION over all process/prefixed groups.
1475 FUNCTION will be called with the group name as the paremeter
1476 and with point over the group in question."
1477 (let ((,groups (gnus-group-process-prefix arg))
1478 (,window (selected-window))
1480 (while (setq ,group (pop ,groups))
1481 (select-window ,window)
1482 (gnus-group-remove-mark ,group)
1483 (save-selected-window
1485 (funcall ,function ,group)))))))))
1487 (put 'gnus-group-iterate 'lisp-indent-function 1)
1489 ;; Selecting groups.
1491 (defun gnus-group-read-group (&optional all no-article group select-articles)
1492 "Read news in this newsgroup.
1493 If the prefix argument ALL is non-nil, already read articles become
1494 readable. IF ALL is a number, fetch this number of articles. If the
1495 optional argument NO-ARTICLE is non-nil, no article will be
1496 auto-selected upon group entry. If GROUP is non-nil, fetch that
1499 (let ((no-display (eq all 0))
1500 (group (or group (gnus-group-group-name)))
1501 number active marked entry)
1505 (error "No group on current line"))
1506 (setq marked (gnus-info-marks
1507 (nth 2 (setq entry (gnus-gethash
1508 group gnus-newsrc-hashtb)))))
1509 ;; This group might be a dead group. In that case we have to get
1510 ;; the number of unread articles from `gnus-active-hashtb'.
1512 (cond ((numberp all) all)
1514 ((setq active (gnus-active group))
1515 (- (1+ (cdr active)) (car active)))))
1516 (gnus-summary-read-group
1517 group (or all (and (numberp number)
1518 (zerop (+ number (gnus-range-length
1519 (cdr (assq 'tick marked)))
1521 (cdr (assq 'dormant marked)))))))
1522 no-article nil no-display nil select-articles)))
1524 (defun gnus-group-select-group (&optional all)
1525 "Select this newsgroup.
1526 No article is selected automatically.
1527 If ALL is non-nil, already read articles become readable.
1528 If ALL is a number, fetch this number of articles."
1530 (gnus-group-read-group all t))
1532 (defun gnus-group-quick-select-group (&optional all)
1533 "Select the current group \"quickly\".
1534 This means that no highlighting or scoring will be performed.
1535 If ALL (the prefix argument) is 0, don't even generate the summary
1538 This might be useful if you want to toggle threading
1539 before entering the group."
1541 (require 'gnus-score)
1543 gnus-score-find-score-files-function
1544 gnus-home-score-file
1545 gnus-apply-kill-hook
1546 gnus-summary-expunge-below)
1547 (gnus-group-read-group all t)))
1549 (defun gnus-group-visible-select-group (&optional all)
1550 "Select the current group without hiding any articles."
1552 (let ((gnus-inhibit-limiting t))
1553 (gnus-group-read-group all t)))
1555 (defun gnus-group-select-group-ephemerally ()
1556 "Select the current group without doing any processing whatsoever.
1557 You will actually be entered into a group that's a copy of
1558 the current group; no changes you make while in this group will
1561 (require 'gnus-score)
1563 gnus-score-find-score-files-function gnus-apply-kill-hook
1564 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1565 gnus-summary-mode-hook gnus-select-group-hook
1566 (group (gnus-group-group-name))
1567 (method (gnus-find-method-for-group group)))
1568 (gnus-group-read-ephemeral-group
1569 (gnus-group-prefixed-name group method) method)))
1572 (defun gnus-fetch-group (group)
1573 "Start Gnus if necessary and enter GROUP.
1574 Returns whether the fetching was successful or not."
1575 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1576 (unless (get-buffer gnus-group-buffer)
1578 (gnus-group-read-group nil nil group))
1581 (defun gnus-fetch-group-other-frame (group)
1582 "Pop up a frame and enter GROUP."
1584 (let ((window (get-buffer-window gnus-group-buffer)))
1586 (select-frame (window-frame window)))
1587 ((= (length (frame-list)) 1)
1588 (select-frame (make-frame)))
1591 (gnus-fetch-group group))
1593 (defvar gnus-ephemeral-group-server 0)
1595 ;; Enter a group that is not in the group buffer. Non-nil is returned
1596 ;; if selection was successful.
1597 (defun gnus-group-read-ephemeral-group (group method &optional activate
1598 quit-config request-only
1600 "Read GROUP from METHOD as an ephemeral group.
1601 If ACTIVATE, request the group first.
1602 If QUIT-CONFIG, use that window configuration when exiting from the
1604 If REQUEST-ONLY, don't actually read the group; just request it.
1605 If SELECT-ARTICLES, only select those articles.
1607 Return the name of the group if selection was successful."
1608 ;; Transform the select method into a unique server.
1609 (when (stringp method)
1610 (setq method (gnus-server-to-method method)))
1612 `(,(car method) ,(concat (cadr method) "-ephemeral")
1613 (,(intern (format "%s-address" (car method))) ,(cadr method))
1615 (let ((group (if (gnus-group-foreign-p group) group
1616 (gnus-group-prefixed-name group method))))
1620 ,gnus-level-default-subscribed nil nil ,method
1622 ,(if quit-config quit-config
1623 (cons gnus-summary-buffer
1624 gnus-current-window-configuration))))))
1626 (push method gnus-ephemeral-servers)
1627 (set-buffer gnus-group-buffer)
1628 (unless (gnus-check-server method)
1629 (error "Unable to contact server: %s" (gnus-status-message method)))
1631 (gnus-activate-group group 'scan)
1632 (unless (gnus-request-group group)
1633 (error "Couldn't request group: %s"
1634 (nnheader-get-report (car method)))))
1638 (when (gnus-group-read-group t t group select-articles)
1643 (defun gnus-group-jump-to-group (group)
1644 "Jump to newsgroup GROUP."
1646 (list (completing-read
1647 "Group: " gnus-active-hashtb nil
1648 (gnus-read-active-file-p)
1650 'gnus-group-history)))
1652 (when (equal group "")
1653 (error "Empty group name"))
1655 (unless (gnus-ephemeral-group-p group)
1656 ;; Either go to the line in the group buffer...
1657 (unless (gnus-group-goto-group group)
1658 ;; ... or insert the line.
1659 (gnus-group-update-group group)
1660 (gnus-group-goto-group group)))
1661 ;; Adjust cursor point.
1662 (gnus-group-position-point))
1664 (defun gnus-group-goto-group (group &optional far)
1665 "Goto to newsgroup GROUP.
1666 If FAR, it is likely that the group is not on the current line."
1671 (point-min) (point-max)
1672 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1675 ;; It's quite likely that we are on the right line, so
1676 ;; we check the current line first.
1677 ((eq (get-text-property (point) 'gnus-group)
1678 (gnus-intern-safe group gnus-active-hashtb))
1680 ;; Previous and next line are also likely, so we check them as well.
1683 (eq (get-text-property (point) 'gnus-group)
1684 (gnus-intern-safe group gnus-active-hashtb)))
1689 (eq (get-text-property (point) 'gnus-group)
1690 (gnus-intern-safe group gnus-active-hashtb)))
1694 ;; Search through the entire buffer.
1697 (point-min) (point-max)
1698 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1700 (defun gnus-group-next-group (n &optional silent)
1701 "Go to next N'th newsgroup.
1702 If N is negative, search backward instead.
1703 Returns the difference between N and the number of skips actually
1706 (gnus-group-next-unread-group n t nil silent))
1708 (defun gnus-group-next-unread-group (n &optional all level silent)
1709 "Go to next N'th unread newsgroup.
1710 If N is negative, search backward instead.
1711 If ALL is non-nil, choose any newsgroup, unread or not.
1712 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1713 such group can be found, the next group with a level higher than
1715 Returns the difference between N and the number of skips actually
1718 (let ((backward (< n 0))
1721 (gnus-group-search-forward
1722 backward (or (not gnus-group-goto-unread) all) level))
1726 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1727 (if level " on this level or higher" "")))
1730 (defun gnus-group-prev-group (n)
1731 "Go to previous N'th newsgroup.
1732 Returns the difference between N and the number of skips actually
1735 (gnus-group-next-unread-group (- n) t))
1737 (defun gnus-group-prev-unread-group (n)
1738 "Go to previous N'th unread newsgroup.
1739 Returns the difference between N and the number of skips actually
1742 (gnus-group-next-unread-group (- n)))
1744 (defun gnus-group-next-unread-group-same-level (n)
1745 "Go to next N'th unread newsgroup on the same level.
1746 If N is negative, search backward instead.
1747 Returns the difference between N and the number of skips actually
1750 (gnus-group-next-unread-group n t (gnus-group-group-level))
1751 (gnus-group-position-point))
1753 (defun gnus-group-prev-unread-group-same-level (n)
1754 "Go to next N'th unread newsgroup on the same level.
1755 Returns the difference between N and the number of skips actually
1758 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1759 (gnus-group-position-point))
1761 (defun gnus-group-best-unread-group (&optional exclude-group)
1762 "Go to the group with the highest level.
1763 If EXCLUDE-GROUP, do not go to that group."
1765 (goto-char (point-min))
1769 (setq unread (get-text-property (point) 'gnus-unread))
1770 (when (and (numberp unread) (> unread 0))
1771 (when (and (get-text-property (point) 'gnus-level)
1772 (< (get-text-property (point) 'gnus-level) best)
1773 (or (not exclude-group)
1774 (not (equal exclude-group (gnus-group-group-name)))))
1775 (setq best (get-text-property (point) 'gnus-level))
1776 (setq best-point (point))))
1779 (goto-char best-point))
1780 (gnus-summary-position-point)
1781 (and best-point (gnus-group-group-name))))
1783 (defun gnus-group-first-unread-group ()
1784 "Go to the first group with unread articles."
1787 (let ((opoint (point))
1789 (goto-char (point-min))
1790 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1791 (and (numberp unread) ; Not a topic.
1792 (not (zerop unread))) ; Has unread articles.
1793 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1796 nil)) ; Not success.
1797 (gnus-group-position-point)))
1799 (defun gnus-group-enter-server-mode ()
1800 "Jump to the server buffer."
1802 (gnus-enter-server-buffer))
1804 (defun gnus-group-make-group (name &optional method address args)
1805 "Add a new newsgroup.
1806 The user will be prompted for a NAME, for a select METHOD, and an
1810 (gnus-read-group "Group name: ")
1811 (gnus-read-method "From method: ")))
1813 (when (stringp method)
1814 (setq method (or (gnus-server-to-method method) method)))
1815 (let* ((meth (gnus-method-simplify
1817 (not (gnus-server-equal method gnus-select-method)))
1818 (if address (list (intern method) address)
1820 (nname (if method (gnus-group-prefixed-name name meth) name))
1822 (when (gnus-gethash nname gnus-newsrc-hashtb)
1823 (error "Group %s already exists" nname))
1824 ;; Subscribe to the new group.
1825 (gnus-group-change-level
1826 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1827 gnus-level-default-subscribed gnus-level-killed
1828 (and (gnus-group-group-name)
1829 (gnus-gethash (gnus-group-group-name)
1830 gnus-newsrc-hashtb))
1833 (gnus-set-active nname (cons 1 0))
1834 (unless (gnus-ephemeral-group-p name)
1836 (concat "(gnus-group-set-info '"
1837 (gnus-prin1-to-string (cdr info)) ")")))
1839 (gnus-group-insert-group-line-info nname)
1841 (gnus-group-position-point)
1843 ;; Load the backend and try to make the backend create
1844 ;; the group as well.
1845 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1847 gnus-valid-select-methods)
1849 (gnus-check-server meth)
1850 (when (gnus-check-backend-function 'request-create-group nname)
1851 (gnus-request-create-group nname nil args))
1854 (defun gnus-group-delete-groups (&optional arg)
1855 "Delete the current group. Only meaningful with editable groups."
1857 (let ((n (length (gnus-group-process-prefix arg))))
1858 (when (gnus-yes-or-no-p
1860 "Delete this 1 group? "
1861 (format "Delete these %d groups? " n)))
1862 (gnus-group-iterate arg
1864 (gnus-group-delete-group group nil t))))))
1866 (defun gnus-group-delete-group (group &optional force no-prompt)
1867 "Delete the current group. Only meaningful with editable groups.
1868 If FORCE (the prefix) is non-nil, all the articles in the group will
1869 be deleted. This is \"deleted\" as in \"removed forever from the face
1870 of the Earth\". There is no undo. The user will be prompted before
1871 doing the deletion."
1873 (list (gnus-group-group-name)
1874 current-prefix-arg))
1876 (error "No group to rename"))
1877 (unless (gnus-check-backend-function 'request-delete-group group)
1878 (error "This backend does not support group deletion"))
1880 (if (and (not no-prompt)
1881 (not (gnus-yes-or-no-p
1883 "Do you really want to delete %s%s? "
1884 group (if force " and all its contents" "")))))
1886 (gnus-message 6 "Deleting group %s..." group)
1887 (if (not (gnus-request-delete-group group force))
1888 (gnus-error 3 "Couldn't delete group %s" group)
1889 (gnus-message 6 "Deleting group %s...done" group)
1890 (gnus-group-goto-group group)
1891 (gnus-group-kill-group 1 t)
1892 (gnus-sethash group nil gnus-active-hashtb)
1894 (gnus-group-position-point)))
1896 (defun gnus-group-rename-group (group new-name)
1897 "Rename group from GROUP to NEW-NAME.
1898 When used interactively, GROUP is the group under point
1899 and NEW-NAME will be prompted for."
1902 (gnus-group-group-name)
1904 (unless (gnus-check-backend-function
1905 'request-rename-group (gnus-group-group-name))
1906 (error "This backend does not support renaming groups"))
1907 (gnus-read-group "Rename group to: "
1908 (gnus-group-real-name (gnus-group-group-name))))))
1910 (unless (gnus-check-backend-function 'request-rename-group group)
1911 (error "This backend does not support renaming groups"))
1913 (error "No group to rename"))
1914 (when (equal (gnus-group-real-name group) new-name)
1915 (error "Can't rename to the same name"))
1917 ;; We find the proper prefixed name.
1919 (if (gnus-group-native-p group)
1923 (gnus-group-prefixed-name
1924 (gnus-group-real-name new-name)
1925 (gnus-info-method (gnus-get-info group)))))
1927 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1929 (if (not (gnus-request-rename-group group new-name))
1930 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1931 ;; We rename the group internally by killing it...
1932 (gnus-group-goto-group group)
1933 (gnus-group-kill-group)
1934 ;; ... changing its name ...
1935 (setcar (cdar gnus-list-of-killed-groups) new-name)
1936 ;; ... and then yanking it. Magic!
1937 (gnus-group-yank-group)
1938 (gnus-set-active new-name (gnus-active group))
1939 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1941 (setq gnus-killed-list (delete group gnus-killed-list))
1942 (gnus-set-active group nil)
1943 (gnus-dribble-touch)
1944 (gnus-group-position-point)))
1946 (defun gnus-group-edit-group (group &optional part)
1947 "Edit the group on the current line."
1948 (interactive (list (gnus-group-group-name)))
1949 (let ((part (or part 'info))
1952 (error "No group on current line"))
1953 (unless (setq info (gnus-get-info group))
1954 (error "Killed group; can't be edited"))
1956 (gnus-close-group group))
1958 ;; Find the proper form to edit.
1959 (cond ((eq part 'method)
1960 (or (gnus-info-method info) "native"))
1962 (gnus-info-params info))
1964 ;; The proper documentation.
1966 "Editing the %s for `%s'."
1968 ((eq part 'method) "select method")
1969 ((eq part 'params) "group parameters")
1973 (gnus-group-edit-group-done ',part ,group form)))))
1975 (defun gnus-group-edit-group-method (group)
1976 "Edit the select method of GROUP."
1977 (interactive (list (gnus-group-group-name)))
1978 (gnus-group-edit-group group 'method))
1980 (defun gnus-group-edit-group-parameters (group)
1981 "Edit the group parameters of GROUP."
1982 (interactive (list (gnus-group-group-name)))
1983 (gnus-group-edit-group group 'params))
1985 (defun gnus-group-edit-group-done (part group form)
1987 (let* ((method (cond ((eq part 'info) (nth 4 form))
1988 ((eq part 'method) form)
1990 (info (cond ((eq part 'info) form)
1991 ((eq part 'method) (gnus-get-info group))
1994 (if (or (not method)
1996 gnus-select-method method))
1997 (gnus-group-real-name (car info))
1998 (gnus-group-prefixed-name
1999 (gnus-group-real-name (car info)) method))
2001 (when (and new-group
2002 (not (equal new-group group)))
2003 (when (gnus-group-goto-group group)
2004 (gnus-group-kill-group 1))
2005 (gnus-activate-group new-group))
2007 (if (not (and info new-group))
2008 (gnus-group-set-info form (or new-group group) part)
2009 (setq info (gnus-copy-sequence info))
2010 (setcar info new-group)
2011 (unless (gnus-server-equal method "native")
2012 (unless (nthcdr 3 info)
2013 (nconc info (list nil nil)))
2014 (unless (nthcdr 4 info)
2015 (nconc info (list nil)))
2016 (gnus-info-set-method info method))
2017 (gnus-group-set-info info))
2018 (gnus-group-update-group (or new-group group))
2019 (gnus-group-position-point)))
2021 (defun gnus-group-make-useful-group (group method)
2022 "Create one of the groups described in `gnus-useful-groups'."
2024 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2026 gnus-useful-groups)))
2027 (list (cadr entry) (caddr entry))))
2028 (setq method (gnus-copy-sequence method))
2030 (while (setq entry (memq (assq 'eval method) method))
2031 (setcar entry (eval (cadar entry)))))
2032 (gnus-group-make-group group method))
2034 (defun gnus-group-make-help-group ()
2035 "Create the Gnus documentation group."
2037 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2038 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2039 (when (gnus-gethash name gnus-newsrc-hashtb)
2040 (error "Documentation group already exists"))
2042 (gnus-message 1 "Couldn't find doc group")
2043 (gnus-group-make-group
2044 (gnus-group-real-name name)
2045 (list 'nndoc "gnus-help"
2046 (list 'nndoc-address file)
2047 (list 'nndoc-article-type 'mbox)))))
2048 (gnus-group-position-point))
2050 (defun gnus-group-make-doc-group (file type)
2051 "Create a group that uses a single file as the source."
2053 (list (read-file-name "File name: ")
2054 (and current-prefix-arg 'ask)))
2055 (when (eq type 'ask)
2060 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2062 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2063 ((= char ?b) 'babyl)
2064 ((= char ?d) 'digest)
2065 ((= char ?f) 'forward)
2067 ((= char ?g) 'guess)
2068 (t (setq err (format "%c unknown. " char))
2071 (let* ((file (expand-file-name file))
2072 (name (gnus-generate-new-group-name
2073 (gnus-group-prefixed-name
2074 (file-name-nondirectory file) '(nndoc "")))))
2075 (gnus-group-make-group
2076 (gnus-group-real-name name)
2078 (list 'nndoc-address file)
2079 (list 'nndoc-article-type (or type 'guess))))))
2081 (defvar nnweb-type-definition)
2082 (defvar gnus-group-web-type-history nil)
2083 (defvar gnus-group-web-search-history nil)
2084 (defun gnus-group-make-web-group (&optional solid)
2085 "Create an ephemeral nnweb group.
2086 If SOLID (the prefix), create a solid group."
2090 (if solid (gnus-read-group "Group name: ")
2091 (message-unique-id)))
2092 (default-type (or (car gnus-group-web-type-history)
2093 (symbol-name (caar nnweb-type-definition))))
2097 (format "Search engine type (default %s): " default-type)
2098 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2099 nnweb-type-definition)
2100 nil t nil 'gnus-group-web-type-history)
2105 (cons (or (car gnus-group-web-search-history) "") 0)
2106 'gnus-group-web-search-history))
2108 `(nnweb ,group (nnweb-search ,search)
2109 (nnweb-type ,(intern type))
2110 (nnweb-ephemeral-p t))))
2112 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2113 (gnus-group-read-ephemeral-group
2115 (cons (current-buffer)
2116 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2118 (defvar nnwarchive-type-definition)
2119 (defvar gnus-group-warchive-type-history nil)
2120 (defvar gnus-group-warchive-login-history nil)
2121 (defvar gnus-group-warchive-address-history nil)
2123 (defun gnus-group-make-warchive-group ()
2124 "Create a nnwarchive group."
2126 (require 'nnwarchive)
2127 (let* ((group (gnus-read-group "Group name: "))
2128 (default-type (or (car gnus-group-warchive-type-history)
2129 (symbol-name (caar nnwarchive-type-definition))))
2133 (format "Warchive type (default %s): " default-type)
2134 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2135 nnwarchive-type-definition)
2136 nil t nil 'gnus-group-warchive-type-history)
2138 (address (read-string "Warchive address: "
2139 nil 'gnus-group-warchive-address-history))
2140 (default-login (or (car gnus-group-warchive-login-history)
2145 (format "Warchive login (default %s): " user-mail-address)
2146 default-login 'gnus-group-warchive-login-history)
2149 `(nnwarchive ,address
2150 (nnwarchive-type ,(intern type))
2151 (nnwarchive-login ,login))))
2152 (gnus-group-make-group group method)))
2154 (defun gnus-group-make-archive-group (&optional all)
2155 "Create the (ding) Gnus archive group of the most recent articles.
2156 Given a prefix, create a full group."
2158 (let ((group (gnus-group-prefixed-name
2159 (if all "ding.archives" "ding.recent") '(nndir ""))))
2160 (when (gnus-gethash group gnus-newsrc-hashtb)
2161 (error "Archive group already exists"))
2162 (gnus-group-make-group
2163 (gnus-group-real-name group)
2164 (list 'nndir (if all "hpc" "edu")
2165 (list 'nndir-directory
2166 (if all gnus-group-archive-directory
2167 gnus-group-recent-archive-directory))))
2168 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2170 (defun gnus-group-make-directory-group (dir)
2171 "Create an nndir group.
2172 The user will be prompted for a directory. The contents of this
2173 directory will be used as a newsgroup. The directory should contain
2174 mail messages or news articles in files that have numeric names."
2176 (list (read-file-name "Create group from directory: ")))
2177 (unless (file-exists-p dir)
2178 (error "No such directory"))
2179 (unless (file-directory-p dir)
2180 (error "Not a directory"))
2184 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2186 (gnus-group-prefixed-name
2187 (concat (file-name-as-directory (directory-file-name dir))
2190 (setq ext (format "<%d>" (setq i (1+ i)))))
2191 (gnus-group-make-group
2192 (gnus-group-real-name group)
2193 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2195 (defun gnus-group-make-kiboze-group (group address scores)
2196 "Create an nnkiboze group.
2197 The user will be prompted for a name, a regexp to match groups, and
2198 score file entries for articles to include in the group."
2201 (read-string "nnkiboze group name: ")
2202 (read-string "Source groups (regexp): ")
2203 (let ((headers (mapcar (lambda (group) (list group))
2204 '("subject" "from" "number" "date" "message-id"
2205 "references" "chars" "lines" "xref"
2206 "followup" "all" "body" "head")))
2207 scores header regexp regexps)
2208 (while (not (equal "" (setq header (completing-read
2209 "Match on header: " headers nil t))))
2211 (while (not (equal "" (setq regexp (read-string
2212 (format "Match on %s (string): "
2214 (push (list regexp nil nil 'r) regexps))
2215 (push (cons header regexps) scores))
2217 (gnus-group-make-group group "nnkiboze" address)
2218 (with-temp-file (gnus-score-file-name (concat "nnkiboze:" group))
2219 (let (emacs-lisp-mode-hook)
2220 (pp scores (current-buffer)))))
2222 (defun gnus-group-add-to-virtual (n vgroup)
2223 "Add the current group to a virtual group."
2225 (list current-prefix-arg
2226 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2228 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2229 (error "%s is not an nnvirtual group" vgroup))
2230 (gnus-close-group vgroup)
2231 (let* ((groups (gnus-group-process-prefix n))
2232 (method (gnus-info-method (gnus-get-info vgroup))))
2233 (setcar (cdr method)
2235 (nth 1 method) "\\|"
2238 (gnus-group-remove-mark s)
2239 (concat "\\(^" (regexp-quote s) "$\\)"))
2241 (gnus-group-position-point))
2243 (defun gnus-group-make-empty-virtual (group)
2244 "Create a new, fresh, empty virtual group."
2245 (interactive "sCreate new, empty virtual group: ")
2246 (let* ((method (list 'nnvirtual "^$"))
2247 (pgroup (gnus-group-prefixed-name group method)))
2248 ;; Check whether it exists already.
2249 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2250 (error "Group %s already exists" pgroup))
2251 ;; Subscribe the new group after the group on the current line.
2252 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2253 (gnus-group-update-group pgroup)
2255 (gnus-group-position-point)))
2257 (defun gnus-group-enter-directory (dir)
2258 "Enter an ephemeral nneething group."
2259 (interactive "DDirectory to read: ")
2260 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2261 (leaf (gnus-group-prefixed-name
2262 (file-name-nondirectory (directory-file-name dir))
2264 (name (gnus-generate-new-group-name leaf)))
2265 (unless (gnus-group-read-ephemeral-group
2267 (cons (current-buffer)
2268 (if (eq major-mode 'gnus-summary-mode)
2270 (error "Couldn't enter %s" dir))))
2273 (autoload 'nnimap-expunge "nnimap")
2274 (autoload 'nnimap-acl-get "nnimap")
2275 (autoload 'nnimap-acl-edit "nnimap"))
2277 (defun gnus-group-nnimap-expunge (group)
2278 "Expunge deleted articles in current nnimap GROUP."
2279 (interactive (list (gnus-group-group-name)))
2280 (let ((mailbox (gnus-group-real-name group)) method)
2282 (error "No group on current line"))
2283 (unless (gnus-get-info group)
2284 (error "Killed group; can't be edited"))
2285 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2286 (error "%s is not an nnimap group" group))
2287 (nnimap-expunge mailbox (cadr method))))
2289 (defun gnus-group-nnimap-edit-acl (group)
2290 "Edit the Access Control List of current nnimap GROUP."
2291 (interactive (list (gnus-group-group-name)))
2292 (let ((mailbox (gnus-group-real-name group)) method acl)
2294 (error "No group on current line"))
2295 (unless (gnus-get-info group)
2296 (error "Killed group; can't be edited"))
2297 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2298 (error "%s is not an nnimap group" group))
2299 (gnus-edit-form (setq acl (nnimap-acl-get mailbox (cadr method)))
2300 (format "Editing the access control list for `%s'.
2302 An access control list is a list of (identifier . rights) elements.
2304 The identifier string specifies the corresponding user. The
2305 identifier \"anyone\" is reserved to refer to the universal identity.
2307 Rights is a string listing a (possibly empty) set of alphanumeric
2308 characters, each character listing a set of operations which is being
2309 controlled. Letters are reserved for ``standard'' rights, listed
2310 below. Digits are reserved for implementation or site defined rights.
2312 l - lookup (mailbox is visible to LIST/LSUB commands)
2313 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2314 SEARCH, COPY from mailbox)
2315 s - keep seen/unseen information across sessions (STORE SEEN flag)
2316 w - write (STORE flags other than SEEN and DELETED)
2317 i - insert (perform APPEND, COPY into mailbox)
2318 p - post (send mail to submission address for mailbox,
2319 not enforced by IMAP4 itself)
2320 c - create (CREATE new sub-mailboxes in any implementation-defined
2322 d - delete (STORE DELETED flag, perform EXPUNGE)
2323 a - administer (perform SETACL)" group)
2326 ,mailbox ',method ',acl form)))))
2328 ;; Group sorting commands
2329 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2331 (defun gnus-group-sort-groups (func &optional reverse)
2332 "Sort the group buffer according to FUNC.
2333 When used interactively, the sorting function used will be
2334 determined by the `gnus-group-sort-function' variable.
2335 If REVERSE (the prefix), reverse the sorting order."
2336 (interactive (list gnus-group-sort-function current-prefix-arg))
2337 (funcall gnus-group-sort-alist-function
2338 (gnus-make-sort-function func) reverse)
2339 (gnus-group-list-groups)
2340 (gnus-dribble-touch))
2342 (defun gnus-group-sort-flat (func reverse)
2343 ;; We peel off the dummy group from the alist.
2345 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2346 (pop gnus-newsrc-alist))
2348 (setq gnus-newsrc-alist
2349 (sort gnus-newsrc-alist func))
2351 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2352 ;; Regenerate the hash table.
2353 (gnus-make-hashtable-from-newsrc-alist)))
2355 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2356 "Sort the group buffer alphabetically by group name.
2357 If REVERSE, sort in reverse order."
2359 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2361 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2362 "Sort the group buffer by number of unread articles.
2363 If REVERSE, sort in reverse order."
2365 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2367 (defun gnus-group-sort-groups-by-level (&optional reverse)
2368 "Sort the group buffer by group level.
2369 If REVERSE, sort in reverse order."
2371 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2373 (defun gnus-group-sort-groups-by-score (&optional reverse)
2374 "Sort the group buffer by group score.
2375 If REVERSE, sort in reverse order."
2377 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2379 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2380 "Sort the group buffer by group rank.
2381 If REVERSE, sort in reverse order."
2383 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2385 (defun gnus-group-sort-groups-by-method (&optional reverse)
2386 "Sort the group buffer alphabetically by backend name.
2387 If REVERSE, sort in reverse order."
2389 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2391 ;;; Selected group sorting.
2393 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2394 "Sort the process/prefixed groups."
2395 (interactive (list current-prefix-arg gnus-group-sort-function))
2396 (let ((groups (gnus-group-process-prefix n)))
2397 (funcall gnus-group-sort-selected-function
2398 groups (gnus-make-sort-function func) reverse)
2399 (gnus-group-list-groups)))
2401 (defun gnus-group-sort-selected-flat (groups func reverse)
2402 (let (entries infos)
2403 ;; First find all the group entries for these groups.
2405 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2407 ;; Then sort the infos.
2411 (lambda (entry) (car entry))
2412 (setq entries (nreverse entries)))
2415 (setq infos (nreverse infos)))
2416 ;; Go through all the infos and replace the old entries
2417 ;; with the new infos.
2419 (setcar (car entries) (pop infos))
2421 ;; Update the hashtable.
2422 (gnus-make-hashtable-from-newsrc-alist)))
2424 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2425 "Sort the group buffer alphabetically by group name.
2426 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2427 sort in reverse order."
2428 (interactive (gnus-interactive "P\ny"))
2429 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2431 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2432 "Sort the group buffer by number of unread articles.
2433 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2434 sort in reverse order."
2435 (interactive (gnus-interactive "P\ny"))
2436 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2438 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2439 "Sort the group buffer by group level.
2440 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2441 sort in reverse order."
2442 (interactive (gnus-interactive "P\ny"))
2443 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2445 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2446 "Sort the group buffer by group score.
2447 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2448 sort in reverse order."
2449 (interactive (gnus-interactive "P\ny"))
2450 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2452 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2453 "Sort the group buffer by group rank.
2454 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2455 sort in reverse order."
2456 (interactive (gnus-interactive "P\ny"))
2457 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2459 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2460 "Sort the group buffer alphabetically by backend name.
2461 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2462 sort in reverse order."
2463 (interactive (gnus-interactive "P\ny"))
2464 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2466 ;;; Sorting predicates.
2468 (defun gnus-group-sort-by-alphabet (info1 info2)
2469 "Sort alphabetically."
2470 (string< (gnus-info-group info1) (gnus-info-group info2)))
2472 (defun gnus-group-sort-by-real-name (info1 info2)
2473 "Sort alphabetically on real (unprefixed) names."
2474 (string< (gnus-group-real-name (gnus-info-group info1))
2475 (gnus-group-real-name (gnus-info-group info2))))
2477 (defun gnus-group-sort-by-unread (info1 info2)
2478 "Sort by number of unread articles."
2479 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2480 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2481 (< (or (and (numberp n1) n1) 0)
2482 (or (and (numberp n2) n2) 0))))
2484 (defun gnus-group-sort-by-level (info1 info2)
2486 (< (gnus-info-level info1) (gnus-info-level info2)))
2488 (defun gnus-group-sort-by-method (info1 info2)
2489 "Sort alphabetically by backend name."
2490 (string< (symbol-name (car (gnus-find-method-for-group
2491 (gnus-info-group info1) info1)))
2492 (symbol-name (car (gnus-find-method-for-group
2493 (gnus-info-group info2) info2)))))
2495 (defun gnus-group-sort-by-score (info1 info2)
2496 "Sort by group score."
2497 (< (gnus-info-score info1) (gnus-info-score info2)))
2499 (defun gnus-group-sort-by-rank (info1 info2)
2500 "Sort by level and score."
2501 (let ((level1 (gnus-info-level info1))
2502 (level2 (gnus-info-level info2)))
2503 (or (< level1 level2)
2504 (and (= level1 level2)
2505 (> (gnus-info-score info1) (gnus-info-score info2))))))
2509 (defun gnus-group-clear-data (&optional arg)
2510 "Clear all marks and read ranges from the current group."
2512 (gnus-group-iterate arg
2515 (gnus-info-clear-data (setq info (gnus-get-info group)))
2516 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2517 (when (gnus-group-goto-group group)
2518 (gnus-group-update-group-line))))))
2520 (defun gnus-group-clear-data-on-native-groups ()
2521 "Clear all marks and read ranges from all native groups."
2523 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2524 (let ((alist (cdr gnus-newsrc-alist))
2526 (while (setq info (pop alist))
2527 (when (gnus-group-native-p (gnus-info-group info))
2528 (gnus-info-clear-data info)))
2529 (gnus-get-unread-articles)
2530 (gnus-dribble-touch)
2531 (when (gnus-y-or-n-p
2532 "Move the cache away to avoid problems in the future? ")
2533 (call-interactively 'gnus-cache-move-cache)))))
2535 (defun gnus-info-clear-data (info)
2536 "Clear all marks and read ranges from INFO."
2537 (let ((group (gnus-info-group info)))
2540 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2541 (gnus-info-set-read ',info ',(gnus-info-read info))
2542 (when (gnus-group-goto-group ,group)
2543 (gnus-group-update-group-line))))
2544 (gnus-info-set-read info nil)
2545 (when (gnus-info-marks info)
2546 (gnus-info-set-marks info nil))))
2548 ;; Group catching up.
2550 (defun gnus-group-catchup-current (&optional n all)
2551 "Mark all articles not marked as unread in current newsgroup as read.
2552 If prefix argument N is numeric, the next N newsgroups will be
2553 caught up. If ALL is non-nil, marked articles will also be marked as
2554 read. Cross references (Xref: header) of articles are ignored.
2555 The number of newsgroups that this function was unable to catch
2558 (let ((groups (gnus-group-process-prefix n))
2561 (unless groups (error "No groups selected"))
2563 (or (not gnus-interactive-catchup) ;Without confirmation?
2568 "Do you really want to mark all articles in %s as read? "
2569 "Mark all unread articles in %s as read? ")
2570 (if (= (length groups) 1)
2572 (format "these %d groups" (length groups)))))))
2574 (while (setq group (pop groups))
2575 (gnus-group-remove-mark group)
2576 ;; Virtual groups have to be given special treatment.
2577 (let ((method (gnus-find-method-for-group group)))
2578 (when (eq 'nnvirtual (car method))
2579 (nnvirtual-catchup-group
2580 (gnus-group-real-name group) (nth 1 method) all)))
2581 (if (>= (gnus-group-level group) gnus-level-zombie)
2582 (gnus-message 2 "Dead groups can't be caught up")
2584 (gnus-group-goto-group group)
2585 (gnus-group-catchup group all))
2586 (gnus-group-update-group-line)
2587 (setq ret (1+ ret)))))
2588 (gnus-group-next-unread-group 1)
2591 (defun gnus-group-catchup-current-all (&optional n)
2592 "Mark all articles in current newsgroup as read.
2593 Cross references (Xref: header) of articles are ignored."
2595 (gnus-group-catchup-current n 'all))
2597 (defun gnus-group-catchup (group &optional all)
2598 "Mark all articles in GROUP as read.
2599 If ALL is non-nil, all articles are marked as read.
2600 The return value is the number of articles that were marked as read,
2601 or nil if no action could be taken."
2602 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2604 ;; Remove entries for this group.
2605 (nnmail-purge-split-history (gnus-group-real-name group))
2606 ;; Do the updating only if the newsgroup isn't killed.
2607 (if (not (numberp (car entry)))
2608 (gnus-message 1 "Can't catch up %s; non-active group" group)
2609 ;; Do auto-expirable marks if that's required.
2610 (when (gnus-group-auto-expirable-p group)
2611 (gnus-add-marked-articles
2612 group 'expire (gnus-list-of-unread-articles group))
2614 (let ((marks (nth 3 (nth 2 entry))))
2615 (gnus-add-marked-articles
2616 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2617 (gnus-add-marked-articles
2618 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2620 (gnus-update-read-articles group nil)
2621 ;; Also nix out the lists of marks and dormants.
2623 (gnus-add-marked-articles group 'tick nil nil 'force)
2624 (gnus-add-marked-articles group 'dormant nil nil 'force))
2625 (let ((gnus-newsgroup-name group))
2626 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2629 (defun gnus-group-expire-articles (&optional n)
2630 "Expire all expirable articles in the current newsgroup."
2632 (let ((groups (gnus-group-process-prefix n))
2635 (error "No groups to expire"))
2636 (while (setq group (pop groups))
2637 (gnus-group-remove-mark group)
2638 (gnus-group-expire-articles-1 group)
2639 (gnus-dribble-touch)
2640 (gnus-group-position-point))))
2642 (defun gnus-group-expire-articles-1 (group)
2643 (when (gnus-check-backend-function 'request-expire-articles group)
2644 (gnus-message 6 "Expiring articles in %s..." group)
2645 (let* ((info (gnus-get-info group))
2646 (expirable (if (gnus-group-total-expirable-p group)
2647 (cons nil (gnus-list-of-read-articles group))
2648 (assq 'expire (gnus-info-marks info))))
2649 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2650 (nnmail-expiry-target
2651 (or (gnus-group-find-parameter group 'expiry-target)
2652 nnmail-expiry-target)))
2656 (gnus-compress-sequence
2658 ;; We set the expiry variables to the group
2660 (let ((nnmail-expiry-wait-function nil)
2661 (nnmail-expiry-wait expiry-wait))
2662 (gnus-request-expire-articles
2663 (gnus-uncompress-sequence (cdr expirable)) group))
2664 ;; Just expire using the normal expiry values.
2665 (gnus-request-expire-articles
2666 (gnus-uncompress-sequence (cdr expirable)) group))))
2667 (gnus-close-group group))
2668 (gnus-message 6 "Expiring articles in %s...done" group))))
2670 (defun gnus-group-expire-all-groups ()
2671 "Expire all expirable articles in all newsgroups."
2674 (gnus-message 5 "Expiring...")
2675 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2676 (cdr gnus-newsrc-alist))))
2677 (gnus-group-expire-articles nil)))
2678 (gnus-group-position-point)
2679 (gnus-message 5 "Expiring...done"))
2681 (defun gnus-group-set-current-level (n level)
2682 "Set the level of the next N groups to LEVEL."
2687 (let ((s (read-string
2688 (format "Level (default %s): "
2689 (or (gnus-group-group-level)
2690 gnus-level-default-subscribed)))))
2691 (if (string-match "^\\s-*$" s)
2692 (int-to-string (or (gnus-group-group-level)
2693 gnus-level-default-subscribed))
2695 (unless (and (>= level 1) (<= level gnus-level-killed))
2696 (error "Invalid level: %d" level))
2697 (let ((groups (gnus-group-process-prefix n))
2699 (while (setq group (pop groups))
2700 (gnus-group-remove-mark group)
2701 (gnus-message 6 "Changed level of %s from %d to %d"
2702 group (or (gnus-group-group-level) gnus-level-killed)
2704 (gnus-group-change-level
2705 group level (or (gnus-group-group-level) gnus-level-killed))
2706 (gnus-group-update-group-line)))
2707 (gnus-group-position-point))
2709 (defun gnus-group-unsubscribe (&optional n)
2710 "Unsubscribe the current group."
2712 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2714 (defun gnus-group-subscribe (&optional n)
2715 "Subscribe the current group."
2717 (gnus-group-unsubscribe-current-group n 'subscribe))
2719 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2720 "Toggle subscription of the current group.
2721 If given numerical prefix, toggle the N next groups."
2723 (let ((groups (gnus-group-process-prefix n))
2726 (setq group (car groups)
2727 groups (cdr groups))
2728 (gnus-group-remove-mark group)
2729 (gnus-group-unsubscribe-group
2732 ((eq do-sub 'unsubscribe)
2733 gnus-level-default-unsubscribed)
2734 ((eq do-sub 'subscribe)
2735 gnus-level-default-subscribed)
2736 ((<= (gnus-group-group-level) gnus-level-subscribed)
2737 gnus-level-default-unsubscribed)
2739 gnus-level-default-subscribed))
2741 (gnus-group-update-group-line))
2742 (gnus-group-next-group 1)))
2744 (defun gnus-group-unsubscribe-group (group &optional level silent)
2745 "Toggle subscription to GROUP.
2746 Killed newsgroups are subscribed. If SILENT, don't try to update the
2749 (list (completing-read
2750 "Group: " gnus-active-hashtb nil
2751 (gnus-read-active-file-p)
2753 'gnus-group-history)))
2754 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2756 ((string-match "^[ \t]*$" group)
2757 (error "Empty group name"))
2759 ;; Toggle subscription flag.
2760 (gnus-group-change-level
2761 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2762 gnus-level-subscribed)
2763 (1+ gnus-level-subscribed)
2764 gnus-level-default-subscribed)))
2766 (gnus-group-update-group group)))
2767 ((and (stringp group)
2768 (or (not (gnus-read-active-file-p))
2769 (gnus-active group)))
2770 ;; Add new newsgroup.
2771 (gnus-group-change-level
2773 (if level level gnus-level-default-subscribed)
2774 (or (and (member group gnus-zombie-list)
2777 (when (gnus-group-group-name)
2778 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2780 (gnus-group-update-group group)))
2781 (t (error "No such newsgroup: %s" group)))
2782 (gnus-group-position-point)))
2784 (defun gnus-group-transpose-groups (n)
2785 "Move the current newsgroup up N places.
2786 If given a negative prefix, move down instead. The difference between
2787 N and the number of steps taken is returned."
2789 (unless (gnus-group-group-name)
2790 (error "No group on current line"))
2791 (gnus-group-kill-group 1)
2793 (forward-line (- n))
2794 (gnus-group-yank-group)
2795 (gnus-group-position-point)))
2797 (defun gnus-group-kill-all-zombies (&optional dummy)
2798 "Kill all zombie newsgroups.
2799 The optional DUMMY should always be nil."
2800 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2802 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2803 (setq gnus-zombie-list nil)
2804 (gnus-dribble-touch)
2805 (gnus-group-list-groups)))
2807 (defun gnus-group-kill-region (begin end)
2808 "Kill newsgroups in current region (excluding current point).
2809 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2824 (beginning-of-line) ;Important when LINES < 1
2825 (gnus-group-kill-group lines)))
2827 (defun gnus-group-kill-group (&optional n discard)
2828 "Kill the next N groups.
2829 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2830 However, only groups that were alive can be yanked; already killed
2831 groups or zombie groups can't be yanked.
2832 The return value is the name of the group that was killed, or a list
2835 (let ((buffer-read-only nil)
2836 (groups (gnus-group-process-prefix n))
2837 group entry level out)
2838 (if (< (length groups) 10)
2839 ;; This is faster when there are few groups.
2841 (push (setq group (pop groups)) out)
2842 (gnus-group-remove-mark group)
2843 (setq level (gnus-group-group-level))
2845 (when (and (not discard)
2846 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2849 (gnus-group-goto-group ,(gnus-group-group-name))
2850 (gnus-group-yank-group)))
2851 (push (cons (car entry) (nth 2 entry))
2852 gnus-list-of-killed-groups))
2853 (gnus-group-change-level
2854 (if entry entry group) gnus-level-killed (if entry nil level))
2855 (message "Killed group %s" group))
2856 ;; If there are lots and lots of groups to be killed, we use
2857 ;; this thing instead.
2859 (setq groups (nreverse groups))
2861 (gnus-group-remove-mark (setq group (pop groups)))
2863 (push group gnus-killed-list)
2864 (setq gnus-newsrc-alist
2865 (delq (assoc group gnus-newsrc-alist)
2867 (when gnus-group-change-level-function
2868 (funcall gnus-group-change-level-function
2869 group gnus-level-killed 3))
2871 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2872 (push (cons (car entry) (nth 2 entry))
2873 gnus-list-of-killed-groups)
2874 (setcdr (cdr entry) (cdddr entry)))
2875 ((member group gnus-zombie-list)
2876 (setq gnus-zombie-list (delete group gnus-zombie-list))))
2877 ;; There may be more than one instance displayed.
2878 (while (gnus-group-goto-group group)
2879 (gnus-delete-line)))
2880 (gnus-make-hashtable-from-newsrc-alist)))
2882 (gnus-group-position-point)
2883 (if (< (length out) 2) (car out) (nreverse out))))
2885 (defun gnus-group-yank-group (&optional arg)
2886 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
2887 The numeric ARG specifies how many newsgroups are to be yanked. The
2888 name of the newsgroup yanked is returned, or (if several groups are
2889 yanked) a list of yanked groups is returned."
2891 (setq arg (or arg 1))
2892 (let (info group prev out)
2893 (while (>= (decf arg) 0)
2894 (when (not (setq info (pop gnus-list-of-killed-groups)))
2895 (error "No more newsgroups to yank"))
2896 (push (setq group (nth 1 info)) out)
2897 ;; Find which newsgroup to insert this one before - search
2898 ;; backward until something suitable is found. If there are no
2899 ;; other newsgroups in this buffer, just make this newsgroup the
2901 (setq prev (gnus-group-group-name))
2902 (gnus-group-change-level
2903 info (gnus-info-level (cdr info)) gnus-level-killed
2904 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2906 (gnus-group-insert-group-line-info group)
2908 `(when (gnus-group-goto-group ,group)
2909 (gnus-group-kill-group 1))))
2911 (gnus-group-position-point)
2912 (if (< (length out) 2) (car out) (nreverse out))))
2914 (defun gnus-group-kill-level (level)
2915 "Kill all groups that is on a certain LEVEL."
2916 (interactive "nKill all groups on level: ")
2918 ((= level gnus-level-zombie)
2919 (setq gnus-killed-list
2920 (nconc gnus-zombie-list gnus-killed-list))
2921 (setq gnus-zombie-list nil))
2922 ((and (< level gnus-level-zombie)
2924 (or gnus-expert-user
2927 "Do you really want to kill all groups on level %d? "
2929 (let* ((prev gnus-newsrc-alist)
2932 (if (= (gnus-info-level (car alist)) level)
2934 (push (gnus-info-group (car alist)) gnus-killed-list)
2935 (setcdr prev (cdr alist)))
2937 (setq alist (cdr alist)))
2938 (gnus-make-hashtable-from-newsrc-alist)
2939 (gnus-group-list-groups)))
2941 (error "Can't kill; invalid level: %d" level))))
2943 (defun gnus-group-list-all-groups (&optional arg)
2944 "List all newsgroups with level ARG or lower.
2945 Default is gnus-level-unsubscribed, which lists all subscribed and most
2946 unsubscribed groups."
2948 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2950 ;; Redefine this to list ALL killed groups if prefix arg used.
2951 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2952 (defun gnus-group-list-killed (&optional arg)
2953 "List all killed newsgroups in the group buffer.
2954 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2955 entail asking the server for the groups."
2957 ;; Find all possible killed newsgroups if arg.
2959 (gnus-get-killed-groups))
2960 (if (not gnus-killed-list)
2961 (gnus-message 6 "No killed groups")
2962 (let (gnus-group-list-mode)
2963 (funcall gnus-group-prepare-function
2964 gnus-level-killed t gnus-level-killed))
2965 (goto-char (point-min)))
2966 (gnus-group-position-point))
2968 (defun gnus-group-list-zombies ()
2969 "List all zombie newsgroups in the group buffer."
2971 (if (not gnus-zombie-list)
2972 (gnus-message 6 "No zombie groups")
2973 (let (gnus-group-list-mode)
2974 (funcall gnus-group-prepare-function
2975 gnus-level-zombie t gnus-level-zombie))
2976 (goto-char (point-min)))
2977 (gnus-group-position-point))
2979 (defun gnus-group-list-active ()
2980 "List all groups that are available from the server(s)."
2982 ;; First we make sure that we have really read the active file.
2983 (unless (gnus-read-active-file-p)
2984 (let ((gnus-read-active-file t)
2985 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
2986 (gnus-read-active-file)))
2987 ;; Find all groups and sort them.
2995 (push (symbol-name sym) list)))
2999 (buffer-read-only nil)
3003 (gnus-add-text-properties
3004 (point) (prog1 (1+ (point))
3006 (setq group (pop groups)) "\n"))
3007 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3009 'gnus-level (inline (gnus-group-level group)))))
3010 (goto-char (point-min))))
3012 (defun gnus-activate-all-groups (level)
3013 "Activate absolutely all groups."
3014 (interactive (list gnus-level-unsubscribed))
3015 (let ((gnus-activate-level level)
3016 (gnus-activate-foreign-newsgroups level))
3017 (gnus-group-get-new-news)))
3019 (defun gnus-group-get-new-news (&optional arg)
3020 "Get newly arrived articles.
3021 If ARG is a number, it specifies which levels you are interested in
3022 re-scanning. If ARG is non-nil and not a number, this will force
3023 \"hard\" re-reading of the active files from all servers."
3026 (let ((gnus-inhibit-demon t)
3027 ;; Binding this variable will inhibit multiple fetchings
3028 ;; of the same mail source.
3029 (nnmail-fetched-sources (list t)))
3030 (gnus-run-hooks 'gnus-get-new-news-hook)
3032 ;; Read any slave files.
3034 (gnus-master-read-slave-newsrc))
3036 ;; We might read in new NoCeM messages here.
3037 (when (and gnus-use-nocem
3039 (gnus-nocem-scan-groups))
3040 ;; If ARG is not a number, then we read the active file.
3041 (when (and arg (not (numberp arg)))
3042 (let ((gnus-read-active-file t))
3043 (gnus-read-active-file))
3046 ;; If the user wants it, we scan for new groups.
3047 (when (eq gnus-check-new-newsgroups 'always)
3048 (gnus-find-new-newsgroups)))
3050 (setq arg (gnus-group-default-level arg t))
3051 (if (and gnus-read-active-file (not arg))
3053 (gnus-read-active-file)
3054 (gnus-get-unread-articles arg))
3055 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3056 (gnus-get-unread-articles arg)))
3057 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3058 (gnus-group-list-groups (and (numberp arg)
3059 (max (car gnus-group-list-mode) arg)))))
3061 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3062 "Check for newly arrived news in the current group (and the N-1 next groups).
3063 The difference between N and the number of newsgroup checked is returned.
3064 If N is negative, this group and the N-1 previous groups will be checked."
3066 (let* ((groups (gnus-group-process-prefix n))
3067 (ret (if (numberp n) (- n (length groups)) 0))
3071 (gnus-inhibit-demon t)
3072 ;; Binding this variable will inhibit multiple fetchings
3073 ;; of the same mail source.
3074 (nnmail-fetched-sources (list t)))
3075 (gnus-run-hooks 'gnus-get-new-news-hook)
3076 (while (setq group (pop groups))
3077 (gnus-group-remove-mark group)
3078 ;; Bypass any previous denials from the server.
3079 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3080 (if (gnus-activate-group group (if dont-scan nil 'scan))
3082 (gnus-get-unread-articles-in-group
3083 (gnus-get-info group) (gnus-active group) t)
3084 (unless (gnus-virtual-group-p group)
3085 (gnus-close-group group))
3087 (gnus-agent-save-group-info
3088 method (gnus-group-real-name group) (gnus-active group)))
3089 (gnus-group-update-group group))
3090 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3092 (gnus-error 3 "Server denied access")
3093 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3096 (when gnus-goto-next-group-when-activating
3097 (gnus-group-next-unread-group 1 t))
3098 (gnus-summary-position-point)
3101 (defun gnus-group-fetch-faq (group &optional faq-dir)
3102 "Fetch the FAQ for the current group.
3103 If given a prefix argument, prompt for the FAQ dir
3107 (gnus-group-group-name)
3108 (when current-prefix-arg
3110 "Faq dir: " (and (listp gnus-group-faq-directory)
3111 (mapcar (lambda (file) (list file))
3112 gnus-group-faq-directory))))))
3114 (error "No group name given"))
3115 (let ((dirs (or faq-dir gnus-group-faq-directory))
3117 (unless (listp dirs)
3118 (setq dirs (list dirs)))
3119 (while (and (not found)
3120 (setq dir (pop dirs)))
3121 (let ((name (gnus-group-real-name group)))
3122 (setq file (concat (file-name-as-directory dir) name)))
3123 (if (not (file-exists-p file))
3124 (gnus-message 1 "No such file: %s" file)
3125 (let ((enable-local-variables nil))
3129 (defun gnus-group-describe-group (force &optional group)
3130 "Display a description of the current newsgroup."
3131 (interactive (list current-prefix-arg (gnus-group-group-name)))
3132 (let* ((method (gnus-find-method-for-group group))
3133 (mname (gnus-group-prefixed-name "" method))
3136 gnus-description-hashtb)
3137 (gnus-sethash mname nil gnus-description-hashtb))
3139 (error "No group name given"))
3140 (when (or (and gnus-description-hashtb
3141 ;; We check whether this group's method has been
3142 ;; queried for a description file.
3143 (gnus-gethash mname gnus-description-hashtb))
3144 (setq desc (gnus-group-get-description group))
3145 (gnus-read-descriptions-file method))
3147 (or desc (gnus-gethash group gnus-description-hashtb)
3148 "No description available")))))
3150 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3151 (defun gnus-group-describe-all-groups (&optional force)
3152 "Pop up a buffer with descriptions of all newsgroups."
3155 (setq gnus-description-hashtb nil))
3156 (when (not (or gnus-description-hashtb
3157 (gnus-read-all-descriptions-files)))
3158 (error "Couldn't request descriptions file"))
3159 (let ((buffer-read-only nil)
3165 (insert (format " *: %-20s %s\n" (symbol-name group)
3166 (symbol-value group)))
3167 (gnus-add-text-properties
3168 b (1+ b) (list 'gnus-group group
3169 'gnus-unread t 'gnus-marked nil
3170 'gnus-level (1+ gnus-level-subscribed))))
3171 gnus-description-hashtb)
3172 (goto-char (point-min))
3173 (gnus-group-position-point)))
3175 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3176 (defun gnus-group-apropos (regexp &optional search-description)
3177 "List all newsgroups that have names that match a regexp."
3178 (interactive "sGnus apropos (regexp): ")
3180 (obuf (current-buffer))
3182 ;; Go through all newsgroups that are known to Gnus.
3185 (and (symbol-name group)
3186 (string-match regexp (symbol-name group))
3187 (symbol-value group)
3188 (push (symbol-name group) groups)))
3190 ;; Also go through all descriptions that are known to Gnus.
3191 (when search-description
3194 (and (string-match regexp (symbol-value group))
3195 (push (symbol-name group) groups)))
3196 gnus-description-hashtb))
3198 (gnus-message 3 "No groups matched \"%s\"." regexp)
3199 ;; Print out all the groups.
3201 (pop-to-buffer "*Gnus Help*")
3202 (buffer-disable-undo)
3204 (setq groups (sort groups 'string<))
3206 ;; Groups may be entered twice into the list of groups.
3207 (when (not (string= (car groups) prev))
3208 (insert (setq prev (car groups)) "\n")
3209 (when (and gnus-description-hashtb
3210 (setq des (gnus-gethash (car groups)
3211 gnus-description-hashtb)))
3212 (insert " " des "\n")))
3213 (setq groups (cdr groups)))
3214 (goto-char (point-min))))
3215 (pop-to-buffer obuf)))
3217 (defun gnus-group-description-apropos (regexp)
3218 "List all newsgroups that have names or descriptions that match a regexp."
3219 (interactive "sGnus description apropos (regexp): ")
3220 (when (not (or gnus-description-hashtb
3221 (gnus-read-all-descriptions-files)))
3222 (error "Couldn't request descriptions file"))
3223 (gnus-group-apropos regexp t))
3225 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3226 (defun gnus-group-list-matching (level regexp &optional all lowest)
3227 "List all groups with unread articles that match REGEXP.
3228 If the prefix LEVEL is non-nil, it should be a number that says which
3229 level to cut off listing groups.
3230 If ALL, also list groups with no unread articles.
3231 If LOWEST, don't list groups with level lower than LOWEST.
3233 This command may read the active file."
3234 (interactive "P\nsList newsgroups matching: ")
3235 ;; First make sure active file has been read.
3237 (> (prefix-numeric-value level) gnus-level-killed))
3238 (gnus-get-killed-groups))
3239 (gnus-group-prepare-flat
3240 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3241 (goto-char (point-min))
3242 (gnus-group-position-point))
3244 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3245 "List all groups that match REGEXP.
3246 If the prefix LEVEL is non-nil, it should be a number that says which
3247 level to cut off listing groups.
3248 If LOWEST, don't list groups with level lower than LOWEST."
3249 (interactive "P\nsList newsgroups matching: ")
3251 (setq level (prefix-numeric-value level)))
3252 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3254 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3255 (defun gnus-group-save-newsrc (&optional force)
3256 "Save the Gnus startup files.
3257 If FORCE, force saving whether it is necessary or not."
3259 (gnus-save-newsrc-file force))
3261 (defun gnus-group-restart (&optional arg)
3262 "Force Gnus to read the .newsrc file."
3264 (when (gnus-yes-or-no-p
3265 (format "Are you sure you want to restart Gnus? "))
3266 (gnus-save-newsrc-file)
3270 (defun gnus-group-read-init-file ()
3271 "Read the Gnus elisp init file."
3273 (gnus-read-init-file)
3274 (gnus-message 5 "Read %s" gnus-init-file))
3276 (defun gnus-group-check-bogus-groups (&optional silent)
3277 "Check bogus newsgroups.
3278 If given a prefix, don't ask for confirmation before removing a bogus
3281 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3282 (gnus-group-list-groups))
3284 (defun gnus-group-find-new-groups (&optional arg)
3285 "Search for new groups and add them.
3286 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3287 With 1 C-u, use the `ask-server' method to query the server for new
3289 With 2 C-u's, use most complete method possible to query the server
3290 for new groups, and subscribe the new groups as zombies."
3292 (gnus-find-new-newsgroups (or arg 1))
3293 (gnus-group-list-groups))
3295 (defun gnus-group-edit-global-kill (&optional article group)
3296 "Edit the global kill file.
3297 If GROUP, edit that local kill file instead."
3299 (setq gnus-current-kill-article article)
3300 (gnus-kill-file-edit-file group)
3303 (substitute-command-keys
3304 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3305 (if group "local" "global")))))
3307 (defun gnus-group-edit-local-kill (article group)
3308 "Edit a local kill file."
3309 (interactive (list nil (gnus-group-group-name)))
3310 (gnus-group-edit-global-kill article group))
3312 (defun gnus-group-force-update ()
3313 "Update `.newsrc' file."
3315 (gnus-save-newsrc-file))
3317 (defun gnus-group-suspend ()
3318 "Suspend the current Gnus session.
3319 In fact, cleanup buffers except for group mode buffer.
3320 The hook gnus-suspend-gnus-hook is called before actually suspending."
3322 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3323 ;; Kill Gnus buffers except for group mode buffer.
3324 (let ((group-buf (get-buffer gnus-group-buffer)))
3325 (mapcar (lambda (buf)
3326 (unless (member buf (list group-buf gnus-dribble-buffer))
3329 (gnus-kill-gnus-frames)
3331 (bury-buffer group-buf)
3332 (delete-windows-on group-buf t))))
3334 (defun gnus-group-clear-dribble ()
3335 "Clear all information from the dribble buffer."
3337 (gnus-dribble-clear)
3338 (gnus-message 7 "Cleared dribble buffer"))
3340 (defun gnus-group-exit ()
3341 "Quit reading news after updating .newsrc.eld and .newsrc.
3342 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3345 (or noninteractive ;For gnus-batch-kill
3346 (not gnus-interactive-exit) ;Without confirmation
3348 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3349 (gnus-run-hooks 'gnus-exit-gnus-hook)
3350 ;; Offer to save data from non-quitted summary buffers.
3351 (gnus-offer-save-summaries)
3352 ;; Save the newsrc file(s).
3353 (gnus-save-newsrc-file)
3355 (gnus-close-backends)
3356 ;; Reset everything.
3358 ;; Allow the user to do things after cleaning up.
3359 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3361 (defun gnus-group-quit ()
3362 "Quit reading news without updating .newsrc.eld or .newsrc.
3363 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3365 (when (or noninteractive ;For gnus-batch-kill
3366 (zerop (buffer-size))
3367 (not (gnus-server-opened gnus-select-method))
3369 (not gnus-current-startup-file)
3371 (format "Quit reading news without saving %s? "
3372 (file-name-nondirectory gnus-current-startup-file))))
3373 (gnus-run-hooks 'gnus-exit-gnus-hook)
3374 (gnus-configure-windows 'group t)
3376 (gnus-close-backends)
3378 (gnus-kill-buffer gnus-group-buffer)
3379 ;; Allow the user to do things after cleaning up.
3380 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3382 (defun gnus-group-describe-briefly ()
3383 "Give a one line description of the group mode commands."
3385 (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")))
3387 (defun gnus-group-browse-foreign-server (method)
3388 "Browse a foreign news server.
3389 If called interactively, this function will ask for a select method
3390 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3391 If not, METHOD should be a list where the first element is the method
3392 and the second element is the address."
3394 (list (let ((how (completing-read
3396 (append gnus-valid-select-methods gnus-server-alist)
3397 nil t (cons "nntp" 0) 'gnus-method-history)))
3398 ;; We either got a backend name or a virtual server name.
3399 ;; If the first, we also need an address.
3400 (if (assoc how gnus-valid-select-methods)
3402 ;; Suggested by mapjph@bath.ac.uk.
3405 (mapcar (lambda (server) (list server))
3406 gnus-secondary-servers)))
3407 ;; We got a server name.
3409 (gnus-browse-foreign-server method))
3411 (defun gnus-group-set-info (info &optional method-only-group part)
3412 (when (or info part)
3413 (let* ((entry (gnus-gethash
3414 (or method-only-group (gnus-info-group info))
3415 gnus-newsrc-hashtb))
3417 (info (if method-only-group (nth 2 entry) info))
3419 (when method-only-group
3421 (error "Trying to change non-existent group %s" method-only-group))
3422 ;; We have received parts of the actual group info - either the
3423 ;; select method or the group parameters. We first check
3424 ;; whether we have to extend the info, and if so, do that.
3425 (let ((len (length info))
3426 (total (if (eq part 'method) 5 6)))
3428 (setcdr (nthcdr (1- len) info)
3429 (make-list (- total len) nil)))
3430 ;; Then we enter the new info.
3431 (setcar (nthcdr (1- total) info) part-info)))
3433 ;; This is a new group, so we just create it.
3435 (set-buffer gnus-group-buffer)
3436 (setq method (gnus-info-method info))
3437 (when (gnus-server-equal method "native")
3440 (set-buffer gnus-group-buffer)
3442 ;; It's a foreign group...
3443 (gnus-group-make-group
3444 (gnus-group-real-name (gnus-info-group info))
3445 (if (stringp method) method
3446 (prin1-to-string (car method)))
3448 (nth 1 (gnus-info-method info))))
3449 ;; It's a native group.
3450 (gnus-group-make-group (gnus-info-group info))))
3451 (gnus-message 6 "Note: New group created")
3453 (gnus-gethash (gnus-group-prefixed-name
3454 (gnus-group-real-name (gnus-info-group info))
3455 (or (gnus-info-method info) gnus-select-method))
3456 gnus-newsrc-hashtb))))
3457 ;; Whether it was a new group or not, we now have the entry, so we
3458 ;; can do the update.
3461 (setcar (nthcdr 2 entry) info)
3462 (when (and (not (eq (car entry) t))
3463 (gnus-active (gnus-info-group info)))
3464 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3465 (error "No such group: %s" (gnus-info-group info))))))
3467 (defun gnus-group-set-method-info (group select-method)
3468 (gnus-group-set-info select-method group 'method))
3470 (defun gnus-group-set-params-info (group params)
3471 (gnus-group-set-info params group 'params))
3473 (defun gnus-add-marked-articles (group type articles &optional info force)
3474 ;; Add ARTICLES of TYPE to the info of GROUP.
3475 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3476 ;; add, but replace marked articles of TYPE with ARTICLES.
3477 (let ((info (or info (gnus-get-info group)))
3480 (and (not (setq marked (nthcdr 3 info)))
3482 (setcdr (nthcdr 2 info)
3483 (list (list (cons type (gnus-compress-sequence
3485 (and (not (setq m (assq type (car marked))))
3488 (cons (cons type (gnus-compress-sequence articles t) )
3492 (setcar (nthcdr 3 info)
3493 (gnus-delete-alist type (car marked)))
3494 (setcdr m (gnus-compress-sequence articles t)))
3495 (setcdr m (gnus-compress-sequence
3496 (sort (nconc (gnus-uncompress-range (cdr m))
3497 (copy-sequence articles)) '<) t))))))
3500 ;;; Group timestamps
3503 (defun gnus-group-set-timestamp ()
3504 "Change the timestamp of the current group to the current time.
3505 This function can be used in hooks like `gnus-select-group-hook'
3506 or `gnus-group-catchup-group-hook'."
3507 (when gnus-newsgroup-name
3508 (let ((time (current-time)))
3509 (setcdr (cdr time) nil)
3510 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3512 (defsubst gnus-group-timestamp (group)
3513 "Return the timestamp for GROUP."
3514 (gnus-group-get-parameter group 'timestamp t))
3516 (defun gnus-group-timestamp-delta (group)
3517 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3518 (let* ((time (or (gnus-group-timestamp group)
3520 (delta (subtract-time (current-time) time)))
3521 (+ (* (nth 0 delta) 65536.0)
3524 (defun gnus-group-timestamp-string (group)
3525 "Return a string of the timestamp for GROUP."
3526 (let ((time (gnus-group-timestamp group)))
3529 (gnus-time-iso8601 time))))
3531 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest)
3532 "List all newsgroups with unread articles of level LEVEL or lower.
3533 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3534 If PREDICATE, only list groups which PREDICATE returns non-nil."
3535 (set-buffer gnus-group-buffer)
3536 (let ((buffer-read-only nil)
3537 (newsrc (cdr gnus-newsrc-alist))
3538 (lowest (or lowest 1))
3539 info clevel unread group params)
3541 ;; List living groups.
3543 (setq info (car newsrc)
3544 group (gnus-info-group info)
3545 params (gnus-info-params info)
3547 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3548 (and unread ; This group might be unchecked
3549 (funcall predicate info)
3550 (<= (setq clevel (gnus-info-level info)) level)
3552 (gnus-group-insert-group-line
3553 group (gnus-info-level info)
3554 (gnus-info-marks info) unread (gnus-info-method info))))
3556 (gnus-group-set-mode-line)
3557 (setq gnus-group-list-mode (cons level t))
3558 (gnus-run-hooks 'gnus-group-prepare-hook)
3561 (defun gnus-group-list-cached (level &optional lowest)
3562 "List all groups with cached articles.
3563 If the prefix LEVEL is non-nil, it should be a number that says which
3564 level to cut off listing groups.
3565 If LOWEST, don't list groups with level lower than LOWEST.
3567 This command may read the active file."
3570 (setq level (prefix-numeric-value level)))
3571 (gnus-group-prepare-flat-predicate (or level gnus-level-killed)
3573 (let ((marks (gnus-info-marks info)))
3574 (assq 'cache marks)))
3576 (goto-char (point-min))
3577 (gnus-group-position-point))
3579 (provide 'gnus-group)
3581 ;;; gnus-group.el ends here