1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (defcustom gnus-group-archive-directory
42 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
43 "*The address of the (ding) archives."
44 :group 'gnus-group-foreign
47 (defcustom gnus-group-recent-archive-directory
48 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
49 "*The address of the most recent (ding) articles."
50 :group 'gnus-group-foreign
53 (defcustom gnus-no-groups-message "No gnus is bad news"
54 "*Message displayed by Gnus when no groups are available."
58 (defcustom gnus-keep-same-level nil
59 "*Non-nil means that the next newsgroup after the current will be on the same level.
60 When you type, for instance, `n' after reading the last article in the
61 current newsgroup, you will go to the next newsgroup. If this variable
62 is nil, the next newsgroup will be the next from the group
64 If this variable is non-nil, Gnus will either put you in the
65 next newsgroup with the same level, or, if no such newsgroup is
66 available, the next newsgroup with the lowest possible level higher
67 than the current level.
68 If this variable is `best', Gnus will make the next newsgroup the one
70 :group 'gnus-group-levels
71 :type '(choice (const nil)
73 (sexp :tag "other" t)))
75 (defcustom gnus-group-goto-unread t
76 "*If non-nil, movement commands will go to the next unread and subscribed group."
77 :link '(custom-manual "(gnus)Group Maneuvering")
78 :group 'gnus-group-various
81 (defcustom gnus-goto-next-group-when-activating t
82 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
83 :link '(custom-manual "(gnus)Scanning New Messages")
84 :group 'gnus-group-various
87 (defcustom gnus-permanently-visible-groups nil
88 "*Regexp to match groups that should always be listed in the group buffer.
89 This means that they will still be listed even when there are no
90 unread articles in the groups.
92 If nil, no groups are permanently visible."
93 :group 'gnus-group-listing
94 :type '(choice regexp (const nil)))
96 (defcustom gnus-list-groups-with-ticked-articles t
97 "*If non-nil, list groups that have only ticked articles.
98 If nil, only list groups that have unread articles."
99 :group 'gnus-group-listing
102 (defcustom gnus-group-default-list-level gnus-level-subscribed
103 "*Default listing level.
104 Ignored if `gnus-group-use-permanent-levels' is non-nil."
105 :group 'gnus-group-listing
108 (defcustom gnus-group-list-inactive-groups t
109 "*If non-nil, inactive groups will be listed."
110 :group 'gnus-group-listing
111 :group 'gnus-group-levels
114 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
115 "*Function used for sorting the group buffer.
116 This function will be called with group info entries as the arguments
117 for the groups to be sorted. Pre-made functions include
118 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
119 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
120 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
121 `gnus-group-sort-by-rank'.
123 This variable can also be a list of sorting functions. In that case,
124 the most significant sort function should be the last function in the
126 :group 'gnus-group-listing
127 :link '(custom-manual "(gnus)Sorting Groups")
128 :type '(radio (function-item gnus-group-sort-by-alphabet)
129 (function-item gnus-group-sort-by-real-name)
130 (function-item gnus-group-sort-by-unread)
131 (function-item gnus-group-sort-by-level)
132 (function-item gnus-group-sort-by-score)
133 (function-item gnus-group-sort-by-method)
134 (function-item gnus-group-sort-by-rank)
135 (function :tag "other" nil)))
137 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
138 "*Format of group lines.
139 It works along the same lines as a normal formatting string,
140 with some simple extensions.
142 %M Only marked articles (character, \"*\" or \" \")
143 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
144 %L Level of subscribedness (integer)
145 %N Number of unread articles (integer)
146 %I Number of dormant articles (integer)
147 %i Number of ticked and dormant (integer)
148 %T Number of ticked articles (integer)
149 %R Number of read articles (integer)
150 %t Estimated total number of articles (integer)
151 %y Number of unread, unticked articles (integer)
152 %G Group name (string)
153 %g Qualified group name (string)
154 %D Group description (string)
155 %s Select method (string)
156 %o Moderated group (char, \"m\")
157 %p Process mark (char)
158 %O Moderated group (string, \"(m)\" or \"\")
159 %P Topic indentation (string)
160 %m Whether there is new(ish) mail in the group (char, \"%\")
161 %l Whether there are GroupLens predictions for this group (string)
162 %n Select from where (string)
163 %z A string that look like `<%s:%n>' if a foreign select method is used
164 %d The date the group was last entered.
165 %E Icon as defined by `gnus-group-icon-list'.
166 %u User defined specifier. The next character in the format string should
167 be a letter. Gnus will call the function gnus-user-format-function-X,
168 where X is the letter following %u. The function will be passed the
169 current header as argument. The function should return a string, which
170 will be inserted into the buffer just like information from any other
173 Text between %( and %) will be highlighted with `gnus-mouse-face' when
174 the mouse point move inside the area. There can only be one such area.
176 Note that this format specification is not always respected. For
177 reasons of efficiency, when listing killed groups, this specification
178 is ignored altogether. If the spec is changed considerably, your
179 output may end up looking strange when listing both alive and killed
182 If you use %o or %O, reading the active file will be slower and quite
183 a bit of extra memory will be used. %D will also worsen performance.
184 Also note that if you change the format specification to include any
185 of these specs, you must probably re-start Gnus to see them go into
187 :group 'gnus-group-visual
190 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
191 "*The format specification for the group mode line.
192 It works along the same lines as a normal formatting string,
193 with some simple extensions:
195 %S The native news server.
196 %M The native select method.
197 %: \":\" if %S isn't \"\"."
198 :group 'gnus-group-visual
201 (defcustom gnus-group-mode-hook nil
202 "Hook for Gnus group mode."
203 :group 'gnus-group-various
204 :options '(gnus-topic-mode)
207 (defcustom gnus-group-menu-hook nil
208 "Hook run after the creation of the group mode menu."
209 :group 'gnus-group-various
212 (defcustom gnus-group-catchup-group-hook nil
213 "Hook run when catching up a group from the group buffer."
214 :group 'gnus-group-various
215 :link '(custom-manual "(gnus)Group Data")
218 (defcustom gnus-group-update-group-hook nil
219 "Hook called when updating group lines."
220 :group 'gnus-group-visual
223 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
224 "*A function that is called to generate the group buffer.
225 The function is called with three arguments: The first is a number;
226 all group with a level less or equal to that number should be listed,
227 if the second is non-nil, empty groups should also be displayed. If
228 the third is non-nil, it is a number. No groups with a level lower
229 than this number should be displayed.
231 The only current function implemented is `gnus-group-prepare-flat'."
232 :group 'gnus-group-listing
235 (defcustom gnus-group-prepare-hook nil
236 "Hook called after the group buffer has been generated.
237 If you want to modify the group buffer, you can use this hook."
238 :group 'gnus-group-listing
241 (defcustom gnus-suspend-gnus-hook nil
242 "Hook called when suspending (not exiting) Gnus."
246 (defcustom gnus-exit-gnus-hook nil
247 "Hook called when exiting Gnus."
251 (defcustom gnus-after-exiting-gnus-hook nil
252 "Hook called after exiting Gnus."
256 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
257 "Hook called when a group line is changed.
258 The hook will not be called if `gnus-visual' is nil.
260 The default function `gnus-group-highlight-line' will
261 highlight the line according to the `gnus-group-highlight'
263 :group 'gnus-group-visual
266 (defcustom gnus-useful-groups
267 '(("(ding) mailing list mirrored at sunsite.auc.dk"
269 (nntp "sunsite.auc.dk"
270 (nntp-address "sunsite.auc.dk")))
273 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
277 (nndoc-article-type mbox)
278 (eval `(nndoc-address
279 ,(let ((file (nnheader-find-etc-directory
282 (error "Couldn't find doc group"))
284 "*Alist of useful group-server pairs."
285 :group 'gnus-group-listing
286 :type '(repeat (list (string :tag "Description")
288 (sexp :tag "Method"))))
290 (defcustom gnus-group-highlight
292 ((and (= unread 0) (not mailp) (eq level 1)) .
293 gnus-group-news-1-empty-face)
294 ((and (not mailp) (eq level 1)) .
295 gnus-group-news-1-face)
296 ((and (= unread 0) (not mailp) (eq level 2)) .
297 gnus-group-news-2-empty-face)
298 ((and (not mailp) (eq level 2)) .
299 gnus-group-news-2-face)
300 ((and (= unread 0) (not mailp) (eq level 3)) .
301 gnus-group-news-3-empty-face)
302 ((and (not mailp) (eq level 3)) .
303 gnus-group-news-3-face)
304 ((and (= unread 0) (not mailp) (eq level 4)) .
305 gnus-group-news-4-empty-face)
306 ((and (not mailp) (eq level 4)) .
307 gnus-group-news-4-face)
308 ((and (= unread 0) (not mailp) (eq level 5)) .
309 gnus-group-news-5-empty-face)
310 ((and (not mailp) (eq level 5)) .
311 gnus-group-news-5-face)
312 ((and (= unread 0) (not mailp) (eq level 6)) .
313 gnus-group-news-6-empty-face)
314 ((and (not mailp) (eq level 6)) .
315 gnus-group-news-6-face)
316 ((and (= unread 0) (not mailp)) .
317 gnus-group-news-low-empty-face)
319 gnus-group-news-low-face)
321 ((and (= unread 0) (eq level 1)) .
322 gnus-group-mail-1-empty-face)
324 gnus-group-mail-1-face)
325 ((and (= unread 0) (eq level 2)) .
326 gnus-group-mail-2-empty-face)
328 gnus-group-mail-2-face)
329 ((and (= unread 0) (eq level 3)) .
330 gnus-group-mail-3-empty-face)
332 gnus-group-mail-3-face)
334 gnus-group-mail-low-empty-face)
336 gnus-group-mail-low-face))
337 "*Controls the highlighting of group buffer lines.
339 Below is a list of `Form'/`Face' pairs. When deciding how a a
340 particular group line should be displayed, each form is
341 evaluated. The content of the face field after the first true form is
342 used. You can change how those group lines are displayed by
343 editing the face field.
345 It is also possible to change and add form fields, but currently that
346 requires an understanding of Lisp expressions. Hopefully this will
347 change in a future release. For now, you can use the following
348 variables in the Lisp expression:
350 group: The name of the group.
351 unread: The number of unread articles in the group.
352 method: The select method used.
353 mailp: Whether it's a mail group or not.
354 level: The level of the group.
355 score: The score of the group.
356 ticked: The number of ticked articles."
357 :group 'gnus-group-visual
358 :type '(repeat (cons (sexp :tag "Form") face)))
360 (defcustom gnus-new-mail-mark ?%
361 "Mark used for groups with new mail."
362 :group 'gnus-group-visual
365 (defgroup gnus-group-icons nil
366 "Add Icons to your group buffer. "
367 :group 'gnus-group-visual)
369 (defcustom gnus-group-icon-list
371 "*Controls the insertion of icons into group buffer lines.
373 Below is a list of `Form'/`File' pairs. When deciding how a
374 particular group line should be displayed, each form is evaluated.
375 The icon from the file field after the first true form is used. You
376 can change how those group lines are displayed by editing the file
377 field. The File will either be found in the
378 `gnus-group-glyph-directory' or by designating absolute path to the
381 It is also possible to change and add form fields, but currently that
382 requires an understanding of Lisp expressions. Hopefully this will
383 change in a future release. For now, you can use the following
384 variables in the Lisp expression:
386 group: The name of the group.
387 unread: The number of unread articles in the group.
388 method: The select method used.
389 mailp: Whether it's a mail group or not.
390 newsp: Whether it's a news group or not
391 level: The level of the group.
392 score: The score of the group.
393 ticked: The number of ticked articles."
394 :group 'gnus-group-icons
395 :type '(repeat (cons (sexp :tag "Form") file)))
397 (defcustom gnus-group-name-charset-method-alist nil
398 "*Alist of method and the charset for group names.
401 (((nntp \"news.com.cn\") . cn-gb-2312))
404 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
406 (defcustom gnus-group-name-charset-group-alist nil
407 "*Alist of group regexp and the charset for group names.
410 ((\"\\.com\\.cn:\" . cn-gb-2312))
413 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
415 (defvar gnus-group-jump-to-group-prompt nil
416 "GNUS-GROUP-JUMP-TO-GROUP prompt.
417 If non-nil, the value should be a string, e.g. \"nnml:\",
418 in which case GNUS-GROUP-JUMP-TO-GROUP offers \"Group: nnml:\"
419 in the minibuffer prompt.")
421 ;;; Internal variables
423 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
424 "Function for sorting the group buffer.")
426 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
427 "Function for sorting the selected groups in the group buffer.")
429 (defvar gnus-group-indentation-function nil)
430 (defvar gnus-goto-missing-group-function nil)
431 (defvar gnus-group-update-group-function nil)
432 (defvar gnus-group-goto-next-group-function nil
433 "Function to override finding the next group after listing groups.")
435 (defvar gnus-group-edit-buffer nil)
437 (defvar gnus-group-line-format-alist
438 `((?M gnus-tmp-marked-mark ?c)
439 (?S gnus-tmp-subscribed ?c)
440 (?L gnus-tmp-level ?d)
441 (?N (cond ((eq number t) "*" )
445 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
446 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
448 (?R gnus-tmp-number-of-read ?s)
449 (?t gnus-tmp-number-total ?d)
450 (?y gnus-tmp-number-of-unread ?s)
451 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
452 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
453 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
454 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
455 (?g gnus-tmp-group ?s)
456 (?G gnus-tmp-qualified-group ?s)
457 (?c (gnus-short-group-name gnus-tmp-group) ?s)
458 (?D gnus-tmp-newsgroup-description ?s)
459 (?o gnus-tmp-moderated ?c)
460 (?O gnus-tmp-moderated-string ?s)
461 (?p gnus-tmp-process-marked ?c)
462 (?s gnus-tmp-news-server ?s)
463 (?n gnus-tmp-news-method ?s)
464 (?P gnus-group-indentation ?s)
465 (?E gnus-tmp-group-icon ?s)
466 (?l gnus-tmp-grouplens ?s)
467 (?z gnus-tmp-news-method-string ?s)
468 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
469 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
470 (?u gnus-tmp-user-defined ?s)))
472 (defvar gnus-group-mode-line-format-alist
473 `((?S gnus-tmp-news-server ?s)
474 (?M gnus-tmp-news-method ?s)
475 (?u gnus-tmp-user-defined ?s)
476 (?: gnus-tmp-colon ?s)))
478 (defvar gnus-topic-topology nil
479 "The complete topic hierarchy.")
481 (defvar gnus-topic-alist nil
482 "The complete topic-group alist.")
484 (defvar gnus-group-marked nil)
486 (defvar gnus-group-list-mode nil)
489 (defvar gnus-group-icon-cache nil)
491 (defvar gnus-group-listed-groups nil)
492 (defvar gnus-group-list-option nil)
498 (put 'gnus-group-mode 'mode-class 'special)
501 (gnus-define-keys gnus-group-mode-map
502 " " gnus-group-read-group
503 "=" gnus-group-select-group
504 "\r" gnus-group-select-group
505 "\M-\r" gnus-group-quick-select-group
506 "\M- " gnus-group-visible-select-group
507 [(meta control return)] gnus-group-select-group-ephemerally
508 "j" gnus-group-jump-to-group
509 "n" gnus-group-next-unread-group
510 "p" gnus-group-prev-unread-group
511 "\177" gnus-group-prev-unread-group
512 [delete] gnus-group-prev-unread-group
513 [backspace] gnus-group-prev-unread-group
514 "N" gnus-group-next-group
515 "P" gnus-group-prev-group
516 "\M-n" gnus-group-next-unread-group-same-level
517 "\M-p" gnus-group-prev-unread-group-same-level
518 "," gnus-group-best-unread-group
519 "." gnus-group-first-unread-group
520 "u" gnus-group-unsubscribe-current-group
521 "U" gnus-group-unsubscribe-group
522 "c" gnus-group-catchup-current
523 "C" gnus-group-catchup-current-all
524 "\M-c" gnus-group-clear-data
525 "l" gnus-group-list-groups
526 "L" gnus-group-list-all-groups
528 "g" gnus-group-get-new-news
529 "\M-g" gnus-group-get-new-news-this-group
530 "R" gnus-group-restart
531 "r" gnus-group-read-init-file
532 "B" gnus-group-browse-foreign-server
533 "b" gnus-group-check-bogus-groups
534 "F" gnus-group-find-new-groups
535 "\C-c\C-d" gnus-group-describe-group
536 "\M-d" gnus-group-describe-all-groups
537 "\C-c\C-a" gnus-group-apropos
538 "\C-c\M-\C-a" gnus-group-description-apropos
539 "a" gnus-group-post-news
540 "\ek" gnus-group-edit-local-kill
541 "\eK" gnus-group-edit-global-kill
542 "\C-k" gnus-group-kill-group
543 "\C-y" gnus-group-yank-group
544 "\C-w" gnus-group-kill-region
545 "\C-x\C-t" gnus-group-transpose-groups
546 "\C-c\C-l" gnus-group-list-killed
547 "\C-c\C-x" gnus-group-expire-articles
548 "\C-c\M-\C-x" gnus-group-expire-all-groups
550 "s" gnus-group-save-newsrc
551 "z" gnus-group-suspend
554 "?" gnus-group-describe-briefly
555 "\C-c\C-i" gnus-info-find-node
556 "\M-e" gnus-group-edit-group-method
557 "^" gnus-group-enter-server-mode
558 gnus-mouse-2 gnus-mouse-pick-group
559 "<" beginning-of-buffer
562 "\C-c\C-s" gnus-group-sort-groups
564 "\C-c\M-g" gnus-activate-all-groups
565 "\M-&" gnus-group-universal-argument
566 "#" gnus-group-mark-group
567 "\M-#" gnus-group-unmark-group)
569 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
570 "m" gnus-group-mark-group
571 "u" gnus-group-unmark-group
572 "w" gnus-group-mark-region
573 "b" gnus-group-mark-buffer
574 "r" gnus-group-mark-regexp
575 "U" gnus-group-unmark-all-groups)
577 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
578 "d" gnus-group-make-directory-group
579 "h" gnus-group-make-help-group
580 "u" gnus-group-make-useful-group
581 "a" gnus-group-make-archive-group
582 "k" gnus-group-make-kiboze-group
583 "l" gnus-group-nnimap-edit-acl
584 "m" gnus-group-make-group
585 "E" gnus-group-edit-group
586 "e" gnus-group-edit-group-method
587 "p" gnus-group-edit-group-parameters
588 "v" gnus-group-add-to-virtual
589 "V" gnus-group-make-empty-virtual
590 "D" gnus-group-enter-directory
591 "f" gnus-group-make-doc-group
592 "w" gnus-group-make-web-group
593 "r" gnus-group-rename-group
594 "c" gnus-group-customize
595 "x" gnus-group-nnimap-expunge
596 "\177" gnus-group-delete-group
597 [delete] gnus-group-delete-group)
599 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
600 "b" gnus-group-brew-soup
601 "w" gnus-soup-save-areas
602 "s" gnus-soup-send-replies
603 "p" gnus-soup-pack-packet
604 "r" nnsoup-pack-replies)
606 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
607 "s" gnus-group-sort-groups
608 "a" gnus-group-sort-groups-by-alphabet
609 "u" gnus-group-sort-groups-by-unread
610 "l" gnus-group-sort-groups-by-level
611 "v" gnus-group-sort-groups-by-score
612 "r" gnus-group-sort-groups-by-rank
613 "m" gnus-group-sort-groups-by-method)
615 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
616 "s" gnus-group-sort-selected-groups
617 "a" gnus-group-sort-selected-groups-by-alphabet
618 "u" gnus-group-sort-selected-groups-by-unread
619 "l" gnus-group-sort-selected-groups-by-level
620 "v" gnus-group-sort-selected-groups-by-score
621 "r" gnus-group-sort-selected-groups-by-rank
622 "m" gnus-group-sort-selected-groups-by-method)
624 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
625 "k" gnus-group-list-killed
626 "z" gnus-group-list-zombies
627 "s" gnus-group-list-groups
628 "u" gnus-group-list-all-groups
629 "A" gnus-group-list-active
630 "a" gnus-group-apropos
631 "d" gnus-group-description-apropos
632 "m" gnus-group-list-matching
633 "M" gnus-group-list-all-matching
634 "l" gnus-group-list-level
635 "c" gnus-group-list-cached
636 "?" gnus-group-list-dormant)
638 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
639 "k" gnus-group-list-limit
640 "z" gnus-group-list-limit
641 "s" gnus-group-list-limit
642 "u" gnus-group-list-limit
643 "A" gnus-group-list-limit
644 "m" gnus-group-list-limit
645 "M" gnus-group-list-limit
646 "l" gnus-group-list-limit
647 "c" gnus-group-list-limit
648 "?" gnus-group-list-limit)
650 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
651 "k" gnus-group-list-flush
652 "z" gnus-group-list-flush
653 "s" gnus-group-list-flush
654 "u" gnus-group-list-flush
655 "A" gnus-group-list-flush
656 "m" gnus-group-list-flush
657 "M" gnus-group-list-flush
658 "l" gnus-group-list-flush
659 "c" gnus-group-list-flush
660 "?" gnus-group-list-flush)
662 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
663 "k" gnus-group-list-plus
664 "z" gnus-group-list-plus
665 "s" gnus-group-list-plus
666 "u" gnus-group-list-plus
667 "A" gnus-group-list-plus
668 "m" gnus-group-list-plus
669 "M" gnus-group-list-plus
670 "l" gnus-group-list-plus
671 "c" gnus-group-list-plus
672 "?" gnus-group-list-plus)
674 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
675 "f" gnus-score-flush-cache)
677 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
678 "d" gnus-group-describe-group
679 "f" gnus-group-fetch-faq
682 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
683 "l" gnus-group-set-current-level
684 "t" gnus-group-unsubscribe-current-group
685 "s" gnus-group-unsubscribe-group
686 "k" gnus-group-kill-group
687 "y" gnus-group-yank-group
688 "w" gnus-group-kill-region
689 "\C-k" gnus-group-kill-level
690 "z" gnus-group-kill-all-zombies))
692 (defun gnus-group-make-menu-bar ()
693 (gnus-turn-off-edit-menu 'group)
694 (unless (boundp 'gnus-group-reading-menu)
697 gnus-group-reading-menu gnus-group-mode-map ""
699 ["Read" gnus-group-read-group (gnus-group-group-name)]
700 ["Select" gnus-group-select-group (gnus-group-group-name)]
701 ["See old articles" (gnus-group-select-group 'all)
702 :keys "C-u SPC" :active (gnus-group-group-name)]
703 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
704 ["Catch up all articles" gnus-group-catchup-current-all
705 (gnus-group-group-name)]
706 ["Check for new articles" gnus-group-get-new-news-this-group
707 (gnus-group-group-name)]
708 ["Toggle subscription" gnus-group-unsubscribe-current-group
709 (gnus-group-group-name)]
710 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
711 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
712 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
713 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
714 ;; Actually one should check, if any of the marked groups gives t for
715 ;; (gnus-check-backend-function 'request-expire-articles ...)
716 ["Expire articles" gnus-group-expire-articles
717 (or (and (gnus-group-group-name)
718 (gnus-check-backend-function
719 'request-expire-articles
720 (gnus-group-group-name))) gnus-group-marked)]
721 ["Set group level" gnus-group-set-current-level
722 (gnus-group-group-name)]
723 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
724 ["Customize" gnus-group-customize (gnus-group-group-name)]
726 ["Parameters" gnus-group-edit-group-parameters
727 (gnus-group-group-name)]
728 ["Select method" gnus-group-edit-group-method
729 (gnus-group-group-name)]
730 ["Info" gnus-group-edit-group (gnus-group-group-name)]
731 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
732 ["Global kill file" gnus-group-edit-global-kill t])))
735 gnus-group-group-menu gnus-group-mode-map ""
738 ["List unread subscribed groups" gnus-group-list-groups t]
739 ["List (un)subscribed groups" gnus-group-list-all-groups t]
740 ["List killed groups" gnus-group-list-killed gnus-killed-list]
741 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
742 ["List level..." gnus-group-list-level t]
743 ["Describe all groups" gnus-group-describe-all-groups t]
744 ["Group apropos..." gnus-group-apropos t]
745 ["Group and description apropos..." gnus-group-description-apropos t]
746 ["List groups matching..." gnus-group-list-matching t]
747 ["List all groups matching..." gnus-group-list-all-matching t]
748 ["List active file" gnus-group-list-active t]
749 ["List groups with cached" gnus-group-list-cached t]
750 ["List groups with dormant" gnus-group-list-dormant t])
752 ["Default sort" gnus-group-sort-groups t]
753 ["Sort by method" gnus-group-sort-groups-by-method t]
754 ["Sort by rank" gnus-group-sort-groups-by-rank t]
755 ["Sort by score" gnus-group-sort-groups-by-score t]
756 ["Sort by level" gnus-group-sort-groups-by-level t]
757 ["Sort by unread" gnus-group-sort-groups-by-unread t]
758 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
759 ("Sort process/prefixed"
760 ["Default sort" gnus-group-sort-selected-groups
761 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
762 ["Sort by method" gnus-group-sort-selected-groups-by-method
763 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
764 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
765 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
766 ["Sort by score" gnus-group-sort-selected-groups-by-score
767 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
768 ["Sort by level" gnus-group-sort-selected-groups-by-level
769 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
770 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
771 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
772 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
773 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
775 ["Mark group" gnus-group-mark-group
776 (and (gnus-group-group-name)
777 (not (memq (gnus-group-group-name) gnus-group-marked)))]
778 ["Unmark group" gnus-group-unmark-group
779 (and (gnus-group-group-name)
780 (memq (gnus-group-group-name) gnus-group-marked))]
781 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
782 ["Mark regexp..." gnus-group-mark-regexp t]
783 ["Mark region" gnus-group-mark-region t]
784 ["Mark buffer" gnus-group-mark-buffer t]
785 ["Execute command" gnus-group-universal-argument
786 (or gnus-group-marked (gnus-group-group-name))])
788 ["Subscribe to a group" gnus-group-unsubscribe-group t]
789 ["Kill all newsgroups in region" gnus-group-kill-region t]
790 ["Kill all zombie groups" gnus-group-kill-all-zombies
792 ["Kill all groups on level..." gnus-group-kill-level t])
794 ["Make a foreign group" gnus-group-make-group t]
795 ["Add a directory group" gnus-group-make-directory-group t]
796 ["Add the help group" gnus-group-make-help-group t]
797 ["Add the archive group" gnus-group-make-archive-group t]
798 ["Make a doc group" gnus-group-make-doc-group t]
799 ["Make a web group" gnus-group-make-web-group t]
800 ["Make a kiboze group" gnus-group-make-kiboze-group t]
801 ["Make a virtual group" gnus-group-make-empty-virtual t]
802 ["Add a group to a virtual" gnus-group-add-to-virtual t]
803 ["Rename group" gnus-group-rename-group
804 (gnus-check-backend-function
805 'request-rename-group (gnus-group-group-name))]
806 ["Delete group" gnus-group-delete-group
807 (gnus-check-backend-function
808 'request-delete-group (gnus-group-group-name))])
810 ["Next" gnus-group-next-group t]
811 ["Previous" gnus-group-prev-group t]
812 ["Next unread" gnus-group-next-unread-group t]
813 ["Previous unread" gnus-group-prev-unread-group t]
814 ["Next unread same level" gnus-group-next-unread-group-same-level t]
815 ["Previous unread same level"
816 gnus-group-prev-unread-group-same-level t]
817 ["Jump to group" gnus-group-jump-to-group t]
818 ["First unread group" gnus-group-first-unread-group t]
819 ["Best unread group" gnus-group-best-unread-group t])
820 ["Delete bogus groups" gnus-group-check-bogus-groups t]
821 ["Find new newsgroups" gnus-group-find-new-groups t]
822 ["Transpose" gnus-group-transpose-groups
823 (gnus-group-group-name)]
824 ["Read a directory as a group..." gnus-group-enter-directory t]))
827 gnus-group-misc-menu gnus-group-mode-map ""
830 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
831 ["Send replies" gnus-soup-send-replies
832 (fboundp 'gnus-soup-pack-packet)]
833 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
834 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
835 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
836 ["Send a mail" gnus-group-mail t]
837 ["Post an article..." gnus-group-post-news t]
838 ["Check for new news" gnus-group-get-new-news t]
839 ["Activate all groups" gnus-activate-all-groups t]
840 ["Restart Gnus" gnus-group-restart t]
841 ["Read init file" gnus-group-read-init-file t]
842 ["Browse foreign server" gnus-group-browse-foreign-server t]
843 ["Enter server buffer" gnus-group-enter-server-mode t]
844 ["Expire all expirable articles" gnus-group-expire-all-groups t]
845 ["Generate any kiboze groups" nnkiboze-generate-groups t]
846 ["Gnus version" gnus-version t]
847 ["Save .newsrc files" gnus-group-save-newsrc t]
848 ["Suspend Gnus" gnus-group-suspend t]
849 ["Clear dribble buffer" gnus-group-clear-dribble t]
850 ["Read manual" gnus-info-find-node t]
851 ["Flush score cache" gnus-score-flush-cache t]
852 ["Toggle topics" gnus-topic-mode t]
853 ["Send a bug report" gnus-bug t]
854 ["Exit from Gnus" gnus-group-exit t]
855 ["Exit without saving" gnus-group-quit t]))
857 (gnus-run-hooks 'gnus-group-menu-hook)))
859 (defun gnus-group-mode ()
860 "Major mode for reading news.
862 All normal editing commands are switched off.
863 \\<gnus-group-mode-map>
864 The group buffer lists (some of) the groups available. For instance,
865 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
866 lists all zombie groups.
868 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
869 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
871 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
873 The following commands are available:
875 \\{gnus-group-mode-map}"
877 (when (gnus-visual-p 'group-menu 'menu)
878 (gnus-group-make-menu-bar))
879 (kill-all-local-variables)
880 (gnus-simplify-mode-line)
881 (setq major-mode 'gnus-group-mode)
882 (setq mode-name "Group")
883 (gnus-group-set-mode-line)
884 (setq mode-line-process nil)
885 (use-local-map gnus-group-mode-map)
886 (buffer-disable-undo)
887 (setq truncate-lines t)
888 (setq buffer-read-only t)
889 (gnus-set-default-directory)
890 (gnus-update-format-specifications nil 'group 'group-mode)
891 (gnus-update-group-mark-positions)
896 (gnus-run-hooks 'gnus-group-mode-hook))
898 (defun gnus-update-group-mark-positions ()
900 (let ((gnus-process-mark ?\200)
901 (gnus-group-marked '("dummy.group"))
902 (gnus-active-hashtb (make-vector 10 0))
904 (gnus-set-active "dummy.group" '(0 . 0))
905 (gnus-set-work-buffer)
906 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
907 (goto-char (point-min))
908 (setq gnus-group-mark-positions
909 (list (cons 'process (and (search-forward "\200" nil t)
912 (defun gnus-mouse-pick-group (e)
913 "Enter the group under the mouse pointer."
916 (gnus-group-read-group nil))
918 ;; Look at LEVEL and find out what the level is really supposed to be.
919 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
920 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
921 (defun gnus-group-default-level (&optional level number-or-nil)
923 (gnus-group-use-permanent-levels
924 (or (setq gnus-group-use-permanent-levels
925 (or level (if (numberp gnus-group-use-permanent-levels)
926 gnus-group-use-permanent-levels
927 (or gnus-group-default-list-level
928 gnus-level-subscribed))))
929 gnus-group-default-list-level gnus-level-subscribed))
933 (or level gnus-group-default-list-level gnus-level-subscribed))))
935 (defun gnus-group-setup-buffer ()
936 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
937 (unless (eq major-mode 'gnus-group-mode)
940 (gnus-carpal-setup-buffer 'group))))
942 (defsubst gnus-group-name-charset (method group)
944 (setq method (gnus-find-method-for-group group)))
945 (let ((item (assoc method gnus-group-name-charset-method-alist))
946 (alist gnus-group-name-charset-group-alist)
950 (while (setq item (pop alist))
951 (if (string-match (car item) group)
956 (defsubst gnus-group-name-decode (string charset)
957 (if (and string charset (featurep 'mule))
958 (mm-decode-coding-string string charset)
961 (defun gnus-group-decoded-name (string)
962 (let ((charset (gnus-group-name-charset nil string)))
963 (gnus-group-name-decode string charset)))
965 (defun gnus-group-list-groups (&optional level unread lowest)
966 "List newsgroups with level LEVEL or lower that have unread articles.
967 Default is all subscribed groups.
968 If argument UNREAD is non-nil, groups with no unread articles are also
971 Also see the `gnus-group-use-permanent-levels' variable."
973 (list (if current-prefix-arg
974 (prefix-numeric-value current-prefix-arg)
976 (gnus-group-default-level nil t)
977 gnus-group-default-list-level
978 gnus-level-subscribed))))
980 (setq level (car gnus-group-list-mode)
981 unread (cdr gnus-group-list-mode)))
982 (setq level (gnus-group-default-level level))
983 (gnus-group-setup-buffer)
984 (gnus-update-format-specifications nil 'group 'group-mode)
985 (let ((case-fold-search nil)
986 (props (text-properties-at (gnus-point-at-bol)))
987 (empty (= (point-min) (point-max)))
988 (group (gnus-group-group-name))
990 (set-buffer gnus-group-buffer)
991 (setq number (funcall gnus-group-prepare-function level unread lowest))
992 (when (or (and (numberp number)
994 (zerop (buffer-size)))
995 ;; No groups in the buffer.
996 (gnus-message 5 gnus-no-groups-message))
997 ;; We have some groups displayed.
998 (goto-char (point-max))
999 (when (or (not gnus-group-goto-next-group-function)
1000 (not (funcall gnus-group-goto-next-group-function
1004 (goto-char (point-min)))
1006 ;; Go to the first group with unread articles.
1007 (gnus-group-search-forward t))
1009 ;; Find the right group to put point on. If the current group
1010 ;; has disappeared in the new listing, try to find the next
1011 ;; one. If no next one can be found, just leave point at the
1012 ;; first newsgroup in the buffer.
1013 (when (not (gnus-goto-char
1015 (point-min) (point-max)
1016 'gnus-group (gnus-intern-safe
1017 group gnus-active-hashtb))))
1018 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1020 (not (gnus-goto-char
1022 (point-min) (point-max) 'gnus-group
1024 (caar newsrc) gnus-active-hashtb)))))
1025 (setq newsrc (cdr newsrc)))
1027 (goto-char (point-max))
1028 (forward-line -1)))))))
1029 ;; Adjust cursor point.
1030 (gnus-group-position-point)))
1032 (defun gnus-group-list-level (level &optional all)
1033 "List groups on LEVEL.
1034 If ALL (the prefix), also list groups that have no unread articles."
1035 (interactive "nList groups on level: \nP")
1036 (gnus-group-list-groups level all level))
1038 (defun gnus-group-prepare-logic (group test)
1039 (or (and gnus-group-listed-groups
1040 (null gnus-group-list-option)
1041 (member group gnus-group-listed-groups))
1043 ((null gnus-group-listed-groups) test)
1044 ((null gnus-group-list-option) test)
1045 (t (and (member group gnus-group-listed-groups)
1046 (if (eq gnus-group-list-option 'flush)
1050 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1051 "List all newsgroups with unread articles of level LEVEL or lower.
1052 If PREDICATE is a function, list groups that the function returns non-nil;
1053 if it is t, list groups that have no unread articles.
1054 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1055 If REGEXP is a function, list dead groups that the function returns non-nil;
1056 if it is a string, only list groups matching REGEXP."
1057 (set-buffer gnus-group-buffer)
1058 (let ((buffer-read-only nil)
1059 (newsrc (cdr gnus-newsrc-alist))
1060 (lowest (or lowest 1))
1061 (not-in-list (and gnus-group-listed-groups
1062 (copy-sequence gnus-group-listed-groups)))
1063 info clevel unread group params)
1065 (when (or (< lowest gnus-level-zombie)
1066 gnus-group-listed-groups)
1067 ;; List living groups.
1069 (setq info (car newsrc)
1070 group (gnus-info-group info)
1071 params (gnus-info-params info)
1073 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1075 (setq not-in-list (delete group not-in-list)))
1077 (gnus-group-prepare-logic
1079 (and unread ; This group might be unchecked
1080 (or (not (stringp regexp))
1081 (string-match regexp group))
1082 (<= (setq clevel (gnus-info-level info)) level)
1085 ((functionp predicate)
1086 (funcall predicate info))
1087 (predicate t) ; We list all groups?
1090 (if (eq unread t) ; Unactivated?
1091 gnus-group-list-inactive-groups
1092 ; We list unactivated
1094 ; We list groups with unread articles
1095 (and gnus-list-groups-with-ticked-articles
1096 (cdr (assq 'tick (gnus-info-marks info))))
1097 ; And groups with tickeds
1098 ;; Check for permanent visibility.
1099 (and gnus-permanently-visible-groups
1100 (string-match gnus-permanently-visible-groups group))
1101 (memq 'visible params)
1102 (cdr (assq 'visible params)))))))
1103 (gnus-group-insert-group-line
1104 group (gnus-info-level info)
1105 (gnus-info-marks info) unread (gnus-info-method info)))))
1107 ;; List dead groups.
1108 (if (or gnus-group-listed-groups
1109 (and (>= level gnus-level-zombie)
1110 (<= lowest gnus-level-zombie)))
1111 (gnus-group-prepare-flat-list-dead
1112 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1113 gnus-level-zombie ?Z
1116 (dolist (group gnus-zombie-list)
1117 (setq not-in-list (delete group not-in-list))))
1118 (if (or gnus-group-listed-groups
1119 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1120 (gnus-group-prepare-flat-list-dead
1123 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1124 gnus-level-killed ?K regexp))
1126 (gnus-group-set-mode-line)
1127 (setq gnus-group-list-mode (cons level predicate))
1128 (gnus-run-hooks 'gnus-group-prepare-hook)
1131 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1132 ;; List zombies and killed lists somewhat faster, which was
1133 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1134 ;; this by ignoring the group format specification altogether.
1137 (setq group (pop groups))
1138 (when (gnus-group-prepare-logic
1141 (and (stringp regexp) (string-match regexp group))
1142 (and (functionp regexp) (funcall regexp group))))
1143 ;;; (gnus-add-text-properties
1144 ;;; (point) (prog1 (1+ (point))
1145 ;;; (insert " " mark " *: "
1146 ;;; (gnus-group-name-decode group
1147 ;;; (gnus-group-name-charset
1150 ;;; (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1152 ;;; 'gnus-level level))
1153 (gnus-group-insert-group-line
1155 (let ((active (gnus-active group)))
1157 (if (zerop (cdr active))
1159 (- (1+ (cdr active)) (car active)))
1161 (gnus-method-simplify (gnus-find-method-for-group group)))))))
1163 (defun gnus-group-update-group-line ()
1164 "Update the current line in the group buffer."
1165 (let* ((buffer-read-only nil)
1166 (group (gnus-group-group-name))
1167 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1168 gnus-group-indentation)
1171 (not (gnus-ephemeral-group-p group))
1173 (concat "(gnus-group-set-info '"
1174 (gnus-prin1-to-string (nth 2 entry))
1176 (setq gnus-group-indentation (gnus-group-group-indentation))
1178 (gnus-group-insert-group-line-info group)
1180 (gnus-group-position-point))))
1182 (defun gnus-group-insert-group-line-info (group)
1183 "Insert GROUP on the current line."
1184 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1185 (gnus-group-indentation (gnus-group-group-indentation))
1189 ;; (Un)subscribed group.
1190 (setq info (nth 2 entry))
1191 (gnus-group-insert-group-line
1192 group (gnus-info-level info) (gnus-info-marks info)
1193 (or (car entry) t) (gnus-info-method info)))
1194 ;; This group is dead.
1195 (gnus-group-insert-group-line
1197 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1199 (if (setq active (gnus-active group))
1200 (if (zerop (cdr active))
1202 (- (1+ (cdr active)) (car active)))
1204 (gnus-method-simplify (gnus-find-method-for-group group))))))
1206 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1207 gnus-tmp-marked number
1209 "Insert a group line in the group buffer."
1210 (let* ((gnus-tmp-method
1211 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1212 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1214 (gnus-tmp-active (gnus-active gnus-tmp-group))
1215 (gnus-tmp-number-total
1217 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1219 (gnus-tmp-number-of-unread
1220 (if (numberp number) (int-to-string (max 0 number))
1222 (gnus-tmp-number-of-read
1223 (if (numberp number)
1224 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1226 (gnus-tmp-subscribed
1227 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1228 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1229 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1231 (gnus-tmp-qualified-group
1232 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1233 group-name-charset))
1234 (gnus-tmp-newsgroup-description
1235 (if gnus-description-hashtb
1236 (or (gnus-group-name-decode
1237 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1238 group-name-charset) "")
1241 (if (and gnus-moderated-hashtb
1242 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1244 (gnus-tmp-moderated-string
1245 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1246 (gnus-tmp-group-icon "==&&==")
1247 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1248 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1249 (gnus-tmp-news-method-string
1251 (format "(%s:%s)" (car gnus-tmp-method)
1252 (cadr gnus-tmp-method)) ""))
1253 (gnus-tmp-marked-mark
1254 (if (and (numberp number)
1256 (cdr (assq 'tick gnus-tmp-marked)))
1258 (gnus-tmp-process-marked
1259 (if (member gnus-tmp-group gnus-group-marked)
1260 gnus-process-mark ? ))
1262 (or (and gnus-use-grouplens
1263 (bbb-grouplens-group-p gnus-tmp-group))
1265 (buffer-read-only nil)
1266 header gnus-tmp-header) ; passed as parameter to user-funcs.
1268 (gnus-add-text-properties
1272 (eval gnus-group-line-format-spec))
1273 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1274 gnus-unread ,(if (numberp number)
1275 (string-to-int gnus-tmp-number-of-unread)
1277 gnus-marked ,gnus-tmp-marked-mark
1278 gnus-indentation ,gnus-group-indentation
1279 gnus-level ,gnus-tmp-level))
1281 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1282 (gnus-run-hooks 'gnus-group-update-hook))
1284 ;; Allow XEmacs to remove front-sticky text properties.
1285 (gnus-group-remove-excess-properties)))
1287 (defun gnus-group-highlight-line ()
1288 "Highlight the current line according to `gnus-group-highlight'."
1289 (let* ((list gnus-group-highlight)
1291 (end (progn (end-of-line) (point)))
1292 ;; now find out where the line starts and leave point there.
1293 (beg (progn (beginning-of-line) (point)))
1294 (group (gnus-group-group-name))
1295 (entry (gnus-group-entry group))
1296 (unread (if (numberp (car entry)) (car entry) 0))
1297 (active (gnus-active group))
1298 (total (if active (1+ (- (cdr active) (car active))) 0))
1299 (info (nth 2 entry))
1300 (method (gnus-server-get-method group (gnus-info-method info)))
1301 (marked (gnus-info-marks info))
1302 (mailp (memq 'mail (assoc (symbol-name
1303 (car (or method gnus-select-method)))
1304 gnus-valid-select-methods)))
1305 (level (or (gnus-info-level info) gnus-level-killed))
1306 (score (or (gnus-info-score info) 0))
1307 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1308 (group-age (gnus-group-timestamp-delta group))
1309 (inhibit-read-only t))
1310 ;; Eval the cars of the lists until we find a match.
1312 (not (eval (caar list))))
1313 (setq list (cdr list)))
1314 (let ((face (cdar list)))
1315 (unless (eq face (get-text-property beg 'face))
1316 (gnus-put-text-property-excluding-characters-with-faces
1318 (setq face (if (boundp face) (symbol-value face) face)))
1319 (gnus-extent-start-open beg)))
1322 (defun gnus-group-update-group (group &optional visible-only)
1323 "Update all lines where GROUP appear.
1324 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1326 ;; Can't use `save-excursion' here, so we do it manually.
1327 (let ((buf (current-buffer))
1329 (set-buffer gnus-group-buffer)
1330 (setq mark (point-marker))
1331 ;; The buffer may be narrowed.
1334 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1336 found buffer-read-only)
1337 ;; Enter the current status into the dribble buffer.
1338 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1340 (not (gnus-ephemeral-group-p group)))
1342 (concat "(gnus-group-set-info '"
1343 (gnus-prin1-to-string (nth 2 entry))
1345 ;; Find all group instances. If topics are in use, each group
1346 ;; may be listed in more than once.
1347 (while (setq loc (text-property-any
1348 loc (point-max) 'gnus-group ident))
1351 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1353 (gnus-group-insert-group-line-info group)
1356 (gnus-run-hooks 'gnus-group-update-group-hook)))
1357 (setq loc (1+ loc)))
1358 (unless (or found visible-only)
1359 ;; No such line in the buffer, find out where it's supposed to
1360 ;; go, and insert it there (or at the end of the buffer).
1361 (if gnus-goto-missing-group-function
1362 (funcall gnus-goto-missing-group-function group)
1363 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1364 (while (and entry (car entry)
1368 (point-min) (point-max)
1369 'gnus-group (gnus-intern-safe
1370 (caar entry) gnus-active-hashtb)))))
1371 (setq entry (cdr entry)))
1372 (or entry (goto-char (point-max)))))
1373 ;; Finally insert the line.
1374 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1375 (gnus-group-insert-group-line-info group)
1378 (gnus-run-hooks 'gnus-group-update-group-hook))))
1379 (when gnus-group-update-group-function
1380 (funcall gnus-group-update-group-function group))
1381 (gnus-group-set-mode-line)))
1383 (set-marker mark nil)
1386 (defun gnus-group-set-mode-line ()
1387 "Update the mode line in the group buffer."
1388 (when (memq 'group gnus-updated-mode-lines)
1389 ;; Yes, we want to keep this mode line updated.
1391 (set-buffer gnus-group-buffer)
1392 (let* ((gformat (or gnus-group-mode-line-format-spec
1393 (gnus-set-format 'group-mode)))
1394 (gnus-tmp-news-server (cadr gnus-select-method))
1395 (gnus-tmp-news-method (car gnus-select-method))
1396 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1398 gnus-tmp-header ;Dummy binding for user-defined formats
1399 ;; Get the resulting string.
1401 (and gnus-dribble-buffer
1402 (buffer-name gnus-dribble-buffer)
1403 (buffer-modified-p gnus-dribble-buffer)
1405 (set-buffer gnus-dribble-buffer)
1406 (not (zerop (buffer-size))))))
1407 (mode-string (eval gformat)))
1408 ;; Say whether the dribble buffer has been modified.
1409 (setq mode-line-modified
1410 (if modified (car gnus-mode-line-modified)
1411 (cdr gnus-mode-line-modified)))
1412 ;; If the line is too long, we chop it off.
1413 (when (> (length mode-string) max-len)
1414 (setq mode-string (substring mode-string 0 (- max-len 4))))
1416 (setq mode-line-buffer-identification
1417 (gnus-mode-line-buffer-identification
1418 (list mode-string)))
1419 (set-buffer-modified-p modified))))))
1421 (defun gnus-group-group-name ()
1422 "Get the name of the newsgroup on the current line."
1423 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1425 (symbol-name group))))
1427 (defun gnus-group-group-level ()
1428 "Get the level of the newsgroup on the current line."
1429 (get-text-property (gnus-point-at-bol) 'gnus-level))
1431 (defun gnus-group-group-indentation ()
1432 "Get the indentation of the newsgroup on the current line."
1433 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1434 (and gnus-group-indentation-function
1435 (funcall gnus-group-indentation-function))
1438 (defun gnus-group-group-unread ()
1439 "Get the number of unread articles of the newsgroup on the current line."
1440 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1442 (defun gnus-group-new-mail (group)
1443 (if (nnmail-new-mail-p (gnus-group-real-name group))
1447 (defun gnus-group-level (group)
1448 "Return the estimated level of GROUP."
1449 (or (gnus-info-level (gnus-get-info group))
1450 (and (member group gnus-zombie-list) gnus-level-zombie)
1453 (defun gnus-group-search-forward (&optional backward all level first-too)
1454 "Find the next newsgroup with unread articles.
1455 If BACKWARD is non-nil, find the previous newsgroup instead.
1456 If ALL is non-nil, just find any newsgroup.
1457 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1459 If FIRST-TOO, the current line is also eligible as a target."
1460 (let ((way (if backward -1 1))
1461 (low gnus-level-killed)
1464 (if (and backward (progn (beginning-of-line)) (bobp))
1473 (get-text-property (point) 'gnus-group)
1477 (get-text-property (point) 'gnus-unread)))
1478 (and (numberp unread) (> unread 0)))
1479 (setq lev (get-text-property (point)
1481 (<= lev gnus-level-subscribed)))
1483 (and (setq lev (get-text-property (point)
1492 (zerop (forward-line way)))))
1494 (progn (gnus-group-position-point) t)
1495 (goto-char (or pos beg))
1498 ;;; Gnus group mode commands
1502 (defun gnus-group-mark-line-p ()
1505 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1506 (eq (char-after) gnus-process-mark)))
1508 (defun gnus-group-mark-group (n &optional unmark no-advance)
1509 "Mark the current group."
1511 (let ((buffer-read-only nil)
1515 (when (setq group (gnus-group-group-name))
1516 ;; Go to the mark position.
1518 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1519 (subst-char-in-region
1520 (point) (1+ (point)) (char-after)
1523 (setq gnus-group-marked (delete group gnus-group-marked))
1525 (setq gnus-group-marked
1526 (cons group (delete group gnus-group-marked)))
1527 gnus-process-mark)))
1529 (gnus-group-next-group 1))
1531 (gnus-summary-position-point)
1534 (defun gnus-group-unmark-group (n)
1535 "Remove the mark from the current group."
1537 (gnus-group-mark-group n 'unmark)
1538 (gnus-group-position-point))
1540 (defun gnus-group-unmark-all-groups ()
1541 "Unmark all groups."
1543 (let ((groups gnus-group-marked))
1546 (gnus-group-remove-mark (pop groups)))))
1547 (gnus-group-position-point))
1549 (defun gnus-group-mark-region (unmark beg end)
1550 "Mark all groups between point and mark.
1551 If UNMARK, remove the mark instead."
1552 (interactive "P\nr")
1553 (let ((num (count-lines beg end)))
1556 (- num (gnus-group-mark-group num unmark)))))
1558 (defun gnus-group-mark-buffer (&optional unmark)
1559 "Mark all groups in the buffer.
1560 If UNMARK, remove the mark instead."
1562 (gnus-group-mark-region unmark (point-min) (point-max)))
1564 (defun gnus-group-mark-regexp (regexp)
1565 "Mark all groups that match some regexp."
1566 (interactive "sMark (regexp): ")
1567 (let ((alist (cdr gnus-newsrc-alist))
1570 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1571 (gnus-group-set-mark group))))
1572 (gnus-group-position-point))
1574 (defun gnus-group-remove-mark (group &optional test-marked)
1575 "Remove the process mark from GROUP and move point there.
1576 Return nil if the group isn't displayed."
1577 (if (gnus-group-goto-group group nil test-marked)
1579 (gnus-group-mark-group 1 'unmark t)
1581 (setq gnus-group-marked
1582 (delete group gnus-group-marked))
1585 (defun gnus-group-set-mark (group)
1586 "Set the process mark on GROUP."
1587 (if (gnus-group-goto-group group)
1589 (gnus-group-mark-group 1 nil t))
1590 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1592 (defun gnus-group-universal-argument (arg &optional groups func)
1593 "Perform any command on all groups according to the process/prefix convention."
1595 (if (eq (setq func (or func
1598 (substitute-command-keys
1599 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1601 (gnus-error 1 "Undefined key")
1602 (gnus-group-iterate arg
1604 (command-execute func))))
1605 (gnus-group-position-point))
1607 (defun gnus-group-process-prefix (n)
1608 "Return a list of groups to work on.
1609 Take into consideration N (the prefix) and the list of marked groups."
1612 (setq n (prefix-numeric-value n))
1613 ;; There is a prefix, so we return a list of the N next
1615 (let ((way (if (< n 0) -1 1))
1620 (if (setq group (gnus-group-group-name))
1621 (push group groups))
1623 (gnus-group-next-group way)))
1625 ((gnus-region-active-p)
1626 ;; Work on the region between point and mark.
1627 (let ((max (max (point) (mark)))
1630 (goto-char (min (point) (mark)))
1633 (push (gnus-group-group-name) groups)
1634 (zerop (gnus-group-next-group 1))
1636 (nreverse groups))))
1638 ;; No prefix, but a list of marked articles.
1639 (reverse gnus-group-marked))
1641 ;; Neither marked articles or a prefix, so we return the
1643 (let ((group (gnus-group-group-name)))
1644 (and group (list group))))))
1646 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1647 ;;; imagine why I went through these contortions...
1649 (let ((function (make-symbol "gnus-group-iterate-function"))
1650 (window (make-symbol "gnus-group-iterate-window"))
1651 (groups (make-symbol "gnus-group-iterate-groups"))
1652 (group (make-symbol "gnus-group-iterate-group")))
1654 `(defun gnus-group-iterate (arg ,function)
1655 "Iterate FUNCTION over all process/prefixed groups.
1656 FUNCTION will be called with the group name as the parameter
1657 and with point over the group in question."
1658 (let ((,groups (gnus-group-process-prefix arg))
1659 (,window (selected-window))
1662 (setq ,group (car ,groups)
1663 ,groups (cdr ,groups))
1664 (select-window ,window)
1665 (gnus-group-remove-mark ,group)
1666 (save-selected-window
1668 (funcall ,function ,group)))))))))
1670 (put 'gnus-group-iterate 'lisp-indent-function 1)
1672 ;; Selecting groups.
1674 (defun gnus-group-read-group (&optional all no-article group select-articles)
1675 "Read news in this newsgroup.
1676 If the prefix argument ALL is non-nil, already read articles become
1677 readable. IF ALL is a number, fetch this number of articles. If the
1678 optional argument NO-ARTICLE is non-nil, no article will be
1679 auto-selected upon group entry. If GROUP is non-nil, fetch that
1682 (let ((no-display (eq all 0))
1683 (group (or group (gnus-group-group-name)))
1684 number active marked entry)
1688 (error "No group on current line"))
1689 (setq marked (gnus-info-marks
1690 (nth 2 (setq entry (gnus-gethash
1691 group gnus-newsrc-hashtb)))))
1692 ;; This group might be a dead group. In that case we have to get
1693 ;; the number of unread articles from `gnus-active-hashtb'.
1695 (cond ((numberp all) all)
1697 ((setq active (gnus-active group))
1698 (- (1+ (cdr active)) (car active)))))
1699 (gnus-summary-read-group
1700 group (or all (and (numberp number)
1701 (zerop (+ number (gnus-range-length
1702 (cdr (assq 'tick marked)))
1704 (cdr (assq 'dormant marked)))))))
1705 no-article nil no-display nil select-articles)))
1707 (defun gnus-group-select-group (&optional all)
1708 "Select this newsgroup.
1709 No article is selected automatically.
1710 If ALL is non-nil, already read articles become readable.
1711 If ALL is a number, fetch this number of articles."
1713 (gnus-group-read-group all t))
1715 (defun gnus-group-quick-select-group (&optional all)
1716 "Select the current group \"quickly\".
1717 This means that no highlighting or scoring will be performed.
1718 If ALL (the prefix argument) is 0, don't even generate the summary
1721 This might be useful if you want to toggle threading
1722 before entering the group."
1724 (require 'gnus-score)
1726 gnus-score-find-score-files-function
1727 gnus-home-score-file
1728 gnus-apply-kill-hook
1729 gnus-summary-expunge-below)
1730 (gnus-group-read-group all t)))
1732 (defun gnus-group-visible-select-group (&optional all)
1733 "Select the current group without hiding any articles."
1735 (let ((gnus-inhibit-limiting t))
1736 (gnus-group-read-group all t)))
1738 (defun gnus-group-select-group-ephemerally ()
1739 "Select the current group without doing any processing whatsoever.
1740 You will actually be entered into a group that's a copy of
1741 the current group; no changes you make while in this group will
1744 (require 'gnus-score)
1746 gnus-score-find-score-files-function gnus-apply-kill-hook
1747 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1748 gnus-summary-mode-hook gnus-select-group-hook
1749 (group (gnus-group-group-name))
1750 (method (gnus-find-method-for-group group)))
1751 (gnus-group-read-ephemeral-group
1752 (gnus-group-prefixed-name group method) method)))
1755 (defun gnus-fetch-group (group)
1756 "Start Gnus if necessary and enter GROUP.
1757 Returns whether the fetching was successful or not."
1758 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1759 (unless (get-buffer gnus-group-buffer)
1761 (gnus-group-read-group nil nil group))
1764 (defun gnus-fetch-group-other-frame (group)
1765 "Pop up a frame and enter GROUP."
1767 (let ((window (get-buffer-window gnus-group-buffer)))
1769 (select-frame (window-frame window)))
1770 ((= (length (frame-list)) 1)
1771 (select-frame (make-frame)))
1774 (gnus-fetch-group group))
1776 (defvar gnus-ephemeral-group-server 0)
1778 ;; Enter a group that is not in the group buffer. Non-nil is returned
1779 ;; if selection was successful.
1780 (defun gnus-group-read-ephemeral-group (group method &optional activate
1781 quit-config request-only
1783 "Read GROUP from METHOD as an ephemeral group.
1784 If ACTIVATE, request the group first.
1785 If QUIT-CONFIG, use that window configuration when exiting from the
1787 If REQUEST-ONLY, don't actually read the group; just request it.
1788 If SELECT-ARTICLES, only select those articles.
1790 Return the name of the group if selection was successful."
1791 ;; Transform the select method into a unique server.
1792 (when (stringp method)
1793 (setq method (gnus-server-to-method method)))
1795 `(,(car method) ,(concat (cadr method) "-ephemeral")
1796 (,(intern (format "%s-address" (car method))) ,(cadr method))
1798 (let ((group (if (gnus-group-foreign-p group) group
1799 (gnus-group-prefixed-name group method))))
1803 ,gnus-level-default-subscribed nil nil ,method
1805 ,(if quit-config quit-config
1806 (cons gnus-summary-buffer
1807 gnus-current-window-configuration))))))
1809 (push method gnus-ephemeral-servers)
1810 (set-buffer gnus-group-buffer)
1811 (unless (gnus-check-server method)
1812 (error "Unable to contact server: %s" (gnus-status-message method)))
1814 (gnus-activate-group group 'scan)
1815 (unless (gnus-request-group group)
1816 (error "Couldn't request group: %s"
1817 (nnheader-get-report (car method)))))
1821 (when (gnus-group-read-group t t group select-articles)
1825 (message "Quit reading the ephemeral group")
1828 (defun gnus-group-jump-to-group (group)
1829 "Jump to newsgroup GROUP."
1831 (list (completing-read
1832 "Group: " gnus-active-hashtb nil
1833 (gnus-read-active-file-p)
1834 gnus-group-jump-to-group-prompt
1835 'gnus-group-history)))
1837 (when (equal group "")
1838 (error "Empty group name"))
1840 (unless (gnus-ephemeral-group-p group)
1841 ;; Either go to the line in the group buffer...
1842 (unless (gnus-group-goto-group group)
1843 ;; ... or insert the line.
1844 (gnus-group-update-group group)
1845 (gnus-group-goto-group group)))
1846 ;; Adjust cursor point.
1847 (gnus-group-position-point))
1849 (defun gnus-group-goto-group (group &optional far test-marked)
1850 "Goto to newsgroup GROUP.
1851 If FAR, it is likely that the group is not on the current line.
1852 If TEST-MARKED, the line must be marked."
1856 ;; It's quite likely that we are on the right line, so
1857 ;; we check the current line first.
1859 (eq (get-text-property (point) 'gnus-group)
1860 (gnus-intern-safe group gnus-active-hashtb))
1861 (or (not test-marked) (gnus-group-mark-line-p)))
1863 ;; Previous and next line are also likely, so we check them as well.
1867 (and (eq (get-text-property (point) 'gnus-group)
1868 (gnus-intern-safe group gnus-active-hashtb))
1869 (or (not test-marked) (gnus-group-mark-line-p)))))
1875 (and (eq (get-text-property (point) 'gnus-group)
1876 (gnus-intern-safe group gnus-active-hashtb))
1877 (or (not test-marked) (gnus-group-mark-line-p)))))
1881 (goto-char (point-min))
1883 (while (and (not found)
1888 (gnus-intern-safe group gnus-active-hashtb))))
1889 (if (gnus-group-mark-line-p)
1894 ;; Search through the entire buffer.
1897 (point-min) (point-max)
1898 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1900 (defun gnus-group-next-group (n &optional silent)
1901 "Go to next N'th newsgroup.
1902 If N is negative, search backward instead.
1903 Returns the difference between N and the number of skips actually
1906 (gnus-group-next-unread-group n t nil silent))
1908 (defun gnus-group-next-unread-group (n &optional all level silent)
1909 "Go to next N'th unread newsgroup.
1910 If N is negative, search backward instead.
1911 If ALL is non-nil, choose any newsgroup, unread or not.
1912 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1913 such group can be found, the next group with a level higher than
1915 Returns the difference between N and the number of skips actually
1918 (let ((backward (< n 0))
1921 (gnus-group-search-forward
1922 backward (or (not gnus-group-goto-unread) all) level))
1926 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1927 (if level " on this level or higher" "")))
1930 (defun gnus-group-prev-group (n)
1931 "Go to previous N'th newsgroup.
1932 Returns the difference between N and the number of skips actually
1935 (gnus-group-next-unread-group (- n) t))
1937 (defun gnus-group-prev-unread-group (n)
1938 "Go to previous N'th unread newsgroup.
1939 Returns the difference between N and the number of skips actually
1942 (gnus-group-next-unread-group (- n)))
1944 (defun gnus-group-next-unread-group-same-level (n)
1945 "Go to next N'th unread newsgroup on the same level.
1946 If N is negative, search backward instead.
1947 Returns the difference between N and the number of skips actually
1950 (gnus-group-next-unread-group n t (gnus-group-group-level))
1951 (gnus-group-position-point))
1953 (defun gnus-group-prev-unread-group-same-level (n)
1954 "Go to next N'th unread newsgroup on the same level.
1955 Returns the difference between N and the number of skips actually
1958 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1959 (gnus-group-position-point))
1961 (defun gnus-group-best-unread-group (&optional exclude-group)
1962 "Go to the group with the highest level.
1963 If EXCLUDE-GROUP, do not go to that group."
1965 (goto-char (point-min))
1969 (setq unread (get-text-property (point) 'gnus-unread))
1970 (when (and (numberp unread) (> unread 0))
1971 (when (and (get-text-property (point) 'gnus-level)
1972 (< (get-text-property (point) 'gnus-level) best)
1973 (or (not exclude-group)
1974 (not (equal exclude-group (gnus-group-group-name)))))
1975 (setq best (get-text-property (point) 'gnus-level))
1976 (setq best-point (point))))
1979 (goto-char best-point))
1980 (gnus-summary-position-point)
1981 (and best-point (gnus-group-group-name))))
1983 (defun gnus-group-first-unread-group ()
1984 "Go to the first group with unread articles."
1987 (let ((opoint (point))
1989 (goto-char (point-min))
1990 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1991 (and (numberp unread) ; Not a topic.
1992 (not (zerop unread))) ; Has unread articles.
1993 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1996 nil)) ; Not success.
1997 (gnus-group-position-point)))
1999 (defun gnus-group-enter-server-mode ()
2000 "Jump to the server buffer."
2002 (gnus-enter-server-buffer))
2004 (defun gnus-group-make-group (name &optional method address args)
2005 "Add a new newsgroup.
2006 The user will be prompted for a NAME, for a select METHOD, and an
2010 (gnus-read-group "Group name: ")
2011 (gnus-read-method "From method: ")))
2013 (when (stringp method)
2014 (setq method (or (gnus-server-to-method method) method)))
2015 (let* ((meth (gnus-method-simplify
2017 (not (gnus-server-equal method gnus-select-method)))
2018 (if address (list (intern method) address)
2020 (nname (if method (gnus-group-prefixed-name name meth) name))
2022 (when (gnus-gethash nname gnus-newsrc-hashtb)
2023 (error "Group %s already exists" nname))
2024 ;; Subscribe to the new group.
2025 (gnus-group-change-level
2026 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2027 gnus-level-default-subscribed gnus-level-killed
2028 (and (gnus-group-group-name)
2029 (gnus-gethash (gnus-group-group-name)
2030 gnus-newsrc-hashtb))
2033 (gnus-set-active nname (cons 1 0))
2034 (unless (gnus-ephemeral-group-p name)
2036 (concat "(gnus-group-set-info '"
2037 (gnus-prin1-to-string (cdr info)) ")")))
2039 (gnus-group-insert-group-line-info nname)
2041 (gnus-group-position-point)
2043 ;; Load the backend and try to make the backend create
2044 ;; the group as well.
2045 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2047 gnus-valid-select-methods)
2049 (gnus-check-server meth)
2050 (when (gnus-check-backend-function 'request-create-group nname)
2051 (gnus-request-create-group nname nil args))
2054 (defun gnus-group-delete-groups (&optional arg)
2055 "Delete the current group. Only meaningful with editable groups."
2057 (let ((n (length (gnus-group-process-prefix arg))))
2058 (when (gnus-yes-or-no-p
2060 "Delete this 1 group? "
2061 (format "Delete these %d groups? " n)))
2062 (gnus-group-iterate arg
2064 (gnus-group-delete-group group nil t))))))
2066 (defun gnus-group-delete-group (group &optional force no-prompt)
2067 "Delete the current group. Only meaningful with editable groups.
2068 If FORCE (the prefix) is non-nil, all the articles in the group will
2069 be deleted. This is \"deleted\" as in \"removed forever from the face
2070 of the Earth\". There is no undo. The user will be prompted before
2071 doing the deletion."
2073 (list (gnus-group-group-name)
2074 current-prefix-arg))
2076 (error "No group to rename"))
2077 (unless (gnus-check-backend-function 'request-delete-group group)
2078 (error "This backend does not support group deletion"))
2080 (if (and (not no-prompt)
2081 (not (gnus-yes-or-no-p
2083 "Do you really want to delete %s%s? "
2084 group (if force " and all its contents" "")))))
2086 (gnus-message 6 "Deleting group %s..." group)
2087 (if (not (gnus-request-delete-group group force))
2088 (gnus-error 3 "Couldn't delete group %s" group)
2089 (gnus-message 6 "Deleting group %s...done" group)
2090 (gnus-group-goto-group group)
2091 (gnus-group-kill-group 1 t)
2092 (gnus-sethash group nil gnus-active-hashtb)
2094 (gnus-group-position-point)))
2096 (defun gnus-group-rename-group (group new-name)
2097 "Rename group from GROUP to NEW-NAME.
2098 When used interactively, GROUP is the group under point
2099 and NEW-NAME will be prompted for."
2102 (gnus-group-group-name)
2104 (unless (gnus-check-backend-function
2105 'request-rename-group (gnus-group-group-name))
2106 (error "This backend does not support renaming groups"))
2107 (gnus-read-group "Rename group to: "
2108 (gnus-group-real-name (gnus-group-group-name))))))
2110 (unless (gnus-check-backend-function 'request-rename-group group)
2111 (error "This backend does not support renaming groups"))
2113 (error "No group to rename"))
2114 (when (equal (gnus-group-real-name group) new-name)
2115 (error "Can't rename to the same name"))
2117 ;; We find the proper prefixed name.
2119 (if (gnus-group-native-p group)
2123 (gnus-group-prefixed-name
2124 (gnus-group-real-name new-name)
2125 (gnus-info-method (gnus-get-info group)))))
2127 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2130 (gnus-group-goto-group group)
2131 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2132 (gnus-request-rename-group group new-name))))
2133 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2134 ;; We rename the group internally by killing it...
2135 (gnus-group-kill-group)
2136 ;; ... changing its name ...
2137 (setcar (cdar gnus-list-of-killed-groups) new-name)
2138 ;; ... and then yanking it. Magic!
2139 (gnus-group-yank-group)
2140 (gnus-set-active new-name (gnus-active group))
2141 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2143 (setq gnus-killed-list (delete group gnus-killed-list))
2144 (gnus-set-active group nil)
2145 (gnus-dribble-touch)
2146 (gnus-group-position-point)))
2148 (defun gnus-group-edit-group (group &optional part)
2149 "Edit the group on the current line."
2150 (interactive (list (gnus-group-group-name)))
2151 (let ((part (or part 'info))
2154 (error "No group on current line"))
2155 (unless (setq info (gnus-get-info group))
2156 (error "Killed group; can't be edited"))
2158 (gnus-close-group group))
2160 ;; Find the proper form to edit.
2161 (cond ((eq part 'method)
2162 (or (gnus-info-method info) "native"))
2164 (gnus-info-params info))
2166 ;; The proper documentation.
2168 "Editing the %s for `%s'."
2170 ((eq part 'method) "select method")
2171 ((eq part 'params) "group parameters")
2173 (gnus-group-decoded-name group))
2175 (gnus-group-edit-group-done ',part ,group form)))))
2177 (defun gnus-group-edit-group-method (group)
2178 "Edit the select method of GROUP."
2179 (interactive (list (gnus-group-group-name)))
2180 (gnus-group-edit-group group 'method))
2182 (defun gnus-group-edit-group-parameters (group)
2183 "Edit the group parameters of GROUP."
2184 (interactive (list (gnus-group-group-name)))
2185 (gnus-group-edit-group group 'params))
2187 (defun gnus-group-edit-group-done (part group form)
2189 (let* ((method (cond ((eq part 'info) (nth 4 form))
2190 ((eq part 'method) form)
2192 (info (cond ((eq part 'info) form)
2193 ((eq part 'method) (gnus-get-info group))
2196 (if (or (not method)
2198 gnus-select-method method))
2199 (gnus-group-real-name (car info))
2200 (gnus-group-prefixed-name
2201 (gnus-group-real-name (car info)) method))
2203 (when (and new-group
2204 (not (equal new-group group)))
2205 (when (gnus-group-goto-group group)
2206 (gnus-group-kill-group 1))
2207 (gnus-activate-group new-group))
2209 (if (not (and info new-group))
2210 (gnus-group-set-info form (or new-group group) part)
2211 (setq info (gnus-copy-sequence info))
2212 (setcar info new-group)
2213 (unless (gnus-server-equal method "native")
2214 (unless (nthcdr 3 info)
2215 (nconc info (list nil nil)))
2216 (unless (nthcdr 4 info)
2217 (nconc info (list nil)))
2218 (gnus-info-set-method info method))
2219 (gnus-group-set-info info))
2220 (gnus-group-update-group (or new-group group))
2221 (gnus-group-position-point)))
2223 (defun gnus-group-make-useful-group (group method)
2224 "Create one of the groups described in `gnus-useful-groups'."
2226 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2228 gnus-useful-groups)))
2229 (list (cadr entry) (caddr entry))))
2230 (setq method (gnus-copy-sequence method))
2232 (while (setq entry (memq (assq 'eval method) method))
2233 (setcar entry (eval (cadar entry)))))
2234 (gnus-group-make-group group method))
2236 (defun gnus-group-make-help-group ()
2237 "Create the Gnus documentation group."
2239 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2240 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2241 (when (gnus-gethash name gnus-newsrc-hashtb)
2242 (error "Documentation group already exists"))
2244 (gnus-message 1 "Couldn't find doc group")
2245 (gnus-group-make-group
2246 (gnus-group-real-name name)
2247 (list 'nndoc "gnus-help"
2248 (list 'nndoc-address file)
2249 (list 'nndoc-article-type 'mbox)))))
2250 (gnus-group-position-point))
2252 (defun gnus-group-make-doc-group (file type)
2253 "Create a group that uses a single file as the source."
2255 (list (read-file-name "File name: ")
2256 (and current-prefix-arg 'ask)))
2257 (when (eq type 'ask)
2262 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2264 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2265 ((= char ?b) 'babyl)
2266 ((= char ?d) 'digest)
2267 ((= char ?f) 'forward)
2269 ((= char ?g) 'guess)
2270 (t (setq err (format "%c unknown. " char))
2273 (let* ((file (expand-file-name file))
2274 (name (gnus-generate-new-group-name
2275 (gnus-group-prefixed-name
2276 (file-name-nondirectory file) '(nndoc "")))))
2277 (gnus-group-make-group
2278 (gnus-group-real-name name)
2280 (list 'nndoc-address file)
2281 (list 'nndoc-article-type (or type 'guess))))))
2283 (defvar nnweb-type-definition)
2284 (defvar gnus-group-web-type-history nil)
2285 (defvar gnus-group-web-search-history nil)
2286 (defun gnus-group-make-web-group (&optional solid)
2287 "Create an ephemeral nnweb group.
2288 If SOLID (the prefix), create a solid group."
2292 (if solid (gnus-read-group "Group name: ")
2293 (message-unique-id)))
2294 (default-type (or (car gnus-group-web-type-history)
2295 (symbol-name (caar nnweb-type-definition))))
2299 (format "Search engine type (default %s): " default-type)
2300 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2301 nnweb-type-definition)
2302 nil t nil 'gnus-group-web-type-history)
2307 (cons (or (car gnus-group-web-search-history) "") 0)
2308 'gnus-group-web-search-history))
2310 `(nnweb ,group (nnweb-search ,search)
2311 (nnweb-type ,(intern type))
2312 (nnweb-ephemeral-p t))))
2314 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2315 (gnus-group-read-ephemeral-group
2317 (cons (current-buffer)
2318 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2320 (defvar nnwarchive-type-definition)
2321 (defvar gnus-group-warchive-type-history nil)
2322 (defvar gnus-group-warchive-login-history nil)
2323 (defvar gnus-group-warchive-address-history nil)
2325 (defun gnus-group-make-warchive-group ()
2326 "Create a nnwarchive group."
2328 (require 'nnwarchive)
2329 (let* ((group (gnus-read-group "Group name: "))
2330 (default-type (or (car gnus-group-warchive-type-history)
2331 (symbol-name (caar nnwarchive-type-definition))))
2335 (format "Warchive type (default %s): " default-type)
2336 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2337 nnwarchive-type-definition)
2338 nil t nil 'gnus-group-warchive-type-history)
2340 (address (read-string "Warchive address: "
2341 nil 'gnus-group-warchive-address-history))
2342 (default-login (or (car gnus-group-warchive-login-history)
2347 (format "Warchive login (default %s): " user-mail-address)
2348 default-login 'gnus-group-warchive-login-history)
2351 `(nnwarchive ,address
2352 (nnwarchive-type ,(intern type))
2353 (nnwarchive-login ,login))))
2354 (gnus-group-make-group group method)))
2356 (defun gnus-group-make-archive-group (&optional all)
2357 "Create the (ding) Gnus archive group of the most recent articles.
2358 Given a prefix, create a full group."
2360 (let ((group (gnus-group-prefixed-name
2361 (if all "ding.archives" "ding.recent") '(nndir ""))))
2362 (when (gnus-gethash group gnus-newsrc-hashtb)
2363 (error "Archive group already exists"))
2364 (gnus-group-make-group
2365 (gnus-group-real-name group)
2366 (list 'nndir (if all "hpc" "edu")
2367 (list 'nndir-directory
2368 (if all gnus-group-archive-directory
2369 gnus-group-recent-archive-directory))))
2370 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2372 (defun gnus-group-make-directory-group (dir)
2373 "Create an nndir group.
2374 The user will be prompted for a directory. The contents of this
2375 directory will be used as a newsgroup. The directory should contain
2376 mail messages or news articles in files that have numeric names."
2378 (list (read-file-name "Create group from directory: ")))
2379 (unless (file-exists-p dir)
2380 (error "No such directory"))
2381 (unless (file-directory-p dir)
2382 (error "Not a directory"))
2386 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2388 (gnus-group-prefixed-name
2389 (concat (file-name-as-directory (directory-file-name dir))
2392 (setq ext (format "<%d>" (setq i (1+ i)))))
2393 (gnus-group-make-group
2394 (gnus-group-real-name group)
2395 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2397 (defun gnus-group-make-kiboze-group (group address scores)
2398 "Create an nnkiboze group.
2399 The user will be prompted for a name, a regexp to match groups, and
2400 score file entries for articles to include in the group."
2403 (read-string "nnkiboze group name: ")
2404 (read-string "Source groups (regexp): ")
2405 (let ((headers (mapcar (lambda (group) (list group))
2406 '("subject" "from" "number" "date" "message-id"
2407 "references" "chars" "lines" "xref"
2408 "followup" "all" "body" "head")))
2409 scores header regexp regexps)
2410 (while (not (equal "" (setq header (completing-read
2411 "Match on header: " headers nil t))))
2413 (while (not (equal "" (setq regexp (read-string
2414 (format "Match on %s (regexp): "
2416 (push (list regexp nil nil 'r) regexps))
2417 (push (cons header regexps) scores))
2419 (gnus-group-make-group group "nnkiboze" address)
2420 (let* ((nnkiboze-current-group group)
2421 (score-file (car (nnkiboze-score-file "")))
2422 (score-dir (file-name-directory score-file)))
2423 (unless (file-exists-p score-dir)
2424 (make-directory score-dir))
2425 (with-temp-file score-file
2426 (let (emacs-lisp-mode-hook)
2427 (pp scores (current-buffer))))))
2429 (defun gnus-group-add-to-virtual (n vgroup)
2430 "Add the current group to a virtual group."
2432 (list current-prefix-arg
2433 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2435 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2436 (error "%s is not an nnvirtual group" vgroup))
2437 (gnus-close-group vgroup)
2438 (let* ((groups (gnus-group-process-prefix n))
2439 (method (gnus-info-method (gnus-get-info vgroup))))
2440 (setcar (cdr method)
2442 (nth 1 method) "\\|"
2445 (gnus-group-remove-mark s)
2446 (concat "\\(^" (regexp-quote s) "$\\)"))
2448 (gnus-group-position-point))
2450 (defun gnus-group-make-empty-virtual (group)
2451 "Create a new, fresh, empty virtual group."
2452 (interactive "sCreate new, empty virtual group: ")
2453 (let* ((method (list 'nnvirtual "^$"))
2454 (pgroup (gnus-group-prefixed-name group method)))
2455 ;; Check whether it exists already.
2456 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2457 (error "Group %s already exists" pgroup))
2458 ;; Subscribe the new group after the group on the current line.
2459 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2460 (gnus-group-update-group pgroup)
2462 (gnus-group-position-point)))
2464 (defun gnus-group-enter-directory (dir)
2465 "Enter an ephemeral nneething group."
2466 (interactive "DDirectory to read: ")
2467 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2468 (leaf (gnus-group-prefixed-name
2469 (file-name-nondirectory (directory-file-name dir))
2471 (name (gnus-generate-new-group-name leaf)))
2472 (unless (gnus-group-read-ephemeral-group
2474 (cons (current-buffer)
2475 (if (eq major-mode 'gnus-summary-mode)
2477 (error "Couldn't enter %s" dir))))
2480 (autoload 'nnimap-expunge "nnimap")
2481 (autoload 'nnimap-acl-get "nnimap")
2482 (autoload 'nnimap-acl-edit "nnimap"))
2484 (defun gnus-group-nnimap-expunge (group)
2485 "Expunge deleted articles in current nnimap GROUP."
2486 (interactive (list (gnus-group-group-name)))
2487 (let ((mailbox (gnus-group-real-name group)) method)
2489 (error "No group on current line"))
2490 (unless (gnus-get-info group)
2491 (error "Killed group; can't be edited"))
2492 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2493 (error "%s is not an nnimap group" group))
2494 (nnimap-expunge mailbox (cadr method))))
2496 (defun gnus-group-nnimap-edit-acl (group)
2497 "Edit the Access Control List of current nnimap GROUP."
2498 (interactive (list (gnus-group-group-name)))
2499 (let ((mailbox (gnus-group-real-name group)) method acl)
2501 (error "No group on current line"))
2502 (unless (gnus-get-info group)
2503 (error "Killed group; can't be edited"))
2504 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2505 (error "%s is not an nnimap group" group))
2506 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2507 (error "Server does not support ACL's"))
2508 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2510 An access control list is a list of (identifier . rights) elements.
2512 The identifier string specifies the corresponding user. The
2513 identifier \"anyone\" is reserved to refer to the universal identity.
2515 Rights is a string listing a (possibly empty) set of alphanumeric
2516 characters, each character listing a set of operations which is being
2517 controlled. Letters are reserved for ``standard'' rights, listed
2518 below. Digits are reserved for implementation or site defined rights.
2520 l - lookup (mailbox is visible to LIST/LSUB commands)
2521 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2522 SEARCH, COPY from mailbox)
2523 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2524 w - write (STORE flags other than \\SEEN and \\DELETED)
2525 i - insert (perform APPEND, COPY into mailbox)
2526 p - post (send mail to submission address for mailbox,
2527 not enforced by IMAP4 itself)
2528 c - create and delete mailbox (CREATE new sub-mailboxes in any
2529 implementation-defined hierarchy, RENAME or DELETE mailbox)
2530 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2531 a - administer (perform SETACL)" group)
2534 ,mailbox ',method ',acl form)))))
2536 ;; Group sorting commands
2537 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2539 (defun gnus-group-sort-groups (func &optional reverse)
2540 "Sort the group buffer according to FUNC.
2541 When used interactively, the sorting function used will be
2542 determined by the `gnus-group-sort-function' variable.
2543 If REVERSE (the prefix), reverse the sorting order."
2544 (interactive (list gnus-group-sort-function current-prefix-arg))
2545 (funcall gnus-group-sort-alist-function
2546 (gnus-make-sort-function func) reverse)
2547 (gnus-group-list-groups)
2548 (gnus-dribble-touch))
2550 (defun gnus-group-sort-flat (func reverse)
2551 ;; We peel off the dummy group from the alist.
2553 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2554 (pop gnus-newsrc-alist))
2556 (setq gnus-newsrc-alist
2557 (sort gnus-newsrc-alist func))
2559 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2560 ;; Regenerate the hash table.
2561 (gnus-make-hashtable-from-newsrc-alist)))
2563 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2564 "Sort the group buffer alphabetically by group name.
2565 If REVERSE, sort in reverse order."
2567 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2569 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2570 "Sort the group buffer by number of unread articles.
2571 If REVERSE, sort in reverse order."
2573 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2575 (defun gnus-group-sort-groups-by-level (&optional reverse)
2576 "Sort the group buffer by group level.
2577 If REVERSE, sort in reverse order."
2579 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2581 (defun gnus-group-sort-groups-by-score (&optional reverse)
2582 "Sort the group buffer by group score.
2583 If REVERSE, sort in reverse order."
2585 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2587 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2588 "Sort the group buffer by group rank.
2589 If REVERSE, sort in reverse order."
2591 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2593 (defun gnus-group-sort-groups-by-method (&optional reverse)
2594 "Sort the group buffer alphabetically by backend name.
2595 If REVERSE, sort in reverse order."
2597 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2599 ;;; Selected group sorting.
2601 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2602 "Sort the process/prefixed groups."
2603 (interactive (list current-prefix-arg gnus-group-sort-function))
2604 (let ((groups (gnus-group-process-prefix n)))
2605 (funcall gnus-group-sort-selected-function
2606 groups (gnus-make-sort-function func) reverse)
2607 (gnus-group-list-groups)))
2609 (defun gnus-group-sort-selected-flat (groups func reverse)
2610 (let (entries infos)
2611 ;; First find all the group entries for these groups.
2613 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2615 ;; Then sort the infos.
2619 (lambda (entry) (car entry))
2620 (setq entries (nreverse entries)))
2623 (setq infos (nreverse infos)))
2624 ;; Go through all the infos and replace the old entries
2625 ;; with the new infos.
2627 (setcar (car entries) (pop infos))
2629 ;; Update the hashtable.
2630 (gnus-make-hashtable-from-newsrc-alist)))
2632 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2633 "Sort the group buffer alphabetically by group name.
2634 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2635 sort in reverse order."
2636 (interactive (gnus-interactive "P\ny"))
2637 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2639 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2640 "Sort the group buffer by number of unread articles.
2641 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2642 sort in reverse order."
2643 (interactive (gnus-interactive "P\ny"))
2644 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2646 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2647 "Sort the group buffer by group level.
2648 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2649 sort in reverse order."
2650 (interactive (gnus-interactive "P\ny"))
2651 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2653 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2654 "Sort the group buffer by group score.
2655 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2656 sort in reverse order."
2657 (interactive (gnus-interactive "P\ny"))
2658 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2660 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2661 "Sort the group buffer by group rank.
2662 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2663 sort in reverse order."
2664 (interactive (gnus-interactive "P\ny"))
2665 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2667 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2668 "Sort the group buffer alphabetically by backend name.
2669 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2670 sort in reverse order."
2671 (interactive (gnus-interactive "P\ny"))
2672 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2674 ;;; Sorting predicates.
2676 (defun gnus-group-sort-by-alphabet (info1 info2)
2677 "Sort alphabetically."
2678 (string< (gnus-info-group info1) (gnus-info-group info2)))
2680 (defun gnus-group-sort-by-real-name (info1 info2)
2681 "Sort alphabetically on real (unprefixed) names."
2682 (string< (gnus-group-real-name (gnus-info-group info1))
2683 (gnus-group-real-name (gnus-info-group info2))))
2685 (defun gnus-group-sort-by-unread (info1 info2)
2686 "Sort by number of unread articles."
2687 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2688 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2689 (< (or (and (numberp n1) n1) 0)
2690 (or (and (numberp n2) n2) 0))))
2692 (defun gnus-group-sort-by-level (info1 info2)
2694 (< (gnus-info-level info1) (gnus-info-level info2)))
2696 (defun gnus-group-sort-by-method (info1 info2)
2697 "Sort alphabetically by backend name."
2698 (string< (symbol-name (car (gnus-find-method-for-group
2699 (gnus-info-group info1) info1)))
2700 (symbol-name (car (gnus-find-method-for-group
2701 (gnus-info-group info2) info2)))))
2703 (defun gnus-group-sort-by-score (info1 info2)
2704 "Sort by group score."
2705 (< (gnus-info-score info1) (gnus-info-score info2)))
2707 (defun gnus-group-sort-by-rank (info1 info2)
2708 "Sort by level and score."
2709 (let ((level1 (gnus-info-level info1))
2710 (level2 (gnus-info-level info2)))
2711 (or (< level1 level2)
2712 (and (= level1 level2)
2713 (> (gnus-info-score info1) (gnus-info-score info2))))))
2717 (defun gnus-group-clear-data (&optional arg)
2718 "Clear all marks and read ranges from the current group."
2720 (gnus-group-iterate arg
2723 (gnus-info-clear-data (setq info (gnus-get-info group)))
2724 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2725 (when (gnus-group-goto-group group)
2726 (gnus-group-update-group-line))))))
2728 (defun gnus-group-clear-data-on-native-groups ()
2729 "Clear all marks and read ranges from all native groups."
2731 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2732 (let ((alist (cdr gnus-newsrc-alist))
2734 (while (setq info (pop alist))
2735 (when (gnus-group-native-p (gnus-info-group info))
2736 (gnus-info-clear-data info)))
2737 (gnus-get-unread-articles)
2738 (gnus-dribble-touch)
2739 (when (gnus-y-or-n-p
2740 "Move the cache away to avoid problems in the future? ")
2741 (call-interactively 'gnus-cache-move-cache)))))
2743 (defun gnus-info-clear-data (info)
2744 "Clear all marks and read ranges from INFO."
2745 (let ((group (gnus-info-group info)))
2748 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2749 (gnus-info-set-read ',info ',(gnus-info-read info))
2750 (when (gnus-group-goto-group ,group)
2751 (gnus-group-update-group-line))))
2752 (gnus-info-set-read info nil)
2753 (when (gnus-info-marks info)
2754 (gnus-info-set-marks info nil))))
2756 ;; Group catching up.
2758 (defun gnus-group-catchup-current (&optional n all)
2759 "Mark all unread articles in the current newsgroup as read.
2760 If prefix argument N is numeric, the next N newsgroups will be
2761 caught up. If ALL is non-nil, marked articles will also be marked as
2762 read. Cross references (Xref: header) of articles are ignored.
2763 The number of newsgroups that this function was unable to catch
2766 (let ((groups (gnus-group-process-prefix n))
2769 (unless groups (error "No groups selected"))
2771 (or (not gnus-interactive-catchup) ;Without confirmation?
2776 "Do you really want to mark all articles in %s as read? "
2777 "Mark all unread articles in %s as read? ")
2778 (if (= (length groups) 1)
2780 (format "these %d groups" (length groups)))))))
2782 (while (setq group (pop groups))
2783 (gnus-group-remove-mark group)
2784 ;; Virtual groups have to be given special treatment.
2785 (let ((method (gnus-find-method-for-group group)))
2786 (when (eq 'nnvirtual (car method))
2787 (nnvirtual-catchup-group
2788 (gnus-group-real-name group) (nth 1 method) all)))
2789 (if (>= (gnus-group-level group) gnus-level-zombie)
2790 (gnus-message 2 "Dead groups can't be caught up")
2792 (gnus-group-goto-group group)
2793 (gnus-group-catchup group all))
2794 (gnus-group-update-group-line)
2795 (setq ret (1+ ret)))))
2796 (gnus-group-next-unread-group 1)
2799 (defun gnus-group-catchup-current-all (&optional n)
2800 "Mark all articles in current newsgroup as read.
2801 Cross references (Xref: header) of articles are ignored."
2803 (gnus-group-catchup-current n 'all))
2805 (defun gnus-group-catchup (group &optional all)
2806 "Mark all articles in GROUP as read.
2807 If ALL is non-nil, all articles are marked as read.
2808 The return value is the number of articles that were marked as read,
2809 or nil if no action could be taken."
2810 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2812 ;; Remove entries for this group.
2813 (nnmail-purge-split-history (gnus-group-real-name group))
2814 ;; Do the updating only if the newsgroup isn't killed.
2815 (if (not (numberp (car entry)))
2816 (gnus-message 1 "Can't catch up %s; non-active group" group)
2817 ;; Do auto-expirable marks if that's required.
2818 (when (gnus-group-auto-expirable-p group)
2819 (gnus-add-marked-articles
2820 group 'expire (gnus-list-of-unread-articles group))
2822 (let ((marks (nth 3 (nth 2 entry))))
2823 (gnus-add-marked-articles
2824 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2825 (gnus-add-marked-articles
2826 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2828 (gnus-update-read-articles group nil)
2829 ;; Also nix out the lists of marks and dormants.
2831 (gnus-add-marked-articles group 'tick nil nil 'force)
2832 (gnus-add-marked-articles group 'dormant nil nil 'force))
2833 (let ((gnus-newsgroup-name group))
2834 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2837 (defun gnus-group-expire-articles (&optional n)
2838 "Expire all expirable articles in the current newsgroup."
2840 (let ((groups (gnus-group-process-prefix n))
2843 (error "No groups to expire"))
2844 (while (setq group (pop groups))
2845 (gnus-group-remove-mark group)
2846 (gnus-group-expire-articles-1 group)
2847 (gnus-dribble-touch)
2848 (gnus-group-position-point))))
2850 (defun gnus-group-expire-articles-1 (group)
2851 (when (gnus-check-backend-function 'request-expire-articles group)
2852 (gnus-message 6 "Expiring articles in %s..." group)
2853 (let* ((info (gnus-get-info group))
2854 (expirable (if (gnus-group-total-expirable-p group)
2855 (cons nil (gnus-list-of-read-articles group))
2856 (assq 'expire (gnus-info-marks info))))
2857 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2858 (nnmail-expiry-target
2859 (or (gnus-group-find-parameter group 'expiry-target)
2860 nnmail-expiry-target)))
2862 (gnus-check-group group)
2865 (gnus-compress-sequence
2867 ;; We set the expiry variables to the group
2869 (let ((nnmail-expiry-wait-function nil)
2870 (nnmail-expiry-wait expiry-wait))
2871 (gnus-request-expire-articles
2872 (gnus-uncompress-sequence (cdr expirable)) group))
2873 ;; Just expire using the normal expiry values.
2874 (gnus-request-expire-articles
2875 (gnus-uncompress-sequence (cdr expirable)) group))))
2876 (gnus-close-group group))
2877 (gnus-message 6 "Expiring articles in %s...done" group)
2878 ;; Return the list of un-expired articles.
2881 (defun gnus-group-expire-all-groups ()
2882 "Expire all expirable articles in all newsgroups."
2885 (gnus-message 5 "Expiring...")
2886 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2887 (cdr gnus-newsrc-alist))))
2888 (gnus-group-expire-articles nil)))
2889 (gnus-group-position-point)
2890 (gnus-message 5 "Expiring...done"))
2892 (defun gnus-group-set-current-level (n level)
2893 "Set the level of the next N groups to LEVEL."
2898 (let ((s (read-string
2899 (format "Level (default %s): "
2900 (or (gnus-group-group-level)
2901 gnus-level-default-subscribed)))))
2902 (if (string-match "^\\s-*$" s)
2903 (int-to-string (or (gnus-group-group-level)
2904 gnus-level-default-subscribed))
2906 (unless (and (>= level 1) (<= level gnus-level-killed))
2907 (error "Invalid level: %d" level))
2908 (let ((groups (gnus-group-process-prefix n))
2910 (while (setq group (pop groups))
2911 (gnus-group-remove-mark group)
2912 (gnus-message 6 "Changed level of %s from %d to %d"
2913 group (or (gnus-group-group-level) gnus-level-killed)
2915 (gnus-group-change-level
2916 group level (or (gnus-group-group-level) gnus-level-killed))
2917 (gnus-group-update-group-line)))
2918 (gnus-group-position-point))
2920 (defun gnus-group-unsubscribe (&optional n)
2921 "Unsubscribe the current group."
2923 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2925 (defun gnus-group-subscribe (&optional n)
2926 "Subscribe the current group."
2928 (gnus-group-unsubscribe-current-group n 'subscribe))
2930 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2931 "Toggle subscription of the current group.
2932 If given numerical prefix, toggle the N next groups."
2934 (let ((groups (gnus-group-process-prefix n))
2937 (setq group (car groups)
2938 groups (cdr groups))
2939 (gnus-group-remove-mark group)
2940 (gnus-group-unsubscribe-group
2943 ((eq do-sub 'unsubscribe)
2944 gnus-level-default-unsubscribed)
2945 ((eq do-sub 'subscribe)
2946 gnus-level-default-subscribed)
2947 ((<= (gnus-group-group-level) gnus-level-subscribed)
2948 gnus-level-default-unsubscribed)
2950 gnus-level-default-subscribed))
2952 (gnus-group-update-group-line))
2953 (gnus-group-next-group 1)))
2955 (defun gnus-group-unsubscribe-group (group &optional level silent)
2956 "Toggle subscription to GROUP.
2957 Killed newsgroups are subscribed. If SILENT, don't try to update the
2960 (list (completing-read
2961 "Group: " gnus-active-hashtb nil
2962 (gnus-read-active-file-p)
2964 'gnus-group-history)))
2965 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2967 ((string-match "^[ \t]*$" group)
2968 (error "Empty group name"))
2970 ;; Toggle subscription flag.
2971 (gnus-group-change-level
2972 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2973 gnus-level-subscribed)
2974 (1+ gnus-level-subscribed)
2975 gnus-level-default-subscribed)))
2977 (gnus-group-update-group group)))
2978 ((and (stringp group)
2979 (or (not (gnus-read-active-file-p))
2980 (gnus-active group)))
2981 ;; Add new newsgroup.
2982 (gnus-group-change-level
2984 (if level level gnus-level-default-subscribed)
2985 (or (and (member group gnus-zombie-list)
2988 (when (gnus-group-group-name)
2989 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2991 (gnus-group-update-group group)))
2992 (t (error "No such newsgroup: %s" group)))
2993 (gnus-group-position-point)))
2995 (defun gnus-group-transpose-groups (n)
2996 "Move the current newsgroup up N places.
2997 If given a negative prefix, move down instead. The difference between
2998 N and the number of steps taken is returned."
3000 (unless (gnus-group-group-name)
3001 (error "No group on current line"))
3002 (gnus-group-kill-group 1)
3004 (forward-line (- n))
3005 (gnus-group-yank-group)
3006 (gnus-group-position-point)))
3008 (defun gnus-group-kill-all-zombies (&optional dummy)
3009 "Kill all zombie newsgroups.
3010 The optional DUMMY should always be nil."
3011 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3013 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3014 (setq gnus-zombie-list nil)
3015 (gnus-dribble-touch)
3016 (gnus-group-list-groups)))
3018 (defun gnus-group-kill-region (begin end)
3019 "Kill newsgroups in current region (excluding current point).
3020 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3035 (beginning-of-line) ;Important when LINES < 1
3036 (gnus-group-kill-group lines)))
3038 (defun gnus-group-kill-group (&optional n discard)
3039 "Kill the next N groups.
3040 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3041 However, only groups that were alive can be yanked; already killed
3042 groups or zombie groups can't be yanked.
3043 The return value is the name of the group that was killed, or a list
3046 (let ((buffer-read-only nil)
3047 (groups (gnus-group-process-prefix n))
3048 group entry level out)
3049 (if (< (length groups) 10)
3050 ;; This is faster when there are few groups.
3052 (push (setq group (pop groups)) out)
3053 (gnus-group-remove-mark group)
3054 (setq level (gnus-group-group-level))
3056 (when (and (not discard)
3057 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3060 (gnus-group-goto-group ,(gnus-group-group-name))
3061 (gnus-group-yank-group)))
3062 (push (cons (car entry) (nth 2 entry))
3063 gnus-list-of-killed-groups))
3064 (gnus-group-change-level
3065 (if entry entry group) gnus-level-killed (if entry nil level))
3066 (message "Killed group %s" group))
3067 ;; If there are lots and lots of groups to be killed, we use
3068 ;; this thing instead.
3070 (setq groups (nreverse groups))
3072 (gnus-group-remove-mark (setq group (pop groups)))
3074 (push group gnus-killed-list)
3075 (setq gnus-newsrc-alist
3076 (delq (assoc group gnus-newsrc-alist)
3078 (when gnus-group-change-level-function
3079 (funcall gnus-group-change-level-function
3080 group gnus-level-killed 3))
3082 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3083 (push (cons (car entry) (nth 2 entry))
3084 gnus-list-of-killed-groups)
3085 (setcdr (cdr entry) (cdddr entry)))
3086 ((member group gnus-zombie-list)
3087 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3088 ;; There may be more than one instance displayed.
3089 (while (gnus-group-goto-group group)
3090 (gnus-delete-line)))
3091 (gnus-make-hashtable-from-newsrc-alist)))
3093 (gnus-group-position-point)
3094 (if (< (length out) 2) (car out) (nreverse out))))
3096 (defun gnus-group-yank-group (&optional arg)
3097 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3098 The numeric ARG specifies how many newsgroups are to be yanked. The
3099 name of the newsgroup yanked is returned, or (if several groups are
3100 yanked) a list of yanked groups is returned."
3102 (setq arg (or arg 1))
3103 (let (info group prev out)
3104 (while (>= (decf arg) 0)
3105 (when (not (setq info (pop gnus-list-of-killed-groups)))
3106 (error "No more newsgroups to yank"))
3107 (push (setq group (nth 1 info)) out)
3108 ;; Find which newsgroup to insert this one before - search
3109 ;; backward until something suitable is found. If there are no
3110 ;; other newsgroups in this buffer, just make this newsgroup the
3112 (setq prev (gnus-group-group-name))
3113 (gnus-group-change-level
3114 info (gnus-info-level (cdr info)) gnus-level-killed
3115 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3117 (gnus-group-insert-group-line-info group)
3119 `(when (gnus-group-goto-group ,group)
3120 (gnus-group-kill-group 1))))
3122 (gnus-group-position-point)
3123 (if (< (length out) 2) (car out) (nreverse out))))
3125 (defun gnus-group-kill-level (level)
3126 "Kill all groups that is on a certain LEVEL."
3127 (interactive "nKill all groups on level: ")
3129 ((= level gnus-level-zombie)
3130 (setq gnus-killed-list
3131 (nconc gnus-zombie-list gnus-killed-list))
3132 (setq gnus-zombie-list nil))
3133 ((and (< level gnus-level-zombie)
3135 (or gnus-expert-user
3138 "Do you really want to kill all groups on level %d? "
3140 (let* ((prev gnus-newsrc-alist)
3143 (if (= (gnus-info-level (car alist)) level)
3145 (push (gnus-info-group (car alist)) gnus-killed-list)
3146 (setcdr prev (cdr alist)))
3148 (setq alist (cdr alist)))
3149 (gnus-make-hashtable-from-newsrc-alist)
3150 (gnus-group-list-groups)))
3152 (error "Can't kill; invalid level: %d" level))))
3154 (defun gnus-group-list-all-groups (&optional arg)
3155 "List all newsgroups with level ARG or lower.
3156 Default is gnus-level-unsubscribed, which lists all subscribed and most
3157 unsubscribed groups."
3159 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3161 ;; Redefine this to list ALL killed groups if prefix arg used.
3162 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3163 (defun gnus-group-list-killed (&optional arg)
3164 "List all killed newsgroups in the group buffer.
3165 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3166 entail asking the server for the groups."
3168 ;; Find all possible killed newsgroups if arg.
3170 (gnus-get-killed-groups))
3171 (if (not gnus-killed-list)
3172 (gnus-message 6 "No killed groups")
3173 (let (gnus-group-list-mode)
3174 (funcall gnus-group-prepare-function
3175 gnus-level-killed t gnus-level-killed))
3176 (goto-char (point-min)))
3177 (gnus-group-position-point))
3179 (defun gnus-group-list-zombies ()
3180 "List all zombie newsgroups in the group buffer."
3182 (if (not gnus-zombie-list)
3183 (gnus-message 6 "No zombie groups")
3184 (let (gnus-group-list-mode)
3185 (funcall gnus-group-prepare-function
3186 gnus-level-zombie t gnus-level-zombie))
3187 (goto-char (point-min)))
3188 (gnus-group-position-point))
3190 (defun gnus-group-list-active ()
3191 "List all groups that are available from the server(s)."
3193 ;; First we make sure that we have really read the active file.
3194 (unless (gnus-read-active-file-p)
3195 (let ((gnus-read-active-file t)
3196 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3197 (gnus-read-active-file)))
3198 ;; Find all groups and sort them.
3206 (push (symbol-name sym) list)))
3210 (buffer-read-only nil)
3214 (setq group (pop groups))
3215 (gnus-add-text-properties
3216 (point) (prog1 (1+ (point))
3218 (gnus-group-name-decode group
3219 (gnus-group-name-charset
3222 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3224 'gnus-level (inline (gnus-group-level group)))))
3225 (goto-char (point-min))))
3227 (defun gnus-activate-all-groups (level)
3228 "Activate absolutely all groups."
3229 (interactive (list gnus-level-unsubscribed))
3230 (let ((gnus-activate-level level)
3231 (gnus-activate-foreign-newsgroups level))
3232 (gnus-group-get-new-news)))
3234 (defun gnus-group-get-new-news (&optional arg)
3235 "Get newly arrived articles.
3236 If ARG is a number, it specifies which levels you are interested in
3237 re-scanning. If ARG is non-nil and not a number, this will force
3238 \"hard\" re-reading of the active files from all servers."
3241 (let ((gnus-inhibit-demon t)
3242 ;; Binding this variable will inhibit multiple fetchings
3243 ;; of the same mail source.
3244 (nnmail-fetched-sources (list t)))
3245 (gnus-run-hooks 'gnus-get-new-news-hook)
3247 ;; Read any slave files.
3249 (gnus-master-read-slave-newsrc))
3251 ;; We might read in new NoCeM messages here.
3252 (when (and gnus-use-nocem
3254 (gnus-nocem-scan-groups))
3255 ;; If ARG is not a number, then we read the active file.
3256 (when (and arg (not (numberp arg)))
3257 (let ((gnus-read-active-file t))
3258 (gnus-read-active-file))
3261 ;; If the user wants it, we scan for new groups.
3262 (when (eq gnus-check-new-newsgroups 'always)
3263 (gnus-find-new-newsgroups)))
3265 (setq arg (gnus-group-default-level arg t))
3266 (if (and gnus-read-active-file (not arg))
3268 (gnus-read-active-file)
3269 (gnus-get-unread-articles arg))
3270 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3271 (gnus-get-unread-articles arg)))
3272 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3273 (gnus-group-list-groups (and (numberp arg)
3274 (max (car gnus-group-list-mode) arg)))))
3276 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3277 "Check for newly arrived news in the current group (and the N-1 next groups).
3278 The difference between N and the number of newsgroup checked is returned.
3279 If N is negative, this group and the N-1 previous groups will be checked."
3281 (let* ((groups (gnus-group-process-prefix n))
3282 (ret (if (numberp n) (- n (length groups)) 0))
3286 (gnus-inhibit-demon t)
3287 ;; Binding this variable will inhibit multiple fetchings
3288 ;; of the same mail source.
3289 (nnmail-fetched-sources (list t)))
3290 (gnus-run-hooks 'gnus-get-new-news-hook)
3291 (while (setq group (pop groups))
3292 (gnus-group-remove-mark group)
3293 ;; Bypass any previous denials from the server.
3294 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3295 (if (gnus-activate-group group (if dont-scan nil 'scan))
3297 (gnus-get-unread-articles-in-group
3298 (gnus-get-info group) (gnus-active group) t)
3299 (unless (gnus-virtual-group-p group)
3300 (gnus-close-group group))
3302 (gnus-agent-save-group-info
3303 method (gnus-group-real-name group) (gnus-active group)))
3304 (gnus-group-update-group group))
3305 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3307 (gnus-error 3 "Server denied access")
3308 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3311 (when gnus-goto-next-group-when-activating
3312 (gnus-group-next-unread-group 1 t))
3313 (gnus-summary-position-point)
3316 (defun gnus-group-fetch-faq (group &optional faq-dir)
3317 "Fetch the FAQ for the current group.
3318 If given a prefix argument, prompt for the FAQ dir
3322 (gnus-group-group-name)
3323 (when current-prefix-arg
3325 "Faq dir: " (and (listp gnus-group-faq-directory)
3326 (mapcar (lambda (file) (list file))
3327 gnus-group-faq-directory))))))
3329 (error "No group name given"))
3330 (let ((dirs (or faq-dir gnus-group-faq-directory))
3332 (unless (listp dirs)
3333 (setq dirs (list dirs)))
3334 (while (and (not found)
3335 (setq dir (pop dirs)))
3336 (let ((name (gnus-group-real-name group)))
3337 (setq file (concat (file-name-as-directory dir) name)))
3338 (if (not (file-exists-p file))
3339 (gnus-message 1 "No such file: %s" file)
3340 (let ((enable-local-variables nil))
3344 (defun gnus-group-describe-group (force &optional group)
3345 "Display a description of the current newsgroup."
3346 (interactive (list current-prefix-arg (gnus-group-group-name)))
3347 (let* ((method (gnus-find-method-for-group group))
3348 (mname (gnus-group-prefixed-name "" method))
3351 gnus-description-hashtb)
3352 (gnus-sethash mname nil gnus-description-hashtb))
3354 (error "No group name given"))
3355 (when (or (and gnus-description-hashtb
3356 ;; We check whether this group's method has been
3357 ;; queried for a description file.
3358 (gnus-gethash mname gnus-description-hashtb))
3359 (setq desc (gnus-group-get-description group))
3360 (gnus-read-descriptions-file method))
3362 (or desc (gnus-gethash group gnus-description-hashtb)
3363 "No description available")))))
3365 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3366 (defun gnus-group-describe-all-groups (&optional force)
3367 "Pop up a buffer with descriptions of all newsgroups."
3370 (setq gnus-description-hashtb nil))
3371 (when (not (or gnus-description-hashtb
3372 (gnus-read-all-descriptions-files)))
3373 (error "Couldn't request descriptions file"))
3374 (let ((buffer-read-only nil)
3380 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3381 (insert (format " *: %-20s %s\n"
3382 (gnus-group-name-decode
3383 (symbol-name group) charset)
3384 (gnus-group-name-decode
3385 (symbol-value group) charset))))
3386 (gnus-add-text-properties
3387 b (1+ b) (list 'gnus-group group
3388 'gnus-unread t 'gnus-marked nil
3389 'gnus-level (1+ gnus-level-subscribed))))
3390 gnus-description-hashtb)
3391 (goto-char (point-min))
3392 (gnus-group-position-point)))
3394 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3395 (defun gnus-group-apropos (regexp &optional search-description)
3396 "List all newsgroups that have names that match a regexp."
3397 (interactive "sGnus apropos (regexp): ")
3399 (obuf (current-buffer))
3401 ;; Go through all newsgroups that are known to Gnus.
3404 (and (symbol-name group)
3405 (string-match regexp (symbol-name group))
3406 (symbol-value group)
3407 (push (symbol-name group) groups)))
3409 ;; Also go through all descriptions that are known to Gnus.
3410 (when search-description
3413 (and (string-match regexp (symbol-value group))
3414 (push (symbol-name group) groups)))
3415 gnus-description-hashtb))
3417 (gnus-message 3 "No groups matched \"%s\"." regexp)
3418 ;; Print out all the groups.
3420 (pop-to-buffer "*Gnus Help*")
3421 (buffer-disable-undo)
3423 (setq groups (sort groups 'string<))
3425 ;; Groups may be entered twice into the list of groups.
3426 (when (not (string= (car groups) prev))
3427 (setq prev (car groups))
3428 (let ((charset (gnus-group-name-charset nil prev)))
3429 (insert (gnus-group-name-decode prev charset) "\n")
3430 (when (and gnus-description-hashtb
3431 (setq des (gnus-gethash (car groups)
3432 gnus-description-hashtb)))
3433 (insert " " (gnus-group-name-decode des charset) "\n"))))
3434 (setq groups (cdr groups)))
3435 (goto-char (point-min))))
3436 (pop-to-buffer obuf)))
3438 (defun gnus-group-description-apropos (regexp)
3439 "List all newsgroups that have names or descriptions that match a regexp."
3440 (interactive "sGnus description apropos (regexp): ")
3441 (when (not (or gnus-description-hashtb
3442 (gnus-read-all-descriptions-files)))
3443 (error "Couldn't request descriptions file"))
3444 (gnus-group-apropos regexp t))
3446 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3447 (defun gnus-group-list-matching (level regexp &optional all lowest)
3448 "List all groups with unread articles that match REGEXP.
3449 If the prefix LEVEL is non-nil, it should be a number that says which
3450 level to cut off listing groups.
3451 If ALL, also list groups with no unread articles.
3452 If LOWEST, don't list groups with level lower than LOWEST.
3454 This command may read the active file."
3455 (interactive "P\nsList newsgroups matching: ")
3456 ;; First make sure active file has been read.
3458 (> (prefix-numeric-value level) gnus-level-killed))
3459 (gnus-get-killed-groups))
3460 (funcall gnus-group-prepare-function
3461 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3462 (goto-char (point-min))
3463 (gnus-group-position-point))
3465 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3466 "List all groups that match REGEXP.
3467 If the prefix LEVEL is non-nil, it should be a number that says which
3468 level to cut off listing groups.
3469 If LOWEST, don't list groups with level lower than LOWEST."
3470 (interactive "P\nsList newsgroups matching: ")
3472 (setq level (prefix-numeric-value level)))
3473 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3475 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3476 (defun gnus-group-save-newsrc (&optional force)
3477 "Save the Gnus startup files.
3478 If FORCE, force saving whether it is necessary or not."
3480 (gnus-save-newsrc-file force))
3482 (defun gnus-group-restart (&optional arg)
3483 "Force Gnus to read the .newsrc file."
3485 (when (gnus-yes-or-no-p
3486 (format "Are you sure you want to restart Gnus? "))
3487 (gnus-save-newsrc-file)
3491 (defun gnus-group-read-init-file ()
3492 "Read the Gnus elisp init file."
3494 (gnus-read-init-file)
3495 (gnus-message 5 "Read %s" gnus-init-file))
3497 (defun gnus-group-check-bogus-groups (&optional silent)
3498 "Check bogus newsgroups.
3499 If given a prefix, don't ask for confirmation before removing a bogus
3502 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3503 (gnus-group-list-groups))
3505 (defun gnus-group-find-new-groups (&optional arg)
3506 "Search for new groups and add them.
3507 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3508 With 1 C-u, use the `ask-server' method to query the server for new
3510 With 2 C-u's, use most complete method possible to query the server
3511 for new groups, and subscribe the new groups as zombies."
3513 (gnus-find-new-newsgroups (or arg 1))
3514 (gnus-group-list-groups))
3516 (defun gnus-group-edit-global-kill (&optional article group)
3517 "Edit the global kill file.
3518 If GROUP, edit that local kill file instead."
3520 (setq gnus-current-kill-article article)
3521 (gnus-kill-file-edit-file group)
3524 (substitute-command-keys
3525 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3526 (if group "local" "global")))))
3528 (defun gnus-group-edit-local-kill (article group)
3529 "Edit a local kill file."
3530 (interactive (list nil (gnus-group-group-name)))
3531 (gnus-group-edit-global-kill article group))
3533 (defun gnus-group-force-update ()
3534 "Update `.newsrc' file."
3536 (gnus-save-newsrc-file))
3538 (defun gnus-group-suspend ()
3539 "Suspend the current Gnus session.
3540 In fact, cleanup buffers except for group mode buffer.
3541 The hook gnus-suspend-gnus-hook is called before actually suspending."
3543 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3544 ;; Kill Gnus buffers except for group mode buffer.
3545 (let ((group-buf (get-buffer gnus-group-buffer)))
3546 (mapcar (lambda (buf)
3547 (unless (member buf (list group-buf gnus-dribble-buffer))
3550 (gnus-kill-gnus-frames)
3552 (bury-buffer group-buf)
3553 (delete-windows-on group-buf t))))
3555 (defun gnus-group-clear-dribble ()
3556 "Clear all information from the dribble buffer."
3558 (gnus-dribble-clear)
3559 (gnus-message 7 "Cleared dribble buffer"))
3561 (defun gnus-group-exit ()
3562 "Quit reading news after updating .newsrc.eld and .newsrc.
3563 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3566 (or noninteractive ;For gnus-batch-kill
3567 (not gnus-interactive-exit) ;Without confirmation
3569 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3570 (gnus-run-hooks 'gnus-exit-gnus-hook)
3571 ;; Offer to save data from non-quitted summary buffers.
3572 (gnus-offer-save-summaries)
3573 ;; Save the newsrc file(s).
3574 (gnus-save-newsrc-file)
3576 (gnus-close-backends)
3577 ;; Reset everything.
3579 ;; Allow the user to do things after cleaning up.
3580 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3582 (defun gnus-group-quit ()
3583 "Quit reading news without updating .newsrc.eld or .newsrc.
3584 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3586 (when (or noninteractive ;For gnus-batch-kill
3587 (zerop (buffer-size))
3588 (not (gnus-server-opened gnus-select-method))
3590 (not gnus-current-startup-file)
3592 (format "Quit reading news without saving %s? "
3593 (file-name-nondirectory gnus-current-startup-file))))
3594 (gnus-run-hooks 'gnus-exit-gnus-hook)
3595 (gnus-configure-windows 'group t)
3597 (gnus-close-backends)
3599 (gnus-kill-buffer gnus-group-buffer)
3600 ;; Allow the user to do things after cleaning up.
3601 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3603 (defun gnus-group-describe-briefly ()
3604 "Give a one line description of the group mode commands."
3606 (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")))
3608 (defun gnus-group-browse-foreign-server (method)
3609 "Browse a foreign news server.
3610 If called interactively, this function will ask for a select method
3611 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3612 If not, METHOD should be a list where the first element is the method
3613 and the second element is the address."
3615 (list (let ((how (completing-read
3617 (append gnus-valid-select-methods gnus-server-alist)
3618 nil t (cons "nntp" 0) 'gnus-method-history)))
3619 ;; We either got a backend name or a virtual server name.
3620 ;; If the first, we also need an address.
3621 (if (assoc how gnus-valid-select-methods)
3623 ;; Suggested by mapjph@bath.ac.uk.
3626 (mapcar (lambda (server) (list server))
3627 gnus-secondary-servers)))
3628 ;; We got a server name.
3630 (gnus-browse-foreign-server method))
3632 (defun gnus-group-set-info (info &optional method-only-group part)
3633 (when (or info part)
3634 (let* ((entry (gnus-gethash
3635 (or method-only-group (gnus-info-group info))
3636 gnus-newsrc-hashtb))
3638 (info (if method-only-group (nth 2 entry) info))
3640 (when method-only-group
3642 (error "Trying to change non-existent group %s" method-only-group))
3643 ;; We have received parts of the actual group info - either the
3644 ;; select method or the group parameters. We first check
3645 ;; whether we have to extend the info, and if so, do that.
3646 (let ((len (length info))
3647 (total (if (eq part 'method) 5 6)))
3649 (setcdr (nthcdr (1- len) info)
3650 (make-list (- total len) nil)))
3651 ;; Then we enter the new info.
3652 (setcar (nthcdr (1- total) info) part-info)))
3654 ;; This is a new group, so we just create it.
3656 (set-buffer gnus-group-buffer)
3657 (setq method (gnus-info-method info))
3658 (when (gnus-server-equal method "native")
3661 (set-buffer gnus-group-buffer)
3663 ;; It's a foreign group...
3664 (gnus-group-make-group
3665 (gnus-group-real-name (gnus-info-group info))
3666 (if (stringp method) method
3667 (prin1-to-string (car method)))
3669 (nth 1 (gnus-info-method info))))
3670 ;; It's a native group.
3671 (gnus-group-make-group (gnus-info-group info))))
3672 (gnus-message 6 "Note: New group created")
3674 (gnus-gethash (gnus-group-prefixed-name
3675 (gnus-group-real-name (gnus-info-group info))
3676 (or (gnus-info-method info) gnus-select-method))
3677 gnus-newsrc-hashtb))))
3678 ;; Whether it was a new group or not, we now have the entry, so we
3679 ;; can do the update.
3682 (setcar (nthcdr 2 entry) info)
3683 (when (and (not (eq (car entry) t))
3684 (gnus-active (gnus-info-group info)))
3685 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3686 (error "No such group: %s" (gnus-info-group info))))))
3688 (defun gnus-group-set-method-info (group select-method)
3689 (gnus-group-set-info select-method group 'method))
3691 (defun gnus-group-set-params-info (group params)
3692 (gnus-group-set-info params group 'params))
3694 (defun gnus-add-marked-articles (group type articles &optional info force)
3695 ;; Add ARTICLES of TYPE to the info of GROUP.
3696 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3697 ;; add, but replace marked articles of TYPE with ARTICLES.
3698 (let ((info (or info (gnus-get-info group)))
3701 (and (not (setq marked (nthcdr 3 info)))
3703 (setcdr (nthcdr 2 info)
3704 (list (list (cons type (gnus-compress-sequence
3706 (and (not (setq m (assq type (car marked))))
3709 (cons (cons type (gnus-compress-sequence articles t) )
3713 (setcar (nthcdr 3 info)
3714 (gnus-delete-alist type (car marked)))
3715 (setcdr m (gnus-compress-sequence articles t)))
3716 (setcdr m (gnus-compress-sequence
3717 (sort (nconc (gnus-uncompress-range (cdr m))
3718 (copy-sequence articles)) '<) t))))))
3721 ;;; Group timestamps
3724 (defun gnus-group-set-timestamp ()
3725 "Change the timestamp of the current group to the current time.
3726 This function can be used in hooks like `gnus-select-group-hook'
3727 or `gnus-group-catchup-group-hook'."
3728 (when gnus-newsgroup-name
3729 (let ((time (current-time)))
3730 (setcdr (cdr time) nil)
3731 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3733 (defsubst gnus-group-timestamp (group)
3734 "Return the timestamp for GROUP."
3735 (gnus-group-get-parameter group 'timestamp t))
3737 (defun gnus-group-timestamp-delta (group)
3738 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3739 (let* ((time (or (gnus-group-timestamp group)
3741 (delta (subtract-time (current-time) time)))
3742 (+ (* (nth 0 delta) 65536.0)
3745 (defun gnus-group-timestamp-string (group)
3746 "Return a string of the timestamp for GROUP."
3747 (let ((time (gnus-group-timestamp group)))
3750 (gnus-time-iso8601 time))))
3752 (defun gnus-group-list-cached (level &optional lowest)
3753 "List all groups with cached articles.
3754 If the prefix LEVEL is non-nil, it should be a number that says which
3755 level to cut off listing groups.
3756 If LOWEST, don't list groups with level lower than LOWEST.
3758 This command may read the active file."
3761 (setq level (prefix-numeric-value level)))
3762 (when (or (not level) (>= level gnus-level-zombie))
3764 (funcall gnus-group-prepare-function
3765 (or level gnus-level-subscribed)
3767 (let ((marks (gnus-info-marks info)))
3768 (assq 'cache marks)))
3771 (or (gnus-gethash group
3772 gnus-cache-active-hashtb)
3773 ;; Cache active file might use "."
3776 (mapconcat 'identity
3777 (split-string group ":")
3779 gnus-cache-active-hashtb))))
3780 (goto-char (point-min))
3781 (gnus-group-position-point))
3783 (defun gnus-group-list-dormant (level &optional lowest)
3784 "List all groups with dormant 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 (funcall gnus-group-prepare-function
3796 (or level gnus-level-subscribed)
3798 (let ((marks (gnus-info-marks info)))
3799 (assq 'dormant marks)))
3802 (goto-char (point-min))
3803 (gnus-group-position-point))
3805 (defun gnus-group-listed-groups ()
3806 "Return a list of listed groups."
3808 (goto-char (point-min))
3809 (while (setq point (text-property-not-all (point) (point-max)
3812 (push (symbol-name (get-text-property point 'gnus-group)) groups)
3816 (defun gnus-group-list-plus (&optional args)
3817 "List groups plus the current selection."
3819 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
3820 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
3822 (push last-command-event unread-command-events)
3823 (if (featurep 'xemacs)
3824 (push (make-event 'key-press '(key ?A)) unread-command-events)
3825 (push ?A unread-command-events))
3826 (let (gnus-pick-mode keys)
3827 (setq keys (if (featurep 'xemacs)
3828 (events-to-keys (read-key-sequence nil))
3829 (read-key-sequence nil)))
3830 (setq func (lookup-key (current-local-map) keys)))
3834 (call-interactively func))))
3836 (defun gnus-group-list-flush (&optional args)
3837 "Flush groups from the current selection."
3839 (let ((gnus-group-list-option 'flush))
3840 (gnus-group-list-plus args)))
3842 (defun gnus-group-list-limit (&optional args)
3843 "List groups limited within the current selection."
3845 (let ((gnus-group-list-option 'limit))
3846 (gnus-group-list-plus args)))
3848 (provide 'gnus-group)
3850 ;;; gnus-group.el ends here