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.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %U Number of unseen articles (integer)
160 %t Estimated total number of articles (integer)
161 %y Number of unread, unticked articles (integer)
162 %G Group name (string)
163 %g Qualified group name (string)
164 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
165 %C Group comment (string)
166 %D Group description (string)
167 %s Select method (string)
168 %o Moderated group (char, \"m\")
169 %p Process mark (char)
170 %B Whether a summary buffer for the group is open (char, \"*\")
171 %O Moderated group (string, \"(m)\" or \"\")
172 %P Topic indentation (string)
173 %m Whether there is new(ish) mail in the group (char, \"%\")
174 %l Whether there are GroupLens predictions for this group (string)
175 %n Select from where (string)
176 %z A string that look like `<%s:%n>' if a foreign select method is used
177 %d The date the group was last entered.
178 %E Icon as defined by `gnus-group-icon-list'.
179 %u User defined specifier. The next character in the format string should
180 be a letter. Gnus will call the function gnus-user-format-function-X,
181 where X is the letter following %u. The function will be passed a
182 single dummy parameter as argument.. The function should return a
183 string, which will be inserted into the buffer just like information
184 from any other group specifier.
186 Note that this format specification is not always respected. For
187 reasons of efficiency, when listing killed groups, this specification
188 is ignored altogether. If the spec is changed considerably, your
189 output may end up looking strange when listing both alive and killed
192 If you use %o or %O, reading the active file will be slower and quite
193 a bit of extra memory will be used. %D will also worsen performance.
194 Also note that if you change the format specification to include any
195 of these specs, you must probably re-start Gnus to see them go into
198 General format specifiers can also be used.
199 See Info node `(gnus)Formatting Variables'."
200 :link '(custom-manual "(gnus)Formatting Variables")
201 :group 'gnus-group-visual
204 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
205 "*The format specification for the group mode line.
206 It works along the same lines as a normal formatting string,
207 with some simple extensions:
209 %S The native news server.
210 %M The native select method.
211 %: \":\" if %S isn't \"\"."
212 :group 'gnus-group-visual
215 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
216 (when (featurep 'xemacs)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
218 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
220 (defcustom gnus-group-menu-hook nil
221 "Hook run after the creation of the group mode menu."
222 :group 'gnus-group-various
225 (defcustom gnus-group-catchup-group-hook nil
226 "Hook run when catching up a group from the group buffer."
227 :group 'gnus-group-various
228 :link '(custom-manual "(gnus)Group Data")
231 (defcustom gnus-group-update-group-hook nil
232 "Hook called when updating group lines."
233 :group 'gnus-group-visual
236 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
237 "*A function that is called to generate the group buffer.
238 The function is called with three arguments: The first is a number;
239 all group with a level less or equal to that number should be listed,
240 if the second is non-nil, empty groups should also be displayed. If
241 the third is non-nil, it is a number. No groups with a level lower
242 than this number should be displayed.
244 The only current function implemented is `gnus-group-prepare-flat'."
245 :group 'gnus-group-listing
248 (defcustom gnus-group-prepare-hook nil
249 "Hook called after the group buffer has been generated.
250 If you want to modify the group buffer, you can use this hook."
251 :group 'gnus-group-listing
254 (defcustom gnus-suspend-gnus-hook nil
255 "Hook called when suspending (not exiting) Gnus."
259 (defcustom gnus-exit-gnus-hook nil
260 "Hook called when exiting Gnus."
264 (defcustom gnus-after-exiting-gnus-hook nil
265 "Hook called after exiting Gnus."
269 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
270 "Hook called when a group line is changed.
271 The hook will not be called if `gnus-visual' is nil.
273 The default function `gnus-group-highlight-line' will
274 highlight the line according to the `gnus-group-highlight'
276 :group 'gnus-group-visual
279 (defcustom gnus-useful-groups
280 '(("(ding) mailing list mirrored at sunsite.auc.dk"
282 (nntp "sunsite.auc.dk"
283 (nntp-address "sunsite.auc.dk")))
286 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
290 (nndoc-article-type mbox)
291 (eval `(nndoc-address
292 ,(let ((file (nnheader-find-etc-directory
295 (error "Couldn't find doc group"))
297 "*Alist of useful group-server pairs."
298 :group 'gnus-group-listing
299 :type '(repeat (list (string :tag "Description")
301 (sexp :tag "Method"))))
303 (defcustom gnus-group-highlight
305 ((and mailp (= unread 0) (eq level 1)) .
306 gnus-group-mail-1-empty-face)
307 ((and mailp (eq level 1)) .
308 gnus-group-mail-1-face)
309 ((and mailp (= unread 0) (eq level 2)) .
310 gnus-group-mail-2-empty-face)
311 ((and mailp (eq level 2)) .
312 gnus-group-mail-2-face)
313 ((and mailp (= unread 0) (eq level 3)) .
314 gnus-group-mail-3-empty-face)
315 ((and mailp (eq level 3)) .
316 gnus-group-mail-3-face)
317 ((and mailp (= unread 0)) .
318 gnus-group-mail-low-empty-face)
320 gnus-group-mail-low-face)
322 ((and (= unread 0) (eq level 1)) .
323 gnus-group-news-1-empty-face)
324 ((and (eq level 1)) .
325 gnus-group-news-1-face)
326 ((and (= unread 0) (eq level 2)) .
327 gnus-group-news-2-empty-face)
328 ((and (eq level 2)) .
329 gnus-group-news-2-face)
330 ((and (= unread 0) (eq level 3)) .
331 gnus-group-news-3-empty-face)
332 ((and (eq level 3)) .
333 gnus-group-news-3-face)
334 ((and (= unread 0) (eq level 4)) .
335 gnus-group-news-4-empty-face)
336 ((and (eq level 4)) .
337 gnus-group-news-4-face)
338 ((and (= unread 0) (eq level 5)) .
339 gnus-group-news-5-empty-face)
340 ((and (eq level 5)) .
341 gnus-group-news-5-face)
342 ((and (= unread 0) (eq level 6)) .
343 gnus-group-news-6-empty-face)
344 ((and (eq level 6)) .
345 gnus-group-news-6-face)
346 ((and (= unread 0)) .
347 gnus-group-news-low-empty-face)
349 gnus-group-news-low-face))
350 "*Controls the highlighting of group buffer lines.
352 Below is a list of `Form'/`Face' pairs. When deciding how a a
353 particular group line should be displayed, each form is
354 evaluated. The content of the face field after the first true form is
355 used. You can change how those group lines are displayed by
356 editing the face field.
358 It is also possible to change and add form fields, but currently that
359 requires an understanding of Lisp expressions. Hopefully this will
360 change in a future release. For now, you can use the following
361 variables in the Lisp expression:
363 group: The name of the group.
364 unread: The number of unread articles in the group.
365 method: The select method used.
366 mailp: Whether it's a mail group or not.
367 level: The level of the group.
368 score: The score of the group.
369 ticked: The number of ticked articles."
370 :group 'gnus-group-visual
371 :type '(repeat (cons (sexp :tag "Form") face)))
373 (defcustom gnus-new-mail-mark ?%
374 "Mark used for groups with new mail."
375 :group 'gnus-group-visual
378 (defgroup gnus-group-icons nil
379 "Add Icons to your group buffer. "
380 :group 'gnus-group-visual)
382 (defcustom gnus-group-icon-list
384 "*Controls the insertion of icons into group buffer lines.
386 Below is a list of `Form'/`File' pairs. When deciding how a
387 particular group line should be displayed, each form is evaluated.
388 The icon from the file field after the first true form is used. You
389 can change how those group lines are displayed by editing the file
390 field. The File will either be found in the
391 `gnus-group-glyph-directory' or by designating absolute name of the
394 It is also possible to change and add form fields, but currently that
395 requires an understanding of Lisp expressions. Hopefully this will
396 change in a future release. For now, you can use the following
397 variables in the Lisp expression:
399 group: The name of the group.
400 unread: The number of unread articles in the group.
401 method: The select method used.
402 mailp: Whether it's a mail group or not.
403 newsp: Whether it's a news group or not
404 level: The level of the group.
405 score: The score of the group.
406 ticked: The number of ticked articles."
407 :group 'gnus-group-icons
408 :type '(repeat (cons (sexp :tag "Form") file)))
410 (defcustom gnus-group-name-charset-method-alist nil
411 "Alist of method and the charset for group names.
414 (((nntp \"news.com.cn\") . cn-gb-2312))"
417 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
419 (defcustom gnus-group-name-charset-group-alist
420 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
421 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
424 "Alist of group regexp and the charset for group names.
427 ((\"\\.com\\.cn:\" . cn-gb-2312))"
429 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
431 (defcustom gnus-group-jump-to-group-prompt nil
432 "Default prompt for `gnus-group-jump-to-group'.
433 If non-nil, the value should be a string, e.g. \"nnml:\",
434 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
435 in the minibuffer prompt."
436 :group 'gnus-group-various
437 :type '(choice (string :tag "Prompt string")
438 (const :tag "Empty" nil)))
440 (defvar gnus-group-listing-limit 1000
441 "*A limit of the number of groups when listing.
442 If the number of groups is larger than the limit, list them in a
445 ;;; Internal variables
447 (defvar gnus-group-is-exiting-p nil)
448 (defvar gnus-group-is-exiting-without-update-p nil)
449 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
450 "Function for sorting the group buffer.")
452 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
453 "Function for sorting the selected groups in the group buffer.")
455 (defvar gnus-group-indentation-function nil)
456 (defvar gnus-goto-missing-group-function nil)
457 (defvar gnus-group-update-group-function nil)
458 (defvar gnus-group-goto-next-group-function nil
459 "Function to override finding the next group after listing groups.")
461 (defvar gnus-group-edit-buffer nil)
463 (defvar gnus-group-line-format-alist
464 `((?M gnus-tmp-marked-mark ?c)
465 (?S gnus-tmp-subscribed ?c)
466 (?L gnus-tmp-level ?d)
467 (?N (cond ((eq number t) "*" )
471 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
472 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
474 (?R gnus-tmp-number-of-read ?s)
475 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
476 (?t gnus-tmp-number-total ?d)
477 (?y gnus-tmp-number-of-unread ?s)
478 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
479 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
480 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
481 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
482 (?g gnus-tmp-group ?s)
483 (?G gnus-tmp-qualified-group ?s)
484 (?c (gnus-short-group-name gnus-tmp-group) ?s)
485 (?C gnus-tmp-comment ?s)
486 (?D gnus-tmp-newsgroup-description ?s)
487 (?o gnus-tmp-moderated ?c)
488 (?O gnus-tmp-moderated-string ?s)
489 (?p gnus-tmp-process-marked ?c)
490 (?s gnus-tmp-news-server ?s)
491 (?n gnus-tmp-news-method ?s)
492 (?P gnus-group-indentation ?s)
493 (?E gnus-tmp-group-icon ?s)
494 (?B gnus-tmp-summary-live ?c)
495 (?l gnus-tmp-grouplens ?s)
496 (?z gnus-tmp-news-method-string ?s)
497 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
498 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
499 (?u gnus-tmp-user-defined ?s)))
501 (defvar gnus-group-mode-line-format-alist
502 `((?S gnus-tmp-news-server ?s)
503 (?M gnus-tmp-news-method ?s)
504 (?u gnus-tmp-user-defined ?s)
505 (?: gnus-tmp-colon ?s)))
507 (defvar gnus-topic-topology nil
508 "The complete topic hierarchy.")
510 (defvar gnus-topic-alist nil
511 "The complete topic-group alist.")
513 (defvar gnus-group-marked nil)
515 (defvar gnus-group-list-mode nil)
518 (defvar gnus-group-icon-cache nil)
520 (defvar gnus-group-listed-groups nil)
521 (defvar gnus-group-list-option nil)
527 (put 'gnus-group-mode 'mode-class 'special)
530 (gnus-define-keys gnus-group-mode-map
531 " " gnus-group-read-group
532 "=" gnus-group-select-group
533 "\r" gnus-group-select-group
534 "\M-\r" gnus-group-quick-select-group
535 "\M- " gnus-group-visible-select-group
536 [(meta control return)] gnus-group-select-group-ephemerally
537 "j" gnus-group-jump-to-group
538 "n" gnus-group-next-unread-group
539 "p" gnus-group-prev-unread-group
540 "\177" gnus-group-prev-unread-group
541 [delete] gnus-group-prev-unread-group
542 [backspace] gnus-group-prev-unread-group
543 "N" gnus-group-next-group
544 "P" gnus-group-prev-group
545 "\M-n" gnus-group-next-unread-group-same-level
546 "\M-p" gnus-group-prev-unread-group-same-level
547 "," gnus-group-best-unread-group
548 "." gnus-group-first-unread-group
549 "u" gnus-group-unsubscribe-current-group
550 "U" gnus-group-unsubscribe-group
551 "c" gnus-group-catchup-current
552 "C" gnus-group-catchup-current-all
553 "\M-c" gnus-group-clear-data
554 "l" gnus-group-list-groups
555 "L" gnus-group-list-all-groups
558 "g" gnus-group-get-new-news
559 "\M-g" gnus-group-get-new-news-this-group
560 "R" gnus-group-restart
561 "r" gnus-group-read-init-file
562 "B" gnus-group-browse-foreign-server
563 "b" gnus-group-check-bogus-groups
564 "F" gnus-group-find-new-groups
565 "\C-c\C-d" gnus-group-describe-group
566 "\M-d" gnus-group-describe-all-groups
567 "\C-c\C-a" gnus-group-apropos
568 "\C-c\M-\C-a" gnus-group-description-apropos
569 "a" gnus-group-post-news
570 "\ek" gnus-group-edit-local-kill
571 "\eK" gnus-group-edit-global-kill
572 "\C-k" gnus-group-kill-group
573 "\C-y" gnus-group-yank-group
574 "\C-w" gnus-group-kill-region
575 "\C-x\C-t" gnus-group-transpose-groups
576 "\C-c\C-l" gnus-group-list-killed
577 "\C-c\C-x" gnus-group-expire-articles
578 "\C-c\M-\C-x" gnus-group-expire-all-groups
580 "s" gnus-group-save-newsrc
581 "z" gnus-group-suspend
584 "?" gnus-group-describe-briefly
585 "\C-c\C-i" gnus-info-find-node
586 "\M-e" gnus-group-edit-group-method
587 "^" gnus-group-enter-server-mode
588 gnus-mouse-2 gnus-mouse-pick-group
589 "<" beginning-of-buffer
592 "\C-c\C-s" gnus-group-sort-groups
594 "\C-c\M-g" gnus-activate-all-groups
595 "\M-&" gnus-group-universal-argument
596 "#" gnus-group-mark-group
597 "\M-#" gnus-group-unmark-group)
599 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
600 "m" gnus-group-mark-group
601 "u" gnus-group-unmark-group
602 "w" gnus-group-mark-region
603 "b" gnus-group-mark-buffer
604 "r" gnus-group-mark-regexp
605 "U" gnus-group-unmark-all-groups)
607 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
608 "u" gnus-sieve-update
609 "g" gnus-sieve-generate)
611 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
612 "d" gnus-group-make-directory-group
613 "h" gnus-group-make-help-group
614 "u" gnus-group-make-useful-group
615 "a" gnus-group-make-archive-group
616 "k" gnus-group-make-kiboze-group
617 "l" gnus-group-nnimap-edit-acl
618 "m" gnus-group-make-group
619 "E" gnus-group-edit-group
620 "e" gnus-group-edit-group-method
621 "p" gnus-group-edit-group-parameters
622 "v" gnus-group-add-to-virtual
623 "V" gnus-group-make-empty-virtual
624 "D" gnus-group-enter-directory
625 "f" gnus-group-make-doc-group
626 "w" gnus-group-make-web-group
627 "r" gnus-group-rename-group
628 "R" gnus-group-make-rss-group
629 "c" gnus-group-customize
630 "x" gnus-group-nnimap-expunge
631 "\177" gnus-group-delete-group
632 [delete] gnus-group-delete-group)
634 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
635 "b" gnus-group-brew-soup
636 "w" gnus-soup-save-areas
637 "s" gnus-soup-send-replies
638 "p" gnus-soup-pack-packet
639 "r" nnsoup-pack-replies)
641 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
642 "s" gnus-group-sort-groups
643 "a" gnus-group-sort-groups-by-alphabet
644 "u" gnus-group-sort-groups-by-unread
645 "l" gnus-group-sort-groups-by-level
646 "v" gnus-group-sort-groups-by-score
647 "r" gnus-group-sort-groups-by-rank
648 "m" gnus-group-sort-groups-by-method
649 "n" gnus-group-sort-groups-by-real-name)
651 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
652 "s" gnus-group-sort-selected-groups
653 "a" gnus-group-sort-selected-groups-by-alphabet
654 "u" gnus-group-sort-selected-groups-by-unread
655 "l" gnus-group-sort-selected-groups-by-level
656 "v" gnus-group-sort-selected-groups-by-score
657 "r" gnus-group-sort-selected-groups-by-rank
658 "m" gnus-group-sort-selected-groups-by-method
659 "n" gnus-group-sort-selected-groups-by-real-name)
661 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
662 "k" gnus-group-list-killed
663 "z" gnus-group-list-zombies
664 "s" gnus-group-list-groups
665 "u" gnus-group-list-all-groups
666 "A" gnus-group-list-active
667 "a" gnus-group-apropos
668 "d" gnus-group-description-apropos
669 "m" gnus-group-list-matching
670 "M" gnus-group-list-all-matching
671 "l" gnus-group-list-level
672 "c" gnus-group-list-cached
673 "?" gnus-group-list-dormant)
675 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
676 "k" gnus-group-list-limit
677 "z" gnus-group-list-limit
678 "s" gnus-group-list-limit
679 "u" gnus-group-list-limit
680 "A" gnus-group-list-limit
681 "m" gnus-group-list-limit
682 "M" gnus-group-list-limit
683 "l" gnus-group-list-limit
684 "c" gnus-group-list-limit
685 "?" gnus-group-list-limit)
687 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
688 "k" gnus-group-list-flush
689 "z" gnus-group-list-flush
690 "s" gnus-group-list-flush
691 "u" gnus-group-list-flush
692 "A" gnus-group-list-flush
693 "m" gnus-group-list-flush
694 "M" gnus-group-list-flush
695 "l" gnus-group-list-flush
696 "c" gnus-group-list-flush
697 "?" gnus-group-list-flush)
699 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
700 "k" gnus-group-list-plus
701 "z" gnus-group-list-plus
702 "s" gnus-group-list-plus
703 "u" gnus-group-list-plus
704 "A" gnus-group-list-plus
705 "m" gnus-group-list-plus
706 "M" gnus-group-list-plus
707 "l" gnus-group-list-plus
708 "c" gnus-group-list-plus
709 "?" gnus-group-list-plus)
711 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
712 "f" gnus-score-flush-cache)
714 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
715 "c" gnus-group-fetch-charter
716 "C" gnus-group-fetch-control
717 "d" gnus-group-describe-group
718 "f" gnus-group-fetch-faq
721 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
722 "l" gnus-group-set-current-level
723 "t" gnus-group-unsubscribe-current-group
724 "s" gnus-group-unsubscribe-group
725 "k" gnus-group-kill-group
726 "y" gnus-group-yank-group
727 "w" gnus-group-kill-region
728 "\C-k" gnus-group-kill-level
729 "z" gnus-group-kill-all-zombies))
731 (defun gnus-topic-mode-p ()
732 "Return non-nil in `gnus-topic-mode'."
733 (and (boundp 'gnus-topic-mode)
734 (symbol-value 'gnus-topic-mode)))
736 (defun gnus-group-make-menu-bar ()
737 (gnus-turn-off-edit-menu 'group)
738 (unless (boundp 'gnus-group-reading-menu)
741 gnus-group-reading-menu gnus-group-mode-map ""
743 ["Read" gnus-group-read-group
744 :included (not (gnus-topic-mode-p))
745 :active (gnus-group-group-name)]
746 ["Read " gnus-topic-read-group
747 :included (gnus-topic-mode-p)]
748 ["Select" gnus-group-select-group
749 :included (not (gnus-topic-mode-p))
750 :active (gnus-group-group-name)]
751 ["Select " gnus-topic-select-group
752 :included (gnus-topic-mode-p)]
753 ["See old articles" (gnus-group-select-group 'all)
754 :keys "C-u SPC" :active (gnus-group-group-name)]
755 ["Catch up" gnus-group-catchup-current
756 :included (not (gnus-topic-mode-p))
757 :active (gnus-group-group-name)
758 ,@(if (featurep 'xemacs) nil
759 '(:help "Mark unread articles in the current group as read"))]
760 ["Catch up " gnus-topic-catchup-articles
761 :included (gnus-topic-mode-p)
762 ,@(if (featurep 'xemacs) nil
763 '(:help "Mark unread articles in the current group or topic as read"))]
764 ["Catch up all articles" gnus-group-catchup-current-all
765 (gnus-group-group-name)]
766 ["Check for new articles" gnus-group-get-new-news-this-group
767 :included (not (gnus-topic-mode-p))
768 :active (gnus-group-group-name)
769 ,@(if (featurep 'xemacs) nil
770 '(:help "Check for new messages in current group"))]
771 ["Check for new articles " gnus-topic-get-new-news-this-topic
772 :included (gnus-topic-mode-p)
773 ,@(if (featurep 'xemacs) nil
774 '(:help "Check for new messages in current group or topic"))]
775 ["Toggle subscription" gnus-group-unsubscribe-current-group
776 (gnus-group-group-name)]
777 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
778 ,@(if (featurep 'xemacs) nil
779 '(:help "Kill (remove) current group"))]
780 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
781 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
782 ,@(if (featurep 'xemacs) nil
783 '(:help "Display description of the current group"))]
784 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
785 ["Fetch charter" gnus-group-fetch-charter
786 :active (gnus-group-group-name)
787 ,@(if (featurep 'xemacs) nil
788 '(:help "Display the charter of the current group"))]
789 ["Fetch control message" gnus-group-fetch-control
790 :active (gnus-group-group-name)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Display the archived control message for the current group"))]
793 ;; Actually one should check, if any of the marked groups gives t for
794 ;; (gnus-check-backend-function 'request-expire-articles ...)
795 ["Expire articles" gnus-group-expire-articles
796 :included (not (gnus-topic-mode-p))
797 :active (or (and (gnus-group-group-name)
798 (gnus-check-backend-function
799 'request-expire-articles
800 (gnus-group-group-name))) gnus-group-marked)]
801 ["Expire articles " gnus-topic-expire-articles
802 :included (gnus-topic-mode-p)]
803 ["Set group level..." gnus-group-set-current-level
804 (gnus-group-group-name)]
805 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
806 ["Customize" gnus-group-customize (gnus-group-group-name)]
808 ["Parameters" gnus-group-edit-group-parameters
809 :included (not (gnus-topic-mode-p))
810 :active (gnus-group-group-name)]
811 ["Parameters " gnus-topic-edit-parameters
812 :included (gnus-topic-mode-p)]
813 ["Select method" gnus-group-edit-group-method
814 (gnus-group-group-name)]
815 ["Info" gnus-group-edit-group (gnus-group-group-name)]
816 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
817 ["Global kill file" gnus-group-edit-global-kill t])))
820 gnus-group-group-menu gnus-group-mode-map ""
823 ["List unread subscribed groups" gnus-group-list-groups t]
824 ["List (un)subscribed groups" gnus-group-list-all-groups t]
825 ["List killed groups" gnus-group-list-killed gnus-killed-list]
826 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
827 ["List level..." gnus-group-list-level t]
828 ["Describe all groups" gnus-group-describe-all-groups t]
829 ["Group apropos..." gnus-group-apropos t]
830 ["Group and description apropos..." gnus-group-description-apropos t]
831 ["List groups matching..." gnus-group-list-matching t]
832 ["List all groups matching..." gnus-group-list-all-matching t]
833 ["List active file" gnus-group-list-active t]
834 ["List groups with cached" gnus-group-list-cached t]
835 ["List groups with dormant" gnus-group-list-dormant t])
837 ["Default sort" gnus-group-sort-groups t]
838 ["Sort by method" gnus-group-sort-groups-by-method t]
839 ["Sort by rank" gnus-group-sort-groups-by-rank t]
840 ["Sort by score" gnus-group-sort-groups-by-score t]
841 ["Sort by level" gnus-group-sort-groups-by-level t]
842 ["Sort by unread" gnus-group-sort-groups-by-unread t]
843 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
844 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
845 ("Sort process/prefixed"
846 ["Default sort" gnus-group-sort-selected-groups
847 (not (gnus-topic-mode-p))]
848 ["Sort by method" gnus-group-sort-selected-groups-by-method
849 (not (gnus-topic-mode-p))]
850 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
851 (not (gnus-topic-mode-p))]
852 ["Sort by score" gnus-group-sort-selected-groups-by-score
853 (not (gnus-topic-mode-p))]
854 ["Sort by level" gnus-group-sort-selected-groups-by-level
855 (not (gnus-topic-mode-p))]
856 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
857 (not (gnus-topic-mode-p))]
858 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
859 (not (gnus-topic-mode-p))]
860 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
861 (not (gnus-topic-mode-p))])
863 ["Mark group" gnus-group-mark-group
864 (and (gnus-group-group-name)
865 (not (memq (gnus-group-group-name) gnus-group-marked)))]
866 ["Unmark group" gnus-group-unmark-group
867 (and (gnus-group-group-name)
868 (memq (gnus-group-group-name) gnus-group-marked))]
869 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
870 ["Mark regexp..." gnus-group-mark-regexp t]
871 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
872 ["Mark buffer" gnus-group-mark-buffer t]
873 ["Execute command" gnus-group-universal-argument
874 (or gnus-group-marked (gnus-group-group-name))])
876 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
877 ["Kill all newsgroups in region" gnus-group-kill-region
878 :active (gnus-mark-active-p)]
879 ["Kill all zombie groups" gnus-group-kill-all-zombies
881 ["Kill all groups on level..." gnus-group-kill-level t])
883 ["Make a foreign group..." gnus-group-make-group t]
884 ["Add a directory group..." gnus-group-make-directory-group t]
885 ["Add the help group" gnus-group-make-help-group t]
886 ["Add the archive group" gnus-group-make-archive-group t]
887 ["Make a doc group..." gnus-group-make-doc-group t]
888 ["Make a web group..." gnus-group-make-web-group t]
889 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
890 ["Make a virtual group..." gnus-group-make-empty-virtual t]
891 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
892 ["Rename group..." gnus-group-rename-group
893 (gnus-check-backend-function
894 'request-rename-group (gnus-group-group-name))]
895 ["Delete group" gnus-group-delete-group
896 (gnus-check-backend-function
897 'request-delete-group (gnus-group-group-name))])
899 ["Next" gnus-group-next-group t]
900 ["Previous" gnus-group-prev-group t]
901 ["Next unread" gnus-group-next-unread-group t]
902 ["Previous unread" gnus-group-prev-unread-group t]
903 ["Next unread same level" gnus-group-next-unread-group-same-level t]
904 ["Previous unread same level"
905 gnus-group-prev-unread-group-same-level t]
906 ["Jump to group..." gnus-group-jump-to-group t]
907 ["First unread group" gnus-group-first-unread-group t]
908 ["Best unread group" gnus-group-best-unread-group t])
910 ["Generate" gnus-sieve-generate t]
911 ["Generate and update" gnus-sieve-update t])
912 ["Delete bogus groups" gnus-group-check-bogus-groups t]
913 ["Find new newsgroups" gnus-group-find-new-groups t]
914 ["Transpose" gnus-group-transpose-groups
915 (gnus-group-group-name)]
916 ["Read a directory as a group..." gnus-group-enter-directory t]))
919 gnus-group-misc-menu gnus-group-mode-map ""
922 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
923 ["Send replies" gnus-soup-send-replies
924 (fboundp 'gnus-soup-pack-packet)]
925 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
926 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
927 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
928 ["Send a mail" gnus-group-mail t]
929 ["Send a message (mail or news)" gnus-group-post-news t]
930 ["Create a local message" gnus-group-news t]
931 ["Check for new news" gnus-group-get-new-news
932 ,@(if (featurep 'xemacs) '(t)
933 '(:help "Get newly arrived articles"))
935 ["Send queued messages" gnus-delay-send-queue
936 ,@(if (featurep 'xemacs) '(t)
937 '(:help "Send all messages that are scheduled to be sent now"))
939 ["Activate all groups" gnus-activate-all-groups t]
940 ["Restart Gnus" gnus-group-restart t]
941 ["Read init file" gnus-group-read-init-file t]
942 ["Browse foreign server..." gnus-group-browse-foreign-server t]
943 ["Enter server buffer" gnus-group-enter-server-mode t]
944 ["Expire all expirable articles" gnus-group-expire-all-groups t]
945 ["Generate any kiboze groups" nnkiboze-generate-groups t]
946 ["Gnus version" gnus-version t]
947 ["Save .newsrc files" gnus-group-save-newsrc t]
948 ["Suspend Gnus" gnus-group-suspend t]
949 ["Clear dribble buffer" gnus-group-clear-dribble t]
950 ["Read manual" gnus-info-find-node t]
951 ["Flush score cache" gnus-score-flush-cache t]
952 ["Toggle topics" gnus-topic-mode t]
953 ["Send a bug report" gnus-bug t]
954 ["Exit from Gnus" gnus-group-exit
955 ,@(if (featurep 'xemacs) '(t)
956 '(:help "Quit reading news"))]
957 ["Exit without saving" gnus-group-quit t]))
959 (gnus-run-hooks 'gnus-group-menu-hook)))
961 (defvar gnus-group-toolbar-map nil)
963 ;; Emacs 21 tool bar. Should be no-op otherwise.
964 (defun gnus-group-make-tool-bar ()
966 (condition-case nil (require 'tool-bar) (error nil))
967 (fboundp 'tool-bar-add-item-from-menu)
968 (default-value 'tool-bar-mode)
969 (not gnus-group-toolbar-map))
970 (setq gnus-group-toolbar-map
971 (let ((tool-bar-map (make-sparse-keymap))
972 (load-path (mm-image-load-path)))
973 (tool-bar-add-item-from-menu
974 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
975 (tool-bar-add-item-from-menu
976 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
977 (tool-bar-add-item-from-menu
978 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
979 (tool-bar-add-item-from-menu
980 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
981 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
982 :help "Subscribe to the current group")
983 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
985 :help "Unsubscribe from the current group")
986 (tool-bar-add-item-from-menu
987 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
989 (if gnus-group-toolbar-map
990 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
992 (defun gnus-group-mode ()
993 "Major mode for reading news.
995 All normal editing commands are switched off.
996 \\<gnus-group-mode-map>
997 The group buffer lists (some of) the groups available. For instance,
998 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
999 lists all zombie groups.
1001 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1002 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1004 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1006 The following commands are available:
1008 \\{gnus-group-mode-map}"
1010 (kill-all-local-variables)
1011 (when (gnus-visual-p 'group-menu 'menu)
1012 (gnus-group-make-menu-bar)
1013 (gnus-group-make-tool-bar))
1014 (gnus-simplify-mode-line)
1015 (setq major-mode 'gnus-group-mode)
1016 (setq mode-name "Group")
1017 (gnus-group-set-mode-line)
1018 (setq mode-line-process nil)
1019 (use-local-map gnus-group-mode-map)
1020 (buffer-disable-undo)
1021 (setq truncate-lines t)
1022 (setq buffer-read-only t)
1023 (gnus-set-default-directory)
1024 (gnus-update-format-specifications nil 'group 'group-mode)
1025 (gnus-update-group-mark-positions)
1030 (gnus-run-hooks 'gnus-group-mode-hook))
1032 (defun gnus-update-group-mark-positions ()
1034 (let ((gnus-process-mark ?\200)
1035 (gnus-group-update-hook nil)
1036 (gnus-group-marked '("dummy.group"))
1037 (gnus-active-hashtb (make-vector 10 0))
1039 (gnus-set-active "dummy.group" '(0 . 0))
1040 (gnus-set-work-buffer)
1041 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1042 (goto-char (point-min))
1043 (setq gnus-group-mark-positions
1044 (list (cons 'process (and (search-forward "\200" nil t)
1045 (- (point) 2))))))))
1047 (defun gnus-mouse-pick-group (e)
1048 "Enter the group under the mouse pointer."
1051 (gnus-group-read-group nil))
1053 ;; Look at LEVEL and find out what the level is really supposed to be.
1054 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1055 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1056 (defun gnus-group-default-level (&optional level number-or-nil)
1058 (gnus-group-use-permanent-levels
1059 (or (setq gnus-group-use-permanent-levels
1060 (or level (if (numberp gnus-group-use-permanent-levels)
1061 gnus-group-use-permanent-levels
1062 (or gnus-group-default-list-level
1063 gnus-level-subscribed))))
1064 gnus-group-default-list-level gnus-level-subscribed))
1068 (or level gnus-group-default-list-level gnus-level-subscribed))))
1070 (defun gnus-group-setup-buffer ()
1071 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1072 (unless (eq major-mode 'gnus-group-mode)
1075 (gnus-carpal-setup-buffer 'group))))
1077 (defun gnus-group-name-charset (method group)
1079 (setq method (gnus-find-method-for-group group)))
1080 (let ((item (assoc method gnus-group-name-charset-method-alist))
1081 (alist gnus-group-name-charset-group-alist)
1085 (while (setq item (pop alist))
1086 (if (string-match (car item) group)
1088 result (cdr item))))
1091 (defun gnus-group-name-decode (string charset)
1092 (if (and string charset (featurep 'mule))
1093 (mm-decode-coding-string string charset)
1096 (defun gnus-group-decoded-name (string)
1097 (let ((charset (gnus-group-name-charset nil string)))
1098 (gnus-group-name-decode string charset)))
1100 (defun gnus-group-list-groups (&optional level unread lowest)
1101 "List newsgroups with level LEVEL or lower that have unread articles.
1102 Default is all subscribed groups.
1103 If argument UNREAD is non-nil, groups with no unread articles are also
1106 Also see the `gnus-group-use-permanent-levels' variable."
1108 (list (if current-prefix-arg
1109 (prefix-numeric-value current-prefix-arg)
1111 (gnus-group-default-level nil t)
1112 gnus-group-default-list-level
1113 gnus-level-subscribed))))
1115 (setq level (car gnus-group-list-mode)
1116 unread (cdr gnus-group-list-mode)))
1117 (setq level (gnus-group-default-level level))
1118 (gnus-group-setup-buffer)
1119 (gnus-update-format-specifications nil 'group 'group-mode)
1120 (let ((case-fold-search nil)
1121 (props (text-properties-at (gnus-point-at-bol)))
1122 (empty (= (point-min) (point-max)))
1123 (group (gnus-group-group-name))
1125 (set-buffer gnus-group-buffer)
1126 (setq number (funcall gnus-group-prepare-function level unread lowest))
1127 (when (or (and (numberp number)
1129 (zerop (buffer-size)))
1130 ;; No groups in the buffer.
1131 (gnus-message 5 gnus-no-groups-message))
1132 ;; We have some groups displayed.
1133 (goto-char (point-max))
1134 (when (or (not gnus-group-goto-next-group-function)
1135 (not (funcall gnus-group-goto-next-group-function
1139 (goto-char (point-min)))
1141 ;; Go to the first group with unread articles.
1142 (gnus-group-search-forward t))
1144 ;; Find the right group to put point on. If the current group
1145 ;; has disappeared in the new listing, try to find the next
1146 ;; one. If no next one can be found, just leave point at the
1147 ;; first newsgroup in the buffer.
1148 (when (not (gnus-goto-char
1150 (point-min) (point-max)
1151 'gnus-group (gnus-intern-safe
1152 group gnus-active-hashtb))))
1153 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1155 (not (gnus-goto-char
1157 (point-min) (point-max) 'gnus-group
1159 (caar newsrc) gnus-active-hashtb)))))
1160 (setq newsrc (cdr newsrc)))
1162 (goto-char (point-max))
1163 (forward-line -1)))))))
1164 ;; Adjust cursor point.
1165 (gnus-group-position-point)))
1167 (defun gnus-group-list-level (level &optional all)
1168 "List groups on LEVEL.
1169 If ALL (the prefix), also list groups that have no unread articles."
1170 (interactive "nList groups on level: \nP")
1171 (gnus-group-list-groups level all level))
1173 (defun gnus-group-prepare-logic (group test)
1174 (or (and gnus-group-listed-groups
1175 (null gnus-group-list-option)
1176 (member group gnus-group-listed-groups))
1178 ((null gnus-group-listed-groups) test)
1179 ((null gnus-group-list-option) test)
1180 (t (and (member group gnus-group-listed-groups)
1181 (if (eq gnus-group-list-option 'flush)
1185 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1186 "List all newsgroups with unread articles of level LEVEL or lower.
1187 If PREDICATE is a function, list groups that the function returns non-nil;
1188 if it is t, list groups that have no unread articles.
1189 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1190 If REGEXP is a function, list dead groups that the function returns non-nil;
1191 if it is a string, only list groups matching REGEXP."
1192 (set-buffer gnus-group-buffer)
1193 (let ((buffer-read-only nil)
1194 (newsrc (cdr gnus-newsrc-alist))
1195 (lowest (or lowest 1))
1196 (not-in-list (and gnus-group-listed-groups
1197 (copy-sequence gnus-group-listed-groups)))
1198 info clevel unread group params)
1200 (when (or (< lowest gnus-level-zombie)
1201 gnus-group-listed-groups)
1202 ;; List living groups.
1204 (setq info (car newsrc)
1205 group (gnus-info-group info)
1206 params (gnus-info-params info)
1208 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1210 (setq not-in-list (delete group not-in-list)))
1211 (when (gnus-group-prepare-logic
1213 (and unread ; This group might be unchecked
1214 (or (not (stringp regexp))
1215 (string-match regexp group))
1216 (<= (setq clevel (gnus-info-level info)) level)
1219 ((functionp predicate)
1220 (funcall predicate info))
1221 (predicate t) ; We list all groups?
1224 (if (eq unread t) ; Unactivated?
1225 gnus-group-list-inactive-groups
1226 ; We list unactivated
1228 ; We list groups with unread articles
1229 (and gnus-list-groups-with-ticked-articles
1230 (cdr (assq 'tick (gnus-info-marks info))))
1231 ; And groups with tickeds
1232 ;; Check for permanent visibility.
1233 (and gnus-permanently-visible-groups
1234 (string-match gnus-permanently-visible-groups
1236 (memq 'visible params)
1237 (cdr (assq 'visible params)))))))
1238 (gnus-group-insert-group-line
1239 group (gnus-info-level info)
1240 (gnus-info-marks info) unread (gnus-info-method info)))))
1242 ;; List dead groups.
1243 (when (or gnus-group-listed-groups
1244 (and (>= level gnus-level-zombie)
1245 (<= lowest gnus-level-zombie)))
1246 (gnus-group-prepare-flat-list-dead
1247 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1248 gnus-level-zombie ?Z
1251 (dolist (group gnus-zombie-list)
1252 (setq not-in-list (delete group not-in-list))))
1253 (when (or gnus-group-listed-groups
1254 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1255 (gnus-group-prepare-flat-list-dead
1258 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1259 gnus-level-killed ?K regexp))
1261 (gnus-group-set-mode-line)
1262 (setq gnus-group-list-mode (cons level predicate))
1263 (gnus-run-hooks 'gnus-group-prepare-hook)
1266 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1267 ;; List zombies and killed lists somewhat faster, which was
1268 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1269 ;; this by ignoring the group format specification altogether.
1271 (if (> (length groups) gnus-group-listing-limit)
1273 (setq group (pop groups))
1274 (when (gnus-group-prepare-logic
1277 (and (stringp regexp) (string-match regexp group))
1278 (and (functionp regexp) (funcall regexp group))))
1279 (gnus-add-text-properties
1280 (point) (prog1 (1+ (point))
1281 (insert " " mark " *: "
1282 (gnus-group-decoded-name group)
1284 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1286 'gnus-level level))))
1288 (setq group (pop groups))
1289 (when (gnus-group-prepare-logic
1292 (and (stringp regexp) (string-match regexp group))
1293 (and (functionp regexp) (funcall regexp group))))
1294 (gnus-group-insert-group-line
1296 (let ((active (gnus-active group)))
1298 (if (zerop (cdr active))
1300 (- (1+ (cdr active)) (car active)))
1302 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1304 (defun gnus-group-update-group-line ()
1305 "Update the current line in the group buffer."
1306 (let* ((buffer-read-only nil)
1307 (group (gnus-group-group-name))
1308 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1309 gnus-group-indentation)
1312 (not (gnus-ephemeral-group-p group))
1314 (concat "(gnus-group-set-info '"
1315 (gnus-prin1-to-string (nth 2 entry))
1317 (setq gnus-group-indentation (gnus-group-group-indentation))
1319 (gnus-group-insert-group-line-info group)
1321 (gnus-group-position-point))))
1323 (defun gnus-group-insert-group-line-info (group)
1324 "Insert GROUP on the current line."
1325 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1326 (gnus-group-indentation (gnus-group-group-indentation))
1330 ;; (Un)subscribed group.
1331 (setq info (nth 2 entry))
1332 (gnus-group-insert-group-line
1333 group (gnus-info-level info) (gnus-info-marks info)
1334 (or (car entry) t) (gnus-info-method info)))
1335 ;; This group is dead.
1336 (gnus-group-insert-group-line
1338 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1340 (if (setq 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-number-of-unseen-articles-in-group (group)
1348 (let* ((info (nth 2 (gnus-group-entry group)))
1349 (marked (gnus-info-marks info))
1350 (seen (cdr (assq 'seen marked)))
1351 (active (gnus-active group)))
1354 (length (gnus-uncompress-range
1355 (gnus-range-difference
1356 (gnus-range-difference (list active) (gnus-info-read info))
1359 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1360 gnus-tmp-marked number
1362 "Insert a group line in the group buffer."
1363 (let* ((gnus-tmp-method
1364 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1365 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1367 (gnus-tmp-active (gnus-active gnus-tmp-group))
1368 (gnus-tmp-number-total
1370 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1372 (gnus-tmp-number-of-unread
1373 (if (numberp number) (int-to-string (max 0 number))
1375 (gnus-tmp-number-of-read
1376 (if (numberp number)
1377 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1379 (gnus-tmp-subscribed
1380 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1381 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1382 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1384 (gnus-tmp-qualified-group
1385 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1386 group-name-charset))
1388 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1390 (gnus-tmp-newsgroup-description
1391 (if gnus-description-hashtb
1392 (or (gnus-group-name-decode
1393 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1394 group-name-charset) "")
1397 (if (and gnus-moderated-hashtb
1398 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1400 (gnus-tmp-moderated-string
1401 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1402 (gnus-tmp-group-icon "==&&==")
1403 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1404 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1405 (gnus-tmp-news-method-string
1407 (format "(%s:%s)" (car gnus-tmp-method)
1408 (cadr gnus-tmp-method)) ""))
1409 (gnus-tmp-marked-mark
1410 (if (and (numberp number)
1412 (cdr (assq 'tick gnus-tmp-marked)))
1414 (gnus-tmp-summary-live
1415 (if (and (not gnus-group-is-exiting-p)
1416 (gnus-buffer-live-p (gnus-summary-buffer-name
1419 (gnus-tmp-process-marked
1420 (if (member gnus-tmp-group gnus-group-marked)
1421 gnus-process-mark ? ))
1423 (or (and gnus-use-grouplens
1424 (bbb-grouplens-group-p gnus-tmp-group))
1426 (buffer-read-only nil)
1427 header gnus-tmp-header) ; passed as parameter to user-funcs.
1429 (gnus-add-text-properties
1433 (let ((gnus-tmp-group (gnus-group-name-decode
1434 gnus-tmp-group group-name-charset)))
1435 (eval gnus-group-line-format-spec)))
1436 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1437 gnus-unread ,(if (numberp number)
1438 (string-to-int gnus-tmp-number-of-unread)
1440 gnus-marked ,gnus-tmp-marked-mark
1441 gnus-indentation ,gnus-group-indentation
1442 gnus-level ,gnus-tmp-level))
1444 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1445 (gnus-run-hooks 'gnus-group-update-hook))
1447 ;; Allow XEmacs to remove front-sticky text properties.
1448 (gnus-group-remove-excess-properties)))
1450 (defun gnus-group-highlight-line ()
1451 "Highlight the current line according to `gnus-group-highlight'."
1452 (let* ((list gnus-group-highlight)
1454 (end (gnus-point-at-eol))
1455 ;; now find out where the line starts and leave point there.
1456 (beg (progn (beginning-of-line) (point)))
1457 (group (gnus-group-group-name))
1458 (entry (gnus-group-entry group))
1459 (unread (if (numberp (car entry)) (car entry) 0))
1460 (active (gnus-active group))
1461 (total (if active (1+ (- (cdr active) (car active))) 0))
1462 (info (nth 2 entry))
1463 (method (gnus-server-get-method group (gnus-info-method info)))
1464 (marked (gnus-info-marks info))
1465 (mailp (apply 'append
1468 (memq x (assoc (symbol-name
1469 (car (or method gnus-select-method)))
1470 gnus-valid-select-methods)))
1471 '(mail post-mail))))
1472 (level (or (gnus-info-level info) gnus-level-killed))
1473 (score (or (gnus-info-score info) 0))
1474 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1475 (group-age (gnus-group-timestamp-delta group))
1476 (inhibit-read-only t))
1477 ;; Eval the cars of the lists until we find a match.
1479 (not (eval (caar list))))
1480 (setq list (cdr list)))
1481 (let ((face (cdar list)))
1482 (unless (eq face (get-text-property beg 'face))
1483 (gnus-put-text-property-excluding-characters-with-faces
1485 (setq face (if (boundp face) (symbol-value face) face)))
1486 (gnus-extent-start-open beg)))
1489 (defun gnus-group-update-group (group &optional visible-only)
1490 "Update all lines where GROUP appear.
1491 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1493 ;; Can't use `save-excursion' here, so we do it manually.
1494 (let ((buf (current-buffer))
1496 (set-buffer gnus-group-buffer)
1497 (setq mark (point-marker))
1498 ;; The buffer may be narrowed.
1501 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1503 found buffer-read-only)
1504 ;; Enter the current status into the dribble buffer.
1505 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1507 (not (gnus-ephemeral-group-p group)))
1509 (concat "(gnus-group-set-info '"
1510 (gnus-prin1-to-string (nth 2 entry))
1512 ;; Find all group instances. If topics are in use, each group
1513 ;; may be listed in more than once.
1514 (while (setq loc (text-property-any
1515 loc (point-max) 'gnus-group ident))
1518 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1520 (gnus-group-insert-group-line-info group)
1523 (gnus-run-hooks 'gnus-group-update-group-hook)))
1524 (setq loc (1+ loc)))
1525 (unless (or found visible-only)
1526 ;; No such line in the buffer, find out where it's supposed to
1527 ;; go, and insert it there (or at the end of the buffer).
1528 (if gnus-goto-missing-group-function
1529 (funcall gnus-goto-missing-group-function group)
1530 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1531 (while (and entry (car entry)
1535 (point-min) (point-max)
1536 'gnus-group (gnus-intern-safe
1537 (caar entry) gnus-active-hashtb)))))
1538 (setq entry (cdr entry)))
1539 (or entry (goto-char (point-max)))))
1540 ;; Finally insert the line.
1541 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1542 (gnus-group-insert-group-line-info group)
1545 (gnus-run-hooks 'gnus-group-update-group-hook))))
1546 (when gnus-group-update-group-function
1547 (funcall gnus-group-update-group-function group))
1548 (gnus-group-set-mode-line)))
1550 (set-marker mark nil)
1553 (defun gnus-group-set-mode-line ()
1554 "Update the mode line in the group buffer."
1555 (when (memq 'group gnus-updated-mode-lines)
1556 ;; Yes, we want to keep this mode line updated.
1558 (set-buffer gnus-group-buffer)
1559 (let* ((gformat (or gnus-group-mode-line-format-spec
1560 (gnus-set-format 'group-mode)))
1561 (gnus-tmp-news-server (cadr gnus-select-method))
1562 (gnus-tmp-news-method (car gnus-select-method))
1563 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1565 gnus-tmp-header ;Dummy binding for user-defined formats
1566 ;; Get the resulting string.
1568 (and gnus-dribble-buffer
1569 (buffer-name gnus-dribble-buffer)
1570 (buffer-modified-p gnus-dribble-buffer)
1572 (set-buffer gnus-dribble-buffer)
1573 (not (zerop (buffer-size))))))
1574 (mode-string (eval gformat)))
1575 ;; Say whether the dribble buffer has been modified.
1576 (setq mode-line-modified
1577 (if modified (car gnus-mode-line-modified)
1578 (cdr gnus-mode-line-modified)))
1579 ;; If the line is too long, we chop it off.
1580 (when (> (length mode-string) max-len)
1581 (setq mode-string (substring mode-string 0 (- max-len 4))))
1583 (setq mode-line-buffer-identification
1584 (gnus-mode-line-buffer-identification
1585 (list mode-string)))
1586 (set-buffer-modified-p modified))))))
1588 (defun gnus-group-group-name ()
1589 "Get the name of the newsgroup on the current line."
1590 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1592 (symbol-name group))))
1594 (defun gnus-group-group-level ()
1595 "Get the level of the newsgroup on the current line."
1596 (get-text-property (gnus-point-at-bol) 'gnus-level))
1598 (defun gnus-group-group-indentation ()
1599 "Get the indentation of the newsgroup on the current line."
1600 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1601 (and gnus-group-indentation-function
1602 (funcall gnus-group-indentation-function))
1605 (defun gnus-group-group-unread ()
1606 "Get the number of unread articles of the newsgroup on the current line."
1607 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1609 (defun gnus-group-new-mail (group)
1610 (if (nnmail-new-mail-p (gnus-group-real-name group))
1614 (defun gnus-group-level (group)
1615 "Return the estimated level of GROUP."
1616 (or (gnus-info-level (gnus-get-info group))
1617 (and (member group gnus-zombie-list) gnus-level-zombie)
1620 (defun gnus-group-search-forward (&optional backward all level first-too)
1621 "Find the next newsgroup with unread articles.
1622 If BACKWARD is non-nil, find the previous newsgroup instead.
1623 If ALL is non-nil, just find any newsgroup.
1624 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1626 If FIRST-TOO, the current line is also eligible as a target."
1627 (let ((way (if backward -1 1))
1628 (low gnus-level-killed)
1631 (if (and backward (progn (beginning-of-line)) (bobp))
1640 (get-text-property (point) 'gnus-group)
1644 (get-text-property (point) 'gnus-unread)))
1645 (and (numberp unread) (> unread 0)))
1646 (setq lev (get-text-property (point)
1648 (<= lev gnus-level-subscribed)))
1650 (and (setq lev (get-text-property (point)
1659 (zerop (forward-line way)))))
1661 (progn (gnus-group-position-point) t)
1662 (goto-char (or pos beg))
1665 ;;; Gnus group mode commands
1669 (defun gnus-group-mark-line-p ()
1672 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1673 (eq (char-after) gnus-process-mark)))
1675 (defun gnus-group-mark-group (n &optional unmark no-advance)
1676 "Mark the current group."
1678 (let ((buffer-read-only nil)
1682 (when (setq group (gnus-group-group-name))
1683 ;; Go to the mark position.
1685 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1686 (subst-char-in-region
1687 (point) (1+ (point)) (char-after)
1690 (setq gnus-group-marked (delete group gnus-group-marked))
1692 (setq gnus-group-marked
1693 (cons group (delete group gnus-group-marked)))
1694 gnus-process-mark)))
1696 (gnus-group-next-group 1))
1698 (gnus-summary-position-point)
1701 (defun gnus-group-unmark-group (n)
1702 "Remove the mark from the current group."
1704 (gnus-group-mark-group n 'unmark)
1705 (gnus-group-position-point))
1707 (defun gnus-group-unmark-all-groups ()
1708 "Unmark all groups."
1710 (let ((groups gnus-group-marked))
1713 (gnus-group-remove-mark (pop groups)))))
1714 (gnus-group-position-point))
1716 (defun gnus-group-mark-region (unmark beg end)
1717 "Mark all groups between point and mark.
1718 If UNMARK, remove the mark instead."
1719 (interactive "P\nr")
1720 (let ((num (count-lines beg end)))
1723 (- num (gnus-group-mark-group num unmark)))))
1725 (defun gnus-group-mark-buffer (&optional unmark)
1726 "Mark all groups in the buffer.
1727 If UNMARK, remove the mark instead."
1729 (gnus-group-mark-region unmark (point-min) (point-max)))
1731 (defun gnus-group-mark-regexp (regexp)
1732 "Mark all groups that match some regexp."
1733 (interactive "sMark (regexp): ")
1734 (let ((alist (cdr gnus-newsrc-alist))
1737 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1738 (gnus-group-set-mark group))))
1739 (gnus-group-position-point))
1741 (defun gnus-group-remove-mark (group &optional test-marked)
1742 "Remove the process mark from GROUP and move point there.
1743 Return nil if the group isn't displayed."
1744 (if (gnus-group-goto-group group nil test-marked)
1746 (gnus-group-mark-group 1 'unmark t)
1748 (setq gnus-group-marked
1749 (delete group gnus-group-marked))
1752 (defun gnus-group-set-mark (group)
1753 "Set the process mark on GROUP."
1754 (if (gnus-group-goto-group group)
1756 (gnus-group-mark-group 1 nil t))
1757 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1759 (defun gnus-group-universal-argument (arg &optional groups func)
1760 "Perform any command on all groups according to the process/prefix convention."
1762 (if (eq (setq func (or func
1765 (substitute-command-keys
1766 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1768 (gnus-error 1 "Undefined key")
1769 (gnus-group-iterate arg
1771 (command-execute func))))
1772 (gnus-group-position-point))
1774 (defun gnus-group-process-prefix (n)
1775 "Return a list of groups to work on.
1776 Take into consideration N (the prefix) and the list of marked groups."
1779 (setq n (prefix-numeric-value n))
1780 ;; There is a prefix, so we return a list of the N next
1782 (let ((way (if (< n 0) -1 1))
1787 (if (setq group (gnus-group-group-name))
1788 (push group groups))
1790 (gnus-group-next-group way)))
1792 ((and (gnus-region-active-p) (mark))
1793 ;; Work on the region between point and mark.
1794 (let ((max (max (point) (mark)))
1797 (goto-char (min (point) (mark)))
1800 (push (gnus-group-group-name) groups)
1801 (zerop (gnus-group-next-group 1))
1803 (nreverse groups))))
1805 ;; No prefix, but a list of marked articles.
1806 (reverse gnus-group-marked))
1808 ;; Neither marked articles or a prefix, so we return the
1810 (let ((group (gnus-group-group-name)))
1811 (and group (list group))))))
1813 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1814 ;;; imagine why I went through these contortions...
1816 (let ((function (make-symbol "gnus-group-iterate-function"))
1817 (window (make-symbol "gnus-group-iterate-window"))
1818 (groups (make-symbol "gnus-group-iterate-groups"))
1819 (group (make-symbol "gnus-group-iterate-group")))
1821 `(defun gnus-group-iterate (arg ,function)
1822 "Iterate FUNCTION over all process/prefixed groups.
1823 FUNCTION will be called with the group name as the parameter
1824 and with point over the group in question."
1825 (let ((,groups (gnus-group-process-prefix arg))
1826 (,window (selected-window))
1829 (setq ,group (car ,groups)
1830 ,groups (cdr ,groups))
1831 (select-window ,window)
1832 (gnus-group-remove-mark ,group)
1833 (save-selected-window
1835 (funcall ,function ,group)))))))))
1837 (put 'gnus-group-iterate 'lisp-indent-function 1)
1839 ;; Selecting groups.
1841 (defun gnus-group-read-group (&optional all no-article group select-articles)
1842 "Read news in this newsgroup.
1843 If the prefix argument ALL is non-nil, already read articles become
1844 readable. IF ALL is a number, fetch this number of articles. If the
1845 optional argument NO-ARTICLE is non-nil, no article will be
1846 auto-selected upon group entry. If GROUP is non-nil, fetch that
1849 (let ((no-display (eq all 0))
1850 (group (or group (gnus-group-group-name)))
1851 number active marked entry)
1855 (error "No group on current line"))
1856 (setq marked (gnus-info-marks
1857 (nth 2 (setq entry (gnus-gethash
1858 group gnus-newsrc-hashtb)))))
1859 ;; This group might be a dead group. In that case we have to get
1860 ;; the number of unread articles from `gnus-active-hashtb'.
1862 (cond ((numberp all) all)
1864 ((setq active (gnus-active group))
1865 (- (1+ (cdr active)) (car active)))))
1866 (gnus-summary-read-group
1867 group (or all (and (numberp number)
1868 (zerop (+ number (gnus-range-length
1869 (cdr (assq 'tick marked)))
1871 (cdr (assq 'dormant marked)))))))
1872 no-article nil no-display nil select-articles)))
1874 (defun gnus-group-select-group (&optional all)
1875 "Select this newsgroup.
1876 No article is selected automatically.
1877 If the group is opened, just switch the summary buffer.
1878 If ALL is non-nil, already read articles become readable.
1879 If ALL is a number, fetch this number of articles."
1881 (when (and (eobp) (not (gnus-group-group-name)))
1883 (gnus-group-read-group all t))
1885 (defun gnus-group-quick-select-group (&optional all)
1886 "Select the current group \"quickly\".
1887 This means that no highlighting or scoring will be performed.
1888 If ALL (the prefix argument) is 0, don't even generate the summary
1891 This might be useful if you want to toggle threading
1892 before entering the group."
1894 (require 'gnus-score)
1896 gnus-score-find-score-files-function
1897 gnus-home-score-file
1898 gnus-apply-kill-hook
1899 gnus-summary-expunge-below)
1900 (gnus-group-read-group all t)))
1902 (defun gnus-group-visible-select-group (&optional all)
1903 "Select the current group without hiding any articles."
1905 (let ((gnus-inhibit-limiting t))
1906 (gnus-group-read-group all t)))
1908 (defun gnus-group-select-group-ephemerally ()
1909 "Select the current group without doing any processing whatsoever.
1910 You will actually be entered into a group that's a copy of
1911 the current group; no changes you make while in this group will
1914 (require 'gnus-score)
1916 gnus-score-find-score-files-function gnus-apply-kill-hook
1917 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1918 gnus-summary-mode-hook gnus-select-group-hook
1919 (group (gnus-group-group-name))
1920 (method (gnus-find-method-for-group group)))
1921 (gnus-group-read-ephemeral-group
1922 (gnus-group-prefixed-name group method) method)))
1925 (defun gnus-fetch-group (group &optional articles)
1926 "Start Gnus if necessary and enter GROUP.
1927 Returns whether the fetching was successful or not."
1928 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1929 (unless (get-buffer gnus-group-buffer)
1931 (gnus-group-read-group articles nil group))
1934 (defun gnus-fetch-group-other-frame (group)
1935 "Pop up a frame and enter GROUP."
1937 (let ((window (get-buffer-window gnus-group-buffer)))
1939 (select-frame (window-frame window)))
1940 ((= (length (frame-list)) 1)
1941 (select-frame (make-frame)))
1944 (gnus-fetch-group group))
1946 (defvar gnus-ephemeral-group-server 0)
1948 ;; Enter a group that is not in the group buffer. Non-nil is returned
1949 ;; if selection was successful.
1950 (defun gnus-group-read-ephemeral-group (group method &optional activate
1951 quit-config request-only
1954 "Read GROUP from METHOD as an ephemeral group.
1955 If ACTIVATE, request the group first.
1956 If QUIT-CONFIG, use that window configuration when exiting from the
1958 If REQUEST-ONLY, don't actually read the group; just request it.
1959 If SELECT-ARTICLES, only select those articles.
1960 If PARAMETERS, use those as the group parameters.
1962 Return the name of the group if selection was successful."
1963 ;; Transform the select method into a unique server.
1964 (when (stringp method)
1965 (setq method (gnus-server-to-method method)))
1967 `(,(car method) ,(concat (cadr method) "-ephemeral")
1968 (,(intern (format "%s-address" (car method))) ,(cadr method))
1970 (let ((group (if (gnus-group-foreign-p group) group
1971 (gnus-group-prefixed-name (gnus-group-real-name group)
1976 ,gnus-level-default-subscribed nil nil ,method
1979 (cons 'quit-config quit-config)
1981 (cons gnus-summary-buffer
1982 gnus-current-window-configuration)))
1985 (push method gnus-ephemeral-servers)
1986 (set-buffer gnus-group-buffer)
1987 (unless (gnus-check-server method)
1988 (error "Unable to contact server: %s" (gnus-status-message method)))
1990 (gnus-activate-group group 'scan)
1991 (unless (gnus-request-group group)
1992 (error "Couldn't request group: %s"
1993 (nnheader-get-report (car method)))))
1997 (when (gnus-group-read-group t t group select-articles)
2001 (message "Quit reading the ephemeral group")
2004 (defun gnus-group-jump-to-group (group)
2005 "Jump to newsgroup GROUP."
2007 (list (mm-string-make-unibyte
2009 "Group: " gnus-active-hashtb nil
2010 (gnus-read-active-file-p)
2011 gnus-group-jump-to-group-prompt
2012 'gnus-group-history))))
2014 (when (equal group "")
2015 (error "Empty group name"))
2017 (unless (gnus-ephemeral-group-p group)
2018 ;; Either go to the line in the group buffer...
2019 (unless (gnus-group-goto-group group)
2020 ;; ... or insert the line.
2021 (gnus-group-update-group group)
2022 (gnus-group-goto-group group)))
2023 ;; Adjust cursor point.
2024 (gnus-group-position-point))
2026 (defun gnus-group-goto-group (group &optional far test-marked)
2027 "Goto to newsgroup GROUP.
2028 If FAR, it is likely that the group is not on the current line.
2029 If TEST-MARKED, the line must be marked."
2033 ;; It's quite likely that we are on the right line, so
2034 ;; we check the current line first.
2036 (eq (get-text-property (point) 'gnus-group)
2037 (gnus-intern-safe group gnus-active-hashtb))
2038 (or (not test-marked) (gnus-group-mark-line-p)))
2040 ;; Previous and next line are also likely, so we check them as well.
2044 (and (eq (get-text-property (point) 'gnus-group)
2045 (gnus-intern-safe group gnus-active-hashtb))
2046 (or (not test-marked) (gnus-group-mark-line-p)))))
2052 (and (eq (get-text-property (point) 'gnus-group)
2053 (gnus-intern-safe group gnus-active-hashtb))
2054 (or (not test-marked) (gnus-group-mark-line-p)))))
2058 (goto-char (point-min))
2060 (while (and (not found)
2065 (gnus-intern-safe group gnus-active-hashtb))))
2066 (if (gnus-group-mark-line-p)
2071 ;; Search through the entire buffer.
2074 (point-min) (point-max)
2075 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2077 (defun gnus-group-next-group (n &optional silent)
2078 "Go to next N'th newsgroup.
2079 If N is negative, search backward instead.
2080 Returns the difference between N and the number of skips actually
2083 (gnus-group-next-unread-group n t nil silent))
2085 (defun gnus-group-next-unread-group (n &optional all level silent)
2086 "Go to next N'th unread newsgroup.
2087 If N is negative, search backward instead.
2088 If ALL is non-nil, choose any newsgroup, unread or not.
2089 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2090 such group can be found, the next group with a level higher than
2092 Returns the difference between N and the number of skips actually
2095 (let ((backward (< n 0))
2098 (gnus-group-search-forward
2099 backward (or (not gnus-group-goto-unread) all) level))
2103 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2104 (if level " on this level or higher" "")))
2107 (defun gnus-group-prev-group (n)
2108 "Go to previous N'th newsgroup.
2109 Returns the difference between N and the number of skips actually
2112 (gnus-group-next-unread-group (- n) t))
2114 (defun gnus-group-prev-unread-group (n)
2115 "Go to previous N'th unread newsgroup.
2116 Returns the difference between N and the number of skips actually
2119 (gnus-group-next-unread-group (- n)))
2121 (defun gnus-group-next-unread-group-same-level (n)
2122 "Go to next N'th unread newsgroup on the same level.
2123 If N is negative, search backward instead.
2124 Returns the difference between N and the number of skips actually
2127 (gnus-group-next-unread-group n t (gnus-group-group-level))
2128 (gnus-group-position-point))
2130 (defun gnus-group-prev-unread-group-same-level (n)
2131 "Go to next N'th unread newsgroup on the same level.
2132 Returns the difference between N and the number of skips actually
2135 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2136 (gnus-group-position-point))
2138 (defun gnus-group-best-unread-group (&optional exclude-group)
2139 "Go to the group with the highest level.
2140 If EXCLUDE-GROUP, do not go to that group."
2142 (goto-char (point-min))
2146 (setq unread (get-text-property (point) 'gnus-unread))
2147 (when (and (numberp unread) (> unread 0))
2148 (when (and (get-text-property (point) 'gnus-level)
2149 (< (get-text-property (point) 'gnus-level) best)
2150 (or (not exclude-group)
2151 (not (equal exclude-group (gnus-group-group-name)))))
2152 (setq best (get-text-property (point) 'gnus-level))
2153 (setq best-point (point))))
2156 (goto-char best-point))
2157 (gnus-group-position-point)
2158 (and best-point (gnus-group-group-name))))
2160 (defun gnus-group-first-unread-group ()
2161 "Go to the first group with unread articles."
2164 (let ((opoint (point))
2166 (goto-char (point-min))
2167 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2168 (and (numberp unread) ; Not a topic.
2169 (not (zerop unread))) ; Has unread articles.
2170 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2173 nil)) ; Not success.
2174 (gnus-group-position-point)))
2176 (defun gnus-group-enter-server-mode ()
2177 "Jump to the server buffer."
2179 (gnus-enter-server-buffer))
2181 (defun gnus-group-make-group (name &optional method address args)
2182 "Add a new newsgroup.
2183 The user will be prompted for a NAME, for a select METHOD, and an
2187 (gnus-read-group "Group name: ")
2188 (gnus-read-method "From method: ")))
2190 (when (stringp method)
2191 (setq method (or (gnus-server-to-method method) method)))
2192 (let* ((meth (gnus-method-simplify
2194 (not (gnus-server-equal method gnus-select-method)))
2195 (if address (list (intern method) address)
2197 (nname (if method (gnus-group-prefixed-name name meth) name))
2199 (when (gnus-gethash nname gnus-newsrc-hashtb)
2200 (error "Group %s already exists" nname))
2201 ;; Subscribe to the new group.
2202 (gnus-group-change-level
2203 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2204 gnus-level-default-subscribed gnus-level-killed
2205 (and (gnus-group-group-name)
2206 (gnus-gethash (gnus-group-group-name)
2207 gnus-newsrc-hashtb))
2210 (gnus-set-active nname (cons 1 0))
2211 (unless (gnus-ephemeral-group-p name)
2213 (concat "(gnus-group-set-info '"
2214 (gnus-prin1-to-string (cdr info)) ")")))
2216 (gnus-group-insert-group-line-info nname)
2218 (gnus-group-position-point)
2220 ;; Load the backend and try to make the backend create
2221 ;; the group as well.
2222 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2224 gnus-valid-select-methods)
2226 (gnus-check-server meth)
2227 (when (gnus-check-backend-function 'request-create-group nname)
2228 (unless (gnus-request-create-group nname nil args)
2229 (error "Could not create group on server: %s"
2230 (nnheader-get-report backend))))
2233 (defun gnus-group-delete-groups (&optional arg)
2234 "Delete the current group. Only meaningful with editable groups."
2236 (let ((n (length (gnus-group-process-prefix arg))))
2237 (when (gnus-yes-or-no-p
2239 "Delete this 1 group? "
2240 (format "Delete these %d groups? " n)))
2241 (gnus-group-iterate arg
2243 (gnus-group-delete-group group nil t))))))
2245 (defun gnus-group-delete-group (group &optional force no-prompt)
2246 "Delete the current group. Only meaningful with editable groups.
2247 If FORCE (the prefix) is non-nil, all the articles in the group will
2248 be deleted. This is \"deleted\" as in \"removed forever from the face
2249 of the Earth\". There is no undo. The user will be prompted before
2250 doing the deletion."
2252 (list (gnus-group-group-name)
2253 current-prefix-arg))
2255 (error "No group to delete"))
2256 (unless (gnus-check-backend-function 'request-delete-group group)
2257 (error "This backend does not support group deletion"))
2259 (if (and (not no-prompt)
2260 (not (gnus-yes-or-no-p
2262 "Do you really want to delete %s%s? "
2263 group (if force " and all its contents" "")))))
2265 (gnus-message 6 "Deleting group %s..." group)
2266 (if (not (gnus-request-delete-group group force))
2267 (gnus-error 3 "Couldn't delete group %s" group)
2268 (gnus-message 6 "Deleting group %s...done" group)
2269 (gnus-group-goto-group group)
2270 (gnus-group-kill-group 1 t)
2271 (gnus-sethash group nil gnus-active-hashtb)
2272 (when (and (boundp 'gnus-cache-active-hashtb)
2273 gnus-cache-active-hashtb)
2274 (gnus-sethash group nil gnus-cache-active-hashtb)
2275 (setq gnus-cache-active-altered t))
2277 (gnus-group-position-point)))
2279 (defun gnus-group-rename-group (group new-name)
2280 "Rename group from GROUP to NEW-NAME.
2281 When used interactively, GROUP is the group under point
2282 and NEW-NAME will be prompted for."
2285 (gnus-group-group-name)
2287 (unless (gnus-check-backend-function
2288 'request-rename-group (gnus-group-group-name))
2289 (error "This backend does not support renaming groups"))
2290 (gnus-read-group "Rename group to: "
2291 (gnus-group-real-name (gnus-group-group-name))))))
2293 (unless (gnus-check-backend-function 'request-rename-group group)
2294 (error "This backend does not support renaming groups"))
2296 (error "No group to rename"))
2297 (when (equal (gnus-group-real-name group) new-name)
2298 (error "Can't rename to the same name"))
2300 ;; We find the proper prefixed name.
2302 (if (gnus-group-native-p group)
2306 (gnus-group-prefixed-name
2307 (gnus-group-real-name new-name)
2308 (gnus-info-method (gnus-get-info group)))))
2310 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2313 (gnus-group-goto-group group)
2314 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2315 (gnus-request-rename-group group new-name))))
2316 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2317 ;; We rename the group internally by killing it...
2318 (gnus-group-kill-group)
2319 ;; ... changing its name ...
2320 (setcar (cdar gnus-list-of-killed-groups) new-name)
2321 ;; ... and then yanking it. Magic!
2322 (gnus-group-yank-group)
2323 (gnus-set-active new-name (gnus-active group))
2324 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2326 (setq gnus-killed-list (delete group gnus-killed-list))
2327 (gnus-set-active group nil)
2328 (gnus-dribble-touch)
2329 (gnus-group-position-point)))
2331 (defun gnus-group-edit-group (group &optional part)
2332 "Edit the group on the current line."
2333 (interactive (list (gnus-group-group-name)))
2334 (let ((part (or part 'info))
2337 (error "No group on current line"))
2338 (unless (setq info (gnus-get-info group))
2339 (error "Killed group; can't be edited"))
2341 (gnus-close-group group))
2343 ;; Find the proper form to edit.
2344 (cond ((eq part 'method)
2345 (or (gnus-info-method info) "native"))
2347 (gnus-info-params info))
2349 ;; The proper documentation.
2351 "Editing the %s for `%s'."
2353 ((eq part 'method) "select method")
2354 ((eq part 'params) "group parameters")
2356 (gnus-group-decoded-name group))
2358 (gnus-group-edit-group-done ',part ,group form)))
2361 (gnus-create-info-command
2364 "(gnus)Select Methods")
2366 "(gnus)Group Parameters")
2368 "(gnus)Group Info"))))))
2370 (defun gnus-group-edit-group-method (group)
2371 "Edit the select method of GROUP."
2372 (interactive (list (gnus-group-group-name)))
2373 (gnus-group-edit-group group 'method))
2375 (defun gnus-group-edit-group-parameters (group)
2376 "Edit the group parameters of GROUP."
2377 (interactive (list (gnus-group-group-name)))
2378 (gnus-group-edit-group group 'params))
2380 (defun gnus-group-edit-group-done (part group form)
2382 (let* ((method (cond ((eq part 'info) (nth 4 form))
2383 ((eq part 'method) form)
2385 (info (cond ((eq part 'info) form)
2386 ((eq part 'method) (gnus-get-info group))
2389 (if (or (not method)
2391 gnus-select-method method))
2392 (gnus-group-real-name (car info))
2393 (gnus-group-prefixed-name
2394 (gnus-group-real-name (car info)) method))
2396 (when (and new-group
2397 (not (equal new-group group)))
2398 (when (gnus-group-goto-group group)
2399 (gnus-group-kill-group 1))
2400 (gnus-activate-group new-group))
2402 (if (not (and info new-group))
2403 (gnus-group-set-info form (or new-group group) part)
2404 (setq info (gnus-copy-sequence info))
2405 (setcar info new-group)
2406 (unless (gnus-server-equal method "native")
2407 (unless (nthcdr 3 info)
2408 (nconc info (list nil nil)))
2409 (unless (nthcdr 4 info)
2410 (nconc info (list nil)))
2411 (gnus-info-set-method info method))
2412 (gnus-group-set-info info))
2413 (gnus-group-update-group (or new-group group))
2414 (gnus-group-position-point)))
2416 (defun gnus-group-make-useful-group (group method)
2417 "Create one of the groups described in `gnus-useful-groups'."
2419 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2421 gnus-useful-groups)))
2422 (list (cadr entry) (caddr entry))))
2423 (setq method (gnus-copy-sequence method))
2425 (while (setq entry (memq (assq 'eval method) method))
2426 (setcar entry (eval (cadar entry)))))
2427 (gnus-group-make-group group method))
2429 (defun gnus-group-make-help-group (&optional noerror)
2430 "Create the Gnus documentation group.
2431 Optional argument NOERROR modifies the behavior of this function when the
2432 group already exists:
2433 - if not given, and error is signaled,
2434 - if t, stay silent,
2435 - if anything else, just print a message."
2437 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2438 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2439 (if (gnus-gethash name gnus-newsrc-hashtb)
2440 (cond ((eq noerror nil)
2441 (error "Documentation group already exists"))
2446 (gnus-message 1 "Documentation group already exists")))
2449 (gnus-message 1 "Couldn't find doc group")
2450 (gnus-group-make-group
2451 (gnus-group-real-name name)
2452 (list 'nndoc "gnus-help"
2453 (list 'nndoc-address file)
2454 (list 'nndoc-article-type 'mbox))))
2456 (gnus-group-position-point))
2458 (defun gnus-group-make-doc-group (file type)
2459 "Create a group that uses a single file as the source."
2461 (list (read-file-name "File name: ")
2462 (and current-prefix-arg 'ask)))
2463 (when (eq type 'ask)
2468 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2470 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2471 ((= char ?b) 'babyl)
2472 ((= char ?d) 'digest)
2473 ((= char ?f) 'forward)
2475 ((= char ?g) 'guess)
2476 (t (setq err (format "%c unknown. " char))
2479 (let* ((file (expand-file-name file))
2480 (name (gnus-generate-new-group-name
2481 (gnus-group-prefixed-name
2482 (file-name-nondirectory file) '(nndoc "")))))
2483 (gnus-group-make-group
2484 (gnus-group-real-name name)
2486 (list 'nndoc-address file)
2487 (list 'nndoc-article-type (or type 'guess))))))
2489 (defvar nnweb-type-definition)
2490 (defvar gnus-group-web-type-history nil)
2491 (defvar gnus-group-web-search-history nil)
2492 (defun gnus-group-make-web-group (&optional solid)
2493 "Create an ephemeral nnweb group.
2494 If SOLID (the prefix), create a solid group."
2498 (if solid (gnus-read-group "Group name: ")
2499 (message-unique-id)))
2500 (default-type (or (car gnus-group-web-type-history)
2501 (symbol-name (caar nnweb-type-definition))))
2505 (format "Search engine type (default %s): " default-type)
2506 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2507 nnweb-type-definition)
2508 nil t nil 'gnus-group-web-type-history)
2513 (cons (or (car gnus-group-web-search-history) "") 0)
2514 'gnus-group-web-search-history))
2516 `(nnweb ,group (nnweb-search ,search)
2517 (nnweb-type ,(intern type))
2518 (nnweb-ephemeral-p t))))
2521 (gnus-pull 'nnweb-ephemeral-p method)
2522 (gnus-group-make-group group method))
2523 (gnus-group-read-ephemeral-group
2525 (cons (current-buffer)
2526 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2528 (eval-when-compile (defvar nnrss-group-alist)
2529 (defun nnrss-discover-feed (arg))
2530 (defun nnrss-save-server-data (arg)))
2531 (defun gnus-group-make-rss-group (&optional url)
2532 "Given a URL, discover if there is an RSS feed. If there is,
2533 use Gnus' to create an nnrss group"
2537 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2538 (let ((feedinfo (nnrss-discover-feed url)))
2540 (let ((title (read-from-minibuffer "Title: "
2543 (desc (read-from-minibuffer "Description: "
2544 (cdr (assoc 'description
2546 (href (cdr (assoc 'href feedinfo))))
2547 (push (list title href desc)
2549 (gnus-group-unsubscribe-group
2550 (concat "nnrss:" title))
2551 (nnrss-save-server-data nil))
2552 (error "No feeds found for %s" url))))
2554 (defvar nnwarchive-type-definition)
2555 (defvar gnus-group-warchive-type-history nil)
2556 (defvar gnus-group-warchive-login-history nil)
2557 (defvar gnus-group-warchive-address-history nil)
2559 (defun gnus-group-make-warchive-group ()
2560 "Create a nnwarchive group."
2562 (require 'nnwarchive)
2563 (let* ((group (gnus-read-group "Group name: "))
2564 (default-type (or (car gnus-group-warchive-type-history)
2565 (symbol-name (caar nnwarchive-type-definition))))
2569 (format "Warchive type (default %s): " default-type)
2570 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2571 nnwarchive-type-definition)
2572 nil t nil 'gnus-group-warchive-type-history)
2574 (address (read-string "Warchive address: "
2575 nil 'gnus-group-warchive-address-history))
2576 (default-login (or (car gnus-group-warchive-login-history)
2581 (format "Warchive login (default %s): " user-mail-address)
2582 default-login 'gnus-group-warchive-login-history)
2585 `(nnwarchive ,address
2586 (nnwarchive-type ,(intern type))
2587 (nnwarchive-login ,login))))
2588 (gnus-group-make-group group method)))
2590 (defun gnus-group-make-archive-group (&optional all)
2591 "Create the (ding) Gnus archive group of the most recent articles.
2592 Given a prefix, create a full group."
2594 (let ((group (gnus-group-prefixed-name
2595 (if all "ding.archives" "ding.recent") '(nndir ""))))
2596 (when (gnus-gethash group gnus-newsrc-hashtb)
2597 (error "Archive group already exists"))
2598 (gnus-group-make-group
2599 (gnus-group-real-name group)
2600 (list 'nndir (if all "hpc" "edu")
2601 (list 'nndir-directory
2602 (if all gnus-group-archive-directory
2603 gnus-group-recent-archive-directory))))
2604 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2606 (defun gnus-group-make-directory-group (dir)
2607 "Create an nndir group.
2608 The user will be prompted for a directory. The contents of this
2609 directory will be used as a newsgroup. The directory should contain
2610 mail messages or news articles in files that have numeric names."
2612 (list (read-file-name "Create group from directory: ")))
2613 (unless (file-exists-p dir)
2614 (error "No such directory"))
2615 (unless (file-directory-p dir)
2616 (error "Not a directory"))
2620 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2622 (gnus-group-prefixed-name
2623 (expand-file-name ext dir)
2625 (setq ext (format "<%d>" (setq i (1+ i)))))
2626 (gnus-group-make-group
2627 (gnus-group-real-name group)
2628 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2630 (eval-when-compile (defvar nnkiboze-score-file))
2631 (defun gnus-group-make-kiboze-group (group address scores)
2632 "Create an nnkiboze group.
2633 The user will be prompted for a name, a regexp to match groups, and
2634 score file entries for articles to include in the group."
2637 (read-string "nnkiboze group name: ")
2638 (read-string "Source groups (regexp): ")
2639 (let ((headers (mapcar (lambda (group) (list group))
2640 '("subject" "from" "number" "date" "message-id"
2641 "references" "chars" "lines" "xref"
2642 "followup" "all" "body" "head")))
2643 scores header regexp regexps)
2644 (while (not (equal "" (setq header (completing-read
2645 "Match on header: " headers nil t))))
2647 (while (not (equal "" (setq regexp (read-string
2648 (format "Match on %s (regexp): "
2650 (push (list regexp nil nil 'r) regexps))
2651 (push (cons header regexps) scores))
2653 (gnus-group-make-group group "nnkiboze" address)
2654 (let* ((nnkiboze-current-group group)
2655 (score-file (car (nnkiboze-score-file "")))
2656 (score-dir (file-name-directory score-file)))
2657 (unless (file-exists-p score-dir)
2658 (make-directory score-dir))
2659 (with-temp-file score-file
2660 (let (emacs-lisp-mode-hook)
2661 (pp scores (current-buffer))))))
2663 (defun gnus-group-add-to-virtual (n vgroup)
2664 "Add the current group to a virtual group."
2666 (list current-prefix-arg
2667 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2669 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2670 (error "%s is not an nnvirtual group" vgroup))
2671 (gnus-close-group vgroup)
2672 (let* ((groups (gnus-group-process-prefix n))
2673 (method (gnus-info-method (gnus-get-info vgroup))))
2674 (setcar (cdr method)
2676 (nth 1 method) "\\|"
2679 (gnus-group-remove-mark s)
2680 (concat "\\(^" (regexp-quote s) "$\\)"))
2682 (gnus-group-position-point))
2684 (defun gnus-group-make-empty-virtual (group)
2685 "Create a new, fresh, empty virtual group."
2686 (interactive "sCreate new, empty virtual group: ")
2687 (let* ((method (list 'nnvirtual "^$"))
2688 (pgroup (gnus-group-prefixed-name group method)))
2689 ;; Check whether it exists already.
2690 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2691 (error "Group %s already exists" pgroup))
2692 ;; Subscribe the new group after the group on the current line.
2693 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2694 (gnus-group-update-group pgroup)
2696 (gnus-group-position-point)))
2698 (defun gnus-group-enter-directory (dir)
2699 "Enter an ephemeral nneething group."
2700 (interactive "DDirectory to read: ")
2701 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2702 (leaf (gnus-group-prefixed-name
2703 (file-name-nondirectory (directory-file-name dir))
2705 (name (gnus-generate-new-group-name leaf)))
2706 (unless (gnus-group-read-ephemeral-group
2708 (cons (current-buffer)
2709 (if (eq major-mode 'gnus-summary-mode)
2711 (error "Couldn't enter %s" dir))))
2714 (autoload 'nnimap-expunge "nnimap")
2715 (autoload 'nnimap-acl-get "nnimap")
2716 (autoload 'nnimap-acl-edit "nnimap"))
2718 (defun gnus-group-nnimap-expunge (group)
2719 "Expunge deleted articles in current nnimap GROUP."
2720 (interactive (list (gnus-group-group-name)))
2721 (let ((mailbox (gnus-group-real-name group)) method)
2723 (error "No group on current line"))
2724 (unless (gnus-get-info group)
2725 (error "Killed group; can't be edited"))
2726 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2727 (error "%s is not an nnimap group" group))
2728 (nnimap-expunge mailbox (cadr method))))
2730 (defun gnus-group-nnimap-edit-acl (group)
2731 "Edit the Access Control List of current nnimap GROUP."
2732 (interactive (list (gnus-group-group-name)))
2733 (let ((mailbox (gnus-group-real-name group)) method acl)
2735 (error "No group on current line"))
2736 (unless (gnus-get-info group)
2737 (error "Killed group; can't be edited"))
2738 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2739 (error "%s is not an nnimap group" group))
2740 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2741 (error "Server does not support ACL's"))
2742 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2744 An access control list is a list of (identifier . rights) elements.
2746 The identifier string specifies the corresponding user. The
2747 identifier \"anyone\" is reserved to refer to the universal identity.
2749 Rights is a string listing a (possibly empty) set of alphanumeric
2750 characters, each character listing a set of operations which is being
2751 controlled. Letters are reserved for ``standard'' rights, listed
2752 below. Digits are reserved for implementation or site defined rights.
2754 l - lookup (mailbox is visible to LIST/LSUB commands)
2755 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2756 SEARCH, COPY from mailbox)
2757 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2758 w - write (STORE flags other than \\SEEN and \\DELETED)
2759 i - insert (perform APPEND, COPY into mailbox)
2760 p - post (send mail to submission address for mailbox,
2761 not enforced by IMAP4 itself)
2762 c - create and delete mailbox (CREATE new sub-mailboxes in any
2763 implementation-defined hierarchy, RENAME or DELETE mailbox)
2764 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2765 a - administer (perform SETACL)" group)
2768 ,mailbox ',method ',acl form)))))
2770 ;; Group sorting commands
2771 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2773 (defun gnus-group-sort-groups (func &optional reverse)
2774 "Sort the group buffer according to FUNC.
2775 When used interactively, the sorting function used will be
2776 determined by the `gnus-group-sort-function' variable.
2777 If REVERSE (the prefix), reverse the sorting order."
2778 (interactive (list gnus-group-sort-function current-prefix-arg))
2779 (funcall gnus-group-sort-alist-function
2780 (gnus-make-sort-function func) reverse)
2781 (gnus-group-unmark-all-groups)
2782 (gnus-group-list-groups)
2783 (gnus-dribble-touch))
2785 (defun gnus-group-sort-flat (func reverse)
2786 ;; We peel off the dummy group from the alist.
2788 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2789 (pop gnus-newsrc-alist))
2791 (setq gnus-newsrc-alist
2792 (sort gnus-newsrc-alist func))
2794 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2795 ;; Regenerate the hash table.
2796 (gnus-make-hashtable-from-newsrc-alist)))
2798 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2799 "Sort the group buffer alphabetically by group name.
2800 If REVERSE, sort in reverse order."
2802 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2804 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2805 "Sort the group buffer alphabetically by real (unprefixed) group name.
2806 If REVERSE, sort in reverse order."
2808 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2810 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2811 "Sort the group buffer by number of unread articles.
2812 If REVERSE, sort in reverse order."
2814 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2816 (defun gnus-group-sort-groups-by-level (&optional reverse)
2817 "Sort the group buffer by group level.
2818 If REVERSE, sort in reverse order."
2820 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2822 (defun gnus-group-sort-groups-by-score (&optional reverse)
2823 "Sort the group buffer by group score.
2824 If REVERSE, sort in reverse order."
2826 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2828 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2829 "Sort the group buffer by group rank.
2830 If REVERSE, sort in reverse order."
2832 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2834 (defun gnus-group-sort-groups-by-method (&optional reverse)
2835 "Sort the group buffer alphabetically by backend name.
2836 If REVERSE, sort in reverse order."
2838 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2840 (defun gnus-group-sort-groups-by-server (&optional reverse)
2841 "Sort the group buffer alphabetically by server name.
2842 If REVERSE, sort in reverse order."
2844 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2846 ;;; Selected group sorting.
2848 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2849 "Sort the process/prefixed groups."
2850 (interactive (list current-prefix-arg gnus-group-sort-function))
2851 (let ((groups (gnus-group-process-prefix n)))
2852 (funcall gnus-group-sort-selected-function
2853 groups (gnus-make-sort-function func) reverse)
2854 (gnus-group-unmark-all-groups)
2855 (gnus-group-list-groups)
2856 (gnus-dribble-touch)))
2858 (defun gnus-group-sort-selected-flat (groups func reverse)
2859 (let (entries infos)
2860 ;; First find all the group entries for these groups.
2862 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2864 ;; Then sort the infos.
2868 (lambda (entry) (car entry))
2869 (setq entries (nreverse entries)))
2872 (setq infos (nreverse infos)))
2873 ;; Go through all the infos and replace the old entries
2874 ;; with the new infos.
2876 (setcar (car entries) (pop infos))
2878 ;; Update the hashtable.
2879 (gnus-make-hashtable-from-newsrc-alist)))
2881 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2882 "Sort the group buffer alphabetically by group name.
2883 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2884 sort in reverse order."
2885 (interactive (gnus-interactive "P\ny"))
2886 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2888 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2889 "Sort the group buffer alphabetically by real group name.
2890 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2891 sort in reverse order."
2892 (interactive (gnus-interactive "P\ny"))
2893 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2895 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2896 "Sort the group buffer by number of unread articles.
2897 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2898 sort in reverse order."
2899 (interactive (gnus-interactive "P\ny"))
2900 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2902 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2903 "Sort the group buffer by group level.
2904 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2905 sort in reverse order."
2906 (interactive (gnus-interactive "P\ny"))
2907 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2909 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2910 "Sort the group buffer by group score.
2911 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2912 sort in reverse order."
2913 (interactive (gnus-interactive "P\ny"))
2914 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2916 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2917 "Sort the group buffer by group rank.
2918 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2919 sort in reverse order."
2920 (interactive (gnus-interactive "P\ny"))
2921 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2923 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2924 "Sort the group buffer alphabetically by backend name.
2925 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2926 sort in reverse order."
2927 (interactive (gnus-interactive "P\ny"))
2928 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2930 ;;; Sorting predicates.
2932 (defun gnus-group-sort-by-alphabet (info1 info2)
2933 "Sort alphabetically."
2934 (string< (gnus-info-group info1) (gnus-info-group info2)))
2936 (defun gnus-group-sort-by-real-name (info1 info2)
2937 "Sort alphabetically on real (unprefixed) names."
2938 (string< (gnus-group-real-name (gnus-info-group info1))
2939 (gnus-group-real-name (gnus-info-group info2))))
2941 (defun gnus-group-sort-by-unread (info1 info2)
2942 "Sort by number of unread articles."
2943 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2944 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2945 (< (or (and (numberp n1) n1) 0)
2946 (or (and (numberp n2) n2) 0))))
2948 (defun gnus-group-sort-by-level (info1 info2)
2950 (< (gnus-info-level info1) (gnus-info-level info2)))
2952 (defun gnus-group-sort-by-method (info1 info2)
2953 "Sort alphabetically by backend name."
2954 (string< (car (gnus-find-method-for-group
2955 (gnus-info-group info1) info1))
2956 (car (gnus-find-method-for-group
2957 (gnus-info-group info2) info2))))
2959 (defun gnus-group-sort-by-server (info1 info2)
2960 "Sort alphabetically by server name."
2961 (string< (gnus-method-to-full-server-name
2962 (gnus-find-method-for-group
2963 (gnus-info-group info1) info1))
2964 (gnus-method-to-full-server-name
2965 (gnus-find-method-for-group
2966 (gnus-info-group info2) info2))))
2968 (defun gnus-group-sort-by-score (info1 info2)
2969 "Sort by group score."
2970 (> (gnus-info-score info1) (gnus-info-score info2)))
2972 (defun gnus-group-sort-by-rank (info1 info2)
2973 "Sort by level and score."
2974 (let ((level1 (gnus-info-level info1))
2975 (level2 (gnus-info-level info2)))
2976 (or (< level1 level2)
2977 (and (= level1 level2)
2978 (> (gnus-info-score info1) (gnus-info-score info2))))))
2982 (defun gnus-group-clear-data (&optional arg)
2983 "Clear all marks and read ranges from the current group."
2985 (gnus-group-iterate arg
2988 (gnus-info-clear-data (setq info (gnus-get-info group)))
2989 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2990 (when (gnus-group-goto-group group)
2991 (gnus-group-update-group-line))))))
2993 (defun gnus-group-clear-data-on-native-groups ()
2994 "Clear all marks and read ranges from all native groups."
2996 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2997 (let ((alist (cdr gnus-newsrc-alist))
2999 (while (setq info (pop alist))
3000 (when (gnus-group-native-p (gnus-info-group info))
3001 (gnus-info-clear-data info)))
3002 (gnus-get-unread-articles)
3003 (gnus-dribble-touch)
3004 (when (gnus-y-or-n-p
3005 "Move the cache away to avoid problems in the future? ")
3006 (call-interactively 'gnus-cache-move-cache)))))
3008 (defun gnus-info-clear-data (info)
3009 "Clear all marks and read ranges from INFO."
3010 (let ((group (gnus-info-group info))
3012 (dolist (el (gnus-info-marks info))
3013 (push `(,(cdr el) add (,(car el))) action))
3014 (push `(,(gnus-info-read info) add (read)) action)
3017 (gnus-request-set-mark ,group ',action)
3018 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3019 (gnus-info-set-read ',info ',(gnus-info-read info))
3020 (when (gnus-group-goto-group ,group)
3021 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3022 (gnus-group-update-group-line))))
3023 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3025 (gnus-request-set-mark group action)
3026 (gnus-info-set-read info nil)
3027 (when (gnus-info-marks info)
3028 (gnus-info-set-marks info nil))))
3030 ;; Group catching up.
3032 (defun gnus-group-catchup-current (&optional n all)
3033 "Mark all unread articles in the current newsgroup as read.
3034 If prefix argument N is numeric, the next N newsgroups will be
3035 caught up. If ALL is non-nil, marked articles will also be marked as
3036 read. Cross references (Xref: header) of articles are ignored.
3037 The number of newsgroups that this function was unable to catch
3040 (let ((groups (gnus-group-process-prefix n))
3043 (unless groups (error "No groups selected"))
3045 (or (not gnus-interactive-catchup) ;Without confirmation?
3050 "Do you really want to mark all articles in %s as read? "
3051 "Mark all unread articles in %s as read? ")
3052 (if (= (length groups) 1)
3054 (format "these %d groups" (length groups)))))))
3056 (while (setq group (pop groups))
3057 (gnus-group-remove-mark group)
3058 ;; Virtual groups have to be given special treatment.
3059 (let ((method (gnus-find-method-for-group group)))
3060 (when (eq 'nnvirtual (car method))
3061 (nnvirtual-catchup-group
3062 (gnus-group-real-name group) (nth 1 method) all)))
3063 (if (>= (gnus-group-level group) gnus-level-zombie)
3064 (gnus-message 2 "Dead groups can't be caught up")
3066 (gnus-group-goto-group group)
3067 (gnus-group-catchup group all))
3068 (gnus-group-update-group-line)
3069 (setq ret (1+ ret)))))
3070 (gnus-group-next-unread-group 1)
3073 (defun gnus-group-catchup-current-all (&optional n)
3074 "Mark all articles in current newsgroup as read.
3075 Cross references (Xref: header) of articles are ignored."
3077 (gnus-group-catchup-current n 'all))
3079 (defun gnus-group-catchup (group &optional all)
3080 "Mark all articles in GROUP as read.
3081 If ALL is non-nil, all articles are marked as read.
3082 The return value is the number of articles that were marked as read,
3083 or nil if no action could be taken."
3084 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3086 (marks (nth 3 (nth 2 entry)))
3087 (unread (gnus-list-of-unread-articles group)))
3088 ;; Remove entries for this group.
3089 (nnmail-purge-split-history (gnus-group-real-name group))
3090 ;; Do the updating only if the newsgroup isn't killed.
3091 (if (not (numberp (car entry)))
3092 (gnus-message 1 "Can't catch up %s; non-active group" group)
3093 (gnus-update-read-articles group nil)
3095 ;; Nix out the lists of marks and dormants.
3096 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3098 (list (cdr (assq 'dormant marks))
3100 (setq unread (gnus-uncompress-range
3101 (gnus-range-add (gnus-range-add
3102 unread (cdr (assq 'dormant marks)))
3103 (cdr (assq 'tick marks)))))
3104 (gnus-add-marked-articles group 'tick nil nil 'force)
3105 (gnus-add-marked-articles group 'dormant nil nil 'force))
3106 ;; Do auto-expirable marks if that's required.
3107 (when (gnus-group-auto-expirable-p group)
3108 (gnus-add-marked-articles group 'expire unread)
3109 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3110 (let ((gnus-newsgroup-name group))
3111 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3114 (defun gnus-group-expire-articles (&optional n)
3115 "Expire all expirable articles in the current newsgroup.
3116 Uses the process/prefix convention."
3118 (let ((groups (gnus-group-process-prefix n))
3121 (error "No groups to expire"))
3122 (while (setq group (pop groups))
3123 (gnus-group-remove-mark group)
3124 (gnus-group-expire-articles-1 group)
3125 (gnus-dribble-touch)
3126 (gnus-group-position-point))))
3128 (defun gnus-group-expire-articles-1 (group)
3129 (when (gnus-check-backend-function 'request-expire-articles group)
3130 (gnus-message 6 "Expiring articles in %s..." group)
3131 (let* ((info (gnus-get-info group))
3132 (expirable (if (gnus-group-total-expirable-p group)
3133 (cons nil (gnus-list-of-read-articles group))
3134 (assq 'expire (gnus-info-marks info))))
3135 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3136 (nnmail-expiry-target
3137 (or (gnus-group-find-parameter group 'expiry-target)
3138 nnmail-expiry-target)))
3140 (gnus-check-group group)
3143 (gnus-compress-sequence
3145 ;; We set the expiry variables to the group
3147 (let ((nnmail-expiry-wait-function nil)
3148 (nnmail-expiry-wait expiry-wait))
3149 (gnus-request-expire-articles
3150 (gnus-uncompress-sequence (cdr expirable)) group))
3151 ;; Just expire using the normal expiry values.
3152 (gnus-request-expire-articles
3153 (gnus-uncompress-sequence (cdr expirable)) group))))
3154 (gnus-close-group group))
3155 (gnus-message 6 "Expiring articles in %s...done" group)
3156 ;; Return the list of un-expired articles.
3159 (defun gnus-group-expire-all-groups ()
3160 "Expire all expirable articles in all newsgroups."
3163 (gnus-message 5 "Expiring...")
3164 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3165 (cdr gnus-newsrc-alist))))
3166 (gnus-group-expire-articles nil)))
3167 (gnus-group-position-point)
3168 (gnus-message 5 "Expiring...done"))
3170 (defun gnus-group-set-current-level (n level)
3171 "Set the level of the next N groups to LEVEL."
3176 (let ((s (read-string
3177 (format "Level (default %s): "
3178 (or (gnus-group-group-level)
3179 gnus-level-default-subscribed)))))
3180 (if (string-match "^\\s-*$" s)
3181 (int-to-string (or (gnus-group-group-level)
3182 gnus-level-default-subscribed))
3184 (unless (and (>= level 1) (<= level gnus-level-killed))
3185 (error "Invalid level: %d" level))
3186 (let ((groups (gnus-group-process-prefix n))
3188 (while (setq group (pop groups))
3189 (gnus-group-remove-mark group)
3190 (gnus-message 6 "Changed level of %s from %d to %d"
3191 group (or (gnus-group-group-level) gnus-level-killed)
3193 (gnus-group-change-level
3194 group level (or (gnus-group-group-level) gnus-level-killed))
3195 (gnus-group-update-group-line)))
3196 (gnus-group-position-point))
3198 (defun gnus-group-unsubscribe (&optional n)
3199 "Unsubscribe the current group."
3201 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3203 (defun gnus-group-subscribe (&optional n)
3204 "Subscribe the current group."
3206 (gnus-group-unsubscribe-current-group n 'subscribe))
3208 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3209 "Toggle subscription of the current group.
3210 If given numerical prefix, toggle the N next groups."
3212 (let ((groups (gnus-group-process-prefix n))
3215 (setq group (car groups)
3216 groups (cdr groups))
3217 (gnus-group-remove-mark group)
3218 (gnus-group-unsubscribe-group
3221 ((eq do-sub 'unsubscribe)
3222 gnus-level-default-unsubscribed)
3223 ((eq do-sub 'subscribe)
3224 gnus-level-default-subscribed)
3225 ((<= (gnus-group-group-level) gnus-level-subscribed)
3226 gnus-level-default-unsubscribed)
3228 gnus-level-default-subscribed))
3230 (gnus-group-update-group-line))
3231 (gnus-group-next-group 1)))
3233 (defun gnus-group-unsubscribe-group (group &optional level silent)
3234 "Toggle subscription to GROUP.
3235 Killed newsgroups are subscribed. If SILENT, don't try to update the
3238 (list (completing-read
3239 "Group: " gnus-active-hashtb nil
3240 (gnus-read-active-file-p)
3242 'gnus-group-history)))
3243 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3245 ((string-match "^[ \t]*$" group)
3246 (error "Empty group name"))
3248 ;; Toggle subscription flag.
3249 (gnus-group-change-level
3250 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3251 gnus-level-subscribed)
3252 (1+ gnus-level-subscribed)
3253 gnus-level-default-subscribed)))
3255 (gnus-group-update-group group)))
3256 ((and (stringp group)
3257 (or (not (gnus-read-active-file-p))
3258 (gnus-active group)))
3259 ;; Add new newsgroup.
3260 (gnus-group-change-level
3262 (if level level gnus-level-default-subscribed)
3263 (or (and (member group gnus-zombie-list)
3266 (when (gnus-group-group-name)
3267 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3269 (gnus-group-update-group group)))
3270 (t (error "No such newsgroup: %s" group)))
3271 (gnus-group-position-point)))
3273 (defun gnus-group-transpose-groups (n)
3274 "Move the current newsgroup up N places.
3275 If given a negative prefix, move down instead. The difference between
3276 N and the number of steps taken is returned."
3278 (unless (gnus-group-group-name)
3279 (error "No group on current line"))
3280 (gnus-group-kill-group 1)
3282 (forward-line (- n))
3283 (gnus-group-yank-group)
3284 (gnus-group-position-point)))
3286 (defun gnus-group-kill-all-zombies (&optional dummy)
3287 "Kill all zombie newsgroups.
3288 The optional DUMMY should always be nil."
3289 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3291 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3292 (setq gnus-zombie-list nil)
3293 (gnus-dribble-touch)
3294 (gnus-group-list-groups)))
3296 (defun gnus-group-kill-region (begin end)
3297 "Kill newsgroups in current region (excluding current point).
3298 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3313 (beginning-of-line) ;Important when LINES < 1
3314 (gnus-group-kill-group lines)))
3316 (defun gnus-group-kill-group (&optional n discard)
3317 "Kill the next N groups.
3318 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3319 However, only groups that were alive can be yanked; already killed
3320 groups or zombie groups can't be yanked.
3321 The return value is the name of the group that was killed, or a list
3324 (let ((buffer-read-only nil)
3325 (groups (gnus-group-process-prefix n))
3326 group entry level out)
3327 (if (< (length groups) 10)
3328 ;; This is faster when there are few groups.
3330 (push (setq group (pop groups)) out)
3331 (gnus-group-remove-mark group)
3332 (setq level (gnus-group-group-level))
3334 (when (and (not discard)
3335 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3338 (gnus-group-goto-group ,(gnus-group-group-name))
3339 (gnus-group-yank-group)))
3340 (push (cons (car entry) (nth 2 entry))
3341 gnus-list-of-killed-groups))
3342 (gnus-group-change-level
3343 (if entry entry group) gnus-level-killed (if entry nil level))
3344 (message "Killed group %s" group))
3345 ;; If there are lots and lots of groups to be killed, we use
3346 ;; this thing instead.
3348 (setq groups (nreverse groups))
3350 (gnus-group-remove-mark (setq group (pop groups)))
3352 (push group gnus-killed-list)
3353 (setq gnus-newsrc-alist
3354 (delq (assoc group gnus-newsrc-alist)
3356 (when gnus-group-change-level-function
3357 (funcall gnus-group-change-level-function
3358 group gnus-level-killed 3))
3360 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3361 (push (cons (car entry) (nth 2 entry))
3362 gnus-list-of-killed-groups)
3363 (setcdr (cdr entry) (cdddr entry)))
3364 ((member group gnus-zombie-list)
3365 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3366 ;; There may be more than one instance displayed.
3367 (while (gnus-group-goto-group group)
3368 (gnus-delete-line)))
3369 (gnus-make-hashtable-from-newsrc-alist)))
3371 (gnus-group-position-point)
3372 (if (< (length out) 2) (car out) (nreverse out))))
3374 (defun gnus-group-yank-group (&optional arg)
3375 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3376 The numeric ARG specifies how many newsgroups are to be yanked. The
3377 name of the newsgroup yanked is returned, or (if several groups are
3378 yanked) a list of yanked groups is returned."
3380 (setq arg (or arg 1))
3381 (let (info group prev out)
3382 (while (>= (decf arg) 0)
3383 (when (not (setq info (pop gnus-list-of-killed-groups)))
3384 (error "No more newsgroups to yank"))
3385 (push (setq group (nth 1 info)) out)
3386 ;; Find which newsgroup to insert this one before - search
3387 ;; backward until something suitable is found. If there are no
3388 ;; other newsgroups in this buffer, just make this newsgroup the
3390 (setq prev (gnus-group-group-name))
3391 (gnus-group-change-level
3392 info (gnus-info-level (cdr info)) gnus-level-killed
3393 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3395 (gnus-group-insert-group-line-info group)
3397 `(when (gnus-group-goto-group ,group)
3398 (gnus-group-kill-group 1))))
3400 (gnus-group-position-point)
3401 (if (< (length out) 2) (car out) (nreverse out))))
3403 (defun gnus-group-kill-level (level)
3404 "Kill all groups that is on a certain LEVEL."
3405 (interactive "nKill all groups on level: ")
3407 ((= level gnus-level-zombie)
3408 (setq gnus-killed-list
3409 (nconc gnus-zombie-list gnus-killed-list))
3410 (setq gnus-zombie-list nil))
3411 ((and (< level gnus-level-zombie)
3413 (or gnus-expert-user
3416 "Do you really want to kill all groups on level %d? "
3418 (let* ((prev gnus-newsrc-alist)
3421 (if (= (gnus-info-level (car alist)) level)
3423 (push (gnus-info-group (car alist)) gnus-killed-list)
3424 (setcdr prev (cdr alist)))
3426 (setq alist (cdr alist)))
3427 (gnus-make-hashtable-from-newsrc-alist)
3428 (gnus-group-list-groups)))
3430 (error "Can't kill; invalid level: %d" level))))
3432 (defun gnus-group-list-all-groups (&optional arg)
3433 "List all newsgroups with level ARG or lower.
3434 Default is gnus-level-unsubscribed, which lists all subscribed and most
3435 unsubscribed groups."
3437 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3439 ;; Redefine this to list ALL killed groups if prefix arg used.
3440 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3441 (defun gnus-group-list-killed (&optional arg)
3442 "List all killed newsgroups in the group buffer.
3443 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3444 entail asking the server for the groups."
3446 ;; Find all possible killed newsgroups if arg.
3448 (gnus-get-killed-groups))
3449 (if (not gnus-killed-list)
3450 (gnus-message 6 "No killed groups")
3451 (let (gnus-group-list-mode)
3452 (funcall gnus-group-prepare-function
3453 gnus-level-killed t gnus-level-killed))
3454 (goto-char (point-min)))
3455 (gnus-group-position-point))
3457 (defun gnus-group-list-zombies ()
3458 "List all zombie newsgroups in the group buffer."
3460 (if (not gnus-zombie-list)
3461 (gnus-message 6 "No zombie groups")
3462 (let (gnus-group-list-mode)
3463 (funcall gnus-group-prepare-function
3464 gnus-level-zombie t gnus-level-zombie))
3465 (goto-char (point-min)))
3466 (gnus-group-position-point))
3468 (defun gnus-group-list-active ()
3469 "List all groups that are available from the server(s)."
3471 ;; First we make sure that we have really read the active file.
3472 (unless (gnus-read-active-file-p)
3473 (let ((gnus-read-active-file t)
3474 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3475 (gnus-read-active-file)))
3476 ;; Find all groups and sort them.
3484 (push (symbol-name sym) list)))
3488 (buffer-read-only nil)
3492 (setq group (pop groups))
3493 (gnus-add-text-properties
3494 (point) (prog1 (1+ (point))
3496 (gnus-group-decoded-name group)
3498 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3500 'gnus-level (inline (gnus-group-level group)))))
3501 (goto-char (point-min))))
3503 (defun gnus-activate-all-groups (level)
3504 "Activate absolutely all groups."
3505 (interactive (list gnus-level-unsubscribed))
3506 (let ((gnus-activate-level level)
3507 (gnus-activate-foreign-newsgroups level))
3508 (gnus-group-get-new-news)))
3510 (defun gnus-group-get-new-news (&optional arg)
3511 "Get newly arrived articles.
3512 If ARG is a number, it specifies which levels you are interested in
3513 re-scanning. If ARG is non-nil and not a number, this will force
3514 \"hard\" re-reading of the active files from all servers."
3517 (let ((gnus-inhibit-demon t)
3518 ;; Binding this variable will inhibit multiple fetchings
3519 ;; of the same mail source.
3520 (nnmail-fetched-sources (list t)))
3521 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3522 (gnus-run-hooks 'gnus-get-new-news-hook)
3524 ;; Read any slave files.
3526 (gnus-master-read-slave-newsrc))
3528 ;; We might read in new NoCeM messages here.
3529 (when (and gnus-use-nocem
3531 (gnus-nocem-scan-groups))
3532 ;; If ARG is not a number, then we read the active file.
3533 (when (and arg (not (numberp arg)))
3534 (let ((gnus-read-active-file t))
3535 (gnus-read-active-file))
3538 ;; If the user wants it, we scan for new groups.
3539 (when (eq gnus-check-new-newsgroups 'always)
3540 (gnus-find-new-newsgroups)))
3542 (setq arg (gnus-group-default-level arg t))
3543 (if (and gnus-read-active-file (not arg))
3545 (gnus-read-active-file)
3546 (gnus-get-unread-articles arg))
3547 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3548 (gnus-get-unread-articles arg)))
3549 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3550 (gnus-group-list-groups (and (numberp arg)
3551 (max (car gnus-group-list-mode) arg)))))
3553 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3554 "Check for newly arrived news in the current group (and the N-1 next groups).
3555 The difference between N and the number of newsgroup checked is returned.
3556 If N is negative, this group and the N-1 previous groups will be checked."
3558 (let* ((groups (gnus-group-process-prefix n))
3559 (ret (if (numberp n) (- n (length groups)) 0))
3563 (gnus-inhibit-demon t)
3564 ;; Binding this variable will inhibit multiple fetchings
3565 ;; of the same mail source.
3566 (nnmail-fetched-sources (list t)))
3567 (gnus-run-hooks 'gnus-get-new-news-hook)
3568 (while (setq group (pop groups))
3569 (gnus-group-remove-mark group)
3570 ;; Bypass any previous denials from the server.
3571 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3572 (if (gnus-activate-group group (if dont-scan nil 'scan))
3574 (gnus-get-unread-articles-in-group
3575 (gnus-get-info group) (gnus-active group) t)
3576 (unless (gnus-virtual-group-p group)
3577 (gnus-close-group group))
3579 (gnus-agent-save-group-info
3580 method (gnus-group-real-name group) (gnus-active group)))
3581 (gnus-group-update-group group))
3582 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3584 (gnus-error 3 "Server denied access")
3585 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3588 (when gnus-goto-next-group-when-activating
3589 (gnus-group-next-unread-group 1 t))
3590 (gnus-summary-position-point)
3593 (defun gnus-group-fetch-faq (group &optional faq-dir)
3594 "Fetch the FAQ for the current group.
3595 If given a prefix argument, prompt for the FAQ dir
3599 (gnus-group-group-name)
3600 (when current-prefix-arg
3602 "FAQ dir: " (and (listp gnus-group-faq-directory)
3604 gnus-group-faq-directory))))))
3606 (error "No group name given"))
3607 (let ((dirs (or faq-dir gnus-group-faq-directory))
3609 (unless (listp dirs)
3610 (setq dirs (list dirs)))
3611 (while (and (not found)
3612 (setq dir (pop dirs)))
3613 (let ((name (gnus-group-real-name group)))
3614 (setq file (expand-file-name name dir)))
3615 (if (not (file-exists-p file))
3616 (gnus-message 1 "No such file: %s" file)
3617 (let ((enable-local-variables nil))
3621 (defun gnus-group-fetch-charter (group)
3622 "Fetch the charter for the current group.
3623 If given a prefix argument, prompt for a group."
3625 (list (or (when current-prefix-arg
3626 (completing-read "Group: " gnus-active-hashtb))
3627 (gnus-group-group-name)
3628 gnus-newsgroup-name)))
3630 (error "No group name given"))
3632 (condition-case nil (require 'url-http) (error nil))
3633 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3635 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3636 (setq hierarchy (match-string 1 name))
3637 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3638 (if (fboundp 'url-http-file-exists-p)
3639 (url-http-file-exists-p (eval url))
3641 (browse-url (eval url))
3642 (setq url (concat "http://" hierarchy
3643 ".news-admin.org/charters/" name))
3644 (if (and (fboundp 'url-http-file-exists-p)
3645 (url-http-file-exists-p url))
3647 (gnus-group-fetch-control group))))))
3649 (defun gnus-group-fetch-control (group)
3650 "Fetch the archived control messages for the current group.
3651 If given a prefix argument, prompt for a group."
3653 (list (or (when current-prefix-arg
3654 (completing-read "Group: " gnus-active-hashtb))
3655 (gnus-group-group-name)
3656 gnus-newsgroup-name)))
3658 (error "No group name given"))
3659 (let ((name (gnus-group-real-name group))
3661 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3662 (setq hierarchy (match-string 1 name))
3663 (if gnus-group-fetch-control-use-browse-url
3664 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3665 hierarchy "/" name ".Z"))
3666 (let ((enable-local-variables nil))
3667 (gnus-group-read-ephemeral-group
3669 `(nndoc ,group (nndoc-address
3670 ,(find-file-noselect
3671 (concat "/ftp@ftp.isc.org:/usenet/control/"
3672 hierarchy "/" name ".Z")))
3673 (nndoc-article-type mbox)) t nil nil))))))
3675 (defun gnus-group-describe-group (force &optional group)
3676 "Display a description of the current newsgroup."
3677 (interactive (list current-prefix-arg (gnus-group-group-name)))
3678 (let* ((method (gnus-find-method-for-group group))
3679 (mname (gnus-group-prefixed-name "" method))
3682 gnus-description-hashtb)
3683 (gnus-sethash mname nil gnus-description-hashtb))
3685 (error "No group name given"))
3686 (when (or (and gnus-description-hashtb
3687 ;; We check whether this group's method has been
3688 ;; queried for a description file.
3689 (gnus-gethash mname gnus-description-hashtb))
3690 (setq desc (gnus-group-get-description group))
3691 (gnus-read-descriptions-file method))
3693 (or desc (gnus-gethash group gnus-description-hashtb)
3694 "No description available")))))
3696 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3697 (defun gnus-group-describe-all-groups (&optional force)
3698 "Pop up a buffer with descriptions of all newsgroups."
3701 (setq gnus-description-hashtb nil))
3702 (when (not (or gnus-description-hashtb
3703 (gnus-read-all-descriptions-files)))
3704 (error "Couldn't request descriptions file"))
3705 (let ((buffer-read-only nil)
3711 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3712 (insert (format " *: %-20s %s\n"
3713 (gnus-group-name-decode
3714 (symbol-name group) charset)
3715 (gnus-group-name-decode
3716 (symbol-value group) charset))))
3717 (gnus-add-text-properties
3718 b (1+ b) (list 'gnus-group group
3719 'gnus-unread t 'gnus-marked nil
3720 'gnus-level (1+ gnus-level-subscribed))))
3721 gnus-description-hashtb)
3722 (goto-char (point-min))
3723 (gnus-group-position-point)))
3725 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3726 (defun gnus-group-apropos (regexp &optional search-description)
3727 "List all newsgroups that have names that match a regexp."
3728 (interactive "sGnus apropos (regexp): ")
3730 (obuf (current-buffer))
3732 ;; Go through all newsgroups that are known to Gnus.
3735 (and (symbol-name group)
3736 (string-match regexp (symbol-name group))
3737 (symbol-value group)
3738 (push (symbol-name group) groups)))
3740 ;; Also go through all descriptions that are known to Gnus.
3741 (when search-description
3744 (and (string-match regexp (symbol-value group))
3745 (push (symbol-name group) groups)))
3746 gnus-description-hashtb))
3748 (gnus-message 3 "No groups matched \"%s\"." regexp)
3749 ;; Print out all the groups.
3751 (pop-to-buffer "*Gnus Help*")
3752 (buffer-disable-undo)
3754 (setq groups (sort groups 'string<))
3756 ;; Groups may be entered twice into the list of groups.
3757 (when (not (string= (car groups) prev))
3758 (setq prev (car groups))
3759 (let ((charset (gnus-group-name-charset nil prev)))
3760 (insert (gnus-group-name-decode prev charset) "\n")
3761 (when (and gnus-description-hashtb
3762 (setq des (gnus-gethash (car groups)
3763 gnus-description-hashtb)))
3764 (insert " " (gnus-group-name-decode des charset) "\n"))))
3765 (setq groups (cdr groups)))
3766 (goto-char (point-min))))
3767 (pop-to-buffer obuf)))
3769 (defun gnus-group-description-apropos (regexp)
3770 "List all newsgroups that have names or descriptions that match a regexp."
3771 (interactive "sGnus description apropos (regexp): ")
3772 (when (not (or gnus-description-hashtb
3773 (gnus-read-all-descriptions-files)))
3774 (error "Couldn't request descriptions file"))
3775 (gnus-group-apropos regexp t))
3777 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3778 (defun gnus-group-list-matching (level regexp &optional all lowest)
3779 "List all groups with unread articles that match REGEXP.
3780 If the prefix LEVEL is non-nil, it should be a number that says which
3781 level to cut off listing groups.
3782 If ALL, also list groups with no unread articles.
3783 If LOWEST, don't list groups with level lower than LOWEST.
3785 This command may read the active file."
3786 (interactive "P\nsList newsgroups matching: ")
3787 ;; First make sure active file has been read.
3789 (> (prefix-numeric-value level) gnus-level-killed))
3790 (gnus-get-killed-groups))
3791 (funcall gnus-group-prepare-function
3792 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3793 (goto-char (point-min))
3794 (gnus-group-position-point))
3796 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3797 "List all groups that match REGEXP.
3798 If the prefix LEVEL is non-nil, it should be a number that says which
3799 level to cut off listing groups.
3800 If LOWEST, don't list groups with level lower than LOWEST."
3801 (interactive "P\nsList newsgroups matching: ")
3803 (setq level (prefix-numeric-value level)))
3804 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3806 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3807 (defun gnus-group-save-newsrc (&optional force)
3808 "Save the Gnus startup files.
3809 If FORCE, force saving whether it is necessary or not."
3811 (gnus-save-newsrc-file force))
3813 (defun gnus-group-restart (&optional arg)
3814 "Force Gnus to read the .newsrc file."
3816 (when (gnus-yes-or-no-p
3817 (format "Are you sure you want to restart Gnus? "))
3818 (gnus-save-newsrc-file)
3822 (defun gnus-group-read-init-file ()
3823 "Read the Gnus elisp init file."
3825 (gnus-read-init-file)
3826 (gnus-message 5 "Read %s" gnus-init-file))
3828 (defun gnus-group-check-bogus-groups (&optional silent)
3829 "Check bogus newsgroups.
3830 If given a prefix, don't ask for confirmation before removing a bogus
3833 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3834 (gnus-group-list-groups))
3836 (defun gnus-group-find-new-groups (&optional arg)
3837 "Search for new groups and add them.
3838 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3839 With 1 C-u, use the `ask-server' method to query the server for new
3841 With 2 C-u's, use most complete method possible to query the server
3842 for new groups, and subscribe the new groups as zombies."
3844 (gnus-find-new-newsgroups (or arg 1))
3845 (gnus-group-list-groups))
3847 (defun gnus-group-edit-global-kill (&optional article group)
3848 "Edit the global kill file.
3849 If GROUP, edit that local kill file instead."
3851 (setq gnus-current-kill-article article)
3852 (gnus-kill-file-edit-file group)
3855 (substitute-command-keys
3856 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3857 (if group "local" "global")))))
3859 (defun gnus-group-edit-local-kill (article group)
3860 "Edit a local kill file."
3861 (interactive (list nil (gnus-group-group-name)))
3862 (gnus-group-edit-global-kill article group))
3864 (defun gnus-group-force-update ()
3865 "Update `.newsrc' file."
3867 (gnus-save-newsrc-file))
3869 (defun gnus-group-suspend ()
3870 "Suspend the current Gnus session.
3871 In fact, cleanup buffers except for group mode buffer.
3872 The hook gnus-suspend-gnus-hook is called before actually suspending."
3874 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3875 (gnus-offer-save-summaries)
3876 ;; Kill Gnus buffers except for group mode buffer.
3877 (let ((group-buf (get-buffer gnus-group-buffer)))
3878 (mapcar (lambda (buf)
3879 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3883 (eq major-mode 'message-mode))))
3884 (gnus-kill-buffer buf)))
3886 (gnus-kill-gnus-frames)
3888 (bury-buffer group-buf)
3889 (delete-windows-on group-buf t))))
3891 (defun gnus-group-clear-dribble ()
3892 "Clear all information from the dribble buffer."
3894 (gnus-dribble-clear)
3895 (gnus-message 7 "Cleared dribble buffer"))
3897 (defun gnus-group-exit ()
3898 "Quit reading news after updating .newsrc.eld and .newsrc.
3899 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3902 (or noninteractive ;For gnus-batch-kill
3903 (not gnus-interactive-exit) ;Without confirmation
3905 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3906 (gnus-run-hooks 'gnus-exit-gnus-hook)
3907 ;; Offer to save data from non-quitted summary buffers.
3908 (gnus-offer-save-summaries)
3909 ;; Save the newsrc file(s).
3910 (gnus-save-newsrc-file)
3912 (gnus-close-backends)
3913 ;; Reset everything.
3915 ;; Allow the user to do things after cleaning up.
3916 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3918 (defun gnus-group-quit ()
3919 "Quit reading news without updating .newsrc.eld or .newsrc.
3920 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3922 (when (or noninteractive ;For gnus-batch-kill
3923 (zerop (buffer-size))
3924 (not (gnus-server-opened gnus-select-method))
3926 (not gnus-current-startup-file)
3928 (format "Quit reading news without saving %s? "
3929 (file-name-nondirectory gnus-current-startup-file))))
3930 (gnus-run-hooks 'gnus-exit-gnus-hook)
3931 (gnus-configure-windows 'group t)
3932 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3933 (not (zerop (save-excursion
3934 (set-buffer gnus-dribble-buffer)
3937 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3939 (gnus-close-backends)
3941 (gnus-kill-buffer gnus-group-buffer)
3942 ;; Allow the user to do things after cleaning up.
3943 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3945 (defun gnus-group-describe-briefly ()
3946 "Give a one line description of the group mode commands."
3948 (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")))
3950 (defun gnus-group-browse-foreign-server (method)
3951 "Browse a foreign news server.
3952 If called interactively, this function will ask for a select method
3953 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3954 If not, METHOD should be a list where the first element is the method
3955 and the second element is the address."
3957 (list (let ((how (completing-read
3959 (append gnus-valid-select-methods gnus-server-alist)
3960 nil t (cons "nntp" 0) 'gnus-method-history)))
3961 ;; We either got a backend name or a virtual server name.
3962 ;; If the first, we also need an address.
3963 (if (assoc how gnus-valid-select-methods)
3965 ;; Suggested by mapjph@bath.ac.uk.
3968 (mapcar (lambda (server) (list server))
3969 gnus-secondary-servers)))
3970 ;; We got a server name.
3972 (gnus-browse-foreign-server method))
3974 (defun gnus-group-set-info (info &optional method-only-group part)
3975 (when (or info part)
3976 (let* ((entry (gnus-gethash
3977 (or method-only-group (gnus-info-group info))
3978 gnus-newsrc-hashtb))
3980 (info (if method-only-group (nth 2 entry) info))
3982 (when method-only-group
3984 (error "Trying to change non-existent group %s" method-only-group))
3985 ;; We have received parts of the actual group info - either the
3986 ;; select method or the group parameters. We first check
3987 ;; whether we have to extend the info, and if so, do that.
3988 (let ((len (length info))
3989 (total (if (eq part 'method) 5 6)))
3991 (setcdr (nthcdr (1- len) info)
3992 (make-list (- total len) nil)))
3993 ;; Then we enter the new info.
3994 (setcar (nthcdr (1- total) info) part-info)))
3996 ;; This is a new group, so we just create it.
3998 (set-buffer gnus-group-buffer)
3999 (setq method (gnus-info-method info))
4000 (when (gnus-server-equal method "native")
4003 (set-buffer gnus-group-buffer)
4005 ;; It's a foreign group...
4006 (gnus-group-make-group
4007 (gnus-group-real-name (gnus-info-group info))
4008 (if (stringp method) method
4009 (prin1-to-string (car method)))
4011 (nth 1 (gnus-info-method info))))
4012 ;; It's a native group.
4013 (gnus-group-make-group (gnus-info-group info))))
4014 (gnus-message 6 "Note: New group created")
4016 (gnus-gethash (gnus-group-prefixed-name
4017 (gnus-group-real-name (gnus-info-group info))
4018 (or (gnus-info-method info) gnus-select-method))
4019 gnus-newsrc-hashtb))))
4020 ;; Whether it was a new group or not, we now have the entry, so we
4021 ;; can do the update.
4024 (setcar (nthcdr 2 entry) info)
4025 (when (and (not (eq (car entry) t))
4026 (gnus-active (gnus-info-group info)))
4027 (setcar entry (length
4028 (gnus-list-of-unread-articles (car info))))))
4029 (error "No such group: %s" (gnus-info-group info))))))
4031 (defun gnus-group-set-method-info (group select-method)
4032 (gnus-group-set-info select-method group 'method))
4034 (defun gnus-group-set-params-info (group params)
4035 (gnus-group-set-info params group 'params))
4037 (defun gnus-add-marked-articles (group type articles &optional info force)
4038 ;; Add ARTICLES of TYPE to the info of GROUP.
4039 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4040 ;; add, but replace marked articles of TYPE with ARTICLES.
4041 (let ((info (or info (gnus-get-info group)))
4044 (and (not (setq marked (nthcdr 3 info)))
4046 (setcdr (nthcdr 2 info)
4047 (list (list (cons type (gnus-compress-sequence
4049 (and (not (setq m (assq type (car marked))))
4052 (cons (cons type (gnus-compress-sequence articles t) )
4056 (setcar (nthcdr 3 info)
4057 (gnus-delete-alist type (car marked)))
4058 (setcdr m (gnus-compress-sequence articles t)))
4059 (setcdr m (gnus-compress-sequence
4060 (sort (nconc (gnus-uncompress-range (cdr m))
4061 (copy-sequence articles)) '<) t))))))
4063 (defun gnus-add-mark (group mark article)
4064 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4065 (let ((buffer (gnus-summary-buffer-name group)))
4066 (if (gnus-buffer-live-p buffer)
4068 (set-buffer (get-buffer buffer))
4069 (gnus-summary-add-mark article mark))
4070 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4074 ;;; Group timestamps
4077 (defun gnus-group-set-timestamp ()
4078 "Change the timestamp of the current group to the current time.
4079 This function can be used in hooks like `gnus-select-group-hook'
4080 or `gnus-group-catchup-group-hook'."
4081 (when gnus-newsgroup-name
4082 (let ((time (current-time)))
4083 (setcdr (cdr time) nil)
4084 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4086 (defsubst gnus-group-timestamp (group)
4087 "Return the timestamp for GROUP."
4088 (gnus-group-get-parameter group 'timestamp t))
4090 (defun gnus-group-timestamp-delta (group)
4091 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4092 (let* ((time (or (gnus-group-timestamp group)
4094 (delta (subtract-time (current-time) time)))
4095 (+ (* (nth 0 delta) 65536.0)
4098 (defun gnus-group-timestamp-string (group)
4099 "Return a string of the timestamp for GROUP."
4100 (let ((time (gnus-group-timestamp group)))
4103 (gnus-time-iso8601 time))))
4105 (defun gnus-group-list-cached (level &optional lowest)
4106 "List all groups with cached articles.
4107 If the prefix LEVEL is non-nil, it should be a number that says which
4108 level to cut off listing groups.
4109 If LOWEST, don't list groups with level lower than LOWEST.
4111 This command may read the active file."
4114 (setq level (prefix-numeric-value level)))
4115 (when (or (not level) (>= level gnus-level-zombie))
4117 (funcall gnus-group-prepare-function
4118 (or level gnus-level-subscribed)
4120 (let ((marks (gnus-info-marks info)))
4121 (assq 'cache marks)))
4124 (or (gnus-gethash group
4125 gnus-cache-active-hashtb)
4126 ;; Cache active file might use "."
4129 (mapconcat 'identity
4130 (split-string group ":")
4132 gnus-cache-active-hashtb))))
4133 (goto-char (point-min))
4134 (gnus-group-position-point))
4136 (defun gnus-group-list-dormant (level &optional lowest)
4137 "List all groups with dormant articles.
4138 If the prefix LEVEL is non-nil, it should be a number that says which
4139 level to cut off listing groups.
4140 If LOWEST, don't list groups with level lower than LOWEST.
4142 This command may read the active file."
4145 (setq level (prefix-numeric-value level)))
4146 (when (or (not level) (>= level gnus-level-zombie))
4148 (funcall gnus-group-prepare-function
4149 (or level gnus-level-subscribed)
4151 (let ((marks (gnus-info-marks info)))
4152 (assq 'dormant marks)))
4155 (goto-char (point-min))
4156 (gnus-group-position-point))
4158 (defun gnus-group-listed-groups ()
4159 "Return a list of listed groups."
4161 (goto-char (point-min))
4162 (while (setq point (text-property-not-all (point) (point-max)
4165 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4169 (defun gnus-group-list-plus (&optional args)
4170 "List groups plus the current selection."
4172 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4173 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4175 (push last-command-event unread-command-events)
4176 (if (featurep 'xemacs)
4177 (push (make-event 'key-press '(key ?A)) unread-command-events)
4178 (push ?A unread-command-events))
4179 (let (gnus-pick-mode keys)
4180 (setq keys (if (featurep 'xemacs)
4181 (events-to-keys (read-key-sequence nil))
4182 (read-key-sequence nil)))
4183 (setq func (lookup-key (current-local-map) keys)))
4187 (call-interactively func))))
4189 (defun gnus-group-list-flush (&optional args)
4190 "Flush groups from the current selection."
4192 (let ((gnus-group-list-option 'flush))
4193 (gnus-group-list-plus args)))
4195 (defun gnus-group-list-limit (&optional args)
4196 "List groups limited within the current selection."
4198 (let ((gnus-group-list-option 'limit))
4199 (gnus-group-list-plus args)))
4201 (defun gnus-group-mark-article-read (group article)
4202 "Mark ARTICLE read."
4203 (let ((buffer (gnus-summary-buffer-name group))
4204 (mark gnus-read-mark)
4206 (if (get-buffer buffer)
4207 (with-current-buffer buffer
4208 (setq active gnus-newsgroup-active)
4209 (gnus-activate-group group)
4210 (when gnus-newsgroup-prepared
4211 (when (and gnus-newsgroup-auto-expire
4212 (memq mark gnus-auto-expirable-marks))
4213 (setq mark gnus-expirable-mark))
4214 (setq mark (gnus-request-update-mark
4215 group article mark))
4216 (gnus-mark-article-as-read article mark)
4217 (setq gnus-newsgroup-active (gnus-active group))
4219 (setq n (1+ (cdr active)))
4220 (while (<= n (cdr gnus-newsgroup-active))
4221 (unless (eq n article)
4222 (push n gnus-newsgroup-unselected))
4224 (setq gnus-newsgroup-unselected
4225 (nreverse gnus-newsgroup-unselected)))))
4226 (gnus-activate-group group)
4227 (gnus-group-make-articles-read group (list article))
4228 (when (gnus-group-auto-expirable-p group)
4229 (gnus-add-marked-articles
4230 group 'expire (list article))))))
4232 (provide 'gnus-group)
4234 ;;; gnus-group.el ends here