1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
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.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (unless (boundp 'gnus-cache-active-hashtb)
49 (defvar gnus-cache-active-hashtb nil)))
51 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
52 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54 (defcustom gnus-group-archive-directory
55 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
56 "*The address of the (ding) archives."
57 :group 'gnus-group-foreign
60 (defcustom gnus-group-recent-archive-directory
61 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
62 "*The address of the most recent (ding) articles."
63 :group 'gnus-group-foreign
66 (defcustom gnus-no-groups-message "No Gnus is good news"
67 "*Message displayed by Gnus when no groups are available."
71 (defcustom gnus-keep-same-level nil
72 "*Non-nil means that the next newsgroup after the current will be on the same level.
73 When you type, for instance, `n' after reading the last article in the
74 current newsgroup, you will go to the next newsgroup. If this variable
75 is nil, the next newsgroup will be the next from the group
77 If this variable is non-nil, Gnus will either put you in the
78 next newsgroup with the same level, or, if no such newsgroup is
79 available, the next newsgroup with the lowest possible level higher
80 than the current level.
81 If this variable is `best', Gnus will make the next newsgroup the one
83 :group 'gnus-group-levels
84 :type '(choice (const nil)
86 (sexp :tag "other" t)))
88 (defcustom gnus-group-goto-unread t
89 "*If non-nil, movement commands will go to the next unread and subscribed group."
90 :link '(custom-manual "(gnus)Group Maneuvering")
91 :group 'gnus-group-various
94 (defcustom gnus-goto-next-group-when-activating t
95 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
96 :link '(custom-manual "(gnus)Scanning New Messages")
97 :group 'gnus-group-various
100 (defcustom gnus-permanently-visible-groups nil
101 "*Regexp to match groups that should always be listed in the group buffer.
102 This means that they will still be listed even when there are no
103 unread articles in the groups.
105 If nil, no groups are permanently visible."
106 :group 'gnus-group-listing
107 :type '(choice regexp (const nil)))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "*If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "*Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
121 (defcustom gnus-group-list-inactive-groups t
122 "*If non-nil, inactive groups will be listed."
123 :group 'gnus-group-listing
124 :group 'gnus-group-levels
127 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
128 "*Function used for sorting the group buffer.
129 This function will be called with group info entries as the arguments
130 for the groups to be sorted. Pre-made functions include
131 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
132 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
133 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
134 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136 This variable can also be a list of sorting functions. In that case,
137 the most significant sort function should be the last function in the
139 :group 'gnus-group-listing
140 :link '(custom-manual "(gnus)Sorting Groups")
141 :type '(repeat :value-to-internal (lambda (widget value)
142 (if (listp value) value (list value)))
143 :match (lambda (widget value)
145 (widget-editable-list-match widget value)))
146 (choice (function-item gnus-group-sort-by-alphabet)
147 (function-item gnus-group-sort-by-real-name)
148 (function-item gnus-group-sort-by-unread)
149 (function-item gnus-group-sort-by-level)
150 (function-item gnus-group-sort-by-score)
151 (function-item gnus-group-sort-by-method)
152 (function-item gnus-group-sort-by-server)
153 (function-item gnus-group-sort-by-rank)
154 (function :tag "other" nil))))
156 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
157 "*Format of group lines.
158 It works along the same lines as a normal formatting string,
159 with some simple extensions.
161 %M Only marked articles (character, \"*\" or \" \")
162 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
163 %L Level of subscribedness (integer)
164 %N Number of unread articles (integer)
165 %I Number of dormant articles (integer)
166 %i Number of ticked and dormant (integer)
167 %T Number of ticked articles (integer)
168 %R Number of read articles (integer)
169 %U Number of unseen articles (integer)
170 %t Estimated total number of articles (integer)
171 %y Number of unread, unticked articles (integer)
172 %G Group name (string)
173 %g Qualified group name (string)
174 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
175 %C Group comment (string)
176 %D Group description (string)
177 %s Select method (string)
178 %o Moderated group (char, \"m\")
179 %p Process mark (char)
180 %B Whether a summary buffer for the group is open (char, \"*\")
181 %O Moderated group (string, \"(m)\" or \"\")
182 %P Topic indentation (string)
183 %m Whether there is new(ish) mail in the group (char, \"%\")
184 %w Number of new(ish) mails in the group (integer)
185 %n Select from where (string)
186 %z A string that look like `<%s:%n>' if a foreign select method is used
187 %d The date the group was last entered.
188 %E Icon as defined by `gnus-group-icon-list'.
189 %F The disk space used by the articles fetched by both the cache and agent.
190 %u User defined specifier. The next character in the format string should
191 be a letter. Gnus will call the function gnus-user-format-function-X,
192 where X is the letter following %u. The function will be passed a
193 single dummy parameter as argument. The function should return a
194 string, which will be inserted into the buffer just like information
195 from any other group specifier.
197 Note that this format specification is not always respected. For
198 reasons of efficiency, when listing killed groups, this specification
199 is ignored altogether. If the spec is changed considerably, your
200 output may end up looking strange when listing both alive and killed
203 If you use %o or %O, reading the active file will be slower and quite
204 a bit of extra memory will be used. %D and %F will also worsen
205 performance. Also note that if you change the format specification to
206 include any of these specs, you must probably re-start Gnus to see
209 General format specifiers can also be used.
210 See Info node `(gnus)Formatting Variables'."
211 :link '(custom-manual "(gnus)Formatting Variables")
212 :group 'gnus-group-visual
215 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
216 "*The format specification for the group mode line.
217 It works along the same lines as a normal formatting string,
218 with some simple extensions:
220 %S The native news server.
221 %M The native select method.
222 %: \":\" if %S isn't \"\"."
223 :group 'gnus-group-visual
226 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
227 (when (featurep 'xemacs)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
229 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
231 (defcustom gnus-group-menu-hook nil
232 "Hook run after the creation of the group mode menu."
233 :group 'gnus-group-various
236 (defcustom gnus-group-catchup-group-hook nil
237 "Hook run when catching up a group from the group buffer."
238 :group 'gnus-group-various
239 :link '(custom-manual "(gnus)Group Data")
242 (defcustom gnus-group-update-group-hook nil
243 "Hook called when updating group lines."
244 :group 'gnus-group-visual
247 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
248 "*A function that is called to generate the group buffer.
249 The function is called with three arguments: The first is a number;
250 all group with a level less or equal to that number should be listed,
251 if the second is non-nil, empty groups should also be displayed. If
252 the third is non-nil, it is a number. No groups with a level lower
253 than this number should be displayed.
255 The only current function implemented is `gnus-group-prepare-flat'."
256 :group 'gnus-group-listing
259 (defcustom gnus-group-prepare-hook nil
260 "Hook called after the group buffer has been generated.
261 If you want to modify the group buffer, you can use this hook."
262 :group 'gnus-group-listing
265 (defcustom gnus-suspend-gnus-hook nil
266 "Hook called when suspending (not exiting) Gnus."
270 (defcustom gnus-exit-gnus-hook nil
271 "Hook called when exiting Gnus."
275 (defcustom gnus-after-exiting-gnus-hook nil
276 "Hook called after exiting Gnus."
280 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
281 "Hook called when a group line is changed.
282 The hook will not be called if `gnus-visual' is nil.
284 The default function `gnus-group-highlight-line' will
285 highlight the line according to the `gnus-group-highlight'
287 :group 'gnus-group-visual
290 (defcustom gnus-useful-groups
291 '(("(ding) mailing list mirrored at sunsite.auc.dk"
293 (nntp "sunsite.auc.dk"
294 (nntp-address "sunsite.auc.dk")))
297 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
301 (nndoc-article-type mbox)
302 (eval `(nndoc-address
303 ,(let ((file (nnheader-find-etc-directory
306 (error "Couldn't find doc group"))
308 "*Alist of useful group-server pairs."
309 :group 'gnus-group-listing
310 :type '(repeat (list (string :tag "Description")
312 (sexp :tag "Method"))))
314 (defcustom gnus-group-highlight
316 ((and mailp (= unread 0) (eq level 1)) .
317 gnus-group-mail-1-empty-face)
318 ((and mailp (eq level 1)) .
319 gnus-group-mail-1-face)
320 ((and mailp (= unread 0) (eq level 2)) .
321 gnus-group-mail-2-empty-face)
322 ((and mailp (eq level 2)) .
323 gnus-group-mail-2-face)
324 ((and mailp (= unread 0) (eq level 3)) .
325 gnus-group-mail-3-empty-face)
326 ((and mailp (eq level 3)) .
327 gnus-group-mail-3-face)
328 ((and mailp (= unread 0)) .
329 gnus-group-mail-low-empty-face)
331 gnus-group-mail-low-face)
333 ((and (= unread 0) (eq level 1)) .
334 gnus-group-news-1-empty-face)
335 ((and (eq level 1)) .
336 gnus-group-news-1-face)
337 ((and (= unread 0) (eq level 2)) .
338 gnus-group-news-2-empty-face)
339 ((and (eq level 2)) .
340 gnus-group-news-2-face)
341 ((and (= unread 0) (eq level 3)) .
342 gnus-group-news-3-empty-face)
343 ((and (eq level 3)) .
344 gnus-group-news-3-face)
345 ((and (= unread 0) (eq level 4)) .
346 gnus-group-news-4-empty-face)
347 ((and (eq level 4)) .
348 gnus-group-news-4-face)
349 ((and (= unread 0) (eq level 5)) .
350 gnus-group-news-5-empty-face)
351 ((and (eq level 5)) .
352 gnus-group-news-5-face)
353 ((and (= unread 0) (eq level 6)) .
354 gnus-group-news-6-empty-face)
355 ((and (eq level 6)) .
356 gnus-group-news-6-face)
357 ((and (= unread 0)) .
358 gnus-group-news-low-empty-face)
360 gnus-group-news-low-face))
361 "*Controls the highlighting of group buffer lines.
363 Below is a list of `Form'/`Face' pairs. When deciding how a a
364 particular group line should be displayed, each form is
365 evaluated. The content of the face field after the first true form is
366 used. You can change how those group lines are displayed by
367 editing the face field.
369 It is also possible to change and add form fields, but currently that
370 requires an understanding of Lisp expressions. Hopefully this will
371 change in a future release. For now, you can use the following
372 variables in the Lisp expression:
374 group: The name of the group.
375 unread: The number of unread articles in the group.
376 method: The select method used.
377 mailp: Whether it's a mail group or not.
378 level: The level of the group.
379 score: The score of the group.
380 ticked: The number of ticked articles."
381 :group 'gnus-group-visual
382 :type '(repeat (cons (sexp :tag "Form") face)))
384 (defcustom gnus-new-mail-mark ?%
385 "Mark used for groups with new mail."
386 :group 'gnus-group-visual
389 (defgroup gnus-group-icons nil
390 "Add Icons to your group buffer. "
391 :group 'gnus-group-visual)
393 (defcustom gnus-group-icon-list
395 "*Controls the insertion of icons into group buffer lines.
397 Below is a list of `Form'/`File' pairs. When deciding how a
398 particular group line should be displayed, each form is evaluated.
399 The icon from the file field after the first true form is used. You
400 can change how those group lines are displayed by editing the file
401 field. The File will either be found in the
402 `gnus-group-glyph-directory' or by designating absolute name of the
405 It is also possible to change and add form fields, but currently that
406 requires an understanding of Lisp expressions. Hopefully this will
407 change in a future release. For now, you can use the following
408 variables in the Lisp expression:
410 group: The name of the group.
411 unread: The number of unread articles in the group.
412 method: The select method used.
413 mailp: Whether it's a mail group or not.
414 newsp: Whether it's a news group or not
415 level: The level of the group.
416 score: The score of the group.
417 ticked: The number of ticked articles."
418 :group 'gnus-group-icons
419 :type '(repeat (cons (sexp :tag "Form") file)))
421 (defcustom gnus-group-name-charset-method-alist nil
422 "Alist of method and the charset for group names.
425 (((nntp \"news.com.cn\") . cn-gb-2312))"
428 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
430 (defcustom gnus-group-name-charset-group-alist
431 (if (mm-coding-system-p 'utf-8)
432 '(("[^\000-\177]" . utf-8))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
444 If non-nil, the value should be a string or an alist. If it is a string,
445 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
446 nnml:\" in the minibuffer prompt.
448 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
449 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
450 used when no prefix argument is given to `gnus-group-jump-to-group'."
451 :group 'gnus-group-various
452 :type '(choice (string :tag "Prompt string")
453 (const :tag "Empty" nil)
454 (repeat (cons (integer :tag "Argument")
455 (string :tag "Prompt string")))))
457 (defvar gnus-group-listing-limit 1000
458 "*A limit of the number of groups when listing.
459 If the number of groups is larger than the limit, list them in a
462 ;;; Internal variables
464 (defvar gnus-group-is-exiting-p nil)
465 (defvar gnus-group-is-exiting-without-update-p nil)
466 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
467 "Function for sorting the group buffer.")
469 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
470 "Function for sorting the selected groups in the group buffer.")
472 (defvar gnus-group-indentation-function nil)
473 (defvar gnus-goto-missing-group-function nil)
474 (defvar gnus-group-update-group-function nil)
475 (defvar gnus-group-goto-next-group-function nil
476 "Function to override finding the next group after listing groups.")
478 (defvar gnus-group-edit-buffer nil)
480 (defvar gnus-group-line-format-alist
481 `((?M gnus-tmp-marked-mark ?c)
482 (?S gnus-tmp-subscribed ?c)
483 (?L gnus-tmp-level ?d)
484 (?N (cond ((eq number t) "*" )
488 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
489 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
491 (?R gnus-tmp-number-of-read ?s)
492 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
493 (?t gnus-tmp-number-total ?d)
494 (?y gnus-tmp-number-of-unread ?s)
495 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
496 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
497 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
498 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
499 (?g gnus-tmp-group ?s)
500 (?G gnus-tmp-qualified-group ?s)
501 (?c (gnus-short-group-name gnus-tmp-group) ?s)
502 (?C gnus-tmp-comment ?s)
503 (?D gnus-tmp-newsgroup-description ?s)
504 (?o gnus-tmp-moderated ?c)
505 (?O gnus-tmp-moderated-string ?s)
506 (?p gnus-tmp-process-marked ?c)
507 (?s gnus-tmp-news-server ?s)
508 (?n ,(if (featurep 'xemacs)
509 '(symbol-name gnus-tmp-news-method)
510 'gnus-tmp-news-method)
512 (?P gnus-group-indentation ?s)
513 (?E gnus-tmp-group-icon ?s)
514 (?B gnus-tmp-summary-live ?c)
515 (?z gnus-tmp-news-method-string ?s)
516 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
517 (?w (if (gnus-news-group-p gnus-tmp-group)
521 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
524 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
525 (?u gnus-tmp-user-defined ?s)
526 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
529 (defvar gnus-group-mode-line-format-alist
530 `((?S gnus-tmp-news-server ?s)
531 (?M gnus-tmp-news-method ?s)
532 (?u gnus-tmp-user-defined ?s)
533 (?: gnus-tmp-colon ?s)))
535 (defvar gnus-topic-topology nil
536 "The complete topic hierarchy.")
538 (defvar gnus-topic-alist nil
539 "The complete topic-group alist.")
541 (defvar gnus-group-marked nil)
543 (defvar gnus-group-list-mode nil)
546 (defvar gnus-group-icon-cache nil)
548 (defvar gnus-group-listed-groups nil)
549 (defvar gnus-group-list-option nil)
555 (put 'gnus-group-mode 'mode-class 'special)
557 (gnus-define-keys gnus-group-mode-map
558 " " gnus-group-read-group
559 "=" gnus-group-select-group
560 "\r" gnus-group-select-group
561 "\M-\r" gnus-group-quick-select-group
562 "\M- " gnus-group-visible-select-group
563 [(meta control return)] gnus-group-select-group-ephemerally
564 "j" gnus-group-jump-to-group
565 "n" gnus-group-next-unread-group
566 "p" gnus-group-prev-unread-group
567 "\177" gnus-group-prev-unread-group
568 [delete] gnus-group-prev-unread-group
569 [backspace] gnus-group-prev-unread-group
570 "N" gnus-group-next-group
571 "P" gnus-group-prev-group
572 "\M-n" gnus-group-next-unread-group-same-level
573 "\M-p" gnus-group-prev-unread-group-same-level
574 "," gnus-group-best-unread-group
575 "." gnus-group-first-unread-group
576 "u" gnus-group-unsubscribe-current-group
577 "U" gnus-group-unsubscribe-group
578 "c" gnus-group-catchup-current
579 "C" gnus-group-catchup-current-all
580 "\M-c" gnus-group-clear-data
581 "l" gnus-group-list-groups
582 "L" gnus-group-list-all-groups
585 "g" gnus-group-get-new-news
586 "\M-g" gnus-group-get-new-news-this-group
587 "R" gnus-group-restart
588 "r" gnus-group-read-init-file
589 "B" gnus-group-browse-foreign-server
590 "b" gnus-group-check-bogus-groups
591 "F" gnus-group-find-new-groups
592 "\C-c\C-d" gnus-group-describe-group
593 "\M-d" gnus-group-describe-all-groups
594 "\C-c\C-a" gnus-group-apropos
595 "\C-c\M-\C-a" gnus-group-description-apropos
596 "a" gnus-group-post-news
597 "\ek" gnus-group-edit-local-kill
598 "\eK" gnus-group-edit-global-kill
599 "\C-k" gnus-group-kill-group
600 "\C-y" gnus-group-yank-group
601 "\C-w" gnus-group-kill-region
602 "\C-x\C-t" gnus-group-transpose-groups
603 "\C-c\C-l" gnus-group-list-killed
604 "\C-c\C-x" gnus-group-expire-articles
605 "\C-c\M-\C-x" gnus-group-expire-all-groups
607 "s" gnus-group-save-newsrc
608 "z" gnus-group-suspend
611 "?" gnus-group-describe-briefly
612 "\C-c\C-i" gnus-info-find-node
613 "\M-e" gnus-group-edit-group-method
614 "^" gnus-group-enter-server-mode
615 gnus-mouse-2 gnus-mouse-pick-group
616 "<" beginning-of-buffer
619 "\C-c\C-n" gnus-namazu-search
620 "\C-c\C-s" gnus-group-sort-groups
622 "\C-c\M-g" gnus-activate-all-groups
623 "\M-&" gnus-group-universal-argument
624 "#" gnus-group-mark-group
625 "\M-#" gnus-group-unmark-group)
627 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
628 "m" gnus-group-mark-group
629 "u" gnus-group-unmark-group
630 "w" gnus-group-mark-region
631 "b" gnus-group-mark-buffer
632 "r" gnus-group-mark-regexp
633 "U" gnus-group-unmark-all-groups)
635 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
636 "u" gnus-sieve-update
637 "g" gnus-sieve-generate)
639 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
640 "d" gnus-group-make-directory-group
641 "h" gnus-group-make-help-group
642 "u" gnus-group-make-useful-group
643 "a" gnus-group-make-archive-group
644 "k" gnus-group-make-kiboze-group
645 "l" gnus-group-nnimap-edit-acl
646 "m" gnus-group-make-group
647 "n" gnus-group-make-shimbun-group
648 "E" gnus-group-edit-group
649 "e" gnus-group-edit-group-method
650 "p" gnus-group-edit-group-parameters
651 "v" gnus-group-add-to-virtual
652 "V" gnus-group-make-empty-virtual
653 "D" gnus-group-enter-directory
654 "f" gnus-group-make-doc-group
655 "G" gnus-group-make-nnir-group
656 "w" gnus-group-make-web-group
657 "M" gnus-group-read-ephemeral-group
658 "r" gnus-group-rename-group
659 "R" gnus-group-make-rss-group
660 "c" gnus-group-customize
661 "x" gnus-group-nnimap-expunge
662 "\177" gnus-group-delete-group
663 [delete] gnus-group-delete-group)
665 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
666 "b" gnus-group-brew-soup
667 "w" gnus-soup-save-areas
668 "s" gnus-soup-send-replies
669 "p" gnus-soup-pack-packet
670 "r" nnsoup-pack-replies)
672 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
673 "s" gnus-group-sort-groups
674 "a" gnus-group-sort-groups-by-alphabet
675 "u" gnus-group-sort-groups-by-unread
676 "l" gnus-group-sort-groups-by-level
677 "v" gnus-group-sort-groups-by-score
678 "r" gnus-group-sort-groups-by-rank
679 "m" gnus-group-sort-groups-by-method
680 "n" gnus-group-sort-groups-by-real-name)
682 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
683 "s" gnus-group-sort-selected-groups
684 "a" gnus-group-sort-selected-groups-by-alphabet
685 "u" gnus-group-sort-selected-groups-by-unread
686 "l" gnus-group-sort-selected-groups-by-level
687 "v" gnus-group-sort-selected-groups-by-score
688 "r" gnus-group-sort-selected-groups-by-rank
689 "m" gnus-group-sort-selected-groups-by-method
690 "n" gnus-group-sort-selected-groups-by-real-name)
692 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
693 "k" gnus-group-list-killed
694 "z" gnus-group-list-zombies
695 "s" gnus-group-list-groups
696 "u" gnus-group-list-all-groups
697 "A" gnus-group-list-active
698 "a" gnus-group-apropos
699 "d" gnus-group-description-apropos
700 "m" gnus-group-list-matching
701 "M" gnus-group-list-all-matching
702 "l" gnus-group-list-level
703 "c" gnus-group-list-cached
704 "?" gnus-group-list-dormant)
706 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
707 "k" gnus-group-list-limit
708 "z" gnus-group-list-limit
709 "s" gnus-group-list-limit
710 "u" gnus-group-list-limit
711 "A" gnus-group-list-limit
712 "m" gnus-group-list-limit
713 "M" gnus-group-list-limit
714 "l" gnus-group-list-limit
715 "c" gnus-group-list-limit
716 "?" gnus-group-list-limit)
718 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
719 "k" gnus-group-list-flush
720 "z" gnus-group-list-flush
721 "s" gnus-group-list-flush
722 "u" gnus-group-list-flush
723 "A" gnus-group-list-flush
724 "m" gnus-group-list-flush
725 "M" gnus-group-list-flush
726 "l" gnus-group-list-flush
727 "c" gnus-group-list-flush
728 "?" gnus-group-list-flush)
730 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
731 "k" gnus-group-list-plus
732 "z" gnus-group-list-plus
733 "s" gnus-group-list-plus
734 "u" gnus-group-list-plus
735 "A" gnus-group-list-plus
736 "m" gnus-group-list-plus
737 "M" gnus-group-list-plus
738 "l" gnus-group-list-plus
739 "c" gnus-group-list-plus
740 "?" gnus-group-list-plus)
742 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
743 "f" gnus-score-flush-cache
744 "e" gnus-score-edit-all-score)
746 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
747 "c" gnus-group-fetch-charter
748 "C" gnus-group-fetch-control
749 "d" gnus-group-describe-group
750 "f" gnus-group-fetch-faq
753 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
754 "l" gnus-group-set-current-level
755 "t" gnus-group-unsubscribe-current-group
756 "s" gnus-group-unsubscribe-group
757 "k" gnus-group-kill-group
758 "y" gnus-group-yank-group
759 "w" gnus-group-kill-region
760 "\C-k" gnus-group-kill-level
761 "z" gnus-group-kill-all-zombies)
763 (defun gnus-topic-mode-p ()
764 "Return non-nil in `gnus-topic-mode'."
765 (and (boundp 'gnus-topic-mode)
766 (symbol-value 'gnus-topic-mode)))
768 (defun gnus-group-make-menu-bar ()
769 (gnus-turn-off-edit-menu 'group)
770 (unless (boundp 'gnus-group-reading-menu)
773 gnus-group-reading-menu gnus-group-mode-map ""
775 ["Read" gnus-group-read-group
776 :included (not (gnus-topic-mode-p))
777 :active (gnus-group-group-name)]
778 ["Read " gnus-topic-read-group
779 :included (gnus-topic-mode-p)]
780 ["Select" gnus-group-select-group
781 :included (not (gnus-topic-mode-p))
782 :active (gnus-group-group-name)]
783 ["Select " gnus-topic-select-group
784 :included (gnus-topic-mode-p)]
785 ["See old articles" (gnus-group-select-group 'all)
786 :keys "C-u SPC" :active (gnus-group-group-name)]
787 ["Catch up" gnus-group-catchup-current
788 :included (not (gnus-topic-mode-p))
789 :active (gnus-group-group-name)
790 ,@(if (featurep 'xemacs) nil
791 '(:help "Mark unread articles in the current group as read"))]
792 ["Catch up " gnus-topic-catchup-articles
793 :included (gnus-topic-mode-p)
794 ,@(if (featurep 'xemacs) nil
795 '(:help "Mark unread articles in the current group or topic as read"))]
796 ["Catch up all articles" gnus-group-catchup-current-all
797 (gnus-group-group-name)]
798 ["Check for new articles" gnus-group-get-new-news-this-group
799 :included (not (gnus-topic-mode-p))
800 :active (gnus-group-group-name)
801 ,@(if (featurep 'xemacs) nil
802 '(:help "Check for new messages in current group"))]
803 ["Check for new articles " gnus-topic-get-new-news-this-topic
804 :included (gnus-topic-mode-p)
805 ,@(if (featurep 'xemacs) nil
806 '(:help "Check for new messages in current group or topic"))]
807 ["Toggle subscription" gnus-group-unsubscribe-current-group
808 (gnus-group-group-name)]
809 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
810 ,@(if (featurep 'xemacs) nil
811 '(:help "Kill (remove) current group"))]
812 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
813 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
814 ,@(if (featurep 'xemacs) nil
815 '(:help "Display description of the current group"))]
816 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
817 ["Fetch charter" gnus-group-fetch-charter
818 :active (gnus-group-group-name)
819 ,@(if (featurep 'xemacs) nil
820 '(:help "Display the charter of the current group"))]
821 ["Fetch control message" gnus-group-fetch-control
822 :active (gnus-group-group-name)
823 ,@(if (featurep 'xemacs) nil
824 '(:help "Display the archived control message for the current group"))]
825 ;; Actually one should check, if any of the marked groups gives t for
826 ;; (gnus-check-backend-function 'request-expire-articles ...)
827 ["Expire articles" gnus-group-expire-articles
828 :included (not (gnus-topic-mode-p))
829 :active (or (and (gnus-group-group-name)
830 (gnus-check-backend-function
831 'request-expire-articles
832 (gnus-group-group-name))) gnus-group-marked)]
833 ["Expire articles " gnus-topic-expire-articles
834 :included (gnus-topic-mode-p)]
835 ["Set group level..." gnus-group-set-current-level
836 (gnus-group-group-name)]
837 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
838 ["Customize" gnus-group-customize (gnus-group-group-name)]
840 ["Parameters" gnus-group-edit-group-parameters
841 :included (not (gnus-topic-mode-p))
842 :active (gnus-group-group-name)]
843 ["Parameters " gnus-topic-edit-parameters
844 :included (gnus-topic-mode-p)]
845 ["Select method" gnus-group-edit-group-method
846 (gnus-group-group-name)]
847 ["Info" gnus-group-edit-group (gnus-group-group-name)]
848 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
849 ["Global kill file" gnus-group-edit-global-kill t])))
852 gnus-group-group-menu gnus-group-mode-map ""
855 ["List unread subscribed groups" gnus-group-list-groups t]
856 ["List (un)subscribed groups" gnus-group-list-all-groups t]
857 ["List killed groups" gnus-group-list-killed gnus-killed-list]
858 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
859 ["List level..." gnus-group-list-level t]
860 ["Describe all groups" gnus-group-describe-all-groups t]
861 ["Group apropos..." gnus-group-apropos t]
862 ["Group and description apropos..." gnus-group-description-apropos t]
863 ["List groups matching..." gnus-group-list-matching t]
864 ["List all groups matching..." gnus-group-list-all-matching t]
865 ["List active file" gnus-group-list-active t]
866 ["List groups with cached" gnus-group-list-cached t]
867 ["List groups with dormant" gnus-group-list-dormant t])
869 ["Default sort" gnus-group-sort-groups t]
870 ["Sort by method" gnus-group-sort-groups-by-method t]
871 ["Sort by rank" gnus-group-sort-groups-by-rank t]
872 ["Sort by score" gnus-group-sort-groups-by-score t]
873 ["Sort by level" gnus-group-sort-groups-by-level t]
874 ["Sort by unread" gnus-group-sort-groups-by-unread t]
875 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
876 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
877 ("Sort process/prefixed"
878 ["Default sort" gnus-group-sort-selected-groups
879 (not (gnus-topic-mode-p))]
880 ["Sort by method" gnus-group-sort-selected-groups-by-method
881 (not (gnus-topic-mode-p))]
882 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
883 (not (gnus-topic-mode-p))]
884 ["Sort by score" gnus-group-sort-selected-groups-by-score
885 (not (gnus-topic-mode-p))]
886 ["Sort by level" gnus-group-sort-selected-groups-by-level
887 (not (gnus-topic-mode-p))]
888 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
889 (not (gnus-topic-mode-p))]
890 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
891 (not (gnus-topic-mode-p))]
892 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
893 (not (gnus-topic-mode-p))])
895 ["Mark group" gnus-group-mark-group
896 (and (gnus-group-group-name)
897 (not (memq (gnus-group-group-name) gnus-group-marked)))]
898 ["Unmark group" gnus-group-unmark-group
899 (and (gnus-group-group-name)
900 (memq (gnus-group-group-name) gnus-group-marked))]
901 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
902 ["Mark regexp..." gnus-group-mark-regexp t]
903 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
904 ["Mark buffer" gnus-group-mark-buffer t]
905 ["Execute command" gnus-group-universal-argument
906 (or gnus-group-marked (gnus-group-group-name))])
908 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
909 ["Kill all newsgroups in region" gnus-group-kill-region
910 :active (gnus-mark-active-p)]
911 ["Kill all zombie groups" gnus-group-kill-all-zombies
913 ["Kill all groups on level..." gnus-group-kill-level t])
915 ["Make a foreign group..." gnus-group-make-group t]
916 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
917 ["Add a directory group..." gnus-group-make-directory-group t]
918 ["Add the help group" gnus-group-make-help-group t]
919 ["Add the archive group" gnus-group-make-archive-group t]
920 ["Make a doc group..." gnus-group-make-doc-group t]
921 ["Make a web group..." gnus-group-make-web-group t]
922 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
923 ["Make a virtual group..." gnus-group-make-empty-virtual t]
924 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
925 ["Make an RSS group..." gnus-group-make-rss-group t]
926 ["Rename group..." gnus-group-rename-group
927 (gnus-check-backend-function
928 'request-rename-group (gnus-group-group-name))]
929 ["Delete group" gnus-group-delete-group
930 (gnus-check-backend-function
931 'request-delete-group (gnus-group-group-name))])
933 ["Next" gnus-group-next-group t]
934 ["Previous" gnus-group-prev-group t]
935 ["Next unread" gnus-group-next-unread-group t]
936 ["Previous unread" gnus-group-prev-unread-group t]
937 ["Next unread same level" gnus-group-next-unread-group-same-level t]
938 ["Previous unread same level"
939 gnus-group-prev-unread-group-same-level t]
940 ["Jump to group..." gnus-group-jump-to-group t]
941 ["First unread group" gnus-group-first-unread-group t]
942 ["Best unread group" gnus-group-best-unread-group t])
944 ["Generate" gnus-sieve-generate t]
945 ["Generate and update" gnus-sieve-update t])
946 ["Delete bogus groups" gnus-group-check-bogus-groups t]
947 ["Find new newsgroups" gnus-group-find-new-groups t]
948 ["Transpose" gnus-group-transpose-groups
949 (gnus-group-group-name)]
950 ["Read a directory as a group..." gnus-group-enter-directory t]))
953 gnus-group-misc-menu gnus-group-mode-map ""
956 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
957 ["Send replies" gnus-soup-send-replies
958 (fboundp 'gnus-soup-pack-packet)]
959 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
960 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
961 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
962 ["Send a mail" gnus-group-mail t]
963 ["Send a message (mail or news)" gnus-group-post-news t]
964 ["Create a local message" gnus-group-news t]
965 ["Check for new news" gnus-group-get-new-news
966 ,@(if (featurep 'xemacs) '(t)
967 '(:help "Get newly arrived articles"))
969 ["Send queued messages" gnus-delay-send-queue
970 ,@(if (featurep 'xemacs) '(t)
971 '(:help "Send all messages that are scheduled to be sent now"))
973 ["Activate all groups" gnus-activate-all-groups t]
974 ["Restart Gnus" gnus-group-restart t]
975 ["Read init file" gnus-group-read-init-file t]
976 ["Browse foreign server..." gnus-group-browse-foreign-server t]
977 ["Enter server buffer" gnus-group-enter-server-mode t]
978 ["Expire all expirable articles" gnus-group-expire-all-groups t]
979 ["Generate any kiboze groups" nnkiboze-generate-groups t]
980 ["Gnus version" gnus-version t]
981 ["Save .newsrc files" gnus-group-save-newsrc t]
982 ["Suspend Gnus" gnus-group-suspend t]
983 ["Clear dribble buffer" gnus-group-clear-dribble t]
984 ["Read manual" gnus-info-find-node t]
985 ["Flush score cache" gnus-score-flush-cache t]
986 ["Toggle topics" gnus-topic-mode t]
987 ["Send a bug report" gnus-bug t]
988 ["Exit from Gnus" gnus-group-exit
989 ,@(if (featurep 'xemacs) '(t)
990 '(:help "Quit reading news"))]
991 ["Exit without saving" gnus-group-quit t]))
993 (gnus-run-hooks 'gnus-group-menu-hook)))
995 (defvar gnus-group-toolbar-map nil)
997 ;; Emacs 21 tool bar. Should be no-op otherwise.
998 (defun gnus-group-make-tool-bar ()
1000 (condition-case nil (require 'tool-bar) (error nil))
1001 (fboundp 'tool-bar-add-item-from-menu)
1002 (default-value 'tool-bar-mode)
1003 (not gnus-group-toolbar-map))
1004 (setq gnus-group-toolbar-map
1005 (let ((tool-bar-map (make-sparse-keymap))
1006 (load-path (mm-image-load-path)))
1007 (tool-bar-add-item-from-menu
1008 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1009 (tool-bar-add-item-from-menu
1010 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1011 (tool-bar-add-item-from-menu
1012 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1013 (tool-bar-add-item-from-menu
1014 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1015 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1016 :help "Subscribe to the current group")
1017 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1019 :help "Unsubscribe from the current group")
1020 (tool-bar-add-item-from-menu
1021 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1023 (if gnus-group-toolbar-map
1024 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1026 (defun gnus-group-mode ()
1027 "Major mode for reading news.
1029 All normal editing commands are switched off.
1030 \\<gnus-group-mode-map>
1031 The group buffer lists (some of) the groups available. For instance,
1032 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1033 lists all zombie groups.
1035 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1036 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1038 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1040 The following commands are available:
1042 \\{gnus-group-mode-map}"
1044 (kill-all-local-variables)
1045 (when (gnus-visual-p 'group-menu 'menu)
1046 (gnus-group-make-menu-bar)
1047 (gnus-group-make-tool-bar))
1048 (gnus-simplify-mode-line)
1049 (setq major-mode 'gnus-group-mode)
1050 (setq mode-name "Group")
1051 (gnus-group-set-mode-line)
1052 (setq mode-line-process nil)
1053 (use-local-map gnus-group-mode-map)
1054 (buffer-disable-undo)
1055 (setq truncate-lines t)
1056 (setq buffer-read-only t
1057 show-trailing-whitespace nil)
1058 (gnus-set-default-directory)
1059 (gnus-update-format-specifications nil 'group 'group-mode)
1060 (gnus-update-group-mark-positions)
1065 (gnus-run-hooks 'gnus-group-mode-hook))
1067 (defun gnus-update-group-mark-positions ()
1069 (let ((gnus-process-mark ?\200)
1070 (gnus-group-update-hook nil)
1071 (gnus-group-marked '("dummy.group"))
1072 (gnus-active-hashtb (make-vector 10 0))
1074 (gnus-set-active "dummy.group" '(0 . 0))
1075 (gnus-set-work-buffer)
1076 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1077 (goto-char (point-min))
1078 (setq gnus-group-mark-positions
1079 (list (cons 'process (and (search-forward "\200" nil t)
1080 (- (point) 2))))))))
1082 (defun gnus-mouse-pick-group (e)
1083 "Enter the group under the mouse pointer."
1086 (gnus-group-read-group nil))
1088 ;; Look at LEVEL and find out what the level is really supposed to be.
1089 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1090 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1091 (defun gnus-group-default-level (&optional level number-or-nil)
1093 (gnus-group-use-permanent-levels
1094 (or (setq gnus-group-use-permanent-levels
1095 (or level (if (numberp gnus-group-use-permanent-levels)
1096 gnus-group-use-permanent-levels
1097 (or gnus-group-default-list-level
1098 gnus-level-subscribed))))
1099 gnus-group-default-list-level gnus-level-subscribed))
1103 (or level gnus-group-default-list-level gnus-level-subscribed))))
1105 (defun gnus-group-setup-buffer ()
1106 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1107 (unless (eq major-mode 'gnus-group-mode)
1110 (gnus-carpal-setup-buffer 'group))))
1112 (defun gnus-group-name-charset (method group)
1114 (setq method (gnus-find-method-for-group group)))
1115 (let ((item (assoc method gnus-group-name-charset-method-alist))
1116 (alist gnus-group-name-charset-group-alist)
1120 (while (setq item (pop alist))
1121 (if (string-match (car item) group)
1123 result (cdr item))))
1126 (defun gnus-group-name-decode (string charset)
1127 ;; Fixme: Don't decode in unibyte mode.
1128 (if (and string charset (featurep 'mule))
1129 (decode-coding-string string charset)
1132 (defun gnus-group-decoded-name (string)
1133 (let ((charset (gnus-group-name-charset nil string)))
1134 (gnus-group-name-decode string charset)))
1136 (defun gnus-group-name-encode (string charset)
1137 (if (and string charset (featurep 'mule))
1138 (encode-coding-string string charset)
1141 (defun gnus-group-encoded-name (string)
1142 (let ((charset (gnus-group-name-charset nil string)))
1143 (gnus-group-name-encode string charset)))
1145 (defun gnus-group-completing-read-group-name
1146 (prompt table &optional predicate require-match initial-contents history)
1150 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1154 (dolist (entry (prog1
1157 (push (list (gnus-group-decoded-name (car entry))) table)))
1158 (gnus-group-encoded-name
1160 prompt table predicate
1165 (defun gnus-group-list-groups (&optional level unread lowest)
1166 "List newsgroups with level LEVEL or lower that have unread articles.
1167 Default is all subscribed groups.
1168 If argument UNREAD is non-nil, groups with no unread articles are also
1171 Also see the `gnus-group-use-permanent-levels' variable."
1173 (list (if current-prefix-arg
1174 (prefix-numeric-value current-prefix-arg)
1176 (gnus-group-default-level nil t)
1177 gnus-group-default-list-level
1178 gnus-level-subscribed))))
1180 (setq level (car gnus-group-list-mode)
1181 unread (cdr gnus-group-list-mode)))
1182 (setq level (gnus-group-default-level level))
1183 (gnus-group-setup-buffer)
1184 (gnus-update-format-specifications nil 'group 'group-mode)
1185 (let ((case-fold-search nil)
1186 (props (text-properties-at (point-at-bol)))
1187 (empty (= (point-min) (point-max)))
1188 (group (gnus-group-group-name))
1190 (set-buffer gnus-group-buffer)
1191 (setq number (funcall gnus-group-prepare-function level unread lowest))
1192 (when (or (and (numberp number)
1194 (zerop (buffer-size)))
1195 ;; No groups in the buffer.
1196 (gnus-message 5 gnus-no-groups-message))
1197 ;; We have some groups displayed.
1198 (goto-char (point-max))
1199 (when (or (not gnus-group-goto-next-group-function)
1200 (not (funcall gnus-group-goto-next-group-function
1204 (goto-char (point-min)))
1206 ;; Go to the first group with unread articles.
1207 (gnus-group-search-forward t))
1209 ;; Find the right group to put point on. If the current group
1210 ;; has disappeared in the new listing, try to find the next
1211 ;; one. If no next one can be found, just leave point at the
1212 ;; first newsgroup in the buffer.
1213 (when (not (gnus-goto-char
1215 (point-min) (point-max)
1216 'gnus-group (gnus-intern-safe
1217 group gnus-active-hashtb))))
1218 (let ((newsrc (cdddr (gnus-group-entry group))))
1220 (not (gnus-goto-char
1222 (point-min) (point-max) 'gnus-group
1224 (caar newsrc) gnus-active-hashtb)))))
1225 (setq newsrc (cdr newsrc)))
1227 (goto-char (point-max))
1228 (forward-line -1)))))))
1229 ;; Adjust cursor point.
1230 (gnus-group-position-point)))
1232 (defun gnus-group-list-level (level &optional all)
1233 "List groups on LEVEL.
1234 If ALL (the prefix), also list groups that have no unread articles."
1235 (interactive "nList groups on level: \nP")
1236 (gnus-group-list-groups level all level))
1238 (defun gnus-group-prepare-logic (group test)
1239 (or (and gnus-group-listed-groups
1240 (null gnus-group-list-option)
1241 (member group gnus-group-listed-groups))
1243 ((null gnus-group-listed-groups) test)
1244 ((null gnus-group-list-option) test)
1245 (t (and (member group gnus-group-listed-groups)
1246 (if (eq gnus-group-list-option 'flush)
1250 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1251 "List all newsgroups with unread articles of level LEVEL or lower.
1252 If PREDICATE is a function, list groups that the function returns non-nil;
1253 if it is t, list groups that have no unread articles.
1254 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1255 If REGEXP is a function, list dead groups that the function returns non-nil;
1256 if it is a string, only list groups matching REGEXP."
1257 (set-buffer gnus-group-buffer)
1258 (let ((buffer-read-only nil)
1259 (newsrc (cdr gnus-newsrc-alist))
1260 (lowest (or lowest 1))
1261 (not-in-list (and gnus-group-listed-groups
1262 (copy-sequence gnus-group-listed-groups)))
1263 info clevel unread group params)
1265 (when (or (< lowest gnus-level-zombie)
1266 gnus-group-listed-groups)
1267 ;; List living groups.
1269 (setq info (car newsrc)
1270 group (gnus-info-group info)
1271 params (gnus-info-params info)
1273 unread (gnus-group-unread group))
1275 (setq not-in-list (delete group not-in-list)))
1276 (when (gnus-group-prepare-logic
1278 (and unread ; This group might be unchecked
1279 (or (not (stringp regexp))
1280 (string-match regexp group))
1281 (<= (setq clevel (gnus-info-level info)) level)
1284 ((functionp predicate)
1285 (funcall predicate info))
1286 (predicate t) ; We list all groups?
1289 (if (eq unread t) ; Unactivated?
1290 gnus-group-list-inactive-groups
1291 ; We list unactivated
1293 ; We list groups with unread articles
1294 (and gnus-list-groups-with-ticked-articles
1295 (cdr (assq 'tick (gnus-info-marks info))))
1296 ; And groups with tickeds
1297 ;; Check for permanent visibility.
1298 (and gnus-permanently-visible-groups
1299 (string-match gnus-permanently-visible-groups
1301 (memq 'visible params)
1302 (cdr (assq 'visible params)))))))
1303 (gnus-group-insert-group-line
1304 group (gnus-info-level info)
1305 (gnus-info-marks info) unread (gnus-info-method info)))))
1307 ;; List dead groups.
1308 (when (or gnus-group-listed-groups
1309 (and (>= level gnus-level-zombie)
1310 (<= lowest gnus-level-zombie)))
1311 (gnus-group-prepare-flat-list-dead
1312 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1313 gnus-level-zombie ?Z
1316 (dolist (group gnus-zombie-list)
1317 (setq not-in-list (delete group not-in-list))))
1318 (when (or gnus-group-listed-groups
1319 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1320 (gnus-group-prepare-flat-list-dead
1323 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1324 gnus-level-killed ?K regexp))
1326 (gnus-group-set-mode-line)
1327 (setq gnus-group-list-mode (cons level predicate))
1328 (gnus-run-hooks 'gnus-group-prepare-hook)
1331 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1332 ;; List zombies and killed lists somewhat faster, which was
1333 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1334 ;; this by ignoring the group format specification altogether.
1336 (if (> (length groups) gnus-group-listing-limit)
1338 (setq group (pop groups))
1339 (when (gnus-group-prepare-logic
1342 (and (stringp regexp) (string-match regexp group))
1343 (and (functionp regexp) (funcall regexp group))))
1344 (gnus-add-text-properties
1345 (point) (prog1 (1+ (point))
1346 (insert " " mark " *: "
1347 (gnus-group-decoded-name group)
1349 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1351 'gnus-level level))))
1353 (setq group (pop groups))
1354 (when (gnus-group-prepare-logic
1357 (and (stringp regexp) (string-match regexp group))
1358 (and (functionp regexp) (funcall regexp group))))
1359 (gnus-group-insert-group-line
1361 (let ((active (gnus-active group)))
1363 (if (zerop (cdr active))
1365 (- (1+ (cdr active)) (car active)))
1367 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1369 (defun gnus-group-update-group-line ()
1370 "Update the current line in the group buffer."
1371 (let* ((buffer-read-only nil)
1372 (group (gnus-group-group-name))
1373 (entry (and group (gnus-group-entry group)))
1374 gnus-group-indentation)
1377 (not (gnus-ephemeral-group-p group))
1379 (concat "(gnus-group-set-info '"
1380 (gnus-prin1-to-string (nth 2 entry))
1382 (setq gnus-group-indentation (gnus-group-group-indentation))
1384 (gnus-group-insert-group-line-info group)
1386 (gnus-group-position-point))))
1388 (defun gnus-group-insert-group-line-info (group)
1389 "Insert GROUP on the current line."
1390 (let ((entry (gnus-group-entry group))
1391 (gnus-group-indentation (gnus-group-group-indentation))
1395 ;; (Un)subscribed group.
1396 (setq info (nth 2 entry))
1397 (gnus-group-insert-group-line
1398 group (gnus-info-level info) (gnus-info-marks info)
1399 (or (car entry) t) (gnus-info-method info)))
1400 ;; This group is dead.
1401 (gnus-group-insert-group-line
1403 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1405 (if (setq active (gnus-active group))
1406 (if (zerop (cdr active))
1408 (- (1+ (cdr active)) (car active)))
1410 (gnus-method-simplify (gnus-find-method-for-group group))))))
1412 (defun gnus-number-of-unseen-articles-in-group (group)
1413 (let* ((info (nth 2 (gnus-group-entry group)))
1414 (marked (gnus-info-marks info))
1415 (seen (cdr (assq 'seen marked)))
1416 (active (gnus-active group)))
1419 (length (gnus-uncompress-range
1420 (gnus-range-difference
1421 (gnus-range-difference (list active) (gnus-info-read info))
1424 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1425 gnus-tmp-marked number
1427 "Insert a group line in the group buffer."
1428 (let* ((gnus-tmp-method
1429 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1430 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1432 (gnus-tmp-active (gnus-active gnus-tmp-group))
1433 (gnus-tmp-number-total
1435 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1437 (gnus-tmp-number-of-unread
1438 (if (numberp number) (int-to-string (max 0 number))
1440 (gnus-tmp-number-of-read
1441 (if (numberp number)
1442 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1444 (gnus-tmp-subscribed
1445 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1446 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1447 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1449 (gnus-tmp-qualified-group
1450 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1451 group-name-charset))
1453 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1455 (gnus-tmp-newsgroup-description
1456 (if gnus-description-hashtb
1457 (or (gnus-group-name-decode
1458 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1459 group-name-charset) "")
1462 (if (and gnus-moderated-hashtb
1463 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1465 (gnus-tmp-moderated-string
1466 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1467 (gnus-tmp-group-icon "==&&==")
1468 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1469 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1470 (gnus-tmp-news-method-string
1472 (format "(%s:%s)" (car gnus-tmp-method)
1473 (cadr gnus-tmp-method)) ""))
1474 (gnus-tmp-marked-mark
1475 (if (and (numberp number)
1477 (cdr (assq 'tick gnus-tmp-marked)))
1479 (gnus-tmp-summary-live
1480 (if (and (not gnus-group-is-exiting-p)
1481 (gnus-buffer-live-p (gnus-summary-buffer-name
1484 (gnus-tmp-process-marked
1485 (if (member gnus-tmp-group gnus-group-marked)
1486 gnus-process-mark ? ))
1487 (buffer-read-only nil)
1488 header gnus-tmp-header) ; passed as parameter to user-funcs.
1490 (gnus-add-text-properties
1494 (let ((gnus-tmp-group (gnus-group-name-decode
1495 gnus-tmp-group group-name-charset)))
1496 (eval gnus-group-line-format-spec)))
1497 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1498 gnus-unread ,(if (numberp number)
1499 (string-to-int gnus-tmp-number-of-unread)
1501 gnus-marked ,gnus-tmp-marked-mark
1502 gnus-indentation ,gnus-group-indentation
1503 gnus-level ,gnus-tmp-level))
1505 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1506 (gnus-run-hooks 'gnus-group-update-hook))
1508 ;; Allow XEmacs to remove front-sticky text properties.
1509 (gnus-group-remove-excess-properties)))
1511 (defun gnus-group-highlight-line ()
1512 "Highlight the current line according to `gnus-group-highlight'."
1513 (let* ((list gnus-group-highlight)
1515 (end (point-at-eol))
1516 ;; now find out where the line starts and leave point there.
1517 (beg (progn (beginning-of-line) (point)))
1518 (group (gnus-group-group-name))
1519 (entry (gnus-group-entry group))
1520 (unread (if (numberp (car entry)) (car entry) 0))
1521 (active (gnus-active group))
1522 (total (if active (1+ (- (cdr active) (car active))) 0))
1523 (info (nth 2 entry))
1524 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1525 (marked (gnus-info-marks info))
1526 (mailp (apply 'append
1529 (memq x (assoc (symbol-name
1530 (car (or method gnus-select-method)))
1531 gnus-valid-select-methods)))
1532 '(mail post-mail))))
1533 (level (or (gnus-info-level info) gnus-level-killed))
1534 (score (or (gnus-info-score info) 0))
1535 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1536 (group-age (gnus-group-timestamp-delta group))
1537 (inhibit-read-only t))
1538 ;; Eval the cars of the lists until we find a match.
1540 (not (eval (caar list))))
1541 (setq list (cdr list)))
1542 (let ((face (cdar list)))
1543 (unless (eq face (get-text-property beg 'face))
1544 (gnus-put-text-property-excluding-characters-with-faces
1546 (setq face (if (boundp face) (symbol-value face) face)))
1547 (gnus-extent-start-open beg)))
1550 (defun gnus-group-update-group (group &optional visible-only)
1551 "Update all lines where GROUP appear.
1552 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1554 ;; Can't use `save-excursion' here, so we do it manually.
1555 (let ((buf (current-buffer))
1557 (set-buffer gnus-group-buffer)
1558 (setq mark (point-marker))
1559 ;; The buffer may be narrowed.
1562 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1564 found buffer-read-only)
1565 ;; Enter the current status into the dribble buffer.
1566 (let ((entry (gnus-group-entry group)))
1568 (not (gnus-ephemeral-group-p group)))
1570 (concat "(gnus-group-set-info '"
1571 (gnus-prin1-to-string (nth 2 entry))
1573 ;; Find all group instances. If topics are in use, each group
1574 ;; may be listed in more than once.
1575 (while (setq loc (text-property-any
1576 loc (point-max) 'gnus-group ident))
1579 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1581 (gnus-group-insert-group-line-info group)
1584 (gnus-run-hooks 'gnus-group-update-group-hook)))
1585 (setq loc (1+ loc)))
1586 (unless (or found visible-only)
1587 ;; No such line in the buffer, find out where it's supposed to
1588 ;; go, and insert it there (or at the end of the buffer).
1589 (if gnus-goto-missing-group-function
1590 (funcall gnus-goto-missing-group-function group)
1591 (let ((entry (cddr (gnus-group-entry group))))
1592 (while (and entry (car entry)
1596 (point-min) (point-max)
1597 'gnus-group (gnus-intern-safe
1598 (caar entry) gnus-active-hashtb)))))
1599 (setq entry (cdr entry)))
1600 (or entry (goto-char (point-max)))))
1601 ;; Finally insert the line.
1602 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1603 (gnus-group-insert-group-line-info group)
1606 (gnus-run-hooks 'gnus-group-update-group-hook))))
1607 (when gnus-group-update-group-function
1608 (funcall gnus-group-update-group-function group))
1609 (gnus-group-set-mode-line)))
1611 (set-marker mark nil)
1614 (defun gnus-group-set-mode-line ()
1615 "Update the mode line in the group buffer."
1616 (when (memq 'group gnus-updated-mode-lines)
1617 ;; Yes, we want to keep this mode line updated.
1619 (set-buffer gnus-group-buffer)
1620 (let* ((gformat (or gnus-group-mode-line-format-spec
1621 (gnus-set-format 'group-mode)))
1622 (gnus-tmp-news-server (cadr gnus-select-method))
1623 (gnus-tmp-news-method (car gnus-select-method))
1624 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1626 gnus-tmp-header ;Dummy binding for user-defined formats
1627 ;; Get the resulting string.
1629 (and gnus-dribble-buffer
1630 (buffer-name gnus-dribble-buffer)
1631 (buffer-modified-p gnus-dribble-buffer)
1633 (set-buffer gnus-dribble-buffer)
1634 (not (zerop (buffer-size))))))
1635 (mode-string (eval gformat)))
1636 ;; Say whether the dribble buffer has been modified.
1637 (setq mode-line-modified
1638 (if modified (car gnus-mode-line-modified)
1639 (cdr gnus-mode-line-modified)))
1640 ;; If the line is too long, we chop it off.
1641 (when (> (length mode-string) max-len)
1642 (setq mode-string (substring mode-string 0 (- max-len 4))))
1644 (setq mode-line-buffer-identification
1645 (gnus-mode-line-buffer-identification
1646 (list mode-string)))
1647 (set-buffer-modified-p modified))))))
1649 (defun gnus-group-group-name ()
1650 "Get the name of the newsgroup on the current line."
1651 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1653 (symbol-name group))))
1655 (defun gnus-group-group-level ()
1656 "Get the level of the newsgroup on the current line."
1657 (get-text-property (point-at-bol) 'gnus-level))
1659 (defun gnus-group-group-indentation ()
1660 "Get the indentation of the newsgroup on the current line."
1661 (or (get-text-property (point-at-bol) 'gnus-indentation)
1662 (and gnus-group-indentation-function
1663 (funcall gnus-group-indentation-function))
1666 (defun gnus-group-group-unread ()
1667 "Get the number of unread articles of the newsgroup on the current line."
1668 (get-text-property (point-at-bol) 'gnus-unread))
1670 (defun gnus-group-new-mail (group)
1671 (if (nnmail-new-mail-p (gnus-group-real-name group))
1675 (defun gnus-group-level (group)
1676 "Return the estimated level of GROUP."
1677 (or (gnus-info-level (gnus-get-info group))
1678 (and (member group gnus-zombie-list) gnus-level-zombie)
1681 (defun gnus-group-search-forward (&optional backward all level first-too)
1682 "Find the next newsgroup with unread articles.
1683 If BACKWARD is non-nil, find the previous newsgroup instead.
1684 If ALL is non-nil, just find any newsgroup.
1685 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1687 If FIRST-TOO, the current line is also eligible as a target."
1688 (let ((way (if backward -1 1))
1689 (low gnus-level-killed)
1692 (if (and backward (progn (beginning-of-line)) (bobp))
1701 (get-text-property (point) 'gnus-group)
1705 (get-text-property (point) 'gnus-unread)))
1706 (and (numberp unread) (> unread 0)))
1707 (setq lev (get-text-property (point)
1709 (<= lev gnus-level-subscribed)))
1711 (and (setq lev (get-text-property (point)
1720 (zerop (forward-line way)))))
1722 (progn (gnus-group-position-point) t)
1723 (goto-char (or pos beg))
1726 (defun gnus-total-fetched-for (group)
1727 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1728 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1729 (size (+ size-in-cache size-in-agent))
1730 (suffix '("B" "K" "M" "G"))
1732 (cutoff (* 10 scale)))
1733 (while (> size cutoff)
1734 (setq size (/ size scale)
1735 suffix (cdr suffix)))
1736 (format "%5.1f%s" size (car suffix))))
1738 ;;; Gnus group mode commands
1742 (defun gnus-group-mark-line-p ()
1745 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1746 (eq (char-after) gnus-process-mark)))
1748 (defun gnus-group-mark-group (n &optional unmark no-advance)
1749 "Mark the current group."
1751 (let ((buffer-read-only nil)
1755 (when (setq group (gnus-group-group-name))
1756 ;; Go to the mark position.
1758 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1762 (setq gnus-group-marked (delete group gnus-group-marked))
1763 (insert-char ? 1 t))
1764 (setq gnus-group-marked
1765 (cons group (delete group gnus-group-marked)))
1766 (insert-char gnus-process-mark 1 t)))
1768 (gnus-group-next-group 1))
1770 (gnus-summary-position-point)
1773 (defun gnus-group-unmark-group (n)
1774 "Remove the mark from the current group."
1776 (gnus-group-mark-group n 'unmark)
1777 (gnus-group-position-point))
1779 (defun gnus-group-unmark-all-groups ()
1780 "Unmark all groups."
1782 (let ((groups gnus-group-marked))
1785 (gnus-group-remove-mark (pop groups)))))
1786 (gnus-group-position-point))
1788 (defun gnus-group-mark-region (unmark beg end)
1789 "Mark all groups between point and mark.
1790 If UNMARK, remove the mark instead."
1791 (interactive "P\nr")
1792 (let ((num (count-lines beg end)))
1795 (- num (gnus-group-mark-group num unmark)))))
1797 (defun gnus-group-mark-buffer (&optional unmark)
1798 "Mark all groups in the buffer.
1799 If UNMARK, remove the mark instead."
1801 (gnus-group-mark-region unmark (point-min) (point-max)))
1803 (defun gnus-group-mark-regexp (regexp)
1804 "Mark all groups that match some regexp."
1805 (interactive "sMark (regexp): ")
1806 (let ((alist (cdr gnus-newsrc-alist))
1810 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1811 (gnus-group-jump-to-group group)
1812 (gnus-group-set-mark group)))))
1813 (gnus-group-position-point))
1815 (defun gnus-group-remove-mark (group &optional test-marked)
1816 "Remove the process mark from GROUP and move point there.
1817 Return nil if the group isn't displayed."
1818 (if (gnus-group-goto-group group nil test-marked)
1820 (gnus-group-mark-group 1 'unmark t)
1822 (setq gnus-group-marked
1823 (delete group gnus-group-marked))
1826 (defun gnus-group-set-mark (group)
1827 "Set the process mark on GROUP."
1828 (if (gnus-group-goto-group group)
1830 (gnus-group-mark-group 1 nil t))
1831 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1833 (defun gnus-group-universal-argument (arg &optional groups func)
1834 "Perform any command on all groups according to the process/prefix convention."
1836 (if (eq (setq func (or func
1839 (substitute-command-keys
1840 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1842 (gnus-error 1 "Undefined key")
1843 (gnus-group-iterate arg
1845 (command-execute func))))
1846 (gnus-group-position-point))
1848 (defun gnus-group-process-prefix (n)
1849 "Return a list of groups to work on.
1850 Take into consideration N (the prefix) and the list of marked groups."
1853 (setq n (prefix-numeric-value n))
1854 ;; There is a prefix, so we return a list of the N next
1856 (let ((way (if (< n 0) -1 1))
1861 (if (setq group (gnus-group-group-name))
1862 (push group groups))
1864 (gnus-group-next-group way)))
1866 ((and (gnus-region-active-p) (mark))
1867 ;; Work on the region between point and mark.
1868 (let ((max (max (point) (mark)))
1871 (goto-char (min (point) (mark)))
1874 (push (gnus-group-group-name) groups)
1875 (zerop (gnus-group-next-group 1))
1877 (nreverse groups))))
1879 ;; No prefix, but a list of marked articles.
1880 (reverse gnus-group-marked))
1882 ;; Neither marked articles or a prefix, so we return the
1884 (let ((group (gnus-group-group-name)))
1885 (and group (list group))))))
1887 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1888 ;;; imagine why I went through these contortions...
1890 (let ((function (make-symbol "gnus-group-iterate-function"))
1891 (window (make-symbol "gnus-group-iterate-window"))
1892 (groups (make-symbol "gnus-group-iterate-groups"))
1893 (group (make-symbol "gnus-group-iterate-group")))
1895 `(defun gnus-group-iterate (arg ,function)
1896 "Iterate FUNCTION over all process/prefixed groups.
1897 FUNCTION will be called with the group name as the parameter
1898 and with point over the group in question."
1899 (let ((,groups (gnus-group-process-prefix arg))
1900 (,window (selected-window))
1903 (setq ,group (car ,groups)
1904 ,groups (cdr ,groups))
1905 (select-window ,window)
1906 (gnus-group-remove-mark ,group)
1907 (save-selected-window
1909 (funcall ,function ,group)))))))))
1911 (put 'gnus-group-iterate 'lisp-indent-function 1)
1913 ;; Selecting groups.
1915 (defun gnus-group-read-group (&optional all no-article group select-articles)
1916 "Read news in this newsgroup.
1917 If the prefix argument ALL is non-nil, already read articles become
1918 readable. IF ALL is a number, fetch this number of articles. If the
1919 optional argument NO-ARTICLE is non-nil, no article will be
1920 auto-selected upon group entry. If GROUP is non-nil, fetch that
1923 (let ((no-display (eq all 0))
1924 (group (or group (gnus-group-group-name)))
1925 number active marked entry)
1929 (error "No group on current line"))
1930 (setq marked (gnus-info-marks
1931 (nth 2 (setq entry (gnus-group-entry group)))))
1932 ;; This group might be a dead group. In that case we have to get
1933 ;; the number of unread articles from `gnus-active-hashtb'.
1935 (cond ((numberp all) all)
1937 ((setq active (gnus-active group))
1938 (- (1+ (cdr active)) (car active)))))
1939 (gnus-summary-read-group
1940 group (or all (and (numberp number)
1941 (zerop (+ number (gnus-range-length
1942 (cdr (assq 'tick marked)))
1944 (cdr (assq 'dormant marked)))))))
1945 no-article nil no-display nil select-articles)))
1947 (defun gnus-group-select-group (&optional all)
1948 "Select this newsgroup.
1949 No article is selected automatically.
1950 If the group is opened, just switch the summary buffer.
1951 If ALL is non-nil, already read articles become readable.
1952 If ALL is a positive number, fetch this number of the latest
1953 articles in the group.
1954 If ALL is a negative number, fetch this number of the earliest
1955 articles in the group."
1957 (when (and (eobp) (not (gnus-group-group-name)))
1959 (gnus-group-read-group all t))
1961 (defun gnus-group-quick-select-group (&optional all)
1962 "Select the current group \"quickly\".
1963 This means that no highlighting or scoring will be performed.
1964 If ALL (the prefix argument) is 0, don't even generate the summary
1967 This might be useful if you want to toggle threading
1968 before entering the group."
1970 (require 'gnus-score)
1972 gnus-score-find-score-files-function
1973 gnus-home-score-file
1974 gnus-apply-kill-hook
1975 gnus-summary-expunge-below)
1976 (gnus-group-read-group all t)))
1978 (defun gnus-group-visible-select-group (&optional all)
1979 "Select the current group without hiding any articles."
1981 (let ((gnus-inhibit-limiting t))
1982 (gnus-group-read-group all t)))
1984 (defun gnus-group-select-group-ephemerally ()
1985 "Select the current group without doing any processing whatsoever.
1986 You will actually be entered into a group that's a copy of
1987 the current group; no changes you make while in this group will
1990 (require 'gnus-score)
1992 gnus-score-find-score-files-function gnus-apply-kill-hook
1993 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1994 gnus-summary-mode-hook gnus-select-group-hook
1995 (group (gnus-group-group-name))
1996 (method (gnus-find-method-for-group group)))
1997 (gnus-group-read-ephemeral-group
1998 (gnus-group-prefixed-name group method) method)))
2001 (defun gnus-fetch-group (group &optional articles)
2002 "Start Gnus if necessary and enter GROUP.
2003 Returns whether the fetching was successful or not."
2004 (interactive (list (gnus-group-completing-read-group-name
2005 "Group name: " gnus-active-hashtb)))
2006 (unless (get-buffer gnus-group-buffer)
2008 (gnus-group-read-group articles nil group))
2011 (defun gnus-fetch-group-other-frame (group)
2012 "Pop up a frame and enter GROUP."
2014 (let ((window (get-buffer-window gnus-group-buffer)))
2016 (select-frame (window-frame window)))
2017 ((= (length (frame-list)) 1)
2018 (select-frame (make-frame)))
2021 (gnus-fetch-group group))
2023 (defvar gnus-ephemeral-group-server 0)
2025 (defcustom gnus-large-ephemeral-newsgroup 200
2026 "The number of articles which indicates a large ephemeral newsgroup.
2027 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2029 If the number of articles in a newsgroup is greater than this value,
2030 confirmation is required for selecting the newsgroup. If it is nil, no
2031 confirmation is required."
2032 :group 'gnus-group-select
2033 :type '(choice (const :tag "No limit" nil)
2036 (defcustom gnus-fetch-old-ephemeral-headers nil
2037 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2039 :type '(choice (const :tag "off" nil)
2042 (sexp :menu-tag "other" t)))
2044 ;; Enter a group that is not in the group buffer. Non-nil is returned
2045 ;; if selection was successful.
2046 (defun gnus-group-read-ephemeral-group (group method &optional activate
2047 quit-config request-only
2050 "Read GROUP from METHOD as an ephemeral group.
2051 If ACTIVATE, request the group first.
2052 If QUIT-CONFIG, use that window configuration when exiting from the
2054 If REQUEST-ONLY, don't actually read the group; just request it.
2055 If SELECT-ARTICLES, only select those articles.
2056 If PARAMETERS, use those as the group parameters.
2058 Return the name of the group if selection was successful."
2061 ;; (gnus-read-group "Group name: ")
2063 "Group: " gnus-active-hashtb
2065 'gnus-group-history)
2066 (gnus-read-method "From method: ")))
2067 ;; Transform the select method into a unique server.
2068 (when (stringp method)
2069 (setq method (gnus-server-to-method method)))
2071 `(,(car method) ,(concat (cadr method) "-ephemeral")
2072 (,(intern (format "%s-address" (car method))) ,(cadr method))
2074 (let ((group (if (gnus-group-foreign-p group) group
2075 (gnus-group-prefixed-name (gnus-group-real-name group)
2080 ,gnus-level-default-subscribed nil nil ,method
2083 (cons 'quit-config quit-config)
2085 (cons gnus-summary-buffer
2086 gnus-current-window-configuration)))
2089 (push method gnus-ephemeral-servers)
2090 (set-buffer gnus-group-buffer)
2091 (unless (gnus-check-server method)
2092 (error "Unable to contact server: %s" (gnus-status-message method)))
2094 (gnus-activate-group group 'scan)
2095 (unless (gnus-request-group group)
2096 (error "Couldn't request group: %s"
2097 (nnheader-get-report (car method)))))
2101 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2102 (gnus-fetch-old-headers
2103 gnus-fetch-old-ephemeral-headers))
2104 (gnus-group-read-group t t group select-articles))
2108 (message "Quit reading the ephemeral group")
2111 (defun gnus-group-jump-to-group (group &optional prompt)
2112 "Jump to newsgroup GROUP.
2114 If PROMPT (the prefix) is a number, use the prompt specified in
2115 `gnus-group-jump-to-group-prompt'."
2117 (list (mm-string-make-unibyte
2119 "Group: " gnus-active-hashtb nil
2120 (gnus-read-active-file-p)
2121 (if current-prefix-arg
2122 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2123 (or (and (stringp gnus-group-jump-to-group-prompt)
2124 gnus-group-jump-to-group-prompt)
2125 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2126 (and (stringp p) p))))
2127 'gnus-group-history))))
2129 (when (equal group "")
2130 (error "Empty group name"))
2132 (unless (gnus-ephemeral-group-p group)
2133 ;; Either go to the line in the group buffer...
2134 (unless (gnus-group-goto-group group)
2135 ;; ... or insert the line.
2136 (gnus-group-update-group group)
2137 (gnus-group-goto-group group)))
2138 ;; Adjust cursor point.
2139 (gnus-group-position-point))
2141 (defun gnus-group-goto-group (group &optional far test-marked)
2142 "Goto to newsgroup GROUP.
2143 If FAR, it is likely that the group is not on the current line.
2144 If TEST-MARKED, the line must be marked."
2148 ;; It's quite likely that we are on the right line, so
2149 ;; we check the current line first.
2151 (eq (get-text-property (point) 'gnus-group)
2152 (gnus-intern-safe group gnus-active-hashtb))
2153 (or (not test-marked) (gnus-group-mark-line-p)))
2155 ;; Previous and next line are also likely, so we check them as well.
2159 (and (eq (get-text-property (point) 'gnus-group)
2160 (gnus-intern-safe group gnus-active-hashtb))
2161 (or (not test-marked) (gnus-group-mark-line-p)))))
2167 (and (eq (get-text-property (point) 'gnus-group)
2168 (gnus-intern-safe group gnus-active-hashtb))
2169 (or (not test-marked) (gnus-group-mark-line-p)))))
2173 (goto-char (point-min))
2175 (while (and (not found)
2180 (gnus-intern-safe group gnus-active-hashtb))))
2181 (if (gnus-group-mark-line-p)
2186 ;; Search through the entire buffer.
2189 (point-min) (point-max)
2190 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2192 (defun gnus-group-next-group (n &optional silent)
2193 "Go to next N'th newsgroup.
2194 If N is negative, search backward instead.
2195 Returns the difference between N and the number of skips actually
2198 (gnus-group-next-unread-group n t nil silent))
2200 (defun gnus-group-next-unread-group (n &optional all level silent)
2201 "Go to next N'th unread newsgroup.
2202 If N is negative, search backward instead.
2203 If ALL is non-nil, choose any newsgroup, unread or not.
2204 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2205 such group can be found, the next group with a level higher than
2207 Returns the difference between N and the number of skips actually
2210 (let ((backward (< n 0))
2213 (gnus-group-search-forward
2214 backward (or (not gnus-group-goto-unread) all) level))
2218 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2219 (if level " on this level or higher" "")))
2222 (defun gnus-group-prev-group (n)
2223 "Go to previous N'th newsgroup.
2224 Returns the difference between N and the number of skips actually
2227 (gnus-group-next-unread-group (- n) t))
2229 (defun gnus-group-prev-unread-group (n)
2230 "Go to previous N'th unread newsgroup.
2231 Returns the difference between N and the number of skips actually
2234 (gnus-group-next-unread-group (- n)))
2236 (defun gnus-group-next-unread-group-same-level (n)
2237 "Go to next N'th unread newsgroup on the same level.
2238 If N is negative, search backward instead.
2239 Returns the difference between N and the number of skips actually
2242 (gnus-group-next-unread-group n t (gnus-group-group-level))
2243 (gnus-group-position-point))
2245 (defun gnus-group-prev-unread-group-same-level (n)
2246 "Go to next N'th unread newsgroup on the same level.
2247 Returns the difference between N and the number of skips actually
2250 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2251 (gnus-group-position-point))
2253 (defun gnus-group-best-unread-group (&optional exclude-group)
2254 "Go to the group with the highest level.
2255 If EXCLUDE-GROUP, do not go to that group."
2257 (goto-char (point-min))
2261 (setq unread (get-text-property (point) 'gnus-unread))
2262 (when (and (numberp unread) (> unread 0))
2263 (when (and (get-text-property (point) 'gnus-level)
2264 (< (get-text-property (point) 'gnus-level) best)
2265 (or (not exclude-group)
2266 (not (equal exclude-group (gnus-group-group-name)))))
2267 (setq best (get-text-property (point) 'gnus-level))
2268 (setq best-point (point))))
2271 (goto-char best-point))
2272 (gnus-group-position-point)
2273 (and best-point (gnus-group-group-name))))
2275 (defun gnus-group-first-unread-group ()
2276 "Go to the first group with unread articles."
2279 (let ((opoint (point))
2281 (goto-char (point-min))
2282 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2283 (and (numberp unread) ; Not a topic.
2284 (not (zerop unread))) ; Has unread articles.
2285 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2288 nil)) ; Not success.
2289 (gnus-group-position-point)))
2291 (defun gnus-group-enter-server-mode ()
2292 "Jump to the server buffer."
2294 (gnus-enter-server-buffer))
2296 (defun gnus-group-make-group-simple (&optional group)
2297 "Add a new newsgroup.
2298 The user will be prompted for GROUP."
2300 (list (completing-read "Group: " gnus-active-hashtb
2301 nil nil nil 'gnus-group-history)))
2302 (gnus-group-make-group
2303 (gnus-group-real-name group)
2304 (gnus-group-server group)))
2306 (defun gnus-group-make-group (name &optional method address args)
2307 "Add a new newsgroup.
2308 The user will be prompted for a NAME, for a select METHOD, and an
2312 (gnus-read-group "Group name: ")
2313 (gnus-read-method "From method: ")))
2315 (when (stringp method)
2316 (setq method (or (gnus-server-to-method method) method)))
2317 (let* ((meth (gnus-method-simplify
2319 (not (gnus-server-equal method gnus-select-method)))
2320 (if address (list (intern method) address)
2322 (nname (if method (gnus-group-prefixed-name name meth) name))
2324 (when (gnus-group-entry nname)
2325 (error "Group %s already exists" nname))
2326 ;; Subscribe to the new group.
2327 (gnus-group-change-level
2328 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2329 gnus-level-default-subscribed gnus-level-killed
2330 (and (gnus-group-group-name)
2331 (gnus-group-entry (gnus-group-group-name)))
2334 (gnus-set-active nname (cons 1 0))
2335 (unless (gnus-ephemeral-group-p name)
2337 (concat "(gnus-group-set-info '"
2338 (gnus-prin1-to-string (cdr info)) ")")))
2340 (gnus-group-insert-group-line-info nname)
2342 (gnus-group-position-point)
2344 ;; Load the back end and try to make the back end create
2345 ;; the group as well.
2346 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2348 gnus-valid-select-methods)
2350 (gnus-check-server meth)
2351 (when (gnus-check-backend-function 'request-create-group nname)
2352 (unless (gnus-request-create-group nname nil args)
2353 (error "Could not create group on server: %s"
2354 (nnheader-get-report backend))))
2357 (defun gnus-group-delete-groups (&optional arg)
2358 "Delete the current group. Only meaningful with editable groups."
2360 (let ((n (length (gnus-group-process-prefix arg))))
2361 (when (gnus-yes-or-no-p
2363 "Delete this 1 group? "
2364 (format "Delete these %d groups? " n)))
2365 (gnus-group-iterate arg
2367 (gnus-group-delete-group group nil t))))))
2369 (defun gnus-group-delete-group (group &optional force no-prompt)
2370 "Delete the current group. Only meaningful with editable groups.
2371 If FORCE (the prefix) is non-nil, all the articles in the group will
2372 be deleted. This is \"deleted\" as in \"removed forever from the face
2373 of the Earth\". There is no undo. The user will be prompted before
2375 Note that you also have to specify FORCE if you want the group to
2376 be removed from the server, even when it's empty."
2378 (list (gnus-group-group-name)
2379 current-prefix-arg))
2381 (error "No group to delete"))
2382 (unless (gnus-check-backend-function 'request-delete-group group)
2383 (error "This back end does not support group deletion"))
2385 (if (and (not no-prompt)
2386 (not (gnus-yes-or-no-p
2388 "Do you really want to delete %s%s? "
2389 group (if force " and all its contents" "")))))
2391 (gnus-message 6 "Deleting group %s..." group)
2392 (if (not (gnus-request-delete-group group force))
2393 (gnus-error 3 "Couldn't delete group %s" group)
2394 (gnus-message 6 "Deleting group %s...done" group)
2395 (gnus-group-goto-group group)
2396 (gnus-group-kill-group 1 t)
2397 (gnus-set-active group nil)
2399 (gnus-group-position-point)))
2401 (defun gnus-group-rename-group (group new-name)
2402 "Rename group from GROUP to NEW-NAME.
2403 When used interactively, GROUP is the group under point
2404 and NEW-NAME will be prompted for."
2407 (gnus-group-group-name)
2409 (unless (gnus-check-backend-function
2410 'request-rename-group (gnus-group-group-name))
2411 (error "This back end does not support renaming groups"))
2412 (gnus-read-group "Rename group to: "
2413 (gnus-group-real-name (gnus-group-group-name))))))
2415 (unless (gnus-check-backend-function 'request-rename-group group)
2416 (error "This back end does not support renaming groups"))
2418 (error "No group to rename"))
2419 (when (equal (gnus-group-real-name group) new-name)
2420 (error "Can't rename to the same name"))
2422 ;; We find the proper prefixed name.
2424 (if (gnus-group-native-p group)
2428 (gnus-group-prefixed-name
2429 (gnus-group-real-name new-name)
2430 (gnus-info-method (gnus-get-info group)))))
2432 (when (gnus-active new-name)
2433 (error "The group %s already exists" new-name))
2435 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2438 (gnus-group-goto-group group)
2439 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2440 (gnus-request-rename-group group new-name))))
2441 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2442 ;; We rename the group internally by killing it...
2443 (gnus-group-kill-group)
2444 ;; ... changing its name ...
2445 (setcar (cdar gnus-list-of-killed-groups) new-name)
2446 ;; ... and then yanking it. Magic!
2447 (gnus-group-yank-group)
2448 (gnus-set-active new-name (gnus-active group))
2449 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2451 (setq gnus-killed-list (delete group gnus-killed-list))
2452 (gnus-set-active group nil)
2453 (gnus-dribble-touch)
2454 (gnus-group-position-point)))
2456 (defun gnus-group-edit-group (group &optional part)
2457 "Edit the group on the current line."
2458 (interactive (list (gnus-group-group-name)))
2459 (let ((part (or part 'info))
2462 (error "No group on current line"))
2463 (unless (setq info (gnus-get-info group))
2464 (error "Killed group; can't be edited"))
2466 (gnus-close-group group))
2468 ;; Find the proper form to edit.
2469 (cond ((eq part 'method)
2470 (or (gnus-info-method info) "native"))
2472 (gnus-info-params info))
2474 ;; The proper documentation.
2476 "Editing the %s for `%s'."
2478 ((eq part 'method) "select method")
2479 ((eq part 'params) "group parameters")
2481 (gnus-group-decoded-name group))
2483 (gnus-group-edit-group-done ',part ,group form)))
2486 (gnus-create-info-command
2488 (or gnus-info-filename
2489 (get-language-info current-language-environment 'gnus-info)
2491 (cond ((eq part 'method)
2498 (defun gnus-group-edit-group-method (group)
2499 "Edit the select method of GROUP."
2500 (interactive (list (gnus-group-group-name)))
2501 (gnus-group-edit-group group 'method))
2503 (defun gnus-group-edit-group-parameters (group)
2504 "Edit the group parameters of GROUP."
2505 (interactive (list (gnus-group-group-name)))
2506 (gnus-group-edit-group group 'params))
2508 (defun gnus-group-edit-group-done (part group form)
2510 (let* ((method (cond ((eq part 'info) (nth 4 form))
2511 ((eq part 'method) form)
2513 (info (cond ((eq part 'info) form)
2514 ((eq part 'method) (gnus-get-info group))
2517 (if (or (not method)
2519 gnus-select-method method))
2520 (gnus-group-real-name (car info))
2521 (gnus-group-prefixed-name
2522 (gnus-group-real-name (car info)) method))
2524 (when (and new-group
2525 (not (equal new-group group)))
2526 (when (gnus-group-goto-group group)
2527 (gnus-group-kill-group 1))
2528 (gnus-activate-group new-group))
2530 (if (not (and info new-group))
2531 (gnus-group-set-info form (or new-group group) part)
2532 (setq info (gnus-copy-sequence info))
2533 (setcar info new-group)
2534 (unless (gnus-server-equal method "native")
2535 (unless (nthcdr 3 info)
2536 (nconc info (list nil nil)))
2537 (unless (nthcdr 4 info)
2538 (nconc info (list nil)))
2539 (gnus-info-set-method info method))
2540 (gnus-group-set-info info))
2541 (gnus-group-update-group (or new-group group))
2542 (gnus-group-position-point)))
2544 (defun gnus-group-make-useful-group (group method)
2545 "Create one of the groups described in `gnus-useful-groups'."
2547 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2549 gnus-useful-groups)))
2550 (list (cadr entry) (caddr entry))))
2551 (setq method (gnus-copy-sequence method))
2553 (while (setq entry (memq (assq 'eval method) method))
2554 (setcar entry (eval (cadar entry)))))
2555 (gnus-group-make-group group method))
2557 (defun gnus-group-make-help-group (&optional noerror)
2558 "Create the Gnus documentation group.
2559 Optional argument NOERROR modifies the behavior of this function when the
2560 group already exists:
2561 - if not given, and error is signaled,
2562 - if t, stay silent,
2563 - if anything else, just print a message."
2565 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2566 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2567 (if (gnus-group-entry name)
2568 (cond ((eq noerror nil)
2569 (error "Documentation group already exists"))
2574 (gnus-message 1 "Documentation group already exists")))
2577 (gnus-message 1 "Couldn't find doc group")
2578 (gnus-group-make-group
2579 (gnus-group-real-name name)
2580 (list 'nndoc "gnus-help"
2581 (list 'nndoc-address file)
2582 (list 'nndoc-article-type 'mbox))))
2584 (gnus-group-position-point))
2586 (defun gnus-group-make-doc-group (file type)
2587 "Create a group that uses a single file as the source."
2589 (list (read-file-name "File name: ")
2590 (and current-prefix-arg 'ask)))
2591 (when (eq type 'ask)
2596 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2598 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2599 ((= char ?b) 'babyl)
2600 ((= char ?d) 'digest)
2601 ((= char ?f) 'forward)
2603 ((= char ?g) 'guess)
2604 (t (setq err (format "%c unknown. " char))
2607 (let* ((file (expand-file-name file))
2608 (name (gnus-generate-new-group-name
2609 (gnus-group-prefixed-name
2610 (file-name-nondirectory file) '(nndoc "")))))
2611 (gnus-group-make-group
2612 (gnus-group-real-name name)
2614 (list 'nndoc-address file)
2615 (list 'nndoc-article-type (or type 'guess))))))
2617 (defvar nnweb-type-definition)
2618 (defvar gnus-group-web-type-history nil)
2619 (defvar gnus-group-web-search-history nil)
2620 (defun gnus-group-make-web-group (&optional solid)
2621 "Create an ephemeral nnweb group.
2622 If SOLID (the prefix), create a solid group."
2626 (if solid (gnus-read-group "Group name: ")
2627 (message-unique-id)))
2628 (default-type (or (car gnus-group-web-type-history)
2629 (symbol-name (caar nnweb-type-definition))))
2633 (format "Search engine type (default %s): " default-type)
2634 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2635 nnweb-type-definition)
2636 nil t nil 'gnus-group-web-type-history)
2641 (cons (or (car gnus-group-web-search-history) "") 0)
2642 'gnus-group-web-search-history))
2644 `(nnweb ,group (nnweb-search ,search)
2645 (nnweb-type ,(intern type))
2646 (nnweb-ephemeral-p t))))
2649 (gnus-pull 'nnweb-ephemeral-p method)
2650 (gnus-group-make-group group method))
2651 (gnus-group-read-ephemeral-group
2653 (cons (current-buffer)
2654 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2657 (defvar nnrss-group-alist)
2658 (defun nnrss-discover-feed (arg))
2659 (defun nnrss-save-server-data (arg)))
2660 (defun gnus-group-make-rss-group (&optional url)
2661 "Given a URL, discover if there is an RSS feed.
2662 If there is, use Gnus to create an nnrss group"
2666 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2667 (let ((feedinfo (nnrss-discover-feed url)))
2669 (let ((title (read-from-minibuffer "Title: "
2672 (desc (read-from-minibuffer "Description: "
2673 (cdr (assoc 'description
2675 (href (cdr (assoc 'href feedinfo))))
2676 (push (list title href desc)
2678 (gnus-group-unsubscribe-group
2679 (concat "nnrss:" title))
2680 (nnrss-save-server-data nil))
2681 (error "No feeds found for %s" url))))
2683 (defvar nnwarchive-type-definition)
2684 (defvar gnus-group-warchive-type-history nil)
2685 (defvar gnus-group-warchive-login-history nil)
2686 (defvar gnus-group-warchive-address-history nil)
2688 (defun gnus-group-make-warchive-group ()
2689 "Create a nnwarchive group."
2691 (require 'nnwarchive)
2692 (let* ((group (gnus-read-group "Group name: "))
2693 (default-type (or (car gnus-group-warchive-type-history)
2694 (symbol-name (caar nnwarchive-type-definition))))
2698 (format "Warchive type (default %s): " default-type)
2699 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2700 nnwarchive-type-definition)
2701 nil t nil 'gnus-group-warchive-type-history)
2703 (address (read-string "Warchive address: "
2704 nil 'gnus-group-warchive-address-history))
2705 (default-login (or (car gnus-group-warchive-login-history)
2710 (format "Warchive login (default %s): " user-mail-address)
2711 default-login 'gnus-group-warchive-login-history)
2714 `(nnwarchive ,address
2715 (nnwarchive-type ,(intern type))
2716 (nnwarchive-login ,login))))
2717 (gnus-group-make-group group method)))
2719 (defun gnus-group-make-archive-group (&optional all)
2720 "Create the (ding) Gnus archive group of the most recent articles.
2721 Given a prefix, create a full group."
2723 (let ((group (gnus-group-prefixed-name
2724 (if all "ding.archives" "ding.recent") '(nndir ""))))
2725 (when (gnus-group-entry group)
2726 (error "Archive group already exists"))
2727 (gnus-group-make-group
2728 (gnus-group-real-name group)
2729 (list 'nndir (if all "hpc" "edu")
2730 (list 'nndir-directory
2731 (if all gnus-group-archive-directory
2732 gnus-group-recent-archive-directory))))
2733 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2735 (defun gnus-group-make-directory-group (dir)
2736 "Create an nndir group.
2737 The user will be prompted for a directory. The contents of this
2738 directory will be used as a newsgroup. The directory should contain
2739 mail messages or news articles in files that have numeric names."
2741 (list (read-file-name "Create group from directory: ")))
2742 (unless (file-exists-p dir)
2743 (error "No such directory"))
2744 (unless (file-directory-p dir)
2745 (error "Not a directory"))
2749 (while (or (not group) (gnus-group-entry group))
2751 (gnus-group-prefixed-name
2752 (expand-file-name ext dir)
2754 (setq ext (format "<%d>" (setq i (1+ i)))))
2755 (gnus-group-make-group
2756 (gnus-group-real-name group)
2757 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2759 (defvar nnkiboze-score-file)
2760 (defun gnus-group-make-kiboze-group (group address scores)
2761 "Create an nnkiboze group.
2762 The user will be prompted for a name, a regexp to match groups, and
2763 score file entries for articles to include in the group."
2766 (read-string "nnkiboze group name: ")
2767 (read-string "Source groups (regexp): ")
2768 (let ((headers (mapcar 'list
2769 '("subject" "from" "number" "date" "message-id"
2770 "references" "chars" "lines" "xref"
2771 "followup" "all" "body" "head")))
2772 scores header regexp regexps)
2773 (while (not (equal "" (setq header (completing-read
2774 "Match on header: " headers nil t))))
2776 (while (not (equal "" (setq regexp (read-string
2777 (format "Match on %s (regexp): "
2779 (push (list regexp nil nil 'r) regexps))
2780 (push (cons header regexps) scores))
2782 (gnus-group-make-group group "nnkiboze" address)
2783 (let* ((nnkiboze-current-group group)
2784 (score-file (car (nnkiboze-score-file "")))
2785 (score-dir (file-name-directory score-file)))
2786 (unless (file-exists-p score-dir)
2787 (make-directory score-dir))
2788 (with-temp-file score-file
2789 (let (emacs-lisp-mode-hook)
2790 (gnus-pp scores)))))
2792 (defun gnus-group-add-to-virtual (n vgroup)
2793 "Add the current group to a virtual group."
2795 (list current-prefix-arg
2796 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2798 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2799 (error "%s is not an nnvirtual group" vgroup))
2800 (gnus-close-group vgroup)
2801 (let* ((groups (gnus-group-process-prefix n))
2802 (method (gnus-info-method (gnus-get-info vgroup))))
2803 (setcar (cdr method)
2805 (nth 1 method) "\\|"
2808 (gnus-group-remove-mark s)
2809 (concat "\\(^" (regexp-quote s) "$\\)"))
2811 (gnus-group-position-point))
2813 (defun gnus-group-make-empty-virtual (group)
2814 "Create a new, fresh, empty virtual group."
2815 (interactive "sCreate new, empty virtual group: ")
2816 (let* ((method (list 'nnvirtual "^$"))
2817 (pgroup (gnus-group-prefixed-name group method)))
2818 ;; Check whether it exists already.
2819 (when (gnus-group-entry pgroup)
2820 (error "Group %s already exists" pgroup))
2821 ;; Subscribe the new group after the group on the current line.
2822 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2823 (gnus-group-update-group pgroup)
2825 (gnus-group-position-point)))
2827 (defun gnus-group-enter-directory (dir)
2828 "Enter an ephemeral nneething group."
2829 (interactive "DDirectory to read: ")
2830 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2831 (leaf (gnus-group-prefixed-name
2832 (file-name-nondirectory (directory-file-name dir))
2834 (name (gnus-generate-new-group-name leaf)))
2835 (unless (gnus-group-read-ephemeral-group
2837 (cons (current-buffer)
2838 (if (eq major-mode 'gnus-summary-mode)
2840 (error "Couldn't enter %s" dir))))
2843 (autoload 'nnimap-expunge "nnimap")
2844 (autoload 'nnimap-acl-get "nnimap")
2845 (autoload 'nnimap-acl-edit "nnimap"))
2847 (defun gnus-group-nnimap-expunge (group)
2848 "Expunge deleted articles in current nnimap GROUP."
2849 (interactive (list (gnus-group-group-name)))
2850 (let ((mailbox (gnus-group-real-name group)) method)
2852 (error "No group on current line"))
2853 (unless (gnus-get-info group)
2854 (error "Killed group; can't be edited"))
2855 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2856 (error "%s is not an nnimap group" group))
2857 (nnimap-expunge mailbox (cadr method))))
2859 (defun gnus-group-nnimap-edit-acl (group)
2860 "Edit the Access Control List of current nnimap GROUP."
2861 (interactive (list (gnus-group-group-name)))
2862 (let ((mailbox (gnus-group-real-name group)) method acl)
2864 (error "No group on current line"))
2865 (unless (gnus-get-info group)
2866 (error "Killed group; can't be edited"))
2867 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2868 (error "%s is not an nnimap group" group))
2869 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2870 (error "Server does not support ACL's"))
2871 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2873 An access control list is a list of (identifier . rights) elements.
2875 The identifier string specifies the corresponding user. The
2876 identifier \"anyone\" is reserved to refer to the universal identity.
2878 Rights is a string listing a (possibly empty) set of alphanumeric
2879 characters, each character listing a set of operations which is being
2880 controlled. Letters are reserved for ``standard'' rights, listed
2881 below. Digits are reserved for implementation or site defined rights.
2883 l - lookup (mailbox is visible to LIST/LSUB commands)
2884 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2885 SEARCH, COPY from mailbox)
2886 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2887 w - write (STORE flags other than \\SEEN and \\DELETED)
2888 i - insert (perform APPEND, COPY into mailbox)
2889 p - post (send mail to submission address for mailbox,
2890 not enforced by IMAP4 itself)
2891 c - create and delete mailbox (CREATE new sub-mailboxes in any
2892 implementation-defined hierarchy, RENAME or DELETE mailbox)
2893 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2894 a - administer (perform SETACL)" group)
2897 ,mailbox ',method ',acl form)))))
2899 ;; Group sorting commands
2900 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2902 (defun gnus-group-sort-groups (func &optional reverse)
2903 "Sort the group buffer according to FUNC.
2904 When used interactively, the sorting function used will be
2905 determined by the `gnus-group-sort-function' variable.
2906 If REVERSE (the prefix), reverse the sorting order."
2907 (interactive (list gnus-group-sort-function current-prefix-arg))
2908 (funcall gnus-group-sort-alist-function
2909 (gnus-make-sort-function func) reverse)
2910 (gnus-group-unmark-all-groups)
2911 (gnus-group-list-groups)
2912 (gnus-dribble-touch))
2914 (defun gnus-group-sort-flat (func reverse)
2915 ;; We peel off the dummy group from the alist.
2917 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2918 (pop gnus-newsrc-alist))
2920 (setq gnus-newsrc-alist
2921 (sort gnus-newsrc-alist func))
2923 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2924 ;; Regenerate the hash table.
2925 (gnus-make-hashtable-from-newsrc-alist)))
2927 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2928 "Sort the group buffer alphabetically by group name.
2929 If REVERSE, sort in reverse order."
2931 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2933 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2934 "Sort the group buffer alphabetically by real (unprefixed) group name.
2935 If REVERSE, sort in reverse order."
2937 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2939 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2940 "Sort the group buffer by number of unread articles.
2941 If REVERSE, sort in reverse order."
2943 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2945 (defun gnus-group-sort-groups-by-level (&optional reverse)
2946 "Sort the group buffer by group level.
2947 If REVERSE, sort in reverse order."
2949 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2951 (defun gnus-group-sort-groups-by-score (&optional reverse)
2952 "Sort the group buffer by group score.
2953 If REVERSE, sort in reverse order."
2955 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2957 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2958 "Sort the group buffer by group rank.
2959 If REVERSE, sort in reverse order."
2961 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2963 (defun gnus-group-sort-groups-by-method (&optional reverse)
2964 "Sort the group buffer alphabetically by back end name.
2965 If REVERSE, sort in reverse order."
2967 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2969 (defun gnus-group-sort-groups-by-server (&optional reverse)
2970 "Sort the group buffer alphabetically by server name.
2971 If REVERSE, sort in reverse order."
2973 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2975 ;;; Selected group sorting.
2977 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2978 "Sort the process/prefixed groups."
2979 (interactive (list current-prefix-arg gnus-group-sort-function))
2980 (let ((groups (gnus-group-process-prefix n)))
2981 (funcall gnus-group-sort-selected-function
2982 groups (gnus-make-sort-function func) reverse)
2983 (gnus-group-unmark-all-groups)
2984 (gnus-group-list-groups)
2985 (gnus-dribble-touch)))
2987 (defun gnus-group-sort-selected-flat (groups func reverse)
2988 (let (entries infos)
2989 ;; First find all the group entries for these groups.
2991 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2993 ;; Then sort the infos.
2997 (lambda (entry) (car entry))
2998 (setq entries (nreverse entries)))
3001 (setq infos (nreverse infos)))
3002 ;; Go through all the infos and replace the old entries
3003 ;; with the new infos.
3005 (setcar (car entries) (pop infos))
3007 ;; Update the hashtable.
3008 (gnus-make-hashtable-from-newsrc-alist)))
3010 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3011 "Sort the group buffer alphabetically by group name.
3012 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3013 sort in reverse order."
3014 (interactive (gnus-interactive "P\ny"))
3015 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3017 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3018 "Sort the group buffer alphabetically by real group name.
3019 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3020 sort in reverse order."
3021 (interactive (gnus-interactive "P\ny"))
3022 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3024 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3025 "Sort the group buffer by number of unread articles.
3026 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3027 sort in reverse order."
3028 (interactive (gnus-interactive "P\ny"))
3029 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3031 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3032 "Sort the group buffer by group level.
3033 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3034 sort in reverse order."
3035 (interactive (gnus-interactive "P\ny"))
3036 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3038 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3039 "Sort the group buffer by group score.
3040 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3041 sort in reverse order."
3042 (interactive (gnus-interactive "P\ny"))
3043 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3045 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3046 "Sort the group buffer by group rank.
3047 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3048 sort in reverse order."
3049 (interactive (gnus-interactive "P\ny"))
3050 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3052 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3053 "Sort the group buffer alphabetically by back end name.
3054 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3055 sort in reverse order."
3056 (interactive (gnus-interactive "P\ny"))
3057 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3059 ;;; Sorting predicates.
3061 (defun gnus-group-sort-by-alphabet (info1 info2)
3062 "Sort alphabetically."
3063 (string< (gnus-info-group info1) (gnus-info-group info2)))
3065 (defun gnus-group-sort-by-real-name (info1 info2)
3066 "Sort alphabetically on real (unprefixed) names."
3067 (string< (gnus-group-real-name (gnus-info-group info1))
3068 (gnus-group-real-name (gnus-info-group info2))))
3070 (defun gnus-group-sort-by-unread (info1 info2)
3071 "Sort by number of unread articles."
3072 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3073 (n2 (gnus-group-unread (gnus-info-group info1))))
3074 (< (or (and (numberp n1) n1) 0)
3075 (or (and (numberp n2) n2) 0))))
3077 (defun gnus-group-sort-by-level (info1 info2)
3079 (< (gnus-info-level info1) (gnus-info-level info2)))
3081 (defun gnus-group-sort-by-method (info1 info2)
3082 "Sort alphabetically by back end name."
3083 (string< (car (gnus-find-method-for-group
3084 (gnus-info-group info1) info1))
3085 (car (gnus-find-method-for-group
3086 (gnus-info-group info2) info2))))
3088 (defun gnus-group-sort-by-server (info1 info2)
3089 "Sort alphabetically by server name."
3090 (string< (gnus-method-to-full-server-name
3091 (gnus-find-method-for-group
3092 (gnus-info-group info1) info1))
3093 (gnus-method-to-full-server-name
3094 (gnus-find-method-for-group
3095 (gnus-info-group info2) info2))))
3097 (defun gnus-group-sort-by-score (info1 info2)
3098 "Sort by group score."
3099 (> (gnus-info-score info1) (gnus-info-score info2)))
3101 (defun gnus-group-sort-by-rank (info1 info2)
3102 "Sort by level and score."
3103 (let ((level1 (gnus-info-level info1))
3104 (level2 (gnus-info-level info2)))
3105 (or (< level1 level2)
3106 (and (= level1 level2)
3107 (> (gnus-info-score info1) (gnus-info-score info2))))))
3111 (defun gnus-group-clear-data (&optional arg)
3112 "Clear all marks and read ranges from the current group."
3114 (gnus-group-iterate arg
3117 (gnus-info-clear-data (setq info (gnus-get-info group)))
3118 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3119 (when (gnus-group-goto-group group)
3120 (gnus-group-update-group-line))))))
3122 (defun gnus-group-clear-data-on-native-groups ()
3123 "Clear all marks and read ranges from all native groups."
3125 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3126 (let ((alist (cdr gnus-newsrc-alist))
3128 (while (setq info (pop alist))
3129 (when (gnus-group-native-p (gnus-info-group info))
3130 (gnus-info-clear-data info)))
3131 (gnus-get-unread-articles)
3132 (gnus-dribble-touch)
3133 (when (gnus-y-or-n-p
3134 "Move the cache away to avoid problems in the future? ")
3135 (call-interactively 'gnus-cache-move-cache)))))
3137 (defun gnus-info-clear-data (info)
3138 "Clear all marks and read ranges from INFO."
3139 (let ((group (gnus-info-group info))
3141 (dolist (el (gnus-info-marks info))
3142 (push `(,(cdr el) add (,(car el))) action))
3143 (push `(,(gnus-info-read info) add (read)) action)
3146 (gnus-request-set-mark ,group ',action)
3147 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3148 (gnus-info-set-read ',info ',(gnus-info-read info))
3149 (when (gnus-group-goto-group ,group)
3150 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3151 (gnus-group-update-group-line))))
3152 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3154 (gnus-request-set-mark group action)
3155 (gnus-info-set-read info nil)
3156 (when (gnus-info-marks info)
3157 (gnus-info-set-marks info nil))))
3159 ;; Group catching up.
3161 (defun gnus-group-catchup-current (&optional n all)
3162 "Mark all unread articles in the current newsgroup as read.
3163 If prefix argument N is numeric, the next N newsgroups will be
3164 caught up. If ALL is non-nil, marked articles will also be marked as
3165 read. Cross references (Xref: header) of articles are ignored.
3166 The number of newsgroups that this function was unable to catch
3169 (let ((groups (gnus-group-process-prefix n))
3172 (unless groups (error "No groups selected"))
3174 (or (not gnus-interactive-catchup) ;Without confirmation?
3179 "Do you really want to mark all articles in %s as read? "
3180 "Mark all unread articles in %s as read? ")
3181 (if (= (length groups) 1)
3183 (format "these %d groups" (length groups)))))))
3185 (while (setq group (pop groups))
3186 (gnus-group-remove-mark group)
3187 ;; Virtual groups have to be given special treatment.
3188 (let ((method (gnus-find-method-for-group group)))
3189 (when (eq 'nnvirtual (car method))
3190 (nnvirtual-catchup-group
3191 (gnus-group-real-name group) (nth 1 method) all)))
3192 (if (>= (gnus-group-level group) gnus-level-zombie)
3193 (gnus-message 2 "Dead groups can't be caught up")
3195 (gnus-group-goto-group group)
3196 (gnus-group-catchup group all))
3197 (gnus-group-update-group-line)
3198 (setq ret (1+ ret)))))
3199 (gnus-group-next-unread-group 1)
3202 (defun gnus-group-catchup-current-all (&optional n)
3203 "Mark all articles in current newsgroup as read.
3204 Cross references (Xref: header) of articles are ignored."
3206 (gnus-group-catchup-current n 'all))
3208 (defun gnus-group-catchup (group &optional all)
3209 "Mark all articles in GROUP as read.
3210 If ALL is non-nil, all articles are marked as read.
3211 The return value is the number of articles that were marked as read,
3212 or nil if no action could be taken."
3213 (let* ((entry (gnus-group-entry group))
3215 (marks (gnus-info-marks (nth 2 entry)))
3216 (unread (gnus-sequence-of-unread-articles group)))
3217 ;; Remove entries for this group.
3218 (nnmail-purge-split-history (gnus-group-real-name group))
3219 ;; Do the updating only if the newsgroup isn't killed.
3220 (if (not (numberp (car entry)))
3221 (gnus-message 1 "Can't catch up %s; non-active group" group)
3222 (gnus-update-read-articles group nil)
3224 ;; Nix out the lists of marks and dormants.
3225 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3227 (list (cdr (assq 'dormant marks))
3229 (setq unread (gnus-range-add (gnus-range-add
3230 unread (cdr (assq 'dormant marks)))
3231 (cdr (assq 'tick marks))))
3232 (gnus-add-marked-articles group 'tick nil nil 'force)
3233 (gnus-add-marked-articles group 'dormant nil nil 'force))
3234 ;; Do auto-expirable marks if that's required.
3235 (when (gnus-group-auto-expirable-p group)
3236 (gnus-range-map (lambda (article)
3237 (gnus-add-marked-articles group 'expire (list article))
3238 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3240 (let ((gnus-newsgroup-name group))
3241 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3244 (defun gnus-group-expire-articles (&optional n)
3245 "Expire all expirable articles in the current newsgroup.
3246 Uses the process/prefix convention."
3248 (let ((groups (gnus-group-process-prefix n))
3251 (error "No groups to expire"))
3252 (while (setq group (pop groups))
3253 (gnus-group-remove-mark group)
3254 (gnus-group-expire-articles-1 group)
3255 (gnus-dribble-touch)
3256 (gnus-group-position-point))))
3258 (defun gnus-group-expire-articles-1 (group)
3259 (when (gnus-check-backend-function 'request-expire-articles group)
3260 (gnus-message 6 "Expiring articles in %s..." group)
3261 (let* ((info (gnus-get-info group))
3262 (expirable (if (gnus-group-total-expirable-p group)
3263 (cons nil (gnus-list-of-read-articles group))
3264 (assq 'expire (gnus-info-marks info))))
3265 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3266 (nnmail-expiry-target
3267 (or (gnus-group-find-parameter group 'expiry-target)
3268 nnmail-expiry-target)))
3270 (gnus-check-group group)
3273 (gnus-compress-sequence
3275 ;; We set the expiry variables to the group
3277 (let ((nnmail-expiry-wait-function nil)
3278 (nnmail-expiry-wait expiry-wait))
3279 (gnus-request-expire-articles
3280 (gnus-uncompress-sequence (cdr expirable)) group))
3281 ;; Just expire using the normal expiry values.
3282 (gnus-request-expire-articles
3283 (gnus-uncompress-sequence (cdr expirable)) group))))
3284 (gnus-close-group group))
3285 (gnus-message 6 "Expiring articles in %s...done" group)
3286 ;; Return the list of un-expired articles.
3289 (defun gnus-group-expire-all-groups ()
3290 "Expire all expirable articles in all newsgroups."
3293 (gnus-message 5 "Expiring...")
3294 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3295 (cdr gnus-newsrc-alist))))
3296 (gnus-group-expire-articles nil)))
3297 (gnus-group-position-point)
3298 (gnus-message 5 "Expiring...done"))
3300 (defun gnus-group-set-current-level (n level)
3301 "Set the level of the next N groups to LEVEL."
3306 (unless (gnus-group-process-prefix current-prefix-arg)
3307 (error "No group on the current line"))
3309 (let ((s (read-string
3310 (format "Level (default %s): "
3311 (or (gnus-group-group-level)
3312 gnus-level-default-subscribed)))))
3313 (if (string-match "^\\s-*$" s)
3314 (int-to-string (or (gnus-group-group-level)
3315 gnus-level-default-subscribed))
3317 (unless (and (>= level 1) (<= level gnus-level-killed))
3318 (error "Invalid level: %d" level))
3319 (let ((groups (gnus-group-process-prefix n))
3321 (while (setq group (pop groups))
3322 (gnus-group-remove-mark group)
3323 (gnus-message 6 "Changed level of %s from %d to %d"
3324 group (or (gnus-group-group-level) gnus-level-killed)
3326 (gnus-group-change-level
3327 group level (or (gnus-group-group-level) gnus-level-killed))
3328 (gnus-group-update-group-line)))
3329 (gnus-group-position-point))
3331 (defun gnus-group-unsubscribe (&optional n)
3332 "Unsubscribe the current group."
3334 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3336 (defun gnus-group-subscribe (&optional n)
3337 "Subscribe the current group."
3339 (gnus-group-unsubscribe-current-group n 'subscribe))
3341 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3342 "Toggle subscription of the current group.
3343 If given numerical prefix, toggle the N next groups."
3345 (dolist (group (gnus-group-process-prefix n))
3346 (gnus-group-remove-mark group)
3347 (gnus-group-unsubscribe-group
3350 ((eq do-sub 'unsubscribe)
3351 gnus-level-default-unsubscribed)
3352 ((eq do-sub 'subscribe)
3353 gnus-level-default-subscribed)
3354 ((<= (gnus-group-group-level) gnus-level-subscribed)
3355 gnus-level-default-unsubscribed)
3357 gnus-level-default-subscribed))
3359 (gnus-group-update-group-line))
3360 (gnus-group-next-group 1))
3362 (defun gnus-group-unsubscribe-group (group &optional level silent)
3363 "Toggle subscription to GROUP.
3364 Killed newsgroups are subscribed. If SILENT, don't try to update the
3367 (list (gnus-group-completing-read-group-name
3368 "Group: " gnus-active-hashtb nil
3369 (gnus-read-active-file-p)
3371 'gnus-group-history)))
3372 (let ((newsrc (gnus-group-entry group)))
3374 ((string-match "^[ \t]*$" group)
3375 (error "Empty group name"))
3377 ;; Toggle subscription flag.
3378 (gnus-group-change-level
3379 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3380 gnus-level-subscribed)
3381 (1+ gnus-level-subscribed)
3382 gnus-level-default-subscribed)))
3384 (gnus-group-update-group group)))
3385 ((and (stringp group)
3386 (or (not (gnus-read-active-file-p))
3387 (gnus-active group)))
3388 ;; Add new newsgroup.
3389 (gnus-group-change-level
3391 (if level level gnus-level-default-subscribed)
3392 (or (and (member group gnus-zombie-list)
3395 (when (gnus-group-group-name)
3396 (gnus-group-entry (gnus-group-group-name))))
3398 (gnus-group-update-group group)))
3399 (t (error "No such newsgroup: %s" group)))
3400 (gnus-group-position-point)))
3402 (defun gnus-group-transpose-groups (n)
3403 "Move the current newsgroup up N places.
3404 If given a negative prefix, move down instead. The difference between
3405 N and the number of steps taken is returned."
3407 (unless (gnus-group-group-name)
3408 (error "No group on current line"))
3409 (gnus-group-kill-group 1)
3411 (forward-line (- n))
3412 (gnus-group-yank-group)
3413 (gnus-group-position-point)))
3415 (defun gnus-group-kill-all-zombies (&optional dummy)
3416 "Kill all zombie newsgroups.
3417 The optional DUMMY should always be nil."
3418 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3420 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3421 (setq gnus-zombie-list nil)
3422 (gnus-dribble-touch)
3423 (gnus-group-list-groups)))
3425 (defun gnus-group-kill-region (begin end)
3426 "Kill newsgroups in current region (excluding current point).
3427 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3440 (beginning-of-line) ;Important when LINES < 1
3441 (gnus-group-kill-group lines)))
3443 (defun gnus-group-kill-group (&optional n discard)
3444 "Kill the next N groups.
3445 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3446 However, only groups that were alive can be yanked; already killed
3447 groups or zombie groups can't be yanked.
3448 The return value is the name of the group that was killed, or a list
3451 (let ((buffer-read-only nil)
3452 (groups (gnus-group-process-prefix n))
3453 group entry level out)
3454 (if (< (length groups) 10)
3455 ;; This is faster when there are few groups.
3457 (push (setq group (pop groups)) out)
3458 (gnus-group-remove-mark group)
3459 (setq level (gnus-group-group-level))
3461 (when (and (not discard)
3462 (setq entry (gnus-group-entry group)))
3465 (gnus-group-goto-group ,(gnus-group-group-name))
3466 (gnus-group-yank-group)))
3467 (push (cons (car entry) (nth 2 entry))
3468 gnus-list-of-killed-groups))
3469 (gnus-group-change-level
3470 (if entry entry group) gnus-level-killed (if entry nil level))
3471 (message "Killed group %s" group))
3472 ;; If there are lots and lots of groups to be killed, we use
3473 ;; this thing instead.
3474 (dolist (group (nreverse groups))
3475 (gnus-group-remove-mark group)
3477 (push group gnus-killed-list)
3478 (setq gnus-newsrc-alist
3479 (delq (assoc group gnus-newsrc-alist)
3481 (when gnus-group-change-level-function
3482 (funcall gnus-group-change-level-function
3483 group gnus-level-killed 3))
3485 ((setq entry (gnus-group-entry group))
3486 (push (cons (car entry) (nth 2 entry))
3487 gnus-list-of-killed-groups)
3488 (setcdr (cdr entry) (cdddr entry)))
3489 ((member group gnus-zombie-list)
3490 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3491 ;; There may be more than one instance displayed.
3492 (while (gnus-group-goto-group group)
3493 (gnus-delete-line)))
3494 (gnus-make-hashtable-from-newsrc-alist))
3496 (gnus-group-position-point)
3497 (if (< (length out) 2) (car out) (nreverse out))))
3499 (defun gnus-group-yank-group (&optional arg)
3500 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3501 The numeric ARG specifies how many newsgroups are to be yanked. The
3502 name of the newsgroup yanked is returned, or (if several groups are
3503 yanked) a list of yanked groups is returned."
3505 (setq arg (or arg 1))
3506 (let (info group prev out)
3507 (while (>= (decf arg) 0)
3508 (when (not (setq info (pop gnus-list-of-killed-groups)))
3509 (error "No more newsgroups to yank"))
3510 (push (setq group (nth 1 info)) out)
3511 ;; Find which newsgroup to insert this one before - search
3512 ;; backward until something suitable is found. If there are no
3513 ;; other newsgroups in this buffer, just make this newsgroup the
3515 (setq prev (gnus-group-group-name))
3516 (gnus-group-change-level
3517 info (gnus-info-level (cdr info)) gnus-level-killed
3518 (and prev (gnus-group-entry prev))
3520 (gnus-group-insert-group-line-info group)
3522 `(when (gnus-group-goto-group ,group)
3523 (gnus-group-kill-group 1))))
3525 (gnus-group-position-point)
3526 (if (< (length out) 2) (car out) (nreverse out))))
3528 (defun gnus-group-kill-level (level)
3529 "Kill all groups that is on a certain LEVEL."
3530 (interactive "nKill all groups on level: ")
3532 ((= level gnus-level-zombie)
3533 (setq gnus-killed-list
3534 (nconc gnus-zombie-list gnus-killed-list))
3535 (setq gnus-zombie-list nil))
3536 ((and (< level gnus-level-zombie)
3538 (or gnus-expert-user
3541 "Do you really want to kill all groups on level %d? "
3543 (let* ((prev gnus-newsrc-alist)
3546 (if (= (gnus-info-level (car alist)) level)
3548 (push (gnus-info-group (car alist)) gnus-killed-list)
3549 (setcdr prev (cdr alist)))
3551 (setq alist (cdr alist)))
3552 (gnus-make-hashtable-from-newsrc-alist)
3553 (gnus-group-list-groups)))
3555 (error "Can't kill; invalid level: %d" level))))
3557 (defun gnus-group-list-all-groups (&optional arg)
3558 "List all newsgroups with level ARG or lower.
3559 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3560 unsubscribed groups."
3562 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3564 ;; Redefine this to list ALL killed groups if prefix arg used.
3565 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3566 (defun gnus-group-list-killed (&optional arg)
3567 "List all killed newsgroups in the group buffer.
3568 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3569 entail asking the server for the groups."
3571 ;; Find all possible killed newsgroups if arg.
3573 (gnus-get-killed-groups))
3574 (if (not gnus-killed-list)
3575 (gnus-message 6 "No killed groups")
3576 (let (gnus-group-list-mode)
3577 (funcall gnus-group-prepare-function
3578 gnus-level-killed t gnus-level-killed))
3579 (goto-char (point-min)))
3580 (gnus-group-position-point))
3582 (defun gnus-group-list-zombies ()
3583 "List all zombie newsgroups in the group buffer."
3585 (if (not gnus-zombie-list)
3586 (gnus-message 6 "No zombie groups")
3587 (let (gnus-group-list-mode)
3588 (funcall gnus-group-prepare-function
3589 gnus-level-zombie t gnus-level-zombie))
3590 (goto-char (point-min)))
3591 (gnus-group-position-point))
3593 (defun gnus-group-list-active ()
3594 "List all groups that are available from the server(s)."
3596 ;; First we make sure that we have really read the active file.
3597 (unless (gnus-read-active-file-p)
3598 (let ((gnus-read-active-file t)
3599 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3600 (gnus-read-active-file)))
3601 ;; Find all groups and sort them.
3609 (push (symbol-name sym) list)))
3613 (buffer-read-only nil)
3617 (setq group (pop groups))
3618 (gnus-add-text-properties
3619 (point) (prog1 (1+ (point))
3621 (gnus-group-decoded-name group)
3623 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3625 'gnus-level (inline (gnus-group-level group)))))
3626 (goto-char (point-min))))
3628 (defun gnus-activate-all-groups (level)
3629 "Activate absolutely all groups."
3630 (interactive (list gnus-level-unsubscribed))
3631 (let ((gnus-activate-level level)
3632 (gnus-activate-foreign-newsgroups level))
3633 (gnus-group-get-new-news)))
3635 (defun gnus-group-get-new-news (&optional arg)
3636 "Get newly arrived articles.
3637 If ARG is a number, it specifies which levels you are interested in
3638 re-scanning. If ARG is non-nil and not a number, this will force
3639 \"hard\" re-reading of the active files from all servers."
3642 (let ((gnus-inhibit-demon t)
3643 ;; Binding this variable will inhibit multiple fetchings
3644 ;; of the same mail source.
3645 (nnmail-fetched-sources (list t)))
3646 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3647 (gnus-run-hooks 'gnus-get-new-news-hook)
3649 ;; Read any slave files.
3651 (gnus-master-read-slave-newsrc))
3653 ;; We might read in new NoCeM messages here.
3654 (when (and gnus-use-nocem
3656 (gnus-nocem-scan-groups))
3657 ;; If ARG is not a number, then we read the active file.
3658 (when (and arg (not (numberp arg)))
3659 (let ((gnus-read-active-file t))
3660 (gnus-read-active-file))
3663 ;; If the user wants it, we scan for new groups.
3664 (when (eq gnus-check-new-newsgroups 'always)
3665 (gnus-find-new-newsgroups)))
3667 (setq arg (gnus-group-default-level arg t))
3668 (if (and gnus-read-active-file (not arg))
3670 (gnus-read-active-file)
3671 (gnus-get-unread-articles arg))
3672 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3673 (gnus-get-unread-articles arg)))
3674 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3675 (gnus-group-list-groups (and (numberp arg)
3676 (max (car gnus-group-list-mode) arg))))
3678 (when (and gnus-agent (not (interactive-p)))
3679 (gnus-agent-toggle-plugged gnus-plugged)))
3681 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3682 "Check for newly arrived news in the current group (and the N-1 next groups).
3683 The difference between N and the number of newsgroup checked is returned.
3684 If N is negative, this group and the N-1 previous groups will be checked.
3685 If DONT-SCAN is non-nil, scan non-activated groups as well."
3687 (let* ((groups (gnus-group-process-prefix n))
3688 (ret (if (numberp n) (- n (length groups)) 0))
3692 (gnus-inhibit-demon t)
3693 ;; Binding this variable will inhibit multiple fetchings
3694 ;; of the same mail source.
3695 (nnmail-fetched-sources (list t)))
3696 (gnus-run-hooks 'gnus-get-new-news-hook)
3697 (while (setq group (pop groups))
3698 (gnus-group-remove-mark group)
3699 ;; Bypass any previous denials from the server.
3700 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3701 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3702 (let ((info (gnus-get-info group))
3703 (active (gnus-active group)))
3705 (gnus-request-update-info info method))
3706 (gnus-get-unread-articles-in-group info active)
3707 (unless (gnus-virtual-group-p group)
3708 (gnus-close-group group))
3710 (gnus-agent-save-group-info
3711 method (gnus-group-real-name group) active))
3712 (gnus-group-update-group group))
3713 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3715 (gnus-error 3 "Server denied access")
3716 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3719 (when gnus-goto-next-group-when-activating
3720 (gnus-group-next-unread-group 1 t))
3721 (gnus-summary-position-point)
3724 (defun gnus-group-fetch-faq (group &optional faq-dir)
3725 "Fetch the FAQ for the current group.
3726 If given a prefix argument, prompt for the FAQ dir
3730 (gnus-group-group-name)
3731 (when current-prefix-arg
3733 "FAQ dir: " (and (listp gnus-group-faq-directory)
3735 gnus-group-faq-directory))))))
3737 (error "No group name given"))
3738 (let ((dirs (or faq-dir gnus-group-faq-directory))
3740 (unless (listp dirs)
3741 (setq dirs (list dirs)))
3742 (while (and (not found)
3743 (setq dir (pop dirs)))
3744 (let ((name (gnus-group-real-name group)))
3745 (setq file (expand-file-name name dir)))
3746 (if (not (file-exists-p file))
3747 (gnus-message 1 "No such file: %s" file)
3748 (let ((enable-local-variables nil))
3752 (defun gnus-group-fetch-charter (group)
3753 "Fetch the charter for the current group.
3754 If given a prefix argument, prompt for a group."
3756 (list (or (when current-prefix-arg
3757 (completing-read "Group: " gnus-active-hashtb))
3758 (gnus-group-group-name)
3759 gnus-newsgroup-name)))
3761 (error "No group name given"))
3763 (condition-case nil (require 'url-http) (error nil))
3764 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3766 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3767 (setq hierarchy (match-string 1 name))
3768 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3769 (if (fboundp 'url-http-file-exists-p)
3770 (url-http-file-exists-p (eval url))
3772 (browse-url (eval url))
3773 (setq url (concat "http://" hierarchy
3774 ".news-admin.org/charters/" name))
3775 (if (and (fboundp 'url-http-file-exists-p)
3776 (url-http-file-exists-p url))
3778 (gnus-group-fetch-control group))))))
3780 (defun gnus-group-fetch-control (group)
3781 "Fetch the archived control messages for the current group.
3782 If given a prefix argument, prompt for a group."
3784 (list (or (when current-prefix-arg
3785 (completing-read "Group: " gnus-active-hashtb))
3786 (gnus-group-group-name)
3787 gnus-newsgroup-name)))
3789 (error "No group name given"))
3790 (let ((name (gnus-group-real-name group))
3792 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3793 (setq hierarchy (match-string 1 name))
3794 (if gnus-group-fetch-control-use-browse-url
3795 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3796 hierarchy "/" name ".gz"))
3797 (let ((enable-local-variables nil))
3798 (gnus-group-read-ephemeral-group
3800 `(nndoc ,group (nndoc-address
3801 ,(find-file-noselect
3802 (concat "/ftp@ftp.isc.org:/usenet/control/"
3803 hierarchy "/" name ".gz")))
3804 (nndoc-article-type mbox)) t nil nil))))))
3806 (defun gnus-group-describe-group (force &optional group)
3807 "Display a description of the current newsgroup."
3808 (interactive (list current-prefix-arg (gnus-group-group-name)))
3809 (let* ((method (gnus-find-method-for-group group))
3810 (mname (gnus-group-prefixed-name "" method))
3813 gnus-description-hashtb)
3814 (gnus-sethash mname nil gnus-description-hashtb))
3816 (error "No group name given"))
3817 (when (or (and gnus-description-hashtb
3818 ;; We check whether this group's method has been
3819 ;; queried for a description file.
3820 (gnus-gethash mname gnus-description-hashtb))
3821 (setq desc (gnus-group-get-description group))
3822 (gnus-read-descriptions-file method))
3824 (or desc (gnus-gethash group gnus-description-hashtb)
3825 "No description available")))))
3827 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3828 (defun gnus-group-describe-all-groups (&optional force)
3829 "Pop up a buffer with descriptions of all newsgroups."
3832 (setq gnus-description-hashtb nil))
3833 (when (not (or gnus-description-hashtb
3834 (gnus-read-all-descriptions-files)))
3835 (error "Couldn't request descriptions file"))
3836 (let ((buffer-read-only nil)
3842 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3843 (insert (format " *: %-20s %s\n"
3844 (gnus-group-name-decode
3845 (symbol-name group) charset)
3846 (gnus-group-name-decode
3847 (symbol-value group) charset))))
3848 (gnus-add-text-properties
3849 b (1+ b) (list 'gnus-group group
3850 'gnus-unread t 'gnus-marked nil
3851 'gnus-level (1+ gnus-level-subscribed))))
3852 gnus-description-hashtb)
3853 (goto-char (point-min))
3854 (gnus-group-position-point)))
3856 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3857 (defun gnus-group-apropos (regexp &optional search-description)
3858 "List all newsgroups that have names that match a regexp."
3859 (interactive "sGnus apropos (regexp): ")
3861 (obuf (current-buffer))
3863 ;; Go through all newsgroups that are known to Gnus.
3866 (and (symbol-name group)
3867 (string-match regexp (symbol-name group))
3868 (symbol-value group)
3869 (push (symbol-name group) groups)))
3871 ;; Also go through all descriptions that are known to Gnus.
3872 (when search-description
3875 (and (string-match regexp (symbol-value group))
3876 (push (symbol-name group) groups)))
3877 gnus-description-hashtb))
3879 (gnus-message 3 "No groups matched \"%s\"." regexp)
3880 ;; Print out all the groups.
3882 (pop-to-buffer "*Gnus Help*")
3883 (buffer-disable-undo)
3885 (setq groups (sort groups 'string<))
3887 ;; Groups may be entered twice into the list of groups.
3888 (when (not (string= (car groups) prev))
3889 (setq prev (car groups))
3890 (let ((charset (gnus-group-name-charset nil prev)))
3891 (insert (gnus-group-name-decode prev charset) "\n")
3892 (when (and gnus-description-hashtb
3893 (setq des (gnus-gethash (car groups)
3894 gnus-description-hashtb)))
3895 (insert " " (gnus-group-name-decode des charset) "\n"))))
3896 (setq groups (cdr groups)))
3897 (goto-char (point-min))))
3898 (pop-to-buffer obuf)))
3900 (defun gnus-group-description-apropos (regexp)
3901 "List all newsgroups that have names or descriptions that match REGEXP."
3902 (interactive "sGnus description apropos (regexp): ")
3903 (when (not (or gnus-description-hashtb
3904 (gnus-read-all-descriptions-files)))
3905 (error "Couldn't request descriptions file"))
3906 (gnus-group-apropos regexp t))
3908 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3909 (defun gnus-group-list-matching (level regexp &optional all lowest)
3910 "List all groups with unread articles that match REGEXP.
3911 If the prefix LEVEL is non-nil, it should be a number that says which
3912 level to cut off listing groups.
3913 If ALL, also list groups with no unread articles.
3914 If LOWEST, don't list groups with level lower than LOWEST.
3916 This command may read the active file."
3917 (interactive "P\nsList newsgroups matching: ")
3918 ;; First make sure active file has been read.
3920 (> (prefix-numeric-value level) gnus-level-killed))
3921 (gnus-get-killed-groups))
3922 (funcall gnus-group-prepare-function
3923 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3924 (goto-char (point-min))
3925 (gnus-group-position-point))
3927 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3928 "List all groups that match REGEXP.
3929 If the prefix LEVEL is non-nil, it should be a number that says which
3930 level to cut off listing groups.
3931 If LOWEST, don't list groups with level lower than LOWEST."
3932 (interactive "P\nsList newsgroups matching: ")
3934 (setq level (prefix-numeric-value level)))
3935 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3937 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3938 (defun gnus-group-save-newsrc (&optional force)
3939 "Save the Gnus startup files.
3940 If FORCE, force saving whether it is necessary or not."
3942 (gnus-save-newsrc-file force))
3944 (defun gnus-group-restart (&optional arg)
3945 "Force Gnus to read the .newsrc file."
3947 (when (gnus-yes-or-no-p
3948 (format "Are you sure you want to restart Gnus? "))
3949 (gnus-save-newsrc-file)
3953 (defun gnus-group-read-init-file ()
3954 "Read the Gnus elisp init file."
3956 (gnus-read-init-file)
3957 (gnus-message 5 "Read %s" gnus-init-file))
3959 (defun gnus-group-check-bogus-groups (&optional silent)
3960 "Check bogus newsgroups.
3961 If given a prefix, don't ask for confirmation before removing a bogus
3964 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3965 (gnus-group-list-groups))
3967 (defun gnus-group-find-new-groups (&optional arg)
3968 "Search for new groups and add them.
3969 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3970 With 1 C-u, use the `ask-server' method to query the server for new
3972 With 2 C-u's, use most complete method possible to query the server
3973 for new groups, and subscribe the new groups as zombies."
3975 (gnus-find-new-newsgroups (or arg 1))
3976 (gnus-group-list-groups))
3978 (defun gnus-group-edit-global-kill (&optional article group)
3979 "Edit the global kill file.
3980 If GROUP, edit that local kill file instead."
3982 (setq gnus-current-kill-article article)
3983 (gnus-kill-file-edit-file group)
3986 (substitute-command-keys
3987 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3988 (if group "local" "global")))))
3990 (defun gnus-group-edit-local-kill (article group)
3991 "Edit a local kill file."
3992 (interactive (list nil (gnus-group-group-name)))
3993 (gnus-group-edit-global-kill article group))
3995 (defun gnus-group-force-update ()
3996 "Update `.newsrc' file."
3998 (gnus-save-newsrc-file))
4000 (defvar gnus-backlog-articles)
4002 (defun gnus-group-suspend ()
4003 "Suspend the current Gnus session.
4004 In fact, cleanup buffers except for group mode buffer.
4005 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4007 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4008 (gnus-offer-save-summaries)
4009 ;; Kill Gnus buffers except for group mode buffer.
4010 (let ((group-buf (get-buffer gnus-group-buffer)))
4011 (mapcar (lambda (buf)
4012 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4013 (with-current-buffer buf
4014 (eq major-mode 'message-mode)))
4015 (gnus-kill-buffer buf)))
4017 (setq gnus-backlog-articles nil)
4018 (gnus-kill-gnus-frames)
4020 (bury-buffer group-buf)
4021 (delete-windows-on group-buf t))))
4023 (defun gnus-group-clear-dribble ()
4024 "Clear all information from the dribble buffer."
4026 (gnus-dribble-clear)
4027 (gnus-message 7 "Cleared dribble buffer"))
4029 (defun gnus-group-exit ()
4030 "Quit reading news after updating .newsrc.eld and .newsrc.
4031 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4034 (or noninteractive ;For gnus-batch-kill
4035 (not gnus-interactive-exit) ;Without confirmation
4037 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4038 (gnus-run-hooks 'gnus-exit-gnus-hook)
4039 ;; Offer to save data from non-quitted summary buffers.
4040 (gnus-offer-save-summaries)
4041 ;; Save the newsrc file(s).
4042 (gnus-save-newsrc-file)
4044 (gnus-close-backends)
4045 ;; Reset everything.
4047 ;; Allow the user to do things after cleaning up.
4048 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4050 (defun gnus-group-quit ()
4051 "Quit reading news without updating .newsrc.eld or .newsrc.
4052 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4054 (when (or noninteractive ;For gnus-batch-kill
4055 (zerop (buffer-size))
4056 (not (gnus-server-opened gnus-select-method))
4058 (not gnus-current-startup-file)
4060 (format "Quit reading news without saving %s? "
4061 (file-name-nondirectory gnus-current-startup-file))))
4062 (gnus-run-hooks 'gnus-exit-gnus-hook)
4063 (gnus-configure-windows 'group t)
4064 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4065 (not (zerop (save-excursion
4066 (set-buffer gnus-dribble-buffer)
4069 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4071 (gnus-close-backends)
4073 (gnus-kill-buffer gnus-group-buffer)
4074 ;; Allow the user to do things after cleaning up.
4075 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4077 (defun gnus-group-describe-briefly ()
4078 "Give a one line description of the group mode commands."
4080 (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")))
4082 (defun gnus-group-browse-foreign-server (method)
4083 "Browse a foreign news server.
4084 If called interactively, this function will ask for a select method
4085 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4086 If not, METHOD should be a list where the first element is the method
4087 and the second element is the address."
4089 (list (let ((how (completing-read
4091 (append gnus-valid-select-methods gnus-server-alist)
4092 nil t (cons "nntp" 0) 'gnus-method-history)))
4093 ;; We either got a back end name or a virtual server name.
4094 ;; If the first, we also need an address.
4095 (if (assoc how gnus-valid-select-methods)
4097 ;; Suggested by mapjph@bath.ac.uk.
4100 (mapcar 'list gnus-secondary-servers)))
4101 ;; We got a server name.
4103 (gnus-browse-foreign-server method))
4105 (defun gnus-group-set-info (info &optional method-only-group part)
4106 (when (or info part)
4107 (let* ((entry (gnus-group-entry
4108 (or method-only-group (gnus-info-group info))))
4110 (info (if method-only-group (nth 2 entry) info))
4112 (when method-only-group
4114 (error "Trying to change non-existent group %s" method-only-group))
4115 ;; We have received parts of the actual group info - either the
4116 ;; select method or the group parameters. We first check
4117 ;; whether we have to extend the info, and if so, do that.
4118 (let ((len (length info))
4119 (total (if (eq part 'method) 5 6)))
4121 (setcdr (nthcdr (1- len) info)
4122 (make-list (- total len) nil)))
4123 ;; Then we enter the new info.
4124 (setcar (nthcdr (1- total) info) part-info)))
4126 ;; This is a new group, so we just create it.
4128 (set-buffer gnus-group-buffer)
4129 (setq method (gnus-info-method info))
4130 (when (gnus-server-equal method "native")
4133 (set-buffer gnus-group-buffer)
4135 ;; It's a foreign group...
4136 (gnus-group-make-group
4137 (gnus-group-real-name (gnus-info-group info))
4138 (if (stringp method) method
4139 (prin1-to-string (car method)))
4141 (nth 1 (gnus-info-method info))))
4142 ;; It's a native group.
4143 (gnus-group-make-group (gnus-info-group info))))
4144 (gnus-message 6 "Note: New group created")
4146 (gnus-group-entry (gnus-group-prefixed-name
4147 (gnus-group-real-name (gnus-info-group info))
4148 (or (gnus-info-method info) gnus-select-method))))))
4149 ;; Whether it was a new group or not, we now have the entry, so we
4150 ;; can do the update.
4153 (setcar (nthcdr 2 entry) info)
4154 (when (and (not (eq (car entry) t))
4155 (gnus-active (gnus-info-group info)))
4156 (setcar entry (length
4157 (gnus-list-of-unread-articles (car info))))))
4158 (error "No such group: %s" (gnus-info-group info))))))
4160 (defun gnus-group-set-method-info (group select-method)
4161 (gnus-group-set-info select-method group 'method))
4163 (defun gnus-group-set-params-info (group params)
4164 (gnus-group-set-info params group 'params))
4166 (defun gnus-add-marked-articles (group type articles &optional info force)
4167 ;; Add ARTICLES of TYPE to the info of GROUP.
4168 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4169 ;; add, but replace marked articles of TYPE with ARTICLES.
4170 (let ((info (or info (gnus-get-info group)))
4173 (and (not (setq marked (nthcdr 3 info)))
4175 (setcdr (nthcdr 2 info)
4176 (list (list (cons type (gnus-compress-sequence
4178 (and (not (setq m (assq type (car marked))))
4181 (cons (cons type (gnus-compress-sequence articles t) )
4185 (setcar (nthcdr 3 info)
4186 (gnus-delete-alist type (car marked)))
4187 (setcdr m (gnus-compress-sequence articles t)))
4188 (setcdr m (gnus-compress-sequence
4189 (sort (nconc (gnus-uncompress-range (cdr m))
4190 (copy-sequence articles)) '<) t))))))
4192 (defun gnus-add-mark (group mark article)
4193 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4194 (let ((buffer (gnus-summary-buffer-name group)))
4195 (if (gnus-buffer-live-p buffer)
4197 (set-buffer (get-buffer buffer))
4198 (gnus-summary-add-mark article mark))
4199 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4203 ;;; Group timestamps
4206 (defun gnus-group-set-timestamp ()
4207 "Change the timestamp of the current group to the current time.
4208 This function can be used in hooks like `gnus-select-group-hook'
4209 or `gnus-group-catchup-group-hook'."
4210 (when gnus-newsgroup-name
4211 (let ((time (current-time)))
4212 (setcdr (cdr time) nil)
4213 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4215 (defsubst gnus-group-timestamp (group)
4216 "Return the timestamp for GROUP."
4217 (gnus-group-get-parameter group 'timestamp t))
4219 (defun gnus-group-timestamp-delta (group)
4220 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4221 (let* ((time (or (gnus-group-timestamp group)
4223 (delta (subtract-time (current-time) time)))
4224 (+ (* (nth 0 delta) 65536.0)
4227 (defun gnus-group-timestamp-string (group)
4228 "Return a string of the timestamp for GROUP."
4229 (let ((time (gnus-group-timestamp group)))
4232 (gnus-time-iso8601 time))))
4234 (defun gnus-group-list-cached (level &optional lowest)
4235 "List all groups with cached articles.
4236 If the prefix LEVEL is non-nil, it should be a number that says which
4237 level to cut off listing groups.
4238 If LOWEST, don't list groups with level lower than LOWEST.
4240 This command may read the active file."
4243 (setq level (prefix-numeric-value level)))
4244 (when (or (not level) (>= level gnus-level-zombie))
4246 (funcall gnus-group-prepare-function
4247 (or level gnus-level-subscribed)
4249 (let ((marks (gnus-info-marks info)))
4250 (assq 'cache marks)))
4253 (or (gnus-gethash group
4254 gnus-cache-active-hashtb)
4255 ;; Cache active file might use "."
4258 (mapconcat 'identity
4259 (split-string group ":")
4261 gnus-cache-active-hashtb))))
4262 (goto-char (point-min))
4263 (gnus-group-position-point))
4265 (defun gnus-group-list-dormant (level &optional lowest)
4266 "List all groups with dormant articles.
4267 If the prefix LEVEL is non-nil, it should be a number that says which
4268 level to cut off listing groups.
4269 If LOWEST, don't list groups with level lower than LOWEST.
4271 This command may read the active file."
4274 (setq level (prefix-numeric-value level)))
4275 (when (or (not level) (>= level gnus-level-zombie))
4277 (funcall gnus-group-prepare-function
4278 (or level gnus-level-subscribed)
4280 (let ((marks (gnus-info-marks info)))
4281 (assq 'dormant marks)))
4284 (goto-char (point-min))
4285 (gnus-group-position-point))
4287 (defun gnus-group-listed-groups ()
4288 "Return a list of listed groups."
4290 (goto-char (point-min))
4291 (while (setq point (text-property-not-all (point) (point-max)
4294 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4298 (defun gnus-group-list-plus (&optional args)
4299 "List groups plus the current selection."
4301 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4302 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4304 (push last-command-event unread-command-events)
4305 (if (featurep 'xemacs)
4306 (push (make-event 'key-press '(key ?A)) unread-command-events)
4307 (push ?A unread-command-events))
4308 (let (gnus-pick-mode keys)
4309 (setq keys (if (featurep 'xemacs)
4310 (events-to-keys (read-key-sequence nil))
4311 (read-key-sequence nil)))
4312 (setq func (lookup-key (current-local-map) keys)))
4316 (call-interactively func))))
4318 (defun gnus-group-list-flush (&optional args)
4319 "Flush groups from the current selection."
4321 (let ((gnus-group-list-option 'flush))
4322 (gnus-group-list-plus args)))
4324 (defun gnus-group-list-limit (&optional args)
4325 "List groups limited within the current selection."
4327 (let ((gnus-group-list-option 'limit))
4328 (gnus-group-list-plus args)))
4330 (defun gnus-group-mark-article-read (group article)
4331 "Mark ARTICLE read."
4332 (let ((buffer (gnus-summary-buffer-name group))
4333 (mark gnus-read-mark)
4335 (if (get-buffer buffer)
4336 (with-current-buffer buffer
4337 (setq active gnus-newsgroup-active)
4338 (gnus-activate-group group)
4339 (when gnus-newsgroup-prepared
4340 (when (and gnus-newsgroup-auto-expire
4341 (memq mark gnus-auto-expirable-marks))
4342 (setq mark gnus-expirable-mark))
4343 (setq mark (gnus-request-update-mark
4344 group article mark))
4345 (gnus-mark-article-as-read article mark)
4346 (setq gnus-newsgroup-active (gnus-active group))
4348 (setq n (1+ (cdr active)))
4349 (while (<= n (cdr gnus-newsgroup-active))
4350 (unless (eq n article)
4351 (push n gnus-newsgroup-unselected))
4353 (setq gnus-newsgroup-unselected
4354 (nreverse gnus-newsgroup-unselected)))))
4355 (gnus-activate-group group)
4356 (gnus-group-make-articles-read group (list article))
4357 (when (gnus-group-auto-expirable-p group)
4358 (gnus-add-marked-articles
4359 group 'expire (list article))))))
4361 (provide 'gnus-group)
4363 ;;; gnus-group.el ends here