1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (unless (boundp 'gnus-cache-active-hashtb)
49 (defvar gnus-cache-active-hashtb nil)))
51 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
52 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54 (defcustom gnus-group-archive-directory
55 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
56 "*The address of the (ding) archives."
57 :group 'gnus-group-foreign
60 (defcustom gnus-group-recent-archive-directory
61 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
62 "*The address of the most recent (ding) articles."
63 :group 'gnus-group-foreign
66 (defcustom gnus-no-groups-message "No Gnus is good news"
67 "*Message displayed by Gnus when no groups are available."
71 (defcustom gnus-keep-same-level nil
72 "*Non-nil means that the next newsgroup after the current will be on the same level.
73 When you type, for instance, `n' after reading the last article in the
74 current newsgroup, you will go to the next newsgroup. If this variable
75 is nil, the next newsgroup will be the next from the group
77 If this variable is non-nil, Gnus will either put you in the
78 next newsgroup with the same level, or, if no such newsgroup is
79 available, the next newsgroup with the lowest possible level higher
80 than the current level.
81 If this variable is `best', Gnus will make the next newsgroup the one
83 :group 'gnus-group-levels
84 :type '(choice (const nil)
86 (sexp :tag "other" t)))
88 (defcustom gnus-group-goto-unread t
89 "*If non-nil, movement commands will go to the next unread and subscribed group."
90 :link '(custom-manual "(gnus)Group Maneuvering")
91 :group 'gnus-group-various
94 (defcustom gnus-goto-next-group-when-activating t
95 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
96 :link '(custom-manual "(gnus)Scanning New Messages")
97 :group 'gnus-group-various
100 (defcustom gnus-permanently-visible-groups nil
101 "*Regexp to match groups that should always be listed in the group buffer.
102 This means that they will still be listed even when there are no
103 unread articles in the groups.
105 If nil, no groups are permanently visible."
106 :group 'gnus-group-listing
107 :type '(choice regexp (const nil)))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "*If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "*Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
121 (defcustom gnus-group-list-inactive-groups t
122 "*If non-nil, inactive groups will be listed."
123 :group 'gnus-group-listing
124 :group 'gnus-group-levels
127 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
128 "*Function used for sorting the group buffer.
129 This function will be called with group info entries as the arguments
130 for the groups to be sorted. Pre-made functions include
131 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
132 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
133 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
134 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136 This variable can also be a list of sorting functions. In that case,
137 the most significant sort function should be the last function in the
139 :group 'gnus-group-listing
140 :link '(custom-manual "(gnus)Sorting Groups")
141 :type '(repeat :value-to-internal (lambda (widget value)
142 (if (listp value) value (list value)))
143 :match (lambda (widget value)
145 (widget-editable-list-match widget value)))
146 (choice (function-item gnus-group-sort-by-alphabet)
147 (function-item gnus-group-sort-by-real-name)
148 (function-item gnus-group-sort-by-unread)
149 (function-item gnus-group-sort-by-level)
150 (function-item gnus-group-sort-by-score)
151 (function-item gnus-group-sort-by-method)
152 (function-item gnus-group-sort-by-server)
153 (function-item gnus-group-sort-by-rank)
154 (function :tag "other" nil))))
156 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
157 "*Format of group lines.
158 It works along the same lines as a normal formatting string,
159 with some simple extensions.
161 %M Only marked articles (character, \"*\" or \" \")
162 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
163 %L Level of subscribedness (integer)
164 %N Number of unread articles (integer)
165 %I Number of dormant articles (integer)
166 %i Number of ticked and dormant (integer)
167 %T Number of ticked articles (integer)
168 %R Number of read articles (integer)
169 %U Number of unseen articles (integer)
170 %t Estimated total number of articles (integer)
171 %y Number of unread, unticked articles (integer)
172 %G Group name (string)
173 %g Qualified group name (string)
174 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
175 %C Group comment (string)
176 %D Group description (string)
177 %s Select method (string)
178 %o Moderated group (char, \"m\")
179 %p Process mark (char)
180 %B Whether a summary buffer for the group is open (char, \"*\")
181 %O Moderated group (string, \"(m)\" or \"\")
182 %P Topic indentation (string)
183 %m Whether there is new(ish) mail in the group (char, \"%\")
184 %w Number of new(ish) mails in the group (integer)
185 %n Select from where (string)
186 %z A string that look like `<%s:%n>' if a foreign select method is used
187 %d The date the group was last entered.
188 %E Icon as defined by `gnus-group-icon-list'.
189 %F The disk space used by the articles fetched by both the cache and agent.
190 %u User defined specifier. The next character in the format string should
191 be a letter. Gnus will call the function gnus-user-format-function-X,
192 where X is the letter following %u. The function will be passed a
193 single dummy parameter as argument. The function should return a
194 string, which will be inserted into the buffer just like information
195 from any other group specifier.
197 Note that this format specification is not always respected. For
198 reasons of efficiency, when listing killed groups, this specification
199 is ignored altogether. If the spec is changed considerably, your
200 output may end up looking strange when listing both alive and killed
203 If you use %o or %O, reading the active file will be slower and quite
204 a bit of extra memory will be used. %D and %F will also worsen
205 performance. Also note that if you change the format specification to
206 include any of these specs, you must probably re-start Gnus to see
209 General format specifiers can also be used.
210 See Info node `(gnus)Formatting Variables'."
211 :link '(custom-manual "(gnus)Formatting Variables")
212 :group 'gnus-group-visual
215 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
216 "*The format specification for the group mode line.
217 It works along the same lines as a normal formatting string,
218 with some simple extensions:
220 %S The native news server.
221 %M The native select method.
222 %: \":\" if %S isn't \"\"."
223 :group 'gnus-group-visual
226 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
227 (when (featurep 'xemacs)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
229 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
231 (defcustom gnus-group-menu-hook nil
232 "Hook run after the creation of the group mode menu."
233 :group 'gnus-group-various
236 (defcustom gnus-group-catchup-group-hook nil
237 "Hook run when catching up a group from the group buffer."
238 :group 'gnus-group-various
239 :link '(custom-manual "(gnus)Group Data")
242 (defcustom gnus-group-update-group-hook nil
243 "Hook called when updating group lines."
244 :group 'gnus-group-visual
247 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
248 "*A function that is called to generate the group buffer.
249 The function is called with three arguments: The first is a number;
250 all group with a level less or equal to that number should be listed,
251 if the second is non-nil, empty groups should also be displayed. If
252 the third is non-nil, it is a number. No groups with a level lower
253 than this number should be displayed.
255 The only current function implemented is `gnus-group-prepare-flat'."
256 :group 'gnus-group-listing
259 (defcustom gnus-group-prepare-hook nil
260 "Hook called after the group buffer has been generated.
261 If you want to modify the group buffer, you can use this hook."
262 :group 'gnus-group-listing
265 (defcustom gnus-suspend-gnus-hook nil
266 "Hook called when suspending (not exiting) Gnus."
270 (defcustom gnus-exit-gnus-hook nil
271 "Hook called when exiting Gnus."
275 (defcustom gnus-after-exiting-gnus-hook nil
276 "Hook called after exiting Gnus."
280 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
281 "Hook called when a group line is changed.
282 The hook will not be called if `gnus-visual' is nil.
284 The default function `gnus-group-highlight-line' will
285 highlight the line according to the `gnus-group-highlight'
287 :group 'gnus-group-visual
290 (defcustom gnus-useful-groups
291 '(("(ding) mailing list mirrored at sunsite.auc.dk"
293 (nntp "sunsite.auc.dk"
294 (nntp-address "sunsite.auc.dk")))
297 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
301 (nndoc-article-type mbox)
302 (eval `(nndoc-address
303 ,(let ((file (nnheader-find-etc-directory
306 (error "Couldn't find doc group"))
308 "*Alist of useful group-server pairs."
309 :group 'gnus-group-listing
310 :type '(repeat (list (string :tag "Description")
312 (sexp :tag "Method"))))
314 (defcustom gnus-group-highlight
316 ((and mailp (= unread 0) (eq level 1)) .
317 gnus-group-mail-1-empty-face)
318 ((and mailp (eq level 1)) .
319 gnus-group-mail-1-face)
320 ((and mailp (= unread 0) (eq level 2)) .
321 gnus-group-mail-2-empty-face)
322 ((and mailp (eq level 2)) .
323 gnus-group-mail-2-face)
324 ((and mailp (= unread 0) (eq level 3)) .
325 gnus-group-mail-3-empty-face)
326 ((and mailp (eq level 3)) .
327 gnus-group-mail-3-face)
328 ((and mailp (= unread 0)) .
329 gnus-group-mail-low-empty-face)
331 gnus-group-mail-low-face)
333 ((and (= unread 0) (eq level 1)) .
334 gnus-group-news-1-empty-face)
335 ((and (eq level 1)) .
336 gnus-group-news-1-face)
337 ((and (= unread 0) (eq level 2)) .
338 gnus-group-news-2-empty-face)
339 ((and (eq level 2)) .
340 gnus-group-news-2-face)
341 ((and (= unread 0) (eq level 3)) .
342 gnus-group-news-3-empty-face)
343 ((and (eq level 3)) .
344 gnus-group-news-3-face)
345 ((and (= unread 0) (eq level 4)) .
346 gnus-group-news-4-empty-face)
347 ((and (eq level 4)) .
348 gnus-group-news-4-face)
349 ((and (= unread 0) (eq level 5)) .
350 gnus-group-news-5-empty-face)
351 ((and (eq level 5)) .
352 gnus-group-news-5-face)
353 ((and (= unread 0) (eq level 6)) .
354 gnus-group-news-6-empty-face)
355 ((and (eq level 6)) .
356 gnus-group-news-6-face)
357 ((and (= unread 0)) .
358 gnus-group-news-low-empty-face)
360 gnus-group-news-low-face))
361 "*Controls the highlighting of group buffer lines.
363 Below is a list of `Form'/`Face' pairs. When deciding how a a
364 particular group line should be displayed, each form is
365 evaluated. The content of the face field after the first true form is
366 used. You can change how those group lines are displayed by
367 editing the face field.
369 It is also possible to change and add form fields, but currently that
370 requires an understanding of Lisp expressions. Hopefully this will
371 change in a future release. For now, you can use the following
372 variables in the Lisp expression:
374 group: The name of the group.
375 unread: The number of unread articles in the group.
376 method: The select method used.
377 mailp: Whether it's a mail group or not.
378 level: The level of the group.
379 score: The score of the group.
380 ticked: The number of ticked articles."
381 :group 'gnus-group-visual
382 :type '(repeat (cons (sexp :tag "Form") face)))
384 (defcustom gnus-new-mail-mark ?%
385 "Mark used for groups with new mail."
386 :group 'gnus-group-visual
389 (defgroup gnus-group-icons nil
390 "Add Icons to your group buffer. "
391 :group 'gnus-group-visual)
393 (defcustom gnus-group-icon-list
395 "*Controls the insertion of icons into group buffer lines.
397 Below is a list of `Form'/`File' pairs. When deciding how a
398 particular group line should be displayed, each form is evaluated.
399 The icon from the file field after the first true form is used. You
400 can change how those group lines are displayed by editing the file
401 field. The File will either be found in the
402 `gnus-group-glyph-directory' or by designating absolute name of the
405 It is also possible to change and add form fields, but currently that
406 requires an understanding of Lisp expressions. Hopefully this will
407 change in a future release. For now, you can use the following
408 variables in the Lisp expression:
410 group: The name of the group.
411 unread: The number of unread articles in the group.
412 method: The select method used.
413 mailp: Whether it's a mail group or not.
414 newsp: Whether it's a news group or not
415 level: The level of the group.
416 score: The score of the group.
417 ticked: The number of ticked articles."
418 :group 'gnus-group-icons
419 :type '(repeat (cons (sexp :tag "Form") file)))
421 (defcustom gnus-group-name-charset-method-alist nil
422 "Alist of method and the charset for group names.
425 (((nntp \"news.com.cn\") . cn-gb-2312))"
428 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
430 (defcustom gnus-group-name-charset-group-alist
431 (if (mm-coding-system-p 'utf-8)
432 '(("[^\000-\177]" . utf-8))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
443 If non-nil, the value should be a string, e.g. \"nnml:\",
444 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
445 in the minibuffer prompt."
446 :group 'gnus-group-various
447 :type '(choice (string :tag "Prompt string")
448 (const :tag "Empty" nil)))
450 (defvar gnus-group-listing-limit 1000
451 "*A limit of the number of groups when listing.
452 If the number of groups is larger than the limit, list them in a
455 ;;; Internal variables
457 (defvar gnus-group-is-exiting-p nil)
458 (defvar gnus-group-is-exiting-without-update-p nil)
459 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
460 "Function for sorting the group buffer.")
462 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
463 "Function for sorting the selected groups in the group buffer.")
465 (defvar gnus-group-indentation-function nil)
466 (defvar gnus-goto-missing-group-function nil)
467 (defvar gnus-group-update-group-function nil)
468 (defvar gnus-group-goto-next-group-function nil
469 "Function to override finding the next group after listing groups.")
471 (defvar gnus-group-edit-buffer nil)
473 (defvar gnus-group-line-format-alist
474 `((?M gnus-tmp-marked-mark ?c)
475 (?S gnus-tmp-subscribed ?c)
476 (?L gnus-tmp-level ?d)
477 (?N (cond ((eq number t) "*" )
481 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
482 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
484 (?R gnus-tmp-number-of-read ?s)
485 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
486 (?t gnus-tmp-number-total ?d)
487 (?y gnus-tmp-number-of-unread ?s)
488 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
489 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
490 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
491 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
492 (?g gnus-tmp-group ?s)
493 (?G gnus-tmp-qualified-group ?s)
494 (?c (gnus-short-group-name gnus-tmp-group) ?s)
495 (?C gnus-tmp-comment ?s)
496 (?D gnus-tmp-newsgroup-description ?s)
497 (?o gnus-tmp-moderated ?c)
498 (?O gnus-tmp-moderated-string ?s)
499 (?p gnus-tmp-process-marked ?c)
500 (?s gnus-tmp-news-server ?s)
501 (?n gnus-tmp-news-method ?s)
502 (?P gnus-group-indentation ?s)
503 (?E gnus-tmp-group-icon ?s)
504 (?B gnus-tmp-summary-live ?c)
505 (?z gnus-tmp-news-method-string ?s)
506 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
507 (?w (if (gnus-news-group-p gnus-tmp-group)
511 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
514 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
515 (?u gnus-tmp-user-defined ?s)
516 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
519 (defvar gnus-group-mode-line-format-alist
520 `((?S gnus-tmp-news-server ?s)
521 (?M gnus-tmp-news-method ?s)
522 (?u gnus-tmp-user-defined ?s)
523 (?: gnus-tmp-colon ?s)))
525 (defvar gnus-topic-topology nil
526 "The complete topic hierarchy.")
528 (defvar gnus-topic-alist nil
529 "The complete topic-group alist.")
531 (defvar gnus-group-marked nil)
533 (defvar gnus-group-list-mode nil)
536 (defvar gnus-group-icon-cache nil)
538 (defvar gnus-group-listed-groups nil)
539 (defvar gnus-group-list-option nil)
545 (put 'gnus-group-mode 'mode-class 'special)
547 (gnus-define-keys gnus-group-mode-map
548 " " gnus-group-read-group
549 "=" gnus-group-select-group
550 "\r" gnus-group-select-group
551 "\M-\r" gnus-group-quick-select-group
552 "\M- " gnus-group-visible-select-group
553 [(meta control return)] gnus-group-select-group-ephemerally
554 "j" gnus-group-jump-to-group
555 "n" gnus-group-next-unread-group
556 "p" gnus-group-prev-unread-group
557 "\177" gnus-group-prev-unread-group
558 [delete] gnus-group-prev-unread-group
559 [backspace] gnus-group-prev-unread-group
560 "N" gnus-group-next-group
561 "P" gnus-group-prev-group
562 "\M-n" gnus-group-next-unread-group-same-level
563 "\M-p" gnus-group-prev-unread-group-same-level
564 "," gnus-group-best-unread-group
565 "." gnus-group-first-unread-group
566 "u" gnus-group-unsubscribe-current-group
567 "U" gnus-group-unsubscribe-group
568 "c" gnus-group-catchup-current
569 "C" gnus-group-catchup-current-all
570 "\M-c" gnus-group-clear-data
571 "l" gnus-group-list-groups
572 "L" gnus-group-list-all-groups
575 "g" gnus-group-get-new-news
576 "\M-g" gnus-group-get-new-news-this-group
577 "R" gnus-group-restart
578 "r" gnus-group-read-init-file
579 "B" gnus-group-browse-foreign-server
580 "b" gnus-group-check-bogus-groups
581 "F" gnus-group-find-new-groups
582 "\C-c\C-d" gnus-group-describe-group
583 "\M-d" gnus-group-describe-all-groups
584 "\C-c\C-a" gnus-group-apropos
585 "\C-c\M-\C-a" gnus-group-description-apropos
586 "a" gnus-group-post-news
587 "\ek" gnus-group-edit-local-kill
588 "\eK" gnus-group-edit-global-kill
589 "\C-k" gnus-group-kill-group
590 "\C-y" gnus-group-yank-group
591 "\C-w" gnus-group-kill-region
592 "\C-x\C-t" gnus-group-transpose-groups
593 "\C-c\C-l" gnus-group-list-killed
594 "\C-c\C-x" gnus-group-expire-articles
595 "\C-c\M-\C-x" gnus-group-expire-all-groups
597 "s" gnus-group-save-newsrc
598 "z" gnus-group-suspend
601 "?" gnus-group-describe-briefly
602 "\C-c\C-i" gnus-info-find-node
603 "\M-e" gnus-group-edit-group-method
604 "^" gnus-group-enter-server-mode
605 gnus-mouse-2 gnus-mouse-pick-group
606 "<" beginning-of-buffer
609 "\C-c\C-n" gnus-namazu-search
610 "\C-c\C-s" gnus-group-sort-groups
612 "\C-c\M-g" gnus-activate-all-groups
613 "\M-&" gnus-group-universal-argument
614 "#" gnus-group-mark-group
615 "\M-#" gnus-group-unmark-group)
617 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
618 "m" gnus-group-mark-group
619 "u" gnus-group-unmark-group
620 "w" gnus-group-mark-region
621 "b" gnus-group-mark-buffer
622 "r" gnus-group-mark-regexp
623 "U" gnus-group-unmark-all-groups)
625 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
626 "u" gnus-sieve-update
627 "g" gnus-sieve-generate)
629 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
630 "d" gnus-group-make-directory-group
631 "h" gnus-group-make-help-group
632 "u" gnus-group-make-useful-group
633 "a" gnus-group-make-archive-group
634 "k" gnus-group-make-kiboze-group
635 "l" gnus-group-nnimap-edit-acl
636 "m" gnus-group-make-group
637 "n" gnus-group-make-shimbun-group
638 "E" gnus-group-edit-group
639 "e" gnus-group-edit-group-method
640 "p" gnus-group-edit-group-parameters
641 "v" gnus-group-add-to-virtual
642 "V" gnus-group-make-empty-virtual
643 "D" gnus-group-enter-directory
644 "f" gnus-group-make-doc-group
645 "G" gnus-group-make-nnir-group
646 "w" gnus-group-make-web-group
647 "M" gnus-group-read-ephemeral-group
648 "r" gnus-group-rename-group
649 "R" gnus-group-make-rss-group
650 "c" gnus-group-customize
651 "x" gnus-group-nnimap-expunge
652 "\177" gnus-group-delete-group
653 [delete] gnus-group-delete-group)
655 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
656 "b" gnus-group-brew-soup
657 "w" gnus-soup-save-areas
658 "s" gnus-soup-send-replies
659 "p" gnus-soup-pack-packet
660 "r" nnsoup-pack-replies)
662 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
663 "s" gnus-group-sort-groups
664 "a" gnus-group-sort-groups-by-alphabet
665 "u" gnus-group-sort-groups-by-unread
666 "l" gnus-group-sort-groups-by-level
667 "v" gnus-group-sort-groups-by-score
668 "r" gnus-group-sort-groups-by-rank
669 "m" gnus-group-sort-groups-by-method
670 "n" gnus-group-sort-groups-by-real-name)
672 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
673 "s" gnus-group-sort-selected-groups
674 "a" gnus-group-sort-selected-groups-by-alphabet
675 "u" gnus-group-sort-selected-groups-by-unread
676 "l" gnus-group-sort-selected-groups-by-level
677 "v" gnus-group-sort-selected-groups-by-score
678 "r" gnus-group-sort-selected-groups-by-rank
679 "m" gnus-group-sort-selected-groups-by-method
680 "n" gnus-group-sort-selected-groups-by-real-name)
682 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
683 "k" gnus-group-list-killed
684 "z" gnus-group-list-zombies
685 "s" gnus-group-list-groups
686 "u" gnus-group-list-all-groups
687 "A" gnus-group-list-active
688 "a" gnus-group-apropos
689 "d" gnus-group-description-apropos
690 "m" gnus-group-list-matching
691 "M" gnus-group-list-all-matching
692 "l" gnus-group-list-level
693 "c" gnus-group-list-cached
694 "?" gnus-group-list-dormant)
696 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
697 "k" gnus-group-list-limit
698 "z" gnus-group-list-limit
699 "s" gnus-group-list-limit
700 "u" gnus-group-list-limit
701 "A" gnus-group-list-limit
702 "m" gnus-group-list-limit
703 "M" gnus-group-list-limit
704 "l" gnus-group-list-limit
705 "c" gnus-group-list-limit
706 "?" gnus-group-list-limit)
708 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
709 "k" gnus-group-list-flush
710 "z" gnus-group-list-flush
711 "s" gnus-group-list-flush
712 "u" gnus-group-list-flush
713 "A" gnus-group-list-flush
714 "m" gnus-group-list-flush
715 "M" gnus-group-list-flush
716 "l" gnus-group-list-flush
717 "c" gnus-group-list-flush
718 "?" gnus-group-list-flush)
720 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
721 "k" gnus-group-list-plus
722 "z" gnus-group-list-plus
723 "s" gnus-group-list-plus
724 "u" gnus-group-list-plus
725 "A" gnus-group-list-plus
726 "m" gnus-group-list-plus
727 "M" gnus-group-list-plus
728 "l" gnus-group-list-plus
729 "c" gnus-group-list-plus
730 "?" gnus-group-list-plus)
732 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
733 "f" gnus-score-flush-cache
734 "e" gnus-score-edit-all-score)
736 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
737 "c" gnus-group-fetch-charter
738 "C" gnus-group-fetch-control
739 "d" gnus-group-describe-group
740 "f" gnus-group-fetch-faq
743 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
744 "l" gnus-group-set-current-level
745 "t" gnus-group-unsubscribe-current-group
746 "s" gnus-group-unsubscribe-group
747 "k" gnus-group-kill-group
748 "y" gnus-group-yank-group
749 "w" gnus-group-kill-region
750 "\C-k" gnus-group-kill-level
751 "z" gnus-group-kill-all-zombies)
753 (defun gnus-topic-mode-p ()
754 "Return non-nil in `gnus-topic-mode'."
755 (and (boundp 'gnus-topic-mode)
756 (symbol-value 'gnus-topic-mode)))
758 (defun gnus-group-make-menu-bar ()
759 (gnus-turn-off-edit-menu 'group)
760 (unless (boundp 'gnus-group-reading-menu)
763 gnus-group-reading-menu gnus-group-mode-map ""
765 ["Read" gnus-group-read-group
766 :included (not (gnus-topic-mode-p))
767 :active (gnus-group-group-name)]
768 ["Read " gnus-topic-read-group
769 :included (gnus-topic-mode-p)]
770 ["Select" gnus-group-select-group
771 :included (not (gnus-topic-mode-p))
772 :active (gnus-group-group-name)]
773 ["Select " gnus-topic-select-group
774 :included (gnus-topic-mode-p)]
775 ["See old articles" (gnus-group-select-group 'all)
776 :keys "C-u SPC" :active (gnus-group-group-name)]
777 ["Catch up" gnus-group-catchup-current
778 :included (not (gnus-topic-mode-p))
779 :active (gnus-group-group-name)
780 ,@(if (featurep 'xemacs) nil
781 '(:help "Mark unread articles in the current group as read"))]
782 ["Catch up " gnus-topic-catchup-articles
783 :included (gnus-topic-mode-p)
784 ,@(if (featurep 'xemacs) nil
785 '(:help "Mark unread articles in the current group or topic as read"))]
786 ["Catch up all articles" gnus-group-catchup-current-all
787 (gnus-group-group-name)]
788 ["Check for new articles" gnus-group-get-new-news-this-group
789 :included (not (gnus-topic-mode-p))
790 :active (gnus-group-group-name)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Check for new messages in current group"))]
793 ["Check for new articles " gnus-topic-get-new-news-this-topic
794 :included (gnus-topic-mode-p)
795 ,@(if (featurep 'xemacs) nil
796 '(:help "Check for new messages in current group or topic"))]
797 ["Toggle subscription" gnus-group-unsubscribe-current-group
798 (gnus-group-group-name)]
799 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
800 ,@(if (featurep 'xemacs) nil
801 '(:help "Kill (remove) current group"))]
802 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
803 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
804 ,@(if (featurep 'xemacs) nil
805 '(:help "Display description of the current group"))]
806 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
807 ["Fetch charter" gnus-group-fetch-charter
808 :active (gnus-group-group-name)
809 ,@(if (featurep 'xemacs) nil
810 '(:help "Display the charter of the current group"))]
811 ["Fetch control message" gnus-group-fetch-control
812 :active (gnus-group-group-name)
813 ,@(if (featurep 'xemacs) nil
814 '(:help "Display the archived control message for the current group"))]
815 ;; Actually one should check, if any of the marked groups gives t for
816 ;; (gnus-check-backend-function 'request-expire-articles ...)
817 ["Expire articles" gnus-group-expire-articles
818 :included (not (gnus-topic-mode-p))
819 :active (or (and (gnus-group-group-name)
820 (gnus-check-backend-function
821 'request-expire-articles
822 (gnus-group-group-name))) gnus-group-marked)]
823 ["Expire articles " gnus-topic-expire-articles
824 :included (gnus-topic-mode-p)]
825 ["Set group level..." gnus-group-set-current-level
826 (gnus-group-group-name)]
827 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
828 ["Customize" gnus-group-customize (gnus-group-group-name)]
830 ["Parameters" gnus-group-edit-group-parameters
831 :included (not (gnus-topic-mode-p))
832 :active (gnus-group-group-name)]
833 ["Parameters " gnus-topic-edit-parameters
834 :included (gnus-topic-mode-p)]
835 ["Select method" gnus-group-edit-group-method
836 (gnus-group-group-name)]
837 ["Info" gnus-group-edit-group (gnus-group-group-name)]
838 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
839 ["Global kill file" gnus-group-edit-global-kill t])))
842 gnus-group-group-menu gnus-group-mode-map ""
845 ["List unread subscribed groups" gnus-group-list-groups t]
846 ["List (un)subscribed groups" gnus-group-list-all-groups t]
847 ["List killed groups" gnus-group-list-killed gnus-killed-list]
848 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
849 ["List level..." gnus-group-list-level t]
850 ["Describe all groups" gnus-group-describe-all-groups t]
851 ["Group apropos..." gnus-group-apropos t]
852 ["Group and description apropos..." gnus-group-description-apropos t]
853 ["List groups matching..." gnus-group-list-matching t]
854 ["List all groups matching..." gnus-group-list-all-matching t]
855 ["List active file" gnus-group-list-active t]
856 ["List groups with cached" gnus-group-list-cached t]
857 ["List groups with dormant" gnus-group-list-dormant t])
859 ["Default sort" gnus-group-sort-groups t]
860 ["Sort by method" gnus-group-sort-groups-by-method t]
861 ["Sort by rank" gnus-group-sort-groups-by-rank t]
862 ["Sort by score" gnus-group-sort-groups-by-score t]
863 ["Sort by level" gnus-group-sort-groups-by-level t]
864 ["Sort by unread" gnus-group-sort-groups-by-unread t]
865 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
866 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
867 ("Sort process/prefixed"
868 ["Default sort" gnus-group-sort-selected-groups
869 (not (gnus-topic-mode-p))]
870 ["Sort by method" gnus-group-sort-selected-groups-by-method
871 (not (gnus-topic-mode-p))]
872 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
873 (not (gnus-topic-mode-p))]
874 ["Sort by score" gnus-group-sort-selected-groups-by-score
875 (not (gnus-topic-mode-p))]
876 ["Sort by level" gnus-group-sort-selected-groups-by-level
877 (not (gnus-topic-mode-p))]
878 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
879 (not (gnus-topic-mode-p))]
880 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
881 (not (gnus-topic-mode-p))]
882 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
883 (not (gnus-topic-mode-p))])
885 ["Mark group" gnus-group-mark-group
886 (and (gnus-group-group-name)
887 (not (memq (gnus-group-group-name) gnus-group-marked)))]
888 ["Unmark group" gnus-group-unmark-group
889 (and (gnus-group-group-name)
890 (memq (gnus-group-group-name) gnus-group-marked))]
891 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
892 ["Mark regexp..." gnus-group-mark-regexp t]
893 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
894 ["Mark buffer" gnus-group-mark-buffer t]
895 ["Execute command" gnus-group-universal-argument
896 (or gnus-group-marked (gnus-group-group-name))])
898 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
899 ["Kill all newsgroups in region" gnus-group-kill-region
900 :active (gnus-mark-active-p)]
901 ["Kill all zombie groups" gnus-group-kill-all-zombies
903 ["Kill all groups on level..." gnus-group-kill-level t])
905 ["Make a foreign group..." gnus-group-make-group t]
906 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
907 ["Add a directory group..." gnus-group-make-directory-group t]
908 ["Add the help group" gnus-group-make-help-group t]
909 ["Add the archive group" gnus-group-make-archive-group t]
910 ["Make a doc group..." gnus-group-make-doc-group t]
911 ["Make a web group..." gnus-group-make-web-group t]
912 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
913 ["Make a virtual group..." gnus-group-make-empty-virtual t]
914 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
915 ["Make an RSS group..." gnus-group-make-rss-group t]
916 ["Rename group..." gnus-group-rename-group
917 (gnus-check-backend-function
918 'request-rename-group (gnus-group-group-name))]
919 ["Delete group" gnus-group-delete-group
920 (gnus-check-backend-function
921 'request-delete-group (gnus-group-group-name))])
923 ["Next" gnus-group-next-group t]
924 ["Previous" gnus-group-prev-group t]
925 ["Next unread" gnus-group-next-unread-group t]
926 ["Previous unread" gnus-group-prev-unread-group t]
927 ["Next unread same level" gnus-group-next-unread-group-same-level t]
928 ["Previous unread same level"
929 gnus-group-prev-unread-group-same-level t]
930 ["Jump to group..." gnus-group-jump-to-group t]
931 ["First unread group" gnus-group-first-unread-group t]
932 ["Best unread group" gnus-group-best-unread-group t])
934 ["Generate" gnus-sieve-generate t]
935 ["Generate and update" gnus-sieve-update t])
936 ["Delete bogus groups" gnus-group-check-bogus-groups t]
937 ["Find new newsgroups" gnus-group-find-new-groups t]
938 ["Transpose" gnus-group-transpose-groups
939 (gnus-group-group-name)]
940 ["Read a directory as a group..." gnus-group-enter-directory t]))
943 gnus-group-misc-menu gnus-group-mode-map ""
946 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
947 ["Send replies" gnus-soup-send-replies
948 (fboundp 'gnus-soup-pack-packet)]
949 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
950 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
951 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
952 ["Send a mail" gnus-group-mail t]
953 ["Send a message (mail or news)" gnus-group-post-news t]
954 ["Create a local message" gnus-group-news t]
955 ["Check for new news" gnus-group-get-new-news
956 ,@(if (featurep 'xemacs) '(t)
957 '(:help "Get newly arrived articles"))
959 ["Send queued messages" gnus-delay-send-queue
960 ,@(if (featurep 'xemacs) '(t)
961 '(:help "Send all messages that are scheduled to be sent now"))
963 ["Activate all groups" gnus-activate-all-groups t]
964 ["Restart Gnus" gnus-group-restart t]
965 ["Read init file" gnus-group-read-init-file t]
966 ["Browse foreign server..." gnus-group-browse-foreign-server t]
967 ["Enter server buffer" gnus-group-enter-server-mode t]
968 ["Expire all expirable articles" gnus-group-expire-all-groups t]
969 ["Generate any kiboze groups" nnkiboze-generate-groups t]
970 ["Gnus version" gnus-version t]
971 ["Save .newsrc files" gnus-group-save-newsrc t]
972 ["Suspend Gnus" gnus-group-suspend t]
973 ["Clear dribble buffer" gnus-group-clear-dribble t]
974 ["Read manual" gnus-info-find-node t]
975 ["Flush score cache" gnus-score-flush-cache t]
976 ["Toggle topics" gnus-topic-mode t]
977 ["Send a bug report" gnus-bug t]
978 ["Exit from Gnus" gnus-group-exit
979 ,@(if (featurep 'xemacs) '(t)
980 '(:help "Quit reading news"))]
981 ["Exit without saving" gnus-group-quit t]))
983 (gnus-run-hooks 'gnus-group-menu-hook)))
985 (defvar gnus-group-toolbar-map nil)
987 ;; Emacs 21 tool bar. Should be no-op otherwise.
988 (defun gnus-group-make-tool-bar ()
990 (condition-case nil (require 'tool-bar) (error nil))
991 (fboundp 'tool-bar-add-item-from-menu)
992 (default-value 'tool-bar-mode)
993 (not gnus-group-toolbar-map))
994 (setq gnus-group-toolbar-map
995 (let ((tool-bar-map (make-sparse-keymap))
996 (load-path (mm-image-load-path)))
997 (tool-bar-add-item-from-menu
998 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
999 (tool-bar-add-item-from-menu
1000 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1001 (tool-bar-add-item-from-menu
1002 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1003 (tool-bar-add-item-from-menu
1004 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1005 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1006 :help "Subscribe to the current group")
1007 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1009 :help "Unsubscribe from the current group")
1010 (tool-bar-add-item-from-menu
1011 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1013 (if gnus-group-toolbar-map
1014 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1016 (defun gnus-group-mode ()
1017 "Major mode for reading news.
1019 All normal editing commands are switched off.
1020 \\<gnus-group-mode-map>
1021 The group buffer lists (some of) the groups available. For instance,
1022 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1023 lists all zombie groups.
1025 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1026 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1028 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1030 The following commands are available:
1032 \\{gnus-group-mode-map}"
1034 (kill-all-local-variables)
1035 (when (gnus-visual-p 'group-menu 'menu)
1036 (gnus-group-make-menu-bar)
1037 (gnus-group-make-tool-bar))
1038 (gnus-simplify-mode-line)
1039 (setq major-mode 'gnus-group-mode)
1040 (setq mode-name "Group")
1041 (gnus-group-set-mode-line)
1042 (setq mode-line-process nil)
1043 (use-local-map gnus-group-mode-map)
1044 (buffer-disable-undo)
1045 (setq truncate-lines t)
1046 (setq buffer-read-only t)
1047 (gnus-set-default-directory)
1048 (gnus-update-format-specifications nil 'group 'group-mode)
1049 (gnus-update-group-mark-positions)
1054 (gnus-run-hooks 'gnus-group-mode-hook))
1056 (defun gnus-update-group-mark-positions ()
1058 (let ((gnus-process-mark ?\200)
1059 (gnus-group-update-hook nil)
1060 (gnus-group-marked '("dummy.group"))
1061 (gnus-active-hashtb (make-vector 10 0))
1063 (gnus-set-active "dummy.group" '(0 . 0))
1064 (gnus-set-work-buffer)
1065 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1066 (goto-char (point-min))
1067 (setq gnus-group-mark-positions
1068 (list (cons 'process (and (search-forward "\200" nil t)
1069 (- (point) 2))))))))
1071 (defun gnus-mouse-pick-group (e)
1072 "Enter the group under the mouse pointer."
1075 (gnus-group-read-group nil))
1077 ;; Look at LEVEL and find out what the level is really supposed to be.
1078 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1079 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1080 (defun gnus-group-default-level (&optional level number-or-nil)
1082 (gnus-group-use-permanent-levels
1083 (or (setq gnus-group-use-permanent-levels
1084 (or level (if (numberp gnus-group-use-permanent-levels)
1085 gnus-group-use-permanent-levels
1086 (or gnus-group-default-list-level
1087 gnus-level-subscribed))))
1088 gnus-group-default-list-level gnus-level-subscribed))
1092 (or level gnus-group-default-list-level gnus-level-subscribed))))
1094 (defun gnus-group-setup-buffer ()
1095 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1096 (unless (eq major-mode 'gnus-group-mode)
1099 (gnus-carpal-setup-buffer 'group))))
1101 (defun gnus-group-name-charset (method group)
1103 (setq method (gnus-find-method-for-group group)))
1104 (let ((item (assoc method gnus-group-name-charset-method-alist))
1105 (alist gnus-group-name-charset-group-alist)
1109 (while (setq item (pop alist))
1110 (if (string-match (car item) group)
1112 result (cdr item))))
1115 (defun gnus-group-name-decode (string charset)
1116 ;; Fixme: Don't decode in unibyte mode.
1117 (if (and string charset (featurep 'mule))
1118 (decode-coding-string string charset)
1121 (defun gnus-group-decoded-name (string)
1122 (let ((charset (gnus-group-name-charset nil string)))
1123 (gnus-group-name-decode string charset)))
1125 (defun gnus-group-name-encode (string charset)
1126 (if (and string charset (featurep 'mule))
1127 (encode-coding-string string charset)
1130 (defun gnus-group-encoded-name (string)
1131 (let ((charset (gnus-group-name-charset nil string)))
1132 (gnus-group-name-encode string charset)))
1134 (defun gnus-group-completing-read-group-name
1135 (prompt table &optional predicate require-match initial-contents history)
1139 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1143 (dolist (entry (prog1
1146 (push (list (gnus-group-decoded-name (car entry))) table)))
1147 (gnus-group-encoded-name
1149 prompt table predicate
1154 (defun gnus-group-list-groups (&optional level unread lowest)
1155 "List newsgroups with level LEVEL or lower that have unread articles.
1156 Default is all subscribed groups.
1157 If argument UNREAD is non-nil, groups with no unread articles are also
1160 Also see the `gnus-group-use-permanent-levels' variable."
1162 (list (if current-prefix-arg
1163 (prefix-numeric-value current-prefix-arg)
1165 (gnus-group-default-level nil t)
1166 gnus-group-default-list-level
1167 gnus-level-subscribed))))
1169 (setq level (car gnus-group-list-mode)
1170 unread (cdr gnus-group-list-mode)))
1171 (setq level (gnus-group-default-level level))
1172 (gnus-group-setup-buffer)
1173 (gnus-update-format-specifications nil 'group 'group-mode)
1174 (let ((case-fold-search nil)
1175 (props (text-properties-at (point-at-bol)))
1176 (empty (= (point-min) (point-max)))
1177 (group (gnus-group-group-name))
1179 (set-buffer gnus-group-buffer)
1180 (setq number (funcall gnus-group-prepare-function level unread lowest))
1181 (when (or (and (numberp number)
1183 (zerop (buffer-size)))
1184 ;; No groups in the buffer.
1185 (gnus-message 5 gnus-no-groups-message))
1186 ;; We have some groups displayed.
1187 (goto-char (point-max))
1188 (when (or (not gnus-group-goto-next-group-function)
1189 (not (funcall gnus-group-goto-next-group-function
1193 (goto-char (point-min)))
1195 ;; Go to the first group with unread articles.
1196 (gnus-group-search-forward t))
1198 ;; Find the right group to put point on. If the current group
1199 ;; has disappeared in the new listing, try to find the next
1200 ;; one. If no next one can be found, just leave point at the
1201 ;; first newsgroup in the buffer.
1202 (when (not (gnus-goto-char
1204 (point-min) (point-max)
1205 'gnus-group (gnus-intern-safe
1206 group gnus-active-hashtb))))
1207 (let ((newsrc (cdddr (gnus-group-entry group))))
1209 (not (gnus-goto-char
1211 (point-min) (point-max) 'gnus-group
1213 (caar newsrc) gnus-active-hashtb)))))
1214 (setq newsrc (cdr newsrc)))
1216 (goto-char (point-max))
1217 (forward-line -1)))))))
1218 ;; Adjust cursor point.
1219 (gnus-group-position-point)))
1221 (defun gnus-group-list-level (level &optional all)
1222 "List groups on LEVEL.
1223 If ALL (the prefix), also list groups that have no unread articles."
1224 (interactive "nList groups on level: \nP")
1225 (gnus-group-list-groups level all level))
1227 (defun gnus-group-prepare-logic (group test)
1228 (or (and gnus-group-listed-groups
1229 (null gnus-group-list-option)
1230 (member group gnus-group-listed-groups))
1232 ((null gnus-group-listed-groups) test)
1233 ((null gnus-group-list-option) test)
1234 (t (and (member group gnus-group-listed-groups)
1235 (if (eq gnus-group-list-option 'flush)
1239 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1240 "List all newsgroups with unread articles of level LEVEL or lower.
1241 If PREDICATE is a function, list groups that the function returns non-nil;
1242 if it is t, list groups that have no unread articles.
1243 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1244 If REGEXP is a function, list dead groups that the function returns non-nil;
1245 if it is a string, only list groups matching REGEXP."
1246 (set-buffer gnus-group-buffer)
1247 (let ((buffer-read-only nil)
1248 (newsrc (cdr gnus-newsrc-alist))
1249 (lowest (or lowest 1))
1250 (not-in-list (and gnus-group-listed-groups
1251 (copy-sequence gnus-group-listed-groups)))
1252 info clevel unread group params)
1254 (when (or (< lowest gnus-level-zombie)
1255 gnus-group-listed-groups)
1256 ;; List living groups.
1258 (setq info (car newsrc)
1259 group (gnus-info-group info)
1260 params (gnus-info-params info)
1262 unread (gnus-group-unread group))
1264 (setq not-in-list (delete group not-in-list)))
1265 (when (gnus-group-prepare-logic
1267 (and unread ; This group might be unchecked
1268 (or (not (stringp regexp))
1269 (string-match regexp group))
1270 (<= (setq clevel (gnus-info-level info)) level)
1273 ((functionp predicate)
1274 (funcall predicate info))
1275 (predicate t) ; We list all groups?
1278 (if (eq unread t) ; Unactivated?
1279 gnus-group-list-inactive-groups
1280 ; We list unactivated
1282 ; We list groups with unread articles
1283 (and gnus-list-groups-with-ticked-articles
1284 (cdr (assq 'tick (gnus-info-marks info))))
1285 ; And groups with tickeds
1286 ;; Check for permanent visibility.
1287 (and gnus-permanently-visible-groups
1288 (string-match gnus-permanently-visible-groups
1290 (memq 'visible params)
1291 (cdr (assq 'visible params)))))))
1292 (gnus-group-insert-group-line
1293 group (gnus-info-level info)
1294 (gnus-info-marks info) unread (gnus-info-method info)))))
1296 ;; List dead groups.
1297 (when (or gnus-group-listed-groups
1298 (and (>= level gnus-level-zombie)
1299 (<= lowest gnus-level-zombie)))
1300 (gnus-group-prepare-flat-list-dead
1301 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1302 gnus-level-zombie ?Z
1305 (dolist (group gnus-zombie-list)
1306 (setq not-in-list (delete group not-in-list))))
1307 (when (or gnus-group-listed-groups
1308 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1309 (gnus-group-prepare-flat-list-dead
1312 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1313 gnus-level-killed ?K regexp))
1315 (gnus-group-set-mode-line)
1316 (setq gnus-group-list-mode (cons level predicate))
1317 (gnus-run-hooks 'gnus-group-prepare-hook)
1320 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1321 ;; List zombies and killed lists somewhat faster, which was
1322 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1323 ;; this by ignoring the group format specification altogether.
1325 (if (> (length groups) gnus-group-listing-limit)
1327 (setq group (pop groups))
1328 (when (gnus-group-prepare-logic
1331 (and (stringp regexp) (string-match regexp group))
1332 (and (functionp regexp) (funcall regexp group))))
1333 (gnus-add-text-properties
1334 (point) (prog1 (1+ (point))
1335 (insert " " mark " *: "
1336 (gnus-group-decoded-name group)
1338 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1340 'gnus-level level))))
1342 (setq group (pop groups))
1343 (when (gnus-group-prepare-logic
1346 (and (stringp regexp) (string-match regexp group))
1347 (and (functionp regexp) (funcall regexp group))))
1348 (gnus-group-insert-group-line
1350 (let ((active (gnus-active group)))
1352 (if (zerop (cdr active))
1354 (- (1+ (cdr active)) (car active)))
1356 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1358 (defun gnus-group-update-group-line ()
1359 "Update the current line in the group buffer."
1360 (let* ((buffer-read-only nil)
1361 (group (gnus-group-group-name))
1362 (entry (and group (gnus-group-entry group)))
1363 gnus-group-indentation)
1366 (not (gnus-ephemeral-group-p group))
1368 (concat "(gnus-group-set-info '"
1369 (gnus-prin1-to-string (nth 2 entry))
1371 (setq gnus-group-indentation (gnus-group-group-indentation))
1373 (gnus-group-insert-group-line-info group)
1375 (gnus-group-position-point))))
1377 (defun gnus-group-insert-group-line-info (group)
1378 "Insert GROUP on the current line."
1379 (let ((entry (gnus-group-entry group))
1380 (gnus-group-indentation (gnus-group-group-indentation))
1384 ;; (Un)subscribed group.
1385 (setq info (nth 2 entry))
1386 (gnus-group-insert-group-line
1387 group (gnus-info-level info) (gnus-info-marks info)
1388 (or (car entry) t) (gnus-info-method info)))
1389 ;; This group is dead.
1390 (gnus-group-insert-group-line
1392 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1394 (if (setq active (gnus-active group))
1395 (if (zerop (cdr active))
1397 (- (1+ (cdr active)) (car active)))
1399 (gnus-method-simplify (gnus-find-method-for-group group))))))
1401 (defun gnus-number-of-unseen-articles-in-group (group)
1402 (let* ((info (nth 2 (gnus-group-entry group)))
1403 (marked (gnus-info-marks info))
1404 (seen (cdr (assq 'seen marked)))
1405 (active (gnus-active group)))
1408 (length (gnus-uncompress-range
1409 (gnus-range-difference
1410 (gnus-range-difference (list active) (gnus-info-read info))
1413 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1414 gnus-tmp-marked number
1416 "Insert a group line in the group buffer."
1417 (let* ((gnus-tmp-method
1418 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1419 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1421 (gnus-tmp-active (gnus-active gnus-tmp-group))
1422 (gnus-tmp-number-total
1424 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1426 (gnus-tmp-number-of-unread
1427 (if (numberp number) (int-to-string (max 0 number))
1429 (gnus-tmp-number-of-read
1430 (if (numberp number)
1431 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1433 (gnus-tmp-subscribed
1434 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1435 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1436 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1438 (gnus-tmp-qualified-group
1439 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1440 group-name-charset))
1442 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1444 (gnus-tmp-newsgroup-description
1445 (if gnus-description-hashtb
1446 (or (gnus-group-name-decode
1447 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1448 group-name-charset) "")
1451 (if (and gnus-moderated-hashtb
1452 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1454 (gnus-tmp-moderated-string
1455 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1456 (gnus-tmp-group-icon "==&&==")
1457 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1458 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1459 (gnus-tmp-news-method-string
1461 (format "(%s:%s)" (car gnus-tmp-method)
1462 (cadr gnus-tmp-method)) ""))
1463 (gnus-tmp-marked-mark
1464 (if (and (numberp number)
1466 (cdr (assq 'tick gnus-tmp-marked)))
1468 (gnus-tmp-summary-live
1469 (if (and (not gnus-group-is-exiting-p)
1470 (gnus-buffer-live-p (gnus-summary-buffer-name
1473 (gnus-tmp-process-marked
1474 (if (member gnus-tmp-group gnus-group-marked)
1475 gnus-process-mark ? ))
1476 (buffer-read-only nil)
1477 header gnus-tmp-header) ; passed as parameter to user-funcs.
1479 (gnus-add-text-properties
1483 (let ((gnus-tmp-group (gnus-group-name-decode
1484 gnus-tmp-group group-name-charset)))
1485 (eval gnus-group-line-format-spec)))
1486 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1487 gnus-unread ,(if (numberp number)
1488 (string-to-int gnus-tmp-number-of-unread)
1490 gnus-marked ,gnus-tmp-marked-mark
1491 gnus-indentation ,gnus-group-indentation
1492 gnus-level ,gnus-tmp-level))
1494 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1495 (gnus-run-hooks 'gnus-group-update-hook))
1497 ;; Allow XEmacs to remove front-sticky text properties.
1498 (gnus-group-remove-excess-properties)))
1500 (defun gnus-group-highlight-line ()
1501 "Highlight the current line according to `gnus-group-highlight'."
1502 (let* ((list gnus-group-highlight)
1504 (end (point-at-eol))
1505 ;; now find out where the line starts and leave point there.
1506 (beg (progn (beginning-of-line) (point)))
1507 (group (gnus-group-group-name))
1508 (entry (gnus-group-entry group))
1509 (unread (if (numberp (car entry)) (car entry) 0))
1510 (active (gnus-active group))
1511 (total (if active (1+ (- (cdr active) (car active))) 0))
1512 (info (nth 2 entry))
1513 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1514 (marked (gnus-info-marks info))
1515 (mailp (apply 'append
1518 (memq x (assoc (symbol-name
1519 (car (or method gnus-select-method)))
1520 gnus-valid-select-methods)))
1521 '(mail post-mail))))
1522 (level (or (gnus-info-level info) gnus-level-killed))
1523 (score (or (gnus-info-score info) 0))
1524 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1525 (group-age (gnus-group-timestamp-delta group))
1526 (inhibit-read-only t))
1527 ;; Eval the cars of the lists until we find a match.
1529 (not (eval (caar list))))
1530 (setq list (cdr list)))
1531 (let ((face (cdar list)))
1532 (unless (eq face (get-text-property beg 'face))
1533 (gnus-put-text-property-excluding-characters-with-faces
1535 (setq face (if (boundp face) (symbol-value face) face)))
1536 (gnus-extent-start-open beg)))
1539 (defun gnus-group-update-group (group &optional visible-only)
1540 "Update all lines where GROUP appear.
1541 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1543 ;; Can't use `save-excursion' here, so we do it manually.
1544 (let ((buf (current-buffer))
1546 (set-buffer gnus-group-buffer)
1547 (setq mark (point-marker))
1548 ;; The buffer may be narrowed.
1551 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1553 found buffer-read-only)
1554 ;; Enter the current status into the dribble buffer.
1555 (let ((entry (gnus-group-entry group)))
1557 (not (gnus-ephemeral-group-p group)))
1559 (concat "(gnus-group-set-info '"
1560 (gnus-prin1-to-string (nth 2 entry))
1562 ;; Find all group instances. If topics are in use, each group
1563 ;; may be listed in more than once.
1564 (while (setq loc (text-property-any
1565 loc (point-max) 'gnus-group ident))
1568 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1570 (gnus-group-insert-group-line-info group)
1573 (gnus-run-hooks 'gnus-group-update-group-hook)))
1574 (setq loc (1+ loc)))
1575 (unless (or found visible-only)
1576 ;; No such line in the buffer, find out where it's supposed to
1577 ;; go, and insert it there (or at the end of the buffer).
1578 (if gnus-goto-missing-group-function
1579 (funcall gnus-goto-missing-group-function group)
1580 (let ((entry (cddr (gnus-group-entry group))))
1581 (while (and entry (car entry)
1585 (point-min) (point-max)
1586 'gnus-group (gnus-intern-safe
1587 (caar entry) gnus-active-hashtb)))))
1588 (setq entry (cdr entry)))
1589 (or entry (goto-char (point-max)))))
1590 ;; Finally insert the line.
1591 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1592 (gnus-group-insert-group-line-info group)
1595 (gnus-run-hooks 'gnus-group-update-group-hook))))
1596 (when gnus-group-update-group-function
1597 (funcall gnus-group-update-group-function group))
1598 (gnus-group-set-mode-line)))
1600 (set-marker mark nil)
1603 (defun gnus-group-set-mode-line ()
1604 "Update the mode line in the group buffer."
1605 (when (memq 'group gnus-updated-mode-lines)
1606 ;; Yes, we want to keep this mode line updated.
1608 (set-buffer gnus-group-buffer)
1609 (let* ((gformat (or gnus-group-mode-line-format-spec
1610 (gnus-set-format 'group-mode)))
1611 (gnus-tmp-news-server (cadr gnus-select-method))
1612 (gnus-tmp-news-method (car gnus-select-method))
1613 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1615 gnus-tmp-header ;Dummy binding for user-defined formats
1616 ;; Get the resulting string.
1618 (and gnus-dribble-buffer
1619 (buffer-name gnus-dribble-buffer)
1620 (buffer-modified-p gnus-dribble-buffer)
1622 (set-buffer gnus-dribble-buffer)
1623 (not (zerop (buffer-size))))))
1624 (mode-string (eval gformat)))
1625 ;; Say whether the dribble buffer has been modified.
1626 (setq mode-line-modified
1627 (if modified (car gnus-mode-line-modified)
1628 (cdr gnus-mode-line-modified)))
1629 ;; If the line is too long, we chop it off.
1630 (when (> (length mode-string) max-len)
1631 (setq mode-string (substring mode-string 0 (- max-len 4))))
1633 (setq mode-line-buffer-identification
1634 (gnus-mode-line-buffer-identification
1635 (list mode-string)))
1636 (set-buffer-modified-p modified))))))
1638 (defun gnus-group-group-name ()
1639 "Get the name of the newsgroup on the current line."
1640 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1642 (symbol-name group))))
1644 (defun gnus-group-group-level ()
1645 "Get the level of the newsgroup on the current line."
1646 (get-text-property (point-at-bol) 'gnus-level))
1648 (defun gnus-group-group-indentation ()
1649 "Get the indentation of the newsgroup on the current line."
1650 (or (get-text-property (point-at-bol) 'gnus-indentation)
1651 (and gnus-group-indentation-function
1652 (funcall gnus-group-indentation-function))
1655 (defun gnus-group-group-unread ()
1656 "Get the number of unread articles of the newsgroup on the current line."
1657 (get-text-property (point-at-bol) 'gnus-unread))
1659 (defun gnus-group-new-mail (group)
1660 (if (nnmail-new-mail-p (gnus-group-real-name group))
1664 (defun gnus-group-level (group)
1665 "Return the estimated level of GROUP."
1666 (or (gnus-info-level (gnus-get-info group))
1667 (and (member group gnus-zombie-list) gnus-level-zombie)
1670 (defun gnus-group-search-forward (&optional backward all level first-too)
1671 "Find the next newsgroup with unread articles.
1672 If BACKWARD is non-nil, find the previous newsgroup instead.
1673 If ALL is non-nil, just find any newsgroup.
1674 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1676 If FIRST-TOO, the current line is also eligible as a target."
1677 (let ((way (if backward -1 1))
1678 (low gnus-level-killed)
1681 (if (and backward (progn (beginning-of-line)) (bobp))
1690 (get-text-property (point) 'gnus-group)
1694 (get-text-property (point) 'gnus-unread)))
1695 (and (numberp unread) (> unread 0)))
1696 (setq lev (get-text-property (point)
1698 (<= lev gnus-level-subscribed)))
1700 (and (setq lev (get-text-property (point)
1709 (zerop (forward-line way)))))
1711 (progn (gnus-group-position-point) t)
1712 (goto-char (or pos beg))
1715 (defun gnus-total-fetched-for (group)
1716 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1717 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1718 (size (+ size-in-cache size-in-agent))
1719 (suffix '("B" "K" "M" "G"))
1721 (cutoff (* 10 scale)))
1722 (while (> size cutoff)
1723 (setq size (/ size scale)
1724 suffix (cdr suffix)))
1725 (format "%5.1f%s" size (car suffix))))
1727 ;;; Gnus group mode commands
1731 (defun gnus-group-mark-line-p ()
1734 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1735 (eq (char-after) gnus-process-mark)))
1737 (defun gnus-group-mark-group (n &optional unmark no-advance)
1738 "Mark the current group."
1740 (let ((buffer-read-only nil)
1744 (when (setq group (gnus-group-group-name))
1745 ;; Go to the mark position.
1747 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1751 (setq gnus-group-marked (delete group gnus-group-marked))
1752 (insert-char ? 1 t))
1753 (setq gnus-group-marked
1754 (cons group (delete group gnus-group-marked)))
1755 (insert-char gnus-process-mark 1 t)))
1757 (gnus-group-next-group 1))
1759 (gnus-summary-position-point)
1762 (defun gnus-group-unmark-group (n)
1763 "Remove the mark from the current group."
1765 (gnus-group-mark-group n 'unmark)
1766 (gnus-group-position-point))
1768 (defun gnus-group-unmark-all-groups ()
1769 "Unmark all groups."
1771 (let ((groups gnus-group-marked))
1774 (gnus-group-remove-mark (pop groups)))))
1775 (gnus-group-position-point))
1777 (defun gnus-group-mark-region (unmark beg end)
1778 "Mark all groups between point and mark.
1779 If UNMARK, remove the mark instead."
1780 (interactive "P\nr")
1781 (let ((num (count-lines beg end)))
1784 (- num (gnus-group-mark-group num unmark)))))
1786 (defun gnus-group-mark-buffer (&optional unmark)
1787 "Mark all groups in the buffer.
1788 If UNMARK, remove the mark instead."
1790 (gnus-group-mark-region unmark (point-min) (point-max)))
1792 (defun gnus-group-mark-regexp (regexp)
1793 "Mark all groups that match some regexp."
1794 (interactive "sMark (regexp): ")
1795 (let ((alist (cdr gnus-newsrc-alist))
1799 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1800 (gnus-group-jump-to-group group)
1801 (gnus-group-set-mark group)))))
1802 (gnus-group-position-point))
1804 (defun gnus-group-remove-mark (group &optional test-marked)
1805 "Remove the process mark from GROUP and move point there.
1806 Return nil if the group isn't displayed."
1807 (if (gnus-group-goto-group group nil test-marked)
1809 (gnus-group-mark-group 1 'unmark t)
1811 (setq gnus-group-marked
1812 (delete group gnus-group-marked))
1815 (defun gnus-group-set-mark (group)
1816 "Set the process mark on GROUP."
1817 (if (gnus-group-goto-group group)
1819 (gnus-group-mark-group 1 nil t))
1820 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1822 (defun gnus-group-universal-argument (arg &optional groups func)
1823 "Perform any command on all groups according to the process/prefix convention."
1825 (if (eq (setq func (or func
1828 (substitute-command-keys
1829 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1831 (gnus-error 1 "Undefined key")
1832 (gnus-group-iterate arg
1834 (command-execute func))))
1835 (gnus-group-position-point))
1837 (defun gnus-group-process-prefix (n)
1838 "Return a list of groups to work on.
1839 Take into consideration N (the prefix) and the list of marked groups."
1842 (setq n (prefix-numeric-value n))
1843 ;; There is a prefix, so we return a list of the N next
1845 (let ((way (if (< n 0) -1 1))
1850 (if (setq group (gnus-group-group-name))
1851 (push group groups))
1853 (gnus-group-next-group way)))
1855 ((and (gnus-region-active-p) (mark))
1856 ;; Work on the region between point and mark.
1857 (let ((max (max (point) (mark)))
1860 (goto-char (min (point) (mark)))
1863 (push (gnus-group-group-name) groups)
1864 (zerop (gnus-group-next-group 1))
1866 (nreverse groups))))
1868 ;; No prefix, but a list of marked articles.
1869 (reverse gnus-group-marked))
1871 ;; Neither marked articles or a prefix, so we return the
1873 (let ((group (gnus-group-group-name)))
1874 (and group (list group))))))
1876 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1877 ;;; imagine why I went through these contortions...
1879 (let ((function (make-symbol "gnus-group-iterate-function"))
1880 (window (make-symbol "gnus-group-iterate-window"))
1881 (groups (make-symbol "gnus-group-iterate-groups"))
1882 (group (make-symbol "gnus-group-iterate-group")))
1884 `(defun gnus-group-iterate (arg ,function)
1885 "Iterate FUNCTION over all process/prefixed groups.
1886 FUNCTION will be called with the group name as the parameter
1887 and with point over the group in question."
1888 (let ((,groups (gnus-group-process-prefix arg))
1889 (,window (selected-window))
1892 (setq ,group (car ,groups)
1893 ,groups (cdr ,groups))
1894 (select-window ,window)
1895 (gnus-group-remove-mark ,group)
1896 (save-selected-window
1898 (funcall ,function ,group)))))))))
1900 (put 'gnus-group-iterate 'lisp-indent-function 1)
1902 ;; Selecting groups.
1904 (defun gnus-group-read-group (&optional all no-article group select-articles)
1905 "Read news in this newsgroup.
1906 If the prefix argument ALL is non-nil, already read articles become
1907 readable. IF ALL is a number, fetch this number of articles. If the
1908 optional argument NO-ARTICLE is non-nil, no article will be
1909 auto-selected upon group entry. If GROUP is non-nil, fetch that
1912 (let ((no-display (eq all 0))
1913 (group (or group (gnus-group-group-name)))
1914 number active marked entry)
1918 (error "No group on current line"))
1919 (setq marked (gnus-info-marks
1920 (nth 2 (setq entry (gnus-group-entry group)))))
1921 ;; This group might be a dead group. In that case we have to get
1922 ;; the number of unread articles from `gnus-active-hashtb'.
1924 (cond ((numberp all) all)
1926 ((setq active (gnus-active group))
1927 (- (1+ (cdr active)) (car active)))))
1928 (gnus-summary-read-group
1929 group (or all (and (numberp number)
1930 (zerop (+ number (gnus-range-length
1931 (cdr (assq 'tick marked)))
1933 (cdr (assq 'dormant marked)))))))
1934 no-article nil no-display nil select-articles)))
1936 (defun gnus-group-select-group (&optional all)
1937 "Select this newsgroup.
1938 No article is selected automatically.
1939 If the group is opened, just switch the summary buffer.
1940 If ALL is non-nil, already read articles become readable.
1941 If ALL is a number, fetch this number of articles."
1943 (when (and (eobp) (not (gnus-group-group-name)))
1945 (gnus-group-read-group all t))
1947 (defun gnus-group-quick-select-group (&optional all)
1948 "Select the current group \"quickly\".
1949 This means that no highlighting or scoring will be performed.
1950 If ALL (the prefix argument) is 0, don't even generate the summary
1953 This might be useful if you want to toggle threading
1954 before entering the group."
1956 (require 'gnus-score)
1958 gnus-score-find-score-files-function
1959 gnus-home-score-file
1960 gnus-apply-kill-hook
1961 gnus-summary-expunge-below)
1962 (gnus-group-read-group all t)))
1964 (defun gnus-group-visible-select-group (&optional all)
1965 "Select the current group without hiding any articles."
1967 (let ((gnus-inhibit-limiting t))
1968 (gnus-group-read-group all t)))
1970 (defun gnus-group-select-group-ephemerally ()
1971 "Select the current group without doing any processing whatsoever.
1972 You will actually be entered into a group that's a copy of
1973 the current group; no changes you make while in this group will
1976 (require 'gnus-score)
1978 gnus-score-find-score-files-function gnus-apply-kill-hook
1979 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1980 gnus-summary-mode-hook gnus-select-group-hook
1981 (group (gnus-group-group-name))
1982 (method (gnus-find-method-for-group group)))
1983 (gnus-group-read-ephemeral-group
1984 (gnus-group-prefixed-name group method) method)))
1987 (defun gnus-fetch-group (group &optional articles)
1988 "Start Gnus if necessary and enter GROUP.
1989 Returns whether the fetching was successful or not."
1990 (interactive (list (gnus-group-completing-read-group-name
1991 "Group name: " gnus-active-hashtb)))
1992 (unless (get-buffer gnus-group-buffer)
1994 (gnus-group-read-group articles nil group))
1997 (defun gnus-fetch-group-other-frame (group)
1998 "Pop up a frame and enter GROUP."
2000 (let ((window (get-buffer-window gnus-group-buffer)))
2002 (select-frame (window-frame window)))
2003 ((= (length (frame-list)) 1)
2004 (select-frame (make-frame)))
2007 (gnus-fetch-group group))
2009 (defvar gnus-ephemeral-group-server 0)
2011 (defcustom gnus-large-ephemeral-newsgroup 200
2012 "The number of articles which indicates a large ephemeral newsgroup.
2013 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2015 If the number of articles in a newsgroup is greater than this value,
2016 confirmation is required for selecting the newsgroup. If it is nil, no
2017 confirmation is required."
2018 :group 'gnus-group-select
2019 :type '(choice (const :tag "No limit" nil)
2022 (defcustom gnus-fetch-old-ephemeral-headers nil
2023 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2025 :type '(choice (const :tag "off" nil)
2028 (sexp :menu-tag "other" t)))
2030 ;; Enter a group that is not in the group buffer. Non-nil is returned
2031 ;; if selection was successful.
2032 (defun gnus-group-read-ephemeral-group (group method &optional activate
2033 quit-config request-only
2036 "Read GROUP from METHOD as an ephemeral group.
2037 If ACTIVATE, request the group first.
2038 If QUIT-CONFIG, use that window configuration when exiting from the
2040 If REQUEST-ONLY, don't actually read the group; just request it.
2041 If SELECT-ARTICLES, only select those articles.
2042 If PARAMETERS, use those as the group parameters.
2044 Return the name of the group if selection was successful."
2047 ;; (gnus-read-group "Group name: ")
2049 "Group: " gnus-active-hashtb
2051 'gnus-group-history)
2052 (gnus-read-method "From method: ")))
2053 ;; Transform the select method into a unique server.
2054 (when (stringp method)
2055 (setq method (gnus-server-to-method method)))
2057 `(,(car method) ,(concat (cadr method) "-ephemeral")
2058 (,(intern (format "%s-address" (car method))) ,(cadr method))
2060 (let ((group (if (gnus-group-foreign-p group) group
2061 (gnus-group-prefixed-name (gnus-group-real-name group)
2066 ,gnus-level-default-subscribed nil nil ,method
2069 (cons 'quit-config quit-config)
2071 (cons gnus-summary-buffer
2072 gnus-current-window-configuration)))
2075 (push method gnus-ephemeral-servers)
2076 (set-buffer gnus-group-buffer)
2077 (unless (gnus-check-server method)
2078 (error "Unable to contact server: %s" (gnus-status-message method)))
2080 (gnus-activate-group group 'scan)
2081 (unless (gnus-request-group group)
2082 (error "Couldn't request group: %s"
2083 (nnheader-get-report (car method)))))
2087 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2088 (gnus-fetch-old-headers
2089 gnus-fetch-old-ephemeral-headers))
2090 (gnus-group-read-group t t group select-articles))
2094 (message "Quit reading the ephemeral group")
2097 (defun gnus-group-jump-to-group (group)
2098 "Jump to newsgroup GROUP."
2100 (list (gnus-group-completing-read-group-name
2101 "Group: " gnus-active-hashtb nil
2102 (gnus-read-active-file-p)
2103 gnus-group-jump-to-group-prompt
2104 'gnus-group-history)))
2106 (when (equal group "")
2107 (error "Empty group name"))
2109 (unless (gnus-ephemeral-group-p group)
2110 ;; Either go to the line in the group buffer...
2111 (unless (gnus-group-goto-group group)
2112 ;; ... or insert the line.
2113 (gnus-group-update-group group)
2114 (gnus-group-goto-group group)))
2115 ;; Adjust cursor point.
2116 (gnus-group-position-point))
2118 (defun gnus-group-goto-group (group &optional far test-marked)
2119 "Goto to newsgroup GROUP.
2120 If FAR, it is likely that the group is not on the current line.
2121 If TEST-MARKED, the line must be marked."
2125 ;; It's quite likely that we are on the right line, so
2126 ;; we check the current line first.
2128 (eq (get-text-property (point) 'gnus-group)
2129 (gnus-intern-safe group gnus-active-hashtb))
2130 (or (not test-marked) (gnus-group-mark-line-p)))
2132 ;; Previous and next line are also likely, so we check them as well.
2136 (and (eq (get-text-property (point) 'gnus-group)
2137 (gnus-intern-safe group gnus-active-hashtb))
2138 (or (not test-marked) (gnus-group-mark-line-p)))))
2144 (and (eq (get-text-property (point) 'gnus-group)
2145 (gnus-intern-safe group gnus-active-hashtb))
2146 (or (not test-marked) (gnus-group-mark-line-p)))))
2150 (goto-char (point-min))
2152 (while (and (not found)
2157 (gnus-intern-safe group gnus-active-hashtb))))
2158 (if (gnus-group-mark-line-p)
2163 ;; Search through the entire buffer.
2166 (point-min) (point-max)
2167 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2169 (defun gnus-group-next-group (n &optional silent)
2170 "Go to next N'th newsgroup.
2171 If N is negative, search backward instead.
2172 Returns the difference between N and the number of skips actually
2175 (gnus-group-next-unread-group n t nil silent))
2177 (defun gnus-group-next-unread-group (n &optional all level silent)
2178 "Go to next N'th unread newsgroup.
2179 If N is negative, search backward instead.
2180 If ALL is non-nil, choose any newsgroup, unread or not.
2181 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2182 such group can be found, the next group with a level higher than
2184 Returns the difference between N and the number of skips actually
2187 (let ((backward (< n 0))
2190 (gnus-group-search-forward
2191 backward (or (not gnus-group-goto-unread) all) level))
2195 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2196 (if level " on this level or higher" "")))
2199 (defun gnus-group-prev-group (n)
2200 "Go to previous N'th newsgroup.
2201 Returns the difference between N and the number of skips actually
2204 (gnus-group-next-unread-group (- n) t))
2206 (defun gnus-group-prev-unread-group (n)
2207 "Go to previous N'th unread newsgroup.
2208 Returns the difference between N and the number of skips actually
2211 (gnus-group-next-unread-group (- n)))
2213 (defun gnus-group-next-unread-group-same-level (n)
2214 "Go to next N'th unread newsgroup on the same level.
2215 If N is negative, search backward instead.
2216 Returns the difference between N and the number of skips actually
2219 (gnus-group-next-unread-group n t (gnus-group-group-level))
2220 (gnus-group-position-point))
2222 (defun gnus-group-prev-unread-group-same-level (n)
2223 "Go to next N'th unread newsgroup on the same level.
2224 Returns the difference between N and the number of skips actually
2227 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2228 (gnus-group-position-point))
2230 (defun gnus-group-best-unread-group (&optional exclude-group)
2231 "Go to the group with the highest level.
2232 If EXCLUDE-GROUP, do not go to that group."
2234 (goto-char (point-min))
2238 (setq unread (get-text-property (point) 'gnus-unread))
2239 (when (and (numberp unread) (> unread 0))
2240 (when (and (get-text-property (point) 'gnus-level)
2241 (< (get-text-property (point) 'gnus-level) best)
2242 (or (not exclude-group)
2243 (not (equal exclude-group (gnus-group-group-name)))))
2244 (setq best (get-text-property (point) 'gnus-level))
2245 (setq best-point (point))))
2248 (goto-char best-point))
2249 (gnus-group-position-point)
2250 (and best-point (gnus-group-group-name))))
2252 (defun gnus-group-first-unread-group ()
2253 "Go to the first group with unread articles."
2256 (let ((opoint (point))
2258 (goto-char (point-min))
2259 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2260 (and (numberp unread) ; Not a topic.
2261 (not (zerop unread))) ; Has unread articles.
2262 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2265 nil)) ; Not success.
2266 (gnus-group-position-point)))
2268 (defun gnus-group-enter-server-mode ()
2269 "Jump to the server buffer."
2271 (gnus-enter-server-buffer))
2273 (defun gnus-group-make-group (name &optional method address args)
2274 "Add a new newsgroup.
2275 The user will be prompted for a NAME, for a select METHOD, and an
2279 (gnus-read-group "Group name: ")
2280 (gnus-read-method "From method: ")))
2282 (when (stringp method)
2283 (setq method (or (gnus-server-to-method method) method)))
2284 (let* ((meth (gnus-method-simplify
2286 (not (gnus-server-equal method gnus-select-method)))
2287 (if address (list (intern method) address)
2289 (nname (if method (gnus-group-prefixed-name name meth) name))
2291 (when (gnus-group-entry nname)
2292 (error "Group %s already exists" nname))
2293 ;; Subscribe to the new group.
2294 (gnus-group-change-level
2295 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2296 gnus-level-default-subscribed gnus-level-killed
2297 (and (gnus-group-group-name)
2298 (gnus-group-entry (gnus-group-group-name)))
2301 (gnus-set-active nname (cons 1 0))
2302 (unless (gnus-ephemeral-group-p name)
2304 (concat "(gnus-group-set-info '"
2305 (gnus-prin1-to-string (cdr info)) ")")))
2307 (gnus-group-insert-group-line-info nname)
2309 (gnus-group-position-point)
2311 ;; Load the back end and try to make the back end create
2312 ;; the group as well.
2313 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2315 gnus-valid-select-methods)
2317 (gnus-check-server meth)
2318 (when (gnus-check-backend-function 'request-create-group nname)
2319 (unless (gnus-request-create-group nname nil args)
2320 (error "Could not create group on server: %s"
2321 (nnheader-get-report backend))))
2324 (defun gnus-group-delete-groups (&optional arg)
2325 "Delete the current group. Only meaningful with editable groups."
2327 (let ((n (length (gnus-group-process-prefix arg))))
2328 (when (gnus-yes-or-no-p
2330 "Delete this 1 group? "
2331 (format "Delete these %d groups? " n)))
2332 (gnus-group-iterate arg
2334 (gnus-group-delete-group group nil t))))))
2336 (defun gnus-group-delete-group (group &optional force no-prompt)
2337 "Delete the current group. Only meaningful with editable groups.
2338 If FORCE (the prefix) is non-nil, all the articles in the group will
2339 be deleted. This is \"deleted\" as in \"removed forever from the face
2340 of the Earth\". There is no undo. The user will be prompted before
2342 Note that you also have to specify FORCE if you want the group to
2343 be removed from the server, even when it's empty."
2345 (list (gnus-group-group-name)
2346 current-prefix-arg))
2348 (error "No group to delete"))
2349 (unless (gnus-check-backend-function 'request-delete-group group)
2350 (error "This back end does not support group deletion"))
2352 (if (and (not no-prompt)
2353 (not (gnus-yes-or-no-p
2355 "Do you really want to delete %s%s? "
2356 group (if force " and all its contents" "")))))
2358 (gnus-message 6 "Deleting group %s..." group)
2359 (if (not (gnus-request-delete-group group force))
2360 (gnus-error 3 "Couldn't delete group %s" group)
2361 (gnus-message 6 "Deleting group %s...done" group)
2362 (gnus-group-goto-group group)
2363 (gnus-group-kill-group 1 t)
2364 (gnus-set-active group nil)
2366 (gnus-group-position-point)))
2368 (defun gnus-group-rename-group (group new-name)
2369 "Rename group from GROUP to NEW-NAME.
2370 When used interactively, GROUP is the group under point
2371 and NEW-NAME will be prompted for."
2374 (gnus-group-group-name)
2376 (unless (gnus-check-backend-function
2377 'request-rename-group (gnus-group-group-name))
2378 (error "This back end does not support renaming groups"))
2379 (gnus-read-group "Rename group to: "
2380 (gnus-group-real-name (gnus-group-group-name))))))
2382 (unless (gnus-check-backend-function 'request-rename-group group)
2383 (error "This back end does not support renaming groups"))
2385 (error "No group to rename"))
2386 (when (equal (gnus-group-real-name group) new-name)
2387 (error "Can't rename to the same name"))
2389 ;; We find the proper prefixed name.
2391 (if (gnus-group-native-p group)
2395 (gnus-group-prefixed-name
2396 (gnus-group-real-name new-name)
2397 (gnus-info-method (gnus-get-info group)))))
2399 (when (gnus-active new-name)
2400 (error "The group %s already exists" new-name))
2402 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2405 (gnus-group-goto-group group)
2406 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2407 (gnus-request-rename-group group new-name))))
2408 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2409 ;; We rename the group internally by killing it...
2410 (gnus-group-kill-group)
2411 ;; ... changing its name ...
2412 (setcar (cdar gnus-list-of-killed-groups) new-name)
2413 ;; ... and then yanking it. Magic!
2414 (gnus-group-yank-group)
2415 (gnus-set-active new-name (gnus-active group))
2416 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2418 (setq gnus-killed-list (delete group gnus-killed-list))
2419 (gnus-set-active group nil)
2420 (gnus-dribble-touch)
2421 (gnus-group-position-point)))
2423 (defun gnus-group-edit-group (group &optional part)
2424 "Edit the group on the current line."
2425 (interactive (list (gnus-group-group-name)))
2426 (let ((part (or part 'info))
2429 (error "No group on current line"))
2430 (unless (setq info (gnus-get-info group))
2431 (error "Killed group; can't be edited"))
2433 (gnus-close-group group))
2435 ;; Find the proper form to edit.
2436 (cond ((eq part 'method)
2437 (or (gnus-info-method info) "native"))
2439 (gnus-info-params info))
2441 ;; The proper documentation.
2443 "Editing the %s for `%s'."
2445 ((eq part 'method) "select method")
2446 ((eq part 'params) "group parameters")
2448 (gnus-group-decoded-name group))
2450 (gnus-group-edit-group-done ',part ,group form)))
2453 (gnus-create-info-command
2455 (or gnus-info-filename
2456 (get-language-info current-language-environment 'gnus-info)
2458 (cond ((eq part 'method)
2465 (defun gnus-group-edit-group-method (group)
2466 "Edit the select method of GROUP."
2467 (interactive (list (gnus-group-group-name)))
2468 (gnus-group-edit-group group 'method))
2470 (defun gnus-group-edit-group-parameters (group)
2471 "Edit the group parameters of GROUP."
2472 (interactive (list (gnus-group-group-name)))
2473 (gnus-group-edit-group group 'params))
2475 (defun gnus-group-edit-group-done (part group form)
2477 (let* ((method (cond ((eq part 'info) (nth 4 form))
2478 ((eq part 'method) form)
2480 (info (cond ((eq part 'info) form)
2481 ((eq part 'method) (gnus-get-info group))
2484 (if (or (not method)
2486 gnus-select-method method))
2487 (gnus-group-real-name (car info))
2488 (gnus-group-prefixed-name
2489 (gnus-group-real-name (car info)) method))
2491 (when (and new-group
2492 (not (equal new-group group)))
2493 (when (gnus-group-goto-group group)
2494 (gnus-group-kill-group 1))
2495 (gnus-activate-group new-group))
2497 (if (not (and info new-group))
2498 (gnus-group-set-info form (or new-group group) part)
2499 (setq info (gnus-copy-sequence info))
2500 (setcar info new-group)
2501 (unless (gnus-server-equal method "native")
2502 (unless (nthcdr 3 info)
2503 (nconc info (list nil nil)))
2504 (unless (nthcdr 4 info)
2505 (nconc info (list nil)))
2506 (gnus-info-set-method info method))
2507 (gnus-group-set-info info))
2508 (gnus-group-update-group (or new-group group))
2509 (gnus-group-position-point)))
2511 (defun gnus-group-make-useful-group (group method)
2512 "Create one of the groups described in `gnus-useful-groups'."
2514 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2516 gnus-useful-groups)))
2517 (list (cadr entry) (caddr entry))))
2518 (setq method (gnus-copy-sequence method))
2520 (while (setq entry (memq (assq 'eval method) method))
2521 (setcar entry (eval (cadar entry)))))
2522 (gnus-group-make-group group method))
2524 (defun gnus-group-make-help-group (&optional noerror)
2525 "Create the Gnus documentation group.
2526 Optional argument NOERROR modifies the behavior of this function when the
2527 group already exists:
2528 - if not given, and error is signaled,
2529 - if t, stay silent,
2530 - if anything else, just print a message."
2532 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2533 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2534 (if (gnus-group-entry name)
2535 (cond ((eq noerror nil)
2536 (error "Documentation group already exists"))
2541 (gnus-message 1 "Documentation group already exists")))
2544 (gnus-message 1 "Couldn't find doc group")
2545 (gnus-group-make-group
2546 (gnus-group-real-name name)
2547 (list 'nndoc "gnus-help"
2548 (list 'nndoc-address file)
2549 (list 'nndoc-article-type 'mbox))))
2551 (gnus-group-position-point))
2553 (defun gnus-group-make-doc-group (file type)
2554 "Create a group that uses a single file as the source."
2556 (list (read-file-name "File name: ")
2557 (and current-prefix-arg 'ask)))
2558 (when (eq type 'ask)
2563 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2565 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2566 ((= char ?b) 'babyl)
2567 ((= char ?d) 'digest)
2568 ((= char ?f) 'forward)
2570 ((= char ?g) 'guess)
2571 (t (setq err (format "%c unknown. " char))
2574 (let* ((file (expand-file-name file))
2575 (name (gnus-generate-new-group-name
2576 (gnus-group-prefixed-name
2577 (file-name-nondirectory file) '(nndoc "")))))
2578 (gnus-group-make-group
2579 (gnus-group-real-name name)
2581 (list 'nndoc-address file)
2582 (list 'nndoc-article-type (or type 'guess))))))
2584 (defvar nnweb-type-definition)
2585 (defvar gnus-group-web-type-history nil)
2586 (defvar gnus-group-web-search-history nil)
2587 (defun gnus-group-make-web-group (&optional solid)
2588 "Create an ephemeral nnweb group.
2589 If SOLID (the prefix), create a solid group."
2593 (if solid (gnus-read-group "Group name: ")
2594 (message-unique-id)))
2595 (default-type (or (car gnus-group-web-type-history)
2596 (symbol-name (caar nnweb-type-definition))))
2600 (format "Search engine type (default %s): " default-type)
2601 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2602 nnweb-type-definition)
2603 nil t nil 'gnus-group-web-type-history)
2608 (cons (or (car gnus-group-web-search-history) "") 0)
2609 'gnus-group-web-search-history))
2611 `(nnweb ,group (nnweb-search ,search)
2612 (nnweb-type ,(intern type))
2613 (nnweb-ephemeral-p t))))
2616 (gnus-pull 'nnweb-ephemeral-p method)
2617 (gnus-group-make-group group method))
2618 (gnus-group-read-ephemeral-group
2620 (cons (current-buffer)
2621 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2624 (defvar nnrss-group-alist)
2625 (defun nnrss-discover-feed (arg))
2626 (defun nnrss-save-server-data (arg)))
2627 (defun gnus-group-make-rss-group (&optional url)
2628 "Given a URL, discover if there is an RSS feed.
2629 If there is, use Gnus to create an nnrss group"
2633 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2634 (let ((feedinfo (nnrss-discover-feed url)))
2636 (let ((title (read-from-minibuffer "Title: "
2639 (desc (read-from-minibuffer "Description: "
2640 (cdr (assoc 'description
2642 (href (cdr (assoc 'href feedinfo))))
2643 (push (list title href desc)
2645 (gnus-group-unsubscribe-group
2646 (concat "nnrss:" title))
2647 (nnrss-save-server-data nil))
2648 (error "No feeds found for %s" url))))
2650 (defvar nnwarchive-type-definition)
2651 (defvar gnus-group-warchive-type-history nil)
2652 (defvar gnus-group-warchive-login-history nil)
2653 (defvar gnus-group-warchive-address-history nil)
2655 (defun gnus-group-make-warchive-group ()
2656 "Create a nnwarchive group."
2658 (require 'nnwarchive)
2659 (let* ((group (gnus-read-group "Group name: "))
2660 (default-type (or (car gnus-group-warchive-type-history)
2661 (symbol-name (caar nnwarchive-type-definition))))
2665 (format "Warchive type (default %s): " default-type)
2666 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2667 nnwarchive-type-definition)
2668 nil t nil 'gnus-group-warchive-type-history)
2670 (address (read-string "Warchive address: "
2671 nil 'gnus-group-warchive-address-history))
2672 (default-login (or (car gnus-group-warchive-login-history)
2677 (format "Warchive login (default %s): " user-mail-address)
2678 default-login 'gnus-group-warchive-login-history)
2681 `(nnwarchive ,address
2682 (nnwarchive-type ,(intern type))
2683 (nnwarchive-login ,login))))
2684 (gnus-group-make-group group method)))
2686 (defun gnus-group-make-archive-group (&optional all)
2687 "Create the (ding) Gnus archive group of the most recent articles.
2688 Given a prefix, create a full group."
2690 (let ((group (gnus-group-prefixed-name
2691 (if all "ding.archives" "ding.recent") '(nndir ""))))
2692 (when (gnus-group-entry group)
2693 (error "Archive group already exists"))
2694 (gnus-group-make-group
2695 (gnus-group-real-name group)
2696 (list 'nndir (if all "hpc" "edu")
2697 (list 'nndir-directory
2698 (if all gnus-group-archive-directory
2699 gnus-group-recent-archive-directory))))
2700 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2702 (defun gnus-group-make-directory-group (dir)
2703 "Create an nndir group.
2704 The user will be prompted for a directory. The contents of this
2705 directory will be used as a newsgroup. The directory should contain
2706 mail messages or news articles in files that have numeric names."
2708 (list (read-file-name "Create group from directory: ")))
2709 (unless (file-exists-p dir)
2710 (error "No such directory"))
2711 (unless (file-directory-p dir)
2712 (error "Not a directory"))
2716 (while (or (not group) (gnus-group-entry group))
2718 (gnus-group-prefixed-name
2719 (expand-file-name ext dir)
2721 (setq ext (format "<%d>" (setq i (1+ i)))))
2722 (gnus-group-make-group
2723 (gnus-group-real-name group)
2724 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2726 (defvar nnkiboze-score-file)
2727 (defun gnus-group-make-kiboze-group (group address scores)
2728 "Create an nnkiboze group.
2729 The user will be prompted for a name, a regexp to match groups, and
2730 score file entries for articles to include in the group."
2733 (read-string "nnkiboze group name: ")
2734 (read-string "Source groups (regexp): ")
2735 (let ((headers (mapcar (lambda (group) (list group))
2736 '("subject" "from" "number" "date" "message-id"
2737 "references" "chars" "lines" "xref"
2738 "followup" "all" "body" "head")))
2739 scores header regexp regexps)
2740 (while (not (equal "" (setq header (completing-read
2741 "Match on header: " headers nil t))))
2743 (while (not (equal "" (setq regexp (read-string
2744 (format "Match on %s (regexp): "
2746 (push (list regexp nil nil 'r) regexps))
2747 (push (cons header regexps) scores))
2749 (gnus-group-make-group group "nnkiboze" address)
2750 (let* ((nnkiboze-current-group group)
2751 (score-file (car (nnkiboze-score-file "")))
2752 (score-dir (file-name-directory score-file)))
2753 (unless (file-exists-p score-dir)
2754 (make-directory score-dir))
2755 (with-temp-file score-file
2756 (let (emacs-lisp-mode-hook)
2757 (pp scores (current-buffer))))))
2759 (defun gnus-group-add-to-virtual (n vgroup)
2760 "Add the current group to a virtual group."
2762 (list current-prefix-arg
2763 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2765 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2766 (error "%s is not an nnvirtual group" vgroup))
2767 (gnus-close-group vgroup)
2768 (let* ((groups (gnus-group-process-prefix n))
2769 (method (gnus-info-method (gnus-get-info vgroup))))
2770 (setcar (cdr method)
2772 (nth 1 method) "\\|"
2775 (gnus-group-remove-mark s)
2776 (concat "\\(^" (regexp-quote s) "$\\)"))
2778 (gnus-group-position-point))
2780 (defun gnus-group-make-empty-virtual (group)
2781 "Create a new, fresh, empty virtual group."
2782 (interactive "sCreate new, empty virtual group: ")
2783 (let* ((method (list 'nnvirtual "^$"))
2784 (pgroup (gnus-group-prefixed-name group method)))
2785 ;; Check whether it exists already.
2786 (when (gnus-group-entry pgroup)
2787 (error "Group %s already exists" pgroup))
2788 ;; Subscribe the new group after the group on the current line.
2789 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2790 (gnus-group-update-group pgroup)
2792 (gnus-group-position-point)))
2794 (defun gnus-group-enter-directory (dir)
2795 "Enter an ephemeral nneething group."
2796 (interactive "DDirectory to read: ")
2797 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2798 (leaf (gnus-group-prefixed-name
2799 (file-name-nondirectory (directory-file-name dir))
2801 (name (gnus-generate-new-group-name leaf)))
2802 (unless (gnus-group-read-ephemeral-group
2804 (cons (current-buffer)
2805 (if (eq major-mode 'gnus-summary-mode)
2807 (error "Couldn't enter %s" dir))))
2810 (autoload 'nnimap-expunge "nnimap")
2811 (autoload 'nnimap-acl-get "nnimap")
2812 (autoload 'nnimap-acl-edit "nnimap"))
2814 (defun gnus-group-nnimap-expunge (group)
2815 "Expunge deleted articles in current nnimap GROUP."
2816 (interactive (list (gnus-group-group-name)))
2817 (let ((mailbox (gnus-group-real-name group)) method)
2819 (error "No group on current line"))
2820 (unless (gnus-get-info group)
2821 (error "Killed group; can't be edited"))
2822 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2823 (error "%s is not an nnimap group" group))
2824 (nnimap-expunge mailbox (cadr method))))
2826 (defun gnus-group-nnimap-edit-acl (group)
2827 "Edit the Access Control List of current nnimap GROUP."
2828 (interactive (list (gnus-group-group-name)))
2829 (let ((mailbox (gnus-group-real-name group)) method acl)
2831 (error "No group on current line"))
2832 (unless (gnus-get-info group)
2833 (error "Killed group; can't be edited"))
2834 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2835 (error "%s is not an nnimap group" group))
2836 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2837 (error "Server does not support ACL's"))
2838 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2840 An access control list is a list of (identifier . rights) elements.
2842 The identifier string specifies the corresponding user. The
2843 identifier \"anyone\" is reserved to refer to the universal identity.
2845 Rights is a string listing a (possibly empty) set of alphanumeric
2846 characters, each character listing a set of operations which is being
2847 controlled. Letters are reserved for ``standard'' rights, listed
2848 below. Digits are reserved for implementation or site defined rights.
2850 l - lookup (mailbox is visible to LIST/LSUB commands)
2851 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2852 SEARCH, COPY from mailbox)
2853 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2854 w - write (STORE flags other than \\SEEN and \\DELETED)
2855 i - insert (perform APPEND, COPY into mailbox)
2856 p - post (send mail to submission address for mailbox,
2857 not enforced by IMAP4 itself)
2858 c - create and delete mailbox (CREATE new sub-mailboxes in any
2859 implementation-defined hierarchy, RENAME or DELETE mailbox)
2860 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2861 a - administer (perform SETACL)" group)
2864 ,mailbox ',method ',acl form)))))
2866 ;; Group sorting commands
2867 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2869 (defun gnus-group-sort-groups (func &optional reverse)
2870 "Sort the group buffer according to FUNC.
2871 When used interactively, the sorting function used will be
2872 determined by the `gnus-group-sort-function' variable.
2873 If REVERSE (the prefix), reverse the sorting order."
2874 (interactive (list gnus-group-sort-function current-prefix-arg))
2875 (funcall gnus-group-sort-alist-function
2876 (gnus-make-sort-function func) reverse)
2877 (gnus-group-unmark-all-groups)
2878 (gnus-group-list-groups)
2879 (gnus-dribble-touch))
2881 (defun gnus-group-sort-flat (func reverse)
2882 ;; We peel off the dummy group from the alist.
2884 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2885 (pop gnus-newsrc-alist))
2887 (setq gnus-newsrc-alist
2888 (sort gnus-newsrc-alist func))
2890 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2891 ;; Regenerate the hash table.
2892 (gnus-make-hashtable-from-newsrc-alist)))
2894 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2895 "Sort the group buffer alphabetically by group name.
2896 If REVERSE, sort in reverse order."
2898 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2900 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2901 "Sort the group buffer alphabetically by real (unprefixed) group name.
2902 If REVERSE, sort in reverse order."
2904 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2906 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2907 "Sort the group buffer by number of unread articles.
2908 If REVERSE, sort in reverse order."
2910 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2912 (defun gnus-group-sort-groups-by-level (&optional reverse)
2913 "Sort the group buffer by group level.
2914 If REVERSE, sort in reverse order."
2916 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2918 (defun gnus-group-sort-groups-by-score (&optional reverse)
2919 "Sort the group buffer by group score.
2920 If REVERSE, sort in reverse order."
2922 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2924 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2925 "Sort the group buffer by group rank.
2926 If REVERSE, sort in reverse order."
2928 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2930 (defun gnus-group-sort-groups-by-method (&optional reverse)
2931 "Sort the group buffer alphabetically by back end name.
2932 If REVERSE, sort in reverse order."
2934 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2936 (defun gnus-group-sort-groups-by-server (&optional reverse)
2937 "Sort the group buffer alphabetically by server name.
2938 If REVERSE, sort in reverse order."
2940 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2942 ;;; Selected group sorting.
2944 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2945 "Sort the process/prefixed groups."
2946 (interactive (list current-prefix-arg gnus-group-sort-function))
2947 (let ((groups (gnus-group-process-prefix n)))
2948 (funcall gnus-group-sort-selected-function
2949 groups (gnus-make-sort-function func) reverse)
2950 (gnus-group-unmark-all-groups)
2951 (gnus-group-list-groups)
2952 (gnus-dribble-touch)))
2954 (defun gnus-group-sort-selected-flat (groups func reverse)
2955 (let (entries infos)
2956 ;; First find all the group entries for these groups.
2958 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2960 ;; Then sort the infos.
2964 (lambda (entry) (car entry))
2965 (setq entries (nreverse entries)))
2968 (setq infos (nreverse infos)))
2969 ;; Go through all the infos and replace the old entries
2970 ;; with the new infos.
2972 (setcar (car entries) (pop infos))
2974 ;; Update the hashtable.
2975 (gnus-make-hashtable-from-newsrc-alist)))
2977 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2978 "Sort the group buffer alphabetically by group name.
2979 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2980 sort in reverse order."
2981 (interactive (gnus-interactive "P\ny"))
2982 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2984 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2985 "Sort the group buffer alphabetically by real group name.
2986 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2987 sort in reverse order."
2988 (interactive (gnus-interactive "P\ny"))
2989 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2991 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2992 "Sort the group buffer by number of unread articles.
2993 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2994 sort in reverse order."
2995 (interactive (gnus-interactive "P\ny"))
2996 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2998 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2999 "Sort the group buffer by group level.
3000 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3001 sort in reverse order."
3002 (interactive (gnus-interactive "P\ny"))
3003 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3005 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3006 "Sort the group buffer by group score.
3007 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3008 sort in reverse order."
3009 (interactive (gnus-interactive "P\ny"))
3010 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3012 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3013 "Sort the group buffer by group rank.
3014 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3015 sort in reverse order."
3016 (interactive (gnus-interactive "P\ny"))
3017 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3019 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3020 "Sort the group buffer alphabetically by back end name.
3021 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3022 sort in reverse order."
3023 (interactive (gnus-interactive "P\ny"))
3024 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3026 ;;; Sorting predicates.
3028 (defun gnus-group-sort-by-alphabet (info1 info2)
3029 "Sort alphabetically."
3030 (string< (gnus-info-group info1) (gnus-info-group info2)))
3032 (defun gnus-group-sort-by-real-name (info1 info2)
3033 "Sort alphabetically on real (unprefixed) names."
3034 (string< (gnus-group-real-name (gnus-info-group info1))
3035 (gnus-group-real-name (gnus-info-group info2))))
3037 (defun gnus-group-sort-by-unread (info1 info2)
3038 "Sort by number of unread articles."
3039 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3040 (n2 (gnus-group-unread (gnus-info-group info1))))
3041 (< (or (and (numberp n1) n1) 0)
3042 (or (and (numberp n2) n2) 0))))
3044 (defun gnus-group-sort-by-level (info1 info2)
3046 (< (gnus-info-level info1) (gnus-info-level info2)))
3048 (defun gnus-group-sort-by-method (info1 info2)
3049 "Sort alphabetically by back end name."
3050 (string< (car (gnus-find-method-for-group
3051 (gnus-info-group info1) info1))
3052 (car (gnus-find-method-for-group
3053 (gnus-info-group info2) info2))))
3055 (defun gnus-group-sort-by-server (info1 info2)
3056 "Sort alphabetically by server name."
3057 (string< (gnus-method-to-full-server-name
3058 (gnus-find-method-for-group
3059 (gnus-info-group info1) info1))
3060 (gnus-method-to-full-server-name
3061 (gnus-find-method-for-group
3062 (gnus-info-group info2) info2))))
3064 (defun gnus-group-sort-by-score (info1 info2)
3065 "Sort by group score."
3066 (> (gnus-info-score info1) (gnus-info-score info2)))
3068 (defun gnus-group-sort-by-rank (info1 info2)
3069 "Sort by level and score."
3070 (let ((level1 (gnus-info-level info1))
3071 (level2 (gnus-info-level info2)))
3072 (or (< level1 level2)
3073 (and (= level1 level2)
3074 (> (gnus-info-score info1) (gnus-info-score info2))))))
3078 (defun gnus-group-clear-data (&optional arg)
3079 "Clear all marks and read ranges from the current group."
3081 (gnus-group-iterate arg
3084 (gnus-info-clear-data (setq info (gnus-get-info group)))
3085 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3086 (when (gnus-group-goto-group group)
3087 (gnus-group-update-group-line))))))
3089 (defun gnus-group-clear-data-on-native-groups ()
3090 "Clear all marks and read ranges from all native groups."
3092 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3093 (let ((alist (cdr gnus-newsrc-alist))
3095 (while (setq info (pop alist))
3096 (when (gnus-group-native-p (gnus-info-group info))
3097 (gnus-info-clear-data info)))
3098 (gnus-get-unread-articles)
3099 (gnus-dribble-touch)
3100 (when (gnus-y-or-n-p
3101 "Move the cache away to avoid problems in the future? ")
3102 (call-interactively 'gnus-cache-move-cache)))))
3104 (defun gnus-info-clear-data (info)
3105 "Clear all marks and read ranges from INFO."
3106 (let ((group (gnus-info-group info))
3108 (dolist (el (gnus-info-marks info))
3109 (push `(,(cdr el) add (,(car el))) action))
3110 (push `(,(gnus-info-read info) add (read)) action)
3113 (gnus-request-set-mark ,group ',action)
3114 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3115 (gnus-info-set-read ',info ',(gnus-info-read info))
3116 (when (gnus-group-goto-group ,group)
3117 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3118 (gnus-group-update-group-line))))
3119 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3121 (gnus-request-set-mark group action)
3122 (gnus-info-set-read info nil)
3123 (when (gnus-info-marks info)
3124 (gnus-info-set-marks info nil))))
3126 ;; Group catching up.
3128 (defun gnus-group-catchup-current (&optional n all)
3129 "Mark all unread articles in the current newsgroup as read.
3130 If prefix argument N is numeric, the next N newsgroups will be
3131 caught up. If ALL is non-nil, marked articles will also be marked as
3132 read. Cross references (Xref: header) of articles are ignored.
3133 The number of newsgroups that this function was unable to catch
3136 (let ((groups (gnus-group-process-prefix n))
3139 (unless groups (error "No groups selected"))
3141 (or (not gnus-interactive-catchup) ;Without confirmation?
3146 "Do you really want to mark all articles in %s as read? "
3147 "Mark all unread articles in %s as read? ")
3148 (if (= (length groups) 1)
3150 (format "these %d groups" (length groups)))))))
3152 (while (setq group (pop groups))
3153 (gnus-group-remove-mark group)
3154 ;; Virtual groups have to be given special treatment.
3155 (let ((method (gnus-find-method-for-group group)))
3156 (when (eq 'nnvirtual (car method))
3157 (nnvirtual-catchup-group
3158 (gnus-group-real-name group) (nth 1 method) all)))
3159 (if (>= (gnus-group-level group) gnus-level-zombie)
3160 (gnus-message 2 "Dead groups can't be caught up")
3162 (gnus-group-goto-group group)
3163 (gnus-group-catchup group all))
3164 (gnus-group-update-group-line)
3165 (setq ret (1+ ret)))))
3166 (gnus-group-next-unread-group 1)
3169 (defun gnus-group-catchup-current-all (&optional n)
3170 "Mark all articles in current newsgroup as read.
3171 Cross references (Xref: header) of articles are ignored."
3173 (gnus-group-catchup-current n 'all))
3175 (defun gnus-group-catchup (group &optional all)
3176 "Mark all articles in GROUP as read.
3177 If ALL is non-nil, all articles are marked as read.
3178 The return value is the number of articles that were marked as read,
3179 or nil if no action could be taken."
3180 (let* ((entry (gnus-group-entry group))
3182 (marks (gnus-info-marks (nth 2 entry)))
3183 (unread (gnus-sequence-of-unread-articles group)))
3184 ;; Remove entries for this group.
3185 (nnmail-purge-split-history (gnus-group-real-name group))
3186 ;; Do the updating only if the newsgroup isn't killed.
3187 (if (not (numberp (car entry)))
3188 (gnus-message 1 "Can't catch up %s; non-active group" group)
3189 (gnus-update-read-articles group nil)
3191 ;; Nix out the lists of marks and dormants.
3192 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3194 (list (cdr (assq 'dormant marks))
3196 (setq unread (gnus-range-add (gnus-range-add
3197 unread (cdr (assq 'dormant marks)))
3198 (cdr (assq 'tick marks))))
3199 (gnus-add-marked-articles group 'tick nil nil 'force)
3200 (gnus-add-marked-articles group 'dormant nil nil 'force))
3201 ;; Do auto-expirable marks if that's required.
3202 (when (gnus-group-auto-expirable-p group)
3203 (gnus-range-map (lambda (article)
3204 (gnus-add-marked-articles group 'expire (list article))
3205 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3207 (let ((gnus-newsgroup-name group))
3208 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3211 (defun gnus-group-expire-articles (&optional n)
3212 "Expire all expirable articles in the current newsgroup.
3213 Uses the process/prefix convention."
3215 (let ((groups (gnus-group-process-prefix n))
3218 (error "No groups to expire"))
3219 (while (setq group (pop groups))
3220 (gnus-group-remove-mark group)
3221 (gnus-group-expire-articles-1 group)
3222 (gnus-dribble-touch)
3223 (gnus-group-position-point))))
3225 (defun gnus-group-expire-articles-1 (group)
3226 (when (gnus-check-backend-function 'request-expire-articles group)
3227 (gnus-message 6 "Expiring articles in %s..." group)
3228 (let* ((info (gnus-get-info group))
3229 (expirable (if (gnus-group-total-expirable-p group)
3230 (cons nil (gnus-list-of-read-articles group))
3231 (assq 'expire (gnus-info-marks info))))
3232 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3233 (nnmail-expiry-target
3234 (or (gnus-group-find-parameter group 'expiry-target)
3235 nnmail-expiry-target)))
3237 (gnus-check-group group)
3240 (gnus-compress-sequence
3242 ;; We set the expiry variables to the group
3244 (let ((nnmail-expiry-wait-function nil)
3245 (nnmail-expiry-wait expiry-wait))
3246 (gnus-request-expire-articles
3247 (gnus-uncompress-sequence (cdr expirable)) group))
3248 ;; Just expire using the normal expiry values.
3249 (gnus-request-expire-articles
3250 (gnus-uncompress-sequence (cdr expirable)) group))))
3251 (gnus-close-group group))
3252 (gnus-message 6 "Expiring articles in %s...done" group)
3253 ;; Return the list of un-expired articles.
3256 (defun gnus-group-expire-all-groups ()
3257 "Expire all expirable articles in all newsgroups."
3260 (gnus-message 5 "Expiring...")
3261 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3262 (cdr gnus-newsrc-alist))))
3263 (gnus-group-expire-articles nil)))
3264 (gnus-group-position-point)
3265 (gnus-message 5 "Expiring...done"))
3267 (defun gnus-group-set-current-level (n level)
3268 "Set the level of the next N groups to LEVEL."
3273 (unless (gnus-group-process-prefix current-prefix-arg)
3274 (error "No group on the current line"))
3276 (let ((s (read-string
3277 (format "Level (default %s): "
3278 (or (gnus-group-group-level)
3279 gnus-level-default-subscribed)))))
3280 (if (string-match "^\\s-*$" s)
3281 (int-to-string (or (gnus-group-group-level)
3282 gnus-level-default-subscribed))
3284 (unless (and (>= level 1) (<= level gnus-level-killed))
3285 (error "Invalid level: %d" level))
3286 (let ((groups (gnus-group-process-prefix n))
3288 (while (setq group (pop groups))
3289 (gnus-group-remove-mark group)
3290 (gnus-message 6 "Changed level of %s from %d to %d"
3291 group (or (gnus-group-group-level) gnus-level-killed)
3293 (gnus-group-change-level
3294 group level (or (gnus-group-group-level) gnus-level-killed))
3295 (gnus-group-update-group-line)))
3296 (gnus-group-position-point))
3298 (defun gnus-group-unsubscribe (&optional n)
3299 "Unsubscribe the current group."
3301 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3303 (defun gnus-group-subscribe (&optional n)
3304 "Subscribe the current group."
3306 (gnus-group-unsubscribe-current-group n 'subscribe))
3308 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3309 "Toggle subscription of the current group.
3310 If given numerical prefix, toggle the N next groups."
3312 (dolist (group (gnus-group-process-prefix n))
3313 (gnus-group-remove-mark group)
3314 (gnus-group-unsubscribe-group
3317 ((eq do-sub 'unsubscribe)
3318 gnus-level-default-unsubscribed)
3319 ((eq do-sub 'subscribe)
3320 gnus-level-default-subscribed)
3321 ((<= (gnus-group-group-level) gnus-level-subscribed)
3322 gnus-level-default-unsubscribed)
3324 gnus-level-default-subscribed))
3326 (gnus-group-update-group-line))
3327 (gnus-group-next-group 1))
3329 (defun gnus-group-unsubscribe-group (group &optional level silent)
3330 "Toggle subscription to GROUP.
3331 Killed newsgroups are subscribed. If SILENT, don't try to update the
3334 (list (gnus-group-completing-read-group-name
3335 "Group: " gnus-active-hashtb nil
3336 (gnus-read-active-file-p)
3338 'gnus-group-history)))
3339 (let ((newsrc (gnus-group-entry group)))
3341 ((string-match "^[ \t]*$" group)
3342 (error "Empty group name"))
3344 ;; Toggle subscription flag.
3345 (gnus-group-change-level
3346 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3347 gnus-level-subscribed)
3348 (1+ gnus-level-subscribed)
3349 gnus-level-default-subscribed)))
3351 (gnus-group-update-group group)))
3352 ((and (stringp group)
3353 (or (not (gnus-read-active-file-p))
3354 (gnus-active group)))
3355 ;; Add new newsgroup.
3356 (gnus-group-change-level
3358 (if level level gnus-level-default-subscribed)
3359 (or (and (member group gnus-zombie-list)
3362 (when (gnus-group-group-name)
3363 (gnus-group-entry (gnus-group-group-name))))
3365 (gnus-group-update-group group)))
3366 (t (error "No such newsgroup: %s" group)))
3367 (gnus-group-position-point)))
3369 (defun gnus-group-transpose-groups (n)
3370 "Move the current newsgroup up N places.
3371 If given a negative prefix, move down instead. The difference between
3372 N and the number of steps taken is returned."
3374 (unless (gnus-group-group-name)
3375 (error "No group on current line"))
3376 (gnus-group-kill-group 1)
3378 (forward-line (- n))
3379 (gnus-group-yank-group)
3380 (gnus-group-position-point)))
3382 (defun gnus-group-kill-all-zombies (&optional dummy)
3383 "Kill all zombie newsgroups.
3384 The optional DUMMY should always be nil."
3385 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3387 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3388 (setq gnus-zombie-list nil)
3389 (gnus-dribble-touch)
3390 (gnus-group-list-groups)))
3392 (defun gnus-group-kill-region (begin end)
3393 "Kill newsgroups in current region (excluding current point).
3394 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3407 (beginning-of-line) ;Important when LINES < 1
3408 (gnus-group-kill-group lines)))
3410 (defun gnus-group-kill-group (&optional n discard)
3411 "Kill the next N groups.
3412 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3413 However, only groups that were alive can be yanked; already killed
3414 groups or zombie groups can't be yanked.
3415 The return value is the name of the group that was killed, or a list
3418 (let ((buffer-read-only nil)
3419 (groups (gnus-group-process-prefix n))
3420 group entry level out)
3421 (if (< (length groups) 10)
3422 ;; This is faster when there are few groups.
3424 (push (setq group (pop groups)) out)
3425 (gnus-group-remove-mark group)
3426 (setq level (gnus-group-group-level))
3428 (when (and (not discard)
3429 (setq entry (gnus-group-entry group)))
3432 (gnus-group-goto-group ,(gnus-group-group-name))
3433 (gnus-group-yank-group)))
3434 (push (cons (car entry) (nth 2 entry))
3435 gnus-list-of-killed-groups))
3436 (gnus-group-change-level
3437 (if entry entry group) gnus-level-killed (if entry nil level))
3438 (message "Killed group %s" group))
3439 ;; If there are lots and lots of groups to be killed, we use
3440 ;; this thing instead.
3441 (dolist (group (nreverse groups))
3442 (gnus-group-remove-mark group)
3444 (push group gnus-killed-list)
3445 (setq gnus-newsrc-alist
3446 (delq (assoc group gnus-newsrc-alist)
3448 (when gnus-group-change-level-function
3449 (funcall gnus-group-change-level-function
3450 group gnus-level-killed 3))
3452 ((setq entry (gnus-group-entry group))
3453 (push (cons (car entry) (nth 2 entry))
3454 gnus-list-of-killed-groups)
3455 (setcdr (cdr entry) (cdddr entry)))
3456 ((member group gnus-zombie-list)
3457 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3458 ;; There may be more than one instance displayed.
3459 (while (gnus-group-goto-group group)
3460 (gnus-delete-line)))
3461 (gnus-make-hashtable-from-newsrc-alist))
3463 (gnus-group-position-point)
3464 (if (< (length out) 2) (car out) (nreverse out))))
3466 (defun gnus-group-yank-group (&optional arg)
3467 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3468 The numeric ARG specifies how many newsgroups are to be yanked. The
3469 name of the newsgroup yanked is returned, or (if several groups are
3470 yanked) a list of yanked groups is returned."
3472 (setq arg (or arg 1))
3473 (let (info group prev out)
3474 (while (>= (decf arg) 0)
3475 (when (not (setq info (pop gnus-list-of-killed-groups)))
3476 (error "No more newsgroups to yank"))
3477 (push (setq group (nth 1 info)) out)
3478 ;; Find which newsgroup to insert this one before - search
3479 ;; backward until something suitable is found. If there are no
3480 ;; other newsgroups in this buffer, just make this newsgroup the
3482 (setq prev (gnus-group-group-name))
3483 (gnus-group-change-level
3484 info (gnus-info-level (cdr info)) gnus-level-killed
3485 (and prev (gnus-group-entry prev))
3487 (gnus-group-insert-group-line-info group)
3489 `(when (gnus-group-goto-group ,group)
3490 (gnus-group-kill-group 1))))
3492 (gnus-group-position-point)
3493 (if (< (length out) 2) (car out) (nreverse out))))
3495 (defun gnus-group-kill-level (level)
3496 "Kill all groups that is on a certain LEVEL."
3497 (interactive "nKill all groups on level: ")
3499 ((= level gnus-level-zombie)
3500 (setq gnus-killed-list
3501 (nconc gnus-zombie-list gnus-killed-list))
3502 (setq gnus-zombie-list nil))
3503 ((and (< level gnus-level-zombie)
3505 (or gnus-expert-user
3508 "Do you really want to kill all groups on level %d? "
3510 (let* ((prev gnus-newsrc-alist)
3513 (if (= (gnus-info-level (car alist)) level)
3515 (push (gnus-info-group (car alist)) gnus-killed-list)
3516 (setcdr prev (cdr alist)))
3518 (setq alist (cdr alist)))
3519 (gnus-make-hashtable-from-newsrc-alist)
3520 (gnus-group-list-groups)))
3522 (error "Can't kill; invalid level: %d" level))))
3524 (defun gnus-group-list-all-groups (&optional arg)
3525 "List all newsgroups with level ARG or lower.
3526 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3527 unsubscribed groups."
3529 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3531 ;; Redefine this to list ALL killed groups if prefix arg used.
3532 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3533 (defun gnus-group-list-killed (&optional arg)
3534 "List all killed newsgroups in the group buffer.
3535 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3536 entail asking the server for the groups."
3538 ;; Find all possible killed newsgroups if arg.
3540 (gnus-get-killed-groups))
3541 (if (not gnus-killed-list)
3542 (gnus-message 6 "No killed groups")
3543 (let (gnus-group-list-mode)
3544 (funcall gnus-group-prepare-function
3545 gnus-level-killed t gnus-level-killed))
3546 (goto-char (point-min)))
3547 (gnus-group-position-point))
3549 (defun gnus-group-list-zombies ()
3550 "List all zombie newsgroups in the group buffer."
3552 (if (not gnus-zombie-list)
3553 (gnus-message 6 "No zombie groups")
3554 (let (gnus-group-list-mode)
3555 (funcall gnus-group-prepare-function
3556 gnus-level-zombie t gnus-level-zombie))
3557 (goto-char (point-min)))
3558 (gnus-group-position-point))
3560 (defun gnus-group-list-active ()
3561 "List all groups that are available from the server(s)."
3563 ;; First we make sure that we have really read the active file.
3564 (unless (gnus-read-active-file-p)
3565 (let ((gnus-read-active-file t)
3566 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3567 (gnus-read-active-file)))
3568 ;; Find all groups and sort them.
3576 (push (symbol-name sym) list)))
3580 (buffer-read-only nil)
3584 (setq group (pop groups))
3585 (gnus-add-text-properties
3586 (point) (prog1 (1+ (point))
3588 (gnus-group-decoded-name group)
3590 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3592 'gnus-level (inline (gnus-group-level group)))))
3593 (goto-char (point-min))))
3595 (defun gnus-activate-all-groups (level)
3596 "Activate absolutely all groups."
3597 (interactive (list gnus-level-unsubscribed))
3598 (let ((gnus-activate-level level)
3599 (gnus-activate-foreign-newsgroups level))
3600 (gnus-group-get-new-news)))
3602 (defun gnus-group-get-new-news (&optional arg)
3603 "Get newly arrived articles.
3604 If ARG is a number, it specifies which levels you are interested in
3605 re-scanning. If ARG is non-nil and not a number, this will force
3606 \"hard\" re-reading of the active files from all servers."
3609 (let ((gnus-inhibit-demon t)
3610 ;; Binding this variable will inhibit multiple fetchings
3611 ;; of the same mail source.
3612 (nnmail-fetched-sources (list t)))
3613 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3614 (gnus-run-hooks 'gnus-get-new-news-hook)
3616 ;; Read any slave files.
3618 (gnus-master-read-slave-newsrc))
3620 ;; We might read in new NoCeM messages here.
3621 (when (and gnus-use-nocem
3623 (gnus-nocem-scan-groups))
3624 ;; If ARG is not a number, then we read the active file.
3625 (when (and arg (not (numberp arg)))
3626 (let ((gnus-read-active-file t))
3627 (gnus-read-active-file))
3630 ;; If the user wants it, we scan for new groups.
3631 (when (eq gnus-check-new-newsgroups 'always)
3632 (gnus-find-new-newsgroups)))
3634 (setq arg (gnus-group-default-level arg t))
3635 (if (and gnus-read-active-file (not arg))
3637 (gnus-read-active-file)
3638 (gnus-get-unread-articles arg))
3639 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3640 (gnus-get-unread-articles arg)))
3641 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3642 (gnus-group-list-groups (and (numberp arg)
3643 (max (car gnus-group-list-mode) arg))))
3645 (when (and gnus-agent (not (interactive-p)))
3646 (gnus-agent-toggle-plugged gnus-plugged)))
3648 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3649 "Check for newly arrived news in the current group (and the N-1 next groups).
3650 The difference between N and the number of newsgroup checked is returned.
3651 If N is negative, this group and the N-1 previous groups will be checked."
3653 (let* ((groups (gnus-group-process-prefix n))
3654 (ret (if (numberp n) (- n (length groups)) 0))
3658 (gnus-inhibit-demon t)
3659 ;; Binding this variable will inhibit multiple fetchings
3660 ;; of the same mail source.
3661 (nnmail-fetched-sources (list t)))
3662 (gnus-run-hooks 'gnus-get-new-news-hook)
3663 (while (setq group (pop groups))
3664 (gnus-group-remove-mark group)
3665 ;; Bypass any previous denials from the server.
3666 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3667 (if (gnus-activate-group group (if dont-scan nil 'scan))
3669 (gnus-get-unread-articles-in-group
3670 (gnus-get-info group) (gnus-active group) t)
3671 (unless (gnus-virtual-group-p group)
3672 (gnus-close-group group))
3674 (gnus-agent-save-group-info
3675 method (gnus-group-real-name group) (gnus-active group)))
3676 (gnus-group-update-group group))
3677 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3679 (gnus-error 3 "Server denied access")
3680 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3683 (when gnus-goto-next-group-when-activating
3684 (gnus-group-next-unread-group 1 t))
3685 (gnus-summary-position-point)
3688 (defun gnus-group-fetch-faq (group &optional faq-dir)
3689 "Fetch the FAQ for the current group.
3690 If given a prefix argument, prompt for the FAQ dir
3694 (gnus-group-group-name)
3695 (when current-prefix-arg
3697 "FAQ dir: " (and (listp gnus-group-faq-directory)
3699 gnus-group-faq-directory))))))
3701 (error "No group name given"))
3702 (let ((dirs (or faq-dir gnus-group-faq-directory))
3704 (unless (listp dirs)
3705 (setq dirs (list dirs)))
3706 (while (and (not found)
3707 (setq dir (pop dirs)))
3708 (let ((name (gnus-group-real-name group)))
3709 (setq file (expand-file-name name dir)))
3710 (if (not (file-exists-p file))
3711 (gnus-message 1 "No such file: %s" file)
3712 (let ((enable-local-variables nil))
3716 (defun gnus-group-fetch-charter (group)
3717 "Fetch the charter for the current group.
3718 If given a prefix argument, prompt for a group."
3720 (list (or (when current-prefix-arg
3721 (completing-read "Group: " gnus-active-hashtb))
3722 (gnus-group-group-name)
3723 gnus-newsgroup-name)))
3725 (error "No group name given"))
3727 (condition-case nil (require 'url-http) (error nil))
3728 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3730 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3731 (setq hierarchy (match-string 1 name))
3732 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3733 (if (fboundp 'url-http-file-exists-p)
3734 (url-http-file-exists-p (eval url))
3736 (browse-url (eval url))
3737 (setq url (concat "http://" hierarchy
3738 ".news-admin.org/charters/" name))
3739 (if (and (fboundp 'url-http-file-exists-p)
3740 (url-http-file-exists-p url))
3742 (gnus-group-fetch-control group))))))
3744 (defun gnus-group-fetch-control (group)
3745 "Fetch the archived control messages for the current group.
3746 If given a prefix argument, prompt for a group."
3748 (list (or (when current-prefix-arg
3749 (completing-read "Group: " gnus-active-hashtb))
3750 (gnus-group-group-name)
3751 gnus-newsgroup-name)))
3753 (error "No group name given"))
3754 (let ((name (gnus-group-real-name group))
3756 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3757 (setq hierarchy (match-string 1 name))
3758 (if gnus-group-fetch-control-use-browse-url
3759 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3760 hierarchy "/" name ".gz"))
3761 (let ((enable-local-variables nil))
3762 (gnus-group-read-ephemeral-group
3764 `(nndoc ,group (nndoc-address
3765 ,(find-file-noselect
3766 (concat "/ftp@ftp.isc.org:/usenet/control/"
3767 hierarchy "/" name ".gz")))
3768 (nndoc-article-type mbox)) t nil nil))))))
3770 (defun gnus-group-describe-group (force &optional group)
3771 "Display a description of the current newsgroup."
3772 (interactive (list current-prefix-arg (gnus-group-group-name)))
3773 (let* ((method (gnus-find-method-for-group group))
3774 (mname (gnus-group-prefixed-name "" method))
3777 gnus-description-hashtb)
3778 (gnus-sethash mname nil gnus-description-hashtb))
3780 (error "No group name given"))
3781 (when (or (and gnus-description-hashtb
3782 ;; We check whether this group's method has been
3783 ;; queried for a description file.
3784 (gnus-gethash mname gnus-description-hashtb))
3785 (setq desc (gnus-group-get-description group))
3786 (gnus-read-descriptions-file method))
3788 (or desc (gnus-gethash group gnus-description-hashtb)
3789 "No description available")))))
3791 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3792 (defun gnus-group-describe-all-groups (&optional force)
3793 "Pop up a buffer with descriptions of all newsgroups."
3796 (setq gnus-description-hashtb nil))
3797 (when (not (or gnus-description-hashtb
3798 (gnus-read-all-descriptions-files)))
3799 (error "Couldn't request descriptions file"))
3800 (let ((buffer-read-only nil)
3806 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3807 (insert (format " *: %-20s %s\n"
3808 (gnus-group-name-decode
3809 (symbol-name group) charset)
3810 (gnus-group-name-decode
3811 (symbol-value group) charset))))
3812 (gnus-add-text-properties
3813 b (1+ b) (list 'gnus-group group
3814 'gnus-unread t 'gnus-marked nil
3815 'gnus-level (1+ gnus-level-subscribed))))
3816 gnus-description-hashtb)
3817 (goto-char (point-min))
3818 (gnus-group-position-point)))
3820 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3821 (defun gnus-group-apropos (regexp &optional search-description)
3822 "List all newsgroups that have names that match a regexp."
3823 (interactive "sGnus apropos (regexp): ")
3825 (obuf (current-buffer))
3827 ;; Go through all newsgroups that are known to Gnus.
3830 (and (symbol-name group)
3831 (string-match regexp (symbol-name group))
3832 (symbol-value group)
3833 (push (symbol-name group) groups)))
3835 ;; Also go through all descriptions that are known to Gnus.
3836 (when search-description
3839 (and (string-match regexp (symbol-value group))
3840 (push (symbol-name group) groups)))
3841 gnus-description-hashtb))
3843 (gnus-message 3 "No groups matched \"%s\"." regexp)
3844 ;; Print out all the groups.
3846 (pop-to-buffer "*Gnus Help*")
3847 (buffer-disable-undo)
3849 (setq groups (sort groups 'string<))
3851 ;; Groups may be entered twice into the list of groups.
3852 (when (not (string= (car groups) prev))
3853 (setq prev (car groups))
3854 (let ((charset (gnus-group-name-charset nil prev)))
3855 (insert (gnus-group-name-decode prev charset) "\n")
3856 (when (and gnus-description-hashtb
3857 (setq des (gnus-gethash (car groups)
3858 gnus-description-hashtb)))
3859 (insert " " (gnus-group-name-decode des charset) "\n"))))
3860 (setq groups (cdr groups)))
3861 (goto-char (point-min))))
3862 (pop-to-buffer obuf)))
3864 (defun gnus-group-description-apropos (regexp)
3865 "List all newsgroups that have names or descriptions that match REGEXP."
3866 (interactive "sGnus description apropos (regexp): ")
3867 (when (not (or gnus-description-hashtb
3868 (gnus-read-all-descriptions-files)))
3869 (error "Couldn't request descriptions file"))
3870 (gnus-group-apropos regexp t))
3872 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3873 (defun gnus-group-list-matching (level regexp &optional all lowest)
3874 "List all groups with unread articles that match REGEXP.
3875 If the prefix LEVEL is non-nil, it should be a number that says which
3876 level to cut off listing groups.
3877 If ALL, also list groups with no unread articles.
3878 If LOWEST, don't list groups with level lower than LOWEST.
3880 This command may read the active file."
3881 (interactive "P\nsList newsgroups matching: ")
3882 ;; First make sure active file has been read.
3884 (> (prefix-numeric-value level) gnus-level-killed))
3885 (gnus-get-killed-groups))
3886 (funcall gnus-group-prepare-function
3887 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3888 (goto-char (point-min))
3889 (gnus-group-position-point))
3891 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3892 "List all groups that match REGEXP.
3893 If the prefix LEVEL is non-nil, it should be a number that says which
3894 level to cut off listing groups.
3895 If LOWEST, don't list groups with level lower than LOWEST."
3896 (interactive "P\nsList newsgroups matching: ")
3898 (setq level (prefix-numeric-value level)))
3899 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3901 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3902 (defun gnus-group-save-newsrc (&optional force)
3903 "Save the Gnus startup files.
3904 If FORCE, force saving whether it is necessary or not."
3906 (gnus-save-newsrc-file force))
3908 (defun gnus-group-restart (&optional arg)
3909 "Force Gnus to read the .newsrc file."
3911 (when (gnus-yes-or-no-p
3912 (format "Are you sure you want to restart Gnus? "))
3913 (gnus-save-newsrc-file)
3917 (defun gnus-group-read-init-file ()
3918 "Read the Gnus elisp init file."
3920 (gnus-read-init-file)
3921 (gnus-message 5 "Read %s" gnus-init-file))
3923 (defun gnus-group-check-bogus-groups (&optional silent)
3924 "Check bogus newsgroups.
3925 If given a prefix, don't ask for confirmation before removing a bogus
3928 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3929 (gnus-group-list-groups))
3931 (defun gnus-group-find-new-groups (&optional arg)
3932 "Search for new groups and add them.
3933 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3934 With 1 C-u, use the `ask-server' method to query the server for new
3936 With 2 C-u's, use most complete method possible to query the server
3937 for new groups, and subscribe the new groups as zombies."
3939 (gnus-find-new-newsgroups (or arg 1))
3940 (gnus-group-list-groups))
3942 (defun gnus-group-edit-global-kill (&optional article group)
3943 "Edit the global kill file.
3944 If GROUP, edit that local kill file instead."
3946 (setq gnus-current-kill-article article)
3947 (gnus-kill-file-edit-file group)
3950 (substitute-command-keys
3951 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3952 (if group "local" "global")))))
3954 (defun gnus-group-edit-local-kill (article group)
3955 "Edit a local kill file."
3956 (interactive (list nil (gnus-group-group-name)))
3957 (gnus-group-edit-global-kill article group))
3959 (defun gnus-group-force-update ()
3960 "Update `.newsrc' file."
3962 (gnus-save-newsrc-file))
3964 (defvar gnus-backlog-articles)
3966 (defun gnus-group-suspend ()
3967 "Suspend the current Gnus session.
3968 In fact, cleanup buffers except for group mode buffer.
3969 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3971 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3972 (gnus-offer-save-summaries)
3973 ;; Kill Gnus buffers except for group mode buffer.
3974 (let ((group-buf (get-buffer gnus-group-buffer)))
3975 (mapcar (lambda (buf)
3976 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3977 (with-current-buffer buf
3978 (eq major-mode 'message-mode)))
3979 (gnus-kill-buffer buf)))
3981 (setq gnus-backlog-articles nil)
3982 (gnus-kill-gnus-frames)
3984 (bury-buffer group-buf)
3985 (delete-windows-on group-buf t))))
3987 (defun gnus-group-clear-dribble ()
3988 "Clear all information from the dribble buffer."
3990 (gnus-dribble-clear)
3991 (gnus-message 7 "Cleared dribble buffer"))
3993 (defun gnus-group-exit ()
3994 "Quit reading news after updating .newsrc.eld and .newsrc.
3995 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3998 (or noninteractive ;For gnus-batch-kill
3999 (not gnus-interactive-exit) ;Without confirmation
4001 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4002 (gnus-run-hooks 'gnus-exit-gnus-hook)
4003 ;; Offer to save data from non-quitted summary buffers.
4004 (gnus-offer-save-summaries)
4005 ;; Save the newsrc file(s).
4006 (gnus-save-newsrc-file)
4008 (gnus-close-backends)
4009 ;; Reset everything.
4011 ;; Allow the user to do things after cleaning up.
4012 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4014 (defun gnus-group-quit ()
4015 "Quit reading news without updating .newsrc.eld or .newsrc.
4016 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4018 (when (or noninteractive ;For gnus-batch-kill
4019 (zerop (buffer-size))
4020 (not (gnus-server-opened gnus-select-method))
4022 (not gnus-current-startup-file)
4024 (format "Quit reading news without saving %s? "
4025 (file-name-nondirectory gnus-current-startup-file))))
4026 (gnus-run-hooks 'gnus-exit-gnus-hook)
4027 (gnus-configure-windows 'group t)
4028 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4029 (not (zerop (save-excursion
4030 (set-buffer gnus-dribble-buffer)
4033 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4035 (gnus-close-backends)
4037 (gnus-kill-buffer gnus-group-buffer)
4038 ;; Allow the user to do things after cleaning up.
4039 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4041 (defun gnus-group-describe-briefly ()
4042 "Give a one line description of the group mode commands."
4044 (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")))
4046 (defun gnus-group-browse-foreign-server (method)
4047 "Browse a foreign news server.
4048 If called interactively, this function will ask for a select method
4049 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4050 If not, METHOD should be a list where the first element is the method
4051 and the second element is the address."
4053 (list (let ((how (completing-read
4055 (append gnus-valid-select-methods gnus-server-alist)
4056 nil t (cons "nntp" 0) 'gnus-method-history)))
4057 ;; We either got a back end name or a virtual server name.
4058 ;; If the first, we also need an address.
4059 (if (assoc how gnus-valid-select-methods)
4061 ;; Suggested by mapjph@bath.ac.uk.
4064 (mapcar (lambda (server) (list server))
4065 gnus-secondary-servers)))
4066 ;; We got a server name.
4068 (gnus-browse-foreign-server method))
4070 (defun gnus-group-set-info (info &optional method-only-group part)
4071 (when (or info part)
4072 (let* ((entry (gnus-group-entry
4073 (or method-only-group (gnus-info-group info))))
4075 (info (if method-only-group (nth 2 entry) info))
4077 (when method-only-group
4079 (error "Trying to change non-existent group %s" method-only-group))
4080 ;; We have received parts of the actual group info - either the
4081 ;; select method or the group parameters. We first check
4082 ;; whether we have to extend the info, and if so, do that.
4083 (let ((len (length info))
4084 (total (if (eq part 'method) 5 6)))
4086 (setcdr (nthcdr (1- len) info)
4087 (make-list (- total len) nil)))
4088 ;; Then we enter the new info.
4089 (setcar (nthcdr (1- total) info) part-info)))
4091 ;; This is a new group, so we just create it.
4093 (set-buffer gnus-group-buffer)
4094 (setq method (gnus-info-method info))
4095 (when (gnus-server-equal method "native")
4098 (set-buffer gnus-group-buffer)
4100 ;; It's a foreign group...
4101 (gnus-group-make-group
4102 (gnus-group-real-name (gnus-info-group info))
4103 (if (stringp method) method
4104 (prin1-to-string (car method)))
4106 (nth 1 (gnus-info-method info))))
4107 ;; It's a native group.
4108 (gnus-group-make-group (gnus-info-group info))))
4109 (gnus-message 6 "Note: New group created")
4111 (gnus-group-entry (gnus-group-prefixed-name
4112 (gnus-group-real-name (gnus-info-group info))
4113 (or (gnus-info-method info) gnus-select-method))))))
4114 ;; Whether it was a new group or not, we now have the entry, so we
4115 ;; can do the update.
4118 (setcar (nthcdr 2 entry) info)
4119 (when (and (not (eq (car entry) t))
4120 (gnus-active (gnus-info-group info)))
4121 (setcar entry (length
4122 (gnus-list-of-unread-articles (car info))))))
4123 (error "No such group: %s" (gnus-info-group info))))))
4125 (defun gnus-group-set-method-info (group select-method)
4126 (gnus-group-set-info select-method group 'method))
4128 (defun gnus-group-set-params-info (group params)
4129 (gnus-group-set-info params group 'params))
4131 (defun gnus-add-marked-articles (group type articles &optional info force)
4132 ;; Add ARTICLES of TYPE to the info of GROUP.
4133 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4134 ;; add, but replace marked articles of TYPE with ARTICLES.
4135 (let ((info (or info (gnus-get-info group)))
4138 (and (not (setq marked (nthcdr 3 info)))
4140 (setcdr (nthcdr 2 info)
4141 (list (list (cons type (gnus-compress-sequence
4143 (and (not (setq m (assq type (car marked))))
4146 (cons (cons type (gnus-compress-sequence articles t) )
4150 (setcar (nthcdr 3 info)
4151 (gnus-delete-alist type (car marked)))
4152 (setcdr m (gnus-compress-sequence articles t)))
4153 (setcdr m (gnus-compress-sequence
4154 (sort (nconc (gnus-uncompress-range (cdr m))
4155 (copy-sequence articles)) '<) t))))))
4157 (defun gnus-add-mark (group mark article)
4158 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4159 (let ((buffer (gnus-summary-buffer-name group)))
4160 (if (gnus-buffer-live-p buffer)
4162 (set-buffer (get-buffer buffer))
4163 (gnus-summary-add-mark article mark))
4164 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4168 ;;; Group timestamps
4171 (defun gnus-group-set-timestamp ()
4172 "Change the timestamp of the current group to the current time.
4173 This function can be used in hooks like `gnus-select-group-hook'
4174 or `gnus-group-catchup-group-hook'."
4175 (when gnus-newsgroup-name
4176 (let ((time (current-time)))
4177 (setcdr (cdr time) nil)
4178 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4180 (defsubst gnus-group-timestamp (group)
4181 "Return the timestamp for GROUP."
4182 (gnus-group-get-parameter group 'timestamp t))
4184 (defun gnus-group-timestamp-delta (group)
4185 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4186 (let* ((time (or (gnus-group-timestamp group)
4188 (delta (subtract-time (current-time) time)))
4189 (+ (* (nth 0 delta) 65536.0)
4192 (defun gnus-group-timestamp-string (group)
4193 "Return a string of the timestamp for GROUP."
4194 (let ((time (gnus-group-timestamp group)))
4197 (gnus-time-iso8601 time))))
4199 (defun gnus-group-list-cached (level &optional lowest)
4200 "List all groups with cached articles.
4201 If the prefix LEVEL is non-nil, it should be a number that says which
4202 level to cut off listing groups.
4203 If LOWEST, don't list groups with level lower than LOWEST.
4205 This command may read the active file."
4208 (setq level (prefix-numeric-value level)))
4209 (when (or (not level) (>= level gnus-level-zombie))
4211 (funcall gnus-group-prepare-function
4212 (or level gnus-level-subscribed)
4214 (let ((marks (gnus-info-marks info)))
4215 (assq 'cache marks)))
4218 (or (gnus-gethash group
4219 gnus-cache-active-hashtb)
4220 ;; Cache active file might use "."
4223 (mapconcat 'identity
4224 (split-string group ":")
4226 gnus-cache-active-hashtb))))
4227 (goto-char (point-min))
4228 (gnus-group-position-point))
4230 (defun gnus-group-list-dormant (level &optional lowest)
4231 "List all groups with dormant articles.
4232 If the prefix LEVEL is non-nil, it should be a number that says which
4233 level to cut off listing groups.
4234 If LOWEST, don't list groups with level lower than LOWEST.
4236 This command may read the active file."
4239 (setq level (prefix-numeric-value level)))
4240 (when (or (not level) (>= level gnus-level-zombie))
4242 (funcall gnus-group-prepare-function
4243 (or level gnus-level-subscribed)
4245 (let ((marks (gnus-info-marks info)))
4246 (assq 'dormant marks)))
4249 (goto-char (point-min))
4250 (gnus-group-position-point))
4252 (defun gnus-group-listed-groups ()
4253 "Return a list of listed groups."
4255 (goto-char (point-min))
4256 (while (setq point (text-property-not-all (point) (point-max)
4259 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4263 (defun gnus-group-list-plus (&optional args)
4264 "List groups plus the current selection."
4266 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4267 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4269 (push last-command-event unread-command-events)
4270 (if (featurep 'xemacs)
4271 (push (make-event 'key-press '(key ?A)) unread-command-events)
4272 (push ?A unread-command-events))
4273 (let (gnus-pick-mode keys)
4274 (setq keys (if (featurep 'xemacs)
4275 (events-to-keys (read-key-sequence nil))
4276 (read-key-sequence nil)))
4277 (setq func (lookup-key (current-local-map) keys)))
4281 (call-interactively func))))
4283 (defun gnus-group-list-flush (&optional args)
4284 "Flush groups from the current selection."
4286 (let ((gnus-group-list-option 'flush))
4287 (gnus-group-list-plus args)))
4289 (defun gnus-group-list-limit (&optional args)
4290 "List groups limited within the current selection."
4292 (let ((gnus-group-list-option 'limit))
4293 (gnus-group-list-plus args)))
4295 (defun gnus-group-mark-article-read (group article)
4296 "Mark ARTICLE read."
4297 (let ((buffer (gnus-summary-buffer-name group))
4298 (mark gnus-read-mark)
4300 (if (get-buffer buffer)
4301 (with-current-buffer buffer
4302 (setq active gnus-newsgroup-active)
4303 (gnus-activate-group group)
4304 (when gnus-newsgroup-prepared
4305 (when (and gnus-newsgroup-auto-expire
4306 (memq mark gnus-auto-expirable-marks))
4307 (setq mark gnus-expirable-mark))
4308 (setq mark (gnus-request-update-mark
4309 group article mark))
4310 (gnus-mark-article-as-read article mark)
4311 (setq gnus-newsgroup-active (gnus-active group))
4313 (setq n (1+ (cdr active)))
4314 (while (<= n (cdr gnus-newsgroup-active))
4315 (unless (eq n article)
4316 (push n gnus-newsgroup-unselected))
4318 (setq gnus-newsgroup-unselected
4319 (nreverse gnus-newsgroup-unselected)))))
4320 (gnus-activate-group group)
4321 (gnus-group-make-articles-read group (list article))
4322 (when (gnus-group-auto-expirable-p group)
4323 (gnus-add-marked-articles
4324 group 'expire (list article))))))
4326 (provide 'gnus-group)
4328 ;;; gnus-group.el ends here