1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
44 (eval-when-compile (require 'mm-url))
46 (defcustom gnus-group-archive-directory
47 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
48 "*The address of the (ding) archives."
49 :group 'gnus-group-foreign
52 (defcustom gnus-group-recent-archive-directory
53 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
54 "*The address of the most recent (ding) articles."
55 :group 'gnus-group-foreign
58 (defcustom gnus-no-groups-message "No Gnus is good news"
59 "*Message displayed by Gnus when no groups are available."
63 (defcustom gnus-keep-same-level nil
64 "*Non-nil means that the next newsgroup after the current will be on the same level.
65 When you type, for instance, `n' after reading the last article in the
66 current newsgroup, you will go to the next newsgroup. If this variable
67 is nil, the next newsgroup will be the next from the group
69 If this variable is non-nil, Gnus will either put you in the
70 next newsgroup with the same level, or, if no such newsgroup is
71 available, the next newsgroup with the lowest possible level higher
72 than the current level.
73 If this variable is `best', Gnus will make the next newsgroup the one
75 :group 'gnus-group-levels
76 :type '(choice (const nil)
78 (sexp :tag "other" t)))
80 (defcustom gnus-group-goto-unread t
81 "*If non-nil, movement commands will go to the next unread and subscribed group."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-group-various
86 (defcustom gnus-goto-next-group-when-activating t
87 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
88 :link '(custom-manual "(gnus)Scanning New Messages")
89 :group 'gnus-group-various
92 (defcustom gnus-permanently-visible-groups nil
93 "*Regexp to match groups that should always be listed in the group buffer.
94 This means that they will still be listed even when there are no
95 unread articles in the groups.
97 If nil, no groups are permanently visible."
98 :group 'gnus-group-listing
99 :type '(choice regexp (const nil)))
101 (defcustom gnus-list-groups-with-ticked-articles t
102 "*If non-nil, list groups that have only ticked articles.
103 If nil, only list groups that have unread articles."
104 :group 'gnus-group-listing
107 (defcustom gnus-group-default-list-level gnus-level-subscribed
108 "*Default listing level.
109 Ignored if `gnus-group-use-permanent-levels' is non-nil."
110 :group 'gnus-group-listing
113 (defcustom gnus-group-list-inactive-groups t
114 "*If non-nil, inactive groups will be listed."
115 :group 'gnus-group-listing
116 :group 'gnus-group-levels
119 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
120 "*Function used for sorting the group buffer.
121 This function will be called with group info entries as the arguments
122 for the groups to be sorted. Pre-made functions include
123 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
124 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
125 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
126 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
128 This variable can also be a list of sorting functions. In that case,
129 the most significant sort function should be the last function in the
131 :group 'gnus-group-listing
132 :link '(custom-manual "(gnus)Sorting Groups")
133 :type '(repeat :value-to-internal (lambda (widget value)
134 (if (listp value) value (list value)))
135 :match (lambda (widget value)
137 (widget-editable-list-match widget value)))
138 (choice (function-item gnus-group-sort-by-alphabet)
139 (function-item gnus-group-sort-by-real-name)
140 (function-item gnus-group-sort-by-unread)
141 (function-item gnus-group-sort-by-level)
142 (function-item gnus-group-sort-by-score)
143 (function-item gnus-group-sort-by-method)
144 (function-item gnus-group-sort-by-server)
145 (function-item gnus-group-sort-by-rank)
146 (function :tag "other" nil))))
148 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
149 "*Format of group lines.
150 It works along the same lines as a normal formatting string,
151 with some simple extensions.
153 %M Only marked articles (character, \"*\" or \" \")
154 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
155 %L Level of subscribedness (integer)
156 %N Number of unread articles (integer)
157 %I Number of dormant articles (integer)
158 %i Number of ticked and dormant (integer)
159 %T Number of ticked articles (integer)
160 %R Number of read articles (integer)
161 %U Number of unseen articles (integer)
162 %t Estimated total number of articles (integer)
163 %y Number of unread, unticked articles (integer)
164 %G Group name (string)
165 %g Qualified group name (string)
166 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
167 %C Group comment (string)
168 %D Group description (string)
169 %s Select method (string)
170 %o Moderated group (char, \"m\")
171 %p Process mark (char)
172 %B Whether a summary buffer for the group is open (char, \"*\")
173 %O Moderated group (string, \"(m)\" or \"\")
174 %P Topic indentation (string)
175 %m Whether there is new(ish) mail in the group (char, \"%\")
176 %n Select from where (string)
177 %z A string that look like `<%s:%n>' if a foreign select method is used
178 %d The date the group was last entered.
179 %E Icon as defined by `gnus-group-icon-list'.
180 %u User defined specifier. The next character in the format string should
181 be a letter. Gnus will call the function gnus-user-format-function-X,
182 where X is the letter following %u. The function will be passed a
183 single dummy parameter as argument. The function should return a
184 string, which will be inserted into the buffer just like information
185 from any other group specifier.
187 Note that this format specification is not always respected. For
188 reasons of efficiency, when listing killed groups, this specification
189 is ignored altogether. If the spec is changed considerably, your
190 output may end up looking strange when listing both alive and killed
193 If you use %o or %O, reading the active file will be slower and quite
194 a bit of extra memory will be used. %D will also worsen performance.
195 Also note that if you change the format specification to include any
196 of these specs, you must probably re-start Gnus to see them go into
199 General format specifiers can also be used.
200 See Info node `(gnus)Formatting Variables'."
201 :link '(custom-manual "(gnus)Formatting Variables")
202 :group 'gnus-group-visual
205 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
206 "*The format specification for the group mode line.
207 It works along the same lines as a normal formatting string,
208 with some simple extensions:
210 %S The native news server.
211 %M The native select method.
212 %: \":\" if %S isn't \"\"."
213 :group 'gnus-group-visual
216 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
217 (when (featurep 'xemacs)
218 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
219 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
221 (defcustom gnus-group-menu-hook nil
222 "Hook run after the creation of the group mode menu."
223 :group 'gnus-group-various
226 (defcustom gnus-group-catchup-group-hook nil
227 "Hook run when catching up a group from the group buffer."
228 :group 'gnus-group-various
229 :link '(custom-manual "(gnus)Group Data")
232 (defcustom gnus-group-update-group-hook nil
233 "Hook called when updating group lines."
234 :group 'gnus-group-visual
237 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
238 "*A function that is called to generate the group buffer.
239 The function is called with three arguments: The first is a number;
240 all group with a level less or equal to that number should be listed,
241 if the second is non-nil, empty groups should also be displayed. If
242 the third is non-nil, it is a number. No groups with a level lower
243 than this number should be displayed.
245 The only current function implemented is `gnus-group-prepare-flat'."
246 :group 'gnus-group-listing
249 (defcustom gnus-group-prepare-hook nil
250 "Hook called after the group buffer has been generated.
251 If you want to modify the group buffer, you can use this hook."
252 :group 'gnus-group-listing
255 (defcustom gnus-suspend-gnus-hook nil
256 "Hook called when suspending (not exiting) Gnus."
260 (defcustom gnus-exit-gnus-hook nil
261 "Hook called when exiting Gnus."
265 (defcustom gnus-after-exiting-gnus-hook nil
266 "Hook called after exiting Gnus."
270 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
271 "Hook called when a group line is changed.
272 The hook will not be called if `gnus-visual' is nil.
274 The default function `gnus-group-highlight-line' will
275 highlight the line according to the `gnus-group-highlight'
277 :group 'gnus-group-visual
280 (defcustom gnus-useful-groups
281 '(("(ding) mailing list mirrored at sunsite.auc.dk"
283 (nntp "sunsite.auc.dk"
284 (nntp-address "sunsite.auc.dk")))
287 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
291 (nndoc-article-type mbox)
292 (eval `(nndoc-address
293 ,(let ((file (nnheader-find-etc-directory
296 (error "Couldn't find doc group"))
298 "*Alist of useful group-server pairs."
299 :group 'gnus-group-listing
300 :type '(repeat (list (string :tag "Description")
302 (sexp :tag "Method"))))
304 (defcustom gnus-group-highlight
306 ((and mailp (= unread 0) (eq level 1)) .
307 gnus-group-mail-1-empty-face)
308 ((and mailp (eq level 1)) .
309 gnus-group-mail-1-face)
310 ((and mailp (= unread 0) (eq level 2)) .
311 gnus-group-mail-2-empty-face)
312 ((and mailp (eq level 2)) .
313 gnus-group-mail-2-face)
314 ((and mailp (= unread 0) (eq level 3)) .
315 gnus-group-mail-3-empty-face)
316 ((and mailp (eq level 3)) .
317 gnus-group-mail-3-face)
318 ((and mailp (= unread 0)) .
319 gnus-group-mail-low-empty-face)
321 gnus-group-mail-low-face)
323 ((and (= unread 0) (eq level 1)) .
324 gnus-group-news-1-empty-face)
325 ((and (eq level 1)) .
326 gnus-group-news-1-face)
327 ((and (= unread 0) (eq level 2)) .
328 gnus-group-news-2-empty-face)
329 ((and (eq level 2)) .
330 gnus-group-news-2-face)
331 ((and (= unread 0) (eq level 3)) .
332 gnus-group-news-3-empty-face)
333 ((and (eq level 3)) .
334 gnus-group-news-3-face)
335 ((and (= unread 0) (eq level 4)) .
336 gnus-group-news-4-empty-face)
337 ((and (eq level 4)) .
338 gnus-group-news-4-face)
339 ((and (= unread 0) (eq level 5)) .
340 gnus-group-news-5-empty-face)
341 ((and (eq level 5)) .
342 gnus-group-news-5-face)
343 ((and (= unread 0) (eq level 6)) .
344 gnus-group-news-6-empty-face)
345 ((and (eq level 6)) .
346 gnus-group-news-6-face)
347 ((and (= unread 0)) .
348 gnus-group-news-low-empty-face)
350 gnus-group-news-low-face))
351 "*Controls the highlighting of group buffer lines.
353 Below is a list of `Form'/`Face' pairs. When deciding how a a
354 particular group line should be displayed, each form is
355 evaluated. The content of the face field after the first true form is
356 used. You can change how those group lines are displayed by
357 editing the face field.
359 It is also possible to change and add form fields, but currently that
360 requires an understanding of Lisp expressions. Hopefully this will
361 change in a future release. For now, you can use the following
362 variables in the Lisp expression:
364 group: The name of the group.
365 unread: The number of unread articles in the group.
366 method: The select method used.
367 mailp: Whether it's a mail group or not.
368 level: The level of the group.
369 score: The score of the group.
370 ticked: The number of ticked articles."
371 :group 'gnus-group-visual
372 :type '(repeat (cons (sexp :tag "Form") face)))
374 (defcustom gnus-new-mail-mark ?%
375 "Mark used for groups with new mail."
376 :group 'gnus-group-visual
379 (defgroup gnus-group-icons nil
380 "Add Icons to your group buffer. "
381 :group 'gnus-group-visual)
383 (defcustom gnus-group-icon-list
385 "*Controls the insertion of icons into group buffer lines.
387 Below is a list of `Form'/`File' pairs. When deciding how a
388 particular group line should be displayed, each form is evaluated.
389 The icon from the file field after the first true form is used. You
390 can change how those group lines are displayed by editing the file
391 field. The File will either be found in the
392 `gnus-group-glyph-directory' or by designating absolute name of the
395 It is also possible to change and add form fields, but currently that
396 requires an understanding of Lisp expressions. Hopefully this will
397 change in a future release. For now, you can use the following
398 variables in the Lisp expression:
400 group: The name of the group.
401 unread: The number of unread articles in the group.
402 method: The select method used.
403 mailp: Whether it's a mail group or not.
404 newsp: Whether it's a news group or not
405 level: The level of the group.
406 score: The score of the group.
407 ticked: The number of ticked articles."
408 :group 'gnus-group-icons
409 :type '(repeat (cons (sexp :tag "Form") file)))
411 (defcustom gnus-group-name-charset-method-alist nil
412 "Alist of method and the charset for group names.
415 (((nntp \"news.com.cn\") . cn-gb-2312))"
418 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
420 (defcustom gnus-group-name-charset-group-alist
421 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
422 (mm-coding-system-p 'utf-8))
425 "Alist of group regexp and the charset for group names.
428 ((\"\\.com\\.cn:\" . cn-gb-2312))"
430 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
432 (defcustom gnus-group-jump-to-group-prompt nil
433 "Default prompt for `gnus-group-jump-to-group'.
434 If non-nil, the value should be a string, e.g. \"nnml:\",
435 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
436 in the minibuffer prompt."
437 :group 'gnus-group-various
438 :type '(choice (string :tag "Prompt string")
439 (const :tag "Empty" nil)))
441 (defvar gnus-group-listing-limit 1000
442 "*A limit of the number of groups when listing.
443 If the number of groups is larger than the limit, list them in a
446 ;;; Internal variables
448 (defvar gnus-group-is-exiting-p nil)
449 (defvar gnus-group-is-exiting-without-update-p nil)
450 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
451 "Function for sorting the group buffer.")
453 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
454 "Function for sorting the selected groups in the group buffer.")
456 (defvar gnus-group-indentation-function nil)
457 (defvar gnus-goto-missing-group-function nil)
458 (defvar gnus-group-update-group-function nil)
459 (defvar gnus-group-goto-next-group-function nil
460 "Function to override finding the next group after listing groups.")
462 (defvar gnus-group-edit-buffer nil)
464 (defvar gnus-group-line-format-alist
465 `((?M gnus-tmp-marked-mark ?c)
466 (?S gnus-tmp-subscribed ?c)
467 (?L gnus-tmp-level ?d)
468 (?N (cond ((eq number t) "*" )
472 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
473 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
475 (?R gnus-tmp-number-of-read ?s)
476 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
477 (?t gnus-tmp-number-total ?d)
478 (?y gnus-tmp-number-of-unread ?s)
479 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
480 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
481 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
482 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
483 (?g gnus-tmp-group ?s)
484 (?G gnus-tmp-qualified-group ?s)
485 (?c (gnus-short-group-name gnus-tmp-group) ?s)
486 (?C gnus-tmp-comment ?s)
487 (?D gnus-tmp-newsgroup-description ?s)
488 (?o gnus-tmp-moderated ?c)
489 (?O gnus-tmp-moderated-string ?s)
490 (?p gnus-tmp-process-marked ?c)
491 (?s gnus-tmp-news-server ?s)
492 (?n gnus-tmp-news-method ?s)
493 (?P gnus-group-indentation ?s)
494 (?E gnus-tmp-group-icon ?s)
495 (?B gnus-tmp-summary-live ?c)
496 (?z gnus-tmp-news-method-string ?s)
497 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
498 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
499 (?u gnus-tmp-user-defined ?s)))
501 (defvar gnus-group-mode-line-format-alist
502 `((?S gnus-tmp-news-server ?s)
503 (?M gnus-tmp-news-method ?s)
504 (?u gnus-tmp-user-defined ?s)
505 (?: gnus-tmp-colon ?s)))
507 (defvar gnus-topic-topology nil
508 "The complete topic hierarchy.")
510 (defvar gnus-topic-alist nil
511 "The complete topic-group alist.")
513 (defvar gnus-group-marked nil)
515 (defvar gnus-group-list-mode nil)
518 (defvar gnus-group-icon-cache nil)
520 (defvar gnus-group-listed-groups nil)
521 (defvar gnus-group-list-option nil)
527 (put 'gnus-group-mode 'mode-class 'special)
529 (gnus-define-keys gnus-group-mode-map
530 " " gnus-group-read-group
531 "=" gnus-group-select-group
532 "\r" gnus-group-select-group
533 "\M-\r" gnus-group-quick-select-group
534 "\M- " gnus-group-visible-select-group
535 [(meta control return)] gnus-group-select-group-ephemerally
536 "j" gnus-group-jump-to-group
537 "n" gnus-group-next-unread-group
538 "p" gnus-group-prev-unread-group
539 "\177" gnus-group-prev-unread-group
540 [delete] gnus-group-prev-unread-group
541 [backspace] gnus-group-prev-unread-group
542 "N" gnus-group-next-group
543 "P" gnus-group-prev-group
544 "\M-n" gnus-group-next-unread-group-same-level
545 "\M-p" gnus-group-prev-unread-group-same-level
546 "," gnus-group-best-unread-group
547 "." gnus-group-first-unread-group
548 "u" gnus-group-unsubscribe-current-group
549 "U" gnus-group-unsubscribe-group
550 "c" gnus-group-catchup-current
551 "C" gnus-group-catchup-current-all
552 "\M-c" gnus-group-clear-data
553 "l" gnus-group-list-groups
554 "L" gnus-group-list-all-groups
557 "g" gnus-group-get-new-news
558 "\M-g" gnus-group-get-new-news-this-group
559 "R" gnus-group-restart
560 "r" gnus-group-read-init-file
561 "B" gnus-group-browse-foreign-server
562 "b" gnus-group-check-bogus-groups
563 "F" gnus-group-find-new-groups
564 "\C-c\C-d" gnus-group-describe-group
565 "\M-d" gnus-group-describe-all-groups
566 "\C-c\C-a" gnus-group-apropos
567 "\C-c\M-\C-a" gnus-group-description-apropos
568 "a" gnus-group-post-news
569 "\ek" gnus-group-edit-local-kill
570 "\eK" gnus-group-edit-global-kill
571 "\C-k" gnus-group-kill-group
572 "\C-y" gnus-group-yank-group
573 "\C-w" gnus-group-kill-region
574 "\C-x\C-t" gnus-group-transpose-groups
575 "\C-c\C-l" gnus-group-list-killed
576 "\C-c\C-x" gnus-group-expire-articles
577 "\C-c\M-\C-x" gnus-group-expire-all-groups
579 "s" gnus-group-save-newsrc
580 "z" gnus-group-suspend
583 "?" gnus-group-describe-briefly
584 "\C-c\C-i" gnus-info-find-node
585 "\M-e" gnus-group-edit-group-method
586 "^" gnus-group-enter-server-mode
587 gnus-mouse-2 gnus-mouse-pick-group
588 "<" beginning-of-buffer
591 "\C-c\C-s" gnus-group-sort-groups
593 "\C-c\M-g" gnus-activate-all-groups
594 "\M-&" gnus-group-universal-argument
595 "#" gnus-group-mark-group
596 "\M-#" gnus-group-unmark-group)
598 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
599 "m" gnus-group-mark-group
600 "u" gnus-group-unmark-group
601 "w" gnus-group-mark-region
602 "b" gnus-group-mark-buffer
603 "r" gnus-group-mark-regexp
604 "U" gnus-group-unmark-all-groups)
606 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
607 "u" gnus-sieve-update
608 "g" gnus-sieve-generate)
610 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
611 "d" gnus-group-make-directory-group
612 "h" gnus-group-make-help-group
613 "u" gnus-group-make-useful-group
614 "a" gnus-group-make-archive-group
615 "k" gnus-group-make-kiboze-group
616 "l" gnus-group-nnimap-edit-acl
617 "m" gnus-group-make-group
618 "E" gnus-group-edit-group
619 "e" gnus-group-edit-group-method
620 "p" gnus-group-edit-group-parameters
621 "v" gnus-group-add-to-virtual
622 "V" gnus-group-make-empty-virtual
623 "D" gnus-group-enter-directory
624 "f" gnus-group-make-doc-group
625 "w" gnus-group-make-web-group
626 "M" gnus-group-read-ephemeral-group
627 "r" gnus-group-rename-group
628 "R" gnus-group-make-rss-group
629 "c" gnus-group-customize
630 "x" gnus-group-nnimap-expunge
631 "\177" gnus-group-delete-group
632 [delete] gnus-group-delete-group)
634 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
635 "b" gnus-group-brew-soup
636 "w" gnus-soup-save-areas
637 "s" gnus-soup-send-replies
638 "p" gnus-soup-pack-packet
639 "r" nnsoup-pack-replies)
641 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
642 "s" gnus-group-sort-groups
643 "a" gnus-group-sort-groups-by-alphabet
644 "u" gnus-group-sort-groups-by-unread
645 "l" gnus-group-sort-groups-by-level
646 "v" gnus-group-sort-groups-by-score
647 "r" gnus-group-sort-groups-by-rank
648 "m" gnus-group-sort-groups-by-method
649 "n" gnus-group-sort-groups-by-real-name)
651 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
652 "s" gnus-group-sort-selected-groups
653 "a" gnus-group-sort-selected-groups-by-alphabet
654 "u" gnus-group-sort-selected-groups-by-unread
655 "l" gnus-group-sort-selected-groups-by-level
656 "v" gnus-group-sort-selected-groups-by-score
657 "r" gnus-group-sort-selected-groups-by-rank
658 "m" gnus-group-sort-selected-groups-by-method
659 "n" gnus-group-sort-selected-groups-by-real-name)
661 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
662 "k" gnus-group-list-killed
663 "z" gnus-group-list-zombies
664 "s" gnus-group-list-groups
665 "u" gnus-group-list-all-groups
666 "A" gnus-group-list-active
667 "a" gnus-group-apropos
668 "d" gnus-group-description-apropos
669 "m" gnus-group-list-matching
670 "M" gnus-group-list-all-matching
671 "l" gnus-group-list-level
672 "c" gnus-group-list-cached
673 "?" gnus-group-list-dormant)
675 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
676 "k" gnus-group-list-limit
677 "z" gnus-group-list-limit
678 "s" gnus-group-list-limit
679 "u" gnus-group-list-limit
680 "A" gnus-group-list-limit
681 "m" gnus-group-list-limit
682 "M" gnus-group-list-limit
683 "l" gnus-group-list-limit
684 "c" gnus-group-list-limit
685 "?" gnus-group-list-limit)
687 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
688 "k" gnus-group-list-flush
689 "z" gnus-group-list-flush
690 "s" gnus-group-list-flush
691 "u" gnus-group-list-flush
692 "A" gnus-group-list-flush
693 "m" gnus-group-list-flush
694 "M" gnus-group-list-flush
695 "l" gnus-group-list-flush
696 "c" gnus-group-list-flush
697 "?" gnus-group-list-flush)
699 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
700 "k" gnus-group-list-plus
701 "z" gnus-group-list-plus
702 "s" gnus-group-list-plus
703 "u" gnus-group-list-plus
704 "A" gnus-group-list-plus
705 "m" gnus-group-list-plus
706 "M" gnus-group-list-plus
707 "l" gnus-group-list-plus
708 "c" gnus-group-list-plus
709 "?" gnus-group-list-plus)
711 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
712 "f" gnus-score-flush-cache
713 "e" gnus-score-edit-all-score)
715 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
716 "c" gnus-group-fetch-charter
717 "C" gnus-group-fetch-control
718 "d" gnus-group-describe-group
719 "f" gnus-group-fetch-faq
722 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
723 "l" gnus-group-set-current-level
724 "t" gnus-group-unsubscribe-current-group
725 "s" gnus-group-unsubscribe-group
726 "k" gnus-group-kill-group
727 "y" gnus-group-yank-group
728 "w" gnus-group-kill-region
729 "\C-k" gnus-group-kill-level
730 "z" gnus-group-kill-all-zombies)
732 (defun gnus-topic-mode-p ()
733 "Return non-nil in `gnus-topic-mode'."
734 (and (boundp 'gnus-topic-mode)
735 (symbol-value 'gnus-topic-mode)))
737 (defun gnus-group-make-menu-bar ()
738 (gnus-turn-off-edit-menu 'group)
739 (unless (boundp 'gnus-group-reading-menu)
742 gnus-group-reading-menu gnus-group-mode-map ""
744 ["Read" gnus-group-read-group
745 :included (not (gnus-topic-mode-p))
746 :active (gnus-group-group-name)]
747 ["Read " gnus-topic-read-group
748 :included (gnus-topic-mode-p)]
749 ["Select" gnus-group-select-group
750 :included (not (gnus-topic-mode-p))
751 :active (gnus-group-group-name)]
752 ["Select " gnus-topic-select-group
753 :included (gnus-topic-mode-p)]
754 ["See old articles" (gnus-group-select-group 'all)
755 :keys "C-u SPC" :active (gnus-group-group-name)]
756 ["Catch up" gnus-group-catchup-current
757 :included (not (gnus-topic-mode-p))
758 :active (gnus-group-group-name)
759 ,@(if (featurep 'xemacs) nil
760 '(:help "Mark unread articles in the current group as read"))]
761 ["Catch up " gnus-topic-catchup-articles
762 :included (gnus-topic-mode-p)
763 ,@(if (featurep 'xemacs) nil
764 '(:help "Mark unread articles in the current group or topic as read"))]
765 ["Catch up all articles" gnus-group-catchup-current-all
766 (gnus-group-group-name)]
767 ["Check for new articles" gnus-group-get-new-news-this-group
768 :included (not (gnus-topic-mode-p))
769 :active (gnus-group-group-name)
770 ,@(if (featurep 'xemacs) nil
771 '(:help "Check for new messages in current group"))]
772 ["Check for new articles " gnus-topic-get-new-news-this-topic
773 :included (gnus-topic-mode-p)
774 ,@(if (featurep 'xemacs) nil
775 '(:help "Check for new messages in current group or topic"))]
776 ["Toggle subscription" gnus-group-unsubscribe-current-group
777 (gnus-group-group-name)]
778 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
779 ,@(if (featurep 'xemacs) nil
780 '(:help "Kill (remove) current group"))]
781 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
782 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
783 ,@(if (featurep 'xemacs) nil
784 '(:help "Display description of the current group"))]
785 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
786 ["Fetch charter" gnus-group-fetch-charter
787 :active (gnus-group-group-name)
788 ,@(if (featurep 'xemacs) nil
789 '(:help "Display the charter of the current group"))]
790 ["Fetch control message" gnus-group-fetch-control
791 :active (gnus-group-group-name)
792 ,@(if (featurep 'xemacs) nil
793 '(:help "Display the archived control message for the current group"))]
794 ;; Actually one should check, if any of the marked groups gives t for
795 ;; (gnus-check-backend-function 'request-expire-articles ...)
796 ["Expire articles" gnus-group-expire-articles
797 :included (not (gnus-topic-mode-p))
798 :active (or (and (gnus-group-group-name)
799 (gnus-check-backend-function
800 'request-expire-articles
801 (gnus-group-group-name))) gnus-group-marked)]
802 ["Expire articles " gnus-topic-expire-articles
803 :included (gnus-topic-mode-p)]
804 ["Set group level..." gnus-group-set-current-level
805 (gnus-group-group-name)]
806 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
807 ["Customize" gnus-group-customize (gnus-group-group-name)]
809 ["Parameters" gnus-group-edit-group-parameters
810 :included (not (gnus-topic-mode-p))
811 :active (gnus-group-group-name)]
812 ["Parameters " gnus-topic-edit-parameters
813 :included (gnus-topic-mode-p)]
814 ["Select method" gnus-group-edit-group-method
815 (gnus-group-group-name)]
816 ["Info" gnus-group-edit-group (gnus-group-group-name)]
817 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
818 ["Global kill file" gnus-group-edit-global-kill t])))
821 gnus-group-group-menu gnus-group-mode-map ""
824 ["List unread subscribed groups" gnus-group-list-groups t]
825 ["List (un)subscribed groups" gnus-group-list-all-groups t]
826 ["List killed groups" gnus-group-list-killed gnus-killed-list]
827 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
828 ["List level..." gnus-group-list-level t]
829 ["Describe all groups" gnus-group-describe-all-groups t]
830 ["Group apropos..." gnus-group-apropos t]
831 ["Group and description apropos..." gnus-group-description-apropos t]
832 ["List groups matching..." gnus-group-list-matching t]
833 ["List all groups matching..." gnus-group-list-all-matching t]
834 ["List active file" gnus-group-list-active t]
835 ["List groups with cached" gnus-group-list-cached t]
836 ["List groups with dormant" gnus-group-list-dormant t])
838 ["Default sort" gnus-group-sort-groups t]
839 ["Sort by method" gnus-group-sort-groups-by-method t]
840 ["Sort by rank" gnus-group-sort-groups-by-rank t]
841 ["Sort by score" gnus-group-sort-groups-by-score t]
842 ["Sort by level" gnus-group-sort-groups-by-level t]
843 ["Sort by unread" gnus-group-sort-groups-by-unread t]
844 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
845 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
846 ("Sort process/prefixed"
847 ["Default sort" gnus-group-sort-selected-groups
848 (not (gnus-topic-mode-p))]
849 ["Sort by method" gnus-group-sort-selected-groups-by-method
850 (not (gnus-topic-mode-p))]
851 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
852 (not (gnus-topic-mode-p))]
853 ["Sort by score" gnus-group-sort-selected-groups-by-score
854 (not (gnus-topic-mode-p))]
855 ["Sort by level" gnus-group-sort-selected-groups-by-level
856 (not (gnus-topic-mode-p))]
857 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
858 (not (gnus-topic-mode-p))]
859 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
860 (not (gnus-topic-mode-p))]
861 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
862 (not (gnus-topic-mode-p))])
864 ["Mark group" gnus-group-mark-group
865 (and (gnus-group-group-name)
866 (not (memq (gnus-group-group-name) gnus-group-marked)))]
867 ["Unmark group" gnus-group-unmark-group
868 (and (gnus-group-group-name)
869 (memq (gnus-group-group-name) gnus-group-marked))]
870 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
871 ["Mark regexp..." gnus-group-mark-regexp t]
872 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
873 ["Mark buffer" gnus-group-mark-buffer t]
874 ["Execute command" gnus-group-universal-argument
875 (or gnus-group-marked (gnus-group-group-name))])
877 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
878 ["Kill all newsgroups in region" gnus-group-kill-region
879 :active (gnus-mark-active-p)]
880 ["Kill all zombie groups" gnus-group-kill-all-zombies
882 ["Kill all groups on level..." gnus-group-kill-level t])
884 ["Make a foreign group..." gnus-group-make-group t]
885 ["Add a directory group..." gnus-group-make-directory-group t]
886 ["Add the help group" gnus-group-make-help-group t]
887 ["Add the archive group" gnus-group-make-archive-group t]
888 ["Make a doc group..." gnus-group-make-doc-group t]
889 ["Make a web group..." gnus-group-make-web-group t]
890 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
891 ["Make a virtual group..." gnus-group-make-empty-virtual t]
892 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
893 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
894 ["Make an RSS group..." gnus-group-make-rss-group t]
895 ["Rename group..." gnus-group-rename-group
896 (gnus-check-backend-function
897 'request-rename-group (gnus-group-group-name))]
898 ["Delete group" gnus-group-delete-group
899 (gnus-check-backend-function
900 'request-delete-group (gnus-group-group-name))])
902 ["Next" gnus-group-next-group t]
903 ["Previous" gnus-group-prev-group t]
904 ["Next unread" gnus-group-next-unread-group t]
905 ["Previous unread" gnus-group-prev-unread-group t]
906 ["Next unread same level" gnus-group-next-unread-group-same-level t]
907 ["Previous unread same level"
908 gnus-group-prev-unread-group-same-level t]
909 ["Jump to group..." gnus-group-jump-to-group t]
910 ["First unread group" gnus-group-first-unread-group t]
911 ["Best unread group" gnus-group-best-unread-group t])
913 ["Generate" gnus-sieve-generate t]
914 ["Generate and update" gnus-sieve-update t])
915 ["Delete bogus groups" gnus-group-check-bogus-groups t]
916 ["Find new newsgroups" gnus-group-find-new-groups t]
917 ["Transpose" gnus-group-transpose-groups
918 (gnus-group-group-name)]
919 ["Read a directory as a group..." gnus-group-enter-directory t]))
922 gnus-group-misc-menu gnus-group-mode-map ""
925 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
926 ["Send replies" gnus-soup-send-replies
927 (fboundp 'gnus-soup-pack-packet)]
928 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
929 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
930 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
931 ["Send a mail" gnus-group-mail t]
932 ["Send a message (mail or news)" gnus-group-post-news t]
933 ["Create a local message" gnus-group-news t]
934 ["Check for new news" gnus-group-get-new-news
935 ,@(if (featurep 'xemacs) '(t)
936 '(:help "Get newly arrived articles"))
938 ["Send queued messages" gnus-delay-send-queue
939 ,@(if (featurep 'xemacs) '(t)
940 '(:help "Send all messages that are scheduled to be sent now"))
942 ["Activate all groups" gnus-activate-all-groups t]
943 ["Restart Gnus" gnus-group-restart t]
944 ["Read init file" gnus-group-read-init-file t]
945 ["Browse foreign server..." gnus-group-browse-foreign-server t]
946 ["Enter server buffer" gnus-group-enter-server-mode t]
947 ["Expire all expirable articles" gnus-group-expire-all-groups t]
948 ["Generate any kiboze groups" nnkiboze-generate-groups t]
949 ["Gnus version" gnus-version t]
950 ["Save .newsrc files" gnus-group-save-newsrc t]
951 ["Suspend Gnus" gnus-group-suspend t]
952 ["Clear dribble buffer" gnus-group-clear-dribble t]
953 ["Read manual" gnus-info-find-node t]
954 ["Flush score cache" gnus-score-flush-cache t]
955 ["Toggle topics" gnus-topic-mode t]
956 ["Send a bug report" gnus-bug t]
957 ["Exit from Gnus" gnus-group-exit
958 ,@(if (featurep 'xemacs) '(t)
959 '(:help "Quit reading news"))]
960 ["Exit without saving" gnus-group-quit t]))
962 (gnus-run-hooks 'gnus-group-menu-hook)))
964 (defvar gnus-group-toolbar-map nil)
966 ;; Emacs 21 tool bar. Should be no-op otherwise.
967 (defun gnus-group-make-tool-bar ()
969 (condition-case nil (require 'tool-bar) (error nil))
970 (fboundp 'tool-bar-add-item-from-menu)
971 (default-value 'tool-bar-mode)
972 (not gnus-group-toolbar-map))
973 (setq gnus-group-toolbar-map
974 (let ((tool-bar-map (make-sparse-keymap))
975 (load-path (mm-image-load-path)))
976 (tool-bar-add-item-from-menu
977 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
978 (tool-bar-add-item-from-menu
979 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
980 (tool-bar-add-item-from-menu
981 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
982 (tool-bar-add-item-from-menu
983 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
984 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
985 :help "Subscribe to the current group")
986 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
988 :help "Unsubscribe from the current group")
989 (tool-bar-add-item-from-menu
990 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
992 (if gnus-group-toolbar-map
993 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
995 (defun gnus-group-mode ()
996 "Major mode for reading news.
998 All normal editing commands are switched off.
999 \\<gnus-group-mode-map>
1000 The group buffer lists (some of) the groups available. For instance,
1001 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1002 lists all zombie groups.
1004 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1005 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1007 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1009 The following commands are available:
1011 \\{gnus-group-mode-map}"
1013 (kill-all-local-variables)
1014 (when (gnus-visual-p 'group-menu 'menu)
1015 (gnus-group-make-menu-bar)
1016 (gnus-group-make-tool-bar))
1017 (gnus-simplify-mode-line)
1018 (setq major-mode 'gnus-group-mode)
1019 (setq mode-name "Group")
1020 (gnus-group-set-mode-line)
1021 (setq mode-line-process nil)
1022 (use-local-map gnus-group-mode-map)
1023 (buffer-disable-undo)
1024 (setq truncate-lines t)
1025 (setq buffer-read-only t)
1026 (gnus-set-default-directory)
1027 (gnus-update-format-specifications nil 'group 'group-mode)
1028 (gnus-update-group-mark-positions)
1033 (gnus-run-hooks 'gnus-group-mode-hook))
1035 (defun gnus-update-group-mark-positions ()
1037 (let ((gnus-process-mark ?\200)
1038 (gnus-group-update-hook nil)
1039 (gnus-group-marked '("dummy.group"))
1040 (gnus-active-hashtb (make-vector 10 0))
1042 (gnus-set-active "dummy.group" '(0 . 0))
1043 (gnus-set-work-buffer)
1044 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1045 (goto-char (point-min))
1046 (setq gnus-group-mark-positions
1047 (list (cons 'process (and (search-forward "\200" nil t)
1048 (- (point) 2))))))))
1050 (defun gnus-mouse-pick-group (e)
1051 "Enter the group under the mouse pointer."
1054 (gnus-group-read-group nil))
1056 ;; Look at LEVEL and find out what the level is really supposed to be.
1057 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1058 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1059 (defun gnus-group-default-level (&optional level number-or-nil)
1061 (gnus-group-use-permanent-levels
1062 (or (setq gnus-group-use-permanent-levels
1063 (or level (if (numberp gnus-group-use-permanent-levels)
1064 gnus-group-use-permanent-levels
1065 (or gnus-group-default-list-level
1066 gnus-level-subscribed))))
1067 gnus-group-default-list-level gnus-level-subscribed))
1071 (or level gnus-group-default-list-level gnus-level-subscribed))))
1073 (defun gnus-group-setup-buffer ()
1074 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1075 (unless (eq major-mode 'gnus-group-mode)
1078 (gnus-carpal-setup-buffer 'group))))
1080 (defun gnus-group-name-charset (method group)
1082 (setq method (gnus-find-method-for-group group)))
1083 (let ((item (assoc method gnus-group-name-charset-method-alist))
1084 (alist gnus-group-name-charset-group-alist)
1088 (while (setq item (pop alist))
1089 (if (string-match (car item) group)
1091 result (cdr item))))
1094 (defun gnus-group-name-decode (string charset)
1095 ;; Fixme: Don't decode in unibyte mode.
1096 (if (and string charset (featurep 'mule))
1097 (mm-decode-coding-string string charset)
1100 (defun gnus-group-decoded-name (string)
1101 (let ((charset (gnus-group-name-charset nil string)))
1102 (gnus-group-name-decode string charset)))
1104 (defun gnus-group-list-groups (&optional level unread lowest)
1105 "List newsgroups with level LEVEL or lower that have unread articles.
1106 Default is all subscribed groups.
1107 If argument UNREAD is non-nil, groups with no unread articles are also
1110 Also see the `gnus-group-use-permanent-levels' variable."
1112 (list (if current-prefix-arg
1113 (prefix-numeric-value current-prefix-arg)
1115 (gnus-group-default-level nil t)
1116 gnus-group-default-list-level
1117 gnus-level-subscribed))))
1119 (setq level (car gnus-group-list-mode)
1120 unread (cdr gnus-group-list-mode)))
1121 (setq level (gnus-group-default-level level))
1122 (gnus-group-setup-buffer)
1123 (gnus-update-format-specifications nil 'group 'group-mode)
1124 (let ((case-fold-search nil)
1125 (props (text-properties-at (point-at-bol)))
1126 (empty (= (point-min) (point-max)))
1127 (group (gnus-group-group-name))
1129 (set-buffer gnus-group-buffer)
1130 (setq number (funcall gnus-group-prepare-function level unread lowest))
1131 (when (or (and (numberp number)
1133 (zerop (buffer-size)))
1134 ;; No groups in the buffer.
1135 (gnus-message 5 gnus-no-groups-message))
1136 ;; We have some groups displayed.
1137 (goto-char (point-max))
1138 (when (or (not gnus-group-goto-next-group-function)
1139 (not (funcall gnus-group-goto-next-group-function
1143 (goto-char (point-min)))
1145 ;; Go to the first group with unread articles.
1146 (gnus-group-search-forward t))
1148 ;; Find the right group to put point on. If the current group
1149 ;; has disappeared in the new listing, try to find the next
1150 ;; one. If no next one can be found, just leave point at the
1151 ;; first newsgroup in the buffer.
1152 (when (not (gnus-goto-char
1154 (point-min) (point-max)
1155 'gnus-group (gnus-intern-safe
1156 group gnus-active-hashtb))))
1157 (let ((newsrc (cdddr (gnus-group-entry group))))
1159 (not (gnus-goto-char
1161 (point-min) (point-max) 'gnus-group
1163 (caar newsrc) gnus-active-hashtb)))))
1164 (setq newsrc (cdr newsrc)))
1166 (goto-char (point-max))
1167 (forward-line -1)))))))
1168 ;; Adjust cursor point.
1169 (gnus-group-position-point)))
1171 (defun gnus-group-list-level (level &optional all)
1172 "List groups on LEVEL.
1173 If ALL (the prefix), also list groups that have no unread articles."
1174 (interactive "nList groups on level: \nP")
1175 (gnus-group-list-groups level all level))
1177 (defun gnus-group-prepare-logic (group test)
1178 (or (and gnus-group-listed-groups
1179 (null gnus-group-list-option)
1180 (member group gnus-group-listed-groups))
1182 ((null gnus-group-listed-groups) test)
1183 ((null gnus-group-list-option) test)
1184 (t (and (member group gnus-group-listed-groups)
1185 (if (eq gnus-group-list-option 'flush)
1189 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1190 "List all newsgroups with unread articles of level LEVEL or lower.
1191 If PREDICATE is a function, list groups that the function returns non-nil;
1192 if it is t, list groups that have no unread articles.
1193 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1194 If REGEXP is a function, list dead groups that the function returns non-nil;
1195 if it is a string, only list groups matching REGEXP."
1196 (set-buffer gnus-group-buffer)
1197 (let ((buffer-read-only nil)
1198 (newsrc (cdr gnus-newsrc-alist))
1199 (lowest (or lowest 1))
1200 (not-in-list (and gnus-group-listed-groups
1201 (copy-sequence gnus-group-listed-groups)))
1202 info clevel unread group params)
1204 (when (or (< lowest gnus-level-zombie)
1205 gnus-group-listed-groups)
1206 ;; List living groups.
1208 (setq info (car newsrc)
1209 group (gnus-info-group info)
1210 params (gnus-info-params info)
1212 unread (gnus-group-unread group))
1214 (setq not-in-list (delete group not-in-list)))
1215 (when (gnus-group-prepare-logic
1217 (and unread ; This group might be unchecked
1218 (or (not (stringp regexp))
1219 (string-match regexp group))
1220 (<= (setq clevel (gnus-info-level info)) level)
1223 ((functionp predicate)
1224 (funcall predicate info))
1225 (predicate t) ; We list all groups?
1228 (if (eq unread t) ; Unactivated?
1229 gnus-group-list-inactive-groups
1230 ; We list unactivated
1232 ; We list groups with unread articles
1233 (and gnus-list-groups-with-ticked-articles
1234 (cdr (assq 'tick (gnus-info-marks info))))
1235 ; And groups with tickeds
1236 ;; Check for permanent visibility.
1237 (and gnus-permanently-visible-groups
1238 (string-match gnus-permanently-visible-groups
1240 (memq 'visible params)
1241 (cdr (assq 'visible params)))))))
1242 (gnus-group-insert-group-line
1243 group (gnus-info-level info)
1244 (gnus-info-marks info) unread (gnus-info-method info)))))
1246 ;; List dead groups.
1247 (when (or gnus-group-listed-groups
1248 (and (>= level gnus-level-zombie)
1249 (<= lowest gnus-level-zombie)))
1250 (gnus-group-prepare-flat-list-dead
1251 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1252 gnus-level-zombie ?Z
1255 (dolist (group gnus-zombie-list)
1256 (setq not-in-list (delete group not-in-list))))
1257 (when (or gnus-group-listed-groups
1258 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1259 (gnus-group-prepare-flat-list-dead
1262 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1263 gnus-level-killed ?K regexp))
1265 (gnus-group-set-mode-line)
1266 (setq gnus-group-list-mode (cons level predicate))
1267 (gnus-run-hooks 'gnus-group-prepare-hook)
1270 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1271 ;; List zombies and killed lists somewhat faster, which was
1272 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1273 ;; this by ignoring the group format specification altogether.
1275 (if (> (length groups) gnus-group-listing-limit)
1277 (setq group (pop groups))
1278 (when (gnus-group-prepare-logic
1281 (and (stringp regexp) (string-match regexp group))
1282 (and (functionp regexp) (funcall regexp group))))
1283 (gnus-add-text-properties
1284 (point) (prog1 (1+ (point))
1285 (insert " " mark " *: "
1286 (gnus-group-decoded-name group)
1288 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1290 'gnus-level level))))
1292 (setq group (pop groups))
1293 (when (gnus-group-prepare-logic
1296 (and (stringp regexp) (string-match regexp group))
1297 (and (functionp regexp) (funcall regexp group))))
1298 (gnus-group-insert-group-line
1300 (let ((active (gnus-active group)))
1302 (if (zerop (cdr active))
1304 (- (1+ (cdr active)) (car active)))
1306 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1308 (defun gnus-group-update-group-line ()
1309 "Update the current line in the group buffer."
1310 (let* ((buffer-read-only nil)
1311 (group (gnus-group-group-name))
1312 (entry (and group (gnus-group-entry group)))
1313 gnus-group-indentation)
1316 (not (gnus-ephemeral-group-p group))
1318 (concat "(gnus-group-set-info '"
1319 (gnus-prin1-to-string (nth 2 entry))
1321 (setq gnus-group-indentation (gnus-group-group-indentation))
1323 (gnus-group-insert-group-line-info group)
1325 (gnus-group-position-point))))
1327 (defun gnus-group-insert-group-line-info (group)
1328 "Insert GROUP on the current line."
1329 (let ((entry (gnus-group-entry group))
1330 (gnus-group-indentation (gnus-group-group-indentation))
1334 ;; (Un)subscribed group.
1335 (setq info (nth 2 entry))
1336 (gnus-group-insert-group-line
1337 group (gnus-info-level info) (gnus-info-marks info)
1338 (or (car entry) t) (gnus-info-method info)))
1339 ;; This group is dead.
1340 (gnus-group-insert-group-line
1342 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1344 (if (setq active (gnus-active group))
1345 (if (zerop (cdr active))
1347 (- (1+ (cdr active)) (car active)))
1349 (gnus-method-simplify (gnus-find-method-for-group group))))))
1351 (defun gnus-number-of-unseen-articles-in-group (group)
1352 (let* ((info (nth 2 (gnus-group-entry group)))
1353 (marked (gnus-info-marks info))
1354 (seen (cdr (assq 'seen marked)))
1355 (active (gnus-active group)))
1358 (length (gnus-uncompress-range
1359 (gnus-range-difference
1360 (gnus-range-difference (list active) (gnus-info-read info))
1363 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1364 gnus-tmp-marked number
1366 "Insert a group line in the group buffer."
1367 (let* ((gnus-tmp-method
1368 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1369 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1371 (gnus-tmp-active (gnus-active gnus-tmp-group))
1372 (gnus-tmp-number-total
1374 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1376 (gnus-tmp-number-of-unread
1377 (if (numberp number) (int-to-string (max 0 number))
1379 (gnus-tmp-number-of-read
1380 (if (numberp number)
1381 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1383 (gnus-tmp-subscribed
1384 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1385 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1386 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1388 (gnus-tmp-qualified-group
1389 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1390 group-name-charset))
1392 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1394 (gnus-tmp-newsgroup-description
1395 (if gnus-description-hashtb
1396 (or (gnus-group-name-decode
1397 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1398 group-name-charset) "")
1401 (if (and gnus-moderated-hashtb
1402 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1404 (gnus-tmp-moderated-string
1405 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1406 (gnus-tmp-group-icon "==&&==")
1407 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1408 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1409 (gnus-tmp-news-method-string
1411 (format "(%s:%s)" (car gnus-tmp-method)
1412 (cadr gnus-tmp-method)) ""))
1413 (gnus-tmp-marked-mark
1414 (if (and (numberp number)
1416 (cdr (assq 'tick gnus-tmp-marked)))
1418 (gnus-tmp-summary-live
1419 (if (and (not gnus-group-is-exiting-p)
1420 (gnus-buffer-live-p (gnus-summary-buffer-name
1423 (gnus-tmp-process-marked
1424 (if (member gnus-tmp-group gnus-group-marked)
1425 gnus-process-mark ? ))
1426 (buffer-read-only nil)
1427 header gnus-tmp-header) ; passed as parameter to user-funcs.
1429 (gnus-add-text-properties
1433 (let ((gnus-tmp-group (gnus-group-name-decode
1434 gnus-tmp-group group-name-charset)))
1435 (eval gnus-group-line-format-spec)))
1436 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1437 gnus-unread ,(if (numberp number)
1438 (string-to-int gnus-tmp-number-of-unread)
1440 gnus-marked ,gnus-tmp-marked-mark
1441 gnus-indentation ,gnus-group-indentation
1442 gnus-level ,gnus-tmp-level))
1444 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1445 (gnus-run-hooks 'gnus-group-update-hook))
1447 ;; Allow XEmacs to remove front-sticky text properties.
1448 (gnus-group-remove-excess-properties)))
1450 (defun gnus-group-highlight-line ()
1451 "Highlight the current line according to `gnus-group-highlight'."
1452 (let* ((list gnus-group-highlight)
1454 (end (point-at-eol))
1455 ;; now find out where the line starts and leave point there.
1456 (beg (progn (beginning-of-line) (point)))
1457 (group (gnus-group-group-name))
1458 (entry (gnus-group-entry group))
1459 (unread (if (numberp (car entry)) (car entry) 0))
1460 (active (gnus-active group))
1461 (total (if active (1+ (- (cdr active) (car active))) 0))
1462 (info (nth 2 entry))
1463 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1464 (marked (gnus-info-marks info))
1465 (mailp (apply 'append
1468 (memq x (assoc (symbol-name
1469 (car (or method gnus-select-method)))
1470 gnus-valid-select-methods)))
1471 '(mail post-mail))))
1472 (level (or (gnus-info-level info) gnus-level-killed))
1473 (score (or (gnus-info-score info) 0))
1474 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1475 (group-age (gnus-group-timestamp-delta group))
1476 (inhibit-read-only t))
1477 ;; Eval the cars of the lists until we find a match.
1479 (not (eval (caar list))))
1480 (setq list (cdr list)))
1481 (let ((face (cdar list)))
1482 (unless (eq face (get-text-property beg 'face))
1483 (gnus-put-text-property-excluding-characters-with-faces
1485 (setq face (if (boundp face) (symbol-value face) face)))
1486 (gnus-extent-start-open beg)))
1489 (defun gnus-group-update-group (group &optional visible-only)
1490 "Update all lines where GROUP appear.
1491 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1493 ;; Can't use `save-excursion' here, so we do it manually.
1494 (let ((buf (current-buffer))
1496 (set-buffer gnus-group-buffer)
1497 (setq mark (point-marker))
1498 ;; The buffer may be narrowed.
1501 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1503 found buffer-read-only)
1504 ;; Enter the current status into the dribble buffer.
1505 (let ((entry (gnus-group-entry group)))
1507 (not (gnus-ephemeral-group-p group)))
1509 (concat "(gnus-group-set-info '"
1510 (gnus-prin1-to-string (nth 2 entry))
1512 ;; Find all group instances. If topics are in use, each group
1513 ;; may be listed in more than once.
1514 (while (setq loc (text-property-any
1515 loc (point-max) 'gnus-group ident))
1518 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1520 (gnus-group-insert-group-line-info group)
1523 (gnus-run-hooks 'gnus-group-update-group-hook)))
1524 (setq loc (1+ loc)))
1525 (unless (or found visible-only)
1526 ;; No such line in the buffer, find out where it's supposed to
1527 ;; go, and insert it there (or at the end of the buffer).
1528 (if gnus-goto-missing-group-function
1529 (funcall gnus-goto-missing-group-function group)
1530 (let ((entry (cddr (gnus-group-entry group))))
1531 (while (and entry (car entry)
1535 (point-min) (point-max)
1536 'gnus-group (gnus-intern-safe
1537 (caar entry) gnus-active-hashtb)))))
1538 (setq entry (cdr entry)))
1539 (or entry (goto-char (point-max)))))
1540 ;; Finally insert the line.
1541 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1542 (gnus-group-insert-group-line-info group)
1545 (gnus-run-hooks 'gnus-group-update-group-hook))))
1546 (when gnus-group-update-group-function
1547 (funcall gnus-group-update-group-function group))
1548 (gnus-group-set-mode-line)))
1550 (set-marker mark nil)
1553 (defun gnus-group-set-mode-line ()
1554 "Update the mode line in the group buffer."
1555 (when (memq 'group gnus-updated-mode-lines)
1556 ;; Yes, we want to keep this mode line updated.
1558 (set-buffer gnus-group-buffer)
1559 (let* ((gformat (or gnus-group-mode-line-format-spec
1560 (gnus-set-format 'group-mode)))
1561 (gnus-tmp-news-server (cadr gnus-select-method))
1562 (gnus-tmp-news-method (car gnus-select-method))
1563 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1565 gnus-tmp-header ;Dummy binding for user-defined formats
1566 ;; Get the resulting string.
1568 (and gnus-dribble-buffer
1569 (buffer-name gnus-dribble-buffer)
1570 (buffer-modified-p gnus-dribble-buffer)
1572 (set-buffer gnus-dribble-buffer)
1573 (not (zerop (buffer-size))))))
1574 (mode-string (eval gformat)))
1575 ;; Say whether the dribble buffer has been modified.
1576 (setq mode-line-modified
1577 (if modified (car gnus-mode-line-modified)
1578 (cdr gnus-mode-line-modified)))
1579 ;; If the line is too long, we chop it off.
1580 (when (> (length mode-string) max-len)
1581 (setq mode-string (substring mode-string 0 (- max-len 4))))
1583 (setq mode-line-buffer-identification
1584 (gnus-mode-line-buffer-identification
1585 (list mode-string)))
1586 (set-buffer-modified-p modified))))))
1588 (defun gnus-group-group-name ()
1589 "Get the name of the newsgroup on the current line."
1590 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1592 (symbol-name group))))
1594 (defun gnus-group-group-level ()
1595 "Get the level of the newsgroup on the current line."
1596 (get-text-property (point-at-bol) 'gnus-level))
1598 (defun gnus-group-group-indentation ()
1599 "Get the indentation of the newsgroup on the current line."
1600 (or (get-text-property (point-at-bol) 'gnus-indentation)
1601 (and gnus-group-indentation-function
1602 (funcall gnus-group-indentation-function))
1605 (defun gnus-group-group-unread ()
1606 "Get the number of unread articles of the newsgroup on the current line."
1607 (get-text-property (point-at-bol) 'gnus-unread))
1609 (defun gnus-group-new-mail (group)
1610 (if (nnmail-new-mail-p (gnus-group-real-name group))
1614 (defun gnus-group-level (group)
1615 "Return the estimated level of GROUP."
1616 (or (gnus-info-level (gnus-get-info group))
1617 (and (member group gnus-zombie-list) gnus-level-zombie)
1620 (defun gnus-group-search-forward (&optional backward all level first-too)
1621 "Find the next newsgroup with unread articles.
1622 If BACKWARD is non-nil, find the previous newsgroup instead.
1623 If ALL is non-nil, just find any newsgroup.
1624 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1626 If FIRST-TOO, the current line is also eligible as a target."
1627 (let ((way (if backward -1 1))
1628 (low gnus-level-killed)
1631 (if (and backward (progn (beginning-of-line)) (bobp))
1640 (get-text-property (point) 'gnus-group)
1644 (get-text-property (point) 'gnus-unread)))
1645 (and (numberp unread) (> unread 0)))
1646 (setq lev (get-text-property (point)
1648 (<= lev gnus-level-subscribed)))
1650 (and (setq lev (get-text-property (point)
1659 (zerop (forward-line way)))))
1661 (progn (gnus-group-position-point) t)
1662 (goto-char (or pos beg))
1665 ;;; Gnus group mode commands
1669 (defun gnus-group-mark-line-p ()
1672 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1673 (eq (char-after) gnus-process-mark)))
1675 (defun gnus-group-mark-group (n &optional unmark no-advance)
1676 "Mark the current group."
1678 (let ((buffer-read-only nil)
1682 (when (setq group (gnus-group-group-name))
1683 ;; Go to the mark position.
1685 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1689 (setq gnus-group-marked (delete group gnus-group-marked))
1690 (insert-char ? 1 t))
1691 (setq gnus-group-marked
1692 (cons group (delete group gnus-group-marked)))
1693 (insert-char gnus-process-mark 1 t)))
1695 (gnus-group-next-group 1))
1697 (gnus-summary-position-point)
1700 (defun gnus-group-unmark-group (n)
1701 "Remove the mark from the current group."
1703 (gnus-group-mark-group n 'unmark)
1704 (gnus-group-position-point))
1706 (defun gnus-group-unmark-all-groups ()
1707 "Unmark all groups."
1709 (let ((groups gnus-group-marked))
1712 (gnus-group-remove-mark (pop groups)))))
1713 (gnus-group-position-point))
1715 (defun gnus-group-mark-region (unmark beg end)
1716 "Mark all groups between point and mark.
1717 If UNMARK, remove the mark instead."
1718 (interactive "P\nr")
1719 (let ((num (count-lines beg end)))
1722 (- num (gnus-group-mark-group num unmark)))))
1724 (defun gnus-group-mark-buffer (&optional unmark)
1725 "Mark all groups in the buffer.
1726 If UNMARK, remove the mark instead."
1728 (gnus-group-mark-region unmark (point-min) (point-max)))
1730 (defun gnus-group-mark-regexp (regexp)
1731 "Mark all groups that match some regexp."
1732 (interactive "sMark (regexp): ")
1733 (let ((alist (cdr gnus-newsrc-alist))
1737 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1738 (gnus-group-jump-to-group group)
1739 (gnus-group-set-mark group)))))
1740 (gnus-group-position-point))
1742 (defun gnus-group-remove-mark (group &optional test-marked)
1743 "Remove the process mark from GROUP and move point there.
1744 Return nil if the group isn't displayed."
1745 (if (gnus-group-goto-group group nil test-marked)
1747 (gnus-group-mark-group 1 'unmark t)
1749 (setq gnus-group-marked
1750 (delete group gnus-group-marked))
1753 (defun gnus-group-set-mark (group)
1754 "Set the process mark on GROUP."
1755 (if (gnus-group-goto-group group)
1757 (gnus-group-mark-group 1 nil t))
1758 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1760 (defun gnus-group-universal-argument (arg &optional groups func)
1761 "Perform any command on all groups according to the process/prefix convention."
1763 (if (eq (setq func (or func
1766 (substitute-command-keys
1767 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1769 (gnus-error 1 "Undefined key")
1770 (gnus-group-iterate arg
1772 (command-execute func))))
1773 (gnus-group-position-point))
1775 (defun gnus-group-process-prefix (n)
1776 "Return a list of groups to work on.
1777 Take into consideration N (the prefix) and the list of marked groups."
1780 (setq n (prefix-numeric-value n))
1781 ;; There is a prefix, so we return a list of the N next
1783 (let ((way (if (< n 0) -1 1))
1788 (if (setq group (gnus-group-group-name))
1789 (push group groups))
1791 (gnus-group-next-group way)))
1793 ((and (gnus-region-active-p) (mark))
1794 ;; Work on the region between point and mark.
1795 (let ((max (max (point) (mark)))
1798 (goto-char (min (point) (mark)))
1801 (push (gnus-group-group-name) groups)
1802 (zerop (gnus-group-next-group 1))
1804 (nreverse groups))))
1806 ;; No prefix, but a list of marked articles.
1807 (reverse gnus-group-marked))
1809 ;; Neither marked articles or a prefix, so we return the
1811 (let ((group (gnus-group-group-name)))
1812 (and group (list group))))))
1814 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1815 ;;; imagine why I went through these contortions...
1817 (let ((function (make-symbol "gnus-group-iterate-function"))
1818 (window (make-symbol "gnus-group-iterate-window"))
1819 (groups (make-symbol "gnus-group-iterate-groups"))
1820 (group (make-symbol "gnus-group-iterate-group")))
1822 `(defun gnus-group-iterate (arg ,function)
1823 "Iterate FUNCTION over all process/prefixed groups.
1824 FUNCTION will be called with the group name as the parameter
1825 and with point over the group in question."
1826 (let ((,groups (gnus-group-process-prefix arg))
1827 (,window (selected-window))
1830 (setq ,group (car ,groups)
1831 ,groups (cdr ,groups))
1832 (select-window ,window)
1833 (gnus-group-remove-mark ,group)
1834 (save-selected-window
1836 (funcall ,function ,group)))))))))
1838 (put 'gnus-group-iterate 'lisp-indent-function 1)
1840 ;; Selecting groups.
1842 (defun gnus-group-read-group (&optional all no-article group select-articles)
1843 "Read news in this newsgroup.
1844 If the prefix argument ALL is non-nil, already read articles become
1845 readable. IF ALL is a number, fetch this number of articles. If the
1846 optional argument NO-ARTICLE is non-nil, no article will be
1847 auto-selected upon group entry. If GROUP is non-nil, fetch that
1850 (let ((no-display (eq all 0))
1851 (group (or group (gnus-group-group-name)))
1852 number active marked entry)
1856 (error "No group on current line"))
1857 (setq marked (gnus-info-marks
1858 (nth 2 (setq entry (gnus-group-entry group)))))
1859 ;; This group might be a dead group. In that case we have to get
1860 ;; the number of unread articles from `gnus-active-hashtb'.
1862 (cond ((numberp all) all)
1864 ((setq active (gnus-active group))
1865 (- (1+ (cdr active)) (car active)))))
1866 (gnus-summary-read-group
1867 group (or all (and (numberp number)
1868 (zerop (+ number (gnus-range-length
1869 (cdr (assq 'tick marked)))
1871 (cdr (assq 'dormant marked)))))))
1872 no-article nil no-display nil select-articles)))
1874 (defun gnus-group-select-group (&optional all)
1875 "Select this newsgroup.
1876 No article is selected automatically.
1877 If the group is opened, just switch the summary buffer.
1878 If ALL is non-nil, already read articles become readable.
1879 If ALL is a number, fetch this number of articles."
1881 (when (and (eobp) (not (gnus-group-group-name)))
1883 (gnus-group-read-group all t))
1885 (defun gnus-group-quick-select-group (&optional all)
1886 "Select the current group \"quickly\".
1887 This means that no highlighting or scoring will be performed.
1888 If ALL (the prefix argument) is 0, don't even generate the summary
1891 This might be useful if you want to toggle threading
1892 before entering the group."
1894 (require 'gnus-score)
1896 gnus-score-find-score-files-function
1897 gnus-home-score-file
1898 gnus-apply-kill-hook
1899 gnus-summary-expunge-below)
1900 (gnus-group-read-group all t)))
1902 (defun gnus-group-visible-select-group (&optional all)
1903 "Select the current group without hiding any articles."
1905 (let ((gnus-inhibit-limiting t))
1906 (gnus-group-read-group all t)))
1908 (defun gnus-group-select-group-ephemerally ()
1909 "Select the current group without doing any processing whatsoever.
1910 You will actually be entered into a group that's a copy of
1911 the current group; no changes you make while in this group will
1914 (require 'gnus-score)
1916 gnus-score-find-score-files-function gnus-apply-kill-hook
1917 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1918 gnus-summary-mode-hook gnus-select-group-hook
1919 (group (gnus-group-group-name))
1920 (method (gnus-find-method-for-group group)))
1921 (gnus-group-read-ephemeral-group
1922 (gnus-group-prefixed-name group method) method)))
1925 (defun gnus-fetch-group (group &optional articles)
1926 "Start Gnus if necessary and enter GROUP.
1927 Returns whether the fetching was successful or not."
1928 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1929 (unless (get-buffer gnus-group-buffer)
1931 (gnus-group-read-group articles nil group))
1934 (defun gnus-fetch-group-other-frame (group)
1935 "Pop up a frame and enter GROUP."
1937 (let ((window (get-buffer-window gnus-group-buffer)))
1939 (select-frame (window-frame window)))
1940 ((= (length (frame-list)) 1)
1941 (select-frame (make-frame)))
1944 (gnus-fetch-group group))
1946 (defvar gnus-ephemeral-group-server 0)
1948 (defcustom gnus-large-ephemeral-newsgroup 200
1949 "The number of articles which indicates a large ephemeral newsgroup.
1950 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1952 If the number of articles in a newsgroup is greater than this value,
1953 confirmation is required for selecting the newsgroup. If it is nil, no
1954 confirmation is required."
1955 :group 'gnus-group-select
1956 :type '(choice (const :tag "No limit" nil)
1959 (defcustom gnus-fetch-old-ephemeral-headers nil
1960 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
1962 :type '(choice (const :tag "off" nil)
1965 (sexp :menu-tag "other" t)))
1967 ;; Enter a group that is not in the group buffer. Non-nil is returned
1968 ;; if selection was successful.
1969 (defun gnus-group-read-ephemeral-group (group method &optional activate
1970 quit-config request-only
1973 "Read GROUP from METHOD as an ephemeral group.
1974 If ACTIVATE, request the group first.
1975 If QUIT-CONFIG, use that window configuration when exiting from the
1977 If REQUEST-ONLY, don't actually read the group; just request it.
1978 If SELECT-ARTICLES, only select those articles.
1979 If PARAMETERS, use those as the group parameters.
1981 Return the name of the group if selection was successful."
1984 ;; (gnus-read-group "Group name: ")
1986 "Group: " gnus-active-hashtb
1988 'gnus-group-history)
1989 (gnus-read-method "From method: ")))
1990 ;; Transform the select method into a unique server.
1991 (when (stringp method)
1992 (setq method (gnus-server-to-method method)))
1994 `(,(car method) ,(concat (cadr method) "-ephemeral")
1995 (,(intern (format "%s-address" (car method))) ,(cadr method))
1997 (let ((group (if (gnus-group-foreign-p group) group
1998 (gnus-group-prefixed-name (gnus-group-real-name group)
2003 ,gnus-level-default-subscribed nil nil ,method
2006 (cons 'quit-config quit-config)
2008 (cons gnus-summary-buffer
2009 gnus-current-window-configuration)))
2012 (push method gnus-ephemeral-servers)
2013 (set-buffer gnus-group-buffer)
2014 (unless (gnus-check-server method)
2015 (error "Unable to contact server: %s" (gnus-status-message method)))
2017 (gnus-activate-group group 'scan)
2018 (unless (gnus-request-group group)
2019 (error "Couldn't request group: %s"
2020 (nnheader-get-report (car method)))))
2024 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2025 (gnus-fetch-old-headers
2026 gnus-fetch-old-ephemeral-headers))
2027 (gnus-group-read-group t t group select-articles))
2031 (message "Quit reading the ephemeral group")
2034 (defun gnus-group-jump-to-group (group)
2035 "Jump to newsgroup GROUP."
2037 (list (mm-string-make-unibyte
2039 "Group: " gnus-active-hashtb nil
2040 (gnus-read-active-file-p)
2041 gnus-group-jump-to-group-prompt
2042 'gnus-group-history))))
2044 (when (equal group "")
2045 (error "Empty group name"))
2047 (unless (gnus-ephemeral-group-p group)
2048 ;; Either go to the line in the group buffer...
2049 (unless (gnus-group-goto-group group)
2050 ;; ... or insert the line.
2051 (gnus-group-update-group group)
2052 (gnus-group-goto-group group)))
2053 ;; Adjust cursor point.
2054 (gnus-group-position-point))
2056 (defun gnus-group-goto-group (group &optional far test-marked)
2057 "Goto to newsgroup GROUP.
2058 If FAR, it is likely that the group is not on the current line.
2059 If TEST-MARKED, the line must be marked."
2063 ;; It's quite likely that we are on the right line, so
2064 ;; we check the current line first.
2066 (eq (get-text-property (point) 'gnus-group)
2067 (gnus-intern-safe group gnus-active-hashtb))
2068 (or (not test-marked) (gnus-group-mark-line-p)))
2070 ;; Previous and next line are also likely, so we check them as well.
2074 (and (eq (get-text-property (point) 'gnus-group)
2075 (gnus-intern-safe group gnus-active-hashtb))
2076 (or (not test-marked) (gnus-group-mark-line-p)))))
2082 (and (eq (get-text-property (point) 'gnus-group)
2083 (gnus-intern-safe group gnus-active-hashtb))
2084 (or (not test-marked) (gnus-group-mark-line-p)))))
2088 (goto-char (point-min))
2090 (while (and (not found)
2095 (gnus-intern-safe group gnus-active-hashtb))))
2096 (if (gnus-group-mark-line-p)
2101 ;; Search through the entire buffer.
2104 (point-min) (point-max)
2105 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2107 (defun gnus-group-next-group (n &optional silent)
2108 "Go to next N'th newsgroup.
2109 If N is negative, search backward instead.
2110 Returns the difference between N and the number of skips actually
2113 (gnus-group-next-unread-group n t nil silent))
2115 (defun gnus-group-next-unread-group (n &optional all level silent)
2116 "Go to next N'th unread newsgroup.
2117 If N is negative, search backward instead.
2118 If ALL is non-nil, choose any newsgroup, unread or not.
2119 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2120 such group can be found, the next group with a level higher than
2122 Returns the difference between N and the number of skips actually
2125 (let ((backward (< n 0))
2128 (gnus-group-search-forward
2129 backward (or (not gnus-group-goto-unread) all) level))
2133 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2134 (if level " on this level or higher" "")))
2137 (defun gnus-group-prev-group (n)
2138 "Go to previous N'th newsgroup.
2139 Returns the difference between N and the number of skips actually
2142 (gnus-group-next-unread-group (- n) t))
2144 (defun gnus-group-prev-unread-group (n)
2145 "Go to previous N'th unread newsgroup.
2146 Returns the difference between N and the number of skips actually
2149 (gnus-group-next-unread-group (- n)))
2151 (defun gnus-group-next-unread-group-same-level (n)
2152 "Go to next N'th unread newsgroup on the same level.
2153 If N is negative, search backward instead.
2154 Returns the difference between N and the number of skips actually
2157 (gnus-group-next-unread-group n t (gnus-group-group-level))
2158 (gnus-group-position-point))
2160 (defun gnus-group-prev-unread-group-same-level (n)
2161 "Go to next N'th unread newsgroup on the same level.
2162 Returns the difference between N and the number of skips actually
2165 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2166 (gnus-group-position-point))
2168 (defun gnus-group-best-unread-group (&optional exclude-group)
2169 "Go to the group with the highest level.
2170 If EXCLUDE-GROUP, do not go to that group."
2172 (goto-char (point-min))
2176 (setq unread (get-text-property (point) 'gnus-unread))
2177 (when (and (numberp unread) (> unread 0))
2178 (when (and (get-text-property (point) 'gnus-level)
2179 (< (get-text-property (point) 'gnus-level) best)
2180 (or (not exclude-group)
2181 (not (equal exclude-group (gnus-group-group-name)))))
2182 (setq best (get-text-property (point) 'gnus-level))
2183 (setq best-point (point))))
2186 (goto-char best-point))
2187 (gnus-group-position-point)
2188 (and best-point (gnus-group-group-name))))
2190 (defun gnus-group-first-unread-group ()
2191 "Go to the first group with unread articles."
2194 (let ((opoint (point))
2196 (goto-char (point-min))
2197 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2198 (and (numberp unread) ; Not a topic.
2199 (not (zerop unread))) ; Has unread articles.
2200 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2203 nil)) ; Not success.
2204 (gnus-group-position-point)))
2206 (defun gnus-group-enter-server-mode ()
2207 "Jump to the server buffer."
2209 (gnus-enter-server-buffer))
2211 (defun gnus-group-make-group (name &optional method address args)
2212 "Add a new newsgroup.
2213 The user will be prompted for a NAME, for a select METHOD, and an
2217 (gnus-read-group "Group name: ")
2218 (gnus-read-method "From method: ")))
2220 (when (stringp method)
2221 (setq method (or (gnus-server-to-method method) method)))
2222 (let* ((meth (gnus-method-simplify
2224 (not (gnus-server-equal method gnus-select-method)))
2225 (if address (list (intern method) address)
2227 (nname (if method (gnus-group-prefixed-name name meth) name))
2229 (when (gnus-group-entry nname)
2230 (error "Group %s already exists" nname))
2231 ;; Subscribe to the new group.
2232 (gnus-group-change-level
2233 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2234 gnus-level-default-subscribed gnus-level-killed
2235 (and (gnus-group-group-name)
2236 (gnus-group-entry (gnus-group-group-name)))
2239 (gnus-set-active nname (cons 1 0))
2240 (unless (gnus-ephemeral-group-p name)
2242 (concat "(gnus-group-set-info '"
2243 (gnus-prin1-to-string (cdr info)) ")")))
2245 (gnus-group-insert-group-line-info nname)
2247 (gnus-group-position-point)
2249 ;; Load the back end and try to make the back end create
2250 ;; the group as well.
2251 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2253 gnus-valid-select-methods)
2255 (gnus-check-server meth)
2256 (when (gnus-check-backend-function 'request-create-group nname)
2257 (unless (gnus-request-create-group nname nil args)
2258 (error "Could not create group on server: %s"
2259 (nnheader-get-report backend))))
2262 (defun gnus-group-delete-groups (&optional arg)
2263 "Delete the current group. Only meaningful with editable groups."
2265 (let ((n (length (gnus-group-process-prefix arg))))
2266 (when (gnus-yes-or-no-p
2268 "Delete this 1 group? "
2269 (format "Delete these %d groups? " n)))
2270 (gnus-group-iterate arg
2272 (gnus-group-delete-group group nil t))))))
2274 (defvar gnus-cache-active-altered)
2276 (defun gnus-group-delete-group (group &optional force no-prompt)
2277 "Delete the current group. Only meaningful with editable groups.
2278 If FORCE (the prefix) is non-nil, all the articles in the group will
2279 be deleted. This is \"deleted\" as in \"removed forever from the face
2280 of the Earth\". There is no undo. The user will be prompted before
2282 Note that you also have to specify FORCE if you want the group to
2283 be removed from the server, even when it's empty."
2285 (list (gnus-group-group-name)
2286 current-prefix-arg))
2288 (error "No group to delete"))
2289 (unless (gnus-check-backend-function 'request-delete-group group)
2290 (error "This back end does not support group deletion"))
2292 (if (and (not no-prompt)
2293 (not (gnus-yes-or-no-p
2295 "Do you really want to delete %s%s? "
2296 group (if force " and all its contents" "")))))
2298 (gnus-message 6 "Deleting group %s..." group)
2299 (if (not (gnus-request-delete-group group force))
2300 (gnus-error 3 "Couldn't delete group %s" group)
2301 (gnus-message 6 "Deleting group %s...done" group)
2302 (gnus-group-goto-group group)
2303 (gnus-group-kill-group 1 t)
2304 (gnus-set-active group nil)
2305 (if (boundp 'gnus-cache-active-hashtb)
2306 (when gnus-cache-active-hashtb
2307 (gnus-sethash group nil gnus-cache-active-hashtb)
2308 (setq gnus-cache-active-altered t)))
2310 (gnus-group-position-point)))
2312 (defun gnus-group-rename-group (group new-name)
2313 "Rename group from GROUP to NEW-NAME.
2314 When used interactively, GROUP is the group under point
2315 and NEW-NAME will be prompted for."
2318 (gnus-group-group-name)
2320 (unless (gnus-check-backend-function
2321 'request-rename-group (gnus-group-group-name))
2322 (error "This back end does not support renaming groups"))
2323 (gnus-read-group "Rename group to: "
2324 (gnus-group-real-name (gnus-group-group-name))))))
2326 (unless (gnus-check-backend-function 'request-rename-group group)
2327 (error "This back end does not support renaming groups"))
2329 (error "No group to rename"))
2330 (when (equal (gnus-group-real-name group) new-name)
2331 (error "Can't rename to the same name"))
2333 ;; We find the proper prefixed name.
2335 (if (gnus-group-native-p group)
2339 (gnus-group-prefixed-name
2340 (gnus-group-real-name new-name)
2341 (gnus-info-method (gnus-get-info group)))))
2343 (when (gnus-active new-name)
2344 (error "The group %s already exists" new-name))
2346 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2349 (gnus-group-goto-group group)
2350 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2351 (gnus-request-rename-group group new-name))))
2352 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2353 ;; We rename the group internally by killing it...
2354 (gnus-group-kill-group)
2355 ;; ... changing its name ...
2356 (setcar (cdar gnus-list-of-killed-groups) new-name)
2357 ;; ... and then yanking it. Magic!
2358 (gnus-group-yank-group)
2359 (gnus-set-active new-name (gnus-active group))
2360 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2362 (setq gnus-killed-list (delete group gnus-killed-list))
2363 (gnus-set-active group nil)
2364 (gnus-dribble-touch)
2365 (gnus-group-position-point)))
2367 (defun gnus-group-edit-group (group &optional part)
2368 "Edit the group on the current line."
2369 (interactive (list (gnus-group-group-name)))
2370 (let ((part (or part 'info))
2373 (error "No group on current line"))
2374 (unless (setq info (gnus-get-info group))
2375 (error "Killed group; can't be edited"))
2377 (gnus-close-group group))
2379 ;; Find the proper form to edit.
2380 (cond ((eq part 'method)
2381 (or (gnus-info-method info) "native"))
2383 (gnus-info-params info))
2385 ;; The proper documentation.
2387 "Editing the %s for `%s'."
2389 ((eq part 'method) "select method")
2390 ((eq part 'params) "group parameters")
2392 (gnus-group-decoded-name group))
2394 (gnus-group-edit-group-done ',part ,group form)))
2397 (gnus-create-info-command
2400 "(gnus)Select Methods")
2402 "(gnus)Group Parameters")
2404 "(gnus)Group Info"))))))
2406 (defun gnus-group-edit-group-method (group)
2407 "Edit the select method of GROUP."
2408 (interactive (list (gnus-group-group-name)))
2409 (gnus-group-edit-group group 'method))
2411 (defun gnus-group-edit-group-parameters (group)
2412 "Edit the group parameters of GROUP."
2413 (interactive (list (gnus-group-group-name)))
2414 (gnus-group-edit-group group 'params))
2416 (defun gnus-group-edit-group-done (part group form)
2418 (let* ((method (cond ((eq part 'info) (nth 4 form))
2419 ((eq part 'method) form)
2421 (info (cond ((eq part 'info) form)
2422 ((eq part 'method) (gnus-get-info group))
2425 (if (or (not method)
2427 gnus-select-method method))
2428 (gnus-group-real-name (car info))
2429 (gnus-group-prefixed-name
2430 (gnus-group-real-name (car info)) method))
2432 (when (and new-group
2433 (not (equal new-group group)))
2434 (when (gnus-group-goto-group group)
2435 (gnus-group-kill-group 1))
2436 (gnus-activate-group new-group))
2438 (if (not (and info new-group))
2439 (gnus-group-set-info form (or new-group group) part)
2440 (setq info (gnus-copy-sequence info))
2441 (setcar info new-group)
2442 (unless (gnus-server-equal method "native")
2443 (unless (nthcdr 3 info)
2444 (nconc info (list nil nil)))
2445 (unless (nthcdr 4 info)
2446 (nconc info (list nil)))
2447 (gnus-info-set-method info method))
2448 (gnus-group-set-info info))
2449 (gnus-group-update-group (or new-group group))
2450 (gnus-group-position-point)))
2452 (defun gnus-group-make-useful-group (group method)
2453 "Create one of the groups described in `gnus-useful-groups'."
2455 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2457 gnus-useful-groups)))
2458 (list (cadr entry) (caddr entry))))
2459 (setq method (gnus-copy-sequence method))
2461 (while (setq entry (memq (assq 'eval method) method))
2462 (setcar entry (eval (cadar entry)))))
2463 (gnus-group-make-group group method))
2465 (defun gnus-group-make-help-group (&optional noerror)
2466 "Create the Gnus documentation group.
2467 Optional argument NOERROR modifies the behavior of this function when the
2468 group already exists:
2469 - if not given, and error is signaled,
2470 - if t, stay silent,
2471 - if anything else, just print a message."
2473 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2474 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2475 (if (gnus-group-entry name)
2476 (cond ((eq noerror nil)
2477 (error "Documentation group already exists"))
2482 (gnus-message 1 "Documentation group already exists")))
2485 (gnus-message 1 "Couldn't find doc group")
2486 (gnus-group-make-group
2487 (gnus-group-real-name name)
2488 (list 'nndoc "gnus-help"
2489 (list 'nndoc-address file)
2490 (list 'nndoc-article-type 'mbox))))
2492 (gnus-group-position-point))
2494 (defun gnus-group-make-doc-group (file type)
2495 "Create a group that uses a single file as the source."
2497 (list (read-file-name "File name: ")
2498 (and current-prefix-arg 'ask)))
2499 (when (eq type 'ask)
2504 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2506 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2507 ((= char ?b) 'babyl)
2508 ((= char ?d) 'digest)
2509 ((= char ?f) 'forward)
2511 ((= char ?g) 'guess)
2512 (t (setq err (format "%c unknown. " char))
2515 (let* ((file (expand-file-name file))
2516 (name (gnus-generate-new-group-name
2517 (gnus-group-prefixed-name
2518 (file-name-nondirectory file) '(nndoc "")))))
2519 (gnus-group-make-group
2520 (gnus-group-real-name name)
2522 (list 'nndoc-address file)
2523 (list 'nndoc-article-type (or type 'guess))))))
2525 (defvar nnweb-type-definition)
2526 (defvar gnus-group-web-type-history nil)
2527 (defvar gnus-group-web-search-history nil)
2528 (defun gnus-group-make-web-group (&optional solid)
2529 "Create an ephemeral nnweb group.
2530 If SOLID (the prefix), create a solid group."
2534 (if solid (gnus-read-group "Group name: ")
2535 (message-unique-id)))
2536 (default-type (or (car gnus-group-web-type-history)
2537 (symbol-name (caar nnweb-type-definition))))
2541 (format "Search engine type (default %s): " default-type)
2542 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2543 nnweb-type-definition)
2544 nil t nil 'gnus-group-web-type-history)
2549 (cons (or (car gnus-group-web-search-history) "") 0)
2550 'gnus-group-web-search-history))
2552 `(nnweb ,group (nnweb-search ,search)
2553 (nnweb-type ,(intern type))
2554 (nnweb-ephemeral-p t))))
2557 (gnus-pull 'nnweb-ephemeral-p method)
2558 (gnus-group-make-group group method))
2559 (gnus-group-read-ephemeral-group
2561 (cons (current-buffer)
2562 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2565 (defvar nnrss-group-alist)
2566 (defun nnrss-discover-feed (arg))
2567 (defun nnrss-save-server-data (arg)))
2568 (defun gnus-group-make-rss-group (&optional url)
2569 "Given a URL, discover if there is an RSS feed.
2570 If there is, use Gnus to create an nnrss group"
2574 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2575 (let ((feedinfo (nnrss-discover-feed url)))
2577 (let ((title (read-from-minibuffer "Title: "
2580 (desc (read-from-minibuffer "Description: "
2581 (cdr (assoc 'description
2583 (href (cdr (assoc 'href feedinfo))))
2584 (push (list title href desc)
2586 (gnus-group-unsubscribe-group
2587 (concat "nnrss:" title))
2588 (nnrss-save-server-data nil))
2589 (error "No feeds found for %s" url))))
2591 (defvar nnwarchive-type-definition)
2592 (defvar gnus-group-warchive-type-history nil)
2593 (defvar gnus-group-warchive-login-history nil)
2594 (defvar gnus-group-warchive-address-history nil)
2596 (defun gnus-group-make-warchive-group ()
2597 "Create a nnwarchive group."
2599 (require 'nnwarchive)
2600 (let* ((group (gnus-read-group "Group name: "))
2601 (default-type (or (car gnus-group-warchive-type-history)
2602 (symbol-name (caar nnwarchive-type-definition))))
2606 (format "Warchive type (default %s): " default-type)
2607 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2608 nnwarchive-type-definition)
2609 nil t nil 'gnus-group-warchive-type-history)
2611 (address (read-string "Warchive address: "
2612 nil 'gnus-group-warchive-address-history))
2613 (default-login (or (car gnus-group-warchive-login-history)
2618 (format "Warchive login (default %s): " user-mail-address)
2619 default-login 'gnus-group-warchive-login-history)
2622 `(nnwarchive ,address
2623 (nnwarchive-type ,(intern type))
2624 (nnwarchive-login ,login))))
2625 (gnus-group-make-group group method)))
2627 (defun gnus-group-make-archive-group (&optional all)
2628 "Create the (ding) Gnus archive group of the most recent articles.
2629 Given a prefix, create a full group."
2631 (let ((group (gnus-group-prefixed-name
2632 (if all "ding.archives" "ding.recent") '(nndir ""))))
2633 (when (gnus-group-entry group)
2634 (error "Archive group already exists"))
2635 (gnus-group-make-group
2636 (gnus-group-real-name group)
2637 (list 'nndir (if all "hpc" "edu")
2638 (list 'nndir-directory
2639 (if all gnus-group-archive-directory
2640 gnus-group-recent-archive-directory))))
2641 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2643 (defun gnus-group-make-directory-group (dir)
2644 "Create an nndir group.
2645 The user will be prompted for a directory. The contents of this
2646 directory will be used as a newsgroup. The directory should contain
2647 mail messages or news articles in files that have numeric names."
2649 (list (read-file-name "Create group from directory: ")))
2650 (unless (file-exists-p dir)
2651 (error "No such directory"))
2652 (unless (file-directory-p dir)
2653 (error "Not a directory"))
2657 (while (or (not group) (gnus-group-entry group))
2659 (gnus-group-prefixed-name
2660 (expand-file-name ext dir)
2662 (setq ext (format "<%d>" (setq i (1+ i)))))
2663 (gnus-group-make-group
2664 (gnus-group-real-name group)
2665 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2667 (defvar nnkiboze-score-file)
2668 (defun gnus-group-make-kiboze-group (group address scores)
2669 "Create an nnkiboze group.
2670 The user will be prompted for a name, a regexp to match groups, and
2671 score file entries for articles to include in the group."
2674 (read-string "nnkiboze group name: ")
2675 (read-string "Source groups (regexp): ")
2676 (let ((headers (mapcar (lambda (group) (list group))
2677 '("subject" "from" "number" "date" "message-id"
2678 "references" "chars" "lines" "xref"
2679 "followup" "all" "body" "head")))
2680 scores header regexp regexps)
2681 (while (not (equal "" (setq header (completing-read
2682 "Match on header: " headers nil t))))
2684 (while (not (equal "" (setq regexp (read-string
2685 (format "Match on %s (regexp): "
2687 (push (list regexp nil nil 'r) regexps))
2688 (push (cons header regexps) scores))
2690 (gnus-group-make-group group "nnkiboze" address)
2691 (let* ((nnkiboze-current-group group)
2692 (score-file (car (nnkiboze-score-file "")))
2693 (score-dir (file-name-directory score-file)))
2694 (unless (file-exists-p score-dir)
2695 (make-directory score-dir))
2696 (with-temp-file score-file
2697 (let (emacs-lisp-mode-hook)
2698 (pp scores (current-buffer))))))
2700 (defun gnus-group-add-to-virtual (n vgroup)
2701 "Add the current group to a virtual group."
2703 (list current-prefix-arg
2704 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2706 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2707 (error "%s is not an nnvirtual group" vgroup))
2708 (gnus-close-group vgroup)
2709 (let* ((groups (gnus-group-process-prefix n))
2710 (method (gnus-info-method (gnus-get-info vgroup))))
2711 (setcar (cdr method)
2713 (nth 1 method) "\\|"
2716 (gnus-group-remove-mark s)
2717 (concat "\\(^" (regexp-quote s) "$\\)"))
2719 (gnus-group-position-point))
2721 (defun gnus-group-make-empty-virtual (group)
2722 "Create a new, fresh, empty virtual group."
2723 (interactive "sCreate new, empty virtual group: ")
2724 (let* ((method (list 'nnvirtual "^$"))
2725 (pgroup (gnus-group-prefixed-name group method)))
2726 ;; Check whether it exists already.
2727 (when (gnus-group-entry pgroup)
2728 (error "Group %s already exists" pgroup))
2729 ;; Subscribe the new group after the group on the current line.
2730 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2731 (gnus-group-update-group pgroup)
2733 (gnus-group-position-point)))
2735 (defun gnus-group-enter-directory (dir)
2736 "Enter an ephemeral nneething group."
2737 (interactive "DDirectory to read: ")
2738 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2739 (leaf (gnus-group-prefixed-name
2740 (file-name-nondirectory (directory-file-name dir))
2742 (name (gnus-generate-new-group-name leaf)))
2743 (unless (gnus-group-read-ephemeral-group
2745 (cons (current-buffer)
2746 (if (eq major-mode 'gnus-summary-mode)
2748 (error "Couldn't enter %s" dir))))
2751 (autoload 'nnimap-expunge "nnimap")
2752 (autoload 'nnimap-acl-get "nnimap")
2753 (autoload 'nnimap-acl-edit "nnimap"))
2755 (defun gnus-group-nnimap-expunge (group)
2756 "Expunge deleted articles in current nnimap GROUP."
2757 (interactive (list (gnus-group-group-name)))
2758 (let ((mailbox (gnus-group-real-name group)) method)
2760 (error "No group on current line"))
2761 (unless (gnus-get-info group)
2762 (error "Killed group; can't be edited"))
2763 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2764 (error "%s is not an nnimap group" group))
2765 (nnimap-expunge mailbox (cadr method))))
2767 (defun gnus-group-nnimap-edit-acl (group)
2768 "Edit the Access Control List of current nnimap GROUP."
2769 (interactive (list (gnus-group-group-name)))
2770 (let ((mailbox (gnus-group-real-name group)) method acl)
2772 (error "No group on current line"))
2773 (unless (gnus-get-info group)
2774 (error "Killed group; can't be edited"))
2775 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2776 (error "%s is not an nnimap group" group))
2777 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2778 (error "Server does not support ACL's"))
2779 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2781 An access control list is a list of (identifier . rights) elements.
2783 The identifier string specifies the corresponding user. The
2784 identifier \"anyone\" is reserved to refer to the universal identity.
2786 Rights is a string listing a (possibly empty) set of alphanumeric
2787 characters, each character listing a set of operations which is being
2788 controlled. Letters are reserved for ``standard'' rights, listed
2789 below. Digits are reserved for implementation or site defined rights.
2791 l - lookup (mailbox is visible to LIST/LSUB commands)
2792 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2793 SEARCH, COPY from mailbox)
2794 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2795 w - write (STORE flags other than \\SEEN and \\DELETED)
2796 i - insert (perform APPEND, COPY into mailbox)
2797 p - post (send mail to submission address for mailbox,
2798 not enforced by IMAP4 itself)
2799 c - create and delete mailbox (CREATE new sub-mailboxes in any
2800 implementation-defined hierarchy, RENAME or DELETE mailbox)
2801 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2802 a - administer (perform SETACL)" group)
2805 ,mailbox ',method ',acl form)))))
2807 ;; Group sorting commands
2808 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2810 (defun gnus-group-sort-groups (func &optional reverse)
2811 "Sort the group buffer according to FUNC.
2812 When used interactively, the sorting function used will be
2813 determined by the `gnus-group-sort-function' variable.
2814 If REVERSE (the prefix), reverse the sorting order."
2815 (interactive (list gnus-group-sort-function current-prefix-arg))
2816 (funcall gnus-group-sort-alist-function
2817 (gnus-make-sort-function func) reverse)
2818 (gnus-group-unmark-all-groups)
2819 (gnus-group-list-groups)
2820 (gnus-dribble-touch))
2822 (defun gnus-group-sort-flat (func reverse)
2823 ;; We peel off the dummy group from the alist.
2825 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2826 (pop gnus-newsrc-alist))
2828 (setq gnus-newsrc-alist
2829 (sort gnus-newsrc-alist func))
2831 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2832 ;; Regenerate the hash table.
2833 (gnus-make-hashtable-from-newsrc-alist)))
2835 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2836 "Sort the group buffer alphabetically by group name.
2837 If REVERSE, sort in reverse order."
2839 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2841 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2842 "Sort the group buffer alphabetically by real (unprefixed) group name.
2843 If REVERSE, sort in reverse order."
2845 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2847 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2848 "Sort the group buffer by number of unread articles.
2849 If REVERSE, sort in reverse order."
2851 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2853 (defun gnus-group-sort-groups-by-level (&optional reverse)
2854 "Sort the group buffer by group level.
2855 If REVERSE, sort in reverse order."
2857 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2859 (defun gnus-group-sort-groups-by-score (&optional reverse)
2860 "Sort the group buffer by group score.
2861 If REVERSE, sort in reverse order."
2863 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2865 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2866 "Sort the group buffer by group rank.
2867 If REVERSE, sort in reverse order."
2869 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2871 (defun gnus-group-sort-groups-by-method (&optional reverse)
2872 "Sort the group buffer alphabetically by back end name.
2873 If REVERSE, sort in reverse order."
2875 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2877 (defun gnus-group-sort-groups-by-server (&optional reverse)
2878 "Sort the group buffer alphabetically by server name.
2879 If REVERSE, sort in reverse order."
2881 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2883 ;;; Selected group sorting.
2885 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2886 "Sort the process/prefixed groups."
2887 (interactive (list current-prefix-arg gnus-group-sort-function))
2888 (let ((groups (gnus-group-process-prefix n)))
2889 (funcall gnus-group-sort-selected-function
2890 groups (gnus-make-sort-function func) reverse)
2891 (gnus-group-unmark-all-groups)
2892 (gnus-group-list-groups)
2893 (gnus-dribble-touch)))
2895 (defun gnus-group-sort-selected-flat (groups func reverse)
2896 (let (entries infos)
2897 ;; First find all the group entries for these groups.
2899 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2901 ;; Then sort the infos.
2905 (lambda (entry) (car entry))
2906 (setq entries (nreverse entries)))
2909 (setq infos (nreverse infos)))
2910 ;; Go through all the infos and replace the old entries
2911 ;; with the new infos.
2913 (setcar (car entries) (pop infos))
2915 ;; Update the hashtable.
2916 (gnus-make-hashtable-from-newsrc-alist)))
2918 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2919 "Sort the group buffer alphabetically by group name.
2920 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2921 sort in reverse order."
2922 (interactive (gnus-interactive "P\ny"))
2923 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2925 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2926 "Sort the group buffer alphabetically by real group name.
2927 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2928 sort in reverse order."
2929 (interactive (gnus-interactive "P\ny"))
2930 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2932 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2933 "Sort the group buffer by number of unread articles.
2934 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2935 sort in reverse order."
2936 (interactive (gnus-interactive "P\ny"))
2937 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2939 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2940 "Sort the group buffer by group level.
2941 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2942 sort in reverse order."
2943 (interactive (gnus-interactive "P\ny"))
2944 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2946 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2947 "Sort the group buffer by group score.
2948 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2949 sort in reverse order."
2950 (interactive (gnus-interactive "P\ny"))
2951 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2953 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2954 "Sort the group buffer by group rank.
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-rank reverse))
2960 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2961 "Sort the group buffer alphabetically by back end 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-method reverse))
2967 ;;; Sorting predicates.
2969 (defun gnus-group-sort-by-alphabet (info1 info2)
2970 "Sort alphabetically."
2971 (string< (gnus-info-group info1) (gnus-info-group info2)))
2973 (defun gnus-group-sort-by-real-name (info1 info2)
2974 "Sort alphabetically on real (unprefixed) names."
2975 (string< (gnus-group-real-name (gnus-info-group info1))
2976 (gnus-group-real-name (gnus-info-group info2))))
2978 (defun gnus-group-sort-by-unread (info1 info2)
2979 "Sort by number of unread articles."
2980 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
2981 (n2 (gnus-group-unread (gnus-info-group info1))))
2982 (< (or (and (numberp n1) n1) 0)
2983 (or (and (numberp n2) n2) 0))))
2985 (defun gnus-group-sort-by-level (info1 info2)
2987 (< (gnus-info-level info1) (gnus-info-level info2)))
2989 (defun gnus-group-sort-by-method (info1 info2)
2990 "Sort alphabetically by back end name."
2991 (string< (car (gnus-find-method-for-group
2992 (gnus-info-group info1) info1))
2993 (car (gnus-find-method-for-group
2994 (gnus-info-group info2) info2))))
2996 (defun gnus-group-sort-by-server (info1 info2)
2997 "Sort alphabetically by server name."
2998 (string< (gnus-method-to-full-server-name
2999 (gnus-find-method-for-group
3000 (gnus-info-group info1) info1))
3001 (gnus-method-to-full-server-name
3002 (gnus-find-method-for-group
3003 (gnus-info-group info2) info2))))
3005 (defun gnus-group-sort-by-score (info1 info2)
3006 "Sort by group score."
3007 (> (gnus-info-score info1) (gnus-info-score info2)))
3009 (defun gnus-group-sort-by-rank (info1 info2)
3010 "Sort by level and score."
3011 (let ((level1 (gnus-info-level info1))
3012 (level2 (gnus-info-level info2)))
3013 (or (< level1 level2)
3014 (and (= level1 level2)
3015 (> (gnus-info-score info1) (gnus-info-score info2))))))
3019 (defun gnus-group-clear-data (&optional arg)
3020 "Clear all marks and read ranges from the current group."
3022 (gnus-group-iterate arg
3025 (gnus-info-clear-data (setq info (gnus-get-info group)))
3026 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3027 (when (gnus-group-goto-group group)
3028 (gnus-group-update-group-line))))))
3030 (defun gnus-group-clear-data-on-native-groups ()
3031 "Clear all marks and read ranges from all native groups."
3033 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3034 (let ((alist (cdr gnus-newsrc-alist))
3036 (while (setq info (pop alist))
3037 (when (gnus-group-native-p (gnus-info-group info))
3038 (gnus-info-clear-data info)))
3039 (gnus-get-unread-articles)
3040 (gnus-dribble-touch)
3041 (when (gnus-y-or-n-p
3042 "Move the cache away to avoid problems in the future? ")
3043 (call-interactively 'gnus-cache-move-cache)))))
3045 (defun gnus-info-clear-data (info)
3046 "Clear all marks and read ranges from INFO."
3047 (let ((group (gnus-info-group info))
3049 (dolist (el (gnus-info-marks info))
3050 (push `(,(cdr el) add (,(car el))) action))
3051 (push `(,(gnus-info-read info) add (read)) action)
3054 (gnus-request-set-mark ,group ',action)
3055 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3056 (gnus-info-set-read ',info ',(gnus-info-read info))
3057 (when (gnus-group-goto-group ,group)
3058 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3059 (gnus-group-update-group-line))))
3060 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3062 (gnus-request-set-mark group action)
3063 (gnus-info-set-read info nil)
3064 (when (gnus-info-marks info)
3065 (gnus-info-set-marks info nil))))
3067 ;; Group catching up.
3069 (defun gnus-group-catchup-current (&optional n all)
3070 "Mark all unread articles in the current newsgroup as read.
3071 If prefix argument N is numeric, the next N newsgroups will be
3072 caught up. If ALL is non-nil, marked articles will also be marked as
3073 read. Cross references (Xref: header) of articles are ignored.
3074 The number of newsgroups that this function was unable to catch
3077 (let ((groups (gnus-group-process-prefix n))
3080 (unless groups (error "No groups selected"))
3082 (or (not gnus-interactive-catchup) ;Without confirmation?
3087 "Do you really want to mark all articles in %s as read? "
3088 "Mark all unread articles in %s as read? ")
3089 (if (= (length groups) 1)
3091 (format "these %d groups" (length groups)))))))
3093 (while (setq group (pop groups))
3094 (gnus-group-remove-mark group)
3095 ;; Virtual groups have to be given special treatment.
3096 (let ((method (gnus-find-method-for-group group)))
3097 (when (eq 'nnvirtual (car method))
3098 (nnvirtual-catchup-group
3099 (gnus-group-real-name group) (nth 1 method) all)))
3100 (if (>= (gnus-group-level group) gnus-level-zombie)
3101 (gnus-message 2 "Dead groups can't be caught up")
3103 (gnus-group-goto-group group)
3104 (gnus-group-catchup group all))
3105 (gnus-group-update-group-line)
3106 (setq ret (1+ ret)))))
3107 (gnus-group-next-unread-group 1)
3110 (defun gnus-group-catchup-current-all (&optional n)
3111 "Mark all articles in current newsgroup as read.
3112 Cross references (Xref: header) of articles are ignored."
3114 (gnus-group-catchup-current n 'all))
3116 (defun gnus-group-catchup (group &optional all)
3117 "Mark all articles in GROUP as read.
3118 If ALL is non-nil, all articles are marked as read.
3119 The return value is the number of articles that were marked as read,
3120 or nil if no action could be taken."
3121 (let* ((entry (gnus-group-entry group))
3123 (marks (gnus-info-marks (nth 2 entry)))
3124 (unread (gnus-sequence-of-unread-articles group)))
3125 ;; Remove entries for this group.
3126 (nnmail-purge-split-history (gnus-group-real-name group))
3127 ;; Do the updating only if the newsgroup isn't killed.
3128 (if (not (numberp (car entry)))
3129 (gnus-message 1 "Can't catch up %s; non-active group" group)
3130 (gnus-update-read-articles group nil)
3132 ;; Nix out the lists of marks and dormants.
3133 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3135 (list (cdr (assq 'dormant marks))
3137 (setq unread (gnus-range-add (gnus-range-add
3138 unread (cdr (assq 'dormant marks)))
3139 (cdr (assq 'tick marks))))
3140 (gnus-add-marked-articles group 'tick nil nil 'force)
3141 (gnus-add-marked-articles group 'dormant nil nil 'force))
3142 ;; Do auto-expirable marks if that's required.
3143 (when (gnus-group-auto-expirable-p group)
3144 (gnus-range-map (lambda (article)
3145 (gnus-add-marked-articles group 'expire (list article))
3146 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3148 (let ((gnus-newsgroup-name group))
3149 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3152 (defun gnus-group-expire-articles (&optional n)
3153 "Expire all expirable articles in the current newsgroup.
3154 Uses the process/prefix convention."
3156 (let ((groups (gnus-group-process-prefix n))
3159 (error "No groups to expire"))
3160 (while (setq group (pop groups))
3161 (gnus-group-remove-mark group)
3162 (gnus-group-expire-articles-1 group)
3163 (gnus-dribble-touch)
3164 (gnus-group-position-point))))
3166 (defun gnus-group-expire-articles-1 (group)
3167 (when (gnus-check-backend-function 'request-expire-articles group)
3168 (gnus-message 6 "Expiring articles in %s..." group)
3169 (let* ((info (gnus-get-info group))
3170 (expirable (if (gnus-group-total-expirable-p group)
3171 (cons nil (gnus-list-of-read-articles group))
3172 (assq 'expire (gnus-info-marks info))))
3173 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3174 (nnmail-expiry-target
3175 (or (gnus-group-find-parameter group 'expiry-target)
3176 nnmail-expiry-target)))
3178 (gnus-check-group group)
3181 (gnus-compress-sequence
3183 ;; We set the expiry variables to the group
3185 (let ((nnmail-expiry-wait-function nil)
3186 (nnmail-expiry-wait expiry-wait))
3187 (gnus-request-expire-articles
3188 (gnus-uncompress-sequence (cdr expirable)) group))
3189 ;; Just expire using the normal expiry values.
3190 (gnus-request-expire-articles
3191 (gnus-uncompress-sequence (cdr expirable)) group))))
3192 (gnus-close-group group))
3193 (gnus-message 6 "Expiring articles in %s...done" group)
3194 ;; Return the list of un-expired articles.
3197 (defun gnus-group-expire-all-groups ()
3198 "Expire all expirable articles in all newsgroups."
3201 (gnus-message 5 "Expiring...")
3202 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3203 (cdr gnus-newsrc-alist))))
3204 (gnus-group-expire-articles nil)))
3205 (gnus-group-position-point)
3206 (gnus-message 5 "Expiring...done"))
3208 (defun gnus-group-set-current-level (n level)
3209 "Set the level of the next N groups to LEVEL."
3214 (unless (gnus-group-process-prefix current-prefix-arg)
3215 (error "No group on the current line"))
3217 (let ((s (read-string
3218 (format "Level (default %s): "
3219 (or (gnus-group-group-level)
3220 gnus-level-default-subscribed)))))
3221 (if (string-match "^\\s-*$" s)
3222 (int-to-string (or (gnus-group-group-level)
3223 gnus-level-default-subscribed))
3225 (unless (and (>= level 1) (<= level gnus-level-killed))
3226 (error "Invalid level: %d" level))
3227 (let ((groups (gnus-group-process-prefix n))
3229 (while (setq group (pop groups))
3230 (gnus-group-remove-mark group)
3231 (gnus-message 6 "Changed level of %s from %d to %d"
3232 group (or (gnus-group-group-level) gnus-level-killed)
3234 (gnus-group-change-level
3235 group level (or (gnus-group-group-level) gnus-level-killed))
3236 (gnus-group-update-group-line)))
3237 (gnus-group-position-point))
3239 (defun gnus-group-unsubscribe (&optional n)
3240 "Unsubscribe the current group."
3242 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3244 (defun gnus-group-subscribe (&optional n)
3245 "Subscribe the current group."
3247 (gnus-group-unsubscribe-current-group n 'subscribe))
3249 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3250 "Toggle subscription of the current group.
3251 If given numerical prefix, toggle the N next groups."
3253 (dolist (group (gnus-group-process-prefix n))
3254 (gnus-group-remove-mark group)
3255 (gnus-group-unsubscribe-group
3258 ((eq do-sub 'unsubscribe)
3259 gnus-level-default-unsubscribed)
3260 ((eq do-sub 'subscribe)
3261 gnus-level-default-subscribed)
3262 ((<= (gnus-group-group-level) gnus-level-subscribed)
3263 gnus-level-default-unsubscribed)
3265 gnus-level-default-subscribed))
3267 (gnus-group-update-group-line))
3268 (gnus-group-next-group 1))
3270 (defun gnus-group-unsubscribe-group (group &optional level silent)
3271 "Toggle subscription to GROUP.
3272 Killed newsgroups are subscribed. If SILENT, don't try to update the
3275 (list (completing-read
3276 "Group: " gnus-active-hashtb nil
3277 (gnus-read-active-file-p)
3279 'gnus-group-history)))
3280 (let ((newsrc (gnus-group-entry group)))
3282 ((string-match "^[ \t]*$" group)
3283 (error "Empty group name"))
3285 ;; Toggle subscription flag.
3286 (gnus-group-change-level
3287 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3288 gnus-level-subscribed)
3289 (1+ gnus-level-subscribed)
3290 gnus-level-default-subscribed)))
3292 (gnus-group-update-group group)))
3293 ((and (stringp group)
3294 (or (not (gnus-read-active-file-p))
3295 (gnus-active group)))
3296 ;; Add new newsgroup.
3297 (gnus-group-change-level
3299 (if level level gnus-level-default-subscribed)
3300 (or (and (member group gnus-zombie-list)
3303 (when (gnus-group-group-name)
3304 (gnus-group-entry (gnus-group-group-name))))
3306 (gnus-group-update-group group)))
3307 (t (error "No such newsgroup: %s" group)))
3308 (gnus-group-position-point)))
3310 (defun gnus-group-transpose-groups (n)
3311 "Move the current newsgroup up N places.
3312 If given a negative prefix, move down instead. The difference between
3313 N and the number of steps taken is returned."
3315 (unless (gnus-group-group-name)
3316 (error "No group on current line"))
3317 (gnus-group-kill-group 1)
3319 (forward-line (- n))
3320 (gnus-group-yank-group)
3321 (gnus-group-position-point)))
3323 (defun gnus-group-kill-all-zombies (&optional dummy)
3324 "Kill all zombie newsgroups.
3325 The optional DUMMY should always be nil."
3326 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3328 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3329 (setq gnus-zombie-list nil)
3330 (gnus-dribble-touch)
3331 (gnus-group-list-groups)))
3333 (defun gnus-group-kill-region (begin end)
3334 "Kill newsgroups in current region (excluding current point).
3335 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3348 (beginning-of-line) ;Important when LINES < 1
3349 (gnus-group-kill-group lines)))
3351 (defun gnus-group-kill-group (&optional n discard)
3352 "Kill the next N groups.
3353 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3354 However, only groups that were alive can be yanked; already killed
3355 groups or zombie groups can't be yanked.
3356 The return value is the name of the group that was killed, or a list
3359 (let ((buffer-read-only nil)
3360 (groups (gnus-group-process-prefix n))
3361 group entry level out)
3362 (if (< (length groups) 10)
3363 ;; This is faster when there are few groups.
3365 (push (setq group (pop groups)) out)
3366 (gnus-group-remove-mark group)
3367 (setq level (gnus-group-group-level))
3369 (when (and (not discard)
3370 (setq entry (gnus-group-entry group)))
3373 (gnus-group-goto-group ,(gnus-group-group-name))
3374 (gnus-group-yank-group)))
3375 (push (cons (car entry) (nth 2 entry))
3376 gnus-list-of-killed-groups))
3377 (gnus-group-change-level
3378 (if entry entry group) gnus-level-killed (if entry nil level))
3379 (message "Killed group %s" group))
3380 ;; If there are lots and lots of groups to be killed, we use
3381 ;; this thing instead.
3382 (dolist (group (nreverse groups))
3383 (gnus-group-remove-mark group)
3385 (push group gnus-killed-list)
3386 (setq gnus-newsrc-alist
3387 (delq (assoc group gnus-newsrc-alist)
3389 (when gnus-group-change-level-function
3390 (funcall gnus-group-change-level-function
3391 group gnus-level-killed 3))
3393 ((setq entry (gnus-group-entry group))
3394 (push (cons (car entry) (nth 2 entry))
3395 gnus-list-of-killed-groups)
3396 (setcdr (cdr entry) (cdddr entry)))
3397 ((member group gnus-zombie-list)
3398 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3399 ;; There may be more than one instance displayed.
3400 (while (gnus-group-goto-group group)
3401 (gnus-delete-line)))
3402 (gnus-make-hashtable-from-newsrc-alist))
3404 (gnus-group-position-point)
3405 (if (< (length out) 2) (car out) (nreverse out))))
3407 (defun gnus-group-yank-group (&optional arg)
3408 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3409 The numeric ARG specifies how many newsgroups are to be yanked. The
3410 name of the newsgroup yanked is returned, or (if several groups are
3411 yanked) a list of yanked groups is returned."
3413 (setq arg (or arg 1))
3414 (let (info group prev out)
3415 (while (>= (decf arg) 0)
3416 (when (not (setq info (pop gnus-list-of-killed-groups)))
3417 (error "No more newsgroups to yank"))
3418 (push (setq group (nth 1 info)) out)
3419 ;; Find which newsgroup to insert this one before - search
3420 ;; backward until something suitable is found. If there are no
3421 ;; other newsgroups in this buffer, just make this newsgroup the
3423 (setq prev (gnus-group-group-name))
3424 (gnus-group-change-level
3425 info (gnus-info-level (cdr info)) gnus-level-killed
3426 (and prev (gnus-group-entry prev))
3428 (gnus-group-insert-group-line-info group)
3430 `(when (gnus-group-goto-group ,group)
3431 (gnus-group-kill-group 1))))
3433 (gnus-group-position-point)
3434 (if (< (length out) 2) (car out) (nreverse out))))
3436 (defun gnus-group-kill-level (level)
3437 "Kill all groups that is on a certain LEVEL."
3438 (interactive "nKill all groups on level: ")
3440 ((= level gnus-level-zombie)
3441 (setq gnus-killed-list
3442 (nconc gnus-zombie-list gnus-killed-list))
3443 (setq gnus-zombie-list nil))
3444 ((and (< level gnus-level-zombie)
3446 (or gnus-expert-user
3449 "Do you really want to kill all groups on level %d? "
3451 (let* ((prev gnus-newsrc-alist)
3454 (if (= (gnus-info-level (car alist)) level)
3456 (push (gnus-info-group (car alist)) gnus-killed-list)
3457 (setcdr prev (cdr alist)))
3459 (setq alist (cdr alist)))
3460 (gnus-make-hashtable-from-newsrc-alist)
3461 (gnus-group-list-groups)))
3463 (error "Can't kill; invalid level: %d" level))))
3465 (defun gnus-group-list-all-groups (&optional arg)
3466 "List all newsgroups with level ARG or lower.
3467 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3468 unsubscribed groups."
3470 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3472 ;; Redefine this to list ALL killed groups if prefix arg used.
3473 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3474 (defun gnus-group-list-killed (&optional arg)
3475 "List all killed newsgroups in the group buffer.
3476 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3477 entail asking the server for the groups."
3479 ;; Find all possible killed newsgroups if arg.
3481 (gnus-get-killed-groups))
3482 (if (not gnus-killed-list)
3483 (gnus-message 6 "No killed groups")
3484 (let (gnus-group-list-mode)
3485 (funcall gnus-group-prepare-function
3486 gnus-level-killed t gnus-level-killed))
3487 (goto-char (point-min)))
3488 (gnus-group-position-point))
3490 (defun gnus-group-list-zombies ()
3491 "List all zombie newsgroups in the group buffer."
3493 (if (not gnus-zombie-list)
3494 (gnus-message 6 "No zombie groups")
3495 (let (gnus-group-list-mode)
3496 (funcall gnus-group-prepare-function
3497 gnus-level-zombie t gnus-level-zombie))
3498 (goto-char (point-min)))
3499 (gnus-group-position-point))
3501 (defun gnus-group-list-active ()
3502 "List all groups that are available from the server(s)."
3504 ;; First we make sure that we have really read the active file.
3505 (unless (gnus-read-active-file-p)
3506 (let ((gnus-read-active-file t)
3507 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3508 (gnus-read-active-file)))
3509 ;; Find all groups and sort them.
3517 (push (symbol-name sym) list)))
3521 (buffer-read-only nil)
3525 (setq group (pop groups))
3526 (gnus-add-text-properties
3527 (point) (prog1 (1+ (point))
3529 (gnus-group-decoded-name group)
3531 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3533 'gnus-level (inline (gnus-group-level group)))))
3534 (goto-char (point-min))))
3536 (defun gnus-activate-all-groups (level)
3537 "Activate absolutely all groups."
3538 (interactive (list gnus-level-unsubscribed))
3539 (let ((gnus-activate-level level)
3540 (gnus-activate-foreign-newsgroups level))
3541 (gnus-group-get-new-news)))
3543 (defun gnus-group-get-new-news (&optional arg)
3544 "Get newly arrived articles.
3545 If ARG is a number, it specifies which levels you are interested in
3546 re-scanning. If ARG is non-nil and not a number, this will force
3547 \"hard\" re-reading of the active files from all servers."
3550 (let ((gnus-inhibit-demon t)
3551 ;; Binding this variable will inhibit multiple fetchings
3552 ;; of the same mail source.
3553 (nnmail-fetched-sources (list t)))
3554 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3555 (gnus-run-hooks 'gnus-get-new-news-hook)
3557 ;; Read any slave files.
3559 (gnus-master-read-slave-newsrc))
3561 ;; We might read in new NoCeM messages here.
3562 (when (and gnus-use-nocem
3564 (gnus-nocem-scan-groups))
3565 ;; If ARG is not a number, then we read the active file.
3566 (when (and arg (not (numberp arg)))
3567 (let ((gnus-read-active-file t))
3568 (gnus-read-active-file))
3571 ;; If the user wants it, we scan for new groups.
3572 (when (eq gnus-check-new-newsgroups 'always)
3573 (gnus-find-new-newsgroups)))
3575 (setq arg (gnus-group-default-level arg t))
3576 (if (and gnus-read-active-file (not arg))
3578 (gnus-read-active-file)
3579 (gnus-get-unread-articles arg))
3580 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3581 (gnus-get-unread-articles arg)))
3582 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3583 (gnus-group-list-groups (and (numberp arg)
3584 (max (car gnus-group-list-mode) arg)))))
3586 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3587 "Check for newly arrived news in the current group (and the N-1 next groups).
3588 The difference between N and the number of newsgroup checked is returned.
3589 If N is negative, this group and the N-1 previous groups will be checked."
3591 (let* ((groups (gnus-group-process-prefix n))
3592 (ret (if (numberp n) (- n (length groups)) 0))
3596 (gnus-inhibit-demon t)
3597 ;; Binding this variable will inhibit multiple fetchings
3598 ;; of the same mail source.
3599 (nnmail-fetched-sources (list t)))
3600 (gnus-run-hooks 'gnus-get-new-news-hook)
3601 (while (setq group (pop groups))
3602 (gnus-group-remove-mark group)
3603 ;; Bypass any previous denials from the server.
3604 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3605 (if (gnus-activate-group group (if dont-scan nil 'scan))
3607 (gnus-get-unread-articles-in-group
3608 (gnus-get-info group) (gnus-active group) t)
3609 (unless (gnus-virtual-group-p group)
3610 (gnus-close-group group))
3612 (gnus-agent-save-group-info
3613 method (gnus-group-real-name group) (gnus-active group)))
3614 (gnus-group-update-group group))
3615 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3617 (gnus-error 3 "Server denied access")
3618 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3621 (when gnus-goto-next-group-when-activating
3622 (gnus-group-next-unread-group 1 t))
3623 (gnus-summary-position-point)
3626 (defun gnus-group-fetch-faq (group &optional faq-dir)
3627 "Fetch the FAQ for the current group.
3628 If given a prefix argument, prompt for the FAQ dir
3632 (gnus-group-group-name)
3633 (when current-prefix-arg
3635 "FAQ dir: " (and (listp gnus-group-faq-directory)
3637 gnus-group-faq-directory))))))
3639 (error "No group name given"))
3640 (let ((dirs (or faq-dir gnus-group-faq-directory))
3642 (unless (listp dirs)
3643 (setq dirs (list dirs)))
3644 (while (and (not found)
3645 (setq dir (pop dirs)))
3646 (let ((name (gnus-group-real-name group)))
3647 (setq file (expand-file-name name dir)))
3648 (if (not (file-exists-p file))
3649 (gnus-message 1 "No such file: %s" file)
3650 (let ((enable-local-variables nil))
3654 (defun gnus-group-fetch-charter (group)
3655 "Fetch the charter for the current group.
3656 If given a prefix argument, prompt for a group."
3658 (list (or (when current-prefix-arg
3659 (completing-read "Group: " gnus-active-hashtb))
3660 (gnus-group-group-name)
3661 gnus-newsgroup-name)))
3663 (error "No group name given"))
3665 (condition-case nil (require 'url-http) (error nil))
3666 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3668 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3669 (setq hierarchy (match-string 1 name))
3670 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3671 (if (fboundp 'url-http-file-exists-p)
3672 (url-http-file-exists-p (eval url))
3674 (browse-url (eval url))
3675 (setq url (concat "http://" hierarchy
3676 ".news-admin.org/charters/" name))
3677 (if (and (fboundp 'url-http-file-exists-p)
3678 (url-http-file-exists-p url))
3680 (gnus-group-fetch-control group))))))
3682 (defun gnus-group-fetch-control (group)
3683 "Fetch the archived control messages for the current group.
3684 If given a prefix argument, prompt for a group."
3686 (list (or (when current-prefix-arg
3687 (completing-read "Group: " gnus-active-hashtb))
3688 (gnus-group-group-name)
3689 gnus-newsgroup-name)))
3691 (error "No group name given"))
3692 (let ((name (gnus-group-real-name group))
3694 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3695 (setq hierarchy (match-string 1 name))
3696 (if gnus-group-fetch-control-use-browse-url
3697 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3698 hierarchy "/" name ".gz"))
3699 (let ((enable-local-variables nil))
3700 (gnus-group-read-ephemeral-group
3702 `(nndoc ,group (nndoc-address
3703 ,(find-file-noselect
3704 (concat "/ftp@ftp.isc.org:/usenet/control/"
3705 hierarchy "/" name ".gz")))
3706 (nndoc-article-type mbox)) t nil nil))))))
3708 (defun gnus-group-describe-group (force &optional group)
3709 "Display a description of the current newsgroup."
3710 (interactive (list current-prefix-arg (gnus-group-group-name)))
3711 (let* ((method (gnus-find-method-for-group group))
3712 (mname (gnus-group-prefixed-name "" method))
3715 gnus-description-hashtb)
3716 (gnus-sethash mname nil gnus-description-hashtb))
3718 (error "No group name given"))
3719 (when (or (and gnus-description-hashtb
3720 ;; We check whether this group's method has been
3721 ;; queried for a description file.
3722 (gnus-gethash mname gnus-description-hashtb))
3723 (setq desc (gnus-group-get-description group))
3724 (gnus-read-descriptions-file method))
3726 (or desc (gnus-gethash group gnus-description-hashtb)
3727 "No description available")))))
3729 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3730 (defun gnus-group-describe-all-groups (&optional force)
3731 "Pop up a buffer with descriptions of all newsgroups."
3734 (setq gnus-description-hashtb nil))
3735 (when (not (or gnus-description-hashtb
3736 (gnus-read-all-descriptions-files)))
3737 (error "Couldn't request descriptions file"))
3738 (let ((buffer-read-only nil)
3744 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3745 (insert (format " *: %-20s %s\n"
3746 (gnus-group-name-decode
3747 (symbol-name group) charset)
3748 (gnus-group-name-decode
3749 (symbol-value group) charset))))
3750 (gnus-add-text-properties
3751 b (1+ b) (list 'gnus-group group
3752 'gnus-unread t 'gnus-marked nil
3753 'gnus-level (1+ gnus-level-subscribed))))
3754 gnus-description-hashtb)
3755 (goto-char (point-min))
3756 (gnus-group-position-point)))
3758 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3759 (defun gnus-group-apropos (regexp &optional search-description)
3760 "List all newsgroups that have names that match a regexp."
3761 (interactive "sGnus apropos (regexp): ")
3763 (obuf (current-buffer))
3765 ;; Go through all newsgroups that are known to Gnus.
3768 (and (symbol-name group)
3769 (string-match regexp (symbol-name group))
3770 (symbol-value group)
3771 (push (symbol-name group) groups)))
3773 ;; Also go through all descriptions that are known to Gnus.
3774 (when search-description
3777 (and (string-match regexp (symbol-value group))
3778 (push (symbol-name group) groups)))
3779 gnus-description-hashtb))
3781 (gnus-message 3 "No groups matched \"%s\"." regexp)
3782 ;; Print out all the groups.
3784 (pop-to-buffer "*Gnus Help*")
3785 (buffer-disable-undo)
3787 (setq groups (sort groups 'string<))
3789 ;; Groups may be entered twice into the list of groups.
3790 (when (not (string= (car groups) prev))
3791 (setq prev (car groups))
3792 (let ((charset (gnus-group-name-charset nil prev)))
3793 (insert (gnus-group-name-decode prev charset) "\n")
3794 (when (and gnus-description-hashtb
3795 (setq des (gnus-gethash (car groups)
3796 gnus-description-hashtb)))
3797 (insert " " (gnus-group-name-decode des charset) "\n"))))
3798 (setq groups (cdr groups)))
3799 (goto-char (point-min))))
3800 (pop-to-buffer obuf)))
3802 (defun gnus-group-description-apropos (regexp)
3803 "List all newsgroups that have names or descriptions that match REGEXP."
3804 (interactive "sGnus description apropos (regexp): ")
3805 (when (not (or gnus-description-hashtb
3806 (gnus-read-all-descriptions-files)))
3807 (error "Couldn't request descriptions file"))
3808 (gnus-group-apropos regexp t))
3810 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3811 (defun gnus-group-list-matching (level regexp &optional all lowest)
3812 "List all groups with unread articles that match REGEXP.
3813 If the prefix LEVEL is non-nil, it should be a number that says which
3814 level to cut off listing groups.
3815 If ALL, also list groups with no unread articles.
3816 If LOWEST, don't list groups with level lower than LOWEST.
3818 This command may read the active file."
3819 (interactive "P\nsList newsgroups matching: ")
3820 ;; First make sure active file has been read.
3822 (> (prefix-numeric-value level) gnus-level-killed))
3823 (gnus-get-killed-groups))
3824 (funcall gnus-group-prepare-function
3825 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3826 (goto-char (point-min))
3827 (gnus-group-position-point))
3829 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3830 "List all groups that match REGEXP.
3831 If the prefix LEVEL is non-nil, it should be a number that says which
3832 level to cut off listing groups.
3833 If LOWEST, don't list groups with level lower than LOWEST."
3834 (interactive "P\nsList newsgroups matching: ")
3836 (setq level (prefix-numeric-value level)))
3837 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3839 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3840 (defun gnus-group-save-newsrc (&optional force)
3841 "Save the Gnus startup files.
3842 If FORCE, force saving whether it is necessary or not."
3844 (gnus-save-newsrc-file force))
3846 (defun gnus-group-restart (&optional arg)
3847 "Force Gnus to read the .newsrc file."
3849 (when (gnus-yes-or-no-p
3850 (format "Are you sure you want to restart Gnus? "))
3851 (gnus-save-newsrc-file)
3855 (defun gnus-group-read-init-file ()
3856 "Read the Gnus elisp init file."
3858 (gnus-read-init-file)
3859 (gnus-message 5 "Read %s" gnus-init-file))
3861 (defun gnus-group-check-bogus-groups (&optional silent)
3862 "Check bogus newsgroups.
3863 If given a prefix, don't ask for confirmation before removing a bogus
3866 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3867 (gnus-group-list-groups))
3869 (defun gnus-group-find-new-groups (&optional arg)
3870 "Search for new groups and add them.
3871 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3872 With 1 C-u, use the `ask-server' method to query the server for new
3874 With 2 C-u's, use most complete method possible to query the server
3875 for new groups, and subscribe the new groups as zombies."
3877 (gnus-find-new-newsgroups (or arg 1))
3878 (gnus-group-list-groups))
3880 (defun gnus-group-edit-global-kill (&optional article group)
3881 "Edit the global kill file.
3882 If GROUP, edit that local kill file instead."
3884 (setq gnus-current-kill-article article)
3885 (gnus-kill-file-edit-file group)
3888 (substitute-command-keys
3889 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3890 (if group "local" "global")))))
3892 (defun gnus-group-edit-local-kill (article group)
3893 "Edit a local kill file."
3894 (interactive (list nil (gnus-group-group-name)))
3895 (gnus-group-edit-global-kill article group))
3897 (defun gnus-group-force-update ()
3898 "Update `.newsrc' file."
3900 (gnus-save-newsrc-file))
3902 (defvar gnus-backlog-articles)
3904 (defun gnus-group-suspend ()
3905 "Suspend the current Gnus session.
3906 In fact, cleanup buffers except for group mode buffer.
3907 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3909 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3910 (gnus-offer-save-summaries)
3911 ;; Kill Gnus buffers except for group mode buffer.
3912 (let ((group-buf (get-buffer gnus-group-buffer)))
3913 (mapcar (lambda (buf)
3914 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3915 (with-current-buffer buf
3916 (eq major-mode 'message-mode)))
3917 (gnus-kill-buffer buf)))
3919 (setq gnus-backlog-articles nil)
3920 (gnus-kill-gnus-frames)
3922 (bury-buffer group-buf)
3923 (delete-windows-on group-buf t))))
3925 (defun gnus-group-clear-dribble ()
3926 "Clear all information from the dribble buffer."
3928 (gnus-dribble-clear)
3929 (gnus-message 7 "Cleared dribble buffer"))
3931 (defun gnus-group-exit ()
3932 "Quit reading news after updating .newsrc.eld and .newsrc.
3933 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3936 (or noninteractive ;For gnus-batch-kill
3937 (not gnus-interactive-exit) ;Without confirmation
3939 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3940 (gnus-run-hooks 'gnus-exit-gnus-hook)
3941 ;; Offer to save data from non-quitted summary buffers.
3942 (gnus-offer-save-summaries)
3943 ;; Save the newsrc file(s).
3944 (gnus-save-newsrc-file)
3946 (gnus-close-backends)
3947 ;; Reset everything.
3949 ;; Allow the user to do things after cleaning up.
3950 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3952 (defun gnus-group-quit ()
3953 "Quit reading news without updating .newsrc.eld or .newsrc.
3954 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3956 (when (or noninteractive ;For gnus-batch-kill
3957 (zerop (buffer-size))
3958 (not (gnus-server-opened gnus-select-method))
3960 (not gnus-current-startup-file)
3962 (format "Quit reading news without saving %s? "
3963 (file-name-nondirectory gnus-current-startup-file))))
3964 (gnus-run-hooks 'gnus-exit-gnus-hook)
3965 (gnus-configure-windows 'group t)
3966 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3967 (not (zerop (save-excursion
3968 (set-buffer gnus-dribble-buffer)
3971 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3973 (gnus-close-backends)
3975 (gnus-kill-buffer gnus-group-buffer)
3976 ;; Allow the user to do things after cleaning up.
3977 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3979 (defun gnus-group-describe-briefly ()
3980 "Give a one line description of the group mode commands."
3982 (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")))
3984 (defun gnus-group-browse-foreign-server (method)
3985 "Browse a foreign news server.
3986 If called interactively, this function will ask for a select method
3987 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3988 If not, METHOD should be a list where the first element is the method
3989 and the second element is the address."
3991 (list (let ((how (completing-read
3993 (append gnus-valid-select-methods gnus-server-alist)
3994 nil t (cons "nntp" 0) 'gnus-method-history)))
3995 ;; We either got a back end name or a virtual server name.
3996 ;; If the first, we also need an address.
3997 (if (assoc how gnus-valid-select-methods)
3999 ;; Suggested by mapjph@bath.ac.uk.
4002 (mapcar (lambda (server) (list server))
4003 gnus-secondary-servers)))
4004 ;; We got a server name.
4006 (gnus-browse-foreign-server method))
4008 (defun gnus-group-set-info (info &optional method-only-group part)
4009 (when (or info part)
4010 (let* ((entry (gnus-group-entry
4011 (or method-only-group (gnus-info-group info))))
4013 (info (if method-only-group (nth 2 entry) info))
4015 (when method-only-group
4017 (error "Trying to change non-existent group %s" method-only-group))
4018 ;; We have received parts of the actual group info - either the
4019 ;; select method or the group parameters. We first check
4020 ;; whether we have to extend the info, and if so, do that.
4021 (let ((len (length info))
4022 (total (if (eq part 'method) 5 6)))
4024 (setcdr (nthcdr (1- len) info)
4025 (make-list (- total len) nil)))
4026 ;; Then we enter the new info.
4027 (setcar (nthcdr (1- total) info) part-info)))
4029 ;; This is a new group, so we just create it.
4031 (set-buffer gnus-group-buffer)
4032 (setq method (gnus-info-method info))
4033 (when (gnus-server-equal method "native")
4036 (set-buffer gnus-group-buffer)
4038 ;; It's a foreign group...
4039 (gnus-group-make-group
4040 (gnus-group-real-name (gnus-info-group info))
4041 (if (stringp method) method
4042 (prin1-to-string (car method)))
4044 (nth 1 (gnus-info-method info))))
4045 ;; It's a native group.
4046 (gnus-group-make-group (gnus-info-group info))))
4047 (gnus-message 6 "Note: New group created")
4049 (gnus-group-entry (gnus-group-prefixed-name
4050 (gnus-group-real-name (gnus-info-group info))
4051 (or (gnus-info-method info) gnus-select-method))))))
4052 ;; Whether it was a new group or not, we now have the entry, so we
4053 ;; can do the update.
4056 (setcar (nthcdr 2 entry) info)
4057 (when (and (not (eq (car entry) t))
4058 (gnus-active (gnus-info-group info)))
4059 (setcar entry (length
4060 (gnus-list-of-unread-articles (car info))))))
4061 (error "No such group: %s" (gnus-info-group info))))))
4063 (defun gnus-group-set-method-info (group select-method)
4064 (gnus-group-set-info select-method group 'method))
4066 (defun gnus-group-set-params-info (group params)
4067 (gnus-group-set-info params group 'params))
4069 (defun gnus-add-marked-articles (group type articles &optional info force)
4070 ;; Add ARTICLES of TYPE to the info of GROUP.
4071 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4072 ;; add, but replace marked articles of TYPE with ARTICLES.
4073 (let ((info (or info (gnus-get-info group)))
4076 (and (not (setq marked (nthcdr 3 info)))
4078 (setcdr (nthcdr 2 info)
4079 (list (list (cons type (gnus-compress-sequence
4081 (and (not (setq m (assq type (car marked))))
4084 (cons (cons type (gnus-compress-sequence articles t) )
4088 (setcar (nthcdr 3 info)
4089 (gnus-delete-alist type (car marked)))
4090 (setcdr m (gnus-compress-sequence articles t)))
4091 (setcdr m (gnus-compress-sequence
4092 (sort (nconc (gnus-uncompress-range (cdr m))
4093 (copy-sequence articles)) '<) t))))))
4095 (defun gnus-add-mark (group mark article)
4096 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4097 (let ((buffer (gnus-summary-buffer-name group)))
4098 (if (gnus-buffer-live-p buffer)
4100 (set-buffer (get-buffer buffer))
4101 (gnus-summary-add-mark article mark))
4102 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4106 ;;; Group timestamps
4109 (defun gnus-group-set-timestamp ()
4110 "Change the timestamp of the current group to the current time.
4111 This function can be used in hooks like `gnus-select-group-hook'
4112 or `gnus-group-catchup-group-hook'."
4113 (when gnus-newsgroup-name
4114 (let ((time (current-time)))
4115 (setcdr (cdr time) nil)
4116 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4118 (defsubst gnus-group-timestamp (group)
4119 "Return the timestamp for GROUP."
4120 (gnus-group-get-parameter group 'timestamp t))
4122 (defun gnus-group-timestamp-delta (group)
4123 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4124 (let* ((time (or (gnus-group-timestamp group)
4126 (delta (subtract-time (current-time) time)))
4127 (+ (* (nth 0 delta) 65536.0)
4130 (defun gnus-group-timestamp-string (group)
4131 "Return a string of the timestamp for GROUP."
4132 (let ((time (gnus-group-timestamp group)))
4135 (gnus-time-iso8601 time))))
4137 (defun gnus-group-list-cached (level &optional lowest)
4138 "List all groups with cached articles.
4139 If the prefix LEVEL is non-nil, it should be a number that says which
4140 level to cut off listing groups.
4141 If LOWEST, don't list groups with level lower than LOWEST.
4143 This command may read the active file."
4146 (setq level (prefix-numeric-value level)))
4147 (when (or (not level) (>= level gnus-level-zombie))
4149 (funcall gnus-group-prepare-function
4150 (or level gnus-level-subscribed)
4152 (let ((marks (gnus-info-marks info)))
4153 (assq 'cache marks)))
4156 (or (gnus-gethash group
4157 gnus-cache-active-hashtb)
4158 ;; Cache active file might use "."
4161 (mapconcat 'identity
4162 (split-string group ":")
4164 gnus-cache-active-hashtb))))
4165 (goto-char (point-min))
4166 (gnus-group-position-point))
4168 (defun gnus-group-list-dormant (level &optional lowest)
4169 "List all groups with dormant articles.
4170 If the prefix LEVEL is non-nil, it should be a number that says which
4171 level to cut off listing groups.
4172 If LOWEST, don't list groups with level lower than LOWEST.
4174 This command may read the active file."
4177 (setq level (prefix-numeric-value level)))
4178 (when (or (not level) (>= level gnus-level-zombie))
4180 (funcall gnus-group-prepare-function
4181 (or level gnus-level-subscribed)
4183 (let ((marks (gnus-info-marks info)))
4184 (assq 'dormant marks)))
4187 (goto-char (point-min))
4188 (gnus-group-position-point))
4190 (defun gnus-group-listed-groups ()
4191 "Return a list of listed groups."
4193 (goto-char (point-min))
4194 (while (setq point (text-property-not-all (point) (point-max)
4197 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4201 (defun gnus-group-list-plus (&optional args)
4202 "List groups plus the current selection."
4204 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4205 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4207 (push last-command-event unread-command-events)
4208 (if (featurep 'xemacs)
4209 (push (make-event 'key-press '(key ?A)) unread-command-events)
4210 (push ?A unread-command-events))
4211 (let (gnus-pick-mode keys)
4212 (setq keys (if (featurep 'xemacs)
4213 (events-to-keys (read-key-sequence nil))
4214 (read-key-sequence nil)))
4215 (setq func (lookup-key (current-local-map) keys)))
4219 (call-interactively func))))
4221 (defun gnus-group-list-flush (&optional args)
4222 "Flush groups from the current selection."
4224 (let ((gnus-group-list-option 'flush))
4225 (gnus-group-list-plus args)))
4227 (defun gnus-group-list-limit (&optional args)
4228 "List groups limited within the current selection."
4230 (let ((gnus-group-list-option 'limit))
4231 (gnus-group-list-plus args)))
4233 (defun gnus-group-mark-article-read (group article)
4234 "Mark ARTICLE read."
4235 (let ((buffer (gnus-summary-buffer-name group))
4236 (mark gnus-read-mark)
4238 (if (get-buffer buffer)
4239 (with-current-buffer buffer
4240 (setq active gnus-newsgroup-active)
4241 (gnus-activate-group group)
4242 (when gnus-newsgroup-prepared
4243 (when (and gnus-newsgroup-auto-expire
4244 (memq mark gnus-auto-expirable-marks))
4245 (setq mark gnus-expirable-mark))
4246 (setq mark (gnus-request-update-mark
4247 group article mark))
4248 (gnus-mark-article-as-read article mark)
4249 (setq gnus-newsgroup-active (gnus-active group))
4251 (setq n (1+ (cdr active)))
4252 (while (<= n (cdr gnus-newsgroup-active))
4253 (unless (eq n article)
4254 (push n gnus-newsgroup-unselected))
4256 (setq gnus-newsgroup-unselected
4257 (nreverse gnus-newsgroup-unselected)))))
4258 (gnus-activate-group group)
4259 (gnus-group-make-articles-read group (list article))
4260 (when (gnus-group-auto-expirable-p group)
4261 (gnus-add-marked-articles
4262 group 'expire (list article))))))
4264 (provide 'gnus-group)
4266 ;;; gnus-group.el ends here