1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-map))
48 (let ((features (cons 'gnus-group features)))
50 (unless (boundp 'gnus-cache-active-hashtb)
51 (defvar gnus-cache-active-hashtb nil)))
53 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
54 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
56 (defcustom gnus-group-archive-directory
57 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
58 "*The address of the (ding) archives."
59 :group 'gnus-group-foreign
62 (defcustom gnus-group-recent-archive-directory
63 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
64 "*The address of the most recent (ding) articles."
65 :group 'gnus-group-foreign
68 (defcustom gnus-no-groups-message "No Gnus is good news"
69 "*Message displayed by Gnus when no groups are available."
73 (defcustom gnus-keep-same-level nil
74 "*Non-nil means that the next newsgroup after the current will be on the same level.
75 When you type, for instance, `n' after reading the last article in the
76 current newsgroup, you will go to the next newsgroup. If this variable
77 is nil, the next newsgroup will be the next from the group
79 If this variable is non-nil, Gnus will either put you in the
80 next newsgroup with the same level, or, if no such newsgroup is
81 available, the next newsgroup with the lowest possible level higher
82 than the current level.
83 If this variable is `best', Gnus will make the next newsgroup the one
85 :group 'gnus-group-levels
86 :type '(choice (const nil)
88 (sexp :tag "other" t)))
90 (defcustom gnus-group-goto-unread t
91 "*If non-nil, movement commands will go to the next unread and subscribed group."
92 :link '(custom-manual "(gnus)Group Maneuvering")
93 :group 'gnus-group-various
96 (defcustom gnus-goto-next-group-when-activating t
97 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
98 :link '(custom-manual "(gnus)Scanning New Messages")
99 :group 'gnus-group-various
102 (defcustom gnus-permanently-visible-groups nil
103 "*Regexp to match groups that should always be listed in the group buffer.
104 This means that they will still be listed even when there are no
105 unread articles in the groups.
107 If nil, no groups are permanently visible."
108 :group 'gnus-group-listing
109 :type '(choice regexp (const nil)))
111 (defcustom gnus-list-groups-with-ticked-articles t
112 "*If non-nil, list groups that have only ticked articles.
113 If nil, only list groups that have unread articles."
114 :group 'gnus-group-listing
117 (defcustom gnus-group-default-list-level gnus-level-subscribed
118 "*Default listing level.
119 Ignored if `gnus-group-use-permanent-levels' is non-nil."
120 :group 'gnus-group-listing
123 (defcustom gnus-group-list-inactive-groups t
124 "*If non-nil, inactive groups will be listed."
125 :group 'gnus-group-listing
126 :group 'gnus-group-levels
129 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
130 "*Function used for sorting the group buffer.
131 This function will be called with group info entries as the arguments
132 for the groups to be sorted. Pre-made functions include
133 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
134 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
135 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
136 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
138 This variable can also be a list of sorting functions. In that case,
139 the most significant sort function should be the last function in the
141 :group 'gnus-group-listing
142 :link '(custom-manual "(gnus)Sorting Groups")
143 :type '(repeat :value-to-internal (lambda (widget value)
144 (if (listp value) value (list value)))
145 :match (lambda (widget value)
147 (widget-editable-list-match widget value)))
148 (choice (function-item gnus-group-sort-by-alphabet)
149 (function-item gnus-group-sort-by-real-name)
150 (function-item gnus-group-sort-by-unread)
151 (function-item gnus-group-sort-by-level)
152 (function-item gnus-group-sort-by-score)
153 (function-item gnus-group-sort-by-method)
154 (function-item gnus-group-sort-by-server)
155 (function-item gnus-group-sort-by-rank)
156 (function :tag "other" nil))))
158 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
159 "*Format of group lines.
160 It works along the same lines as a normal formatting string,
161 with some simple extensions.
163 %M Only marked articles (character, \"*\" or \" \")
164 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
165 %L Level of subscribedness (integer)
166 %N Number of unread articles (integer)
167 %I Number of dormant articles (integer)
168 %i Number of ticked and dormant (integer)
169 %T Number of ticked articles (integer)
170 %R Number of read articles (integer)
171 %U Number of unseen articles (integer)
172 %t Estimated total number of articles (integer)
173 %y Number of unread, unticked articles (integer)
174 %G Group name (string)
175 %g Qualified group name (string)
176 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
177 %C Group comment (string)
178 %D Group description (string)
179 %s Select method (string)
180 %o Moderated group (char, \"m\")
181 %p Process mark (char)
182 %B Whether a summary buffer for the group is open (char, \"*\")
183 %O Moderated group (string, \"(m)\" or \"\")
184 %P Topic indentation (string)
185 %m Whether there is new(ish) mail in the group (char, \"%\")
186 %w Number of new(ish) mails in the group (integer)
187 %n Select from where (string)
188 %z A string that look like `<%s:%n>' if a foreign select method is used
189 %d The date the group was last entered.
190 %E Icon as defined by `gnus-group-icon-list'.
191 %F The disk space used by the articles fetched by both the cache and agent.
192 %u User defined specifier. The next character in the format string should
193 be a letter. Gnus will call the function gnus-user-format-function-X,
194 where X is the letter following %u. The function will be passed a
195 single dummy parameter as argument. The function should return a
196 string, which will be inserted into the buffer just like information
197 from any other group specifier.
199 Note that this format specification is not always respected. For
200 reasons of efficiency, when listing killed groups, this specification
201 is ignored altogether. If the spec is changed considerably, your
202 output may end up looking strange when listing both alive and killed
205 If you use %o or %O, reading the active file will be slower and quite
206 a bit of extra memory will be used. %D and %F will also worsen
207 performance. Also note that if you change the format specification to
208 include any of these specs, you must probably re-start Gnus to see
211 General format specifiers can also be used.
212 See Info node `(gnus)Formatting Variables'."
213 :link '(custom-manual "(gnus)Formatting Variables")
214 :group 'gnus-group-visual
217 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
218 "*The format specification for the group mode line.
219 It works along the same lines as a normal formatting string,
220 with some simple extensions:
222 %S The native news server.
223 %M The native select method.
224 %: \":\" if %S isn't \"\"."
225 :group 'gnus-group-visual
228 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
229 (when (featurep 'xemacs)
230 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
231 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
233 (defcustom gnus-group-menu-hook nil
234 "Hook run after the creation of the group mode menu."
235 :group 'gnus-group-various
238 (defcustom gnus-group-catchup-group-hook nil
239 "Hook run when catching up a group from the group buffer."
240 :group 'gnus-group-various
241 :link '(custom-manual "(gnus)Group Data")
244 (defcustom gnus-group-update-group-hook nil
245 "Hook called when updating group lines."
246 :group 'gnus-group-visual
249 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
250 "*A function that is called to generate the group buffer.
251 The function is called with three arguments: The first is a number;
252 all group with a level less or equal to that number should be listed,
253 if the second is non-nil, empty groups should also be displayed. If
254 the third is non-nil, it is a number. No groups with a level lower
255 than this number should be displayed.
257 The only current function implemented is `gnus-group-prepare-flat'."
258 :group 'gnus-group-listing
261 (defcustom gnus-group-prepare-hook nil
262 "Hook called after the group buffer has been generated.
263 If you want to modify the group buffer, you can use this hook."
264 :group 'gnus-group-listing
267 (defcustom gnus-suspend-gnus-hook nil
268 "Hook called when suspending (not exiting) Gnus."
272 (defcustom gnus-exit-gnus-hook nil
273 "Hook called when exiting Gnus."
277 (defcustom gnus-after-exiting-gnus-hook nil
278 "Hook called after exiting Gnus."
282 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
283 "Hook called when a group line is changed.
284 The hook will not be called if `gnus-visual' is nil.
286 The default function `gnus-group-highlight-line' will
287 highlight the line according to the `gnus-group-highlight'
289 :group 'gnus-group-visual
292 (defcustom gnus-useful-groups
293 '(("(ding) mailing list mirrored at gmane.org"
294 "gmane.emacs.gnus.general"
296 (nntp-address "news.gmane.org")))
299 (nntp "news.gnus.org"
300 (nntp-address "news.gnus.org")))
301 ("Local Gnus help group"
304 (nndoc-article-type mbox)
305 (eval `(nndoc-address
306 ,(let ((file (nnheader-find-etc-directory
309 (error "Couldn't find doc group"))
311 "*Alist of useful group-server pairs."
312 :group 'gnus-group-listing
313 :type '(repeat (list (string :tag "Description")
315 (sexp :tag "Method"))))
317 (defcustom gnus-group-highlight
319 ((and mailp (= unread 0) (eq level 1)) .
320 gnus-group-mail-1-empty)
321 ((and mailp (eq level 1)) .
323 ((and mailp (= unread 0) (eq level 2)) .
324 gnus-group-mail-2-empty)
325 ((and mailp (eq level 2)) .
327 ((and mailp (= unread 0) (eq level 3)) .
328 gnus-group-mail-3-empty)
329 ((and mailp (eq level 3)) .
331 ((and mailp (= unread 0)) .
332 gnus-group-mail-low-empty)
336 ((and (= unread 0) (eq level 1)) .
337 gnus-group-news-1-empty)
338 ((and (eq level 1)) .
340 ((and (= unread 0) (eq level 2)) .
341 gnus-group-news-2-empty)
342 ((and (eq level 2)) .
344 ((and (= unread 0) (eq level 3)) .
345 gnus-group-news-3-empty)
346 ((and (eq level 3)) .
348 ((and (= unread 0) (eq level 4)) .
349 gnus-group-news-4-empty)
350 ((and (eq level 4)) .
352 ((and (= unread 0) (eq level 5)) .
353 gnus-group-news-5-empty)
354 ((and (eq level 5)) .
356 ((and (= unread 0) (eq level 6)) .
357 gnus-group-news-6-empty)
358 ((and (eq level 6)) .
360 ((and (= unread 0)) .
361 gnus-group-news-low-empty)
363 gnus-group-news-low))
364 "*Controls the highlighting of group buffer lines.
366 Below is a list of `Form'/`Face' pairs. When deciding how a a
367 particular group line should be displayed, each form is
368 evaluated. The content of the face field after the first true form is
369 used. You can change how those group lines are displayed by
370 editing the face field.
372 It is also possible to change and add form fields, but currently that
373 requires an understanding of Lisp expressions. Hopefully this will
374 change in a future release. For now, you can use the following
375 variables in the Lisp expression:
377 group: The name of the group.
378 unread: The number of unread articles in the group.
379 method: The select method used.
380 mailp: Whether it's a mail group or not.
381 level: The level of the group.
382 score: The score of the group.
383 ticked: The number of ticked articles."
384 :group 'gnus-group-visual
385 :type '(repeat (cons (sexp :tag "Form") face)))
387 (defcustom gnus-new-mail-mark ?%
388 "Mark used for groups with new mail."
389 :group 'gnus-group-visual
392 (defgroup gnus-group-icons nil
393 "Add Icons to your group buffer."
394 :group 'gnus-group-visual)
396 (defcustom gnus-group-icon-list
398 "*Controls the insertion of icons into group buffer lines.
400 Below is a list of `Form'/`File' pairs. When deciding how a
401 particular group line should be displayed, each form is evaluated.
402 The icon from the file field after the first true form is used. You
403 can change how those group lines are displayed by editing the file
404 field. The File will either be found in the
405 `gnus-group-glyph-directory' or by designating absolute name of the
408 It is also possible to change and add form fields, but currently that
409 requires an understanding of Lisp expressions. Hopefully this will
410 change in a future release. For now, you can use the following
411 variables in the Lisp expression:
413 group: The name of the group.
414 unread: The number of unread articles in the group.
415 method: The select method used.
416 mailp: Whether it's a mail group or not.
417 newsp: Whether it's a news group or not
418 level: The level of the group.
419 score: The score of the group.
420 ticked: The number of ticked articles."
421 :group 'gnus-group-icons
422 :type '(repeat (cons (sexp :tag "Form") file)))
424 (defcustom gnus-group-name-charset-method-alist nil
425 "Alist of method and the charset for group names.
428 (((nntp \"news.com.cn\") . cn-gb-2312))"
431 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
433 (defcustom gnus-group-name-charset-group-alist
434 (if (mm-coding-system-p 'utf-8)
435 '(("[^\000-\177]" . utf-8))
437 "Alist of group regexp and the charset for group names.
440 ((\"\\.com\\.cn:\" . cn-gb-2312))"
442 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
444 (defcustom gnus-group-jump-to-group-prompt nil
445 "Default prompt for `gnus-group-jump-to-group'.
447 If non-nil, the value should be a string or an alist. If it is a string,
448 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
449 nnml:\" in the minibuffer prompt.
451 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
452 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
453 used when no prefix argument is given to `gnus-group-jump-to-group'."
455 :group 'gnus-group-various
456 :type '(choice (string :tag "Prompt string")
457 (const :tag "Empty" nil)
458 (repeat (cons (integer :tag "Argument")
459 (string :tag "Prompt string")))))
461 (defvar gnus-group-listing-limit 1000
462 "*A limit of the number of groups when listing.
463 If the number of groups is larger than the limit, list them in a
466 ;;; Internal variables
468 (defvar gnus-group-is-exiting-p nil)
469 (defvar gnus-group-is-exiting-without-update-p nil)
470 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
471 "Function for sorting the group buffer.")
473 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
474 "Function for sorting the selected groups in the group buffer.")
476 (defvar gnus-group-indentation-function nil)
477 (defvar gnus-goto-missing-group-function nil)
478 (defvar gnus-group-update-group-function nil)
479 (defvar gnus-group-goto-next-group-function nil
480 "Function to override finding the next group after listing groups.")
482 (defvar gnus-group-edit-buffer nil)
484 (defvar gnus-group-line-format-alist
485 `((?M gnus-tmp-marked-mark ?c)
486 (?S gnus-tmp-subscribed ?c)
487 (?L gnus-tmp-level ?d)
488 (?N (cond ((eq number t) "*" )
492 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
493 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
495 (?R gnus-tmp-number-of-read ?s)
496 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
497 (?t gnus-tmp-number-total ?d)
498 (?y gnus-tmp-number-of-unread ?s)
499 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
500 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
501 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
502 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
503 (?g (if (boundp 'gnus-tmp-decoded-group)
504 gnus-tmp-decoded-group
507 (?G gnus-tmp-qualified-group ?s)
508 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
509 gnus-tmp-decoded-group
512 (?C gnus-tmp-comment ?s)
513 (?D gnus-tmp-newsgroup-description ?s)
514 (?o gnus-tmp-moderated ?c)
515 (?O gnus-tmp-moderated-string ?s)
516 (?p gnus-tmp-process-marked ?c)
517 (?s gnus-tmp-news-server ?s)
518 (?n ,(if (featurep 'xemacs)
519 '(symbol-name gnus-tmp-news-method)
520 'gnus-tmp-news-method)
522 (?P gnus-group-indentation ?s)
523 (?E gnus-tmp-group-icon ?s)
524 (?B gnus-tmp-summary-live ?c)
525 (?z gnus-tmp-news-method-string ?s)
526 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
527 (?w (if (gnus-news-group-p gnus-tmp-group)
531 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
534 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
535 (?u gnus-tmp-user-defined ?s)
536 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
539 (defvar gnus-group-mode-line-format-alist
540 `((?S gnus-tmp-news-server ?s)
541 (?M gnus-tmp-news-method ?s)
542 (?u gnus-tmp-user-defined ?s)
543 (?: gnus-tmp-colon ?s)))
545 (defvar gnus-topic-topology nil
546 "The complete topic hierarchy.")
548 (defvar gnus-topic-alist nil
549 "The complete topic-group alist.")
551 (defvar gnus-group-marked nil)
553 (defvar gnus-group-list-mode nil)
556 (defvar gnus-group-icon-cache nil)
558 (defvar gnus-group-listed-groups nil)
559 (defvar gnus-group-list-option nil)
565 (put 'gnus-group-mode 'mode-class 'special)
567 (gnus-define-keys gnus-group-mode-map
568 " " gnus-group-read-group
569 "=" gnus-group-select-group
570 "\r" gnus-group-select-group
571 "\M-\r" gnus-group-quick-select-group
572 "\M- " gnus-group-visible-select-group
573 [(meta control return)] gnus-group-select-group-ephemerally
574 "j" gnus-group-jump-to-group
575 "n" gnus-group-next-unread-group
576 "p" gnus-group-prev-unread-group
577 "\177" gnus-group-prev-unread-group
578 [delete] gnus-group-prev-unread-group
579 [backspace] gnus-group-prev-unread-group
580 "N" gnus-group-next-group
581 "P" gnus-group-prev-group
582 "\M-n" gnus-group-next-unread-group-same-level
583 "\M-p" gnus-group-prev-unread-group-same-level
584 "," gnus-group-best-unread-group
585 "." gnus-group-first-unread-group
586 "u" gnus-group-unsubscribe-current-group
587 "U" gnus-group-unsubscribe-group
588 "c" gnus-group-catchup-current
589 "C" gnus-group-catchup-current-all
590 "\M-c" gnus-group-clear-data
591 "l" gnus-group-list-groups
592 "L" gnus-group-list-all-groups
595 "g" gnus-group-get-new-news
596 "\M-g" gnus-group-get-new-news-this-group
597 "R" gnus-group-restart
598 "r" gnus-group-read-init-file
599 "B" gnus-group-browse-foreign-server
600 "b" gnus-group-check-bogus-groups
601 "F" gnus-group-find-new-groups
602 "\C-c\C-d" gnus-group-describe-group
603 "\M-d" gnus-group-describe-all-groups
604 "\C-c\C-a" gnus-group-apropos
605 "\C-c\M-\C-a" gnus-group-description-apropos
606 "a" gnus-group-post-news
607 "\ek" gnus-group-edit-local-kill
608 "\eK" gnus-group-edit-global-kill
609 "\C-k" gnus-group-kill-group
610 "\C-y" gnus-group-yank-group
611 "\C-w" gnus-group-kill-region
612 "\C-x\C-t" gnus-group-transpose-groups
613 "\C-c\C-l" gnus-group-list-killed
614 "\C-c\C-x" gnus-group-expire-articles
615 "\C-c\M-\C-x" gnus-group-expire-all-groups
617 "s" gnus-group-save-newsrc
618 "z" gnus-group-suspend
621 "?" gnus-group-describe-briefly
622 "\C-c\C-i" gnus-info-find-node
623 "\M-e" gnus-group-edit-group-method
624 "^" gnus-group-enter-server-mode
625 gnus-mouse-2 gnus-mouse-pick-group
626 [follow-link] mouse-face
627 "<" beginning-of-buffer
630 "\C-c\C-n" gnus-namazu-search
631 "\C-c\C-s" gnus-group-sort-groups
633 "\C-c\M-g" gnus-activate-all-groups
634 "\M-&" gnus-group-universal-argument
635 "#" gnus-group-mark-group
636 "\M-#" gnus-group-unmark-group)
638 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
639 "m" gnus-group-mark-group
640 "u" gnus-group-unmark-group
641 "w" gnus-group-mark-region
642 "b" gnus-group-mark-buffer
643 "r" gnus-group-mark-regexp
644 "U" gnus-group-unmark-all-groups)
646 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
647 "u" gnus-sieve-update
648 "g" gnus-sieve-generate)
650 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
651 "d" gnus-group-make-directory-group
652 "h" gnus-group-make-help-group
653 "u" gnus-group-make-useful-group
654 "a" gnus-group-make-archive-group
655 "k" gnus-group-make-kiboze-group
656 "l" gnus-group-nnimap-edit-acl
657 "m" gnus-group-make-group
658 "n" gnus-group-make-shimbun-group
659 "E" gnus-group-edit-group
660 "e" gnus-group-edit-group-method
661 "p" gnus-group-edit-group-parameters
662 "v" gnus-group-add-to-virtual
663 "V" gnus-group-make-empty-virtual
664 "D" gnus-group-enter-directory
665 "f" gnus-group-make-doc-group
666 "G" gnus-group-make-nnir-group
667 "w" gnus-group-make-web-group
668 "M" gnus-group-read-ephemeral-group
669 "r" gnus-group-rename-group
670 "R" gnus-group-make-rss-group
671 "c" gnus-group-customize
672 "z" gnus-group-compact-group
673 "x" gnus-group-nnimap-expunge
674 "\177" gnus-group-delete-group
675 [delete] gnus-group-delete-group)
677 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
678 "b" gnus-group-brew-soup
679 "w" gnus-soup-save-areas
680 "s" gnus-soup-send-replies
681 "p" gnus-soup-pack-packet
682 "r" nnsoup-pack-replies)
684 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
685 "s" gnus-group-sort-groups
686 "a" gnus-group-sort-groups-by-alphabet
687 "u" gnus-group-sort-groups-by-unread
688 "l" gnus-group-sort-groups-by-level
689 "v" gnus-group-sort-groups-by-score
690 "r" gnus-group-sort-groups-by-rank
691 "m" gnus-group-sort-groups-by-method
692 "n" gnus-group-sort-groups-by-real-name)
694 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
695 "s" gnus-group-sort-selected-groups
696 "a" gnus-group-sort-selected-groups-by-alphabet
697 "u" gnus-group-sort-selected-groups-by-unread
698 "l" gnus-group-sort-selected-groups-by-level
699 "v" gnus-group-sort-selected-groups-by-score
700 "r" gnus-group-sort-selected-groups-by-rank
701 "m" gnus-group-sort-selected-groups-by-method
702 "n" gnus-group-sort-selected-groups-by-real-name)
704 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
705 "k" gnus-group-list-killed
706 "z" gnus-group-list-zombies
707 "s" gnus-group-list-groups
708 "u" gnus-group-list-all-groups
709 "A" gnus-group-list-active
710 "a" gnus-group-apropos
711 "d" gnus-group-description-apropos
712 "m" gnus-group-list-matching
713 "M" gnus-group-list-all-matching
714 "l" gnus-group-list-level
715 "c" gnus-group-list-cached
716 "?" gnus-group-list-dormant)
718 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
719 "k" gnus-group-list-limit
720 "z" gnus-group-list-limit
721 "s" gnus-group-list-limit
722 "u" gnus-group-list-limit
723 "A" gnus-group-list-limit
724 "m" gnus-group-list-limit
725 "M" gnus-group-list-limit
726 "l" gnus-group-list-limit
727 "c" gnus-group-list-limit
728 "?" gnus-group-list-limit)
730 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
731 "k" gnus-group-list-flush
732 "z" gnus-group-list-flush
733 "s" gnus-group-list-flush
734 "u" gnus-group-list-flush
735 "A" gnus-group-list-flush
736 "m" gnus-group-list-flush
737 "M" gnus-group-list-flush
738 "l" gnus-group-list-flush
739 "c" gnus-group-list-flush
740 "?" gnus-group-list-flush)
742 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
743 "k" gnus-group-list-plus
744 "z" gnus-group-list-plus
745 "s" gnus-group-list-plus
746 "u" gnus-group-list-plus
747 "A" gnus-group-list-plus
748 "m" gnus-group-list-plus
749 "M" gnus-group-list-plus
750 "l" gnus-group-list-plus
751 "c" gnus-group-list-plus
752 "?" gnus-group-list-plus)
754 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
755 "f" gnus-score-flush-cache
756 "e" gnus-score-edit-all-score)
758 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
759 "c" gnus-group-fetch-charter
760 "C" gnus-group-fetch-control
761 "d" gnus-group-describe-group
762 "f" gnus-group-fetch-faq
765 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
766 "l" gnus-group-set-current-level
767 "t" gnus-group-unsubscribe-current-group
768 "s" gnus-group-unsubscribe-group
769 "k" gnus-group-kill-group
770 "y" gnus-group-yank-group
771 "w" gnus-group-kill-region
772 "\C-k" gnus-group-kill-level
773 "z" gnus-group-kill-all-zombies)
775 (defun gnus-topic-mode-p ()
776 "Return non-nil in `gnus-topic-mode'."
777 (and (boundp 'gnus-topic-mode)
778 (symbol-value 'gnus-topic-mode)))
780 (defun gnus-group-make-menu-bar ()
781 (gnus-turn-off-edit-menu 'group)
782 (unless (boundp 'gnus-group-reading-menu)
785 gnus-group-reading-menu gnus-group-mode-map ""
787 ["Read" gnus-group-read-group
788 :included (not (gnus-topic-mode-p))
789 :active (gnus-group-group-name)]
790 ["Read " gnus-topic-read-group
791 :included (gnus-topic-mode-p)]
792 ["Select" gnus-group-select-group
793 :included (not (gnus-topic-mode-p))
794 :active (gnus-group-group-name)]
795 ["Select " gnus-topic-select-group
796 :included (gnus-topic-mode-p)]
797 ["See old articles" (gnus-group-select-group 'all)
798 :keys "C-u SPC" :active (gnus-group-group-name)]
799 ["Catch up" gnus-group-catchup-current
800 :included (not (gnus-topic-mode-p))
801 :active (gnus-group-group-name)
802 ,@(if (featurep 'xemacs) nil
803 '(:help "Mark unread articles in the current group as read"))]
804 ["Catch up " gnus-topic-catchup-articles
805 :included (gnus-topic-mode-p)
806 ,@(if (featurep 'xemacs) nil
807 '(:help "Mark unread articles in the current group or topic as read"))]
808 ["Catch up all articles" gnus-group-catchup-current-all
809 (gnus-group-group-name)]
810 ["Check for new articles" gnus-group-get-new-news-this-group
811 :included (not (gnus-topic-mode-p))
812 :active (gnus-group-group-name)
813 ,@(if (featurep 'xemacs) nil
814 '(:help "Check for new messages in current group"))]
815 ["Check for new articles " gnus-topic-get-new-news-this-topic
816 :included (gnus-topic-mode-p)
817 ,@(if (featurep 'xemacs) nil
818 '(:help "Check for new messages in current group or topic"))]
819 ["Toggle subscription" gnus-group-unsubscribe-current-group
820 (gnus-group-group-name)]
821 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
822 ,@(if (featurep 'xemacs) nil
823 '(:help "Kill (remove) current group"))]
824 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
825 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
826 ,@(if (featurep 'xemacs) nil
827 '(:help "Display description of the current group"))]
828 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
829 ["Fetch charter" gnus-group-fetch-charter
830 :active (gnus-group-group-name)
831 ,@(if (featurep 'xemacs) nil
832 '(:help "Display the charter of the current group"))]
833 ["Fetch control message" gnus-group-fetch-control
834 :active (gnus-group-group-name)
835 ,@(if (featurep 'xemacs) nil
836 '(:help "Display the archived control message for the current group"))]
837 ;; Actually one should check, if any of the marked groups gives t for
838 ;; (gnus-check-backend-function 'request-expire-articles ...)
839 ["Expire articles" gnus-group-expire-articles
840 :included (not (gnus-topic-mode-p))
841 :active (or (and (gnus-group-group-name)
842 (gnus-check-backend-function
843 'request-expire-articles
844 (gnus-group-group-name))) gnus-group-marked)]
845 ["Expire articles " gnus-topic-expire-articles
846 :included (gnus-topic-mode-p)]
847 ["Set group level..." gnus-group-set-current-level
848 (gnus-group-group-name)]
849 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
850 ["Customize" gnus-group-customize (gnus-group-group-name)]
851 ["Compact" gnus-group-compact-group
852 :active (gnus-group-group-name)]
854 ["Parameters" gnus-group-edit-group-parameters
855 :included (not (gnus-topic-mode-p))
856 :active (gnus-group-group-name)]
857 ["Parameters " gnus-topic-edit-parameters
858 :included (gnus-topic-mode-p)]
859 ["Select method" gnus-group-edit-group-method
860 (gnus-group-group-name)]
861 ["Info" gnus-group-edit-group (gnus-group-group-name)]
862 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
863 ["Global kill file" gnus-group-edit-global-kill t])))
866 gnus-group-group-menu gnus-group-mode-map ""
869 ["List unread subscribed groups" gnus-group-list-groups t]
870 ["List (un)subscribed groups" gnus-group-list-all-groups t]
871 ["List killed groups" gnus-group-list-killed gnus-killed-list]
872 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
873 ["List level..." gnus-group-list-level t]
874 ["Describe all groups" gnus-group-describe-all-groups t]
875 ["Group apropos..." gnus-group-apropos t]
876 ["Group and description apropos..." gnus-group-description-apropos t]
877 ["List groups matching..." gnus-group-list-matching t]
878 ["List all groups matching..." gnus-group-list-all-matching t]
879 ["List active file" gnus-group-list-active t]
880 ["List groups with cached" gnus-group-list-cached t]
881 ["List groups with dormant" gnus-group-list-dormant t])
883 ["Default sort" gnus-group-sort-groups t]
884 ["Sort by method" gnus-group-sort-groups-by-method t]
885 ["Sort by rank" gnus-group-sort-groups-by-rank t]
886 ["Sort by score" gnus-group-sort-groups-by-score t]
887 ["Sort by level" gnus-group-sort-groups-by-level t]
888 ["Sort by unread" gnus-group-sort-groups-by-unread t]
889 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
890 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
891 ("Sort process/prefixed"
892 ["Default sort" gnus-group-sort-selected-groups
893 (not (gnus-topic-mode-p))]
894 ["Sort by method" gnus-group-sort-selected-groups-by-method
895 (not (gnus-topic-mode-p))]
896 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
897 (not (gnus-topic-mode-p))]
898 ["Sort by score" gnus-group-sort-selected-groups-by-score
899 (not (gnus-topic-mode-p))]
900 ["Sort by level" gnus-group-sort-selected-groups-by-level
901 (not (gnus-topic-mode-p))]
902 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
903 (not (gnus-topic-mode-p))]
904 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
905 (not (gnus-topic-mode-p))]
906 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
907 (not (gnus-topic-mode-p))])
909 ["Mark group" gnus-group-mark-group
910 (and (gnus-group-group-name)
911 (not (memq (gnus-group-group-name) gnus-group-marked)))]
912 ["Unmark group" gnus-group-unmark-group
913 (and (gnus-group-group-name)
914 (memq (gnus-group-group-name) gnus-group-marked))]
915 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
916 ["Mark regexp..." gnus-group-mark-regexp t]
917 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
918 ["Mark buffer" gnus-group-mark-buffer t]
919 ["Execute command" gnus-group-universal-argument
920 (or gnus-group-marked (gnus-group-group-name))])
922 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
923 ["Kill all newsgroups in region" gnus-group-kill-region
924 :active (gnus-mark-active-p)]
925 ["Kill all zombie groups" gnus-group-kill-all-zombies
927 ["Kill all groups on level..." gnus-group-kill-level t])
929 ["Make a foreign group..." gnus-group-make-group t]
930 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
931 ["Add a directory group..." gnus-group-make-directory-group t]
932 ["Add the help group" gnus-group-make-help-group t]
933 ["Add the archive group" gnus-group-make-archive-group t]
934 ["Make a doc group..." gnus-group-make-doc-group t]
935 ["Make a web group..." gnus-group-make-web-group t]
936 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
937 ["Make a virtual group..." gnus-group-make-empty-virtual t]
938 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
939 ["Make an RSS group..." gnus-group-make-rss-group t]
940 ["Rename group..." gnus-group-rename-group
941 (gnus-check-backend-function
942 'request-rename-group (gnus-group-group-name))]
943 ["Delete group" gnus-group-delete-group
944 (gnus-check-backend-function
945 'request-delete-group (gnus-group-group-name))])
947 ["Next" gnus-group-next-group t]
948 ["Previous" gnus-group-prev-group t]
949 ["Next unread" gnus-group-next-unread-group t]
950 ["Previous unread" gnus-group-prev-unread-group t]
951 ["Next unread same level" gnus-group-next-unread-group-same-level t]
952 ["Previous unread same level"
953 gnus-group-prev-unread-group-same-level t]
954 ["Jump to group..." gnus-group-jump-to-group t]
955 ["First unread group" gnus-group-first-unread-group t]
956 ["Best unread group" gnus-group-best-unread-group t])
958 ["Generate" gnus-sieve-generate t]
959 ["Generate and update" gnus-sieve-update t])
960 ["Delete bogus groups" gnus-group-check-bogus-groups t]
961 ["Find new newsgroups" gnus-group-find-new-groups t]
962 ["Transpose" gnus-group-transpose-groups
963 (gnus-group-group-name)]
964 ["Read a directory as a group..." gnus-group-enter-directory t]))
967 gnus-group-misc-menu gnus-group-mode-map ""
970 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
971 ["Send replies" gnus-soup-send-replies
972 (fboundp 'gnus-soup-pack-packet)]
973 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
974 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
975 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
976 ["Send a mail" gnus-group-mail t]
977 ["Send a message (mail or news)" gnus-group-post-news t]
978 ["Create a local message" gnus-group-news t]
979 ["Check for new news" gnus-group-get-new-news
980 ,@(if (featurep 'xemacs) '(t)
981 '(:help "Get newly arrived articles"))
983 ["Send queued messages" gnus-delay-send-queue
984 ,@(if (featurep 'xemacs) '(t)
985 '(:help "Send all messages that are scheduled to be sent now"))
987 ["Activate all groups" gnus-activate-all-groups t]
988 ["Restart Gnus" gnus-group-restart t]
989 ["Read init file" gnus-group-read-init-file t]
990 ["Browse foreign server..." gnus-group-browse-foreign-server t]
991 ["Enter server buffer" gnus-group-enter-server-mode t]
992 ["Expire all expirable articles" gnus-group-expire-all-groups t]
993 ["Generate any kiboze groups" nnkiboze-generate-groups t]
994 ["Gnus version" gnus-version t]
995 ["Save .newsrc files" gnus-group-save-newsrc t]
996 ["Suspend Gnus" gnus-group-suspend t]
997 ["Clear dribble buffer" gnus-group-clear-dribble t]
998 ["Read manual" gnus-info-find-node t]
999 ["Flush score cache" gnus-score-flush-cache t]
1000 ["Toggle topics" gnus-topic-mode t]
1001 ["Send a bug report" gnus-bug t]
1002 ["Exit from Gnus" gnus-group-exit
1003 ,@(if (featurep 'xemacs) '(t)
1004 '(:help "Quit reading news"))]
1005 ["Exit without saving" gnus-group-quit t]))
1007 (gnus-run-hooks 'gnus-group-menu-hook)))
1010 (defvar gnus-group-tool-bar-map nil)
1012 (defun gnus-group-tool-bar-update (&optional symbol value)
1013 "Update group buffer toolbar.
1014 Setter function for custom variables."
1016 (set-default symbol value))
1017 ;; (setq-default gnus-group-tool-bar-map nil)
1018 ;; (use-local-map gnus-group-mode-map)
1019 (when (gnus-alive-p)
1020 (with-current-buffer gnus-group-buffer
1021 (gnus-group-make-tool-bar t))))
1023 ;; The default will be changed when the new icons have been checked in:
1024 (defcustom gnus-group-tool-bar 'gnus-group-tool-bar-retro
1025 "Specifies the Gnus group tool bar.
1027 It can be either a list or a symbol refering to a list. See
1028 `gmm-tool-bar-from-list' for the format of the list. The
1029 default key map is `gnus-group-mode-map'.
1031 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1032 `gnus-group-tool-bar-retro'."
1033 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1034 (const :tag "Retro look" gnus-group-tool-bar-retro)
1035 (repeat :tag "User defined list" gmm-tool-bar-item)
1037 :version "23.0" ;; No Gnus
1038 :initialize 'custom-initialize-default
1039 :set 'gnus-group-tool-bar-update
1042 (defcustom gnus-group-tool-bar-gnome
1043 '((gnus-group-post-news "compose")
1044 (gnus-group-get-new-news "inbox") ;; Add... nil :visible gnus-plugged ?
1045 ;; FIXME: gnus-*-read-group should have a better help text.
1046 (gnus-topic-read-group "open" nil :visible gnus-topic-mode)
1047 (gnus-group-read-group "open" nil :visible (not gnus-topic-mode))
1048 ;; (gnus-group-find-new-groups "???" nil)
1049 (gnus-group-save-newsrc "save")
1050 (gnus-group-describe-group "describe")
1051 (gnus-group-unsubscribe-current-group "toggle-subscription")
1052 ;; (gnus-group-subscribe "subscribe" t
1053 ;; :help "Subscribe to the current group")
1054 ;; (gnus-group-unsubscribe "unsubscribe" t
1055 ;; :help "Unsubscribe from the current group")
1057 ;; Some useful agent icons? I don't use the agent so agent users should
1058 ;; suggest useful commands:
1059 (gnus-group-send-queue "outbox" t
1060 :visible (and gnus-agent gnus-plugged)
1061 :help "Send articles from the queue group")
1062 (gnus-agent-toggle-plugged "connect" nil
1063 :visible (and gnus-agent (not gnus-plugged)))
1064 (gnus-agent-toggle-plugged "disconnect" nil
1065 :visible (and gnus-agent gnus-plugged))
1067 (gnus-group-exit "exit-mode")
1068 (gnus-info-find-node "help"))
1069 "List of functions for the group tool bar (GNOME style).
1071 See `gmm-tool-bar-from-list' for the format of the list."
1072 :type '(repeat gmm-tool-bar-item)
1073 :version "23.0" ;; No Gnus
1074 :initialize 'custom-initialize-default
1075 :set 'gnus-group-tool-bar-update
1078 (defcustom gnus-group-tool-bar-retro
1079 '((gnus-group-get-new-news "get-news")
1080 (gnus-group-get-new-news-this-group "gnntg")
1081 (gnus-group-catchup-current "catchup")
1082 (gnus-group-describe-group "describe-group")
1083 (gnus-group-subscribe "subscribe" t
1084 :help "Subscribe to the current group")
1085 (gnus-group-unsubscribe "unsubscribe" t
1086 :help "Unsubscribe from the current group")
1087 (gnus-group-exit "exit-gnus" gnus-group-mode-map))
1088 "List of functions for the group tool bar (retro look).
1090 See `gmm-tool-bar-from-list' for the format of the list."
1091 :type '(repeat gmm-tool-bar-item)
1092 :version "23.0" ;; No Gnus
1093 :initialize 'custom-initialize-default
1094 :set 'gnus-group-tool-bar-update
1097 ;; FIXME: Moving through the Group buffer (in topic mode) e.g. with C-n
1098 ;; doesn't update the state (enabled/disabled) of the icon
1099 ;; `gnus-group-describe-group'. After `C-l' the state is correct.
1100 ;; See the following report on emacs-devel
1101 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1102 ;; From: Reiner Steib
1103 ;; Subject: tool bar icons not updated according to :active condition
1104 ;; Newsgroups: gmane.emacs.devel
1105 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1106 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1108 (defcustom gnus-group-tool-bar-zap-list t
1109 "List of icon items from the global tool bar.
1110 These items are not displayed in the Gnus group mode tool bar.
1112 See `gmm-tool-bar-from-list' for the format of the list."
1113 :type 'gmm-tool-bar-zap-list
1114 :version "23.0" ;; No Gnus
1115 :initialize 'custom-initialize-default
1116 :set 'gnus-group-tool-bar-update
1119 (defun gnus-group-make-tool-bar (&optional force)
1120 "Make a group mode tool bar from `gnus-group-tool-bar'.
1121 When FORCE, rebuild the tool bar."
1122 (when (and (not (featurep 'xemacs))
1123 (boundp 'tool-bar-mode)
1125 ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1127 (or (not gnus-group-tool-bar-map) force))
1128 (let ((map (when (default-value 'tool-bar-mode)
1129 (let ((load-path (mm-image-load-path)))
1130 (gmm-tool-bar-from-list gnus-group-tool-bar
1131 gnus-group-tool-bar-zap-list
1132 'gnus-group-mode-map)))))
1134 (set (make-local-variable 'tool-bar-map) map))))
1135 gnus-group-tool-bar-map)
1137 (defun gnus-group-mode ()
1138 "Major mode for reading news.
1140 All normal editing commands are switched off.
1141 \\<gnus-group-mode-map>
1142 The group buffer lists (some of) the groups available. For instance,
1143 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1144 lists all zombie groups.
1146 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1147 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1149 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1151 The following commands are available:
1153 \\{gnus-group-mode-map}"
1155 (kill-all-local-variables)
1156 (when (gnus-visual-p 'group-menu 'menu)
1157 (gnus-group-make-menu-bar)
1158 (gnus-group-make-tool-bar))
1159 (gnus-simplify-mode-line)
1160 (setq major-mode 'gnus-group-mode)
1161 (setq mode-name "Group")
1162 (gnus-group-set-mode-line)
1163 (setq mode-line-process nil)
1164 (use-local-map gnus-group-mode-map)
1165 (buffer-disable-undo)
1166 (setq truncate-lines t)
1167 (setq buffer-read-only t
1168 show-trailing-whitespace nil)
1169 (gnus-set-default-directory)
1170 (gnus-update-format-specifications nil 'group 'group-mode)
1171 (gnus-update-group-mark-positions)
1176 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1178 (defun gnus-update-group-mark-positions ()
1180 (let ((gnus-process-mark ?\200)
1181 (gnus-group-update-hook nil)
1182 (gnus-group-marked '("dummy.group"))
1183 (gnus-active-hashtb (make-vector 10 0))
1185 (gnus-set-active "dummy.group" '(0 . 0))
1186 (gnus-set-work-buffer)
1187 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1188 (goto-char (point-min))
1189 (setq gnus-group-mark-positions
1190 (list (cons 'process (and (search-forward
1191 (string-as-multibyte "\200") nil t)
1192 (- (point) 2))))))))
1194 (defun gnus-mouse-pick-group (e)
1195 "Enter the group under the mouse pointer."
1198 (gnus-group-read-group nil))
1200 ;; Look at LEVEL and find out what the level is really supposed to be.
1201 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1202 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1203 (defun gnus-group-default-level (&optional level number-or-nil)
1205 (gnus-group-use-permanent-levels
1206 (or (setq gnus-group-use-permanent-levels
1207 (or level (if (numberp gnus-group-use-permanent-levels)
1208 gnus-group-use-permanent-levels
1209 (or gnus-group-default-list-level
1210 gnus-level-subscribed))))
1211 gnus-group-default-list-level gnus-level-subscribed))
1215 (or level gnus-group-default-list-level gnus-level-subscribed))))
1217 (defun gnus-group-setup-buffer ()
1218 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1219 (unless (eq major-mode 'gnus-group-mode)
1222 (gnus-carpal-setup-buffer 'group))))
1224 (defun gnus-group-name-charset (method group)
1226 (setq method (gnus-find-method-for-group group)))
1227 (let ((item (assoc method gnus-group-name-charset-method-alist))
1228 (alist gnus-group-name-charset-group-alist)
1232 (while (setq item (pop alist))
1233 (if (string-match (car item) group)
1235 result (cdr item))))
1238 (defun gnus-group-name-decode (string charset)
1239 ;; Fixme: Don't decode in unibyte mode.
1240 (if (and string charset (featurep 'mule))
1241 (decode-coding-string string charset)
1244 (defun gnus-group-decoded-name (string)
1245 (let ((charset (gnus-group-name-charset nil string)))
1246 (gnus-group-name-decode string charset)))
1248 (defun gnus-group-name-encode (string charset)
1249 (if (and string charset (featurep 'mule))
1250 (encode-coding-string string charset)
1253 (defun gnus-group-encoded-name (string)
1254 (let ((charset (gnus-group-name-charset nil string)))
1255 (gnus-group-name-encode string charset)))
1257 (defun gnus-group-completing-read-group-name
1258 (prompt table &optional predicate require-match initial-contents history)
1262 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1266 (dolist (entry (prog1
1269 (push (list (gnus-group-decoded-name (car entry))) table)))
1270 (gnus-group-encoded-name
1272 prompt table predicate
1277 (defun gnus-group-list-groups (&optional level unread lowest)
1278 "List newsgroups with level LEVEL or lower that have unread articles.
1279 Default is all subscribed groups.
1280 If argument UNREAD is non-nil, groups with no unread articles are also
1283 Also see the `gnus-group-use-permanent-levels' variable."
1285 (list (if current-prefix-arg
1286 (prefix-numeric-value current-prefix-arg)
1288 (gnus-group-default-level nil t)
1289 gnus-group-default-list-level
1290 gnus-level-subscribed))))
1292 (setq level (car gnus-group-list-mode)
1293 unread (cdr gnus-group-list-mode)))
1294 (setq level (gnus-group-default-level level))
1295 (gnus-group-setup-buffer)
1296 (gnus-update-format-specifications nil 'group 'group-mode)
1297 (let ((case-fold-search nil)
1298 (props (text-properties-at (point-at-bol)))
1299 (empty (= (point-min) (point-max)))
1300 (group (gnus-group-group-name))
1302 (set-buffer gnus-group-buffer)
1303 (setq number (funcall gnus-group-prepare-function level unread lowest))
1304 (when (or (and (numberp number)
1306 (zerop (buffer-size)))
1307 ;; No groups in the buffer.
1308 (gnus-message 5 gnus-no-groups-message))
1309 ;; We have some groups displayed.
1310 (goto-char (point-max))
1311 (when (or (not gnus-group-goto-next-group-function)
1312 (not (funcall gnus-group-goto-next-group-function
1316 (goto-char (point-min)))
1318 ;; Go to the first group with unread articles.
1319 (gnus-group-search-forward t))
1321 ;; Find the right group to put point on. If the current group
1322 ;; has disappeared in the new listing, try to find the next
1323 ;; one. If no next one can be found, just leave point at the
1324 ;; first newsgroup in the buffer.
1325 (when (not (gnus-goto-char
1327 (point-min) (point-max)
1328 'gnus-group (gnus-intern-safe
1329 group gnus-active-hashtb))))
1330 (let ((newsrc (cdddr (gnus-group-entry group))))
1332 (not (gnus-goto-char
1334 (point-min) (point-max) 'gnus-group
1336 (caar newsrc) gnus-active-hashtb)))))
1337 (setq newsrc (cdr newsrc)))
1339 (goto-char (point-max))
1340 (forward-line -1)))))))
1341 ;; Adjust cursor point.
1342 (gnus-group-position-point)))
1344 (defun gnus-group-list-level (level &optional all)
1345 "List groups on LEVEL.
1346 If ALL (the prefix), also list groups that have no unread articles."
1347 (interactive "nList groups on level: \nP")
1348 (gnus-group-list-groups level all level))
1350 (defun gnus-group-prepare-logic (group test)
1351 (or (and gnus-group-listed-groups
1352 (null gnus-group-list-option)
1353 (member group gnus-group-listed-groups))
1355 ((null gnus-group-listed-groups) test)
1356 ((null gnus-group-list-option) test)
1357 (t (and (member group gnus-group-listed-groups)
1358 (if (eq gnus-group-list-option 'flush)
1362 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1363 "List all newsgroups with unread articles of level LEVEL or lower.
1364 If PREDICATE is a function, list groups that the function returns non-nil;
1365 if it is t, list groups that have no unread articles.
1366 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1367 If REGEXP is a function, list dead groups that the function returns non-nil;
1368 if it is a string, only list groups matching REGEXP."
1369 (set-buffer gnus-group-buffer)
1370 (let ((buffer-read-only nil)
1371 (newsrc (cdr gnus-newsrc-alist))
1372 (lowest (or lowest 1))
1373 (not-in-list (and gnus-group-listed-groups
1374 (copy-sequence gnus-group-listed-groups)))
1375 info clevel unread group params)
1377 (when (or (< lowest gnus-level-zombie)
1378 gnus-group-listed-groups)
1379 ;; List living groups.
1381 (setq info (car newsrc)
1382 group (gnus-info-group info)
1383 params (gnus-info-params info)
1385 unread (gnus-group-unread group))
1387 (setq not-in-list (delete group not-in-list)))
1388 (when (gnus-group-prepare-logic
1390 (and unread ; This group might be unchecked
1391 (or (not (stringp regexp))
1392 (string-match regexp group))
1393 (<= (setq clevel (gnus-info-level info)) level)
1396 ((functionp predicate)
1397 (funcall predicate info))
1398 (predicate t) ; We list all groups?
1401 (if (eq unread t) ; Unactivated?
1402 gnus-group-list-inactive-groups
1403 ; We list unactivated
1405 ; We list groups with unread articles
1406 (and gnus-list-groups-with-ticked-articles
1407 (cdr (assq 'tick (gnus-info-marks info))))
1408 ; And groups with tickeds
1409 ;; Check for permanent visibility.
1410 (and gnus-permanently-visible-groups
1411 (string-match gnus-permanently-visible-groups
1413 (memq 'visible params)
1414 (cdr (assq 'visible params)))))))
1415 (gnus-group-insert-group-line
1416 group (gnus-info-level info)
1417 (gnus-info-marks info) unread (gnus-info-method info)))))
1419 ;; List dead groups.
1420 (when (or gnus-group-listed-groups
1421 (and (>= level gnus-level-zombie)
1422 (<= lowest gnus-level-zombie)))
1423 (gnus-group-prepare-flat-list-dead
1424 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1425 gnus-level-zombie ?Z
1428 (dolist (group gnus-zombie-list)
1429 (setq not-in-list (delete group not-in-list))))
1430 (when (or gnus-group-listed-groups
1431 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1432 (gnus-group-prepare-flat-list-dead
1435 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1436 gnus-level-killed ?K regexp))
1438 (gnus-group-set-mode-line)
1439 (setq gnus-group-list-mode (cons level predicate))
1440 (gnus-run-hooks 'gnus-group-prepare-hook)
1443 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1444 ;; List zombies and killed lists somewhat faster, which was
1445 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1446 ;; this by ignoring the group format specification altogether.
1448 (if (> (length groups) gnus-group-listing-limit)
1450 (setq group (pop groups))
1451 (when (gnus-group-prepare-logic
1454 (and (stringp regexp) (string-match regexp group))
1455 (and (functionp regexp) (funcall regexp group))))
1456 (gnus-add-text-properties
1457 (point) (prog1 (1+ (point))
1458 (insert " " mark " *: "
1459 (gnus-group-decoded-name group)
1461 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1463 'gnus-level level))))
1465 (setq group (pop groups))
1466 (when (gnus-group-prepare-logic
1469 (and (stringp regexp) (string-match regexp group))
1470 (and (functionp regexp) (funcall regexp group))))
1471 (gnus-group-insert-group-line
1473 (let ((active (gnus-active group)))
1475 (if (zerop (cdr active))
1477 (- (1+ (cdr active)) (car active)))
1479 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1481 (defun gnus-group-update-group-line ()
1482 "Update the current line in the group buffer."
1483 (let* ((buffer-read-only nil)
1484 (group (gnus-group-group-name))
1485 (entry (and group (gnus-group-entry group)))
1486 gnus-group-indentation)
1489 (not (gnus-ephemeral-group-p group))
1491 (concat "(gnus-group-set-info '"
1492 (gnus-prin1-to-string (nth 2 entry))
1494 (setq gnus-group-indentation (gnus-group-group-indentation))
1496 (gnus-group-insert-group-line-info group)
1498 (gnus-group-position-point))))
1500 (defun gnus-group-insert-group-line-info (group)
1501 "Insert GROUP on the current line."
1502 (let ((entry (gnus-group-entry group))
1503 (gnus-group-indentation (gnus-group-group-indentation))
1507 ;; (Un)subscribed group.
1508 (setq info (nth 2 entry))
1509 (gnus-group-insert-group-line
1510 group (gnus-info-level info) (gnus-info-marks info)
1511 (or (car entry) t) (gnus-info-method info)))
1512 ;; This group is dead.
1513 (gnus-group-insert-group-line
1515 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1517 (if (setq active (gnus-active group))
1518 (if (zerop (cdr active))
1520 (- (1+ (cdr active)) (car active)))
1522 (gnus-method-simplify (gnus-find-method-for-group group))))))
1524 (defun gnus-number-of-unseen-articles-in-group (group)
1525 (let* ((info (nth 2 (gnus-group-entry group)))
1526 (marked (gnus-info-marks info))
1527 (seen (cdr (assq 'seen marked)))
1528 (active (gnus-active group)))
1531 (length (gnus-uncompress-range
1532 (gnus-range-difference
1533 (gnus-range-difference (list active) (gnus-info-read info))
1536 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1537 gnus-tmp-marked number
1539 "Insert a group line in the group buffer."
1540 (let* ((gnus-tmp-method
1541 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1542 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1544 (gnus-tmp-active (gnus-active gnus-tmp-group))
1545 (gnus-tmp-number-total
1547 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1549 (gnus-tmp-number-of-unread
1550 (if (numberp number) (int-to-string (max 0 number))
1552 (gnus-tmp-number-of-read
1553 (if (numberp number)
1554 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1556 (gnus-tmp-subscribed
1557 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1558 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1559 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1561 (gnus-tmp-qualified-group
1562 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1563 group-name-charset))
1565 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1567 (gnus-tmp-newsgroup-description
1568 (if gnus-description-hashtb
1569 (or (gnus-group-name-decode
1570 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1571 group-name-charset) "")
1574 (if (and gnus-moderated-hashtb
1575 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1577 (gnus-tmp-moderated-string
1578 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1579 (gnus-tmp-group-icon "==&&==")
1580 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1581 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1582 (gnus-tmp-news-method-string
1584 (format "(%s:%s)" (car gnus-tmp-method)
1585 (cadr gnus-tmp-method)) ""))
1586 (gnus-tmp-marked-mark
1587 (if (and (numberp number)
1589 (cdr (assq 'tick gnus-tmp-marked)))
1591 (gnus-tmp-summary-live
1592 (if (and (not gnus-group-is-exiting-p)
1593 (gnus-buffer-live-p (gnus-summary-buffer-name
1596 (gnus-tmp-process-marked
1597 (if (member gnus-tmp-group gnus-group-marked)
1598 gnus-process-mark ? ))
1599 (buffer-read-only nil)
1600 header gnus-tmp-header) ; passed as parameter to user-funcs.
1602 (gnus-add-text-properties
1606 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1607 gnus-tmp-group group-name-charset)))
1608 (eval gnus-group-line-format-spec)))
1609 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1610 gnus-unread ,(if (numberp number)
1611 (string-to-number gnus-tmp-number-of-unread)
1613 gnus-marked ,gnus-tmp-marked-mark
1614 gnus-indentation ,gnus-group-indentation
1615 gnus-level ,gnus-tmp-level))
1617 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1618 (gnus-run-hooks 'gnus-group-update-hook))
1620 ;; Allow XEmacs to remove front-sticky text properties.
1621 (gnus-group-remove-excess-properties)))
1623 (defun gnus-group-highlight-line ()
1624 "Highlight the current line according to `gnus-group-highlight'."
1625 (let* ((list gnus-group-highlight)
1627 (end (point-at-eol))
1628 ;; now find out where the line starts and leave point there.
1629 (beg (progn (beginning-of-line) (point)))
1630 (group (gnus-group-group-name))
1631 (entry (gnus-group-entry group))
1632 (unread (if (numberp (car entry)) (car entry) 0))
1633 (active (gnus-active group))
1634 (total (if active (1+ (- (cdr active) (car active))) 0))
1635 (info (nth 2 entry))
1636 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1637 (marked (gnus-info-marks info))
1638 (mailp (apply 'append
1641 (memq x (assoc (symbol-name
1642 (car (or method gnus-select-method)))
1643 gnus-valid-select-methods)))
1644 '(mail post-mail))))
1645 (level (or (gnus-info-level info) gnus-level-killed))
1646 (score (or (gnus-info-score info) 0))
1647 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1648 (group-age (gnus-group-timestamp-delta group))
1649 (inhibit-read-only t))
1650 ;; Eval the cars of the lists until we find a match.
1652 (not (eval (caar list))))
1653 (setq list (cdr list)))
1654 (let ((face (cdar list)))
1655 (unless (eq face (get-text-property beg 'face))
1656 (gnus-put-text-property-excluding-characters-with-faces
1658 (setq face (if (boundp face) (symbol-value face) face)))
1659 (gnus-extent-start-open beg)))
1662 (defun gnus-group-update-group (group &optional visible-only)
1663 "Update all lines where GROUP appear.
1664 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1666 ;; Can't use `save-excursion' here, so we do it manually.
1667 (let ((buf (current-buffer))
1669 (set-buffer gnus-group-buffer)
1670 (setq mark (point-marker))
1671 ;; The buffer may be narrowed.
1674 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1676 found buffer-read-only)
1677 ;; Enter the current status into the dribble buffer.
1678 (let ((entry (gnus-group-entry group)))
1680 (not (gnus-ephemeral-group-p group)))
1682 (concat "(gnus-group-set-info '"
1683 (gnus-prin1-to-string (nth 2 entry))
1685 ;; Find all group instances. If topics are in use, each group
1686 ;; may be listed in more than once.
1687 (while (setq loc (text-property-any
1688 loc (point-max) 'gnus-group ident))
1691 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1693 (gnus-group-insert-group-line-info group)
1696 (gnus-run-hooks 'gnus-group-update-group-hook)))
1697 (setq loc (1+ loc)))
1698 (unless (or found visible-only)
1699 ;; No such line in the buffer, find out where it's supposed to
1700 ;; go, and insert it there (or at the end of the buffer).
1701 (if gnus-goto-missing-group-function
1702 (funcall gnus-goto-missing-group-function group)
1703 (let ((entry (cddr (gnus-group-entry group))))
1704 (while (and entry (car entry)
1708 (point-min) (point-max)
1709 'gnus-group (gnus-intern-safe
1710 (caar entry) gnus-active-hashtb)))))
1711 (setq entry (cdr entry)))
1712 (or entry (goto-char (point-max)))))
1713 ;; Finally insert the line.
1714 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1715 (gnus-group-insert-group-line-info group)
1718 (gnus-run-hooks 'gnus-group-update-group-hook))))
1719 (when gnus-group-update-group-function
1720 (funcall gnus-group-update-group-function group))
1721 (gnus-group-set-mode-line)))
1723 (set-marker mark nil)
1726 (defun gnus-group-set-mode-line ()
1727 "Update the mode line in the group buffer."
1728 (when (memq 'group gnus-updated-mode-lines)
1729 ;; Yes, we want to keep this mode line updated.
1731 (set-buffer gnus-group-buffer)
1732 (let* ((gformat (or gnus-group-mode-line-format-spec
1733 (gnus-set-format 'group-mode)))
1734 (gnus-tmp-news-server (cadr gnus-select-method))
1735 (gnus-tmp-news-method (car gnus-select-method))
1736 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1738 gnus-tmp-header ;Dummy binding for user-defined formats
1739 ;; Get the resulting string.
1741 (and gnus-dribble-buffer
1742 (buffer-name gnus-dribble-buffer)
1743 (buffer-modified-p gnus-dribble-buffer)
1745 (set-buffer gnus-dribble-buffer)
1746 (not (zerop (buffer-size))))))
1747 (mode-string (eval gformat)))
1748 ;; Say whether the dribble buffer has been modified.
1749 (setq mode-line-modified
1750 (if modified (car gnus-mode-line-modified)
1751 (cdr gnus-mode-line-modified)))
1752 ;; If the line is too long, we chop it off.
1753 (when (> (length mode-string) max-len)
1754 (setq mode-string (substring mode-string 0 (- max-len 4))))
1756 (setq mode-line-buffer-identification
1757 (gnus-mode-line-buffer-identification
1758 (list mode-string)))
1759 (set-buffer-modified-p modified))))))
1761 (defun gnus-group-group-name ()
1762 "Get the name of the newsgroup on the current line."
1763 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1765 (symbol-name group))))
1767 (defun gnus-group-group-level ()
1768 "Get the level of the newsgroup on the current line."
1769 (get-text-property (point-at-bol) 'gnus-level))
1771 (defun gnus-group-group-indentation ()
1772 "Get the indentation of the newsgroup on the current line."
1773 (or (get-text-property (point-at-bol) 'gnus-indentation)
1774 (and gnus-group-indentation-function
1775 (funcall gnus-group-indentation-function))
1778 (defun gnus-group-group-unread ()
1779 "Get the number of unread articles of the newsgroup on the current line."
1780 (get-text-property (point-at-bol) 'gnus-unread))
1782 (defun gnus-group-new-mail (group)
1783 (if (nnmail-new-mail-p (gnus-group-real-name group))
1787 (defun gnus-group-level (group)
1788 "Return the estimated level of GROUP."
1789 (or (gnus-info-level (gnus-get-info group))
1790 (and (member group gnus-zombie-list) gnus-level-zombie)
1793 (defun gnus-group-search-forward (&optional backward all level first-too)
1794 "Find the next newsgroup with unread articles.
1795 If BACKWARD is non-nil, find the previous newsgroup instead.
1796 If ALL is non-nil, just find any newsgroup.
1797 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1799 If FIRST-TOO, the current line is also eligible as a target."
1800 (let ((way (if backward -1 1))
1801 (low gnus-level-killed)
1804 (if (and backward (progn (beginning-of-line)) (bobp))
1813 (get-text-property (point) 'gnus-group)
1817 (get-text-property (point) 'gnus-unread)))
1818 (and (numberp unread) (> unread 0)))
1819 (setq lev (get-text-property (point)
1821 (<= lev gnus-level-subscribed)))
1823 (and (setq lev (get-text-property (point)
1832 (zerop (forward-line way)))))
1834 (progn (gnus-group-position-point) t)
1835 (goto-char (or pos beg))
1838 (defun gnus-total-fetched-for (group)
1839 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1840 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1841 (size (+ size-in-cache size-in-agent))
1842 (suffix '("B" "K" "M" "G"))
1845 (while (> size cutoff)
1846 (setq size (/ size scale)
1847 suffix (cdr suffix)))
1848 (format "%5.1f%s" size (car suffix))))
1850 ;;; Gnus group mode commands
1854 (defun gnus-group-mark-line-p ()
1857 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1858 (eq (char-after) gnus-process-mark)))
1860 (defun gnus-group-mark-group (n &optional unmark no-advance)
1861 "Mark the current group."
1863 (let ((buffer-read-only nil)
1867 (when (setq group (gnus-group-group-name))
1868 ;; Go to the mark position.
1870 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1874 (setq gnus-group-marked (delete group gnus-group-marked))
1875 (insert-char ? 1 t))
1876 (setq gnus-group-marked
1877 (cons group (delete group gnus-group-marked)))
1878 (insert-char gnus-process-mark 1 t)))
1880 (gnus-group-next-group 1))
1882 (gnus-summary-position-point)
1885 (defun gnus-group-unmark-group (n)
1886 "Remove the mark from the current group."
1888 (gnus-group-mark-group n 'unmark)
1889 (gnus-group-position-point))
1891 (defun gnus-group-unmark-all-groups ()
1892 "Unmark all groups."
1895 (mapc 'gnus-group-remove-mark gnus-group-marked))
1896 (gnus-group-position-point))
1898 (defun gnus-group-mark-region (unmark beg end)
1899 "Mark all groups between point and mark.
1900 If UNMARK, remove the mark instead."
1901 (interactive "P\nr")
1902 (let ((num (count-lines beg end)))
1905 (- num (gnus-group-mark-group num unmark)))))
1907 (defun gnus-group-mark-buffer (&optional unmark)
1908 "Mark all groups in the buffer.
1909 If UNMARK, remove the mark instead."
1911 (gnus-group-mark-region unmark (point-min) (point-max)))
1913 (defun gnus-group-mark-regexp (regexp)
1914 "Mark all groups that match some regexp."
1915 (interactive "sMark (regexp): ")
1916 (let ((alist (cdr gnus-newsrc-alist))
1920 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1921 (gnus-group-jump-to-group group)
1922 (gnus-group-set-mark group)))))
1923 (gnus-group-position-point))
1925 (defun gnus-group-remove-mark (group &optional test-marked)
1926 "Remove the process mark from GROUP and move point there.
1927 Return nil if the group isn't displayed."
1928 (if (gnus-group-goto-group group nil test-marked)
1930 (gnus-group-mark-group 1 'unmark t)
1932 (setq gnus-group-marked
1933 (delete group gnus-group-marked))
1936 (defun gnus-group-set-mark (group)
1937 "Set the process mark on GROUP."
1938 (if (gnus-group-goto-group group)
1940 (gnus-group-mark-group 1 nil t))
1941 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1943 (defun gnus-group-universal-argument (arg &optional groups func)
1944 "Perform any command on all groups according to the process/prefix convention."
1946 (if (eq (setq func (or func
1949 (substitute-command-keys
1950 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1952 (gnus-error 1 "Undefined key")
1953 (gnus-group-iterate arg
1955 (command-execute func))))
1956 (gnus-group-position-point))
1958 (defun gnus-group-process-prefix (n)
1959 "Return a list of groups to work on.
1960 Take into consideration N (the prefix) and the list of marked groups."
1963 (setq n (prefix-numeric-value n))
1964 ;; There is a prefix, so we return a list of the N next
1966 (let ((way (if (< n 0) -1 1))
1971 (if (setq group (gnus-group-group-name))
1972 (push group groups))
1974 (gnus-group-next-group way)))
1976 ((and (gnus-region-active-p) (mark))
1977 ;; Work on the region between point and mark.
1978 (let ((max (max (point) (mark)))
1981 (goto-char (min (point) (mark)))
1984 (push (gnus-group-group-name) groups)
1985 (zerop (gnus-group-next-group 1))
1987 (nreverse groups))))
1989 ;; No prefix, but a list of marked articles.
1990 (reverse gnus-group-marked))
1992 ;; Neither marked articles or a prefix, so we return the
1994 (let ((group (gnus-group-group-name)))
1995 (and group (list group))))))
1997 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1998 ;;; imagine why I went through these contortions...
2000 (let ((function (make-symbol "gnus-group-iterate-function"))
2001 (window (make-symbol "gnus-group-iterate-window"))
2002 (groups (make-symbol "gnus-group-iterate-groups"))
2003 (group (make-symbol "gnus-group-iterate-group")))
2005 `(defun gnus-group-iterate (arg ,function)
2006 "Iterate FUNCTION over all process/prefixed groups.
2007 FUNCTION will be called with the group name as the parameter
2008 and with point over the group in question."
2009 (let ((,groups (gnus-group-process-prefix arg))
2010 (,window (selected-window))
2013 (setq ,group (car ,groups)
2014 ,groups (cdr ,groups))
2015 (select-window ,window)
2016 (gnus-group-remove-mark ,group)
2017 (save-selected-window
2019 (funcall ,function ,group)))))))))
2021 (put 'gnus-group-iterate 'lisp-indent-function 1)
2023 ;; Selecting groups.
2025 (defun gnus-group-read-group (&optional all no-article group select-articles)
2026 "Read news in this newsgroup.
2027 If the prefix argument ALL is non-nil, already read articles become
2028 readable. IF ALL is a number, fetch this number of articles. If the
2029 optional argument NO-ARTICLE is non-nil, no article will be
2030 auto-selected upon group entry. If GROUP is non-nil, fetch that
2033 (let ((no-display (eq all 0))
2034 (group (or group (gnus-group-group-name)))
2035 number active marked entry)
2039 (error "No group on current line"))
2040 (setq marked (gnus-info-marks
2041 (nth 2 (setq entry (gnus-group-entry group)))))
2042 ;; This group might be a dead group. In that case we have to get
2043 ;; the number of unread articles from `gnus-active-hashtb'.
2045 (cond ((numberp all) all)
2047 ((setq active (gnus-active group))
2048 (- (1+ (cdr active)) (car active)))))
2049 (gnus-summary-read-group
2050 group (or all (and (numberp number)
2051 (zerop (+ number (gnus-range-length
2052 (cdr (assq 'tick marked)))
2054 (cdr (assq 'dormant marked)))))))
2055 no-article nil no-display nil select-articles)))
2057 (defun gnus-group-select-group (&optional all)
2058 "Select this newsgroup.
2059 No article is selected automatically.
2060 If the group is opened, just switch the summary buffer.
2061 If ALL is non-nil, already read articles become readable.
2062 If ALL is a positive number, fetch this number of the latest
2063 articles in the group.
2064 If ALL is a negative number, fetch this number of the earliest
2065 articles in the group."
2067 (when (and (eobp) (not (gnus-group-group-name)))
2069 (gnus-group-read-group all t))
2071 (defun gnus-group-quick-select-group (&optional all)
2072 "Select the current group \"quickly\".
2073 This means that no highlighting or scoring will be performed.
2074 If ALL (the prefix argument) is 0, don't even generate the summary
2077 This might be useful if you want to toggle threading
2078 before entering the group."
2080 (require 'gnus-score)
2082 gnus-score-find-score-files-function
2083 gnus-home-score-file
2084 gnus-apply-kill-hook
2085 gnus-summary-expunge-below)
2086 (gnus-group-read-group all t)))
2088 (defun gnus-group-visible-select-group (&optional all)
2089 "Select the current group without hiding any articles."
2091 (let ((gnus-inhibit-limiting t))
2092 (gnus-group-read-group all t)))
2094 (defun gnus-group-select-group-ephemerally ()
2095 "Select the current group without doing any processing whatsoever.
2096 You will actually be entered into a group that's a copy of
2097 the current group; no changes you make while in this group will
2100 (require 'gnus-score)
2102 gnus-score-find-score-files-function gnus-apply-kill-hook
2103 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2104 gnus-summary-mode-hook gnus-select-group-hook
2105 (group (gnus-group-group-name))
2106 (method (gnus-find-method-for-group group)))
2107 (gnus-group-read-ephemeral-group
2108 (gnus-group-prefixed-name group method) method)))
2111 (defun gnus-fetch-group (group &optional articles)
2112 "Start Gnus if necessary and enter GROUP.
2113 Returns whether the fetching was successful or not."
2114 (interactive (list (gnus-group-completing-read-group-name
2115 "Group name: " gnus-active-hashtb)))
2116 (unless (get-buffer gnus-group-buffer)
2118 (gnus-group-read-group articles nil group))
2121 (defun gnus-fetch-group-other-frame (group)
2122 "Pop up a frame and enter GROUP."
2124 (let ((window (get-buffer-window gnus-group-buffer)))
2126 (select-frame (window-frame window)))
2127 ((= (length (frame-list)) 1)
2128 (select-frame (make-frame)))
2131 (gnus-fetch-group group))
2133 (defvar gnus-ephemeral-group-server 0)
2135 (defcustom gnus-large-ephemeral-newsgroup 200
2136 "The number of articles which indicates a large ephemeral newsgroup.
2137 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2139 If the number of articles in a newsgroup is greater than this value,
2140 confirmation is required for selecting the newsgroup. If it is nil, no
2141 confirmation is required."
2143 :group 'gnus-group-select
2144 :type '(choice (const :tag "No limit" nil)
2147 (defcustom gnus-fetch-old-ephemeral-headers nil
2148 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2151 :type '(choice (const :tag "off" nil)
2154 (sexp :menu-tag "other" t)))
2156 ;; Enter a group that is not in the group buffer. Non-nil is returned
2157 ;; if selection was successful.
2158 (defun gnus-group-read-ephemeral-group (group method &optional activate
2159 quit-config request-only
2163 "Read GROUP from METHOD as an ephemeral group.
2164 If ACTIVATE, request the group first.
2165 If QUIT-CONFIG, use that window configuration when exiting from the
2167 If REQUEST-ONLY, don't actually read the group; just request it.
2168 If SELECT-ARTICLES, only select those articles.
2169 If PARAMETERS, use those as the group parameters.
2170 If NUMBER, fetch this number of articles.
2172 Return the name of the group if selection was successful."
2175 ;; (gnus-read-group "Group name: ")
2177 "Group: " gnus-active-hashtb
2179 'gnus-group-history)
2180 (gnus-read-method "From method: ")))
2181 ;; Transform the select method into a unique server.
2182 (when (stringp method)
2183 (setq method (gnus-server-to-method method)))
2185 `(,(car method) ,(concat (cadr method) "-ephemeral")
2186 (,(intern (format "%s-address" (car method))) ,(cadr method))
2188 (let ((group (if (gnus-group-foreign-p group) group
2189 (gnus-group-prefixed-name (gnus-group-real-name group)
2194 ,gnus-level-default-subscribed nil nil ,method
2197 (cons 'quit-config quit-config)
2199 (cons gnus-summary-buffer
2200 gnus-current-window-configuration)))
2203 (push method gnus-ephemeral-servers)
2204 (set-buffer gnus-group-buffer)
2205 (unless (gnus-check-server method)
2206 (error "Unable to contact server: %s" (gnus-status-message method)))
2208 (gnus-activate-group group 'scan)
2209 (unless (gnus-request-group group)
2210 (error "Couldn't request group: %s"
2211 (nnheader-get-report (car method)))))
2215 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2216 (gnus-fetch-old-headers
2217 gnus-fetch-old-ephemeral-headers))
2218 (gnus-group-read-group (or number t) t group select-articles))
2222 (message "Quit reading the ephemeral group")
2225 (defun gnus-group-jump-to-group (group &optional prompt)
2226 "Jump to newsgroup GROUP.
2228 If PROMPT (the prefix) is a number, use the prompt specified in
2229 `gnus-group-jump-to-group-prompt'."
2231 (list (mm-string-make-unibyte
2233 "Group: " gnus-active-hashtb nil
2234 (gnus-read-active-file-p)
2235 (if current-prefix-arg
2236 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2237 (or (and (stringp gnus-group-jump-to-group-prompt)
2238 gnus-group-jump-to-group-prompt)
2239 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2240 (and (stringp p) p))))
2241 'gnus-group-history))))
2243 (when (equal group "")
2244 (error "Empty group name"))
2246 (unless (gnus-ephemeral-group-p group)
2247 ;; Either go to the line in the group buffer...
2248 (unless (gnus-group-goto-group group)
2249 ;; ... or insert the line.
2250 (gnus-group-update-group group)
2251 (gnus-group-goto-group group)))
2252 ;; Adjust cursor point.
2253 (gnus-group-position-point))
2255 (defun gnus-group-goto-group (group &optional far test-marked)
2256 "Goto to newsgroup GROUP.
2257 If FAR, it is likely that the group is not on the current line.
2258 If TEST-MARKED, the line must be marked."
2262 ;; It's quite likely that we are on the right line, so
2263 ;; we check the current line first.
2265 (eq (get-text-property (point) 'gnus-group)
2266 (gnus-intern-safe group gnus-active-hashtb))
2267 (or (not test-marked) (gnus-group-mark-line-p)))
2269 ;; Previous and next line are also likely, so we check them as well.
2273 (and (eq (get-text-property (point) 'gnus-group)
2274 (gnus-intern-safe group gnus-active-hashtb))
2275 (or (not test-marked) (gnus-group-mark-line-p)))))
2281 (and (eq (get-text-property (point) 'gnus-group)
2282 (gnus-intern-safe group gnus-active-hashtb))
2283 (or (not test-marked) (gnus-group-mark-line-p)))))
2287 (goto-char (point-min))
2289 (while (and (not found)
2294 (gnus-intern-safe group gnus-active-hashtb))))
2295 (if (gnus-group-mark-line-p)
2300 ;; Search through the entire buffer.
2303 (point-min) (point-max)
2304 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2306 (defun gnus-group-next-group (n &optional silent)
2307 "Go to next N'th newsgroup.
2308 If N is negative, search backward instead.
2309 Returns the difference between N and the number of skips actually
2312 (gnus-group-next-unread-group n t nil silent))
2314 (defun gnus-group-next-unread-group (n &optional all level silent)
2315 "Go to next N'th unread newsgroup.
2316 If N is negative, search backward instead.
2317 If ALL is non-nil, choose any newsgroup, unread or not.
2318 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2319 such group can be found, the next group with a level higher than
2321 Returns the difference between N and the number of skips actually
2324 (let ((backward (< n 0))
2327 (gnus-group-search-forward
2328 backward (or (not gnus-group-goto-unread) all) level))
2332 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2333 (if level " on this level or higher" "")))
2336 (defun gnus-group-prev-group (n)
2337 "Go to previous N'th newsgroup.
2338 Returns the difference between N and the number of skips actually
2341 (gnus-group-next-unread-group (- n) t))
2343 (defun gnus-group-prev-unread-group (n)
2344 "Go to previous N'th unread newsgroup.
2345 Returns the difference between N and the number of skips actually
2348 (gnus-group-next-unread-group (- n)))
2350 (defun gnus-group-next-unread-group-same-level (n)
2351 "Go to next N'th unread newsgroup on the same level.
2352 If N is negative, search backward instead.
2353 Returns the difference between N and the number of skips actually
2356 (gnus-group-next-unread-group n t (gnus-group-group-level))
2357 (gnus-group-position-point))
2359 (defun gnus-group-prev-unread-group-same-level (n)
2360 "Go to next N'th unread newsgroup on the same level.
2361 Returns the difference between N and the number of skips actually
2364 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2365 (gnus-group-position-point))
2367 (defun gnus-group-best-unread-group (&optional exclude-group)
2368 "Go to the group with the highest level.
2369 If EXCLUDE-GROUP, do not go to that group."
2371 (goto-char (point-min))
2375 (setq unread (get-text-property (point) 'gnus-unread))
2376 (when (and (numberp unread) (> unread 0))
2377 (when (and (get-text-property (point) 'gnus-level)
2378 (< (get-text-property (point) 'gnus-level) best)
2379 (or (not exclude-group)
2380 (not (equal exclude-group (gnus-group-group-name)))))
2381 (setq best (get-text-property (point) 'gnus-level))
2382 (setq best-point (point))))
2385 (goto-char best-point))
2386 (gnus-group-position-point)
2387 (and best-point (gnus-group-group-name))))
2389 ;; Is there something like an after-point-motion-hook?
2390 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2392 ;; (defun gnus-group-menu-bar-update ()
2393 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2394 ;; (current-buffer))))
2395 ;; (name (buffer-name (car buf))))
2397 ;; (if (> (length name) 27)
2398 ;; (concat (substring name 0 12)
2400 ;; (substring name -12))
2402 ;; (menu-bar-update-buffers-1 buf)))
2404 ;; (defun gnus-group-position-point ()
2405 ;; (gnus-goto-colon)
2406 ;; (gnus-group-menu-bar-update))
2408 (defun gnus-group-first-unread-group ()
2409 "Go to the first group with unread articles."
2412 (let ((opoint (point))
2414 (goto-char (point-min))
2415 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2416 (and (numberp unread) ; Not a topic.
2417 (not (zerop unread))) ; Has unread articles.
2418 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2421 nil)) ; Not success.
2422 (gnus-group-position-point)))
2424 (defun gnus-group-enter-server-mode ()
2425 "Jump to the server buffer."
2427 (gnus-enter-server-buffer))
2429 (defun gnus-group-make-group-simple (&optional group)
2430 "Add a new newsgroup.
2431 The user will be prompted for GROUP."
2433 (list (completing-read "Group: " gnus-active-hashtb
2434 nil nil nil 'gnus-group-history)))
2435 (gnus-group-make-group
2436 (gnus-group-real-name group)
2437 (gnus-group-server group)))
2439 (defun gnus-group-make-group (name &optional method address args)
2440 "Add a new newsgroup.
2441 The user will be prompted for a NAME, for a select METHOD, and an
2445 (gnus-read-group "Group name: ")
2446 (gnus-read-method "From method: ")))
2448 (when (stringp method)
2449 (setq method (or (gnus-server-to-method method) method)))
2450 (let* ((meth (gnus-method-simplify
2452 (not (gnus-server-equal method gnus-select-method)))
2453 (if address (list (intern method) address)
2455 (nname (if method (gnus-group-prefixed-name name meth) name))
2457 (when (gnus-group-entry nname)
2458 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2459 ;; Subscribe to the new group.
2460 (gnus-group-change-level
2461 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2462 gnus-level-default-subscribed gnus-level-killed
2463 (and (gnus-group-group-name)
2464 (gnus-group-entry (gnus-group-group-name)))
2467 (gnus-set-active nname (cons 1 0))
2468 (unless (gnus-ephemeral-group-p name)
2470 (concat "(gnus-group-set-info '"
2471 (gnus-prin1-to-string (cdr info)) ")")))
2473 (gnus-group-insert-group-line-info nname)
2475 (gnus-group-position-point)
2477 ;; Load the back end and try to make the back end create
2478 ;; the group as well.
2479 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2481 gnus-valid-select-methods)
2483 (gnus-check-server meth)
2484 (when (gnus-check-backend-function 'request-create-group nname)
2485 (unless (gnus-request-create-group nname nil args)
2486 (error "Could not create group on server: %s"
2487 (nnheader-get-report backend))))
2490 (defun gnus-group-delete-groups (&optional arg)
2491 "Delete the current group. Only meaningful with editable groups."
2493 (let ((n (length (gnus-group-process-prefix arg))))
2494 (when (gnus-yes-or-no-p
2496 "Delete this 1 group? "
2497 (format "Delete these %d groups? " n)))
2498 (gnus-group-iterate arg
2500 (gnus-group-delete-group group nil t))))))
2502 (defun gnus-group-delete-group (group &optional force no-prompt)
2503 "Delete the current group. Only meaningful with editable groups.
2504 If FORCE (the prefix) is non-nil, all the articles in the group will
2505 be deleted. This is \"deleted\" as in \"removed forever from the face
2506 of the Earth\". There is no undo. The user will be prompted before
2508 Note that you also have to specify FORCE if you want the group to
2509 be removed from the server, even when it's empty."
2511 (list (gnus-group-group-name)
2512 current-prefix-arg))
2514 (error "No group to delete"))
2515 (unless (gnus-check-backend-function 'request-delete-group group)
2516 (error "This back end does not support group deletion"))
2518 (let ((group-decoded (gnus-group-decoded-name group)))
2519 (if (and (not no-prompt)
2520 (not (gnus-yes-or-no-p
2522 "Do you really want to delete %s%s? "
2523 group-decoded (if force " and all its contents" "")))))
2525 (gnus-message 6 "Deleting group %s..." group-decoded)
2526 (if (not (gnus-request-delete-group group force))
2527 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2528 (gnus-message 6 "Deleting group %s...done" group-decoded)
2529 (gnus-group-goto-group group)
2530 (gnus-group-kill-group 1 t)
2531 (gnus-set-active group nil)
2533 (gnus-group-position-point)))
2535 (defun gnus-group-rename-group (group new-name)
2536 "Rename group from GROUP to NEW-NAME.
2537 When used interactively, GROUP is the group under point
2538 and NEW-NAME will be prompted for."
2541 (gnus-group-group-name)
2543 (unless (gnus-check-backend-function
2544 'request-rename-group (gnus-group-group-name))
2545 (error "This back end does not support renaming groups"))
2546 (gnus-read-group "Rename group to: "
2547 (gnus-group-real-name (gnus-group-group-name))))))
2549 (unless (gnus-check-backend-function 'request-rename-group group)
2550 (error "This back end does not support renaming groups"))
2552 (error "No group to rename"))
2553 (when (equal (gnus-group-real-name group) new-name)
2554 (error "Can't rename to the same name"))
2556 ;; We find the proper prefixed name.
2558 (if (gnus-group-native-p group)
2562 (gnus-group-prefixed-name
2563 (gnus-group-real-name new-name)
2564 (gnus-info-method (gnus-get-info group)))))
2566 (when (gnus-active new-name)
2567 (error "The group %s already exists" new-name))
2569 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2572 (gnus-group-goto-group group)
2573 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2574 (gnus-request-rename-group group new-name))))
2575 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2576 ;; We rename the group internally by killing it...
2577 (gnus-group-kill-group)
2578 ;; ... changing its name ...
2579 (setcar (cdar gnus-list-of-killed-groups) new-name)
2580 ;; ... and then yanking it. Magic!
2581 (gnus-group-yank-group)
2582 (gnus-set-active new-name (gnus-active group))
2583 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2585 (setq gnus-killed-list (delete group gnus-killed-list))
2586 (gnus-set-active group nil)
2587 (gnus-dribble-touch)
2588 (gnus-group-position-point)))
2590 (defun gnus-group-edit-group (group &optional part)
2591 "Edit the group on the current line."
2592 (interactive (list (gnus-group-group-name)))
2593 (let ((part (or part 'info))
2596 (error "No group on current line"))
2597 (unless (setq info (gnus-get-info group))
2598 (error "Killed group; can't be edited"))
2600 (gnus-close-group group))
2602 ;; Find the proper form to edit.
2603 (cond ((eq part 'method)
2604 (or (gnus-info-method info) "native"))
2606 (gnus-info-params info))
2608 ;; The proper documentation.
2610 "Editing the %s for `%s'."
2612 ((eq part 'method) "select method")
2613 ((eq part 'params) "group parameters")
2615 (gnus-group-decoded-name group))
2617 (gnus-group-edit-group-done ',part ,group form)))
2620 (gnus-create-info-command
2622 (or gnus-info-filename
2623 (get-language-info current-language-environment 'gnus-info)
2625 (cond ((eq part 'method)
2632 (defun gnus-group-edit-group-method (group)
2633 "Edit the select method of GROUP."
2634 (interactive (list (gnus-group-group-name)))
2635 (gnus-group-edit-group group 'method))
2637 (defun gnus-group-edit-group-parameters (group)
2638 "Edit the group parameters of GROUP."
2639 (interactive (list (gnus-group-group-name)))
2640 (gnus-group-edit-group group 'params))
2642 (defun gnus-group-edit-group-done (part group form)
2644 (let* ((method (cond ((eq part 'info) (nth 4 form))
2645 ((eq part 'method) form)
2647 (info (cond ((eq part 'info) form)
2648 ((eq part 'method) (gnus-get-info group))
2651 (if (or (not method)
2653 gnus-select-method method))
2654 (gnus-group-real-name (car info))
2655 (gnus-group-prefixed-name
2656 (gnus-group-real-name (car info)) method))
2658 (when (and new-group
2659 (not (equal new-group group)))
2660 (when (gnus-group-goto-group group)
2661 (gnus-group-kill-group 1))
2662 (gnus-activate-group new-group))
2664 (if (not (and info new-group))
2665 (gnus-group-set-info form (or new-group group) part)
2666 (setq info (gnus-copy-sequence info))
2667 (setcar info new-group)
2668 (unless (gnus-server-equal method "native")
2669 (unless (nthcdr 3 info)
2670 (nconc info (list nil nil)))
2671 (unless (nthcdr 4 info)
2672 (nconc info (list nil)))
2673 (gnus-info-set-method info method))
2674 (gnus-group-set-info info))
2675 (gnus-group-update-group (or new-group group))
2676 (gnus-group-position-point)))
2678 (defun gnus-group-make-useful-group (group method)
2679 "Create one of the groups described in `gnus-useful-groups'."
2681 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2683 gnus-useful-groups)))
2684 (list (cadr entry) (caddr entry))))
2685 (setq method (gnus-copy-sequence method))
2687 (while (setq entry (memq (assq 'eval method) method))
2688 (setcar entry (eval (cadar entry)))))
2689 (gnus-group-make-group group method))
2691 (defun gnus-group-make-help-group (&optional noerror)
2692 "Create the Gnus documentation group.
2693 Optional argument NOERROR modifies the behavior of this function when the
2694 group already exists:
2695 - if not given, and error is signaled,
2696 - if t, stay silent,
2697 - if anything else, just print a message."
2699 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2700 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2701 (if (gnus-group-entry name)
2702 (cond ((eq noerror nil)
2703 (error "Documentation group already exists"))
2708 (gnus-message 1 "Documentation group already exists")))
2711 (gnus-message 1 "Couldn't find doc group")
2712 (gnus-group-make-group
2713 (gnus-group-real-name name)
2714 (list 'nndoc "gnus-help"
2715 (list 'nndoc-address file)
2716 (list 'nndoc-article-type 'mbox))))
2718 (gnus-group-position-point))
2720 (defun gnus-group-make-doc-group (file type)
2721 "Create a group that uses a single file as the source.
2723 If called with a prefix argument, ask for the file type."
2725 (list (read-file-name "File name: ")
2726 (and current-prefix-arg 'ask)))
2727 (when (eq type 'ask)
2732 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2734 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2735 ((= char ?b) 'babyl)
2736 ((= char ?d) 'digest)
2737 ((= char ?f) 'forward)
2739 ((= char ?g) 'guess)
2740 (t (setq err (format "%c unknown. " char))
2743 (let* ((file (expand-file-name file))
2744 (name (gnus-generate-new-group-name
2745 (gnus-group-prefixed-name
2746 (file-name-nondirectory file) '(nndoc "")))))
2747 (gnus-group-make-group
2748 (gnus-group-real-name name)
2750 (list 'nndoc-address file)
2751 (list 'nndoc-article-type (or type 'guess))))))
2753 (defvar nnweb-type-definition)
2754 (defvar gnus-group-web-type-history nil)
2755 (defvar gnus-group-web-search-history nil)
2756 (defun gnus-group-make-web-group (&optional solid)
2757 "Create an ephemeral nnweb group.
2758 If SOLID (the prefix), create a solid group."
2762 (if solid (gnus-read-group "Group name: ")
2763 (message-unique-id)))
2764 (default-type (or (car gnus-group-web-type-history)
2765 (symbol-name (caar nnweb-type-definition))))
2769 (format "Search engine type (default %s): " default-type)
2770 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2771 nnweb-type-definition)
2772 nil t nil 'gnus-group-web-type-history)
2777 (cons (or (car gnus-group-web-search-history) "") 0)
2778 'gnus-group-web-search-history))
2780 `(nnweb ,group (nnweb-search ,search)
2781 (nnweb-type ,(intern type))
2782 (nnweb-ephemeral-p t))))
2785 (gnus-pull 'nnweb-ephemeral-p method)
2786 (gnus-group-make-group group method))
2787 (gnus-group-read-ephemeral-group
2789 (cons (current-buffer)
2790 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2793 (defvar nnrss-group-alist)
2794 (defun nnrss-discover-feed (arg))
2795 (defun nnrss-save-server-data (arg)))
2796 (defun gnus-group-make-rss-group (&optional url)
2797 "Given a URL, discover if there is an RSS feed.
2798 If there is, use Gnus to create an nnrss group"
2802 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2803 (let ((feedinfo (nnrss-discover-feed url)))
2805 (let ((title (gnus-newsgroup-savable-name
2806 (read-from-minibuffer "Title: "
2807 (gnus-newsgroup-savable-name
2808 (or (cdr (assoc 'title
2811 (desc (read-from-minibuffer "Description: "
2812 (cdr (assoc 'description
2814 (href (cdr (assoc 'href feedinfo)))
2815 (encodable (mm-coding-system-p 'utf-8)))
2817 ;; Unify non-ASCII text.
2818 (setq title (mm-decode-coding-string
2819 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2820 (gnus-group-make-group (if encodable
2821 (mm-encode-coding-string title 'utf-8)
2824 (push (list title href desc) nnrss-group-alist)
2825 (nnrss-save-server-data nil))
2826 (error "No feeds found for %s" url))))
2828 (defvar nnwarchive-type-definition)
2829 (defvar gnus-group-warchive-type-history nil)
2830 (defvar gnus-group-warchive-login-history nil)
2831 (defvar gnus-group-warchive-address-history nil)
2833 (defun gnus-group-make-warchive-group ()
2834 "Create a nnwarchive group."
2836 (require 'nnwarchive)
2837 (let* ((group (gnus-read-group "Group name: "))
2838 (default-type (or (car gnus-group-warchive-type-history)
2839 (symbol-name (caar nnwarchive-type-definition))))
2843 (format "Warchive type (default %s): " default-type)
2844 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2845 nnwarchive-type-definition)
2846 nil t nil 'gnus-group-warchive-type-history)
2848 (address (read-string "Warchive address: "
2849 nil 'gnus-group-warchive-address-history))
2850 (default-login (or (car gnus-group-warchive-login-history)
2855 (format "Warchive login (default %s): " user-mail-address)
2856 default-login 'gnus-group-warchive-login-history)
2859 `(nnwarchive ,address
2860 (nnwarchive-type ,(intern type))
2861 (nnwarchive-login ,login))))
2862 (gnus-group-make-group group method)))
2864 (defun gnus-group-make-archive-group (&optional all)
2865 "Create the (ding) Gnus archive group of the most recent articles.
2866 Given a prefix, create a full group."
2868 (let ((group (gnus-group-prefixed-name
2869 (if all "ding.archives" "ding.recent") '(nndir ""))))
2870 (when (gnus-group-entry group)
2871 (error "Archive group already exists"))
2872 (gnus-group-make-group
2873 (gnus-group-real-name group)
2874 (list 'nndir (if all "hpc" "edu")
2875 (list 'nndir-directory
2876 (if all gnus-group-archive-directory
2877 gnus-group-recent-archive-directory))))
2878 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2880 (defun gnus-group-make-directory-group (dir)
2881 "Create an nndir group.
2882 The user will be prompted for a directory. The contents of this
2883 directory will be used as a newsgroup. The directory should contain
2884 mail messages or news articles in files that have numeric names."
2886 (list (read-file-name "Create group from directory: ")))
2887 (unless (file-exists-p dir)
2888 (error "No such directory"))
2889 (unless (file-directory-p dir)
2890 (error "Not a directory"))
2894 (while (or (not group) (gnus-group-entry group))
2896 (gnus-group-prefixed-name
2897 (expand-file-name ext dir)
2899 (setq ext (format "<%d>" (setq i (1+ i)))))
2900 (gnus-group-make-group
2901 (gnus-group-real-name group)
2902 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2904 (defvar nnkiboze-score-file)
2905 (defun gnus-group-make-kiboze-group (group address scores)
2906 "Create an nnkiboze group.
2907 The user will be prompted for a name, a regexp to match groups, and
2908 score file entries for articles to include in the group."
2911 (read-string "nnkiboze group name: ")
2912 (read-string "Source groups (regexp): ")
2913 (let ((headers (mapcar 'list
2914 '("subject" "from" "number" "date" "message-id"
2915 "references" "chars" "lines" "xref"
2916 "followup" "all" "body" "head")))
2917 scores header regexp regexps)
2918 (while (not (equal "" (setq header (completing-read
2919 "Match on header: " headers nil t))))
2921 (while (not (equal "" (setq regexp (read-string
2922 (format "Match on %s (regexp): "
2924 (push (list regexp nil nil 'r) regexps))
2925 (push (cons header regexps) scores))
2927 (gnus-group-make-group group "nnkiboze" address)
2928 (let* ((nnkiboze-current-group group)
2929 (score-file (car (nnkiboze-score-file "")))
2930 (score-dir (file-name-directory score-file)))
2931 (unless (file-exists-p score-dir)
2932 (make-directory score-dir))
2933 (with-temp-file score-file
2934 (let (emacs-lisp-mode-hook)
2935 (gnus-pp scores)))))
2937 (defun gnus-group-add-to-virtual (n vgroup)
2938 "Add the current group to a virtual group."
2940 (list current-prefix-arg
2941 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2943 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2944 (error "%s is not an nnvirtual group" vgroup))
2945 (gnus-close-group vgroup)
2946 (let* ((groups (gnus-group-process-prefix n))
2947 (method (gnus-info-method (gnus-get-info vgroup))))
2948 (setcar (cdr method)
2950 (nth 1 method) "\\|"
2953 (gnus-group-remove-mark s)
2954 (concat "\\(^" (regexp-quote s) "$\\)"))
2956 (gnus-group-position-point))
2958 (defun gnus-group-make-empty-virtual (group)
2959 "Create a new, fresh, empty virtual group."
2960 (interactive "sCreate new, empty virtual group: ")
2961 (let* ((method (list 'nnvirtual "^$"))
2962 (pgroup (gnus-group-prefixed-name group method)))
2963 ;; Check whether it exists already.
2964 (when (gnus-group-entry pgroup)
2965 (error "Group %s already exists" pgroup))
2966 ;; Subscribe the new group after the group on the current line.
2967 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2968 (gnus-group-update-group pgroup)
2970 (gnus-group-position-point)))
2972 (defun gnus-group-enter-directory (dir)
2973 "Enter an ephemeral nneething group."
2974 (interactive "DDirectory to read: ")
2975 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2976 (leaf (gnus-group-prefixed-name
2977 (file-name-nondirectory (directory-file-name dir))
2979 (name (gnus-generate-new-group-name leaf)))
2980 (unless (gnus-group-read-ephemeral-group
2982 (cons (current-buffer)
2983 (if (eq major-mode 'gnus-summary-mode)
2985 (error "Couldn't enter %s" dir))))
2988 (autoload 'nnimap-expunge "nnimap")
2989 (autoload 'nnimap-acl-get "nnimap")
2990 (autoload 'nnimap-acl-edit "nnimap"))
2992 (defun gnus-group-nnimap-expunge (group)
2993 "Expunge deleted articles in current nnimap GROUP."
2994 (interactive (list (gnus-group-group-name)))
2995 (let ((mailbox (gnus-group-real-name group)) method)
2997 (error "No group on current line"))
2998 (unless (gnus-get-info group)
2999 (error "Killed group; can't be edited"))
3000 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
3001 (error "%s is not an nnimap group" group))
3002 (nnimap-expunge mailbox (cadr method))))
3004 (defun gnus-group-nnimap-edit-acl (group)
3005 "Edit the Access Control List of current nnimap GROUP."
3006 (interactive (list (gnus-group-group-name)))
3007 (let ((mailbox (gnus-group-real-name group)) method acl)
3009 (error "No group on current line"))
3010 (unless (gnus-get-info group)
3011 (error "Killed group; can't be edited"))
3012 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3013 (error "%s is not an nnimap group" group))
3014 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3015 (error "Server does not support ACL's"))
3016 (gnus-edit-form acl (format "Editing the access control list for `%s'.
3018 An access control list is a list of (identifier . rights) elements.
3020 The identifier string specifies the corresponding user. The
3021 identifier \"anyone\" is reserved to refer to the universal identity.
3023 Rights is a string listing a (possibly empty) set of alphanumeric
3024 characters, each character listing a set of operations which is being
3025 controlled. Letters are reserved for ``standard'' rights, listed
3026 below. Digits are reserved for implementation or site defined rights.
3028 l - lookup (mailbox is visible to LIST/LSUB commands)
3029 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3030 SEARCH, COPY from mailbox)
3031 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3032 w - write (STORE flags other than \\SEEN and \\DELETED)
3033 i - insert (perform APPEND, COPY into mailbox)
3034 p - post (send mail to submission address for mailbox,
3035 not enforced by IMAP4 itself)
3036 c - create and delete mailbox (CREATE new sub-mailboxes in any
3037 implementation-defined hierarchy, RENAME or DELETE mailbox)
3038 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3039 a - administer (perform SETACL)" group)
3042 ,mailbox ',method ',acl form)))))
3044 ;; Group sorting commands
3045 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3047 (defun gnus-group-sort-groups (func &optional reverse)
3048 "Sort the group buffer according to FUNC.
3049 When used interactively, the sorting function used will be
3050 determined by the `gnus-group-sort-function' variable.
3051 If REVERSE (the prefix), reverse the sorting order."
3052 (interactive (list gnus-group-sort-function current-prefix-arg))
3053 (funcall gnus-group-sort-alist-function
3054 (gnus-make-sort-function func) reverse)
3055 (gnus-group-unmark-all-groups)
3056 (gnus-group-list-groups)
3057 (gnus-dribble-touch))
3059 (defun gnus-group-sort-flat (func reverse)
3060 ;; We peel off the dummy group from the alist.
3062 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3063 (pop gnus-newsrc-alist))
3065 (setq gnus-newsrc-alist
3066 (sort gnus-newsrc-alist func))
3068 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3069 ;; Regenerate the hash table.
3070 (gnus-make-hashtable-from-newsrc-alist)))
3072 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3073 "Sort the group buffer alphabetically by group name.
3074 If REVERSE, sort in reverse order."
3076 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3078 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3079 "Sort the group buffer alphabetically by real (unprefixed) group name.
3080 If REVERSE, sort in reverse order."
3082 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3084 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3085 "Sort the group buffer by number of unread articles.
3086 If REVERSE, sort in reverse order."
3088 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3090 (defun gnus-group-sort-groups-by-level (&optional reverse)
3091 "Sort the group buffer by group level.
3092 If REVERSE, sort in reverse order."
3094 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3096 (defun gnus-group-sort-groups-by-score (&optional reverse)
3097 "Sort the group buffer by group score.
3098 If REVERSE, sort in reverse order."
3100 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3102 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3103 "Sort the group buffer by group rank.
3104 If REVERSE, sort in reverse order."
3106 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3108 (defun gnus-group-sort-groups-by-method (&optional reverse)
3109 "Sort the group buffer alphabetically by back end name.
3110 If REVERSE, sort in reverse order."
3112 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3114 (defun gnus-group-sort-groups-by-server (&optional reverse)
3115 "Sort the group buffer alphabetically by server name.
3116 If REVERSE, sort in reverse order."
3118 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3120 ;;; Selected group sorting.
3122 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3123 "Sort the process/prefixed groups."
3124 (interactive (list current-prefix-arg gnus-group-sort-function))
3125 (let ((groups (gnus-group-process-prefix n)))
3126 (funcall gnus-group-sort-selected-function
3127 groups (gnus-make-sort-function func) reverse)
3128 (gnus-group-unmark-all-groups)
3129 (gnus-group-list-groups)
3130 (gnus-dribble-touch)))
3132 (defun gnus-group-sort-selected-flat (groups func reverse)
3133 (let (entries infos)
3134 ;; First find all the group entries for these groups.
3136 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3138 ;; Then sort the infos.
3142 (lambda (entry) (car entry))
3143 (setq entries (nreverse entries)))
3146 (setq infos (nreverse infos)))
3147 ;; Go through all the infos and replace the old entries
3148 ;; with the new infos.
3150 (setcar (car entries) (pop infos))
3152 ;; Update the hashtable.
3153 (gnus-make-hashtable-from-newsrc-alist)))
3155 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3156 "Sort the group buffer alphabetically by group name.
3157 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3158 sort in reverse order."
3159 (interactive (gnus-interactive "P\ny"))
3160 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3162 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3163 "Sort the group buffer alphabetically by real group name.
3164 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3165 sort in reverse order."
3166 (interactive (gnus-interactive "P\ny"))
3167 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3169 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3170 "Sort the group buffer by number of unread articles.
3171 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3172 sort in reverse order."
3173 (interactive (gnus-interactive "P\ny"))
3174 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3176 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3177 "Sort the group buffer by group level.
3178 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3179 sort in reverse order."
3180 (interactive (gnus-interactive "P\ny"))
3181 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3183 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3184 "Sort the group buffer by group score.
3185 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3186 sort in reverse order."
3187 (interactive (gnus-interactive "P\ny"))
3188 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3190 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3191 "Sort the group buffer by group rank.
3192 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3193 sort in reverse order."
3194 (interactive (gnus-interactive "P\ny"))
3195 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3197 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3198 "Sort the group buffer alphabetically by back end name.
3199 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3200 sort in reverse order."
3201 (interactive (gnus-interactive "P\ny"))
3202 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3204 ;;; Sorting predicates.
3206 (defun gnus-group-sort-by-alphabet (info1 info2)
3207 "Sort alphabetically."
3208 (string< (gnus-info-group info1) (gnus-info-group info2)))
3210 (defun gnus-group-sort-by-real-name (info1 info2)
3211 "Sort alphabetically on real (unprefixed) names."
3212 (string< (gnus-group-real-name (gnus-info-group info1))
3213 (gnus-group-real-name (gnus-info-group info2))))
3215 (defun gnus-group-sort-by-unread (info1 info2)
3216 "Sort by number of unread articles."
3217 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3218 (n2 (gnus-group-unread (gnus-info-group info1))))
3219 (< (or (and (numberp n1) n1) 0)
3220 (or (and (numberp n2) n2) 0))))
3222 (defun gnus-group-sort-by-level (info1 info2)
3224 (< (gnus-info-level info1) (gnus-info-level info2)))
3226 (defun gnus-group-sort-by-method (info1 info2)
3227 "Sort alphabetically by back end name."
3228 (string< (car (gnus-find-method-for-group
3229 (gnus-info-group info1) info1))
3230 (car (gnus-find-method-for-group
3231 (gnus-info-group info2) info2))))
3233 (defun gnus-group-sort-by-server (info1 info2)
3234 "Sort alphabetically by server name."
3235 (string< (gnus-method-to-full-server-name
3236 (gnus-find-method-for-group
3237 (gnus-info-group info1) info1))
3238 (gnus-method-to-full-server-name
3239 (gnus-find-method-for-group
3240 (gnus-info-group info2) info2))))
3242 (defun gnus-group-sort-by-score (info1 info2)
3243 "Sort by group score."
3244 (> (gnus-info-score info1) (gnus-info-score info2)))
3246 (defun gnus-group-sort-by-rank (info1 info2)
3247 "Sort by level and score."
3248 (let ((level1 (gnus-info-level info1))
3249 (level2 (gnus-info-level info2)))
3250 (or (< level1 level2)
3251 (and (= level1 level2)
3252 (> (gnus-info-score info1) (gnus-info-score info2))))))
3256 (defun gnus-group-clear-data (&optional arg)
3257 "Clear all marks and read ranges from the current group.
3258 Obeys the process/prefix convention."
3260 (gnus-group-iterate arg
3263 (gnus-info-clear-data (setq info (gnus-get-info group)))
3264 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3265 (when (gnus-group-goto-group group)
3266 (gnus-group-update-group-line))))))
3268 (defun gnus-group-clear-data-on-native-groups ()
3269 "Clear all marks and read ranges from all native groups."
3271 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3272 (let ((alist (cdr gnus-newsrc-alist))
3274 (while (setq info (pop alist))
3275 (when (gnus-group-native-p (gnus-info-group info))
3276 (gnus-info-clear-data info)))
3277 (gnus-get-unread-articles)
3278 (gnus-dribble-touch)
3279 (when (gnus-y-or-n-p
3280 "Move the cache away to avoid problems in the future? ")
3281 (call-interactively 'gnus-cache-move-cache)))))
3283 (defun gnus-info-clear-data (info)
3284 "Clear all marks and read ranges from INFO."
3285 (let ((group (gnus-info-group info))
3287 (dolist (el (gnus-info-marks info))
3288 (push `(,(cdr el) add (,(car el))) action))
3289 (push `(,(gnus-info-read info) add (read)) action)
3292 (gnus-request-set-mark ,group ',action)
3293 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3294 (gnus-info-set-read ',info ',(gnus-info-read info))
3295 (when (gnus-group-goto-group ,group)
3296 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3297 (gnus-group-update-group-line))))
3298 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3300 (gnus-request-set-mark group action)
3301 (gnus-info-set-read info nil)
3302 (when (gnus-info-marks info)
3303 (gnus-info-set-marks info nil))))
3305 ;; Group catching up.
3307 (defun gnus-group-catchup-current (&optional n all)
3308 "Mark all unread articles in the current newsgroup as read.
3309 If prefix argument N is numeric, the next N newsgroups will be
3310 caught up. If ALL is non-nil, marked articles will also be marked as
3311 read. Cross references (Xref: header) of articles are ignored.
3312 The number of newsgroups that this function was unable to catch
3315 (let ((groups (gnus-group-process-prefix n))
3318 (unless groups (error "No groups selected"))
3320 (or (not gnus-interactive-catchup) ;Without confirmation?
3325 "Do you really want to mark all articles in %s as read? "
3326 "Mark all unread articles in %s as read? ")
3327 (if (= (length groups) 1)
3328 (gnus-group-decoded-name (car groups))
3329 (format "these %d groups" (length groups)))))))
3331 (while (setq group (pop groups))
3332 (gnus-group-remove-mark group)
3333 ;; Virtual groups have to be given special treatment.
3334 (let ((method (gnus-find-method-for-group group)))
3335 (when (eq 'nnvirtual (car method))
3336 (nnvirtual-catchup-group
3337 (gnus-group-real-name group) (nth 1 method) all)))
3338 (if (>= (gnus-group-level group) gnus-level-zombie)
3339 (gnus-message 2 "Dead groups can't be caught up")
3341 (gnus-group-goto-group group)
3342 (gnus-group-catchup group all))
3343 (gnus-group-update-group-line)
3344 (setq ret (1+ ret)))))
3345 (gnus-group-next-unread-group 1)
3348 (defun gnus-group-catchup-current-all (&optional n)
3349 "Mark all articles in current newsgroup as read.
3350 Cross references (Xref: header) of articles are ignored."
3352 (gnus-group-catchup-current n 'all))
3354 (defun gnus-group-catchup (group &optional all)
3355 "Mark all articles in GROUP as read.
3356 If ALL is non-nil, all articles are marked as read.
3357 The return value is the number of articles that were marked as read,
3358 or nil if no action could be taken."
3359 (let* ((entry (gnus-group-entry group))
3361 (marks (gnus-info-marks (nth 2 entry)))
3362 (unread (gnus-sequence-of-unread-articles group)))
3363 ;; Remove entries for this group.
3364 (nnmail-purge-split-history (gnus-group-real-name group))
3365 ;; Do the updating only if the newsgroup isn't killed.
3366 (if (not (numberp (car entry)))
3367 (gnus-message 1 "Can't catch up %s; non-active group" group)
3368 (gnus-update-read-articles group nil)
3370 ;; Nix out the lists of marks and dormants.
3371 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3373 (list (cdr (assq 'dormant marks))
3375 (setq unread (gnus-range-add (gnus-range-add
3376 unread (cdr (assq 'dormant marks)))
3377 (cdr (assq 'tick marks))))
3378 (gnus-add-marked-articles group 'tick nil nil 'force)
3379 (gnus-add-marked-articles group 'dormant nil nil 'force))
3380 ;; Do auto-expirable marks if that's required.
3381 (when (gnus-group-auto-expirable-p group)
3382 (gnus-range-map (lambda (article)
3383 (gnus-add-marked-articles group 'expire (list article))
3384 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3386 (let ((gnus-newsgroup-name group))
3387 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3390 (defun gnus-group-expire-articles (&optional n)
3391 "Expire all expirable articles in the current newsgroup.
3392 Uses the process/prefix convention."
3394 (let ((groups (gnus-group-process-prefix n))
3397 (error "No groups to expire"))
3398 (while (setq group (pop groups))
3399 (gnus-group-remove-mark group)
3400 (gnus-group-expire-articles-1 group)
3401 (gnus-dribble-touch)
3402 (gnus-group-position-point))))
3404 (defun gnus-group-expire-articles-1 (group)
3405 (when (gnus-check-backend-function 'request-expire-articles group)
3406 (gnus-message 6 "Expiring articles in %s..."
3407 (gnus-group-decoded-name group))
3408 (let* ((info (gnus-get-info group))
3409 (expirable (if (gnus-group-total-expirable-p group)
3410 (cons nil (gnus-list-of-read-articles group))
3411 (assq 'expire (gnus-info-marks info))))
3412 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3413 (nnmail-expiry-target
3414 (or (gnus-group-find-parameter group 'expiry-target)
3415 nnmail-expiry-target)))
3417 (gnus-check-group group)
3420 (gnus-compress-sequence
3422 ;; We set the expiry variables to the group
3424 (let ((nnmail-expiry-wait-function nil)
3425 (nnmail-expiry-wait expiry-wait))
3426 (gnus-request-expire-articles
3427 (gnus-uncompress-sequence (cdr expirable)) group))
3428 ;; Just expire using the normal expiry values.
3429 (gnus-request-expire-articles
3430 (gnus-uncompress-sequence (cdr expirable)) group))))
3431 (gnus-close-group group))
3432 (gnus-message 6 "Expiring articles in %s...done"
3433 (gnus-group-decoded-name group))
3434 ;; Return the list of un-expired articles.
3437 (defun gnus-group-expire-all-groups ()
3438 "Expire all expirable articles in all newsgroups."
3441 (gnus-message 5 "Expiring...")
3442 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3443 (cdr gnus-newsrc-alist))))
3444 (gnus-group-expire-articles nil)))
3445 (gnus-group-position-point)
3446 (gnus-message 5 "Expiring...done"))
3448 (defun gnus-group-set-current-level (n level)
3449 "Set the level of the next N groups to LEVEL."
3454 (unless (gnus-group-process-prefix current-prefix-arg)
3455 (error "No group on the current line"))
3457 (let ((s (read-string
3458 (format "Level (default %s): "
3459 (or (gnus-group-group-level)
3460 gnus-level-default-subscribed)))))
3461 (if (string-match "^\\s-*$" s)
3462 (int-to-string (or (gnus-group-group-level)
3463 gnus-level-default-subscribed))
3465 (unless (and (>= level 1) (<= level gnus-level-killed))
3466 (error "Invalid level: %d" level))
3467 (dolist (group (gnus-group-process-prefix n))
3468 (gnus-group-remove-mark group)
3469 (gnus-message 6 "Changed level of %s from %d to %d"
3470 (gnus-group-decoded-name group)
3471 (or (gnus-group-group-level) gnus-level-killed)
3473 (gnus-group-change-level
3474 group level (or (gnus-group-group-level) gnus-level-killed))
3475 (gnus-group-update-group-line))
3476 (gnus-group-position-point))
3478 (defun gnus-group-unsubscribe (&optional n)
3479 "Unsubscribe the current group."
3481 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3483 (defun gnus-group-subscribe (&optional n)
3484 "Subscribe the current group."
3486 (gnus-group-unsubscribe-current-group n 'subscribe))
3488 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3489 "Toggle subscription of the current group.
3490 If given numerical prefix, toggle the N next groups."
3492 (dolist (group (gnus-group-process-prefix n))
3493 (gnus-group-remove-mark group)
3494 (gnus-group-unsubscribe-group
3497 ((eq do-sub 'unsubscribe)
3498 gnus-level-default-unsubscribed)
3499 ((eq do-sub 'subscribe)
3500 gnus-level-default-subscribed)
3501 ((<= (gnus-group-group-level) gnus-level-subscribed)
3502 gnus-level-default-unsubscribed)
3504 gnus-level-default-subscribed))
3506 (gnus-group-update-group-line))
3507 (gnus-group-next-group 1))
3509 (defun gnus-group-unsubscribe-group (group &optional level silent)
3510 "Toggle subscription to GROUP.
3511 Killed newsgroups are subscribed. If SILENT, don't try to update the
3514 (list (gnus-group-completing-read-group-name
3515 "Group: " gnus-active-hashtb nil
3516 (gnus-read-active-file-p)
3518 'gnus-group-history)))
3519 (let ((newsrc (gnus-group-entry group)))
3521 ((string-match "^[ \t]*$" group)
3522 (error "Empty group name"))
3524 ;; Toggle subscription flag.
3525 (gnus-group-change-level
3526 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3527 gnus-level-subscribed)
3528 (1+ gnus-level-subscribed)
3529 gnus-level-default-subscribed)))
3531 (gnus-group-update-group group)))
3532 ((and (stringp group)
3533 (or (not (gnus-read-active-file-p))
3534 (gnus-active group)))
3535 ;; Add new newsgroup.
3536 (gnus-group-change-level
3538 (if level level gnus-level-default-subscribed)
3539 (or (and (member group gnus-zombie-list)
3542 (when (gnus-group-group-name)
3543 (gnus-group-entry (gnus-group-group-name))))
3545 (gnus-group-update-group group)))
3546 (t (error "No such newsgroup: %s" group)))
3547 (gnus-group-position-point)))
3549 (defun gnus-group-transpose-groups (n)
3550 "Move the current newsgroup up N places.
3551 If given a negative prefix, move down instead. The difference between
3552 N and the number of steps taken is returned."
3554 (unless (gnus-group-group-name)
3555 (error "No group on current line"))
3556 (gnus-group-kill-group 1)
3558 (forward-line (- n))
3559 (gnus-group-yank-group)
3560 (gnus-group-position-point)))
3562 (defun gnus-group-kill-all-zombies (&optional dummy)
3563 "Kill all zombie newsgroups.
3564 The optional DUMMY should always be nil."
3565 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3567 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3568 (setq gnus-zombie-list nil)
3569 (gnus-dribble-touch)
3570 (gnus-group-list-groups)))
3572 (defun gnus-group-kill-region (begin end)
3573 "Kill newsgroups in current region (excluding current point).
3574 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3587 (beginning-of-line) ;Important when LINES < 1
3588 (gnus-group-kill-group lines)))
3590 (defun gnus-group-kill-group (&optional n discard)
3591 "Kill the next N groups.
3592 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3593 However, only groups that were alive can be yanked; already killed
3594 groups or zombie groups can't be yanked.
3595 The return value is the name of the group that was killed, or a list
3598 (let ((buffer-read-only nil)
3599 (groups (gnus-group-process-prefix n))
3600 group entry level out)
3601 (if (< (length groups) 10)
3602 ;; This is faster when there are few groups.
3604 (push (setq group (pop groups)) out)
3605 (gnus-group-remove-mark group)
3606 (setq level (gnus-group-group-level))
3608 (when (and (not discard)
3609 (setq entry (gnus-group-entry group)))
3612 (gnus-group-goto-group ,(gnus-group-group-name))
3613 (gnus-group-yank-group)))
3614 (push (cons (car entry) (nth 2 entry))
3615 gnus-list-of-killed-groups))
3616 (gnus-group-change-level
3617 (if entry entry group) gnus-level-killed (if entry nil level))
3618 (message "Killed group %s" (gnus-group-decoded-name group)))
3619 ;; If there are lots and lots of groups to be killed, we use
3620 ;; this thing instead.
3621 (dolist (group (nreverse groups))
3622 (gnus-group-remove-mark group)
3624 (push group gnus-killed-list)
3625 (setq gnus-newsrc-alist
3626 (delq (assoc group gnus-newsrc-alist)
3628 (when gnus-group-change-level-function
3629 (funcall gnus-group-change-level-function
3630 group gnus-level-killed 3))
3632 ((setq entry (gnus-group-entry group))
3633 (push (cons (car entry) (nth 2 entry))
3634 gnus-list-of-killed-groups)
3635 (setcdr (cdr entry) (cdddr entry)))
3636 ((member group gnus-zombie-list)
3637 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3638 ;; There may be more than one instance displayed.
3639 (while (gnus-group-goto-group group)
3640 (gnus-delete-line)))
3641 (gnus-make-hashtable-from-newsrc-alist))
3643 (gnus-group-position-point)
3644 (if (< (length out) 2) (car out) (nreverse out))))
3646 (defun gnus-group-yank-group (&optional arg)
3647 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3648 The numeric ARG specifies how many newsgroups are to be yanked. The
3649 name of the newsgroup yanked is returned, or (if several groups are
3650 yanked) a list of yanked groups is returned."
3652 (setq arg (or arg 1))
3653 (let (info group prev out)
3654 (while (>= (decf arg) 0)
3655 (when (not (setq info (pop gnus-list-of-killed-groups)))
3656 (error "No more newsgroups to yank"))
3657 (push (setq group (nth 1 info)) out)
3658 ;; Find which newsgroup to insert this one before - search
3659 ;; backward until something suitable is found. If there are no
3660 ;; other newsgroups in this buffer, just make this newsgroup the
3662 (setq prev (gnus-group-group-name))
3663 (gnus-group-change-level
3664 info (gnus-info-level (cdr info)) gnus-level-killed
3665 (and prev (gnus-group-entry prev))
3667 (gnus-group-insert-group-line-info group)
3669 `(when (gnus-group-goto-group ,group)
3670 (gnus-group-kill-group 1))))
3672 (gnus-group-position-point)
3673 (if (< (length out) 2) (car out) (nreverse out))))
3675 (defun gnus-group-kill-level (level)
3676 "Kill all groups that is on a certain LEVEL."
3677 (interactive "nKill all groups on level: ")
3679 ((= level gnus-level-zombie)
3680 (setq gnus-killed-list
3681 (nconc gnus-zombie-list gnus-killed-list))
3682 (setq gnus-zombie-list nil))
3683 ((and (< level gnus-level-zombie)
3685 (or gnus-expert-user
3688 "Do you really want to kill all groups on level %d? "
3690 (let* ((prev gnus-newsrc-alist)
3693 (if (= (gnus-info-level (car alist)) level)
3695 (push (gnus-info-group (car alist)) gnus-killed-list)
3696 (setcdr prev (cdr alist)))
3698 (setq alist (cdr alist)))
3699 (gnus-make-hashtable-from-newsrc-alist)
3700 (gnus-group-list-groups)))
3702 (error "Can't kill; invalid level: %d" level))))
3704 (defun gnus-group-list-all-groups (&optional arg)
3705 "List all newsgroups with level ARG or lower.
3706 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3707 unsubscribed groups."
3709 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3711 ;; Redefine this to list ALL killed groups if prefix arg used.
3712 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3713 (defun gnus-group-list-killed (&optional arg)
3714 "List all killed newsgroups in the group buffer.
3715 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3716 entail asking the server for the groups."
3718 ;; Find all possible killed newsgroups if arg.
3720 (gnus-get-killed-groups))
3721 (if (not gnus-killed-list)
3722 (gnus-message 6 "No killed groups")
3723 (let (gnus-group-list-mode)
3724 (funcall gnus-group-prepare-function
3725 gnus-level-killed t gnus-level-killed))
3726 (goto-char (point-min)))
3727 (gnus-group-position-point))
3729 (defun gnus-group-list-zombies ()
3730 "List all zombie newsgroups in the group buffer."
3732 (if (not gnus-zombie-list)
3733 (gnus-message 6 "No zombie groups")
3734 (let (gnus-group-list-mode)
3735 (funcall gnus-group-prepare-function
3736 gnus-level-zombie t gnus-level-zombie))
3737 (goto-char (point-min)))
3738 (gnus-group-position-point))
3740 (defun gnus-group-list-active ()
3741 "List all groups that are available from the server(s)."
3743 ;; First we make sure that we have really read the active file.
3744 (unless (gnus-read-active-file-p)
3745 (let ((gnus-read-active-file t)
3746 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3747 (gnus-read-active-file)))
3748 ;; Find all groups and sort them.
3756 (push (symbol-name sym) list)))
3760 (buffer-read-only nil)
3764 (setq group (pop groups))
3765 (gnus-add-text-properties
3766 (point) (prog1 (1+ (point))
3768 (gnus-group-decoded-name group)
3770 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3772 'gnus-level (inline (gnus-group-level group)))))
3773 (goto-char (point-min))))
3775 (defun gnus-activate-all-groups (level)
3776 "Activate absolutely all groups."
3777 (interactive (list gnus-level-unsubscribed))
3778 (let ((gnus-activate-level level)
3779 (gnus-activate-foreign-newsgroups level))
3780 (gnus-group-get-new-news)))
3782 (defun gnus-group-get-new-news (&optional arg)
3783 "Get newly arrived articles.
3784 If ARG is a number, it specifies which levels you are interested in
3785 re-scanning. If ARG is non-nil and not a number, this will force
3786 \"hard\" re-reading of the active files from all servers."
3789 (let ((gnus-inhibit-demon t)
3790 ;; Binding this variable will inhibit multiple fetchings
3791 ;; of the same mail source.
3792 (nnmail-fetched-sources (list t)))
3793 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3794 (gnus-run-hooks 'gnus-get-new-news-hook)
3796 ;; Read any slave files.
3798 (gnus-master-read-slave-newsrc))
3800 ;; We might read in new NoCeM messages here.
3801 (when (and gnus-use-nocem
3803 (gnus-nocem-scan-groups))
3804 ;; If ARG is not a number, then we read the active file.
3805 (when (and arg (not (numberp arg)))
3806 (let ((gnus-read-active-file t))
3807 (gnus-read-active-file))
3810 ;; If the user wants it, we scan for new groups.
3811 (when (eq gnus-check-new-newsgroups 'always)
3812 (gnus-find-new-newsgroups)))
3814 (setq arg (gnus-group-default-level arg t))
3815 (if (and gnus-read-active-file (not arg))
3817 (gnus-read-active-file)
3818 (gnus-get-unread-articles arg))
3819 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3820 (gnus-get-unread-articles arg)))
3821 (gnus-check-reasonable-setup)
3822 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3823 (gnus-group-list-groups (and (numberp arg)
3824 (max (car gnus-group-list-mode) arg))))
3826 (when (and gnus-agent (not (interactive-p)))
3827 (gnus-agent-toggle-plugged gnus-plugged)))
3829 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3830 "Check for newly arrived news in the current group (and the N-1 next groups).
3831 The difference between N and the number of newsgroup checked is returned.
3832 If N is negative, this group and the N-1 previous groups will be checked.
3833 If DONT-SCAN is non-nil, scan non-activated groups as well."
3835 (let* ((groups (gnus-group-process-prefix n))
3836 (ret (if (numberp n) (- n (length groups)) 0))
3840 (gnus-inhibit-demon t)
3841 ;; Binding this variable will inhibit multiple fetchings
3842 ;; of the same mail source.
3843 (nnmail-fetched-sources (list t)))
3844 (gnus-run-hooks 'gnus-get-new-news-hook)
3845 (while (setq group (pop groups))
3846 (gnus-group-remove-mark group)
3847 ;; Bypass any previous denials from the server.
3848 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3849 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3850 (let ((info (gnus-get-info group))
3851 (active (gnus-active group)))
3853 (gnus-request-update-info info method))
3854 (gnus-get-unread-articles-in-group info active)
3855 (unless (gnus-virtual-group-p group)
3856 (gnus-close-group group))
3858 (gnus-agent-save-group-info
3859 method (gnus-group-real-name group) active))
3860 (gnus-group-update-group group))
3861 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3863 (gnus-error 3 "Server denied access")
3864 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3867 (when gnus-goto-next-group-when-activating
3868 (gnus-group-next-unread-group 1 t))
3869 (gnus-summary-position-point)
3872 (defun gnus-group-fetch-faq (group &optional faq-dir)
3873 "Fetch the FAQ for the current group.
3874 If given a prefix argument, prompt for the FAQ dir
3878 (gnus-group-group-name)
3879 (when current-prefix-arg
3881 "FAQ dir: " (and (listp gnus-group-faq-directory)
3883 gnus-group-faq-directory))))))
3885 (error "No group name given"))
3886 (let ((dirs (or faq-dir gnus-group-faq-directory))
3888 (unless (listp dirs)
3889 (setq dirs (list dirs)))
3890 (while (and (not found)
3891 (setq dir (pop dirs)))
3892 (let ((name (gnus-group-real-name group)))
3893 (setq file (expand-file-name name dir)))
3894 (if (not (file-exists-p file))
3895 (gnus-message 1 "No such file: %s" file)
3896 (let ((enable-local-variables nil))
3900 (defun gnus-group-fetch-charter (group)
3901 "Fetch the charter for the current group.
3902 If given a prefix argument, prompt for a group."
3904 (list (or (when current-prefix-arg
3905 (completing-read "Group: " gnus-active-hashtb))
3906 (gnus-group-group-name)
3907 gnus-newsgroup-name)))
3909 (error "No group name given"))
3911 (condition-case nil (require 'url-http) (error nil))
3912 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3914 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3915 (setq hierarchy (match-string 1 name))
3916 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3917 (if (fboundp 'url-http-file-exists-p)
3918 (url-http-file-exists-p (eval url))
3920 (browse-url (eval url))
3921 (setq url (concat "http://" hierarchy
3922 ".news-admin.org/charters/" name))
3923 (if (and (fboundp 'url-http-file-exists-p)
3924 (url-http-file-exists-p url))
3926 (gnus-group-fetch-control group))))))
3928 (defun gnus-group-fetch-control (group)
3929 "Fetch the archived control messages for the current group.
3930 If given a prefix argument, prompt for a group."
3932 (list (or (when current-prefix-arg
3933 (completing-read "Group: " gnus-active-hashtb))
3934 (gnus-group-group-name)
3935 gnus-newsgroup-name)))
3937 (error "No group name given"))
3938 (let ((name (gnus-group-real-name group))
3940 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3941 (setq hierarchy (match-string 1 name))
3942 (if gnus-group-fetch-control-use-browse-url
3943 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3944 hierarchy "/" name ".gz"))
3945 (let ((enable-local-variables nil))
3946 (gnus-group-read-ephemeral-group
3948 `(nndoc ,group (nndoc-address
3949 ,(find-file-noselect
3950 (concat "/ftp@ftp.isc.org:/usenet/control/"
3951 hierarchy "/" name ".gz")))
3952 (nndoc-article-type mbox)) t nil nil))))))
3954 (defun gnus-group-describe-group (force &optional group)
3955 "Display a description of the current newsgroup."
3956 (interactive (list current-prefix-arg (gnus-group-group-name)))
3957 (let* ((method (gnus-find-method-for-group group))
3958 (mname (gnus-group-prefixed-name "" method))
3961 gnus-description-hashtb)
3962 (gnus-sethash mname nil gnus-description-hashtb))
3964 (error "No group name given"))
3965 (when (or (and gnus-description-hashtb
3966 ;; We check whether this group's method has been
3967 ;; queried for a description file.
3968 (gnus-gethash mname gnus-description-hashtb))
3969 (setq desc (gnus-group-get-description group))
3970 (gnus-read-descriptions-file method))
3972 (or desc (gnus-gethash group gnus-description-hashtb)
3973 "No description available")))))
3975 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3976 (defun gnus-group-describe-all-groups (&optional force)
3977 "Pop up a buffer with descriptions of all newsgroups."
3980 (setq gnus-description-hashtb nil))
3981 (when (not (or gnus-description-hashtb
3982 (gnus-read-all-descriptions-files)))
3983 (error "Couldn't request descriptions file"))
3984 (let ((buffer-read-only nil)
3990 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3991 (insert (format " *: %-20s %s\n"
3992 (gnus-group-name-decode
3993 (symbol-name group) charset)
3994 (gnus-group-name-decode
3995 (symbol-value group) charset))))
3996 (gnus-add-text-properties
3997 b (1+ b) (list 'gnus-group group
3998 'gnus-unread t 'gnus-marked nil
3999 'gnus-level (1+ gnus-level-subscribed))))
4000 gnus-description-hashtb)
4001 (goto-char (point-min))
4002 (gnus-group-position-point)))
4004 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4005 (defun gnus-group-apropos (regexp &optional search-description)
4006 "List all newsgroups that have names that match a regexp."
4007 (interactive "sGnus apropos (regexp): ")
4009 (obuf (current-buffer))
4011 ;; Go through all newsgroups that are known to Gnus.
4014 (and (symbol-name group)
4015 (string-match regexp (symbol-name group))
4016 (symbol-value group)
4017 (push (symbol-name group) groups)))
4019 ;; Also go through all descriptions that are known to Gnus.
4020 (when search-description
4023 (and (string-match regexp (symbol-value group))
4024 (push (symbol-name group) groups)))
4025 gnus-description-hashtb))
4027 (gnus-message 3 "No groups matched \"%s\"." regexp)
4028 ;; Print out all the groups.
4030 (pop-to-buffer "*Gnus Help*")
4031 (buffer-disable-undo)
4033 (setq groups (sort groups 'string<))
4035 ;; Groups may be entered twice into the list of groups.
4036 (when (not (string= (car groups) prev))
4037 (setq prev (car groups))
4038 (let ((charset (gnus-group-name-charset nil prev)))
4039 (insert (gnus-group-name-decode prev charset) "\n")
4040 (when (and gnus-description-hashtb
4041 (setq des (gnus-gethash (car groups)
4042 gnus-description-hashtb)))
4043 (insert " " (gnus-group-name-decode des charset) "\n"))))
4044 (setq groups (cdr groups)))
4045 (goto-char (point-min))))
4046 (pop-to-buffer obuf)))
4048 (defun gnus-group-description-apropos (regexp)
4049 "List all newsgroups that have names or descriptions that match REGEXP."
4050 (interactive "sGnus description apropos (regexp): ")
4051 (when (not (or gnus-description-hashtb
4052 (gnus-read-all-descriptions-files)))
4053 (error "Couldn't request descriptions file"))
4054 (gnus-group-apropos regexp t))
4056 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4057 (defun gnus-group-list-matching (level regexp &optional all lowest)
4058 "List all groups with unread articles that match REGEXP.
4059 If the prefix LEVEL is non-nil, it should be a number that says which
4060 level to cut off listing groups.
4061 If ALL, also list groups with no unread articles.
4062 If LOWEST, don't list groups with level lower than LOWEST.
4064 This command may read the active file."
4065 (interactive "P\nsList newsgroups matching: ")
4066 ;; First make sure active file has been read.
4068 (> (prefix-numeric-value level) gnus-level-killed))
4069 (gnus-get-killed-groups))
4070 (funcall gnus-group-prepare-function
4071 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4072 (goto-char (point-min))
4073 (gnus-group-position-point))
4075 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4076 "List all groups that match REGEXP.
4077 If the prefix LEVEL is non-nil, it should be a number that says which
4078 level to cut off listing groups.
4079 If LOWEST, don't list groups with level lower than LOWEST."
4080 (interactive "P\nsList newsgroups matching: ")
4082 (setq level (prefix-numeric-value level)))
4083 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4085 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4086 (defun gnus-group-save-newsrc (&optional force)
4087 "Save the Gnus startup files.
4088 If FORCE, force saving whether it is necessary or not."
4090 (gnus-save-newsrc-file force))
4092 (defun gnus-group-restart (&optional arg)
4093 "Force Gnus to read the .newsrc file."
4095 (when (gnus-yes-or-no-p
4096 (format "Are you sure you want to restart Gnus? "))
4097 (gnus-save-newsrc-file)
4101 (defun gnus-group-read-init-file ()
4102 "Read the Gnus elisp init file."
4104 (gnus-read-init-file)
4105 (gnus-message 5 "Read %s" gnus-init-file))
4107 (defun gnus-group-check-bogus-groups (&optional silent)
4108 "Check bogus newsgroups.
4109 If given a prefix, don't ask for confirmation before removing a bogus
4112 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4113 (gnus-group-list-groups))
4115 (defun gnus-group-find-new-groups (&optional arg)
4116 "Search for new groups and add them.
4117 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4118 With 1 C-u, use the `ask-server' method to query the server for new
4120 With 2 C-u's, use most complete method possible to query the server
4121 for new groups, and subscribe the new groups as zombies."
4123 (gnus-find-new-newsgroups (or arg 1))
4124 (gnus-group-list-groups))
4126 (defun gnus-group-edit-global-kill (&optional article group)
4127 "Edit the global kill file.
4128 If GROUP, edit that local kill file instead."
4130 (setq gnus-current-kill-article article)
4131 (gnus-kill-file-edit-file group)
4134 (substitute-command-keys
4135 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4136 (if group "local" "global")))))
4138 (defun gnus-group-edit-local-kill (article group)
4139 "Edit a local kill file."
4140 (interactive (list nil (gnus-group-group-name)))
4141 (gnus-group-edit-global-kill article group))
4143 (defun gnus-group-force-update ()
4144 "Update `.newsrc' file."
4146 (gnus-save-newsrc-file))
4148 (defvar gnus-backlog-articles)
4150 (defun gnus-group-suspend ()
4151 "Suspend the current Gnus session.
4152 In fact, cleanup buffers except for group mode buffer.
4153 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4155 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4156 (gnus-offer-save-summaries)
4157 ;; Kill Gnus buffers except for group mode buffer.
4158 (let ((group-buf (get-buffer gnus-group-buffer)))
4159 (mapcar (lambda (buf)
4160 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4161 (with-current-buffer buf
4162 (eq major-mode 'message-mode)))
4163 (gnus-kill-buffer buf)))
4165 (setq gnus-backlog-articles nil)
4166 (gnus-kill-gnus-frames)
4168 (bury-buffer group-buf)
4169 (delete-windows-on group-buf t))))
4171 (defun gnus-group-clear-dribble ()
4172 "Clear all information from the dribble buffer."
4174 (gnus-dribble-clear)
4175 (gnus-message 7 "Cleared dribble buffer"))
4177 (defun gnus-group-exit ()
4178 "Quit reading news after updating .newsrc.eld and .newsrc.
4179 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4182 (or noninteractive ;For gnus-batch-kill
4183 (not gnus-interactive-exit) ;Without confirmation
4185 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4186 (gnus-run-hooks 'gnus-exit-gnus-hook)
4187 ;; Offer to save data from non-quitted summary buffers.
4188 (gnus-offer-save-summaries)
4189 ;; Save the newsrc file(s).
4190 (gnus-save-newsrc-file)
4192 (gnus-close-backends)
4193 ;; Reset everything.
4195 ;; Allow the user to do things after cleaning up.
4196 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4198 (defun gnus-group-quit ()
4199 "Quit reading news without updating .newsrc.eld or .newsrc.
4200 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4202 (when (or noninteractive ;For gnus-batch-kill
4203 (zerop (buffer-size))
4204 (not (gnus-server-opened gnus-select-method))
4206 (not gnus-current-startup-file)
4208 (format "Quit reading news without saving %s? "
4209 (file-name-nondirectory gnus-current-startup-file))))
4210 (gnus-run-hooks 'gnus-exit-gnus-hook)
4211 (gnus-configure-windows 'group t)
4212 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4213 (not (zerop (save-excursion
4214 (set-buffer gnus-dribble-buffer)
4217 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4219 (gnus-close-backends)
4221 (gnus-kill-buffer gnus-group-buffer)
4222 ;; Allow the user to do things after cleaning up.
4223 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4225 (defun gnus-group-describe-briefly ()
4226 "Give a one line description of the group mode commands."
4228 (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")))
4230 (defun gnus-group-browse-foreign-server (method)
4231 "Browse a foreign news server.
4232 If called interactively, this function will ask for a select method
4233 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4234 If not, METHOD should be a list where the first element is the method
4235 and the second element is the address."
4237 (list (let ((how (completing-read
4239 (append gnus-valid-select-methods gnus-server-alist)
4240 nil t (cons "nntp" 0) 'gnus-method-history)))
4241 ;; We either got a back end name or a virtual server name.
4242 ;; If the first, we also need an address.
4243 (if (assoc how gnus-valid-select-methods)
4245 ;; Suggested by mapjph@bath.ac.uk.
4248 (mapcar 'list gnus-secondary-servers)))
4249 ;; We got a server name.
4251 (gnus-browse-foreign-server method))
4253 (defun gnus-group-set-info (info &optional method-only-group part)
4254 (when (or info part)
4255 (let* ((entry (gnus-group-entry
4256 (or method-only-group (gnus-info-group info))))
4258 (info (if method-only-group (nth 2 entry) info))
4260 (when method-only-group
4262 (error "Trying to change non-existent group %s" method-only-group))
4263 ;; We have received parts of the actual group info - either the
4264 ;; select method or the group parameters. We first check
4265 ;; whether we have to extend the info, and if so, do that.
4266 (let ((len (length info))
4267 (total (if (eq part 'method) 5 6)))
4269 (setcdr (nthcdr (1- len) info)
4270 (make-list (- total len) nil)))
4271 ;; Then we enter the new info.
4272 (setcar (nthcdr (1- total) info) part-info)))
4274 ;; This is a new group, so we just create it.
4276 (set-buffer gnus-group-buffer)
4277 (setq method (gnus-info-method info))
4278 (when (gnus-server-equal method "native")
4281 (set-buffer gnus-group-buffer)
4283 ;; It's a foreign group...
4284 (gnus-group-make-group
4285 (gnus-group-real-name (gnus-info-group info))
4286 (if (stringp method) method
4287 (prin1-to-string (car method)))
4289 (nth 1 (gnus-info-method info))))
4290 ;; It's a native group.
4291 (gnus-group-make-group (gnus-info-group info))))
4292 (gnus-message 6 "Note: New group created")
4294 (gnus-group-entry (gnus-group-prefixed-name
4295 (gnus-group-real-name (gnus-info-group info))
4296 (or (gnus-info-method info) gnus-select-method))))))
4297 ;; Whether it was a new group or not, we now have the entry, so we
4298 ;; can do the update.
4301 (setcar (nthcdr 2 entry) info)
4302 (when (and (not (eq (car entry) t))
4303 (gnus-active (gnus-info-group info)))
4304 (setcar entry (length
4305 (gnus-list-of-unread-articles (car info))))))
4306 (error "No such group: %s" (gnus-info-group info))))))
4308 (defun gnus-group-set-method-info (group select-method)
4309 (gnus-group-set-info select-method group 'method))
4311 (defun gnus-group-set-params-info (group params)
4312 (gnus-group-set-info params group 'params))
4314 (defun gnus-add-marked-articles (group type articles &optional info force)
4315 ;; Add ARTICLES of TYPE to the info of GROUP.
4316 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4317 ;; add, but replace marked articles of TYPE with ARTICLES.
4318 (let ((info (or info (gnus-get-info group)))
4321 (and (not (setq marked (nthcdr 3 info)))
4323 (setcdr (nthcdr 2 info)
4324 (list (list (cons type (gnus-compress-sequence
4326 (and (not (setq m (assq type (car marked))))
4329 (cons (cons type (gnus-compress-sequence articles t) )
4333 (setcar (nthcdr 3 info)
4334 (gnus-delete-alist type (car marked)))
4335 (setcdr m (gnus-compress-sequence articles t)))
4336 (setcdr m (gnus-compress-sequence
4337 (sort (nconc (gnus-uncompress-range (cdr m))
4338 (copy-sequence articles)) '<) t))))))
4340 (defun gnus-add-mark (group mark article)
4341 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4342 (let ((buffer (gnus-summary-buffer-name group)))
4343 (if (gnus-buffer-live-p buffer)
4345 (set-buffer (get-buffer buffer))
4346 (gnus-summary-add-mark article mark))
4347 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4351 ;;; Group timestamps
4354 (defun gnus-group-set-timestamp ()
4355 "Change the timestamp of the current group to the current time.
4356 This function can be used in hooks like `gnus-select-group-hook'
4357 or `gnus-group-catchup-group-hook'."
4358 (when gnus-newsgroup-name
4359 (let ((time (current-time)))
4360 (setcdr (cdr time) nil)
4361 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4363 (defsubst gnus-group-timestamp (group)
4364 "Return the timestamp for GROUP."
4365 (gnus-group-get-parameter group 'timestamp t))
4367 (defun gnus-group-timestamp-delta (group)
4368 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4369 (let* ((time (or (gnus-group-timestamp group)
4371 (delta (subtract-time (current-time) time)))
4372 (+ (* (nth 0 delta) 65536.0)
4375 (defun gnus-group-timestamp-string (group)
4376 "Return a string of the timestamp for GROUP."
4377 (let ((time (gnus-group-timestamp group)))
4380 (gnus-time-iso8601 time))))
4382 (defun gnus-group-list-cached (level &optional lowest)
4383 "List all groups with cached articles.
4384 If the prefix LEVEL is non-nil, it should be a number that says which
4385 level to cut off listing groups.
4386 If LOWEST, don't list groups with level lower than LOWEST.
4388 This command may read the active file."
4391 (setq level (prefix-numeric-value level)))
4392 (when (or (not level) (>= level gnus-level-zombie))
4394 (funcall gnus-group-prepare-function
4395 (or level gnus-level-subscribed)
4397 (let ((marks (gnus-info-marks info)))
4398 (assq 'cache marks)))
4401 (or (gnus-gethash group
4402 gnus-cache-active-hashtb)
4403 ;; Cache active file might use "."
4406 (mapconcat 'identity
4407 (split-string group ":")
4409 gnus-cache-active-hashtb))))
4410 (goto-char (point-min))
4411 (gnus-group-position-point))
4413 (defun gnus-group-list-dormant (level &optional lowest)
4414 "List all groups with dormant articles.
4415 If the prefix LEVEL is non-nil, it should be a number that says which
4416 level to cut off listing groups.
4417 If LOWEST, don't list groups with level lower than LOWEST.
4419 This command may read the active file."
4422 (setq level (prefix-numeric-value level)))
4423 (when (or (not level) (>= level gnus-level-zombie))
4425 (funcall gnus-group-prepare-function
4426 (or level gnus-level-subscribed)
4428 (let ((marks (gnus-info-marks info)))
4429 (assq 'dormant marks)))
4432 (goto-char (point-min))
4433 (gnus-group-position-point))
4435 (defun gnus-group-listed-groups ()
4436 "Return a list of listed groups."
4438 (goto-char (point-min))
4439 (while (setq point (text-property-not-all (point) (point-max)
4442 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4446 (defun gnus-group-list-plus (&optional args)
4447 "List groups plus the current selection."
4449 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4450 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4452 (push last-command-event unread-command-events)
4453 (if (featurep 'xemacs)
4454 (push (make-event 'key-press '(key ?A)) unread-command-events)
4455 (push ?A unread-command-events))
4456 (let (gnus-pick-mode keys)
4457 (setq keys (if (featurep 'xemacs)
4458 (events-to-keys (read-key-sequence nil))
4459 (read-key-sequence nil)))
4460 (setq func (lookup-key (current-local-map) keys)))
4464 (call-interactively func))))
4466 (defun gnus-group-list-flush (&optional args)
4467 "Flush groups from the current selection."
4469 (let ((gnus-group-list-option 'flush))
4470 (gnus-group-list-plus args)))
4472 (defun gnus-group-list-limit (&optional args)
4473 "List groups limited within the current selection."
4475 (let ((gnus-group-list-option 'limit))
4476 (gnus-group-list-plus args)))
4478 (defun gnus-group-mark-article-read (group article)
4479 "Mark ARTICLE read."
4480 (let ((buffer (gnus-summary-buffer-name group))
4481 (mark gnus-read-mark)
4483 (if (get-buffer buffer)
4484 (with-current-buffer buffer
4485 (setq active gnus-newsgroup-active)
4486 (gnus-activate-group group)
4487 (when gnus-newsgroup-prepared
4488 (when (and gnus-newsgroup-auto-expire
4489 (memq mark gnus-auto-expirable-marks))
4490 (setq mark gnus-expirable-mark))
4491 (setq mark (gnus-request-update-mark
4492 group article mark))
4493 (gnus-mark-article-as-read article mark)
4494 (setq gnus-newsgroup-active (gnus-active group))
4496 (setq n (1+ (cdr active)))
4497 (while (<= n (cdr gnus-newsgroup-active))
4498 (unless (eq n article)
4499 (push n gnus-newsgroup-unselected))
4501 (setq gnus-newsgroup-unselected
4502 (nreverse gnus-newsgroup-unselected)))))
4503 (gnus-activate-group group)
4504 (gnus-group-make-articles-read group (list article))
4505 (when (gnus-group-auto-expirable-p group)
4506 (gnus-add-marked-articles
4507 group 'expire (list article))))))
4511 ;;; Group compaction. -- dvl
4514 (defun gnus-group-compact-group (group)
4515 "Compact the current group.
4516 Compaction means removing gaps between article numbers. Hence, this
4517 operation is only meaningful for back ends using one file per article
4520 Note: currently only implemented in nnml."
4521 (interactive (list (gnus-group-group-name)))
4523 (error "No group to compact"))
4524 (unless (gnus-check-backend-function 'request-compact-group group)
4525 (error "This back end does not support group compaction"))
4526 (let ((group-decoded (gnus-group-decoded-name group)))
4528 Compacting group %s... (this may take a long time)"
4531 (if (not (gnus-request-compact-group group))
4532 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4533 (gnus-message 6 "Compacting group %s...done" group-decoded)
4535 ;; Invalidate the "original article" buffer which might be out of date.
4536 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4537 ;; #### will not happen very often, I think this is acceptable.
4538 (let ((original (get-buffer gnus-original-article-buffer)))
4539 (and original (gnus-kill-buffer original)))
4540 ;; Update the group line to reflect new information (art number etc).
4541 (gnus-group-update-group-line))))
4543 (provide 'gnus-group)
4545 ;;; gnus-group.el ends here