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 %n Select from where (string)
185 %z A string that look like `<%s:%n>' if a foreign select method is used
186 %d The date the group was last entered.
187 %E Icon as defined by `gnus-group-icon-list'.
188 %F The disk space used by the articles fetched by both the cache and agent.
189 %u User defined specifier. The next character in the format string should
190 be a letter. Gnus will call the function gnus-user-format-function-X,
191 where X is the letter following %u. The function will be passed a
192 single dummy parameter as argument. The function should return a
193 string, which will be inserted into the buffer just like information
194 from any other group specifier.
196 Note that this format specification is not always respected. For
197 reasons of efficiency, when listing killed groups, this specification
198 is ignored altogether. If the spec is changed considerably, your
199 output may end up looking strange when listing both alive and killed
202 If you use %o or %O, reading the active file will be slower and quite
203 a bit of extra memory will be used. %D and %F will also worsen
204 performance. Also note that if you change the format specification to
205 include any of these specs, you must probably re-start Gnus to see
208 General format specifiers can also be used.
209 See Info node `(gnus)Formatting Variables'."
210 :link '(custom-manual "(gnus)Formatting Variables")
211 :group 'gnus-group-visual
214 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
215 "*The format specification for the group mode line.
216 It works along the same lines as a normal formatting string,
217 with some simple extensions:
219 %S The native news server.
220 %M The native select method.
221 %: \":\" if %S isn't \"\"."
222 :group 'gnus-group-visual
225 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
226 (when (featurep 'xemacs)
227 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
230 (defcustom gnus-group-menu-hook nil
231 "Hook run after the creation of the group mode menu."
232 :group 'gnus-group-various
235 (defcustom gnus-group-catchup-group-hook nil
236 "Hook run when catching up a group from the group buffer."
237 :group 'gnus-group-various
238 :link '(custom-manual "(gnus)Group Data")
241 (defcustom gnus-group-update-group-hook nil
242 "Hook called when updating group lines."
243 :group 'gnus-group-visual
246 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
247 "*A function that is called to generate the group buffer.
248 The function is called with three arguments: The first is a number;
249 all group with a level less or equal to that number should be listed,
250 if the second is non-nil, empty groups should also be displayed. If
251 the third is non-nil, it is a number. No groups with a level lower
252 than this number should be displayed.
254 The only current function implemented is `gnus-group-prepare-flat'."
255 :group 'gnus-group-listing
258 (defcustom gnus-group-prepare-hook nil
259 "Hook called after the group buffer has been generated.
260 If you want to modify the group buffer, you can use this hook."
261 :group 'gnus-group-listing
264 (defcustom gnus-suspend-gnus-hook nil
265 "Hook called when suspending (not exiting) Gnus."
269 (defcustom gnus-exit-gnus-hook nil
270 "Hook called when exiting Gnus."
274 (defcustom gnus-after-exiting-gnus-hook nil
275 "Hook called after exiting Gnus."
279 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
280 "Hook called when a group line is changed.
281 The hook will not be called if `gnus-visual' is nil.
283 The default function `gnus-group-highlight-line' will
284 highlight the line according to the `gnus-group-highlight'
286 :group 'gnus-group-visual
289 (defcustom gnus-useful-groups
290 '(("(ding) mailing list mirrored at sunsite.auc.dk"
292 (nntp "sunsite.auc.dk"
293 (nntp-address "sunsite.auc.dk")))
296 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
300 (nndoc-article-type mbox)
301 (eval `(nndoc-address
302 ,(let ((file (nnheader-find-etc-directory
305 (error "Couldn't find doc group"))
307 "*Alist of useful group-server pairs."
308 :group 'gnus-group-listing
309 :type '(repeat (list (string :tag "Description")
311 (sexp :tag "Method"))))
313 (defcustom gnus-group-highlight
315 ((and mailp (= unread 0) (eq level 1)) .
316 gnus-group-mail-1-empty-face)
317 ((and mailp (eq level 1)) .
318 gnus-group-mail-1-face)
319 ((and mailp (= unread 0) (eq level 2)) .
320 gnus-group-mail-2-empty-face)
321 ((and mailp (eq level 2)) .
322 gnus-group-mail-2-face)
323 ((and mailp (= unread 0) (eq level 3)) .
324 gnus-group-mail-3-empty-face)
325 ((and mailp (eq level 3)) .
326 gnus-group-mail-3-face)
327 ((and mailp (= unread 0)) .
328 gnus-group-mail-low-empty-face)
330 gnus-group-mail-low-face)
332 ((and (= unread 0) (eq level 1)) .
333 gnus-group-news-1-empty-face)
334 ((and (eq level 1)) .
335 gnus-group-news-1-face)
336 ((and (= unread 0) (eq level 2)) .
337 gnus-group-news-2-empty-face)
338 ((and (eq level 2)) .
339 gnus-group-news-2-face)
340 ((and (= unread 0) (eq level 3)) .
341 gnus-group-news-3-empty-face)
342 ((and (eq level 3)) .
343 gnus-group-news-3-face)
344 ((and (= unread 0) (eq level 4)) .
345 gnus-group-news-4-empty-face)
346 ((and (eq level 4)) .
347 gnus-group-news-4-face)
348 ((and (= unread 0) (eq level 5)) .
349 gnus-group-news-5-empty-face)
350 ((and (eq level 5)) .
351 gnus-group-news-5-face)
352 ((and (= unread 0) (eq level 6)) .
353 gnus-group-news-6-empty-face)
354 ((and (eq level 6)) .
355 gnus-group-news-6-face)
356 ((and (= unread 0)) .
357 gnus-group-news-low-empty-face)
359 gnus-group-news-low-face))
360 "*Controls the highlighting of group buffer lines.
362 Below is a list of `Form'/`Face' pairs. When deciding how a a
363 particular group line should be displayed, each form is
364 evaluated. The content of the face field after the first true form is
365 used. You can change how those group lines are displayed by
366 editing the face field.
368 It is also possible to change and add form fields, but currently that
369 requires an understanding of Lisp expressions. Hopefully this will
370 change in a future release. For now, you can use the following
371 variables in the Lisp expression:
373 group: The name of the group.
374 unread: The number of unread articles in the group.
375 method: The select method used.
376 mailp: Whether it's a mail group or not.
377 level: The level of the group.
378 score: The score of the group.
379 ticked: The number of ticked articles."
380 :group 'gnus-group-visual
381 :type '(repeat (cons (sexp :tag "Form") face)))
383 (defcustom gnus-new-mail-mark ?%
384 "Mark used for groups with new mail."
385 :group 'gnus-group-visual
388 (defgroup gnus-group-icons nil
389 "Add Icons to your group buffer. "
390 :group 'gnus-group-visual)
392 (defcustom gnus-group-icon-list
394 "*Controls the insertion of icons into group buffer lines.
396 Below is a list of `Form'/`File' pairs. When deciding how a
397 particular group line should be displayed, each form is evaluated.
398 The icon from the file field after the first true form is used. You
399 can change how those group lines are displayed by editing the file
400 field. The File will either be found in the
401 `gnus-group-glyph-directory' or by designating absolute name of the
404 It is also possible to change and add form fields, but currently that
405 requires an understanding of Lisp expressions. Hopefully this will
406 change in a future release. For now, you can use the following
407 variables in the Lisp expression:
409 group: The name of the group.
410 unread: The number of unread articles in the group.
411 method: The select method used.
412 mailp: Whether it's a mail group or not.
413 newsp: Whether it's a news group or not
414 level: The level of the group.
415 score: The score of the group.
416 ticked: The number of ticked articles."
417 :group 'gnus-group-icons
418 :type '(repeat (cons (sexp :tag "Form") file)))
420 (defcustom gnus-group-name-charset-method-alist nil
421 "Alist of method and the charset for group names.
424 (((nntp \"news.com.cn\") . cn-gb-2312))"
427 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
429 (defcustom gnus-group-name-charset-group-alist
430 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
431 (mm-coding-system-p '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'.
443 If non-nil, the value should be a string, e.g. \"nnml:\",
444 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
445 in the minibuffer prompt."
446 :group 'gnus-group-various
447 :type '(choice (string :tag "Prompt string")
448 (const :tag "Empty" nil)))
450 (defvar gnus-group-listing-limit 1000
451 "*A limit of the number of groups when listing.
452 If the number of groups is larger than the limit, list them in a
455 ;;; Internal variables
457 (defvar gnus-group-is-exiting-p nil)
458 (defvar gnus-group-is-exiting-without-update-p nil)
459 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
460 "Function for sorting the group buffer.")
462 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
463 "Function for sorting the selected groups in the group buffer.")
465 (defvar gnus-group-indentation-function nil)
466 (defvar gnus-goto-missing-group-function nil)
467 (defvar gnus-group-update-group-function nil)
468 (defvar gnus-group-goto-next-group-function nil
469 "Function to override finding the next group after listing groups.")
471 (defvar gnus-group-edit-buffer nil)
473 (defvar gnus-group-line-format-alist
474 `((?M gnus-tmp-marked-mark ?c)
475 (?S gnus-tmp-subscribed ?c)
476 (?L gnus-tmp-level ?d)
477 (?N (cond ((eq number t) "*" )
481 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
482 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
484 (?R gnus-tmp-number-of-read ?s)
485 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
486 (?t gnus-tmp-number-total ?d)
487 (?y gnus-tmp-number-of-unread ?s)
488 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
489 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
490 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
491 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
492 (?g gnus-tmp-group ?s)
493 (?G gnus-tmp-qualified-group ?s)
494 (?c (gnus-short-group-name gnus-tmp-group) ?s)
495 (?C gnus-tmp-comment ?s)
496 (?D gnus-tmp-newsgroup-description ?s)
497 (?o gnus-tmp-moderated ?c)
498 (?O gnus-tmp-moderated-string ?s)
499 (?p gnus-tmp-process-marked ?c)
500 (?s gnus-tmp-news-server ?s)
501 (?n gnus-tmp-news-method ?s)
502 (?P gnus-group-indentation ?s)
503 (?E gnus-tmp-group-icon ?s)
504 (?B gnus-tmp-summary-live ?c)
505 (?z gnus-tmp-news-method-string ?s)
506 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
507 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
508 (?u gnus-tmp-user-defined ?s)
509 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
512 (defvar gnus-group-mode-line-format-alist
513 `((?S gnus-tmp-news-server ?s)
514 (?M gnus-tmp-news-method ?s)
515 (?u gnus-tmp-user-defined ?s)
516 (?: gnus-tmp-colon ?s)))
518 (defvar gnus-topic-topology nil
519 "The complete topic hierarchy.")
521 (defvar gnus-topic-alist nil
522 "The complete topic-group alist.")
524 (defvar gnus-group-marked nil)
526 (defvar gnus-group-list-mode nil)
529 (defvar gnus-group-icon-cache nil)
531 (defvar gnus-group-listed-groups nil)
532 (defvar gnus-group-list-option nil)
538 (put 'gnus-group-mode 'mode-class 'special)
540 (gnus-define-keys gnus-group-mode-map
541 " " gnus-group-read-group
542 "=" gnus-group-select-group
543 "\r" gnus-group-select-group
544 "\M-\r" gnus-group-quick-select-group
545 "\M- " gnus-group-visible-select-group
546 [(meta control return)] gnus-group-select-group-ephemerally
547 "j" gnus-group-jump-to-group
548 "n" gnus-group-next-unread-group
549 "p" gnus-group-prev-unread-group
550 "\177" gnus-group-prev-unread-group
551 [delete] gnus-group-prev-unread-group
552 [backspace] gnus-group-prev-unread-group
553 "N" gnus-group-next-group
554 "P" gnus-group-prev-group
555 "\M-n" gnus-group-next-unread-group-same-level
556 "\M-p" gnus-group-prev-unread-group-same-level
557 "," gnus-group-best-unread-group
558 "." gnus-group-first-unread-group
559 "u" gnus-group-unsubscribe-current-group
560 "U" gnus-group-unsubscribe-group
561 "c" gnus-group-catchup-current
562 "C" gnus-group-catchup-current-all
563 "\M-c" gnus-group-clear-data
564 "l" gnus-group-list-groups
565 "L" gnus-group-list-all-groups
568 "g" gnus-group-get-new-news
569 "\M-g" gnus-group-get-new-news-this-group
570 "R" gnus-group-restart
571 "r" gnus-group-read-init-file
572 "B" gnus-group-browse-foreign-server
573 "b" gnus-group-check-bogus-groups
574 "F" gnus-group-find-new-groups
575 "\C-c\C-d" gnus-group-describe-group
576 "\M-d" gnus-group-describe-all-groups
577 "\C-c\C-a" gnus-group-apropos
578 "\C-c\M-\C-a" gnus-group-description-apropos
579 "a" gnus-group-post-news
580 "\ek" gnus-group-edit-local-kill
581 "\eK" gnus-group-edit-global-kill
582 "\C-k" gnus-group-kill-group
583 "\C-y" gnus-group-yank-group
584 "\C-w" gnus-group-kill-region
585 "\C-x\C-t" gnus-group-transpose-groups
586 "\C-c\C-l" gnus-group-list-killed
587 "\C-c\C-x" gnus-group-expire-articles
588 "\C-c\M-\C-x" gnus-group-expire-all-groups
590 "s" gnus-group-save-newsrc
591 "z" gnus-group-suspend
594 "?" gnus-group-describe-briefly
595 "\C-c\C-i" gnus-info-find-node
596 "\M-e" gnus-group-edit-group-method
597 "^" gnus-group-enter-server-mode
598 gnus-mouse-2 gnus-mouse-pick-group
599 "<" beginning-of-buffer
602 "\C-c\C-s" gnus-group-sort-groups
604 "\C-c\M-g" gnus-activate-all-groups
605 "\M-&" gnus-group-universal-argument
606 "#" gnus-group-mark-group
607 "\M-#" gnus-group-unmark-group)
609 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
610 "m" gnus-group-mark-group
611 "u" gnus-group-unmark-group
612 "w" gnus-group-mark-region
613 "b" gnus-group-mark-buffer
614 "r" gnus-group-mark-regexp
615 "U" gnus-group-unmark-all-groups)
617 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
618 "u" gnus-sieve-update
619 "g" gnus-sieve-generate)
621 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
622 "d" gnus-group-make-directory-group
623 "h" gnus-group-make-help-group
624 "u" gnus-group-make-useful-group
625 "a" gnus-group-make-archive-group
626 "k" gnus-group-make-kiboze-group
627 "l" gnus-group-nnimap-edit-acl
628 "m" gnus-group-make-group
629 "E" gnus-group-edit-group
630 "e" gnus-group-edit-group-method
631 "p" gnus-group-edit-group-parameters
632 "v" gnus-group-add-to-virtual
633 "V" gnus-group-make-empty-virtual
634 "D" gnus-group-enter-directory
635 "f" gnus-group-make-doc-group
636 "w" gnus-group-make-web-group
637 "M" gnus-group-read-ephemeral-group
638 "r" gnus-group-rename-group
639 "R" gnus-group-make-rss-group
640 "c" gnus-group-customize
641 "x" gnus-group-nnimap-expunge
642 "\177" gnus-group-delete-group
643 [delete] gnus-group-delete-group)
645 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
646 "b" gnus-group-brew-soup
647 "w" gnus-soup-save-areas
648 "s" gnus-soup-send-replies
649 "p" gnus-soup-pack-packet
650 "r" nnsoup-pack-replies)
652 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
653 "s" gnus-group-sort-groups
654 "a" gnus-group-sort-groups-by-alphabet
655 "u" gnus-group-sort-groups-by-unread
656 "l" gnus-group-sort-groups-by-level
657 "v" gnus-group-sort-groups-by-score
658 "r" gnus-group-sort-groups-by-rank
659 "m" gnus-group-sort-groups-by-method
660 "n" gnus-group-sort-groups-by-real-name)
662 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
663 "s" gnus-group-sort-selected-groups
664 "a" gnus-group-sort-selected-groups-by-alphabet
665 "u" gnus-group-sort-selected-groups-by-unread
666 "l" gnus-group-sort-selected-groups-by-level
667 "v" gnus-group-sort-selected-groups-by-score
668 "r" gnus-group-sort-selected-groups-by-rank
669 "m" gnus-group-sort-selected-groups-by-method
670 "n" gnus-group-sort-selected-groups-by-real-name)
672 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
673 "k" gnus-group-list-killed
674 "z" gnus-group-list-zombies
675 "s" gnus-group-list-groups
676 "u" gnus-group-list-all-groups
677 "A" gnus-group-list-active
678 "a" gnus-group-apropos
679 "d" gnus-group-description-apropos
680 "m" gnus-group-list-matching
681 "M" gnus-group-list-all-matching
682 "l" gnus-group-list-level
683 "c" gnus-group-list-cached
684 "?" gnus-group-list-dormant)
686 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
687 "k" gnus-group-list-limit
688 "z" gnus-group-list-limit
689 "s" gnus-group-list-limit
690 "u" gnus-group-list-limit
691 "A" gnus-group-list-limit
692 "m" gnus-group-list-limit
693 "M" gnus-group-list-limit
694 "l" gnus-group-list-limit
695 "c" gnus-group-list-limit
696 "?" gnus-group-list-limit)
698 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
699 "k" gnus-group-list-flush
700 "z" gnus-group-list-flush
701 "s" gnus-group-list-flush
702 "u" gnus-group-list-flush
703 "A" gnus-group-list-flush
704 "m" gnus-group-list-flush
705 "M" gnus-group-list-flush
706 "l" gnus-group-list-flush
707 "c" gnus-group-list-flush
708 "?" gnus-group-list-flush)
710 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
711 "k" gnus-group-list-plus
712 "z" gnus-group-list-plus
713 "s" gnus-group-list-plus
714 "u" gnus-group-list-plus
715 "A" gnus-group-list-plus
716 "m" gnus-group-list-plus
717 "M" gnus-group-list-plus
718 "l" gnus-group-list-plus
719 "c" gnus-group-list-plus
720 "?" gnus-group-list-plus)
722 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
723 "f" gnus-score-flush-cache
724 "e" gnus-score-edit-all-score)
726 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
727 "c" gnus-group-fetch-charter
728 "C" gnus-group-fetch-control
729 "d" gnus-group-describe-group
730 "f" gnus-group-fetch-faq
733 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
734 "l" gnus-group-set-current-level
735 "t" gnus-group-unsubscribe-current-group
736 "s" gnus-group-unsubscribe-group
737 "k" gnus-group-kill-group
738 "y" gnus-group-yank-group
739 "w" gnus-group-kill-region
740 "\C-k" gnus-group-kill-level
741 "z" gnus-group-kill-all-zombies)
743 (defun gnus-topic-mode-p ()
744 "Return non-nil in `gnus-topic-mode'."
745 (and (boundp 'gnus-topic-mode)
746 (symbol-value 'gnus-topic-mode)))
748 (defun gnus-group-make-menu-bar ()
749 (gnus-turn-off-edit-menu 'group)
750 (unless (boundp 'gnus-group-reading-menu)
753 gnus-group-reading-menu gnus-group-mode-map ""
755 ["Read" gnus-group-read-group
756 :included (not (gnus-topic-mode-p))
757 :active (gnus-group-group-name)]
758 ["Read " gnus-topic-read-group
759 :included (gnus-topic-mode-p)]
760 ["Select" gnus-group-select-group
761 :included (not (gnus-topic-mode-p))
762 :active (gnus-group-group-name)]
763 ["Select " gnus-topic-select-group
764 :included (gnus-topic-mode-p)]
765 ["See old articles" (gnus-group-select-group 'all)
766 :keys "C-u SPC" :active (gnus-group-group-name)]
767 ["Catch up" gnus-group-catchup-current
768 :included (not (gnus-topic-mode-p))
769 :active (gnus-group-group-name)
770 ,@(if (featurep 'xemacs) nil
771 '(:help "Mark unread articles in the current group as read"))]
772 ["Catch up " gnus-topic-catchup-articles
773 :included (gnus-topic-mode-p)
774 ,@(if (featurep 'xemacs) nil
775 '(:help "Mark unread articles in the current group or topic as read"))]
776 ["Catch up all articles" gnus-group-catchup-current-all
777 (gnus-group-group-name)]
778 ["Check for new articles" gnus-group-get-new-news-this-group
779 :included (not (gnus-topic-mode-p))
780 :active (gnus-group-group-name)
781 ,@(if (featurep 'xemacs) nil
782 '(:help "Check for new messages in current group"))]
783 ["Check for new articles " gnus-topic-get-new-news-this-topic
784 :included (gnus-topic-mode-p)
785 ,@(if (featurep 'xemacs) nil
786 '(:help "Check for new messages in current group or topic"))]
787 ["Toggle subscription" gnus-group-unsubscribe-current-group
788 (gnus-group-group-name)]
789 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
790 ,@(if (featurep 'xemacs) nil
791 '(:help "Kill (remove) current group"))]
792 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
793 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
794 ,@(if (featurep 'xemacs) nil
795 '(:help "Display description of the current group"))]
796 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
797 ["Fetch charter" gnus-group-fetch-charter
798 :active (gnus-group-group-name)
799 ,@(if (featurep 'xemacs) nil
800 '(:help "Display the charter of the current group"))]
801 ["Fetch control message" gnus-group-fetch-control
802 :active (gnus-group-group-name)
803 ,@(if (featurep 'xemacs) nil
804 '(:help "Display the archived control message for the current group"))]
805 ;; Actually one should check, if any of the marked groups gives t for
806 ;; (gnus-check-backend-function 'request-expire-articles ...)
807 ["Expire articles" gnus-group-expire-articles
808 :included (not (gnus-topic-mode-p))
809 :active (or (and (gnus-group-group-name)
810 (gnus-check-backend-function
811 'request-expire-articles
812 (gnus-group-group-name))) gnus-group-marked)]
813 ["Expire articles " gnus-topic-expire-articles
814 :included (gnus-topic-mode-p)]
815 ["Set group level..." gnus-group-set-current-level
816 (gnus-group-group-name)]
817 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
818 ["Customize" gnus-group-customize (gnus-group-group-name)]
820 ["Parameters" gnus-group-edit-group-parameters
821 :included (not (gnus-topic-mode-p))
822 :active (gnus-group-group-name)]
823 ["Parameters " gnus-topic-edit-parameters
824 :included (gnus-topic-mode-p)]
825 ["Select method" gnus-group-edit-group-method
826 (gnus-group-group-name)]
827 ["Info" gnus-group-edit-group (gnus-group-group-name)]
828 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
829 ["Global kill file" gnus-group-edit-global-kill t])))
832 gnus-group-group-menu gnus-group-mode-map ""
835 ["List unread subscribed groups" gnus-group-list-groups t]
836 ["List (un)subscribed groups" gnus-group-list-all-groups t]
837 ["List killed groups" gnus-group-list-killed gnus-killed-list]
838 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
839 ["List level..." gnus-group-list-level t]
840 ["Describe all groups" gnus-group-describe-all-groups t]
841 ["Group apropos..." gnus-group-apropos t]
842 ["Group and description apropos..." gnus-group-description-apropos t]
843 ["List groups matching..." gnus-group-list-matching t]
844 ["List all groups matching..." gnus-group-list-all-matching t]
845 ["List active file" gnus-group-list-active t]
846 ["List groups with cached" gnus-group-list-cached t]
847 ["List groups with dormant" gnus-group-list-dormant t])
849 ["Default sort" gnus-group-sort-groups t]
850 ["Sort by method" gnus-group-sort-groups-by-method t]
851 ["Sort by rank" gnus-group-sort-groups-by-rank t]
852 ["Sort by score" gnus-group-sort-groups-by-score t]
853 ["Sort by level" gnus-group-sort-groups-by-level t]
854 ["Sort by unread" gnus-group-sort-groups-by-unread t]
855 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
856 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
857 ("Sort process/prefixed"
858 ["Default sort" gnus-group-sort-selected-groups
859 (not (gnus-topic-mode-p))]
860 ["Sort by method" gnus-group-sort-selected-groups-by-method
861 (not (gnus-topic-mode-p))]
862 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
863 (not (gnus-topic-mode-p))]
864 ["Sort by score" gnus-group-sort-selected-groups-by-score
865 (not (gnus-topic-mode-p))]
866 ["Sort by level" gnus-group-sort-selected-groups-by-level
867 (not (gnus-topic-mode-p))]
868 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
869 (not (gnus-topic-mode-p))]
870 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
871 (not (gnus-topic-mode-p))]
872 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
873 (not (gnus-topic-mode-p))])
875 ["Mark group" gnus-group-mark-group
876 (and (gnus-group-group-name)
877 (not (memq (gnus-group-group-name) gnus-group-marked)))]
878 ["Unmark group" gnus-group-unmark-group
879 (and (gnus-group-group-name)
880 (memq (gnus-group-group-name) gnus-group-marked))]
881 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
882 ["Mark regexp..." gnus-group-mark-regexp t]
883 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
884 ["Mark buffer" gnus-group-mark-buffer t]
885 ["Execute command" gnus-group-universal-argument
886 (or gnus-group-marked (gnus-group-group-name))])
888 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
889 ["Kill all newsgroups in region" gnus-group-kill-region
890 :active (gnus-mark-active-p)]
891 ["Kill all zombie groups" gnus-group-kill-all-zombies
893 ["Kill all groups on level..." gnus-group-kill-level t])
895 ["Make a foreign group..." gnus-group-make-group t]
896 ["Add a directory group..." gnus-group-make-directory-group t]
897 ["Add the help group" gnus-group-make-help-group t]
898 ["Add the archive group" gnus-group-make-archive-group t]
899 ["Make a doc group..." gnus-group-make-doc-group t]
900 ["Make a web group..." gnus-group-make-web-group t]
901 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
902 ["Make a virtual group..." gnus-group-make-empty-virtual t]
903 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
904 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
905 ["Make an RSS group..." gnus-group-make-rss-group t]
906 ["Rename group..." gnus-group-rename-group
907 (gnus-check-backend-function
908 'request-rename-group (gnus-group-group-name))]
909 ["Delete group" gnus-group-delete-group
910 (gnus-check-backend-function
911 'request-delete-group (gnus-group-group-name))])
913 ["Next" gnus-group-next-group t]
914 ["Previous" gnus-group-prev-group t]
915 ["Next unread" gnus-group-next-unread-group t]
916 ["Previous unread" gnus-group-prev-unread-group t]
917 ["Next unread same level" gnus-group-next-unread-group-same-level t]
918 ["Previous unread same level"
919 gnus-group-prev-unread-group-same-level t]
920 ["Jump to group..." gnus-group-jump-to-group t]
921 ["First unread group" gnus-group-first-unread-group t]
922 ["Best unread group" gnus-group-best-unread-group t])
924 ["Generate" gnus-sieve-generate t]
925 ["Generate and update" gnus-sieve-update t])
926 ["Delete bogus groups" gnus-group-check-bogus-groups t]
927 ["Find new newsgroups" gnus-group-find-new-groups t]
928 ["Transpose" gnus-group-transpose-groups
929 (gnus-group-group-name)]
930 ["Read a directory as a group..." gnus-group-enter-directory t]))
933 gnus-group-misc-menu gnus-group-mode-map ""
936 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
937 ["Send replies" gnus-soup-send-replies
938 (fboundp 'gnus-soup-pack-packet)]
939 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
940 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
941 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
942 ["Send a mail" gnus-group-mail t]
943 ["Send a message (mail or news)" gnus-group-post-news t]
944 ["Create a local message" gnus-group-news t]
945 ["Check for new news" gnus-group-get-new-news
946 ,@(if (featurep 'xemacs) '(t)
947 '(:help "Get newly arrived articles"))
949 ["Send queued messages" gnus-delay-send-queue
950 ,@(if (featurep 'xemacs) '(t)
951 '(:help "Send all messages that are scheduled to be sent now"))
953 ["Activate all groups" gnus-activate-all-groups t]
954 ["Restart Gnus" gnus-group-restart t]
955 ["Read init file" gnus-group-read-init-file t]
956 ["Browse foreign server..." gnus-group-browse-foreign-server t]
957 ["Enter server buffer" gnus-group-enter-server-mode t]
958 ["Expire all expirable articles" gnus-group-expire-all-groups t]
959 ["Generate any kiboze groups" nnkiboze-generate-groups t]
960 ["Gnus version" gnus-version t]
961 ["Save .newsrc files" gnus-group-save-newsrc t]
962 ["Suspend Gnus" gnus-group-suspend t]
963 ["Clear dribble buffer" gnus-group-clear-dribble t]
964 ["Read manual" gnus-info-find-node t]
965 ["Flush score cache" gnus-score-flush-cache t]
966 ["Toggle topics" gnus-topic-mode t]
967 ["Send a bug report" gnus-bug t]
968 ["Exit from Gnus" gnus-group-exit
969 ,@(if (featurep 'xemacs) '(t)
970 '(:help "Quit reading news"))]
971 ["Exit without saving" gnus-group-quit t]))
973 (gnus-run-hooks 'gnus-group-menu-hook)))
975 (defvar gnus-group-toolbar-map nil)
977 ;; Emacs 21 tool bar. Should be no-op otherwise.
978 (defun gnus-group-make-tool-bar ()
980 (condition-case nil (require 'tool-bar) (error nil))
981 (fboundp 'tool-bar-add-item-from-menu)
982 (default-value 'tool-bar-mode)
983 (not gnus-group-toolbar-map))
984 (setq gnus-group-toolbar-map
985 (let ((tool-bar-map (make-sparse-keymap))
986 (load-path (mm-image-load-path)))
987 (tool-bar-add-item-from-menu
988 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
989 (tool-bar-add-item-from-menu
990 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
991 (tool-bar-add-item-from-menu
992 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
993 (tool-bar-add-item-from-menu
994 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
995 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
996 :help "Subscribe to the current group")
997 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
999 :help "Unsubscribe from the current group")
1000 (tool-bar-add-item-from-menu
1001 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1003 (if gnus-group-toolbar-map
1004 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1006 (defun gnus-group-mode ()
1007 "Major mode for reading news.
1009 All normal editing commands are switched off.
1010 \\<gnus-group-mode-map>
1011 The group buffer lists (some of) the groups available. For instance,
1012 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1013 lists all zombie groups.
1015 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1016 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1018 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1020 The following commands are available:
1022 \\{gnus-group-mode-map}"
1024 (kill-all-local-variables)
1025 (when (gnus-visual-p 'group-menu 'menu)
1026 (gnus-group-make-menu-bar)
1027 (gnus-group-make-tool-bar))
1028 (gnus-simplify-mode-line)
1029 (setq major-mode 'gnus-group-mode)
1030 (setq mode-name "Group")
1031 (gnus-group-set-mode-line)
1032 (setq mode-line-process nil)
1033 (use-local-map gnus-group-mode-map)
1034 (buffer-disable-undo)
1035 (setq truncate-lines t)
1036 (setq buffer-read-only t)
1037 (gnus-set-default-directory)
1038 (gnus-update-format-specifications nil 'group 'group-mode)
1039 (gnus-update-group-mark-positions)
1044 (gnus-run-hooks 'gnus-group-mode-hook))
1046 (defun gnus-update-group-mark-positions ()
1048 (let ((gnus-process-mark ?\200)
1049 (gnus-group-update-hook nil)
1050 (gnus-group-marked '("dummy.group"))
1051 (gnus-active-hashtb (make-vector 10 0))
1053 (gnus-set-active "dummy.group" '(0 . 0))
1054 (gnus-set-work-buffer)
1055 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1056 (goto-char (point-min))
1057 (setq gnus-group-mark-positions
1058 (list (cons 'process (and (search-forward "\200" nil t)
1059 (- (point) 2))))))))
1061 (defun gnus-mouse-pick-group (e)
1062 "Enter the group under the mouse pointer."
1065 (gnus-group-read-group nil))
1067 ;; Look at LEVEL and find out what the level is really supposed to be.
1068 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1069 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1070 (defun gnus-group-default-level (&optional level number-or-nil)
1072 (gnus-group-use-permanent-levels
1073 (or (setq gnus-group-use-permanent-levels
1074 (or level (if (numberp gnus-group-use-permanent-levels)
1075 gnus-group-use-permanent-levels
1076 (or gnus-group-default-list-level
1077 gnus-level-subscribed))))
1078 gnus-group-default-list-level gnus-level-subscribed))
1082 (or level gnus-group-default-list-level gnus-level-subscribed))))
1084 (defun gnus-group-setup-buffer ()
1085 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1086 (unless (eq major-mode 'gnus-group-mode)
1089 (gnus-carpal-setup-buffer 'group))))
1091 (defun gnus-group-name-charset (method group)
1093 (setq method (gnus-find-method-for-group group)))
1094 (let ((item (assoc method gnus-group-name-charset-method-alist))
1095 (alist gnus-group-name-charset-group-alist)
1099 (while (setq item (pop alist))
1100 (if (string-match (car item) group)
1102 result (cdr item))))
1105 (defun gnus-group-name-decode (string charset)
1106 ;; Fixme: Don't decode in unibyte mode.
1107 (if (and string charset (featurep 'mule))
1108 (mm-decode-coding-string string charset)
1111 (defun gnus-group-decoded-name (string)
1112 (let ((charset (gnus-group-name-charset nil string)))
1113 (gnus-group-name-decode string charset)))
1115 (defun gnus-group-list-groups (&optional level unread lowest)
1116 "List newsgroups with level LEVEL or lower that have unread articles.
1117 Default is all subscribed groups.
1118 If argument UNREAD is non-nil, groups with no unread articles are also
1121 Also see the `gnus-group-use-permanent-levels' variable."
1123 (list (if current-prefix-arg
1124 (prefix-numeric-value current-prefix-arg)
1126 (gnus-group-default-level nil t)
1127 gnus-group-default-list-level
1128 gnus-level-subscribed))))
1130 (setq level (car gnus-group-list-mode)
1131 unread (cdr gnus-group-list-mode)))
1132 (setq level (gnus-group-default-level level))
1133 (gnus-group-setup-buffer)
1134 (gnus-update-format-specifications nil 'group 'group-mode)
1135 (let ((case-fold-search nil)
1136 (props (text-properties-at (point-at-bol)))
1137 (empty (= (point-min) (point-max)))
1138 (group (gnus-group-group-name))
1140 (set-buffer gnus-group-buffer)
1141 (setq number (funcall gnus-group-prepare-function level unread lowest))
1142 (when (or (and (numberp number)
1144 (zerop (buffer-size)))
1145 ;; No groups in the buffer.
1146 (gnus-message 5 gnus-no-groups-message))
1147 ;; We have some groups displayed.
1148 (goto-char (point-max))
1149 (when (or (not gnus-group-goto-next-group-function)
1150 (not (funcall gnus-group-goto-next-group-function
1154 (goto-char (point-min)))
1156 ;; Go to the first group with unread articles.
1157 (gnus-group-search-forward t))
1159 ;; Find the right group to put point on. If the current group
1160 ;; has disappeared in the new listing, try to find the next
1161 ;; one. If no next one can be found, just leave point at the
1162 ;; first newsgroup in the buffer.
1163 (when (not (gnus-goto-char
1165 (point-min) (point-max)
1166 'gnus-group (gnus-intern-safe
1167 group gnus-active-hashtb))))
1168 (let ((newsrc (cdddr (gnus-group-entry group))))
1170 (not (gnus-goto-char
1172 (point-min) (point-max) 'gnus-group
1174 (caar newsrc) gnus-active-hashtb)))))
1175 (setq newsrc (cdr newsrc)))
1177 (goto-char (point-max))
1178 (forward-line -1)))))))
1179 ;; Adjust cursor point.
1180 (gnus-group-position-point)))
1182 (defun gnus-group-list-level (level &optional all)
1183 "List groups on LEVEL.
1184 If ALL (the prefix), also list groups that have no unread articles."
1185 (interactive "nList groups on level: \nP")
1186 (gnus-group-list-groups level all level))
1188 (defun gnus-group-prepare-logic (group test)
1189 (or (and gnus-group-listed-groups
1190 (null gnus-group-list-option)
1191 (member group gnus-group-listed-groups))
1193 ((null gnus-group-listed-groups) test)
1194 ((null gnus-group-list-option) test)
1195 (t (and (member group gnus-group-listed-groups)
1196 (if (eq gnus-group-list-option 'flush)
1200 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1201 "List all newsgroups with unread articles of level LEVEL or lower.
1202 If PREDICATE is a function, list groups that the function returns non-nil;
1203 if it is t, list groups that have no unread articles.
1204 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1205 If REGEXP is a function, list dead groups that the function returns non-nil;
1206 if it is a string, only list groups matching REGEXP."
1207 (set-buffer gnus-group-buffer)
1208 (let ((buffer-read-only nil)
1209 (newsrc (cdr gnus-newsrc-alist))
1210 (lowest (or lowest 1))
1211 (not-in-list (and gnus-group-listed-groups
1212 (copy-sequence gnus-group-listed-groups)))
1213 info clevel unread group params)
1215 (when (or (< lowest gnus-level-zombie)
1216 gnus-group-listed-groups)
1217 ;; List living groups.
1219 (setq info (car newsrc)
1220 group (gnus-info-group info)
1221 params (gnus-info-params info)
1223 unread (gnus-group-unread group))
1225 (setq not-in-list (delete group not-in-list)))
1226 (when (gnus-group-prepare-logic
1228 (and unread ; This group might be unchecked
1229 (or (not (stringp regexp))
1230 (string-match regexp group))
1231 (<= (setq clevel (gnus-info-level info)) level)
1234 ((functionp predicate)
1235 (funcall predicate info))
1236 (predicate t) ; We list all groups?
1239 (if (eq unread t) ; Unactivated?
1240 gnus-group-list-inactive-groups
1241 ; We list unactivated
1243 ; We list groups with unread articles
1244 (and gnus-list-groups-with-ticked-articles
1245 (cdr (assq 'tick (gnus-info-marks info))))
1246 ; And groups with tickeds
1247 ;; Check for permanent visibility.
1248 (and gnus-permanently-visible-groups
1249 (string-match gnus-permanently-visible-groups
1251 (memq 'visible params)
1252 (cdr (assq 'visible params)))))))
1253 (gnus-group-insert-group-line
1254 group (gnus-info-level info)
1255 (gnus-info-marks info) unread (gnus-info-method info)))))
1257 ;; List dead groups.
1258 (when (or gnus-group-listed-groups
1259 (and (>= level gnus-level-zombie)
1260 (<= lowest gnus-level-zombie)))
1261 (gnus-group-prepare-flat-list-dead
1262 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1263 gnus-level-zombie ?Z
1266 (dolist (group gnus-zombie-list)
1267 (setq not-in-list (delete group not-in-list))))
1268 (when (or gnus-group-listed-groups
1269 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1270 (gnus-group-prepare-flat-list-dead
1273 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1274 gnus-level-killed ?K regexp))
1276 (gnus-group-set-mode-line)
1277 (setq gnus-group-list-mode (cons level predicate))
1278 (gnus-run-hooks 'gnus-group-prepare-hook)
1281 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1282 ;; List zombies and killed lists somewhat faster, which was
1283 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1284 ;; this by ignoring the group format specification altogether.
1286 (if (> (length groups) gnus-group-listing-limit)
1288 (setq group (pop groups))
1289 (when (gnus-group-prepare-logic
1292 (and (stringp regexp) (string-match regexp group))
1293 (and (functionp regexp) (funcall regexp group))))
1294 (gnus-add-text-properties
1295 (point) (prog1 (1+ (point))
1296 (insert " " mark " *: "
1297 (gnus-group-decoded-name group)
1299 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1301 'gnus-level level))))
1303 (setq group (pop groups))
1304 (when (gnus-group-prepare-logic
1307 (and (stringp regexp) (string-match regexp group))
1308 (and (functionp regexp) (funcall regexp group))))
1309 (gnus-group-insert-group-line
1311 (let ((active (gnus-active group)))
1313 (if (zerop (cdr active))
1315 (- (1+ (cdr active)) (car active)))
1317 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1319 (defun gnus-group-update-group-line ()
1320 "Update the current line in the group buffer."
1321 (let* ((buffer-read-only nil)
1322 (group (gnus-group-group-name))
1323 (entry (and group (gnus-group-entry group)))
1324 gnus-group-indentation)
1327 (not (gnus-ephemeral-group-p group))
1329 (concat "(gnus-group-set-info '"
1330 (gnus-prin1-to-string (nth 2 entry))
1332 (setq gnus-group-indentation (gnus-group-group-indentation))
1334 (gnus-group-insert-group-line-info group)
1336 (gnus-group-position-point))))
1338 (defun gnus-group-insert-group-line-info (group)
1339 "Insert GROUP on the current line."
1340 (let ((entry (gnus-group-entry group))
1341 (gnus-group-indentation (gnus-group-group-indentation))
1345 ;; (Un)subscribed group.
1346 (setq info (nth 2 entry))
1347 (gnus-group-insert-group-line
1348 group (gnus-info-level info) (gnus-info-marks info)
1349 (or (car entry) t) (gnus-info-method info)))
1350 ;; This group is dead.
1351 (gnus-group-insert-group-line
1353 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1355 (if (setq active (gnus-active group))
1356 (if (zerop (cdr active))
1358 (- (1+ (cdr active)) (car active)))
1360 (gnus-method-simplify (gnus-find-method-for-group group))))))
1362 (defun gnus-number-of-unseen-articles-in-group (group)
1363 (let* ((info (nth 2 (gnus-group-entry group)))
1364 (marked (gnus-info-marks info))
1365 (seen (cdr (assq 'seen marked)))
1366 (active (gnus-active group)))
1369 (length (gnus-uncompress-range
1370 (gnus-range-difference
1371 (gnus-range-difference (list active) (gnus-info-read info))
1374 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1375 gnus-tmp-marked number
1377 "Insert a group line in the group buffer."
1378 (let* ((gnus-tmp-method
1379 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1380 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1382 (gnus-tmp-active (gnus-active gnus-tmp-group))
1383 (gnus-tmp-number-total
1385 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1387 (gnus-tmp-number-of-unread
1388 (if (numberp number) (int-to-string (max 0 number))
1390 (gnus-tmp-number-of-read
1391 (if (numberp number)
1392 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1394 (gnus-tmp-subscribed
1395 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1396 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1397 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1399 (gnus-tmp-qualified-group
1400 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1401 group-name-charset))
1403 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1405 (gnus-tmp-newsgroup-description
1406 (if gnus-description-hashtb
1407 (or (gnus-group-name-decode
1408 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1409 group-name-charset) "")
1412 (if (and gnus-moderated-hashtb
1413 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1415 (gnus-tmp-moderated-string
1416 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1417 (gnus-tmp-group-icon "==&&==")
1418 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1419 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1420 (gnus-tmp-news-method-string
1422 (format "(%s:%s)" (car gnus-tmp-method)
1423 (cadr gnus-tmp-method)) ""))
1424 (gnus-tmp-marked-mark
1425 (if (and (numberp number)
1427 (cdr (assq 'tick gnus-tmp-marked)))
1429 (gnus-tmp-summary-live
1430 (if (and (not gnus-group-is-exiting-p)
1431 (gnus-buffer-live-p (gnus-summary-buffer-name
1434 (gnus-tmp-process-marked
1435 (if (member gnus-tmp-group gnus-group-marked)
1436 gnus-process-mark ? ))
1437 (buffer-read-only nil)
1438 header gnus-tmp-header) ; passed as parameter to user-funcs.
1440 (gnus-add-text-properties
1444 (let ((gnus-tmp-group (gnus-group-name-decode
1445 gnus-tmp-group group-name-charset)))
1446 (eval gnus-group-line-format-spec)))
1447 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1448 gnus-unread ,(if (numberp number)
1449 (string-to-int gnus-tmp-number-of-unread)
1451 gnus-marked ,gnus-tmp-marked-mark
1452 gnus-indentation ,gnus-group-indentation
1453 gnus-level ,gnus-tmp-level))
1455 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1456 (gnus-run-hooks 'gnus-group-update-hook))
1458 ;; Allow XEmacs to remove front-sticky text properties.
1459 (gnus-group-remove-excess-properties)))
1461 (defun gnus-group-highlight-line ()
1462 "Highlight the current line according to `gnus-group-highlight'."
1463 (let* ((list gnus-group-highlight)
1465 (end (point-at-eol))
1466 ;; now find out where the line starts and leave point there.
1467 (beg (progn (beginning-of-line) (point)))
1468 (group (gnus-group-group-name))
1469 (entry (gnus-group-entry group))
1470 (unread (if (numberp (car entry)) (car entry) 0))
1471 (active (gnus-active group))
1472 (total (if active (1+ (- (cdr active) (car active))) 0))
1473 (info (nth 2 entry))
1474 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1475 (marked (gnus-info-marks info))
1476 (mailp (apply 'append
1479 (memq x (assoc (symbol-name
1480 (car (or method gnus-select-method)))
1481 gnus-valid-select-methods)))
1482 '(mail post-mail))))
1483 (level (or (gnus-info-level info) gnus-level-killed))
1484 (score (or (gnus-info-score info) 0))
1485 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1486 (group-age (gnus-group-timestamp-delta group))
1487 (inhibit-read-only t))
1488 ;; Eval the cars of the lists until we find a match.
1490 (not (eval (caar list))))
1491 (setq list (cdr list)))
1492 (let ((face (cdar list)))
1493 (unless (eq face (get-text-property beg 'face))
1494 (gnus-put-text-property-excluding-characters-with-faces
1496 (setq face (if (boundp face) (symbol-value face) face)))
1497 (gnus-extent-start-open beg)))
1500 (defun gnus-group-update-group (group &optional visible-only)
1501 "Update all lines where GROUP appear.
1502 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1504 ;; Can't use `save-excursion' here, so we do it manually.
1505 (let ((buf (current-buffer))
1507 (set-buffer gnus-group-buffer)
1508 (setq mark (point-marker))
1509 ;; The buffer may be narrowed.
1512 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1514 found buffer-read-only)
1515 ;; Enter the current status into the dribble buffer.
1516 (let ((entry (gnus-group-entry group)))
1518 (not (gnus-ephemeral-group-p group)))
1520 (concat "(gnus-group-set-info '"
1521 (gnus-prin1-to-string (nth 2 entry))
1523 ;; Find all group instances. If topics are in use, each group
1524 ;; may be listed in more than once.
1525 (while (setq loc (text-property-any
1526 loc (point-max) 'gnus-group ident))
1529 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1531 (gnus-group-insert-group-line-info group)
1534 (gnus-run-hooks 'gnus-group-update-group-hook)))
1535 (setq loc (1+ loc)))
1536 (unless (or found visible-only)
1537 ;; No such line in the buffer, find out where it's supposed to
1538 ;; go, and insert it there (or at the end of the buffer).
1539 (if gnus-goto-missing-group-function
1540 (funcall gnus-goto-missing-group-function group)
1541 (let ((entry (cddr (gnus-group-entry group))))
1542 (while (and entry (car entry)
1546 (point-min) (point-max)
1547 'gnus-group (gnus-intern-safe
1548 (caar entry) gnus-active-hashtb)))))
1549 (setq entry (cdr entry)))
1550 (or entry (goto-char (point-max)))))
1551 ;; Finally insert the line.
1552 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1553 (gnus-group-insert-group-line-info group)
1556 (gnus-run-hooks 'gnus-group-update-group-hook))))
1557 (when gnus-group-update-group-function
1558 (funcall gnus-group-update-group-function group))
1559 (gnus-group-set-mode-line)))
1561 (set-marker mark nil)
1564 (defun gnus-group-set-mode-line ()
1565 "Update the mode line in the group buffer."
1566 (when (memq 'group gnus-updated-mode-lines)
1567 ;; Yes, we want to keep this mode line updated.
1569 (set-buffer gnus-group-buffer)
1570 (let* ((gformat (or gnus-group-mode-line-format-spec
1571 (gnus-set-format 'group-mode)))
1572 (gnus-tmp-news-server (cadr gnus-select-method))
1573 (gnus-tmp-news-method (car gnus-select-method))
1574 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1576 gnus-tmp-header ;Dummy binding for user-defined formats
1577 ;; Get the resulting string.
1579 (and gnus-dribble-buffer
1580 (buffer-name gnus-dribble-buffer)
1581 (buffer-modified-p gnus-dribble-buffer)
1583 (set-buffer gnus-dribble-buffer)
1584 (not (zerop (buffer-size))))))
1585 (mode-string (eval gformat)))
1586 ;; Say whether the dribble buffer has been modified.
1587 (setq mode-line-modified
1588 (if modified (car gnus-mode-line-modified)
1589 (cdr gnus-mode-line-modified)))
1590 ;; If the line is too long, we chop it off.
1591 (when (> (length mode-string) max-len)
1592 (setq mode-string (substring mode-string 0 (- max-len 4))))
1594 (setq mode-line-buffer-identification
1595 (gnus-mode-line-buffer-identification
1596 (list mode-string)))
1597 (set-buffer-modified-p modified))))))
1599 (defun gnus-group-group-name ()
1600 "Get the name of the newsgroup on the current line."
1601 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1603 (symbol-name group))))
1605 (defun gnus-group-group-level ()
1606 "Get the level of the newsgroup on the current line."
1607 (get-text-property (point-at-bol) 'gnus-level))
1609 (defun gnus-group-group-indentation ()
1610 "Get the indentation of the newsgroup on the current line."
1611 (or (get-text-property (point-at-bol) 'gnus-indentation)
1612 (and gnus-group-indentation-function
1613 (funcall gnus-group-indentation-function))
1616 (defun gnus-group-group-unread ()
1617 "Get the number of unread articles of the newsgroup on the current line."
1618 (get-text-property (point-at-bol) 'gnus-unread))
1620 (defun gnus-group-new-mail (group)
1621 (if (nnmail-new-mail-p (gnus-group-real-name group))
1625 (defun gnus-group-level (group)
1626 "Return the estimated level of GROUP."
1627 (or (gnus-info-level (gnus-get-info group))
1628 (and (member group gnus-zombie-list) gnus-level-zombie)
1631 (defun gnus-group-search-forward (&optional backward all level first-too)
1632 "Find the next newsgroup with unread articles.
1633 If BACKWARD is non-nil, find the previous newsgroup instead.
1634 If ALL is non-nil, just find any newsgroup.
1635 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1637 If FIRST-TOO, the current line is also eligible as a target."
1638 (let ((way (if backward -1 1))
1639 (low gnus-level-killed)
1642 (if (and backward (progn (beginning-of-line)) (bobp))
1651 (get-text-property (point) 'gnus-group)
1655 (get-text-property (point) 'gnus-unread)))
1656 (and (numberp unread) (> unread 0)))
1657 (setq lev (get-text-property (point)
1659 (<= lev gnus-level-subscribed)))
1661 (and (setq lev (get-text-property (point)
1670 (zerop (forward-line way)))))
1672 (progn (gnus-group-position-point) t)
1673 (goto-char (or pos beg))
1676 (defun gnus-total-fetched-for (group)
1677 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1678 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1679 (size (+ size-in-cache size-in-agent))
1680 (suffix '("B" "K" "M" "G"))
1682 (cutoff (* 10 scale)))
1683 (while (> size cutoff)
1684 (setq size (/ size scale)
1685 suffix (cdr suffix)))
1686 (format "%5.1f%s" size (car suffix))))
1688 ;;; Gnus group mode commands
1692 (defun gnus-group-mark-line-p ()
1695 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1696 (eq (char-after) gnus-process-mark)))
1698 (defun gnus-group-mark-group (n &optional unmark no-advance)
1699 "Mark the current group."
1701 (let ((buffer-read-only nil)
1705 (when (setq group (gnus-group-group-name))
1706 ;; Go to the mark position.
1708 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1712 (setq gnus-group-marked (delete group gnus-group-marked))
1713 (insert-char ? 1 t))
1714 (setq gnus-group-marked
1715 (cons group (delete group gnus-group-marked)))
1716 (insert-char gnus-process-mark 1 t)))
1718 (gnus-group-next-group 1))
1720 (gnus-summary-position-point)
1723 (defun gnus-group-unmark-group (n)
1724 "Remove the mark from the current group."
1726 (gnus-group-mark-group n 'unmark)
1727 (gnus-group-position-point))
1729 (defun gnus-group-unmark-all-groups ()
1730 "Unmark all groups."
1732 (let ((groups gnus-group-marked))
1735 (gnus-group-remove-mark (pop groups)))))
1736 (gnus-group-position-point))
1738 (defun gnus-group-mark-region (unmark beg end)
1739 "Mark all groups between point and mark.
1740 If UNMARK, remove the mark instead."
1741 (interactive "P\nr")
1742 (let ((num (count-lines beg end)))
1745 (- num (gnus-group-mark-group num unmark)))))
1747 (defun gnus-group-mark-buffer (&optional unmark)
1748 "Mark all groups in the buffer.
1749 If UNMARK, remove the mark instead."
1751 (gnus-group-mark-region unmark (point-min) (point-max)))
1753 (defun gnus-group-mark-regexp (regexp)
1754 "Mark all groups that match some regexp."
1755 (interactive "sMark (regexp): ")
1756 (let ((alist (cdr gnus-newsrc-alist))
1760 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1761 (gnus-group-jump-to-group group)
1762 (gnus-group-set-mark group)))))
1763 (gnus-group-position-point))
1765 (defun gnus-group-remove-mark (group &optional test-marked)
1766 "Remove the process mark from GROUP and move point there.
1767 Return nil if the group isn't displayed."
1768 (if (gnus-group-goto-group group nil test-marked)
1770 (gnus-group-mark-group 1 'unmark t)
1772 (setq gnus-group-marked
1773 (delete group gnus-group-marked))
1776 (defun gnus-group-set-mark (group)
1777 "Set the process mark on GROUP."
1778 (if (gnus-group-goto-group group)
1780 (gnus-group-mark-group 1 nil t))
1781 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1783 (defun gnus-group-universal-argument (arg &optional groups func)
1784 "Perform any command on all groups according to the process/prefix convention."
1786 (if (eq (setq func (or func
1789 (substitute-command-keys
1790 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1792 (gnus-error 1 "Undefined key")
1793 (gnus-group-iterate arg
1795 (command-execute func))))
1796 (gnus-group-position-point))
1798 (defun gnus-group-process-prefix (n)
1799 "Return a list of groups to work on.
1800 Take into consideration N (the prefix) and the list of marked groups."
1803 (setq n (prefix-numeric-value n))
1804 ;; There is a prefix, so we return a list of the N next
1806 (let ((way (if (< n 0) -1 1))
1811 (if (setq group (gnus-group-group-name))
1812 (push group groups))
1814 (gnus-group-next-group way)))
1816 ((and (gnus-region-active-p) (mark))
1817 ;; Work on the region between point and mark.
1818 (let ((max (max (point) (mark)))
1821 (goto-char (min (point) (mark)))
1824 (push (gnus-group-group-name) groups)
1825 (zerop (gnus-group-next-group 1))
1827 (nreverse groups))))
1829 ;; No prefix, but a list of marked articles.
1830 (reverse gnus-group-marked))
1832 ;; Neither marked articles or a prefix, so we return the
1834 (let ((group (gnus-group-group-name)))
1835 (and group (list group))))))
1837 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1838 ;;; imagine why I went through these contortions...
1840 (let ((function (make-symbol "gnus-group-iterate-function"))
1841 (window (make-symbol "gnus-group-iterate-window"))
1842 (groups (make-symbol "gnus-group-iterate-groups"))
1843 (group (make-symbol "gnus-group-iterate-group")))
1845 `(defun gnus-group-iterate (arg ,function)
1846 "Iterate FUNCTION over all process/prefixed groups.
1847 FUNCTION will be called with the group name as the parameter
1848 and with point over the group in question."
1849 (let ((,groups (gnus-group-process-prefix arg))
1850 (,window (selected-window))
1853 (setq ,group (car ,groups)
1854 ,groups (cdr ,groups))
1855 (select-window ,window)
1856 (gnus-group-remove-mark ,group)
1857 (save-selected-window
1859 (funcall ,function ,group)))))))))
1861 (put 'gnus-group-iterate 'lisp-indent-function 1)
1863 ;; Selecting groups.
1865 (defun gnus-group-read-group (&optional all no-article group select-articles)
1866 "Read news in this newsgroup.
1867 If the prefix argument ALL is non-nil, already read articles become
1868 readable. IF ALL is a number, fetch this number of articles. If the
1869 optional argument NO-ARTICLE is non-nil, no article will be
1870 auto-selected upon group entry. If GROUP is non-nil, fetch that
1873 (let ((no-display (eq all 0))
1874 (group (or group (gnus-group-group-name)))
1875 number active marked entry)
1879 (error "No group on current line"))
1880 (setq marked (gnus-info-marks
1881 (nth 2 (setq entry (gnus-group-entry group)))))
1882 ;; This group might be a dead group. In that case we have to get
1883 ;; the number of unread articles from `gnus-active-hashtb'.
1885 (cond ((numberp all) all)
1887 ((setq active (gnus-active group))
1888 (- (1+ (cdr active)) (car active)))))
1889 (gnus-summary-read-group
1890 group (or all (and (numberp number)
1891 (zerop (+ number (gnus-range-length
1892 (cdr (assq 'tick marked)))
1894 (cdr (assq 'dormant marked)))))))
1895 no-article nil no-display nil select-articles)))
1897 (defun gnus-group-select-group (&optional all)
1898 "Select this newsgroup.
1899 No article is selected automatically.
1900 If the group is opened, just switch the summary buffer.
1901 If ALL is non-nil, already read articles become readable.
1902 If ALL is a number, fetch this number of articles."
1904 (when (and (eobp) (not (gnus-group-group-name)))
1906 (gnus-group-read-group all t))
1908 (defun gnus-group-quick-select-group (&optional all)
1909 "Select the current group \"quickly\".
1910 This means that no highlighting or scoring will be performed.
1911 If ALL (the prefix argument) is 0, don't even generate the summary
1914 This might be useful if you want to toggle threading
1915 before entering the group."
1917 (require 'gnus-score)
1919 gnus-score-find-score-files-function
1920 gnus-home-score-file
1921 gnus-apply-kill-hook
1922 gnus-summary-expunge-below)
1923 (gnus-group-read-group all t)))
1925 (defun gnus-group-visible-select-group (&optional all)
1926 "Select the current group without hiding any articles."
1928 (let ((gnus-inhibit-limiting t))
1929 (gnus-group-read-group all t)))
1931 (defun gnus-group-select-group-ephemerally ()
1932 "Select the current group without doing any processing whatsoever.
1933 You will actually be entered into a group that's a copy of
1934 the current group; no changes you make while in this group will
1937 (require 'gnus-score)
1939 gnus-score-find-score-files-function gnus-apply-kill-hook
1940 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1941 gnus-summary-mode-hook gnus-select-group-hook
1942 (group (gnus-group-group-name))
1943 (method (gnus-find-method-for-group group)))
1944 (gnus-group-read-ephemeral-group
1945 (gnus-group-prefixed-name group method) method)))
1948 (defun gnus-fetch-group (group &optional articles)
1949 "Start Gnus if necessary and enter GROUP.
1950 Returns whether the fetching was successful or not."
1951 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1952 (unless (get-buffer gnus-group-buffer)
1954 (gnus-group-read-group articles nil group))
1957 (defun gnus-fetch-group-other-frame (group)
1958 "Pop up a frame and enter GROUP."
1960 (let ((window (get-buffer-window gnus-group-buffer)))
1962 (select-frame (window-frame window)))
1963 ((= (length (frame-list)) 1)
1964 (select-frame (make-frame)))
1967 (gnus-fetch-group group))
1969 (defvar gnus-ephemeral-group-server 0)
1971 (defcustom gnus-large-ephemeral-newsgroup 200
1972 "The number of articles which indicates a large ephemeral newsgroup.
1973 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1975 If the number of articles in a newsgroup is greater than this value,
1976 confirmation is required for selecting the newsgroup. If it is nil, no
1977 confirmation is required."
1978 :group 'gnus-group-select
1979 :type '(choice (const :tag "No limit" nil)
1982 (defcustom gnus-fetch-old-ephemeral-headers nil
1983 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
1985 :type '(choice (const :tag "off" nil)
1988 (sexp :menu-tag "other" t)))
1990 ;; Enter a group that is not in the group buffer. Non-nil is returned
1991 ;; if selection was successful.
1992 (defun gnus-group-read-ephemeral-group (group method &optional activate
1993 quit-config request-only
1996 "Read GROUP from METHOD as an ephemeral group.
1997 If ACTIVATE, request the group first.
1998 If QUIT-CONFIG, use that window configuration when exiting from the
2000 If REQUEST-ONLY, don't actually read the group; just request it.
2001 If SELECT-ARTICLES, only select those articles.
2002 If PARAMETERS, use those as the group parameters.
2004 Return the name of the group if selection was successful."
2007 ;; (gnus-read-group "Group name: ")
2009 "Group: " gnus-active-hashtb
2011 'gnus-group-history)
2012 (gnus-read-method "From method: ")))
2013 ;; Transform the select method into a unique server.
2014 (when (stringp method)
2015 (setq method (gnus-server-to-method method)))
2017 `(,(car method) ,(concat (cadr method) "-ephemeral")
2018 (,(intern (format "%s-address" (car method))) ,(cadr method))
2020 (let ((group (if (gnus-group-foreign-p group) group
2021 (gnus-group-prefixed-name (gnus-group-real-name group)
2026 ,gnus-level-default-subscribed nil nil ,method
2029 (cons 'quit-config quit-config)
2031 (cons gnus-summary-buffer
2032 gnus-current-window-configuration)))
2035 (push method gnus-ephemeral-servers)
2036 (set-buffer gnus-group-buffer)
2037 (unless (gnus-check-server method)
2038 (error "Unable to contact server: %s" (gnus-status-message method)))
2040 (gnus-activate-group group 'scan)
2041 (unless (gnus-request-group group)
2042 (error "Couldn't request group: %s"
2043 (nnheader-get-report (car method)))))
2047 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2048 (gnus-fetch-old-headers
2049 gnus-fetch-old-ephemeral-headers))
2050 (gnus-group-read-group t t group select-articles))
2054 (message "Quit reading the ephemeral group")
2057 (defun gnus-group-jump-to-group (group)
2058 "Jump to newsgroup GROUP."
2060 (list (mm-string-make-unibyte
2062 "Group: " gnus-active-hashtb nil
2063 (gnus-read-active-file-p)
2064 gnus-group-jump-to-group-prompt
2065 'gnus-group-history))))
2067 (when (equal group "")
2068 (error "Empty group name"))
2070 (unless (gnus-ephemeral-group-p group)
2071 ;; Either go to the line in the group buffer...
2072 (unless (gnus-group-goto-group group)
2073 ;; ... or insert the line.
2074 (gnus-group-update-group group)
2075 (gnus-group-goto-group group)))
2076 ;; Adjust cursor point.
2077 (gnus-group-position-point))
2079 (defun gnus-group-goto-group (group &optional far test-marked)
2080 "Goto to newsgroup GROUP.
2081 If FAR, it is likely that the group is not on the current line.
2082 If TEST-MARKED, the line must be marked."
2086 ;; It's quite likely that we are on the right line, so
2087 ;; we check the current line first.
2089 (eq (get-text-property (point) 'gnus-group)
2090 (gnus-intern-safe group gnus-active-hashtb))
2091 (or (not test-marked) (gnus-group-mark-line-p)))
2093 ;; Previous and next line are also likely, so we check them as well.
2097 (and (eq (get-text-property (point) 'gnus-group)
2098 (gnus-intern-safe group gnus-active-hashtb))
2099 (or (not test-marked) (gnus-group-mark-line-p)))))
2105 (and (eq (get-text-property (point) 'gnus-group)
2106 (gnus-intern-safe group gnus-active-hashtb))
2107 (or (not test-marked) (gnus-group-mark-line-p)))))
2111 (goto-char (point-min))
2113 (while (and (not found)
2118 (gnus-intern-safe group gnus-active-hashtb))))
2119 (if (gnus-group-mark-line-p)
2124 ;; Search through the entire buffer.
2127 (point-min) (point-max)
2128 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2130 (defun gnus-group-next-group (n &optional silent)
2131 "Go to next N'th newsgroup.
2132 If N is negative, search backward instead.
2133 Returns the difference between N and the number of skips actually
2136 (gnus-group-next-unread-group n t nil silent))
2138 (defun gnus-group-next-unread-group (n &optional all level silent)
2139 "Go to next N'th unread newsgroup.
2140 If N is negative, search backward instead.
2141 If ALL is non-nil, choose any newsgroup, unread or not.
2142 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2143 such group can be found, the next group with a level higher than
2145 Returns the difference between N and the number of skips actually
2148 (let ((backward (< n 0))
2151 (gnus-group-search-forward
2152 backward (or (not gnus-group-goto-unread) all) level))
2156 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2157 (if level " on this level or higher" "")))
2160 (defun gnus-group-prev-group (n)
2161 "Go to previous N'th newsgroup.
2162 Returns the difference between N and the number of skips actually
2165 (gnus-group-next-unread-group (- n) t))
2167 (defun gnus-group-prev-unread-group (n)
2168 "Go to previous N'th unread newsgroup.
2169 Returns the difference between N and the number of skips actually
2172 (gnus-group-next-unread-group (- n)))
2174 (defun gnus-group-next-unread-group-same-level (n)
2175 "Go to next N'th unread newsgroup on the same level.
2176 If N is negative, search backward instead.
2177 Returns the difference between N and the number of skips actually
2180 (gnus-group-next-unread-group n t (gnus-group-group-level))
2181 (gnus-group-position-point))
2183 (defun gnus-group-prev-unread-group-same-level (n)
2184 "Go to next N'th unread newsgroup on the same level.
2185 Returns the difference between N and the number of skips actually
2188 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2189 (gnus-group-position-point))
2191 (defun gnus-group-best-unread-group (&optional exclude-group)
2192 "Go to the group with the highest level.
2193 If EXCLUDE-GROUP, do not go to that group."
2195 (goto-char (point-min))
2199 (setq unread (get-text-property (point) 'gnus-unread))
2200 (when (and (numberp unread) (> unread 0))
2201 (when (and (get-text-property (point) 'gnus-level)
2202 (< (get-text-property (point) 'gnus-level) best)
2203 (or (not exclude-group)
2204 (not (equal exclude-group (gnus-group-group-name)))))
2205 (setq best (get-text-property (point) 'gnus-level))
2206 (setq best-point (point))))
2209 (goto-char best-point))
2210 (gnus-group-position-point)
2211 (and best-point (gnus-group-group-name))))
2213 (defun gnus-group-first-unread-group ()
2214 "Go to the first group with unread articles."
2217 (let ((opoint (point))
2219 (goto-char (point-min))
2220 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2221 (and (numberp unread) ; Not a topic.
2222 (not (zerop unread))) ; Has unread articles.
2223 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2226 nil)) ; Not success.
2227 (gnus-group-position-point)))
2229 (defun gnus-group-enter-server-mode ()
2230 "Jump to the server buffer."
2232 (gnus-enter-server-buffer))
2234 (defun gnus-group-make-group (name &optional method address args)
2235 "Add a new newsgroup.
2236 The user will be prompted for a NAME, for a select METHOD, and an
2240 (gnus-read-group "Group name: ")
2241 (gnus-read-method "From method: ")))
2243 (when (stringp method)
2244 (setq method (or (gnus-server-to-method method) method)))
2245 (let* ((meth (gnus-method-simplify
2247 (not (gnus-server-equal method gnus-select-method)))
2248 (if address (list (intern method) address)
2250 (nname (if method (gnus-group-prefixed-name name meth) name))
2252 (when (gnus-group-entry nname)
2253 (error "Group %s already exists" nname))
2254 ;; Subscribe to the new group.
2255 (gnus-group-change-level
2256 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2257 gnus-level-default-subscribed gnus-level-killed
2258 (and (gnus-group-group-name)
2259 (gnus-group-entry (gnus-group-group-name)))
2262 (gnus-set-active nname (cons 1 0))
2263 (unless (gnus-ephemeral-group-p name)
2265 (concat "(gnus-group-set-info '"
2266 (gnus-prin1-to-string (cdr info)) ")")))
2268 (gnus-group-insert-group-line-info nname)
2270 (gnus-group-position-point)
2272 ;; Load the back end and try to make the back end create
2273 ;; the group as well.
2274 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2276 gnus-valid-select-methods)
2278 (gnus-check-server meth)
2279 (when (gnus-check-backend-function 'request-create-group nname)
2280 (unless (gnus-request-create-group nname nil args)
2281 (error "Could not create group on server: %s"
2282 (nnheader-get-report backend))))
2285 (defun gnus-group-delete-groups (&optional arg)
2286 "Delete the current group. Only meaningful with editable groups."
2288 (let ((n (length (gnus-group-process-prefix arg))))
2289 (when (gnus-yes-or-no-p
2291 "Delete this 1 group? "
2292 (format "Delete these %d groups? " n)))
2293 (gnus-group-iterate arg
2295 (gnus-group-delete-group group nil t))))))
2297 (defun gnus-group-delete-group (group &optional force no-prompt)
2298 "Delete the current group. Only meaningful with editable groups.
2299 If FORCE (the prefix) is non-nil, all the articles in the group will
2300 be deleted. This is \"deleted\" as in \"removed forever from the face
2301 of the Earth\". There is no undo. The user will be prompted before
2303 Note that you also have to specify FORCE if you want the group to
2304 be removed from the server, even when it's empty."
2306 (list (gnus-group-group-name)
2307 current-prefix-arg))
2309 (error "No group to delete"))
2310 (unless (gnus-check-backend-function 'request-delete-group group)
2311 (error "This back end does not support group deletion"))
2313 (if (and (not no-prompt)
2314 (not (gnus-yes-or-no-p
2316 "Do you really want to delete %s%s? "
2317 group (if force " and all its contents" "")))))
2319 (gnus-message 6 "Deleting group %s..." group)
2320 (if (not (gnus-request-delete-group group force))
2321 (gnus-error 3 "Couldn't delete group %s" group)
2322 (gnus-message 6 "Deleting group %s...done" group)
2323 (gnus-group-goto-group group)
2324 (gnus-group-kill-group 1 t)
2325 (gnus-set-active group nil)
2327 (gnus-group-position-point)))
2329 (defun gnus-group-rename-group (group new-name)
2330 "Rename group from GROUP to NEW-NAME.
2331 When used interactively, GROUP is the group under point
2332 and NEW-NAME will be prompted for."
2335 (gnus-group-group-name)
2337 (unless (gnus-check-backend-function
2338 'request-rename-group (gnus-group-group-name))
2339 (error "This back end does not support renaming groups"))
2340 (gnus-read-group "Rename group to: "
2341 (gnus-group-real-name (gnus-group-group-name))))))
2343 (unless (gnus-check-backend-function 'request-rename-group group)
2344 (error "This back end does not support renaming groups"))
2346 (error "No group to rename"))
2347 (when (equal (gnus-group-real-name group) new-name)
2348 (error "Can't rename to the same name"))
2350 ;; We find the proper prefixed name.
2352 (if (gnus-group-native-p group)
2356 (gnus-group-prefixed-name
2357 (gnus-group-real-name new-name)
2358 (gnus-info-method (gnus-get-info group)))))
2360 (when (gnus-active new-name)
2361 (error "The group %s already exists" new-name))
2363 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2366 (gnus-group-goto-group group)
2367 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2368 (gnus-request-rename-group group new-name))))
2369 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2370 ;; We rename the group internally by killing it...
2371 (gnus-group-kill-group)
2372 ;; ... changing its name ...
2373 (setcar (cdar gnus-list-of-killed-groups) new-name)
2374 ;; ... and then yanking it. Magic!
2375 (gnus-group-yank-group)
2376 (gnus-set-active new-name (gnus-active group))
2377 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2379 (setq gnus-killed-list (delete group gnus-killed-list))
2380 (gnus-set-active group nil)
2381 (gnus-dribble-touch)
2382 (gnus-group-position-point)))
2384 (defun gnus-group-edit-group (group &optional part)
2385 "Edit the group on the current line."
2386 (interactive (list (gnus-group-group-name)))
2387 (let ((part (or part 'info))
2390 (error "No group on current line"))
2391 (unless (setq info (gnus-get-info group))
2392 (error "Killed group; can't be edited"))
2394 (gnus-close-group group))
2396 ;; Find the proper form to edit.
2397 (cond ((eq part 'method)
2398 (or (gnus-info-method info) "native"))
2400 (gnus-info-params info))
2402 ;; The proper documentation.
2404 "Editing the %s for `%s'."
2406 ((eq part 'method) "select method")
2407 ((eq part 'params) "group parameters")
2409 (gnus-group-decoded-name group))
2411 (gnus-group-edit-group-done ',part ,group form)))
2414 (gnus-create-info-command
2417 "(gnus)Select Methods")
2419 "(gnus)Group Parameters")
2421 "(gnus)Group Info"))))))
2423 (defun gnus-group-edit-group-method (group)
2424 "Edit the select method of GROUP."
2425 (interactive (list (gnus-group-group-name)))
2426 (gnus-group-edit-group group 'method))
2428 (defun gnus-group-edit-group-parameters (group)
2429 "Edit the group parameters of GROUP."
2430 (interactive (list (gnus-group-group-name)))
2431 (gnus-group-edit-group group 'params))
2433 (defun gnus-group-edit-group-done (part group form)
2435 (let* ((method (cond ((eq part 'info) (nth 4 form))
2436 ((eq part 'method) form)
2438 (info (cond ((eq part 'info) form)
2439 ((eq part 'method) (gnus-get-info group))
2442 (if (or (not method)
2444 gnus-select-method method))
2445 (gnus-group-real-name (car info))
2446 (gnus-group-prefixed-name
2447 (gnus-group-real-name (car info)) method))
2449 (when (and new-group
2450 (not (equal new-group group)))
2451 (when (gnus-group-goto-group group)
2452 (gnus-group-kill-group 1))
2453 (gnus-activate-group new-group))
2455 (if (not (and info new-group))
2456 (gnus-group-set-info form (or new-group group) part)
2457 (setq info (gnus-copy-sequence info))
2458 (setcar info new-group)
2459 (unless (gnus-server-equal method "native")
2460 (unless (nthcdr 3 info)
2461 (nconc info (list nil nil)))
2462 (unless (nthcdr 4 info)
2463 (nconc info (list nil)))
2464 (gnus-info-set-method info method))
2465 (gnus-group-set-info info))
2466 (gnus-group-update-group (or new-group group))
2467 (gnus-group-position-point)))
2469 (defun gnus-group-make-useful-group (group method)
2470 "Create one of the groups described in `gnus-useful-groups'."
2472 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2474 gnus-useful-groups)))
2475 (list (cadr entry) (caddr entry))))
2476 (setq method (gnus-copy-sequence method))
2478 (while (setq entry (memq (assq 'eval method) method))
2479 (setcar entry (eval (cadar entry)))))
2480 (gnus-group-make-group group method))
2482 (defun gnus-group-make-help-group (&optional noerror)
2483 "Create the Gnus documentation group.
2484 Optional argument NOERROR modifies the behavior of this function when the
2485 group already exists:
2486 - if not given, and error is signaled,
2487 - if t, stay silent,
2488 - if anything else, just print a message."
2490 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2491 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2492 (if (gnus-group-entry name)
2493 (cond ((eq noerror nil)
2494 (error "Documentation group already exists"))
2499 (gnus-message 1 "Documentation group already exists")))
2502 (gnus-message 1 "Couldn't find doc group")
2503 (gnus-group-make-group
2504 (gnus-group-real-name name)
2505 (list 'nndoc "gnus-help"
2506 (list 'nndoc-address file)
2507 (list 'nndoc-article-type 'mbox))))
2509 (gnus-group-position-point))
2511 (defun gnus-group-make-doc-group (file type)
2512 "Create a group that uses a single file as the source."
2514 (list (read-file-name "File name: ")
2515 (and current-prefix-arg 'ask)))
2516 (when (eq type 'ask)
2521 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2523 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2524 ((= char ?b) 'babyl)
2525 ((= char ?d) 'digest)
2526 ((= char ?f) 'forward)
2528 ((= char ?g) 'guess)
2529 (t (setq err (format "%c unknown. " char))
2532 (let* ((file (expand-file-name file))
2533 (name (gnus-generate-new-group-name
2534 (gnus-group-prefixed-name
2535 (file-name-nondirectory file) '(nndoc "")))))
2536 (gnus-group-make-group
2537 (gnus-group-real-name name)
2539 (list 'nndoc-address file)
2540 (list 'nndoc-article-type (or type 'guess))))))
2542 (defvar nnweb-type-definition)
2543 (defvar gnus-group-web-type-history nil)
2544 (defvar gnus-group-web-search-history nil)
2545 (defun gnus-group-make-web-group (&optional solid)
2546 "Create an ephemeral nnweb group.
2547 If SOLID (the prefix), create a solid group."
2551 (if solid (gnus-read-group "Group name: ")
2552 (message-unique-id)))
2553 (default-type (or (car gnus-group-web-type-history)
2554 (symbol-name (caar nnweb-type-definition))))
2558 (format "Search engine type (default %s): " default-type)
2559 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2560 nnweb-type-definition)
2561 nil t nil 'gnus-group-web-type-history)
2566 (cons (or (car gnus-group-web-search-history) "") 0)
2567 'gnus-group-web-search-history))
2569 `(nnweb ,group (nnweb-search ,search)
2570 (nnweb-type ,(intern type))
2571 (nnweb-ephemeral-p t))))
2574 (gnus-pull 'nnweb-ephemeral-p method)
2575 (gnus-group-make-group group method))
2576 (gnus-group-read-ephemeral-group
2578 (cons (current-buffer)
2579 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2582 (defvar nnrss-group-alist)
2583 (defun nnrss-discover-feed (arg))
2584 (defun nnrss-save-server-data (arg)))
2585 (defun gnus-group-make-rss-group (&optional url)
2586 "Given a URL, discover if there is an RSS feed.
2587 If there is, use Gnus to create an nnrss group"
2591 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2592 (let ((feedinfo (nnrss-discover-feed url)))
2594 (let ((title (read-from-minibuffer "Title: "
2597 (desc (read-from-minibuffer "Description: "
2598 (cdr (assoc 'description
2600 (href (cdr (assoc 'href feedinfo))))
2601 (push (list title href desc)
2603 (gnus-group-unsubscribe-group
2604 (concat "nnrss:" title))
2605 (nnrss-save-server-data nil))
2606 (error "No feeds found for %s" url))))
2608 (defvar nnwarchive-type-definition)
2609 (defvar gnus-group-warchive-type-history nil)
2610 (defvar gnus-group-warchive-login-history nil)
2611 (defvar gnus-group-warchive-address-history nil)
2613 (defun gnus-group-make-warchive-group ()
2614 "Create a nnwarchive group."
2616 (require 'nnwarchive)
2617 (let* ((group (gnus-read-group "Group name: "))
2618 (default-type (or (car gnus-group-warchive-type-history)
2619 (symbol-name (caar nnwarchive-type-definition))))
2623 (format "Warchive type (default %s): " default-type)
2624 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2625 nnwarchive-type-definition)
2626 nil t nil 'gnus-group-warchive-type-history)
2628 (address (read-string "Warchive address: "
2629 nil 'gnus-group-warchive-address-history))
2630 (default-login (or (car gnus-group-warchive-login-history)
2635 (format "Warchive login (default %s): " user-mail-address)
2636 default-login 'gnus-group-warchive-login-history)
2639 `(nnwarchive ,address
2640 (nnwarchive-type ,(intern type))
2641 (nnwarchive-login ,login))))
2642 (gnus-group-make-group group method)))
2644 (defun gnus-group-make-archive-group (&optional all)
2645 "Create the (ding) Gnus archive group of the most recent articles.
2646 Given a prefix, create a full group."
2648 (let ((group (gnus-group-prefixed-name
2649 (if all "ding.archives" "ding.recent") '(nndir ""))))
2650 (when (gnus-group-entry group)
2651 (error "Archive group already exists"))
2652 (gnus-group-make-group
2653 (gnus-group-real-name group)
2654 (list 'nndir (if all "hpc" "edu")
2655 (list 'nndir-directory
2656 (if all gnus-group-archive-directory
2657 gnus-group-recent-archive-directory))))
2658 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2660 (defun gnus-group-make-directory-group (dir)
2661 "Create an nndir group.
2662 The user will be prompted for a directory. The contents of this
2663 directory will be used as a newsgroup. The directory should contain
2664 mail messages or news articles in files that have numeric names."
2666 (list (read-file-name "Create group from directory: ")))
2667 (unless (file-exists-p dir)
2668 (error "No such directory"))
2669 (unless (file-directory-p dir)
2670 (error "Not a directory"))
2674 (while (or (not group) (gnus-group-entry group))
2676 (gnus-group-prefixed-name
2677 (expand-file-name ext dir)
2679 (setq ext (format "<%d>" (setq i (1+ i)))))
2680 (gnus-group-make-group
2681 (gnus-group-real-name group)
2682 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2684 (defvar nnkiboze-score-file)
2685 (defun gnus-group-make-kiboze-group (group address scores)
2686 "Create an nnkiboze group.
2687 The user will be prompted for a name, a regexp to match groups, and
2688 score file entries for articles to include in the group."
2691 (read-string "nnkiboze group name: ")
2692 (read-string "Source groups (regexp): ")
2693 (let ((headers (mapcar (lambda (group) (list group))
2694 '("subject" "from" "number" "date" "message-id"
2695 "references" "chars" "lines" "xref"
2696 "followup" "all" "body" "head")))
2697 scores header regexp regexps)
2698 (while (not (equal "" (setq header (completing-read
2699 "Match on header: " headers nil t))))
2701 (while (not (equal "" (setq regexp (read-string
2702 (format "Match on %s (regexp): "
2704 (push (list regexp nil nil 'r) regexps))
2705 (push (cons header regexps) scores))
2707 (gnus-group-make-group group "nnkiboze" address)
2708 (let* ((nnkiboze-current-group group)
2709 (score-file (car (nnkiboze-score-file "")))
2710 (score-dir (file-name-directory score-file)))
2711 (unless (file-exists-p score-dir)
2712 (make-directory score-dir))
2713 (with-temp-file score-file
2714 (let (emacs-lisp-mode-hook)
2715 (pp scores (current-buffer))))))
2717 (defun gnus-group-add-to-virtual (n vgroup)
2718 "Add the current group to a virtual group."
2720 (list current-prefix-arg
2721 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2723 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2724 (error "%s is not an nnvirtual group" vgroup))
2725 (gnus-close-group vgroup)
2726 (let* ((groups (gnus-group-process-prefix n))
2727 (method (gnus-info-method (gnus-get-info vgroup))))
2728 (setcar (cdr method)
2730 (nth 1 method) "\\|"
2733 (gnus-group-remove-mark s)
2734 (concat "\\(^" (regexp-quote s) "$\\)"))
2736 (gnus-group-position-point))
2738 (defun gnus-group-make-empty-virtual (group)
2739 "Create a new, fresh, empty virtual group."
2740 (interactive "sCreate new, empty virtual group: ")
2741 (let* ((method (list 'nnvirtual "^$"))
2742 (pgroup (gnus-group-prefixed-name group method)))
2743 ;; Check whether it exists already.
2744 (when (gnus-group-entry pgroup)
2745 (error "Group %s already exists" pgroup))
2746 ;; Subscribe the new group after the group on the current line.
2747 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2748 (gnus-group-update-group pgroup)
2750 (gnus-group-position-point)))
2752 (defun gnus-group-enter-directory (dir)
2753 "Enter an ephemeral nneething group."
2754 (interactive "DDirectory to read: ")
2755 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2756 (leaf (gnus-group-prefixed-name
2757 (file-name-nondirectory (directory-file-name dir))
2759 (name (gnus-generate-new-group-name leaf)))
2760 (unless (gnus-group-read-ephemeral-group
2762 (cons (current-buffer)
2763 (if (eq major-mode 'gnus-summary-mode)
2765 (error "Couldn't enter %s" dir))))
2768 (autoload 'nnimap-expunge "nnimap")
2769 (autoload 'nnimap-acl-get "nnimap")
2770 (autoload 'nnimap-acl-edit "nnimap"))
2772 (defun gnus-group-nnimap-expunge (group)
2773 "Expunge deleted articles in current nnimap GROUP."
2774 (interactive (list (gnus-group-group-name)))
2775 (let ((mailbox (gnus-group-real-name group)) method)
2777 (error "No group on current line"))
2778 (unless (gnus-get-info group)
2779 (error "Killed group; can't be edited"))
2780 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2781 (error "%s is not an nnimap group" group))
2782 (nnimap-expunge mailbox (cadr method))))
2784 (defun gnus-group-nnimap-edit-acl (group)
2785 "Edit the Access Control List of current nnimap GROUP."
2786 (interactive (list (gnus-group-group-name)))
2787 (let ((mailbox (gnus-group-real-name group)) method acl)
2789 (error "No group on current line"))
2790 (unless (gnus-get-info group)
2791 (error "Killed group; can't be edited"))
2792 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2793 (error "%s is not an nnimap group" group))
2794 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2795 (error "Server does not support ACL's"))
2796 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2798 An access control list is a list of (identifier . rights) elements.
2800 The identifier string specifies the corresponding user. The
2801 identifier \"anyone\" is reserved to refer to the universal identity.
2803 Rights is a string listing a (possibly empty) set of alphanumeric
2804 characters, each character listing a set of operations which is being
2805 controlled. Letters are reserved for ``standard'' rights, listed
2806 below. Digits are reserved for implementation or site defined rights.
2808 l - lookup (mailbox is visible to LIST/LSUB commands)
2809 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2810 SEARCH, COPY from mailbox)
2811 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2812 w - write (STORE flags other than \\SEEN and \\DELETED)
2813 i - insert (perform APPEND, COPY into mailbox)
2814 p - post (send mail to submission address for mailbox,
2815 not enforced by IMAP4 itself)
2816 c - create and delete mailbox (CREATE new sub-mailboxes in any
2817 implementation-defined hierarchy, RENAME or DELETE mailbox)
2818 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2819 a - administer (perform SETACL)" group)
2822 ,mailbox ',method ',acl form)))))
2824 ;; Group sorting commands
2825 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2827 (defun gnus-group-sort-groups (func &optional reverse)
2828 "Sort the group buffer according to FUNC.
2829 When used interactively, the sorting function used will be
2830 determined by the `gnus-group-sort-function' variable.
2831 If REVERSE (the prefix), reverse the sorting order."
2832 (interactive (list gnus-group-sort-function current-prefix-arg))
2833 (funcall gnus-group-sort-alist-function
2834 (gnus-make-sort-function func) reverse)
2835 (gnus-group-unmark-all-groups)
2836 (gnus-group-list-groups)
2837 (gnus-dribble-touch))
2839 (defun gnus-group-sort-flat (func reverse)
2840 ;; We peel off the dummy group from the alist.
2842 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2843 (pop gnus-newsrc-alist))
2845 (setq gnus-newsrc-alist
2846 (sort gnus-newsrc-alist func))
2848 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2849 ;; Regenerate the hash table.
2850 (gnus-make-hashtable-from-newsrc-alist)))
2852 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2853 "Sort the group buffer alphabetically by group name.
2854 If REVERSE, sort in reverse order."
2856 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2858 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2859 "Sort the group buffer alphabetically by real (unprefixed) group name.
2860 If REVERSE, sort in reverse order."
2862 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2864 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2865 "Sort the group buffer by number of unread articles.
2866 If REVERSE, sort in reverse order."
2868 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2870 (defun gnus-group-sort-groups-by-level (&optional reverse)
2871 "Sort the group buffer by group level.
2872 If REVERSE, sort in reverse order."
2874 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2876 (defun gnus-group-sort-groups-by-score (&optional reverse)
2877 "Sort the group buffer by group score.
2878 If REVERSE, sort in reverse order."
2880 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2882 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2883 "Sort the group buffer by group rank.
2884 If REVERSE, sort in reverse order."
2886 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2888 (defun gnus-group-sort-groups-by-method (&optional reverse)
2889 "Sort the group buffer alphabetically by back end name.
2890 If REVERSE, sort in reverse order."
2892 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2894 (defun gnus-group-sort-groups-by-server (&optional reverse)
2895 "Sort the group buffer alphabetically by server name.
2896 If REVERSE, sort in reverse order."
2898 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2900 ;;; Selected group sorting.
2902 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2903 "Sort the process/prefixed groups."
2904 (interactive (list current-prefix-arg gnus-group-sort-function))
2905 (let ((groups (gnus-group-process-prefix n)))
2906 (funcall gnus-group-sort-selected-function
2907 groups (gnus-make-sort-function func) reverse)
2908 (gnus-group-unmark-all-groups)
2909 (gnus-group-list-groups)
2910 (gnus-dribble-touch)))
2912 (defun gnus-group-sort-selected-flat (groups func reverse)
2913 (let (entries infos)
2914 ;; First find all the group entries for these groups.
2916 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2918 ;; Then sort the infos.
2922 (lambda (entry) (car entry))
2923 (setq entries (nreverse entries)))
2926 (setq infos (nreverse infos)))
2927 ;; Go through all the infos and replace the old entries
2928 ;; with the new infos.
2930 (setcar (car entries) (pop infos))
2932 ;; Update the hashtable.
2933 (gnus-make-hashtable-from-newsrc-alist)))
2935 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2936 "Sort the group buffer alphabetically by group name.
2937 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2938 sort in reverse order."
2939 (interactive (gnus-interactive "P\ny"))
2940 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2942 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2943 "Sort the group buffer alphabetically by real group name.
2944 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2945 sort in reverse order."
2946 (interactive (gnus-interactive "P\ny"))
2947 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2949 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2950 "Sort the group buffer by number of unread articles.
2951 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2952 sort in reverse order."
2953 (interactive (gnus-interactive "P\ny"))
2954 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2956 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2957 "Sort the group buffer by group level.
2958 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2959 sort in reverse order."
2960 (interactive (gnus-interactive "P\ny"))
2961 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2963 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2964 "Sort the group buffer by group score.
2965 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2966 sort in reverse order."
2967 (interactive (gnus-interactive "P\ny"))
2968 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2970 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2971 "Sort the group buffer by group rank.
2972 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2973 sort in reverse order."
2974 (interactive (gnus-interactive "P\ny"))
2975 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2977 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2978 "Sort the group buffer alphabetically by back end name.
2979 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2980 sort in reverse order."
2981 (interactive (gnus-interactive "P\ny"))
2982 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2984 ;;; Sorting predicates.
2986 (defun gnus-group-sort-by-alphabet (info1 info2)
2987 "Sort alphabetically."
2988 (string< (gnus-info-group info1) (gnus-info-group info2)))
2990 (defun gnus-group-sort-by-real-name (info1 info2)
2991 "Sort alphabetically on real (unprefixed) names."
2992 (string< (gnus-group-real-name (gnus-info-group info1))
2993 (gnus-group-real-name (gnus-info-group info2))))
2995 (defun gnus-group-sort-by-unread (info1 info2)
2996 "Sort by number of unread articles."
2997 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
2998 (n2 (gnus-group-unread (gnus-info-group info1))))
2999 (< (or (and (numberp n1) n1) 0)
3000 (or (and (numberp n2) n2) 0))))
3002 (defun gnus-group-sort-by-level (info1 info2)
3004 (< (gnus-info-level info1) (gnus-info-level info2)))
3006 (defun gnus-group-sort-by-method (info1 info2)
3007 "Sort alphabetically by back end name."
3008 (string< (car (gnus-find-method-for-group
3009 (gnus-info-group info1) info1))
3010 (car (gnus-find-method-for-group
3011 (gnus-info-group info2) info2))))
3013 (defun gnus-group-sort-by-server (info1 info2)
3014 "Sort alphabetically by server name."
3015 (string< (gnus-method-to-full-server-name
3016 (gnus-find-method-for-group
3017 (gnus-info-group info1) info1))
3018 (gnus-method-to-full-server-name
3019 (gnus-find-method-for-group
3020 (gnus-info-group info2) info2))))
3022 (defun gnus-group-sort-by-score (info1 info2)
3023 "Sort by group score."
3024 (> (gnus-info-score info1) (gnus-info-score info2)))
3026 (defun gnus-group-sort-by-rank (info1 info2)
3027 "Sort by level and score."
3028 (let ((level1 (gnus-info-level info1))
3029 (level2 (gnus-info-level info2)))
3030 (or (< level1 level2)
3031 (and (= level1 level2)
3032 (> (gnus-info-score info1) (gnus-info-score info2))))))
3036 (defun gnus-group-clear-data (&optional arg)
3037 "Clear all marks and read ranges from the current group."
3039 (gnus-group-iterate arg
3042 (gnus-info-clear-data (setq info (gnus-get-info group)))
3043 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3044 (when (gnus-group-goto-group group)
3045 (gnus-group-update-group-line))))))
3047 (defun gnus-group-clear-data-on-native-groups ()
3048 "Clear all marks and read ranges from all native groups."
3050 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3051 (let ((alist (cdr gnus-newsrc-alist))
3053 (while (setq info (pop alist))
3054 (when (gnus-group-native-p (gnus-info-group info))
3055 (gnus-info-clear-data info)))
3056 (gnus-get-unread-articles)
3057 (gnus-dribble-touch)
3058 (when (gnus-y-or-n-p
3059 "Move the cache away to avoid problems in the future? ")
3060 (call-interactively 'gnus-cache-move-cache)))))
3062 (defun gnus-info-clear-data (info)
3063 "Clear all marks and read ranges from INFO."
3064 (let ((group (gnus-info-group info))
3066 (dolist (el (gnus-info-marks info))
3067 (push `(,(cdr el) add (,(car el))) action))
3068 (push `(,(gnus-info-read info) add (read)) action)
3071 (gnus-request-set-mark ,group ',action)
3072 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3073 (gnus-info-set-read ',info ',(gnus-info-read info))
3074 (when (gnus-group-goto-group ,group)
3075 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3076 (gnus-group-update-group-line))))
3077 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3079 (gnus-request-set-mark group action)
3080 (gnus-info-set-read info nil)
3081 (when (gnus-info-marks info)
3082 (gnus-info-set-marks info nil))))
3084 ;; Group catching up.
3086 (defun gnus-group-catchup-current (&optional n all)
3087 "Mark all unread articles in the current newsgroup as read.
3088 If prefix argument N is numeric, the next N newsgroups will be
3089 caught up. If ALL is non-nil, marked articles will also be marked as
3090 read. Cross references (Xref: header) of articles are ignored.
3091 The number of newsgroups that this function was unable to catch
3094 (let ((groups (gnus-group-process-prefix n))
3097 (unless groups (error "No groups selected"))
3099 (or (not gnus-interactive-catchup) ;Without confirmation?
3104 "Do you really want to mark all articles in %s as read? "
3105 "Mark all unread articles in %s as read? ")
3106 (if (= (length groups) 1)
3108 (format "these %d groups" (length groups)))))))
3110 (while (setq group (pop groups))
3111 (gnus-group-remove-mark group)
3112 ;; Virtual groups have to be given special treatment.
3113 (let ((method (gnus-find-method-for-group group)))
3114 (when (eq 'nnvirtual (car method))
3115 (nnvirtual-catchup-group
3116 (gnus-group-real-name group) (nth 1 method) all)))
3117 (if (>= (gnus-group-level group) gnus-level-zombie)
3118 (gnus-message 2 "Dead groups can't be caught up")
3120 (gnus-group-goto-group group)
3121 (gnus-group-catchup group all))
3122 (gnus-group-update-group-line)
3123 (setq ret (1+ ret)))))
3124 (gnus-group-next-unread-group 1)
3127 (defun gnus-group-catchup-current-all (&optional n)
3128 "Mark all articles in current newsgroup as read.
3129 Cross references (Xref: header) of articles are ignored."
3131 (gnus-group-catchup-current n 'all))
3133 (defun gnus-group-catchup (group &optional all)
3134 "Mark all articles in GROUP as read.
3135 If ALL is non-nil, all articles are marked as read.
3136 The return value is the number of articles that were marked as read,
3137 or nil if no action could be taken."
3138 (let* ((entry (gnus-group-entry group))
3140 (marks (gnus-info-marks (nth 2 entry)))
3141 (unread (gnus-sequence-of-unread-articles group)))
3142 ;; Remove entries for this group.
3143 (nnmail-purge-split-history (gnus-group-real-name group))
3144 ;; Do the updating only if the newsgroup isn't killed.
3145 (if (not (numberp (car entry)))
3146 (gnus-message 1 "Can't catch up %s; non-active group" group)
3147 (gnus-update-read-articles group nil)
3149 ;; Nix out the lists of marks and dormants.
3150 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3152 (list (cdr (assq 'dormant marks))
3154 (setq unread (gnus-range-add (gnus-range-add
3155 unread (cdr (assq 'dormant marks)))
3156 (cdr (assq 'tick marks))))
3157 (gnus-add-marked-articles group 'tick nil nil 'force)
3158 (gnus-add-marked-articles group 'dormant nil nil 'force))
3159 ;; Do auto-expirable marks if that's required.
3160 (when (gnus-group-auto-expirable-p group)
3161 (gnus-range-map (lambda (article)
3162 (gnus-add-marked-articles group 'expire (list article))
3163 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3165 (let ((gnus-newsgroup-name group))
3166 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3169 (defun gnus-group-expire-articles (&optional n)
3170 "Expire all expirable articles in the current newsgroup.
3171 Uses the process/prefix convention."
3173 (let ((groups (gnus-group-process-prefix n))
3176 (error "No groups to expire"))
3177 (while (setq group (pop groups))
3178 (gnus-group-remove-mark group)
3179 (gnus-group-expire-articles-1 group)
3180 (gnus-dribble-touch)
3181 (gnus-group-position-point))))
3183 (defun gnus-group-expire-articles-1 (group)
3184 (when (gnus-check-backend-function 'request-expire-articles group)
3185 (gnus-message 6 "Expiring articles in %s..." group)
3186 (let* ((info (gnus-get-info group))
3187 (expirable (if (gnus-group-total-expirable-p group)
3188 (cons nil (gnus-list-of-read-articles group))
3189 (assq 'expire (gnus-info-marks info))))
3190 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3191 (nnmail-expiry-target
3192 (or (gnus-group-find-parameter group 'expiry-target)
3193 nnmail-expiry-target)))
3195 (gnus-check-group group)
3198 (gnus-compress-sequence
3200 ;; We set the expiry variables to the group
3202 (let ((nnmail-expiry-wait-function nil)
3203 (nnmail-expiry-wait expiry-wait))
3204 (gnus-request-expire-articles
3205 (gnus-uncompress-sequence (cdr expirable)) group))
3206 ;; Just expire using the normal expiry values.
3207 (gnus-request-expire-articles
3208 (gnus-uncompress-sequence (cdr expirable)) group))))
3209 (gnus-close-group group))
3210 (gnus-message 6 "Expiring articles in %s...done" group)
3211 ;; Return the list of un-expired articles.
3214 (defun gnus-group-expire-all-groups ()
3215 "Expire all expirable articles in all newsgroups."
3218 (gnus-message 5 "Expiring...")
3219 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3220 (cdr gnus-newsrc-alist))))
3221 (gnus-group-expire-articles nil)))
3222 (gnus-group-position-point)
3223 (gnus-message 5 "Expiring...done"))
3225 (defun gnus-group-set-current-level (n level)
3226 "Set the level of the next N groups to LEVEL."
3231 (unless (gnus-group-process-prefix current-prefix-arg)
3232 (error "No group on the current line"))
3234 (let ((s (read-string
3235 (format "Level (default %s): "
3236 (or (gnus-group-group-level)
3237 gnus-level-default-subscribed)))))
3238 (if (string-match "^\\s-*$" s)
3239 (int-to-string (or (gnus-group-group-level)
3240 gnus-level-default-subscribed))
3242 (unless (and (>= level 1) (<= level gnus-level-killed))
3243 (error "Invalid level: %d" level))
3244 (let ((groups (gnus-group-process-prefix n))
3246 (while (setq group (pop groups))
3247 (gnus-group-remove-mark group)
3248 (gnus-message 6 "Changed level of %s from %d to %d"
3249 group (or (gnus-group-group-level) gnus-level-killed)
3251 (gnus-group-change-level
3252 group level (or (gnus-group-group-level) gnus-level-killed))
3253 (gnus-group-update-group-line)))
3254 (gnus-group-position-point))
3256 (defun gnus-group-unsubscribe (&optional n)
3257 "Unsubscribe the current group."
3259 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3261 (defun gnus-group-subscribe (&optional n)
3262 "Subscribe the current group."
3264 (gnus-group-unsubscribe-current-group n 'subscribe))
3266 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3267 "Toggle subscription of the current group.
3268 If given numerical prefix, toggle the N next groups."
3270 (dolist (group (gnus-group-process-prefix n))
3271 (gnus-group-remove-mark group)
3272 (gnus-group-unsubscribe-group
3275 ((eq do-sub 'unsubscribe)
3276 gnus-level-default-unsubscribed)
3277 ((eq do-sub 'subscribe)
3278 gnus-level-default-subscribed)
3279 ((<= (gnus-group-group-level) gnus-level-subscribed)
3280 gnus-level-default-unsubscribed)
3282 gnus-level-default-subscribed))
3284 (gnus-group-update-group-line))
3285 (gnus-group-next-group 1))
3287 (defun gnus-group-unsubscribe-group (group &optional level silent)
3288 "Toggle subscription to GROUP.
3289 Killed newsgroups are subscribed. If SILENT, don't try to update the
3292 (list (completing-read
3293 "Group: " gnus-active-hashtb nil
3294 (gnus-read-active-file-p)
3296 'gnus-group-history)))
3297 (let ((newsrc (gnus-group-entry group)))
3299 ((string-match "^[ \t]*$" group)
3300 (error "Empty group name"))
3302 ;; Toggle subscription flag.
3303 (gnus-group-change-level
3304 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3305 gnus-level-subscribed)
3306 (1+ gnus-level-subscribed)
3307 gnus-level-default-subscribed)))
3309 (gnus-group-update-group group)))
3310 ((and (stringp group)
3311 (or (not (gnus-read-active-file-p))
3312 (gnus-active group)))
3313 ;; Add new newsgroup.
3314 (gnus-group-change-level
3316 (if level level gnus-level-default-subscribed)
3317 (or (and (member group gnus-zombie-list)
3320 (when (gnus-group-group-name)
3321 (gnus-group-entry (gnus-group-group-name))))
3323 (gnus-group-update-group group)))
3324 (t (error "No such newsgroup: %s" group)))
3325 (gnus-group-position-point)))
3327 (defun gnus-group-transpose-groups (n)
3328 "Move the current newsgroup up N places.
3329 If given a negative prefix, move down instead. The difference between
3330 N and the number of steps taken is returned."
3332 (unless (gnus-group-group-name)
3333 (error "No group on current line"))
3334 (gnus-group-kill-group 1)
3336 (forward-line (- n))
3337 (gnus-group-yank-group)
3338 (gnus-group-position-point)))
3340 (defun gnus-group-kill-all-zombies (&optional dummy)
3341 "Kill all zombie newsgroups.
3342 The optional DUMMY should always be nil."
3343 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3345 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3346 (setq gnus-zombie-list nil)
3347 (gnus-dribble-touch)
3348 (gnus-group-list-groups)))
3350 (defun gnus-group-kill-region (begin end)
3351 "Kill newsgroups in current region (excluding current point).
3352 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3365 (beginning-of-line) ;Important when LINES < 1
3366 (gnus-group-kill-group lines)))
3368 (defun gnus-group-kill-group (&optional n discard)
3369 "Kill the next N groups.
3370 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3371 However, only groups that were alive can be yanked; already killed
3372 groups or zombie groups can't be yanked.
3373 The return value is the name of the group that was killed, or a list
3376 (let ((buffer-read-only nil)
3377 (groups (gnus-group-process-prefix n))
3378 group entry level out)
3379 (if (< (length groups) 10)
3380 ;; This is faster when there are few groups.
3382 (push (setq group (pop groups)) out)
3383 (gnus-group-remove-mark group)
3384 (setq level (gnus-group-group-level))
3386 (when (and (not discard)
3387 (setq entry (gnus-group-entry group)))
3390 (gnus-group-goto-group ,(gnus-group-group-name))
3391 (gnus-group-yank-group)))
3392 (push (cons (car entry) (nth 2 entry))
3393 gnus-list-of-killed-groups))
3394 (gnus-group-change-level
3395 (if entry entry group) gnus-level-killed (if entry nil level))
3396 (message "Killed group %s" group))
3397 ;; If there are lots and lots of groups to be killed, we use
3398 ;; this thing instead.
3399 (dolist (group (nreverse groups))
3400 (gnus-group-remove-mark group)
3402 (push group gnus-killed-list)
3403 (setq gnus-newsrc-alist
3404 (delq (assoc group gnus-newsrc-alist)
3406 (when gnus-group-change-level-function
3407 (funcall gnus-group-change-level-function
3408 group gnus-level-killed 3))
3410 ((setq entry (gnus-group-entry group))
3411 (push (cons (car entry) (nth 2 entry))
3412 gnus-list-of-killed-groups)
3413 (setcdr (cdr entry) (cdddr entry)))
3414 ((member group gnus-zombie-list)
3415 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3416 ;; There may be more than one instance displayed.
3417 (while (gnus-group-goto-group group)
3418 (gnus-delete-line)))
3419 (gnus-make-hashtable-from-newsrc-alist))
3421 (gnus-group-position-point)
3422 (if (< (length out) 2) (car out) (nreverse out))))
3424 (defun gnus-group-yank-group (&optional arg)
3425 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3426 The numeric ARG specifies how many newsgroups are to be yanked. The
3427 name of the newsgroup yanked is returned, or (if several groups are
3428 yanked) a list of yanked groups is returned."
3430 (setq arg (or arg 1))
3431 (let (info group prev out)
3432 (while (>= (decf arg) 0)
3433 (when (not (setq info (pop gnus-list-of-killed-groups)))
3434 (error "No more newsgroups to yank"))
3435 (push (setq group (nth 1 info)) out)
3436 ;; Find which newsgroup to insert this one before - search
3437 ;; backward until something suitable is found. If there are no
3438 ;; other newsgroups in this buffer, just make this newsgroup the
3440 (setq prev (gnus-group-group-name))
3441 (gnus-group-change-level
3442 info (gnus-info-level (cdr info)) gnus-level-killed
3443 (and prev (gnus-group-entry prev))
3445 (gnus-group-insert-group-line-info group)
3447 `(when (gnus-group-goto-group ,group)
3448 (gnus-group-kill-group 1))))
3450 (gnus-group-position-point)
3451 (if (< (length out) 2) (car out) (nreverse out))))
3453 (defun gnus-group-kill-level (level)
3454 "Kill all groups that is on a certain LEVEL."
3455 (interactive "nKill all groups on level: ")
3457 ((= level gnus-level-zombie)
3458 (setq gnus-killed-list
3459 (nconc gnus-zombie-list gnus-killed-list))
3460 (setq gnus-zombie-list nil))
3461 ((and (< level gnus-level-zombie)
3463 (or gnus-expert-user
3466 "Do you really want to kill all groups on level %d? "
3468 (let* ((prev gnus-newsrc-alist)
3471 (if (= (gnus-info-level (car alist)) level)
3473 (push (gnus-info-group (car alist)) gnus-killed-list)
3474 (setcdr prev (cdr alist)))
3476 (setq alist (cdr alist)))
3477 (gnus-make-hashtable-from-newsrc-alist)
3478 (gnus-group-list-groups)))
3480 (error "Can't kill; invalid level: %d" level))))
3482 (defun gnus-group-list-all-groups (&optional arg)
3483 "List all newsgroups with level ARG or lower.
3484 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3485 unsubscribed groups."
3487 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3489 ;; Redefine this to list ALL killed groups if prefix arg used.
3490 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3491 (defun gnus-group-list-killed (&optional arg)
3492 "List all killed newsgroups in the group buffer.
3493 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3494 entail asking the server for the groups."
3496 ;; Find all possible killed newsgroups if arg.
3498 (gnus-get-killed-groups))
3499 (if (not gnus-killed-list)
3500 (gnus-message 6 "No killed groups")
3501 (let (gnus-group-list-mode)
3502 (funcall gnus-group-prepare-function
3503 gnus-level-killed t gnus-level-killed))
3504 (goto-char (point-min)))
3505 (gnus-group-position-point))
3507 (defun gnus-group-list-zombies ()
3508 "List all zombie newsgroups in the group buffer."
3510 (if (not gnus-zombie-list)
3511 (gnus-message 6 "No zombie groups")
3512 (let (gnus-group-list-mode)
3513 (funcall gnus-group-prepare-function
3514 gnus-level-zombie t gnus-level-zombie))
3515 (goto-char (point-min)))
3516 (gnus-group-position-point))
3518 (defun gnus-group-list-active ()
3519 "List all groups that are available from the server(s)."
3521 ;; First we make sure that we have really read the active file.
3522 (unless (gnus-read-active-file-p)
3523 (let ((gnus-read-active-file t)
3524 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3525 (gnus-read-active-file)))
3526 ;; Find all groups and sort them.
3534 (push (symbol-name sym) list)))
3538 (buffer-read-only nil)
3542 (setq group (pop groups))
3543 (gnus-add-text-properties
3544 (point) (prog1 (1+ (point))
3546 (gnus-group-decoded-name group)
3548 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3550 'gnus-level (inline (gnus-group-level group)))))
3551 (goto-char (point-min))))
3553 (defun gnus-activate-all-groups (level)
3554 "Activate absolutely all groups."
3555 (interactive (list gnus-level-unsubscribed))
3556 (let ((gnus-activate-level level)
3557 (gnus-activate-foreign-newsgroups level))
3558 (gnus-group-get-new-news)))
3560 (defun gnus-group-get-new-news (&optional arg)
3561 "Get newly arrived articles.
3562 If ARG is a number, it specifies which levels you are interested in
3563 re-scanning. If ARG is non-nil and not a number, this will force
3564 \"hard\" re-reading of the active files from all servers."
3567 (let ((gnus-inhibit-demon t)
3568 ;; Binding this variable will inhibit multiple fetchings
3569 ;; of the same mail source.
3570 (nnmail-fetched-sources (list t)))
3571 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3572 (gnus-run-hooks 'gnus-get-new-news-hook)
3574 ;; Read any slave files.
3576 (gnus-master-read-slave-newsrc))
3578 ;; We might read in new NoCeM messages here.
3579 (when (and gnus-use-nocem
3581 (gnus-nocem-scan-groups))
3582 ;; If ARG is not a number, then we read the active file.
3583 (when (and arg (not (numberp arg)))
3584 (let ((gnus-read-active-file t))
3585 (gnus-read-active-file))
3588 ;; If the user wants it, we scan for new groups.
3589 (when (eq gnus-check-new-newsgroups 'always)
3590 (gnus-find-new-newsgroups)))
3592 (setq arg (gnus-group-default-level arg t))
3593 (if (and gnus-read-active-file (not arg))
3595 (gnus-read-active-file)
3596 (gnus-get-unread-articles arg))
3597 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3598 (gnus-get-unread-articles arg)))
3599 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3600 (gnus-group-list-groups (and (numberp arg)
3601 (max (car gnus-group-list-mode) arg)))))
3603 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3604 "Check for newly arrived news in the current group (and the N-1 next groups).
3605 The difference between N and the number of newsgroup checked is returned.
3606 If N is negative, this group and the N-1 previous groups will be checked."
3608 (let* ((groups (gnus-group-process-prefix n))
3609 (ret (if (numberp n) (- n (length groups)) 0))
3613 (gnus-inhibit-demon t)
3614 ;; Binding this variable will inhibit multiple fetchings
3615 ;; of the same mail source.
3616 (nnmail-fetched-sources (list t)))
3617 (gnus-run-hooks 'gnus-get-new-news-hook)
3618 (while (setq group (pop groups))
3619 (gnus-group-remove-mark group)
3620 ;; Bypass any previous denials from the server.
3621 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3622 (if (gnus-activate-group group (if dont-scan nil 'scan))
3624 (gnus-get-unread-articles-in-group
3625 (gnus-get-info group) (gnus-active group) t)
3626 (unless (gnus-virtual-group-p group)
3627 (gnus-close-group group))
3629 (gnus-agent-save-group-info
3630 method (gnus-group-real-name group) (gnus-active group)))
3631 (gnus-group-update-group group))
3632 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3634 (gnus-error 3 "Server denied access")
3635 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3638 (when gnus-goto-next-group-when-activating
3639 (gnus-group-next-unread-group 1 t))
3640 (gnus-summary-position-point)
3643 (defun gnus-group-fetch-faq (group &optional faq-dir)
3644 "Fetch the FAQ for the current group.
3645 If given a prefix argument, prompt for the FAQ dir
3649 (gnus-group-group-name)
3650 (when current-prefix-arg
3652 "FAQ dir: " (and (listp gnus-group-faq-directory)
3654 gnus-group-faq-directory))))))
3656 (error "No group name given"))
3657 (let ((dirs (or faq-dir gnus-group-faq-directory))
3659 (unless (listp dirs)
3660 (setq dirs (list dirs)))
3661 (while (and (not found)
3662 (setq dir (pop dirs)))
3663 (let ((name (gnus-group-real-name group)))
3664 (setq file (expand-file-name name dir)))
3665 (if (not (file-exists-p file))
3666 (gnus-message 1 "No such file: %s" file)
3667 (let ((enable-local-variables nil))
3671 (defun gnus-group-fetch-charter (group)
3672 "Fetch the charter for the current group.
3673 If given a prefix argument, prompt for a group."
3675 (list (or (when current-prefix-arg
3676 (completing-read "Group: " gnus-active-hashtb))
3677 (gnus-group-group-name)
3678 gnus-newsgroup-name)))
3680 (error "No group name given"))
3682 (condition-case nil (require 'url-http) (error nil))
3683 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3685 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3686 (setq hierarchy (match-string 1 name))
3687 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3688 (if (fboundp 'url-http-file-exists-p)
3689 (url-http-file-exists-p (eval url))
3691 (browse-url (eval url))
3692 (setq url (concat "http://" hierarchy
3693 ".news-admin.org/charters/" name))
3694 (if (and (fboundp 'url-http-file-exists-p)
3695 (url-http-file-exists-p url))
3697 (gnus-group-fetch-control group))))))
3699 (defun gnus-group-fetch-control (group)
3700 "Fetch the archived control messages for the current group.
3701 If given a prefix argument, prompt for a group."
3703 (list (or (when current-prefix-arg
3704 (completing-read "Group: " gnus-active-hashtb))
3705 (gnus-group-group-name)
3706 gnus-newsgroup-name)))
3708 (error "No group name given"))
3709 (let ((name (gnus-group-real-name group))
3711 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3712 (setq hierarchy (match-string 1 name))
3713 (if gnus-group-fetch-control-use-browse-url
3714 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3715 hierarchy "/" name ".gz"))
3716 (let ((enable-local-variables nil))
3717 (gnus-group-read-ephemeral-group
3719 `(nndoc ,group (nndoc-address
3720 ,(find-file-noselect
3721 (concat "/ftp@ftp.isc.org:/usenet/control/"
3722 hierarchy "/" name ".gz")))
3723 (nndoc-article-type mbox)) t nil nil))))))
3725 (defun gnus-group-describe-group (force &optional group)
3726 "Display a description of the current newsgroup."
3727 (interactive (list current-prefix-arg (gnus-group-group-name)))
3728 (let* ((method (gnus-find-method-for-group group))
3729 (mname (gnus-group-prefixed-name "" method))
3732 gnus-description-hashtb)
3733 (gnus-sethash mname nil gnus-description-hashtb))
3735 (error "No group name given"))
3736 (when (or (and gnus-description-hashtb
3737 ;; We check whether this group's method has been
3738 ;; queried for a description file.
3739 (gnus-gethash mname gnus-description-hashtb))
3740 (setq desc (gnus-group-get-description group))
3741 (gnus-read-descriptions-file method))
3743 (or desc (gnus-gethash group gnus-description-hashtb)
3744 "No description available")))))
3746 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3747 (defun gnus-group-describe-all-groups (&optional force)
3748 "Pop up a buffer with descriptions of all newsgroups."
3751 (setq gnus-description-hashtb nil))
3752 (when (not (or gnus-description-hashtb
3753 (gnus-read-all-descriptions-files)))
3754 (error "Couldn't request descriptions file"))
3755 (let ((buffer-read-only nil)
3761 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3762 (insert (format " *: %-20s %s\n"
3763 (gnus-group-name-decode
3764 (symbol-name group) charset)
3765 (gnus-group-name-decode
3766 (symbol-value group) charset))))
3767 (gnus-add-text-properties
3768 b (1+ b) (list 'gnus-group group
3769 'gnus-unread t 'gnus-marked nil
3770 'gnus-level (1+ gnus-level-subscribed))))
3771 gnus-description-hashtb)
3772 (goto-char (point-min))
3773 (gnus-group-position-point)))
3775 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3776 (defun gnus-group-apropos (regexp &optional search-description)
3777 "List all newsgroups that have names that match a regexp."
3778 (interactive "sGnus apropos (regexp): ")
3780 (obuf (current-buffer))
3782 ;; Go through all newsgroups that are known to Gnus.
3785 (and (symbol-name group)
3786 (string-match regexp (symbol-name group))
3787 (symbol-value group)
3788 (push (symbol-name group) groups)))
3790 ;; Also go through all descriptions that are known to Gnus.
3791 (when search-description
3794 (and (string-match regexp (symbol-value group))
3795 (push (symbol-name group) groups)))
3796 gnus-description-hashtb))
3798 (gnus-message 3 "No groups matched \"%s\"." regexp)
3799 ;; Print out all the groups.
3801 (pop-to-buffer "*Gnus Help*")
3802 (buffer-disable-undo)
3804 (setq groups (sort groups 'string<))
3806 ;; Groups may be entered twice into the list of groups.
3807 (when (not (string= (car groups) prev))
3808 (setq prev (car groups))
3809 (let ((charset (gnus-group-name-charset nil prev)))
3810 (insert (gnus-group-name-decode prev charset) "\n")
3811 (when (and gnus-description-hashtb
3812 (setq des (gnus-gethash (car groups)
3813 gnus-description-hashtb)))
3814 (insert " " (gnus-group-name-decode des charset) "\n"))))
3815 (setq groups (cdr groups)))
3816 (goto-char (point-min))))
3817 (pop-to-buffer obuf)))
3819 (defun gnus-group-description-apropos (regexp)
3820 "List all newsgroups that have names or descriptions that match REGEXP."
3821 (interactive "sGnus description apropos (regexp): ")
3822 (when (not (or gnus-description-hashtb
3823 (gnus-read-all-descriptions-files)))
3824 (error "Couldn't request descriptions file"))
3825 (gnus-group-apropos regexp t))
3827 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3828 (defun gnus-group-list-matching (level regexp &optional all lowest)
3829 "List all groups with unread articles that match REGEXP.
3830 If the prefix LEVEL is non-nil, it should be a number that says which
3831 level to cut off listing groups.
3832 If ALL, also list groups with no unread articles.
3833 If LOWEST, don't list groups with level lower than LOWEST.
3835 This command may read the active file."
3836 (interactive "P\nsList newsgroups matching: ")
3837 ;; First make sure active file has been read.
3839 (> (prefix-numeric-value level) gnus-level-killed))
3840 (gnus-get-killed-groups))
3841 (funcall gnus-group-prepare-function
3842 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3843 (goto-char (point-min))
3844 (gnus-group-position-point))
3846 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3847 "List all groups that match REGEXP.
3848 If the prefix LEVEL is non-nil, it should be a number that says which
3849 level to cut off listing groups.
3850 If LOWEST, don't list groups with level lower than LOWEST."
3851 (interactive "P\nsList newsgroups matching: ")
3853 (setq level (prefix-numeric-value level)))
3854 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3856 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3857 (defun gnus-group-save-newsrc (&optional force)
3858 "Save the Gnus startup files.
3859 If FORCE, force saving whether it is necessary or not."
3861 (gnus-save-newsrc-file force))
3863 (defun gnus-group-restart (&optional arg)
3864 "Force Gnus to read the .newsrc file."
3866 (when (gnus-yes-or-no-p
3867 (format "Are you sure you want to restart Gnus? "))
3868 (gnus-save-newsrc-file)
3872 (defun gnus-group-read-init-file ()
3873 "Read the Gnus elisp init file."
3875 (gnus-read-init-file)
3876 (gnus-message 5 "Read %s" gnus-init-file))
3878 (defun gnus-group-check-bogus-groups (&optional silent)
3879 "Check bogus newsgroups.
3880 If given a prefix, don't ask for confirmation before removing a bogus
3883 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3884 (gnus-group-list-groups))
3886 (defun gnus-group-find-new-groups (&optional arg)
3887 "Search for new groups and add them.
3888 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3889 With 1 C-u, use the `ask-server' method to query the server for new
3891 With 2 C-u's, use most complete method possible to query the server
3892 for new groups, and subscribe the new groups as zombies."
3894 (gnus-find-new-newsgroups (or arg 1))
3895 (gnus-group-list-groups))
3897 (defun gnus-group-edit-global-kill (&optional article group)
3898 "Edit the global kill file.
3899 If GROUP, edit that local kill file instead."
3901 (setq gnus-current-kill-article article)
3902 (gnus-kill-file-edit-file group)
3905 (substitute-command-keys
3906 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3907 (if group "local" "global")))))
3909 (defun gnus-group-edit-local-kill (article group)
3910 "Edit a local kill file."
3911 (interactive (list nil (gnus-group-group-name)))
3912 (gnus-group-edit-global-kill article group))
3914 (defun gnus-group-force-update ()
3915 "Update `.newsrc' file."
3917 (gnus-save-newsrc-file))
3919 (defvar gnus-backlog-articles)
3921 (defun gnus-group-suspend ()
3922 "Suspend the current Gnus session.
3923 In fact, cleanup buffers except for group mode buffer.
3924 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3926 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3927 (gnus-offer-save-summaries)
3928 ;; Kill Gnus buffers except for group mode buffer.
3929 (let ((group-buf (get-buffer gnus-group-buffer)))
3930 (mapcar (lambda (buf)
3931 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3932 (with-current-buffer buf
3933 (eq major-mode 'message-mode)))
3934 (gnus-kill-buffer buf)))
3936 (setq gnus-backlog-articles nil)
3937 (gnus-kill-gnus-frames)
3939 (bury-buffer group-buf)
3940 (delete-windows-on group-buf t))))
3942 (defun gnus-group-clear-dribble ()
3943 "Clear all information from the dribble buffer."
3945 (gnus-dribble-clear)
3946 (gnus-message 7 "Cleared dribble buffer"))
3948 (defun gnus-group-exit ()
3949 "Quit reading news after updating .newsrc.eld and .newsrc.
3950 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3953 (or noninteractive ;For gnus-batch-kill
3954 (not gnus-interactive-exit) ;Without confirmation
3956 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3957 (gnus-run-hooks 'gnus-exit-gnus-hook)
3958 ;; Offer to save data from non-quitted summary buffers.
3959 (gnus-offer-save-summaries)
3960 ;; Save the newsrc file(s).
3961 (gnus-save-newsrc-file)
3963 (gnus-close-backends)
3964 ;; Reset everything.
3966 ;; Allow the user to do things after cleaning up.
3967 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3969 (defun gnus-group-quit ()
3970 "Quit reading news without updating .newsrc.eld or .newsrc.
3971 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3973 (when (or noninteractive ;For gnus-batch-kill
3974 (zerop (buffer-size))
3975 (not (gnus-server-opened gnus-select-method))
3977 (not gnus-current-startup-file)
3979 (format "Quit reading news without saving %s? "
3980 (file-name-nondirectory gnus-current-startup-file))))
3981 (gnus-run-hooks 'gnus-exit-gnus-hook)
3982 (gnus-configure-windows 'group t)
3983 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3984 (not (zerop (save-excursion
3985 (set-buffer gnus-dribble-buffer)
3988 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3990 (gnus-close-backends)
3992 (gnus-kill-buffer gnus-group-buffer)
3993 ;; Allow the user to do things after cleaning up.
3994 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3996 (defun gnus-group-describe-briefly ()
3997 "Give a one line description of the group mode commands."
3999 (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")))
4001 (defun gnus-group-browse-foreign-server (method)
4002 "Browse a foreign news server.
4003 If called interactively, this function will ask for a select method
4004 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4005 If not, METHOD should be a list where the first element is the method
4006 and the second element is the address."
4008 (list (let ((how (completing-read
4010 (append gnus-valid-select-methods gnus-server-alist)
4011 nil t (cons "nntp" 0) 'gnus-method-history)))
4012 ;; We either got a back end name or a virtual server name.
4013 ;; If the first, we also need an address.
4014 (if (assoc how gnus-valid-select-methods)
4016 ;; Suggested by mapjph@bath.ac.uk.
4019 (mapcar (lambda (server) (list server))
4020 gnus-secondary-servers)))
4021 ;; We got a server name.
4023 (gnus-browse-foreign-server method))
4025 (defun gnus-group-set-info (info &optional method-only-group part)
4026 (when (or info part)
4027 (let* ((entry (gnus-group-entry
4028 (or method-only-group (gnus-info-group info))))
4030 (info (if method-only-group (nth 2 entry) info))
4032 (when method-only-group
4034 (error "Trying to change non-existent group %s" method-only-group))
4035 ;; We have received parts of the actual group info - either the
4036 ;; select method or the group parameters. We first check
4037 ;; whether we have to extend the info, and if so, do that.
4038 (let ((len (length info))
4039 (total (if (eq part 'method) 5 6)))
4041 (setcdr (nthcdr (1- len) info)
4042 (make-list (- total len) nil)))
4043 ;; Then we enter the new info.
4044 (setcar (nthcdr (1- total) info) part-info)))
4046 ;; This is a new group, so we just create it.
4048 (set-buffer gnus-group-buffer)
4049 (setq method (gnus-info-method info))
4050 (when (gnus-server-equal method "native")
4053 (set-buffer gnus-group-buffer)
4055 ;; It's a foreign group...
4056 (gnus-group-make-group
4057 (gnus-group-real-name (gnus-info-group info))
4058 (if (stringp method) method
4059 (prin1-to-string (car method)))
4061 (nth 1 (gnus-info-method info))))
4062 ;; It's a native group.
4063 (gnus-group-make-group (gnus-info-group info))))
4064 (gnus-message 6 "Note: New group created")
4066 (gnus-group-entry (gnus-group-prefixed-name
4067 (gnus-group-real-name (gnus-info-group info))
4068 (or (gnus-info-method info) gnus-select-method))))))
4069 ;; Whether it was a new group or not, we now have the entry, so we
4070 ;; can do the update.
4073 (setcar (nthcdr 2 entry) info)
4074 (when (and (not (eq (car entry) t))
4075 (gnus-active (gnus-info-group info)))
4076 (setcar entry (length
4077 (gnus-list-of-unread-articles (car info))))))
4078 (error "No such group: %s" (gnus-info-group info))))))
4080 (defun gnus-group-set-method-info (group select-method)
4081 (gnus-group-set-info select-method group 'method))
4083 (defun gnus-group-set-params-info (group params)
4084 (gnus-group-set-info params group 'params))
4086 (defun gnus-add-marked-articles (group type articles &optional info force)
4087 ;; Add ARTICLES of TYPE to the info of GROUP.
4088 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4089 ;; add, but replace marked articles of TYPE with ARTICLES.
4090 (let ((info (or info (gnus-get-info group)))
4093 (and (not (setq marked (nthcdr 3 info)))
4095 (setcdr (nthcdr 2 info)
4096 (list (list (cons type (gnus-compress-sequence
4098 (and (not (setq m (assq type (car marked))))
4101 (cons (cons type (gnus-compress-sequence articles t) )
4105 (setcar (nthcdr 3 info)
4106 (gnus-delete-alist type (car marked)))
4107 (setcdr m (gnus-compress-sequence articles t)))
4108 (setcdr m (gnus-compress-sequence
4109 (sort (nconc (gnus-uncompress-range (cdr m))
4110 (copy-sequence articles)) '<) t))))))
4112 (defun gnus-add-mark (group mark article)
4113 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4114 (let ((buffer (gnus-summary-buffer-name group)))
4115 (if (gnus-buffer-live-p buffer)
4117 (set-buffer (get-buffer buffer))
4118 (gnus-summary-add-mark article mark))
4119 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4123 ;;; Group timestamps
4126 (defun gnus-group-set-timestamp ()
4127 "Change the timestamp of the current group to the current time.
4128 This function can be used in hooks like `gnus-select-group-hook'
4129 or `gnus-group-catchup-group-hook'."
4130 (when gnus-newsgroup-name
4131 (let ((time (current-time)))
4132 (setcdr (cdr time) nil)
4133 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4135 (defsubst gnus-group-timestamp (group)
4136 "Return the timestamp for GROUP."
4137 (gnus-group-get-parameter group 'timestamp t))
4139 (defun gnus-group-timestamp-delta (group)
4140 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4141 (let* ((time (or (gnus-group-timestamp group)
4143 (delta (subtract-time (current-time) time)))
4144 (+ (* (nth 0 delta) 65536.0)
4147 (defun gnus-group-timestamp-string (group)
4148 "Return a string of the timestamp for GROUP."
4149 (let ((time (gnus-group-timestamp group)))
4152 (gnus-time-iso8601 time))))
4154 (defun gnus-group-list-cached (level &optional lowest)
4155 "List all groups with cached articles.
4156 If the prefix LEVEL is non-nil, it should be a number that says which
4157 level to cut off listing groups.
4158 If LOWEST, don't list groups with level lower than LOWEST.
4160 This command may read the active file."
4163 (setq level (prefix-numeric-value level)))
4164 (when (or (not level) (>= level gnus-level-zombie))
4166 (funcall gnus-group-prepare-function
4167 (or level gnus-level-subscribed)
4169 (let ((marks (gnus-info-marks info)))
4170 (assq 'cache marks)))
4173 (or (gnus-gethash group
4174 gnus-cache-active-hashtb)
4175 ;; Cache active file might use "."
4178 (mapconcat 'identity
4179 (split-string group ":")
4181 gnus-cache-active-hashtb))))
4182 (goto-char (point-min))
4183 (gnus-group-position-point))
4185 (defun gnus-group-list-dormant (level &optional lowest)
4186 "List all groups with dormant articles.
4187 If the prefix LEVEL is non-nil, it should be a number that says which
4188 level to cut off listing groups.
4189 If LOWEST, don't list groups with level lower than LOWEST.
4191 This command may read the active file."
4194 (setq level (prefix-numeric-value level)))
4195 (when (or (not level) (>= level gnus-level-zombie))
4197 (funcall gnus-group-prepare-function
4198 (or level gnus-level-subscribed)
4200 (let ((marks (gnus-info-marks info)))
4201 (assq 'dormant marks)))
4204 (goto-char (point-min))
4205 (gnus-group-position-point))
4207 (defun gnus-group-listed-groups ()
4208 "Return a list of listed groups."
4210 (goto-char (point-min))
4211 (while (setq point (text-property-not-all (point) (point-max)
4214 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4218 (defun gnus-group-list-plus (&optional args)
4219 "List groups plus the current selection."
4221 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4222 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4224 (push last-command-event unread-command-events)
4225 (if (featurep 'xemacs)
4226 (push (make-event 'key-press '(key ?A)) unread-command-events)
4227 (push ?A unread-command-events))
4228 (let (gnus-pick-mode keys)
4229 (setq keys (if (featurep 'xemacs)
4230 (events-to-keys (read-key-sequence nil))
4231 (read-key-sequence nil)))
4232 (setq func (lookup-key (current-local-map) keys)))
4236 (call-interactively func))))
4238 (defun gnus-group-list-flush (&optional args)
4239 "Flush groups from the current selection."
4241 (let ((gnus-group-list-option 'flush))
4242 (gnus-group-list-plus args)))
4244 (defun gnus-group-list-limit (&optional args)
4245 "List groups limited within the current selection."
4247 (let ((gnus-group-list-option 'limit))
4248 (gnus-group-list-plus args)))
4250 (defun gnus-group-mark-article-read (group article)
4251 "Mark ARTICLE read."
4252 (let ((buffer (gnus-summary-buffer-name group))
4253 (mark gnus-read-mark)
4255 (if (get-buffer buffer)
4256 (with-current-buffer buffer
4257 (setq active gnus-newsgroup-active)
4258 (gnus-activate-group group)
4259 (when gnus-newsgroup-prepared
4260 (when (and gnus-newsgroup-auto-expire
4261 (memq mark gnus-auto-expirable-marks))
4262 (setq mark gnus-expirable-mark))
4263 (setq mark (gnus-request-update-mark
4264 group article mark))
4265 (gnus-mark-article-as-read article mark)
4266 (setq gnus-newsgroup-active (gnus-active group))
4268 (setq n (1+ (cdr active)))
4269 (while (<= n (cdr gnus-newsgroup-active))
4270 (unless (eq n article)
4271 (push n gnus-newsgroup-unselected))
4273 (setq gnus-newsgroup-unselected
4274 (nreverse gnus-newsgroup-unselected)))))
4275 (gnus-activate-group group)
4276 (gnus-group-make-articles-read group (list article))
4277 (when (gnus-group-auto-expirable-p group)
4278 (gnus-add-marked-articles
4279 group 'expire (list article))))))
4281 (provide 'gnus-group)
4283 ;;; gnus-group.el ends here