1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (defcustom gnus-group-archive-directory
43 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
44 "*The address of the (ding) archives."
45 :group 'gnus-group-foreign
48 (defcustom gnus-group-recent-archive-directory
49 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
50 "*The address of the most recent (ding) articles."
51 :group 'gnus-group-foreign
54 (defcustom gnus-no-groups-message "No gnus is bad news"
55 "*Message displayed by Gnus when no groups are available."
59 (defcustom gnus-keep-same-level nil
60 "*Non-nil means that the next newsgroup after the current will be on the same level.
61 When you type, for instance, `n' after reading the last article in the
62 current newsgroup, you will go to the next newsgroup. If this variable
63 is nil, the next newsgroup will be the next from the group
65 If this variable is non-nil, Gnus will either put you in the
66 next newsgroup with the same level, or, if no such newsgroup is
67 available, the next newsgroup with the lowest possible level higher
68 than the current level.
69 If this variable is `best', Gnus will make the next newsgroup the one
71 :group 'gnus-group-levels
72 :type '(choice (const nil)
74 (sexp :tag "other" t)))
76 (defcustom gnus-group-goto-unread t
77 "*If non-nil, movement commands will go to the next unread and subscribed group."
78 :link '(custom-manual "(gnus)Group Maneuvering")
79 :group 'gnus-group-various
82 (defcustom gnus-goto-next-group-when-activating t
83 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
84 :link '(custom-manual "(gnus)Scanning New Messages")
85 :group 'gnus-group-various
88 (defcustom gnus-permanently-visible-groups nil
89 "*Regexp to match groups that should always be listed in the group buffer.
90 This means that they will still be listed even when there are no
91 unread articles in the groups.
93 If nil, no groups are permanently visible."
94 :group 'gnus-group-listing
95 :type '(choice regexp (const nil)))
97 (defcustom gnus-list-groups-with-ticked-articles t
98 "*If non-nil, list groups that have only ticked articles.
99 If nil, only list groups that have unread articles."
100 :group 'gnus-group-listing
103 (defcustom gnus-group-default-list-level gnus-level-subscribed
104 "*Default listing level.
105 Ignored if `gnus-group-use-permanent-levels' is non-nil."
106 :group 'gnus-group-listing
109 (defcustom gnus-group-list-inactive-groups t
110 "*If non-nil, inactive groups will be listed."
111 :group 'gnus-group-listing
112 :group 'gnus-group-levels
115 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
116 "*Function used for sorting the group buffer.
117 This function will be called with group info entries as the arguments
118 for the groups to be sorted. Pre-made functions include
119 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
120 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
121 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
122 `gnus-group-sort-by-rank'.
124 This variable can also be a list of sorting functions. In that case,
125 the most significant sort function should be the last function in the
127 :group 'gnus-group-listing
128 :link '(custom-manual "(gnus)Sorting Groups")
129 :type '(radio (function-item gnus-group-sort-by-alphabet)
130 (function-item gnus-group-sort-by-real-name)
131 (function-item gnus-group-sort-by-unread)
132 (function-item gnus-group-sort-by-level)
133 (function-item gnus-group-sort-by-score)
134 (function-item gnus-group-sort-by-method)
135 (function-item gnus-group-sort-by-rank)
136 (function :tag "other" nil)))
138 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
139 "*Format of group lines.
140 It works along the same lines as a normal formatting string,
141 with some simple extensions.
143 %M Only marked articles (character, \"*\" or \" \")
144 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
145 %L Level of subscribedness (integer)
146 %N Number of unread articles (integer)
147 %I Number of dormant articles (integer)
148 %i Number of ticked and dormant (integer)
149 %T Number of ticked articles (integer)
150 %R Number of read articles (integer)
151 %t Estimated total number of articles (integer)
152 %y Number of unread, unticked articles (integer)
153 %G Group name (string)
154 %g Qualified group name (string)
155 %D Group description (string)
156 %s Select method (string)
157 %o Moderated group (char, \"m\")
158 %p Process mark (char)
159 %O Moderated group (string, \"(m)\" or \"\")
160 %P Topic indentation (string)
161 %m Whether there is new(ish) mail in the group (char, \"%\")
162 %w Number of new(ish) mails in the group (integer)
163 %l Whether there are GroupLens predictions for this group (string)
164 %n Select from where (string)
165 %z A string that look like `<%s:%n>' if a foreign select method is used
166 %d The date the group was last entered.
167 %E Icon as defined by `gnus-group-icon-list'.
168 %u User defined specifier. The next character in the format string should
169 be a letter. Gnus will call the function gnus-user-format-function-X,
170 where X is the letter following %u. The function will be passed the
171 current header as argument. The function should return a string, which
172 will be inserted into the buffer just like information from any other
175 Text between %( and %) will be highlighted with `gnus-mouse-face' when
176 the mouse point move inside the area. There can only be one such area.
178 Note that this format specification is not always respected. For
179 reasons of efficiency, when listing killed groups, this specification
180 is ignored altogether. If the spec is changed considerably, your
181 output may end up looking strange when listing both alive and killed
184 If you use %o or %O, reading the active file will be slower and quite
185 a bit of extra memory will be used. %D will also worsen performance.
186 Also note that if you change the format specification to include any
187 of these specs, you must probably re-start Gnus to see them go into
189 :group 'gnus-group-visual
192 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
193 "*The format specification for the group mode line.
194 It works along the same lines as a normal formatting string,
195 with some simple extensions:
197 %S The native news server.
198 %M The native select method.
199 %: \":\" if %S isn't \"\"."
200 :group 'gnus-group-visual
203 (defcustom gnus-group-mode-hook nil
204 "Hook for Gnus group mode."
205 :group 'gnus-group-various
206 :options '(gnus-topic-mode)
209 (defcustom gnus-group-menu-hook nil
210 "Hook run after the creation of the group mode menu."
211 :group 'gnus-group-various
214 (defcustom gnus-group-catchup-group-hook nil
215 "Hook run when catching up a group from the group buffer."
216 :group 'gnus-group-various
217 :link '(custom-manual "(gnus)Group Data")
220 (defcustom gnus-group-update-group-hook nil
221 "Hook called when updating group lines."
222 :group 'gnus-group-visual
225 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
226 "*A function that is called to generate the group buffer.
227 The function is called with three arguments: The first is a number;
228 all group with a level less or equal to that number should be listed,
229 if the second is non-nil, empty groups should also be displayed. If
230 the third is non-nil, it is a number. No groups with a level lower
231 than this number should be displayed.
233 The only current function implemented is `gnus-group-prepare-flat'."
234 :group 'gnus-group-listing
237 (defcustom gnus-group-prepare-hook nil
238 "Hook called after the group buffer has been generated.
239 If you want to modify the group buffer, you can use this hook."
240 :group 'gnus-group-listing
243 (defcustom gnus-suspend-gnus-hook nil
244 "Hook called when suspending (not exiting) Gnus."
248 (defcustom gnus-exit-gnus-hook nil
249 "Hook called when exiting Gnus."
253 (defcustom gnus-after-exiting-gnus-hook nil
254 "Hook called after exiting Gnus."
258 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
259 "Hook called when a group line is changed.
260 The hook will not be called if `gnus-visual' is nil.
262 The default function `gnus-group-highlight-line' will
263 highlight the line according to the `gnus-group-highlight'
265 :group 'gnus-group-visual
268 (defcustom gnus-useful-groups
269 '(("(ding) mailing list mirrored at sunsite.auc.dk"
271 (nntp "sunsite.auc.dk"
272 (nntp-address "sunsite.auc.dk")))
275 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
279 (nndoc-article-type mbox)
280 (eval `(nndoc-address
281 ,(let ((file (nnheader-find-etc-directory
284 (error "Couldn't find doc group"))
286 "*Alist of useful group-server pairs."
287 :group 'gnus-group-listing
288 :type '(repeat (list (string :tag "Description")
290 (sexp :tag "Method"))))
292 (defcustom gnus-group-highlight
294 ((and (= unread 0) (not mailp) (eq level 1)) .
295 gnus-group-news-1-empty-face)
296 ((and (not mailp) (eq level 1)) .
297 gnus-group-news-1-face)
298 ((and (= unread 0) (not mailp) (eq level 2)) .
299 gnus-group-news-2-empty-face)
300 ((and (not mailp) (eq level 2)) .
301 gnus-group-news-2-face)
302 ((and (= unread 0) (not mailp) (eq level 3)) .
303 gnus-group-news-3-empty-face)
304 ((and (not mailp) (eq level 3)) .
305 gnus-group-news-3-face)
306 ((and (= unread 0) (not mailp) (eq level 4)) .
307 gnus-group-news-4-empty-face)
308 ((and (not mailp) (eq level 4)) .
309 gnus-group-news-4-face)
310 ((and (= unread 0) (not mailp) (eq level 5)) .
311 gnus-group-news-5-empty-face)
312 ((and (not mailp) (eq level 5)) .
313 gnus-group-news-5-face)
314 ((and (= unread 0) (not mailp) (eq level 6)) .
315 gnus-group-news-6-empty-face)
316 ((and (not mailp) (eq level 6)) .
317 gnus-group-news-6-face)
318 ((and (= unread 0) (not mailp)) .
319 gnus-group-news-low-empty-face)
321 gnus-group-news-low-face)
323 ((and (= unread 0) (eq level 1)) .
324 gnus-group-mail-1-empty-face)
326 gnus-group-mail-1-face)
327 ((and (= unread 0) (eq level 2)) .
328 gnus-group-mail-2-empty-face)
330 gnus-group-mail-2-face)
331 ((and (= unread 0) (eq level 3)) .
332 gnus-group-mail-3-empty-face)
334 gnus-group-mail-3-face)
336 gnus-group-mail-low-empty-face)
338 gnus-group-mail-low-face))
339 "*Controls the highlighting of group buffer lines.
341 Below is a list of `Form'/`Face' pairs. When deciding how a a
342 particular group line should be displayed, each form is
343 evaluated. The content of the face field after the first true form is
344 used. You can change how those group lines are displayed by
345 editing the face field.
347 It is also possible to change and add form fields, but currently that
348 requires an understanding of Lisp expressions. Hopefully this will
349 change in a future release. For now, you can use the following
350 variables in the Lisp expression:
352 group: The name of the group.
353 unread: The number of unread articles in the group.
354 method: The select method used.
355 mailp: Whether it's a mail group or not.
356 level: The level of the group.
357 score: The score of the group.
358 ticked: The number of ticked articles."
359 :group 'gnus-group-visual
360 :type '(repeat (cons (sexp :tag "Form") face)))
362 (defcustom gnus-new-mail-mark ?%
363 "Mark used for groups with new mail."
364 :group 'gnus-group-visual
367 (defgroup gnus-group-icons nil
368 "Add Icons to your group buffer. "
369 :group 'gnus-group-visual)
371 (defcustom gnus-group-icon-list
373 "*Controls the insertion of icons into group buffer lines.
375 Below is a list of `Form'/`File' pairs. When deciding how a
376 particular group line should be displayed, each form is evaluated.
377 The icon from the file field after the first true form is used. You
378 can change how those group lines are displayed by editing the file
379 field. The File will either be found in the
380 `gnus-group-glyph-directory' or by designating absolute path to the
383 It is also possible to change and add form fields, but currently that
384 requires an understanding of Lisp expressions. Hopefully this will
385 change in a future release. For now, you can use the following
386 variables in the Lisp expression:
388 group: The name of the group.
389 unread: The number of unread articles in the group.
390 method: The select method used.
391 mailp: Whether it's a mail group or not.
392 newsp: Whether it's a news group or not
393 level: The level of the group.
394 score: The score of the group.
395 ticked: The number of ticked articles."
396 :group 'gnus-group-icons
397 :type '(repeat (cons (sexp :tag "Form") file)))
399 (defcustom gnus-group-name-charset-method-alist nil
400 "*Alist of method and the charset for group names.
403 (((nntp \"news.com.cn\") . cn-gb-2312))
406 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
408 (defcustom gnus-group-name-charset-group-alist nil
409 "*Alist of group regexp and the charset for group names.
412 ((\"\\.com\\.cn:\" . cn-gb-2312))
415 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
417 (defcustom gnus-group-jump-to-group-prompt nil
418 "Default prompt for `gnus-group-jump-to-group'.
419 If non-nil, the value should be a string, e.g. \"nnml:\",
420 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
421 in the minibuffer prompt."
422 :group 'gnus-group-various
423 :type '(choice (string :tag "Prompt string")
424 (const :tag "Empty" nil)))
426 ;;; Internal variables
428 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
429 "Function for sorting the group buffer.")
431 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
432 "Function for sorting the selected groups in the group buffer.")
434 (defvar gnus-group-indentation-function nil)
435 (defvar gnus-goto-missing-group-function nil)
436 (defvar gnus-group-update-group-function nil)
437 (defvar gnus-group-goto-next-group-function nil
438 "Function to override finding the next group after listing groups.")
440 (defvar gnus-group-edit-buffer nil)
442 (defvar gnus-group-line-format-alist
443 `((?M gnus-tmp-marked-mark ?c)
444 (?S gnus-tmp-subscribed ?c)
445 (?L gnus-tmp-level ?d)
446 (?N (cond ((eq number t) "*" )
450 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
451 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
453 (?R gnus-tmp-number-of-read ?s)
454 (?t gnus-tmp-number-total ?d)
455 (?y gnus-tmp-number-of-unread ?s)
456 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
457 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
458 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
459 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
460 (?g gnus-tmp-group ?s)
461 (?G gnus-tmp-qualified-group ?s)
462 (?c (gnus-short-group-name gnus-tmp-group) ?s)
463 (?D gnus-tmp-newsgroup-description ?s)
464 (?o gnus-tmp-moderated ?c)
465 (?O gnus-tmp-moderated-string ?s)
466 (?p gnus-tmp-process-marked ?c)
467 (?s gnus-tmp-news-server ?s)
468 (?n gnus-tmp-news-method ?s)
469 (?P gnus-group-indentation ?s)
470 (?E gnus-tmp-group-icon ?s)
471 (?l gnus-tmp-grouplens ?s)
472 (?z gnus-tmp-news-method-string ?s)
473 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
474 (?w (if (gnus-news-group-p gnus-tmp-group)
478 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
481 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
482 (?u gnus-tmp-user-defined ?s)))
484 (defvar gnus-group-mode-line-format-alist
485 `((?S gnus-tmp-news-server ?s)
486 (?M gnus-tmp-news-method ?s)
487 (?u gnus-tmp-user-defined ?s)
488 (?: gnus-tmp-colon ?s)))
490 (defvar gnus-topic-topology nil
491 "The complete topic hierarchy.")
493 (defvar gnus-topic-alist nil
494 "The complete topic-group alist.")
496 (defvar gnus-group-marked nil)
498 (defvar gnus-group-list-mode nil)
501 (defvar gnus-group-icon-cache nil)
507 (put 'gnus-group-mode 'mode-class 'special)
510 (gnus-define-keys gnus-group-mode-map
511 " " gnus-group-read-group
512 "=" gnus-group-select-group
513 "\r" gnus-group-select-group
514 "\M-\r" gnus-group-quick-select-group
515 "\M- " gnus-group-visible-select-group
516 [(meta control return)] gnus-group-select-group-ephemerally
517 "j" gnus-group-jump-to-group
518 "n" gnus-group-next-unread-group
519 "p" gnus-group-prev-unread-group
520 "\177" gnus-group-prev-unread-group
521 [delete] gnus-group-prev-unread-group
522 [backspace] gnus-group-prev-unread-group
523 "N" gnus-group-next-group
524 "P" gnus-group-prev-group
525 "\M-n" gnus-group-next-unread-group-same-level
526 "\M-p" gnus-group-prev-unread-group-same-level
527 "," gnus-group-best-unread-group
528 "." gnus-group-first-unread-group
529 "u" gnus-group-unsubscribe-current-group
530 "U" gnus-group-unsubscribe-group
531 "c" gnus-group-catchup-current
532 "C" gnus-group-catchup-current-all
533 "\M-c" gnus-group-clear-data
534 "l" gnus-group-list-groups
535 "L" gnus-group-list-all-groups
537 "g" gnus-group-get-new-news
538 "\M-g" gnus-group-get-new-news-this-group
539 "R" gnus-group-restart
540 "r" gnus-group-read-init-file
541 "B" gnus-group-browse-foreign-server
542 "b" gnus-group-check-bogus-groups
543 "F" gnus-group-find-new-groups
544 "\C-c\C-d" gnus-group-describe-group
545 "\M-d" gnus-group-describe-all-groups
546 "\C-c\C-a" gnus-group-apropos
547 "\C-c\M-\C-a" gnus-group-description-apropos
548 "a" gnus-group-post-news
549 "\ek" gnus-group-edit-local-kill
550 "\eK" gnus-group-edit-global-kill
551 "\C-k" gnus-group-kill-group
552 "\C-y" gnus-group-yank-group
553 "\C-w" gnus-group-kill-region
554 "\C-x\C-t" gnus-group-transpose-groups
555 "\C-c\C-l" gnus-group-list-killed
556 "\C-c\C-x" gnus-group-expire-articles
557 "\C-c\M-\C-x" gnus-group-expire-all-groups
559 "s" gnus-group-save-newsrc
560 "z" gnus-group-suspend
563 "?" gnus-group-describe-briefly
564 "\C-c\C-i" gnus-info-find-node
565 "\M-e" gnus-group-edit-group-method
566 "^" gnus-group-enter-server-mode
567 gnus-mouse-2 gnus-mouse-pick-group
568 "<" beginning-of-buffer
571 "\C-c\C-s" gnus-group-sort-groups
573 "\C-c\M-g" gnus-activate-all-groups
574 "\M-&" gnus-group-universal-argument
575 "#" gnus-group-mark-group
576 "\M-#" gnus-group-unmark-group)
578 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
579 "m" gnus-group-mark-group
580 "u" gnus-group-unmark-group
581 "w" gnus-group-mark-region
582 "b" gnus-group-mark-buffer
583 "r" gnus-group-mark-regexp
584 "U" gnus-group-unmark-all-groups)
586 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
587 "d" gnus-group-make-directory-group
588 "h" gnus-group-make-help-group
589 "u" gnus-group-make-useful-group
590 "a" gnus-group-make-archive-group
591 "k" gnus-group-make-kiboze-group
592 "l" gnus-group-nnimap-edit-acl
593 "m" gnus-group-make-group
594 "E" gnus-group-edit-group
595 "e" gnus-group-edit-group-method
596 "p" gnus-group-edit-group-parameters
597 "v" gnus-group-add-to-virtual
598 "V" gnus-group-make-empty-virtual
599 "D" gnus-group-enter-directory
600 "f" gnus-group-make-doc-group
601 "w" gnus-group-make-web-group
602 "r" gnus-group-rename-group
603 "c" gnus-group-customize
604 "x" gnus-group-nnimap-expunge
605 "\177" gnus-group-delete-group
606 [delete] gnus-group-delete-group)
608 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
609 "b" gnus-group-brew-soup
610 "w" gnus-soup-save-areas
611 "s" gnus-soup-send-replies
612 "p" gnus-soup-pack-packet
613 "r" nnsoup-pack-replies)
615 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
616 "s" gnus-group-sort-groups
617 "a" gnus-group-sort-groups-by-alphabet
618 "u" gnus-group-sort-groups-by-unread
619 "l" gnus-group-sort-groups-by-level
620 "v" gnus-group-sort-groups-by-score
621 "r" gnus-group-sort-groups-by-rank
622 "m" gnus-group-sort-groups-by-method)
624 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
625 "s" gnus-group-sort-selected-groups
626 "a" gnus-group-sort-selected-groups-by-alphabet
627 "u" gnus-group-sort-selected-groups-by-unread
628 "l" gnus-group-sort-selected-groups-by-level
629 "v" gnus-group-sort-selected-groups-by-score
630 "r" gnus-group-sort-selected-groups-by-rank
631 "m" gnus-group-sort-selected-groups-by-method)
633 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
634 "k" gnus-group-list-killed
635 "z" gnus-group-list-zombies
636 "s" gnus-group-list-groups
637 "u" gnus-group-list-all-groups
638 "A" gnus-group-list-active
639 "a" gnus-group-apropos
640 "d" gnus-group-description-apropos
641 "m" gnus-group-list-matching
642 "M" gnus-group-list-all-matching
643 "l" gnus-group-list-level
644 "c" gnus-group-list-cached
645 "?" gnus-group-list-dormant)
647 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
648 "f" gnus-score-flush-cache)
650 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
651 "d" gnus-group-describe-group
652 "f" gnus-group-fetch-faq
655 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
656 "l" gnus-group-set-current-level
657 "t" gnus-group-unsubscribe-current-group
658 "s" gnus-group-unsubscribe-group
659 "k" gnus-group-kill-group
660 "y" gnus-group-yank-group
661 "w" gnus-group-kill-region
662 "\C-k" gnus-group-kill-level
663 "z" gnus-group-kill-all-zombies))
665 (defun gnus-group-make-menu-bar ()
666 (gnus-turn-off-edit-menu 'group)
667 (unless (boundp 'gnus-group-reading-menu)
670 gnus-group-reading-menu gnus-group-mode-map ""
672 ["Read" gnus-group-read-group (gnus-group-group-name)]
673 ["Select" gnus-group-select-group (gnus-group-group-name)]
674 ["See old articles" (gnus-group-select-group 'all)
675 :keys "C-u SPC" :active (gnus-group-group-name)]
676 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
677 ["Catch up all articles" gnus-group-catchup-current-all
678 (gnus-group-group-name)]
679 ["Check for new articles" gnus-group-get-new-news-this-group
680 (gnus-group-group-name)]
681 ["Toggle subscription" gnus-group-unsubscribe-current-group
682 (gnus-group-group-name)]
683 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
684 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
685 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
686 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
687 ;; Actually one should check, if any of the marked groups gives t for
688 ;; (gnus-check-backend-function 'request-expire-articles ...)
689 ["Expire articles" gnus-group-expire-articles
690 (or (and (gnus-group-group-name)
691 (gnus-check-backend-function
692 'request-expire-articles
693 (gnus-group-group-name))) gnus-group-marked)]
694 ["Set group level" gnus-group-set-current-level
695 (gnus-group-group-name)]
696 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
697 ["Customize" gnus-group-customize (gnus-group-group-name)]
699 ["Parameters" gnus-group-edit-group-parameters
700 (gnus-group-group-name)]
701 ["Select method" gnus-group-edit-group-method
702 (gnus-group-group-name)]
703 ["Info" gnus-group-edit-group (gnus-group-group-name)]
704 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
705 ["Global kill file" gnus-group-edit-global-kill t])))
708 gnus-group-group-menu gnus-group-mode-map ""
711 ["List unread subscribed groups" gnus-group-list-groups t]
712 ["List (un)subscribed groups" gnus-group-list-all-groups t]
713 ["List killed groups" gnus-group-list-killed gnus-killed-list]
714 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
715 ["List level..." gnus-group-list-level t]
716 ["Describe all groups" gnus-group-describe-all-groups t]
717 ["Group apropos..." gnus-group-apropos t]
718 ["Group and description apropos..." gnus-group-description-apropos t]
719 ["List groups matching..." gnus-group-list-matching t]
720 ["List all groups matching..." gnus-group-list-all-matching t]
721 ["List active file" gnus-group-list-active t]
722 ["List groups with cached" gnus-group-list-cached t]
723 ["List groups with dormant" gnus-group-list-dormant t])
725 ["Default sort" gnus-group-sort-groups t]
726 ["Sort by method" gnus-group-sort-groups-by-method t]
727 ["Sort by rank" gnus-group-sort-groups-by-rank t]
728 ["Sort by score" gnus-group-sort-groups-by-score t]
729 ["Sort by level" gnus-group-sort-groups-by-level t]
730 ["Sort by unread" gnus-group-sort-groups-by-unread t]
731 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
732 ("Sort process/prefixed"
733 ["Default sort" gnus-group-sort-selected-groups
734 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
735 ["Sort by method" gnus-group-sort-selected-groups-by-method
736 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
737 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
738 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
739 ["Sort by score" gnus-group-sort-selected-groups-by-score
740 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
741 ["Sort by level" gnus-group-sort-selected-groups-by-level
742 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
743 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
744 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
745 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
746 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
748 ["Mark group" gnus-group-mark-group
749 (and (gnus-group-group-name)
750 (not (memq (gnus-group-group-name) gnus-group-marked)))]
751 ["Unmark group" gnus-group-unmark-group
752 (and (gnus-group-group-name)
753 (memq (gnus-group-group-name) gnus-group-marked))]
754 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
755 ["Mark regexp..." gnus-group-mark-regexp t]
756 ["Mark region" gnus-group-mark-region t]
757 ["Mark buffer" gnus-group-mark-buffer t]
758 ["Execute command" gnus-group-universal-argument
759 (or gnus-group-marked (gnus-group-group-name))])
761 ["Subscribe to a group" gnus-group-unsubscribe-group t]
762 ["Kill all newsgroups in region" gnus-group-kill-region t]
763 ["Kill all zombie groups" gnus-group-kill-all-zombies
765 ["Kill all groups on level..." gnus-group-kill-level t])
767 ["Make a foreign group" gnus-group-make-group t]
768 ["Add a directory group" gnus-group-make-directory-group t]
769 ["Add the help group" gnus-group-make-help-group t]
770 ["Add the archive group" gnus-group-make-archive-group t]
771 ["Make a doc group" gnus-group-make-doc-group t]
772 ["Make a web group" gnus-group-make-web-group t]
773 ["Make a kiboze group" gnus-group-make-kiboze-group t]
774 ["Make a virtual group" gnus-group-make-empty-virtual t]
775 ["Add a group to a virtual" gnus-group-add-to-virtual t]
776 ["Rename group" gnus-group-rename-group
777 (gnus-check-backend-function
778 'request-rename-group (gnus-group-group-name))]
779 ["Delete group" gnus-group-delete-group
780 (gnus-check-backend-function
781 'request-delete-group (gnus-group-group-name))])
783 ["Next" gnus-group-next-group t]
784 ["Previous" gnus-group-prev-group t]
785 ["Next unread" gnus-group-next-unread-group t]
786 ["Previous unread" gnus-group-prev-unread-group t]
787 ["Next unread same level" gnus-group-next-unread-group-same-level t]
788 ["Previous unread same level"
789 gnus-group-prev-unread-group-same-level t]
790 ["Jump to group" gnus-group-jump-to-group t]
791 ["First unread group" gnus-group-first-unread-group t]
792 ["Best unread group" gnus-group-best-unread-group t])
793 ["Delete bogus groups" gnus-group-check-bogus-groups t]
794 ["Find new newsgroups" gnus-group-find-new-groups t]
795 ["Transpose" gnus-group-transpose-groups
796 (gnus-group-group-name)]
797 ["Read a directory as a group..." gnus-group-enter-directory t]))
800 gnus-group-misc-menu gnus-group-mode-map ""
803 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
804 ["Send replies" gnus-soup-send-replies
805 (fboundp 'gnus-soup-pack-packet)]
806 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
807 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
808 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
809 ["Send a mail" gnus-group-mail t]
810 ["Post an article..." gnus-group-post-news t]
811 ["Check for new news" gnus-group-get-new-news t]
812 ["Activate all groups" gnus-activate-all-groups t]
813 ["Restart Gnus" gnus-group-restart t]
814 ["Read init file" gnus-group-read-init-file t]
815 ["Browse foreign server" gnus-group-browse-foreign-server t]
816 ["Enter server buffer" gnus-group-enter-server-mode t]
817 ["Expire all expirable articles" gnus-group-expire-all-groups t]
818 ["Generate any kiboze groups" nnkiboze-generate-groups t]
819 ["Gnus version" gnus-version t]
820 ["Save .newsrc files" gnus-group-save-newsrc t]
821 ["Suspend Gnus" gnus-group-suspend t]
822 ["Clear dribble buffer" gnus-group-clear-dribble t]
823 ["Read manual" gnus-info-find-node t]
824 ["Flush score cache" gnus-score-flush-cache t]
825 ["Toggle topics" gnus-topic-mode t]
826 ["Send a bug report" gnus-bug t]
827 ["Exit from Gnus" gnus-group-exit t]
828 ["Exit without saving" gnus-group-quit t]))
830 (gnus-run-hooks 'gnus-group-menu-hook)))
832 (defun gnus-group-mode ()
833 "Major mode for reading news.
835 All normal editing commands are switched off.
836 \\<gnus-group-mode-map>
837 The group buffer lists (some of) the groups available. For instance,
838 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
839 lists all zombie groups.
841 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
842 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
844 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
846 The following commands are available:
848 \\{gnus-group-mode-map}"
850 (when (gnus-visual-p 'group-menu 'menu)
851 (gnus-group-make-menu-bar))
852 (kill-all-local-variables)
853 (gnus-simplify-mode-line)
854 (setq major-mode 'gnus-group-mode)
855 (setq mode-name "Group")
856 (gnus-group-set-mode-line)
857 (setq mode-line-process nil)
858 (use-local-map gnus-group-mode-map)
859 (buffer-disable-undo)
860 (setq truncate-lines t)
861 (setq buffer-read-only t)
862 (gnus-set-default-directory)
863 (gnus-update-format-specifications nil 'group 'group-mode)
864 (gnus-update-group-mark-positions)
869 (gnus-run-hooks 'gnus-group-mode-hook))
871 (defun gnus-update-group-mark-positions ()
873 (let ((gnus-process-mark ?\200)
874 (gnus-group-marked '("dummy.group"))
875 (gnus-active-hashtb (make-vector 10 0))
877 (gnus-set-active "dummy.group" '(0 . 0))
878 (gnus-set-work-buffer)
879 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
880 (goto-char (point-min))
881 (setq gnus-group-mark-positions
882 (list (cons 'process (and (search-forward "\200" nil t)
885 (defun gnus-mouse-pick-group (e)
886 "Enter the group under the mouse pointer."
889 (gnus-group-read-group nil))
891 ;; Look at LEVEL and find out what the level is really supposed to be.
892 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
893 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
894 (defun gnus-group-default-level (&optional level number-or-nil)
896 (gnus-group-use-permanent-levels
897 (or (setq gnus-group-use-permanent-levels
898 (or level (if (numberp gnus-group-use-permanent-levels)
899 gnus-group-use-permanent-levels
900 (or gnus-group-default-list-level
901 gnus-level-subscribed))))
902 gnus-group-default-list-level gnus-level-subscribed))
906 (or level gnus-group-default-list-level gnus-level-subscribed))))
908 (defun gnus-group-setup-buffer ()
909 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
910 (unless (eq major-mode 'gnus-group-mode)
913 (gnus-carpal-setup-buffer 'group))))
915 (defsubst gnus-group-name-charset (method group)
917 (setq method (gnus-find-method-for-group group)))
918 (let ((item (assoc method gnus-group-name-charset-method-alist))
919 (alist gnus-group-name-charset-group-alist)
923 (while (setq item (pop alist))
924 (if (string-match (car item) group)
929 (defsubst gnus-group-name-decode (string charset)
930 (if (and string charset (featurep 'mule))
931 (decode-coding-string string charset)
934 (defun gnus-group-decoded-name (string)
935 (let ((charset (gnus-group-name-charset nil string)))
936 (gnus-group-name-decode string charset)))
938 (defun gnus-group-list-groups (&optional level unread lowest)
939 "List newsgroups with level LEVEL or lower that have unread articles.
940 Default is all subscribed groups.
941 If argument UNREAD is non-nil, groups with no unread articles are also
944 Also see the `gnus-group-use-permanent-levels' variable."
946 (list (if current-prefix-arg
947 (prefix-numeric-value current-prefix-arg)
949 (gnus-group-default-level nil t)
950 gnus-group-default-list-level
951 gnus-level-subscribed))))
953 (setq level (car gnus-group-list-mode)
954 unread (cdr gnus-group-list-mode)))
955 (setq level (gnus-group-default-level level))
956 (gnus-group-setup-buffer)
957 (gnus-update-format-specifications nil 'group 'group-mode)
958 (let ((case-fold-search nil)
959 (props (text-properties-at (gnus-point-at-bol)))
960 (empty (= (point-min) (point-max)))
961 (group (gnus-group-group-name))
963 (set-buffer gnus-group-buffer)
964 (setq number (funcall gnus-group-prepare-function level unread lowest))
965 (when (or (and (numberp number)
967 (zerop (buffer-size)))
968 ;; No groups in the buffer.
969 (gnus-message 5 gnus-no-groups-message))
970 ;; We have some groups displayed.
971 (goto-char (point-max))
972 (when (or (not gnus-group-goto-next-group-function)
973 (not (funcall gnus-group-goto-next-group-function
977 (goto-char (point-min)))
979 ;; Go to the first group with unread articles.
980 (gnus-group-search-forward t))
982 ;; Find the right group to put point on. If the current group
983 ;; has disappeared in the new listing, try to find the next
984 ;; one. If no next one can be found, just leave point at the
985 ;; first newsgroup in the buffer.
986 (when (not (gnus-goto-char
988 (point-min) (point-max)
989 'gnus-group (gnus-intern-safe
990 group gnus-active-hashtb))))
991 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
995 (point-min) (point-max) 'gnus-group
997 (caar newsrc) gnus-active-hashtb)))))
998 (setq newsrc (cdr newsrc)))
1000 (goto-char (point-max))
1001 (forward-line -1)))))))
1002 ;; Adjust cursor point.
1003 (gnus-group-position-point)))
1005 (defun gnus-group-list-level (level &optional all)
1006 "List groups on LEVEL.
1007 If ALL (the prefix), also list groups that have no unread articles."
1008 (interactive "nList groups on level: \nP")
1009 (gnus-group-list-groups level all level))
1011 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
1012 "List all newsgroups with unread articles of level LEVEL or lower.
1013 If ALL is non-nil, list groups that have no unread articles.
1014 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1015 If REGEXP, only list groups matching REGEXP."
1016 (set-buffer gnus-group-buffer)
1017 (let ((buffer-read-only nil)
1018 (newsrc (cdr gnus-newsrc-alist))
1019 (lowest (or lowest 1))
1020 info clevel unread group params)
1022 (when (< lowest gnus-level-zombie)
1023 ;; List living groups.
1025 (setq info (car newsrc)
1026 group (gnus-info-group info)
1027 params (gnus-info-params info)
1029 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1030 (and unread ; This group might be unchecked
1032 (string-match regexp group))
1033 (<= (setq clevel (gnus-info-level info)) level)
1035 (or all ; We list all groups?
1036 (if (eq unread t) ; Unactivated?
1037 gnus-group-list-inactive-groups ; We list unactivated
1038 (> unread 0)) ; We list groups with unread articles
1039 (and gnus-list-groups-with-ticked-articles
1040 (cdr (assq 'tick (gnus-info-marks info))))
1041 ; And groups with tickeds
1042 ;; Check for permanent visibility.
1043 (and gnus-permanently-visible-groups
1044 (string-match gnus-permanently-visible-groups
1046 (memq 'visible params)
1047 (cdr (assq 'visible params)))
1048 (gnus-group-insert-group-line
1049 group (gnus-info-level info)
1050 (gnus-info-marks info) unread (gnus-info-method info)))))
1052 ;; List dead groups.
1053 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
1054 (gnus-group-prepare-flat-list-dead
1055 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1056 gnus-level-zombie ?Z
1058 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
1059 (gnus-group-prepare-flat-list-dead
1060 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1061 gnus-level-killed ?K regexp))
1063 (gnus-group-set-mode-line)
1064 (setq gnus-group-list-mode (cons level all))
1065 (gnus-run-hooks 'gnus-group-prepare-hook)
1068 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1069 ;; List zombies and killed lists somewhat faster, which was
1070 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1071 ;; this by ignoring the group format specification altogether.
1074 ;; This loop is used when listing groups that match some
1077 (setq group (pop groups))
1078 (when (string-match regexp group)
1079 (gnus-add-text-properties
1080 (point) (prog1 (1+ (point))
1081 (insert " " mark " *: "
1082 (gnus-group-name-decode group
1083 (gnus-group-name-charset
1086 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1088 'gnus-level level))))
1089 ;; This loop is used when listing all groups.
1091 (setq group (pop groups))
1092 (gnus-add-text-properties
1093 (point) (prog1 (1+ (point))
1094 (insert " " mark " *: "
1095 (gnus-group-name-decode group
1096 (gnus-group-name-charset
1099 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1101 'gnus-level level))))))
1103 (defun gnus-group-update-group-line ()
1104 "Update the current line in the group buffer."
1105 (let* ((buffer-read-only nil)
1106 (group (gnus-group-group-name))
1107 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1108 gnus-group-indentation)
1111 (not (gnus-ephemeral-group-p group))
1113 (concat "(gnus-group-set-info '"
1114 (gnus-prin1-to-string (nth 2 entry))
1116 (setq gnus-group-indentation (gnus-group-group-indentation))
1118 (gnus-group-insert-group-line-info group)
1120 (gnus-group-position-point))))
1122 (defun gnus-group-insert-group-line-info (group)
1123 "Insert GROUP on the current line."
1124 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1125 (gnus-group-indentation (gnus-group-group-indentation))
1129 ;; (Un)subscribed group.
1130 (setq info (nth 2 entry))
1131 (gnus-group-insert-group-line
1132 group (gnus-info-level info) (gnus-info-marks info)
1133 (or (car entry) t) (gnus-info-method info)))
1134 ;; This group is dead.
1135 (gnus-group-insert-group-line
1137 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1139 (if (setq active (gnus-active group))
1140 (if (zerop (cdr active))
1142 (- (1+ (cdr active)) (car active)))
1146 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1147 gnus-tmp-marked number
1149 "Insert a group line in the group buffer."
1150 (let* ((gnus-tmp-method
1151 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1152 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1154 (gnus-tmp-active (gnus-active gnus-tmp-group))
1155 (gnus-tmp-number-total
1157 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1159 (gnus-tmp-number-of-unread
1160 (if (numberp number) (int-to-string (max 0 number))
1162 (gnus-tmp-number-of-read
1163 (if (numberp number)
1164 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1166 (gnus-tmp-subscribed
1167 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1168 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1169 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1171 (gnus-tmp-qualified-group
1172 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1173 group-name-charset))
1174 (gnus-tmp-newsgroup-description
1175 (if gnus-description-hashtb
1176 (or (gnus-group-name-decode
1177 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1178 group-name-charset) "")
1181 (if (and gnus-moderated-hashtb
1182 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1184 (gnus-tmp-moderated-string
1185 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1186 (gnus-tmp-group-icon "==&&==")
1187 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1188 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1189 (gnus-tmp-news-method-string
1191 (format "(%s:%s)" (car gnus-tmp-method)
1192 (cadr gnus-tmp-method)) ""))
1193 (gnus-tmp-marked-mark
1194 (if (and (numberp number)
1196 (cdr (assq 'tick gnus-tmp-marked)))
1198 (gnus-tmp-process-marked
1199 (if (member gnus-tmp-group gnus-group-marked)
1200 gnus-process-mark ? ))
1202 (or (and gnus-use-grouplens
1203 (bbb-grouplens-group-p gnus-tmp-group))
1205 (buffer-read-only nil)
1206 header gnus-tmp-header) ; passed as parameter to user-funcs.
1208 (gnus-add-text-properties
1212 (eval gnus-group-line-format-spec))
1213 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1214 gnus-unread ,(if (numberp number)
1215 (string-to-int gnus-tmp-number-of-unread)
1217 gnus-marked ,gnus-tmp-marked-mark
1218 gnus-indentation ,gnus-group-indentation
1219 gnus-level ,gnus-tmp-level))
1221 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1222 (gnus-run-hooks 'gnus-group-update-hook))
1224 ;; Allow XEmacs to remove front-sticky text properties.
1225 (gnus-group-remove-excess-properties)))
1227 (defun gnus-group-highlight-line ()
1228 "Highlight the current line according to `gnus-group-highlight'."
1229 (let* ((list gnus-group-highlight)
1231 (end (progn (end-of-line) (point)))
1232 ;; now find out where the line starts and leave point there.
1233 (beg (progn (beginning-of-line) (point)))
1234 (group (gnus-group-group-name))
1235 (entry (gnus-group-entry group))
1236 (unread (if (numberp (car entry)) (car entry) 0))
1237 (active (gnus-active group))
1238 (total (if active (1+ (- (cdr active) (car active))) 0))
1239 (info (nth 2 entry))
1240 (method (gnus-server-get-method group (gnus-info-method info)))
1241 (marked (gnus-info-marks info))
1242 (mailp (memq 'mail (assoc (symbol-name
1243 (car (or method gnus-select-method)))
1244 gnus-valid-select-methods)))
1245 (level (or (gnus-info-level info) gnus-level-killed))
1246 (score (or (gnus-info-score info) 0))
1247 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1248 (group-age (gnus-group-timestamp-delta group))
1249 (inhibit-read-only t))
1250 ;; Eval the cars of the lists until we find a match.
1252 (not (eval (caar list))))
1253 (setq list (cdr list)))
1254 (let ((face (cdar list)))
1255 (unless (eq face (get-text-property beg 'face))
1256 (gnus-put-text-property-excluding-characters-with-faces
1258 (setq face (if (boundp face) (symbol-value face) face)))
1259 (gnus-extent-start-open beg)))
1262 (defun gnus-group-update-group (group &optional visible-only)
1263 "Update all lines where GROUP appear.
1264 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1266 ;; Can't use `save-excursion' here, so we do it manually.
1267 (let ((buf (current-buffer))
1269 (set-buffer gnus-group-buffer)
1270 (setq mark (point-marker))
1271 ;; The buffer may be narrowed.
1274 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1276 found buffer-read-only)
1277 ;; Enter the current status into the dribble buffer.
1278 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1280 (not (gnus-ephemeral-group-p group)))
1282 (concat "(gnus-group-set-info '"
1283 (gnus-prin1-to-string (nth 2 entry))
1285 ;; Find all group instances. If topics are in use, each group
1286 ;; may be listed in more than once.
1287 (while (setq loc (text-property-any
1288 loc (point-max) 'gnus-group ident))
1291 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1293 (gnus-group-insert-group-line-info group)
1296 (gnus-run-hooks 'gnus-group-update-group-hook)))
1297 (setq loc (1+ loc)))
1298 (unless (or found visible-only)
1299 ;; No such line in the buffer, find out where it's supposed to
1300 ;; go, and insert it there (or at the end of the buffer).
1301 (if gnus-goto-missing-group-function
1302 (funcall gnus-goto-missing-group-function group)
1303 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1304 (while (and entry (car entry)
1308 (point-min) (point-max)
1309 'gnus-group (gnus-intern-safe
1310 (caar entry) gnus-active-hashtb)))))
1311 (setq entry (cdr entry)))
1312 (or entry (goto-char (point-max)))))
1313 ;; Finally insert the line.
1314 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1315 (gnus-group-insert-group-line-info group)
1318 (gnus-run-hooks 'gnus-group-update-group-hook))))
1319 (when gnus-group-update-group-function
1320 (funcall gnus-group-update-group-function group))
1321 (gnus-group-set-mode-line)))
1323 (set-marker mark nil)
1326 (defun gnus-group-set-mode-line ()
1327 "Update the mode line in the group buffer."
1328 (when (memq 'group gnus-updated-mode-lines)
1329 ;; Yes, we want to keep this mode line updated.
1331 (set-buffer gnus-group-buffer)
1332 (let* ((gformat (or gnus-group-mode-line-format-spec
1333 (gnus-set-format 'group-mode)))
1334 (gnus-tmp-news-server (cadr gnus-select-method))
1335 (gnus-tmp-news-method (car gnus-select-method))
1336 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1338 gnus-tmp-header ;Dummy binding for user-defined formats
1339 ;; Get the resulting string.
1341 (and gnus-dribble-buffer
1342 (buffer-name gnus-dribble-buffer)
1343 (buffer-modified-p gnus-dribble-buffer)
1345 (set-buffer gnus-dribble-buffer)
1346 (not (zerop (buffer-size))))))
1347 (mode-string (eval gformat)))
1348 ;; Say whether the dribble buffer has been modified.
1349 (setq mode-line-modified
1350 (if modified (car gnus-mode-line-modified)
1351 (cdr gnus-mode-line-modified)))
1352 ;; If the line is too long, we chop it off.
1353 (when (> (length mode-string) max-len)
1354 (setq mode-string (substring mode-string 0 (- max-len 4))))
1356 (setq mode-line-buffer-identification
1357 (gnus-mode-line-buffer-identification
1358 (list mode-string)))
1359 (set-buffer-modified-p modified))))))
1361 (defun gnus-group-group-name ()
1362 "Get the name of the newsgroup on the current line."
1363 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1365 (symbol-name group))))
1367 (defun gnus-group-group-level ()
1368 "Get the level of the newsgroup on the current line."
1369 (get-text-property (gnus-point-at-bol) 'gnus-level))
1371 (defun gnus-group-group-indentation ()
1372 "Get the indentation of the newsgroup on the current line."
1373 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1374 (and gnus-group-indentation-function
1375 (funcall gnus-group-indentation-function))
1378 (defun gnus-group-group-unread ()
1379 "Get the number of unread articles of the newsgroup on the current line."
1380 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1382 (defun gnus-group-new-mail (group)
1383 (if (nnmail-new-mail-p (gnus-group-real-name group))
1387 (defun gnus-group-level (group)
1388 "Return the estimated level of GROUP."
1389 (or (gnus-info-level (gnus-get-info group))
1390 (and (member group gnus-zombie-list) gnus-level-zombie)
1393 (defun gnus-group-search-forward (&optional backward all level first-too)
1394 "Find the next newsgroup with unread articles.
1395 If BACKWARD is non-nil, find the previous newsgroup instead.
1396 If ALL is non-nil, just find any newsgroup.
1397 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1399 If FIRST-TOO, the current line is also eligible as a target."
1400 (let ((way (if backward -1 1))
1401 (low gnus-level-killed)
1404 (if (and backward (progn (beginning-of-line)) (bobp))
1413 (get-text-property (point) 'gnus-group)
1417 (get-text-property (point) 'gnus-unread)))
1418 (and (numberp unread) (> unread 0)))
1419 (setq lev (get-text-property (point)
1421 (<= lev gnus-level-subscribed)))
1423 (and (setq lev (get-text-property (point)
1432 (zerop (forward-line way)))))
1434 (progn (gnus-group-position-point) t)
1435 (goto-char (or pos beg))
1438 ;;; Gnus group mode commands
1442 (defun gnus-group-mark-line-p ()
1445 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1446 (eq (char-after) gnus-process-mark)))
1448 (defun gnus-group-mark-group (n &optional unmark no-advance)
1449 "Mark the current group."
1451 (let ((buffer-read-only nil)
1455 (when (setq group (gnus-group-group-name))
1456 ;; Go to the mark position.
1458 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1459 (subst-char-in-region
1460 (point) (1+ (point)) (char-after)
1463 (setq gnus-group-marked (delete group gnus-group-marked))
1465 (setq gnus-group-marked
1466 (cons group (delete group gnus-group-marked)))
1467 gnus-process-mark)))
1469 (gnus-group-next-group 1))
1471 (gnus-summary-position-point)
1474 (defun gnus-group-unmark-group (n)
1475 "Remove the mark from the current group."
1477 (gnus-group-mark-group n 'unmark)
1478 (gnus-group-position-point))
1480 (defun gnus-group-unmark-all-groups ()
1481 "Unmark all groups."
1483 (let ((groups gnus-group-marked))
1486 (gnus-group-remove-mark (pop groups)))))
1487 (gnus-group-position-point))
1489 (defun gnus-group-mark-region (unmark beg end)
1490 "Mark all groups between point and mark.
1491 If UNMARK, remove the mark instead."
1492 (interactive "P\nr")
1493 (let ((num (count-lines beg end)))
1496 (- num (gnus-group-mark-group num unmark)))))
1498 (defun gnus-group-mark-buffer (&optional unmark)
1499 "Mark all groups in the buffer.
1500 If UNMARK, remove the mark instead."
1502 (gnus-group-mark-region unmark (point-min) (point-max)))
1504 (defun gnus-group-mark-regexp (regexp)
1505 "Mark all groups that match some regexp."
1506 (interactive "sMark (regexp): ")
1507 (let ((alist (cdr gnus-newsrc-alist))
1510 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1511 (gnus-group-set-mark group))))
1512 (gnus-group-position-point))
1514 (defun gnus-group-remove-mark (group &optional test-marked)
1515 "Remove the process mark from GROUP and move point there.
1516 Return nil if the group isn't displayed."
1517 (if (gnus-group-goto-group group nil test-marked)
1519 (gnus-group-mark-group 1 'unmark t)
1521 (setq gnus-group-marked
1522 (delete group gnus-group-marked))
1525 (defun gnus-group-set-mark (group)
1526 "Set the process mark on GROUP."
1527 (if (gnus-group-goto-group group)
1529 (gnus-group-mark-group 1 nil t))
1530 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1532 (defun gnus-group-universal-argument (arg &optional groups func)
1533 "Perform any command on all groups according to the process/prefix convention."
1535 (if (eq (setq func (or func
1538 (substitute-command-keys
1539 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1541 (gnus-error 1 "Undefined key")
1542 (gnus-group-iterate arg
1544 (command-execute func))))
1545 (gnus-group-position-point))
1547 (defun gnus-group-process-prefix (n)
1548 "Return a list of groups to work on.
1549 Take into consideration N (the prefix) and the list of marked groups."
1552 (setq n (prefix-numeric-value n))
1553 ;; There is a prefix, so we return a list of the N next
1555 (let ((way (if (< n 0) -1 1))
1560 (if (setq group (gnus-group-group-name))
1561 (push group groups))
1563 (gnus-group-next-group way)))
1565 ((gnus-region-active-p)
1566 ;; Work on the region between point and mark.
1567 (let ((max (max (point) (mark)))
1570 (goto-char (min (point) (mark)))
1573 (push (gnus-group-group-name) groups)
1574 (zerop (gnus-group-next-group 1))
1576 (nreverse groups))))
1578 ;; No prefix, but a list of marked articles.
1579 (reverse gnus-group-marked))
1581 ;; Neither marked articles or a prefix, so we return the
1583 (let ((group (gnus-group-group-name)))
1584 (and group (list group))))))
1586 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1587 ;;; imagine why I went through these contortions...
1589 (let ((function (make-symbol "gnus-group-iterate-function"))
1590 (window (make-symbol "gnus-group-iterate-window"))
1591 (groups (make-symbol "gnus-group-iterate-groups"))
1592 (group (make-symbol "gnus-group-iterate-group")))
1594 `(defun gnus-group-iterate (arg ,function)
1595 "Iterate FUNCTION over all process/prefixed groups.
1596 FUNCTION will be called with the group name as the parameter
1597 and with point over the group in question."
1598 (let ((,groups (gnus-group-process-prefix arg))
1599 (,window (selected-window))
1602 (setq ,group (car ,groups)
1603 ,groups (cdr ,groups))
1604 (select-window ,window)
1605 (gnus-group-remove-mark ,group)
1606 (save-selected-window
1608 (funcall ,function ,group)))))))))
1610 (put 'gnus-group-iterate 'lisp-indent-function 1)
1612 ;; Selecting groups.
1614 (defun gnus-group-read-group (&optional all no-article group select-articles)
1615 "Read news in this newsgroup.
1616 If the prefix argument ALL is non-nil, already read articles become
1617 readable. IF ALL is a number, fetch this number of articles. If the
1618 optional argument NO-ARTICLE is non-nil, no article will be
1619 auto-selected upon group entry. If GROUP is non-nil, fetch that
1622 (let ((no-display (eq all 0))
1623 (group (or group (gnus-group-group-name)))
1624 number active marked entry)
1628 (error "No group on current line"))
1629 (setq marked (gnus-info-marks
1630 (nth 2 (setq entry (gnus-gethash
1631 group gnus-newsrc-hashtb)))))
1632 ;; This group might be a dead group. In that case we have to get
1633 ;; the number of unread articles from `gnus-active-hashtb'.
1635 (cond ((numberp all) all)
1637 ((setq active (gnus-active group))
1638 (- (1+ (cdr active)) (car active)))))
1639 (gnus-summary-read-group
1640 group (or all (and (numberp number)
1641 (zerop (+ number (gnus-range-length
1642 (cdr (assq 'tick marked)))
1644 (cdr (assq 'dormant marked)))))))
1645 no-article nil no-display nil select-articles)))
1647 (defun gnus-group-select-group (&optional all)
1648 "Select this newsgroup.
1649 No article is selected automatically.
1650 If ALL is non-nil, already read articles become readable.
1651 If ALL is a number, fetch this number of articles."
1653 (gnus-group-read-group all t))
1655 (defun gnus-group-quick-select-group (&optional all)
1656 "Select the current group \"quickly\".
1657 This means that no highlighting or scoring will be performed.
1658 If ALL (the prefix argument) is 0, don't even generate the summary
1661 This might be useful if you want to toggle threading
1662 before entering the group."
1664 (require 'gnus-score)
1666 gnus-score-find-score-files-function
1667 gnus-home-score-file
1668 gnus-apply-kill-hook
1669 gnus-summary-expunge-below)
1670 (gnus-group-read-group all t)))
1672 (defun gnus-group-visible-select-group (&optional all)
1673 "Select the current group without hiding any articles."
1675 (let ((gnus-inhibit-limiting t))
1676 (gnus-group-read-group all t)))
1678 (defun gnus-group-select-group-ephemerally ()
1679 "Select the current group without doing any processing whatsoever.
1680 You will actually be entered into a group that's a copy of
1681 the current group; no changes you make while in this group will
1684 (require 'gnus-score)
1686 gnus-score-find-score-files-function gnus-apply-kill-hook
1687 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1688 gnus-summary-mode-hook gnus-select-group-hook
1689 (group (gnus-group-group-name))
1690 (method (gnus-find-method-for-group group)))
1691 (gnus-group-read-ephemeral-group
1692 (gnus-group-prefixed-name group method) method)))
1695 (defun gnus-fetch-group (group)
1696 "Start Gnus if necessary and enter GROUP.
1697 Returns whether the fetching was successful or not."
1698 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1699 (unless (get-buffer gnus-group-buffer)
1701 (gnus-group-read-group nil nil group))
1704 (defun gnus-fetch-group-other-frame (group)
1705 "Pop up a frame and enter GROUP."
1707 (let ((window (get-buffer-window gnus-group-buffer)))
1709 (select-frame (window-frame window)))
1710 ((= (length (frame-list)) 1)
1711 (select-frame (make-frame)))
1714 (gnus-fetch-group group))
1716 (defvar gnus-ephemeral-group-server 0)
1718 ;; Enter a group that is not in the group buffer. Non-nil is returned
1719 ;; if selection was successful.
1720 (defun gnus-group-read-ephemeral-group (group method &optional activate
1721 quit-config request-only
1723 "Read GROUP from METHOD as an ephemeral group.
1724 If ACTIVATE, request the group first.
1725 If QUIT-CONFIG, use that window configuration when exiting from the
1727 If REQUEST-ONLY, don't actually read the group; just request it.
1728 If SELECT-ARTICLES, only select those articles.
1730 Return the name of the group if selection was successful."
1731 ;; Transform the select method into a unique server.
1732 (when (stringp method)
1733 (setq method (gnus-server-to-method method)))
1735 `(,(car method) ,(concat (cadr method) "-ephemeral")
1736 (,(intern (format "%s-address" (car method))) ,(cadr method))
1738 (let ((group (if (gnus-group-foreign-p group) group
1739 (gnus-group-prefixed-name group method))))
1743 ,gnus-level-default-subscribed nil nil ,method
1745 ,(if quit-config quit-config
1746 (cons gnus-summary-buffer
1747 gnus-current-window-configuration))))))
1749 (push method gnus-ephemeral-servers)
1750 (set-buffer gnus-group-buffer)
1751 (unless (gnus-check-server method)
1752 (error "Unable to contact server: %s" (gnus-status-message method)))
1754 (gnus-activate-group group 'scan)
1755 (unless (gnus-request-group group)
1756 (error "Couldn't request group: %s"
1757 (nnheader-get-report (car method)))))
1761 (when (gnus-group-read-group t t group select-articles)
1765 (message "Quit reading the ephemeral group")
1768 (defun gnus-group-jump-to-group (group)
1769 "Jump to newsgroup GROUP."
1771 (list (completing-read
1772 "Group: " gnus-active-hashtb nil
1773 (gnus-read-active-file-p)
1774 gnus-group-jump-to-group-prompt
1775 'gnus-group-history)))
1777 (when (equal group "")
1778 (error "Empty group name"))
1780 (unless (gnus-ephemeral-group-p group)
1781 ;; Either go to the line in the group buffer...
1782 (unless (gnus-group-goto-group group)
1783 ;; ... or insert the line.
1784 (gnus-group-update-group group)
1785 (gnus-group-goto-group group)))
1786 ;; Adjust cursor point.
1787 (gnus-group-position-point))
1789 (defun gnus-group-goto-group (group &optional far test-marked)
1790 "Goto to newsgroup GROUP.
1791 If FAR, it is likely that the group is not on the current line.
1792 If TEST-MARKED, the line must be marked."
1796 ;; It's quite likely that we are on the right line, so
1797 ;; we check the current line first.
1799 (eq (get-text-property (point) 'gnus-group)
1800 (gnus-intern-safe group gnus-active-hashtb))
1801 (or (not test-marked) (gnus-group-mark-line-p)))
1803 ;; Previous and next line are also likely, so we check them as well.
1807 (and (eq (get-text-property (point) 'gnus-group)
1808 (gnus-intern-safe group gnus-active-hashtb))
1809 (or (not test-marked) (gnus-group-mark-line-p)))))
1815 (and (eq (get-text-property (point) 'gnus-group)
1816 (gnus-intern-safe group gnus-active-hashtb))
1817 (or (not test-marked) (gnus-group-mark-line-p)))))
1821 (goto-char (point-min))
1823 (while (and (not found)
1828 (gnus-intern-safe group gnus-active-hashtb))))
1829 (if (gnus-group-mark-line-p)
1834 ;; Search through the entire buffer.
1837 (point-min) (point-max)
1838 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1840 (defun gnus-group-next-group (n &optional silent)
1841 "Go to next N'th newsgroup.
1842 If N is negative, search backward instead.
1843 Returns the difference between N and the number of skips actually
1846 (gnus-group-next-unread-group n t nil silent))
1848 (defun gnus-group-next-unread-group (n &optional all level silent)
1849 "Go to next N'th unread newsgroup.
1850 If N is negative, search backward instead.
1851 If ALL is non-nil, choose any newsgroup, unread or not.
1852 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1853 such group can be found, the next group with a level higher than
1855 Returns the difference between N and the number of skips actually
1858 (let ((backward (< n 0))
1861 (gnus-group-search-forward
1862 backward (or (not gnus-group-goto-unread) all) level))
1866 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1867 (if level " on this level or higher" "")))
1870 (defun gnus-group-prev-group (n)
1871 "Go to previous N'th newsgroup.
1872 Returns the difference between N and the number of skips actually
1875 (gnus-group-next-unread-group (- n) t))
1877 (defun gnus-group-prev-unread-group (n)
1878 "Go to previous N'th unread newsgroup.
1879 Returns the difference between N and the number of skips actually
1882 (gnus-group-next-unread-group (- n)))
1884 (defun gnus-group-next-unread-group-same-level (n)
1885 "Go to next N'th unread newsgroup on the same level.
1886 If N is negative, search backward instead.
1887 Returns the difference between N and the number of skips actually
1890 (gnus-group-next-unread-group n t (gnus-group-group-level))
1891 (gnus-group-position-point))
1893 (defun gnus-group-prev-unread-group-same-level (n)
1894 "Go to next N'th unread newsgroup on the same level.
1895 Returns the difference between N and the number of skips actually
1898 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1899 (gnus-group-position-point))
1901 (defun gnus-group-best-unread-group (&optional exclude-group)
1902 "Go to the group with the highest level.
1903 If EXCLUDE-GROUP, do not go to that group."
1905 (goto-char (point-min))
1909 (setq unread (get-text-property (point) 'gnus-unread))
1910 (when (and (numberp unread) (> unread 0))
1911 (when (and (get-text-property (point) 'gnus-level)
1912 (< (get-text-property (point) 'gnus-level) best)
1913 (or (not exclude-group)
1914 (not (equal exclude-group (gnus-group-group-name)))))
1915 (setq best (get-text-property (point) 'gnus-level))
1916 (setq best-point (point))))
1919 (goto-char best-point))
1920 (gnus-summary-position-point)
1921 (and best-point (gnus-group-group-name))))
1923 (defun gnus-group-first-unread-group ()
1924 "Go to the first group with unread articles."
1927 (let ((opoint (point))
1929 (goto-char (point-min))
1930 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1931 (and (numberp unread) ; Not a topic.
1932 (not (zerop unread))) ; Has unread articles.
1933 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1936 nil)) ; Not success.
1937 (gnus-group-position-point)))
1939 (defun gnus-group-enter-server-mode ()
1940 "Jump to the server buffer."
1942 (gnus-enter-server-buffer))
1944 (defun gnus-group-make-group (name &optional method address args)
1945 "Add a new newsgroup.
1946 The user will be prompted for a NAME, for a select METHOD, and an
1950 (gnus-read-group "Group name: ")
1951 (gnus-read-method "From method: ")))
1953 (when (stringp method)
1954 (setq method (or (gnus-server-to-method method) method)))
1955 (let* ((meth (gnus-method-simplify
1957 (not (gnus-server-equal method gnus-select-method)))
1958 (if address (list (intern method) address)
1960 (nname (if method (gnus-group-prefixed-name name meth) name))
1962 (when (gnus-gethash nname gnus-newsrc-hashtb)
1963 (error "Group %s already exists" nname))
1964 ;; Subscribe to the new group.
1965 (gnus-group-change-level
1966 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1967 gnus-level-default-subscribed gnus-level-killed
1968 (and (gnus-group-group-name)
1969 (gnus-gethash (gnus-group-group-name)
1970 gnus-newsrc-hashtb))
1973 (gnus-set-active nname (cons 1 0))
1974 (unless (gnus-ephemeral-group-p name)
1976 (concat "(gnus-group-set-info '"
1977 (gnus-prin1-to-string (cdr info)) ")")))
1979 (gnus-group-insert-group-line-info nname)
1981 (gnus-group-position-point)
1983 ;; Load the backend and try to make the backend create
1984 ;; the group as well.
1985 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1987 gnus-valid-select-methods)
1989 (gnus-check-server meth)
1990 (when (gnus-check-backend-function 'request-create-group nname)
1991 (gnus-request-create-group nname nil args))
1994 (defun gnus-group-delete-groups (&optional arg)
1995 "Delete the current group. Only meaningful with editable groups."
1997 (let ((n (length (gnus-group-process-prefix arg))))
1998 (when (gnus-yes-or-no-p
2000 "Delete this 1 group? "
2001 (format "Delete these %d groups? " n)))
2002 (gnus-group-iterate arg
2004 (gnus-group-delete-group group nil t))))))
2006 (defun gnus-group-delete-group (group &optional force no-prompt)
2007 "Delete the current group. Only meaningful with editable groups.
2008 If FORCE (the prefix) is non-nil, all the articles in the group will
2009 be deleted. This is \"deleted\" as in \"removed forever from the face
2010 of the Earth\". There is no undo. The user will be prompted before
2011 doing the deletion."
2013 (list (gnus-group-group-name)
2014 current-prefix-arg))
2016 (error "No group to rename"))
2017 (unless (gnus-check-backend-function 'request-delete-group group)
2018 (error "This backend does not support group deletion"))
2020 (if (and (not no-prompt)
2021 (not (gnus-yes-or-no-p
2023 "Do you really want to delete %s%s? "
2024 group (if force " and all its contents" "")))))
2026 (gnus-message 6 "Deleting group %s..." group)
2027 (if (not (gnus-request-delete-group group force))
2028 (gnus-error 3 "Couldn't delete group %s" group)
2029 (gnus-message 6 "Deleting group %s...done" group)
2030 (gnus-group-goto-group group)
2031 (gnus-group-kill-group 1 t)
2032 (gnus-sethash group nil gnus-active-hashtb)
2034 (gnus-group-position-point)))
2036 (defun gnus-group-rename-group (group new-name)
2037 "Rename group from GROUP to NEW-NAME.
2038 When used interactively, GROUP is the group under point
2039 and NEW-NAME will be prompted for."
2042 (gnus-group-group-name)
2044 (unless (gnus-check-backend-function
2045 'request-rename-group (gnus-group-group-name))
2046 (error "This backend does not support renaming groups"))
2047 (gnus-read-group "Rename group to: "
2048 (gnus-group-real-name (gnus-group-group-name))))))
2050 (unless (gnus-check-backend-function 'request-rename-group group)
2051 (error "This backend does not support renaming groups"))
2053 (error "No group to rename"))
2054 (when (equal (gnus-group-real-name group) new-name)
2055 (error "Can't rename to the same name"))
2057 ;; We find the proper prefixed name.
2059 (if (gnus-group-native-p group)
2063 (gnus-group-prefixed-name
2064 (gnus-group-real-name new-name)
2065 (gnus-info-method (gnus-get-info group)))))
2067 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2070 (gnus-group-goto-group group)
2071 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2072 (gnus-request-rename-group group new-name))))
2073 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2074 ;; We rename the group internally by killing it...
2075 (gnus-group-kill-group)
2076 ;; ... changing its name ...
2077 (setcar (cdar gnus-list-of-killed-groups) new-name)
2078 ;; ... and then yanking it. Magic!
2079 (gnus-group-yank-group)
2080 (gnus-set-active new-name (gnus-active group))
2081 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2083 (setq gnus-killed-list (delete group gnus-killed-list))
2084 (gnus-set-active group nil)
2085 (gnus-dribble-touch)
2086 (gnus-group-position-point)))
2088 (defun gnus-group-edit-group (group &optional part)
2089 "Edit the group on the current line."
2090 (interactive (list (gnus-group-group-name)))
2091 (let ((part (or part 'info))
2094 (error "No group on current line"))
2095 (unless (setq info (gnus-get-info group))
2096 (error "Killed group; can't be edited"))
2098 (gnus-close-group group))
2100 ;; Find the proper form to edit.
2101 (cond ((eq part 'method)
2102 (or (gnus-info-method info) "native"))
2104 (gnus-info-params info))
2106 ;; The proper documentation.
2108 "Editing the %s for `%s'."
2110 ((eq part 'method) "select method")
2111 ((eq part 'params) "group parameters")
2113 (gnus-group-decoded-name group))
2115 (gnus-group-edit-group-done ',part ,group form)))))
2117 (defun gnus-group-edit-group-method (group)
2118 "Edit the select method of GROUP."
2119 (interactive (list (gnus-group-group-name)))
2120 (gnus-group-edit-group group 'method))
2122 (defun gnus-group-edit-group-parameters (group)
2123 "Edit the group parameters of GROUP."
2124 (interactive (list (gnus-group-group-name)))
2125 (gnus-group-edit-group group 'params))
2127 (defun gnus-group-edit-group-done (part group form)
2129 (let* ((method (cond ((eq part 'info) (nth 4 form))
2130 ((eq part 'method) form)
2132 (info (cond ((eq part 'info) form)
2133 ((eq part 'method) (gnus-get-info group))
2136 (if (or (not method)
2138 gnus-select-method method))
2139 (gnus-group-real-name (car info))
2140 (gnus-group-prefixed-name
2141 (gnus-group-real-name (car info)) method))
2143 (when (and new-group
2144 (not (equal new-group group)))
2145 (when (gnus-group-goto-group group)
2146 (gnus-group-kill-group 1))
2147 (gnus-activate-group new-group))
2149 (if (not (and info new-group))
2150 (gnus-group-set-info form (or new-group group) part)
2151 (setq info (gnus-copy-sequence info))
2152 (setcar info new-group)
2153 (unless (gnus-server-equal method "native")
2154 (unless (nthcdr 3 info)
2155 (nconc info (list nil nil)))
2156 (unless (nthcdr 4 info)
2157 (nconc info (list nil)))
2158 (gnus-info-set-method info method))
2159 (gnus-group-set-info info))
2160 (gnus-group-update-group (or new-group group))
2161 (gnus-group-position-point)))
2163 (defun gnus-group-make-useful-group (group method)
2164 "Create one of the groups described in `gnus-useful-groups'."
2166 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2168 gnus-useful-groups)))
2169 (list (cadr entry) (caddr entry))))
2170 (setq method (gnus-copy-sequence method))
2172 (while (setq entry (memq (assq 'eval method) method))
2173 (setcar entry (eval (cadar entry)))))
2174 (gnus-group-make-group group method))
2176 (defun gnus-group-make-help-group ()
2177 "Create the Gnus documentation group."
2179 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2180 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2181 (when (gnus-gethash name gnus-newsrc-hashtb)
2182 (error "Documentation group already exists"))
2184 (gnus-message 1 "Couldn't find doc group")
2185 (gnus-group-make-group
2186 (gnus-group-real-name name)
2187 (list 'nndoc "gnus-help"
2188 (list 'nndoc-address file)
2189 (list 'nndoc-article-type 'mbox)))))
2190 (gnus-group-position-point))
2192 (defun gnus-group-make-doc-group (file type)
2193 "Create a group that uses a single file as the source."
2195 (list (read-file-name "File name: ")
2196 (and current-prefix-arg 'ask)))
2197 (when (eq type 'ask)
2202 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2204 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2205 ((= char ?b) 'babyl)
2206 ((= char ?d) 'digest)
2207 ((= char ?f) 'forward)
2209 ((= char ?g) 'guess)
2210 (t (setq err (format "%c unknown. " char))
2213 (let* ((file (expand-file-name file))
2214 (name (gnus-generate-new-group-name
2215 (gnus-group-prefixed-name
2216 (file-name-nondirectory file) '(nndoc "")))))
2217 (gnus-group-make-group
2218 (gnus-group-real-name name)
2220 (list 'nndoc-address file)
2221 (list 'nndoc-article-type (or type 'guess))))))
2223 (defvar nnweb-type-definition)
2224 (defvar gnus-group-web-type-history nil)
2225 (defvar gnus-group-web-search-history nil)
2226 (defun gnus-group-make-web-group (&optional solid)
2227 "Create an ephemeral nnweb group.
2228 If SOLID (the prefix), create a solid group."
2232 (if solid (gnus-read-group "Group name: ")
2233 (message-unique-id)))
2234 (default-type (or (car gnus-group-web-type-history)
2235 (symbol-name (caar nnweb-type-definition))))
2239 (format "Search engine type (default %s): " default-type)
2240 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2241 nnweb-type-definition)
2242 nil t nil 'gnus-group-web-type-history)
2247 (cons (or (car gnus-group-web-search-history) "") 0)
2248 'gnus-group-web-search-history))
2250 `(nnweb ,group (nnweb-search ,search)
2251 (nnweb-type ,(intern type))
2252 (nnweb-ephemeral-p t))))
2254 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2255 (gnus-group-read-ephemeral-group
2257 (cons (current-buffer)
2258 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2260 (defvar nnwarchive-type-definition)
2261 (defvar gnus-group-warchive-type-history nil)
2262 (defvar gnus-group-warchive-login-history nil)
2263 (defvar gnus-group-warchive-address-history nil)
2265 (defun gnus-group-make-warchive-group ()
2266 "Create a nnwarchive group."
2268 (require 'nnwarchive)
2269 (let* ((group (gnus-read-group "Group name: "))
2270 (default-type (or (car gnus-group-warchive-type-history)
2271 (symbol-name (caar nnwarchive-type-definition))))
2275 (format "Warchive type (default %s): " default-type)
2276 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2277 nnwarchive-type-definition)
2278 nil t nil 'gnus-group-warchive-type-history)
2280 (address (read-string "Warchive address: "
2281 nil 'gnus-group-warchive-address-history))
2282 (default-login (or (car gnus-group-warchive-login-history)
2287 (format "Warchive login (default %s): " user-mail-address)
2288 default-login 'gnus-group-warchive-login-history)
2291 `(nnwarchive ,address
2292 (nnwarchive-type ,(intern type))
2293 (nnwarchive-login ,login))))
2294 (gnus-group-make-group group method)))
2296 (defvar nnshimbun-type-definition)
2297 (defvar gnus-group-shimbun-server-history nil)
2299 (defun gnus-group-make-shimbun-group ()
2300 "Create a nnshimbun group."
2302 (require 'nnshimbun)
2303 (let* ((minibuffer-setup-hook (append minibuffer-setup-hook
2304 '(beginning-of-line)))
2305 (server (completing-read
2307 (mapcar (lambda (elem) (list (car elem)))
2308 nnshimbun-type-definition)
2310 (or (car gnus-group-shimbun-server-history)
2311 (caar nnshimbun-type-definition))
2312 'gnus-group-shimbun-server-history))
2313 (group (completing-read
2315 (mapcar (lambda (elem) (list elem))
2317 (cdr (assoc server nnshimbun-type-definition)))))
2319 (nnshimbun-pre-fetch-article nil))
2320 (gnus-group-make-group group `(nnshimbun ,server))))
2322 (defun gnus-group-make-archive-group (&optional all)
2323 "Create the (ding) Gnus archive group of the most recent articles.
2324 Given a prefix, create a full group."
2326 (let ((group (gnus-group-prefixed-name
2327 (if all "ding.archives" "ding.recent") '(nndir ""))))
2328 (when (gnus-gethash group gnus-newsrc-hashtb)
2329 (error "Archive group already exists"))
2330 (gnus-group-make-group
2331 (gnus-group-real-name group)
2332 (list 'nndir (if all "hpc" "edu")
2333 (list 'nndir-directory
2334 (if all gnus-group-archive-directory
2335 gnus-group-recent-archive-directory))))
2336 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2338 (defun gnus-group-make-directory-group (dir)
2339 "Create an nndir group.
2340 The user will be prompted for a directory. The contents of this
2341 directory will be used as a newsgroup. The directory should contain
2342 mail messages or news articles in files that have numeric names."
2344 (list (read-file-name "Create group from directory: ")))
2345 (unless (file-exists-p dir)
2346 (error "No such directory"))
2347 (unless (file-directory-p dir)
2348 (error "Not a directory"))
2352 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2354 (gnus-group-prefixed-name
2355 (expand-file-name ext dir)
2357 (setq ext (format "<%d>" (setq i (1+ i)))))
2358 (gnus-group-make-group
2359 (gnus-group-real-name group)
2360 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2362 (eval-when-compile (defvar nnkiboze-score-file))
2363 (defun gnus-group-make-kiboze-group (group address scores)
2364 "Create an nnkiboze group.
2365 The user will be prompted for a name, a regexp to match groups, and
2366 score file entries for articles to include in the group."
2369 (read-string "nnkiboze group name: ")
2370 (read-string "Source groups (regexp): ")
2371 (let ((headers (mapcar (lambda (group) (list group))
2372 '("subject" "from" "number" "date" "message-id"
2373 "references" "chars" "lines" "xref"
2374 "followup" "all" "body" "head")))
2375 scores header regexp regexps)
2376 (while (not (equal "" (setq header (completing-read
2377 "Match on header: " headers nil t))))
2379 (while (not (equal "" (setq regexp (read-string
2380 (format "Match on %s (regexp): "
2382 (push (list regexp nil nil 'r) regexps))
2383 (push (cons header regexps) scores))
2385 (gnus-group-make-group group "nnkiboze" address)
2386 (let* ((nnkiboze-current-group group)
2387 (score-file (car (nnkiboze-score-file "")))
2388 (score-dir (file-name-directory score-file)))
2389 (unless (file-exists-p score-dir)
2390 (make-directory score-dir))
2391 (with-temp-file score-file
2392 (let (emacs-lisp-mode-hook)
2393 (pp scores (current-buffer))))))
2395 (defun gnus-group-add-to-virtual (n vgroup)
2396 "Add the current group to a virtual group."
2398 (list current-prefix-arg
2399 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2401 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2402 (error "%s is not an nnvirtual group" vgroup))
2403 (gnus-close-group vgroup)
2404 (let* ((groups (gnus-group-process-prefix n))
2405 (method (gnus-info-method (gnus-get-info vgroup))))
2406 (setcar (cdr method)
2408 (nth 1 method) "\\|"
2411 (gnus-group-remove-mark s)
2412 (concat "\\(^" (regexp-quote s) "$\\)"))
2414 (gnus-group-position-point))
2416 (defun gnus-group-make-empty-virtual (group)
2417 "Create a new, fresh, empty virtual group."
2418 (interactive "sCreate new, empty virtual group: ")
2419 (let* ((method (list 'nnvirtual "^$"))
2420 (pgroup (gnus-group-prefixed-name group method)))
2421 ;; Check whether it exists already.
2422 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2423 (error "Group %s already exists" pgroup))
2424 ;; Subscribe the new group after the group on the current line.
2425 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2426 (gnus-group-update-group pgroup)
2428 (gnus-group-position-point)))
2430 (defun gnus-group-enter-directory (dir)
2431 "Enter an ephemeral nneething group."
2432 (interactive "DDirectory to read: ")
2433 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2434 (leaf (gnus-group-prefixed-name
2435 (file-name-nondirectory (directory-file-name dir))
2437 (name (gnus-generate-new-group-name leaf)))
2438 (unless (gnus-group-read-ephemeral-group
2440 (cons (current-buffer)
2441 (if (eq major-mode 'gnus-summary-mode)
2443 (error "Couldn't enter %s" dir))))
2446 (autoload 'nnimap-expunge "nnimap")
2447 (autoload 'nnimap-acl-get "nnimap")
2448 (autoload 'nnimap-acl-edit "nnimap"))
2450 (defun gnus-group-nnimap-expunge (group)
2451 "Expunge deleted articles in current nnimap GROUP."
2452 (interactive (list (gnus-group-group-name)))
2453 (let ((mailbox (gnus-group-real-name group)) method)
2455 (error "No group on current line"))
2456 (unless (gnus-get-info group)
2457 (error "Killed group; can't be edited"))
2458 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2459 (error "%s is not an nnimap group" group))
2460 (nnimap-expunge mailbox (cadr method))))
2462 (defun gnus-group-nnimap-edit-acl (group)
2463 "Edit the Access Control List of current nnimap GROUP."
2464 (interactive (list (gnus-group-group-name)))
2465 (let ((mailbox (gnus-group-real-name group)) method acl)
2467 (error "No group on current line"))
2468 (unless (gnus-get-info group)
2469 (error "Killed group; can't be edited"))
2470 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2471 (error "%s is not an nnimap group" group))
2472 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2473 (error "Server does not support ACL's"))
2474 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2476 An access control list is a list of (identifier . rights) elements.
2478 The identifier string specifies the corresponding user. The
2479 identifier \"anyone\" is reserved to refer to the universal identity.
2481 Rights is a string listing a (possibly empty) set of alphanumeric
2482 characters, each character listing a set of operations which is being
2483 controlled. Letters are reserved for ``standard'' rights, listed
2484 below. Digits are reserved for implementation or site defined rights.
2486 l - lookup (mailbox is visible to LIST/LSUB commands)
2487 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2488 SEARCH, COPY from mailbox)
2489 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2490 w - write (STORE flags other than \\SEEN and \\DELETED)
2491 i - insert (perform APPEND, COPY into mailbox)
2492 p - post (send mail to submission address for mailbox,
2493 not enforced by IMAP4 itself)
2494 c - create and delete mailbox (CREATE new sub-mailboxes in any
2495 implementation-defined hierarchy, RENAME or DELETE mailbox)
2496 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2497 a - administer (perform SETACL)" group)
2500 ,mailbox ',method ',acl form)))))
2502 ;; Group sorting commands
2503 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2505 (defun gnus-group-sort-groups (func &optional reverse)
2506 "Sort the group buffer according to FUNC.
2507 When used interactively, the sorting function used will be
2508 determined by the `gnus-group-sort-function' variable.
2509 If REVERSE (the prefix), reverse the sorting order."
2510 (interactive (list gnus-group-sort-function current-prefix-arg))
2511 (funcall gnus-group-sort-alist-function
2512 (gnus-make-sort-function func) reverse)
2513 (gnus-group-list-groups)
2514 (gnus-dribble-touch))
2516 (defun gnus-group-sort-flat (func reverse)
2517 ;; We peel off the dummy group from the alist.
2519 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2520 (pop gnus-newsrc-alist))
2522 (setq gnus-newsrc-alist
2523 (sort gnus-newsrc-alist func))
2525 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2526 ;; Regenerate the hash table.
2527 (gnus-make-hashtable-from-newsrc-alist)))
2529 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2530 "Sort the group buffer alphabetically by group name.
2531 If REVERSE, sort in reverse order."
2533 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2535 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2536 "Sort the group buffer by number of unread articles.
2537 If REVERSE, sort in reverse order."
2539 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2541 (defun gnus-group-sort-groups-by-level (&optional reverse)
2542 "Sort the group buffer by group level.
2543 If REVERSE, sort in reverse order."
2545 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2547 (defun gnus-group-sort-groups-by-score (&optional reverse)
2548 "Sort the group buffer by group score.
2549 If REVERSE, sort in reverse order."
2551 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2553 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2554 "Sort the group buffer by group rank.
2555 If REVERSE, sort in reverse order."
2557 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2559 (defun gnus-group-sort-groups-by-method (&optional reverse)
2560 "Sort the group buffer alphabetically by backend name.
2561 If REVERSE, sort in reverse order."
2563 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2565 ;;; Selected group sorting.
2567 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2568 "Sort the process/prefixed groups."
2569 (interactive (list current-prefix-arg gnus-group-sort-function))
2570 (let ((groups (gnus-group-process-prefix n)))
2571 (funcall gnus-group-sort-selected-function
2572 groups (gnus-make-sort-function func) reverse)
2573 (gnus-group-list-groups)))
2575 (defun gnus-group-sort-selected-flat (groups func reverse)
2576 (let (entries infos)
2577 ;; First find all the group entries for these groups.
2579 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2581 ;; Then sort the infos.
2585 (lambda (entry) (car entry))
2586 (setq entries (nreverse entries)))
2589 (setq infos (nreverse infos)))
2590 ;; Go through all the infos and replace the old entries
2591 ;; with the new infos.
2593 (setcar (car entries) (pop infos))
2595 ;; Update the hashtable.
2596 (gnus-make-hashtable-from-newsrc-alist)))
2598 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2599 "Sort the group buffer alphabetically by group name.
2600 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2601 sort in reverse order."
2602 (interactive (gnus-interactive "P\ny"))
2603 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2605 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2606 "Sort the group buffer by number of unread articles.
2607 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2608 sort in reverse order."
2609 (interactive (gnus-interactive "P\ny"))
2610 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2612 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2613 "Sort the group buffer by group level.
2614 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2615 sort in reverse order."
2616 (interactive (gnus-interactive "P\ny"))
2617 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2619 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2620 "Sort the group buffer by group score.
2621 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2622 sort in reverse order."
2623 (interactive (gnus-interactive "P\ny"))
2624 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2626 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2627 "Sort the group buffer by group rank.
2628 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2629 sort in reverse order."
2630 (interactive (gnus-interactive "P\ny"))
2631 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2633 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2634 "Sort the group buffer alphabetically by backend name.
2635 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2636 sort in reverse order."
2637 (interactive (gnus-interactive "P\ny"))
2638 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2640 ;;; Sorting predicates.
2642 (defun gnus-group-sort-by-alphabet (info1 info2)
2643 "Sort alphabetically."
2644 (string< (gnus-info-group info1) (gnus-info-group info2)))
2646 (defun gnus-group-sort-by-real-name (info1 info2)
2647 "Sort alphabetically on real (unprefixed) names."
2648 (string< (gnus-group-real-name (gnus-info-group info1))
2649 (gnus-group-real-name (gnus-info-group info2))))
2651 (defun gnus-group-sort-by-unread (info1 info2)
2652 "Sort by number of unread articles."
2653 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2654 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2655 (< (or (and (numberp n1) n1) 0)
2656 (or (and (numberp n2) n2) 0))))
2658 (defun gnus-group-sort-by-level (info1 info2)
2660 (< (gnus-info-level info1) (gnus-info-level info2)))
2662 (defun gnus-group-sort-by-method (info1 info2)
2663 "Sort alphabetically by backend name."
2664 (string< (symbol-name (car (gnus-find-method-for-group
2665 (gnus-info-group info1) info1)))
2666 (symbol-name (car (gnus-find-method-for-group
2667 (gnus-info-group info2) info2)))))
2669 (defun gnus-group-sort-by-score (info1 info2)
2670 "Sort by group score."
2671 (< (gnus-info-score info1) (gnus-info-score info2)))
2673 (defun gnus-group-sort-by-rank (info1 info2)
2674 "Sort by level and score."
2675 (let ((level1 (gnus-info-level info1))
2676 (level2 (gnus-info-level info2)))
2677 (or (< level1 level2)
2678 (and (= level1 level2)
2679 (> (gnus-info-score info1) (gnus-info-score info2))))))
2683 (defun gnus-group-clear-data (&optional arg)
2684 "Clear all marks and read ranges from the current group."
2686 (gnus-group-iterate arg
2689 (gnus-info-clear-data (setq info (gnus-get-info group)))
2690 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2691 (when (gnus-group-goto-group group)
2692 (gnus-group-update-group-line))))))
2694 (defun gnus-group-clear-data-on-native-groups ()
2695 "Clear all marks and read ranges from all native groups."
2697 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2698 (let ((alist (cdr gnus-newsrc-alist))
2700 (while (setq info (pop alist))
2701 (when (gnus-group-native-p (gnus-info-group info))
2702 (gnus-info-clear-data info)))
2703 (gnus-get-unread-articles)
2704 (gnus-dribble-touch)
2705 (when (gnus-y-or-n-p
2706 "Move the cache away to avoid problems in the future? ")
2707 (call-interactively 'gnus-cache-move-cache)))))
2709 (defun gnus-info-clear-data (info)
2710 "Clear all marks and read ranges from INFO."
2711 (let ((group (gnus-info-group info)))
2714 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2715 (gnus-info-set-read ',info ',(gnus-info-read info))
2716 (when (gnus-group-goto-group ,group)
2717 (gnus-group-update-group-line))))
2718 (gnus-info-set-read info nil)
2719 (when (gnus-info-marks info)
2720 (gnus-info-set-marks info nil))))
2722 ;; Group catching up.
2724 (defun gnus-group-catchup-current (&optional n all)
2725 "Mark all unread articles in the current newsgroup as read.
2726 If prefix argument N is numeric, the next N newsgroups will be
2727 caught up. If ALL is non-nil, marked articles will also be marked as
2728 read. Cross references (Xref: header) of articles are ignored.
2729 The number of newsgroups that this function was unable to catch
2732 (let ((groups (gnus-group-process-prefix n))
2735 (unless groups (error "No groups selected"))
2737 (or (not gnus-interactive-catchup) ;Without confirmation?
2742 "Do you really want to mark all articles in %s as read? "
2743 "Mark all unread articles in %s as read? ")
2744 (if (= (length groups) 1)
2746 (format "these %d groups" (length groups)))))))
2748 (while (setq group (pop groups))
2749 (gnus-group-remove-mark group)
2750 ;; Virtual groups have to be given special treatment.
2751 (let ((method (gnus-find-method-for-group group)))
2752 (when (eq 'nnvirtual (car method))
2753 (nnvirtual-catchup-group
2754 (gnus-group-real-name group) (nth 1 method) all)))
2755 (if (>= (gnus-group-level group) gnus-level-zombie)
2756 (gnus-message 2 "Dead groups can't be caught up")
2758 (gnus-group-goto-group group)
2759 (gnus-group-catchup group all))
2760 (gnus-group-update-group-line)
2761 (setq ret (1+ ret)))))
2762 (gnus-group-next-unread-group 1)
2765 (defun gnus-group-catchup-current-all (&optional n)
2766 "Mark all articles in current newsgroup as read.
2767 Cross references (Xref: header) of articles are ignored."
2769 (gnus-group-catchup-current n 'all))
2771 (defun gnus-group-catchup (group &optional all)
2772 "Mark all articles in GROUP as read.
2773 If ALL is non-nil, all articles are marked as read.
2774 The return value is the number of articles that were marked as read,
2775 or nil if no action could be taken."
2776 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2778 ;; Remove entries for this group.
2779 (nnmail-purge-split-history (gnus-group-real-name group))
2780 ;; Do the updating only if the newsgroup isn't killed.
2781 (if (not (numberp (car entry)))
2782 (gnus-message 1 "Can't catch up %s; non-active group" group)
2783 ;; Do auto-expirable marks if that's required.
2784 (when (gnus-group-auto-expirable-p group)
2785 (gnus-add-marked-articles
2786 group 'expire (gnus-list-of-unread-articles group))
2788 (let ((marks (nth 3 (nth 2 entry))))
2789 (gnus-add-marked-articles
2790 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2791 (gnus-add-marked-articles
2792 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2794 (gnus-update-read-articles group nil)
2795 ;; Also nix out the lists of marks and dormants.
2797 (gnus-add-marked-articles group 'tick nil nil 'force)
2798 (gnus-add-marked-articles group 'dormant nil nil 'force))
2799 (let ((gnus-newsgroup-name group))
2800 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2803 (defun gnus-group-expire-articles (&optional n)
2804 "Expire all expirable articles in the current newsgroup."
2806 (let ((groups (gnus-group-process-prefix n))
2809 (error "No groups to expire"))
2810 (while (setq group (pop groups))
2811 (gnus-group-remove-mark group)
2812 (gnus-group-expire-articles-1 group)
2813 (gnus-dribble-touch)
2814 (gnus-group-position-point))))
2816 (defun gnus-group-expire-articles-1 (group)
2817 (when (gnus-check-backend-function 'request-expire-articles group)
2818 (gnus-message 6 "Expiring articles in %s..." group)
2819 (let* ((info (gnus-get-info group))
2820 (expirable (if (gnus-group-total-expirable-p group)
2821 (cons nil (gnus-list-of-read-articles group))
2822 (assq 'expire (gnus-info-marks info))))
2823 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2824 (nnmail-expiry-target
2825 (or (gnus-group-find-parameter group 'expiry-target)
2826 nnmail-expiry-target)))
2828 (gnus-check-group group)
2831 (gnus-compress-sequence
2833 ;; We set the expiry variables to the group
2835 (let ((nnmail-expiry-wait-function nil)
2836 (nnmail-expiry-wait expiry-wait))
2837 (gnus-request-expire-articles
2838 (gnus-uncompress-sequence (cdr expirable)) group))
2839 ;; Just expire using the normal expiry values.
2840 (gnus-request-expire-articles
2841 (gnus-uncompress-sequence (cdr expirable)) group))))
2842 (gnus-close-group group))
2843 (gnus-message 6 "Expiring articles in %s...done" group)
2844 ;; Return the list of un-expired articles.
2847 (defun gnus-group-expire-all-groups ()
2848 "Expire all expirable articles in all newsgroups."
2851 (gnus-message 5 "Expiring...")
2852 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2853 (cdr gnus-newsrc-alist))))
2854 (gnus-group-expire-articles nil)))
2855 (gnus-group-position-point)
2856 (gnus-message 5 "Expiring...done"))
2858 (defun gnus-group-set-current-level (n level)
2859 "Set the level of the next N groups to LEVEL."
2864 (let ((s (read-string
2865 (format "Level (default %s): "
2866 (or (gnus-group-group-level)
2867 gnus-level-default-subscribed)))))
2868 (if (string-match "^\\s-*$" s)
2869 (int-to-string (or (gnus-group-group-level)
2870 gnus-level-default-subscribed))
2872 (unless (and (>= level 1) (<= level gnus-level-killed))
2873 (error "Invalid level: %d" level))
2874 (let ((groups (gnus-group-process-prefix n))
2876 (while (setq group (pop groups))
2877 (gnus-group-remove-mark group)
2878 (gnus-message 6 "Changed level of %s from %d to %d"
2879 group (or (gnus-group-group-level) gnus-level-killed)
2881 (gnus-group-change-level
2882 group level (or (gnus-group-group-level) gnus-level-killed))
2883 (gnus-group-update-group-line)))
2884 (gnus-group-position-point))
2886 (defun gnus-group-unsubscribe (&optional n)
2887 "Unsubscribe the current group."
2889 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2891 (defun gnus-group-subscribe (&optional n)
2892 "Subscribe the current group."
2894 (gnus-group-unsubscribe-current-group n 'subscribe))
2896 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2897 "Toggle subscription of the current group.
2898 If given numerical prefix, toggle the N next groups."
2900 (let ((groups (gnus-group-process-prefix n))
2903 (setq group (car groups)
2904 groups (cdr groups))
2905 (gnus-group-remove-mark group)
2906 (gnus-group-unsubscribe-group
2909 ((eq do-sub 'unsubscribe)
2910 gnus-level-default-unsubscribed)
2911 ((eq do-sub 'subscribe)
2912 gnus-level-default-subscribed)
2913 ((<= (gnus-group-group-level) gnus-level-subscribed)
2914 gnus-level-default-unsubscribed)
2916 gnus-level-default-subscribed))
2918 (gnus-group-update-group-line))
2919 (gnus-group-next-group 1)))
2921 (defun gnus-group-unsubscribe-group (group &optional level silent)
2922 "Toggle subscription to GROUP.
2923 Killed newsgroups are subscribed. If SILENT, don't try to update the
2926 (list (completing-read
2927 "Group: " gnus-active-hashtb nil
2928 (gnus-read-active-file-p)
2930 'gnus-group-history)))
2931 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2933 ((string-match "^[ \t]*$" group)
2934 (error "Empty group name"))
2936 ;; Toggle subscription flag.
2937 (gnus-group-change-level
2938 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2939 gnus-level-subscribed)
2940 (1+ gnus-level-subscribed)
2941 gnus-level-default-subscribed)))
2943 (gnus-group-update-group group)))
2944 ((and (stringp group)
2945 (or (not (gnus-read-active-file-p))
2946 (gnus-active group)))
2947 ;; Add new newsgroup.
2948 (gnus-group-change-level
2950 (if level level gnus-level-default-subscribed)
2951 (or (and (member group gnus-zombie-list)
2954 (when (gnus-group-group-name)
2955 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2957 (gnus-group-update-group group)))
2958 (t (error "No such newsgroup: %s" group)))
2959 (gnus-group-position-point)))
2961 (defun gnus-group-transpose-groups (n)
2962 "Move the current newsgroup up N places.
2963 If given a negative prefix, move down instead. The difference between
2964 N and the number of steps taken is returned."
2966 (unless (gnus-group-group-name)
2967 (error "No group on current line"))
2968 (gnus-group-kill-group 1)
2970 (forward-line (- n))
2971 (gnus-group-yank-group)
2972 (gnus-group-position-point)))
2974 (defun gnus-group-kill-all-zombies (&optional dummy)
2975 "Kill all zombie newsgroups.
2976 The optional DUMMY should always be nil."
2977 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
2979 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2980 (setq gnus-zombie-list nil)
2981 (gnus-dribble-touch)
2982 (gnus-group-list-groups)))
2984 (defun gnus-group-kill-region (begin end)
2985 "Kill newsgroups in current region (excluding current point).
2986 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3001 (beginning-of-line) ;Important when LINES < 1
3002 (gnus-group-kill-group lines)))
3004 (defun gnus-group-kill-group (&optional n discard)
3005 "Kill the next N groups.
3006 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3007 However, only groups that were alive can be yanked; already killed
3008 groups or zombie groups can't be yanked.
3009 The return value is the name of the group that was killed, or a list
3012 (let ((buffer-read-only nil)
3013 (groups (gnus-group-process-prefix n))
3014 group entry level out)
3015 (if (< (length groups) 10)
3016 ;; This is faster when there are few groups.
3018 (push (setq group (pop groups)) out)
3019 (gnus-group-remove-mark group)
3020 (setq level (gnus-group-group-level))
3022 (when (and (not discard)
3023 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3026 (gnus-group-goto-group ,(gnus-group-group-name))
3027 (gnus-group-yank-group)))
3028 (push (cons (car entry) (nth 2 entry))
3029 gnus-list-of-killed-groups))
3030 (gnus-group-change-level
3031 (if entry entry group) gnus-level-killed (if entry nil level))
3032 (message "Killed group %s" group))
3033 ;; If there are lots and lots of groups to be killed, we use
3034 ;; this thing instead.
3036 (setq groups (nreverse groups))
3038 (gnus-group-remove-mark (setq group (pop groups)))
3040 (push group gnus-killed-list)
3041 (setq gnus-newsrc-alist
3042 (delq (assoc group gnus-newsrc-alist)
3044 (when gnus-group-change-level-function
3045 (funcall gnus-group-change-level-function
3046 group gnus-level-killed 3))
3048 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3049 (push (cons (car entry) (nth 2 entry))
3050 gnus-list-of-killed-groups)
3051 (setcdr (cdr entry) (cdddr entry)))
3052 ((member group gnus-zombie-list)
3053 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3054 ;; There may be more than one instance displayed.
3055 (while (gnus-group-goto-group group)
3056 (gnus-delete-line)))
3057 (gnus-make-hashtable-from-newsrc-alist)))
3059 (gnus-group-position-point)
3060 (if (< (length out) 2) (car out) (nreverse out))))
3062 (defun gnus-group-yank-group (&optional arg)
3063 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3064 The numeric ARG specifies how many newsgroups are to be yanked. The
3065 name of the newsgroup yanked is returned, or (if several groups are
3066 yanked) a list of yanked groups is returned."
3068 (setq arg (or arg 1))
3069 (let (info group prev out)
3070 (while (>= (decf arg) 0)
3071 (when (not (setq info (pop gnus-list-of-killed-groups)))
3072 (error "No more newsgroups to yank"))
3073 (push (setq group (nth 1 info)) out)
3074 ;; Find which newsgroup to insert this one before - search
3075 ;; backward until something suitable is found. If there are no
3076 ;; other newsgroups in this buffer, just make this newsgroup the
3078 (setq prev (gnus-group-group-name))
3079 (gnus-group-change-level
3080 info (gnus-info-level (cdr info)) gnus-level-killed
3081 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3083 (gnus-group-insert-group-line-info group)
3085 `(when (gnus-group-goto-group ,group)
3086 (gnus-group-kill-group 1))))
3088 (gnus-group-position-point)
3089 (if (< (length out) 2) (car out) (nreverse out))))
3091 (defun gnus-group-kill-level (level)
3092 "Kill all groups that is on a certain LEVEL."
3093 (interactive "nKill all groups on level: ")
3095 ((= level gnus-level-zombie)
3096 (setq gnus-killed-list
3097 (nconc gnus-zombie-list gnus-killed-list))
3098 (setq gnus-zombie-list nil))
3099 ((and (< level gnus-level-zombie)
3101 (or gnus-expert-user
3104 "Do you really want to kill all groups on level %d? "
3106 (let* ((prev gnus-newsrc-alist)
3109 (if (= (gnus-info-level (car alist)) level)
3111 (push (gnus-info-group (car alist)) gnus-killed-list)
3112 (setcdr prev (cdr alist)))
3114 (setq alist (cdr alist)))
3115 (gnus-make-hashtable-from-newsrc-alist)
3116 (gnus-group-list-groups)))
3118 (error "Can't kill; invalid level: %d" level))))
3120 (defun gnus-group-list-all-groups (&optional arg)
3121 "List all newsgroups with level ARG or lower.
3122 Default is gnus-level-unsubscribed, which lists all subscribed and most
3123 unsubscribed groups."
3125 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3127 ;; Redefine this to list ALL killed groups if prefix arg used.
3128 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3129 (defun gnus-group-list-killed (&optional arg)
3130 "List all killed newsgroups in the group buffer.
3131 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3132 entail asking the server for the groups."
3134 ;; Find all possible killed newsgroups if arg.
3136 (gnus-get-killed-groups))
3137 (if (not gnus-killed-list)
3138 (gnus-message 6 "No killed groups")
3139 (let (gnus-group-list-mode)
3140 (funcall gnus-group-prepare-function
3141 gnus-level-killed t gnus-level-killed))
3142 (goto-char (point-min)))
3143 (gnus-group-position-point))
3145 (defun gnus-group-list-zombies ()
3146 "List all zombie newsgroups in the group buffer."
3148 (if (not gnus-zombie-list)
3149 (gnus-message 6 "No zombie groups")
3150 (let (gnus-group-list-mode)
3151 (funcall gnus-group-prepare-function
3152 gnus-level-zombie t gnus-level-zombie))
3153 (goto-char (point-min)))
3154 (gnus-group-position-point))
3156 (defun gnus-group-list-active ()
3157 "List all groups that are available from the server(s)."
3159 ;; First we make sure that we have really read the active file.
3160 (unless (gnus-read-active-file-p)
3161 (let ((gnus-read-active-file t)
3162 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3163 (gnus-read-active-file)))
3164 ;; Find all groups and sort them.
3172 (push (symbol-name sym) list)))
3176 (buffer-read-only nil)
3180 (setq group (pop groups))
3181 (gnus-add-text-properties
3182 (point) (prog1 (1+ (point))
3184 (gnus-group-name-decode group
3185 (gnus-group-name-charset
3188 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3190 'gnus-level (inline (gnus-group-level group)))))
3191 (goto-char (point-min))))
3193 (defun gnus-activate-all-groups (level)
3194 "Activate absolutely all groups."
3195 (interactive (list gnus-level-unsubscribed))
3196 (let ((gnus-activate-level level)
3197 (gnus-activate-foreign-newsgroups level))
3198 (gnus-group-get-new-news)))
3200 (defun gnus-group-get-new-news (&optional arg)
3201 "Get newly arrived articles.
3202 If ARG is a number, it specifies which levels you are interested in
3203 re-scanning. If ARG is non-nil and not a number, this will force
3204 \"hard\" re-reading of the active files from all servers."
3207 (let ((gnus-inhibit-demon t)
3208 ;; Binding this variable will inhibit multiple fetchings
3209 ;; of the same mail source.
3210 (nnmail-fetched-sources (list t)))
3211 (gnus-run-hooks 'gnus-get-new-news-hook)
3213 ;; Read any slave files.
3215 (gnus-master-read-slave-newsrc))
3217 ;; We might read in new NoCeM messages here.
3218 (when (and gnus-use-nocem
3220 (gnus-nocem-scan-groups))
3221 ;; If ARG is not a number, then we read the active file.
3222 (when (and arg (not (numberp arg)))
3223 (let ((gnus-read-active-file t))
3224 (gnus-read-active-file))
3227 ;; If the user wants it, we scan for new groups.
3228 (when (eq gnus-check-new-newsgroups 'always)
3229 (gnus-find-new-newsgroups)))
3231 (setq arg (gnus-group-default-level arg t))
3232 (if (and gnus-read-active-file (not arg))
3234 (gnus-read-active-file)
3235 (gnus-get-unread-articles arg))
3236 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3237 (gnus-get-unread-articles arg)))
3238 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3239 (gnus-group-list-groups (and (numberp arg)
3240 (max (car gnus-group-list-mode) arg))))
3242 (when (and gnus-agent (not (interactive-p)))
3243 (gnus-agent-toggle-plugged gnus-plugged)))
3245 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3246 "Check for newly arrived news in the current group (and the N-1 next groups).
3247 The difference between N and the number of newsgroup checked is returned.
3248 If N is negative, this group and the N-1 previous groups will be checked."
3250 (let* ((groups (gnus-group-process-prefix n))
3251 (ret (if (numberp n) (- n (length groups)) 0))
3255 (gnus-inhibit-demon t)
3256 ;; Binding this variable will inhibit multiple fetchings
3257 ;; of the same mail source.
3258 (nnmail-fetched-sources (list t)))
3259 (gnus-run-hooks 'gnus-get-new-news-hook)
3260 (while (setq group (pop groups))
3261 (gnus-group-remove-mark group)
3262 ;; Bypass any previous denials from the server.
3263 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3264 (if (gnus-activate-group group (if dont-scan nil 'scan))
3266 (gnus-get-unread-articles-in-group
3267 (gnus-get-info group) (gnus-active group) t)
3268 (unless (gnus-virtual-group-p group)
3269 (gnus-close-group group))
3271 (gnus-agent-save-group-info
3272 method (gnus-group-real-name group) (gnus-active group)))
3273 (gnus-group-update-group group))
3274 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3276 (gnus-error 3 "Server denied access")
3277 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3280 (when gnus-goto-next-group-when-activating
3281 (gnus-group-next-unread-group 1 t))
3282 (gnus-summary-position-point)
3285 (defun gnus-group-fetch-faq (group &optional faq-dir)
3286 "Fetch the FAQ for the current group.
3287 If given a prefix argument, prompt for the FAQ dir
3291 (gnus-group-group-name)
3292 (when current-prefix-arg
3294 "Faq dir: " (and (listp gnus-group-faq-directory)
3296 gnus-group-faq-directory))))))
3298 (error "No group name given"))
3299 (let ((dirs (or faq-dir gnus-group-faq-directory))
3301 (unless (listp dirs)
3302 (setq dirs (list dirs)))
3303 (while (and (not found)
3304 (setq dir (pop dirs)))
3305 (let ((name (gnus-group-real-name group)))
3306 (setq file (expand-file-name name dir)))
3307 (if (not (file-exists-p file))
3308 (gnus-message 1 "No such file: %s" file)
3309 (let ((enable-local-variables nil))
3313 (defun gnus-group-describe-group (force &optional group)
3314 "Display a description of the current newsgroup."
3315 (interactive (list current-prefix-arg (gnus-group-group-name)))
3316 (let* ((method (gnus-find-method-for-group group))
3317 (mname (gnus-group-prefixed-name "" method))
3320 gnus-description-hashtb)
3321 (gnus-sethash mname nil gnus-description-hashtb))
3323 (error "No group name given"))
3324 (when (or (and gnus-description-hashtb
3325 ;; We check whether this group's method has been
3326 ;; queried for a description file.
3327 (gnus-gethash mname gnus-description-hashtb))
3328 (setq desc (gnus-group-get-description group))
3329 (gnus-read-descriptions-file method))
3331 (or desc (gnus-gethash group gnus-description-hashtb)
3332 "No description available")))))
3334 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3335 (defun gnus-group-describe-all-groups (&optional force)
3336 "Pop up a buffer with descriptions of all newsgroups."
3339 (setq gnus-description-hashtb nil))
3340 (when (not (or gnus-description-hashtb
3341 (gnus-read-all-descriptions-files)))
3342 (error "Couldn't request descriptions file"))
3343 (let ((buffer-read-only nil)
3349 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3350 (insert (format " *: %-20s %s\n"
3351 (gnus-group-name-decode
3352 (symbol-name group) charset)
3353 (gnus-group-name-decode
3354 (symbol-value group) charset))))
3355 (gnus-add-text-properties
3356 b (1+ b) (list 'gnus-group group
3357 'gnus-unread t 'gnus-marked nil
3358 'gnus-level (1+ gnus-level-subscribed))))
3359 gnus-description-hashtb)
3360 (goto-char (point-min))
3361 (gnus-group-position-point)))
3363 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3364 (defun gnus-group-apropos (regexp &optional search-description)
3365 "List all newsgroups that have names that match a regexp."
3366 (interactive "sGnus apropos (regexp): ")
3368 (obuf (current-buffer))
3370 ;; Go through all newsgroups that are known to Gnus.
3373 (and (symbol-name group)
3374 (string-match regexp (symbol-name group))
3375 (symbol-value group)
3376 (push (symbol-name group) groups)))
3378 ;; Also go through all descriptions that are known to Gnus.
3379 (when search-description
3382 (and (string-match regexp (symbol-value group))
3383 (push (symbol-name group) groups)))
3384 gnus-description-hashtb))
3386 (gnus-message 3 "No groups matched \"%s\"." regexp)
3387 ;; Print out all the groups.
3389 (pop-to-buffer "*Gnus Help*")
3390 (buffer-disable-undo)
3392 (setq groups (sort groups 'string<))
3394 ;; Groups may be entered twice into the list of groups.
3395 (when (not (string= (car groups) prev))
3396 (setq prev (car groups))
3397 (let ((charset (gnus-group-name-charset nil prev)))
3398 (insert (gnus-group-name-decode prev charset) "\n")
3399 (when (and gnus-description-hashtb
3400 (setq des (gnus-gethash (car groups)
3401 gnus-description-hashtb)))
3402 (insert " " (gnus-group-name-decode des charset) "\n"))))
3403 (setq groups (cdr groups)))
3404 (goto-char (point-min))))
3405 (pop-to-buffer obuf)))
3407 (defun gnus-group-description-apropos (regexp)
3408 "List all newsgroups that have names or descriptions that match a regexp."
3409 (interactive "sGnus description apropos (regexp): ")
3410 (when (not (or gnus-description-hashtb
3411 (gnus-read-all-descriptions-files)))
3412 (error "Couldn't request descriptions file"))
3413 (gnus-group-apropos regexp t))
3415 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3416 (defun gnus-group-list-matching (level regexp &optional all lowest)
3417 "List all groups with unread articles that match REGEXP.
3418 If the prefix LEVEL is non-nil, it should be a number that says which
3419 level to cut off listing groups.
3420 If ALL, also list groups with no unread articles.
3421 If LOWEST, don't list groups with level lower than LOWEST.
3423 This command may read the active file."
3424 (interactive "P\nsList newsgroups matching: ")
3425 ;; First make sure active file has been read.
3427 (> (prefix-numeric-value level) gnus-level-killed))
3428 (gnus-get-killed-groups))
3429 (gnus-group-prepare-flat
3430 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3431 (goto-char (point-min))
3432 (gnus-group-position-point))
3434 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3435 "List all groups that match REGEXP.
3436 If the prefix LEVEL is non-nil, it should be a number that says which
3437 level to cut off listing groups.
3438 If LOWEST, don't list groups with level lower than LOWEST."
3439 (interactive "P\nsList newsgroups matching: ")
3441 (setq level (prefix-numeric-value level)))
3442 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3444 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3445 (defun gnus-group-save-newsrc (&optional force)
3446 "Save the Gnus startup files.
3447 If FORCE, force saving whether it is necessary or not."
3449 (gnus-save-newsrc-file force))
3451 (defun gnus-group-restart (&optional arg)
3452 "Force Gnus to read the .newsrc file."
3454 (when (gnus-yes-or-no-p
3455 (format "Are you sure you want to restart Gnus? "))
3456 (gnus-save-newsrc-file)
3460 (defun gnus-group-read-init-file ()
3461 "Read the Gnus elisp init file."
3463 (gnus-read-init-file)
3464 (gnus-message 5 "Read %s" gnus-init-file))
3466 (defun gnus-group-check-bogus-groups (&optional silent)
3467 "Check bogus newsgroups.
3468 If given a prefix, don't ask for confirmation before removing a bogus
3471 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3472 (gnus-group-list-groups))
3474 (defun gnus-group-find-new-groups (&optional arg)
3475 "Search for new groups and add them.
3476 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3477 With 1 C-u, use the `ask-server' method to query the server for new
3479 With 2 C-u's, use most complete method possible to query the server
3480 for new groups, and subscribe the new groups as zombies."
3482 (gnus-find-new-newsgroups (or arg 1))
3483 (gnus-group-list-groups))
3485 (defun gnus-group-edit-global-kill (&optional article group)
3486 "Edit the global kill file.
3487 If GROUP, edit that local kill file instead."
3489 (setq gnus-current-kill-article article)
3490 (gnus-kill-file-edit-file group)
3493 (substitute-command-keys
3494 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3495 (if group "local" "global")))))
3497 (defun gnus-group-edit-local-kill (article group)
3498 "Edit a local kill file."
3499 (interactive (list nil (gnus-group-group-name)))
3500 (gnus-group-edit-global-kill article group))
3502 (defun gnus-group-force-update ()
3503 "Update `.newsrc' file."
3505 (gnus-save-newsrc-file))
3507 (defun gnus-group-suspend ()
3508 "Suspend the current Gnus session.
3509 In fact, cleanup buffers except for group mode buffer.
3510 The hook gnus-suspend-gnus-hook is called before actually suspending."
3512 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3513 ;; Kill Gnus buffers except for group mode buffer.
3514 (let ((group-buf (get-buffer gnus-group-buffer)))
3515 (mapcar (lambda (buf)
3516 (unless (member buf (list group-buf gnus-dribble-buffer))
3519 (gnus-kill-gnus-frames)
3521 (bury-buffer group-buf)
3522 (delete-windows-on group-buf t))))
3524 (defun gnus-group-clear-dribble ()
3525 "Clear all information from the dribble buffer."
3527 (gnus-dribble-clear)
3528 (gnus-message 7 "Cleared dribble buffer"))
3530 (defun gnus-group-exit ()
3531 "Quit reading news after updating .newsrc.eld and .newsrc.
3532 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3535 (or noninteractive ;For gnus-batch-kill
3536 (not gnus-interactive-exit) ;Without confirmation
3538 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3539 (gnus-run-hooks 'gnus-exit-gnus-hook)
3540 ;; Offer to save data from non-quitted summary buffers.
3541 (gnus-offer-save-summaries)
3542 ;; Save the newsrc file(s).
3543 (gnus-save-newsrc-file)
3545 (gnus-close-backends)
3546 ;; Reset everything.
3548 ;; Allow the user to do things after cleaning up.
3549 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3551 (defun gnus-group-quit ()
3552 "Quit reading news without updating .newsrc.eld or .newsrc.
3553 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3555 (when (or noninteractive ;For gnus-batch-kill
3556 (zerop (buffer-size))
3557 (not (gnus-server-opened gnus-select-method))
3559 (not gnus-current-startup-file)
3561 (format "Quit reading news without saving %s? "
3562 (file-name-nondirectory gnus-current-startup-file))))
3563 (gnus-run-hooks 'gnus-exit-gnus-hook)
3564 (gnus-configure-windows 'group t)
3566 (gnus-close-backends)
3568 (gnus-kill-buffer gnus-group-buffer)
3569 ;; Allow the user to do things after cleaning up.
3570 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3572 (defun gnus-group-describe-briefly ()
3573 "Give a one line description of the group mode commands."
3575 (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")))
3577 (defun gnus-group-browse-foreign-server (method)
3578 "Browse a foreign news server.
3579 If called interactively, this function will ask for a select method
3580 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3581 If not, METHOD should be a list where the first element is the method
3582 and the second element is the address."
3584 (list (let ((how (completing-read
3586 (append gnus-valid-select-methods gnus-server-alist)
3587 nil t (cons "nntp" 0) 'gnus-method-history)))
3588 ;; We either got a backend name or a virtual server name.
3589 ;; If the first, we also need an address.
3590 (if (assoc how gnus-valid-select-methods)
3592 ;; Suggested by mapjph@bath.ac.uk.
3595 (mapcar (lambda (server) (list server))
3596 gnus-secondary-servers)))
3597 ;; We got a server name.
3599 (gnus-browse-foreign-server method))
3601 (defun gnus-group-set-info (info &optional method-only-group part)
3602 (when (or info part)
3603 (let* ((entry (gnus-gethash
3604 (or method-only-group (gnus-info-group info))
3605 gnus-newsrc-hashtb))
3607 (info (if method-only-group (nth 2 entry) info))
3609 (when method-only-group
3611 (error "Trying to change non-existent group %s" method-only-group))
3612 ;; We have received parts of the actual group info - either the
3613 ;; select method or the group parameters. We first check
3614 ;; whether we have to extend the info, and if so, do that.
3615 (let ((len (length info))
3616 (total (if (eq part 'method) 5 6)))
3618 (setcdr (nthcdr (1- len) info)
3619 (make-list (- total len) nil)))
3620 ;; Then we enter the new info.
3621 (setcar (nthcdr (1- total) info) part-info)))
3623 ;; This is a new group, so we just create it.
3625 (set-buffer gnus-group-buffer)
3626 (setq method (gnus-info-method info))
3627 (when (gnus-server-equal method "native")
3630 (set-buffer gnus-group-buffer)
3632 ;; It's a foreign group...
3633 (gnus-group-make-group
3634 (gnus-group-real-name (gnus-info-group info))
3635 (if (stringp method) method
3636 (prin1-to-string (car method)))
3638 (nth 1 (gnus-info-method info))))
3639 ;; It's a native group.
3640 (gnus-group-make-group (gnus-info-group info))))
3641 (gnus-message 6 "Note: New group created")
3643 (gnus-gethash (gnus-group-prefixed-name
3644 (gnus-group-real-name (gnus-info-group info))
3645 (or (gnus-info-method info) gnus-select-method))
3646 gnus-newsrc-hashtb))))
3647 ;; Whether it was a new group or not, we now have the entry, so we
3648 ;; can do the update.
3651 (setcar (nthcdr 2 entry) info)
3652 (when (and (not (eq (car entry) t))
3653 (gnus-active (gnus-info-group info)))
3654 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3655 (error "No such group: %s" (gnus-info-group info))))))
3657 (defun gnus-group-set-method-info (group select-method)
3658 (gnus-group-set-info select-method group 'method))
3660 (defun gnus-group-set-params-info (group params)
3661 (gnus-group-set-info params group 'params))
3663 (defun gnus-add-marked-articles (group type articles &optional info force)
3664 ;; Add ARTICLES of TYPE to the info of GROUP.
3665 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3666 ;; add, but replace marked articles of TYPE with ARTICLES.
3667 (let ((info (or info (gnus-get-info group)))
3670 (and (not (setq marked (nthcdr 3 info)))
3672 (setcdr (nthcdr 2 info)
3673 (list (list (cons type (gnus-compress-sequence
3675 (and (not (setq m (assq type (car marked))))
3678 (cons (cons type (gnus-compress-sequence articles t) )
3682 (setcar (nthcdr 3 info)
3683 (gnus-delete-alist type (car marked)))
3684 (setcdr m (gnus-compress-sequence articles t)))
3685 (setcdr m (gnus-compress-sequence
3686 (sort (nconc (gnus-uncompress-range (cdr m))
3687 (copy-sequence articles)) '<) t))))))
3690 ;;; Group timestamps
3693 (defun gnus-group-set-timestamp ()
3694 "Change the timestamp of the current group to the current time.
3695 This function can be used in hooks like `gnus-select-group-hook'
3696 or `gnus-group-catchup-group-hook'."
3697 (when gnus-newsgroup-name
3698 (let ((time (current-time)))
3699 (setcdr (cdr time) nil)
3700 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3702 (defsubst gnus-group-timestamp (group)
3703 "Return the timestamp for GROUP."
3704 (gnus-group-get-parameter group 'timestamp t))
3706 (defun gnus-group-timestamp-delta (group)
3707 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3708 (let* ((time (or (gnus-group-timestamp group)
3710 (delta (subtract-time (current-time) time)))
3711 (+ (* (nth 0 delta) 65536.0)
3714 (defun gnus-group-timestamp-string (group)
3715 "Return a string of the timestamp for GROUP."
3716 (let ((time (gnus-group-timestamp group)))
3719 (gnus-time-iso8601 time))))
3721 (defun gnus-group-prepare-flat-list-dead-predicate
3722 (groups level mark predicate)
3725 ;; This loop is used when listing groups that match some
3727 (while (setq group (pop groups))
3728 (when (funcall predicate group)
3729 (gnus-add-text-properties
3730 (point) (prog1 (1+ (point))
3731 (insert " " mark " *: "
3732 (gnus-group-name-decode group
3733 (gnus-group-name-charset
3736 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3738 'gnus-level level)))))))
3740 (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest
3742 "List all newsgroups with unread articles of level LEVEL or lower.
3743 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3744 If PREDICATE, only list groups which PREDICATE returns non-nil.
3745 If DEAD-PREDICATE, list dead groups which DEAD-PREDICATE returns non-nil."
3746 (set-buffer gnus-group-buffer)
3747 (let ((buffer-read-only nil)
3748 (newsrc (cdr gnus-newsrc-alist))
3749 (lowest (or lowest 1))
3750 info clevel unread group params)
3752 ;; List living groups.
3754 (setq info (car newsrc)
3755 group (gnus-info-group info)
3756 params (gnus-info-params info)
3758 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3759 (and unread ; This group might be unchecked
3760 (funcall predicate info)
3761 (<= (setq clevel (gnus-info-level info)) level)
3763 (gnus-group-insert-group-line
3764 group (gnus-info-level info)
3765 (gnus-info-marks info) unread (gnus-info-method info))))
3767 ;; List dead groups.
3768 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3769 (gnus-group-prepare-flat-list-dead-predicate
3770 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3771 gnus-level-zombie ?Z
3773 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3774 (gnus-group-prepare-flat-list-dead-predicate
3775 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3776 gnus-level-killed ?K dead-predicate))
3778 (gnus-group-set-mode-line)
3779 (setq gnus-group-list-mode (cons level t))
3780 (gnus-run-hooks 'gnus-group-prepare-hook)
3783 (defun gnus-group-list-cached (level &optional lowest)
3784 "List all groups with cached articles.
3785 If the prefix LEVEL is non-nil, it should be a number that says which
3786 level to cut off listing groups.
3787 If LOWEST, don't list groups with level lower than LOWEST.
3789 This command may read the active file."
3792 (setq level (prefix-numeric-value level)))
3793 (when (or (not level) (>= level gnus-level-zombie))
3795 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3797 (let ((marks (gnus-info-marks info)))
3798 (assq 'cache marks)))
3801 (or (gnus-gethash group
3802 gnus-cache-active-hashtb)
3803 ;; Cache active file might use "."
3806 (mapconcat 'identity
3807 (split-string group ":")
3809 gnus-cache-active-hashtb))))
3810 (goto-char (point-min))
3811 (gnus-group-position-point))
3813 (defun gnus-group-list-dormant (level &optional lowest)
3814 "List all groups with dormant articles.
3815 If the prefix LEVEL is non-nil, it should be a number that says which
3816 level to cut off listing groups.
3817 If LOWEST, don't list groups with level lower than LOWEST.
3819 This command may read the active file."
3822 (setq level (prefix-numeric-value level)))
3823 (when (or (not level) (>= level gnus-level-zombie))
3825 (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed)
3827 (let ((marks (gnus-info-marks info)))
3828 (assq 'dormant marks)))
3830 (goto-char (point-min))
3831 (gnus-group-position-point))
3833 (provide 'gnus-group)
3835 ;;; gnus-group.el ends here