1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-map))
47 (let ((features (cons 'gnus-group features)))
49 (defvar gnus-cache-active-hashtb))
51 (defcustom gnus-group-archive-directory
52 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
53 "*The address of the (ding) archives."
54 :group 'gnus-group-foreign
57 (defcustom gnus-group-recent-archive-directory
58 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
59 "*The address of the most recent (ding) articles."
60 :group 'gnus-group-foreign
63 (defcustom gnus-no-groups-message "No gnus is bad news"
64 "*Message displayed by Gnus when no groups are available."
68 (defcustom gnus-keep-same-level nil
69 "*Non-nil means that the next newsgroup after the current will be on the same level.
70 When you type, for instance, `n' after reading the last article in the
71 current newsgroup, you will go to the next newsgroup. If this variable
72 is nil, the next newsgroup will be the next from the group
74 If this variable is non-nil, Gnus will either put you in the
75 next newsgroup with the same level, or, if no such newsgroup is
76 available, the next newsgroup with the lowest possible level higher
77 than the current level.
78 If this variable is `best', Gnus will make the next newsgroup the one
80 :group 'gnus-group-levels
81 :type '(choice (const nil)
83 (sexp :tag "other" t)))
85 (defcustom gnus-group-goto-unread t
86 "*If non-nil, movement commands will go to the next unread and subscribed group."
87 :link '(custom-manual "(gnus)Group Maneuvering")
88 :group 'gnus-group-various
91 (defcustom gnus-goto-next-group-when-activating t
92 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
93 :link '(custom-manual "(gnus)Scanning New Messages")
94 :group 'gnus-group-various
97 (defcustom gnus-permanently-visible-groups nil
98 "*Regexp to match groups that should always be listed in the group buffer.
99 This means that they will still be listed even when there are no
100 unread articles in the groups.
102 If nil, no groups are permanently visible."
103 :group 'gnus-group-listing
104 :type '(choice regexp (const nil)))
106 (defcustom gnus-list-groups-with-ticked-articles t
107 "*If non-nil, list groups that have only ticked articles.
108 If nil, only list groups that have unread articles."
109 :group 'gnus-group-listing
112 (defcustom gnus-group-default-list-level gnus-level-subscribed
113 "*Default listing level.
114 Ignored if `gnus-group-use-permanent-levels' is non-nil."
115 :group 'gnus-group-listing
118 (defcustom gnus-group-list-inactive-groups t
119 "*If non-nil, inactive groups will be listed."
120 :group 'gnus-group-listing
121 :group 'gnus-group-levels
124 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
125 "*Function used for sorting the group buffer.
126 This function will be called with group info entries as the arguments
127 for the groups to be sorted. Pre-made functions include
128 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
129 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
130 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
131 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
133 This variable can also be a list of sorting functions. In that case,
134 the most significant sort function should be the last function in the
136 :group 'gnus-group-listing
137 :link '(custom-manual "(gnus)Sorting Groups")
138 :type '(repeat :value-to-internal (lambda (widget value)
139 (if (listp value) value (list value)))
140 :match (lambda (widget value)
142 (widget-editable-list-match widget value)))
143 (choice (function-item gnus-group-sort-by-alphabet)
144 (function-item gnus-group-sort-by-real-name)
145 (function-item gnus-group-sort-by-unread)
146 (function-item gnus-group-sort-by-level)
147 (function-item gnus-group-sort-by-score)
148 (function-item gnus-group-sort-by-method)
149 (function-item gnus-group-sort-by-server)
150 (function-item gnus-group-sort-by-rank)
151 (function :tag "other" nil))))
153 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
154 "*Format of group lines.
155 It works along the same lines as a normal formatting string,
156 with some simple extensions.
158 %M Only marked articles (character, \"*\" or \" \")
159 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
160 %L Level of subscribedness (integer)
161 %N Number of unread articles (integer)
162 %I Number of dormant articles (integer)
163 %i Number of ticked and dormant (integer)
164 %T Number of ticked articles (integer)
165 %R Number of read articles (integer)
166 %U Number of unseen articles (integer)
167 %t Estimated total number of articles (integer)
168 %y Number of unread, unticked articles (integer)
169 %G Group name (string)
170 %g Qualified group name (string)
171 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
172 %C Group comment (string)
173 %D Group description (string)
174 %s Select method (string)
175 %o Moderated group (char, \"m\")
176 %p Process mark (char)
177 %B Whether a summary buffer for the group is open (char, \"*\")
178 %O Moderated group (string, \"(m)\" or \"\")
179 %P Topic indentation (string)
180 %m Whether there is new(ish) mail in the group (char, \"%\")
181 %l Whether there are GroupLens predictions for this group (string)
182 %n Select from where (string)
183 %z A string that look like `<%s:%n>' if a foreign select method is used
184 %d The date the group was last entered.
185 %E Icon as defined by `gnus-group-icon-list'.
186 %u User defined specifier. The next character in the format string should
187 be a letter. Gnus will call the function gnus-user-format-function-X,
188 where X is the letter following %u. The function will be passed a
189 single dummy parameter as argument. The function should return a
190 string, which will be inserted into the buffer just like information
191 from any other group specifier.
193 Note that this format specification is not always respected. For
194 reasons of efficiency, when listing killed groups, this specification
195 is ignored altogether. If the spec is changed considerably, your
196 output may end up looking strange when listing both alive and killed
199 If you use %o or %O, reading the active file will be slower and quite
200 a bit of extra memory will be used. %D will also worsen performance.
201 Also note that if you change the format specification to include any
202 of these specs, you must probably re-start Gnus to see them go into
205 General format specifiers can also be used.
206 See Info node `(gnus)Formatting Variables'."
207 :link '(custom-manual "(gnus)Formatting Variables")
208 :group 'gnus-group-visual
211 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
212 "*The format specification for the group mode line.
213 It works along the same lines as a normal formatting string,
214 with some simple extensions:
216 %S The native news server.
217 %M The native select method.
218 %: \":\" if %S isn't \"\"."
219 :group 'gnus-group-visual
222 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
223 (when (featurep 'xemacs)
224 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
225 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
227 (defcustom gnus-group-menu-hook nil
228 "Hook run after the creation of the group mode menu."
229 :group 'gnus-group-various
232 (defcustom gnus-group-catchup-group-hook nil
233 "Hook run when catching up a group from the group buffer."
234 :group 'gnus-group-various
235 :link '(custom-manual "(gnus)Group Data")
238 (defcustom gnus-group-update-group-hook nil
239 "Hook called when updating group lines."
240 :group 'gnus-group-visual
243 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
244 "*A function that is called to generate the group buffer.
245 The function is called with three arguments: The first is a number;
246 all group with a level less or equal to that number should be listed,
247 if the second is non-nil, empty groups should also be displayed. If
248 the third is non-nil, it is a number. No groups with a level lower
249 than this number should be displayed.
251 The only current function implemented is `gnus-group-prepare-flat'."
252 :group 'gnus-group-listing
255 (defcustom gnus-group-prepare-hook nil
256 "Hook called after the group buffer has been generated.
257 If you want to modify the group buffer, you can use this hook."
258 :group 'gnus-group-listing
261 (defcustom gnus-suspend-gnus-hook nil
262 "Hook called when suspending (not exiting) Gnus."
266 (defcustom gnus-exit-gnus-hook nil
267 "Hook called when exiting Gnus."
271 (defcustom gnus-after-exiting-gnus-hook nil
272 "Hook called after exiting Gnus."
276 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
277 "Hook called when a group line is changed.
278 The hook will not be called if `gnus-visual' is nil.
280 The default function `gnus-group-highlight-line' will
281 highlight the line according to the `gnus-group-highlight'
283 :group 'gnus-group-visual
286 (defcustom gnus-useful-groups
287 '(("(ding) mailing list mirrored at sunsite.auc.dk"
289 (nntp "sunsite.auc.dk"
290 (nntp-address "sunsite.auc.dk")))
293 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
297 (nndoc-article-type mbox)
298 (eval `(nndoc-address
299 ,(let ((file (nnheader-find-etc-directory
302 (error "Couldn't find doc group"))
304 "*Alist of useful group-server pairs."
305 :group 'gnus-group-listing
306 :type '(repeat (list (string :tag "Description")
308 (sexp :tag "Method"))))
310 (defcustom gnus-group-highlight
312 ((and mailp (= unread 0) (eq level 1)) .
313 gnus-group-mail-1-empty)
314 ((and mailp (eq level 1)) .
316 ((and mailp (= unread 0) (eq level 2)) .
317 gnus-group-mail-2-empty)
318 ((and mailp (eq level 2)) .
320 ((and mailp (= unread 0) (eq level 3)) .
321 gnus-group-mail-3-empty)
322 ((and mailp (eq level 3)) .
324 ((and mailp (= unread 0)) .
325 gnus-group-mail-low-empty)
329 ((and (= unread 0) (eq level 1)) .
330 gnus-group-news-1-empty)
331 ((and (eq level 1)) .
333 ((and (= unread 0) (eq level 2)) .
334 gnus-group-news-2-empty)
335 ((and (eq level 2)) .
337 ((and (= unread 0) (eq level 3)) .
338 gnus-group-news-3-empty)
339 ((and (eq level 3)) .
341 ((and (= unread 0) (eq level 4)) .
342 gnus-group-news-4-empty)
343 ((and (eq level 4)) .
345 ((and (= unread 0) (eq level 5)) .
346 gnus-group-news-5-empty)
347 ((and (eq level 5)) .
349 ((and (= unread 0) (eq level 6)) .
350 gnus-group-news-6-empty)
351 ((and (eq level 6)) .
353 ((and (= unread 0)) .
354 gnus-group-news-low-empty)
356 gnus-group-news-low))
357 "*Controls the highlighting of group buffer lines.
359 Below is a list of `Form'/`Face' pairs. When deciding how a a
360 particular group line should be displayed, each form is
361 evaluated. The content of the face field after the first true form is
362 used. You can change how those group lines are displayed by
363 editing the face field.
365 It is also possible to change and add form fields, but currently that
366 requires an understanding of Lisp expressions. Hopefully this will
367 change in a future release. For now, you can use the following
368 variables in the Lisp expression:
370 group: The name of the group.
371 unread: The number of unread articles in the group.
372 method: The select method used.
373 mailp: Whether it's a mail group or not.
374 level: The level of the group.
375 score: The score of the group.
376 ticked: The number of ticked articles."
377 :group 'gnus-group-visual
378 :type '(repeat (cons (sexp :tag "Form") face)))
380 (defcustom gnus-new-mail-mark ?%
381 "Mark used for groups with new mail."
382 :group 'gnus-group-visual
385 (defgroup gnus-group-icons nil
386 "Add Icons to your group buffer."
387 :group 'gnus-group-visual)
389 (defcustom gnus-group-icon-list
391 "*Controls the insertion of icons into group buffer lines.
393 Below is a list of `Form'/`File' pairs. When deciding how a
394 particular group line should be displayed, each form is evaluated.
395 The icon from the file field after the first true form is used. You
396 can change how those group lines are displayed by editing the file
397 field. The File will either be found in the
398 `gnus-group-glyph-directory' or by designating absolute name of the
401 It is also possible to change and add form fields, but currently that
402 requires an understanding of Lisp expressions. Hopefully this will
403 change in a future release. For now, you can use the following
404 variables in the Lisp expression:
406 group: The name of the group.
407 unread: The number of unread articles in the group.
408 method: The select method used.
409 mailp: Whether it's a mail group or not.
410 newsp: Whether it's a news group or not
411 level: The level of the group.
412 score: The score of the group.
413 ticked: The number of ticked articles."
414 :group 'gnus-group-icons
415 :type '(repeat (cons (sexp :tag "Form") file)))
417 (defcustom gnus-group-name-charset-method-alist nil
418 "Alist of method and the charset for group names.
421 (((nntp \"news.com.cn\") . cn-gb-2312))"
424 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
426 (defcustom gnus-group-name-charset-group-alist
427 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
428 (mm-coding-system-p 'utf-8))
431 "Alist of group regexp and the charset for group names.
434 ((\"\\.com\\.cn:\" . cn-gb-2312))"
436 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
438 (defcustom gnus-group-jump-to-group-prompt nil
439 "Default prompt for `gnus-group-jump-to-group'.
440 If non-nil, the value should be a string, e.g. \"nnml:\",
441 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
442 in the minibuffer prompt."
444 :group 'gnus-group-various
445 :type '(choice (string :tag "Prompt string")
446 (const :tag "Empty" nil)))
448 (defvar gnus-group-listing-limit 1000
449 "*A limit of the number of groups when listing.
450 If the number of groups is larger than the limit, list them in a
453 ;;; Internal variables
455 (defvar gnus-group-is-exiting-p nil)
456 (defvar gnus-group-is-exiting-without-update-p nil)
457 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
458 "Function for sorting the group buffer.")
460 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
461 "Function for sorting the selected groups in the group buffer.")
463 (defvar gnus-group-indentation-function nil)
464 (defvar gnus-goto-missing-group-function nil)
465 (defvar gnus-group-update-group-function nil)
466 (defvar gnus-group-goto-next-group-function nil
467 "Function to override finding the next group after listing groups.")
469 (defvar gnus-group-edit-buffer nil)
471 (defvar gnus-group-line-format-alist
472 `((?M gnus-tmp-marked-mark ?c)
473 (?S gnus-tmp-subscribed ?c)
474 (?L gnus-tmp-level ?d)
475 (?N (cond ((eq number t) "*" )
479 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
480 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
482 (?R gnus-tmp-number-of-read ?s)
483 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
484 (?t gnus-tmp-number-total ?d)
485 (?y gnus-tmp-number-of-unread ?s)
486 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
487 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
488 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
489 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
490 (?g (if (boundp 'gnus-tmp-decoded-group)
491 gnus-tmp-decoded-group
494 (?G gnus-tmp-qualified-group ?s)
495 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
496 gnus-tmp-decoded-group
499 (?C gnus-tmp-comment ?s)
500 (?D gnus-tmp-newsgroup-description ?s)
501 (?o gnus-tmp-moderated ?c)
502 (?O gnus-tmp-moderated-string ?s)
503 (?p gnus-tmp-process-marked ?c)
504 (?s gnus-tmp-news-server ?s)
505 (?n ,(if (featurep 'xemacs)
506 '(symbol-name gnus-tmp-news-method)
507 'gnus-tmp-news-method)
509 (?P gnus-group-indentation ?s)
510 (?E gnus-tmp-group-icon ?s)
511 (?B gnus-tmp-summary-live ?c)
512 (?l gnus-tmp-grouplens ?s)
513 (?z gnus-tmp-news-method-string ?s)
514 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
515 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
516 (?u gnus-tmp-user-defined ?s)))
518 (defvar gnus-group-mode-line-format-alist
519 `((?S gnus-tmp-news-server ?s)
520 (?M gnus-tmp-news-method ?s)
521 (?u gnus-tmp-user-defined ?s)
522 (?: gnus-tmp-colon ?s)))
524 (defvar gnus-topic-topology nil
525 "The complete topic hierarchy.")
527 (defvar gnus-topic-alist nil
528 "The complete topic-group alist.")
530 (defvar gnus-group-marked nil)
532 (defvar gnus-group-list-mode nil)
535 (defvar gnus-group-icon-cache nil)
537 (defvar gnus-group-listed-groups nil)
538 (defvar gnus-group-list-option nil)
544 (put 'gnus-group-mode 'mode-class 'special)
546 (gnus-define-keys gnus-group-mode-map
547 " " gnus-group-read-group
548 "=" gnus-group-select-group
549 "\r" gnus-group-select-group
550 "\M-\r" gnus-group-quick-select-group
551 "\M- " gnus-group-visible-select-group
552 [(meta control return)] gnus-group-select-group-ephemerally
553 "j" gnus-group-jump-to-group
554 "n" gnus-group-next-unread-group
555 "p" gnus-group-prev-unread-group
556 "\177" gnus-group-prev-unread-group
557 [delete] gnus-group-prev-unread-group
558 [backspace] gnus-group-prev-unread-group
559 "N" gnus-group-next-group
560 "P" gnus-group-prev-group
561 "\M-n" gnus-group-next-unread-group-same-level
562 "\M-p" gnus-group-prev-unread-group-same-level
563 "," gnus-group-best-unread-group
564 "." gnus-group-first-unread-group
565 "u" gnus-group-unsubscribe-current-group
566 "U" gnus-group-unsubscribe-group
567 "c" gnus-group-catchup-current
568 "C" gnus-group-catchup-current-all
569 "\M-c" gnus-group-clear-data
570 "l" gnus-group-list-groups
571 "L" gnus-group-list-all-groups
574 "g" gnus-group-get-new-news
575 "\M-g" gnus-group-get-new-news-this-group
576 "R" gnus-group-restart
577 "r" gnus-group-read-init-file
578 "B" gnus-group-browse-foreign-server
579 "b" gnus-group-check-bogus-groups
580 "F" gnus-group-find-new-groups
581 "\C-c\C-d" gnus-group-describe-group
582 "\M-d" gnus-group-describe-all-groups
583 "\C-c\C-a" gnus-group-apropos
584 "\C-c\M-\C-a" gnus-group-description-apropos
585 "a" gnus-group-post-news
586 "\ek" gnus-group-edit-local-kill
587 "\eK" gnus-group-edit-global-kill
588 "\C-k" gnus-group-kill-group
589 "\C-y" gnus-group-yank-group
590 "\C-w" gnus-group-kill-region
591 "\C-x\C-t" gnus-group-transpose-groups
592 "\C-c\C-l" gnus-group-list-killed
593 "\C-c\C-x" gnus-group-expire-articles
594 "\C-c\M-\C-x" gnus-group-expire-all-groups
596 "s" gnus-group-save-newsrc
597 "z" gnus-group-suspend
600 "?" gnus-group-describe-briefly
601 "\C-c\C-i" gnus-info-find-node
602 "\M-e" gnus-group-edit-group-method
603 "^" gnus-group-enter-server-mode
604 gnus-mouse-2 gnus-mouse-pick-group
605 [follow-link] mouse-face
606 "<" beginning-of-buffer
609 "\C-c\C-s" gnus-group-sort-groups
611 "\C-c\M-g" gnus-activate-all-groups
612 "\M-&" gnus-group-universal-argument
613 "#" gnus-group-mark-group
614 "\M-#" gnus-group-unmark-group)
616 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
617 "m" gnus-group-mark-group
618 "u" gnus-group-unmark-group
619 "w" gnus-group-mark-region
620 "b" gnus-group-mark-buffer
621 "r" gnus-group-mark-regexp
622 "U" gnus-group-unmark-all-groups)
624 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
625 "u" gnus-sieve-update
626 "g" gnus-sieve-generate)
628 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
629 "d" gnus-group-make-directory-group
630 "h" gnus-group-make-help-group
631 "u" gnus-group-make-useful-group
632 "a" gnus-group-make-archive-group
633 "k" gnus-group-make-kiboze-group
634 "l" gnus-group-nnimap-edit-acl
635 "m" gnus-group-make-group
636 "E" gnus-group-edit-group
637 "e" gnus-group-edit-group-method
638 "p" gnus-group-edit-group-parameters
639 "v" gnus-group-add-to-virtual
640 "V" gnus-group-make-empty-virtual
641 "D" gnus-group-enter-directory
642 "f" gnus-group-make-doc-group
643 "w" gnus-group-make-web-group
644 "M" gnus-group-read-ephemeral-group
645 "r" gnus-group-rename-group
646 "R" gnus-group-make-rss-group
647 "c" gnus-group-customize
648 "x" gnus-group-nnimap-expunge
649 "\177" gnus-group-delete-group
650 [delete] gnus-group-delete-group)
652 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
653 "b" gnus-group-brew-soup
654 "w" gnus-soup-save-areas
655 "s" gnus-soup-send-replies
656 "p" gnus-soup-pack-packet
657 "r" nnsoup-pack-replies)
659 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
660 "s" gnus-group-sort-groups
661 "a" gnus-group-sort-groups-by-alphabet
662 "u" gnus-group-sort-groups-by-unread
663 "l" gnus-group-sort-groups-by-level
664 "v" gnus-group-sort-groups-by-score
665 "r" gnus-group-sort-groups-by-rank
666 "m" gnus-group-sort-groups-by-method
667 "n" gnus-group-sort-groups-by-real-name)
669 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
670 "s" gnus-group-sort-selected-groups
671 "a" gnus-group-sort-selected-groups-by-alphabet
672 "u" gnus-group-sort-selected-groups-by-unread
673 "l" gnus-group-sort-selected-groups-by-level
674 "v" gnus-group-sort-selected-groups-by-score
675 "r" gnus-group-sort-selected-groups-by-rank
676 "m" gnus-group-sort-selected-groups-by-method
677 "n" gnus-group-sort-selected-groups-by-real-name)
679 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
680 "k" gnus-group-list-killed
681 "z" gnus-group-list-zombies
682 "s" gnus-group-list-groups
683 "u" gnus-group-list-all-groups
684 "A" gnus-group-list-active
685 "a" gnus-group-apropos
686 "d" gnus-group-description-apropos
687 "m" gnus-group-list-matching
688 "M" gnus-group-list-all-matching
689 "l" gnus-group-list-level
690 "c" gnus-group-list-cached
691 "?" gnus-group-list-dormant)
693 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
694 "k" gnus-group-list-limit
695 "z" gnus-group-list-limit
696 "s" gnus-group-list-limit
697 "u" gnus-group-list-limit
698 "A" gnus-group-list-limit
699 "m" gnus-group-list-limit
700 "M" gnus-group-list-limit
701 "l" gnus-group-list-limit
702 "c" gnus-group-list-limit
703 "?" gnus-group-list-limit)
705 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
706 "k" gnus-group-list-flush
707 "z" gnus-group-list-flush
708 "s" gnus-group-list-flush
709 "u" gnus-group-list-flush
710 "A" gnus-group-list-flush
711 "m" gnus-group-list-flush
712 "M" gnus-group-list-flush
713 "l" gnus-group-list-flush
714 "c" gnus-group-list-flush
715 "?" gnus-group-list-flush)
717 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
718 "k" gnus-group-list-plus
719 "z" gnus-group-list-plus
720 "s" gnus-group-list-plus
721 "u" gnus-group-list-plus
722 "A" gnus-group-list-plus
723 "m" gnus-group-list-plus
724 "M" gnus-group-list-plus
725 "l" gnus-group-list-plus
726 "c" gnus-group-list-plus
727 "?" gnus-group-list-plus)
729 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
730 "f" gnus-score-flush-cache)
732 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
733 "c" gnus-group-fetch-charter
734 "C" gnus-group-fetch-control
735 "d" gnus-group-describe-group
736 "f" gnus-group-fetch-faq
739 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
740 "l" gnus-group-set-current-level
741 "t" gnus-group-unsubscribe-current-group
742 "s" gnus-group-unsubscribe-group
743 "k" gnus-group-kill-group
744 "y" gnus-group-yank-group
745 "w" gnus-group-kill-region
746 "\C-k" gnus-group-kill-level
747 "z" gnus-group-kill-all-zombies)
749 (defun gnus-topic-mode-p ()
750 "Return non-nil in `gnus-topic-mode'."
751 (and (boundp 'gnus-topic-mode)
752 (symbol-value 'gnus-topic-mode)))
754 (defun gnus-group-make-menu-bar ()
755 (gnus-turn-off-edit-menu 'group)
756 (unless (boundp 'gnus-group-reading-menu)
759 gnus-group-reading-menu gnus-group-mode-map ""
761 ["Read" gnus-group-read-group
762 :included (not (gnus-topic-mode-p))
763 :active (gnus-group-group-name)]
764 ["Read " gnus-topic-read-group
765 :included (gnus-topic-mode-p)]
766 ["Select" gnus-group-select-group
767 :included (not (gnus-topic-mode-p))
768 :active (gnus-group-group-name)]
769 ["Select " gnus-topic-select-group
770 :included (gnus-topic-mode-p)]
771 ["See old articles" (gnus-group-select-group 'all)
772 :keys "C-u SPC" :active (gnus-group-group-name)]
773 ["Catch up" gnus-group-catchup-current
774 :included (not (gnus-topic-mode-p))
775 :active (gnus-group-group-name)
776 ,@(if (featurep 'xemacs) nil
777 '(:help "Mark unread articles in the current group as read"))]
778 ["Catch up " gnus-topic-catchup-articles
779 :included (gnus-topic-mode-p)
780 ,@(if (featurep 'xemacs) nil
781 '(:help "Mark unread articles in the current group or topic as read"))]
782 ["Catch up all articles" gnus-group-catchup-current-all
783 (gnus-group-group-name)]
784 ["Check for new articles" gnus-group-get-new-news-this-group
785 :included (not (gnus-topic-mode-p))
786 :active (gnus-group-group-name)
787 ,@(if (featurep 'xemacs) nil
788 '(:help "Check for new messages in current group"))]
789 ["Check for new articles " gnus-topic-get-new-news-this-topic
790 :included (gnus-topic-mode-p)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Check for new messages in current group or topic"))]
793 ["Toggle subscription" gnus-group-unsubscribe-current-group
794 (gnus-group-group-name)]
795 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
796 ,@(if (featurep 'xemacs) nil
797 '(:help "Kill (remove) current group"))]
798 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
799 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
800 ,@(if (featurep 'xemacs) nil
801 '(:help "Display description of the current group"))]
802 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
803 ["Fetch charter" gnus-group-fetch-charter
804 :active (gnus-group-group-name)
805 ,@(if (featurep 'xemacs) nil
806 '(:help "Display the charter of the current group"))]
807 ["Fetch control message" gnus-group-fetch-control
808 :active (gnus-group-group-name)
809 ,@(if (featurep 'xemacs) nil
810 '(:help "Display the archived control message for the current group"))]
811 ;; Actually one should check, if any of the marked groups gives t for
812 ;; (gnus-check-backend-function 'request-expire-articles ...)
813 ["Expire articles" gnus-group-expire-articles
814 :included (not (gnus-topic-mode-p))
815 :active (or (and (gnus-group-group-name)
816 (gnus-check-backend-function
817 'request-expire-articles
818 (gnus-group-group-name))) gnus-group-marked)]
819 ["Expire articles " gnus-topic-expire-articles
820 :included (gnus-topic-mode-p)]
821 ["Set group level..." gnus-group-set-current-level
822 (gnus-group-group-name)]
823 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
824 ["Customize" gnus-group-customize (gnus-group-group-name)]
826 ["Parameters" gnus-group-edit-group-parameters
827 :included (not (gnus-topic-mode-p))
828 :active (gnus-group-group-name)]
829 ["Parameters " gnus-topic-edit-parameters
830 :included (gnus-topic-mode-p)]
831 ["Select method" gnus-group-edit-group-method
832 (gnus-group-group-name)]
833 ["Info" gnus-group-edit-group (gnus-group-group-name)]
834 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
835 ["Global kill file" gnus-group-edit-global-kill t])))
838 gnus-group-group-menu gnus-group-mode-map ""
841 ["List unread subscribed groups" gnus-group-list-groups t]
842 ["List (un)subscribed groups" gnus-group-list-all-groups t]
843 ["List killed groups" gnus-group-list-killed gnus-killed-list]
844 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
845 ["List level..." gnus-group-list-level t]
846 ["Describe all groups" gnus-group-describe-all-groups t]
847 ["Group apropos..." gnus-group-apropos t]
848 ["Group and description apropos..." gnus-group-description-apropos t]
849 ["List groups matching..." gnus-group-list-matching t]
850 ["List all groups matching..." gnus-group-list-all-matching t]
851 ["List active file" gnus-group-list-active t]
852 ["List groups with cached" gnus-group-list-cached t]
853 ["List groups with dormant" gnus-group-list-dormant t])
855 ["Default sort" gnus-group-sort-groups t]
856 ["Sort by method" gnus-group-sort-groups-by-method t]
857 ["Sort by rank" gnus-group-sort-groups-by-rank t]
858 ["Sort by score" gnus-group-sort-groups-by-score t]
859 ["Sort by level" gnus-group-sort-groups-by-level t]
860 ["Sort by unread" gnus-group-sort-groups-by-unread t]
861 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
862 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
863 ("Sort process/prefixed"
864 ["Default sort" gnus-group-sort-selected-groups
865 (not (gnus-topic-mode-p))]
866 ["Sort by method" gnus-group-sort-selected-groups-by-method
867 (not (gnus-topic-mode-p))]
868 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
869 (not (gnus-topic-mode-p))]
870 ["Sort by score" gnus-group-sort-selected-groups-by-score
871 (not (gnus-topic-mode-p))]
872 ["Sort by level" gnus-group-sort-selected-groups-by-level
873 (not (gnus-topic-mode-p))]
874 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
875 (not (gnus-topic-mode-p))]
876 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
877 (not (gnus-topic-mode-p))]
878 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
879 (not (gnus-topic-mode-p))])
881 ["Mark group" gnus-group-mark-group
882 (and (gnus-group-group-name)
883 (not (memq (gnus-group-group-name) gnus-group-marked)))]
884 ["Unmark group" gnus-group-unmark-group
885 (and (gnus-group-group-name)
886 (memq (gnus-group-group-name) gnus-group-marked))]
887 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
888 ["Mark regexp..." gnus-group-mark-regexp t]
889 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
890 ["Mark buffer" gnus-group-mark-buffer t]
891 ["Execute command" gnus-group-universal-argument
892 (or gnus-group-marked (gnus-group-group-name))])
894 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
895 ["Kill all newsgroups in region" gnus-group-kill-region
896 :active (gnus-mark-active-p)]
897 ["Kill all zombie groups" gnus-group-kill-all-zombies
899 ["Kill all groups on level..." gnus-group-kill-level t])
901 ["Make a foreign group..." gnus-group-make-group t]
902 ["Add a directory group..." gnus-group-make-directory-group t]
903 ["Add the help group" gnus-group-make-help-group t]
904 ["Add the archive group" gnus-group-make-archive-group t]
905 ["Make a doc group..." gnus-group-make-doc-group t]
906 ["Make a web group..." gnus-group-make-web-group t]
907 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
908 ["Make a virtual group..." gnus-group-make-empty-virtual t]
909 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
910 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
911 ["Make an RSS group..." gnus-group-make-rss-group t]
912 ["Rename group..." gnus-group-rename-group
913 (gnus-check-backend-function
914 'request-rename-group (gnus-group-group-name))]
915 ["Delete group" gnus-group-delete-group
916 (gnus-check-backend-function
917 'request-delete-group (gnus-group-group-name))])
919 ["Next" gnus-group-next-group t]
920 ["Previous" gnus-group-prev-group t]
921 ["Next unread" gnus-group-next-unread-group t]
922 ["Previous unread" gnus-group-prev-unread-group t]
923 ["Next unread same level" gnus-group-next-unread-group-same-level t]
924 ["Previous unread same level"
925 gnus-group-prev-unread-group-same-level t]
926 ["Jump to group..." gnus-group-jump-to-group t]
927 ["First unread group" gnus-group-first-unread-group t]
928 ["Best unread group" gnus-group-best-unread-group t])
930 ["Generate" gnus-sieve-generate t]
931 ["Generate and update" gnus-sieve-update t])
932 ["Delete bogus groups" gnus-group-check-bogus-groups t]
933 ["Find new newsgroups" gnus-group-find-new-groups t]
934 ["Transpose" gnus-group-transpose-groups
935 (gnus-group-group-name)]
936 ["Read a directory as a group..." gnus-group-enter-directory t]))
939 gnus-group-misc-menu gnus-group-mode-map ""
942 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
943 ["Send replies" gnus-soup-send-replies
944 (fboundp 'gnus-soup-pack-packet)]
945 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
946 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
947 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
948 ["Send a mail" gnus-group-mail t]
949 ["Send a message (mail or news)" gnus-group-post-news t]
950 ["Create a local message" gnus-group-news t]
951 ["Check for new news" gnus-group-get-new-news
952 ,@(if (featurep 'xemacs) '(t)
953 '(:help "Get newly arrived articles"))
955 ["Send queued messages" gnus-delay-send-queue
956 ,@(if (featurep 'xemacs) '(t)
957 '(:help "Send all messages that are scheduled to be sent now"))
959 ["Activate all groups" gnus-activate-all-groups t]
960 ["Restart Gnus" gnus-group-restart t]
961 ["Read init file" gnus-group-read-init-file t]
962 ["Browse foreign server..." gnus-group-browse-foreign-server t]
963 ["Enter server buffer" gnus-group-enter-server-mode t]
964 ["Expire all expirable articles" gnus-group-expire-all-groups t]
965 ["Generate any kiboze groups" nnkiboze-generate-groups t]
966 ["Gnus version" gnus-version t]
967 ["Save .newsrc files" gnus-group-save-newsrc t]
968 ["Suspend Gnus" gnus-group-suspend t]
969 ["Clear dribble buffer" gnus-group-clear-dribble t]
970 ["Read manual" gnus-info-find-node t]
971 ["Flush score cache" gnus-score-flush-cache t]
972 ["Toggle topics" gnus-topic-mode t]
973 ["Send a bug report" gnus-bug t]
974 ["Exit from Gnus" gnus-group-exit
975 ,@(if (featurep 'xemacs) '(t)
976 '(:help "Quit reading news"))]
977 ["Exit without saving" gnus-group-quit t]))
979 (gnus-run-hooks 'gnus-group-menu-hook)))
981 (defvar gnus-group-toolbar-map nil)
983 ;; Emacs 21 tool bar. Should be no-op otherwise.
984 (defun gnus-group-make-tool-bar ()
986 (condition-case nil (require 'tool-bar) (error nil))
987 (fboundp 'tool-bar-add-item-from-menu)
988 (default-value 'tool-bar-mode)
989 (not gnus-group-toolbar-map))
990 (setq gnus-group-toolbar-map
991 (let ((tool-bar-map (make-sparse-keymap))
992 (load-path (mm-image-load-path)))
993 (tool-bar-add-item-from-menu
994 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
995 (tool-bar-add-item-from-menu
996 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
997 (tool-bar-add-item-from-menu
998 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
999 (tool-bar-add-item-from-menu
1000 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1001 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1002 :help "Subscribe to the current group")
1003 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1005 :help "Unsubscribe from the current group")
1006 (tool-bar-add-item-from-menu
1007 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1009 (if gnus-group-toolbar-map
1010 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1012 (defun gnus-group-mode ()
1013 "Major mode for reading news.
1015 All normal editing commands are switched off.
1016 \\<gnus-group-mode-map>
1017 The group buffer lists (some of) the groups available. For instance,
1018 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1019 lists all zombie groups.
1021 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1022 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1024 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1026 The following commands are available:
1028 \\{gnus-group-mode-map}"
1030 (kill-all-local-variables)
1031 (when (gnus-visual-p 'group-menu 'menu)
1032 (gnus-group-make-menu-bar)
1033 (gnus-group-make-tool-bar))
1034 (gnus-simplify-mode-line)
1035 (setq major-mode 'gnus-group-mode)
1036 (setq mode-name "Group")
1037 (gnus-group-set-mode-line)
1038 (setq mode-line-process nil)
1039 (use-local-map gnus-group-mode-map)
1040 (buffer-disable-undo)
1041 (setq truncate-lines t)
1042 (setq buffer-read-only t)
1043 (gnus-set-default-directory)
1044 (gnus-update-format-specifications nil 'group 'group-mode)
1045 (gnus-update-group-mark-positions)
1050 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1052 (defun gnus-update-group-mark-positions ()
1054 (let ((gnus-process-mark ?\200)
1055 (gnus-group-update-hook nil)
1056 (gnus-group-marked '("dummy.group"))
1057 (gnus-active-hashtb (make-vector 10 0))
1059 (gnus-set-active "dummy.group" '(0 . 0))
1060 (gnus-set-work-buffer)
1061 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1062 (goto-char (point-min))
1063 (setq gnus-group-mark-positions
1064 (list (cons 'process (and (search-forward
1065 (mm-string-as-multibyte "\200") nil t)
1066 (- (point) 2))))))))
1068 (defun gnus-mouse-pick-group (e)
1069 "Enter the group under the mouse pointer."
1072 (gnus-group-read-group nil))
1074 ;; Look at LEVEL and find out what the level is really supposed to be.
1075 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1076 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1077 (defun gnus-group-default-level (&optional level number-or-nil)
1079 (gnus-group-use-permanent-levels
1080 (or (setq gnus-group-use-permanent-levels
1081 (or level (if (numberp gnus-group-use-permanent-levels)
1082 gnus-group-use-permanent-levels
1083 (or gnus-group-default-list-level
1084 gnus-level-subscribed))))
1085 gnus-group-default-list-level gnus-level-subscribed))
1089 (or level gnus-group-default-list-level gnus-level-subscribed))))
1091 (defun gnus-group-setup-buffer ()
1092 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1093 (unless (eq major-mode 'gnus-group-mode)
1096 (gnus-carpal-setup-buffer 'group))))
1098 (defun gnus-group-name-charset (method group)
1100 (setq method (gnus-find-method-for-group group)))
1101 (let ((item (assoc method gnus-group-name-charset-method-alist))
1102 (alist gnus-group-name-charset-group-alist)
1106 (while (setq item (pop alist))
1107 (if (string-match (car item) group)
1109 result (cdr item))))
1112 (defun gnus-group-name-decode (string charset)
1113 ;; Fixme: Don't decode in unibyte mode.
1114 (if (and string charset (featurep 'mule))
1115 (mm-decode-coding-string string charset)
1118 (defun gnus-group-decoded-name (string)
1119 (let ((charset (gnus-group-name-charset nil string)))
1120 (gnus-group-name-decode string charset)))
1122 (defun gnus-group-list-groups (&optional level unread lowest)
1123 "List newsgroups with level LEVEL or lower that have unread articles.
1124 Default is all subscribed groups.
1125 If argument UNREAD is non-nil, groups with no unread articles are also
1128 Also see the `gnus-group-use-permanent-levels' variable."
1130 (list (if current-prefix-arg
1131 (prefix-numeric-value current-prefix-arg)
1133 (gnus-group-default-level nil t)
1134 gnus-group-default-list-level
1135 gnus-level-subscribed))))
1137 (setq level (car gnus-group-list-mode)
1138 unread (cdr gnus-group-list-mode)))
1139 (setq level (gnus-group-default-level level))
1140 (gnus-group-setup-buffer)
1141 (gnus-update-format-specifications nil 'group 'group-mode)
1142 (let ((case-fold-search nil)
1143 (props (text-properties-at (gnus-point-at-bol)))
1144 (empty (= (point-min) (point-max)))
1145 (group (gnus-group-group-name))
1147 (set-buffer gnus-group-buffer)
1148 (setq number (funcall gnus-group-prepare-function level unread lowest))
1149 (when (or (and (numberp number)
1151 (zerop (buffer-size)))
1152 ;; No groups in the buffer.
1153 (gnus-message 5 gnus-no-groups-message))
1154 ;; We have some groups displayed.
1155 (goto-char (point-max))
1156 (when (or (not gnus-group-goto-next-group-function)
1157 (not (funcall gnus-group-goto-next-group-function
1161 (goto-char (point-min)))
1163 ;; Go to the first group with unread articles.
1164 (gnus-group-search-forward t))
1166 ;; Find the right group to put point on. If the current group
1167 ;; has disappeared in the new listing, try to find the next
1168 ;; one. If no next one can be found, just leave point at the
1169 ;; first newsgroup in the buffer.
1170 (when (not (gnus-goto-char
1172 (point-min) (point-max)
1173 'gnus-group (gnus-intern-safe
1174 group gnus-active-hashtb))))
1175 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1177 (not (gnus-goto-char
1179 (point-min) (point-max) 'gnus-group
1181 (caar newsrc) gnus-active-hashtb)))))
1182 (setq newsrc (cdr newsrc)))
1184 (goto-char (point-max))
1185 (forward-line -1)))))))
1186 ;; Adjust cursor point.
1187 (gnus-group-position-point)))
1189 (defun gnus-group-list-level (level &optional all)
1190 "List groups on LEVEL.
1191 If ALL (the prefix), also list groups that have no unread articles."
1192 (interactive "nList groups on level: \nP")
1193 (gnus-group-list-groups level all level))
1195 (defun gnus-group-prepare-logic (group test)
1196 (or (and gnus-group-listed-groups
1197 (null gnus-group-list-option)
1198 (member group gnus-group-listed-groups))
1200 ((null gnus-group-listed-groups) test)
1201 ((null gnus-group-list-option) test)
1202 (t (and (member group gnus-group-listed-groups)
1203 (if (eq gnus-group-list-option 'flush)
1207 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1208 "List all newsgroups with unread articles of level LEVEL or lower.
1209 If PREDICATE is a function, list groups that the function returns non-nil;
1210 if it is t, list groups that have no unread articles.
1211 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1212 If REGEXP is a function, list dead groups that the function returns non-nil;
1213 if it is a string, only list groups matching REGEXP."
1214 (set-buffer gnus-group-buffer)
1215 (let ((buffer-read-only nil)
1216 (newsrc (cdr gnus-newsrc-alist))
1217 (lowest (or lowest 1))
1218 (not-in-list (and gnus-group-listed-groups
1219 (copy-sequence gnus-group-listed-groups)))
1220 info clevel unread group params)
1222 (when (or (< lowest gnus-level-zombie)
1223 gnus-group-listed-groups)
1224 ;; List living groups.
1226 (setq info (car newsrc)
1227 group (gnus-info-group info)
1228 params (gnus-info-params info)
1230 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1232 (setq not-in-list (delete group not-in-list)))
1233 (when (gnus-group-prepare-logic
1235 (and unread ; This group might be unchecked
1236 (or (not (stringp regexp))
1237 (string-match regexp group))
1238 (<= (setq clevel (gnus-info-level info)) level)
1241 ((functionp predicate)
1242 (funcall predicate info))
1243 (predicate t) ; We list all groups?
1246 (if (eq unread t) ; Unactivated?
1247 gnus-group-list-inactive-groups
1248 ; We list unactivated
1250 ; We list groups with unread articles
1251 (and gnus-list-groups-with-ticked-articles
1252 (cdr (assq 'tick (gnus-info-marks info))))
1253 ; And groups with tickeds
1254 ;; Check for permanent visibility.
1255 (and gnus-permanently-visible-groups
1256 (string-match gnus-permanently-visible-groups
1258 (memq 'visible params)
1259 (cdr (assq 'visible params)))))))
1260 (gnus-group-insert-group-line
1261 group (gnus-info-level info)
1262 (gnus-info-marks info) unread (gnus-info-method info)))))
1264 ;; List dead groups.
1265 (when (or gnus-group-listed-groups
1266 (and (>= level gnus-level-zombie)
1267 (<= lowest gnus-level-zombie)))
1268 (gnus-group-prepare-flat-list-dead
1269 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1270 gnus-level-zombie ?Z
1273 (dolist (group gnus-zombie-list)
1274 (setq not-in-list (delete group not-in-list))))
1275 (when (or gnus-group-listed-groups
1276 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1277 (gnus-group-prepare-flat-list-dead
1280 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1281 gnus-level-killed ?K regexp))
1283 (gnus-group-set-mode-line)
1284 (setq gnus-group-list-mode (cons level predicate))
1285 (gnus-run-hooks 'gnus-group-prepare-hook)
1288 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1289 ;; List zombies and killed lists somewhat faster, which was
1290 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1291 ;; this by ignoring the group format specification altogether.
1293 (if (> (length groups) gnus-group-listing-limit)
1295 (setq group (pop groups))
1296 (when (gnus-group-prepare-logic
1299 (and (stringp regexp) (string-match regexp group))
1300 (and (functionp regexp) (funcall regexp group))))
1301 (gnus-add-text-properties
1302 (point) (prog1 (1+ (point))
1303 (insert " " mark " *: "
1304 (gnus-group-decoded-name group)
1306 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1308 'gnus-level level))))
1310 (setq group (pop groups))
1311 (when (gnus-group-prepare-logic
1314 (and (stringp regexp) (string-match regexp group))
1315 (and (functionp regexp) (funcall regexp group))))
1316 (gnus-group-insert-group-line
1318 (let ((active (gnus-active group)))
1320 (if (zerop (cdr active))
1322 (- (1+ (cdr active)) (car active)))
1324 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1326 (defun gnus-group-update-group-line ()
1327 "Update the current line in the group buffer."
1328 (let* ((buffer-read-only nil)
1329 (group (gnus-group-group-name))
1330 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1331 gnus-group-indentation)
1334 (not (gnus-ephemeral-group-p group))
1336 (concat "(gnus-group-set-info '"
1337 (gnus-prin1-to-string (nth 2 entry))
1339 (setq gnus-group-indentation (gnus-group-group-indentation))
1341 (gnus-group-insert-group-line-info group)
1343 (gnus-group-position-point))))
1345 (defun gnus-group-insert-group-line-info (group)
1346 "Insert GROUP on the current line."
1347 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1348 (gnus-group-indentation (gnus-group-group-indentation))
1352 ;; (Un)subscribed group.
1353 (setq info (nth 2 entry))
1354 (gnus-group-insert-group-line
1355 group (gnus-info-level info) (gnus-info-marks info)
1356 (or (car entry) t) (gnus-info-method info)))
1357 ;; This group is dead.
1358 (gnus-group-insert-group-line
1360 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1362 (if (setq active (gnus-active group))
1363 (if (zerop (cdr active))
1365 (- (1+ (cdr active)) (car active)))
1367 (gnus-method-simplify (gnus-find-method-for-group group))))))
1369 (defun gnus-number-of-unseen-articles-in-group (group)
1370 (let* ((info (nth 2 (gnus-group-entry group)))
1371 (marked (gnus-info-marks info))
1372 (seen (cdr (assq 'seen marked)))
1373 (active (gnus-active group)))
1376 (length (gnus-uncompress-range
1377 (gnus-range-difference
1378 (gnus-range-difference (list active) (gnus-info-read info))
1381 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1382 gnus-tmp-marked number
1384 "Insert a group line in the group buffer."
1385 (let* ((gnus-tmp-method
1386 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1387 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1389 (gnus-tmp-active (gnus-active gnus-tmp-group))
1390 (gnus-tmp-number-total
1392 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1394 (gnus-tmp-number-of-unread
1395 (if (numberp number) (int-to-string (max 0 number))
1397 (gnus-tmp-number-of-read
1398 (if (numberp number)
1399 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1401 (gnus-tmp-subscribed
1402 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1403 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1404 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1406 (gnus-tmp-qualified-group
1407 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1408 group-name-charset))
1410 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1412 (gnus-tmp-newsgroup-description
1413 (if gnus-description-hashtb
1414 (or (gnus-group-name-decode
1415 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1416 group-name-charset) "")
1419 (if (and gnus-moderated-hashtb
1420 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1422 (gnus-tmp-moderated-string
1423 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1424 (gnus-tmp-group-icon "==&&==")
1425 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1426 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1427 (gnus-tmp-news-method-string
1429 (format "(%s:%s)" (car gnus-tmp-method)
1430 (cadr gnus-tmp-method)) ""))
1431 (gnus-tmp-marked-mark
1432 (if (and (numberp number)
1434 (cdr (assq 'tick gnus-tmp-marked)))
1436 (gnus-tmp-summary-live
1437 (if (and (not gnus-group-is-exiting-p)
1438 (gnus-buffer-live-p (gnus-summary-buffer-name
1441 (gnus-tmp-process-marked
1442 (if (member gnus-tmp-group gnus-group-marked)
1443 gnus-process-mark ? ))
1445 (or (and gnus-use-grouplens
1446 (bbb-grouplens-group-p gnus-tmp-group))
1448 (buffer-read-only nil)
1449 header gnus-tmp-header) ; passed as parameter to user-funcs.
1451 (gnus-add-text-properties
1455 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1456 gnus-tmp-group group-name-charset)))
1457 (eval gnus-group-line-format-spec)))
1458 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1459 gnus-unread ,(if (numberp number)
1460 (string-to-number gnus-tmp-number-of-unread)
1462 gnus-marked ,gnus-tmp-marked-mark
1463 gnus-indentation ,gnus-group-indentation
1464 gnus-level ,gnus-tmp-level))
1466 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1467 (gnus-run-hooks 'gnus-group-update-hook))
1469 ;; Allow XEmacs to remove front-sticky text properties.
1470 (gnus-group-remove-excess-properties)))
1472 (defun gnus-group-highlight-line ()
1473 "Highlight the current line according to `gnus-group-highlight'."
1474 (let* ((list gnus-group-highlight)
1476 (end (gnus-point-at-eol))
1477 ;; now find out where the line starts and leave point there.
1478 (beg (progn (beginning-of-line) (point)))
1479 (group (gnus-group-group-name))
1480 (entry (gnus-group-entry group))
1481 (unread (if (numberp (car entry)) (car entry) 0))
1482 (active (gnus-active group))
1483 (total (if active (1+ (- (cdr active) (car active))) 0))
1484 (info (nth 2 entry))
1485 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1486 (marked (gnus-info-marks info))
1487 (mailp (apply 'append
1490 (memq x (assoc (symbol-name
1491 (car (or method gnus-select-method)))
1492 gnus-valid-select-methods)))
1493 '(mail post-mail))))
1494 (level (or (gnus-info-level info) gnus-level-killed))
1495 (score (or (gnus-info-score info) 0))
1496 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1497 (group-age (gnus-group-timestamp-delta group))
1498 (inhibit-read-only t))
1499 ;; Eval the cars of the lists until we find a match.
1501 (not (eval (caar list))))
1502 (setq list (cdr list)))
1503 (let ((face (cdar list)))
1504 (unless (eq face (get-text-property beg 'face))
1505 (gnus-put-text-property-excluding-characters-with-faces
1507 (setq face (if (boundp face) (symbol-value face) face)))
1508 (gnus-extent-start-open beg)))
1511 (defun gnus-group-update-group (group &optional visible-only)
1512 "Update all lines where GROUP appear.
1513 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1515 ;; Can't use `save-excursion' here, so we do it manually.
1516 (let ((buf (current-buffer))
1518 (set-buffer gnus-group-buffer)
1519 (setq mark (point-marker))
1520 ;; The buffer may be narrowed.
1523 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1525 found buffer-read-only)
1526 ;; Enter the current status into the dribble buffer.
1527 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1529 (not (gnus-ephemeral-group-p group)))
1531 (concat "(gnus-group-set-info '"
1532 (gnus-prin1-to-string (nth 2 entry))
1534 ;; Find all group instances. If topics are in use, each group
1535 ;; may be listed in more than once.
1536 (while (setq loc (text-property-any
1537 loc (point-max) 'gnus-group ident))
1540 (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 (setq loc (1+ loc)))
1547 (unless (or found visible-only)
1548 ;; No such line in the buffer, find out where it's supposed to
1549 ;; go, and insert it there (or at the end of the buffer).
1550 (if gnus-goto-missing-group-function
1551 (funcall gnus-goto-missing-group-function group)
1552 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1553 (while (and entry (car entry)
1557 (point-min) (point-max)
1558 'gnus-group (gnus-intern-safe
1559 (caar entry) gnus-active-hashtb)))))
1560 (setq entry (cdr entry)))
1561 (or entry (goto-char (point-max)))))
1562 ;; Finally insert the line.
1563 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1564 (gnus-group-insert-group-line-info group)
1567 (gnus-run-hooks 'gnus-group-update-group-hook))))
1568 (when gnus-group-update-group-function
1569 (funcall gnus-group-update-group-function group))
1570 (gnus-group-set-mode-line)))
1572 (set-marker mark nil)
1575 (defun gnus-group-set-mode-line ()
1576 "Update the mode line in the group buffer."
1577 (when (memq 'group gnus-updated-mode-lines)
1578 ;; Yes, we want to keep this mode line updated.
1580 (set-buffer gnus-group-buffer)
1581 (let* ((gformat (or gnus-group-mode-line-format-spec
1582 (gnus-set-format 'group-mode)))
1583 (gnus-tmp-news-server (cadr gnus-select-method))
1584 (gnus-tmp-news-method (car gnus-select-method))
1585 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1587 gnus-tmp-header ;Dummy binding for user-defined formats
1588 ;; Get the resulting string.
1590 (and gnus-dribble-buffer
1591 (buffer-name gnus-dribble-buffer)
1592 (buffer-modified-p gnus-dribble-buffer)
1594 (set-buffer gnus-dribble-buffer)
1595 (not (zerop (buffer-size))))))
1596 (mode-string (eval gformat)))
1597 ;; Say whether the dribble buffer has been modified.
1598 (setq mode-line-modified
1599 (if modified (car gnus-mode-line-modified)
1600 (cdr gnus-mode-line-modified)))
1601 ;; If the line is too long, we chop it off.
1602 (when (> (length mode-string) max-len)
1603 (setq mode-string (substring mode-string 0 (- max-len 4))))
1605 (setq mode-line-buffer-identification
1606 (gnus-mode-line-buffer-identification
1607 (list mode-string)))
1608 (set-buffer-modified-p modified))))))
1610 (defun gnus-group-group-name ()
1611 "Get the name of the newsgroup on the current line."
1612 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1614 (symbol-name group))))
1616 (defun gnus-group-group-level ()
1617 "Get the level of the newsgroup on the current line."
1618 (get-text-property (gnus-point-at-bol) 'gnus-level))
1620 (defun gnus-group-group-indentation ()
1621 "Get the indentation of the newsgroup on the current line."
1622 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1623 (and gnus-group-indentation-function
1624 (funcall gnus-group-indentation-function))
1627 (defun gnus-group-group-unread ()
1628 "Get the number of unread articles of the newsgroup on the current line."
1629 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1631 (defun gnus-group-new-mail (group)
1632 (if (nnmail-new-mail-p (gnus-group-real-name group))
1636 (defun gnus-group-level (group)
1637 "Return the estimated level of GROUP."
1638 (or (gnus-info-level (gnus-get-info group))
1639 (and (member group gnus-zombie-list) gnus-level-zombie)
1642 (defun gnus-group-search-forward (&optional backward all level first-too)
1643 "Find the next newsgroup with unread articles.
1644 If BACKWARD is non-nil, find the previous newsgroup instead.
1645 If ALL is non-nil, just find any newsgroup.
1646 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1648 If FIRST-TOO, the current line is also eligible as a target."
1649 (let ((way (if backward -1 1))
1650 (low gnus-level-killed)
1653 (if (and backward (progn (beginning-of-line)) (bobp))
1662 (get-text-property (point) 'gnus-group)
1666 (get-text-property (point) 'gnus-unread)))
1667 (and (numberp unread) (> unread 0)))
1668 (setq lev (get-text-property (point)
1670 (<= lev gnus-level-subscribed)))
1672 (and (setq lev (get-text-property (point)
1681 (zerop (forward-line way)))))
1683 (progn (gnus-group-position-point) t)
1684 (goto-char (or pos beg))
1687 ;;; Gnus group mode commands
1691 (defun gnus-group-mark-line-p ()
1694 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1695 (eq (char-after) gnus-process-mark)))
1697 (defun gnus-group-mark-group (n &optional unmark no-advance)
1698 "Mark the current group."
1700 (let ((buffer-read-only nil)
1704 (when (setq group (gnus-group-group-name))
1705 ;; Go to the mark position.
1707 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1708 (subst-char-in-region
1709 (point) (1+ (point)) (char-after)
1712 (setq gnus-group-marked (delete group gnus-group-marked))
1714 (setq gnus-group-marked
1715 (cons group (delete group gnus-group-marked)))
1716 gnus-process-mark)))
1718 (gnus-group-next-group 1))
1720 (gnus-summary-position-point)
1723 (defun gnus-group-unmark-group (n)
1724 "Remove the mark from the current group."
1726 (gnus-group-mark-group n 'unmark)
1727 (gnus-group-position-point))
1729 (defun gnus-group-unmark-all-groups ()
1730 "Unmark all groups."
1732 (let ((groups gnus-group-marked))
1735 (gnus-group-remove-mark (pop groups)))))
1736 (gnus-group-position-point))
1738 (defun gnus-group-mark-region (unmark beg end)
1739 "Mark all groups between point and mark.
1740 If UNMARK, remove the mark instead."
1741 (interactive "P\nr")
1742 (let ((num (count-lines beg end)))
1745 (- num (gnus-group-mark-group num unmark)))))
1747 (defun gnus-group-mark-buffer (&optional unmark)
1748 "Mark all groups in the buffer.
1749 If UNMARK, remove the mark instead."
1751 (gnus-group-mark-region unmark (point-min) (point-max)))
1753 (defun gnus-group-mark-regexp (regexp)
1754 "Mark all groups that match some regexp."
1755 (interactive "sMark (regexp): ")
1756 (let ((alist (cdr gnus-newsrc-alist))
1760 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1761 (gnus-group-jump-to-group group)
1762 (gnus-group-set-mark group)))))
1763 (gnus-group-position-point))
1765 (defun gnus-group-remove-mark (group &optional test-marked)
1766 "Remove the process mark from GROUP and move point there.
1767 Return nil if the group isn't displayed."
1768 (if (gnus-group-goto-group group nil test-marked)
1770 (gnus-group-mark-group 1 'unmark t)
1772 (setq gnus-group-marked
1773 (delete group gnus-group-marked))
1776 (defun gnus-group-set-mark (group)
1777 "Set the process mark on GROUP."
1778 (if (gnus-group-goto-group group)
1780 (gnus-group-mark-group 1 nil t))
1781 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1783 (defun gnus-group-universal-argument (arg &optional groups func)
1784 "Perform any command on all groups according to the process/prefix convention."
1786 (if (eq (setq func (or func
1789 (substitute-command-keys
1790 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1792 (gnus-error 1 "Undefined key")
1793 (gnus-group-iterate arg
1795 (command-execute func))))
1796 (gnus-group-position-point))
1798 (defun gnus-group-process-prefix (n)
1799 "Return a list of groups to work on.
1800 Take into consideration N (the prefix) and the list of marked groups."
1803 (setq n (prefix-numeric-value n))
1804 ;; There is a prefix, so we return a list of the N next
1806 (let ((way (if (< n 0) -1 1))
1811 (if (setq group (gnus-group-group-name))
1812 (push group groups))
1814 (gnus-group-next-group way)))
1816 ((and (gnus-region-active-p) (mark))
1817 ;; Work on the region between point and mark.
1818 (let ((max (max (point) (mark)))
1821 (goto-char (min (point) (mark)))
1824 (push (gnus-group-group-name) groups)
1825 (zerop (gnus-group-next-group 1))
1827 (nreverse groups))))
1829 ;; No prefix, but a list of marked articles.
1830 (reverse gnus-group-marked))
1832 ;; Neither marked articles or a prefix, so we return the
1834 (let ((group (gnus-group-group-name)))
1835 (and group (list group))))))
1837 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1838 ;;; imagine why I went through these contortions...
1840 (let ((function (make-symbol "gnus-group-iterate-function"))
1841 (window (make-symbol "gnus-group-iterate-window"))
1842 (groups (make-symbol "gnus-group-iterate-groups"))
1843 (group (make-symbol "gnus-group-iterate-group")))
1845 `(defun gnus-group-iterate (arg ,function)
1846 "Iterate FUNCTION over all process/prefixed groups.
1847 FUNCTION will be called with the group name as the parameter
1848 and with point over the group in question."
1849 (let ((,groups (gnus-group-process-prefix arg))
1850 (,window (selected-window))
1853 (setq ,group (car ,groups)
1854 ,groups (cdr ,groups))
1855 (select-window ,window)
1856 (gnus-group-remove-mark ,group)
1857 (save-selected-window
1859 (funcall ,function ,group)))))))))
1861 (put 'gnus-group-iterate 'lisp-indent-function 1)
1863 ;; Selecting groups.
1865 (defun gnus-group-read-group (&optional all no-article group select-articles)
1866 "Read news in this newsgroup.
1867 If the prefix argument ALL is non-nil, already read articles become
1868 readable. IF ALL is a number, fetch this number of articles. If the
1869 optional argument NO-ARTICLE is non-nil, no article will be
1870 auto-selected upon group entry. If GROUP is non-nil, fetch that
1873 (let ((no-display (eq all 0))
1874 (group (or group (gnus-group-group-name)))
1875 number active marked entry)
1879 (error "No group on current line"))
1880 (setq marked (gnus-info-marks
1881 (nth 2 (setq entry (gnus-gethash
1882 group gnus-newsrc-hashtb)))))
1883 ;; This group might be a dead group. In that case we have to get
1884 ;; the number of unread articles from `gnus-active-hashtb'.
1886 (cond ((numberp all) all)
1888 ((setq active (gnus-active group))
1889 (- (1+ (cdr active)) (car active)))))
1890 (gnus-summary-read-group
1891 group (or all (and (numberp number)
1892 (zerop (+ number (gnus-range-length
1893 (cdr (assq 'tick marked)))
1895 (cdr (assq 'dormant marked)))))))
1896 no-article nil no-display nil select-articles)))
1898 (defun gnus-group-select-group (&optional all)
1899 "Select this newsgroup.
1900 No article is selected automatically.
1901 If the group is opened, just switch the summary buffer.
1902 If ALL is non-nil, already read articles become readable.
1903 If ALL is a number, fetch this number of articles."
1905 (when (and (eobp) (not (gnus-group-group-name)))
1907 (gnus-group-read-group all t))
1909 (defun gnus-group-quick-select-group (&optional all)
1910 "Select the current group \"quickly\".
1911 This means that no highlighting or scoring will be performed.
1912 If ALL (the prefix argument) is 0, don't even generate the summary
1915 This might be useful if you want to toggle threading
1916 before entering the group."
1918 (require 'gnus-score)
1920 gnus-score-find-score-files-function
1921 gnus-home-score-file
1922 gnus-apply-kill-hook
1923 gnus-summary-expunge-below)
1924 (gnus-group-read-group all t)))
1926 (defun gnus-group-visible-select-group (&optional all)
1927 "Select the current group without hiding any articles."
1929 (let ((gnus-inhibit-limiting t))
1930 (gnus-group-read-group all t)))
1932 (defun gnus-group-select-group-ephemerally ()
1933 "Select the current group without doing any processing whatsoever.
1934 You will actually be entered into a group that's a copy of
1935 the current group; no changes you make while in this group will
1938 (require 'gnus-score)
1940 gnus-score-find-score-files-function gnus-apply-kill-hook
1941 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1942 gnus-summary-mode-hook gnus-select-group-hook
1943 (group (gnus-group-group-name))
1944 (method (gnus-find-method-for-group group)))
1945 (gnus-group-read-ephemeral-group
1946 (gnus-group-prefixed-name group method) method)))
1949 (defun gnus-fetch-group (group &optional articles)
1950 "Start Gnus if necessary and enter GROUP.
1951 Returns whether the fetching was successful or not."
1952 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1953 (unless (get-buffer gnus-group-buffer)
1955 (gnus-group-read-group articles nil group))
1958 (defun gnus-fetch-group-other-frame (group)
1959 "Pop up a frame and enter GROUP."
1961 (let ((window (get-buffer-window gnus-group-buffer)))
1963 (select-frame (window-frame window)))
1964 ((= (length (frame-list)) 1)
1965 (select-frame (make-frame)))
1968 (gnus-fetch-group group))
1970 (defvar gnus-ephemeral-group-server 0)
1972 (defcustom gnus-large-ephemeral-newsgroup 200
1973 "The number of articles which indicates a large ephemeral newsgroup.
1974 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1976 If the number of articles in a newsgroup is greater than this value,
1977 confirmation is required for selecting the newsgroup. If it is nil, no
1978 confirmation is required."
1980 :group 'gnus-group-select
1981 :type '(choice (const :tag "No limit" nil)
1984 (defcustom gnus-fetch-old-ephemeral-headers nil
1985 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
1988 :type '(choice (const :tag "off" nil)
1991 (sexp :menu-tag "other" t)))
1993 ;; Enter a group that is not in the group buffer. Non-nil is returned
1994 ;; if selection was successful.
1995 (defun gnus-group-read-ephemeral-group (group method &optional activate
1996 quit-config request-only
2000 "Read GROUP from METHOD as an ephemeral group.
2001 If ACTIVATE, request the group first.
2002 If QUIT-CONFIG, use that window configuration when exiting from the
2004 If REQUEST-ONLY, don't actually read the group; just request it.
2005 If SELECT-ARTICLES, only select those articles.
2006 If PARAMETERS, use those as the group parameters.
2007 If NUMBER, fetch this number of articles.
2009 Return the name of the group if selection was successful."
2012 ;; (gnus-read-group "Group name: ")
2014 "Group: " gnus-active-hashtb
2016 'gnus-group-history)
2017 (gnus-read-method "From method: ")))
2018 ;; Transform the select method into a unique server.
2019 (when (stringp method)
2020 (setq method (gnus-server-to-method method)))
2022 `(,(car method) ,(concat (cadr method) "-ephemeral")
2023 (,(intern (format "%s-address" (car method))) ,(cadr method))
2025 (let ((group (if (gnus-group-foreign-p group) group
2026 (gnus-group-prefixed-name (gnus-group-real-name group)
2031 ,gnus-level-default-subscribed nil nil ,method
2034 (cons 'quit-config quit-config)
2036 (cons gnus-summary-buffer
2037 gnus-current-window-configuration)))
2040 (push method gnus-ephemeral-servers)
2041 (set-buffer gnus-group-buffer)
2042 (unless (gnus-check-server method)
2043 (error "Unable to contact server: %s" (gnus-status-message method)))
2045 (gnus-activate-group group 'scan)
2046 (unless (gnus-request-group group)
2047 (error "Couldn't request group: %s"
2048 (nnheader-get-report (car method)))))
2052 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2053 (gnus-fetch-old-headers
2054 gnus-fetch-old-ephemeral-headers))
2055 (gnus-group-read-group (or number t) t group select-articles))
2059 (message "Quit reading the ephemeral group")
2062 (defun gnus-group-jump-to-group (group)
2063 "Jump to newsgroup GROUP."
2065 (list (mm-string-make-unibyte
2067 "Group: " gnus-active-hashtb nil
2068 (gnus-read-active-file-p)
2069 gnus-group-jump-to-group-prompt
2070 'gnus-group-history))))
2072 (when (equal group "")
2073 (error "Empty group name"))
2075 (unless (gnus-ephemeral-group-p group)
2076 ;; Either go to the line in the group buffer...
2077 (unless (gnus-group-goto-group group)
2078 ;; ... or insert the line.
2079 (gnus-group-update-group group)
2080 (gnus-group-goto-group group)))
2081 ;; Adjust cursor point.
2082 (gnus-group-position-point))
2084 (defun gnus-group-goto-group (group &optional far test-marked)
2085 "Goto to newsgroup GROUP.
2086 If FAR, it is likely that the group is not on the current line.
2087 If TEST-MARKED, the line must be marked."
2091 ;; It's quite likely that we are on the right line, so
2092 ;; we check the current line first.
2094 (eq (get-text-property (point) 'gnus-group)
2095 (gnus-intern-safe group gnus-active-hashtb))
2096 (or (not test-marked) (gnus-group-mark-line-p)))
2098 ;; Previous and next line are also likely, so we check them as well.
2102 (and (eq (get-text-property (point) 'gnus-group)
2103 (gnus-intern-safe group gnus-active-hashtb))
2104 (or (not test-marked) (gnus-group-mark-line-p)))))
2110 (and (eq (get-text-property (point) 'gnus-group)
2111 (gnus-intern-safe group gnus-active-hashtb))
2112 (or (not test-marked) (gnus-group-mark-line-p)))))
2116 (goto-char (point-min))
2118 (while (and (not found)
2123 (gnus-intern-safe group gnus-active-hashtb))))
2124 (if (gnus-group-mark-line-p)
2129 ;; Search through the entire buffer.
2132 (point-min) (point-max)
2133 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2135 (defun gnus-group-next-group (n &optional silent)
2136 "Go to next N'th newsgroup.
2137 If N is negative, search backward instead.
2138 Returns the difference between N and the number of skips actually
2141 (gnus-group-next-unread-group n t nil silent))
2143 (defun gnus-group-next-unread-group (n &optional all level silent)
2144 "Go to next N'th unread newsgroup.
2145 If N is negative, search backward instead.
2146 If ALL is non-nil, choose any newsgroup, unread or not.
2147 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2148 such group can be found, the next group with a level higher than
2150 Returns the difference between N and the number of skips actually
2153 (let ((backward (< n 0))
2156 (gnus-group-search-forward
2157 backward (or (not gnus-group-goto-unread) all) level))
2161 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2162 (if level " on this level or higher" "")))
2165 (defun gnus-group-prev-group (n)
2166 "Go to previous N'th newsgroup.
2167 Returns the difference between N and the number of skips actually
2170 (gnus-group-next-unread-group (- n) t))
2172 (defun gnus-group-prev-unread-group (n)
2173 "Go to previous N'th unread newsgroup.
2174 Returns the difference between N and the number of skips actually
2177 (gnus-group-next-unread-group (- n)))
2179 (defun gnus-group-next-unread-group-same-level (n)
2180 "Go to next N'th unread newsgroup on the same level.
2181 If N is negative, search backward instead.
2182 Returns the difference between N and the number of skips actually
2185 (gnus-group-next-unread-group n t (gnus-group-group-level))
2186 (gnus-group-position-point))
2188 (defun gnus-group-prev-unread-group-same-level (n)
2189 "Go to next N'th unread newsgroup on the same level.
2190 Returns the difference between N and the number of skips actually
2193 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2194 (gnus-group-position-point))
2196 (defun gnus-group-best-unread-group (&optional exclude-group)
2197 "Go to the group with the highest level.
2198 If EXCLUDE-GROUP, do not go to that group."
2200 (goto-char (point-min))
2204 (setq unread (get-text-property (point) 'gnus-unread))
2205 (when (and (numberp unread) (> unread 0))
2206 (when (and (get-text-property (point) 'gnus-level)
2207 (< (get-text-property (point) 'gnus-level) best)
2208 (or (not exclude-group)
2209 (not (equal exclude-group (gnus-group-group-name)))))
2210 (setq best (get-text-property (point) 'gnus-level))
2211 (setq best-point (point))))
2214 (goto-char best-point))
2215 (gnus-group-position-point)
2216 (and best-point (gnus-group-group-name))))
2218 (defun gnus-group-first-unread-group ()
2219 "Go to the first group with unread articles."
2222 (let ((opoint (point))
2224 (goto-char (point-min))
2225 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2226 (and (numberp unread) ; Not a topic.
2227 (not (zerop unread))) ; Has unread articles.
2228 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2231 nil)) ; Not success.
2232 (gnus-group-position-point)))
2234 (defun gnus-group-enter-server-mode ()
2235 "Jump to the server buffer."
2237 (gnus-enter-server-buffer))
2239 (defun gnus-group-make-group (name &optional method address args)
2240 "Add a new newsgroup.
2241 The user will be prompted for a NAME, for a select METHOD, and an
2245 (gnus-read-group "Group name: ")
2246 (gnus-read-method "From method: ")))
2248 (when (stringp method)
2249 (setq method (or (gnus-server-to-method method) method)))
2250 (let* ((meth (gnus-method-simplify
2252 (not (gnus-server-equal method gnus-select-method)))
2253 (if address (list (intern method) address)
2255 (nname (if method (gnus-group-prefixed-name name meth) name))
2257 (when (gnus-gethash nname gnus-newsrc-hashtb)
2258 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2259 ;; Subscribe to the new group.
2260 (gnus-group-change-level
2261 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2262 gnus-level-default-subscribed gnus-level-killed
2263 (and (gnus-group-group-name)
2264 (gnus-gethash (gnus-group-group-name)
2265 gnus-newsrc-hashtb))
2268 (gnus-set-active nname (cons 1 0))
2269 (unless (gnus-ephemeral-group-p name)
2271 (concat "(gnus-group-set-info '"
2272 (gnus-prin1-to-string (cdr info)) ")")))
2274 (gnus-group-insert-group-line-info nname)
2276 (gnus-group-position-point)
2278 ;; Load the back end and try to make the back end create
2279 ;; the group as well.
2280 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2282 gnus-valid-select-methods)
2284 (gnus-check-server meth)
2285 (when (gnus-check-backend-function 'request-create-group nname)
2286 (unless (gnus-request-create-group nname nil args)
2287 (error "Could not create group on server: %s"
2288 (nnheader-get-report backend))))
2291 (defun gnus-group-delete-groups (&optional arg)
2292 "Delete the current group. Only meaningful with editable groups."
2294 (let ((n (length (gnus-group-process-prefix arg))))
2295 (when (gnus-yes-or-no-p
2297 "Delete this 1 group? "
2298 (format "Delete these %d groups? " n)))
2299 (gnus-group-iterate arg
2301 (gnus-group-delete-group group nil t))))))
2303 (defun gnus-group-delete-group (group &optional force no-prompt)
2304 "Delete the current group. Only meaningful with editable groups.
2305 If FORCE (the prefix) is non-nil, all the articles in the group will
2306 be deleted. This is \"deleted\" as in \"removed forever from the face
2307 of the Earth\". There is no undo. The user will be prompted before
2309 Note that you also have to specify FORCE if you want the group to
2310 be removed from the server, even when it's empty."
2312 (list (gnus-group-group-name)
2313 current-prefix-arg))
2315 (error "No group to delete"))
2316 (unless (gnus-check-backend-function 'request-delete-group group)
2317 (error "This back end does not support group deletion"))
2319 (let ((group-decoded (gnus-group-decoded-name group)))
2320 (if (and (not no-prompt)
2321 (not (gnus-yes-or-no-p
2323 "Do you really want to delete %s%s? "
2324 group-decoded (if force " and all its contents" "")))))
2326 (gnus-message 6 "Deleting group %s..." group-decoded)
2327 (if (not (gnus-request-delete-group group force))
2328 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2329 (gnus-message 6 "Deleting group %s...done" group-decoded)
2330 (gnus-group-goto-group group)
2331 (gnus-group-kill-group 1 t)
2332 (gnus-sethash group nil gnus-active-hashtb)
2334 (gnus-group-position-point)))
2336 (defun gnus-group-rename-group (group new-name)
2337 "Rename group from GROUP to NEW-NAME.
2338 When used interactively, GROUP is the group under point
2339 and NEW-NAME will be prompted for."
2342 (gnus-group-group-name)
2344 (unless (gnus-check-backend-function
2345 'request-rename-group (gnus-group-group-name))
2346 (error "This back end does not support renaming groups"))
2347 (gnus-read-group "Rename group to: "
2348 (gnus-group-real-name (gnus-group-group-name))))))
2350 (unless (gnus-check-backend-function 'request-rename-group group)
2351 (error "This back end does not support renaming groups"))
2353 (error "No group to rename"))
2354 (when (equal (gnus-group-real-name group) new-name)
2355 (error "Can't rename to the same name"))
2357 ;; We find the proper prefixed name.
2359 (if (gnus-group-native-p group)
2363 (gnus-group-prefixed-name
2364 (gnus-group-real-name new-name)
2365 (gnus-info-method (gnus-get-info group)))))
2367 (when (gnus-active new-name)
2368 (error "The group %s already exists" new-name))
2370 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2373 (gnus-group-goto-group group)
2374 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2375 (gnus-request-rename-group group new-name))))
2376 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2377 ;; We rename the group internally by killing it...
2378 (gnus-group-kill-group)
2379 ;; ... changing its name ...
2380 (setcar (cdar gnus-list-of-killed-groups) new-name)
2381 ;; ... and then yanking it. Magic!
2382 (gnus-group-yank-group)
2383 (gnus-set-active new-name (gnus-active group))
2384 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2386 (setq gnus-killed-list (delete group gnus-killed-list))
2387 (gnus-set-active group nil)
2388 (gnus-dribble-touch)
2389 (gnus-group-position-point)))
2391 (defun gnus-group-edit-group (group &optional part)
2392 "Edit the group on the current line."
2393 (interactive (list (gnus-group-group-name)))
2394 (let ((part (or part 'info))
2397 (error "No group on current line"))
2398 (unless (setq info (gnus-get-info group))
2399 (error "Killed group; can't be edited"))
2401 (gnus-close-group group))
2403 ;; Find the proper form to edit.
2404 (cond ((eq part 'method)
2405 (or (gnus-info-method info) "native"))
2407 (gnus-info-params info))
2409 ;; The proper documentation.
2411 "Editing the %s for `%s'."
2413 ((eq part 'method) "select method")
2414 ((eq part 'params) "group parameters")
2416 (gnus-group-decoded-name group))
2418 (gnus-group-edit-group-done ',part ,group form)))
2421 (gnus-create-info-command
2424 "(gnus)Select Methods")
2426 "(gnus)Group Parameters")
2428 "(gnus)Group Info"))))))
2430 (defun gnus-group-edit-group-method (group)
2431 "Edit the select method of GROUP."
2432 (interactive (list (gnus-group-group-name)))
2433 (gnus-group-edit-group group 'method))
2435 (defun gnus-group-edit-group-parameters (group)
2436 "Edit the group parameters of GROUP."
2437 (interactive (list (gnus-group-group-name)))
2438 (gnus-group-edit-group group 'params))
2440 (defun gnus-group-edit-group-done (part group form)
2442 (let* ((method (cond ((eq part 'info) (nth 4 form))
2443 ((eq part 'method) form)
2445 (info (cond ((eq part 'info) form)
2446 ((eq part 'method) (gnus-get-info group))
2449 (if (or (not method)
2451 gnus-select-method method))
2452 (gnus-group-real-name (car info))
2453 (gnus-group-prefixed-name
2454 (gnus-group-real-name (car info)) method))
2456 (when (and new-group
2457 (not (equal new-group group)))
2458 (when (gnus-group-goto-group group)
2459 (gnus-group-kill-group 1))
2460 (gnus-activate-group new-group))
2462 (if (not (and info new-group))
2463 (gnus-group-set-info form (or new-group group) part)
2464 (setq info (gnus-copy-sequence info))
2465 (setcar info new-group)
2466 (unless (gnus-server-equal method "native")
2467 (unless (nthcdr 3 info)
2468 (nconc info (list nil nil)))
2469 (unless (nthcdr 4 info)
2470 (nconc info (list nil)))
2471 (gnus-info-set-method info method))
2472 (gnus-group-set-info info))
2473 (gnus-group-update-group (or new-group group))
2474 (gnus-group-position-point)))
2476 (defun gnus-group-make-useful-group (group method)
2477 "Create one of the groups described in `gnus-useful-groups'."
2479 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2481 gnus-useful-groups)))
2482 (list (cadr entry) (caddr entry))))
2483 (setq method (gnus-copy-sequence method))
2485 (while (setq entry (memq (assq 'eval method) method))
2486 (setcar entry (eval (cadar entry)))))
2487 (gnus-group-make-group group method))
2489 (defun gnus-group-make-help-group (&optional noerror)
2490 "Create the Gnus documentation group.
2491 Optional argument NOERROR modifies the behavior of this function when the
2492 group already exists:
2493 - if not given, and error is signaled,
2494 - if t, stay silent,
2495 - if anything else, just print a message."
2497 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2498 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2499 (if (gnus-gethash name gnus-newsrc-hashtb)
2500 (cond ((eq noerror nil)
2501 (error "Documentation group already exists"))
2506 (gnus-message 1 "Documentation group already exists")))
2509 (gnus-message 1 "Couldn't find doc group")
2510 (gnus-group-make-group
2511 (gnus-group-real-name name)
2512 (list 'nndoc "gnus-help"
2513 (list 'nndoc-address file)
2514 (list 'nndoc-article-type 'mbox))))
2516 (gnus-group-position-point))
2518 (defun gnus-group-make-doc-group (file type)
2519 "Create a group that uses a single file as the source.
2521 If called with a prefix argument, ask for the file type."
2523 (list (read-file-name "File name: ")
2524 (and current-prefix-arg 'ask)))
2525 (when (eq type 'ask)
2530 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2532 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2533 ((= char ?b) 'babyl)
2534 ((= char ?d) 'digest)
2535 ((= char ?f) 'forward)
2537 ((= char ?g) 'guess)
2538 (t (setq err (format "%c unknown. " char))
2541 (let* ((file (expand-file-name file))
2542 (name (gnus-generate-new-group-name
2543 (gnus-group-prefixed-name
2544 (file-name-nondirectory file) '(nndoc "")))))
2545 (gnus-group-make-group
2546 (gnus-group-real-name name)
2548 (list 'nndoc-address file)
2549 (list 'nndoc-article-type (or type 'guess))))))
2551 (defvar nnweb-type-definition)
2552 (defvar gnus-group-web-type-history nil)
2553 (defvar gnus-group-web-search-history nil)
2554 (defun gnus-group-make-web-group (&optional solid)
2555 "Create an ephemeral nnweb group.
2556 If SOLID (the prefix), create a solid group."
2560 (if solid (gnus-read-group "Group name: ")
2561 (message-unique-id)))
2562 (default-type (or (car gnus-group-web-type-history)
2563 (symbol-name (caar nnweb-type-definition))))
2567 (format "Search engine type (default %s): " default-type)
2568 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2569 nnweb-type-definition)
2570 nil t nil 'gnus-group-web-type-history)
2575 (cons (or (car gnus-group-web-search-history) "") 0)
2576 'gnus-group-web-search-history))
2578 `(nnweb ,group (nnweb-search ,search)
2579 (nnweb-type ,(intern type))
2580 (nnweb-ephemeral-p t))))
2583 (gnus-pull 'nnweb-ephemeral-p method)
2584 (gnus-group-make-group group method))
2585 (gnus-group-read-ephemeral-group
2587 (cons (current-buffer)
2588 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2591 (defvar nnrss-group-alist)
2592 (defun nnrss-discover-feed (arg))
2593 (defun nnrss-save-server-data (arg)))
2594 (defun gnus-group-make-rss-group (&optional url)
2595 "Given a URL, discover if there is an RSS feed.
2596 If there is, use Gnus to create an nnrss group"
2600 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2601 (let ((feedinfo (nnrss-discover-feed url)))
2603 (let ((title (gnus-newsgroup-savable-name
2604 (read-from-minibuffer "Title: "
2605 (gnus-newsgroup-savable-name
2606 (or (cdr (assoc 'title
2609 (desc (read-from-minibuffer "Description: "
2610 (cdr (assoc 'description
2612 (href (cdr (assoc 'href feedinfo)))
2613 (encodable (mm-coding-system-p 'utf-8)))
2615 ;; Unify non-ASCII text.
2616 (setq title (mm-decode-coding-string
2617 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2618 (gnus-group-make-group (if encodable
2619 (mm-encode-coding-string title 'utf-8)
2622 (push (list title href desc) nnrss-group-alist)
2623 (nnrss-save-server-data nil))
2624 (error "No feeds found for %s" url))))
2626 (defvar nnwarchive-type-definition)
2627 (defvar gnus-group-warchive-type-history nil)
2628 (defvar gnus-group-warchive-login-history nil)
2629 (defvar gnus-group-warchive-address-history nil)
2631 (defun gnus-group-make-warchive-group ()
2632 "Create a nnwarchive group."
2634 (require 'nnwarchive)
2635 (let* ((group (gnus-read-group "Group name: "))
2636 (default-type (or (car gnus-group-warchive-type-history)
2637 (symbol-name (caar nnwarchive-type-definition))))
2641 (format "Warchive type (default %s): " default-type)
2642 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2643 nnwarchive-type-definition)
2644 nil t nil 'gnus-group-warchive-type-history)
2646 (address (read-string "Warchive address: "
2647 nil 'gnus-group-warchive-address-history))
2648 (default-login (or (car gnus-group-warchive-login-history)
2653 (format "Warchive login (default %s): " user-mail-address)
2654 default-login 'gnus-group-warchive-login-history)
2657 `(nnwarchive ,address
2658 (nnwarchive-type ,(intern type))
2659 (nnwarchive-login ,login))))
2660 (gnus-group-make-group group method)))
2662 (defun gnus-group-make-archive-group (&optional all)
2663 "Create the (ding) Gnus archive group of the most recent articles.
2664 Given a prefix, create a full group."
2666 (let ((group (gnus-group-prefixed-name
2667 (if all "ding.archives" "ding.recent") '(nndir ""))))
2668 (when (gnus-gethash group gnus-newsrc-hashtb)
2669 (error "Archive group already exists"))
2670 (gnus-group-make-group
2671 (gnus-group-real-name group)
2672 (list 'nndir (if all "hpc" "edu")
2673 (list 'nndir-directory
2674 (if all gnus-group-archive-directory
2675 gnus-group-recent-archive-directory))))
2676 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2678 (defun gnus-group-make-directory-group (dir)
2679 "Create an nndir group.
2680 The user will be prompted for a directory. The contents of this
2681 directory will be used as a newsgroup. The directory should contain
2682 mail messages or news articles in files that have numeric names."
2684 (list (read-file-name "Create group from directory: ")))
2685 (unless (file-exists-p dir)
2686 (error "No such directory"))
2687 (unless (file-directory-p dir)
2688 (error "Not a directory"))
2692 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2694 (gnus-group-prefixed-name
2695 (expand-file-name ext dir)
2697 (setq ext (format "<%d>" (setq i (1+ i)))))
2698 (gnus-group-make-group
2699 (gnus-group-real-name group)
2700 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2702 (defvar nnkiboze-score-file)
2703 (defun gnus-group-make-kiboze-group (group address scores)
2704 "Create an nnkiboze group.
2705 The user will be prompted for a name, a regexp to match groups, and
2706 score file entries for articles to include in the group."
2709 (read-string "nnkiboze group name: ")
2710 (read-string "Source groups (regexp): ")
2711 (let ((headers (mapcar (lambda (group) (list group))
2712 '("subject" "from" "number" "date" "message-id"
2713 "references" "chars" "lines" "xref"
2714 "followup" "all" "body" "head")))
2715 scores header regexp regexps)
2716 (while (not (equal "" (setq header (completing-read
2717 "Match on header: " headers nil t))))
2719 (while (not (equal "" (setq regexp (read-string
2720 (format "Match on %s (regexp): "
2722 (push (list regexp nil nil 'r) regexps))
2723 (push (cons header regexps) scores))
2725 (gnus-group-make-group group "nnkiboze" address)
2726 (let* ((nnkiboze-current-group group)
2727 (score-file (car (nnkiboze-score-file "")))
2728 (score-dir (file-name-directory score-file)))
2729 (unless (file-exists-p score-dir)
2730 (make-directory score-dir))
2731 (with-temp-file score-file
2732 (let (emacs-lisp-mode-hook)
2733 (gnus-pp scores)))))
2735 (defun gnus-group-add-to-virtual (n vgroup)
2736 "Add the current group to a virtual group."
2738 (list current-prefix-arg
2739 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2741 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2742 (error "%s is not an nnvirtual group" vgroup))
2743 (gnus-close-group vgroup)
2744 (let* ((groups (gnus-group-process-prefix n))
2745 (method (gnus-info-method (gnus-get-info vgroup))))
2746 (setcar (cdr method)
2748 (nth 1 method) "\\|"
2751 (gnus-group-remove-mark s)
2752 (concat "\\(^" (regexp-quote s) "$\\)"))
2754 (gnus-group-position-point))
2756 (defun gnus-group-make-empty-virtual (group)
2757 "Create a new, fresh, empty virtual group."
2758 (interactive "sCreate new, empty virtual group: ")
2759 (let* ((method (list 'nnvirtual "^$"))
2760 (pgroup (gnus-group-prefixed-name group method)))
2761 ;; Check whether it exists already.
2762 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2763 (error "Group %s already exists" pgroup))
2764 ;; Subscribe the new group after the group on the current line.
2765 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2766 (gnus-group-update-group pgroup)
2768 (gnus-group-position-point)))
2770 (defun gnus-group-enter-directory (dir)
2771 "Enter an ephemeral nneething group."
2772 (interactive "DDirectory to read: ")
2773 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2774 (leaf (gnus-group-prefixed-name
2775 (file-name-nondirectory (directory-file-name dir))
2777 (name (gnus-generate-new-group-name leaf)))
2778 (unless (gnus-group-read-ephemeral-group
2780 (cons (current-buffer)
2781 (if (eq major-mode 'gnus-summary-mode)
2783 (error "Couldn't enter %s" dir))))
2786 (autoload 'nnimap-expunge "nnimap")
2787 (autoload 'nnimap-acl-get "nnimap")
2788 (autoload 'nnimap-acl-edit "nnimap"))
2790 (defun gnus-group-nnimap-expunge (group)
2791 "Expunge deleted articles in current nnimap GROUP."
2792 (interactive (list (gnus-group-group-name)))
2793 (let ((mailbox (gnus-group-real-name group)) method)
2795 (error "No group on current line"))
2796 (unless (gnus-get-info group)
2797 (error "Killed group; can't be edited"))
2798 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2799 (error "%s is not an nnimap group" group))
2800 (nnimap-expunge mailbox (cadr method))))
2802 (defun gnus-group-nnimap-edit-acl (group)
2803 "Edit the Access Control List of current nnimap GROUP."
2804 (interactive (list (gnus-group-group-name)))
2805 (let ((mailbox (gnus-group-real-name group)) method acl)
2807 (error "No group on current line"))
2808 (unless (gnus-get-info group)
2809 (error "Killed group; can't be edited"))
2810 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2811 (error "%s is not an nnimap group" group))
2812 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2813 (error "Server does not support ACL's"))
2814 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2816 An access control list is a list of (identifier . rights) elements.
2818 The identifier string specifies the corresponding user. The
2819 identifier \"anyone\" is reserved to refer to the universal identity.
2821 Rights is a string listing a (possibly empty) set of alphanumeric
2822 characters, each character listing a set of operations which is being
2823 controlled. Letters are reserved for ``standard'' rights, listed
2824 below. Digits are reserved for implementation or site defined rights.
2826 l - lookup (mailbox is visible to LIST/LSUB commands)
2827 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2828 SEARCH, COPY from mailbox)
2829 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2830 w - write (STORE flags other than \\SEEN and \\DELETED)
2831 i - insert (perform APPEND, COPY into mailbox)
2832 p - post (send mail to submission address for mailbox,
2833 not enforced by IMAP4 itself)
2834 c - create and delete mailbox (CREATE new sub-mailboxes in any
2835 implementation-defined hierarchy, RENAME or DELETE mailbox)
2836 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2837 a - administer (perform SETACL)" group)
2840 ,mailbox ',method ',acl form)))))
2842 ;; Group sorting commands
2843 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2845 (defun gnus-group-sort-groups (func &optional reverse)
2846 "Sort the group buffer according to FUNC.
2847 When used interactively, the sorting function used will be
2848 determined by the `gnus-group-sort-function' variable.
2849 If REVERSE (the prefix), reverse the sorting order."
2850 (interactive (list gnus-group-sort-function current-prefix-arg))
2851 (funcall gnus-group-sort-alist-function
2852 (gnus-make-sort-function func) reverse)
2853 (gnus-group-unmark-all-groups)
2854 (gnus-group-list-groups)
2855 (gnus-dribble-touch))
2857 (defun gnus-group-sort-flat (func reverse)
2858 ;; We peel off the dummy group from the alist.
2860 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2861 (pop gnus-newsrc-alist))
2863 (setq gnus-newsrc-alist
2864 (sort gnus-newsrc-alist func))
2866 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2867 ;; Regenerate the hash table.
2868 (gnus-make-hashtable-from-newsrc-alist)))
2870 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2871 "Sort the group buffer alphabetically by group name.
2872 If REVERSE, sort in reverse order."
2874 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2876 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2877 "Sort the group buffer alphabetically by real (unprefixed) group name.
2878 If REVERSE, sort in reverse order."
2880 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2882 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2883 "Sort the group buffer by number of unread articles.
2884 If REVERSE, sort in reverse order."
2886 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2888 (defun gnus-group-sort-groups-by-level (&optional reverse)
2889 "Sort the group buffer by group level.
2890 If REVERSE, sort in reverse order."
2892 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2894 (defun gnus-group-sort-groups-by-score (&optional reverse)
2895 "Sort the group buffer by group score.
2896 If REVERSE, sort in reverse order."
2898 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2900 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2901 "Sort the group buffer by group rank.
2902 If REVERSE, sort in reverse order."
2904 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2906 (defun gnus-group-sort-groups-by-method (&optional reverse)
2907 "Sort the group buffer alphabetically by back end name.
2908 If REVERSE, sort in reverse order."
2910 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2912 (defun gnus-group-sort-groups-by-server (&optional reverse)
2913 "Sort the group buffer alphabetically by server name.
2914 If REVERSE, sort in reverse order."
2916 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2918 ;;; Selected group sorting.
2920 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2921 "Sort the process/prefixed groups."
2922 (interactive (list current-prefix-arg gnus-group-sort-function))
2923 (let ((groups (gnus-group-process-prefix n)))
2924 (funcall gnus-group-sort-selected-function
2925 groups (gnus-make-sort-function func) reverse)
2926 (gnus-group-unmark-all-groups)
2927 (gnus-group-list-groups)
2928 (gnus-dribble-touch)))
2930 (defun gnus-group-sort-selected-flat (groups func reverse)
2931 (let (entries infos)
2932 ;; First find all the group entries for these groups.
2934 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2936 ;; Then sort the infos.
2940 (lambda (entry) (car entry))
2941 (setq entries (nreverse entries)))
2944 (setq infos (nreverse infos)))
2945 ;; Go through all the infos and replace the old entries
2946 ;; with the new infos.
2948 (setcar (car entries) (pop infos))
2950 ;; Update the hashtable.
2951 (gnus-make-hashtable-from-newsrc-alist)))
2953 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2954 "Sort the group buffer alphabetically by group name.
2955 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2956 sort in reverse order."
2957 (interactive (gnus-interactive "P\ny"))
2958 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2960 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2961 "Sort the group buffer alphabetically by real group name.
2962 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2963 sort in reverse order."
2964 (interactive (gnus-interactive "P\ny"))
2965 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2967 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2968 "Sort the group buffer by number of unread articles.
2969 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2970 sort in reverse order."
2971 (interactive (gnus-interactive "P\ny"))
2972 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2974 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2975 "Sort the group buffer by group level.
2976 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2977 sort in reverse order."
2978 (interactive (gnus-interactive "P\ny"))
2979 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2981 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2982 "Sort the group buffer by group score.
2983 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2984 sort in reverse order."
2985 (interactive (gnus-interactive "P\ny"))
2986 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2988 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2989 "Sort the group buffer by group rank.
2990 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2991 sort in reverse order."
2992 (interactive (gnus-interactive "P\ny"))
2993 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2995 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2996 "Sort the group buffer alphabetically by back end name.
2997 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2998 sort in reverse order."
2999 (interactive (gnus-interactive "P\ny"))
3000 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3002 ;;; Sorting predicates.
3004 (defun gnus-group-sort-by-alphabet (info1 info2)
3005 "Sort alphabetically."
3006 (string< (gnus-info-group info1) (gnus-info-group info2)))
3008 (defun gnus-group-sort-by-real-name (info1 info2)
3009 "Sort alphabetically on real (unprefixed) names."
3010 (string< (gnus-group-real-name (gnus-info-group info1))
3011 (gnus-group-real-name (gnus-info-group info2))))
3013 (defun gnus-group-sort-by-unread (info1 info2)
3014 "Sort by number of unread articles."
3015 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
3016 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
3017 (< (or (and (numberp n1) n1) 0)
3018 (or (and (numberp n2) n2) 0))))
3020 (defun gnus-group-sort-by-level (info1 info2)
3022 (< (gnus-info-level info1) (gnus-info-level info2)))
3024 (defun gnus-group-sort-by-method (info1 info2)
3025 "Sort alphabetically by back end name."
3026 (string< (car (gnus-find-method-for-group
3027 (gnus-info-group info1) info1))
3028 (car (gnus-find-method-for-group
3029 (gnus-info-group info2) info2))))
3031 (defun gnus-group-sort-by-server (info1 info2)
3032 "Sort alphabetically by server name."
3033 (string< (gnus-method-to-full-server-name
3034 (gnus-find-method-for-group
3035 (gnus-info-group info1) info1))
3036 (gnus-method-to-full-server-name
3037 (gnus-find-method-for-group
3038 (gnus-info-group info2) info2))))
3040 (defun gnus-group-sort-by-score (info1 info2)
3041 "Sort by group score."
3042 (> (gnus-info-score info1) (gnus-info-score info2)))
3044 (defun gnus-group-sort-by-rank (info1 info2)
3045 "Sort by level and score."
3046 (let ((level1 (gnus-info-level info1))
3047 (level2 (gnus-info-level info2)))
3048 (or (< level1 level2)
3049 (and (= level1 level2)
3050 (> (gnus-info-score info1) (gnus-info-score info2))))))
3054 (defun gnus-group-clear-data (&optional arg)
3055 "Clear all marks and read ranges from the current group.
3056 Obeys the process/prefix convention."
3058 (gnus-group-iterate arg
3061 (gnus-info-clear-data (setq info (gnus-get-info group)))
3062 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3063 (when (gnus-group-goto-group group)
3064 (gnus-group-update-group-line))))))
3066 (defun gnus-group-clear-data-on-native-groups ()
3067 "Clear all marks and read ranges from all native groups."
3069 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3070 (let ((alist (cdr gnus-newsrc-alist))
3072 (while (setq info (pop alist))
3073 (when (gnus-group-native-p (gnus-info-group info))
3074 (gnus-info-clear-data info)))
3075 (gnus-get-unread-articles)
3076 (gnus-dribble-touch)
3077 (when (gnus-y-or-n-p
3078 "Move the cache away to avoid problems in the future? ")
3079 (call-interactively 'gnus-cache-move-cache)))))
3081 (defun gnus-info-clear-data (info)
3082 "Clear all marks and read ranges from INFO."
3083 (let ((group (gnus-info-group info))
3085 (dolist (el (gnus-info-marks info))
3086 (push `(,(cdr el) add (,(car el))) action))
3087 (push `(,(gnus-info-read info) add (read)) action)
3090 (gnus-request-set-mark ,group ',action)
3091 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3092 (gnus-info-set-read ',info ',(gnus-info-read info))
3093 (when (gnus-group-goto-group ,group)
3094 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3095 (gnus-group-update-group-line))))
3096 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3098 (gnus-request-set-mark group action)
3099 (gnus-info-set-read info nil)
3100 (when (gnus-info-marks info)
3101 (gnus-info-set-marks info nil))))
3103 ;; Group catching up.
3105 (defun gnus-group-catchup-current (&optional n all)
3106 "Mark all unread articles in the current newsgroup as read.
3107 If prefix argument N is numeric, the next N newsgroups will be
3108 caught up. If ALL is non-nil, marked articles will also be marked as
3109 read. Cross references (Xref: header) of articles are ignored.
3110 The number of newsgroups that this function was unable to catch
3113 (let ((groups (gnus-group-process-prefix n))
3116 (unless groups (error "No groups selected"))
3118 (or (not gnus-interactive-catchup) ;Without confirmation?
3123 "Do you really want to mark all articles in %s as read? "
3124 "Mark all unread articles in %s as read? ")
3125 (if (= (length groups) 1)
3126 (gnus-group-decoded-name (car groups))
3127 (format "these %d groups" (length groups)))))))
3129 (while (setq group (pop groups))
3130 (gnus-group-remove-mark group)
3131 ;; Virtual groups have to be given special treatment.
3132 (let ((method (gnus-find-method-for-group group)))
3133 (when (eq 'nnvirtual (car method))
3134 (nnvirtual-catchup-group
3135 (gnus-group-real-name group) (nth 1 method) all)))
3136 (if (>= (gnus-group-level group) gnus-level-zombie)
3137 (gnus-message 2 "Dead groups can't be caught up")
3139 (gnus-group-goto-group group)
3140 (gnus-group-catchup group all))
3141 (gnus-group-update-group-line)
3142 (setq ret (1+ ret)))))
3143 (gnus-group-next-unread-group 1)
3146 (defun gnus-group-catchup-current-all (&optional n)
3147 "Mark all articles in current newsgroup as read.
3148 Cross references (Xref: header) of articles are ignored."
3150 (gnus-group-catchup-current n 'all))
3152 (defun gnus-group-catchup (group &optional all)
3153 "Mark all articles in GROUP as read.
3154 If ALL is non-nil, all articles are marked as read.
3155 The return value is the number of articles that were marked as read,
3156 or nil if no action could be taken."
3157 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3159 (marks (nth 3 (nth 2 entry)))
3160 (unread (gnus-sequence-of-unread-articles group)))
3161 ;; Remove entries for this group.
3162 (nnmail-purge-split-history (gnus-group-real-name group))
3163 ;; Do the updating only if the newsgroup isn't killed.
3164 (if (not (numberp (car entry)))
3165 (gnus-message 1 "Can't catch up %s; non-active group" group)
3166 (gnus-update-read-articles group nil)
3168 ;; Nix out the lists of marks and dormants.
3169 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3171 (list (cdr (assq 'dormant marks))
3173 (setq unread (gnus-range-add (gnus-range-add
3174 unread (cdr (assq 'dormant marks)))
3175 (cdr (assq 'tick marks))))
3176 (gnus-add-marked-articles group 'tick nil nil 'force)
3177 (gnus-add-marked-articles group 'dormant nil nil 'force))
3178 ;; Do auto-expirable marks if that's required.
3179 (when (gnus-group-auto-expirable-p group)
3180 (gnus-range-map (lambda (article)
3181 (gnus-add-marked-articles group 'expire (list article))
3182 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3184 (let ((gnus-newsgroup-name group))
3185 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3188 (defun gnus-group-expire-articles (&optional n)
3189 "Expire all expirable articles in the current newsgroup.
3190 Uses the process/prefix convention."
3192 (let ((groups (gnus-group-process-prefix n))
3195 (error "No groups to expire"))
3196 (while (setq group (pop groups))
3197 (gnus-group-remove-mark group)
3198 (gnus-group-expire-articles-1 group)
3199 (gnus-dribble-touch)
3200 (gnus-group-position-point))))
3202 (defun gnus-group-expire-articles-1 (group)
3203 (when (gnus-check-backend-function 'request-expire-articles group)
3204 (gnus-message 6 "Expiring articles in %s..."
3205 (gnus-group-decoded-name group))
3206 (let* ((info (gnus-get-info group))
3207 (expirable (if (gnus-group-total-expirable-p group)
3208 (cons nil (gnus-list-of-read-articles group))
3209 (assq 'expire (gnus-info-marks info))))
3210 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3211 (nnmail-expiry-target
3212 (or (gnus-group-find-parameter group 'expiry-target)
3213 nnmail-expiry-target)))
3215 (gnus-check-group group)
3218 (gnus-compress-sequence
3220 ;; We set the expiry variables to the group
3222 (let ((nnmail-expiry-wait-function nil)
3223 (nnmail-expiry-wait expiry-wait))
3224 (gnus-request-expire-articles
3225 (gnus-uncompress-sequence (cdr expirable)) group))
3226 ;; Just expire using the normal expiry values.
3227 (gnus-request-expire-articles
3228 (gnus-uncompress-sequence (cdr expirable)) group))))
3229 (gnus-close-group group))
3230 (gnus-message 6 "Expiring articles in %s...done"
3231 (gnus-group-decoded-name group))
3232 ;; Return the list of un-expired articles.
3235 (defun gnus-group-expire-all-groups ()
3236 "Expire all expirable articles in all newsgroups."
3239 (gnus-message 5 "Expiring...")
3240 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3241 (cdr gnus-newsrc-alist))))
3242 (gnus-group-expire-articles nil)))
3243 (gnus-group-position-point)
3244 (gnus-message 5 "Expiring...done"))
3246 (defun gnus-group-set-current-level (n level)
3247 "Set the level of the next N groups to LEVEL."
3252 (unless (gnus-group-process-prefix current-prefix-arg)
3253 (error "No group on the current line"))
3255 (let ((s (read-string
3256 (format "Level (default %s): "
3257 (or (gnus-group-group-level)
3258 gnus-level-default-subscribed)))))
3259 (if (string-match "^\\s-*$" s)
3260 (int-to-string (or (gnus-group-group-level)
3261 gnus-level-default-subscribed))
3263 (unless (and (>= level 1) (<= level gnus-level-killed))
3264 (error "Invalid level: %d" level))
3265 (let ((groups (gnus-group-process-prefix n))
3267 (while (setq group (pop groups))
3268 (gnus-group-remove-mark group)
3269 (gnus-message 6 "Changed level of %s from %d to %d"
3270 (gnus-group-decoded-name group)
3271 (or (gnus-group-group-level) gnus-level-killed)
3273 (gnus-group-change-level
3274 group level (or (gnus-group-group-level) gnus-level-killed))
3275 (gnus-group-update-group-line)))
3276 (gnus-group-position-point))
3278 (defun gnus-group-unsubscribe (&optional n)
3279 "Unsubscribe the current group."
3281 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3283 (defun gnus-group-subscribe (&optional n)
3284 "Subscribe the current group."
3286 (gnus-group-unsubscribe-current-group n 'subscribe))
3288 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3289 "Toggle subscription of the current group.
3290 If given numerical prefix, toggle the N next groups."
3292 (dolist (group (gnus-group-process-prefix n))
3293 (gnus-group-remove-mark group)
3294 (gnus-group-unsubscribe-group
3297 ((eq do-sub 'unsubscribe)
3298 gnus-level-default-unsubscribed)
3299 ((eq do-sub 'subscribe)
3300 gnus-level-default-subscribed)
3301 ((<= (gnus-group-group-level) gnus-level-subscribed)
3302 gnus-level-default-unsubscribed)
3304 gnus-level-default-subscribed))
3306 (gnus-group-update-group-line))
3307 (gnus-group-next-group 1))
3309 (defun gnus-group-unsubscribe-group (group &optional level silent)
3310 "Toggle subscription to GROUP.
3311 Killed newsgroups are subscribed. If SILENT, don't try to update the
3314 (list (completing-read
3315 "Group: " gnus-active-hashtb nil
3316 (gnus-read-active-file-p)
3318 'gnus-group-history)))
3319 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3321 ((string-match "^[ \t]*$" group)
3322 (error "Empty group name"))
3324 ;; Toggle subscription flag.
3325 (gnus-group-change-level
3326 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3327 gnus-level-subscribed)
3328 (1+ gnus-level-subscribed)
3329 gnus-level-default-subscribed)))
3331 (gnus-group-update-group group)))
3332 ((and (stringp group)
3333 (or (not (gnus-read-active-file-p))
3334 (gnus-active group)))
3335 ;; Add new newsgroup.
3336 (gnus-group-change-level
3338 (if level level gnus-level-default-subscribed)
3339 (or (and (member group gnus-zombie-list)
3342 (when (gnus-group-group-name)
3343 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3345 (gnus-group-update-group group)))
3346 (t (error "No such newsgroup: %s" group)))
3347 (gnus-group-position-point)))
3349 (defun gnus-group-transpose-groups (n)
3350 "Move the current newsgroup up N places.
3351 If given a negative prefix, move down instead. The difference between
3352 N and the number of steps taken is returned."
3354 (unless (gnus-group-group-name)
3355 (error "No group on current line"))
3356 (gnus-group-kill-group 1)
3358 (forward-line (- n))
3359 (gnus-group-yank-group)
3360 (gnus-group-position-point)))
3362 (defun gnus-group-kill-all-zombies (&optional dummy)
3363 "Kill all zombie newsgroups.
3364 The optional DUMMY should always be nil."
3365 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3367 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3368 (setq gnus-zombie-list nil)
3369 (gnus-dribble-touch)
3370 (gnus-group-list-groups)))
3372 (defun gnus-group-kill-region (begin end)
3373 "Kill newsgroups in current region (excluding current point).
3374 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3389 (beginning-of-line) ;Important when LINES < 1
3390 (gnus-group-kill-group lines)))
3392 (defun gnus-group-kill-group (&optional n discard)
3393 "Kill the next N groups.
3394 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3395 However, only groups that were alive can be yanked; already killed
3396 groups or zombie groups can't be yanked.
3397 The return value is the name of the group that was killed, or a list
3400 (let ((buffer-read-only nil)
3401 (groups (gnus-group-process-prefix n))
3402 group entry level out)
3403 (if (< (length groups) 10)
3404 ;; This is faster when there are few groups.
3406 (push (setq group (pop groups)) out)
3407 (gnus-group-remove-mark group)
3408 (setq level (gnus-group-group-level))
3410 (when (and (not discard)
3411 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3414 (gnus-group-goto-group ,(gnus-group-group-name))
3415 (gnus-group-yank-group)))
3416 (push (cons (car entry) (nth 2 entry))
3417 gnus-list-of-killed-groups))
3418 (gnus-group-change-level
3419 (if entry entry group) gnus-level-killed (if entry nil level))
3420 (message "Killed group %s" (gnus-group-decoded-name group)))
3421 ;; If there are lots and lots of groups to be killed, we use
3422 ;; this thing instead.
3423 (dolist (group (nreverse groups))
3424 (gnus-group-remove-mark group)
3426 (push group gnus-killed-list)
3427 (setq gnus-newsrc-alist
3428 (delq (assoc group gnus-newsrc-alist)
3430 (when gnus-group-change-level-function
3431 (funcall gnus-group-change-level-function
3432 group gnus-level-killed 3))
3434 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3435 (push (cons (car entry) (nth 2 entry))
3436 gnus-list-of-killed-groups)
3437 (setcdr (cdr entry) (cdddr entry)))
3438 ((member group gnus-zombie-list)
3439 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3440 ;; There may be more than one instance displayed.
3441 (while (gnus-group-goto-group group)
3442 (gnus-delete-line)))
3443 (gnus-make-hashtable-from-newsrc-alist))
3445 (gnus-group-position-point)
3446 (if (< (length out) 2) (car out) (nreverse out))))
3448 (defun gnus-group-yank-group (&optional arg)
3449 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3450 The numeric ARG specifies how many newsgroups are to be yanked. The
3451 name of the newsgroup yanked is returned, or (if several groups are
3452 yanked) a list of yanked groups is returned."
3454 (setq arg (or arg 1))
3455 (let (info group prev out)
3456 (while (>= (decf arg) 0)
3457 (when (not (setq info (pop gnus-list-of-killed-groups)))
3458 (error "No more newsgroups to yank"))
3459 (push (setq group (nth 1 info)) out)
3460 ;; Find which newsgroup to insert this one before - search
3461 ;; backward until something suitable is found. If there are no
3462 ;; other newsgroups in this buffer, just make this newsgroup the
3464 (setq prev (gnus-group-group-name))
3465 (gnus-group-change-level
3466 info (gnus-info-level (cdr info)) gnus-level-killed
3467 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3469 (gnus-group-insert-group-line-info group)
3471 `(when (gnus-group-goto-group ,group)
3472 (gnus-group-kill-group 1))))
3474 (gnus-group-position-point)
3475 (if (< (length out) 2) (car out) (nreverse out))))
3477 (defun gnus-group-kill-level (level)
3478 "Kill all groups that is on a certain LEVEL."
3479 (interactive "nKill all groups on level: ")
3481 ((= level gnus-level-zombie)
3482 (setq gnus-killed-list
3483 (nconc gnus-zombie-list gnus-killed-list))
3484 (setq gnus-zombie-list nil))
3485 ((and (< level gnus-level-zombie)
3487 (or gnus-expert-user
3490 "Do you really want to kill all groups on level %d? "
3492 (let* ((prev gnus-newsrc-alist)
3495 (if (= (gnus-info-level (car alist)) level)
3497 (push (gnus-info-group (car alist)) gnus-killed-list)
3498 (setcdr prev (cdr alist)))
3500 (setq alist (cdr alist)))
3501 (gnus-make-hashtable-from-newsrc-alist)
3502 (gnus-group-list-groups)))
3504 (error "Can't kill; invalid level: %d" level))))
3506 (defun gnus-group-list-all-groups (&optional arg)
3507 "List all newsgroups with level ARG or lower.
3508 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3509 unsubscribed groups."
3511 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3513 ;; Redefine this to list ALL killed groups if prefix arg used.
3514 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3515 (defun gnus-group-list-killed (&optional arg)
3516 "List all killed newsgroups in the group buffer.
3517 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3518 entail asking the server for the groups."
3520 ;; Find all possible killed newsgroups if arg.
3522 (gnus-get-killed-groups))
3523 (if (not gnus-killed-list)
3524 (gnus-message 6 "No killed groups")
3525 (let (gnus-group-list-mode)
3526 (funcall gnus-group-prepare-function
3527 gnus-level-killed t gnus-level-killed))
3528 (goto-char (point-min)))
3529 (gnus-group-position-point))
3531 (defun gnus-group-list-zombies ()
3532 "List all zombie newsgroups in the group buffer."
3534 (if (not gnus-zombie-list)
3535 (gnus-message 6 "No zombie groups")
3536 (let (gnus-group-list-mode)
3537 (funcall gnus-group-prepare-function
3538 gnus-level-zombie t gnus-level-zombie))
3539 (goto-char (point-min)))
3540 (gnus-group-position-point))
3542 (defun gnus-group-list-active ()
3543 "List all groups that are available from the server(s)."
3545 ;; First we make sure that we have really read the active file.
3546 (unless (gnus-read-active-file-p)
3547 (let ((gnus-read-active-file t)
3548 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3549 (gnus-read-active-file)))
3550 ;; Find all groups and sort them.
3558 (push (symbol-name sym) list)))
3562 (buffer-read-only nil)
3566 (setq group (pop groups))
3567 (gnus-add-text-properties
3568 (point) (prog1 (1+ (point))
3570 (gnus-group-decoded-name group)
3572 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3574 'gnus-level (inline (gnus-group-level group)))))
3575 (goto-char (point-min))))
3577 (defun gnus-activate-all-groups (level)
3578 "Activate absolutely all groups."
3579 (interactive (list gnus-level-unsubscribed))
3580 (let ((gnus-activate-level level)
3581 (gnus-activate-foreign-newsgroups level))
3582 (gnus-group-get-new-news)))
3584 (defun gnus-group-get-new-news (&optional arg)
3585 "Get newly arrived articles.
3586 If ARG is a number, it specifies which levels you are interested in
3587 re-scanning. If ARG is non-nil and not a number, this will force
3588 \"hard\" re-reading of the active files from all servers."
3591 (let ((gnus-inhibit-demon t)
3592 ;; Binding this variable will inhibit multiple fetchings
3593 ;; of the same mail source.
3594 (nnmail-fetched-sources (list t)))
3595 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3596 (gnus-run-hooks 'gnus-get-new-news-hook)
3598 ;; Read any slave files.
3600 (gnus-master-read-slave-newsrc))
3602 ;; We might read in new NoCeM messages here.
3603 (when (and gnus-use-nocem
3605 (gnus-nocem-scan-groups))
3606 ;; If ARG is not a number, then we read the active file.
3607 (when (and arg (not (numberp arg)))
3608 (let ((gnus-read-active-file t))
3609 (gnus-read-active-file))
3612 ;; If the user wants it, we scan for new groups.
3613 (when (eq gnus-check-new-newsgroups 'always)
3614 (gnus-find-new-newsgroups)))
3616 (setq arg (gnus-group-default-level arg t))
3617 (if (and gnus-read-active-file (not arg))
3619 (gnus-read-active-file)
3620 (gnus-get-unread-articles arg))
3621 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3622 (gnus-get-unread-articles arg)))
3623 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3624 (gnus-group-list-groups (and (numberp arg)
3625 (max (car gnus-group-list-mode) arg)))))
3627 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3628 "Check for newly arrived news in the current group (and the N-1 next groups).
3629 The difference between N and the number of newsgroup checked is returned.
3630 If N is negative, this group and the N-1 previous groups will be checked.
3631 If DONT-SCAN is non-nil, scan non-activated groups as well."
3633 (let* ((groups (gnus-group-process-prefix n))
3634 (ret (if (numberp n) (- n (length groups)) 0))
3638 (gnus-inhibit-demon t)
3639 ;; Binding this variable will inhibit multiple fetchings
3640 ;; of the same mail source.
3641 (nnmail-fetched-sources (list t)))
3642 (gnus-run-hooks 'gnus-get-new-news-hook)
3643 (while (setq group (pop groups))
3644 (gnus-group-remove-mark group)
3645 ;; Bypass any previous denials from the server.
3646 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3647 (if (gnus-activate-group group (if dont-scan nil 'scan))
3649 (gnus-get-unread-articles-in-group
3650 (gnus-get-info group) (gnus-active group) t)
3651 (unless (gnus-virtual-group-p group)
3652 (gnus-close-group group))
3654 (gnus-agent-save-group-info
3655 method (gnus-group-real-name group) (gnus-active group)))
3656 (gnus-group-update-group group))
3657 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3659 (gnus-error 3 "Server denied access")
3660 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3663 (when gnus-goto-next-group-when-activating
3664 (gnus-group-next-unread-group 1 t))
3665 (gnus-summary-position-point)
3668 (defun gnus-group-fetch-faq (group &optional faq-dir)
3669 "Fetch the FAQ for the current group.
3670 If given a prefix argument, prompt for the FAQ dir
3674 (gnus-group-group-name)
3675 (when current-prefix-arg
3677 "FAQ dir: " (and (listp gnus-group-faq-directory)
3679 gnus-group-faq-directory))))))
3681 (error "No group name given"))
3682 (let ((dirs (or faq-dir gnus-group-faq-directory))
3684 (unless (listp dirs)
3685 (setq dirs (list dirs)))
3686 (while (and (not found)
3687 (setq dir (pop dirs)))
3688 (let ((name (gnus-group-real-name group)))
3689 (setq file (expand-file-name name dir)))
3690 (if (not (file-exists-p file))
3691 (gnus-message 1 "No such file: %s" file)
3692 (let ((enable-local-variables nil))
3696 (defun gnus-group-fetch-charter (group)
3697 "Fetch the charter for the current group.
3698 If given a prefix argument, prompt for a group."
3700 (list (or (when current-prefix-arg
3701 (completing-read "Group: " gnus-active-hashtb))
3702 (gnus-group-group-name)
3703 gnus-newsgroup-name)))
3705 (error "No group name given"))
3707 (condition-case nil (require 'url-http) (error nil))
3708 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3710 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3711 (setq hierarchy (match-string 1 name))
3712 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3713 (if (fboundp 'url-http-file-exists-p)
3714 (url-http-file-exists-p (eval url))
3716 (browse-url (eval url))
3717 (setq url (concat "http://" hierarchy
3718 ".news-admin.org/charters/" name))
3719 (if (and (fboundp 'url-http-file-exists-p)
3720 (url-http-file-exists-p url))
3722 (gnus-group-fetch-control group))))))
3724 (defun gnus-group-fetch-control (group)
3725 "Fetch the archived control messages for the current group.
3726 If given a prefix argument, prompt for a group."
3728 (list (or (when current-prefix-arg
3729 (completing-read "Group: " gnus-active-hashtb))
3730 (gnus-group-group-name)
3731 gnus-newsgroup-name)))
3733 (error "No group name given"))
3734 (let ((name (gnus-group-real-name group))
3736 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3737 (setq hierarchy (match-string 1 name))
3738 (if gnus-group-fetch-control-use-browse-url
3739 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3740 hierarchy "/" name ".gz"))
3741 (let ((enable-local-variables nil))
3742 (gnus-group-read-ephemeral-group
3744 `(nndoc ,group (nndoc-address
3745 ,(find-file-noselect
3746 (concat "/ftp@ftp.isc.org:/usenet/control/"
3747 hierarchy "/" name ".gz")))
3748 (nndoc-article-type mbox)) t nil nil))))))
3750 (defun gnus-group-describe-group (force &optional group)
3751 "Display a description of the current newsgroup."
3752 (interactive (list current-prefix-arg (gnus-group-group-name)))
3753 (let* ((method (gnus-find-method-for-group group))
3754 (mname (gnus-group-prefixed-name "" method))
3757 gnus-description-hashtb)
3758 (gnus-sethash mname nil gnus-description-hashtb))
3760 (error "No group name given"))
3761 (when (or (and gnus-description-hashtb
3762 ;; We check whether this group's method has been
3763 ;; queried for a description file.
3764 (gnus-gethash mname gnus-description-hashtb))
3765 (setq desc (gnus-group-get-description group))
3766 (gnus-read-descriptions-file method))
3768 (or desc (gnus-gethash group gnus-description-hashtb)
3769 "No description available")))))
3771 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3772 (defun gnus-group-describe-all-groups (&optional force)
3773 "Pop up a buffer with descriptions of all newsgroups."
3776 (setq gnus-description-hashtb nil))
3777 (when (not (or gnus-description-hashtb
3778 (gnus-read-all-descriptions-files)))
3779 (error "Couldn't request descriptions file"))
3780 (let ((buffer-read-only nil)
3786 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3787 (insert (format " *: %-20s %s\n"
3788 (gnus-group-name-decode
3789 (symbol-name group) charset)
3790 (gnus-group-name-decode
3791 (symbol-value group) charset))))
3792 (gnus-add-text-properties
3793 b (1+ b) (list 'gnus-group group
3794 'gnus-unread t 'gnus-marked nil
3795 'gnus-level (1+ gnus-level-subscribed))))
3796 gnus-description-hashtb)
3797 (goto-char (point-min))
3798 (gnus-group-position-point)))
3800 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3801 (defun gnus-group-apropos (regexp &optional search-description)
3802 "List all newsgroups that have names that match a regexp."
3803 (interactive "sGnus apropos (regexp): ")
3805 (obuf (current-buffer))
3807 ;; Go through all newsgroups that are known to Gnus.
3810 (and (symbol-name group)
3811 (string-match regexp (symbol-name group))
3812 (symbol-value group)
3813 (push (symbol-name group) groups)))
3815 ;; Also go through all descriptions that are known to Gnus.
3816 (when search-description
3819 (and (string-match regexp (symbol-value group))
3820 (push (symbol-name group) groups)))
3821 gnus-description-hashtb))
3823 (gnus-message 3 "No groups matched \"%s\"." regexp)
3824 ;; Print out all the groups.
3826 (pop-to-buffer "*Gnus Help*")
3827 (buffer-disable-undo)
3829 (setq groups (sort groups 'string<))
3831 ;; Groups may be entered twice into the list of groups.
3832 (when (not (string= (car groups) prev))
3833 (setq prev (car groups))
3834 (let ((charset (gnus-group-name-charset nil prev)))
3835 (insert (gnus-group-name-decode prev charset) "\n")
3836 (when (and gnus-description-hashtb
3837 (setq des (gnus-gethash (car groups)
3838 gnus-description-hashtb)))
3839 (insert " " (gnus-group-name-decode des charset) "\n"))))
3840 (setq groups (cdr groups)))
3841 (goto-char (point-min))))
3842 (pop-to-buffer obuf)))
3844 (defun gnus-group-description-apropos (regexp)
3845 "List all newsgroups that have names or descriptions that match REGEXP."
3846 (interactive "sGnus description apropos (regexp): ")
3847 (when (not (or gnus-description-hashtb
3848 (gnus-read-all-descriptions-files)))
3849 (error "Couldn't request descriptions file"))
3850 (gnus-group-apropos regexp t))
3852 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3853 (defun gnus-group-list-matching (level regexp &optional all lowest)
3854 "List all groups with unread articles that match REGEXP.
3855 If the prefix LEVEL is non-nil, it should be a number that says which
3856 level to cut off listing groups.
3857 If ALL, also list groups with no unread articles.
3858 If LOWEST, don't list groups with level lower than LOWEST.
3860 This command may read the active file."
3861 (interactive "P\nsList newsgroups matching: ")
3862 ;; First make sure active file has been read.
3864 (> (prefix-numeric-value level) gnus-level-killed))
3865 (gnus-get-killed-groups))
3866 (funcall gnus-group-prepare-function
3867 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3868 (goto-char (point-min))
3869 (gnus-group-position-point))
3871 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3872 "List all groups that match REGEXP.
3873 If the prefix LEVEL is non-nil, it should be a number that says which
3874 level to cut off listing groups.
3875 If LOWEST, don't list groups with level lower than LOWEST."
3876 (interactive "P\nsList newsgroups matching: ")
3878 (setq level (prefix-numeric-value level)))
3879 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3881 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3882 (defun gnus-group-save-newsrc (&optional force)
3883 "Save the Gnus startup files.
3884 If FORCE, force saving whether it is necessary or not."
3886 (gnus-save-newsrc-file force))
3888 (defun gnus-group-restart (&optional arg)
3889 "Force Gnus to read the .newsrc file."
3891 (when (gnus-yes-or-no-p
3892 (format "Are you sure you want to restart Gnus? "))
3893 (gnus-save-newsrc-file)
3897 (defun gnus-group-read-init-file ()
3898 "Read the Gnus elisp init file."
3900 (gnus-read-init-file)
3901 (gnus-message 5 "Read %s" gnus-init-file))
3903 (defun gnus-group-check-bogus-groups (&optional silent)
3904 "Check bogus newsgroups.
3905 If given a prefix, don't ask for confirmation before removing a bogus
3908 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3909 (gnus-group-list-groups))
3911 (defun gnus-group-find-new-groups (&optional arg)
3912 "Search for new groups and add them.
3913 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3914 With 1 C-u, use the `ask-server' method to query the server for new
3916 With 2 C-u's, use most complete method possible to query the server
3917 for new groups, and subscribe the new groups as zombies."
3919 (gnus-find-new-newsgroups (or arg 1))
3920 (gnus-group-list-groups))
3922 (defun gnus-group-edit-global-kill (&optional article group)
3923 "Edit the global kill file.
3924 If GROUP, edit that local kill file instead."
3926 (setq gnus-current-kill-article article)
3927 (gnus-kill-file-edit-file group)
3930 (substitute-command-keys
3931 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3932 (if group "local" "global")))))
3934 (defun gnus-group-edit-local-kill (article group)
3935 "Edit a local kill file."
3936 (interactive (list nil (gnus-group-group-name)))
3937 (gnus-group-edit-global-kill article group))
3939 (defun gnus-group-force-update ()
3940 "Update `.newsrc' file."
3942 (gnus-save-newsrc-file))
3944 (defvar gnus-backlog-articles)
3946 (defun gnus-group-suspend ()
3947 "Suspend the current Gnus session.
3948 In fact, cleanup buffers except for group mode buffer.
3949 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3951 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3952 (gnus-offer-save-summaries)
3953 ;; Kill Gnus buffers except for group mode buffer.
3954 (let ((group-buf (get-buffer gnus-group-buffer)))
3955 (mapcar (lambda (buf)
3956 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3960 (eq major-mode 'message-mode))))
3961 (gnus-kill-buffer buf)))
3963 (setq gnus-backlog-articles nil)
3964 (gnus-kill-gnus-frames)
3966 (bury-buffer group-buf)
3967 (delete-windows-on group-buf t))))
3969 (defun gnus-group-clear-dribble ()
3970 "Clear all information from the dribble buffer."
3972 (gnus-dribble-clear)
3973 (gnus-message 7 "Cleared dribble buffer"))
3975 (defun gnus-group-exit ()
3976 "Quit reading news after updating .newsrc.eld and .newsrc.
3977 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3980 (or noninteractive ;For gnus-batch-kill
3981 (not gnus-interactive-exit) ;Without confirmation
3983 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3984 (gnus-run-hooks 'gnus-exit-gnus-hook)
3985 ;; Offer to save data from non-quitted summary buffers.
3986 (gnus-offer-save-summaries)
3987 ;; Save the newsrc file(s).
3988 (gnus-save-newsrc-file)
3990 (gnus-close-backends)
3991 ;; Reset everything.
3993 ;; Allow the user to do things after cleaning up.
3994 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3996 (defun gnus-group-quit ()
3997 "Quit reading news without updating .newsrc.eld or .newsrc.
3998 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4000 (when (or noninteractive ;For gnus-batch-kill
4001 (zerop (buffer-size))
4002 (not (gnus-server-opened gnus-select-method))
4004 (not gnus-current-startup-file)
4006 (format "Quit reading news without saving %s? "
4007 (file-name-nondirectory gnus-current-startup-file))))
4008 (gnus-run-hooks 'gnus-exit-gnus-hook)
4009 (gnus-configure-windows 'group t)
4010 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4011 (not (zerop (save-excursion
4012 (set-buffer gnus-dribble-buffer)
4015 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4017 (gnus-close-backends)
4019 (gnus-kill-buffer gnus-group-buffer)
4020 ;; Allow the user to do things after cleaning up.
4021 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4023 (defun gnus-group-describe-briefly ()
4024 "Give a one line description of the group mode commands."
4026 (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")))
4028 (defun gnus-group-browse-foreign-server (method)
4029 "Browse a foreign news server.
4030 If called interactively, this function will ask for a select method
4031 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4032 If not, METHOD should be a list where the first element is the method
4033 and the second element is the address."
4035 (list (let ((how (completing-read
4037 (append gnus-valid-select-methods gnus-server-alist)
4038 nil t (cons "nntp" 0) 'gnus-method-history)))
4039 ;; We either got a back end name or a virtual server name.
4040 ;; If the first, we also need an address.
4041 (if (assoc how gnus-valid-select-methods)
4043 ;; Suggested by mapjph@bath.ac.uk.
4046 (mapcar (lambda (server) (list server))
4047 gnus-secondary-servers)))
4048 ;; We got a server name.
4050 (gnus-browse-foreign-server method))
4052 (defun gnus-group-set-info (info &optional method-only-group part)
4053 (when (or info part)
4054 (let* ((entry (gnus-gethash
4055 (or method-only-group (gnus-info-group info))
4056 gnus-newsrc-hashtb))
4058 (info (if method-only-group (nth 2 entry) info))
4060 (when method-only-group
4062 (error "Trying to change non-existent group %s" method-only-group))
4063 ;; We have received parts of the actual group info - either the
4064 ;; select method or the group parameters. We first check
4065 ;; whether we have to extend the info, and if so, do that.
4066 (let ((len (length info))
4067 (total (if (eq part 'method) 5 6)))
4069 (setcdr (nthcdr (1- len) info)
4070 (make-list (- total len) nil)))
4071 ;; Then we enter the new info.
4072 (setcar (nthcdr (1- total) info) part-info)))
4074 ;; This is a new group, so we just create it.
4076 (set-buffer gnus-group-buffer)
4077 (setq method (gnus-info-method info))
4078 (when (gnus-server-equal method "native")
4081 (set-buffer gnus-group-buffer)
4083 ;; It's a foreign group...
4084 (gnus-group-make-group
4085 (gnus-group-real-name (gnus-info-group info))
4086 (if (stringp method) method
4087 (prin1-to-string (car method)))
4089 (nth 1 (gnus-info-method info))))
4090 ;; It's a native group.
4091 (gnus-group-make-group (gnus-info-group info))))
4092 (gnus-message 6 "Note: New group created")
4094 (gnus-gethash (gnus-group-prefixed-name
4095 (gnus-group-real-name (gnus-info-group info))
4096 (or (gnus-info-method info) gnus-select-method))
4097 gnus-newsrc-hashtb))))
4098 ;; Whether it was a new group or not, we now have the entry, so we
4099 ;; can do the update.
4102 (setcar (nthcdr 2 entry) info)
4103 (when (and (not (eq (car entry) t))
4104 (gnus-active (gnus-info-group info)))
4105 (setcar entry (length
4106 (gnus-list-of-unread-articles (car info))))))
4107 (error "No such group: %s" (gnus-info-group info))))))
4109 (defun gnus-group-set-method-info (group select-method)
4110 (gnus-group-set-info select-method group 'method))
4112 (defun gnus-group-set-params-info (group params)
4113 (gnus-group-set-info params group 'params))
4115 (defun gnus-add-marked-articles (group type articles &optional info force)
4116 ;; Add ARTICLES of TYPE to the info of GROUP.
4117 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4118 ;; add, but replace marked articles of TYPE with ARTICLES.
4119 (let ((info (or info (gnus-get-info group)))
4122 (and (not (setq marked (nthcdr 3 info)))
4124 (setcdr (nthcdr 2 info)
4125 (list (list (cons type (gnus-compress-sequence
4127 (and (not (setq m (assq type (car marked))))
4130 (cons (cons type (gnus-compress-sequence articles t) )
4134 (setcar (nthcdr 3 info)
4135 (gnus-delete-alist type (car marked)))
4136 (setcdr m (gnus-compress-sequence articles t)))
4137 (setcdr m (gnus-compress-sequence
4138 (sort (nconc (gnus-uncompress-range (cdr m))
4139 (copy-sequence articles)) '<) t))))))
4141 (defun gnus-add-mark (group mark article)
4142 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4143 (let ((buffer (gnus-summary-buffer-name group)))
4144 (if (gnus-buffer-live-p buffer)
4146 (set-buffer (get-buffer buffer))
4147 (gnus-summary-add-mark article mark))
4148 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4152 ;;; Group timestamps
4155 (defun gnus-group-set-timestamp ()
4156 "Change the timestamp of the current group to the current time.
4157 This function can be used in hooks like `gnus-select-group-hook'
4158 or `gnus-group-catchup-group-hook'."
4159 (when gnus-newsgroup-name
4160 (let ((time (current-time)))
4161 (setcdr (cdr time) nil)
4162 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4164 (defsubst gnus-group-timestamp (group)
4165 "Return the timestamp for GROUP."
4166 (gnus-group-get-parameter group 'timestamp t))
4168 (defun gnus-group-timestamp-delta (group)
4169 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4170 (let* ((time (or (gnus-group-timestamp group)
4172 (delta (subtract-time (current-time) time)))
4173 (+ (* (nth 0 delta) 65536.0)
4176 (defun gnus-group-timestamp-string (group)
4177 "Return a string of the timestamp for GROUP."
4178 (let ((time (gnus-group-timestamp group)))
4181 (gnus-time-iso8601 time))))
4183 (defun gnus-group-list-cached (level &optional lowest)
4184 "List all groups with cached articles.
4185 If the prefix LEVEL is non-nil, it should be a number that says which
4186 level to cut off listing groups.
4187 If LOWEST, don't list groups with level lower than LOWEST.
4189 This command may read the active file."
4192 (setq level (prefix-numeric-value level)))
4193 (when (or (not level) (>= level gnus-level-zombie))
4195 (funcall gnus-group-prepare-function
4196 (or level gnus-level-subscribed)
4198 (let ((marks (gnus-info-marks info)))
4199 (assq 'cache marks)))
4202 (or (gnus-gethash group
4203 gnus-cache-active-hashtb)
4204 ;; Cache active file might use "."
4207 (mapconcat 'identity
4208 (split-string group ":")
4210 gnus-cache-active-hashtb))))
4211 (goto-char (point-min))
4212 (gnus-group-position-point))
4214 (defun gnus-group-list-dormant (level &optional lowest)
4215 "List all groups with dormant articles.
4216 If the prefix LEVEL is non-nil, it should be a number that says which
4217 level to cut off listing groups.
4218 If LOWEST, don't list groups with level lower than LOWEST.
4220 This command may read the active file."
4223 (setq level (prefix-numeric-value level)))
4224 (when (or (not level) (>= level gnus-level-zombie))
4226 (funcall gnus-group-prepare-function
4227 (or level gnus-level-subscribed)
4229 (let ((marks (gnus-info-marks info)))
4230 (assq 'dormant marks)))
4233 (goto-char (point-min))
4234 (gnus-group-position-point))
4236 (defun gnus-group-listed-groups ()
4237 "Return a list of listed groups."
4239 (goto-char (point-min))
4240 (while (setq point (text-property-not-all (point) (point-max)
4243 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4247 (defun gnus-group-list-plus (&optional args)
4248 "List groups plus the current selection."
4250 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4251 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4253 (push last-command-event unread-command-events)
4254 (if (featurep 'xemacs)
4255 (push (make-event 'key-press '(key ?A)) unread-command-events)
4256 (push ?A unread-command-events))
4257 (let (gnus-pick-mode keys)
4258 (setq keys (if (featurep 'xemacs)
4259 (events-to-keys (read-key-sequence nil))
4260 (read-key-sequence nil)))
4261 (setq func (lookup-key (current-local-map) keys)))
4265 (call-interactively func))))
4267 (defun gnus-group-list-flush (&optional args)
4268 "Flush groups from the current selection."
4270 (let ((gnus-group-list-option 'flush))
4271 (gnus-group-list-plus args)))
4273 (defun gnus-group-list-limit (&optional args)
4274 "List groups limited within the current selection."
4276 (let ((gnus-group-list-option 'limit))
4277 (gnus-group-list-plus args)))
4279 (defun gnus-group-mark-article-read (group article)
4280 "Mark ARTICLE read."
4281 (let ((buffer (gnus-summary-buffer-name group))
4282 (mark gnus-read-mark)
4284 (if (get-buffer buffer)
4285 (with-current-buffer buffer
4286 (setq active gnus-newsgroup-active)
4287 (gnus-activate-group group)
4288 (when gnus-newsgroup-prepared
4289 (when (and gnus-newsgroup-auto-expire
4290 (memq mark gnus-auto-expirable-marks))
4291 (setq mark gnus-expirable-mark))
4292 (setq mark (gnus-request-update-mark
4293 group article mark))
4294 (gnus-mark-article-as-read article mark)
4295 (setq gnus-newsgroup-active (gnus-active group))
4297 (setq n (1+ (cdr active)))
4298 (while (<= n (cdr gnus-newsgroup-active))
4299 (unless (eq n article)
4300 (push n gnus-newsgroup-unselected))
4302 (setq gnus-newsgroup-unselected
4303 (nreverse gnus-newsgroup-unselected)))))
4304 (gnus-activate-group group)
4305 (gnus-group-make-articles-read group (list article))
4306 (when (gnus-group-auto-expirable-p group)
4307 (gnus-add-marked-articles
4308 group 'expire (list article))))))
4310 (provide 'gnus-group)
4312 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4313 ;;; gnus-group.el ends here