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 (or (not gnus-group-tool-bar-map) force)
1123 (let ((map (when (default-value 'tool-bar-mode)
1124 (let ((load-path (mm-image-load-path)))
1125 (gmm-tool-bar-from-list gnus-group-tool-bar
1126 gnus-group-tool-bar-zap-list
1127 'gnus-group-mode-map)))))
1129 (set (make-local-variable 'tool-bar-map) map))))
1130 gnus-group-tool-bar-map)
1132 (defun gnus-group-mode ()
1133 "Major mode for reading news.
1135 All normal editing commands are switched off.
1136 \\<gnus-group-mode-map>
1137 The group buffer lists (some of) the groups available. For instance,
1138 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1139 lists all zombie groups.
1141 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1142 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1144 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1146 The following commands are available:
1148 \\{gnus-group-mode-map}"
1150 (kill-all-local-variables)
1151 (when (gnus-visual-p 'group-menu 'menu)
1152 (gnus-group-make-menu-bar)
1153 (gnus-group-make-tool-bar))
1154 (gnus-simplify-mode-line)
1155 (setq major-mode 'gnus-group-mode)
1156 (setq mode-name "Group")
1157 (gnus-group-set-mode-line)
1158 (setq mode-line-process nil)
1159 (use-local-map gnus-group-mode-map)
1160 (buffer-disable-undo)
1161 (setq truncate-lines t)
1162 (setq buffer-read-only t
1163 show-trailing-whitespace nil)
1164 (gnus-set-default-directory)
1165 (gnus-update-format-specifications nil 'group 'group-mode)
1166 (gnus-update-group-mark-positions)
1171 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1173 (defun gnus-update-group-mark-positions ()
1175 (let ((gnus-process-mark ?\200)
1176 (gnus-group-update-hook nil)
1177 (gnus-group-marked '("dummy.group"))
1178 (gnus-active-hashtb (make-vector 10 0))
1180 (gnus-set-active "dummy.group" '(0 . 0))
1181 (gnus-set-work-buffer)
1182 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1183 (goto-char (point-min))
1184 (setq gnus-group-mark-positions
1185 (list (cons 'process (and (search-forward
1186 (string-as-multibyte "\200") nil t)
1187 (- (point) 2))))))))
1189 (defun gnus-mouse-pick-group (e)
1190 "Enter the group under the mouse pointer."
1193 (gnus-group-read-group nil))
1195 ;; Look at LEVEL and find out what the level is really supposed to be.
1196 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1197 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1198 (defun gnus-group-default-level (&optional level number-or-nil)
1200 (gnus-group-use-permanent-levels
1201 (or (setq gnus-group-use-permanent-levels
1202 (or level (if (numberp gnus-group-use-permanent-levels)
1203 gnus-group-use-permanent-levels
1204 (or gnus-group-default-list-level
1205 gnus-level-subscribed))))
1206 gnus-group-default-list-level gnus-level-subscribed))
1210 (or level gnus-group-default-list-level gnus-level-subscribed))))
1212 (defun gnus-group-setup-buffer ()
1213 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1214 (unless (eq major-mode 'gnus-group-mode)
1217 (gnus-carpal-setup-buffer 'group))))
1219 (defun gnus-group-name-charset (method group)
1221 (setq method (gnus-find-method-for-group group)))
1222 (let ((item (assoc method gnus-group-name-charset-method-alist))
1223 (alist gnus-group-name-charset-group-alist)
1227 (while (setq item (pop alist))
1228 (if (string-match (car item) group)
1230 result (cdr item))))
1233 (defun gnus-group-name-decode (string charset)
1234 ;; Fixme: Don't decode in unibyte mode.
1235 (if (and string charset (featurep 'mule))
1236 (decode-coding-string string charset)
1239 (defun gnus-group-decoded-name (string)
1240 (let ((charset (gnus-group-name-charset nil string)))
1241 (gnus-group-name-decode string charset)))
1243 (defun gnus-group-name-encode (string charset)
1244 (if (and string charset (featurep 'mule))
1245 (encode-coding-string string charset)
1248 (defun gnus-group-encoded-name (string)
1249 (let ((charset (gnus-group-name-charset nil string)))
1250 (gnus-group-name-encode string charset)))
1252 (defun gnus-group-completing-read-group-name
1253 (prompt table &optional predicate require-match initial-contents history)
1257 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1261 (dolist (entry (prog1
1264 (push (list (gnus-group-decoded-name (car entry))) table)))
1265 (gnus-group-encoded-name
1267 prompt table predicate
1272 (defun gnus-group-list-groups (&optional level unread lowest)
1273 "List newsgroups with level LEVEL or lower that have unread articles.
1274 Default is all subscribed groups.
1275 If argument UNREAD is non-nil, groups with no unread articles are also
1278 Also see the `gnus-group-use-permanent-levels' variable."
1280 (list (if current-prefix-arg
1281 (prefix-numeric-value current-prefix-arg)
1283 (gnus-group-default-level nil t)
1284 gnus-group-default-list-level
1285 gnus-level-subscribed))))
1287 (setq level (car gnus-group-list-mode)
1288 unread (cdr gnus-group-list-mode)))
1289 (setq level (gnus-group-default-level level))
1290 (gnus-group-setup-buffer)
1291 (gnus-update-format-specifications nil 'group 'group-mode)
1292 (let ((case-fold-search nil)
1293 (props (text-properties-at (point-at-bol)))
1294 (empty (= (point-min) (point-max)))
1295 (group (gnus-group-group-name))
1297 (set-buffer gnus-group-buffer)
1298 (setq number (funcall gnus-group-prepare-function level unread lowest))
1299 (when (or (and (numberp number)
1301 (zerop (buffer-size)))
1302 ;; No groups in the buffer.
1303 (gnus-message 5 gnus-no-groups-message))
1304 ;; We have some groups displayed.
1305 (goto-char (point-max))
1306 (when (or (not gnus-group-goto-next-group-function)
1307 (not (funcall gnus-group-goto-next-group-function
1311 (goto-char (point-min)))
1313 ;; Go to the first group with unread articles.
1314 (gnus-group-search-forward t))
1316 ;; Find the right group to put point on. If the current group
1317 ;; has disappeared in the new listing, try to find the next
1318 ;; one. If no next one can be found, just leave point at the
1319 ;; first newsgroup in the buffer.
1320 (when (not (gnus-goto-char
1322 (point-min) (point-max)
1323 'gnus-group (gnus-intern-safe
1324 group gnus-active-hashtb))))
1325 (let ((newsrc (cdddr (gnus-group-entry group))))
1327 (not (gnus-goto-char
1329 (point-min) (point-max) 'gnus-group
1331 (caar newsrc) gnus-active-hashtb)))))
1332 (setq newsrc (cdr newsrc)))
1334 (goto-char (point-max))
1335 (forward-line -1)))))))
1336 ;; Adjust cursor point.
1337 (gnus-group-position-point)))
1339 (defun gnus-group-list-level (level &optional all)
1340 "List groups on LEVEL.
1341 If ALL (the prefix), also list groups that have no unread articles."
1342 (interactive "nList groups on level: \nP")
1343 (gnus-group-list-groups level all level))
1345 (defun gnus-group-prepare-logic (group test)
1346 (or (and gnus-group-listed-groups
1347 (null gnus-group-list-option)
1348 (member group gnus-group-listed-groups))
1350 ((null gnus-group-listed-groups) test)
1351 ((null gnus-group-list-option) test)
1352 (t (and (member group gnus-group-listed-groups)
1353 (if (eq gnus-group-list-option 'flush)
1357 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1358 "List all newsgroups with unread articles of level LEVEL or lower.
1359 If PREDICATE is a function, list groups that the function returns non-nil;
1360 if it is t, list groups that have no unread articles.
1361 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1362 If REGEXP is a function, list dead groups that the function returns non-nil;
1363 if it is a string, only list groups matching REGEXP."
1364 (set-buffer gnus-group-buffer)
1365 (let ((buffer-read-only nil)
1366 (newsrc (cdr gnus-newsrc-alist))
1367 (lowest (or lowest 1))
1368 (not-in-list (and gnus-group-listed-groups
1369 (copy-sequence gnus-group-listed-groups)))
1370 info clevel unread group params)
1372 (when (or (< lowest gnus-level-zombie)
1373 gnus-group-listed-groups)
1374 ;; List living groups.
1376 (setq info (car newsrc)
1377 group (gnus-info-group info)
1378 params (gnus-info-params info)
1380 unread (gnus-group-unread group))
1382 (setq not-in-list (delete group not-in-list)))
1383 (when (gnus-group-prepare-logic
1385 (and unread ; This group might be unchecked
1386 (or (not (stringp regexp))
1387 (string-match regexp group))
1388 (<= (setq clevel (gnus-info-level info)) level)
1391 ((functionp predicate)
1392 (funcall predicate info))
1393 (predicate t) ; We list all groups?
1396 (if (eq unread t) ; Unactivated?
1397 gnus-group-list-inactive-groups
1398 ; We list unactivated
1400 ; We list groups with unread articles
1401 (and gnus-list-groups-with-ticked-articles
1402 (cdr (assq 'tick (gnus-info-marks info))))
1403 ; And groups with tickeds
1404 ;; Check for permanent visibility.
1405 (and gnus-permanently-visible-groups
1406 (string-match gnus-permanently-visible-groups
1408 (memq 'visible params)
1409 (cdr (assq 'visible params)))))))
1410 (gnus-group-insert-group-line
1411 group (gnus-info-level info)
1412 (gnus-info-marks info) unread (gnus-info-method info)))))
1414 ;; List dead groups.
1415 (when (or gnus-group-listed-groups
1416 (and (>= level gnus-level-zombie)
1417 (<= lowest gnus-level-zombie)))
1418 (gnus-group-prepare-flat-list-dead
1419 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1420 gnus-level-zombie ?Z
1423 (dolist (group gnus-zombie-list)
1424 (setq not-in-list (delete group not-in-list))))
1425 (when (or gnus-group-listed-groups
1426 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1427 (gnus-group-prepare-flat-list-dead
1430 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1431 gnus-level-killed ?K regexp))
1433 (gnus-group-set-mode-line)
1434 (setq gnus-group-list-mode (cons level predicate))
1435 (gnus-run-hooks 'gnus-group-prepare-hook)
1438 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1439 ;; List zombies and killed lists somewhat faster, which was
1440 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1441 ;; this by ignoring the group format specification altogether.
1443 (if (> (length groups) gnus-group-listing-limit)
1445 (setq group (pop groups))
1446 (when (gnus-group-prepare-logic
1449 (and (stringp regexp) (string-match regexp group))
1450 (and (functionp regexp) (funcall regexp group))))
1451 (gnus-add-text-properties
1452 (point) (prog1 (1+ (point))
1453 (insert " " mark " *: "
1454 (gnus-group-decoded-name group)
1456 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1458 'gnus-level level))))
1460 (setq group (pop groups))
1461 (when (gnus-group-prepare-logic
1464 (and (stringp regexp) (string-match regexp group))
1465 (and (functionp regexp) (funcall regexp group))))
1466 (gnus-group-insert-group-line
1468 (let ((active (gnus-active group)))
1470 (if (zerop (cdr active))
1472 (- (1+ (cdr active)) (car active)))
1474 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1476 (defun gnus-group-update-group-line ()
1477 "Update the current line in the group buffer."
1478 (let* ((buffer-read-only nil)
1479 (group (gnus-group-group-name))
1480 (entry (and group (gnus-group-entry group)))
1481 gnus-group-indentation)
1484 (not (gnus-ephemeral-group-p group))
1486 (concat "(gnus-group-set-info '"
1487 (gnus-prin1-to-string (nth 2 entry))
1489 (setq gnus-group-indentation (gnus-group-group-indentation))
1491 (gnus-group-insert-group-line-info group)
1493 (gnus-group-position-point))))
1495 (defun gnus-group-insert-group-line-info (group)
1496 "Insert GROUP on the current line."
1497 (let ((entry (gnus-group-entry group))
1498 (gnus-group-indentation (gnus-group-group-indentation))
1502 ;; (Un)subscribed group.
1503 (setq info (nth 2 entry))
1504 (gnus-group-insert-group-line
1505 group (gnus-info-level info) (gnus-info-marks info)
1506 (or (car entry) t) (gnus-info-method info)))
1507 ;; This group is dead.
1508 (gnus-group-insert-group-line
1510 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1512 (if (setq active (gnus-active group))
1513 (if (zerop (cdr active))
1515 (- (1+ (cdr active)) (car active)))
1517 (gnus-method-simplify (gnus-find-method-for-group group))))))
1519 (defun gnus-number-of-unseen-articles-in-group (group)
1520 (let* ((info (nth 2 (gnus-group-entry group)))
1521 (marked (gnus-info-marks info))
1522 (seen (cdr (assq 'seen marked)))
1523 (active (gnus-active group)))
1526 (length (gnus-uncompress-range
1527 (gnus-range-difference
1528 (gnus-range-difference (list active) (gnus-info-read info))
1531 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1532 gnus-tmp-marked number
1534 "Insert a group line in the group buffer."
1535 (let* ((gnus-tmp-method
1536 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1537 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1539 (gnus-tmp-active (gnus-active gnus-tmp-group))
1540 (gnus-tmp-number-total
1542 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1544 (gnus-tmp-number-of-unread
1545 (if (numberp number) (int-to-string (max 0 number))
1547 (gnus-tmp-number-of-read
1548 (if (numberp number)
1549 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1551 (gnus-tmp-subscribed
1552 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1553 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1554 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1556 (gnus-tmp-qualified-group
1557 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1558 group-name-charset))
1560 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1562 (gnus-tmp-newsgroup-description
1563 (if gnus-description-hashtb
1564 (or (gnus-group-name-decode
1565 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1566 group-name-charset) "")
1569 (if (and gnus-moderated-hashtb
1570 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1572 (gnus-tmp-moderated-string
1573 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1574 (gnus-tmp-group-icon "==&&==")
1575 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1576 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1577 (gnus-tmp-news-method-string
1579 (format "(%s:%s)" (car gnus-tmp-method)
1580 (cadr gnus-tmp-method)) ""))
1581 (gnus-tmp-marked-mark
1582 (if (and (numberp number)
1584 (cdr (assq 'tick gnus-tmp-marked)))
1586 (gnus-tmp-summary-live
1587 (if (and (not gnus-group-is-exiting-p)
1588 (gnus-buffer-live-p (gnus-summary-buffer-name
1591 (gnus-tmp-process-marked
1592 (if (member gnus-tmp-group gnus-group-marked)
1593 gnus-process-mark ? ))
1594 (buffer-read-only nil)
1595 header gnus-tmp-header) ; passed as parameter to user-funcs.
1597 (gnus-add-text-properties
1601 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1602 gnus-tmp-group group-name-charset)))
1603 (eval gnus-group-line-format-spec)))
1604 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1605 gnus-unread ,(if (numberp number)
1606 (string-to-number gnus-tmp-number-of-unread)
1608 gnus-marked ,gnus-tmp-marked-mark
1609 gnus-indentation ,gnus-group-indentation
1610 gnus-level ,gnus-tmp-level))
1612 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1613 (gnus-run-hooks 'gnus-group-update-hook))
1615 ;; Allow XEmacs to remove front-sticky text properties.
1616 (gnus-group-remove-excess-properties)))
1618 (defun gnus-group-highlight-line ()
1619 "Highlight the current line according to `gnus-group-highlight'."
1620 (let* ((list gnus-group-highlight)
1622 (end (point-at-eol))
1623 ;; now find out where the line starts and leave point there.
1624 (beg (progn (beginning-of-line) (point)))
1625 (group (gnus-group-group-name))
1626 (entry (gnus-group-entry group))
1627 (unread (if (numberp (car entry)) (car entry) 0))
1628 (active (gnus-active group))
1629 (total (if active (1+ (- (cdr active) (car active))) 0))
1630 (info (nth 2 entry))
1631 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1632 (marked (gnus-info-marks info))
1633 (mailp (apply 'append
1636 (memq x (assoc (symbol-name
1637 (car (or method gnus-select-method)))
1638 gnus-valid-select-methods)))
1639 '(mail post-mail))))
1640 (level (or (gnus-info-level info) gnus-level-killed))
1641 (score (or (gnus-info-score info) 0))
1642 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1643 (group-age (gnus-group-timestamp-delta group))
1644 (inhibit-read-only t))
1645 ;; Eval the cars of the lists until we find a match.
1647 (not (eval (caar list))))
1648 (setq list (cdr list)))
1649 (let ((face (cdar list)))
1650 (unless (eq face (get-text-property beg 'face))
1651 (gnus-put-text-property-excluding-characters-with-faces
1653 (setq face (if (boundp face) (symbol-value face) face)))
1654 (gnus-extent-start-open beg)))
1657 (defun gnus-group-update-group (group &optional visible-only)
1658 "Update all lines where GROUP appear.
1659 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1661 ;; Can't use `save-excursion' here, so we do it manually.
1662 (let ((buf (current-buffer))
1664 (set-buffer gnus-group-buffer)
1665 (setq mark (point-marker))
1666 ;; The buffer may be narrowed.
1669 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1671 found buffer-read-only)
1672 ;; Enter the current status into the dribble buffer.
1673 (let ((entry (gnus-group-entry group)))
1675 (not (gnus-ephemeral-group-p group)))
1677 (concat "(gnus-group-set-info '"
1678 (gnus-prin1-to-string (nth 2 entry))
1680 ;; Find all group instances. If topics are in use, each group
1681 ;; may be listed in more than once.
1682 (while (setq loc (text-property-any
1683 loc (point-max) 'gnus-group ident))
1686 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1688 (gnus-group-insert-group-line-info group)
1691 (gnus-run-hooks 'gnus-group-update-group-hook)))
1692 (setq loc (1+ loc)))
1693 (unless (or found visible-only)
1694 ;; No such line in the buffer, find out where it's supposed to
1695 ;; go, and insert it there (or at the end of the buffer).
1696 (if gnus-goto-missing-group-function
1697 (funcall gnus-goto-missing-group-function group)
1698 (let ((entry (cddr (gnus-group-entry group))))
1699 (while (and entry (car entry)
1703 (point-min) (point-max)
1704 'gnus-group (gnus-intern-safe
1705 (caar entry) gnus-active-hashtb)))))
1706 (setq entry (cdr entry)))
1707 (or entry (goto-char (point-max)))))
1708 ;; Finally insert the line.
1709 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1710 (gnus-group-insert-group-line-info group)
1713 (gnus-run-hooks 'gnus-group-update-group-hook))))
1714 (when gnus-group-update-group-function
1715 (funcall gnus-group-update-group-function group))
1716 (gnus-group-set-mode-line)))
1718 (set-marker mark nil)
1721 (defun gnus-group-set-mode-line ()
1722 "Update the mode line in the group buffer."
1723 (when (memq 'group gnus-updated-mode-lines)
1724 ;; Yes, we want to keep this mode line updated.
1726 (set-buffer gnus-group-buffer)
1727 (let* ((gformat (or gnus-group-mode-line-format-spec
1728 (gnus-set-format 'group-mode)))
1729 (gnus-tmp-news-server (cadr gnus-select-method))
1730 (gnus-tmp-news-method (car gnus-select-method))
1731 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1733 gnus-tmp-header ;Dummy binding for user-defined formats
1734 ;; Get the resulting string.
1736 (and gnus-dribble-buffer
1737 (buffer-name gnus-dribble-buffer)
1738 (buffer-modified-p gnus-dribble-buffer)
1740 (set-buffer gnus-dribble-buffer)
1741 (not (zerop (buffer-size))))))
1742 (mode-string (eval gformat)))
1743 ;; Say whether the dribble buffer has been modified.
1744 (setq mode-line-modified
1745 (if modified (car gnus-mode-line-modified)
1746 (cdr gnus-mode-line-modified)))
1747 ;; If the line is too long, we chop it off.
1748 (when (> (length mode-string) max-len)
1749 (setq mode-string (substring mode-string 0 (- max-len 4))))
1751 (setq mode-line-buffer-identification
1752 (gnus-mode-line-buffer-identification
1753 (list mode-string)))
1754 (set-buffer-modified-p modified))))))
1756 (defun gnus-group-group-name ()
1757 "Get the name of the newsgroup on the current line."
1758 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1760 (symbol-name group))))
1762 (defun gnus-group-group-level ()
1763 "Get the level of the newsgroup on the current line."
1764 (get-text-property (point-at-bol) 'gnus-level))
1766 (defun gnus-group-group-indentation ()
1767 "Get the indentation of the newsgroup on the current line."
1768 (or (get-text-property (point-at-bol) 'gnus-indentation)
1769 (and gnus-group-indentation-function
1770 (funcall gnus-group-indentation-function))
1773 (defun gnus-group-group-unread ()
1774 "Get the number of unread articles of the newsgroup on the current line."
1775 (get-text-property (point-at-bol) 'gnus-unread))
1777 (defun gnus-group-new-mail (group)
1778 (if (nnmail-new-mail-p (gnus-group-real-name group))
1782 (defun gnus-group-level (group)
1783 "Return the estimated level of GROUP."
1784 (or (gnus-info-level (gnus-get-info group))
1785 (and (member group gnus-zombie-list) gnus-level-zombie)
1788 (defun gnus-group-search-forward (&optional backward all level first-too)
1789 "Find the next newsgroup with unread articles.
1790 If BACKWARD is non-nil, find the previous newsgroup instead.
1791 If ALL is non-nil, just find any newsgroup.
1792 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1794 If FIRST-TOO, the current line is also eligible as a target."
1795 (let ((way (if backward -1 1))
1796 (low gnus-level-killed)
1799 (if (and backward (progn (beginning-of-line)) (bobp))
1808 (get-text-property (point) 'gnus-group)
1812 (get-text-property (point) 'gnus-unread)))
1813 (and (numberp unread) (> unread 0)))
1814 (setq lev (get-text-property (point)
1816 (<= lev gnus-level-subscribed)))
1818 (and (setq lev (get-text-property (point)
1827 (zerop (forward-line way)))))
1829 (progn (gnus-group-position-point) t)
1830 (goto-char (or pos beg))
1833 (defun gnus-total-fetched-for (group)
1834 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1835 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1836 (size (+ size-in-cache size-in-agent))
1837 (suffix '("B" "K" "M" "G"))
1840 (while (> size cutoff)
1841 (setq size (/ size scale)
1842 suffix (cdr suffix)))
1843 (format "%5.1f%s" size (car suffix))))
1845 ;;; Gnus group mode commands
1849 (defun gnus-group-mark-line-p ()
1852 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1853 (eq (char-after) gnus-process-mark)))
1855 (defun gnus-group-mark-group (n &optional unmark no-advance)
1856 "Mark the current group."
1858 (let ((buffer-read-only nil)
1862 (when (setq group (gnus-group-group-name))
1863 ;; Go to the mark position.
1865 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1869 (setq gnus-group-marked (delete group gnus-group-marked))
1870 (insert-char ? 1 t))
1871 (setq gnus-group-marked
1872 (cons group (delete group gnus-group-marked)))
1873 (insert-char gnus-process-mark 1 t)))
1875 (gnus-group-next-group 1))
1877 (gnus-summary-position-point)
1880 (defun gnus-group-unmark-group (n)
1881 "Remove the mark from the current group."
1883 (gnus-group-mark-group n 'unmark)
1884 (gnus-group-position-point))
1886 (defun gnus-group-unmark-all-groups ()
1887 "Unmark all groups."
1890 (mapc 'gnus-group-remove-mark gnus-group-marked))
1891 (gnus-group-position-point))
1893 (defun gnus-group-mark-region (unmark beg end)
1894 "Mark all groups between point and mark.
1895 If UNMARK, remove the mark instead."
1896 (interactive "P\nr")
1897 (let ((num (count-lines beg end)))
1900 (- num (gnus-group-mark-group num unmark)))))
1902 (defun gnus-group-mark-buffer (&optional unmark)
1903 "Mark all groups in the buffer.
1904 If UNMARK, remove the mark instead."
1906 (gnus-group-mark-region unmark (point-min) (point-max)))
1908 (defun gnus-group-mark-regexp (regexp)
1909 "Mark all groups that match some regexp."
1910 (interactive "sMark (regexp): ")
1911 (let ((alist (cdr gnus-newsrc-alist))
1915 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1916 (gnus-group-jump-to-group group)
1917 (gnus-group-set-mark group)))))
1918 (gnus-group-position-point))
1920 (defun gnus-group-remove-mark (group &optional test-marked)
1921 "Remove the process mark from GROUP and move point there.
1922 Return nil if the group isn't displayed."
1923 (if (gnus-group-goto-group group nil test-marked)
1925 (gnus-group-mark-group 1 'unmark t)
1927 (setq gnus-group-marked
1928 (delete group gnus-group-marked))
1931 (defun gnus-group-set-mark (group)
1932 "Set the process mark on GROUP."
1933 (if (gnus-group-goto-group group)
1935 (gnus-group-mark-group 1 nil t))
1936 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1938 (defun gnus-group-universal-argument (arg &optional groups func)
1939 "Perform any command on all groups according to the process/prefix convention."
1941 (if (eq (setq func (or func
1944 (substitute-command-keys
1945 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1947 (gnus-error 1 "Undefined key")
1948 (gnus-group-iterate arg
1950 (command-execute func))))
1951 (gnus-group-position-point))
1953 (defun gnus-group-process-prefix (n)
1954 "Return a list of groups to work on.
1955 Take into consideration N (the prefix) and the list of marked groups."
1958 (setq n (prefix-numeric-value n))
1959 ;; There is a prefix, so we return a list of the N next
1961 (let ((way (if (< n 0) -1 1))
1966 (if (setq group (gnus-group-group-name))
1967 (push group groups))
1969 (gnus-group-next-group way)))
1971 ((and (gnus-region-active-p) (mark))
1972 ;; Work on the region between point and mark.
1973 (let ((max (max (point) (mark)))
1976 (goto-char (min (point) (mark)))
1979 (push (gnus-group-group-name) groups)
1980 (zerop (gnus-group-next-group 1))
1982 (nreverse groups))))
1984 ;; No prefix, but a list of marked articles.
1985 (reverse gnus-group-marked))
1987 ;; Neither marked articles or a prefix, so we return the
1989 (let ((group (gnus-group-group-name)))
1990 (and group (list group))))))
1992 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1993 ;;; imagine why I went through these contortions...
1995 (let ((function (make-symbol "gnus-group-iterate-function"))
1996 (window (make-symbol "gnus-group-iterate-window"))
1997 (groups (make-symbol "gnus-group-iterate-groups"))
1998 (group (make-symbol "gnus-group-iterate-group")))
2000 `(defun gnus-group-iterate (arg ,function)
2001 "Iterate FUNCTION over all process/prefixed groups.
2002 FUNCTION will be called with the group name as the parameter
2003 and with point over the group in question."
2004 (let ((,groups (gnus-group-process-prefix arg))
2005 (,window (selected-window))
2008 (setq ,group (car ,groups)
2009 ,groups (cdr ,groups))
2010 (select-window ,window)
2011 (gnus-group-remove-mark ,group)
2012 (save-selected-window
2014 (funcall ,function ,group)))))))))
2016 (put 'gnus-group-iterate 'lisp-indent-function 1)
2018 ;; Selecting groups.
2020 (defun gnus-group-read-group (&optional all no-article group select-articles)
2021 "Read news in this newsgroup.
2022 If the prefix argument ALL is non-nil, already read articles become
2023 readable. IF ALL is a number, fetch this number of articles. If the
2024 optional argument NO-ARTICLE is non-nil, no article will be
2025 auto-selected upon group entry. If GROUP is non-nil, fetch that
2028 (let ((no-display (eq all 0))
2029 (group (or group (gnus-group-group-name)))
2030 number active marked entry)
2034 (error "No group on current line"))
2035 (setq marked (gnus-info-marks
2036 (nth 2 (setq entry (gnus-group-entry group)))))
2037 ;; This group might be a dead group. In that case we have to get
2038 ;; the number of unread articles from `gnus-active-hashtb'.
2040 (cond ((numberp all) all)
2042 ((setq active (gnus-active group))
2043 (- (1+ (cdr active)) (car active)))))
2044 (gnus-summary-read-group
2045 group (or all (and (numberp number)
2046 (zerop (+ number (gnus-range-length
2047 (cdr (assq 'tick marked)))
2049 (cdr (assq 'dormant marked)))))))
2050 no-article nil no-display nil select-articles)))
2052 (defun gnus-group-select-group (&optional all)
2053 "Select this newsgroup.
2054 No article is selected automatically.
2055 If the group is opened, just switch the summary buffer.
2056 If ALL is non-nil, already read articles become readable.
2057 If ALL is a positive number, fetch this number of the latest
2058 articles in the group.
2059 If ALL is a negative number, fetch this number of the earliest
2060 articles in the group."
2062 (when (and (eobp) (not (gnus-group-group-name)))
2064 (gnus-group-read-group all t))
2066 (defun gnus-group-quick-select-group (&optional all)
2067 "Select the current group \"quickly\".
2068 This means that no highlighting or scoring will be performed.
2069 If ALL (the prefix argument) is 0, don't even generate the summary
2072 This might be useful if you want to toggle threading
2073 before entering the group."
2075 (require 'gnus-score)
2077 gnus-score-find-score-files-function
2078 gnus-home-score-file
2079 gnus-apply-kill-hook
2080 gnus-summary-expunge-below)
2081 (gnus-group-read-group all t)))
2083 (defun gnus-group-visible-select-group (&optional all)
2084 "Select the current group without hiding any articles."
2086 (let ((gnus-inhibit-limiting t))
2087 (gnus-group-read-group all t)))
2089 (defun gnus-group-select-group-ephemerally ()
2090 "Select the current group without doing any processing whatsoever.
2091 You will actually be entered into a group that's a copy of
2092 the current group; no changes you make while in this group will
2095 (require 'gnus-score)
2097 gnus-score-find-score-files-function gnus-apply-kill-hook
2098 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2099 gnus-summary-mode-hook gnus-select-group-hook
2100 (group (gnus-group-group-name))
2101 (method (gnus-find-method-for-group group)))
2102 (gnus-group-read-ephemeral-group
2103 (gnus-group-prefixed-name group method) method)))
2106 (defun gnus-fetch-group (group &optional articles)
2107 "Start Gnus if necessary and enter GROUP.
2108 Returns whether the fetching was successful or not."
2109 (interactive (list (gnus-group-completing-read-group-name
2110 "Group name: " gnus-active-hashtb)))
2111 (unless (get-buffer gnus-group-buffer)
2113 (gnus-group-read-group articles nil group))
2116 (defun gnus-fetch-group-other-frame (group)
2117 "Pop up a frame and enter GROUP."
2119 (let ((window (get-buffer-window gnus-group-buffer)))
2121 (select-frame (window-frame window)))
2122 ((= (length (frame-list)) 1)
2123 (select-frame (make-frame)))
2126 (gnus-fetch-group group))
2128 (defvar gnus-ephemeral-group-server 0)
2130 (defcustom gnus-large-ephemeral-newsgroup 200
2131 "The number of articles which indicates a large ephemeral newsgroup.
2132 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2134 If the number of articles in a newsgroup is greater than this value,
2135 confirmation is required for selecting the newsgroup. If it is nil, no
2136 confirmation is required."
2138 :group 'gnus-group-select
2139 :type '(choice (const :tag "No limit" nil)
2142 (defcustom gnus-fetch-old-ephemeral-headers nil
2143 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2146 :type '(choice (const :tag "off" nil)
2149 (sexp :menu-tag "other" t)))
2151 ;; Enter a group that is not in the group buffer. Non-nil is returned
2152 ;; if selection was successful.
2153 (defun gnus-group-read-ephemeral-group (group method &optional activate
2154 quit-config request-only
2158 "Read GROUP from METHOD as an ephemeral group.
2159 If ACTIVATE, request the group first.
2160 If QUIT-CONFIG, use that window configuration when exiting from the
2162 If REQUEST-ONLY, don't actually read the group; just request it.
2163 If SELECT-ARTICLES, only select those articles.
2164 If PARAMETERS, use those as the group parameters.
2165 If NUMBER, fetch this number of articles.
2167 Return the name of the group if selection was successful."
2170 ;; (gnus-read-group "Group name: ")
2172 "Group: " gnus-active-hashtb
2174 'gnus-group-history)
2175 (gnus-read-method "From method: ")))
2176 ;; Transform the select method into a unique server.
2177 (when (stringp method)
2178 (setq method (gnus-server-to-method method)))
2180 `(,(car method) ,(concat (cadr method) "-ephemeral")
2181 (,(intern (format "%s-address" (car method))) ,(cadr method))
2183 (let ((group (if (gnus-group-foreign-p group) group
2184 (gnus-group-prefixed-name (gnus-group-real-name group)
2189 ,gnus-level-default-subscribed nil nil ,method
2192 (cons 'quit-config quit-config)
2194 (cons gnus-summary-buffer
2195 gnus-current-window-configuration)))
2198 (push method gnus-ephemeral-servers)
2199 (set-buffer gnus-group-buffer)
2200 (unless (gnus-check-server method)
2201 (error "Unable to contact server: %s" (gnus-status-message method)))
2203 (gnus-activate-group group 'scan)
2204 (unless (gnus-request-group group)
2205 (error "Couldn't request group: %s"
2206 (nnheader-get-report (car method)))))
2210 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2211 (gnus-fetch-old-headers
2212 gnus-fetch-old-ephemeral-headers))
2213 (gnus-group-read-group (or number t) t group select-articles))
2217 (message "Quit reading the ephemeral group")
2220 (defun gnus-group-jump-to-group (group &optional prompt)
2221 "Jump to newsgroup GROUP.
2223 If PROMPT (the prefix) is a number, use the prompt specified in
2224 `gnus-group-jump-to-group-prompt'."
2226 (list (mm-string-make-unibyte
2228 "Group: " gnus-active-hashtb nil
2229 (gnus-read-active-file-p)
2230 (if current-prefix-arg
2231 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2232 (or (and (stringp gnus-group-jump-to-group-prompt)
2233 gnus-group-jump-to-group-prompt)
2234 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2235 (and (stringp p) p))))
2236 'gnus-group-history))))
2238 (when (equal group "")
2239 (error "Empty group name"))
2241 (unless (gnus-ephemeral-group-p group)
2242 ;; Either go to the line in the group buffer...
2243 (unless (gnus-group-goto-group group)
2244 ;; ... or insert the line.
2245 (gnus-group-update-group group)
2246 (gnus-group-goto-group group)))
2247 ;; Adjust cursor point.
2248 (gnus-group-position-point))
2250 (defun gnus-group-goto-group (group &optional far test-marked)
2251 "Goto to newsgroup GROUP.
2252 If FAR, it is likely that the group is not on the current line.
2253 If TEST-MARKED, the line must be marked."
2257 ;; It's quite likely that we are on the right line, so
2258 ;; we check the current line first.
2260 (eq (get-text-property (point) 'gnus-group)
2261 (gnus-intern-safe group gnus-active-hashtb))
2262 (or (not test-marked) (gnus-group-mark-line-p)))
2264 ;; Previous and next line are also likely, so we check them as well.
2268 (and (eq (get-text-property (point) 'gnus-group)
2269 (gnus-intern-safe group gnus-active-hashtb))
2270 (or (not test-marked) (gnus-group-mark-line-p)))))
2276 (and (eq (get-text-property (point) 'gnus-group)
2277 (gnus-intern-safe group gnus-active-hashtb))
2278 (or (not test-marked) (gnus-group-mark-line-p)))))
2282 (goto-char (point-min))
2284 (while (and (not found)
2289 (gnus-intern-safe group gnus-active-hashtb))))
2290 (if (gnus-group-mark-line-p)
2295 ;; Search through the entire buffer.
2298 (point-min) (point-max)
2299 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2301 (defun gnus-group-next-group (n &optional silent)
2302 "Go to next N'th newsgroup.
2303 If N is negative, search backward instead.
2304 Returns the difference between N and the number of skips actually
2307 (gnus-group-next-unread-group n t nil silent))
2309 (defun gnus-group-next-unread-group (n &optional all level silent)
2310 "Go to next N'th unread newsgroup.
2311 If N is negative, search backward instead.
2312 If ALL is non-nil, choose any newsgroup, unread or not.
2313 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2314 such group can be found, the next group with a level higher than
2316 Returns the difference between N and the number of skips actually
2319 (let ((backward (< n 0))
2322 (gnus-group-search-forward
2323 backward (or (not gnus-group-goto-unread) all) level))
2327 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2328 (if level " on this level or higher" "")))
2331 (defun gnus-group-prev-group (n)
2332 "Go to previous N'th newsgroup.
2333 Returns the difference between N and the number of skips actually
2336 (gnus-group-next-unread-group (- n) t))
2338 (defun gnus-group-prev-unread-group (n)
2339 "Go to previous N'th unread newsgroup.
2340 Returns the difference between N and the number of skips actually
2343 (gnus-group-next-unread-group (- n)))
2345 (defun gnus-group-next-unread-group-same-level (n)
2346 "Go to next N'th unread newsgroup on the same level.
2347 If N is negative, search backward instead.
2348 Returns the difference between N and the number of skips actually
2351 (gnus-group-next-unread-group n t (gnus-group-group-level))
2352 (gnus-group-position-point))
2354 (defun gnus-group-prev-unread-group-same-level (n)
2355 "Go to next N'th unread newsgroup on the same level.
2356 Returns the difference between N and the number of skips actually
2359 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2360 (gnus-group-position-point))
2362 (defun gnus-group-best-unread-group (&optional exclude-group)
2363 "Go to the group with the highest level.
2364 If EXCLUDE-GROUP, do not go to that group."
2366 (goto-char (point-min))
2370 (setq unread (get-text-property (point) 'gnus-unread))
2371 (when (and (numberp unread) (> unread 0))
2372 (when (and (get-text-property (point) 'gnus-level)
2373 (< (get-text-property (point) 'gnus-level) best)
2374 (or (not exclude-group)
2375 (not (equal exclude-group (gnus-group-group-name)))))
2376 (setq best (get-text-property (point) 'gnus-level))
2377 (setq best-point (point))))
2380 (goto-char best-point))
2381 (gnus-group-position-point)
2382 (and best-point (gnus-group-group-name))))
2384 ;; Is there something like an after-point-motion-hook?
2385 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2387 ;; (defun gnus-group-menu-bar-update ()
2388 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2389 ;; (current-buffer))))
2390 ;; (name (buffer-name (car buf))))
2392 ;; (if (> (length name) 27)
2393 ;; (concat (substring name 0 12)
2395 ;; (substring name -12))
2397 ;; (menu-bar-update-buffers-1 buf)))
2399 ;; (defun gnus-group-position-point ()
2400 ;; (gnus-goto-colon)
2401 ;; (gnus-group-menu-bar-update))
2403 (defun gnus-group-first-unread-group ()
2404 "Go to the first group with unread articles."
2407 (let ((opoint (point))
2409 (goto-char (point-min))
2410 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2411 (and (numberp unread) ; Not a topic.
2412 (not (zerop unread))) ; Has unread articles.
2413 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2416 nil)) ; Not success.
2417 (gnus-group-position-point)))
2419 (defun gnus-group-enter-server-mode ()
2420 "Jump to the server buffer."
2422 (gnus-enter-server-buffer))
2424 (defun gnus-group-make-group-simple (&optional group)
2425 "Add a new newsgroup.
2426 The user will be prompted for GROUP."
2428 (list (completing-read "Group: " gnus-active-hashtb
2429 nil nil nil 'gnus-group-history)))
2430 (gnus-group-make-group
2431 (gnus-group-real-name group)
2432 (gnus-group-server group)))
2434 (defun gnus-group-make-group (name &optional method address args)
2435 "Add a new newsgroup.
2436 The user will be prompted for a NAME, for a select METHOD, and an
2440 (gnus-read-group "Group name: ")
2441 (gnus-read-method "From method: ")))
2443 (when (stringp method)
2444 (setq method (or (gnus-server-to-method method) method)))
2445 (let* ((meth (gnus-method-simplify
2447 (not (gnus-server-equal method gnus-select-method)))
2448 (if address (list (intern method) address)
2450 (nname (if method (gnus-group-prefixed-name name meth) name))
2452 (when (gnus-group-entry nname)
2453 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2454 ;; Subscribe to the new group.
2455 (gnus-group-change-level
2456 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2457 gnus-level-default-subscribed gnus-level-killed
2458 (and (gnus-group-group-name)
2459 (gnus-group-entry (gnus-group-group-name)))
2462 (gnus-set-active nname (cons 1 0))
2463 (unless (gnus-ephemeral-group-p name)
2465 (concat "(gnus-group-set-info '"
2466 (gnus-prin1-to-string (cdr info)) ")")))
2468 (gnus-group-insert-group-line-info nname)
2470 (gnus-group-position-point)
2472 ;; Load the back end and try to make the back end create
2473 ;; the group as well.
2474 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2476 gnus-valid-select-methods)
2478 (gnus-check-server meth)
2479 (when (gnus-check-backend-function 'request-create-group nname)
2480 (unless (gnus-request-create-group nname nil args)
2481 (error "Could not create group on server: %s"
2482 (nnheader-get-report backend))))
2485 (defun gnus-group-delete-groups (&optional arg)
2486 "Delete the current group. Only meaningful with editable groups."
2488 (let ((n (length (gnus-group-process-prefix arg))))
2489 (when (gnus-yes-or-no-p
2491 "Delete this 1 group? "
2492 (format "Delete these %d groups? " n)))
2493 (gnus-group-iterate arg
2495 (gnus-group-delete-group group nil t))))))
2497 (defun gnus-group-delete-group (group &optional force no-prompt)
2498 "Delete the current group. Only meaningful with editable groups.
2499 If FORCE (the prefix) is non-nil, all the articles in the group will
2500 be deleted. This is \"deleted\" as in \"removed forever from the face
2501 of the Earth\". There is no undo. The user will be prompted before
2503 Note that you also have to specify FORCE if you want the group to
2504 be removed from the server, even when it's empty."
2506 (list (gnus-group-group-name)
2507 current-prefix-arg))
2509 (error "No group to delete"))
2510 (unless (gnus-check-backend-function 'request-delete-group group)
2511 (error "This back end does not support group deletion"))
2513 (let ((group-decoded (gnus-group-decoded-name group)))
2514 (if (and (not no-prompt)
2515 (not (gnus-yes-or-no-p
2517 "Do you really want to delete %s%s? "
2518 group-decoded (if force " and all its contents" "")))))
2520 (gnus-message 6 "Deleting group %s..." group-decoded)
2521 (if (not (gnus-request-delete-group group force))
2522 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2523 (gnus-message 6 "Deleting group %s...done" group-decoded)
2524 (gnus-group-goto-group group)
2525 (gnus-group-kill-group 1 t)
2526 (gnus-set-active group nil)
2528 (gnus-group-position-point)))
2530 (defun gnus-group-rename-group (group new-name)
2531 "Rename group from GROUP to NEW-NAME.
2532 When used interactively, GROUP is the group under point
2533 and NEW-NAME will be prompted for."
2536 (gnus-group-group-name)
2538 (unless (gnus-check-backend-function
2539 'request-rename-group (gnus-group-group-name))
2540 (error "This back end does not support renaming groups"))
2541 (gnus-read-group "Rename group to: "
2542 (gnus-group-real-name (gnus-group-group-name))))))
2544 (unless (gnus-check-backend-function 'request-rename-group group)
2545 (error "This back end does not support renaming groups"))
2547 (error "No group to rename"))
2548 (when (equal (gnus-group-real-name group) new-name)
2549 (error "Can't rename to the same name"))
2551 ;; We find the proper prefixed name.
2553 (if (gnus-group-native-p group)
2557 (gnus-group-prefixed-name
2558 (gnus-group-real-name new-name)
2559 (gnus-info-method (gnus-get-info group)))))
2561 (when (gnus-active new-name)
2562 (error "The group %s already exists" new-name))
2564 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2567 (gnus-group-goto-group group)
2568 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2569 (gnus-request-rename-group group new-name))))
2570 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2571 ;; We rename the group internally by killing it...
2572 (gnus-group-kill-group)
2573 ;; ... changing its name ...
2574 (setcar (cdar gnus-list-of-killed-groups) new-name)
2575 ;; ... and then yanking it. Magic!
2576 (gnus-group-yank-group)
2577 (gnus-set-active new-name (gnus-active group))
2578 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2580 (setq gnus-killed-list (delete group gnus-killed-list))
2581 (gnus-set-active group nil)
2582 (gnus-dribble-touch)
2583 (gnus-group-position-point)))
2585 (defun gnus-group-edit-group (group &optional part)
2586 "Edit the group on the current line."
2587 (interactive (list (gnus-group-group-name)))
2588 (let ((part (or part 'info))
2591 (error "No group on current line"))
2592 (unless (setq info (gnus-get-info group))
2593 (error "Killed group; can't be edited"))
2595 (gnus-close-group group))
2597 ;; Find the proper form to edit.
2598 (cond ((eq part 'method)
2599 (or (gnus-info-method info) "native"))
2601 (gnus-info-params info))
2603 ;; The proper documentation.
2605 "Editing the %s for `%s'."
2607 ((eq part 'method) "select method")
2608 ((eq part 'params) "group parameters")
2610 (gnus-group-decoded-name group))
2612 (gnus-group-edit-group-done ',part ,group form)))
2615 (gnus-create-info-command
2617 (or gnus-info-filename
2618 (get-language-info current-language-environment 'gnus-info)
2620 (cond ((eq part 'method)
2627 (defun gnus-group-edit-group-method (group)
2628 "Edit the select method of GROUP."
2629 (interactive (list (gnus-group-group-name)))
2630 (gnus-group-edit-group group 'method))
2632 (defun gnus-group-edit-group-parameters (group)
2633 "Edit the group parameters of GROUP."
2634 (interactive (list (gnus-group-group-name)))
2635 (gnus-group-edit-group group 'params))
2637 (defun gnus-group-edit-group-done (part group form)
2639 (let* ((method (cond ((eq part 'info) (nth 4 form))
2640 ((eq part 'method) form)
2642 (info (cond ((eq part 'info) form)
2643 ((eq part 'method) (gnus-get-info group))
2646 (if (or (not method)
2648 gnus-select-method method))
2649 (gnus-group-real-name (car info))
2650 (gnus-group-prefixed-name
2651 (gnus-group-real-name (car info)) method))
2653 (when (and new-group
2654 (not (equal new-group group)))
2655 (when (gnus-group-goto-group group)
2656 (gnus-group-kill-group 1))
2657 (gnus-activate-group new-group))
2659 (if (not (and info new-group))
2660 (gnus-group-set-info form (or new-group group) part)
2661 (setq info (gnus-copy-sequence info))
2662 (setcar info new-group)
2663 (unless (gnus-server-equal method "native")
2664 (unless (nthcdr 3 info)
2665 (nconc info (list nil nil)))
2666 (unless (nthcdr 4 info)
2667 (nconc info (list nil)))
2668 (gnus-info-set-method info method))
2669 (gnus-group-set-info info))
2670 (gnus-group-update-group (or new-group group))
2671 (gnus-group-position-point)))
2673 (defun gnus-group-make-useful-group (group method)
2674 "Create one of the groups described in `gnus-useful-groups'."
2676 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2678 gnus-useful-groups)))
2679 (list (cadr entry) (caddr entry))))
2680 (setq method (gnus-copy-sequence method))
2682 (while (setq entry (memq (assq 'eval method) method))
2683 (setcar entry (eval (cadar entry)))))
2684 (gnus-group-make-group group method))
2686 (defun gnus-group-make-help-group (&optional noerror)
2687 "Create the Gnus documentation group.
2688 Optional argument NOERROR modifies the behavior of this function when the
2689 group already exists:
2690 - if not given, and error is signaled,
2691 - if t, stay silent,
2692 - if anything else, just print a message."
2694 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2695 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2696 (if (gnus-group-entry name)
2697 (cond ((eq noerror nil)
2698 (error "Documentation group already exists"))
2703 (gnus-message 1 "Documentation group already exists")))
2706 (gnus-message 1 "Couldn't find doc group")
2707 (gnus-group-make-group
2708 (gnus-group-real-name name)
2709 (list 'nndoc "gnus-help"
2710 (list 'nndoc-address file)
2711 (list 'nndoc-article-type 'mbox))))
2713 (gnus-group-position-point))
2715 (defun gnus-group-make-doc-group (file type)
2716 "Create a group that uses a single file as the source.
2718 If called with a prefix argument, ask for the file type."
2720 (list (read-file-name "File name: ")
2721 (and current-prefix-arg 'ask)))
2722 (when (eq type 'ask)
2727 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2729 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2730 ((= char ?b) 'babyl)
2731 ((= char ?d) 'digest)
2732 ((= char ?f) 'forward)
2734 ((= char ?g) 'guess)
2735 (t (setq err (format "%c unknown. " char))
2738 (let* ((file (expand-file-name file))
2739 (name (gnus-generate-new-group-name
2740 (gnus-group-prefixed-name
2741 (file-name-nondirectory file) '(nndoc "")))))
2742 (gnus-group-make-group
2743 (gnus-group-real-name name)
2745 (list 'nndoc-address file)
2746 (list 'nndoc-article-type (or type 'guess))))))
2748 (defvar nnweb-type-definition)
2749 (defvar gnus-group-web-type-history nil)
2750 (defvar gnus-group-web-search-history nil)
2751 (defun gnus-group-make-web-group (&optional solid)
2752 "Create an ephemeral nnweb group.
2753 If SOLID (the prefix), create a solid group."
2757 (if solid (gnus-read-group "Group name: ")
2758 (message-unique-id)))
2759 (default-type (or (car gnus-group-web-type-history)
2760 (symbol-name (caar nnweb-type-definition))))
2764 (format "Search engine type (default %s): " default-type)
2765 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2766 nnweb-type-definition)
2767 nil t nil 'gnus-group-web-type-history)
2772 (cons (or (car gnus-group-web-search-history) "") 0)
2773 'gnus-group-web-search-history))
2775 `(nnweb ,group (nnweb-search ,search)
2776 (nnweb-type ,(intern type))
2777 (nnweb-ephemeral-p t))))
2780 (gnus-pull 'nnweb-ephemeral-p method)
2781 (gnus-group-make-group group method))
2782 (gnus-group-read-ephemeral-group
2784 (cons (current-buffer)
2785 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2788 (defvar nnrss-group-alist)
2789 (defun nnrss-discover-feed (arg))
2790 (defun nnrss-save-server-data (arg)))
2791 (defun gnus-group-make-rss-group (&optional url)
2792 "Given a URL, discover if there is an RSS feed.
2793 If there is, use Gnus to create an nnrss group"
2797 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2798 (let ((feedinfo (nnrss-discover-feed url)))
2800 (let ((title (gnus-newsgroup-savable-name
2801 (read-from-minibuffer "Title: "
2802 (gnus-newsgroup-savable-name
2803 (or (cdr (assoc 'title
2806 (desc (read-from-minibuffer "Description: "
2807 (cdr (assoc 'description
2809 (href (cdr (assoc 'href feedinfo)))
2810 (encodable (mm-coding-system-p 'utf-8)))
2812 ;; Unify non-ASCII text.
2813 (setq title (mm-decode-coding-string
2814 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2815 (gnus-group-make-group (if encodable
2816 (mm-encode-coding-string title 'utf-8)
2819 (push (list title href desc) nnrss-group-alist)
2820 (nnrss-save-server-data nil))
2821 (error "No feeds found for %s" url))))
2823 (defvar nnwarchive-type-definition)
2824 (defvar gnus-group-warchive-type-history nil)
2825 (defvar gnus-group-warchive-login-history nil)
2826 (defvar gnus-group-warchive-address-history nil)
2828 (defun gnus-group-make-warchive-group ()
2829 "Create a nnwarchive group."
2831 (require 'nnwarchive)
2832 (let* ((group (gnus-read-group "Group name: "))
2833 (default-type (or (car gnus-group-warchive-type-history)
2834 (symbol-name (caar nnwarchive-type-definition))))
2838 (format "Warchive type (default %s): " default-type)
2839 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2840 nnwarchive-type-definition)
2841 nil t nil 'gnus-group-warchive-type-history)
2843 (address (read-string "Warchive address: "
2844 nil 'gnus-group-warchive-address-history))
2845 (default-login (or (car gnus-group-warchive-login-history)
2850 (format "Warchive login (default %s): " user-mail-address)
2851 default-login 'gnus-group-warchive-login-history)
2854 `(nnwarchive ,address
2855 (nnwarchive-type ,(intern type))
2856 (nnwarchive-login ,login))))
2857 (gnus-group-make-group group method)))
2859 (defun gnus-group-make-archive-group (&optional all)
2860 "Create the (ding) Gnus archive group of the most recent articles.
2861 Given a prefix, create a full group."
2863 (let ((group (gnus-group-prefixed-name
2864 (if all "ding.archives" "ding.recent") '(nndir ""))))
2865 (when (gnus-group-entry group)
2866 (error "Archive group already exists"))
2867 (gnus-group-make-group
2868 (gnus-group-real-name group)
2869 (list 'nndir (if all "hpc" "edu")
2870 (list 'nndir-directory
2871 (if all gnus-group-archive-directory
2872 gnus-group-recent-archive-directory))))
2873 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2875 (defun gnus-group-make-directory-group (dir)
2876 "Create an nndir group.
2877 The user will be prompted for a directory. The contents of this
2878 directory will be used as a newsgroup. The directory should contain
2879 mail messages or news articles in files that have numeric names."
2881 (list (read-file-name "Create group from directory: ")))
2882 (unless (file-exists-p dir)
2883 (error "No such directory"))
2884 (unless (file-directory-p dir)
2885 (error "Not a directory"))
2889 (while (or (not group) (gnus-group-entry group))
2891 (gnus-group-prefixed-name
2892 (expand-file-name ext dir)
2894 (setq ext (format "<%d>" (setq i (1+ i)))))
2895 (gnus-group-make-group
2896 (gnus-group-real-name group)
2897 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2899 (defvar nnkiboze-score-file)
2900 (defun gnus-group-make-kiboze-group (group address scores)
2901 "Create an nnkiboze group.
2902 The user will be prompted for a name, a regexp to match groups, and
2903 score file entries for articles to include in the group."
2906 (read-string "nnkiboze group name: ")
2907 (read-string "Source groups (regexp): ")
2908 (let ((headers (mapcar 'list
2909 '("subject" "from" "number" "date" "message-id"
2910 "references" "chars" "lines" "xref"
2911 "followup" "all" "body" "head")))
2912 scores header regexp regexps)
2913 (while (not (equal "" (setq header (completing-read
2914 "Match on header: " headers nil t))))
2916 (while (not (equal "" (setq regexp (read-string
2917 (format "Match on %s (regexp): "
2919 (push (list regexp nil nil 'r) regexps))
2920 (push (cons header regexps) scores))
2922 (gnus-group-make-group group "nnkiboze" address)
2923 (let* ((nnkiboze-current-group group)
2924 (score-file (car (nnkiboze-score-file "")))
2925 (score-dir (file-name-directory score-file)))
2926 (unless (file-exists-p score-dir)
2927 (make-directory score-dir))
2928 (with-temp-file score-file
2929 (let (emacs-lisp-mode-hook)
2930 (gnus-pp scores)))))
2932 (defun gnus-group-add-to-virtual (n vgroup)
2933 "Add the current group to a virtual group."
2935 (list current-prefix-arg
2936 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2938 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2939 (error "%s is not an nnvirtual group" vgroup))
2940 (gnus-close-group vgroup)
2941 (let* ((groups (gnus-group-process-prefix n))
2942 (method (gnus-info-method (gnus-get-info vgroup))))
2943 (setcar (cdr method)
2945 (nth 1 method) "\\|"
2948 (gnus-group-remove-mark s)
2949 (concat "\\(^" (regexp-quote s) "$\\)"))
2951 (gnus-group-position-point))
2953 (defun gnus-group-make-empty-virtual (group)
2954 "Create a new, fresh, empty virtual group."
2955 (interactive "sCreate new, empty virtual group: ")
2956 (let* ((method (list 'nnvirtual "^$"))
2957 (pgroup (gnus-group-prefixed-name group method)))
2958 ;; Check whether it exists already.
2959 (when (gnus-group-entry pgroup)
2960 (error "Group %s already exists" pgroup))
2961 ;; Subscribe the new group after the group on the current line.
2962 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2963 (gnus-group-update-group pgroup)
2965 (gnus-group-position-point)))
2967 (defun gnus-group-enter-directory (dir)
2968 "Enter an ephemeral nneething group."
2969 (interactive "DDirectory to read: ")
2970 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2971 (leaf (gnus-group-prefixed-name
2972 (file-name-nondirectory (directory-file-name dir))
2974 (name (gnus-generate-new-group-name leaf)))
2975 (unless (gnus-group-read-ephemeral-group
2977 (cons (current-buffer)
2978 (if (eq major-mode 'gnus-summary-mode)
2980 (error "Couldn't enter %s" dir))))
2983 (autoload 'nnimap-expunge "nnimap")
2984 (autoload 'nnimap-acl-get "nnimap")
2985 (autoload 'nnimap-acl-edit "nnimap"))
2987 (defun gnus-group-nnimap-expunge (group)
2988 "Expunge deleted articles in current nnimap GROUP."
2989 (interactive (list (gnus-group-group-name)))
2990 (let ((mailbox (gnus-group-real-name group)) method)
2992 (error "No group on current line"))
2993 (unless (gnus-get-info group)
2994 (error "Killed group; can't be edited"))
2995 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2996 (error "%s is not an nnimap group" group))
2997 (nnimap-expunge mailbox (cadr method))))
2999 (defun gnus-group-nnimap-edit-acl (group)
3000 "Edit the Access Control List of current nnimap GROUP."
3001 (interactive (list (gnus-group-group-name)))
3002 (let ((mailbox (gnus-group-real-name group)) method acl)
3004 (error "No group on current line"))
3005 (unless (gnus-get-info group)
3006 (error "Killed group; can't be edited"))
3007 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3008 (error "%s is not an nnimap group" group))
3009 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3010 (error "Server does not support ACL's"))
3011 (gnus-edit-form acl (format "Editing the access control list for `%s'.
3013 An access control list is a list of (identifier . rights) elements.
3015 The identifier string specifies the corresponding user. The
3016 identifier \"anyone\" is reserved to refer to the universal identity.
3018 Rights is a string listing a (possibly empty) set of alphanumeric
3019 characters, each character listing a set of operations which is being
3020 controlled. Letters are reserved for ``standard'' rights, listed
3021 below. Digits are reserved for implementation or site defined rights.
3023 l - lookup (mailbox is visible to LIST/LSUB commands)
3024 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3025 SEARCH, COPY from mailbox)
3026 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3027 w - write (STORE flags other than \\SEEN and \\DELETED)
3028 i - insert (perform APPEND, COPY into mailbox)
3029 p - post (send mail to submission address for mailbox,
3030 not enforced by IMAP4 itself)
3031 c - create and delete mailbox (CREATE new sub-mailboxes in any
3032 implementation-defined hierarchy, RENAME or DELETE mailbox)
3033 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3034 a - administer (perform SETACL)" group)
3037 ,mailbox ',method ',acl form)))))
3039 ;; Group sorting commands
3040 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3042 (defun gnus-group-sort-groups (func &optional reverse)
3043 "Sort the group buffer according to FUNC.
3044 When used interactively, the sorting function used will be
3045 determined by the `gnus-group-sort-function' variable.
3046 If REVERSE (the prefix), reverse the sorting order."
3047 (interactive (list gnus-group-sort-function current-prefix-arg))
3048 (funcall gnus-group-sort-alist-function
3049 (gnus-make-sort-function func) reverse)
3050 (gnus-group-unmark-all-groups)
3051 (gnus-group-list-groups)
3052 (gnus-dribble-touch))
3054 (defun gnus-group-sort-flat (func reverse)
3055 ;; We peel off the dummy group from the alist.
3057 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3058 (pop gnus-newsrc-alist))
3060 (setq gnus-newsrc-alist
3061 (sort gnus-newsrc-alist func))
3063 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3064 ;; Regenerate the hash table.
3065 (gnus-make-hashtable-from-newsrc-alist)))
3067 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3068 "Sort the group buffer alphabetically by group name.
3069 If REVERSE, sort in reverse order."
3071 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3073 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3074 "Sort the group buffer alphabetically by real (unprefixed) group name.
3075 If REVERSE, sort in reverse order."
3077 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3079 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3080 "Sort the group buffer by number of unread articles.
3081 If REVERSE, sort in reverse order."
3083 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3085 (defun gnus-group-sort-groups-by-level (&optional reverse)
3086 "Sort the group buffer by group level.
3087 If REVERSE, sort in reverse order."
3089 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3091 (defun gnus-group-sort-groups-by-score (&optional reverse)
3092 "Sort the group buffer by group score.
3093 If REVERSE, sort in reverse order."
3095 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3097 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3098 "Sort the group buffer by group rank.
3099 If REVERSE, sort in reverse order."
3101 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3103 (defun gnus-group-sort-groups-by-method (&optional reverse)
3104 "Sort the group buffer alphabetically by back end name.
3105 If REVERSE, sort in reverse order."
3107 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3109 (defun gnus-group-sort-groups-by-server (&optional reverse)
3110 "Sort the group buffer alphabetically by server name.
3111 If REVERSE, sort in reverse order."
3113 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3115 ;;; Selected group sorting.
3117 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3118 "Sort the process/prefixed groups."
3119 (interactive (list current-prefix-arg gnus-group-sort-function))
3120 (let ((groups (gnus-group-process-prefix n)))
3121 (funcall gnus-group-sort-selected-function
3122 groups (gnus-make-sort-function func) reverse)
3123 (gnus-group-unmark-all-groups)
3124 (gnus-group-list-groups)
3125 (gnus-dribble-touch)))
3127 (defun gnus-group-sort-selected-flat (groups func reverse)
3128 (let (entries infos)
3129 ;; First find all the group entries for these groups.
3131 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3133 ;; Then sort the infos.
3137 (lambda (entry) (car entry))
3138 (setq entries (nreverse entries)))
3141 (setq infos (nreverse infos)))
3142 ;; Go through all the infos and replace the old entries
3143 ;; with the new infos.
3145 (setcar (car entries) (pop infos))
3147 ;; Update the hashtable.
3148 (gnus-make-hashtable-from-newsrc-alist)))
3150 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3151 "Sort the group buffer alphabetically by group name.
3152 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3153 sort in reverse order."
3154 (interactive (gnus-interactive "P\ny"))
3155 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3157 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3158 "Sort the group buffer alphabetically by real group name.
3159 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3160 sort in reverse order."
3161 (interactive (gnus-interactive "P\ny"))
3162 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3164 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3165 "Sort the group buffer by number of unread articles.
3166 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3167 sort in reverse order."
3168 (interactive (gnus-interactive "P\ny"))
3169 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3171 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3172 "Sort the group buffer by group level.
3173 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3174 sort in reverse order."
3175 (interactive (gnus-interactive "P\ny"))
3176 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3178 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3179 "Sort the group buffer by group score.
3180 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3181 sort in reverse order."
3182 (interactive (gnus-interactive "P\ny"))
3183 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3185 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3186 "Sort the group buffer by group rank.
3187 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3188 sort in reverse order."
3189 (interactive (gnus-interactive "P\ny"))
3190 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3192 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3193 "Sort the group buffer alphabetically by back end name.
3194 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3195 sort in reverse order."
3196 (interactive (gnus-interactive "P\ny"))
3197 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3199 ;;; Sorting predicates.
3201 (defun gnus-group-sort-by-alphabet (info1 info2)
3202 "Sort alphabetically."
3203 (string< (gnus-info-group info1) (gnus-info-group info2)))
3205 (defun gnus-group-sort-by-real-name (info1 info2)
3206 "Sort alphabetically on real (unprefixed) names."
3207 (string< (gnus-group-real-name (gnus-info-group info1))
3208 (gnus-group-real-name (gnus-info-group info2))))
3210 (defun gnus-group-sort-by-unread (info1 info2)
3211 "Sort by number of unread articles."
3212 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3213 (n2 (gnus-group-unread (gnus-info-group info1))))
3214 (< (or (and (numberp n1) n1) 0)
3215 (or (and (numberp n2) n2) 0))))
3217 (defun gnus-group-sort-by-level (info1 info2)
3219 (< (gnus-info-level info1) (gnus-info-level info2)))
3221 (defun gnus-group-sort-by-method (info1 info2)
3222 "Sort alphabetically by back end name."
3223 (string< (car (gnus-find-method-for-group
3224 (gnus-info-group info1) info1))
3225 (car (gnus-find-method-for-group
3226 (gnus-info-group info2) info2))))
3228 (defun gnus-group-sort-by-server (info1 info2)
3229 "Sort alphabetically by server name."
3230 (string< (gnus-method-to-full-server-name
3231 (gnus-find-method-for-group
3232 (gnus-info-group info1) info1))
3233 (gnus-method-to-full-server-name
3234 (gnus-find-method-for-group
3235 (gnus-info-group info2) info2))))
3237 (defun gnus-group-sort-by-score (info1 info2)
3238 "Sort by group score."
3239 (> (gnus-info-score info1) (gnus-info-score info2)))
3241 (defun gnus-group-sort-by-rank (info1 info2)
3242 "Sort by level and score."
3243 (let ((level1 (gnus-info-level info1))
3244 (level2 (gnus-info-level info2)))
3245 (or (< level1 level2)
3246 (and (= level1 level2)
3247 (> (gnus-info-score info1) (gnus-info-score info2))))))
3251 (defun gnus-group-clear-data (&optional arg)
3252 "Clear all marks and read ranges from the current group.
3253 Obeys the process/prefix convention."
3255 (gnus-group-iterate arg
3258 (gnus-info-clear-data (setq info (gnus-get-info group)))
3259 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3260 (when (gnus-group-goto-group group)
3261 (gnus-group-update-group-line))))))
3263 (defun gnus-group-clear-data-on-native-groups ()
3264 "Clear all marks and read ranges from all native groups."
3266 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3267 (let ((alist (cdr gnus-newsrc-alist))
3269 (while (setq info (pop alist))
3270 (when (gnus-group-native-p (gnus-info-group info))
3271 (gnus-info-clear-data info)))
3272 (gnus-get-unread-articles)
3273 (gnus-dribble-touch)
3274 (when (gnus-y-or-n-p
3275 "Move the cache away to avoid problems in the future? ")
3276 (call-interactively 'gnus-cache-move-cache)))))
3278 (defun gnus-info-clear-data (info)
3279 "Clear all marks and read ranges from INFO."
3280 (let ((group (gnus-info-group info))
3282 (dolist (el (gnus-info-marks info))
3283 (push `(,(cdr el) add (,(car el))) action))
3284 (push `(,(gnus-info-read info) add (read)) action)
3287 (gnus-request-set-mark ,group ',action)
3288 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3289 (gnus-info-set-read ',info ',(gnus-info-read info))
3290 (when (gnus-group-goto-group ,group)
3291 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3292 (gnus-group-update-group-line))))
3293 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3295 (gnus-request-set-mark group action)
3296 (gnus-info-set-read info nil)
3297 (when (gnus-info-marks info)
3298 (gnus-info-set-marks info nil))))
3300 ;; Group catching up.
3302 (defun gnus-group-catchup-current (&optional n all)
3303 "Mark all unread articles in the current newsgroup as read.
3304 If prefix argument N is numeric, the next N newsgroups will be
3305 caught up. If ALL is non-nil, marked articles will also be marked as
3306 read. Cross references (Xref: header) of articles are ignored.
3307 The number of newsgroups that this function was unable to catch
3310 (let ((groups (gnus-group-process-prefix n))
3313 (unless groups (error "No groups selected"))
3315 (or (not gnus-interactive-catchup) ;Without confirmation?
3320 "Do you really want to mark all articles in %s as read? "
3321 "Mark all unread articles in %s as read? ")
3322 (if (= (length groups) 1)
3323 (gnus-group-decoded-name (car groups))
3324 (format "these %d groups" (length groups)))))))
3326 (while (setq group (pop groups))
3327 (gnus-group-remove-mark group)
3328 ;; Virtual groups have to be given special treatment.
3329 (let ((method (gnus-find-method-for-group group)))
3330 (when (eq 'nnvirtual (car method))
3331 (nnvirtual-catchup-group
3332 (gnus-group-real-name group) (nth 1 method) all)))
3333 (if (>= (gnus-group-level group) gnus-level-zombie)
3334 (gnus-message 2 "Dead groups can't be caught up")
3336 (gnus-group-goto-group group)
3337 (gnus-group-catchup group all))
3338 (gnus-group-update-group-line)
3339 (setq ret (1+ ret)))))
3340 (gnus-group-next-unread-group 1)
3343 (defun gnus-group-catchup-current-all (&optional n)
3344 "Mark all articles in current newsgroup as read.
3345 Cross references (Xref: header) of articles are ignored."
3347 (gnus-group-catchup-current n 'all))
3349 (defun gnus-group-catchup (group &optional all)
3350 "Mark all articles in GROUP as read.
3351 If ALL is non-nil, all articles are marked as read.
3352 The return value is the number of articles that were marked as read,
3353 or nil if no action could be taken."
3354 (let* ((entry (gnus-group-entry group))
3356 (marks (gnus-info-marks (nth 2 entry)))
3357 (unread (gnus-sequence-of-unread-articles group)))
3358 ;; Remove entries for this group.
3359 (nnmail-purge-split-history (gnus-group-real-name group))
3360 ;; Do the updating only if the newsgroup isn't killed.
3361 (if (not (numberp (car entry)))
3362 (gnus-message 1 "Can't catch up %s; non-active group" group)
3363 (gnus-update-read-articles group nil)
3365 ;; Nix out the lists of marks and dormants.
3366 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3368 (list (cdr (assq 'dormant marks))
3370 (setq unread (gnus-range-add (gnus-range-add
3371 unread (cdr (assq 'dormant marks)))
3372 (cdr (assq 'tick marks))))
3373 (gnus-add-marked-articles group 'tick nil nil 'force)
3374 (gnus-add-marked-articles group 'dormant nil nil 'force))
3375 ;; Do auto-expirable marks if that's required.
3376 (when (gnus-group-auto-expirable-p group)
3377 (gnus-range-map (lambda (article)
3378 (gnus-add-marked-articles group 'expire (list article))
3379 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3381 (let ((gnus-newsgroup-name group))
3382 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3385 (defun gnus-group-expire-articles (&optional n)
3386 "Expire all expirable articles in the current newsgroup.
3387 Uses the process/prefix convention."
3389 (let ((groups (gnus-group-process-prefix n))
3392 (error "No groups to expire"))
3393 (while (setq group (pop groups))
3394 (gnus-group-remove-mark group)
3395 (gnus-group-expire-articles-1 group)
3396 (gnus-dribble-touch)
3397 (gnus-group-position-point))))
3399 (defun gnus-group-expire-articles-1 (group)
3400 (when (gnus-check-backend-function 'request-expire-articles group)
3401 (gnus-message 6 "Expiring articles in %s..."
3402 (gnus-group-decoded-name group))
3403 (let* ((info (gnus-get-info group))
3404 (expirable (if (gnus-group-total-expirable-p group)
3405 (cons nil (gnus-list-of-read-articles group))
3406 (assq 'expire (gnus-info-marks info))))
3407 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3408 (nnmail-expiry-target
3409 (or (gnus-group-find-parameter group 'expiry-target)
3410 nnmail-expiry-target)))
3412 (gnus-check-group group)
3415 (gnus-compress-sequence
3417 ;; We set the expiry variables to the group
3419 (let ((nnmail-expiry-wait-function nil)
3420 (nnmail-expiry-wait expiry-wait))
3421 (gnus-request-expire-articles
3422 (gnus-uncompress-sequence (cdr expirable)) group))
3423 ;; Just expire using the normal expiry values.
3424 (gnus-request-expire-articles
3425 (gnus-uncompress-sequence (cdr expirable)) group))))
3426 (gnus-close-group group))
3427 (gnus-message 6 "Expiring articles in %s...done"
3428 (gnus-group-decoded-name group))
3429 ;; Return the list of un-expired articles.
3432 (defun gnus-group-expire-all-groups ()
3433 "Expire all expirable articles in all newsgroups."
3436 (gnus-message 5 "Expiring...")
3437 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3438 (cdr gnus-newsrc-alist))))
3439 (gnus-group-expire-articles nil)))
3440 (gnus-group-position-point)
3441 (gnus-message 5 "Expiring...done"))
3443 (defun gnus-group-set-current-level (n level)
3444 "Set the level of the next N groups to LEVEL."
3449 (unless (gnus-group-process-prefix current-prefix-arg)
3450 (error "No group on the current line"))
3452 (let ((s (read-string
3453 (format "Level (default %s): "
3454 (or (gnus-group-group-level)
3455 gnus-level-default-subscribed)))))
3456 (if (string-match "^\\s-*$" s)
3457 (int-to-string (or (gnus-group-group-level)
3458 gnus-level-default-subscribed))
3460 (unless (and (>= level 1) (<= level gnus-level-killed))
3461 (error "Invalid level: %d" level))
3462 (dolist (group (gnus-group-process-prefix n))
3463 (gnus-group-remove-mark group)
3464 (gnus-message 6 "Changed level of %s from %d to %d"
3465 (gnus-group-decoded-name group)
3466 (or (gnus-group-group-level) gnus-level-killed)
3468 (gnus-group-change-level
3469 group level (or (gnus-group-group-level) gnus-level-killed))
3470 (gnus-group-update-group-line))
3471 (gnus-group-position-point))
3473 (defun gnus-group-unsubscribe (&optional n)
3474 "Unsubscribe the current group."
3476 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3478 (defun gnus-group-subscribe (&optional n)
3479 "Subscribe the current group."
3481 (gnus-group-unsubscribe-current-group n 'subscribe))
3483 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3484 "Toggle subscription of the current group.
3485 If given numerical prefix, toggle the N next groups."
3487 (dolist (group (gnus-group-process-prefix n))
3488 (gnus-group-remove-mark group)
3489 (gnus-group-unsubscribe-group
3492 ((eq do-sub 'unsubscribe)
3493 gnus-level-default-unsubscribed)
3494 ((eq do-sub 'subscribe)
3495 gnus-level-default-subscribed)
3496 ((<= (gnus-group-group-level) gnus-level-subscribed)
3497 gnus-level-default-unsubscribed)
3499 gnus-level-default-subscribed))
3501 (gnus-group-update-group-line))
3502 (gnus-group-next-group 1))
3504 (defun gnus-group-unsubscribe-group (group &optional level silent)
3505 "Toggle subscription to GROUP.
3506 Killed newsgroups are subscribed. If SILENT, don't try to update the
3509 (list (gnus-group-completing-read-group-name
3510 "Group: " gnus-active-hashtb nil
3511 (gnus-read-active-file-p)
3513 'gnus-group-history)))
3514 (let ((newsrc (gnus-group-entry group)))
3516 ((string-match "^[ \t]*$" group)
3517 (error "Empty group name"))
3519 ;; Toggle subscription flag.
3520 (gnus-group-change-level
3521 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3522 gnus-level-subscribed)
3523 (1+ gnus-level-subscribed)
3524 gnus-level-default-subscribed)))
3526 (gnus-group-update-group group)))
3527 ((and (stringp group)
3528 (or (not (gnus-read-active-file-p))
3529 (gnus-active group)))
3530 ;; Add new newsgroup.
3531 (gnus-group-change-level
3533 (if level level gnus-level-default-subscribed)
3534 (or (and (member group gnus-zombie-list)
3537 (when (gnus-group-group-name)
3538 (gnus-group-entry (gnus-group-group-name))))
3540 (gnus-group-update-group group)))
3541 (t (error "No such newsgroup: %s" group)))
3542 (gnus-group-position-point)))
3544 (defun gnus-group-transpose-groups (n)
3545 "Move the current newsgroup up N places.
3546 If given a negative prefix, move down instead. The difference between
3547 N and the number of steps taken is returned."
3549 (unless (gnus-group-group-name)
3550 (error "No group on current line"))
3551 (gnus-group-kill-group 1)
3553 (forward-line (- n))
3554 (gnus-group-yank-group)
3555 (gnus-group-position-point)))
3557 (defun gnus-group-kill-all-zombies (&optional dummy)
3558 "Kill all zombie newsgroups.
3559 The optional DUMMY should always be nil."
3560 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3562 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3563 (setq gnus-zombie-list nil)
3564 (gnus-dribble-touch)
3565 (gnus-group-list-groups)))
3567 (defun gnus-group-kill-region (begin end)
3568 "Kill newsgroups in current region (excluding current point).
3569 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3582 (beginning-of-line) ;Important when LINES < 1
3583 (gnus-group-kill-group lines)))
3585 (defun gnus-group-kill-group (&optional n discard)
3586 "Kill the next N groups.
3587 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3588 However, only groups that were alive can be yanked; already killed
3589 groups or zombie groups can't be yanked.
3590 The return value is the name of the group that was killed, or a list
3593 (let ((buffer-read-only nil)
3594 (groups (gnus-group-process-prefix n))
3595 group entry level out)
3596 (if (< (length groups) 10)
3597 ;; This is faster when there are few groups.
3599 (push (setq group (pop groups)) out)
3600 (gnus-group-remove-mark group)
3601 (setq level (gnus-group-group-level))
3603 (when (and (not discard)
3604 (setq entry (gnus-group-entry group)))
3607 (gnus-group-goto-group ,(gnus-group-group-name))
3608 (gnus-group-yank-group)))
3609 (push (cons (car entry) (nth 2 entry))
3610 gnus-list-of-killed-groups))
3611 (gnus-group-change-level
3612 (if entry entry group) gnus-level-killed (if entry nil level))
3613 (message "Killed group %s" (gnus-group-decoded-name group)))
3614 ;; If there are lots and lots of groups to be killed, we use
3615 ;; this thing instead.
3616 (dolist (group (nreverse groups))
3617 (gnus-group-remove-mark group)
3619 (push group gnus-killed-list)
3620 (setq gnus-newsrc-alist
3621 (delq (assoc group gnus-newsrc-alist)
3623 (when gnus-group-change-level-function
3624 (funcall gnus-group-change-level-function
3625 group gnus-level-killed 3))
3627 ((setq entry (gnus-group-entry group))
3628 (push (cons (car entry) (nth 2 entry))
3629 gnus-list-of-killed-groups)
3630 (setcdr (cdr entry) (cdddr entry)))
3631 ((member group gnus-zombie-list)
3632 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3633 ;; There may be more than one instance displayed.
3634 (while (gnus-group-goto-group group)
3635 (gnus-delete-line)))
3636 (gnus-make-hashtable-from-newsrc-alist))
3638 (gnus-group-position-point)
3639 (if (< (length out) 2) (car out) (nreverse out))))
3641 (defun gnus-group-yank-group (&optional arg)
3642 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3643 The numeric ARG specifies how many newsgroups are to be yanked. The
3644 name of the newsgroup yanked is returned, or (if several groups are
3645 yanked) a list of yanked groups is returned."
3647 (setq arg (or arg 1))
3648 (let (info group prev out)
3649 (while (>= (decf arg) 0)
3650 (when (not (setq info (pop gnus-list-of-killed-groups)))
3651 (error "No more newsgroups to yank"))
3652 (push (setq group (nth 1 info)) out)
3653 ;; Find which newsgroup to insert this one before - search
3654 ;; backward until something suitable is found. If there are no
3655 ;; other newsgroups in this buffer, just make this newsgroup the
3657 (setq prev (gnus-group-group-name))
3658 (gnus-group-change-level
3659 info (gnus-info-level (cdr info)) gnus-level-killed
3660 (and prev (gnus-group-entry prev))
3662 (gnus-group-insert-group-line-info group)
3664 `(when (gnus-group-goto-group ,group)
3665 (gnus-group-kill-group 1))))
3667 (gnus-group-position-point)
3668 (if (< (length out) 2) (car out) (nreverse out))))
3670 (defun gnus-group-kill-level (level)
3671 "Kill all groups that is on a certain LEVEL."
3672 (interactive "nKill all groups on level: ")
3674 ((= level gnus-level-zombie)
3675 (setq gnus-killed-list
3676 (nconc gnus-zombie-list gnus-killed-list))
3677 (setq gnus-zombie-list nil))
3678 ((and (< level gnus-level-zombie)
3680 (or gnus-expert-user
3683 "Do you really want to kill all groups on level %d? "
3685 (let* ((prev gnus-newsrc-alist)
3688 (if (= (gnus-info-level (car alist)) level)
3690 (push (gnus-info-group (car alist)) gnus-killed-list)
3691 (setcdr prev (cdr alist)))
3693 (setq alist (cdr alist)))
3694 (gnus-make-hashtable-from-newsrc-alist)
3695 (gnus-group-list-groups)))
3697 (error "Can't kill; invalid level: %d" level))))
3699 (defun gnus-group-list-all-groups (&optional arg)
3700 "List all newsgroups with level ARG or lower.
3701 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3702 unsubscribed groups."
3704 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3706 ;; Redefine this to list ALL killed groups if prefix arg used.
3707 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3708 (defun gnus-group-list-killed (&optional arg)
3709 "List all killed newsgroups in the group buffer.
3710 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3711 entail asking the server for the groups."
3713 ;; Find all possible killed newsgroups if arg.
3715 (gnus-get-killed-groups))
3716 (if (not gnus-killed-list)
3717 (gnus-message 6 "No killed groups")
3718 (let (gnus-group-list-mode)
3719 (funcall gnus-group-prepare-function
3720 gnus-level-killed t gnus-level-killed))
3721 (goto-char (point-min)))
3722 (gnus-group-position-point))
3724 (defun gnus-group-list-zombies ()
3725 "List all zombie newsgroups in the group buffer."
3727 (if (not gnus-zombie-list)
3728 (gnus-message 6 "No zombie groups")
3729 (let (gnus-group-list-mode)
3730 (funcall gnus-group-prepare-function
3731 gnus-level-zombie t gnus-level-zombie))
3732 (goto-char (point-min)))
3733 (gnus-group-position-point))
3735 (defun gnus-group-list-active ()
3736 "List all groups that are available from the server(s)."
3738 ;; First we make sure that we have really read the active file.
3739 (unless (gnus-read-active-file-p)
3740 (let ((gnus-read-active-file t)
3741 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3742 (gnus-read-active-file)))
3743 ;; Find all groups and sort them.
3751 (push (symbol-name sym) list)))
3755 (buffer-read-only nil)
3759 (setq group (pop groups))
3760 (gnus-add-text-properties
3761 (point) (prog1 (1+ (point))
3763 (gnus-group-decoded-name group)
3765 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3767 'gnus-level (inline (gnus-group-level group)))))
3768 (goto-char (point-min))))
3770 (defun gnus-activate-all-groups (level)
3771 "Activate absolutely all groups."
3772 (interactive (list gnus-level-unsubscribed))
3773 (let ((gnus-activate-level level)
3774 (gnus-activate-foreign-newsgroups level))
3775 (gnus-group-get-new-news)))
3777 (defun gnus-group-get-new-news (&optional arg)
3778 "Get newly arrived articles.
3779 If ARG is a number, it specifies which levels you are interested in
3780 re-scanning. If ARG is non-nil and not a number, this will force
3781 \"hard\" re-reading of the active files from all servers."
3784 (let ((gnus-inhibit-demon t)
3785 ;; Binding this variable will inhibit multiple fetchings
3786 ;; of the same mail source.
3787 (nnmail-fetched-sources (list t)))
3788 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3789 (gnus-run-hooks 'gnus-get-new-news-hook)
3791 ;; Read any slave files.
3793 (gnus-master-read-slave-newsrc))
3795 ;; We might read in new NoCeM messages here.
3796 (when (and gnus-use-nocem
3798 (gnus-nocem-scan-groups))
3799 ;; If ARG is not a number, then we read the active file.
3800 (when (and arg (not (numberp arg)))
3801 (let ((gnus-read-active-file t))
3802 (gnus-read-active-file))
3805 ;; If the user wants it, we scan for new groups.
3806 (when (eq gnus-check-new-newsgroups 'always)
3807 (gnus-find-new-newsgroups)))
3809 (setq arg (gnus-group-default-level arg t))
3810 (if (and gnus-read-active-file (not arg))
3812 (gnus-read-active-file)
3813 (gnus-get-unread-articles arg))
3814 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3815 (gnus-get-unread-articles arg)))
3816 (gnus-check-reasonable-setup)
3817 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3818 (gnus-group-list-groups (and (numberp arg)
3819 (max (car gnus-group-list-mode) arg))))
3821 (when (and gnus-agent (not (interactive-p)))
3822 (gnus-agent-toggle-plugged gnus-plugged)))
3824 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3825 "Check for newly arrived news in the current group (and the N-1 next groups).
3826 The difference between N and the number of newsgroup checked is returned.
3827 If N is negative, this group and the N-1 previous groups will be checked.
3828 If DONT-SCAN is non-nil, scan non-activated groups as well."
3830 (let* ((groups (gnus-group-process-prefix n))
3831 (ret (if (numberp n) (- n (length groups)) 0))
3835 (gnus-inhibit-demon t)
3836 ;; Binding this variable will inhibit multiple fetchings
3837 ;; of the same mail source.
3838 (nnmail-fetched-sources (list t)))
3839 (gnus-run-hooks 'gnus-get-new-news-hook)
3840 (while (setq group (pop groups))
3841 (gnus-group-remove-mark group)
3842 ;; Bypass any previous denials from the server.
3843 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3844 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3845 (let ((info (gnus-get-info group))
3846 (active (gnus-active group)))
3848 (gnus-request-update-info info method))
3849 (gnus-get-unread-articles-in-group info active)
3850 (unless (gnus-virtual-group-p group)
3851 (gnus-close-group group))
3853 (gnus-agent-save-group-info
3854 method (gnus-group-real-name group) active))
3855 (gnus-group-update-group group))
3856 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3858 (gnus-error 3 "Server denied access")
3859 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3862 (when gnus-goto-next-group-when-activating
3863 (gnus-group-next-unread-group 1 t))
3864 (gnus-summary-position-point)
3867 (defun gnus-group-fetch-faq (group &optional faq-dir)
3868 "Fetch the FAQ for the current group.
3869 If given a prefix argument, prompt for the FAQ dir
3873 (gnus-group-group-name)
3874 (when current-prefix-arg
3876 "FAQ dir: " (and (listp gnus-group-faq-directory)
3878 gnus-group-faq-directory))))))
3880 (error "No group name given"))
3881 (let ((dirs (or faq-dir gnus-group-faq-directory))
3883 (unless (listp dirs)
3884 (setq dirs (list dirs)))
3885 (while (and (not found)
3886 (setq dir (pop dirs)))
3887 (let ((name (gnus-group-real-name group)))
3888 (setq file (expand-file-name name dir)))
3889 (if (not (file-exists-p file))
3890 (gnus-message 1 "No such file: %s" file)
3891 (let ((enable-local-variables nil))
3895 (defun gnus-group-fetch-charter (group)
3896 "Fetch the charter for the current group.
3897 If given a prefix argument, prompt for a group."
3899 (list (or (when current-prefix-arg
3900 (completing-read "Group: " gnus-active-hashtb))
3901 (gnus-group-group-name)
3902 gnus-newsgroup-name)))
3904 (error "No group name given"))
3906 (condition-case nil (require 'url-http) (error nil))
3907 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3909 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3910 (setq hierarchy (match-string 1 name))
3911 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3912 (if (fboundp 'url-http-file-exists-p)
3913 (url-http-file-exists-p (eval url))
3915 (browse-url (eval url))
3916 (setq url (concat "http://" hierarchy
3917 ".news-admin.org/charters/" name))
3918 (if (and (fboundp 'url-http-file-exists-p)
3919 (url-http-file-exists-p url))
3921 (gnus-group-fetch-control group))))))
3923 (defun gnus-group-fetch-control (group)
3924 "Fetch the archived control messages for the current group.
3925 If given a prefix argument, prompt for a group."
3927 (list (or (when current-prefix-arg
3928 (completing-read "Group: " gnus-active-hashtb))
3929 (gnus-group-group-name)
3930 gnus-newsgroup-name)))
3932 (error "No group name given"))
3933 (let ((name (gnus-group-real-name group))
3935 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3936 (setq hierarchy (match-string 1 name))
3937 (if gnus-group-fetch-control-use-browse-url
3938 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3939 hierarchy "/" name ".gz"))
3940 (let ((enable-local-variables nil))
3941 (gnus-group-read-ephemeral-group
3943 `(nndoc ,group (nndoc-address
3944 ,(find-file-noselect
3945 (concat "/ftp@ftp.isc.org:/usenet/control/"
3946 hierarchy "/" name ".gz")))
3947 (nndoc-article-type mbox)) t nil nil))))))
3949 (defun gnus-group-describe-group (force &optional group)
3950 "Display a description of the current newsgroup."
3951 (interactive (list current-prefix-arg (gnus-group-group-name)))
3952 (let* ((method (gnus-find-method-for-group group))
3953 (mname (gnus-group-prefixed-name "" method))
3956 gnus-description-hashtb)
3957 (gnus-sethash mname nil gnus-description-hashtb))
3959 (error "No group name given"))
3960 (when (or (and gnus-description-hashtb
3961 ;; We check whether this group's method has been
3962 ;; queried for a description file.
3963 (gnus-gethash mname gnus-description-hashtb))
3964 (setq desc (gnus-group-get-description group))
3965 (gnus-read-descriptions-file method))
3967 (or desc (gnus-gethash group gnus-description-hashtb)
3968 "No description available")))))
3970 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3971 (defun gnus-group-describe-all-groups (&optional force)
3972 "Pop up a buffer with descriptions of all newsgroups."
3975 (setq gnus-description-hashtb nil))
3976 (when (not (or gnus-description-hashtb
3977 (gnus-read-all-descriptions-files)))
3978 (error "Couldn't request descriptions file"))
3979 (let ((buffer-read-only nil)
3985 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3986 (insert (format " *: %-20s %s\n"
3987 (gnus-group-name-decode
3988 (symbol-name group) charset)
3989 (gnus-group-name-decode
3990 (symbol-value group) charset))))
3991 (gnus-add-text-properties
3992 b (1+ b) (list 'gnus-group group
3993 'gnus-unread t 'gnus-marked nil
3994 'gnus-level (1+ gnus-level-subscribed))))
3995 gnus-description-hashtb)
3996 (goto-char (point-min))
3997 (gnus-group-position-point)))
3999 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4000 (defun gnus-group-apropos (regexp &optional search-description)
4001 "List all newsgroups that have names that match a regexp."
4002 (interactive "sGnus apropos (regexp): ")
4004 (obuf (current-buffer))
4006 ;; Go through all newsgroups that are known to Gnus.
4009 (and (symbol-name group)
4010 (string-match regexp (symbol-name group))
4011 (symbol-value group)
4012 (push (symbol-name group) groups)))
4014 ;; Also go through all descriptions that are known to Gnus.
4015 (when search-description
4018 (and (string-match regexp (symbol-value group))
4019 (push (symbol-name group) groups)))
4020 gnus-description-hashtb))
4022 (gnus-message 3 "No groups matched \"%s\"." regexp)
4023 ;; Print out all the groups.
4025 (pop-to-buffer "*Gnus Help*")
4026 (buffer-disable-undo)
4028 (setq groups (sort groups 'string<))
4030 ;; Groups may be entered twice into the list of groups.
4031 (when (not (string= (car groups) prev))
4032 (setq prev (car groups))
4033 (let ((charset (gnus-group-name-charset nil prev)))
4034 (insert (gnus-group-name-decode prev charset) "\n")
4035 (when (and gnus-description-hashtb
4036 (setq des (gnus-gethash (car groups)
4037 gnus-description-hashtb)))
4038 (insert " " (gnus-group-name-decode des charset) "\n"))))
4039 (setq groups (cdr groups)))
4040 (goto-char (point-min))))
4041 (pop-to-buffer obuf)))
4043 (defun gnus-group-description-apropos (regexp)
4044 "List all newsgroups that have names or descriptions that match REGEXP."
4045 (interactive "sGnus description apropos (regexp): ")
4046 (when (not (or gnus-description-hashtb
4047 (gnus-read-all-descriptions-files)))
4048 (error "Couldn't request descriptions file"))
4049 (gnus-group-apropos regexp t))
4051 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4052 (defun gnus-group-list-matching (level regexp &optional all lowest)
4053 "List all groups with unread articles that match REGEXP.
4054 If the prefix LEVEL is non-nil, it should be a number that says which
4055 level to cut off listing groups.
4056 If ALL, also list groups with no unread articles.
4057 If LOWEST, don't list groups with level lower than LOWEST.
4059 This command may read the active file."
4060 (interactive "P\nsList newsgroups matching: ")
4061 ;; First make sure active file has been read.
4063 (> (prefix-numeric-value level) gnus-level-killed))
4064 (gnus-get-killed-groups))
4065 (funcall gnus-group-prepare-function
4066 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4067 (goto-char (point-min))
4068 (gnus-group-position-point))
4070 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4071 "List all groups that match REGEXP.
4072 If the prefix LEVEL is non-nil, it should be a number that says which
4073 level to cut off listing groups.
4074 If LOWEST, don't list groups with level lower than LOWEST."
4075 (interactive "P\nsList newsgroups matching: ")
4077 (setq level (prefix-numeric-value level)))
4078 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4080 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4081 (defun gnus-group-save-newsrc (&optional force)
4082 "Save the Gnus startup files.
4083 If FORCE, force saving whether it is necessary or not."
4085 (gnus-save-newsrc-file force))
4087 (defun gnus-group-restart (&optional arg)
4088 "Force Gnus to read the .newsrc file."
4090 (when (gnus-yes-or-no-p
4091 (format "Are you sure you want to restart Gnus? "))
4092 (gnus-save-newsrc-file)
4096 (defun gnus-group-read-init-file ()
4097 "Read the Gnus elisp init file."
4099 (gnus-read-init-file)
4100 (gnus-message 5 "Read %s" gnus-init-file))
4102 (defun gnus-group-check-bogus-groups (&optional silent)
4103 "Check bogus newsgroups.
4104 If given a prefix, don't ask for confirmation before removing a bogus
4107 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4108 (gnus-group-list-groups))
4110 (defun gnus-group-find-new-groups (&optional arg)
4111 "Search for new groups and add them.
4112 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4113 With 1 C-u, use the `ask-server' method to query the server for new
4115 With 2 C-u's, use most complete method possible to query the server
4116 for new groups, and subscribe the new groups as zombies."
4118 (gnus-find-new-newsgroups (or arg 1))
4119 (gnus-group-list-groups))
4121 (defun gnus-group-edit-global-kill (&optional article group)
4122 "Edit the global kill file.
4123 If GROUP, edit that local kill file instead."
4125 (setq gnus-current-kill-article article)
4126 (gnus-kill-file-edit-file group)
4129 (substitute-command-keys
4130 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4131 (if group "local" "global")))))
4133 (defun gnus-group-edit-local-kill (article group)
4134 "Edit a local kill file."
4135 (interactive (list nil (gnus-group-group-name)))
4136 (gnus-group-edit-global-kill article group))
4138 (defun gnus-group-force-update ()
4139 "Update `.newsrc' file."
4141 (gnus-save-newsrc-file))
4143 (defvar gnus-backlog-articles)
4145 (defun gnus-group-suspend ()
4146 "Suspend the current Gnus session.
4147 In fact, cleanup buffers except for group mode buffer.
4148 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4150 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4151 (gnus-offer-save-summaries)
4152 ;; Kill Gnus buffers except for group mode buffer.
4153 (let ((group-buf (get-buffer gnus-group-buffer)))
4154 (mapcar (lambda (buf)
4155 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4156 (with-current-buffer buf
4157 (eq major-mode 'message-mode)))
4158 (gnus-kill-buffer buf)))
4160 (setq gnus-backlog-articles nil)
4161 (gnus-kill-gnus-frames)
4163 (bury-buffer group-buf)
4164 (delete-windows-on group-buf t))))
4166 (defun gnus-group-clear-dribble ()
4167 "Clear all information from the dribble buffer."
4169 (gnus-dribble-clear)
4170 (gnus-message 7 "Cleared dribble buffer"))
4172 (defun gnus-group-exit ()
4173 "Quit reading news after updating .newsrc.eld and .newsrc.
4174 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4177 (or noninteractive ;For gnus-batch-kill
4178 (not gnus-interactive-exit) ;Without confirmation
4180 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4181 (gnus-run-hooks 'gnus-exit-gnus-hook)
4182 ;; Offer to save data from non-quitted summary buffers.
4183 (gnus-offer-save-summaries)
4184 ;; Save the newsrc file(s).
4185 (gnus-save-newsrc-file)
4187 (gnus-close-backends)
4188 ;; Reset everything.
4190 ;; Allow the user to do things after cleaning up.
4191 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4193 (defun gnus-group-quit ()
4194 "Quit reading news without updating .newsrc.eld or .newsrc.
4195 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4197 (when (or noninteractive ;For gnus-batch-kill
4198 (zerop (buffer-size))
4199 (not (gnus-server-opened gnus-select-method))
4201 (not gnus-current-startup-file)
4203 (format "Quit reading news without saving %s? "
4204 (file-name-nondirectory gnus-current-startup-file))))
4205 (gnus-run-hooks 'gnus-exit-gnus-hook)
4206 (gnus-configure-windows 'group t)
4207 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4208 (not (zerop (save-excursion
4209 (set-buffer gnus-dribble-buffer)
4212 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4214 (gnus-close-backends)
4216 (gnus-kill-buffer gnus-group-buffer)
4217 ;; Allow the user to do things after cleaning up.
4218 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4220 (defun gnus-group-describe-briefly ()
4221 "Give a one line description of the group mode commands."
4223 (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")))
4225 (defun gnus-group-browse-foreign-server (method)
4226 "Browse a foreign news server.
4227 If called interactively, this function will ask for a select method
4228 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4229 If not, METHOD should be a list where the first element is the method
4230 and the second element is the address."
4232 (list (let ((how (completing-read
4234 (append gnus-valid-select-methods gnus-server-alist)
4235 nil t (cons "nntp" 0) 'gnus-method-history)))
4236 ;; We either got a back end name or a virtual server name.
4237 ;; If the first, we also need an address.
4238 (if (assoc how gnus-valid-select-methods)
4240 ;; Suggested by mapjph@bath.ac.uk.
4243 (mapcar 'list gnus-secondary-servers)))
4244 ;; We got a server name.
4246 (gnus-browse-foreign-server method))
4248 (defun gnus-group-set-info (info &optional method-only-group part)
4249 (when (or info part)
4250 (let* ((entry (gnus-group-entry
4251 (or method-only-group (gnus-info-group info))))
4253 (info (if method-only-group (nth 2 entry) info))
4255 (when method-only-group
4257 (error "Trying to change non-existent group %s" method-only-group))
4258 ;; We have received parts of the actual group info - either the
4259 ;; select method or the group parameters. We first check
4260 ;; whether we have to extend the info, and if so, do that.
4261 (let ((len (length info))
4262 (total (if (eq part 'method) 5 6)))
4264 (setcdr (nthcdr (1- len) info)
4265 (make-list (- total len) nil)))
4266 ;; Then we enter the new info.
4267 (setcar (nthcdr (1- total) info) part-info)))
4269 ;; This is a new group, so we just create it.
4271 (set-buffer gnus-group-buffer)
4272 (setq method (gnus-info-method info))
4273 (when (gnus-server-equal method "native")
4276 (set-buffer gnus-group-buffer)
4278 ;; It's a foreign group...
4279 (gnus-group-make-group
4280 (gnus-group-real-name (gnus-info-group info))
4281 (if (stringp method) method
4282 (prin1-to-string (car method)))
4284 (nth 1 (gnus-info-method info))))
4285 ;; It's a native group.
4286 (gnus-group-make-group (gnus-info-group info))))
4287 (gnus-message 6 "Note: New group created")
4289 (gnus-group-entry (gnus-group-prefixed-name
4290 (gnus-group-real-name (gnus-info-group info))
4291 (or (gnus-info-method info) gnus-select-method))))))
4292 ;; Whether it was a new group or not, we now have the entry, so we
4293 ;; can do the update.
4296 (setcar (nthcdr 2 entry) info)
4297 (when (and (not (eq (car entry) t))
4298 (gnus-active (gnus-info-group info)))
4299 (setcar entry (length
4300 (gnus-list-of-unread-articles (car info))))))
4301 (error "No such group: %s" (gnus-info-group info))))))
4303 (defun gnus-group-set-method-info (group select-method)
4304 (gnus-group-set-info select-method group 'method))
4306 (defun gnus-group-set-params-info (group params)
4307 (gnus-group-set-info params group 'params))
4309 (defun gnus-add-marked-articles (group type articles &optional info force)
4310 ;; Add ARTICLES of TYPE to the info of GROUP.
4311 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4312 ;; add, but replace marked articles of TYPE with ARTICLES.
4313 (let ((info (or info (gnus-get-info group)))
4316 (and (not (setq marked (nthcdr 3 info)))
4318 (setcdr (nthcdr 2 info)
4319 (list (list (cons type (gnus-compress-sequence
4321 (and (not (setq m (assq type (car marked))))
4324 (cons (cons type (gnus-compress-sequence articles t) )
4328 (setcar (nthcdr 3 info)
4329 (gnus-delete-alist type (car marked)))
4330 (setcdr m (gnus-compress-sequence articles t)))
4331 (setcdr m (gnus-compress-sequence
4332 (sort (nconc (gnus-uncompress-range (cdr m))
4333 (copy-sequence articles)) '<) t))))))
4335 (defun gnus-add-mark (group mark article)
4336 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4337 (let ((buffer (gnus-summary-buffer-name group)))
4338 (if (gnus-buffer-live-p buffer)
4340 (set-buffer (get-buffer buffer))
4341 (gnus-summary-add-mark article mark))
4342 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4346 ;;; Group timestamps
4349 (defun gnus-group-set-timestamp ()
4350 "Change the timestamp of the current group to the current time.
4351 This function can be used in hooks like `gnus-select-group-hook'
4352 or `gnus-group-catchup-group-hook'."
4353 (when gnus-newsgroup-name
4354 (let ((time (current-time)))
4355 (setcdr (cdr time) nil)
4356 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4358 (defsubst gnus-group-timestamp (group)
4359 "Return the timestamp for GROUP."
4360 (gnus-group-get-parameter group 'timestamp t))
4362 (defun gnus-group-timestamp-delta (group)
4363 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4364 (let* ((time (or (gnus-group-timestamp group)
4366 (delta (subtract-time (current-time) time)))
4367 (+ (* (nth 0 delta) 65536.0)
4370 (defun gnus-group-timestamp-string (group)
4371 "Return a string of the timestamp for GROUP."
4372 (let ((time (gnus-group-timestamp group)))
4375 (gnus-time-iso8601 time))))
4377 (defun gnus-group-list-cached (level &optional lowest)
4378 "List all groups with cached articles.
4379 If the prefix LEVEL is non-nil, it should be a number that says which
4380 level to cut off listing groups.
4381 If LOWEST, don't list groups with level lower than LOWEST.
4383 This command may read the active file."
4386 (setq level (prefix-numeric-value level)))
4387 (when (or (not level) (>= level gnus-level-zombie))
4389 (funcall gnus-group-prepare-function
4390 (or level gnus-level-subscribed)
4392 (let ((marks (gnus-info-marks info)))
4393 (assq 'cache marks)))
4396 (or (gnus-gethash group
4397 gnus-cache-active-hashtb)
4398 ;; Cache active file might use "."
4401 (mapconcat 'identity
4402 (split-string group ":")
4404 gnus-cache-active-hashtb))))
4405 (goto-char (point-min))
4406 (gnus-group-position-point))
4408 (defun gnus-group-list-dormant (level &optional lowest)
4409 "List all groups with dormant articles.
4410 If the prefix LEVEL is non-nil, it should be a number that says which
4411 level to cut off listing groups.
4412 If LOWEST, don't list groups with level lower than LOWEST.
4414 This command may read the active file."
4417 (setq level (prefix-numeric-value level)))
4418 (when (or (not level) (>= level gnus-level-zombie))
4420 (funcall gnus-group-prepare-function
4421 (or level gnus-level-subscribed)
4423 (let ((marks (gnus-info-marks info)))
4424 (assq 'dormant marks)))
4427 (goto-char (point-min))
4428 (gnus-group-position-point))
4430 (defun gnus-group-listed-groups ()
4431 "Return a list of listed groups."
4433 (goto-char (point-min))
4434 (while (setq point (text-property-not-all (point) (point-max)
4437 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4441 (defun gnus-group-list-plus (&optional args)
4442 "List groups plus the current selection."
4444 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4445 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4447 (push last-command-event unread-command-events)
4448 (if (featurep 'xemacs)
4449 (push (make-event 'key-press '(key ?A)) unread-command-events)
4450 (push ?A unread-command-events))
4451 (let (gnus-pick-mode keys)
4452 (setq keys (if (featurep 'xemacs)
4453 (events-to-keys (read-key-sequence nil))
4454 (read-key-sequence nil)))
4455 (setq func (lookup-key (current-local-map) keys)))
4459 (call-interactively func))))
4461 (defun gnus-group-list-flush (&optional args)
4462 "Flush groups from the current selection."
4464 (let ((gnus-group-list-option 'flush))
4465 (gnus-group-list-plus args)))
4467 (defun gnus-group-list-limit (&optional args)
4468 "List groups limited within the current selection."
4470 (let ((gnus-group-list-option 'limit))
4471 (gnus-group-list-plus args)))
4473 (defun gnus-group-mark-article-read (group article)
4474 "Mark ARTICLE read."
4475 (let ((buffer (gnus-summary-buffer-name group))
4476 (mark gnus-read-mark)
4478 (if (get-buffer buffer)
4479 (with-current-buffer buffer
4480 (setq active gnus-newsgroup-active)
4481 (gnus-activate-group group)
4482 (when gnus-newsgroup-prepared
4483 (when (and gnus-newsgroup-auto-expire
4484 (memq mark gnus-auto-expirable-marks))
4485 (setq mark gnus-expirable-mark))
4486 (setq mark (gnus-request-update-mark
4487 group article mark))
4488 (gnus-mark-article-as-read article mark)
4489 (setq gnus-newsgroup-active (gnus-active group))
4491 (setq n (1+ (cdr active)))
4492 (while (<= n (cdr gnus-newsgroup-active))
4493 (unless (eq n article)
4494 (push n gnus-newsgroup-unselected))
4496 (setq gnus-newsgroup-unselected
4497 (nreverse gnus-newsgroup-unselected)))))
4498 (gnus-activate-group group)
4499 (gnus-group-make-articles-read group (list article))
4500 (when (gnus-group-auto-expirable-p group)
4501 (gnus-add-marked-articles
4502 group 'expire (list article))))))
4506 ;;; Group compaction. -- dvl
4509 (defun gnus-group-compact-group (group)
4510 "Compact the current group.
4511 Compaction means removing gaps between article numbers. Hence, this
4512 operation is only meaningful for back ends using one file per article
4515 Note: currently only implemented in nnml."
4516 (interactive (list (gnus-group-group-name)))
4518 (error "No group to compact"))
4519 (unless (gnus-check-backend-function 'request-compact-group group)
4520 (error "This back end does not support group compaction"))
4521 (let ((group-decoded (gnus-group-decoded-name group)))
4523 Compacting group %s... (this may take a long time)"
4526 (if (not (gnus-request-compact-group group))
4527 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4528 (gnus-message 6 "Compacting group %s...done" group-decoded)
4530 ;; Invalidate the "original article" buffer which might be out of date.
4531 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4532 ;; #### will not happen very often, I think this is acceptable.
4533 (let ((original (get-buffer gnus-original-article-buffer)))
4534 (and original (gnus-kill-buffer original)))
4535 ;; Update the group line to reflect new information (art number etc).
4536 (gnus-group-update-group-line))))
4538 (provide 'gnus-group)
4540 ;;; gnus-group.el ends here