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-mode))
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 %n Select from where (string)
187 %z A string that look like `<%s:%n>' if a foreign select method is used
188 %d The date the group was last entered.
189 %E Icon as defined by `gnus-group-icon-list'.
190 %F The disk space used by the articles fetched by both the cache and agent.
191 %u User defined specifier. The next character in the format string should
192 be a letter. Gnus will call the function gnus-user-format-function-X,
193 where X is the letter following %u. The function will be passed a
194 single dummy parameter as argument. The function should return a
195 string, which will be inserted into the buffer just like information
196 from any other group specifier.
198 Note that this format specification is not always respected. For
199 reasons of efficiency, when listing killed groups, this specification
200 is ignored altogether. If the spec is changed considerably, your
201 output may end up looking strange when listing both alive and killed
204 If you use %o or %O, reading the active file will be slower and quite
205 a bit of extra memory will be used. %D and %F will also worsen
206 performance. Also note that if you change the format specification to
207 include any of these specs, you must probably re-start Gnus to see
210 General format specifiers can also be used.
211 See Info node `(gnus)Formatting Variables'."
212 :link '(custom-manual "(gnus)Formatting Variables")
213 :group 'gnus-group-visual
216 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
217 "*The format specification for the group mode line.
218 It works along the same lines as a normal formatting string,
219 with some simple extensions:
221 %S The native news server.
222 %M The native select method.
223 %: \":\" if %S isn't \"\"."
224 :group 'gnus-group-visual
227 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
228 (when (featurep 'xemacs)
229 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
230 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
232 (defcustom gnus-group-menu-hook nil
233 "Hook run after the creation of the group mode menu."
234 :group 'gnus-group-various
237 (defcustom gnus-group-catchup-group-hook nil
238 "Hook run when catching up a group from the group buffer."
239 :group 'gnus-group-various
240 :link '(custom-manual "(gnus)Group Data")
243 (defcustom gnus-group-update-group-hook nil
244 "Hook called when updating group lines."
245 :group 'gnus-group-visual
248 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
249 "*A function that is called to generate the group buffer.
250 The function is called with three arguments: The first is a number;
251 all group with a level less or equal to that number should be listed,
252 if the second is non-nil, empty groups should also be displayed. If
253 the third is non-nil, it is a number. No groups with a level lower
254 than this number should be displayed.
256 The only current function implemented is `gnus-group-prepare-flat'."
257 :group 'gnus-group-listing
260 (defcustom gnus-group-prepare-hook nil
261 "Hook called after the group buffer has been generated.
262 If you want to modify the group buffer, you can use this hook."
263 :group 'gnus-group-listing
266 (defcustom gnus-suspend-gnus-hook nil
267 "Hook called when suspending (not exiting) Gnus."
271 (defcustom gnus-exit-gnus-hook nil
272 "Hook called when exiting Gnus."
276 (defcustom gnus-after-exiting-gnus-hook nil
277 "Hook called after exiting Gnus."
281 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
282 "Hook called when a group line is changed.
283 The hook will not be called if `gnus-visual' is nil.
285 The default function `gnus-group-highlight-line' will
286 highlight the line according to the `gnus-group-highlight'
288 :group 'gnus-group-visual
291 (defcustom gnus-useful-groups
292 '(("(ding) mailing list mirrored at gmane.org"
293 "gmane.emacs.gnus.general"
295 (nntp-address "news.gmane.org")))
298 (nntp "news.gnus.org"
299 (nntp-address "news.gnus.org")))
300 ("Local Gnus help group"
303 (nndoc-article-type mbox)
304 (eval `(nndoc-address
305 ,(let ((file (nnheader-find-etc-directory
308 (error "Couldn't find doc group"))
310 "*Alist of useful group-server pairs."
311 :group 'gnus-group-listing
312 :type '(repeat (list (string :tag "Description")
314 (sexp :tag "Method"))))
316 (defcustom gnus-group-highlight
318 ((and mailp (= unread 0) (eq level 1)) .
319 gnus-group-mail-1-empty)
320 ((and mailp (eq level 1)) .
322 ((and mailp (= unread 0) (eq level 2)) .
323 gnus-group-mail-2-empty)
324 ((and mailp (eq level 2)) .
326 ((and mailp (= unread 0) (eq level 3)) .
327 gnus-group-mail-3-empty)
328 ((and mailp (eq level 3)) .
330 ((and mailp (= unread 0)) .
331 gnus-group-mail-low-empty)
335 ((and (= unread 0) (eq level 1)) .
336 gnus-group-news-1-empty)
337 ((and (eq level 1)) .
339 ((and (= unread 0) (eq level 2)) .
340 gnus-group-news-2-empty)
341 ((and (eq level 2)) .
343 ((and (= unread 0) (eq level 3)) .
344 gnus-group-news-3-empty)
345 ((and (eq level 3)) .
347 ((and (= unread 0) (eq level 4)) .
348 gnus-group-news-4-empty)
349 ((and (eq level 4)) .
351 ((and (= unread 0) (eq level 5)) .
352 gnus-group-news-5-empty)
353 ((and (eq level 5)) .
355 ((and (= unread 0) (eq level 6)) .
356 gnus-group-news-6-empty)
357 ((and (eq level 6)) .
359 ((and (= unread 0)) .
360 gnus-group-news-low-empty)
362 gnus-group-news-low))
363 "*Controls the highlighting of group buffer lines.
365 Below is a list of `Form'/`Face' pairs. When deciding how a a
366 particular group line should be displayed, each form is
367 evaluated. The content of the face field after the first true form is
368 used. You can change how those group lines are displayed by
369 editing the face field.
371 It is also possible to change and add form fields, but currently that
372 requires an understanding of Lisp expressions. Hopefully this will
373 change in a future release. For now, you can use the following
374 variables in the Lisp expression:
376 group: The name of the group.
377 unread: The number of unread articles in the group.
378 method: The select method used.
379 mailp: Whether it's a mail group or not.
380 level: The level of the group.
381 score: The score of the group.
382 ticked: The number of ticked articles."
383 :group 'gnus-group-visual
384 :type '(repeat (cons (sexp :tag "Form") face)))
386 (defcustom gnus-new-mail-mark ?%
387 "Mark used for groups with new mail."
388 :group 'gnus-group-visual
391 (defgroup gnus-group-icons nil
392 "Add Icons to your group buffer."
393 :group 'gnus-group-visual)
395 (defcustom gnus-group-icon-list
397 "*Controls the insertion of icons into group buffer lines.
399 Below is a list of `Form'/`File' pairs. When deciding how a
400 particular group line should be displayed, each form is evaluated.
401 The icon from the file field after the first true form is used. You
402 can change how those group lines are displayed by editing the file
403 field. The File will either be found in the
404 `gnus-group-glyph-directory' or by designating absolute name of the
407 It is also possible to change and add form fields, but currently that
408 requires an understanding of Lisp expressions. Hopefully this will
409 change in a future release. For now, you can use the following
410 variables in the Lisp expression:
412 group: The name of the group.
413 unread: The number of unread articles in the group.
414 method: The select method used.
415 mailp: Whether it's a mail group or not.
416 newsp: Whether it's a news group or not
417 level: The level of the group.
418 score: The score of the group.
419 ticked: The number of ticked articles."
420 :group 'gnus-group-icons
421 :type '(repeat (cons (sexp :tag "Form") file)))
423 (defcustom gnus-group-name-charset-method-alist nil
424 "Alist of method and the charset for group names.
427 (((nntp \"news.com.cn\") . cn-gb-2312))"
430 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
432 (defcustom gnus-group-name-charset-group-alist
433 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
434 (mm-coding-system-p '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 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
528 (?u gnus-tmp-user-defined ?s)
529 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
532 (defvar gnus-group-mode-line-format-alist
533 `((?S gnus-tmp-news-server ?s)
534 (?M gnus-tmp-news-method ?s)
535 (?u gnus-tmp-user-defined ?s)
536 (?: gnus-tmp-colon ?s)))
538 (defvar gnus-topic-topology nil
539 "The complete topic hierarchy.")
541 (defvar gnus-topic-alist nil
542 "The complete topic-group alist.")
544 (defvar gnus-group-marked nil)
546 (defvar gnus-group-list-mode nil)
549 (defvar gnus-group-icon-cache nil)
551 (defvar gnus-group-listed-groups nil)
552 (defvar gnus-group-list-option nil)
558 (put 'gnus-group-mode 'mode-class 'special)
560 (gnus-define-keys gnus-group-mode-map
561 " " gnus-group-read-group
562 "=" gnus-group-select-group
563 "\r" gnus-group-select-group
564 "\M-\r" gnus-group-quick-select-group
565 "\M- " gnus-group-visible-select-group
566 [(meta control return)] gnus-group-select-group-ephemerally
567 "j" gnus-group-jump-to-group
568 "n" gnus-group-next-unread-group
569 "p" gnus-group-prev-unread-group
570 "\177" gnus-group-prev-unread-group
571 [delete] gnus-group-prev-unread-group
572 [backspace] gnus-group-prev-unread-group
573 "N" gnus-group-next-group
574 "P" gnus-group-prev-group
575 "\M-n" gnus-group-next-unread-group-same-level
576 "\M-p" gnus-group-prev-unread-group-same-level
577 "," gnus-group-best-unread-group
578 "." gnus-group-first-unread-group
579 "u" gnus-group-unsubscribe-current-group
580 "U" gnus-group-unsubscribe-group
581 "c" gnus-group-catchup-current
582 "C" gnus-group-catchup-current-all
583 "\M-c" gnus-group-clear-data
584 "l" gnus-group-list-groups
585 "L" gnus-group-list-all-groups
588 "g" gnus-group-get-new-news
589 "\M-g" gnus-group-get-new-news-this-group
590 "R" gnus-group-restart
591 "r" gnus-group-read-init-file
592 "B" gnus-group-browse-foreign-server
593 "b" gnus-group-check-bogus-groups
594 "F" gnus-group-find-new-groups
595 "\C-c\C-d" gnus-group-describe-group
596 "\M-d" gnus-group-describe-all-groups
597 "\C-c\C-a" gnus-group-apropos
598 "\C-c\M-\C-a" gnus-group-description-apropos
599 "a" gnus-group-post-news
600 "\ek" gnus-group-edit-local-kill
601 "\eK" gnus-group-edit-global-kill
602 "\C-k" gnus-group-kill-group
603 "\C-y" gnus-group-yank-group
604 "\C-w" gnus-group-kill-region
605 "\C-x\C-t" gnus-group-transpose-groups
606 "\C-c\C-l" gnus-group-list-killed
607 "\C-c\C-x" gnus-group-expire-articles
608 "\C-c\M-\C-x" gnus-group-expire-all-groups
610 "s" gnus-group-save-newsrc
611 "z" gnus-group-suspend
614 "?" gnus-group-describe-briefly
615 "\C-c\C-i" gnus-info-find-node
616 "\M-e" gnus-group-edit-group-method
617 "^" gnus-group-enter-server-mode
618 gnus-mouse-2 gnus-mouse-pick-group
619 [follow-link] mouse-face
620 "<" beginning-of-buffer
623 "\C-c\C-s" gnus-group-sort-groups
625 "\C-c\M-g" gnus-activate-all-groups
626 "\M-&" gnus-group-universal-argument
627 "#" gnus-group-mark-group
628 "\M-#" gnus-group-unmark-group)
630 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
631 "m" gnus-group-mark-group
632 "u" gnus-group-unmark-group
633 "w" gnus-group-mark-region
634 "b" gnus-group-mark-buffer
635 "r" gnus-group-mark-regexp
636 "U" gnus-group-unmark-all-groups)
638 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
639 "u" gnus-sieve-update
640 "g" gnus-sieve-generate)
642 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
643 "d" gnus-group-make-directory-group
644 "h" gnus-group-make-help-group
645 "u" gnus-group-make-useful-group
646 "a" gnus-group-make-archive-group
647 "k" gnus-group-make-kiboze-group
648 "l" gnus-group-nnimap-edit-acl
649 "m" gnus-group-make-group
650 "E" gnus-group-edit-group
651 "e" gnus-group-edit-group-method
652 "p" gnus-group-edit-group-parameters
653 "v" gnus-group-add-to-virtual
654 "V" gnus-group-make-empty-virtual
655 "D" gnus-group-enter-directory
656 "f" gnus-group-make-doc-group
657 "w" gnus-group-make-web-group
658 "M" gnus-group-read-ephemeral-group
659 "r" gnus-group-rename-group
660 "R" gnus-group-make-rss-group
661 "c" gnus-group-customize
662 "z" gnus-group-compact-group
663 "x" gnus-group-nnimap-expunge
664 "\177" gnus-group-delete-group
665 [delete] gnus-group-delete-group)
667 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
668 "b" gnus-group-brew-soup
669 "w" gnus-soup-save-areas
670 "s" gnus-soup-send-replies
671 "p" gnus-soup-pack-packet
672 "r" nnsoup-pack-replies)
674 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
675 "s" gnus-group-sort-groups
676 "a" gnus-group-sort-groups-by-alphabet
677 "u" gnus-group-sort-groups-by-unread
678 "l" gnus-group-sort-groups-by-level
679 "v" gnus-group-sort-groups-by-score
680 "r" gnus-group-sort-groups-by-rank
681 "m" gnus-group-sort-groups-by-method
682 "n" gnus-group-sort-groups-by-real-name)
684 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
685 "s" gnus-group-sort-selected-groups
686 "a" gnus-group-sort-selected-groups-by-alphabet
687 "u" gnus-group-sort-selected-groups-by-unread
688 "l" gnus-group-sort-selected-groups-by-level
689 "v" gnus-group-sort-selected-groups-by-score
690 "r" gnus-group-sort-selected-groups-by-rank
691 "m" gnus-group-sort-selected-groups-by-method
692 "n" gnus-group-sort-selected-groups-by-real-name)
694 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
695 "k" gnus-group-list-killed
696 "z" gnus-group-list-zombies
697 "s" gnus-group-list-groups
698 "u" gnus-group-list-all-groups
699 "A" gnus-group-list-active
700 "a" gnus-group-apropos
701 "d" gnus-group-description-apropos
702 "m" gnus-group-list-matching
703 "M" gnus-group-list-all-matching
704 "l" gnus-group-list-level
705 "c" gnus-group-list-cached
706 "?" gnus-group-list-dormant)
708 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
709 "k" gnus-group-list-limit
710 "z" gnus-group-list-limit
711 "s" gnus-group-list-limit
712 "u" gnus-group-list-limit
713 "A" gnus-group-list-limit
714 "m" gnus-group-list-limit
715 "M" gnus-group-list-limit
716 "l" gnus-group-list-limit
717 "c" gnus-group-list-limit
718 "?" gnus-group-list-limit)
720 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
721 "k" gnus-group-list-flush
722 "z" gnus-group-list-flush
723 "s" gnus-group-list-flush
724 "u" gnus-group-list-flush
725 "A" gnus-group-list-flush
726 "m" gnus-group-list-flush
727 "M" gnus-group-list-flush
728 "l" gnus-group-list-flush
729 "c" gnus-group-list-flush
730 "?" gnus-group-list-flush)
732 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
733 "k" gnus-group-list-plus
734 "z" gnus-group-list-plus
735 "s" gnus-group-list-plus
736 "u" gnus-group-list-plus
737 "A" gnus-group-list-plus
738 "m" gnus-group-list-plus
739 "M" gnus-group-list-plus
740 "l" gnus-group-list-plus
741 "c" gnus-group-list-plus
742 "?" gnus-group-list-plus)
744 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
745 "f" gnus-score-flush-cache
746 "e" gnus-score-edit-all-score)
748 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
749 "c" gnus-group-fetch-charter
750 "C" gnus-group-fetch-control
751 "d" gnus-group-describe-group
752 "f" gnus-group-fetch-faq
755 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
756 "l" gnus-group-set-current-level
757 "t" gnus-group-unsubscribe-current-group
758 "s" gnus-group-unsubscribe-group
759 "k" gnus-group-kill-group
760 "y" gnus-group-yank-group
761 "w" gnus-group-kill-region
762 "\C-k" gnus-group-kill-level
763 "z" gnus-group-kill-all-zombies)
765 (defun gnus-topic-mode-p ()
766 "Return non-nil in `gnus-topic-mode'."
767 (and (boundp 'gnus-topic-mode)
768 (symbol-value 'gnus-topic-mode)))
770 (defun gnus-group-make-menu-bar ()
771 (gnus-turn-off-edit-menu 'group)
772 (unless (boundp 'gnus-group-reading-menu)
775 gnus-group-reading-menu gnus-group-mode-map ""
777 ["Read" gnus-group-read-group
778 :included (not (gnus-topic-mode-p))
779 :active (gnus-group-group-name)]
780 ["Read " gnus-topic-read-group
781 :included (gnus-topic-mode-p)]
782 ["Select" gnus-group-select-group
783 :included (not (gnus-topic-mode-p))
784 :active (gnus-group-group-name)]
785 ["Select " gnus-topic-select-group
786 :included (gnus-topic-mode-p)]
787 ["See old articles" (gnus-group-select-group 'all)
788 :keys "C-u SPC" :active (gnus-group-group-name)]
789 ["Catch up" gnus-group-catchup-current
790 :included (not (gnus-topic-mode-p))
791 :active (gnus-group-group-name)
792 ,@(if (featurep 'xemacs) nil
793 '(:help "Mark unread articles in the current group as read"))]
794 ["Catch up " gnus-topic-catchup-articles
795 :included (gnus-topic-mode-p)
796 ,@(if (featurep 'xemacs) nil
797 '(:help "Mark unread articles in the current group or topic as read"))]
798 ["Catch up all articles" gnus-group-catchup-current-all
799 (gnus-group-group-name)]
800 ["Check for new articles" gnus-group-get-new-news-this-group
801 :included (not (gnus-topic-mode-p))
802 :active (gnus-group-group-name)
803 ,@(if (featurep 'xemacs) nil
804 '(:help "Check for new messages in current group"))]
805 ["Check for new articles " gnus-topic-get-new-news-this-topic
806 :included (gnus-topic-mode-p)
807 ,@(if (featurep 'xemacs) nil
808 '(:help "Check for new messages in current group or topic"))]
809 ["Toggle subscription" gnus-group-unsubscribe-current-group
810 (gnus-group-group-name)]
811 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
812 ,@(if (featurep 'xemacs) nil
813 '(:help "Kill (remove) current group"))]
814 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
815 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
816 ,@(if (featurep 'xemacs) nil
817 '(:help "Display description of the current group"))]
818 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
819 ["Fetch charter" gnus-group-fetch-charter
820 :active (gnus-group-group-name)
821 ,@(if (featurep 'xemacs) nil
822 '(:help "Display the charter of the current group"))]
823 ["Fetch control message" gnus-group-fetch-control
824 :active (gnus-group-group-name)
825 ,@(if (featurep 'xemacs) nil
826 '(:help "Display the archived control message for the current group"))]
827 ;; Actually one should check, if any of the marked groups gives t for
828 ;; (gnus-check-backend-function 'request-expire-articles ...)
829 ["Expire articles" gnus-group-expire-articles
830 :included (not (gnus-topic-mode-p))
831 :active (or (and (gnus-group-group-name)
832 (gnus-check-backend-function
833 'request-expire-articles
834 (gnus-group-group-name))) gnus-group-marked)]
835 ["Expire articles " gnus-topic-expire-articles
836 :included (gnus-topic-mode-p)]
837 ["Set group level..." gnus-group-set-current-level
838 (gnus-group-group-name)]
839 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
840 ["Customize" gnus-group-customize (gnus-group-group-name)]
841 ["Compact" gnus-group-compact-group
842 :active (gnus-group-group-name)]
844 ["Parameters" gnus-group-edit-group-parameters
845 :included (not (gnus-topic-mode-p))
846 :active (gnus-group-group-name)]
847 ["Parameters " gnus-topic-edit-parameters
848 :included (gnus-topic-mode-p)]
849 ["Select method" gnus-group-edit-group-method
850 (gnus-group-group-name)]
851 ["Info" gnus-group-edit-group (gnus-group-group-name)]
852 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
853 ["Global kill file" gnus-group-edit-global-kill t])))
856 gnus-group-group-menu gnus-group-mode-map ""
859 ["List unread subscribed groups" gnus-group-list-groups t]
860 ["List (un)subscribed groups" gnus-group-list-all-groups t]
861 ["List killed groups" gnus-group-list-killed gnus-killed-list]
862 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
863 ["List level..." gnus-group-list-level t]
864 ["Describe all groups" gnus-group-describe-all-groups t]
865 ["Group apropos..." gnus-group-apropos t]
866 ["Group and description apropos..." gnus-group-description-apropos t]
867 ["List groups matching..." gnus-group-list-matching t]
868 ["List all groups matching..." gnus-group-list-all-matching t]
869 ["List active file" gnus-group-list-active t]
870 ["List groups with cached" gnus-group-list-cached t]
871 ["List groups with dormant" gnus-group-list-dormant t])
873 ["Default sort" gnus-group-sort-groups t]
874 ["Sort by method" gnus-group-sort-groups-by-method t]
875 ["Sort by rank" gnus-group-sort-groups-by-rank t]
876 ["Sort by score" gnus-group-sort-groups-by-score t]
877 ["Sort by level" gnus-group-sort-groups-by-level t]
878 ["Sort by unread" gnus-group-sort-groups-by-unread t]
879 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
880 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
881 ("Sort process/prefixed"
882 ["Default sort" gnus-group-sort-selected-groups
883 (not (gnus-topic-mode-p))]
884 ["Sort by method" gnus-group-sort-selected-groups-by-method
885 (not (gnus-topic-mode-p))]
886 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
887 (not (gnus-topic-mode-p))]
888 ["Sort by score" gnus-group-sort-selected-groups-by-score
889 (not (gnus-topic-mode-p))]
890 ["Sort by level" gnus-group-sort-selected-groups-by-level
891 (not (gnus-topic-mode-p))]
892 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
893 (not (gnus-topic-mode-p))]
894 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
895 (not (gnus-topic-mode-p))]
896 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
897 (not (gnus-topic-mode-p))])
899 ["Mark group" gnus-group-mark-group
900 (and (gnus-group-group-name)
901 (not (memq (gnus-group-group-name) gnus-group-marked)))]
902 ["Unmark group" gnus-group-unmark-group
903 (and (gnus-group-group-name)
904 (memq (gnus-group-group-name) gnus-group-marked))]
905 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
906 ["Mark regexp..." gnus-group-mark-regexp t]
907 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
908 ["Mark buffer" gnus-group-mark-buffer t]
909 ["Execute command" gnus-group-universal-argument
910 (or gnus-group-marked (gnus-group-group-name))])
912 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
913 ["Kill all newsgroups in region" gnus-group-kill-region
914 :active (gnus-mark-active-p)]
915 ["Kill all zombie groups" gnus-group-kill-all-zombies
917 ["Kill all groups on level..." gnus-group-kill-level t])
919 ["Make a foreign group..." gnus-group-make-group t]
920 ["Add a directory group..." gnus-group-make-directory-group t]
921 ["Add the help group" gnus-group-make-help-group t]
922 ["Add the archive group" gnus-group-make-archive-group t]
923 ["Make a doc group..." gnus-group-make-doc-group t]
924 ["Make a web group..." gnus-group-make-web-group t]
925 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
926 ["Make a virtual group..." gnus-group-make-empty-virtual t]
927 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
928 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
929 ["Make an RSS group..." gnus-group-make-rss-group t]
930 ["Rename group..." gnus-group-rename-group
931 (gnus-check-backend-function
932 'request-rename-group (gnus-group-group-name))]
933 ["Delete group" gnus-group-delete-group
934 (gnus-check-backend-function
935 'request-delete-group (gnus-group-group-name))])
937 ["Next" gnus-group-next-group t]
938 ["Previous" gnus-group-prev-group t]
939 ["Next unread" gnus-group-next-unread-group t]
940 ["Previous unread" gnus-group-prev-unread-group t]
941 ["Next unread same level" gnus-group-next-unread-group-same-level t]
942 ["Previous unread same level"
943 gnus-group-prev-unread-group-same-level t]
944 ["Jump to group..." gnus-group-jump-to-group t]
945 ["First unread group" gnus-group-first-unread-group t]
946 ["Best unread group" gnus-group-best-unread-group t])
948 ["Generate" gnus-sieve-generate t]
949 ["Generate and update" gnus-sieve-update t])
950 ["Delete bogus groups" gnus-group-check-bogus-groups t]
951 ["Find new newsgroups" gnus-group-find-new-groups t]
952 ["Transpose" gnus-group-transpose-groups
953 (gnus-group-group-name)]
954 ["Read a directory as a group..." gnus-group-enter-directory t]))
957 gnus-group-misc-menu gnus-group-mode-map ""
960 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
961 ["Send replies" gnus-soup-send-replies
962 (fboundp 'gnus-soup-pack-packet)]
963 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
964 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
965 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
966 ["Send a mail" gnus-group-mail t]
967 ["Send a message (mail or news)" gnus-group-post-news t]
968 ["Create a local message" gnus-group-news t]
969 ["Check for new news" gnus-group-get-new-news
970 ,@(if (featurep 'xemacs) '(t)
971 '(:help "Get newly arrived articles"))
973 ["Send queued messages" gnus-delay-send-queue
974 ,@(if (featurep 'xemacs) '(t)
975 '(:help "Send all messages that are scheduled to be sent now"))
977 ["Activate all groups" gnus-activate-all-groups t]
978 ["Restart Gnus" gnus-group-restart t]
979 ["Read init file" gnus-group-read-init-file t]
980 ["Browse foreign server..." gnus-group-browse-foreign-server t]
981 ["Enter server buffer" gnus-group-enter-server-mode t]
982 ["Expire all expirable articles" gnus-group-expire-all-groups t]
983 ["Generate any kiboze groups" nnkiboze-generate-groups t]
984 ["Gnus version" gnus-version t]
985 ["Save .newsrc files" gnus-group-save-newsrc t]
986 ["Suspend Gnus" gnus-group-suspend t]
987 ["Clear dribble buffer" gnus-group-clear-dribble t]
988 ["Read manual" gnus-info-find-node t]
989 ["Flush score cache" gnus-score-flush-cache t]
990 ["Toggle topics" gnus-topic-mode t]
991 ["Send a bug report" gnus-bug t]
992 ["Exit from Gnus" gnus-group-exit
993 ,@(if (featurep 'xemacs) '(t)
994 '(:help "Quit reading news"))]
995 ["Exit without saving" gnus-group-quit t]))
997 (gnus-run-hooks 'gnus-group-menu-hook)))
1000 (defvar gnus-group-tool-bar-map nil)
1002 ;; Work around for Emacs not updating the tool bar, see
1003 ; http://www.google.com/groups?as_umsgid=v9u0an3hti.fsf@marauder.physik.uni-ulm.de
1004 (defvar gnus-group-redraw-when-idle 2
1005 "When non-nil, redraw the Group buffer frame when idle.
1006 Internal variable.")
1007 ;; Don't make this customizable yet.
1009 (defun gnus-group-redraw-check ()
1010 "Check if we need to redraw the frame."
1011 (when (and gnus-group-redraw-when-idle
1012 (not (featurep 'xemacs))
1013 (boundp 'tool-bar-mode)
1015 ;;(run-with-idle-timer gnus-group-redraw-when-idle
1016 ;; nil 'redraw-frame (selected-frame))
1017 (run-with-idle-timer gnus-group-redraw-when-idle
1018 nil 'force-window-update)
1021 (defun gnus-group-tool-bar-update (&optional symbol value)
1022 "Update group buffer toolbar.
1023 Setter function for custom variables."
1025 (set-default symbol value))
1026 ;; (setq-default gnus-group-tool-bar-map nil)
1027 ;; (use-local-map gnus-group-mode-map)
1028 (when (gnus-alive-p)
1029 (with-current-buffer gnus-group-buffer
1030 (gnus-group-make-tool-bar t))))
1032 ;; The default will be changed when the new icons have been checked in:
1033 (defcustom gnus-group-tool-bar 'gnus-group-tool-bar-retro
1034 "Specifies the Gnus group tool bar.
1036 It can be either a list or a symbol refering to a list. See
1037 `gmm-tool-bar-from-list' for the format of the list. The
1038 default key map is `gnus-group-mode-map'.
1040 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1041 `gnus-group-tool-bar-retro'."
1042 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1043 (const :tag "Retro look" gnus-group-tool-bar-retro)
1044 (repeat :tag "User defined list" gmm-tool-bar-item)
1046 :version "23.0" ;; No Gnus
1047 :initialize 'custom-initialize-default
1048 :set 'gnus-group-tool-bar-update
1051 (defcustom gnus-group-tool-bar-gnome
1052 '((gnus-group-post-news "mail/compose")
1053 ;; Some useful agent icons? I don't use the agent so agent users should
1054 ;; suggest useful commands:
1055 (gnus-agent-toggle-plugged "connect" t
1056 :visible (and gnus-agent (not gnus-plugged)))
1057 (gnus-agent-toggle-plugged "disconnect" t
1058 :visible (and gnus-agent gnus-plugged))
1059 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1060 ;; should have a better help text.
1061 (gnus-group-send-queue "mail/outbox" t
1062 :visible (and gnus-agent gnus-plugged)
1063 :help "Send articles from the queue group")
1064 (gnus-group-get-new-news "mail/inbox" nil
1065 :visible (or (not gnus-agent)
1067 ;; FIXME: gnus-*-read-group should have a better help text.
1068 (gnus-topic-read-group "open" nil :visible gnus-topic-mode)
1069 (gnus-group-read-group "open" nil :visible (not gnus-topic-mode))
1070 ;; (gnus-group-find-new-groups "???" nil)
1071 (gnus-group-save-newsrc "save")
1072 (gnus-group-describe-group "describe")
1073 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1074 (gnus-group-prev-unread-group "left-arrow")
1075 (gnus-group-next-unread-group "right-arrow")
1076 (gnus-group-exit "exit")
1077 (gnus-info-find-node "help"))
1078 "List of functions for the group tool bar (GNOME style).
1080 See `gmm-tool-bar-from-list' for the format of the list."
1081 :type '(repeat gmm-tool-bar-item)
1082 :version "23.0" ;; No Gnus
1083 :initialize 'custom-initialize-default
1084 :set 'gnus-group-tool-bar-update
1087 (defcustom gnus-group-tool-bar-retro
1088 '((gnus-group-get-new-news "gnus/get-news")
1089 (gnus-group-get-new-news-this-group "gnus/gnntg")
1090 (gnus-group-catchup-current "gnus/catchup")
1091 (gnus-group-describe-group "gnus/describe-group")
1092 (gnus-group-subscribe "gnus/subscribe" t
1093 :help "Subscribe to the current group")
1094 (gnus-group-unsubscribe "gnus/unsubscribe" t
1095 :help "Unsubscribe from the current group")
1096 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1097 "List of functions for the group tool bar (retro look).
1099 See `gmm-tool-bar-from-list' for the format of the list."
1100 :type '(repeat gmm-tool-bar-item)
1101 :version "23.0" ;; No Gnus
1102 :initialize 'custom-initialize-default
1103 :set 'gnus-group-tool-bar-update
1106 ;; FIXME: Moving through the Group buffer (in topic mode) e.g. with C-n
1107 ;; doesn't update the state (enabled/disabled) of the icon
1108 ;; `gnus-group-describe-group'. After `C-l' the state is correct.
1109 ;; See the following report on emacs-devel
1110 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1111 ;; From: Reiner Steib
1112 ;; Subject: tool bar icons not updated according to :active condition
1113 ;; Newsgroups: gmane.emacs.devel
1114 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1115 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1117 (defcustom gnus-group-tool-bar-zap-list t
1118 "List of icon items from the global tool bar.
1119 These items are not displayed in the Gnus group mode tool bar.
1121 See `gmm-tool-bar-from-list' for the format of the list."
1122 :type 'gmm-tool-bar-zap-list
1123 :version "23.0" ;; No Gnus
1124 :initialize 'custom-initialize-default
1125 :set 'gnus-group-tool-bar-update
1128 (defun gnus-group-make-tool-bar (&optional force)
1129 "Make a group mode tool bar from `gnus-group-tool-bar'.
1130 When FORCE, rebuild the tool bar."
1131 (when (and (not (featurep 'xemacs))
1132 (boundp 'tool-bar-mode)
1134 ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1136 (or (not gnus-group-tool-bar-map) force))
1137 (when gnus-group-redraw-when-idle
1138 (add-to-list (make-local-variable 'post-command-hook)
1139 'gnus-group-redraw-check))
1141 (gmm-image-load-path "gnus" "gnus/toggle-subscription.xpm"
1144 (gmm-image-load-path "gnus" "gnus/toggle-subscription.xpm"
1146 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1147 gnus-group-tool-bar-zap-list
1148 'gnus-group-mode-map)))
1150 (set (make-local-variable 'tool-bar-map) map))))
1151 gnus-group-tool-bar-map)
1153 (defun gnus-group-mode ()
1154 "Major mode for reading news.
1156 All normal editing commands are switched off.
1157 \\<gnus-group-mode-map>
1158 The group buffer lists (some of) the groups available. For instance,
1159 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1160 lists all zombie groups.
1162 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1163 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1165 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1167 The following commands are available:
1169 \\{gnus-group-mode-map}"
1171 (kill-all-local-variables)
1172 (when (gnus-visual-p 'group-menu 'menu)
1173 (gnus-group-make-menu-bar)
1174 (gnus-group-make-tool-bar))
1175 (gnus-simplify-mode-line)
1176 (setq major-mode 'gnus-group-mode)
1177 (setq mode-name "Group")
1178 (gnus-group-set-mode-line)
1179 (setq mode-line-process nil)
1180 (use-local-map gnus-group-mode-map)
1181 (buffer-disable-undo)
1182 (setq truncate-lines t)
1183 (setq buffer-read-only t
1184 show-trailing-whitespace nil)
1185 (gnus-set-default-directory)
1186 (gnus-update-format-specifications nil 'group 'group-mode)
1187 (gnus-update-group-mark-positions)
1192 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1194 (defun gnus-update-group-mark-positions ()
1196 (let ((gnus-process-mark ?\200)
1197 (gnus-group-update-hook nil)
1198 (gnus-group-marked '("dummy.group"))
1199 (gnus-active-hashtb (make-vector 10 0))
1201 (gnus-set-active "dummy.group" '(0 . 0))
1202 (gnus-set-work-buffer)
1203 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1204 (goto-char (point-min))
1205 (setq gnus-group-mark-positions
1206 (list (cons 'process (and (search-forward
1207 (mm-string-as-multibyte "\200") nil t)
1208 (- (point) 2))))))))
1210 (defun gnus-mouse-pick-group (e)
1211 "Enter the group under the mouse pointer."
1214 (gnus-group-read-group nil))
1216 ;; Look at LEVEL and find out what the level is really supposed to be.
1217 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1218 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1219 (defun gnus-group-default-level (&optional level number-or-nil)
1221 (gnus-group-use-permanent-levels
1222 (or (setq gnus-group-use-permanent-levels
1223 (or level (if (numberp gnus-group-use-permanent-levels)
1224 gnus-group-use-permanent-levels
1225 (or gnus-group-default-list-level
1226 gnus-level-subscribed))))
1227 gnus-group-default-list-level gnus-level-subscribed))
1231 (or level gnus-group-default-list-level gnus-level-subscribed))))
1233 (defun gnus-group-setup-buffer ()
1234 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1235 (unless (eq major-mode 'gnus-group-mode)
1238 (gnus-carpal-setup-buffer 'group))))
1240 (defun gnus-group-name-charset (method group)
1242 (setq method (gnus-find-method-for-group group)))
1243 (let ((item (assoc method gnus-group-name-charset-method-alist))
1244 (alist gnus-group-name-charset-group-alist)
1248 (while (setq item (pop alist))
1249 (if (string-match (car item) group)
1251 result (cdr item))))
1254 (defun gnus-group-name-decode (string charset)
1255 ;; Fixme: Don't decode in unibyte mode.
1256 (if (and string charset (featurep 'mule))
1257 (mm-decode-coding-string string charset)
1260 (defun gnus-group-decoded-name (string)
1261 (let ((charset (gnus-group-name-charset nil string)))
1262 (gnus-group-name-decode string charset)))
1264 (defun gnus-group-list-groups (&optional level unread lowest)
1265 "List newsgroups with level LEVEL or lower that have unread articles.
1266 Default is all subscribed groups.
1267 If argument UNREAD is non-nil, groups with no unread articles are also
1270 Also see the `gnus-group-use-permanent-levels' variable."
1272 (list (if current-prefix-arg
1273 (prefix-numeric-value current-prefix-arg)
1275 (gnus-group-default-level nil t)
1276 gnus-group-default-list-level
1277 gnus-level-subscribed))))
1279 (setq level (car gnus-group-list-mode)
1280 unread (cdr gnus-group-list-mode)))
1281 (setq level (gnus-group-default-level level))
1282 (gnus-group-setup-buffer)
1283 (gnus-update-format-specifications nil 'group 'group-mode)
1284 (let ((case-fold-search nil)
1285 (props (text-properties-at (point-at-bol)))
1286 (empty (= (point-min) (point-max)))
1287 (group (gnus-group-group-name))
1289 (set-buffer gnus-group-buffer)
1290 (setq number (funcall gnus-group-prepare-function level unread lowest))
1291 (when (or (and (numberp number)
1293 (zerop (buffer-size)))
1294 ;; No groups in the buffer.
1295 (gnus-message 5 gnus-no-groups-message))
1296 ;; We have some groups displayed.
1297 (goto-char (point-max))
1298 (when (or (not gnus-group-goto-next-group-function)
1299 (not (funcall gnus-group-goto-next-group-function
1303 (goto-char (point-min)))
1305 ;; Go to the first group with unread articles.
1306 (gnus-group-search-forward t))
1308 ;; Find the right group to put point on. If the current group
1309 ;; has disappeared in the new listing, try to find the next
1310 ;; one. If no next one can be found, just leave point at the
1311 ;; first newsgroup in the buffer.
1312 (when (not (gnus-goto-char
1314 (point-min) (point-max)
1315 'gnus-group (gnus-intern-safe
1316 group gnus-active-hashtb))))
1317 (let ((newsrc (cdddr (gnus-group-entry group))))
1319 (not (gnus-goto-char
1321 (point-min) (point-max) 'gnus-group
1323 (caar newsrc) gnus-active-hashtb)))))
1324 (setq newsrc (cdr newsrc)))
1326 (goto-char (point-max))
1327 (forward-line -1)))))))
1328 ;; Adjust cursor point.
1329 (gnus-group-position-point)))
1331 (defun gnus-group-list-level (level &optional all)
1332 "List groups on LEVEL.
1333 If ALL (the prefix), also list groups that have no unread articles."
1334 (interactive "nList groups on level: \nP")
1335 (gnus-group-list-groups level all level))
1337 (defun gnus-group-prepare-logic (group test)
1338 (or (and gnus-group-listed-groups
1339 (null gnus-group-list-option)
1340 (member group gnus-group-listed-groups))
1342 ((null gnus-group-listed-groups) test)
1343 ((null gnus-group-list-option) test)
1344 (t (and (member group gnus-group-listed-groups)
1345 (if (eq gnus-group-list-option 'flush)
1349 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1350 "List all newsgroups with unread articles of level LEVEL or lower.
1351 If PREDICATE is a function, list groups that the function returns non-nil;
1352 if it is t, list groups that have no unread articles.
1353 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1354 If REGEXP is a function, list dead groups that the function returns non-nil;
1355 if it is a string, only list groups matching REGEXP."
1356 (set-buffer gnus-group-buffer)
1357 (let ((buffer-read-only nil)
1358 (newsrc (cdr gnus-newsrc-alist))
1359 (lowest (or lowest 1))
1360 (not-in-list (and gnus-group-listed-groups
1361 (copy-sequence gnus-group-listed-groups)))
1362 info clevel unread group params)
1364 (when (or (< lowest gnus-level-zombie)
1365 gnus-group-listed-groups)
1366 ;; List living groups.
1368 (setq info (car newsrc)
1369 group (gnus-info-group info)
1370 params (gnus-info-params info)
1372 unread (gnus-group-unread group))
1374 (setq not-in-list (delete group not-in-list)))
1375 (when (gnus-group-prepare-logic
1377 (and unread ; This group might be unchecked
1378 (or (not (stringp regexp))
1379 (string-match regexp group))
1380 (<= (setq clevel (gnus-info-level info)) level)
1383 ((functionp predicate)
1384 (funcall predicate info))
1385 (predicate t) ; We list all groups?
1388 (if (eq unread t) ; Unactivated?
1389 gnus-group-list-inactive-groups
1390 ; We list unactivated
1392 ; We list groups with unread articles
1393 (and gnus-list-groups-with-ticked-articles
1394 (cdr (assq 'tick (gnus-info-marks info))))
1395 ; And groups with tickeds
1396 ;; Check for permanent visibility.
1397 (and gnus-permanently-visible-groups
1398 (string-match gnus-permanently-visible-groups
1400 (memq 'visible params)
1401 (cdr (assq 'visible params)))))))
1402 (gnus-group-insert-group-line
1403 group (gnus-info-level info)
1404 (gnus-info-marks info) unread (gnus-info-method info)))))
1406 ;; List dead groups.
1407 (when (or gnus-group-listed-groups
1408 (and (>= level gnus-level-zombie)
1409 (<= lowest gnus-level-zombie)))
1410 (gnus-group-prepare-flat-list-dead
1411 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1412 gnus-level-zombie ?Z
1415 (dolist (group gnus-zombie-list)
1416 (setq not-in-list (delete group not-in-list))))
1417 (when (or gnus-group-listed-groups
1418 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1419 (gnus-group-prepare-flat-list-dead
1422 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1423 gnus-level-killed ?K regexp))
1425 (gnus-group-set-mode-line)
1426 (setq gnus-group-list-mode (cons level predicate))
1427 (gnus-run-hooks 'gnus-group-prepare-hook)
1430 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1431 ;; List zombies and killed lists somewhat faster, which was
1432 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1433 ;; this by ignoring the group format specification altogether.
1435 (if (> (length groups) gnus-group-listing-limit)
1437 (setq group (pop groups))
1438 (when (gnus-group-prepare-logic
1441 (and (stringp regexp) (string-match regexp group))
1442 (and (functionp regexp) (funcall regexp group))))
1443 (gnus-add-text-properties
1444 (point) (prog1 (1+ (point))
1445 (insert " " mark " *: "
1446 (gnus-group-decoded-name group)
1448 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1450 'gnus-level level))))
1452 (setq group (pop groups))
1453 (when (gnus-group-prepare-logic
1456 (and (stringp regexp) (string-match regexp group))
1457 (and (functionp regexp) (funcall regexp group))))
1458 (gnus-group-insert-group-line
1460 (let ((active (gnus-active group)))
1462 (if (zerop (cdr active))
1464 (- (1+ (cdr active)) (car active)))
1466 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1468 (defun gnus-group-update-group-line ()
1469 "Update the current line in the group buffer."
1470 (let* ((buffer-read-only nil)
1471 (group (gnus-group-group-name))
1472 (entry (and group (gnus-group-entry group)))
1473 gnus-group-indentation)
1476 (not (gnus-ephemeral-group-p group))
1478 (concat "(gnus-group-set-info '"
1479 (gnus-prin1-to-string (nth 2 entry))
1481 (setq gnus-group-indentation (gnus-group-group-indentation))
1483 (gnus-group-insert-group-line-info group)
1485 (gnus-group-position-point))))
1487 (defun gnus-group-insert-group-line-info (group)
1488 "Insert GROUP on the current line."
1489 (let ((entry (gnus-group-entry group))
1490 (gnus-group-indentation (gnus-group-group-indentation))
1494 ;; (Un)subscribed group.
1495 (setq info (nth 2 entry))
1496 (gnus-group-insert-group-line
1497 group (gnus-info-level info) (gnus-info-marks info)
1498 (or (car entry) t) (gnus-info-method info)))
1499 ;; This group is dead.
1500 (gnus-group-insert-group-line
1502 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1504 (if (setq active (gnus-active group))
1505 (if (zerop (cdr active))
1507 (- (1+ (cdr active)) (car active)))
1509 (gnus-method-simplify (gnus-find-method-for-group group))))))
1511 (defun gnus-number-of-unseen-articles-in-group (group)
1512 (let* ((info (nth 2 (gnus-group-entry group)))
1513 (marked (gnus-info-marks info))
1514 (seen (cdr (assq 'seen marked)))
1515 (active (gnus-active group)))
1518 (length (gnus-uncompress-range
1519 (gnus-range-difference
1520 (gnus-range-difference (list active) (gnus-info-read info))
1523 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1524 gnus-tmp-marked number
1526 "Insert a group line in the group buffer."
1527 (let* ((gnus-tmp-method
1528 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1529 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1531 (gnus-tmp-active (gnus-active gnus-tmp-group))
1532 (gnus-tmp-number-total
1534 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1536 (gnus-tmp-number-of-unread
1537 (if (numberp number) (int-to-string (max 0 number))
1539 (gnus-tmp-number-of-read
1540 (if (numberp number)
1541 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1543 (gnus-tmp-subscribed
1544 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1545 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1546 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1548 (gnus-tmp-qualified-group
1549 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1550 group-name-charset))
1552 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1554 (gnus-tmp-newsgroup-description
1555 (if gnus-description-hashtb
1556 (or (gnus-group-name-decode
1557 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1558 group-name-charset) "")
1561 (if (and gnus-moderated-hashtb
1562 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1564 (gnus-tmp-moderated-string
1565 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1566 (gnus-tmp-group-icon "==&&==")
1567 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1568 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1569 (gnus-tmp-news-method-string
1571 (format "(%s:%s)" (car gnus-tmp-method)
1572 (cadr gnus-tmp-method)) ""))
1573 (gnus-tmp-marked-mark
1574 (if (and (numberp number)
1576 (cdr (assq 'tick gnus-tmp-marked)))
1578 (gnus-tmp-summary-live
1579 (if (and (not gnus-group-is-exiting-p)
1580 (gnus-buffer-live-p (gnus-summary-buffer-name
1583 (gnus-tmp-process-marked
1584 (if (member gnus-tmp-group gnus-group-marked)
1585 gnus-process-mark ? ))
1586 (buffer-read-only nil)
1587 header gnus-tmp-header) ; passed as parameter to user-funcs.
1589 (gnus-add-text-properties
1593 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1594 gnus-tmp-group group-name-charset)))
1595 (eval gnus-group-line-format-spec)))
1596 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1597 gnus-unread ,(if (numberp number)
1598 (string-to-number gnus-tmp-number-of-unread)
1600 gnus-marked ,gnus-tmp-marked-mark
1601 gnus-indentation ,gnus-group-indentation
1602 gnus-level ,gnus-tmp-level))
1604 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1605 (gnus-run-hooks 'gnus-group-update-hook))
1607 ;; Allow XEmacs to remove front-sticky text properties.
1608 (gnus-group-remove-excess-properties)))
1610 (defun gnus-group-highlight-line ()
1611 "Highlight the current line according to `gnus-group-highlight'."
1612 (let* ((list gnus-group-highlight)
1614 (end (point-at-eol))
1615 ;; now find out where the line starts and leave point there.
1616 (beg (progn (beginning-of-line) (point)))
1617 (group (gnus-group-group-name))
1618 (entry (gnus-group-entry group))
1619 (unread (if (numberp (car entry)) (car entry) 0))
1620 (active (gnus-active group))
1621 (total (if active (1+ (- (cdr active) (car active))) 0))
1622 (info (nth 2 entry))
1623 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1624 (marked (gnus-info-marks info))
1625 (mailp (apply 'append
1628 (memq x (assoc (symbol-name
1629 (car (or method gnus-select-method)))
1630 gnus-valid-select-methods)))
1631 '(mail post-mail))))
1632 (level (or (gnus-info-level info) gnus-level-killed))
1633 (score (or (gnus-info-score info) 0))
1634 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1635 (group-age (gnus-group-timestamp-delta group))
1636 (inhibit-read-only t))
1637 ;; Eval the cars of the lists until we find a match.
1639 (not (eval (caar list))))
1640 (setq list (cdr list)))
1641 (let ((face (cdar list)))
1642 (unless (eq face (get-text-property beg 'face))
1643 (gnus-put-text-property-excluding-characters-with-faces
1645 (setq face (if (boundp face) (symbol-value face) face)))
1646 (gnus-extent-start-open beg)))
1649 (defun gnus-group-update-group (group &optional visible-only)
1650 "Update all lines where GROUP appear.
1651 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1653 ;; Can't use `save-excursion' here, so we do it manually.
1654 (let ((buf (current-buffer))
1656 (set-buffer gnus-group-buffer)
1657 (setq mark (point-marker))
1658 ;; The buffer may be narrowed.
1661 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1663 found buffer-read-only)
1664 ;; Enter the current status into the dribble buffer.
1665 (let ((entry (gnus-group-entry group)))
1667 (not (gnus-ephemeral-group-p group)))
1669 (concat "(gnus-group-set-info '"
1670 (gnus-prin1-to-string (nth 2 entry))
1672 ;; Find all group instances. If topics are in use, each group
1673 ;; may be listed in more than once.
1674 (while (setq loc (text-property-any
1675 loc (point-max) 'gnus-group ident))
1678 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1680 (gnus-group-insert-group-line-info group)
1683 (gnus-run-hooks 'gnus-group-update-group-hook)))
1684 (setq loc (1+ loc)))
1685 (unless (or found visible-only)
1686 ;; No such line in the buffer, find out where it's supposed to
1687 ;; go, and insert it there (or at the end of the buffer).
1688 (if gnus-goto-missing-group-function
1689 (funcall gnus-goto-missing-group-function group)
1690 (let ((entry (cddr (gnus-group-entry group))))
1691 (while (and entry (car entry)
1695 (point-min) (point-max)
1696 'gnus-group (gnus-intern-safe
1697 (caar entry) gnus-active-hashtb)))))
1698 (setq entry (cdr entry)))
1699 (or entry (goto-char (point-max)))))
1700 ;; Finally insert the line.
1701 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1702 (gnus-group-insert-group-line-info group)
1705 (gnus-run-hooks 'gnus-group-update-group-hook))))
1706 (when gnus-group-update-group-function
1707 (funcall gnus-group-update-group-function group))
1708 (gnus-group-set-mode-line)))
1710 (set-marker mark nil)
1713 (defun gnus-group-set-mode-line ()
1714 "Update the mode line in the group buffer."
1715 (when (memq 'group gnus-updated-mode-lines)
1716 ;; Yes, we want to keep this mode line updated.
1718 (set-buffer gnus-group-buffer)
1719 (let* ((gformat (or gnus-group-mode-line-format-spec
1720 (gnus-set-format 'group-mode)))
1721 (gnus-tmp-news-server (cadr gnus-select-method))
1722 (gnus-tmp-news-method (car gnus-select-method))
1723 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1725 gnus-tmp-header ;Dummy binding for user-defined formats
1726 ;; Get the resulting string.
1728 (and gnus-dribble-buffer
1729 (buffer-name gnus-dribble-buffer)
1730 (buffer-modified-p gnus-dribble-buffer)
1732 (set-buffer gnus-dribble-buffer)
1733 (not (zerop (buffer-size))))))
1734 (mode-string (eval gformat)))
1735 ;; Say whether the dribble buffer has been modified.
1736 (setq mode-line-modified
1737 (if modified (car gnus-mode-line-modified)
1738 (cdr gnus-mode-line-modified)))
1739 ;; If the line is too long, we chop it off.
1740 (when (> (length mode-string) max-len)
1741 (setq mode-string (substring mode-string 0 (- max-len 4))))
1743 (setq mode-line-buffer-identification
1744 (gnus-mode-line-buffer-identification
1745 (list mode-string)))
1746 (set-buffer-modified-p modified))))))
1748 (defun gnus-group-group-name ()
1749 "Get the name of the newsgroup on the current line."
1750 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1752 (symbol-name group))))
1754 (defun gnus-group-group-level ()
1755 "Get the level of the newsgroup on the current line."
1756 (get-text-property (point-at-bol) 'gnus-level))
1758 (defun gnus-group-group-indentation ()
1759 "Get the indentation of the newsgroup on the current line."
1760 (or (get-text-property (point-at-bol) 'gnus-indentation)
1761 (and gnus-group-indentation-function
1762 (funcall gnus-group-indentation-function))
1765 (defun gnus-group-group-unread ()
1766 "Get the number of unread articles of the newsgroup on the current line."
1767 (get-text-property (point-at-bol) 'gnus-unread))
1769 (defun gnus-group-new-mail (group)
1770 (if (nnmail-new-mail-p (gnus-group-real-name group))
1774 (defun gnus-group-level (group)
1775 "Return the estimated level of GROUP."
1776 (or (gnus-info-level (gnus-get-info group))
1777 (and (member group gnus-zombie-list) gnus-level-zombie)
1780 (defun gnus-group-search-forward (&optional backward all level first-too)
1781 "Find the next newsgroup with unread articles.
1782 If BACKWARD is non-nil, find the previous newsgroup instead.
1783 If ALL is non-nil, just find any newsgroup.
1784 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1786 If FIRST-TOO, the current line is also eligible as a target."
1787 (let ((way (if backward -1 1))
1788 (low gnus-level-killed)
1791 (if (and backward (progn (beginning-of-line)) (bobp))
1800 (get-text-property (point) 'gnus-group)
1804 (get-text-property (point) 'gnus-unread)))
1805 (and (numberp unread) (> unread 0)))
1806 (setq lev (get-text-property (point)
1808 (<= lev gnus-level-subscribed)))
1810 (and (setq lev (get-text-property (point)
1819 (zerop (forward-line way)))))
1821 (progn (gnus-group-position-point) t)
1822 (goto-char (or pos beg))
1825 (defun gnus-total-fetched-for (group)
1826 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1827 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1828 (size (+ size-in-cache size-in-agent))
1829 (suffix '("B" "K" "M" "G"))
1832 (while (> size cutoff)
1833 (setq size (/ size scale)
1834 suffix (cdr suffix)))
1835 (format "%5.1f%s" size (car suffix))))
1837 ;;; Gnus group mode commands
1841 (defun gnus-group-mark-line-p ()
1844 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1845 (eq (char-after) gnus-process-mark)))
1847 (defun gnus-group-mark-group (n &optional unmark no-advance)
1848 "Mark the current group."
1850 (let ((buffer-read-only nil)
1854 (when (setq group (gnus-group-group-name))
1855 ;; Go to the mark position.
1857 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1861 (setq gnus-group-marked (delete group gnus-group-marked))
1862 (insert-char ? 1 t))
1863 (setq gnus-group-marked
1864 (cons group (delete group gnus-group-marked)))
1865 (insert-char gnus-process-mark 1 t)))
1867 (gnus-group-next-group 1))
1869 (gnus-summary-position-point)
1872 (defun gnus-group-unmark-group (n)
1873 "Remove the mark from the current group."
1875 (gnus-group-mark-group n 'unmark)
1876 (gnus-group-position-point))
1878 (defun gnus-group-unmark-all-groups ()
1879 "Unmark all groups."
1882 (mapc 'gnus-group-remove-mark gnus-group-marked))
1883 (gnus-group-position-point))
1885 (defun gnus-group-mark-region (unmark beg end)
1886 "Mark all groups between point and mark.
1887 If UNMARK, remove the mark instead."
1888 (interactive "P\nr")
1889 (let ((num (count-lines beg end)))
1892 (- num (gnus-group-mark-group num unmark)))))
1894 (defun gnus-group-mark-buffer (&optional unmark)
1895 "Mark all groups in the buffer.
1896 If UNMARK, remove the mark instead."
1898 (gnus-group-mark-region unmark (point-min) (point-max)))
1900 (defun gnus-group-mark-regexp (regexp)
1901 "Mark all groups that match some regexp."
1902 (interactive "sMark (regexp): ")
1903 (let ((alist (cdr gnus-newsrc-alist))
1907 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1908 (gnus-group-jump-to-group group)
1909 (gnus-group-set-mark group)))))
1910 (gnus-group-position-point))
1912 (defun gnus-group-remove-mark (group &optional test-marked)
1913 "Remove the process mark from GROUP and move point there.
1914 Return nil if the group isn't displayed."
1915 (if (gnus-group-goto-group group nil test-marked)
1917 (gnus-group-mark-group 1 'unmark t)
1919 (setq gnus-group-marked
1920 (delete group gnus-group-marked))
1923 (defun gnus-group-set-mark (group)
1924 "Set the process mark on GROUP."
1925 (if (gnus-group-goto-group group)
1927 (gnus-group-mark-group 1 nil t))
1928 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1930 (defun gnus-group-universal-argument (arg &optional groups func)
1931 "Perform any command on all groups according to the process/prefix convention."
1933 (if (eq (setq func (or func
1936 (substitute-command-keys
1937 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1939 (gnus-error 1 "Undefined key")
1940 (gnus-group-iterate arg
1942 (command-execute func))))
1943 (gnus-group-position-point))
1945 (defun gnus-group-process-prefix (n)
1946 "Return a list of groups to work on.
1947 Take into consideration N (the prefix) and the list of marked groups."
1950 (setq n (prefix-numeric-value n))
1951 ;; There is a prefix, so we return a list of the N next
1953 (let ((way (if (< n 0) -1 1))
1958 (if (setq group (gnus-group-group-name))
1959 (push group groups))
1961 (gnus-group-next-group way)))
1963 ((and (gnus-region-active-p) (mark))
1964 ;; Work on the region between point and mark.
1965 (let ((max (max (point) (mark)))
1968 (goto-char (min (point) (mark)))
1971 (push (gnus-group-group-name) groups)
1972 (zerop (gnus-group-next-group 1))
1974 (nreverse groups))))
1976 ;; No prefix, but a list of marked articles.
1977 (reverse gnus-group-marked))
1979 ;; Neither marked articles or a prefix, so we return the
1981 (let ((group (gnus-group-group-name)))
1982 (and group (list group))))))
1984 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1985 ;;; imagine why I went through these contortions...
1987 (let ((function (make-symbol "gnus-group-iterate-function"))
1988 (window (make-symbol "gnus-group-iterate-window"))
1989 (groups (make-symbol "gnus-group-iterate-groups"))
1990 (group (make-symbol "gnus-group-iterate-group")))
1992 `(defun gnus-group-iterate (arg ,function)
1993 "Iterate FUNCTION over all process/prefixed groups.
1994 FUNCTION will be called with the group name as the parameter
1995 and with point over the group in question."
1996 (let ((,groups (gnus-group-process-prefix arg))
1997 (,window (selected-window))
2000 (setq ,group (car ,groups)
2001 ,groups (cdr ,groups))
2002 (select-window ,window)
2003 (gnus-group-remove-mark ,group)
2004 (save-selected-window
2006 (funcall ,function ,group)))))))))
2008 (put 'gnus-group-iterate 'lisp-indent-function 1)
2010 ;; Selecting groups.
2012 (defun gnus-group-read-group (&optional all no-article group select-articles)
2013 "Read news in this newsgroup.
2014 If the prefix argument ALL is non-nil, already read articles become
2015 readable. IF ALL is a number, fetch this number of articles. If the
2016 optional argument NO-ARTICLE is non-nil, no article will be
2017 auto-selected upon group entry. If GROUP is non-nil, fetch that
2020 (let ((no-display (eq all 0))
2021 (group (or group (gnus-group-group-name)))
2022 number active marked entry)
2026 (error "No group on current line"))
2027 (setq marked (gnus-info-marks
2028 (nth 2 (setq entry (gnus-group-entry group)))))
2029 ;; This group might be a dead group. In that case we have to get
2030 ;; the number of unread articles from `gnus-active-hashtb'.
2032 (cond ((numberp all) all)
2034 ((setq active (gnus-active group))
2035 (- (1+ (cdr active)) (car active)))))
2036 (gnus-summary-read-group
2037 group (or all (and (numberp number)
2038 (zerop (+ number (gnus-range-length
2039 (cdr (assq 'tick marked)))
2041 (cdr (assq 'dormant marked)))))))
2042 no-article nil no-display nil select-articles)))
2044 (defun gnus-group-select-group (&optional all)
2045 "Select this newsgroup.
2046 No article is selected automatically.
2047 If the group is opened, just switch the summary buffer.
2048 If ALL is non-nil, already read articles become readable.
2049 If ALL is a positive number, fetch this number of the latest
2050 articles in the group.
2051 If ALL is a negative number, fetch this number of the earliest
2052 articles in the group."
2054 (when (and (eobp) (not (gnus-group-group-name)))
2056 (gnus-group-read-group all t))
2058 (defun gnus-group-quick-select-group (&optional all)
2059 "Select the current group \"quickly\".
2060 This means that no highlighting or scoring will be performed.
2061 If ALL (the prefix argument) is 0, don't even generate the summary
2064 This might be useful if you want to toggle threading
2065 before entering the group."
2067 (require 'gnus-score)
2069 gnus-score-find-score-files-function
2070 gnus-home-score-file
2071 gnus-apply-kill-hook
2072 gnus-summary-expunge-below)
2073 (gnus-group-read-group all t)))
2075 (defun gnus-group-visible-select-group (&optional all)
2076 "Select the current group without hiding any articles."
2078 (let ((gnus-inhibit-limiting t))
2079 (gnus-group-read-group all t)))
2081 (defun gnus-group-select-group-ephemerally ()
2082 "Select the current group without doing any processing whatsoever.
2083 You will actually be entered into a group that's a copy of
2084 the current group; no changes you make while in this group will
2087 (require 'gnus-score)
2089 gnus-score-find-score-files-function gnus-apply-kill-hook
2090 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2091 gnus-summary-mode-hook gnus-select-group-hook
2092 (group (gnus-group-group-name))
2093 (method (gnus-find-method-for-group group)))
2094 (gnus-group-read-ephemeral-group
2095 (gnus-group-prefixed-name group method) method)))
2098 (defun gnus-fetch-group (group &optional articles)
2099 "Start Gnus if necessary and enter GROUP.
2100 Returns whether the fetching was successful or not."
2101 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
2102 (unless (get-buffer gnus-group-buffer)
2104 (gnus-group-read-group articles nil group))
2107 (defun gnus-fetch-group-other-frame (group)
2108 "Pop up a frame and enter GROUP."
2110 (let ((window (get-buffer-window gnus-group-buffer)))
2112 (select-frame (window-frame window)))
2113 ((= (length (frame-list)) 1)
2114 (select-frame (make-frame)))
2117 (gnus-fetch-group group))
2119 (defvar gnus-ephemeral-group-server 0)
2121 (defcustom gnus-large-ephemeral-newsgroup 200
2122 "The number of articles which indicates a large ephemeral newsgroup.
2123 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2125 If the number of articles in a newsgroup is greater than this value,
2126 confirmation is required for selecting the newsgroup. If it is nil, no
2127 confirmation is required."
2129 :group 'gnus-group-select
2130 :type '(choice (const :tag "No limit" nil)
2133 (defcustom gnus-fetch-old-ephemeral-headers nil
2134 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2137 :type '(choice (const :tag "off" nil)
2140 (sexp :menu-tag "other" t)))
2142 ;; Enter a group that is not in the group buffer. Non-nil is returned
2143 ;; if selection was successful.
2144 (defun gnus-group-read-ephemeral-group (group method &optional activate
2145 quit-config request-only
2149 "Read GROUP from METHOD as an ephemeral group.
2150 If ACTIVATE, request the group first.
2151 If QUIT-CONFIG, use that window configuration when exiting from the
2153 If REQUEST-ONLY, don't actually read the group; just request it.
2154 If SELECT-ARTICLES, only select those articles.
2155 If PARAMETERS, use those as the group parameters.
2156 If NUMBER, fetch this number of articles.
2158 Return the name of the group if selection was successful."
2161 ;; (gnus-read-group "Group name: ")
2163 "Group: " gnus-active-hashtb
2165 'gnus-group-history)
2166 (gnus-read-method "From method: ")))
2167 ;; Transform the select method into a unique server.
2168 (when (stringp method)
2169 (setq method (gnus-server-to-method method)))
2171 `(,(car method) ,(concat (cadr method) "-ephemeral")
2172 (,(intern (format "%s-address" (car method))) ,(cadr method))
2174 (let ((group (if (gnus-group-foreign-p group) group
2175 (gnus-group-prefixed-name (gnus-group-real-name group)
2180 ,gnus-level-default-subscribed nil nil ,method
2183 (cons 'quit-config quit-config)
2185 (cons gnus-summary-buffer
2186 gnus-current-window-configuration)))
2189 (push method gnus-ephemeral-servers)
2190 (set-buffer gnus-group-buffer)
2191 (unless (gnus-check-server method)
2192 (error "Unable to contact server: %s" (gnus-status-message method)))
2194 (gnus-activate-group group 'scan)
2195 (unless (gnus-request-group group)
2196 (error "Couldn't request group: %s"
2197 (nnheader-get-report (car method)))))
2201 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2202 (gnus-fetch-old-headers
2203 gnus-fetch-old-ephemeral-headers))
2204 (gnus-group-read-group (or number t) t group select-articles))
2208 (message "Quit reading the ephemeral group")
2211 (defun gnus-group-jump-to-group (group &optional prompt)
2212 "Jump to newsgroup GROUP.
2214 If PROMPT (the prefix) is a number, use the prompt specified in
2215 `gnus-group-jump-to-group-prompt'."
2217 (list (mm-string-make-unibyte
2219 "Group: " gnus-active-hashtb nil
2220 (gnus-read-active-file-p)
2221 (if current-prefix-arg
2222 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2223 (or (and (stringp gnus-group-jump-to-group-prompt)
2224 gnus-group-jump-to-group-prompt)
2225 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2226 (and (stringp p) p))))
2227 'gnus-group-history))))
2229 (when (equal group "")
2230 (error "Empty group name"))
2232 (unless (gnus-ephemeral-group-p group)
2233 ;; Either go to the line in the group buffer...
2234 (unless (gnus-group-goto-group group)
2235 ;; ... or insert the line.
2236 (gnus-group-update-group group)
2237 (gnus-group-goto-group group)))
2238 ;; Adjust cursor point.
2239 (gnus-group-position-point))
2241 (defun gnus-group-goto-group (group &optional far test-marked)
2242 "Goto to newsgroup GROUP.
2243 If FAR, it is likely that the group is not on the current line.
2244 If TEST-MARKED, the line must be marked."
2248 ;; It's quite likely that we are on the right line, so
2249 ;; we check the current line first.
2251 (eq (get-text-property (point) 'gnus-group)
2252 (gnus-intern-safe group gnus-active-hashtb))
2253 (or (not test-marked) (gnus-group-mark-line-p)))
2255 ;; Previous and next line are also likely, so we check them as well.
2259 (and (eq (get-text-property (point) 'gnus-group)
2260 (gnus-intern-safe group gnus-active-hashtb))
2261 (or (not test-marked) (gnus-group-mark-line-p)))))
2267 (and (eq (get-text-property (point) 'gnus-group)
2268 (gnus-intern-safe group gnus-active-hashtb))
2269 (or (not test-marked) (gnus-group-mark-line-p)))))
2273 (goto-char (point-min))
2275 (while (and (not found)
2280 (gnus-intern-safe group gnus-active-hashtb))))
2281 (if (gnus-group-mark-line-p)
2286 ;; Search through the entire buffer.
2289 (point-min) (point-max)
2290 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2292 (defun gnus-group-next-group (n &optional silent)
2293 "Go to next N'th newsgroup.
2294 If N is negative, search backward instead.
2295 Returns the difference between N and the number of skips actually
2298 (gnus-group-next-unread-group n t nil silent))
2300 (defun gnus-group-next-unread-group (n &optional all level silent)
2301 "Go to next N'th unread newsgroup.
2302 If N is negative, search backward instead.
2303 If ALL is non-nil, choose any newsgroup, unread or not.
2304 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2305 such group can be found, the next group with a level higher than
2307 Returns the difference between N and the number of skips actually
2310 (let ((backward (< n 0))
2313 (gnus-group-search-forward
2314 backward (or (not gnus-group-goto-unread) all) level))
2318 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2319 (if level " on this level or higher" "")))
2322 (defun gnus-group-prev-group (n)
2323 "Go to previous N'th newsgroup.
2324 Returns the difference between N and the number of skips actually
2327 (gnus-group-next-unread-group (- n) t))
2329 (defun gnus-group-prev-unread-group (n)
2330 "Go to previous N'th unread newsgroup.
2331 Returns the difference between N and the number of skips actually
2334 (gnus-group-next-unread-group (- n)))
2336 (defun gnus-group-next-unread-group-same-level (n)
2337 "Go to next N'th unread newsgroup on the same level.
2338 If N is negative, search backward instead.
2339 Returns the difference between N and the number of skips actually
2342 (gnus-group-next-unread-group n t (gnus-group-group-level))
2343 (gnus-group-position-point))
2345 (defun gnus-group-prev-unread-group-same-level (n)
2346 "Go to next N'th unread newsgroup on the same level.
2347 Returns the difference between N and the number of skips actually
2350 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2351 (gnus-group-position-point))
2353 (defun gnus-group-best-unread-group (&optional exclude-group)
2354 "Go to the group with the highest level.
2355 If EXCLUDE-GROUP, do not go to that group."
2357 (goto-char (point-min))
2361 (setq unread (get-text-property (point) 'gnus-unread))
2362 (when (and (numberp unread) (> unread 0))
2363 (when (and (get-text-property (point) 'gnus-level)
2364 (< (get-text-property (point) 'gnus-level) best)
2365 (or (not exclude-group)
2366 (not (equal exclude-group (gnus-group-group-name)))))
2367 (setq best (get-text-property (point) 'gnus-level))
2368 (setq best-point (point))))
2371 (goto-char best-point))
2372 (gnus-group-position-point)
2373 (and best-point (gnus-group-group-name))))
2375 ;; Is there something like an after-point-motion-hook?
2376 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2378 ;; (defun gnus-group-menu-bar-update ()
2379 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2380 ;; (current-buffer))))
2381 ;; (name (buffer-name (car buf))))
2383 ;; (if (> (length name) 27)
2384 ;; (concat (substring name 0 12)
2386 ;; (substring name -12))
2388 ;; (menu-bar-update-buffers-1 buf)))
2390 ;; (defun gnus-group-position-point ()
2391 ;; (gnus-goto-colon)
2392 ;; (gnus-group-menu-bar-update))
2394 (defun gnus-group-first-unread-group ()
2395 "Go to the first group with unread articles."
2398 (let ((opoint (point))
2400 (goto-char (point-min))
2401 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2402 (and (numberp unread) ; Not a topic.
2403 (not (zerop unread))) ; Has unread articles.
2404 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2407 nil)) ; Not success.
2408 (gnus-group-position-point)))
2410 (defun gnus-group-enter-server-mode ()
2411 "Jump to the server buffer."
2413 (gnus-enter-server-buffer))
2415 (defun gnus-group-make-group-simple (&optional group)
2416 "Add a new newsgroup.
2417 The user will be prompted for GROUP."
2419 (list (completing-read "Group: " gnus-active-hashtb
2420 nil nil nil 'gnus-group-history)))
2421 (gnus-group-make-group
2422 (gnus-group-real-name group)
2423 (gnus-group-server group)))
2425 (defun gnus-group-make-group (name &optional method address args)
2426 "Add a new newsgroup.
2427 The user will be prompted for a NAME, for a select METHOD, and an
2431 (gnus-read-group "Group name: ")
2432 (gnus-read-method "From method: ")))
2434 (when (stringp method)
2435 (setq method (or (gnus-server-to-method method) method)))
2436 (let* ((meth (gnus-method-simplify
2438 (not (gnus-server-equal method gnus-select-method)))
2439 (if address (list (intern method) address)
2441 (nname (if method (gnus-group-prefixed-name name meth) name))
2443 (when (gnus-group-entry nname)
2444 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2445 ;; Subscribe to the new group.
2446 (gnus-group-change-level
2447 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2448 gnus-level-default-subscribed gnus-level-killed
2449 (and (gnus-group-group-name)
2450 (gnus-group-entry (gnus-group-group-name)))
2453 (gnus-set-active nname (cons 1 0))
2454 (unless (gnus-ephemeral-group-p name)
2456 (concat "(gnus-group-set-info '"
2457 (gnus-prin1-to-string (cdr info)) ")")))
2459 (gnus-group-insert-group-line-info nname)
2461 (gnus-group-position-point)
2463 ;; Load the back end and try to make the back end create
2464 ;; the group as well.
2465 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2467 gnus-valid-select-methods)
2469 (gnus-check-server meth)
2470 (when (gnus-check-backend-function 'request-create-group nname)
2471 (unless (gnus-request-create-group nname nil args)
2472 (error "Could not create group on server: %s"
2473 (nnheader-get-report backend))))
2476 (defun gnus-group-delete-groups (&optional arg)
2477 "Delete the current group. Only meaningful with editable groups."
2479 (let ((n (length (gnus-group-process-prefix arg))))
2480 (when (gnus-yes-or-no-p
2482 "Delete this 1 group? "
2483 (format "Delete these %d groups? " n)))
2484 (gnus-group-iterate arg
2486 (gnus-group-delete-group group nil t))))))
2488 (defun gnus-group-delete-group (group &optional force no-prompt)
2489 "Delete the current group. Only meaningful with editable groups.
2490 If FORCE (the prefix) is non-nil, all the articles in the group will
2491 be deleted. This is \"deleted\" as in \"removed forever from the face
2492 of the Earth\". There is no undo. The user will be prompted before
2494 Note that you also have to specify FORCE if you want the group to
2495 be removed from the server, even when it's empty."
2497 (list (gnus-group-group-name)
2498 current-prefix-arg))
2500 (error "No group to delete"))
2501 (unless (gnus-check-backend-function 'request-delete-group group)
2502 (error "This back end does not support group deletion"))
2504 (let ((group-decoded (gnus-group-decoded-name group)))
2505 (if (and (not no-prompt)
2506 (not (gnus-yes-or-no-p
2508 "Do you really want to delete %s%s? "
2509 group-decoded (if force " and all its contents" "")))))
2511 (gnus-message 6 "Deleting group %s..." group-decoded)
2512 (if (not (gnus-request-delete-group group force))
2513 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2514 (gnus-message 6 "Deleting group %s...done" group-decoded)
2515 (gnus-group-goto-group group)
2516 (gnus-group-kill-group 1 t)
2517 (gnus-set-active group nil)
2519 (gnus-group-position-point)))
2521 (defun gnus-group-rename-group (group new-name)
2522 "Rename group from GROUP to NEW-NAME.
2523 When used interactively, GROUP is the group under point
2524 and NEW-NAME will be prompted for."
2527 (gnus-group-group-name)
2529 (unless (gnus-check-backend-function
2530 'request-rename-group (gnus-group-group-name))
2531 (error "This back end does not support renaming groups"))
2532 (gnus-read-group "Rename group to: "
2533 (gnus-group-real-name (gnus-group-group-name))))))
2535 (unless (gnus-check-backend-function 'request-rename-group group)
2536 (error "This back end does not support renaming groups"))
2538 (error "No group to rename"))
2539 (when (equal (gnus-group-real-name group) new-name)
2540 (error "Can't rename to the same name"))
2542 ;; We find the proper prefixed name.
2544 (if (gnus-group-native-p group)
2548 (gnus-group-prefixed-name
2549 (gnus-group-real-name new-name)
2550 (gnus-info-method (gnus-get-info group)))))
2552 (when (gnus-active new-name)
2553 (error "The group %s already exists" new-name))
2555 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2558 (gnus-group-goto-group group)
2559 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2560 (gnus-request-rename-group group new-name))))
2561 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2562 ;; We rename the group internally by killing it...
2563 (gnus-group-kill-group)
2564 ;; ... changing its name ...
2565 (setcar (cdar gnus-list-of-killed-groups) new-name)
2566 ;; ... and then yanking it. Magic!
2567 (gnus-group-yank-group)
2568 (gnus-set-active new-name (gnus-active group))
2569 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2571 (setq gnus-killed-list (delete group gnus-killed-list))
2572 (gnus-set-active group nil)
2573 (gnus-dribble-touch)
2574 (gnus-group-position-point)))
2576 (defun gnus-group-edit-group (group &optional part)
2577 "Edit the group on the current line."
2578 (interactive (list (gnus-group-group-name)))
2579 (let ((part (or part 'info))
2582 (error "No group on current line"))
2583 (unless (setq info (gnus-get-info group))
2584 (error "Killed group; can't be edited"))
2586 (gnus-close-group group))
2588 ;; Find the proper form to edit.
2589 (cond ((eq part 'method)
2590 (or (gnus-info-method info) "native"))
2592 (gnus-info-params info))
2594 ;; The proper documentation.
2596 "Editing the %s for `%s'."
2598 ((eq part 'method) "select method")
2599 ((eq part 'params) "group parameters")
2601 (gnus-group-decoded-name group))
2603 (gnus-group-edit-group-done ',part ,group form)))
2606 (gnus-create-info-command
2609 "(gnus)Select Methods")
2611 "(gnus)Group Parameters")
2613 "(gnus)Group Info"))))))
2615 (defun gnus-group-edit-group-method (group)
2616 "Edit the select method of GROUP."
2617 (interactive (list (gnus-group-group-name)))
2618 (gnus-group-edit-group group 'method))
2620 (defun gnus-group-edit-group-parameters (group)
2621 "Edit the group parameters of GROUP."
2622 (interactive (list (gnus-group-group-name)))
2623 (gnus-group-edit-group group 'params))
2625 (defun gnus-group-edit-group-done (part group form)
2627 (let* ((method (cond ((eq part 'info) (nth 4 form))
2628 ((eq part 'method) form)
2630 (info (cond ((eq part 'info) form)
2631 ((eq part 'method) (gnus-get-info group))
2634 (if (or (not method)
2636 gnus-select-method method))
2637 (gnus-group-real-name (car info))
2638 (gnus-group-prefixed-name
2639 (gnus-group-real-name (car info)) method))
2641 (when (and new-group
2642 (not (equal new-group group)))
2643 (when (gnus-group-goto-group group)
2644 (gnus-group-kill-group 1))
2645 (gnus-activate-group new-group))
2647 (if (not (and info new-group))
2648 (gnus-group-set-info form (or new-group group) part)
2649 (setq info (gnus-copy-sequence info))
2650 (setcar info new-group)
2651 (unless (gnus-server-equal method "native")
2652 (unless (nthcdr 3 info)
2653 (nconc info (list nil nil)))
2654 (unless (nthcdr 4 info)
2655 (nconc info (list nil)))
2656 (gnus-info-set-method info method))
2657 (gnus-group-set-info info))
2658 (gnus-group-update-group (or new-group group))
2659 (gnus-group-position-point)))
2661 (defun gnus-group-make-useful-group (group method)
2662 "Create one of the groups described in `gnus-useful-groups'."
2664 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2666 gnus-useful-groups)))
2667 (list (cadr entry) (caddr entry))))
2668 (setq method (gnus-copy-sequence method))
2670 (while (setq entry (memq (assq 'eval method) method))
2671 (setcar entry (eval (cadar entry)))))
2672 (gnus-group-make-group group method))
2674 (defun gnus-group-make-help-group (&optional noerror)
2675 "Create the Gnus documentation group.
2676 Optional argument NOERROR modifies the behavior of this function when the
2677 group already exists:
2678 - if not given, and error is signaled,
2679 - if t, stay silent,
2680 - if anything else, just print a message."
2682 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2683 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2684 (if (gnus-group-entry name)
2685 (cond ((eq noerror nil)
2686 (error "Documentation group already exists"))
2691 (gnus-message 1 "Documentation group already exists")))
2694 (gnus-message 1 "Couldn't find doc group")
2695 (gnus-group-make-group
2696 (gnus-group-real-name name)
2697 (list 'nndoc "gnus-help"
2698 (list 'nndoc-address file)
2699 (list 'nndoc-article-type 'mbox))))
2701 (gnus-group-position-point))
2703 (defun gnus-group-make-doc-group (file type)
2704 "Create a group that uses a single file as the source.
2706 If called with a prefix argument, ask for the file type."
2708 (list (read-file-name "File name: ")
2709 (and current-prefix-arg 'ask)))
2710 (when (eq type 'ask)
2715 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2717 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2718 ((= char ?b) 'babyl)
2719 ((= char ?d) 'digest)
2720 ((= char ?f) 'forward)
2722 ((= char ?g) 'guess)
2723 (t (setq err (format "%c unknown. " char))
2726 (let* ((file (expand-file-name file))
2727 (name (gnus-generate-new-group-name
2728 (gnus-group-prefixed-name
2729 (file-name-nondirectory file) '(nndoc "")))))
2730 (gnus-group-make-group
2731 (gnus-group-real-name name)
2733 (list 'nndoc-address file)
2734 (list 'nndoc-article-type (or type 'guess))))))
2736 (defvar nnweb-type-definition)
2737 (defvar gnus-group-web-type-history nil)
2738 (defvar gnus-group-web-search-history nil)
2739 (defun gnus-group-make-web-group (&optional solid)
2740 "Create an ephemeral nnweb group.
2741 If SOLID (the prefix), create a solid group."
2745 (if solid (gnus-read-group "Group name: ")
2746 (message-unique-id)))
2747 (default-type (or (car gnus-group-web-type-history)
2748 (symbol-name (caar nnweb-type-definition))))
2752 (format "Search engine type (default %s): " default-type)
2753 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2754 nnweb-type-definition)
2755 nil t nil 'gnus-group-web-type-history)
2760 (cons (or (car gnus-group-web-search-history) "") 0)
2761 'gnus-group-web-search-history))
2763 `(nnweb ,group (nnweb-search ,search)
2764 (nnweb-type ,(intern type))
2765 (nnweb-ephemeral-p t))))
2768 (gnus-pull 'nnweb-ephemeral-p method)
2769 (gnus-group-make-group group method))
2770 (gnus-group-read-ephemeral-group
2772 (cons (current-buffer)
2773 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2776 (defvar nnrss-group-alist)
2777 (defun nnrss-discover-feed (arg))
2778 (defun nnrss-save-server-data (arg)))
2779 (defun gnus-group-make-rss-group (&optional url)
2780 "Given a URL, discover if there is an RSS feed.
2781 If there is, use Gnus to create an nnrss group"
2785 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2786 (let ((feedinfo (nnrss-discover-feed url)))
2788 (let ((title (gnus-newsgroup-savable-name
2789 (read-from-minibuffer "Title: "
2790 (gnus-newsgroup-savable-name
2791 (or (cdr (assoc 'title
2794 (desc (read-from-minibuffer "Description: "
2795 (cdr (assoc 'description
2797 (href (cdr (assoc 'href feedinfo)))
2798 (encodable (mm-coding-system-p 'utf-8)))
2800 ;; Unify non-ASCII text.
2801 (setq title (mm-decode-coding-string
2802 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2803 (gnus-group-make-group (if encodable
2804 (mm-encode-coding-string title 'utf-8)
2807 (push (list title href desc) nnrss-group-alist)
2808 (nnrss-save-server-data nil))
2809 (error "No feeds found for %s" url))))
2811 (defvar nnwarchive-type-definition)
2812 (defvar gnus-group-warchive-type-history nil)
2813 (defvar gnus-group-warchive-login-history nil)
2814 (defvar gnus-group-warchive-address-history nil)
2816 (defun gnus-group-make-warchive-group ()
2817 "Create a nnwarchive group."
2819 (require 'nnwarchive)
2820 (let* ((group (gnus-read-group "Group name: "))
2821 (default-type (or (car gnus-group-warchive-type-history)
2822 (symbol-name (caar nnwarchive-type-definition))))
2826 (format "Warchive type (default %s): " default-type)
2827 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2828 nnwarchive-type-definition)
2829 nil t nil 'gnus-group-warchive-type-history)
2831 (address (read-string "Warchive address: "
2832 nil 'gnus-group-warchive-address-history))
2833 (default-login (or (car gnus-group-warchive-login-history)
2838 (format "Warchive login (default %s): " user-mail-address)
2839 default-login 'gnus-group-warchive-login-history)
2842 `(nnwarchive ,address
2843 (nnwarchive-type ,(intern type))
2844 (nnwarchive-login ,login))))
2845 (gnus-group-make-group group method)))
2847 (defun gnus-group-make-archive-group (&optional all)
2848 "Create the (ding) Gnus archive group of the most recent articles.
2849 Given a prefix, create a full group."
2851 (let ((group (gnus-group-prefixed-name
2852 (if all "ding.archives" "ding.recent") '(nndir ""))))
2853 (when (gnus-group-entry group)
2854 (error "Archive group already exists"))
2855 (gnus-group-make-group
2856 (gnus-group-real-name group)
2857 (list 'nndir (if all "hpc" "edu")
2858 (list 'nndir-directory
2859 (if all gnus-group-archive-directory
2860 gnus-group-recent-archive-directory))))
2861 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2863 (defun gnus-group-make-directory-group (dir)
2864 "Create an nndir group.
2865 The user will be prompted for a directory. The contents of this
2866 directory will be used as a newsgroup. The directory should contain
2867 mail messages or news articles in files that have numeric names."
2869 (list (read-file-name "Create group from directory: ")))
2870 (unless (file-exists-p dir)
2871 (error "No such directory"))
2872 (unless (file-directory-p dir)
2873 (error "Not a directory"))
2877 (while (or (not group) (gnus-group-entry group))
2879 (gnus-group-prefixed-name
2880 (expand-file-name ext dir)
2882 (setq ext (format "<%d>" (setq i (1+ i)))))
2883 (gnus-group-make-group
2884 (gnus-group-real-name group)
2885 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2887 (defvar nnkiboze-score-file)
2888 (defun gnus-group-make-kiboze-group (group address scores)
2889 "Create an nnkiboze group.
2890 The user will be prompted for a name, a regexp to match groups, and
2891 score file entries for articles to include in the group."
2894 (read-string "nnkiboze group name: ")
2895 (read-string "Source groups (regexp): ")
2896 (let ((headers (mapcar 'list
2897 '("subject" "from" "number" "date" "message-id"
2898 "references" "chars" "lines" "xref"
2899 "followup" "all" "body" "head")))
2900 scores header regexp regexps)
2901 (while (not (equal "" (setq header (completing-read
2902 "Match on header: " headers nil t))))
2904 (while (not (equal "" (setq regexp (read-string
2905 (format "Match on %s (regexp): "
2907 (push (list regexp nil nil 'r) regexps))
2908 (push (cons header regexps) scores))
2910 (gnus-group-make-group group "nnkiboze" address)
2911 (let* ((nnkiboze-current-group group)
2912 (score-file (car (nnkiboze-score-file "")))
2913 (score-dir (file-name-directory score-file)))
2914 (unless (file-exists-p score-dir)
2915 (make-directory score-dir))
2916 (with-temp-file score-file
2917 (let (emacs-lisp-mode-hook)
2918 (gnus-pp scores)))))
2920 (defun gnus-group-add-to-virtual (n vgroup)
2921 "Add the current group to a virtual group."
2923 (list current-prefix-arg
2924 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2926 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2927 (error "%s is not an nnvirtual group" vgroup))
2928 (gnus-close-group vgroup)
2929 (let* ((groups (gnus-group-process-prefix n))
2930 (method (gnus-info-method (gnus-get-info vgroup))))
2931 (setcar (cdr method)
2933 (nth 1 method) "\\|"
2936 (gnus-group-remove-mark s)
2937 (concat "\\(^" (regexp-quote s) "$\\)"))
2939 (gnus-group-position-point))
2941 (defun gnus-group-make-empty-virtual (group)
2942 "Create a new, fresh, empty virtual group."
2943 (interactive "sCreate new, empty virtual group: ")
2944 (let* ((method (list 'nnvirtual "^$"))
2945 (pgroup (gnus-group-prefixed-name group method)))
2946 ;; Check whether it exists already.
2947 (when (gnus-group-entry pgroup)
2948 (error "Group %s already exists" pgroup))
2949 ;; Subscribe the new group after the group on the current line.
2950 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2951 (gnus-group-update-group pgroup)
2953 (gnus-group-position-point)))
2955 (defun gnus-group-enter-directory (dir)
2956 "Enter an ephemeral nneething group."
2957 (interactive "DDirectory to read: ")
2958 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2959 (leaf (gnus-group-prefixed-name
2960 (file-name-nondirectory (directory-file-name dir))
2962 (name (gnus-generate-new-group-name leaf)))
2963 (unless (gnus-group-read-ephemeral-group
2965 (cons (current-buffer)
2966 (if (eq major-mode 'gnus-summary-mode)
2968 (error "Couldn't enter %s" dir))))
2971 (autoload 'nnimap-expunge "nnimap")
2972 (autoload 'nnimap-acl-get "nnimap")
2973 (autoload 'nnimap-acl-edit "nnimap"))
2975 (defun gnus-group-nnimap-expunge (group)
2976 "Expunge deleted articles in current nnimap GROUP."
2977 (interactive (list (gnus-group-group-name)))
2978 (let ((mailbox (gnus-group-real-name group)) method)
2980 (error "No group on current line"))
2981 (unless (gnus-get-info group)
2982 (error "Killed group; can't be edited"))
2983 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2984 (error "%s is not an nnimap group" group))
2985 (nnimap-expunge mailbox (cadr method))))
2987 (defun gnus-group-nnimap-edit-acl (group)
2988 "Edit the Access Control List of current nnimap GROUP."
2989 (interactive (list (gnus-group-group-name)))
2990 (let ((mailbox (gnus-group-real-name group)) method acl)
2992 (error "No group on current line"))
2993 (unless (gnus-get-info group)
2994 (error "Killed group; can't be edited"))
2995 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2996 (error "%s is not an nnimap group" group))
2997 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2998 (error "Server does not support ACL's"))
2999 (gnus-edit-form acl (format "Editing the access control list for `%s'.
3001 An access control list is a list of (identifier . rights) elements.
3003 The identifier string specifies the corresponding user. The
3004 identifier \"anyone\" is reserved to refer to the universal identity.
3006 Rights is a string listing a (possibly empty) set of alphanumeric
3007 characters, each character listing a set of operations which is being
3008 controlled. Letters are reserved for ``standard'' rights, listed
3009 below. Digits are reserved for implementation or site defined rights.
3011 l - lookup (mailbox is visible to LIST/LSUB commands)
3012 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3013 SEARCH, COPY from mailbox)
3014 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3015 w - write (STORE flags other than \\SEEN and \\DELETED)
3016 i - insert (perform APPEND, COPY into mailbox)
3017 p - post (send mail to submission address for mailbox,
3018 not enforced by IMAP4 itself)
3019 c - create and delete mailbox (CREATE new sub-mailboxes in any
3020 implementation-defined hierarchy, RENAME or DELETE mailbox)
3021 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3022 a - administer (perform SETACL)" group)
3025 ,mailbox ',method ',acl form)))))
3027 ;; Group sorting commands
3028 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3030 (defun gnus-group-sort-groups (func &optional reverse)
3031 "Sort the group buffer according to FUNC.
3032 When used interactively, the sorting function used will be
3033 determined by the `gnus-group-sort-function' variable.
3034 If REVERSE (the prefix), reverse the sorting order."
3035 (interactive (list gnus-group-sort-function current-prefix-arg))
3036 (funcall gnus-group-sort-alist-function
3037 (gnus-make-sort-function func) reverse)
3038 (gnus-group-unmark-all-groups)
3039 (gnus-group-list-groups)
3040 (gnus-dribble-touch))
3042 (defun gnus-group-sort-flat (func reverse)
3043 ;; We peel off the dummy group from the alist.
3045 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3046 (pop gnus-newsrc-alist))
3048 (setq gnus-newsrc-alist
3049 (sort gnus-newsrc-alist func))
3051 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3052 ;; Regenerate the hash table.
3053 (gnus-make-hashtable-from-newsrc-alist)))
3055 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3056 "Sort the group buffer alphabetically by group name.
3057 If REVERSE, sort in reverse order."
3059 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3061 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3062 "Sort the group buffer alphabetically by real (unprefixed) group name.
3063 If REVERSE, sort in reverse order."
3065 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3067 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3068 "Sort the group buffer by number of unread articles.
3069 If REVERSE, sort in reverse order."
3071 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3073 (defun gnus-group-sort-groups-by-level (&optional reverse)
3074 "Sort the group buffer by group level.
3075 If REVERSE, sort in reverse order."
3077 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3079 (defun gnus-group-sort-groups-by-score (&optional reverse)
3080 "Sort the group buffer by group score.
3081 If REVERSE, sort in reverse order."
3083 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3085 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3086 "Sort the group buffer by group rank.
3087 If REVERSE, sort in reverse order."
3089 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3091 (defun gnus-group-sort-groups-by-method (&optional reverse)
3092 "Sort the group buffer alphabetically by back end name.
3093 If REVERSE, sort in reverse order."
3095 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3097 (defun gnus-group-sort-groups-by-server (&optional reverse)
3098 "Sort the group buffer alphabetically by server name.
3099 If REVERSE, sort in reverse order."
3101 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3103 ;;; Selected group sorting.
3105 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3106 "Sort the process/prefixed groups."
3107 (interactive (list current-prefix-arg gnus-group-sort-function))
3108 (let ((groups (gnus-group-process-prefix n)))
3109 (funcall gnus-group-sort-selected-function
3110 groups (gnus-make-sort-function func) reverse)
3111 (gnus-group-unmark-all-groups)
3112 (gnus-group-list-groups)
3113 (gnus-dribble-touch)))
3115 (defun gnus-group-sort-selected-flat (groups func reverse)
3116 (let (entries infos)
3117 ;; First find all the group entries for these groups.
3119 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3121 ;; Then sort the infos.
3125 (lambda (entry) (car entry))
3126 (setq entries (nreverse entries)))
3129 (setq infos (nreverse infos)))
3130 ;; Go through all the infos and replace the old entries
3131 ;; with the new infos.
3133 (setcar (car entries) (pop infos))
3135 ;; Update the hashtable.
3136 (gnus-make-hashtable-from-newsrc-alist)))
3138 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3139 "Sort the group buffer alphabetically by group name.
3140 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3141 sort in reverse order."
3142 (interactive (gnus-interactive "P\ny"))
3143 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3145 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3146 "Sort the group buffer alphabetically by real group name.
3147 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3148 sort in reverse order."
3149 (interactive (gnus-interactive "P\ny"))
3150 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3152 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3153 "Sort the group buffer by number of unread articles.
3154 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3155 sort in reverse order."
3156 (interactive (gnus-interactive "P\ny"))
3157 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3159 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3160 "Sort the group buffer by group level.
3161 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3162 sort in reverse order."
3163 (interactive (gnus-interactive "P\ny"))
3164 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3166 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3167 "Sort the group buffer by group score.
3168 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3169 sort in reverse order."
3170 (interactive (gnus-interactive "P\ny"))
3171 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3173 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3174 "Sort the group buffer by group rank.
3175 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3176 sort in reverse order."
3177 (interactive (gnus-interactive "P\ny"))
3178 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3180 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3181 "Sort the group buffer alphabetically by back end name.
3182 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3183 sort in reverse order."
3184 (interactive (gnus-interactive "P\ny"))
3185 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3187 ;;; Sorting predicates.
3189 (defun gnus-group-sort-by-alphabet (info1 info2)
3190 "Sort alphabetically."
3191 (string< (gnus-info-group info1) (gnus-info-group info2)))
3193 (defun gnus-group-sort-by-real-name (info1 info2)
3194 "Sort alphabetically on real (unprefixed) names."
3195 (string< (gnus-group-real-name (gnus-info-group info1))
3196 (gnus-group-real-name (gnus-info-group info2))))
3198 (defun gnus-group-sort-by-unread (info1 info2)
3199 "Sort by number of unread articles."
3200 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3201 (n2 (gnus-group-unread (gnus-info-group info1))))
3202 (< (or (and (numberp n1) n1) 0)
3203 (or (and (numberp n2) n2) 0))))
3205 (defun gnus-group-sort-by-level (info1 info2)
3207 (< (gnus-info-level info1) (gnus-info-level info2)))
3209 (defun gnus-group-sort-by-method (info1 info2)
3210 "Sort alphabetically by back end name."
3211 (string< (car (gnus-find-method-for-group
3212 (gnus-info-group info1) info1))
3213 (car (gnus-find-method-for-group
3214 (gnus-info-group info2) info2))))
3216 (defun gnus-group-sort-by-server (info1 info2)
3217 "Sort alphabetically by server name."
3218 (string< (gnus-method-to-full-server-name
3219 (gnus-find-method-for-group
3220 (gnus-info-group info1) info1))
3221 (gnus-method-to-full-server-name
3222 (gnus-find-method-for-group
3223 (gnus-info-group info2) info2))))
3225 (defun gnus-group-sort-by-score (info1 info2)
3226 "Sort by group score."
3227 (> (gnus-info-score info1) (gnus-info-score info2)))
3229 (defun gnus-group-sort-by-rank (info1 info2)
3230 "Sort by level and score."
3231 (let ((level1 (gnus-info-level info1))
3232 (level2 (gnus-info-level info2)))
3233 (or (< level1 level2)
3234 (and (= level1 level2)
3235 (> (gnus-info-score info1) (gnus-info-score info2))))))
3239 (defun gnus-group-clear-data (&optional arg)
3240 "Clear all marks and read ranges from the current group.
3241 Obeys the process/prefix convention."
3243 (gnus-group-iterate arg
3246 (gnus-info-clear-data (setq info (gnus-get-info group)))
3247 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3248 (when (gnus-group-goto-group group)
3249 (gnus-group-update-group-line))))))
3251 (defun gnus-group-clear-data-on-native-groups ()
3252 "Clear all marks and read ranges from all native groups."
3254 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3255 (let ((alist (cdr gnus-newsrc-alist))
3257 (while (setq info (pop alist))
3258 (when (gnus-group-native-p (gnus-info-group info))
3259 (gnus-info-clear-data info)))
3260 (gnus-get-unread-articles)
3261 (gnus-dribble-touch)
3262 (when (gnus-y-or-n-p
3263 "Move the cache away to avoid problems in the future? ")
3264 (call-interactively 'gnus-cache-move-cache)))))
3266 (defun gnus-info-clear-data (info)
3267 "Clear all marks and read ranges from INFO."
3268 (let ((group (gnus-info-group info))
3270 (dolist (el (gnus-info-marks info))
3271 (push `(,(cdr el) add (,(car el))) action))
3272 (push `(,(gnus-info-read info) add (read)) action)
3275 (gnus-request-set-mark ,group ',action)
3276 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3277 (gnus-info-set-read ',info ',(gnus-info-read info))
3278 (when (gnus-group-goto-group ,group)
3279 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3280 (gnus-group-update-group-line))))
3281 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3283 (gnus-request-set-mark group action)
3284 (gnus-info-set-read info nil)
3285 (when (gnus-info-marks info)
3286 (gnus-info-set-marks info nil))))
3288 ;; Group catching up.
3290 (defun gnus-group-catchup-current (&optional n all)
3291 "Mark all unread articles in the current newsgroup as read.
3292 If prefix argument N is numeric, the next N newsgroups will be
3293 caught up. If ALL is non-nil, marked articles will also be marked as
3294 read. Cross references (Xref: header) of articles are ignored.
3295 The number of newsgroups that this function was unable to catch
3298 (let ((groups (gnus-group-process-prefix n))
3301 (unless groups (error "No groups selected"))
3303 (or (not gnus-interactive-catchup) ;Without confirmation?
3308 "Do you really want to mark all articles in %s as read? "
3309 "Mark all unread articles in %s as read? ")
3310 (if (= (length groups) 1)
3311 (gnus-group-decoded-name (car groups))
3312 (format "these %d groups" (length groups)))))))
3314 (while (setq group (pop groups))
3315 (gnus-group-remove-mark group)
3316 ;; Virtual groups have to be given special treatment.
3317 (let ((method (gnus-find-method-for-group group)))
3318 (when (eq 'nnvirtual (car method))
3319 (nnvirtual-catchup-group
3320 (gnus-group-real-name group) (nth 1 method) all)))
3321 (if (>= (gnus-group-level group) gnus-level-zombie)
3322 (gnus-message 2 "Dead groups can't be caught up")
3324 (gnus-group-goto-group group)
3325 (gnus-group-catchup group all))
3326 (gnus-group-update-group-line)
3327 (setq ret (1+ ret)))))
3328 (gnus-group-next-unread-group 1)
3331 (defun gnus-group-catchup-current-all (&optional n)
3332 "Mark all articles in current newsgroup as read.
3333 Cross references (Xref: header) of articles are ignored."
3335 (gnus-group-catchup-current n 'all))
3337 (defun gnus-group-catchup (group &optional all)
3338 "Mark all articles in GROUP as read.
3339 If ALL is non-nil, all articles are marked as read.
3340 The return value is the number of articles that were marked as read,
3341 or nil if no action could be taken."
3342 (let* ((entry (gnus-group-entry group))
3344 (marks (gnus-info-marks (nth 2 entry)))
3345 (unread (gnus-sequence-of-unread-articles group)))
3346 ;; Remove entries for this group.
3347 (nnmail-purge-split-history (gnus-group-real-name group))
3348 ;; Do the updating only if the newsgroup isn't killed.
3349 (if (not (numberp (car entry)))
3350 (gnus-message 1 "Can't catch up %s; non-active group" group)
3351 (gnus-update-read-articles group nil)
3353 ;; Nix out the lists of marks and dormants.
3354 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3356 (list (cdr (assq 'dormant marks))
3358 (setq unread (gnus-range-add (gnus-range-add
3359 unread (cdr (assq 'dormant marks)))
3360 (cdr (assq 'tick marks))))
3361 (gnus-add-marked-articles group 'tick nil nil 'force)
3362 (gnus-add-marked-articles group 'dormant nil nil 'force))
3363 ;; Do auto-expirable marks if that's required.
3364 (when (gnus-group-auto-expirable-p group)
3365 (gnus-range-map (lambda (article)
3366 (gnus-add-marked-articles group 'expire (list article))
3367 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3369 (let ((gnus-newsgroup-name group))
3370 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3373 (defun gnus-group-expire-articles (&optional n)
3374 "Expire all expirable articles in the current newsgroup.
3375 Uses the process/prefix convention."
3377 (let ((groups (gnus-group-process-prefix n))
3380 (error "No groups to expire"))
3381 (while (setq group (pop groups))
3382 (gnus-group-remove-mark group)
3383 (gnus-group-expire-articles-1 group)
3384 (gnus-dribble-touch)
3385 (gnus-group-position-point))))
3387 (defun gnus-group-expire-articles-1 (group)
3388 (when (gnus-check-backend-function 'request-expire-articles group)
3389 (gnus-message 6 "Expiring articles in %s..."
3390 (gnus-group-decoded-name group))
3391 (let* ((info (gnus-get-info group))
3392 (expirable (if (gnus-group-total-expirable-p group)
3393 (cons nil (gnus-list-of-read-articles group))
3394 (assq 'expire (gnus-info-marks info))))
3395 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3396 (nnmail-expiry-target
3397 (or (gnus-group-find-parameter group 'expiry-target)
3398 nnmail-expiry-target)))
3400 (gnus-check-group group)
3403 (gnus-compress-sequence
3405 ;; We set the expiry variables to the group
3407 (let ((nnmail-expiry-wait-function nil)
3408 (nnmail-expiry-wait expiry-wait))
3409 (gnus-request-expire-articles
3410 (gnus-uncompress-sequence (cdr expirable)) group))
3411 ;; Just expire using the normal expiry values.
3412 (gnus-request-expire-articles
3413 (gnus-uncompress-sequence (cdr expirable)) group))))
3414 (gnus-close-group group))
3415 (gnus-message 6 "Expiring articles in %s...done"
3416 (gnus-group-decoded-name group))
3417 ;; Return the list of un-expired articles.
3420 (defun gnus-group-expire-all-groups ()
3421 "Expire all expirable articles in all newsgroups."
3424 (gnus-message 5 "Expiring...")
3425 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3426 (cdr gnus-newsrc-alist))))
3427 (gnus-group-expire-articles nil)))
3428 (gnus-group-position-point)
3429 (gnus-message 5 "Expiring...done"))
3431 (defun gnus-group-set-current-level (n level)
3432 "Set the level of the next N groups to LEVEL."
3437 (unless (gnus-group-process-prefix current-prefix-arg)
3438 (error "No group on the current line"))
3440 (let ((s (read-string
3441 (format "Level (default %s): "
3442 (or (gnus-group-group-level)
3443 gnus-level-default-subscribed)))))
3444 (if (string-match "^\\s-*$" s)
3445 (int-to-string (or (gnus-group-group-level)
3446 gnus-level-default-subscribed))
3448 (unless (and (>= level 1) (<= level gnus-level-killed))
3449 (error "Invalid level: %d" level))
3450 (dolist (group (gnus-group-process-prefix n))
3451 (gnus-group-remove-mark group)
3452 (gnus-message 6 "Changed level of %s from %d to %d"
3453 (gnus-group-decoded-name group)
3454 (or (gnus-group-group-level) gnus-level-killed)
3456 (gnus-group-change-level
3457 group level (or (gnus-group-group-level) gnus-level-killed))
3458 (gnus-group-update-group-line))
3459 (gnus-group-position-point))
3461 (defun gnus-group-unsubscribe (&optional n)
3462 "Unsubscribe the current group."
3464 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3466 (defun gnus-group-subscribe (&optional n)
3467 "Subscribe the current group."
3469 (gnus-group-unsubscribe-current-group n 'subscribe))
3471 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3472 "Toggle subscription of the current group.
3473 If given numerical prefix, toggle the N next groups."
3475 (dolist (group (gnus-group-process-prefix n))
3476 (gnus-group-remove-mark group)
3477 (gnus-group-unsubscribe-group
3480 ((eq do-sub 'unsubscribe)
3481 gnus-level-default-unsubscribed)
3482 ((eq do-sub 'subscribe)
3483 gnus-level-default-subscribed)
3484 ((<= (gnus-group-group-level) gnus-level-subscribed)
3485 gnus-level-default-unsubscribed)
3487 gnus-level-default-subscribed))
3489 (gnus-group-update-group-line))
3490 (gnus-group-next-group 1))
3492 (defun gnus-group-unsubscribe-group (group &optional level silent)
3493 "Toggle subscription to GROUP.
3494 Killed newsgroups are subscribed. If SILENT, don't try to update the
3497 (list (completing-read
3498 "Group: " gnus-active-hashtb nil
3499 (gnus-read-active-file-p)
3501 'gnus-group-history)))
3502 (let ((newsrc (gnus-group-entry group)))
3504 ((string-match "^[ \t]*$" group)
3505 (error "Empty group name"))
3507 ;; Toggle subscription flag.
3508 (gnus-group-change-level
3509 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3510 gnus-level-subscribed)
3511 (1+ gnus-level-subscribed)
3512 gnus-level-default-subscribed)))
3514 (gnus-group-update-group group)))
3515 ((and (stringp group)
3516 (or (not (gnus-read-active-file-p))
3517 (gnus-active group)))
3518 ;; Add new newsgroup.
3519 (gnus-group-change-level
3521 (if level level gnus-level-default-subscribed)
3522 (or (and (member group gnus-zombie-list)
3525 (when (gnus-group-group-name)
3526 (gnus-group-entry (gnus-group-group-name))))
3528 (gnus-group-update-group group)))
3529 (t (error "No such newsgroup: %s" group)))
3530 (gnus-group-position-point)))
3532 (defun gnus-group-transpose-groups (n)
3533 "Move the current newsgroup up N places.
3534 If given a negative prefix, move down instead. The difference between
3535 N and the number of steps taken is returned."
3537 (unless (gnus-group-group-name)
3538 (error "No group on current line"))
3539 (gnus-group-kill-group 1)
3541 (forward-line (- n))
3542 (gnus-group-yank-group)
3543 (gnus-group-position-point)))
3545 (defun gnus-group-kill-all-zombies (&optional dummy)
3546 "Kill all zombie newsgroups.
3547 The optional DUMMY should always be nil."
3548 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3550 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3551 (setq gnus-zombie-list nil)
3552 (gnus-dribble-touch)
3553 (gnus-group-list-groups)))
3555 (defun gnus-group-kill-region (begin end)
3556 "Kill newsgroups in current region (excluding current point).
3557 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3570 (beginning-of-line) ;Important when LINES < 1
3571 (gnus-group-kill-group lines)))
3573 (defun gnus-group-kill-group (&optional n discard)
3574 "Kill the next N groups.
3575 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3576 However, only groups that were alive can be yanked; already killed
3577 groups or zombie groups can't be yanked.
3578 The return value is the name of the group that was killed, or a list
3581 (let ((buffer-read-only nil)
3582 (groups (gnus-group-process-prefix n))
3583 group entry level out)
3584 (if (< (length groups) 10)
3585 ;; This is faster when there are few groups.
3587 (push (setq group (pop groups)) out)
3588 (gnus-group-remove-mark group)
3589 (setq level (gnus-group-group-level))
3591 (when (and (not discard)
3592 (setq entry (gnus-group-entry group)))
3595 (gnus-group-goto-group ,(gnus-group-group-name))
3596 (gnus-group-yank-group)))
3597 (push (cons (car entry) (nth 2 entry))
3598 gnus-list-of-killed-groups))
3599 (gnus-group-change-level
3600 (if entry entry group) gnus-level-killed (if entry nil level))
3601 (message "Killed group %s" (gnus-group-decoded-name group)))
3602 ;; If there are lots and lots of groups to be killed, we use
3603 ;; this thing instead.
3604 (dolist (group (nreverse groups))
3605 (gnus-group-remove-mark group)
3607 (push group gnus-killed-list)
3608 (setq gnus-newsrc-alist
3609 (delq (assoc group gnus-newsrc-alist)
3611 (when gnus-group-change-level-function
3612 (funcall gnus-group-change-level-function
3613 group gnus-level-killed 3))
3615 ((setq entry (gnus-group-entry group))
3616 (push (cons (car entry) (nth 2 entry))
3617 gnus-list-of-killed-groups)
3618 (setcdr (cdr entry) (cdddr entry)))
3619 ((member group gnus-zombie-list)
3620 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3621 ;; There may be more than one instance displayed.
3622 (while (gnus-group-goto-group group)
3623 (gnus-delete-line)))
3624 (gnus-make-hashtable-from-newsrc-alist))
3626 (gnus-group-position-point)
3627 (if (< (length out) 2) (car out) (nreverse out))))
3629 (defun gnus-group-yank-group (&optional arg)
3630 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3631 The numeric ARG specifies how many newsgroups are to be yanked. The
3632 name of the newsgroup yanked is returned, or (if several groups are
3633 yanked) a list of yanked groups is returned."
3635 (setq arg (or arg 1))
3636 (let (info group prev out)
3637 (while (>= (decf arg) 0)
3638 (when (not (setq info (pop gnus-list-of-killed-groups)))
3639 (error "No more newsgroups to yank"))
3640 (push (setq group (nth 1 info)) out)
3641 ;; Find which newsgroup to insert this one before - search
3642 ;; backward until something suitable is found. If there are no
3643 ;; other newsgroups in this buffer, just make this newsgroup the
3645 (setq prev (gnus-group-group-name))
3646 (gnus-group-change-level
3647 info (gnus-info-level (cdr info)) gnus-level-killed
3648 (and prev (gnus-group-entry prev))
3650 (gnus-group-insert-group-line-info group)
3652 `(when (gnus-group-goto-group ,group)
3653 (gnus-group-kill-group 1))))
3655 (gnus-group-position-point)
3656 (if (< (length out) 2) (car out) (nreverse out))))
3658 (defun gnus-group-kill-level (level)
3659 "Kill all groups that is on a certain LEVEL."
3660 (interactive "nKill all groups on level: ")
3662 ((= level gnus-level-zombie)
3663 (setq gnus-killed-list
3664 (nconc gnus-zombie-list gnus-killed-list))
3665 (setq gnus-zombie-list nil))
3666 ((and (< level gnus-level-zombie)
3668 (or gnus-expert-user
3671 "Do you really want to kill all groups on level %d? "
3673 (let* ((prev gnus-newsrc-alist)
3676 (if (= (gnus-info-level (car alist)) level)
3678 (push (gnus-info-group (car alist)) gnus-killed-list)
3679 (setcdr prev (cdr alist)))
3681 (setq alist (cdr alist)))
3682 (gnus-make-hashtable-from-newsrc-alist)
3683 (gnus-group-list-groups)))
3685 (error "Can't kill; invalid level: %d" level))))
3687 (defun gnus-group-list-all-groups (&optional arg)
3688 "List all newsgroups with level ARG or lower.
3689 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3690 unsubscribed groups."
3692 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3694 ;; Redefine this to list ALL killed groups if prefix arg used.
3695 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3696 (defun gnus-group-list-killed (&optional arg)
3697 "List all killed newsgroups in the group buffer.
3698 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3699 entail asking the server for the groups."
3701 ;; Find all possible killed newsgroups if arg.
3703 (gnus-get-killed-groups))
3704 (if (not gnus-killed-list)
3705 (gnus-message 6 "No killed groups")
3706 (let (gnus-group-list-mode)
3707 (funcall gnus-group-prepare-function
3708 gnus-level-killed t gnus-level-killed))
3709 (goto-char (point-min)))
3710 (gnus-group-position-point))
3712 (defun gnus-group-list-zombies ()
3713 "List all zombie newsgroups in the group buffer."
3715 (if (not gnus-zombie-list)
3716 (gnus-message 6 "No zombie groups")
3717 (let (gnus-group-list-mode)
3718 (funcall gnus-group-prepare-function
3719 gnus-level-zombie t gnus-level-zombie))
3720 (goto-char (point-min)))
3721 (gnus-group-position-point))
3723 (defun gnus-group-list-active ()
3724 "List all groups that are available from the server(s)."
3726 ;; First we make sure that we have really read the active file.
3727 (unless (gnus-read-active-file-p)
3728 (let ((gnus-read-active-file t)
3729 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3730 (gnus-read-active-file)))
3731 ;; Find all groups and sort them.
3739 (push (symbol-name sym) list)))
3743 (buffer-read-only nil)
3747 (setq group (pop groups))
3748 (gnus-add-text-properties
3749 (point) (prog1 (1+ (point))
3751 (gnus-group-decoded-name group)
3753 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3755 'gnus-level (inline (gnus-group-level group)))))
3756 (goto-char (point-min))))
3758 (defun gnus-activate-all-groups (level)
3759 "Activate absolutely all groups."
3760 (interactive (list gnus-level-unsubscribed))
3761 (let ((gnus-activate-level level)
3762 (gnus-activate-foreign-newsgroups level))
3763 (gnus-group-get-new-news)))
3765 (defun gnus-group-get-new-news (&optional arg)
3766 "Get newly arrived articles.
3767 If ARG is a number, it specifies which levels you are interested in
3768 re-scanning. If ARG is non-nil and not a number, this will force
3769 \"hard\" re-reading of the active files from all servers."
3772 (let ((gnus-inhibit-demon t)
3773 ;; Binding this variable will inhibit multiple fetchings
3774 ;; of the same mail source.
3775 (nnmail-fetched-sources (list t)))
3776 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3777 (gnus-run-hooks 'gnus-get-new-news-hook)
3779 ;; Read any slave files.
3781 (gnus-master-read-slave-newsrc))
3783 ;; We might read in new NoCeM messages here.
3784 (when (and gnus-use-nocem
3786 (gnus-nocem-scan-groups))
3787 ;; If ARG is not a number, then we read the active file.
3788 (when (and arg (not (numberp arg)))
3789 (let ((gnus-read-active-file t))
3790 (gnus-read-active-file))
3793 ;; If the user wants it, we scan for new groups.
3794 (when (eq gnus-check-new-newsgroups 'always)
3795 (gnus-find-new-newsgroups)))
3797 (setq arg (gnus-group-default-level arg t))
3798 (if (and gnus-read-active-file (not arg))
3800 (gnus-read-active-file)
3801 (gnus-get-unread-articles arg))
3802 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3803 (gnus-get-unread-articles arg)))
3804 (gnus-check-reasonable-setup)
3805 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3806 (gnus-group-list-groups (and (numberp arg)
3807 (max (car gnus-group-list-mode) arg)))))
3809 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3810 "Check for newly arrived news in the current group (and the N-1 next groups).
3811 The difference between N and the number of newsgroup checked is returned.
3812 If N is negative, this group and the N-1 previous groups will be checked.
3813 If DONT-SCAN is non-nil, scan non-activated groups as well."
3815 (let* ((groups (gnus-group-process-prefix n))
3816 (ret (if (numberp n) (- n (length groups)) 0))
3820 (gnus-inhibit-demon t)
3821 ;; Binding this variable will inhibit multiple fetchings
3822 ;; of the same mail source.
3823 (nnmail-fetched-sources (list t)))
3824 (gnus-run-hooks 'gnus-get-new-news-hook)
3825 (while (setq group (pop groups))
3826 (gnus-group-remove-mark group)
3827 ;; Bypass any previous denials from the server.
3828 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3829 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3830 (let ((info (gnus-get-info group))
3831 (active (gnus-active group)))
3833 (gnus-request-update-info info method))
3834 (gnus-get-unread-articles-in-group info active)
3835 (unless (gnus-virtual-group-p group)
3836 (gnus-close-group group))
3838 (gnus-agent-save-group-info
3839 method (gnus-group-real-name group) active))
3840 (gnus-group-update-group group))
3841 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3843 (gnus-error 3 "Server denied access")
3844 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3847 (when gnus-goto-next-group-when-activating
3848 (gnus-group-next-unread-group 1 t))
3849 (gnus-summary-position-point)
3852 (defun gnus-group-fetch-faq (group &optional faq-dir)
3853 "Fetch the FAQ for the current group.
3854 If given a prefix argument, prompt for the FAQ dir
3858 (gnus-group-group-name)
3859 (when current-prefix-arg
3861 "FAQ dir: " (and (listp gnus-group-faq-directory)
3863 gnus-group-faq-directory))))))
3865 (error "No group name given"))
3866 (let ((dirs (or faq-dir gnus-group-faq-directory))
3868 (unless (listp dirs)
3869 (setq dirs (list dirs)))
3870 (while (and (not found)
3871 (setq dir (pop dirs)))
3872 (let ((name (gnus-group-real-name group)))
3873 (setq file (expand-file-name name dir)))
3874 (if (not (file-exists-p file))
3875 (gnus-message 1 "No such file: %s" file)
3876 (let ((enable-local-variables nil))
3880 (defun gnus-group-fetch-charter (group)
3881 "Fetch the charter for the current group.
3882 If given a prefix argument, prompt for a group."
3884 (list (or (when current-prefix-arg
3885 (completing-read "Group: " gnus-active-hashtb))
3886 (gnus-group-group-name)
3887 gnus-newsgroup-name)))
3889 (error "No group name given"))
3891 (condition-case nil (require 'url-http) (error nil))
3892 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3894 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3895 (setq hierarchy (match-string 1 name))
3896 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3897 (if (fboundp 'url-http-file-exists-p)
3898 (url-http-file-exists-p (eval url))
3900 (browse-url (eval url))
3901 (setq url (concat "http://" hierarchy
3902 ".news-admin.org/charters/" name))
3903 (if (and (fboundp 'url-http-file-exists-p)
3904 (url-http-file-exists-p url))
3906 (gnus-group-fetch-control group))))))
3908 (defun gnus-group-fetch-control (group)
3909 "Fetch the archived control messages for the current group.
3910 If given a prefix argument, prompt for a group."
3912 (list (or (when current-prefix-arg
3913 (completing-read "Group: " gnus-active-hashtb))
3914 (gnus-group-group-name)
3915 gnus-newsgroup-name)))
3917 (error "No group name given"))
3918 (let ((name (gnus-group-real-name group))
3920 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3921 (setq hierarchy (match-string 1 name))
3922 (if gnus-group-fetch-control-use-browse-url
3923 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3924 hierarchy "/" name ".gz"))
3925 (let ((enable-local-variables nil))
3926 (gnus-group-read-ephemeral-group
3928 `(nndoc ,group (nndoc-address
3929 ,(find-file-noselect
3930 (concat "/ftp@ftp.isc.org:/usenet/control/"
3931 hierarchy "/" name ".gz")))
3932 (nndoc-article-type mbox)) t nil nil))))))
3934 (defun gnus-group-describe-group (force &optional group)
3935 "Display a description of the current newsgroup."
3936 (interactive (list current-prefix-arg (gnus-group-group-name)))
3937 (let* ((method (gnus-find-method-for-group group))
3938 (mname (gnus-group-prefixed-name "" method))
3941 gnus-description-hashtb)
3942 (gnus-sethash mname nil gnus-description-hashtb))
3944 (error "No group name given"))
3945 (when (or (and gnus-description-hashtb
3946 ;; We check whether this group's method has been
3947 ;; queried for a description file.
3948 (gnus-gethash mname gnus-description-hashtb))
3949 (setq desc (gnus-group-get-description group))
3950 (gnus-read-descriptions-file method))
3952 (or desc (gnus-gethash group gnus-description-hashtb)
3953 "No description available")))))
3955 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3956 (defun gnus-group-describe-all-groups (&optional force)
3957 "Pop up a buffer with descriptions of all newsgroups."
3960 (setq gnus-description-hashtb nil))
3961 (when (not (or gnus-description-hashtb
3962 (gnus-read-all-descriptions-files)))
3963 (error "Couldn't request descriptions file"))
3964 (let ((buffer-read-only nil)
3970 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3971 (insert (format " *: %-20s %s\n"
3972 (gnus-group-name-decode
3973 (symbol-name group) charset)
3974 (gnus-group-name-decode
3975 (symbol-value group) charset))))
3976 (gnus-add-text-properties
3977 b (1+ b) (list 'gnus-group group
3978 'gnus-unread t 'gnus-marked nil
3979 'gnus-level (1+ gnus-level-subscribed))))
3980 gnus-description-hashtb)
3981 (goto-char (point-min))
3982 (gnus-group-position-point)))
3984 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3985 (defun gnus-group-apropos (regexp &optional search-description)
3986 "List all newsgroups that have names that match a regexp."
3987 (interactive "sGnus apropos (regexp): ")
3989 (obuf (current-buffer))
3991 ;; Go through all newsgroups that are known to Gnus.
3994 (and (symbol-name group)
3995 (string-match regexp (symbol-name group))
3996 (symbol-value group)
3997 (push (symbol-name group) groups)))
3999 ;; Also go through all descriptions that are known to Gnus.
4000 (when search-description
4003 (and (string-match regexp (symbol-value group))
4004 (push (symbol-name group) groups)))
4005 gnus-description-hashtb))
4007 (gnus-message 3 "No groups matched \"%s\"." regexp)
4008 ;; Print out all the groups.
4010 (pop-to-buffer "*Gnus Help*")
4011 (buffer-disable-undo)
4013 (setq groups (sort groups 'string<))
4015 ;; Groups may be entered twice into the list of groups.
4016 (when (not (string= (car groups) prev))
4017 (setq prev (car groups))
4018 (let ((charset (gnus-group-name-charset nil prev)))
4019 (insert (gnus-group-name-decode prev charset) "\n")
4020 (when (and gnus-description-hashtb
4021 (setq des (gnus-gethash (car groups)
4022 gnus-description-hashtb)))
4023 (insert " " (gnus-group-name-decode des charset) "\n"))))
4024 (setq groups (cdr groups)))
4025 (goto-char (point-min))))
4026 (pop-to-buffer obuf)))
4028 (defun gnus-group-description-apropos (regexp)
4029 "List all newsgroups that have names or descriptions that match REGEXP."
4030 (interactive "sGnus description apropos (regexp): ")
4031 (when (not (or gnus-description-hashtb
4032 (gnus-read-all-descriptions-files)))
4033 (error "Couldn't request descriptions file"))
4034 (gnus-group-apropos regexp t))
4036 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4037 (defun gnus-group-list-matching (level regexp &optional all lowest)
4038 "List all groups with unread articles that match REGEXP.
4039 If the prefix LEVEL is non-nil, it should be a number that says which
4040 level to cut off listing groups.
4041 If ALL, also list groups with no unread articles.
4042 If LOWEST, don't list groups with level lower than LOWEST.
4044 This command may read the active file."
4045 (interactive "P\nsList newsgroups matching: ")
4046 ;; First make sure active file has been read.
4048 (> (prefix-numeric-value level) gnus-level-killed))
4049 (gnus-get-killed-groups))
4050 (funcall gnus-group-prepare-function
4051 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4052 (goto-char (point-min))
4053 (gnus-group-position-point))
4055 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4056 "List all groups that match REGEXP.
4057 If the prefix LEVEL is non-nil, it should be a number that says which
4058 level to cut off listing groups.
4059 If LOWEST, don't list groups with level lower than LOWEST."
4060 (interactive "P\nsList newsgroups matching: ")
4062 (setq level (prefix-numeric-value level)))
4063 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4065 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4066 (defun gnus-group-save-newsrc (&optional force)
4067 "Save the Gnus startup files.
4068 If FORCE, force saving whether it is necessary or not."
4070 (gnus-save-newsrc-file force))
4072 (defun gnus-group-restart (&optional arg)
4073 "Force Gnus to read the .newsrc file."
4075 (when (gnus-yes-or-no-p
4076 (format "Are you sure you want to restart Gnus? "))
4077 (gnus-save-newsrc-file)
4081 (defun gnus-group-read-init-file ()
4082 "Read the Gnus elisp init file."
4084 (gnus-read-init-file)
4085 (gnus-message 5 "Read %s" gnus-init-file))
4087 (defun gnus-group-check-bogus-groups (&optional silent)
4088 "Check bogus newsgroups.
4089 If given a prefix, don't ask for confirmation before removing a bogus
4092 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4093 (gnus-group-list-groups))
4095 (defun gnus-group-find-new-groups (&optional arg)
4096 "Search for new groups and add them.
4097 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4098 With 1 C-u, use the `ask-server' method to query the server for new
4100 With 2 C-u's, use most complete method possible to query the server
4101 for new groups, and subscribe the new groups as zombies."
4103 (gnus-find-new-newsgroups (or arg 1))
4104 (gnus-group-list-groups))
4106 (defun gnus-group-edit-global-kill (&optional article group)
4107 "Edit the global kill file.
4108 If GROUP, edit that local kill file instead."
4110 (setq gnus-current-kill-article article)
4111 (gnus-kill-file-edit-file group)
4114 (substitute-command-keys
4115 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4116 (if group "local" "global")))))
4118 (defun gnus-group-edit-local-kill (article group)
4119 "Edit a local kill file."
4120 (interactive (list nil (gnus-group-group-name)))
4121 (gnus-group-edit-global-kill article group))
4123 (defun gnus-group-force-update ()
4124 "Update `.newsrc' file."
4126 (gnus-save-newsrc-file))
4128 (defvar gnus-backlog-articles)
4130 (defun gnus-group-suspend ()
4131 "Suspend the current Gnus session.
4132 In fact, cleanup buffers except for group mode buffer.
4133 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4135 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4136 (gnus-offer-save-summaries)
4137 ;; Kill Gnus buffers except for group mode buffer.
4138 (let ((group-buf (get-buffer gnus-group-buffer)))
4139 (mapcar (lambda (buf)
4140 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4141 (with-current-buffer buf
4142 (eq major-mode 'message-mode)))
4143 (gnus-kill-buffer buf)))
4145 (setq gnus-backlog-articles nil)
4146 (gnus-kill-gnus-frames)
4148 (bury-buffer group-buf)
4149 (delete-windows-on group-buf t))))
4151 (defun gnus-group-clear-dribble ()
4152 "Clear all information from the dribble buffer."
4154 (gnus-dribble-clear)
4155 (gnus-message 7 "Cleared dribble buffer"))
4157 (defun gnus-group-exit ()
4158 "Quit reading news after updating .newsrc.eld and .newsrc.
4159 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4162 (or noninteractive ;For gnus-batch-kill
4163 (not gnus-interactive-exit) ;Without confirmation
4165 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4166 (gnus-run-hooks 'gnus-exit-gnus-hook)
4167 ;; Offer to save data from non-quitted summary buffers.
4168 (gnus-offer-save-summaries)
4169 ;; Save the newsrc file(s).
4170 (gnus-save-newsrc-file)
4172 (gnus-close-backends)
4173 ;; Reset everything.
4175 ;; Allow the user to do things after cleaning up.
4176 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4178 (defun gnus-group-quit ()
4179 "Quit reading news without updating .newsrc.eld or .newsrc.
4180 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4182 (when (or noninteractive ;For gnus-batch-kill
4183 (zerop (buffer-size))
4184 (not (gnus-server-opened gnus-select-method))
4186 (not gnus-current-startup-file)
4188 (format "Quit reading news without saving %s? "
4189 (file-name-nondirectory gnus-current-startup-file))))
4190 (gnus-run-hooks 'gnus-exit-gnus-hook)
4191 (gnus-configure-windows 'group t)
4192 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4193 (not (zerop (save-excursion
4194 (set-buffer gnus-dribble-buffer)
4197 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4199 (gnus-close-backends)
4201 (gnus-kill-buffer gnus-group-buffer)
4202 ;; Allow the user to do things after cleaning up.
4203 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4205 (defun gnus-group-describe-briefly ()
4206 "Give a one line description of the group mode commands."
4208 (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")))
4210 (defun gnus-group-browse-foreign-server (method)
4211 "Browse a foreign news server.
4212 If called interactively, this function will ask for a select method
4213 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4214 If not, METHOD should be a list where the first element is the method
4215 and the second element is the address."
4217 (list (let ((how (completing-read
4219 (append gnus-valid-select-methods gnus-server-alist)
4220 nil t (cons "nntp" 0) 'gnus-method-history)))
4221 ;; We either got a back end name or a virtual server name.
4222 ;; If the first, we also need an address.
4223 (if (assoc how gnus-valid-select-methods)
4225 ;; Suggested by mapjph@bath.ac.uk.
4228 (mapcar 'list gnus-secondary-servers)))
4229 ;; We got a server name.
4231 (gnus-browse-foreign-server method))
4233 (defun gnus-group-set-info (info &optional method-only-group part)
4234 (when (or info part)
4235 (let* ((entry (gnus-group-entry
4236 (or method-only-group (gnus-info-group info))))
4238 (info (if method-only-group (nth 2 entry) info))
4240 (when method-only-group
4242 (error "Trying to change non-existent group %s" method-only-group))
4243 ;; We have received parts of the actual group info - either the
4244 ;; select method or the group parameters. We first check
4245 ;; whether we have to extend the info, and if so, do that.
4246 (let ((len (length info))
4247 (total (if (eq part 'method) 5 6)))
4249 (setcdr (nthcdr (1- len) info)
4250 (make-list (- total len) nil)))
4251 ;; Then we enter the new info.
4252 (setcar (nthcdr (1- total) info) part-info)))
4254 ;; This is a new group, so we just create it.
4256 (set-buffer gnus-group-buffer)
4257 (setq method (gnus-info-method info))
4258 (when (gnus-server-equal method "native")
4261 (set-buffer gnus-group-buffer)
4263 ;; It's a foreign group...
4264 (gnus-group-make-group
4265 (gnus-group-real-name (gnus-info-group info))
4266 (if (stringp method) method
4267 (prin1-to-string (car method)))
4269 (nth 1 (gnus-info-method info))))
4270 ;; It's a native group.
4271 (gnus-group-make-group (gnus-info-group info))))
4272 (gnus-message 6 "Note: New group created")
4274 (gnus-group-entry (gnus-group-prefixed-name
4275 (gnus-group-real-name (gnus-info-group info))
4276 (or (gnus-info-method info) gnus-select-method))))))
4277 ;; Whether it was a new group or not, we now have the entry, so we
4278 ;; can do the update.
4281 (setcar (nthcdr 2 entry) info)
4282 (when (and (not (eq (car entry) t))
4283 (gnus-active (gnus-info-group info)))
4284 (setcar entry (length
4285 (gnus-list-of-unread-articles (car info))))))
4286 (error "No such group: %s" (gnus-info-group info))))))
4288 (defun gnus-group-set-method-info (group select-method)
4289 (gnus-group-set-info select-method group 'method))
4291 (defun gnus-group-set-params-info (group params)
4292 (gnus-group-set-info params group 'params))
4294 (defun gnus-add-marked-articles (group type articles &optional info force)
4295 ;; Add ARTICLES of TYPE to the info of GROUP.
4296 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4297 ;; add, but replace marked articles of TYPE with ARTICLES.
4298 (let ((info (or info (gnus-get-info group)))
4301 (and (not (setq marked (nthcdr 3 info)))
4303 (setcdr (nthcdr 2 info)
4304 (list (list (cons type (gnus-compress-sequence
4306 (and (not (setq m (assq type (car marked))))
4309 (cons (cons type (gnus-compress-sequence articles t) )
4313 (setcar (nthcdr 3 info)
4314 (gnus-delete-alist type (car marked)))
4315 (setcdr m (gnus-compress-sequence articles t)))
4316 (setcdr m (gnus-compress-sequence
4317 (sort (nconc (gnus-uncompress-range (cdr m))
4318 (copy-sequence articles)) '<) t))))))
4320 (defun gnus-add-mark (group mark article)
4321 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4322 (let ((buffer (gnus-summary-buffer-name group)))
4323 (if (gnus-buffer-live-p buffer)
4325 (set-buffer (get-buffer buffer))
4326 (gnus-summary-add-mark article mark))
4327 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4331 ;;; Group timestamps
4334 (defun gnus-group-set-timestamp ()
4335 "Change the timestamp of the current group to the current time.
4336 This function can be used in hooks like `gnus-select-group-hook'
4337 or `gnus-group-catchup-group-hook'."
4338 (when gnus-newsgroup-name
4339 (let ((time (current-time)))
4340 (setcdr (cdr time) nil)
4341 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4343 (defsubst gnus-group-timestamp (group)
4344 "Return the timestamp for GROUP."
4345 (gnus-group-get-parameter group 'timestamp t))
4347 (defun gnus-group-timestamp-delta (group)
4348 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4349 (let* ((time (or (gnus-group-timestamp group)
4351 (delta (subtract-time (current-time) time)))
4352 (+ (* (nth 0 delta) 65536.0)
4355 (defun gnus-group-timestamp-string (group)
4356 "Return a string of the timestamp for GROUP."
4357 (let ((time (gnus-group-timestamp group)))
4360 (gnus-time-iso8601 time))))
4362 (defun gnus-group-list-cached (level &optional lowest)
4363 "List all groups with cached articles.
4364 If the prefix LEVEL is non-nil, it should be a number that says which
4365 level to cut off listing groups.
4366 If LOWEST, don't list groups with level lower than LOWEST.
4368 This command may read the active file."
4371 (setq level (prefix-numeric-value level)))
4372 (when (or (not level) (>= level gnus-level-zombie))
4374 (funcall gnus-group-prepare-function
4375 (or level gnus-level-subscribed)
4377 (let ((marks (gnus-info-marks info)))
4378 (assq 'cache marks)))
4381 (or (gnus-gethash group
4382 gnus-cache-active-hashtb)
4383 ;; Cache active file might use "."
4386 (mapconcat 'identity
4387 (split-string group ":")
4389 gnus-cache-active-hashtb))))
4390 (goto-char (point-min))
4391 (gnus-group-position-point))
4393 (defun gnus-group-list-dormant (level &optional lowest)
4394 "List all groups with dormant articles.
4395 If the prefix LEVEL is non-nil, it should be a number that says which
4396 level to cut off listing groups.
4397 If LOWEST, don't list groups with level lower than LOWEST.
4399 This command may read the active file."
4402 (setq level (prefix-numeric-value level)))
4403 (when (or (not level) (>= level gnus-level-zombie))
4405 (funcall gnus-group-prepare-function
4406 (or level gnus-level-subscribed)
4408 (let ((marks (gnus-info-marks info)))
4409 (assq 'dormant marks)))
4412 (goto-char (point-min))
4413 (gnus-group-position-point))
4415 (defun gnus-group-listed-groups ()
4416 "Return a list of listed groups."
4418 (goto-char (point-min))
4419 (while (setq point (text-property-not-all (point) (point-max)
4422 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4426 (defun gnus-group-list-plus (&optional args)
4427 "List groups plus the current selection."
4429 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4430 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4432 (push last-command-event unread-command-events)
4433 (if (featurep 'xemacs)
4434 (push (make-event 'key-press '(key ?A)) unread-command-events)
4435 (push ?A unread-command-events))
4436 (let (gnus-pick-mode keys)
4437 (setq keys (if (featurep 'xemacs)
4438 (events-to-keys (read-key-sequence nil))
4439 (read-key-sequence nil)))
4440 (setq func (lookup-key (current-local-map) keys)))
4444 (call-interactively func))))
4446 (defun gnus-group-list-flush (&optional args)
4447 "Flush groups from the current selection."
4449 (let ((gnus-group-list-option 'flush))
4450 (gnus-group-list-plus args)))
4452 (defun gnus-group-list-limit (&optional args)
4453 "List groups limited within the current selection."
4455 (let ((gnus-group-list-option 'limit))
4456 (gnus-group-list-plus args)))
4458 (defun gnus-group-mark-article-read (group article)
4459 "Mark ARTICLE read."
4460 (let ((buffer (gnus-summary-buffer-name group))
4461 (mark gnus-read-mark)
4463 (if (get-buffer buffer)
4464 (with-current-buffer buffer
4465 (setq active gnus-newsgroup-active)
4466 (gnus-activate-group group)
4467 (when gnus-newsgroup-prepared
4468 (when (and gnus-newsgroup-auto-expire
4469 (memq mark gnus-auto-expirable-marks))
4470 (setq mark gnus-expirable-mark))
4471 (setq mark (gnus-request-update-mark
4472 group article mark))
4473 (gnus-mark-article-as-read article mark)
4474 (setq gnus-newsgroup-active (gnus-active group))
4476 (setq n (1+ (cdr active)))
4477 (while (<= n (cdr gnus-newsgroup-active))
4478 (unless (eq n article)
4479 (push n gnus-newsgroup-unselected))
4481 (setq gnus-newsgroup-unselected
4482 (nreverse gnus-newsgroup-unselected)))))
4483 (gnus-activate-group group)
4484 (gnus-group-make-articles-read group (list article))
4485 (when (gnus-group-auto-expirable-p group)
4486 (gnus-add-marked-articles
4487 group 'expire (list article))))))
4491 ;;; Group compaction. -- dvl
4494 (defun gnus-group-compact-group (group)
4495 "Compact the current group.
4496 Compaction means removing gaps between article numbers. Hence, this
4497 operation is only meaningful for back ends using one file per article
4500 Note: currently only implemented in nnml."
4501 (interactive (list (gnus-group-group-name)))
4503 (error "No group to compact"))
4504 (unless (gnus-check-backend-function 'request-compact-group group)
4505 (error "This back end does not support group compaction"))
4506 (let ((group-decoded (gnus-group-decoded-name group)))
4508 Compacting group %s... (this may take a long time)"
4511 (if (not (gnus-request-compact-group group))
4512 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4513 (gnus-message 6 "Compacting group %s...done" group-decoded)
4515 ;; Invalidate the "original article" buffer which might be out of date.
4516 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4517 ;; #### will not happen very often, I think this is acceptable.
4518 (let ((original (get-buffer gnus-original-article-buffer)))
4519 (and original (gnus-kill-buffer original)))
4520 ;; Update the group line to reflect new information (art number etc).
4521 (gnus-group-update-group-line))))
4523 (provide 'gnus-group)
4525 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4526 ;;; gnus-group.el ends here