1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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))
44 (eval-when-compile (require 'mm-url))
46 (defcustom gnus-group-archive-directory
47 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
48 "*The address of the (ding) archives."
49 :group 'gnus-group-foreign
52 (defcustom gnus-group-recent-archive-directory
53 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
54 "*The address of the most recent (ding) articles."
55 :group 'gnus-group-foreign
58 (defcustom gnus-no-groups-message "No gnus is bad news"
59 "*Message displayed by Gnus when no groups are available."
63 (defcustom gnus-keep-same-level nil
64 "*Non-nil means that the next newsgroup after the current will be on the same level.
65 When you type, for instance, `n' after reading the last article in the
66 current newsgroup, you will go to the next newsgroup. If this variable
67 is nil, the next newsgroup will be the next from the group
69 If this variable is non-nil, Gnus will either put you in the
70 next newsgroup with the same level, or, if no such newsgroup is
71 available, the next newsgroup with the lowest possible level higher
72 than the current level.
73 If this variable is `best', Gnus will make the next newsgroup the one
75 :group 'gnus-group-levels
76 :type '(choice (const nil)
78 (sexp :tag "other" t)))
80 (defcustom gnus-group-goto-unread t
81 "*If non-nil, movement commands will go to the next unread and subscribed group."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-group-various
86 (defcustom gnus-goto-next-group-when-activating t
87 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
88 :link '(custom-manual "(gnus)Scanning New Messages")
89 :group 'gnus-group-various
92 (defcustom gnus-permanently-visible-groups nil
93 "*Regexp to match groups that should always be listed in the group buffer.
94 This means that they will still be listed even when there are no
95 unread articles in the groups.
97 If nil, no groups are permanently visible."
98 :group 'gnus-group-listing
99 :type '(choice regexp (const nil)))
101 (defcustom gnus-list-groups-with-ticked-articles t
102 "*If non-nil, list groups that have only ticked articles.
103 If nil, only list groups that have unread articles."
104 :group 'gnus-group-listing
107 (defcustom gnus-group-default-list-level gnus-level-subscribed
108 "*Default listing level.
109 Ignored if `gnus-group-use-permanent-levels' is non-nil."
110 :group 'gnus-group-listing
113 (defcustom gnus-group-list-inactive-groups t
114 "*If non-nil, inactive groups will be listed."
115 :group 'gnus-group-listing
116 :group 'gnus-group-levels
119 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
120 "*Function used for sorting the group buffer.
121 This function will be called with group info entries as the arguments
122 for the groups to be sorted. Pre-made functions include
123 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
124 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
125 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
126 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
128 This variable can also be a list of sorting functions. In that case,
129 the most significant sort function should be the last function in the
131 :group 'gnus-group-listing
132 :link '(custom-manual "(gnus)Sorting Groups")
133 :type '(repeat :value-to-internal (lambda (widget value)
134 (if (listp value) value (list value)))
135 :match (lambda (widget value)
137 (widget-editable-list-match widget value)))
138 (choice (function-item gnus-group-sort-by-alphabet)
139 (function-item gnus-group-sort-by-real-name)
140 (function-item gnus-group-sort-by-unread)
141 (function-item gnus-group-sort-by-level)
142 (function-item gnus-group-sort-by-score)
143 (function-item gnus-group-sort-by-method)
144 (function-item gnus-group-sort-by-server)
145 (function-item gnus-group-sort-by-rank)
146 (function :tag "other" nil))))
148 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
149 "*Format of group lines.
150 It works along the same lines as a normal formatting string,
151 with some simple extensions.
153 %M Only marked articles (character, \"*\" or \" \")
154 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
155 %L Level of subscribedness (integer)
156 %N Number of unread articles (integer)
157 %I Number of dormant articles (integer)
158 %i Number of ticked and dormant (integer)
159 %T Number of ticked articles (integer)
160 %R Number of read articles (integer)
161 %U Number of unseen articles (integer)
162 %t Estimated total number of articles (integer)
163 %y Number of unread, unticked articles (integer)
164 %G Group name (string)
165 %g Qualified group name (string)
166 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
167 %C Group comment (string)
168 %D Group description (string)
169 %s Select method (string)
170 %o Moderated group (char, \"m\")
171 %p Process mark (char)
172 %B Whether a summary buffer for the group is open (char, \"*\")
173 %O Moderated group (string, \"(m)\" or \"\")
174 %P Topic indentation (string)
175 %m Whether there is new(ish) mail in the group (char, \"%\")
176 %w Number of new(ish) mails in the group (integer)
177 %l Whether there are GroupLens predictions for this group (string)
178 %n Select from where (string)
179 %z A string that look like `<%s:%n>' if a foreign select method is used
180 %d The date the group was last entered.
181 %E Icon as defined by `gnus-group-icon-list'.
182 %u User defined specifier. The next character in the format string should
183 be a letter. Gnus will call the function gnus-user-format-function-X,
184 where X is the letter following %u. The function will be passed a
185 single dummy parameter as argument.. The function should return a
186 string, which will be inserted into the buffer just like information
187 from any other group specifier.
189 Note that this format specification is not always respected. For
190 reasons of efficiency, when listing killed groups, this specification
191 is ignored altogether. If the spec is changed considerably, your
192 output may end up looking strange when listing both alive and killed
195 If you use %o or %O, reading the active file will be slower and quite
196 a bit of extra memory will be used. %D will also worsen performance.
197 Also note that if you change the format specification to include any
198 of these specs, you must probably re-start Gnus to see them go into
201 General format specifiers can also be used.
202 See Info node `(gnus)Formatting Variables'."
203 :link '(custom-manual "(gnus)Formatting Variables")
204 :group 'gnus-group-visual
207 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
208 "*The format specification for the group mode line.
209 It works along the same lines as a normal formatting string,
210 with some simple extensions:
212 %S The native news server.
213 %M The native select method.
214 %: \":\" if %S isn't \"\"."
215 :group 'gnus-group-visual
218 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
219 (when (featurep 'xemacs)
220 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
221 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
223 (defcustom gnus-group-menu-hook nil
224 "Hook run after the creation of the group mode menu."
225 :group 'gnus-group-various
228 (defcustom gnus-group-catchup-group-hook nil
229 "Hook run when catching up a group from the group buffer."
230 :group 'gnus-group-various
231 :link '(custom-manual "(gnus)Group Data")
234 (defcustom gnus-group-update-group-hook nil
235 "Hook called when updating group lines."
236 :group 'gnus-group-visual
239 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
240 "*A function that is called to generate the group buffer.
241 The function is called with three arguments: The first is a number;
242 all group with a level less or equal to that number should be listed,
243 if the second is non-nil, empty groups should also be displayed. If
244 the third is non-nil, it is a number. No groups with a level lower
245 than this number should be displayed.
247 The only current function implemented is `gnus-group-prepare-flat'."
248 :group 'gnus-group-listing
251 (defcustom gnus-group-prepare-hook nil
252 "Hook called after the group buffer has been generated.
253 If you want to modify the group buffer, you can use this hook."
254 :group 'gnus-group-listing
257 (defcustom gnus-suspend-gnus-hook nil
258 "Hook called when suspending (not exiting) Gnus."
262 (defcustom gnus-exit-gnus-hook nil
263 "Hook called when exiting Gnus."
267 (defcustom gnus-after-exiting-gnus-hook nil
268 "Hook called after exiting Gnus."
272 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
273 "Hook called when a group line is changed.
274 The hook will not be called if `gnus-visual' is nil.
276 The default function `gnus-group-highlight-line' will
277 highlight the line according to the `gnus-group-highlight'
279 :group 'gnus-group-visual
282 (defcustom gnus-useful-groups
283 '(("(ding) mailing list mirrored at sunsite.auc.dk"
285 (nntp "sunsite.auc.dk"
286 (nntp-address "sunsite.auc.dk")))
289 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
293 (nndoc-article-type mbox)
294 (eval `(nndoc-address
295 ,(let ((file (nnheader-find-etc-directory
298 (error "Couldn't find doc group"))
300 "*Alist of useful group-server pairs."
301 :group 'gnus-group-listing
302 :type '(repeat (list (string :tag "Description")
304 (sexp :tag "Method"))))
306 (defcustom gnus-group-highlight
308 ((and mailp (= unread 0) (eq level 1)) .
309 gnus-group-mail-1-empty-face)
310 ((and mailp (eq level 1)) .
311 gnus-group-mail-1-face)
312 ((and mailp (= unread 0) (eq level 2)) .
313 gnus-group-mail-2-empty-face)
314 ((and mailp (eq level 2)) .
315 gnus-group-mail-2-face)
316 ((and mailp (= unread 0) (eq level 3)) .
317 gnus-group-mail-3-empty-face)
318 ((and mailp (eq level 3)) .
319 gnus-group-mail-3-face)
320 ((and mailp (= unread 0)) .
321 gnus-group-mail-low-empty-face)
323 gnus-group-mail-low-face)
325 ((and (= unread 0) (eq level 1)) .
326 gnus-group-news-1-empty-face)
327 ((and (eq level 1)) .
328 gnus-group-news-1-face)
329 ((and (= unread 0) (eq level 2)) .
330 gnus-group-news-2-empty-face)
331 ((and (eq level 2)) .
332 gnus-group-news-2-face)
333 ((and (= unread 0) (eq level 3)) .
334 gnus-group-news-3-empty-face)
335 ((and (eq level 3)) .
336 gnus-group-news-3-face)
337 ((and (= unread 0) (eq level 4)) .
338 gnus-group-news-4-empty-face)
339 ((and (eq level 4)) .
340 gnus-group-news-4-face)
341 ((and (= unread 0) (eq level 5)) .
342 gnus-group-news-5-empty-face)
343 ((and (eq level 5)) .
344 gnus-group-news-5-face)
345 ((and (= unread 0) (eq level 6)) .
346 gnus-group-news-6-empty-face)
347 ((and (eq level 6)) .
348 gnus-group-news-6-face)
349 ((and (= unread 0)) .
350 gnus-group-news-low-empty-face)
352 gnus-group-news-low-face))
353 "*Controls the highlighting of group buffer lines.
355 Below is a list of `Form'/`Face' pairs. When deciding how a a
356 particular group line should be displayed, each form is
357 evaluated. The content of the face field after the first true form is
358 used. You can change how those group lines are displayed by
359 editing the face field.
361 It is also possible to change and add form fields, but currently that
362 requires an understanding of Lisp expressions. Hopefully this will
363 change in a future release. For now, you can use the following
364 variables in the Lisp expression:
366 group: The name of the group.
367 unread: The number of unread articles in the group.
368 method: The select method used.
369 mailp: Whether it's a mail group or not.
370 level: The level of the group.
371 score: The score of the group.
372 ticked: The number of ticked articles."
373 :group 'gnus-group-visual
374 :type '(repeat (cons (sexp :tag "Form") face)))
376 (defcustom gnus-new-mail-mark ?%
377 "Mark used for groups with new mail."
378 :group 'gnus-group-visual
381 (defgroup gnus-group-icons nil
382 "Add Icons to your group buffer. "
383 :group 'gnus-group-visual)
385 (defcustom gnus-group-icon-list
387 "*Controls the insertion of icons into group buffer lines.
389 Below is a list of `Form'/`File' pairs. When deciding how a
390 particular group line should be displayed, each form is evaluated.
391 The icon from the file field after the first true form is used. You
392 can change how those group lines are displayed by editing the file
393 field. The File will either be found in the
394 `gnus-group-glyph-directory' or by designating absolute name of the
397 It is also possible to change and add form fields, but currently that
398 requires an understanding of Lisp expressions. Hopefully this will
399 change in a future release. For now, you can use the following
400 variables in the Lisp expression:
402 group: The name of the group.
403 unread: The number of unread articles in the group.
404 method: The select method used.
405 mailp: Whether it's a mail group or not.
406 newsp: Whether it's a news group or not
407 level: The level of the group.
408 score: The score of the group.
409 ticked: The number of ticked articles."
410 :group 'gnus-group-icons
411 :type '(repeat (cons (sexp :tag "Form") file)))
413 (defcustom gnus-group-name-charset-method-alist nil
414 "Alist of method and the charset for group names.
417 (((nntp \"news.com.cn\") . cn-gb-2312))"
420 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
422 (defcustom gnus-group-name-charset-group-alist
423 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
424 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
425 '(("[^\000-\177]" . utf-8))
427 "Alist of group regexp and the charset for group names.
430 ((\"\\.com\\.cn:\" . cn-gb-2312))"
432 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
434 (defcustom gnus-group-jump-to-group-prompt nil
435 "Default prompt for `gnus-group-jump-to-group'.
436 If non-nil, the value should be a string, e.g. \"nnml:\",
437 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
438 in the minibuffer prompt."
439 :group 'gnus-group-various
440 :type '(choice (string :tag "Prompt string")
441 (const :tag "Empty" nil)))
443 (defvar gnus-group-listing-limit 1000
444 "*A limit of the number of groups when listing.
445 If the number of groups is larger than the limit, list them in a
448 ;;; Internal variables
450 (defvar gnus-group-is-exiting-p nil)
451 (defvar gnus-group-is-exiting-without-update-p nil)
452 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
453 "Function for sorting the group buffer.")
455 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
456 "Function for sorting the selected groups in the group buffer.")
458 (defvar gnus-group-indentation-function nil)
459 (defvar gnus-goto-missing-group-function nil)
460 (defvar gnus-group-update-group-function nil)
461 (defvar gnus-group-goto-next-group-function nil
462 "Function to override finding the next group after listing groups.")
464 (defvar gnus-group-edit-buffer nil)
466 (defvar gnus-group-line-format-alist
467 `((?M gnus-tmp-marked-mark ?c)
468 (?S gnus-tmp-subscribed ?c)
469 (?L gnus-tmp-level ?d)
470 (?N (cond ((eq number t) "*" )
474 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
475 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
477 (?R gnus-tmp-number-of-read ?s)
478 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
479 (?t gnus-tmp-number-total ?d)
480 (?y gnus-tmp-number-of-unread ?s)
481 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
482 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
483 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
484 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
485 (?g gnus-tmp-group ?s)
486 (?G gnus-tmp-qualified-group ?s)
487 (?c (gnus-short-group-name gnus-tmp-group) ?s)
488 (?C gnus-tmp-comment ?s)
489 (?D gnus-tmp-newsgroup-description ?s)
490 (?o gnus-tmp-moderated ?c)
491 (?O gnus-tmp-moderated-string ?s)
492 (?p gnus-tmp-process-marked ?c)
493 (?s gnus-tmp-news-server ?s)
494 (?n gnus-tmp-news-method ?s)
495 (?P gnus-group-indentation ?s)
496 (?E gnus-tmp-group-icon ?s)
497 (?B gnus-tmp-summary-live ?c)
498 (?l gnus-tmp-grouplens ?s)
499 (?z gnus-tmp-news-method-string ?s)
500 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
501 (?w (if (gnus-news-group-p gnus-tmp-group)
505 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
508 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
509 (?u gnus-tmp-user-defined ?s)))
511 (defvar gnus-group-mode-line-format-alist
512 `((?S gnus-tmp-news-server ?s)
513 (?M gnus-tmp-news-method ?s)
514 (?u gnus-tmp-user-defined ?s)
515 (?: gnus-tmp-colon ?s)))
517 (defvar gnus-topic-topology nil
518 "The complete topic hierarchy.")
520 (defvar gnus-topic-alist nil
521 "The complete topic-group alist.")
523 (defvar gnus-group-marked nil)
525 (defvar gnus-group-list-mode nil)
528 (defvar gnus-group-icon-cache nil)
530 (defvar gnus-group-listed-groups nil)
531 (defvar gnus-group-list-option nil)
537 (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-n" gnus-namazu-search
603 "\C-c\C-s" gnus-group-sort-groups
605 "\C-c\M-g" gnus-activate-all-groups
606 "\M-&" gnus-group-universal-argument
607 "#" gnus-group-mark-group
608 "\M-#" gnus-group-unmark-group)
610 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
611 "m" gnus-group-mark-group
612 "u" gnus-group-unmark-group
613 "w" gnus-group-mark-region
614 "b" gnus-group-mark-buffer
615 "r" gnus-group-mark-regexp
616 "U" gnus-group-unmark-all-groups)
618 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
619 "u" gnus-sieve-update
620 "g" gnus-sieve-generate)
622 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
623 "d" gnus-group-make-directory-group
624 "h" gnus-group-make-help-group
625 "u" gnus-group-make-useful-group
626 "a" gnus-group-make-archive-group
627 "k" gnus-group-make-kiboze-group
628 "l" gnus-group-nnimap-edit-acl
629 "m" gnus-group-make-group
630 "n" gnus-group-make-shimbun-group
631 "E" gnus-group-edit-group
632 "e" gnus-group-edit-group-method
633 "p" gnus-group-edit-group-parameters
634 "v" gnus-group-add-to-virtual
635 "V" gnus-group-make-empty-virtual
636 "D" gnus-group-enter-directory
637 "f" gnus-group-make-doc-group
638 "G" gnus-group-make-nnir-group
639 "w" gnus-group-make-web-group
640 "r" gnus-group-rename-group
641 "R" gnus-group-make-rss-group
642 "c" gnus-group-customize
643 "x" gnus-group-nnimap-expunge
644 "\177" gnus-group-delete-group
645 [delete] gnus-group-delete-group)
647 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
648 "b" gnus-group-brew-soup
649 "w" gnus-soup-save-areas
650 "s" gnus-soup-send-replies
651 "p" gnus-soup-pack-packet
652 "r" nnsoup-pack-replies)
654 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
655 "s" gnus-group-sort-groups
656 "a" gnus-group-sort-groups-by-alphabet
657 "u" gnus-group-sort-groups-by-unread
658 "l" gnus-group-sort-groups-by-level
659 "v" gnus-group-sort-groups-by-score
660 "r" gnus-group-sort-groups-by-rank
661 "m" gnus-group-sort-groups-by-method
662 "n" gnus-group-sort-groups-by-real-name)
664 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
665 "s" gnus-group-sort-selected-groups
666 "a" gnus-group-sort-selected-groups-by-alphabet
667 "u" gnus-group-sort-selected-groups-by-unread
668 "l" gnus-group-sort-selected-groups-by-level
669 "v" gnus-group-sort-selected-groups-by-score
670 "r" gnus-group-sort-selected-groups-by-rank
671 "m" gnus-group-sort-selected-groups-by-method
672 "n" gnus-group-sort-selected-groups-by-real-name)
674 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
675 "k" gnus-group-list-killed
676 "z" gnus-group-list-zombies
677 "s" gnus-group-list-groups
678 "u" gnus-group-list-all-groups
679 "A" gnus-group-list-active
680 "a" gnus-group-apropos
681 "d" gnus-group-description-apropos
682 "m" gnus-group-list-matching
683 "M" gnus-group-list-all-matching
684 "l" gnus-group-list-level
685 "c" gnus-group-list-cached
686 "?" gnus-group-list-dormant)
688 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
689 "k" gnus-group-list-limit
690 "z" gnus-group-list-limit
691 "s" gnus-group-list-limit
692 "u" gnus-group-list-limit
693 "A" gnus-group-list-limit
694 "m" gnus-group-list-limit
695 "M" gnus-group-list-limit
696 "l" gnus-group-list-limit
697 "c" gnus-group-list-limit
698 "?" gnus-group-list-limit)
700 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
701 "k" gnus-group-list-flush
702 "z" gnus-group-list-flush
703 "s" gnus-group-list-flush
704 "u" gnus-group-list-flush
705 "A" gnus-group-list-flush
706 "m" gnus-group-list-flush
707 "M" gnus-group-list-flush
708 "l" gnus-group-list-flush
709 "c" gnus-group-list-flush
710 "?" gnus-group-list-flush)
712 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
713 "k" gnus-group-list-plus
714 "z" gnus-group-list-plus
715 "s" gnus-group-list-plus
716 "u" gnus-group-list-plus
717 "A" gnus-group-list-plus
718 "m" gnus-group-list-plus
719 "M" gnus-group-list-plus
720 "l" gnus-group-list-plus
721 "c" gnus-group-list-plus
722 "?" gnus-group-list-plus)
724 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
725 "f" gnus-score-flush-cache)
727 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
728 "c" gnus-group-fetch-charter
729 "C" gnus-group-fetch-control
730 "d" gnus-group-describe-group
731 "f" gnus-group-fetch-faq
734 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
735 "l" gnus-group-set-current-level
736 "t" gnus-group-unsubscribe-current-group
737 "s" gnus-group-unsubscribe-group
738 "k" gnus-group-kill-group
739 "y" gnus-group-yank-group
740 "w" gnus-group-kill-region
741 "\C-k" gnus-group-kill-level
742 "z" gnus-group-kill-all-zombies))
744 (defun gnus-topic-mode-p ()
745 "Return non-nil in `gnus-topic-mode'."
746 (and (boundp 'gnus-topic-mode)
747 (symbol-value 'gnus-topic-mode)))
749 (defun gnus-group-make-menu-bar ()
750 (gnus-turn-off-edit-menu 'group)
751 (unless (boundp 'gnus-group-reading-menu)
754 gnus-group-reading-menu gnus-group-mode-map ""
756 ["Read" gnus-group-read-group
757 :included (not (gnus-topic-mode-p))
758 :active (gnus-group-group-name)]
759 ["Read " gnus-topic-read-group
760 :included (gnus-topic-mode-p)]
761 ["Select" gnus-group-select-group
762 :included (not (gnus-topic-mode-p))
763 :active (gnus-group-group-name)]
764 ["Select " gnus-topic-select-group
765 :included (gnus-topic-mode-p)]
766 ["See old articles" (gnus-group-select-group 'all)
767 :keys "C-u SPC" :active (gnus-group-group-name)]
768 ["Catch up" gnus-group-catchup-current
769 :included (not (gnus-topic-mode-p))
770 :active (gnus-group-group-name)
771 ,@(if (featurep 'xemacs) nil
772 '(:help "Mark unread articles in the current group as read"))]
773 ["Catch up " gnus-topic-catchup-articles
774 :included (gnus-topic-mode-p)
775 ,@(if (featurep 'xemacs) nil
776 '(:help "Mark unread articles in the current group or topic as read"))]
777 ["Catch up all articles" gnus-group-catchup-current-all
778 (gnus-group-group-name)]
779 ["Check for new articles" gnus-group-get-new-news-this-group
780 :included (not (gnus-topic-mode-p))
781 :active (gnus-group-group-name)
782 ,@(if (featurep 'xemacs) nil
783 '(:help "Check for new messages in current group"))]
784 ["Check for new articles " gnus-topic-get-new-news-this-topic
785 :included (gnus-topic-mode-p)
786 ,@(if (featurep 'xemacs) nil
787 '(:help "Check for new messages in current group or topic"))]
788 ["Toggle subscription" gnus-group-unsubscribe-current-group
789 (gnus-group-group-name)]
790 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Kill (remove) current group"))]
793 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
794 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
795 ,@(if (featurep 'xemacs) nil
796 '(:help "Display description of the current group"))]
797 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
798 ["Fetch charter" gnus-group-fetch-charter
799 :active (gnus-group-group-name)
800 ,@(if (featurep 'xemacs) nil
801 '(:help "Display the charter of the current group"))]
802 ["Fetch control message" gnus-group-fetch-control
803 :active (gnus-group-group-name)
804 ,@(if (featurep 'xemacs) nil
805 '(:help "Display the archived control message for the current group"))]
806 ;; Actually one should check, if any of the marked groups gives t for
807 ;; (gnus-check-backend-function 'request-expire-articles ...)
808 ["Expire articles" gnus-group-expire-articles
809 :included (not (gnus-topic-mode-p))
810 :active (or (and (gnus-group-group-name)
811 (gnus-check-backend-function
812 'request-expire-articles
813 (gnus-group-group-name))) gnus-group-marked)]
814 ["Expire articles " gnus-topic-expire-articles
815 :included (gnus-topic-mode-p)]
816 ["Set group level..." gnus-group-set-current-level
817 (gnus-group-group-name)]
818 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
819 ["Customize" gnus-group-customize (gnus-group-group-name)]
821 ["Parameters" gnus-group-edit-group-parameters
822 :included (not (gnus-topic-mode-p))
823 :active (gnus-group-group-name)]
824 ["Parameters " gnus-topic-edit-parameters
825 :included (gnus-topic-mode-p)]
826 ["Select method" gnus-group-edit-group-method
827 (gnus-group-group-name)]
828 ["Info" gnus-group-edit-group (gnus-group-group-name)]
829 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
830 ["Global kill file" gnus-group-edit-global-kill t])))
833 gnus-group-group-menu gnus-group-mode-map ""
836 ["List unread subscribed groups" gnus-group-list-groups t]
837 ["List (un)subscribed groups" gnus-group-list-all-groups t]
838 ["List killed groups" gnus-group-list-killed gnus-killed-list]
839 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
840 ["List level..." gnus-group-list-level t]
841 ["Describe all groups" gnus-group-describe-all-groups t]
842 ["Group apropos..." gnus-group-apropos t]
843 ["Group and description apropos..." gnus-group-description-apropos t]
844 ["List groups matching..." gnus-group-list-matching t]
845 ["List all groups matching..." gnus-group-list-all-matching t]
846 ["List active file" gnus-group-list-active t]
847 ["List groups with cached" gnus-group-list-cached t]
848 ["List groups with dormant" gnus-group-list-dormant t])
850 ["Default sort" gnus-group-sort-groups t]
851 ["Sort by method" gnus-group-sort-groups-by-method t]
852 ["Sort by rank" gnus-group-sort-groups-by-rank t]
853 ["Sort by score" gnus-group-sort-groups-by-score t]
854 ["Sort by level" gnus-group-sort-groups-by-level t]
855 ["Sort by unread" gnus-group-sort-groups-by-unread t]
856 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
857 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
858 ("Sort process/prefixed"
859 ["Default sort" gnus-group-sort-selected-groups
860 (not (gnus-topic-mode-p))]
861 ["Sort by method" gnus-group-sort-selected-groups-by-method
862 (not (gnus-topic-mode-p))]
863 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
864 (not (gnus-topic-mode-p))]
865 ["Sort by score" gnus-group-sort-selected-groups-by-score
866 (not (gnus-topic-mode-p))]
867 ["Sort by level" gnus-group-sort-selected-groups-by-level
868 (not (gnus-topic-mode-p))]
869 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
870 (not (gnus-topic-mode-p))]
871 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
872 (not (gnus-topic-mode-p))]
873 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
874 (not (gnus-topic-mode-p))])
876 ["Mark group" gnus-group-mark-group
877 (and (gnus-group-group-name)
878 (not (memq (gnus-group-group-name) gnus-group-marked)))]
879 ["Unmark group" gnus-group-unmark-group
880 (and (gnus-group-group-name)
881 (memq (gnus-group-group-name) gnus-group-marked))]
882 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
883 ["Mark regexp..." gnus-group-mark-regexp t]
884 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
885 ["Mark buffer" gnus-group-mark-buffer t]
886 ["Execute command" gnus-group-universal-argument
887 (or gnus-group-marked (gnus-group-group-name))])
889 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
890 ["Kill all newsgroups in region" gnus-group-kill-region
891 :active (gnus-mark-active-p)]
892 ["Kill all zombie groups" gnus-group-kill-all-zombies
894 ["Kill all groups on level..." gnus-group-kill-level t])
896 ["Make a foreign group..." gnus-group-make-group t]
897 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
898 ["Add a directory group..." gnus-group-make-directory-group t]
899 ["Add the help group" gnus-group-make-help-group t]
900 ["Add the archive group" gnus-group-make-archive-group t]
901 ["Make a doc group..." gnus-group-make-doc-group t]
902 ["Make a web group..." gnus-group-make-web-group t]
903 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
904 ["Make a virtual group..." gnus-group-make-empty-virtual t]
905 ["Add a group to a virtual..." gnus-group-add-to-virtual 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 (if (and string charset (featurep 'mule))
1107 (decode-coding-string string charset)
1110 (defun gnus-group-decoded-name (string)
1111 (let ((charset (gnus-group-name-charset nil string)))
1112 (gnus-group-name-decode string charset)))
1114 (defun gnus-group-name-encode (string charset)
1115 (if (and string charset (featurep 'mule))
1116 (encode-coding-string string charset)
1119 (defun gnus-group-encoded-name (string)
1120 (let ((charset (gnus-group-name-charset nil string)))
1121 (gnus-group-name-encode string charset)))
1123 (defun gnus-group-completing-read-group-name
1124 (prompt table &optional predicate require-match initial-contents history)
1128 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1132 (dolist (entry (prog1
1135 (push (list (gnus-group-decoded-name (car entry))) table)))
1136 (gnus-group-encoded-name
1138 prompt table predicate
1143 (defun gnus-group-list-groups (&optional level unread lowest)
1144 "List newsgroups with level LEVEL or lower that have unread articles.
1145 Default is all subscribed groups.
1146 If argument UNREAD is non-nil, groups with no unread articles are also
1149 Also see the `gnus-group-use-permanent-levels' variable."
1151 (list (if current-prefix-arg
1152 (prefix-numeric-value current-prefix-arg)
1154 (gnus-group-default-level nil t)
1155 gnus-group-default-list-level
1156 gnus-level-subscribed))))
1158 (setq level (car gnus-group-list-mode)
1159 unread (cdr gnus-group-list-mode)))
1160 (setq level (gnus-group-default-level level))
1161 (gnus-group-setup-buffer)
1162 (gnus-update-format-specifications nil 'group 'group-mode)
1163 (let ((case-fold-search nil)
1164 (props (text-properties-at (gnus-point-at-bol)))
1165 (empty (= (point-min) (point-max)))
1166 (group (gnus-group-group-name))
1168 (set-buffer gnus-group-buffer)
1169 (setq number (funcall gnus-group-prepare-function level unread lowest))
1170 (when (or (and (numberp number)
1172 (zerop (buffer-size)))
1173 ;; No groups in the buffer.
1174 (gnus-message 5 gnus-no-groups-message))
1175 ;; We have some groups displayed.
1176 (goto-char (point-max))
1177 (when (or (not gnus-group-goto-next-group-function)
1178 (not (funcall gnus-group-goto-next-group-function
1182 (goto-char (point-min)))
1184 ;; Go to the first group with unread articles.
1185 (gnus-group-search-forward t))
1187 ;; Find the right group to put point on. If the current group
1188 ;; has disappeared in the new listing, try to find the next
1189 ;; one. If no next one can be found, just leave point at the
1190 ;; first newsgroup in the buffer.
1191 (when (not (gnus-goto-char
1193 (point-min) (point-max)
1194 'gnus-group (gnus-intern-safe
1195 group gnus-active-hashtb))))
1196 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1198 (not (gnus-goto-char
1200 (point-min) (point-max) 'gnus-group
1202 (caar newsrc) gnus-active-hashtb)))))
1203 (setq newsrc (cdr newsrc)))
1205 (goto-char (point-max))
1206 (forward-line -1)))))))
1207 ;; Adjust cursor point.
1208 (gnus-group-position-point)))
1210 (defun gnus-group-list-level (level &optional all)
1211 "List groups on LEVEL.
1212 If ALL (the prefix), also list groups that have no unread articles."
1213 (interactive "nList groups on level: \nP")
1214 (gnus-group-list-groups level all level))
1216 (defun gnus-group-prepare-logic (group test)
1217 (or (and gnus-group-listed-groups
1218 (null gnus-group-list-option)
1219 (member group gnus-group-listed-groups))
1221 ((null gnus-group-listed-groups) test)
1222 ((null gnus-group-list-option) test)
1223 (t (and (member group gnus-group-listed-groups)
1224 (if (eq gnus-group-list-option 'flush)
1228 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1229 "List all newsgroups with unread articles of level LEVEL or lower.
1230 If PREDICATE is a function, list groups that the function returns non-nil;
1231 if it is t, list groups that have no unread articles.
1232 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1233 If REGEXP is a function, list dead groups that the function returns non-nil;
1234 if it is a string, only list groups matching REGEXP."
1235 (set-buffer gnus-group-buffer)
1236 (let ((buffer-read-only nil)
1237 (newsrc (cdr gnus-newsrc-alist))
1238 (lowest (or lowest 1))
1239 (not-in-list (and gnus-group-listed-groups
1240 (copy-sequence gnus-group-listed-groups)))
1241 info clevel unread group params)
1243 (when (or (< lowest gnus-level-zombie)
1244 gnus-group-listed-groups)
1245 ;; List living groups.
1247 (setq info (car newsrc)
1248 group (gnus-info-group info)
1249 params (gnus-info-params info)
1251 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1253 (setq not-in-list (delete group not-in-list)))
1254 (when (gnus-group-prepare-logic
1256 (and unread ; This group might be unchecked
1257 (or (not (stringp regexp))
1258 (string-match regexp group))
1259 (<= (setq clevel (gnus-info-level info)) level)
1262 ((functionp predicate)
1263 (funcall predicate info))
1264 (predicate t) ; We list all groups?
1267 (if (eq unread t) ; Unactivated?
1268 gnus-group-list-inactive-groups
1269 ; We list unactivated
1271 ; We list groups with unread articles
1272 (and gnus-list-groups-with-ticked-articles
1273 (cdr (assq 'tick (gnus-info-marks info))))
1274 ; And groups with tickeds
1275 ;; Check for permanent visibility.
1276 (and gnus-permanently-visible-groups
1277 (string-match gnus-permanently-visible-groups
1279 (memq 'visible params)
1280 (cdr (assq 'visible params)))))))
1281 (gnus-group-insert-group-line
1282 group (gnus-info-level info)
1283 (gnus-info-marks info) unread (gnus-info-method info)))))
1285 ;; List dead groups.
1286 (when (or gnus-group-listed-groups
1287 (and (>= level gnus-level-zombie)
1288 (<= lowest gnus-level-zombie)))
1289 (gnus-group-prepare-flat-list-dead
1290 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1291 gnus-level-zombie ?Z
1294 (dolist (group gnus-zombie-list)
1295 (setq not-in-list (delete group not-in-list))))
1296 (when (or gnus-group-listed-groups
1297 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1298 (gnus-group-prepare-flat-list-dead
1301 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1302 gnus-level-killed ?K regexp))
1304 (gnus-group-set-mode-line)
1305 (setq gnus-group-list-mode (cons level predicate))
1306 (gnus-run-hooks 'gnus-group-prepare-hook)
1309 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1310 ;; List zombies and killed lists somewhat faster, which was
1311 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1312 ;; this by ignoring the group format specification altogether.
1314 (if (> (length groups) gnus-group-listing-limit)
1316 (setq group (pop groups))
1317 (when (gnus-group-prepare-logic
1320 (and (stringp regexp) (string-match regexp group))
1321 (and (functionp regexp) (funcall regexp group))))
1322 (gnus-add-text-properties
1323 (point) (prog1 (1+ (point))
1324 (insert " " mark " *: "
1325 (gnus-group-decoded-name group)
1327 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1329 'gnus-level level))))
1331 (setq group (pop groups))
1332 (when (gnus-group-prepare-logic
1335 (and (stringp regexp) (string-match regexp group))
1336 (and (functionp regexp) (funcall regexp group))))
1337 (gnus-group-insert-group-line
1339 (let ((active (gnus-active group)))
1341 (if (zerop (cdr active))
1343 (- (1+ (cdr active)) (car active)))
1345 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1347 (defun gnus-group-update-group-line ()
1348 "Update the current line in the group buffer."
1349 (let* ((buffer-read-only nil)
1350 (group (gnus-group-group-name))
1351 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1352 gnus-group-indentation)
1355 (not (gnus-ephemeral-group-p group))
1357 (concat "(gnus-group-set-info '"
1358 (gnus-prin1-to-string (nth 2 entry))
1360 (setq gnus-group-indentation (gnus-group-group-indentation))
1362 (gnus-group-insert-group-line-info group)
1364 (gnus-group-position-point))))
1366 (defun gnus-group-insert-group-line-info (group)
1367 "Insert GROUP on the current line."
1368 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1369 (gnus-group-indentation (gnus-group-group-indentation))
1373 ;; (Un)subscribed group.
1374 (setq info (nth 2 entry))
1375 (gnus-group-insert-group-line
1376 group (gnus-info-level info) (gnus-info-marks info)
1377 (or (car entry) t) (gnus-info-method info)))
1378 ;; This group is dead.
1379 (gnus-group-insert-group-line
1381 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1383 (if (setq active (gnus-active group))
1384 (if (zerop (cdr active))
1386 (- (1+ (cdr active)) (car active)))
1388 (gnus-method-simplify (gnus-find-method-for-group group))))))
1390 (defun gnus-number-of-unseen-articles-in-group (group)
1391 (let* ((info (nth 2 (gnus-group-entry group)))
1392 (marked (gnus-info-marks info))
1393 (seen (cdr (assq 'seen marked)))
1394 (active (gnus-active group)))
1397 (length (gnus-uncompress-range
1398 (gnus-range-difference
1399 (gnus-range-difference (list active) (gnus-info-read info))
1402 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1403 gnus-tmp-marked number
1405 "Insert a group line in the group buffer."
1406 (let* ((gnus-tmp-method
1407 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1408 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1410 (gnus-tmp-active (gnus-active gnus-tmp-group))
1411 (gnus-tmp-number-total
1413 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1415 (gnus-tmp-number-of-unread
1416 (if (numberp number) (int-to-string (max 0 number))
1418 (gnus-tmp-number-of-read
1419 (if (numberp number)
1420 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1422 (gnus-tmp-subscribed
1423 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1424 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1425 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1427 (gnus-tmp-qualified-group
1428 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1429 group-name-charset))
1431 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1433 (gnus-tmp-newsgroup-description
1434 (if gnus-description-hashtb
1435 (or (gnus-group-name-decode
1436 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1437 group-name-charset) "")
1440 (if (and gnus-moderated-hashtb
1441 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1443 (gnus-tmp-moderated-string
1444 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1445 (gnus-tmp-group-icon "==&&==")
1446 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1447 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1448 (gnus-tmp-news-method-string
1450 (format "(%s:%s)" (car gnus-tmp-method)
1451 (cadr gnus-tmp-method)) ""))
1452 (gnus-tmp-marked-mark
1453 (if (and (numberp number)
1455 (cdr (assq 'tick gnus-tmp-marked)))
1457 (gnus-tmp-summary-live
1458 (if (and (not gnus-group-is-exiting-p)
1459 (gnus-buffer-live-p (gnus-summary-buffer-name
1462 (gnus-tmp-process-marked
1463 (if (member gnus-tmp-group gnus-group-marked)
1464 gnus-process-mark ? ))
1466 (or (and gnus-use-grouplens
1467 (bbb-grouplens-group-p gnus-tmp-group))
1469 (buffer-read-only nil)
1470 header gnus-tmp-header) ; passed as parameter to user-funcs.
1472 (gnus-add-text-properties
1476 (let ((gnus-tmp-group (gnus-group-name-decode
1477 gnus-tmp-group group-name-charset)))
1478 (eval gnus-group-line-format-spec)))
1479 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1480 gnus-unread ,(if (numberp number)
1481 (string-to-int gnus-tmp-number-of-unread)
1483 gnus-marked ,gnus-tmp-marked-mark
1484 gnus-indentation ,gnus-group-indentation
1485 gnus-level ,gnus-tmp-level))
1487 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1488 (gnus-run-hooks 'gnus-group-update-hook))
1490 ;; Allow XEmacs to remove front-sticky text properties.
1491 (gnus-group-remove-excess-properties)))
1493 (defun gnus-group-highlight-line ()
1494 "Highlight the current line according to `gnus-group-highlight'."
1495 (let* ((list gnus-group-highlight)
1497 (end (gnus-point-at-eol))
1498 ;; now find out where the line starts and leave point there.
1499 (beg (progn (beginning-of-line) (point)))
1500 (group (gnus-group-group-name))
1501 (entry (gnus-group-entry group))
1502 (unread (if (numberp (car entry)) (car entry) 0))
1503 (active (gnus-active group))
1504 (total (if active (1+ (- (cdr active) (car active))) 0))
1505 (info (nth 2 entry))
1506 (method (gnus-server-get-method group (gnus-info-method info)))
1507 (marked (gnus-info-marks info))
1508 (mailp (apply 'append
1511 (memq x (assoc (symbol-name
1512 (car (or method gnus-select-method)))
1513 gnus-valid-select-methods)))
1514 '(mail post-mail))))
1515 (level (or (gnus-info-level info) gnus-level-killed))
1516 (score (or (gnus-info-score info) 0))
1517 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1518 (group-age (gnus-group-timestamp-delta group))
1519 (inhibit-read-only t))
1520 ;; Eval the cars of the lists until we find a match.
1522 (not (eval (caar list))))
1523 (setq list (cdr list)))
1524 (let ((face (cdar list)))
1525 (unless (eq face (get-text-property beg 'face))
1526 (gnus-put-text-property-excluding-characters-with-faces
1528 (setq face (if (boundp face) (symbol-value face) face)))
1529 (gnus-extent-start-open beg)))
1532 (defun gnus-group-update-group (group &optional visible-only)
1533 "Update all lines where GROUP appear.
1534 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1536 ;; Can't use `save-excursion' here, so we do it manually.
1537 (let ((buf (current-buffer))
1539 (set-buffer gnus-group-buffer)
1540 (setq mark (point-marker))
1541 ;; The buffer may be narrowed.
1544 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1546 found buffer-read-only)
1547 ;; Enter the current status into the dribble buffer.
1548 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1550 (not (gnus-ephemeral-group-p group)))
1552 (concat "(gnus-group-set-info '"
1553 (gnus-prin1-to-string (nth 2 entry))
1555 ;; Find all group instances. If topics are in use, each group
1556 ;; may be listed in more than once.
1557 (while (setq loc (text-property-any
1558 loc (point-max) 'gnus-group ident))
1561 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1563 (gnus-group-insert-group-line-info group)
1566 (gnus-run-hooks 'gnus-group-update-group-hook)))
1567 (setq loc (1+ loc)))
1568 (unless (or found visible-only)
1569 ;; No such line in the buffer, find out where it's supposed to
1570 ;; go, and insert it there (or at the end of the buffer).
1571 (if gnus-goto-missing-group-function
1572 (funcall gnus-goto-missing-group-function group)
1573 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1574 (while (and entry (car entry)
1578 (point-min) (point-max)
1579 'gnus-group (gnus-intern-safe
1580 (caar entry) gnus-active-hashtb)))))
1581 (setq entry (cdr entry)))
1582 (or entry (goto-char (point-max)))))
1583 ;; Finally insert the line.
1584 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1585 (gnus-group-insert-group-line-info group)
1588 (gnus-run-hooks 'gnus-group-update-group-hook))))
1589 (when gnus-group-update-group-function
1590 (funcall gnus-group-update-group-function group))
1591 (gnus-group-set-mode-line)))
1593 (set-marker mark nil)
1596 (defun gnus-group-set-mode-line ()
1597 "Update the mode line in the group buffer."
1598 (when (memq 'group gnus-updated-mode-lines)
1599 ;; Yes, we want to keep this mode line updated.
1601 (set-buffer gnus-group-buffer)
1602 (let* ((gformat (or gnus-group-mode-line-format-spec
1603 (gnus-set-format 'group-mode)))
1604 (gnus-tmp-news-server (cadr gnus-select-method))
1605 (gnus-tmp-news-method (car gnus-select-method))
1606 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1608 gnus-tmp-header ;Dummy binding for user-defined formats
1609 ;; Get the resulting string.
1611 (and gnus-dribble-buffer
1612 (buffer-name gnus-dribble-buffer)
1613 (buffer-modified-p gnus-dribble-buffer)
1615 (set-buffer gnus-dribble-buffer)
1616 (not (zerop (buffer-size))))))
1617 (mode-string (eval gformat)))
1618 ;; Say whether the dribble buffer has been modified.
1619 (setq mode-line-modified
1620 (if modified (car gnus-mode-line-modified)
1621 (cdr gnus-mode-line-modified)))
1622 ;; If the line is too long, we chop it off.
1623 (when (> (length mode-string) max-len)
1624 (setq mode-string (substring mode-string 0 (- max-len 4))))
1626 (setq mode-line-buffer-identification
1627 (gnus-mode-line-buffer-identification
1628 (list mode-string)))
1629 (set-buffer-modified-p modified))))))
1631 (defun gnus-group-group-name ()
1632 "Get the name of the newsgroup on the current line."
1633 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1635 (symbol-name group))))
1637 (defun gnus-group-group-level ()
1638 "Get the level of the newsgroup on the current line."
1639 (get-text-property (gnus-point-at-bol) 'gnus-level))
1641 (defun gnus-group-group-indentation ()
1642 "Get the indentation of the newsgroup on the current line."
1643 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1644 (and gnus-group-indentation-function
1645 (funcall gnus-group-indentation-function))
1648 (defun gnus-group-group-unread ()
1649 "Get the number of unread articles of the newsgroup on the current line."
1650 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1652 (defun gnus-group-new-mail (group)
1653 (if (nnmail-new-mail-p (gnus-group-real-name group))
1657 (defun gnus-group-level (group)
1658 "Return the estimated level of GROUP."
1659 (or (gnus-info-level (gnus-get-info group))
1660 (and (member group gnus-zombie-list) gnus-level-zombie)
1663 (defun gnus-group-search-forward (&optional backward all level first-too)
1664 "Find the next newsgroup with unread articles.
1665 If BACKWARD is non-nil, find the previous newsgroup instead.
1666 If ALL is non-nil, just find any newsgroup.
1667 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1669 If FIRST-TOO, the current line is also eligible as a target."
1670 (let ((way (if backward -1 1))
1671 (low gnus-level-killed)
1674 (if (and backward (progn (beginning-of-line)) (bobp))
1683 (get-text-property (point) 'gnus-group)
1687 (get-text-property (point) 'gnus-unread)))
1688 (and (numberp unread) (> unread 0)))
1689 (setq lev (get-text-property (point)
1691 (<= lev gnus-level-subscribed)))
1693 (and (setq lev (get-text-property (point)
1702 (zerop (forward-line way)))))
1704 (progn (gnus-group-position-point) t)
1705 (goto-char (or pos beg))
1708 ;;; Gnus group mode commands
1712 (defun gnus-group-mark-line-p ()
1715 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1716 (eq (char-after) gnus-process-mark)))
1718 (defun gnus-group-mark-group (n &optional unmark no-advance)
1719 "Mark the current group."
1721 (let ((buffer-read-only nil)
1725 (when (setq group (gnus-group-group-name))
1726 ;; Go to the mark position.
1728 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1729 (subst-char-in-region
1730 (point) (1+ (point)) (char-after)
1733 (setq gnus-group-marked (delete group gnus-group-marked))
1735 (setq gnus-group-marked
1736 (cons group (delete group gnus-group-marked)))
1737 gnus-process-mark)))
1739 (gnus-group-next-group 1))
1741 (gnus-summary-position-point)
1744 (defun gnus-group-unmark-group (n)
1745 "Remove the mark from the current group."
1747 (gnus-group-mark-group n 'unmark)
1748 (gnus-group-position-point))
1750 (defun gnus-group-unmark-all-groups ()
1751 "Unmark all groups."
1753 (let ((groups gnus-group-marked))
1756 (gnus-group-remove-mark (pop groups)))))
1757 (gnus-group-position-point))
1759 (defun gnus-group-mark-region (unmark beg end)
1760 "Mark all groups between point and mark.
1761 If UNMARK, remove the mark instead."
1762 (interactive "P\nr")
1763 (let ((num (count-lines beg end)))
1766 (- num (gnus-group-mark-group num unmark)))))
1768 (defun gnus-group-mark-buffer (&optional unmark)
1769 "Mark all groups in the buffer.
1770 If UNMARK, remove the mark instead."
1772 (gnus-group-mark-region unmark (point-min) (point-max)))
1774 (defun gnus-group-mark-regexp (regexp)
1775 "Mark all groups that match some regexp."
1776 (interactive "sMark (regexp): ")
1777 (let ((alist (cdr gnus-newsrc-alist))
1780 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1781 (gnus-group-set-mark group))))
1782 (gnus-group-position-point))
1784 (defun gnus-group-remove-mark (group &optional test-marked)
1785 "Remove the process mark from GROUP and move point there.
1786 Return nil if the group isn't displayed."
1787 (if (gnus-group-goto-group group nil test-marked)
1789 (gnus-group-mark-group 1 'unmark t)
1791 (setq gnus-group-marked
1792 (delete group gnus-group-marked))
1795 (defun gnus-group-set-mark (group)
1796 "Set the process mark on GROUP."
1797 (if (gnus-group-goto-group group)
1799 (gnus-group-mark-group 1 nil t))
1800 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1802 (defun gnus-group-universal-argument (arg &optional groups func)
1803 "Perform any command on all groups according to the process/prefix convention."
1805 (if (eq (setq func (or func
1808 (substitute-command-keys
1809 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1811 (gnus-error 1 "Undefined key")
1812 (gnus-group-iterate arg
1814 (command-execute func))))
1815 (gnus-group-position-point))
1817 (defun gnus-group-process-prefix (n)
1818 "Return a list of groups to work on.
1819 Take into consideration N (the prefix) and the list of marked groups."
1822 (setq n (prefix-numeric-value n))
1823 ;; There is a prefix, so we return a list of the N next
1825 (let ((way (if (< n 0) -1 1))
1830 (if (setq group (gnus-group-group-name))
1831 (push group groups))
1833 (gnus-group-next-group way)))
1835 ((and (gnus-region-active-p) (mark))
1836 ;; Work on the region between point and mark.
1837 (let ((max (max (point) (mark)))
1840 (goto-char (min (point) (mark)))
1843 (push (gnus-group-group-name) groups)
1844 (zerop (gnus-group-next-group 1))
1846 (nreverse groups))))
1848 ;; No prefix, but a list of marked articles.
1849 (reverse gnus-group-marked))
1851 ;; Neither marked articles or a prefix, so we return the
1853 (let ((group (gnus-group-group-name)))
1854 (and group (list group))))))
1856 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1857 ;;; imagine why I went through these contortions...
1859 (let ((function (make-symbol "gnus-group-iterate-function"))
1860 (window (make-symbol "gnus-group-iterate-window"))
1861 (groups (make-symbol "gnus-group-iterate-groups"))
1862 (group (make-symbol "gnus-group-iterate-group")))
1864 `(defun gnus-group-iterate (arg ,function)
1865 "Iterate FUNCTION over all process/prefixed groups.
1866 FUNCTION will be called with the group name as the parameter
1867 and with point over the group in question."
1868 (let ((,groups (gnus-group-process-prefix arg))
1869 (,window (selected-window))
1872 (setq ,group (car ,groups)
1873 ,groups (cdr ,groups))
1874 (select-window ,window)
1875 (gnus-group-remove-mark ,group)
1876 (save-selected-window
1878 (funcall ,function ,group)))))))))
1880 (put 'gnus-group-iterate 'lisp-indent-function 1)
1882 ;; Selecting groups.
1884 (defun gnus-group-read-group (&optional all no-article group select-articles)
1885 "Read news in this newsgroup.
1886 If the prefix argument ALL is non-nil, already read articles become
1887 readable. IF ALL is a number, fetch this number of articles. If the
1888 optional argument NO-ARTICLE is non-nil, no article will be
1889 auto-selected upon group entry. If GROUP is non-nil, fetch that
1892 (let ((no-display (eq all 0))
1893 (group (or group (gnus-group-group-name)))
1894 number active marked entry)
1898 (error "No group on current line"))
1899 (setq marked (gnus-info-marks
1900 (nth 2 (setq entry (gnus-gethash
1901 group gnus-newsrc-hashtb)))))
1902 ;; This group might be a dead group. In that case we have to get
1903 ;; the number of unread articles from `gnus-active-hashtb'.
1905 (cond ((numberp all) all)
1907 ((setq active (gnus-active group))
1908 (- (1+ (cdr active)) (car active)))))
1909 (gnus-summary-read-group
1910 group (or all (and (numberp number)
1911 (zerop (+ number (gnus-range-length
1912 (cdr (assq 'tick marked)))
1914 (cdr (assq 'dormant marked)))))))
1915 no-article nil no-display nil select-articles)))
1917 (defun gnus-group-select-group (&optional all)
1918 "Select this newsgroup.
1919 No article is selected automatically.
1920 If the group is opened, just switch the summary buffer.
1921 If ALL is non-nil, already read articles become readable.
1922 If ALL is a number, fetch this number of articles."
1924 (when (and (eobp) (not (gnus-group-group-name)))
1926 (gnus-group-read-group all t))
1928 (defun gnus-group-quick-select-group (&optional all)
1929 "Select the current group \"quickly\".
1930 This means that no highlighting or scoring will be performed.
1931 If ALL (the prefix argument) is 0, don't even generate the summary
1934 This might be useful if you want to toggle threading
1935 before entering the group."
1937 (require 'gnus-score)
1939 gnus-score-find-score-files-function
1940 gnus-home-score-file
1941 gnus-apply-kill-hook
1942 gnus-summary-expunge-below)
1943 (gnus-group-read-group all t)))
1945 (defun gnus-group-visible-select-group (&optional all)
1946 "Select the current group without hiding any articles."
1948 (let ((gnus-inhibit-limiting t))
1949 (gnus-group-read-group all t)))
1951 (defun gnus-group-select-group-ephemerally ()
1952 "Select the current group without doing any processing whatsoever.
1953 You will actually be entered into a group that's a copy of
1954 the current group; no changes you make while in this group will
1957 (require 'gnus-score)
1959 gnus-score-find-score-files-function gnus-apply-kill-hook
1960 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1961 gnus-summary-mode-hook gnus-select-group-hook
1962 (group (gnus-group-group-name))
1963 (method (gnus-find-method-for-group group)))
1964 (gnus-group-read-ephemeral-group
1965 (gnus-group-prefixed-name group method) method)))
1968 (defun gnus-fetch-group (group &optional articles)
1969 "Start Gnus if necessary and enter GROUP.
1970 Returns whether the fetching was successful or not."
1971 (interactive (list (gnus-group-completing-read-group-name
1972 "Group name: " gnus-active-hashtb)))
1973 (unless (get-buffer gnus-group-buffer)
1975 (gnus-group-read-group articles nil group))
1978 (defun gnus-fetch-group-other-frame (group)
1979 "Pop up a frame and enter GROUP."
1981 (let ((window (get-buffer-window gnus-group-buffer)))
1983 (select-frame (window-frame window)))
1984 ((= (length (frame-list)) 1)
1985 (select-frame (make-frame)))
1988 (gnus-fetch-group group))
1990 (defvar gnus-ephemeral-group-server 0)
1992 ;; Enter a group that is not in the group buffer. Non-nil is returned
1993 ;; if selection was successful.
1994 (defun gnus-group-read-ephemeral-group (group method &optional activate
1995 quit-config request-only
1998 "Read GROUP from METHOD as an ephemeral group.
1999 If ACTIVATE, request the group first.
2000 If QUIT-CONFIG, use that window configuration when exiting from the
2002 If REQUEST-ONLY, don't actually read the group; just request it.
2003 If SELECT-ARTICLES, only select those articles.
2004 If PARAMETERS, use those as the group parameters.
2006 Return the name of the group if selection was successful."
2007 ;; Transform the select method into a unique server.
2008 (when (stringp method)
2009 (setq method (gnus-server-to-method method)))
2011 `(,(car method) ,(concat (cadr method) "-ephemeral")
2012 (,(intern (format "%s-address" (car method))) ,(cadr method))
2014 (let ((group (if (gnus-group-foreign-p group) group
2015 (gnus-group-prefixed-name (gnus-group-real-name group)
2020 ,gnus-level-default-subscribed nil nil ,method
2023 (cons 'quit-config quit-config)
2025 (cons gnus-summary-buffer
2026 gnus-current-window-configuration)))
2029 (push method gnus-ephemeral-servers)
2030 (set-buffer gnus-group-buffer)
2031 (unless (gnus-check-server method)
2032 (error "Unable to contact server: %s" (gnus-status-message method)))
2034 (gnus-activate-group group 'scan)
2035 (unless (gnus-request-group group)
2036 (error "Couldn't request group: %s"
2037 (nnheader-get-report (car method)))))
2041 (when (gnus-group-read-group t t group select-articles)
2045 (message "Quit reading the ephemeral group")
2048 (defun gnus-group-jump-to-group (group)
2049 "Jump to newsgroup GROUP."
2051 (list (gnus-group-completing-read-group-name
2052 "Group: " gnus-active-hashtb nil
2053 (gnus-read-active-file-p)
2054 gnus-group-jump-to-group-prompt
2055 'gnus-group-history)))
2057 (when (equal group "")
2058 (error "Empty group name"))
2060 (unless (gnus-ephemeral-group-p group)
2061 ;; Either go to the line in the group buffer...
2062 (unless (gnus-group-goto-group group)
2063 ;; ... or insert the line.
2064 (gnus-group-update-group group)
2065 (gnus-group-goto-group group)))
2066 ;; Adjust cursor point.
2067 (gnus-group-position-point))
2069 (defun gnus-group-goto-group (group &optional far test-marked)
2070 "Goto to newsgroup GROUP.
2071 If FAR, it is likely that the group is not on the current line.
2072 If TEST-MARKED, the line must be marked."
2076 ;; It's quite likely that we are on the right line, so
2077 ;; we check the current line first.
2079 (eq (get-text-property (point) 'gnus-group)
2080 (gnus-intern-safe group gnus-active-hashtb))
2081 (or (not test-marked) (gnus-group-mark-line-p)))
2083 ;; Previous and next line are also likely, so we check them as well.
2087 (and (eq (get-text-property (point) 'gnus-group)
2088 (gnus-intern-safe group gnus-active-hashtb))
2089 (or (not test-marked) (gnus-group-mark-line-p)))))
2095 (and (eq (get-text-property (point) 'gnus-group)
2096 (gnus-intern-safe group gnus-active-hashtb))
2097 (or (not test-marked) (gnus-group-mark-line-p)))))
2101 (goto-char (point-min))
2103 (while (and (not found)
2108 (gnus-intern-safe group gnus-active-hashtb))))
2109 (if (gnus-group-mark-line-p)
2114 ;; Search through the entire buffer.
2117 (point-min) (point-max)
2118 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2120 (defun gnus-group-next-group (n &optional silent)
2121 "Go to next N'th newsgroup.
2122 If N is negative, search backward instead.
2123 Returns the difference between N and the number of skips actually
2126 (gnus-group-next-unread-group n t nil silent))
2128 (defun gnus-group-next-unread-group (n &optional all level silent)
2129 "Go to next N'th unread newsgroup.
2130 If N is negative, search backward instead.
2131 If ALL is non-nil, choose any newsgroup, unread or not.
2132 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2133 such group can be found, the next group with a level higher than
2135 Returns the difference between N and the number of skips actually
2138 (let ((backward (< n 0))
2141 (gnus-group-search-forward
2142 backward (or (not gnus-group-goto-unread) all) level))
2146 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2147 (if level " on this level or higher" "")))
2150 (defun gnus-group-prev-group (n)
2151 "Go to previous N'th newsgroup.
2152 Returns the difference between N and the number of skips actually
2155 (gnus-group-next-unread-group (- n) t))
2157 (defun gnus-group-prev-unread-group (n)
2158 "Go to previous N'th unread newsgroup.
2159 Returns the difference between N and the number of skips actually
2162 (gnus-group-next-unread-group (- n)))
2164 (defun gnus-group-next-unread-group-same-level (n)
2165 "Go to next N'th unread newsgroup on the same level.
2166 If N is negative, search backward instead.
2167 Returns the difference between N and the number of skips actually
2170 (gnus-group-next-unread-group n t (gnus-group-group-level))
2171 (gnus-group-position-point))
2173 (defun gnus-group-prev-unread-group-same-level (n)
2174 "Go to next N'th unread newsgroup on the same level.
2175 Returns the difference between N and the number of skips actually
2178 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2179 (gnus-group-position-point))
2181 (defun gnus-group-best-unread-group (&optional exclude-group)
2182 "Go to the group with the highest level.
2183 If EXCLUDE-GROUP, do not go to that group."
2185 (goto-char (point-min))
2189 (setq unread (get-text-property (point) 'gnus-unread))
2190 (when (and (numberp unread) (> unread 0))
2191 (when (and (get-text-property (point) 'gnus-level)
2192 (< (get-text-property (point) 'gnus-level) best)
2193 (or (not exclude-group)
2194 (not (equal exclude-group (gnus-group-group-name)))))
2195 (setq best (get-text-property (point) 'gnus-level))
2196 (setq best-point (point))))
2199 (goto-char best-point))
2200 (gnus-group-position-point)
2201 (and best-point (gnus-group-group-name))))
2203 (defun gnus-group-first-unread-group ()
2204 "Go to the first group with unread articles."
2207 (let ((opoint (point))
2209 (goto-char (point-min))
2210 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2211 (and (numberp unread) ; Not a topic.
2212 (not (zerop unread))) ; Has unread articles.
2213 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2216 nil)) ; Not success.
2217 (gnus-group-position-point)))
2219 (defun gnus-group-enter-server-mode ()
2220 "Jump to the server buffer."
2222 (gnus-enter-server-buffer))
2224 (defun gnus-group-make-group (name &optional method address args)
2225 "Add a new newsgroup.
2226 The user will be prompted for a NAME, for a select METHOD, and an
2230 (gnus-read-group "Group name: ")
2231 (gnus-read-method "From method: ")))
2233 (when (stringp method)
2234 (setq method (or (gnus-server-to-method method) method)))
2235 (let* ((meth (gnus-method-simplify
2237 (not (gnus-server-equal method gnus-select-method)))
2238 (if address (list (intern method) address)
2240 (nname (if method (gnus-group-prefixed-name name meth) name))
2242 (when (gnus-gethash nname gnus-newsrc-hashtb)
2243 (error "Group %s already exists" nname))
2244 ;; Subscribe to the new group.
2245 (gnus-group-change-level
2246 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2247 gnus-level-default-subscribed gnus-level-killed
2248 (and (gnus-group-group-name)
2249 (gnus-gethash (gnus-group-group-name)
2250 gnus-newsrc-hashtb))
2253 (gnus-set-active nname (cons 1 0))
2254 (unless (gnus-ephemeral-group-p name)
2256 (concat "(gnus-group-set-info '"
2257 (gnus-prin1-to-string (cdr info)) ")")))
2259 (gnus-group-insert-group-line-info nname)
2261 (gnus-group-position-point)
2263 ;; Load the backend and try to make the backend create
2264 ;; the group as well.
2265 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2267 gnus-valid-select-methods)
2269 (gnus-check-server meth)
2270 (when (gnus-check-backend-function 'request-create-group nname)
2271 (unless (gnus-request-create-group nname nil args)
2272 (error "Could not create group on server: %s"
2273 (nnheader-get-report backend))))
2276 (defun gnus-group-delete-groups (&optional arg)
2277 "Delete the current group. Only meaningful with editable groups."
2279 (let ((n (length (gnus-group-process-prefix arg))))
2280 (when (gnus-yes-or-no-p
2282 "Delete this 1 group? "
2283 (format "Delete these %d groups? " n)))
2284 (gnus-group-iterate arg
2286 (gnus-group-delete-group group nil t))))))
2288 (defun gnus-group-delete-group (group &optional force no-prompt)
2289 "Delete the current group. Only meaningful with editable groups.
2290 If FORCE (the prefix) is non-nil, all the articles in the group will
2291 be deleted. This is \"deleted\" as in \"removed forever from the face
2292 of the Earth\". There is no undo. The user will be prompted before
2293 doing the deletion."
2295 (list (gnus-group-group-name)
2296 current-prefix-arg))
2298 (error "No group to delete"))
2299 (unless (gnus-check-backend-function 'request-delete-group group)
2300 (error "This backend does not support group deletion"))
2302 (if (and (not no-prompt)
2303 (not (gnus-yes-or-no-p
2305 "Do you really want to delete %s%s? "
2306 group (if force " and all its contents" "")))))
2308 (gnus-message 6 "Deleting group %s..." group)
2309 (if (not (gnus-request-delete-group group force))
2310 (gnus-error 3 "Couldn't delete group %s" group)
2311 (gnus-message 6 "Deleting group %s...done" group)
2312 (gnus-group-goto-group group)
2313 (gnus-group-kill-group 1 t)
2314 (gnus-sethash group nil gnus-active-hashtb)
2315 (when (and (boundp 'gnus-cache-active-hashtb)
2316 gnus-cache-active-hashtb)
2317 (gnus-sethash group nil gnus-cache-active-hashtb)
2318 (setq gnus-cache-active-altered t))
2320 (gnus-group-position-point)))
2322 (defun gnus-group-rename-group (group new-name)
2323 "Rename group from GROUP to NEW-NAME.
2324 When used interactively, GROUP is the group under point
2325 and NEW-NAME will be prompted for."
2328 (gnus-group-group-name)
2330 (unless (gnus-check-backend-function
2331 'request-rename-group (gnus-group-group-name))
2332 (error "This backend does not support renaming groups"))
2333 (gnus-read-group "Rename group to: "
2334 (gnus-group-real-name (gnus-group-group-name))))))
2336 (unless (gnus-check-backend-function 'request-rename-group group)
2337 (error "This backend does not support renaming groups"))
2339 (error "No group to rename"))
2340 (when (equal (gnus-group-real-name group) new-name)
2341 (error "Can't rename to the same name"))
2343 ;; We find the proper prefixed name.
2345 (if (gnus-group-native-p group)
2349 (gnus-group-prefixed-name
2350 (gnus-group-real-name new-name)
2351 (gnus-info-method (gnus-get-info group)))))
2353 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2356 (gnus-group-goto-group group)
2357 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2358 (gnus-request-rename-group group new-name))))
2359 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2360 ;; We rename the group internally by killing it...
2361 (gnus-group-kill-group)
2362 ;; ... changing its name ...
2363 (setcar (cdar gnus-list-of-killed-groups) new-name)
2364 ;; ... and then yanking it. Magic!
2365 (gnus-group-yank-group)
2366 (gnus-set-active new-name (gnus-active group))
2367 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2369 (setq gnus-killed-list (delete group gnus-killed-list))
2370 (gnus-set-active group nil)
2371 (gnus-dribble-touch)
2372 (gnus-group-position-point)))
2374 (defun gnus-group-edit-group (group &optional part)
2375 "Edit the group on the current line."
2376 (interactive (list (gnus-group-group-name)))
2377 (let ((part (or part 'info))
2380 (error "No group on current line"))
2381 (unless (setq info (gnus-get-info group))
2382 (error "Killed group; can't be edited"))
2384 (gnus-close-group group))
2386 ;; Find the proper form to edit.
2387 (cond ((eq part 'method)
2388 (or (gnus-info-method info) "native"))
2390 (gnus-info-params info))
2392 ;; The proper documentation.
2394 "Editing the %s for `%s'."
2396 ((eq part 'method) "select method")
2397 ((eq part 'params) "group parameters")
2399 (gnus-group-decoded-name group))
2401 (gnus-group-edit-group-done ',part ,group form)))
2404 (gnus-create-info-command
2407 "(gnus)Select Methods")
2409 "(gnus)Group Parameters")
2411 "(gnus)Group Info"))))))
2413 (defun gnus-group-edit-group-method (group)
2414 "Edit the select method of GROUP."
2415 (interactive (list (gnus-group-group-name)))
2416 (gnus-group-edit-group group 'method))
2418 (defun gnus-group-edit-group-parameters (group)
2419 "Edit the group parameters of GROUP."
2420 (interactive (list (gnus-group-group-name)))
2421 (gnus-group-edit-group group 'params))
2423 (defun gnus-group-edit-group-done (part group form)
2425 (let* ((method (cond ((eq part 'info) (nth 4 form))
2426 ((eq part 'method) form)
2428 (info (cond ((eq part 'info) form)
2429 ((eq part 'method) (gnus-get-info group))
2432 (if (or (not method)
2434 gnus-select-method method))
2435 (gnus-group-real-name (car info))
2436 (gnus-group-prefixed-name
2437 (gnus-group-real-name (car info)) method))
2439 (when (and new-group
2440 (not (equal new-group group)))
2441 (when (gnus-group-goto-group group)
2442 (gnus-group-kill-group 1))
2443 (gnus-activate-group new-group))
2445 (if (not (and info new-group))
2446 (gnus-group-set-info form (or new-group group) part)
2447 (setq info (gnus-copy-sequence info))
2448 (setcar info new-group)
2449 (unless (gnus-server-equal method "native")
2450 (unless (nthcdr 3 info)
2451 (nconc info (list nil nil)))
2452 (unless (nthcdr 4 info)
2453 (nconc info (list nil)))
2454 (gnus-info-set-method info method))
2455 (gnus-group-set-info info))
2456 (gnus-group-update-group (or new-group group))
2457 (gnus-group-position-point)))
2459 (defun gnus-group-make-useful-group (group method)
2460 "Create one of the groups described in `gnus-useful-groups'."
2462 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2464 gnus-useful-groups)))
2465 (list (cadr entry) (caddr entry))))
2466 (setq method (gnus-copy-sequence method))
2468 (while (setq entry (memq (assq 'eval method) method))
2469 (setcar entry (eval (cadar entry)))))
2470 (gnus-group-make-group group method))
2472 (defun gnus-group-make-help-group (&optional noerror)
2473 "Create the Gnus documentation group.
2474 Optional argument NOERROR modifies the behavior of this function when the
2475 group already exists:
2476 - if not given, and error is signaled,
2477 - if t, stay silent,
2478 - if anything else, just print a message."
2480 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2481 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2482 (if (gnus-gethash name gnus-newsrc-hashtb)
2483 (cond ((eq noerror nil)
2484 (error "Documentation group already exists"))
2489 (gnus-message 1 "Documentation group already exists")))
2492 (gnus-message 1 "Couldn't find doc group")
2493 (gnus-group-make-group
2494 (gnus-group-real-name name)
2495 (list 'nndoc "gnus-help"
2496 (list 'nndoc-address file)
2497 (list 'nndoc-article-type 'mbox))))
2499 (gnus-group-position-point))
2501 (defun gnus-group-make-doc-group (file type)
2502 "Create a group that uses a single file as the source."
2504 (list (read-file-name "File name: ")
2505 (and current-prefix-arg 'ask)))
2506 (when (eq type 'ask)
2511 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2513 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2514 ((= char ?b) 'babyl)
2515 ((= char ?d) 'digest)
2516 ((= char ?f) 'forward)
2518 ((= char ?g) 'guess)
2519 (t (setq err (format "%c unknown. " char))
2522 (let* ((file (expand-file-name file))
2523 (name (gnus-generate-new-group-name
2524 (gnus-group-prefixed-name
2525 (file-name-nondirectory file) '(nndoc "")))))
2526 (gnus-group-make-group
2527 (gnus-group-real-name name)
2529 (list 'nndoc-address file)
2530 (list 'nndoc-article-type (or type 'guess))))))
2532 (defvar nnweb-type-definition)
2533 (defvar gnus-group-web-type-history nil)
2534 (defvar gnus-group-web-search-history nil)
2535 (defun gnus-group-make-web-group (&optional solid)
2536 "Create an ephemeral nnweb group.
2537 If SOLID (the prefix), create a solid group."
2541 (if solid (gnus-read-group "Group name: ")
2542 (message-unique-id)))
2543 (default-type (or (car gnus-group-web-type-history)
2544 (symbol-name (caar nnweb-type-definition))))
2548 (format "Search engine type (default %s): " default-type)
2549 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2550 nnweb-type-definition)
2551 nil t nil 'gnus-group-web-type-history)
2556 (cons (or (car gnus-group-web-search-history) "") 0)
2557 'gnus-group-web-search-history))
2559 `(nnweb ,group (nnweb-search ,search)
2560 (nnweb-type ,(intern type))
2561 (nnweb-ephemeral-p t))))
2564 (gnus-pull 'nnweb-ephemeral-p method)
2565 (gnus-group-make-group group method))
2566 (gnus-group-read-ephemeral-group
2568 (cons (current-buffer)
2569 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2571 (eval-when-compile (defvar nnrss-group-alist)
2572 (defun nnrss-discover-feed (arg))
2573 (defun nnrss-save-server-data (arg)))
2574 (defun gnus-group-make-rss-group (&optional url)
2575 "Given a URL, discover if there is an RSS feed. If there is,
2576 use Gnus' to create an nnrss group"
2580 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2581 (let ((feedinfo (nnrss-discover-feed url)))
2583 (let ((title (read-from-minibuffer "Title: "
2586 (desc (read-from-minibuffer "Description: "
2587 (cdr (assoc 'description
2589 (href (cdr (assoc 'href feedinfo))))
2590 (push (list title href desc)
2592 (gnus-group-unsubscribe-group
2593 (concat "nnrss:" title))
2594 (nnrss-save-server-data nil))
2595 (error "No feeds found for %s" url))))
2597 (defvar nnwarchive-type-definition)
2598 (defvar gnus-group-warchive-type-history nil)
2599 (defvar gnus-group-warchive-login-history nil)
2600 (defvar gnus-group-warchive-address-history nil)
2602 (defun gnus-group-make-warchive-group ()
2603 "Create a nnwarchive group."
2605 (require 'nnwarchive)
2606 (let* ((group (gnus-read-group "Group name: "))
2607 (default-type (or (car gnus-group-warchive-type-history)
2608 (symbol-name (caar nnwarchive-type-definition))))
2612 (format "Warchive type (default %s): " default-type)
2613 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2614 nnwarchive-type-definition)
2615 nil t nil 'gnus-group-warchive-type-history)
2617 (address (read-string "Warchive address: "
2618 nil 'gnus-group-warchive-address-history))
2619 (default-login (or (car gnus-group-warchive-login-history)
2624 (format "Warchive login (default %s): " user-mail-address)
2625 default-login 'gnus-group-warchive-login-history)
2628 `(nnwarchive ,address
2629 (nnwarchive-type ,(intern type))
2630 (nnwarchive-login ,login))))
2631 (gnus-group-make-group group method)))
2633 (defun gnus-group-make-archive-group (&optional all)
2634 "Create the (ding) Gnus archive group of the most recent articles.
2635 Given a prefix, create a full group."
2637 (let ((group (gnus-group-prefixed-name
2638 (if all "ding.archives" "ding.recent") '(nndir ""))))
2639 (when (gnus-gethash group gnus-newsrc-hashtb)
2640 (error "Archive group already exists"))
2641 (gnus-group-make-group
2642 (gnus-group-real-name group)
2643 (list 'nndir (if all "hpc" "edu")
2644 (list 'nndir-directory
2645 (if all gnus-group-archive-directory
2646 gnus-group-recent-archive-directory))))
2647 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2649 (defun gnus-group-make-directory-group (dir)
2650 "Create an nndir group.
2651 The user will be prompted for a directory. The contents of this
2652 directory will be used as a newsgroup. The directory should contain
2653 mail messages or news articles in files that have numeric names."
2655 (list (read-file-name "Create group from directory: ")))
2656 (unless (file-exists-p dir)
2657 (error "No such directory"))
2658 (unless (file-directory-p dir)
2659 (error "Not a directory"))
2663 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2665 (gnus-group-prefixed-name
2666 (expand-file-name ext dir)
2668 (setq ext (format "<%d>" (setq i (1+ i)))))
2669 (gnus-group-make-group
2670 (gnus-group-real-name group)
2671 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2673 (eval-when-compile (defvar nnkiboze-score-file))
2674 (defun gnus-group-make-kiboze-group (group address scores)
2675 "Create an nnkiboze group.
2676 The user will be prompted for a name, a regexp to match groups, and
2677 score file entries for articles to include in the group."
2680 (read-string "nnkiboze group name: ")
2681 (read-string "Source groups (regexp): ")
2682 (let ((headers (mapcar (lambda (group) (list group))
2683 '("subject" "from" "number" "date" "message-id"
2684 "references" "chars" "lines" "xref"
2685 "followup" "all" "body" "head")))
2686 scores header regexp regexps)
2687 (while (not (equal "" (setq header (completing-read
2688 "Match on header: " headers nil t))))
2690 (while (not (equal "" (setq regexp (read-string
2691 (format "Match on %s (regexp): "
2693 (push (list regexp nil nil 'r) regexps))
2694 (push (cons header regexps) scores))
2696 (gnus-group-make-group group "nnkiboze" address)
2697 (let* ((nnkiboze-current-group group)
2698 (score-file (car (nnkiboze-score-file "")))
2699 (score-dir (file-name-directory score-file)))
2700 (unless (file-exists-p score-dir)
2701 (make-directory score-dir))
2702 (with-temp-file score-file
2703 (let (emacs-lisp-mode-hook)
2704 (pp scores (current-buffer))))))
2706 (defun gnus-group-add-to-virtual (n vgroup)
2707 "Add the current group to a virtual group."
2709 (list current-prefix-arg
2710 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2712 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2713 (error "%s is not an nnvirtual group" vgroup))
2714 (gnus-close-group vgroup)
2715 (let* ((groups (gnus-group-process-prefix n))
2716 (method (gnus-info-method (gnus-get-info vgroup))))
2717 (setcar (cdr method)
2719 (nth 1 method) "\\|"
2722 (gnus-group-remove-mark s)
2723 (concat "\\(^" (regexp-quote s) "$\\)"))
2725 (gnus-group-position-point))
2727 (defun gnus-group-make-empty-virtual (group)
2728 "Create a new, fresh, empty virtual group."
2729 (interactive "sCreate new, empty virtual group: ")
2730 (let* ((method (list 'nnvirtual "^$"))
2731 (pgroup (gnus-group-prefixed-name group method)))
2732 ;; Check whether it exists already.
2733 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2734 (error "Group %s already exists" pgroup))
2735 ;; Subscribe the new group after the group on the current line.
2736 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2737 (gnus-group-update-group pgroup)
2739 (gnus-group-position-point)))
2741 (defun gnus-group-enter-directory (dir)
2742 "Enter an ephemeral nneething group."
2743 (interactive "DDirectory to read: ")
2744 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2745 (leaf (gnus-group-prefixed-name
2746 (file-name-nondirectory (directory-file-name dir))
2748 (name (gnus-generate-new-group-name leaf)))
2749 (unless (gnus-group-read-ephemeral-group
2751 (cons (current-buffer)
2752 (if (eq major-mode 'gnus-summary-mode)
2754 (error "Couldn't enter %s" dir))))
2757 (autoload 'nnimap-expunge "nnimap")
2758 (autoload 'nnimap-acl-get "nnimap")
2759 (autoload 'nnimap-acl-edit "nnimap"))
2761 (defun gnus-group-nnimap-expunge (group)
2762 "Expunge deleted articles in current nnimap GROUP."
2763 (interactive (list (gnus-group-group-name)))
2764 (let ((mailbox (gnus-group-real-name group)) method)
2766 (error "No group on current line"))
2767 (unless (gnus-get-info group)
2768 (error "Killed group; can't be edited"))
2769 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2770 (error "%s is not an nnimap group" group))
2771 (nnimap-expunge mailbox (cadr method))))
2773 (defun gnus-group-nnimap-edit-acl (group)
2774 "Edit the Access Control List of current nnimap GROUP."
2775 (interactive (list (gnus-group-group-name)))
2776 (let ((mailbox (gnus-group-real-name group)) method acl)
2778 (error "No group on current line"))
2779 (unless (gnus-get-info group)
2780 (error "Killed group; can't be edited"))
2781 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2782 (error "%s is not an nnimap group" group))
2783 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2784 (error "Server does not support ACL's"))
2785 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2787 An access control list is a list of (identifier . rights) elements.
2789 The identifier string specifies the corresponding user. The
2790 identifier \"anyone\" is reserved to refer to the universal identity.
2792 Rights is a string listing a (possibly empty) set of alphanumeric
2793 characters, each character listing a set of operations which is being
2794 controlled. Letters are reserved for ``standard'' rights, listed
2795 below. Digits are reserved for implementation or site defined rights.
2797 l - lookup (mailbox is visible to LIST/LSUB commands)
2798 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2799 SEARCH, COPY from mailbox)
2800 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2801 w - write (STORE flags other than \\SEEN and \\DELETED)
2802 i - insert (perform APPEND, COPY into mailbox)
2803 p - post (send mail to submission address for mailbox,
2804 not enforced by IMAP4 itself)
2805 c - create and delete mailbox (CREATE new sub-mailboxes in any
2806 implementation-defined hierarchy, RENAME or DELETE mailbox)
2807 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2808 a - administer (perform SETACL)" group)
2811 ,mailbox ',method ',acl form)))))
2813 ;; Group sorting commands
2814 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2816 (defun gnus-group-sort-groups (func &optional reverse)
2817 "Sort the group buffer according to FUNC.
2818 When used interactively, the sorting function used will be
2819 determined by the `gnus-group-sort-function' variable.
2820 If REVERSE (the prefix), reverse the sorting order."
2821 (interactive (list gnus-group-sort-function current-prefix-arg))
2822 (funcall gnus-group-sort-alist-function
2823 (gnus-make-sort-function func) reverse)
2824 (gnus-group-unmark-all-groups)
2825 (gnus-group-list-groups)
2826 (gnus-dribble-touch))
2828 (defun gnus-group-sort-flat (func reverse)
2829 ;; We peel off the dummy group from the alist.
2831 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2832 (pop gnus-newsrc-alist))
2834 (setq gnus-newsrc-alist
2835 (sort gnus-newsrc-alist func))
2837 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2838 ;; Regenerate the hash table.
2839 (gnus-make-hashtable-from-newsrc-alist)))
2841 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2842 "Sort the group buffer alphabetically by group name.
2843 If REVERSE, sort in reverse order."
2845 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2847 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2848 "Sort the group buffer alphabetically by real (unprefixed) group name.
2849 If REVERSE, sort in reverse order."
2851 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2853 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2854 "Sort the group buffer by number of unread articles.
2855 If REVERSE, sort in reverse order."
2857 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2859 (defun gnus-group-sort-groups-by-level (&optional reverse)
2860 "Sort the group buffer by group level.
2861 If REVERSE, sort in reverse order."
2863 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2865 (defun gnus-group-sort-groups-by-score (&optional reverse)
2866 "Sort the group buffer by group score.
2867 If REVERSE, sort in reverse order."
2869 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2871 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2872 "Sort the group buffer by group rank.
2873 If REVERSE, sort in reverse order."
2875 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2877 (defun gnus-group-sort-groups-by-method (&optional reverse)
2878 "Sort the group buffer alphabetically by backend name.
2879 If REVERSE, sort in reverse order."
2881 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2883 (defun gnus-group-sort-groups-by-server (&optional reverse)
2884 "Sort the group buffer alphabetically by server name.
2885 If REVERSE, sort in reverse order."
2887 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2889 ;;; Selected group sorting.
2891 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2892 "Sort the process/prefixed groups."
2893 (interactive (list current-prefix-arg gnus-group-sort-function))
2894 (let ((groups (gnus-group-process-prefix n)))
2895 (funcall gnus-group-sort-selected-function
2896 groups (gnus-make-sort-function func) reverse)
2897 (gnus-group-unmark-all-groups)
2898 (gnus-group-list-groups)
2899 (gnus-dribble-touch)))
2901 (defun gnus-group-sort-selected-flat (groups func reverse)
2902 (let (entries infos)
2903 ;; First find all the group entries for these groups.
2905 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2907 ;; Then sort the infos.
2911 (lambda (entry) (car entry))
2912 (setq entries (nreverse entries)))
2915 (setq infos (nreverse infos)))
2916 ;; Go through all the infos and replace the old entries
2917 ;; with the new infos.
2919 (setcar (car entries) (pop infos))
2921 ;; Update the hashtable.
2922 (gnus-make-hashtable-from-newsrc-alist)))
2924 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2925 "Sort the group buffer alphabetically by group name.
2926 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2927 sort in reverse order."
2928 (interactive (gnus-interactive "P\ny"))
2929 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2931 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2932 "Sort the group buffer alphabetically by real group name.
2933 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2934 sort in reverse order."
2935 (interactive (gnus-interactive "P\ny"))
2936 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2938 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2939 "Sort the group buffer by number of unread articles.
2940 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2941 sort in reverse order."
2942 (interactive (gnus-interactive "P\ny"))
2943 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2945 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2946 "Sort the group buffer by group level.
2947 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2948 sort in reverse order."
2949 (interactive (gnus-interactive "P\ny"))
2950 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2952 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2953 "Sort the group buffer by group score.
2954 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2955 sort in reverse order."
2956 (interactive (gnus-interactive "P\ny"))
2957 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2959 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2960 "Sort the group buffer by group rank.
2961 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2962 sort in reverse order."
2963 (interactive (gnus-interactive "P\ny"))
2964 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2966 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2967 "Sort the group buffer alphabetically by backend name.
2968 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2969 sort in reverse order."
2970 (interactive (gnus-interactive "P\ny"))
2971 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2973 ;;; Sorting predicates.
2975 (defun gnus-group-sort-by-alphabet (info1 info2)
2976 "Sort alphabetically."
2977 (string< (gnus-info-group info1) (gnus-info-group info2)))
2979 (defun gnus-group-sort-by-real-name (info1 info2)
2980 "Sort alphabetically on real (unprefixed) names."
2981 (string< (gnus-group-real-name (gnus-info-group info1))
2982 (gnus-group-real-name (gnus-info-group info2))))
2984 (defun gnus-group-sort-by-unread (info1 info2)
2985 "Sort by number of unread articles."
2986 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2987 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2988 (< (or (and (numberp n1) n1) 0)
2989 (or (and (numberp n2) n2) 0))))
2991 (defun gnus-group-sort-by-level (info1 info2)
2993 (< (gnus-info-level info1) (gnus-info-level info2)))
2995 (defun gnus-group-sort-by-method (info1 info2)
2996 "Sort alphabetically by backend name."
2997 (string< (car (gnus-find-method-for-group
2998 (gnus-info-group info1) info1))
2999 (car (gnus-find-method-for-group
3000 (gnus-info-group info2) info2))))
3002 (defun gnus-group-sort-by-server (info1 info2)
3003 "Sort alphabetically by server name."
3004 (string< (gnus-method-to-full-server-name
3005 (gnus-find-method-for-group
3006 (gnus-info-group info1) info1))
3007 (gnus-method-to-full-server-name
3008 (gnus-find-method-for-group
3009 (gnus-info-group info2) info2))))
3011 (defun gnus-group-sort-by-score (info1 info2)
3012 "Sort by group score."
3013 (> (gnus-info-score info1) (gnus-info-score info2)))
3015 (defun gnus-group-sort-by-rank (info1 info2)
3016 "Sort by level and score."
3017 (let ((level1 (gnus-info-level info1))
3018 (level2 (gnus-info-level info2)))
3019 (or (< level1 level2)
3020 (and (= level1 level2)
3021 (> (gnus-info-score info1) (gnus-info-score info2))))))
3025 (defun gnus-group-clear-data (&optional arg)
3026 "Clear all marks and read ranges from the current group."
3028 (gnus-group-iterate arg
3031 (gnus-info-clear-data (setq info (gnus-get-info group)))
3032 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3033 (when (gnus-group-goto-group group)
3034 (gnus-group-update-group-line))))))
3036 (defun gnus-group-clear-data-on-native-groups ()
3037 "Clear all marks and read ranges from all native groups."
3039 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3040 (let ((alist (cdr gnus-newsrc-alist))
3042 (while (setq info (pop alist))
3043 (when (gnus-group-native-p (gnus-info-group info))
3044 (gnus-info-clear-data info)))
3045 (gnus-get-unread-articles)
3046 (gnus-dribble-touch)
3047 (when (gnus-y-or-n-p
3048 "Move the cache away to avoid problems in the future? ")
3049 (call-interactively 'gnus-cache-move-cache)))))
3051 (defun gnus-info-clear-data (info)
3052 "Clear all marks and read ranges from INFO."
3053 (let ((group (gnus-info-group info))
3055 (dolist (el (gnus-info-marks info))
3056 (push `(,(cdr el) add (,(car el))) action))
3057 (push `(,(gnus-info-read info) add (read)) action)
3060 (gnus-request-set-mark ,group ',action)
3061 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3062 (gnus-info-set-read ',info ',(gnus-info-read info))
3063 (when (gnus-group-goto-group ,group)
3064 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3065 (gnus-group-update-group-line))))
3066 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3068 (gnus-request-set-mark group action)
3069 (gnus-info-set-read info nil)
3070 (when (gnus-info-marks info)
3071 (gnus-info-set-marks info nil))))
3073 ;; Group catching up.
3075 (defun gnus-group-catchup-current (&optional n all)
3076 "Mark all unread articles in the current newsgroup as read.
3077 If prefix argument N is numeric, the next N newsgroups will be
3078 caught up. If ALL is non-nil, marked articles will also be marked as
3079 read. Cross references (Xref: header) of articles are ignored.
3080 The number of newsgroups that this function was unable to catch
3083 (let ((groups (gnus-group-process-prefix n))
3086 (unless groups (error "No groups selected"))
3088 (or (not gnus-interactive-catchup) ;Without confirmation?
3093 "Do you really want to mark all articles in %s as read? "
3094 "Mark all unread articles in %s as read? ")
3095 (if (= (length groups) 1)
3097 (format "these %d groups" (length groups)))))))
3099 (while (setq group (pop groups))
3100 (gnus-group-remove-mark group)
3101 ;; Virtual groups have to be given special treatment.
3102 (let ((method (gnus-find-method-for-group group)))
3103 (when (eq 'nnvirtual (car method))
3104 (nnvirtual-catchup-group
3105 (gnus-group-real-name group) (nth 1 method) all)))
3106 (if (>= (gnus-group-level group) gnus-level-zombie)
3107 (gnus-message 2 "Dead groups can't be caught up")
3109 (gnus-group-goto-group group)
3110 (gnus-group-catchup group all))
3111 (gnus-group-update-group-line)
3112 (setq ret (1+ ret)))))
3113 (gnus-group-next-unread-group 1)
3116 (defun gnus-group-catchup-current-all (&optional n)
3117 "Mark all articles in current newsgroup as read.
3118 Cross references (Xref: header) of articles are ignored."
3120 (gnus-group-catchup-current n 'all))
3122 (defun gnus-group-catchup (group &optional all)
3123 "Mark all articles in GROUP as read.
3124 If ALL is non-nil, all articles are marked as read.
3125 The return value is the number of articles that were marked as read,
3126 or nil if no action could be taken."
3127 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3129 (marks (nth 3 (nth 2 entry)))
3130 (unread (gnus-list-of-unread-articles group)))
3131 ;; Remove entries for this group.
3132 (nnmail-purge-split-history (gnus-group-real-name group))
3133 ;; Do the updating only if the newsgroup isn't killed.
3134 (if (not (numberp (car entry)))
3135 (gnus-message 1 "Can't catch up %s; non-active group" group)
3136 (gnus-update-read-articles group nil)
3138 ;; Nix out the lists of marks and dormants.
3139 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3141 (list (cdr (assq 'dormant marks))
3143 (setq unread (gnus-uncompress-range
3144 (gnus-range-add (gnus-range-add
3145 unread (cdr (assq 'dormant marks)))
3146 (cdr (assq 'tick marks)))))
3147 (gnus-add-marked-articles group 'tick nil nil 'force)
3148 (gnus-add-marked-articles group 'dormant nil nil 'force))
3149 ;; Do auto-expirable marks if that's required.
3150 (when (gnus-group-auto-expirable-p group)
3151 (gnus-add-marked-articles group 'expire unread)
3152 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3153 (let ((gnus-newsgroup-name group))
3154 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3157 (defun gnus-group-expire-articles (&optional n)
3158 "Expire all expirable articles in the current newsgroup.
3159 Uses the process/prefix convention."
3161 (let ((groups (gnus-group-process-prefix n))
3164 (error "No groups to expire"))
3165 (while (setq group (pop groups))
3166 (gnus-group-remove-mark group)
3167 (gnus-group-expire-articles-1 group)
3168 (gnus-dribble-touch)
3169 (gnus-group-position-point))))
3171 (defun gnus-group-expire-articles-1 (group)
3172 (when (gnus-check-backend-function 'request-expire-articles group)
3173 (gnus-message 6 "Expiring articles in %s..." group)
3174 (let* ((info (gnus-get-info group))
3175 (expirable (if (gnus-group-total-expirable-p group)
3176 (cons nil (gnus-list-of-read-articles group))
3177 (assq 'expire (gnus-info-marks info))))
3178 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3179 (nnmail-expiry-target
3180 (or (gnus-group-find-parameter group 'expiry-target)
3181 nnmail-expiry-target)))
3183 (gnus-check-group group)
3186 (gnus-compress-sequence
3188 ;; We set the expiry variables to the group
3190 (let ((nnmail-expiry-wait-function nil)
3191 (nnmail-expiry-wait expiry-wait))
3192 (gnus-request-expire-articles
3193 (gnus-uncompress-sequence (cdr expirable)) group))
3194 ;; Just expire using the normal expiry values.
3195 (gnus-request-expire-articles
3196 (gnus-uncompress-sequence (cdr expirable)) group))))
3197 (gnus-close-group group))
3198 (gnus-message 6 "Expiring articles in %s...done" group)
3199 ;; Return the list of un-expired articles.
3202 (defun gnus-group-expire-all-groups ()
3203 "Expire all expirable articles in all newsgroups."
3206 (gnus-message 5 "Expiring...")
3207 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3208 (cdr gnus-newsrc-alist))))
3209 (gnus-group-expire-articles nil)))
3210 (gnus-group-position-point)
3211 (gnus-message 5 "Expiring...done"))
3213 (defun gnus-group-set-current-level (n level)
3214 "Set the level of the next N groups to LEVEL."
3219 (let ((s (read-string
3220 (format "Level (default %s): "
3221 (or (gnus-group-group-level)
3222 gnus-level-default-subscribed)))))
3223 (if (string-match "^\\s-*$" s)
3224 (int-to-string (or (gnus-group-group-level)
3225 gnus-level-default-subscribed))
3227 (unless (and (>= level 1) (<= level gnus-level-killed))
3228 (error "Invalid level: %d" level))
3229 (let ((groups (gnus-group-process-prefix n))
3231 (while (setq group (pop groups))
3232 (gnus-group-remove-mark group)
3233 (gnus-message 6 "Changed level of %s from %d to %d"
3234 group (or (gnus-group-group-level) gnus-level-killed)
3236 (gnus-group-change-level
3237 group level (or (gnus-group-group-level) gnus-level-killed))
3238 (gnus-group-update-group-line)))
3239 (gnus-group-position-point))
3241 (defun gnus-group-unsubscribe (&optional n)
3242 "Unsubscribe the current group."
3244 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3246 (defun gnus-group-subscribe (&optional n)
3247 "Subscribe the current group."
3249 (gnus-group-unsubscribe-current-group n 'subscribe))
3251 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3252 "Toggle subscription of the current group.
3253 If given numerical prefix, toggle the N next groups."
3255 (let ((groups (gnus-group-process-prefix n))
3258 (setq group (car groups)
3259 groups (cdr groups))
3260 (gnus-group-remove-mark group)
3261 (gnus-group-unsubscribe-group
3264 ((eq do-sub 'unsubscribe)
3265 gnus-level-default-unsubscribed)
3266 ((eq do-sub 'subscribe)
3267 gnus-level-default-subscribed)
3268 ((<= (gnus-group-group-level) gnus-level-subscribed)
3269 gnus-level-default-unsubscribed)
3271 gnus-level-default-subscribed))
3273 (gnus-group-update-group-line))
3274 (gnus-group-next-group 1)))
3276 (defun gnus-group-unsubscribe-group (group &optional level silent)
3277 "Toggle subscription to GROUP.
3278 Killed newsgroups are subscribed. If SILENT, don't try to update the
3281 (list (gnus-group-completing-read-group-name
3282 "Group: " gnus-active-hashtb nil
3283 (gnus-read-active-file-p)
3285 'gnus-group-history)))
3286 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3288 ((string-match "^[ \t]*$" group)
3289 (error "Empty group name"))
3291 ;; Toggle subscription flag.
3292 (gnus-group-change-level
3293 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3294 gnus-level-subscribed)
3295 (1+ gnus-level-subscribed)
3296 gnus-level-default-subscribed)))
3298 (gnus-group-update-group group)))
3299 ((and (stringp group)
3300 (or (not (gnus-read-active-file-p))
3301 (gnus-active group)))
3302 ;; Add new newsgroup.
3303 (gnus-group-change-level
3305 (if level level gnus-level-default-subscribed)
3306 (or (and (member group gnus-zombie-list)
3309 (when (gnus-group-group-name)
3310 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3312 (gnus-group-update-group group)))
3313 (t (error "No such newsgroup: %s" group)))
3314 (gnus-group-position-point)))
3316 (defun gnus-group-transpose-groups (n)
3317 "Move the current newsgroup up N places.
3318 If given a negative prefix, move down instead. The difference between
3319 N and the number of steps taken is returned."
3321 (unless (gnus-group-group-name)
3322 (error "No group on current line"))
3323 (gnus-group-kill-group 1)
3325 (forward-line (- n))
3326 (gnus-group-yank-group)
3327 (gnus-group-position-point)))
3329 (defun gnus-group-kill-all-zombies (&optional dummy)
3330 "Kill all zombie newsgroups.
3331 The optional DUMMY should always be nil."
3332 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3334 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3335 (setq gnus-zombie-list nil)
3336 (gnus-dribble-touch)
3337 (gnus-group-list-groups)))
3339 (defun gnus-group-kill-region (begin end)
3340 "Kill newsgroups in current region (excluding current point).
3341 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3356 (beginning-of-line) ;Important when LINES < 1
3357 (gnus-group-kill-group lines)))
3359 (defun gnus-group-kill-group (&optional n discard)
3360 "Kill the next N groups.
3361 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3362 However, only groups that were alive can be yanked; already killed
3363 groups or zombie groups can't be yanked.
3364 The return value is the name of the group that was killed, or a list
3367 (let ((buffer-read-only nil)
3368 (groups (gnus-group-process-prefix n))
3369 group entry level out)
3370 (if (< (length groups) 10)
3371 ;; This is faster when there are few groups.
3373 (push (setq group (pop groups)) out)
3374 (gnus-group-remove-mark group)
3375 (setq level (gnus-group-group-level))
3377 (when (and (not discard)
3378 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3381 (gnus-group-goto-group ,(gnus-group-group-name))
3382 (gnus-group-yank-group)))
3383 (push (cons (car entry) (nth 2 entry))
3384 gnus-list-of-killed-groups))
3385 (gnus-group-change-level
3386 (if entry entry group) gnus-level-killed (if entry nil level))
3387 (message "Killed group %s" group))
3388 ;; If there are lots and lots of groups to be killed, we use
3389 ;; this thing instead.
3391 (setq groups (nreverse groups))
3393 (gnus-group-remove-mark (setq group (pop groups)))
3395 (push group gnus-killed-list)
3396 (setq gnus-newsrc-alist
3397 (delq (assoc group gnus-newsrc-alist)
3399 (when gnus-group-change-level-function
3400 (funcall gnus-group-change-level-function
3401 group gnus-level-killed 3))
3403 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3404 (push (cons (car entry) (nth 2 entry))
3405 gnus-list-of-killed-groups)
3406 (setcdr (cdr entry) (cdddr entry)))
3407 ((member group gnus-zombie-list)
3408 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3409 ;; There may be more than one instance displayed.
3410 (while (gnus-group-goto-group group)
3411 (gnus-delete-line)))
3412 (gnus-make-hashtable-from-newsrc-alist)))
3414 (gnus-group-position-point)
3415 (if (< (length out) 2) (car out) (nreverse out))))
3417 (defun gnus-group-yank-group (&optional arg)
3418 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3419 The numeric ARG specifies how many newsgroups are to be yanked. The
3420 name of the newsgroup yanked is returned, or (if several groups are
3421 yanked) a list of yanked groups is returned."
3423 (setq arg (or arg 1))
3424 (let (info group prev out)
3425 (while (>= (decf arg) 0)
3426 (when (not (setq info (pop gnus-list-of-killed-groups)))
3427 (error "No more newsgroups to yank"))
3428 (push (setq group (nth 1 info)) out)
3429 ;; Find which newsgroup to insert this one before - search
3430 ;; backward until something suitable is found. If there are no
3431 ;; other newsgroups in this buffer, just make this newsgroup the
3433 (setq prev (gnus-group-group-name))
3434 (gnus-group-change-level
3435 info (gnus-info-level (cdr info)) gnus-level-killed
3436 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3438 (gnus-group-insert-group-line-info group)
3440 `(when (gnus-group-goto-group ,group)
3441 (gnus-group-kill-group 1))))
3443 (gnus-group-position-point)
3444 (if (< (length out) 2) (car out) (nreverse out))))
3446 (defun gnus-group-kill-level (level)
3447 "Kill all groups that is on a certain LEVEL."
3448 (interactive "nKill all groups on level: ")
3450 ((= level gnus-level-zombie)
3451 (setq gnus-killed-list
3452 (nconc gnus-zombie-list gnus-killed-list))
3453 (setq gnus-zombie-list nil))
3454 ((and (< level gnus-level-zombie)
3456 (or gnus-expert-user
3459 "Do you really want to kill all groups on level %d? "
3461 (let* ((prev gnus-newsrc-alist)
3464 (if (= (gnus-info-level (car alist)) level)
3466 (push (gnus-info-group (car alist)) gnus-killed-list)
3467 (setcdr prev (cdr alist)))
3469 (setq alist (cdr alist)))
3470 (gnus-make-hashtable-from-newsrc-alist)
3471 (gnus-group-list-groups)))
3473 (error "Can't kill; invalid level: %d" level))))
3475 (defun gnus-group-list-all-groups (&optional arg)
3476 "List all newsgroups with level ARG or lower.
3477 Default is gnus-level-unsubscribed, which lists all subscribed and most
3478 unsubscribed groups."
3480 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3482 ;; Redefine this to list ALL killed groups if prefix arg used.
3483 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3484 (defun gnus-group-list-killed (&optional arg)
3485 "List all killed newsgroups in the group buffer.
3486 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3487 entail asking the server for the groups."
3489 ;; Find all possible killed newsgroups if arg.
3491 (gnus-get-killed-groups))
3492 (if (not gnus-killed-list)
3493 (gnus-message 6 "No killed groups")
3494 (let (gnus-group-list-mode)
3495 (funcall gnus-group-prepare-function
3496 gnus-level-killed t gnus-level-killed))
3497 (goto-char (point-min)))
3498 (gnus-group-position-point))
3500 (defun gnus-group-list-zombies ()
3501 "List all zombie newsgroups in the group buffer."
3503 (if (not gnus-zombie-list)
3504 (gnus-message 6 "No zombie groups")
3505 (let (gnus-group-list-mode)
3506 (funcall gnus-group-prepare-function
3507 gnus-level-zombie t gnus-level-zombie))
3508 (goto-char (point-min)))
3509 (gnus-group-position-point))
3511 (defun gnus-group-list-active ()
3512 "List all groups that are available from the server(s)."
3514 ;; First we make sure that we have really read the active file.
3515 (unless (gnus-read-active-file-p)
3516 (let ((gnus-read-active-file t)
3517 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3518 (gnus-read-active-file)))
3519 ;; Find all groups and sort them.
3527 (push (symbol-name sym) list)))
3531 (buffer-read-only nil)
3535 (setq group (pop groups))
3536 (gnus-add-text-properties
3537 (point) (prog1 (1+ (point))
3539 (gnus-group-decoded-name group)
3541 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3543 'gnus-level (inline (gnus-group-level group)))))
3544 (goto-char (point-min))))
3546 (defun gnus-activate-all-groups (level)
3547 "Activate absolutely all groups."
3548 (interactive (list gnus-level-unsubscribed))
3549 (let ((gnus-activate-level level)
3550 (gnus-activate-foreign-newsgroups level))
3551 (gnus-group-get-new-news)))
3553 (defun gnus-group-get-new-news (&optional arg)
3554 "Get newly arrived articles.
3555 If ARG is a number, it specifies which levels you are interested in
3556 re-scanning. If ARG is non-nil and not a number, this will force
3557 \"hard\" re-reading of the active files from all servers."
3560 (let ((gnus-inhibit-demon t)
3561 ;; Binding this variable will inhibit multiple fetchings
3562 ;; of the same mail source.
3563 (nnmail-fetched-sources (list t)))
3564 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3565 (gnus-run-hooks 'gnus-get-new-news-hook)
3567 ;; Read any slave files.
3569 (gnus-master-read-slave-newsrc))
3571 ;; We might read in new NoCeM messages here.
3572 (when (and gnus-use-nocem
3574 (gnus-nocem-scan-groups))
3575 ;; If ARG is not a number, then we read the active file.
3576 (when (and arg (not (numberp arg)))
3577 (let ((gnus-read-active-file t))
3578 (gnus-read-active-file))
3581 ;; If the user wants it, we scan for new groups.
3582 (when (eq gnus-check-new-newsgroups 'always)
3583 (gnus-find-new-newsgroups)))
3585 (setq arg (gnus-group-default-level arg t))
3586 (if (and gnus-read-active-file (not arg))
3588 (gnus-read-active-file)
3589 (gnus-get-unread-articles arg))
3590 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3591 (gnus-get-unread-articles arg)))
3592 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3593 (gnus-group-list-groups (and (numberp arg)
3594 (max (car gnus-group-list-mode) arg))))
3596 (when (and gnus-agent (not (interactive-p)))
3597 (gnus-agent-toggle-plugged gnus-plugged)))
3599 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3600 "Check for newly arrived news in the current group (and the N-1 next groups).
3601 The difference between N and the number of newsgroup checked is returned.
3602 If N is negative, this group and the N-1 previous groups will be checked."
3604 (let* ((groups (gnus-group-process-prefix n))
3605 (ret (if (numberp n) (- n (length groups)) 0))
3609 (gnus-inhibit-demon t)
3610 ;; Binding this variable will inhibit multiple fetchings
3611 ;; of the same mail source.
3612 (nnmail-fetched-sources (list t)))
3613 (gnus-run-hooks 'gnus-get-new-news-hook)
3614 (while (setq group (pop groups))
3615 (gnus-group-remove-mark group)
3616 ;; Bypass any previous denials from the server.
3617 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3618 (if (gnus-activate-group group (if dont-scan nil 'scan))
3620 (gnus-get-unread-articles-in-group
3621 (gnus-get-info group) (gnus-active group) t)
3622 (unless (gnus-virtual-group-p group)
3623 (gnus-close-group group))
3625 (gnus-agent-save-group-info
3626 method (gnus-group-real-name group) (gnus-active group)))
3627 (gnus-group-update-group group))
3628 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3630 (gnus-error 3 "Server denied access")
3631 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3634 (when gnus-goto-next-group-when-activating
3635 (gnus-group-next-unread-group 1 t))
3636 (gnus-summary-position-point)
3639 (defun gnus-group-fetch-faq (group &optional faq-dir)
3640 "Fetch the FAQ for the current group.
3641 If given a prefix argument, prompt for the FAQ dir
3645 (gnus-group-group-name)
3646 (when current-prefix-arg
3648 "FAQ dir: " (and (listp gnus-group-faq-directory)
3650 gnus-group-faq-directory))))))
3652 (error "No group name given"))
3653 (let ((dirs (or faq-dir gnus-group-faq-directory))
3655 (unless (listp dirs)
3656 (setq dirs (list dirs)))
3657 (while (and (not found)
3658 (setq dir (pop dirs)))
3659 (let ((name (gnus-group-real-name group)))
3660 (setq file (expand-file-name name dir)))
3661 (if (not (file-exists-p file))
3662 (gnus-message 1 "No such file: %s" file)
3663 (let ((enable-local-variables nil))
3667 (defun gnus-group-fetch-charter (group)
3668 "Fetch the charter for the current group.
3669 If given a prefix argument, prompt for a group."
3671 (list (or (when current-prefix-arg
3672 (completing-read "Group: " gnus-active-hashtb))
3673 (gnus-group-group-name)
3674 gnus-newsgroup-name)))
3676 (error "No group name given"))
3678 (condition-case nil (require 'url-http) (error nil))
3679 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3681 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3682 (setq hierarchy (match-string 1 name))
3683 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3684 (if (fboundp 'url-http-file-exists-p)
3685 (url-http-file-exists-p (eval url))
3687 (browse-url (eval url))
3688 (setq url (concat "http://" hierarchy
3689 ".news-admin.org/charters/" name))
3690 (if (and (fboundp 'url-http-file-exists-p)
3691 (url-http-file-exists-p url))
3693 (gnus-group-fetch-control group))))))
3695 (defun gnus-group-fetch-control (group)
3696 "Fetch the archived control messages for the current group.
3697 If given a prefix argument, prompt for a group."
3699 (list (or (when current-prefix-arg
3700 (completing-read "Group: " gnus-active-hashtb))
3701 (gnus-group-group-name)
3702 gnus-newsgroup-name)))
3704 (error "No group name given"))
3705 (let ((name (gnus-group-real-name group))
3707 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3708 (setq hierarchy (match-string 1 name))
3709 (if gnus-group-fetch-control-use-browse-url
3710 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3711 hierarchy "/" name ".Z"))
3712 (let ((enable-local-variables nil))
3713 (gnus-group-read-ephemeral-group
3715 `(nndoc ,group (nndoc-address
3716 ,(find-file-noselect
3717 (concat "/ftp@ftp.isc.org:/usenet/control/"
3718 hierarchy "/" name ".Z")))
3719 (nndoc-article-type mbox)) t nil nil))))))
3721 (defun gnus-group-describe-group (force &optional group)
3722 "Display a description of the current newsgroup."
3723 (interactive (list current-prefix-arg (gnus-group-group-name)))
3724 (let* ((method (gnus-find-method-for-group group))
3725 (mname (gnus-group-prefixed-name "" method))
3728 gnus-description-hashtb)
3729 (gnus-sethash mname nil gnus-description-hashtb))
3731 (error "No group name given"))
3732 (when (or (and gnus-description-hashtb
3733 ;; We check whether this group's method has been
3734 ;; queried for a description file.
3735 (gnus-gethash mname gnus-description-hashtb))
3736 (setq desc (gnus-group-get-description group))
3737 (gnus-read-descriptions-file method))
3739 (or desc (gnus-gethash group gnus-description-hashtb)
3740 "No description available")))))
3742 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3743 (defun gnus-group-describe-all-groups (&optional force)
3744 "Pop up a buffer with descriptions of all newsgroups."
3747 (setq gnus-description-hashtb nil))
3748 (when (not (or gnus-description-hashtb
3749 (gnus-read-all-descriptions-files)))
3750 (error "Couldn't request descriptions file"))
3751 (let ((buffer-read-only nil)
3757 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3758 (insert (format " *: %-20s %s\n"
3759 (gnus-group-name-decode
3760 (symbol-name group) charset)
3761 (gnus-group-name-decode
3762 (symbol-value group) charset))))
3763 (gnus-add-text-properties
3764 b (1+ b) (list 'gnus-group group
3765 'gnus-unread t 'gnus-marked nil
3766 'gnus-level (1+ gnus-level-subscribed))))
3767 gnus-description-hashtb)
3768 (goto-char (point-min))
3769 (gnus-group-position-point)))
3771 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3772 (defun gnus-group-apropos (regexp &optional search-description)
3773 "List all newsgroups that have names that match a regexp."
3774 (interactive "sGnus apropos (regexp): ")
3776 (obuf (current-buffer))
3778 ;; Go through all newsgroups that are known to Gnus.
3781 (and (symbol-name group)
3782 (string-match regexp (symbol-name group))
3783 (symbol-value group)
3784 (push (symbol-name group) groups)))
3786 ;; Also go through all descriptions that are known to Gnus.
3787 (when search-description
3790 (and (string-match regexp (symbol-value group))
3791 (push (symbol-name group) groups)))
3792 gnus-description-hashtb))
3794 (gnus-message 3 "No groups matched \"%s\"." regexp)
3795 ;; Print out all the groups.
3797 (pop-to-buffer "*Gnus Help*")
3798 (buffer-disable-undo)
3800 (setq groups (sort groups 'string<))
3802 ;; Groups may be entered twice into the list of groups.
3803 (when (not (string= (car groups) prev))
3804 (setq prev (car groups))
3805 (let ((charset (gnus-group-name-charset nil prev)))
3806 (insert (gnus-group-name-decode prev charset) "\n")
3807 (when (and gnus-description-hashtb
3808 (setq des (gnus-gethash (car groups)
3809 gnus-description-hashtb)))
3810 (insert " " (gnus-group-name-decode des charset) "\n"))))
3811 (setq groups (cdr groups)))
3812 (goto-char (point-min))))
3813 (pop-to-buffer obuf)))
3815 (defun gnus-group-description-apropos (regexp)
3816 "List all newsgroups that have names or descriptions that match a regexp."
3817 (interactive "sGnus description apropos (regexp): ")
3818 (when (not (or gnus-description-hashtb
3819 (gnus-read-all-descriptions-files)))
3820 (error "Couldn't request descriptions file"))
3821 (gnus-group-apropos regexp t))
3823 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3824 (defun gnus-group-list-matching (level regexp &optional all lowest)
3825 "List all groups with unread articles that match REGEXP.
3826 If the prefix LEVEL is non-nil, it should be a number that says which
3827 level to cut off listing groups.
3828 If ALL, also list groups with no unread articles.
3829 If LOWEST, don't list groups with level lower than LOWEST.
3831 This command may read the active file."
3832 (interactive "P\nsList newsgroups matching: ")
3833 ;; First make sure active file has been read.
3835 (> (prefix-numeric-value level) gnus-level-killed))
3836 (gnus-get-killed-groups))
3837 (funcall gnus-group-prepare-function
3838 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3839 (goto-char (point-min))
3840 (gnus-group-position-point))
3842 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3843 "List all groups that match REGEXP.
3844 If the prefix LEVEL is non-nil, it should be a number that says which
3845 level to cut off listing groups.
3846 If LOWEST, don't list groups with level lower than LOWEST."
3847 (interactive "P\nsList newsgroups matching: ")
3849 (setq level (prefix-numeric-value level)))
3850 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3852 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3853 (defun gnus-group-save-newsrc (&optional force)
3854 "Save the Gnus startup files.
3855 If FORCE, force saving whether it is necessary or not."
3857 (gnus-save-newsrc-file force))
3859 (defun gnus-group-restart (&optional arg)
3860 "Force Gnus to read the .newsrc file."
3862 (when (gnus-yes-or-no-p
3863 (format "Are you sure you want to restart Gnus? "))
3864 (gnus-save-newsrc-file)
3868 (defun gnus-group-read-init-file ()
3869 "Read the Gnus elisp init file."
3871 (gnus-read-init-file)
3872 (gnus-message 5 "Read %s" gnus-init-file))
3874 (defun gnus-group-check-bogus-groups (&optional silent)
3875 "Check bogus newsgroups.
3876 If given a prefix, don't ask for confirmation before removing a bogus
3879 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3880 (gnus-group-list-groups))
3882 (defun gnus-group-find-new-groups (&optional arg)
3883 "Search for new groups and add them.
3884 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3885 With 1 C-u, use the `ask-server' method to query the server for new
3887 With 2 C-u's, use most complete method possible to query the server
3888 for new groups, and subscribe the new groups as zombies."
3890 (gnus-find-new-newsgroups (or arg 1))
3891 (gnus-group-list-groups))
3893 (defun gnus-group-edit-global-kill (&optional article group)
3894 "Edit the global kill file.
3895 If GROUP, edit that local kill file instead."
3897 (setq gnus-current-kill-article article)
3898 (gnus-kill-file-edit-file group)
3901 (substitute-command-keys
3902 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3903 (if group "local" "global")))))
3905 (defun gnus-group-edit-local-kill (article group)
3906 "Edit a local kill file."
3907 (interactive (list nil (gnus-group-group-name)))
3908 (gnus-group-edit-global-kill article group))
3910 (defun gnus-group-force-update ()
3911 "Update `.newsrc' file."
3913 (gnus-save-newsrc-file))
3915 (defun gnus-group-suspend ()
3916 "Suspend the current Gnus session.
3917 In fact, cleanup buffers except for group mode buffer.
3918 The hook gnus-suspend-gnus-hook is called before actually suspending."
3920 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3921 (gnus-offer-save-summaries)
3922 ;; Kill Gnus buffers except for group mode buffer.
3923 (let ((group-buf (get-buffer gnus-group-buffer)))
3924 (mapcar (lambda (buf)
3925 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3929 (eq major-mode 'message-mode))))
3930 (gnus-kill-buffer buf)))
3932 (gnus-kill-gnus-frames)
3934 (bury-buffer group-buf)
3935 (delete-windows-on group-buf t))))
3937 (defun gnus-group-clear-dribble ()
3938 "Clear all information from the dribble buffer."
3940 (gnus-dribble-clear)
3941 (gnus-message 7 "Cleared dribble buffer"))
3943 (defun gnus-group-exit ()
3944 "Quit reading news after updating .newsrc.eld and .newsrc.
3945 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3948 (or noninteractive ;For gnus-batch-kill
3949 (not gnus-interactive-exit) ;Without confirmation
3951 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3952 (gnus-run-hooks 'gnus-exit-gnus-hook)
3953 ;; Offer to save data from non-quitted summary buffers.
3954 (gnus-offer-save-summaries)
3955 ;; Save the newsrc file(s).
3956 (gnus-save-newsrc-file)
3958 (gnus-close-backends)
3959 ;; Reset everything.
3961 ;; Allow the user to do things after cleaning up.
3962 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3964 (defun gnus-group-quit ()
3965 "Quit reading news without updating .newsrc.eld or .newsrc.
3966 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3968 (when (or noninteractive ;For gnus-batch-kill
3969 (zerop (buffer-size))
3970 (not (gnus-server-opened gnus-select-method))
3972 (not gnus-current-startup-file)
3974 (format "Quit reading news without saving %s? "
3975 (file-name-nondirectory gnus-current-startup-file))))
3976 (gnus-run-hooks 'gnus-exit-gnus-hook)
3977 (gnus-configure-windows 'group t)
3978 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3979 (not (zerop (save-excursion
3980 (set-buffer gnus-dribble-buffer)
3983 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3985 (gnus-close-backends)
3987 (gnus-kill-buffer gnus-group-buffer)
3988 ;; Allow the user to do things after cleaning up.
3989 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3991 (defun gnus-group-describe-briefly ()
3992 "Give a one line description of the group mode commands."
3994 (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")))
3996 (defun gnus-group-browse-foreign-server (method)
3997 "Browse a foreign news server.
3998 If called interactively, this function will ask for a select method
3999 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4000 If not, METHOD should be a list where the first element is the method
4001 and the second element is the address."
4003 (list (let ((how (completing-read
4005 (append gnus-valid-select-methods gnus-server-alist)
4006 nil t (cons "nntp" 0) 'gnus-method-history)))
4007 ;; We either got a backend name or a virtual server name.
4008 ;; If the first, we also need an address.
4009 (if (assoc how gnus-valid-select-methods)
4011 ;; Suggested by mapjph@bath.ac.uk.
4014 (mapcar (lambda (server) (list server))
4015 gnus-secondary-servers)))
4016 ;; We got a server name.
4018 (gnus-browse-foreign-server method))
4020 (defun gnus-group-set-info (info &optional method-only-group part)
4021 (when (or info part)
4022 (let* ((entry (gnus-gethash
4023 (or method-only-group (gnus-info-group info))
4024 gnus-newsrc-hashtb))
4026 (info (if method-only-group (nth 2 entry) info))
4028 (when method-only-group
4030 (error "Trying to change non-existent group %s" method-only-group))
4031 ;; We have received parts of the actual group info - either the
4032 ;; select method or the group parameters. We first check
4033 ;; whether we have to extend the info, and if so, do that.
4034 (let ((len (length info))
4035 (total (if (eq part 'method) 5 6)))
4037 (setcdr (nthcdr (1- len) info)
4038 (make-list (- total len) nil)))
4039 ;; Then we enter the new info.
4040 (setcar (nthcdr (1- total) info) part-info)))
4042 ;; This is a new group, so we just create it.
4044 (set-buffer gnus-group-buffer)
4045 (setq method (gnus-info-method info))
4046 (when (gnus-server-equal method "native")
4049 (set-buffer gnus-group-buffer)
4051 ;; It's a foreign group...
4052 (gnus-group-make-group
4053 (gnus-group-real-name (gnus-info-group info))
4054 (if (stringp method) method
4055 (prin1-to-string (car method)))
4057 (nth 1 (gnus-info-method info))))
4058 ;; It's a native group.
4059 (gnus-group-make-group (gnus-info-group info))))
4060 (gnus-message 6 "Note: New group created")
4062 (gnus-gethash (gnus-group-prefixed-name
4063 (gnus-group-real-name (gnus-info-group info))
4064 (or (gnus-info-method info) gnus-select-method))
4065 gnus-newsrc-hashtb))))
4066 ;; Whether it was a new group or not, we now have the entry, so we
4067 ;; can do the update.
4070 (setcar (nthcdr 2 entry) info)
4071 (when (and (not (eq (car entry) t))
4072 (gnus-active (gnus-info-group info)))
4073 (setcar entry (length
4074 (gnus-list-of-unread-articles (car info))))))
4075 (error "No such group: %s" (gnus-info-group info))))))
4077 (defun gnus-group-set-method-info (group select-method)
4078 (gnus-group-set-info select-method group 'method))
4080 (defun gnus-group-set-params-info (group params)
4081 (gnus-group-set-info params group 'params))
4083 (defun gnus-add-marked-articles (group type articles &optional info force)
4084 ;; Add ARTICLES of TYPE to the info of GROUP.
4085 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4086 ;; add, but replace marked articles of TYPE with ARTICLES.
4087 (let ((info (or info (gnus-get-info group)))
4090 (and (not (setq marked (nthcdr 3 info)))
4092 (setcdr (nthcdr 2 info)
4093 (list (list (cons type (gnus-compress-sequence
4095 (and (not (setq m (assq type (car marked))))
4098 (cons (cons type (gnus-compress-sequence articles t) )
4102 (setcar (nthcdr 3 info)
4103 (gnus-delete-alist type (car marked)))
4104 (setcdr m (gnus-compress-sequence articles t)))
4105 (setcdr m (gnus-compress-sequence
4106 (sort (nconc (gnus-uncompress-range (cdr m))
4107 (copy-sequence articles)) '<) t))))))
4109 (defun gnus-add-mark (group mark article)
4110 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4111 (let ((buffer (gnus-summary-buffer-name group)))
4112 (if (gnus-buffer-live-p buffer)
4114 (set-buffer (get-buffer buffer))
4115 (gnus-summary-add-mark article mark))
4116 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4120 ;;; Group timestamps
4123 (defun gnus-group-set-timestamp ()
4124 "Change the timestamp of the current group to the current time.
4125 This function can be used in hooks like `gnus-select-group-hook'
4126 or `gnus-group-catchup-group-hook'."
4127 (when gnus-newsgroup-name
4128 (let ((time (current-time)))
4129 (setcdr (cdr time) nil)
4130 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4132 (defsubst gnus-group-timestamp (group)
4133 "Return the timestamp for GROUP."
4134 (gnus-group-get-parameter group 'timestamp t))
4136 (defun gnus-group-timestamp-delta (group)
4137 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4138 (let* ((time (or (gnus-group-timestamp group)
4140 (delta (subtract-time (current-time) time)))
4141 (+ (* (nth 0 delta) 65536.0)
4144 (defun gnus-group-timestamp-string (group)
4145 "Return a string of the timestamp for GROUP."
4146 (let ((time (gnus-group-timestamp group)))
4149 (gnus-time-iso8601 time))))
4151 (defun gnus-group-list-cached (level &optional lowest)
4152 "List all groups with cached articles.
4153 If the prefix LEVEL is non-nil, it should be a number that says which
4154 level to cut off listing groups.
4155 If LOWEST, don't list groups with level lower than LOWEST.
4157 This command may read the active file."
4160 (setq level (prefix-numeric-value level)))
4161 (when (or (not level) (>= level gnus-level-zombie))
4163 (funcall gnus-group-prepare-function
4164 (or level gnus-level-subscribed)
4166 (let ((marks (gnus-info-marks info)))
4167 (assq 'cache marks)))
4170 (or (gnus-gethash group
4171 gnus-cache-active-hashtb)
4172 ;; Cache active file might use "."
4175 (mapconcat 'identity
4176 (split-string group ":")
4178 gnus-cache-active-hashtb))))
4179 (goto-char (point-min))
4180 (gnus-group-position-point))
4182 (defun gnus-group-list-dormant (level &optional lowest)
4183 "List all groups with dormant articles.
4184 If the prefix LEVEL is non-nil, it should be a number that says which
4185 level to cut off listing groups.
4186 If LOWEST, don't list groups with level lower than LOWEST.
4188 This command may read the active file."
4191 (setq level (prefix-numeric-value level)))
4192 (when (or (not level) (>= level gnus-level-zombie))
4194 (funcall gnus-group-prepare-function
4195 (or level gnus-level-subscribed)
4197 (let ((marks (gnus-info-marks info)))
4198 (assq 'dormant marks)))
4201 (goto-char (point-min))
4202 (gnus-group-position-point))
4204 (defun gnus-group-listed-groups ()
4205 "Return a list of listed groups."
4207 (goto-char (point-min))
4208 (while (setq point (text-property-not-all (point) (point-max)
4211 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4215 (defun gnus-group-list-plus (&optional args)
4216 "List groups plus the current selection."
4218 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4219 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4221 (push last-command-event unread-command-events)
4222 (if (featurep 'xemacs)
4223 (push (make-event 'key-press '(key ?A)) unread-command-events)
4224 (push ?A unread-command-events))
4225 (let (gnus-pick-mode keys)
4226 (setq keys (if (featurep 'xemacs)
4227 (events-to-keys (read-key-sequence nil))
4228 (read-key-sequence nil)))
4229 (setq func (lookup-key (current-local-map) keys)))
4233 (call-interactively func))))
4235 (defun gnus-group-list-flush (&optional args)
4236 "Flush groups from the current selection."
4238 (let ((gnus-group-list-option 'flush))
4239 (gnus-group-list-plus args)))
4241 (defun gnus-group-list-limit (&optional args)
4242 "List groups limited within the current selection."
4244 (let ((gnus-group-list-option 'limit))
4245 (gnus-group-list-plus args)))
4247 (defun gnus-group-mark-article-read (group article)
4248 "Mark ARTICLE read."
4249 (let ((buffer (gnus-summary-buffer-name group))
4250 (mark gnus-read-mark)
4252 (if (get-buffer buffer)
4253 (with-current-buffer buffer
4254 (setq active gnus-newsgroup-active)
4255 (gnus-activate-group group)
4256 (when gnus-newsgroup-prepared
4257 (when (and gnus-newsgroup-auto-expire
4258 (memq mark gnus-auto-expirable-marks))
4259 (setq mark gnus-expirable-mark))
4260 (setq mark (gnus-request-update-mark
4261 group article mark))
4262 (gnus-mark-article-as-read article mark)
4263 (setq gnus-newsgroup-active (gnus-active group))
4265 (setq n (1+ (cdr active)))
4266 (while (<= n (cdr gnus-newsgroup-active))
4267 (unless (eq n article)
4268 (push n gnus-newsgroup-unselected))
4270 (setq gnus-newsgroup-unselected
4271 (nreverse gnus-newsgroup-unselected)))))
4272 (gnus-activate-group group)
4273 (gnus-group-make-articles-read group (list article))
4274 (when (gnus-group-auto-expirable-p group)
4275 (gnus-add-marked-articles
4276 group 'expire (list article))))))
4278 (provide 'gnus-group)
4280 ;;; gnus-group.el ends here