1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-map))
47 (let ((features (cons 'gnus-group features)))
49 (unless (boundp 'gnus-cache-active-hashtb)
50 (defvar gnus-cache-active-hashtb nil)))
52 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
53 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
55 (defcustom gnus-group-archive-directory
56 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
57 "*The address of the (ding) archives."
58 :group 'gnus-group-foreign
61 (defcustom gnus-group-recent-archive-directory
62 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
63 "*The address of the most recent (ding) articles."
64 :group 'gnus-group-foreign
67 (defcustom gnus-no-groups-message "No Gnus is good news"
68 "*Message displayed by Gnus when no groups are available."
72 (defcustom gnus-keep-same-level nil
73 "*Non-nil means that the next newsgroup after the current will be on the same level.
74 When you type, for instance, `n' after reading the last article in the
75 current newsgroup, you will go to the next newsgroup. If this variable
76 is nil, the next newsgroup will be the next from the group
78 If this variable is non-nil, Gnus will either put you in the
79 next newsgroup with the same level, or, if no such newsgroup is
80 available, the next newsgroup with the lowest possible level higher
81 than the current level.
82 If this variable is `best', Gnus will make the next newsgroup the one
84 :group 'gnus-group-levels
85 :type '(choice (const nil)
87 (sexp :tag "other" t)))
89 (defcustom gnus-group-goto-unread t
90 "*If non-nil, movement commands will go to the next unread and subscribed group."
91 :link '(custom-manual "(gnus)Group Maneuvering")
92 :group 'gnus-group-various
95 (defcustom gnus-goto-next-group-when-activating t
96 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
97 :link '(custom-manual "(gnus)Scanning New Messages")
98 :group 'gnus-group-various
101 (defcustom gnus-permanently-visible-groups nil
102 "*Regexp to match groups that should always be listed in the group buffer.
103 This means that they will still be listed even when there are no
104 unread articles in the groups.
106 If nil, no groups are permanently visible."
107 :group 'gnus-group-listing
108 :type '(choice regexp (const nil)))
110 (defcustom gnus-list-groups-with-ticked-articles t
111 "*If non-nil, list groups that have only ticked articles.
112 If nil, only list groups that have unread articles."
113 :group 'gnus-group-listing
116 (defcustom gnus-group-default-list-level gnus-level-subscribed
117 "*Default listing level.
118 Ignored if `gnus-group-use-permanent-levels' is non-nil."
119 :group 'gnus-group-listing
122 (defcustom gnus-group-list-inactive-groups t
123 "*If non-nil, inactive groups will be listed."
124 :group 'gnus-group-listing
125 :group 'gnus-group-levels
128 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
129 "*Function used for sorting the group buffer.
130 This function will be called with group info entries as the arguments
131 for the groups to be sorted. Pre-made functions include
132 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
133 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
134 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
135 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
137 This variable can also be a list of sorting functions. In that case,
138 the most significant sort function should be the last function in the
140 :group 'gnus-group-listing
141 :link '(custom-manual "(gnus)Sorting Groups")
142 :type '(repeat :value-to-internal (lambda (widget value)
143 (if (listp value) value (list value)))
144 :match (lambda (widget value)
146 (widget-editable-list-match widget value)))
147 (choice (function-item gnus-group-sort-by-alphabet)
148 (function-item gnus-group-sort-by-real-name)
149 (function-item gnus-group-sort-by-unread)
150 (function-item gnus-group-sort-by-level)
151 (function-item gnus-group-sort-by-score)
152 (function-item gnus-group-sort-by-method)
153 (function-item gnus-group-sort-by-server)
154 (function-item gnus-group-sort-by-rank)
155 (function :tag "other" nil))))
157 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
158 "*Format of group lines.
159 It works along the same lines as a normal formatting string,
160 with some simple extensions.
162 %M Only marked articles (character, \"*\" or \" \")
163 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
164 %L Level of subscribedness (integer)
165 %N Number of unread articles (integer)
166 %I Number of dormant articles (integer)
167 %i Number of ticked and dormant (integer)
168 %T Number of ticked articles (integer)
169 %R Number of read articles (integer)
170 %U Number of unseen articles (integer)
171 %t Estimated total number of articles (integer)
172 %y Number of unread, unticked articles (integer)
173 %G Group name (string)
174 %g Qualified group name (string)
175 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
176 %C Group comment (string)
177 %D Group description (string)
178 %s Select method (string)
179 %o Moderated group (char, \"m\")
180 %p Process mark (char)
181 %B Whether a summary buffer for the group is open (char, \"*\")
182 %O Moderated group (string, \"(m)\" or \"\")
183 %P Topic indentation (string)
184 %m Whether there is new(ish) mail in the group (char, \"%\")
185 %w Number of new(ish) mails in the group (integer)
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 sunsite.auc.dk"
294 (nntp "sunsite.auc.dk"
295 (nntp-address "sunsite.auc.dk")))
298 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
302 (nndoc-article-type mbox)
303 (eval `(nndoc-address
304 ,(let ((file (nnheader-find-etc-directory
307 (error "Couldn't find doc group"))
309 "*Alist of useful group-server pairs."
310 :group 'gnus-group-listing
311 :type '(repeat (list (string :tag "Description")
313 (sexp :tag "Method"))))
315 (defcustom gnus-group-highlight
317 ((and mailp (= unread 0) (eq level 1)) .
318 gnus-group-mail-1-empty)
319 ((and mailp (eq level 1)) .
321 ((and mailp (= unread 0) (eq level 2)) .
322 gnus-group-mail-2-empty)
323 ((and mailp (eq level 2)) .
325 ((and mailp (= unread 0) (eq level 3)) .
326 gnus-group-mail-3-empty)
327 ((and mailp (eq level 3)) .
329 ((and mailp (= unread 0)) .
330 gnus-group-mail-low-empty)
334 ((and (= unread 0) (eq level 1)) .
335 gnus-group-news-1-empty)
336 ((and (eq level 1)) .
338 ((and (= unread 0) (eq level 2)) .
339 gnus-group-news-2-empty)
340 ((and (eq level 2)) .
342 ((and (= unread 0) (eq level 3)) .
343 gnus-group-news-3-empty)
344 ((and (eq level 3)) .
346 ((and (= unread 0) (eq level 4)) .
347 gnus-group-news-4-empty)
348 ((and (eq level 4)) .
350 ((and (= unread 0) (eq level 5)) .
351 gnus-group-news-5-empty)
352 ((and (eq level 5)) .
354 ((and (= unread 0) (eq level 6)) .
355 gnus-group-news-6-empty)
356 ((and (eq level 6)) .
358 ((and (= unread 0)) .
359 gnus-group-news-low-empty)
361 gnus-group-news-low))
362 "*Controls the highlighting of group buffer lines.
364 Below is a list of `Form'/`Face' pairs. When deciding how a a
365 particular group line should be displayed, each form is
366 evaluated. The content of the face field after the first true form is
367 used. You can change how those group lines are displayed by
368 editing the face field.
370 It is also possible to change and add form fields, but currently that
371 requires an understanding of Lisp expressions. Hopefully this will
372 change in a future release. For now, you can use the following
373 variables in the Lisp expression:
375 group: The name of the group.
376 unread: The number of unread articles in the group.
377 method: The select method used.
378 mailp: Whether it's a mail group or not.
379 level: The level of the group.
380 score: The score of the group.
381 ticked: The number of ticked articles."
382 :group 'gnus-group-visual
383 :type '(repeat (cons (sexp :tag "Form") face)))
385 (defcustom gnus-new-mail-mark ?%
386 "Mark used for groups with new mail."
387 :group 'gnus-group-visual
390 (defgroup gnus-group-icons nil
391 "Add Icons to your group buffer."
392 :group 'gnus-group-visual)
394 (defcustom gnus-group-icon-list
396 "*Controls the insertion of icons into group buffer lines.
398 Below is a list of `Form'/`File' pairs. When deciding how a
399 particular group line should be displayed, each form is evaluated.
400 The icon from the file field after the first true form is used. You
401 can change how those group lines are displayed by editing the file
402 field. The File will either be found in the
403 `gnus-group-glyph-directory' or by designating absolute name of the
406 It is also possible to change and add form fields, but currently that
407 requires an understanding of Lisp expressions. Hopefully this will
408 change in a future release. For now, you can use the following
409 variables in the Lisp expression:
411 group: The name of the group.
412 unread: The number of unread articles in the group.
413 method: The select method used.
414 mailp: Whether it's a mail group or not.
415 newsp: Whether it's a news group or not
416 level: The level of the group.
417 score: The score of the group.
418 ticked: The number of ticked articles."
419 :group 'gnus-group-icons
420 :type '(repeat (cons (sexp :tag "Form") file)))
422 (defcustom gnus-group-name-charset-method-alist nil
423 "Alist of method and the charset for group names.
426 (((nntp \"news.com.cn\") . cn-gb-2312))"
429 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
431 (defcustom gnus-group-name-charset-group-alist
432 (if (mm-coding-system-p 'utf-8)
433 '(("[^\000-\177]" . utf-8))
435 "Alist of group regexp and the charset for group names.
438 ((\"\\.com\\.cn:\" . cn-gb-2312))"
440 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
442 (defcustom gnus-group-jump-to-group-prompt nil
443 "Default prompt for `gnus-group-jump-to-group'.
445 If non-nil, the value should be a string or an alist. If it is a string,
446 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
447 nnml:\" in the minibuffer prompt.
449 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
450 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
451 used when no prefix argument is given to `gnus-group-jump-to-group'."
453 :group 'gnus-group-various
454 :type '(choice (string :tag "Prompt string")
455 (const :tag "Empty" nil)
456 (repeat (cons (integer :tag "Argument")
457 (string :tag "Prompt string")))))
459 (defvar gnus-group-listing-limit 1000
460 "*A limit of the number of groups when listing.
461 If the number of groups is larger than the limit, list them in a
464 ;;; Internal variables
466 (defvar gnus-group-is-exiting-p nil)
467 (defvar gnus-group-is-exiting-without-update-p nil)
468 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
469 "Function for sorting the group buffer.")
471 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
472 "Function for sorting the selected groups in the group buffer.")
474 (defvar gnus-group-indentation-function nil)
475 (defvar gnus-goto-missing-group-function nil)
476 (defvar gnus-group-update-group-function nil)
477 (defvar gnus-group-goto-next-group-function nil
478 "Function to override finding the next group after listing groups.")
480 (defvar gnus-group-edit-buffer nil)
482 (defvar gnus-group-line-format-alist
483 `((?M gnus-tmp-marked-mark ?c)
484 (?S gnus-tmp-subscribed ?c)
485 (?L gnus-tmp-level ?d)
486 (?N (cond ((eq number t) "*" )
490 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
491 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
493 (?R gnus-tmp-number-of-read ?s)
494 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
495 (?t gnus-tmp-number-total ?d)
496 (?y gnus-tmp-number-of-unread ?s)
497 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
498 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
499 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
500 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
501 (?g (if (boundp 'gnus-tmp-decoded-group)
502 gnus-tmp-decoded-group
505 (?G gnus-tmp-qualified-group ?s)
506 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
507 gnus-tmp-decoded-group
510 (?C gnus-tmp-comment ?s)
511 (?D gnus-tmp-newsgroup-description ?s)
512 (?o gnus-tmp-moderated ?c)
513 (?O gnus-tmp-moderated-string ?s)
514 (?p gnus-tmp-process-marked ?c)
515 (?s gnus-tmp-news-server ?s)
516 (?n ,(if (featurep 'xemacs)
517 '(symbol-name gnus-tmp-news-method)
518 'gnus-tmp-news-method)
520 (?P gnus-group-indentation ?s)
521 (?E gnus-tmp-group-icon ?s)
522 (?B gnus-tmp-summary-live ?c)
523 (?z gnus-tmp-news-method-string ?s)
524 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
525 (?w (if (gnus-news-group-p gnus-tmp-group)
529 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
532 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
533 (?u gnus-tmp-user-defined ?s)
534 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
537 (defvar gnus-group-mode-line-format-alist
538 `((?S gnus-tmp-news-server ?s)
539 (?M gnus-tmp-news-method ?s)
540 (?u gnus-tmp-user-defined ?s)
541 (?: gnus-tmp-colon ?s)))
543 (defvar gnus-topic-topology nil
544 "The complete topic hierarchy.")
546 (defvar gnus-topic-alist nil
547 "The complete topic-group alist.")
549 (defvar gnus-group-marked nil)
551 (defvar gnus-group-list-mode nil)
554 (defvar gnus-group-icon-cache nil)
556 (defvar gnus-group-listed-groups nil)
557 (defvar gnus-group-list-option nil)
563 (put 'gnus-group-mode 'mode-class 'special)
565 (gnus-define-keys gnus-group-mode-map
566 " " gnus-group-read-group
567 "=" gnus-group-select-group
568 "\r" gnus-group-select-group
569 "\M-\r" gnus-group-quick-select-group
570 "\M- " gnus-group-visible-select-group
571 [(meta control return)] gnus-group-select-group-ephemerally
572 "j" gnus-group-jump-to-group
573 "n" gnus-group-next-unread-group
574 "p" gnus-group-prev-unread-group
575 "\177" gnus-group-prev-unread-group
576 [delete] gnus-group-prev-unread-group
577 [backspace] gnus-group-prev-unread-group
578 "N" gnus-group-next-group
579 "P" gnus-group-prev-group
580 "\M-n" gnus-group-next-unread-group-same-level
581 "\M-p" gnus-group-prev-unread-group-same-level
582 "," gnus-group-best-unread-group
583 "." gnus-group-first-unread-group
584 "u" gnus-group-unsubscribe-current-group
585 "U" gnus-group-unsubscribe-group
586 "c" gnus-group-catchup-current
587 "C" gnus-group-catchup-current-all
588 "\M-c" gnus-group-clear-data
589 "l" gnus-group-list-groups
590 "L" gnus-group-list-all-groups
593 "g" gnus-group-get-new-news
594 "\M-g" gnus-group-get-new-news-this-group
595 "R" gnus-group-restart
596 "r" gnus-group-read-init-file
597 "B" gnus-group-browse-foreign-server
598 "b" gnus-group-check-bogus-groups
599 "F" gnus-group-find-new-groups
600 "\C-c\C-d" gnus-group-describe-group
601 "\M-d" gnus-group-describe-all-groups
602 "\C-c\C-a" gnus-group-apropos
603 "\C-c\M-\C-a" gnus-group-description-apropos
604 "a" gnus-group-post-news
605 "\ek" gnus-group-edit-local-kill
606 "\eK" gnus-group-edit-global-kill
607 "\C-k" gnus-group-kill-group
608 "\C-y" gnus-group-yank-group
609 "\C-w" gnus-group-kill-region
610 "\C-x\C-t" gnus-group-transpose-groups
611 "\C-c\C-l" gnus-group-list-killed
612 "\C-c\C-x" gnus-group-expire-articles
613 "\C-c\M-\C-x" gnus-group-expire-all-groups
615 "s" gnus-group-save-newsrc
616 "z" gnus-group-suspend
619 "?" gnus-group-describe-briefly
620 "\C-c\C-i" gnus-info-find-node
621 "\M-e" gnus-group-edit-group-method
622 "^" gnus-group-enter-server-mode
623 gnus-mouse-2 gnus-mouse-pick-group
624 [follow-link] mouse-face
625 "<" beginning-of-buffer
628 "\C-c\C-n" gnus-namazu-search
629 "\C-c\C-s" gnus-group-sort-groups
631 "\C-c\M-g" gnus-activate-all-groups
632 "\M-&" gnus-group-universal-argument
633 "#" gnus-group-mark-group
634 "\M-#" gnus-group-unmark-group)
636 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
637 "m" gnus-group-mark-group
638 "u" gnus-group-unmark-group
639 "w" gnus-group-mark-region
640 "b" gnus-group-mark-buffer
641 "r" gnus-group-mark-regexp
642 "U" gnus-group-unmark-all-groups)
644 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
645 "u" gnus-sieve-update
646 "g" gnus-sieve-generate)
648 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
649 "d" gnus-group-make-directory-group
650 "h" gnus-group-make-help-group
651 "u" gnus-group-make-useful-group
652 "a" gnus-group-make-archive-group
653 "k" gnus-group-make-kiboze-group
654 "l" gnus-group-nnimap-edit-acl
655 "m" gnus-group-make-group
656 "n" gnus-group-make-shimbun-group
657 "E" gnus-group-edit-group
658 "e" gnus-group-edit-group-method
659 "p" gnus-group-edit-group-parameters
660 "v" gnus-group-add-to-virtual
661 "V" gnus-group-make-empty-virtual
662 "D" gnus-group-enter-directory
663 "f" gnus-group-make-doc-group
664 "G" gnus-group-make-nnir-group
665 "w" gnus-group-make-web-group
666 "M" gnus-group-read-ephemeral-group
667 "r" gnus-group-rename-group
668 "R" gnus-group-make-rss-group
669 "c" gnus-group-customize
670 "x" gnus-group-nnimap-expunge
671 "\177" gnus-group-delete-group
672 [delete] gnus-group-delete-group)
674 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
675 "b" gnus-group-brew-soup
676 "w" gnus-soup-save-areas
677 "s" gnus-soup-send-replies
678 "p" gnus-soup-pack-packet
679 "r" nnsoup-pack-replies)
681 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
682 "s" gnus-group-sort-groups
683 "a" gnus-group-sort-groups-by-alphabet
684 "u" gnus-group-sort-groups-by-unread
685 "l" gnus-group-sort-groups-by-level
686 "v" gnus-group-sort-groups-by-score
687 "r" gnus-group-sort-groups-by-rank
688 "m" gnus-group-sort-groups-by-method
689 "n" gnus-group-sort-groups-by-real-name)
691 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
692 "s" gnus-group-sort-selected-groups
693 "a" gnus-group-sort-selected-groups-by-alphabet
694 "u" gnus-group-sort-selected-groups-by-unread
695 "l" gnus-group-sort-selected-groups-by-level
696 "v" gnus-group-sort-selected-groups-by-score
697 "r" gnus-group-sort-selected-groups-by-rank
698 "m" gnus-group-sort-selected-groups-by-method
699 "n" gnus-group-sort-selected-groups-by-real-name)
701 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
702 "k" gnus-group-list-killed
703 "z" gnus-group-list-zombies
704 "s" gnus-group-list-groups
705 "u" gnus-group-list-all-groups
706 "A" gnus-group-list-active
707 "a" gnus-group-apropos
708 "d" gnus-group-description-apropos
709 "m" gnus-group-list-matching
710 "M" gnus-group-list-all-matching
711 "l" gnus-group-list-level
712 "c" gnus-group-list-cached
713 "?" gnus-group-list-dormant)
715 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
716 "k" gnus-group-list-limit
717 "z" gnus-group-list-limit
718 "s" gnus-group-list-limit
719 "u" gnus-group-list-limit
720 "A" gnus-group-list-limit
721 "m" gnus-group-list-limit
722 "M" gnus-group-list-limit
723 "l" gnus-group-list-limit
724 "c" gnus-group-list-limit
725 "?" gnus-group-list-limit)
727 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
728 "k" gnus-group-list-flush
729 "z" gnus-group-list-flush
730 "s" gnus-group-list-flush
731 "u" gnus-group-list-flush
732 "A" gnus-group-list-flush
733 "m" gnus-group-list-flush
734 "M" gnus-group-list-flush
735 "l" gnus-group-list-flush
736 "c" gnus-group-list-flush
737 "?" gnus-group-list-flush)
739 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
740 "k" gnus-group-list-plus
741 "z" gnus-group-list-plus
742 "s" gnus-group-list-plus
743 "u" gnus-group-list-plus
744 "A" gnus-group-list-plus
745 "m" gnus-group-list-plus
746 "M" gnus-group-list-plus
747 "l" gnus-group-list-plus
748 "c" gnus-group-list-plus
749 "?" gnus-group-list-plus)
751 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
752 "f" gnus-score-flush-cache
753 "e" gnus-score-edit-all-score)
755 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
756 "c" gnus-group-fetch-charter
757 "C" gnus-group-fetch-control
758 "d" gnus-group-describe-group
759 "f" gnus-group-fetch-faq
762 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
763 "l" gnus-group-set-current-level
764 "t" gnus-group-unsubscribe-current-group
765 "s" gnus-group-unsubscribe-group
766 "k" gnus-group-kill-group
767 "y" gnus-group-yank-group
768 "w" gnus-group-kill-region
769 "\C-k" gnus-group-kill-level
770 "z" gnus-group-kill-all-zombies)
772 (defun gnus-topic-mode-p ()
773 "Return non-nil in `gnus-topic-mode'."
774 (and (boundp 'gnus-topic-mode)
775 (symbol-value 'gnus-topic-mode)))
777 (defun gnus-group-make-menu-bar ()
778 (gnus-turn-off-edit-menu 'group)
779 (unless (boundp 'gnus-group-reading-menu)
782 gnus-group-reading-menu gnus-group-mode-map ""
784 ["Read" gnus-group-read-group
785 :included (not (gnus-topic-mode-p))
786 :active (gnus-group-group-name)]
787 ["Read " gnus-topic-read-group
788 :included (gnus-topic-mode-p)]
789 ["Select" gnus-group-select-group
790 :included (not (gnus-topic-mode-p))
791 :active (gnus-group-group-name)]
792 ["Select " gnus-topic-select-group
793 :included (gnus-topic-mode-p)]
794 ["See old articles" (gnus-group-select-group 'all)
795 :keys "C-u SPC" :active (gnus-group-group-name)]
796 ["Catch up" gnus-group-catchup-current
797 :included (not (gnus-topic-mode-p))
798 :active (gnus-group-group-name)
799 ,@(if (featurep 'xemacs) nil
800 '(:help "Mark unread articles in the current group as read"))]
801 ["Catch up " gnus-topic-catchup-articles
802 :included (gnus-topic-mode-p)
803 ,@(if (featurep 'xemacs) nil
804 '(:help "Mark unread articles in the current group or topic as read"))]
805 ["Catch up all articles" gnus-group-catchup-current-all
806 (gnus-group-group-name)]
807 ["Check for new articles" gnus-group-get-new-news-this-group
808 :included (not (gnus-topic-mode-p))
809 :active (gnus-group-group-name)
810 ,@(if (featurep 'xemacs) nil
811 '(:help "Check for new messages in current group"))]
812 ["Check for new articles " gnus-topic-get-new-news-this-topic
813 :included (gnus-topic-mode-p)
814 ,@(if (featurep 'xemacs) nil
815 '(:help "Check for new messages in current group or topic"))]
816 ["Toggle subscription" gnus-group-unsubscribe-current-group
817 (gnus-group-group-name)]
818 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
819 ,@(if (featurep 'xemacs) nil
820 '(:help "Kill (remove) current group"))]
821 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
822 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
823 ,@(if (featurep 'xemacs) nil
824 '(:help "Display description of the current group"))]
825 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
826 ["Fetch charter" gnus-group-fetch-charter
827 :active (gnus-group-group-name)
828 ,@(if (featurep 'xemacs) nil
829 '(:help "Display the charter of the current group"))]
830 ["Fetch control message" gnus-group-fetch-control
831 :active (gnus-group-group-name)
832 ,@(if (featurep 'xemacs) nil
833 '(:help "Display the archived control message for the current group"))]
834 ;; Actually one should check, if any of the marked groups gives t for
835 ;; (gnus-check-backend-function 'request-expire-articles ...)
836 ["Expire articles" gnus-group-expire-articles
837 :included (not (gnus-topic-mode-p))
838 :active (or (and (gnus-group-group-name)
839 (gnus-check-backend-function
840 'request-expire-articles
841 (gnus-group-group-name))) gnus-group-marked)]
842 ["Expire articles " gnus-topic-expire-articles
843 :included (gnus-topic-mode-p)]
844 ["Set group level..." gnus-group-set-current-level
845 (gnus-group-group-name)]
846 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
847 ["Customize" gnus-group-customize (gnus-group-group-name)]
849 ["Parameters" gnus-group-edit-group-parameters
850 :included (not (gnus-topic-mode-p))
851 :active (gnus-group-group-name)]
852 ["Parameters " gnus-topic-edit-parameters
853 :included (gnus-topic-mode-p)]
854 ["Select method" gnus-group-edit-group-method
855 (gnus-group-group-name)]
856 ["Info" gnus-group-edit-group (gnus-group-group-name)]
857 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
858 ["Global kill file" gnus-group-edit-global-kill t])))
861 gnus-group-group-menu gnus-group-mode-map ""
864 ["List unread subscribed groups" gnus-group-list-groups t]
865 ["List (un)subscribed groups" gnus-group-list-all-groups t]
866 ["List killed groups" gnus-group-list-killed gnus-killed-list]
867 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
868 ["List level..." gnus-group-list-level t]
869 ["Describe all groups" gnus-group-describe-all-groups t]
870 ["Group apropos..." gnus-group-apropos t]
871 ["Group and description apropos..." gnus-group-description-apropos t]
872 ["List groups matching..." gnus-group-list-matching t]
873 ["List all groups matching..." gnus-group-list-all-matching t]
874 ["List active file" gnus-group-list-active t]
875 ["List groups with cached" gnus-group-list-cached t]
876 ["List groups with dormant" gnus-group-list-dormant t])
878 ["Default sort" gnus-group-sort-groups t]
879 ["Sort by method" gnus-group-sort-groups-by-method t]
880 ["Sort by rank" gnus-group-sort-groups-by-rank t]
881 ["Sort by score" gnus-group-sort-groups-by-score t]
882 ["Sort by level" gnus-group-sort-groups-by-level t]
883 ["Sort by unread" gnus-group-sort-groups-by-unread t]
884 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
885 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
886 ("Sort process/prefixed"
887 ["Default sort" gnus-group-sort-selected-groups
888 (not (gnus-topic-mode-p))]
889 ["Sort by method" gnus-group-sort-selected-groups-by-method
890 (not (gnus-topic-mode-p))]
891 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
892 (not (gnus-topic-mode-p))]
893 ["Sort by score" gnus-group-sort-selected-groups-by-score
894 (not (gnus-topic-mode-p))]
895 ["Sort by level" gnus-group-sort-selected-groups-by-level
896 (not (gnus-topic-mode-p))]
897 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
898 (not (gnus-topic-mode-p))]
899 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
900 (not (gnus-topic-mode-p))]
901 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
902 (not (gnus-topic-mode-p))])
904 ["Mark group" gnus-group-mark-group
905 (and (gnus-group-group-name)
906 (not (memq (gnus-group-group-name) gnus-group-marked)))]
907 ["Unmark group" gnus-group-unmark-group
908 (and (gnus-group-group-name)
909 (memq (gnus-group-group-name) gnus-group-marked))]
910 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
911 ["Mark regexp..." gnus-group-mark-regexp t]
912 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
913 ["Mark buffer" gnus-group-mark-buffer t]
914 ["Execute command" gnus-group-universal-argument
915 (or gnus-group-marked (gnus-group-group-name))])
917 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
918 ["Kill all newsgroups in region" gnus-group-kill-region
919 :active (gnus-mark-active-p)]
920 ["Kill all zombie groups" gnus-group-kill-all-zombies
922 ["Kill all groups on level..." gnus-group-kill-level t])
924 ["Make a foreign group..." gnus-group-make-group t]
925 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
926 ["Add a directory group..." gnus-group-make-directory-group t]
927 ["Add the help group" gnus-group-make-help-group t]
928 ["Add the archive group" gnus-group-make-archive-group t]
929 ["Make a doc group..." gnus-group-make-doc-group t]
930 ["Make a web group..." gnus-group-make-web-group t]
931 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
932 ["Make a virtual group..." gnus-group-make-empty-virtual t]
933 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
934 ["Make an RSS group..." gnus-group-make-rss-group t]
935 ["Rename group..." gnus-group-rename-group
936 (gnus-check-backend-function
937 'request-rename-group (gnus-group-group-name))]
938 ["Delete group" gnus-group-delete-group
939 (gnus-check-backend-function
940 'request-delete-group (gnus-group-group-name))])
942 ["Next" gnus-group-next-group t]
943 ["Previous" gnus-group-prev-group t]
944 ["Next unread" gnus-group-next-unread-group t]
945 ["Previous unread" gnus-group-prev-unread-group t]
946 ["Next unread same level" gnus-group-next-unread-group-same-level t]
947 ["Previous unread same level"
948 gnus-group-prev-unread-group-same-level t]
949 ["Jump to group..." gnus-group-jump-to-group t]
950 ["First unread group" gnus-group-first-unread-group t]
951 ["Best unread group" gnus-group-best-unread-group t])
953 ["Generate" gnus-sieve-generate t]
954 ["Generate and update" gnus-sieve-update t])
955 ["Delete bogus groups" gnus-group-check-bogus-groups t]
956 ["Find new newsgroups" gnus-group-find-new-groups t]
957 ["Transpose" gnus-group-transpose-groups
958 (gnus-group-group-name)]
959 ["Read a directory as a group..." gnus-group-enter-directory t]))
962 gnus-group-misc-menu gnus-group-mode-map ""
965 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
966 ["Send replies" gnus-soup-send-replies
967 (fboundp 'gnus-soup-pack-packet)]
968 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
969 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
970 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
971 ["Send a mail" gnus-group-mail t]
972 ["Send a message (mail or news)" gnus-group-post-news t]
973 ["Create a local message" gnus-group-news t]
974 ["Check for new news" gnus-group-get-new-news
975 ,@(if (featurep 'xemacs) '(t)
976 '(:help "Get newly arrived articles"))
978 ["Send queued messages" gnus-delay-send-queue
979 ,@(if (featurep 'xemacs) '(t)
980 '(:help "Send all messages that are scheduled to be sent now"))
982 ["Activate all groups" gnus-activate-all-groups t]
983 ["Restart Gnus" gnus-group-restart t]
984 ["Read init file" gnus-group-read-init-file t]
985 ["Browse foreign server..." gnus-group-browse-foreign-server t]
986 ["Enter server buffer" gnus-group-enter-server-mode t]
987 ["Expire all expirable articles" gnus-group-expire-all-groups t]
988 ["Generate any kiboze groups" nnkiboze-generate-groups t]
989 ["Gnus version" gnus-version t]
990 ["Save .newsrc files" gnus-group-save-newsrc t]
991 ["Suspend Gnus" gnus-group-suspend t]
992 ["Clear dribble buffer" gnus-group-clear-dribble t]
993 ["Read manual" gnus-info-find-node t]
994 ["Flush score cache" gnus-score-flush-cache t]
995 ["Toggle topics" gnus-topic-mode t]
996 ["Send a bug report" gnus-bug t]
997 ["Exit from Gnus" gnus-group-exit
998 ,@(if (featurep 'xemacs) '(t)
999 '(:help "Quit reading news"))]
1000 ["Exit without saving" gnus-group-quit t]))
1002 (gnus-run-hooks 'gnus-group-menu-hook)))
1004 (defvar gnus-group-toolbar-map nil)
1006 ;; Emacs 21 tool bar. Should be no-op otherwise.
1007 (defun gnus-group-make-tool-bar ()
1009 (condition-case nil (require 'tool-bar) (error nil))
1010 (fboundp 'tool-bar-add-item-from-menu)
1011 (default-value 'tool-bar-mode)
1012 (not gnus-group-toolbar-map))
1013 (setq gnus-group-toolbar-map
1014 (let ((tool-bar-map (make-sparse-keymap))
1015 (load-path (mm-image-load-path)))
1016 (tool-bar-add-item-from-menu
1017 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1018 (tool-bar-add-item-from-menu
1019 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1020 (tool-bar-add-item-from-menu
1021 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1022 (tool-bar-add-item-from-menu
1023 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1024 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1025 :help "Subscribe to the current group")
1026 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1028 :help "Unsubscribe from the current group")
1029 (tool-bar-add-item-from-menu
1030 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1032 (if gnus-group-toolbar-map
1033 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1035 (defun gnus-group-mode ()
1036 "Major mode for reading news.
1038 All normal editing commands are switched off.
1039 \\<gnus-group-mode-map>
1040 The group buffer lists (some of) the groups available. For instance,
1041 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1042 lists all zombie groups.
1044 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1045 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1047 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1049 The following commands are available:
1051 \\{gnus-group-mode-map}"
1053 (kill-all-local-variables)
1054 (when (gnus-visual-p 'group-menu 'menu)
1055 (gnus-group-make-menu-bar)
1056 (gnus-group-make-tool-bar))
1057 (gnus-simplify-mode-line)
1058 (setq major-mode 'gnus-group-mode)
1059 (setq mode-name "Group")
1060 (gnus-group-set-mode-line)
1061 (setq mode-line-process nil)
1062 (use-local-map gnus-group-mode-map)
1063 (buffer-disable-undo)
1064 (setq truncate-lines t)
1065 (setq buffer-read-only t
1066 show-trailing-whitespace nil)
1067 (gnus-set-default-directory)
1068 (gnus-update-format-specifications nil 'group 'group-mode)
1069 (gnus-update-group-mark-positions)
1074 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1076 (defun gnus-update-group-mark-positions ()
1078 (let ((gnus-process-mark ?\200)
1079 (gnus-group-update-hook nil)
1080 (gnus-group-marked '("dummy.group"))
1081 (gnus-active-hashtb (make-vector 10 0))
1083 (gnus-set-active "dummy.group" '(0 . 0))
1084 (gnus-set-work-buffer)
1085 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1086 (goto-char (point-min))
1087 (setq gnus-group-mark-positions
1088 (list (cons 'process (and (search-forward
1089 (string-as-multibyte "\200") nil t)
1090 (- (point) 2))))))))
1092 (defun gnus-mouse-pick-group (e)
1093 "Enter the group under the mouse pointer."
1096 (gnus-group-read-group nil))
1098 ;; Look at LEVEL and find out what the level is really supposed to be.
1099 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1100 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1101 (defun gnus-group-default-level (&optional level number-or-nil)
1103 (gnus-group-use-permanent-levels
1104 (or (setq gnus-group-use-permanent-levels
1105 (or level (if (numberp gnus-group-use-permanent-levels)
1106 gnus-group-use-permanent-levels
1107 (or gnus-group-default-list-level
1108 gnus-level-subscribed))))
1109 gnus-group-default-list-level gnus-level-subscribed))
1113 (or level gnus-group-default-list-level gnus-level-subscribed))))
1115 (defun gnus-group-setup-buffer ()
1116 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1117 (unless (eq major-mode 'gnus-group-mode)
1120 (gnus-carpal-setup-buffer 'group))))
1122 (defun gnus-group-name-charset (method group)
1124 (setq method (gnus-find-method-for-group group)))
1125 (let ((item (assoc method gnus-group-name-charset-method-alist))
1126 (alist gnus-group-name-charset-group-alist)
1130 (while (setq item (pop alist))
1131 (if (string-match (car item) group)
1133 result (cdr item))))
1136 (defun gnus-group-name-decode (string charset)
1137 ;; Fixme: Don't decode in unibyte mode.
1138 (if (and string charset (featurep 'mule))
1139 (decode-coding-string string charset)
1142 (defun gnus-group-decoded-name (string)
1143 (let ((charset (gnus-group-name-charset nil string)))
1144 (gnus-group-name-decode string charset)))
1146 (defun gnus-group-name-encode (string charset)
1147 (if (and string charset (featurep 'mule))
1148 (encode-coding-string string charset)
1151 (defun gnus-group-encoded-name (string)
1152 (let ((charset (gnus-group-name-charset nil string)))
1153 (gnus-group-name-encode string charset)))
1155 (defun gnus-group-completing-read-group-name
1156 (prompt table &optional predicate require-match initial-contents history)
1160 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1164 (dolist (entry (prog1
1167 (push (list (gnus-group-decoded-name (car entry))) table)))
1168 (gnus-group-encoded-name
1170 prompt table predicate
1175 (defun gnus-group-list-groups (&optional level unread lowest)
1176 "List newsgroups with level LEVEL or lower that have unread articles.
1177 Default is all subscribed groups.
1178 If argument UNREAD is non-nil, groups with no unread articles are also
1181 Also see the `gnus-group-use-permanent-levels' variable."
1183 (list (if current-prefix-arg
1184 (prefix-numeric-value current-prefix-arg)
1186 (gnus-group-default-level nil t)
1187 gnus-group-default-list-level
1188 gnus-level-subscribed))))
1190 (setq level (car gnus-group-list-mode)
1191 unread (cdr gnus-group-list-mode)))
1192 (setq level (gnus-group-default-level level))
1193 (gnus-group-setup-buffer)
1194 (gnus-update-format-specifications nil 'group 'group-mode)
1195 (let ((case-fold-search nil)
1196 (props (text-properties-at (point-at-bol)))
1197 (empty (= (point-min) (point-max)))
1198 (group (gnus-group-group-name))
1200 (set-buffer gnus-group-buffer)
1201 (setq number (funcall gnus-group-prepare-function level unread lowest))
1202 (when (or (and (numberp number)
1204 (zerop (buffer-size)))
1205 ;; No groups in the buffer.
1206 (gnus-message 5 gnus-no-groups-message))
1207 ;; We have some groups displayed.
1208 (goto-char (point-max))
1209 (when (or (not gnus-group-goto-next-group-function)
1210 (not (funcall gnus-group-goto-next-group-function
1214 (goto-char (point-min)))
1216 ;; Go to the first group with unread articles.
1217 (gnus-group-search-forward t))
1219 ;; Find the right group to put point on. If the current group
1220 ;; has disappeared in the new listing, try to find the next
1221 ;; one. If no next one can be found, just leave point at the
1222 ;; first newsgroup in the buffer.
1223 (when (not (gnus-goto-char
1225 (point-min) (point-max)
1226 'gnus-group (gnus-intern-safe
1227 group gnus-active-hashtb))))
1228 (let ((newsrc (cdddr (gnus-group-entry group))))
1230 (not (gnus-goto-char
1232 (point-min) (point-max) 'gnus-group
1234 (caar newsrc) gnus-active-hashtb)))))
1235 (setq newsrc (cdr newsrc)))
1237 (goto-char (point-max))
1238 (forward-line -1)))))))
1239 ;; Adjust cursor point.
1240 (gnus-group-position-point)))
1242 (defun gnus-group-list-level (level &optional all)
1243 "List groups on LEVEL.
1244 If ALL (the prefix), also list groups that have no unread articles."
1245 (interactive "nList groups on level: \nP")
1246 (gnus-group-list-groups level all level))
1248 (defun gnus-group-prepare-logic (group test)
1249 (or (and gnus-group-listed-groups
1250 (null gnus-group-list-option)
1251 (member group gnus-group-listed-groups))
1253 ((null gnus-group-listed-groups) test)
1254 ((null gnus-group-list-option) test)
1255 (t (and (member group gnus-group-listed-groups)
1256 (if (eq gnus-group-list-option 'flush)
1260 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1261 "List all newsgroups with unread articles of level LEVEL or lower.
1262 If PREDICATE is a function, list groups that the function returns non-nil;
1263 if it is t, list groups that have no unread articles.
1264 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1265 If REGEXP is a function, list dead groups that the function returns non-nil;
1266 if it is a string, only list groups matching REGEXP."
1267 (set-buffer gnus-group-buffer)
1268 (let ((buffer-read-only nil)
1269 (newsrc (cdr gnus-newsrc-alist))
1270 (lowest (or lowest 1))
1271 (not-in-list (and gnus-group-listed-groups
1272 (copy-sequence gnus-group-listed-groups)))
1273 info clevel unread group params)
1275 (when (or (< lowest gnus-level-zombie)
1276 gnus-group-listed-groups)
1277 ;; List living groups.
1279 (setq info (car newsrc)
1280 group (gnus-info-group info)
1281 params (gnus-info-params info)
1283 unread (gnus-group-unread group))
1285 (setq not-in-list (delete group not-in-list)))
1286 (when (gnus-group-prepare-logic
1288 (and unread ; This group might be unchecked
1289 (or (not (stringp regexp))
1290 (string-match regexp group))
1291 (<= (setq clevel (gnus-info-level info)) level)
1294 ((functionp predicate)
1295 (funcall predicate info))
1296 (predicate t) ; We list all groups?
1299 (if (eq unread t) ; Unactivated?
1300 gnus-group-list-inactive-groups
1301 ; We list unactivated
1303 ; We list groups with unread articles
1304 (and gnus-list-groups-with-ticked-articles
1305 (cdr (assq 'tick (gnus-info-marks info))))
1306 ; And groups with tickeds
1307 ;; Check for permanent visibility.
1308 (and gnus-permanently-visible-groups
1309 (string-match gnus-permanently-visible-groups
1311 (memq 'visible params)
1312 (cdr (assq 'visible params)))))))
1313 (gnus-group-insert-group-line
1314 group (gnus-info-level info)
1315 (gnus-info-marks info) unread (gnus-info-method info)))))
1317 ;; List dead groups.
1318 (when (or gnus-group-listed-groups
1319 (and (>= level gnus-level-zombie)
1320 (<= lowest gnus-level-zombie)))
1321 (gnus-group-prepare-flat-list-dead
1322 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1323 gnus-level-zombie ?Z
1326 (dolist (group gnus-zombie-list)
1327 (setq not-in-list (delete group not-in-list))))
1328 (when (or gnus-group-listed-groups
1329 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1330 (gnus-group-prepare-flat-list-dead
1333 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1334 gnus-level-killed ?K regexp))
1336 (gnus-group-set-mode-line)
1337 (setq gnus-group-list-mode (cons level predicate))
1338 (gnus-run-hooks 'gnus-group-prepare-hook)
1341 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1342 ;; List zombies and killed lists somewhat faster, which was
1343 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1344 ;; this by ignoring the group format specification altogether.
1346 (if (> (length groups) gnus-group-listing-limit)
1348 (setq group (pop groups))
1349 (when (gnus-group-prepare-logic
1352 (and (stringp regexp) (string-match regexp group))
1353 (and (functionp regexp) (funcall regexp group))))
1354 (gnus-add-text-properties
1355 (point) (prog1 (1+ (point))
1356 (insert " " mark " *: "
1357 (gnus-group-decoded-name group)
1359 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1361 'gnus-level level))))
1363 (setq group (pop groups))
1364 (when (gnus-group-prepare-logic
1367 (and (stringp regexp) (string-match regexp group))
1368 (and (functionp regexp) (funcall regexp group))))
1369 (gnus-group-insert-group-line
1371 (let ((active (gnus-active group)))
1373 (if (zerop (cdr active))
1375 (- (1+ (cdr active)) (car active)))
1377 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1379 (defun gnus-group-update-group-line ()
1380 "Update the current line in the group buffer."
1381 (let* ((buffer-read-only nil)
1382 (group (gnus-group-group-name))
1383 (entry (and group (gnus-group-entry group)))
1384 gnus-group-indentation)
1387 (not (gnus-ephemeral-group-p group))
1389 (concat "(gnus-group-set-info '"
1390 (gnus-prin1-to-string (nth 2 entry))
1392 (setq gnus-group-indentation (gnus-group-group-indentation))
1394 (gnus-group-insert-group-line-info group)
1396 (gnus-group-position-point))))
1398 (defun gnus-group-insert-group-line-info (group)
1399 "Insert GROUP on the current line."
1400 (let ((entry (gnus-group-entry group))
1401 (gnus-group-indentation (gnus-group-group-indentation))
1405 ;; (Un)subscribed group.
1406 (setq info (nth 2 entry))
1407 (gnus-group-insert-group-line
1408 group (gnus-info-level info) (gnus-info-marks info)
1409 (or (car entry) t) (gnus-info-method info)))
1410 ;; This group is dead.
1411 (gnus-group-insert-group-line
1413 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1415 (if (setq active (gnus-active group))
1416 (if (zerop (cdr active))
1418 (- (1+ (cdr active)) (car active)))
1420 (gnus-method-simplify (gnus-find-method-for-group group))))))
1422 (defun gnus-number-of-unseen-articles-in-group (group)
1423 (let* ((info (nth 2 (gnus-group-entry group)))
1424 (marked (gnus-info-marks info))
1425 (seen (cdr (assq 'seen marked)))
1426 (active (gnus-active group)))
1429 (length (gnus-uncompress-range
1430 (gnus-range-difference
1431 (gnus-range-difference (list active) (gnus-info-read info))
1434 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1435 gnus-tmp-marked number
1437 "Insert a group line in the group buffer."
1438 (let* ((gnus-tmp-method
1439 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1440 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1442 (gnus-tmp-active (gnus-active gnus-tmp-group))
1443 (gnus-tmp-number-total
1445 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1447 (gnus-tmp-number-of-unread
1448 (if (numberp number) (int-to-string (max 0 number))
1450 (gnus-tmp-number-of-read
1451 (if (numberp number)
1452 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1454 (gnus-tmp-subscribed
1455 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1456 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1457 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1459 (gnus-tmp-qualified-group
1460 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1461 group-name-charset))
1463 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1465 (gnus-tmp-newsgroup-description
1466 (if gnus-description-hashtb
1467 (or (gnus-group-name-decode
1468 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1469 group-name-charset) "")
1472 (if (and gnus-moderated-hashtb
1473 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1475 (gnus-tmp-moderated-string
1476 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1477 (gnus-tmp-group-icon "==&&==")
1478 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1479 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1480 (gnus-tmp-news-method-string
1482 (format "(%s:%s)" (car gnus-tmp-method)
1483 (cadr gnus-tmp-method)) ""))
1484 (gnus-tmp-marked-mark
1485 (if (and (numberp number)
1487 (cdr (assq 'tick gnus-tmp-marked)))
1489 (gnus-tmp-summary-live
1490 (if (and (not gnus-group-is-exiting-p)
1491 (gnus-buffer-live-p (gnus-summary-buffer-name
1494 (gnus-tmp-process-marked
1495 (if (member gnus-tmp-group gnus-group-marked)
1496 gnus-process-mark ? ))
1497 (buffer-read-only nil)
1498 header gnus-tmp-header) ; passed as parameter to user-funcs.
1500 (gnus-add-text-properties
1504 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1505 gnus-tmp-group group-name-charset)))
1506 (eval gnus-group-line-format-spec)))
1507 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1508 gnus-unread ,(if (numberp number)
1509 (string-to-number gnus-tmp-number-of-unread)
1511 gnus-marked ,gnus-tmp-marked-mark
1512 gnus-indentation ,gnus-group-indentation
1513 gnus-level ,gnus-tmp-level))
1515 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1516 (gnus-run-hooks 'gnus-group-update-hook))
1518 ;; Allow XEmacs to remove front-sticky text properties.
1519 (gnus-group-remove-excess-properties)))
1521 (defun gnus-group-highlight-line ()
1522 "Highlight the current line according to `gnus-group-highlight'."
1523 (let* ((list gnus-group-highlight)
1525 (end (point-at-eol))
1526 ;; now find out where the line starts and leave point there.
1527 (beg (progn (beginning-of-line) (point)))
1528 (group (gnus-group-group-name))
1529 (entry (gnus-group-entry group))
1530 (unread (if (numberp (car entry)) (car entry) 0))
1531 (active (gnus-active group))
1532 (total (if active (1+ (- (cdr active) (car active))) 0))
1533 (info (nth 2 entry))
1534 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1535 (marked (gnus-info-marks info))
1536 (mailp (apply 'append
1539 (memq x (assoc (symbol-name
1540 (car (or method gnus-select-method)))
1541 gnus-valid-select-methods)))
1542 '(mail post-mail))))
1543 (level (or (gnus-info-level info) gnus-level-killed))
1544 (score (or (gnus-info-score info) 0))
1545 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1546 (group-age (gnus-group-timestamp-delta group))
1547 (inhibit-read-only t))
1548 ;; Eval the cars of the lists until we find a match.
1550 (not (eval (caar list))))
1551 (setq list (cdr list)))
1552 (let ((face (cdar list)))
1553 (unless (eq face (get-text-property beg 'face))
1554 (gnus-put-text-property-excluding-characters-with-faces
1556 (setq face (if (boundp face) (symbol-value face) face)))
1557 (gnus-extent-start-open beg)))
1560 (defun gnus-group-update-group (group &optional visible-only)
1561 "Update all lines where GROUP appear.
1562 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1564 ;; Can't use `save-excursion' here, so we do it manually.
1565 (let ((buf (current-buffer))
1567 (set-buffer gnus-group-buffer)
1568 (setq mark (point-marker))
1569 ;; The buffer may be narrowed.
1572 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1574 found buffer-read-only)
1575 ;; Enter the current status into the dribble buffer.
1576 (let ((entry (gnus-group-entry group)))
1578 (not (gnus-ephemeral-group-p group)))
1580 (concat "(gnus-group-set-info '"
1581 (gnus-prin1-to-string (nth 2 entry))
1583 ;; Find all group instances. If topics are in use, each group
1584 ;; may be listed in more than once.
1585 (while (setq loc (text-property-any
1586 loc (point-max) 'gnus-group ident))
1589 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1591 (gnus-group-insert-group-line-info group)
1594 (gnus-run-hooks 'gnus-group-update-group-hook)))
1595 (setq loc (1+ loc)))
1596 (unless (or found visible-only)
1597 ;; No such line in the buffer, find out where it's supposed to
1598 ;; go, and insert it there (or at the end of the buffer).
1599 (if gnus-goto-missing-group-function
1600 (funcall gnus-goto-missing-group-function group)
1601 (let ((entry (cddr (gnus-group-entry group))))
1602 (while (and entry (car entry)
1606 (point-min) (point-max)
1607 'gnus-group (gnus-intern-safe
1608 (caar entry) gnus-active-hashtb)))))
1609 (setq entry (cdr entry)))
1610 (or entry (goto-char (point-max)))))
1611 ;; Finally insert the line.
1612 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1613 (gnus-group-insert-group-line-info group)
1616 (gnus-run-hooks 'gnus-group-update-group-hook))))
1617 (when gnus-group-update-group-function
1618 (funcall gnus-group-update-group-function group))
1619 (gnus-group-set-mode-line)))
1621 (set-marker mark nil)
1624 (defun gnus-group-set-mode-line ()
1625 "Update the mode line in the group buffer."
1626 (when (memq 'group gnus-updated-mode-lines)
1627 ;; Yes, we want to keep this mode line updated.
1629 (set-buffer gnus-group-buffer)
1630 (let* ((gformat (or gnus-group-mode-line-format-spec
1631 (gnus-set-format 'group-mode)))
1632 (gnus-tmp-news-server (cadr gnus-select-method))
1633 (gnus-tmp-news-method (car gnus-select-method))
1634 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1636 gnus-tmp-header ;Dummy binding for user-defined formats
1637 ;; Get the resulting string.
1639 (and gnus-dribble-buffer
1640 (buffer-name gnus-dribble-buffer)
1641 (buffer-modified-p gnus-dribble-buffer)
1643 (set-buffer gnus-dribble-buffer)
1644 (not (zerop (buffer-size))))))
1645 (mode-string (eval gformat)))
1646 ;; Say whether the dribble buffer has been modified.
1647 (setq mode-line-modified
1648 (if modified (car gnus-mode-line-modified)
1649 (cdr gnus-mode-line-modified)))
1650 ;; If the line is too long, we chop it off.
1651 (when (> (length mode-string) max-len)
1652 (setq mode-string (substring mode-string 0 (- max-len 4))))
1654 (setq mode-line-buffer-identification
1655 (gnus-mode-line-buffer-identification
1656 (list mode-string)))
1657 (set-buffer-modified-p modified))))))
1659 (defun gnus-group-group-name ()
1660 "Get the name of the newsgroup on the current line."
1661 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1663 (symbol-name group))))
1665 (defun gnus-group-group-level ()
1666 "Get the level of the newsgroup on the current line."
1667 (get-text-property (point-at-bol) 'gnus-level))
1669 (defun gnus-group-group-indentation ()
1670 "Get the indentation of the newsgroup on the current line."
1671 (or (get-text-property (point-at-bol) 'gnus-indentation)
1672 (and gnus-group-indentation-function
1673 (funcall gnus-group-indentation-function))
1676 (defun gnus-group-group-unread ()
1677 "Get the number of unread articles of the newsgroup on the current line."
1678 (get-text-property (point-at-bol) 'gnus-unread))
1680 (defun gnus-group-new-mail (group)
1681 (if (nnmail-new-mail-p (gnus-group-real-name group))
1685 (defun gnus-group-level (group)
1686 "Return the estimated level of GROUP."
1687 (or (gnus-info-level (gnus-get-info group))
1688 (and (member group gnus-zombie-list) gnus-level-zombie)
1691 (defun gnus-group-search-forward (&optional backward all level first-too)
1692 "Find the next newsgroup with unread articles.
1693 If BACKWARD is non-nil, find the previous newsgroup instead.
1694 If ALL is non-nil, just find any newsgroup.
1695 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1697 If FIRST-TOO, the current line is also eligible as a target."
1698 (let ((way (if backward -1 1))
1699 (low gnus-level-killed)
1702 (if (and backward (progn (beginning-of-line)) (bobp))
1711 (get-text-property (point) 'gnus-group)
1715 (get-text-property (point) 'gnus-unread)))
1716 (and (numberp unread) (> unread 0)))
1717 (setq lev (get-text-property (point)
1719 (<= lev gnus-level-subscribed)))
1721 (and (setq lev (get-text-property (point)
1730 (zerop (forward-line way)))))
1732 (progn (gnus-group-position-point) t)
1733 (goto-char (or pos beg))
1736 (defun gnus-total-fetched-for (group)
1737 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1738 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1739 (size (+ size-in-cache size-in-agent))
1740 (suffix '("B" "K" "M" "G"))
1742 (cutoff (* 10 scale)))
1743 (while (> size cutoff)
1744 (setq size (/ size scale)
1745 suffix (cdr suffix)))
1746 (format "%5.1f%s" size (car suffix))))
1748 ;;; Gnus group mode commands
1752 (defun gnus-group-mark-line-p ()
1755 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1756 (eq (char-after) gnus-process-mark)))
1758 (defun gnus-group-mark-group (n &optional unmark no-advance)
1759 "Mark the current group."
1761 (let ((buffer-read-only nil)
1765 (when (setq group (gnus-group-group-name))
1766 ;; Go to the mark position.
1768 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1772 (setq gnus-group-marked (delete group gnus-group-marked))
1773 (insert-char ? 1 t))
1774 (setq gnus-group-marked
1775 (cons group (delete group gnus-group-marked)))
1776 (insert-char gnus-process-mark 1 t)))
1778 (gnus-group-next-group 1))
1780 (gnus-summary-position-point)
1783 (defun gnus-group-unmark-group (n)
1784 "Remove the mark from the current group."
1786 (gnus-group-mark-group n 'unmark)
1787 (gnus-group-position-point))
1789 (defun gnus-group-unmark-all-groups ()
1790 "Unmark all groups."
1793 (mapc 'gnus-group-remove-mark gnus-group-marked))
1794 (gnus-group-position-point))
1796 (defun gnus-group-mark-region (unmark beg end)
1797 "Mark all groups between point and mark.
1798 If UNMARK, remove the mark instead."
1799 (interactive "P\nr")
1800 (let ((num (count-lines beg end)))
1803 (- num (gnus-group-mark-group num unmark)))))
1805 (defun gnus-group-mark-buffer (&optional unmark)
1806 "Mark all groups in the buffer.
1807 If UNMARK, remove the mark instead."
1809 (gnus-group-mark-region unmark (point-min) (point-max)))
1811 (defun gnus-group-mark-regexp (regexp)
1812 "Mark all groups that match some regexp."
1813 (interactive "sMark (regexp): ")
1814 (let ((alist (cdr gnus-newsrc-alist))
1818 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1819 (gnus-group-jump-to-group group)
1820 (gnus-group-set-mark group)))))
1821 (gnus-group-position-point))
1823 (defun gnus-group-remove-mark (group &optional test-marked)
1824 "Remove the process mark from GROUP and move point there.
1825 Return nil if the group isn't displayed."
1826 (if (gnus-group-goto-group group nil test-marked)
1828 (gnus-group-mark-group 1 'unmark t)
1830 (setq gnus-group-marked
1831 (delete group gnus-group-marked))
1834 (defun gnus-group-set-mark (group)
1835 "Set the process mark on GROUP."
1836 (if (gnus-group-goto-group group)
1838 (gnus-group-mark-group 1 nil t))
1839 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1841 (defun gnus-group-universal-argument (arg &optional groups func)
1842 "Perform any command on all groups according to the process/prefix convention."
1844 (if (eq (setq func (or func
1847 (substitute-command-keys
1848 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1850 (gnus-error 1 "Undefined key")
1851 (gnus-group-iterate arg
1853 (command-execute func))))
1854 (gnus-group-position-point))
1856 (defun gnus-group-process-prefix (n)
1857 "Return a list of groups to work on.
1858 Take into consideration N (the prefix) and the list of marked groups."
1861 (setq n (prefix-numeric-value n))
1862 ;; There is a prefix, so we return a list of the N next
1864 (let ((way (if (< n 0) -1 1))
1869 (if (setq group (gnus-group-group-name))
1870 (push group groups))
1872 (gnus-group-next-group way)))
1874 ((and (gnus-region-active-p) (mark))
1875 ;; Work on the region between point and mark.
1876 (let ((max (max (point) (mark)))
1879 (goto-char (min (point) (mark)))
1882 (push (gnus-group-group-name) groups)
1883 (zerop (gnus-group-next-group 1))
1885 (nreverse groups))))
1887 ;; No prefix, but a list of marked articles.
1888 (reverse gnus-group-marked))
1890 ;; Neither marked articles or a prefix, so we return the
1892 (let ((group (gnus-group-group-name)))
1893 (and group (list group))))))
1895 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1896 ;;; imagine why I went through these contortions...
1898 (let ((function (make-symbol "gnus-group-iterate-function"))
1899 (window (make-symbol "gnus-group-iterate-window"))
1900 (groups (make-symbol "gnus-group-iterate-groups"))
1901 (group (make-symbol "gnus-group-iterate-group")))
1903 `(defun gnus-group-iterate (arg ,function)
1904 "Iterate FUNCTION over all process/prefixed groups.
1905 FUNCTION will be called with the group name as the parameter
1906 and with point over the group in question."
1907 (let ((,groups (gnus-group-process-prefix arg))
1908 (,window (selected-window))
1911 (setq ,group (car ,groups)
1912 ,groups (cdr ,groups))
1913 (select-window ,window)
1914 (gnus-group-remove-mark ,group)
1915 (save-selected-window
1917 (funcall ,function ,group)))))))))
1919 (put 'gnus-group-iterate 'lisp-indent-function 1)
1921 ;; Selecting groups.
1923 (defun gnus-group-read-group (&optional all no-article group select-articles)
1924 "Read news in this newsgroup.
1925 If the prefix argument ALL is non-nil, already read articles become
1926 readable. IF ALL is a number, fetch this number of articles. If the
1927 optional argument NO-ARTICLE is non-nil, no article will be
1928 auto-selected upon group entry. If GROUP is non-nil, fetch that
1931 (let ((no-display (eq all 0))
1932 (group (or group (gnus-group-group-name)))
1933 number active marked entry)
1937 (error "No group on current line"))
1938 (setq marked (gnus-info-marks
1939 (nth 2 (setq entry (gnus-group-entry group)))))
1940 ;; This group might be a dead group. In that case we have to get
1941 ;; the number of unread articles from `gnus-active-hashtb'.
1943 (cond ((numberp all) all)
1945 ((setq active (gnus-active group))
1946 (- (1+ (cdr active)) (car active)))))
1947 (gnus-summary-read-group
1948 group (or all (and (numberp number)
1949 (zerop (+ number (gnus-range-length
1950 (cdr (assq 'tick marked)))
1952 (cdr (assq 'dormant marked)))))))
1953 no-article nil no-display nil select-articles)))
1955 (defun gnus-group-select-group (&optional all)
1956 "Select this newsgroup.
1957 No article is selected automatically.
1958 If the group is opened, just switch the summary buffer.
1959 If ALL is non-nil, already read articles become readable.
1960 If ALL is a positive number, fetch this number of the latest
1961 articles in the group.
1962 If ALL is a negative number, fetch this number of the earliest
1963 articles in the group."
1965 (when (and (eobp) (not (gnus-group-group-name)))
1967 (gnus-group-read-group all t))
1969 (defun gnus-group-quick-select-group (&optional all)
1970 "Select the current group \"quickly\".
1971 This means that no highlighting or scoring will be performed.
1972 If ALL (the prefix argument) is 0, don't even generate the summary
1975 This might be useful if you want to toggle threading
1976 before entering the group."
1978 (require 'gnus-score)
1980 gnus-score-find-score-files-function
1981 gnus-home-score-file
1982 gnus-apply-kill-hook
1983 gnus-summary-expunge-below)
1984 (gnus-group-read-group all t)))
1986 (defun gnus-group-visible-select-group (&optional all)
1987 "Select the current group without hiding any articles."
1989 (let ((gnus-inhibit-limiting t))
1990 (gnus-group-read-group all t)))
1992 (defun gnus-group-select-group-ephemerally ()
1993 "Select the current group without doing any processing whatsoever.
1994 You will actually be entered into a group that's a copy of
1995 the current group; no changes you make while in this group will
1998 (require 'gnus-score)
2000 gnus-score-find-score-files-function gnus-apply-kill-hook
2001 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2002 gnus-summary-mode-hook gnus-select-group-hook
2003 (group (gnus-group-group-name))
2004 (method (gnus-find-method-for-group group)))
2005 (gnus-group-read-ephemeral-group
2006 (gnus-group-prefixed-name group method) method)))
2009 (defun gnus-fetch-group (group &optional articles)
2010 "Start Gnus if necessary and enter GROUP.
2011 Returns whether the fetching was successful or not."
2012 (interactive (list (gnus-group-completing-read-group-name
2013 "Group name: " gnus-active-hashtb)))
2014 (unless (get-buffer gnus-group-buffer)
2016 (gnus-group-read-group articles nil group))
2019 (defun gnus-fetch-group-other-frame (group)
2020 "Pop up a frame and enter GROUP."
2022 (let ((window (get-buffer-window gnus-group-buffer)))
2024 (select-frame (window-frame window)))
2025 ((= (length (frame-list)) 1)
2026 (select-frame (make-frame)))
2029 (gnus-fetch-group group))
2031 (defvar gnus-ephemeral-group-server 0)
2033 (defcustom gnus-large-ephemeral-newsgroup 200
2034 "The number of articles which indicates a large ephemeral newsgroup.
2035 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2037 If the number of articles in a newsgroup is greater than this value,
2038 confirmation is required for selecting the newsgroup. If it is nil, no
2039 confirmation is required."
2041 :group 'gnus-group-select
2042 :type '(choice (const :tag "No limit" nil)
2045 (defcustom gnus-fetch-old-ephemeral-headers nil
2046 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2049 :type '(choice (const :tag "off" nil)
2052 (sexp :menu-tag "other" t)))
2054 ;; Enter a group that is not in the group buffer. Non-nil is returned
2055 ;; if selection was successful.
2056 (defun gnus-group-read-ephemeral-group (group method &optional activate
2057 quit-config request-only
2061 "Read GROUP from METHOD as an ephemeral group.
2062 If ACTIVATE, request the group first.
2063 If QUIT-CONFIG, use that window configuration when exiting from the
2065 If REQUEST-ONLY, don't actually read the group; just request it.
2066 If SELECT-ARTICLES, only select those articles.
2067 If PARAMETERS, use those as the group parameters.
2068 If NUMBER, fetch this number of articles.
2070 Return the name of the group if selection was successful."
2073 ;; (gnus-read-group "Group name: ")
2075 "Group: " gnus-active-hashtb
2077 'gnus-group-history)
2078 (gnus-read-method "From method: ")))
2079 ;; Transform the select method into a unique server.
2080 (when (stringp method)
2081 (setq method (gnus-server-to-method method)))
2083 `(,(car method) ,(concat (cadr method) "-ephemeral")
2084 (,(intern (format "%s-address" (car method))) ,(cadr method))
2086 (let ((group (if (gnus-group-foreign-p group) group
2087 (gnus-group-prefixed-name (gnus-group-real-name group)
2092 ,gnus-level-default-subscribed nil nil ,method
2095 (cons 'quit-config quit-config)
2097 (cons gnus-summary-buffer
2098 gnus-current-window-configuration)))
2101 (push method gnus-ephemeral-servers)
2102 (set-buffer gnus-group-buffer)
2103 (unless (gnus-check-server method)
2104 (error "Unable to contact server: %s" (gnus-status-message method)))
2106 (gnus-activate-group group 'scan)
2107 (unless (gnus-request-group group)
2108 (error "Couldn't request group: %s"
2109 (nnheader-get-report (car method)))))
2113 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2114 (gnus-fetch-old-headers
2115 gnus-fetch-old-ephemeral-headers))
2116 (gnus-group-read-group (or number t) t group select-articles))
2120 (message "Quit reading the ephemeral group")
2123 (defun gnus-group-jump-to-group (group &optional prompt)
2124 "Jump to newsgroup GROUP.
2126 If PROMPT (the prefix) is a number, use the prompt specified in
2127 `gnus-group-jump-to-group-prompt'."
2129 (list (mm-string-make-unibyte
2131 "Group: " gnus-active-hashtb nil
2132 (gnus-read-active-file-p)
2133 (if current-prefix-arg
2134 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2135 (or (and (stringp gnus-group-jump-to-group-prompt)
2136 gnus-group-jump-to-group-prompt)
2137 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2138 (and (stringp p) p))))
2139 'gnus-group-history))))
2141 (when (equal group "")
2142 (error "Empty group name"))
2144 (unless (gnus-ephemeral-group-p group)
2145 ;; Either go to the line in the group buffer...
2146 (unless (gnus-group-goto-group group)
2147 ;; ... or insert the line.
2148 (gnus-group-update-group group)
2149 (gnus-group-goto-group group)))
2150 ;; Adjust cursor point.
2151 (gnus-group-position-point))
2153 (defun gnus-group-goto-group (group &optional far test-marked)
2154 "Goto to newsgroup GROUP.
2155 If FAR, it is likely that the group is not on the current line.
2156 If TEST-MARKED, the line must be marked."
2160 ;; It's quite likely that we are on the right line, so
2161 ;; we check the current line first.
2163 (eq (get-text-property (point) 'gnus-group)
2164 (gnus-intern-safe group gnus-active-hashtb))
2165 (or (not test-marked) (gnus-group-mark-line-p)))
2167 ;; Previous and next line are also likely, so we check them as well.
2171 (and (eq (get-text-property (point) 'gnus-group)
2172 (gnus-intern-safe group gnus-active-hashtb))
2173 (or (not test-marked) (gnus-group-mark-line-p)))))
2179 (and (eq (get-text-property (point) 'gnus-group)
2180 (gnus-intern-safe group gnus-active-hashtb))
2181 (or (not test-marked) (gnus-group-mark-line-p)))))
2185 (goto-char (point-min))
2187 (while (and (not found)
2192 (gnus-intern-safe group gnus-active-hashtb))))
2193 (if (gnus-group-mark-line-p)
2198 ;; Search through the entire buffer.
2201 (point-min) (point-max)
2202 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2204 (defun gnus-group-next-group (n &optional silent)
2205 "Go to next N'th newsgroup.
2206 If N is negative, search backward instead.
2207 Returns the difference between N and the number of skips actually
2210 (gnus-group-next-unread-group n t nil silent))
2212 (defun gnus-group-next-unread-group (n &optional all level silent)
2213 "Go to next N'th unread newsgroup.
2214 If N is negative, search backward instead.
2215 If ALL is non-nil, choose any newsgroup, unread or not.
2216 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2217 such group can be found, the next group with a level higher than
2219 Returns the difference between N and the number of skips actually
2222 (let ((backward (< n 0))
2225 (gnus-group-search-forward
2226 backward (or (not gnus-group-goto-unread) all) level))
2230 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2231 (if level " on this level or higher" "")))
2234 (defun gnus-group-prev-group (n)
2235 "Go to previous N'th newsgroup.
2236 Returns the difference between N and the number of skips actually
2239 (gnus-group-next-unread-group (- n) t))
2241 (defun gnus-group-prev-unread-group (n)
2242 "Go to previous N'th unread newsgroup.
2243 Returns the difference between N and the number of skips actually
2246 (gnus-group-next-unread-group (- n)))
2248 (defun gnus-group-next-unread-group-same-level (n)
2249 "Go to next N'th unread newsgroup on the same level.
2250 If N is negative, search backward instead.
2251 Returns the difference between N and the number of skips actually
2254 (gnus-group-next-unread-group n t (gnus-group-group-level))
2255 (gnus-group-position-point))
2257 (defun gnus-group-prev-unread-group-same-level (n)
2258 "Go to next N'th unread newsgroup on the same level.
2259 Returns the difference between N and the number of skips actually
2262 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2263 (gnus-group-position-point))
2265 (defun gnus-group-best-unread-group (&optional exclude-group)
2266 "Go to the group with the highest level.
2267 If EXCLUDE-GROUP, do not go to that group."
2269 (goto-char (point-min))
2273 (setq unread (get-text-property (point) 'gnus-unread))
2274 (when (and (numberp unread) (> unread 0))
2275 (when (and (get-text-property (point) 'gnus-level)
2276 (< (get-text-property (point) 'gnus-level) best)
2277 (or (not exclude-group)
2278 (not (equal exclude-group (gnus-group-group-name)))))
2279 (setq best (get-text-property (point) 'gnus-level))
2280 (setq best-point (point))))
2283 (goto-char best-point))
2284 (gnus-group-position-point)
2285 (and best-point (gnus-group-group-name))))
2287 (defun gnus-group-first-unread-group ()
2288 "Go to the first group with unread articles."
2291 (let ((opoint (point))
2293 (goto-char (point-min))
2294 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2295 (and (numberp unread) ; Not a topic.
2296 (not (zerop unread))) ; Has unread articles.
2297 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2300 nil)) ; Not success.
2301 (gnus-group-position-point)))
2303 (defun gnus-group-enter-server-mode ()
2304 "Jump to the server buffer."
2306 (gnus-enter-server-buffer))
2308 (defun gnus-group-make-group-simple (&optional group)
2309 "Add a new newsgroup.
2310 The user will be prompted for GROUP."
2312 (list (completing-read "Group: " gnus-active-hashtb
2313 nil nil nil 'gnus-group-history)))
2314 (gnus-group-make-group
2315 (gnus-group-real-name group)
2316 (gnus-group-server group)))
2318 (defun gnus-group-make-group (name &optional method address args)
2319 "Add a new newsgroup.
2320 The user will be prompted for a NAME, for a select METHOD, and an
2324 (gnus-read-group "Group name: ")
2325 (gnus-read-method "From method: ")))
2327 (when (stringp method)
2328 (setq method (or (gnus-server-to-method method) method)))
2329 (let* ((meth (gnus-method-simplify
2331 (not (gnus-server-equal method gnus-select-method)))
2332 (if address (list (intern method) address)
2334 (nname (if method (gnus-group-prefixed-name name meth) name))
2336 (when (gnus-group-entry nname)
2337 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2338 ;; Subscribe to the new group.
2339 (gnus-group-change-level
2340 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2341 gnus-level-default-subscribed gnus-level-killed
2342 (and (gnus-group-group-name)
2343 (gnus-group-entry (gnus-group-group-name)))
2346 (gnus-set-active nname (cons 1 0))
2347 (unless (gnus-ephemeral-group-p name)
2349 (concat "(gnus-group-set-info '"
2350 (gnus-prin1-to-string (cdr info)) ")")))
2352 (gnus-group-insert-group-line-info nname)
2354 (gnus-group-position-point)
2356 ;; Load the back end and try to make the back end create
2357 ;; the group as well.
2358 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2360 gnus-valid-select-methods)
2362 (gnus-check-server meth)
2363 (when (gnus-check-backend-function 'request-create-group nname)
2364 (unless (gnus-request-create-group nname nil args)
2365 (error "Could not create group on server: %s"
2366 (nnheader-get-report backend))))
2369 (defun gnus-group-delete-groups (&optional arg)
2370 "Delete the current group. Only meaningful with editable groups."
2372 (let ((n (length (gnus-group-process-prefix arg))))
2373 (when (gnus-yes-or-no-p
2375 "Delete this 1 group? "
2376 (format "Delete these %d groups? " n)))
2377 (gnus-group-iterate arg
2379 (gnus-group-delete-group group nil t))))))
2381 (defun gnus-group-delete-group (group &optional force no-prompt)
2382 "Delete the current group. Only meaningful with editable groups.
2383 If FORCE (the prefix) is non-nil, all the articles in the group will
2384 be deleted. This is \"deleted\" as in \"removed forever from the face
2385 of the Earth\". There is no undo. The user will be prompted before
2387 Note that you also have to specify FORCE if you want the group to
2388 be removed from the server, even when it's empty."
2390 (list (gnus-group-group-name)
2391 current-prefix-arg))
2393 (error "No group to delete"))
2394 (unless (gnus-check-backend-function 'request-delete-group group)
2395 (error "This back end does not support group deletion"))
2397 (let ((group-decoded (gnus-group-decoded-name group)))
2398 (if (and (not no-prompt)
2399 (not (gnus-yes-or-no-p
2401 "Do you really want to delete %s%s? "
2402 group-decoded (if force " and all its contents" "")))))
2404 (gnus-message 6 "Deleting group %s..." group-decoded)
2405 (if (not (gnus-request-delete-group group force))
2406 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2407 (gnus-message 6 "Deleting group %s...done" group-decoded)
2408 (gnus-group-goto-group group)
2409 (gnus-group-kill-group 1 t)
2410 (gnus-set-active group nil)
2412 (gnus-group-position-point)))
2414 (defun gnus-group-rename-group (group new-name)
2415 "Rename group from GROUP to NEW-NAME.
2416 When used interactively, GROUP is the group under point
2417 and NEW-NAME will be prompted for."
2420 (gnus-group-group-name)
2422 (unless (gnus-check-backend-function
2423 'request-rename-group (gnus-group-group-name))
2424 (error "This back end does not support renaming groups"))
2425 (gnus-read-group "Rename group to: "
2426 (gnus-group-real-name (gnus-group-group-name))))))
2428 (unless (gnus-check-backend-function 'request-rename-group group)
2429 (error "This back end does not support renaming groups"))
2431 (error "No group to rename"))
2432 (when (equal (gnus-group-real-name group) new-name)
2433 (error "Can't rename to the same name"))
2435 ;; We find the proper prefixed name.
2437 (if (gnus-group-native-p group)
2441 (gnus-group-prefixed-name
2442 (gnus-group-real-name new-name)
2443 (gnus-info-method (gnus-get-info group)))))
2445 (when (gnus-active new-name)
2446 (error "The group %s already exists" new-name))
2448 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2451 (gnus-group-goto-group group)
2452 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2453 (gnus-request-rename-group group new-name))))
2454 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2455 ;; We rename the group internally by killing it...
2456 (gnus-group-kill-group)
2457 ;; ... changing its name ...
2458 (setcar (cdar gnus-list-of-killed-groups) new-name)
2459 ;; ... and then yanking it. Magic!
2460 (gnus-group-yank-group)
2461 (gnus-set-active new-name (gnus-active group))
2462 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2464 (setq gnus-killed-list (delete group gnus-killed-list))
2465 (gnus-set-active group nil)
2466 (gnus-dribble-touch)
2467 (gnus-group-position-point)))
2469 (defun gnus-group-edit-group (group &optional part)
2470 "Edit the group on the current line."
2471 (interactive (list (gnus-group-group-name)))
2472 (let ((part (or part 'info))
2475 (error "No group on current line"))
2476 (unless (setq info (gnus-get-info group))
2477 (error "Killed group; can't be edited"))
2479 (gnus-close-group group))
2481 ;; Find the proper form to edit.
2482 (cond ((eq part 'method)
2483 (or (gnus-info-method info) "native"))
2485 (gnus-info-params info))
2487 ;; The proper documentation.
2489 "Editing the %s for `%s'."
2491 ((eq part 'method) "select method")
2492 ((eq part 'params) "group parameters")
2494 (gnus-group-decoded-name group))
2496 (gnus-group-edit-group-done ',part ,group form)))
2499 (gnus-create-info-command
2501 (or gnus-info-filename
2502 (get-language-info current-language-environment 'gnus-info)
2504 (cond ((eq part 'method)
2511 (defun gnus-group-edit-group-method (group)
2512 "Edit the select method of GROUP."
2513 (interactive (list (gnus-group-group-name)))
2514 (gnus-group-edit-group group 'method))
2516 (defun gnus-group-edit-group-parameters (group)
2517 "Edit the group parameters of GROUP."
2518 (interactive (list (gnus-group-group-name)))
2519 (gnus-group-edit-group group 'params))
2521 (defun gnus-group-edit-group-done (part group form)
2523 (let* ((method (cond ((eq part 'info) (nth 4 form))
2524 ((eq part 'method) form)
2526 (info (cond ((eq part 'info) form)
2527 ((eq part 'method) (gnus-get-info group))
2530 (if (or (not method)
2532 gnus-select-method method))
2533 (gnus-group-real-name (car info))
2534 (gnus-group-prefixed-name
2535 (gnus-group-real-name (car info)) method))
2537 (when (and new-group
2538 (not (equal new-group group)))
2539 (when (gnus-group-goto-group group)
2540 (gnus-group-kill-group 1))
2541 (gnus-activate-group new-group))
2543 (if (not (and info new-group))
2544 (gnus-group-set-info form (or new-group group) part)
2545 (setq info (gnus-copy-sequence info))
2546 (setcar info new-group)
2547 (unless (gnus-server-equal method "native")
2548 (unless (nthcdr 3 info)
2549 (nconc info (list nil nil)))
2550 (unless (nthcdr 4 info)
2551 (nconc info (list nil)))
2552 (gnus-info-set-method info method))
2553 (gnus-group-set-info info))
2554 (gnus-group-update-group (or new-group group))
2555 (gnus-group-position-point)))
2557 (defun gnus-group-make-useful-group (group method)
2558 "Create one of the groups described in `gnus-useful-groups'."
2560 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2562 gnus-useful-groups)))
2563 (list (cadr entry) (caddr entry))))
2564 (setq method (gnus-copy-sequence method))
2566 (while (setq entry (memq (assq 'eval method) method))
2567 (setcar entry (eval (cadar entry)))))
2568 (gnus-group-make-group group method))
2570 (defun gnus-group-make-help-group (&optional noerror)
2571 "Create the Gnus documentation group.
2572 Optional argument NOERROR modifies the behavior of this function when the
2573 group already exists:
2574 - if not given, and error is signaled,
2575 - if t, stay silent,
2576 - if anything else, just print a message."
2578 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2579 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2580 (if (gnus-group-entry name)
2581 (cond ((eq noerror nil)
2582 (error "Documentation group already exists"))
2587 (gnus-message 1 "Documentation group already exists")))
2590 (gnus-message 1 "Couldn't find doc group")
2591 (gnus-group-make-group
2592 (gnus-group-real-name name)
2593 (list 'nndoc "gnus-help"
2594 (list 'nndoc-address file)
2595 (list 'nndoc-article-type 'mbox))))
2597 (gnus-group-position-point))
2599 (defun gnus-group-make-doc-group (file type)
2600 "Create a group that uses a single file as the source.
2602 If called with a prefix argument, ask for the file type."
2604 (list (read-file-name "File name: ")
2605 (and current-prefix-arg 'ask)))
2606 (when (eq type 'ask)
2611 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2613 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2614 ((= char ?b) 'babyl)
2615 ((= char ?d) 'digest)
2616 ((= char ?f) 'forward)
2618 ((= char ?g) 'guess)
2619 (t (setq err (format "%c unknown. " char))
2622 (let* ((file (expand-file-name file))
2623 (name (gnus-generate-new-group-name
2624 (gnus-group-prefixed-name
2625 (file-name-nondirectory file) '(nndoc "")))))
2626 (gnus-group-make-group
2627 (gnus-group-real-name name)
2629 (list 'nndoc-address file)
2630 (list 'nndoc-article-type (or type 'guess))))))
2632 (defvar nnweb-type-definition)
2633 (defvar gnus-group-web-type-history nil)
2634 (defvar gnus-group-web-search-history nil)
2635 (defun gnus-group-make-web-group (&optional solid)
2636 "Create an ephemeral nnweb group.
2637 If SOLID (the prefix), create a solid group."
2641 (if solid (gnus-read-group "Group name: ")
2642 (message-unique-id)))
2643 (default-type (or (car gnus-group-web-type-history)
2644 (symbol-name (caar nnweb-type-definition))))
2648 (format "Search engine type (default %s): " default-type)
2649 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2650 nnweb-type-definition)
2651 nil t nil 'gnus-group-web-type-history)
2656 (cons (or (car gnus-group-web-search-history) "") 0)
2657 'gnus-group-web-search-history))
2659 `(nnweb ,group (nnweb-search ,search)
2660 (nnweb-type ,(intern type))
2661 (nnweb-ephemeral-p t))))
2664 (gnus-pull 'nnweb-ephemeral-p method)
2665 (gnus-group-make-group group method))
2666 (gnus-group-read-ephemeral-group
2668 (cons (current-buffer)
2669 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2672 (defvar nnrss-group-alist)
2673 (defun nnrss-discover-feed (arg))
2674 (defun nnrss-save-server-data (arg)))
2675 (defun gnus-group-make-rss-group (&optional url)
2676 "Given a URL, discover if there is an RSS feed.
2677 If there is, use Gnus to create an nnrss group"
2681 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2682 (let ((feedinfo (nnrss-discover-feed url)))
2684 (let ((title (gnus-newsgroup-savable-name
2685 (read-from-minibuffer "Title: "
2686 (gnus-newsgroup-savable-name
2687 (or (cdr (assoc 'title
2690 (desc (read-from-minibuffer "Description: "
2691 (cdr (assoc 'description
2693 (href (cdr (assoc 'href feedinfo)))
2694 (encodable (mm-coding-system-p 'utf-8)))
2696 ;; Unify non-ASCII text.
2697 (setq title (mm-decode-coding-string
2698 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2699 (gnus-group-make-group (if encodable
2700 (mm-encode-coding-string title 'utf-8)
2703 (push (list title href desc) nnrss-group-alist)
2704 (nnrss-save-server-data nil))
2705 (error "No feeds found for %s" url))))
2707 (defvar nnwarchive-type-definition)
2708 (defvar gnus-group-warchive-type-history nil)
2709 (defvar gnus-group-warchive-login-history nil)
2710 (defvar gnus-group-warchive-address-history nil)
2712 (defun gnus-group-make-warchive-group ()
2713 "Create a nnwarchive group."
2715 (require 'nnwarchive)
2716 (let* ((group (gnus-read-group "Group name: "))
2717 (default-type (or (car gnus-group-warchive-type-history)
2718 (symbol-name (caar nnwarchive-type-definition))))
2722 (format "Warchive type (default %s): " default-type)
2723 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2724 nnwarchive-type-definition)
2725 nil t nil 'gnus-group-warchive-type-history)
2727 (address (read-string "Warchive address: "
2728 nil 'gnus-group-warchive-address-history))
2729 (default-login (or (car gnus-group-warchive-login-history)
2734 (format "Warchive login (default %s): " user-mail-address)
2735 default-login 'gnus-group-warchive-login-history)
2738 `(nnwarchive ,address
2739 (nnwarchive-type ,(intern type))
2740 (nnwarchive-login ,login))))
2741 (gnus-group-make-group group method)))
2743 (defun gnus-group-make-archive-group (&optional all)
2744 "Create the (ding) Gnus archive group of the most recent articles.
2745 Given a prefix, create a full group."
2747 (let ((group (gnus-group-prefixed-name
2748 (if all "ding.archives" "ding.recent") '(nndir ""))))
2749 (when (gnus-group-entry group)
2750 (error "Archive group already exists"))
2751 (gnus-group-make-group
2752 (gnus-group-real-name group)
2753 (list 'nndir (if all "hpc" "edu")
2754 (list 'nndir-directory
2755 (if all gnus-group-archive-directory
2756 gnus-group-recent-archive-directory))))
2757 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2759 (defun gnus-group-make-directory-group (dir)
2760 "Create an nndir group.
2761 The user will be prompted for a directory. The contents of this
2762 directory will be used as a newsgroup. The directory should contain
2763 mail messages or news articles in files that have numeric names."
2765 (list (read-file-name "Create group from directory: ")))
2766 (unless (file-exists-p dir)
2767 (error "No such directory"))
2768 (unless (file-directory-p dir)
2769 (error "Not a directory"))
2773 (while (or (not group) (gnus-group-entry group))
2775 (gnus-group-prefixed-name
2776 (expand-file-name ext dir)
2778 (setq ext (format "<%d>" (setq i (1+ i)))))
2779 (gnus-group-make-group
2780 (gnus-group-real-name group)
2781 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2783 (defvar nnkiboze-score-file)
2784 (defun gnus-group-make-kiboze-group (group address scores)
2785 "Create an nnkiboze group.
2786 The user will be prompted for a name, a regexp to match groups, and
2787 score file entries for articles to include in the group."
2790 (read-string "nnkiboze group name: ")
2791 (read-string "Source groups (regexp): ")
2792 (let ((headers (mapcar 'list
2793 '("subject" "from" "number" "date" "message-id"
2794 "references" "chars" "lines" "xref"
2795 "followup" "all" "body" "head")))
2796 scores header regexp regexps)
2797 (while (not (equal "" (setq header (completing-read
2798 "Match on header: " headers nil t))))
2800 (while (not (equal "" (setq regexp (read-string
2801 (format "Match on %s (regexp): "
2803 (push (list regexp nil nil 'r) regexps))
2804 (push (cons header regexps) scores))
2806 (gnus-group-make-group group "nnkiboze" address)
2807 (let* ((nnkiboze-current-group group)
2808 (score-file (car (nnkiboze-score-file "")))
2809 (score-dir (file-name-directory score-file)))
2810 (unless (file-exists-p score-dir)
2811 (make-directory score-dir))
2812 (with-temp-file score-file
2813 (let (emacs-lisp-mode-hook)
2814 (gnus-pp scores)))))
2816 (defun gnus-group-add-to-virtual (n vgroup)
2817 "Add the current group to a virtual group."
2819 (list current-prefix-arg
2820 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2822 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2823 (error "%s is not an nnvirtual group" vgroup))
2824 (gnus-close-group vgroup)
2825 (let* ((groups (gnus-group-process-prefix n))
2826 (method (gnus-info-method (gnus-get-info vgroup))))
2827 (setcar (cdr method)
2829 (nth 1 method) "\\|"
2832 (gnus-group-remove-mark s)
2833 (concat "\\(^" (regexp-quote s) "$\\)"))
2835 (gnus-group-position-point))
2837 (defun gnus-group-make-empty-virtual (group)
2838 "Create a new, fresh, empty virtual group."
2839 (interactive "sCreate new, empty virtual group: ")
2840 (let* ((method (list 'nnvirtual "^$"))
2841 (pgroup (gnus-group-prefixed-name group method)))
2842 ;; Check whether it exists already.
2843 (when (gnus-group-entry pgroup)
2844 (error "Group %s already exists" pgroup))
2845 ;; Subscribe the new group after the group on the current line.
2846 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2847 (gnus-group-update-group pgroup)
2849 (gnus-group-position-point)))
2851 (defun gnus-group-enter-directory (dir)
2852 "Enter an ephemeral nneething group."
2853 (interactive "DDirectory to read: ")
2854 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2855 (leaf (gnus-group-prefixed-name
2856 (file-name-nondirectory (directory-file-name dir))
2858 (name (gnus-generate-new-group-name leaf)))
2859 (unless (gnus-group-read-ephemeral-group
2861 (cons (current-buffer)
2862 (if (eq major-mode 'gnus-summary-mode)
2864 (error "Couldn't enter %s" dir))))
2867 (autoload 'nnimap-expunge "nnimap")
2868 (autoload 'nnimap-acl-get "nnimap")
2869 (autoload 'nnimap-acl-edit "nnimap"))
2871 (defun gnus-group-nnimap-expunge (group)
2872 "Expunge deleted articles in current nnimap GROUP."
2873 (interactive (list (gnus-group-group-name)))
2874 (let ((mailbox (gnus-group-real-name group)) method)
2876 (error "No group on current line"))
2877 (unless (gnus-get-info group)
2878 (error "Killed group; can't be edited"))
2879 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2880 (error "%s is not an nnimap group" group))
2881 (nnimap-expunge mailbox (cadr method))))
2883 (defun gnus-group-nnimap-edit-acl (group)
2884 "Edit the Access Control List of current nnimap GROUP."
2885 (interactive (list (gnus-group-group-name)))
2886 (let ((mailbox (gnus-group-real-name group)) method acl)
2888 (error "No group on current line"))
2889 (unless (gnus-get-info group)
2890 (error "Killed group; can't be edited"))
2891 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2892 (error "%s is not an nnimap group" group))
2893 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2894 (error "Server does not support ACL's"))
2895 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2897 An access control list is a list of (identifier . rights) elements.
2899 The identifier string specifies the corresponding user. The
2900 identifier \"anyone\" is reserved to refer to the universal identity.
2902 Rights is a string listing a (possibly empty) set of alphanumeric
2903 characters, each character listing a set of operations which is being
2904 controlled. Letters are reserved for ``standard'' rights, listed
2905 below. Digits are reserved for implementation or site defined rights.
2907 l - lookup (mailbox is visible to LIST/LSUB commands)
2908 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2909 SEARCH, COPY from mailbox)
2910 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2911 w - write (STORE flags other than \\SEEN and \\DELETED)
2912 i - insert (perform APPEND, COPY into mailbox)
2913 p - post (send mail to submission address for mailbox,
2914 not enforced by IMAP4 itself)
2915 c - create and delete mailbox (CREATE new sub-mailboxes in any
2916 implementation-defined hierarchy, RENAME or DELETE mailbox)
2917 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2918 a - administer (perform SETACL)" group)
2921 ,mailbox ',method ',acl form)))))
2923 ;; Group sorting commands
2924 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2926 (defun gnus-group-sort-groups (func &optional reverse)
2927 "Sort the group buffer according to FUNC.
2928 When used interactively, the sorting function used will be
2929 determined by the `gnus-group-sort-function' variable.
2930 If REVERSE (the prefix), reverse the sorting order."
2931 (interactive (list gnus-group-sort-function current-prefix-arg))
2932 (funcall gnus-group-sort-alist-function
2933 (gnus-make-sort-function func) reverse)
2934 (gnus-group-unmark-all-groups)
2935 (gnus-group-list-groups)
2936 (gnus-dribble-touch))
2938 (defun gnus-group-sort-flat (func reverse)
2939 ;; We peel off the dummy group from the alist.
2941 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2942 (pop gnus-newsrc-alist))
2944 (setq gnus-newsrc-alist
2945 (sort gnus-newsrc-alist func))
2947 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2948 ;; Regenerate the hash table.
2949 (gnus-make-hashtable-from-newsrc-alist)))
2951 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2952 "Sort the group buffer alphabetically by group name.
2953 If REVERSE, sort in reverse order."
2955 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2957 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2958 "Sort the group buffer alphabetically by real (unprefixed) group name.
2959 If REVERSE, sort in reverse order."
2961 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2963 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2964 "Sort the group buffer by number of unread articles.
2965 If REVERSE, sort in reverse order."
2967 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2969 (defun gnus-group-sort-groups-by-level (&optional reverse)
2970 "Sort the group buffer by group level.
2971 If REVERSE, sort in reverse order."
2973 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2975 (defun gnus-group-sort-groups-by-score (&optional reverse)
2976 "Sort the group buffer by group score.
2977 If REVERSE, sort in reverse order."
2979 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2981 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2982 "Sort the group buffer by group rank.
2983 If REVERSE, sort in reverse order."
2985 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2987 (defun gnus-group-sort-groups-by-method (&optional reverse)
2988 "Sort the group buffer alphabetically by back end name.
2989 If REVERSE, sort in reverse order."
2991 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2993 (defun gnus-group-sort-groups-by-server (&optional reverse)
2994 "Sort the group buffer alphabetically by server name.
2995 If REVERSE, sort in reverse order."
2997 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2999 ;;; Selected group sorting.
3001 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3002 "Sort the process/prefixed groups."
3003 (interactive (list current-prefix-arg gnus-group-sort-function))
3004 (let ((groups (gnus-group-process-prefix n)))
3005 (funcall gnus-group-sort-selected-function
3006 groups (gnus-make-sort-function func) reverse)
3007 (gnus-group-unmark-all-groups)
3008 (gnus-group-list-groups)
3009 (gnus-dribble-touch)))
3011 (defun gnus-group-sort-selected-flat (groups func reverse)
3012 (let (entries infos)
3013 ;; First find all the group entries for these groups.
3015 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3017 ;; Then sort the infos.
3021 (lambda (entry) (car entry))
3022 (setq entries (nreverse entries)))
3025 (setq infos (nreverse infos)))
3026 ;; Go through all the infos and replace the old entries
3027 ;; with the new infos.
3029 (setcar (car entries) (pop infos))
3031 ;; Update the hashtable.
3032 (gnus-make-hashtable-from-newsrc-alist)))
3034 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3035 "Sort the group buffer alphabetically by group name.
3036 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3037 sort in reverse order."
3038 (interactive (gnus-interactive "P\ny"))
3039 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3041 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3042 "Sort the group buffer alphabetically by real group name.
3043 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3044 sort in reverse order."
3045 (interactive (gnus-interactive "P\ny"))
3046 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3048 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3049 "Sort the group buffer by number of unread articles.
3050 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3051 sort in reverse order."
3052 (interactive (gnus-interactive "P\ny"))
3053 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3055 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3056 "Sort the group buffer by group level.
3057 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3058 sort in reverse order."
3059 (interactive (gnus-interactive "P\ny"))
3060 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3062 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3063 "Sort the group buffer by group score.
3064 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3065 sort in reverse order."
3066 (interactive (gnus-interactive "P\ny"))
3067 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3069 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3070 "Sort the group buffer by group rank.
3071 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3072 sort in reverse order."
3073 (interactive (gnus-interactive "P\ny"))
3074 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3076 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3077 "Sort the group buffer alphabetically by back end name.
3078 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3079 sort in reverse order."
3080 (interactive (gnus-interactive "P\ny"))
3081 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3083 ;;; Sorting predicates.
3085 (defun gnus-group-sort-by-alphabet (info1 info2)
3086 "Sort alphabetically."
3087 (string< (gnus-info-group info1) (gnus-info-group info2)))
3089 (defun gnus-group-sort-by-real-name (info1 info2)
3090 "Sort alphabetically on real (unprefixed) names."
3091 (string< (gnus-group-real-name (gnus-info-group info1))
3092 (gnus-group-real-name (gnus-info-group info2))))
3094 (defun gnus-group-sort-by-unread (info1 info2)
3095 "Sort by number of unread articles."
3096 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3097 (n2 (gnus-group-unread (gnus-info-group info1))))
3098 (< (or (and (numberp n1) n1) 0)
3099 (or (and (numberp n2) n2) 0))))
3101 (defun gnus-group-sort-by-level (info1 info2)
3103 (< (gnus-info-level info1) (gnus-info-level info2)))
3105 (defun gnus-group-sort-by-method (info1 info2)
3106 "Sort alphabetically by back end name."
3107 (string< (car (gnus-find-method-for-group
3108 (gnus-info-group info1) info1))
3109 (car (gnus-find-method-for-group
3110 (gnus-info-group info2) info2))))
3112 (defun gnus-group-sort-by-server (info1 info2)
3113 "Sort alphabetically by server name."
3114 (string< (gnus-method-to-full-server-name
3115 (gnus-find-method-for-group
3116 (gnus-info-group info1) info1))
3117 (gnus-method-to-full-server-name
3118 (gnus-find-method-for-group
3119 (gnus-info-group info2) info2))))
3121 (defun gnus-group-sort-by-score (info1 info2)
3122 "Sort by group score."
3123 (> (gnus-info-score info1) (gnus-info-score info2)))
3125 (defun gnus-group-sort-by-rank (info1 info2)
3126 "Sort by level and score."
3127 (let ((level1 (gnus-info-level info1))
3128 (level2 (gnus-info-level info2)))
3129 (or (< level1 level2)
3130 (and (= level1 level2)
3131 (> (gnus-info-score info1) (gnus-info-score info2))))))
3135 (defun gnus-group-clear-data (&optional arg)
3136 "Clear all marks and read ranges from the current group.
3137 Obeys the process/prefix convention."
3139 (gnus-group-iterate arg
3142 (gnus-info-clear-data (setq info (gnus-get-info group)))
3143 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3144 (when (gnus-group-goto-group group)
3145 (gnus-group-update-group-line))))))
3147 (defun gnus-group-clear-data-on-native-groups ()
3148 "Clear all marks and read ranges from all native groups."
3150 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3151 (let ((alist (cdr gnus-newsrc-alist))
3153 (while (setq info (pop alist))
3154 (when (gnus-group-native-p (gnus-info-group info))
3155 (gnus-info-clear-data info)))
3156 (gnus-get-unread-articles)
3157 (gnus-dribble-touch)
3158 (when (gnus-y-or-n-p
3159 "Move the cache away to avoid problems in the future? ")
3160 (call-interactively 'gnus-cache-move-cache)))))
3162 (defun gnus-info-clear-data (info)
3163 "Clear all marks and read ranges from INFO."
3164 (let ((group (gnus-info-group info))
3166 (dolist (el (gnus-info-marks info))
3167 (push `(,(cdr el) add (,(car el))) action))
3168 (push `(,(gnus-info-read info) add (read)) action)
3171 (gnus-request-set-mark ,group ',action)
3172 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3173 (gnus-info-set-read ',info ',(gnus-info-read info))
3174 (when (gnus-group-goto-group ,group)
3175 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3176 (gnus-group-update-group-line))))
3177 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3179 (gnus-request-set-mark group action)
3180 (gnus-info-set-read info nil)
3181 (when (gnus-info-marks info)
3182 (gnus-info-set-marks info nil))))
3184 ;; Group catching up.
3186 (defun gnus-group-catchup-current (&optional n all)
3187 "Mark all unread articles in the current newsgroup as read.
3188 If prefix argument N is numeric, the next N newsgroups will be
3189 caught up. If ALL is non-nil, marked articles will also be marked as
3190 read. Cross references (Xref: header) of articles are ignored.
3191 The number of newsgroups that this function was unable to catch
3194 (let ((groups (gnus-group-process-prefix n))
3197 (unless groups (error "No groups selected"))
3199 (or (not gnus-interactive-catchup) ;Without confirmation?
3204 "Do you really want to mark all articles in %s as read? "
3205 "Mark all unread articles in %s as read? ")
3206 (if (= (length groups) 1)
3207 (gnus-group-decoded-name (car groups))
3208 (format "these %d groups" (length groups)))))))
3210 (while (setq group (pop groups))
3211 (gnus-group-remove-mark group)
3212 ;; Virtual groups have to be given special treatment.
3213 (let ((method (gnus-find-method-for-group group)))
3214 (when (eq 'nnvirtual (car method))
3215 (nnvirtual-catchup-group
3216 (gnus-group-real-name group) (nth 1 method) all)))
3217 (if (>= (gnus-group-level group) gnus-level-zombie)
3218 (gnus-message 2 "Dead groups can't be caught up")
3220 (gnus-group-goto-group group)
3221 (gnus-group-catchup group all))
3222 (gnus-group-update-group-line)
3223 (setq ret (1+ ret)))))
3224 (gnus-group-next-unread-group 1)
3227 (defun gnus-group-catchup-current-all (&optional n)
3228 "Mark all articles in current newsgroup as read.
3229 Cross references (Xref: header) of articles are ignored."
3231 (gnus-group-catchup-current n 'all))
3233 (defun gnus-group-catchup (group &optional all)
3234 "Mark all articles in GROUP as read.
3235 If ALL is non-nil, all articles are marked as read.
3236 The return value is the number of articles that were marked as read,
3237 or nil if no action could be taken."
3238 (let* ((entry (gnus-group-entry group))
3240 (marks (gnus-info-marks (nth 2 entry)))
3241 (unread (gnus-sequence-of-unread-articles group)))
3242 ;; Remove entries for this group.
3243 (nnmail-purge-split-history (gnus-group-real-name group))
3244 ;; Do the updating only if the newsgroup isn't killed.
3245 (if (not (numberp (car entry)))
3246 (gnus-message 1 "Can't catch up %s; non-active group" group)
3247 (gnus-update-read-articles group nil)
3249 ;; Nix out the lists of marks and dormants.
3250 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3252 (list (cdr (assq 'dormant marks))
3254 (setq unread (gnus-range-add (gnus-range-add
3255 unread (cdr (assq 'dormant marks)))
3256 (cdr (assq 'tick marks))))
3257 (gnus-add-marked-articles group 'tick nil nil 'force)
3258 (gnus-add-marked-articles group 'dormant nil nil 'force))
3259 ;; Do auto-expirable marks if that's required.
3260 (when (gnus-group-auto-expirable-p group)
3261 (gnus-range-map (lambda (article)
3262 (gnus-add-marked-articles group 'expire (list article))
3263 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3265 (let ((gnus-newsgroup-name group))
3266 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3269 (defun gnus-group-expire-articles (&optional n)
3270 "Expire all expirable articles in the current newsgroup.
3271 Uses the process/prefix convention."
3273 (let ((groups (gnus-group-process-prefix n))
3276 (error "No groups to expire"))
3277 (while (setq group (pop groups))
3278 (gnus-group-remove-mark group)
3279 (gnus-group-expire-articles-1 group)
3280 (gnus-dribble-touch)
3281 (gnus-group-position-point))))
3283 (defun gnus-group-expire-articles-1 (group)
3284 (when (gnus-check-backend-function 'request-expire-articles group)
3285 (gnus-message 6 "Expiring articles in %s..."
3286 (gnus-group-decoded-name group))
3287 (let* ((info (gnus-get-info group))
3288 (expirable (if (gnus-group-total-expirable-p group)
3289 (cons nil (gnus-list-of-read-articles group))
3290 (assq 'expire (gnus-info-marks info))))
3291 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3292 (nnmail-expiry-target
3293 (or (gnus-group-find-parameter group 'expiry-target)
3294 nnmail-expiry-target)))
3296 (gnus-check-group group)
3299 (gnus-compress-sequence
3301 ;; We set the expiry variables to the group
3303 (let ((nnmail-expiry-wait-function nil)
3304 (nnmail-expiry-wait expiry-wait))
3305 (gnus-request-expire-articles
3306 (gnus-uncompress-sequence (cdr expirable)) group))
3307 ;; Just expire using the normal expiry values.
3308 (gnus-request-expire-articles
3309 (gnus-uncompress-sequence (cdr expirable)) group))))
3310 (gnus-close-group group))
3311 (gnus-message 6 "Expiring articles in %s...done"
3312 (gnus-group-decoded-name group))
3313 ;; Return the list of un-expired articles.
3316 (defun gnus-group-expire-all-groups ()
3317 "Expire all expirable articles in all newsgroups."
3320 (gnus-message 5 "Expiring...")
3321 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3322 (cdr gnus-newsrc-alist))))
3323 (gnus-group-expire-articles nil)))
3324 (gnus-group-position-point)
3325 (gnus-message 5 "Expiring...done"))
3327 (defun gnus-group-set-current-level (n level)
3328 "Set the level of the next N groups to LEVEL."
3333 (unless (gnus-group-process-prefix current-prefix-arg)
3334 (error "No group on the current line"))
3336 (let ((s (read-string
3337 (format "Level (default %s): "
3338 (or (gnus-group-group-level)
3339 gnus-level-default-subscribed)))))
3340 (if (string-match "^\\s-*$" s)
3341 (int-to-string (or (gnus-group-group-level)
3342 gnus-level-default-subscribed))
3344 (unless (and (>= level 1) (<= level gnus-level-killed))
3345 (error "Invalid level: %d" level))
3346 (dolist (group (gnus-group-process-prefix n))
3347 (gnus-group-remove-mark group)
3348 (gnus-message 6 "Changed level of %s from %d to %d"
3349 (gnus-group-decoded-name group)
3350 (or (gnus-group-group-level) gnus-level-killed)
3352 (gnus-group-change-level
3353 group level (or (gnus-group-group-level) gnus-level-killed))
3354 (gnus-group-update-group-line))
3355 (gnus-group-position-point))
3357 (defun gnus-group-unsubscribe (&optional n)
3358 "Unsubscribe the current group."
3360 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3362 (defun gnus-group-subscribe (&optional n)
3363 "Subscribe the current group."
3365 (gnus-group-unsubscribe-current-group n 'subscribe))
3367 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3368 "Toggle subscription of the current group.
3369 If given numerical prefix, toggle the N next groups."
3371 (dolist (group (gnus-group-process-prefix n))
3372 (gnus-group-remove-mark group)
3373 (gnus-group-unsubscribe-group
3376 ((eq do-sub 'unsubscribe)
3377 gnus-level-default-unsubscribed)
3378 ((eq do-sub 'subscribe)
3379 gnus-level-default-subscribed)
3380 ((<= (gnus-group-group-level) gnus-level-subscribed)
3381 gnus-level-default-unsubscribed)
3383 gnus-level-default-subscribed))
3385 (gnus-group-update-group-line))
3386 (gnus-group-next-group 1))
3388 (defun gnus-group-unsubscribe-group (group &optional level silent)
3389 "Toggle subscription to GROUP.
3390 Killed newsgroups are subscribed. If SILENT, don't try to update the
3393 (list (gnus-group-completing-read-group-name
3394 "Group: " gnus-active-hashtb nil
3395 (gnus-read-active-file-p)
3397 'gnus-group-history)))
3398 (let ((newsrc (gnus-group-entry group)))
3400 ((string-match "^[ \t]*$" group)
3401 (error "Empty group name"))
3403 ;; Toggle subscription flag.
3404 (gnus-group-change-level
3405 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3406 gnus-level-subscribed)
3407 (1+ gnus-level-subscribed)
3408 gnus-level-default-subscribed)))
3410 (gnus-group-update-group group)))
3411 ((and (stringp group)
3412 (or (not (gnus-read-active-file-p))
3413 (gnus-active group)))
3414 ;; Add new newsgroup.
3415 (gnus-group-change-level
3417 (if level level gnus-level-default-subscribed)
3418 (or (and (member group gnus-zombie-list)
3421 (when (gnus-group-group-name)
3422 (gnus-group-entry (gnus-group-group-name))))
3424 (gnus-group-update-group group)))
3425 (t (error "No such newsgroup: %s" group)))
3426 (gnus-group-position-point)))
3428 (defun gnus-group-transpose-groups (n)
3429 "Move the current newsgroup up N places.
3430 If given a negative prefix, move down instead. The difference between
3431 N and the number of steps taken is returned."
3433 (unless (gnus-group-group-name)
3434 (error "No group on current line"))
3435 (gnus-group-kill-group 1)
3437 (forward-line (- n))
3438 (gnus-group-yank-group)
3439 (gnus-group-position-point)))
3441 (defun gnus-group-kill-all-zombies (&optional dummy)
3442 "Kill all zombie newsgroups.
3443 The optional DUMMY should always be nil."
3444 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3446 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3447 (setq gnus-zombie-list nil)
3448 (gnus-dribble-touch)
3449 (gnus-group-list-groups)))
3451 (defun gnus-group-kill-region (begin end)
3452 "Kill newsgroups in current region (excluding current point).
3453 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3466 (beginning-of-line) ;Important when LINES < 1
3467 (gnus-group-kill-group lines)))
3469 (defun gnus-group-kill-group (&optional n discard)
3470 "Kill the next N groups.
3471 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3472 However, only groups that were alive can be yanked; already killed
3473 groups or zombie groups can't be yanked.
3474 The return value is the name of the group that was killed, or a list
3477 (let ((buffer-read-only nil)
3478 (groups (gnus-group-process-prefix n))
3479 group entry level out)
3480 (if (< (length groups) 10)
3481 ;; This is faster when there are few groups.
3483 (push (setq group (pop groups)) out)
3484 (gnus-group-remove-mark group)
3485 (setq level (gnus-group-group-level))
3487 (when (and (not discard)
3488 (setq entry (gnus-group-entry group)))
3491 (gnus-group-goto-group ,(gnus-group-group-name))
3492 (gnus-group-yank-group)))
3493 (push (cons (car entry) (nth 2 entry))
3494 gnus-list-of-killed-groups))
3495 (gnus-group-change-level
3496 (if entry entry group) gnus-level-killed (if entry nil level))
3497 (message "Killed group %s" (gnus-group-decoded-name group)))
3498 ;; If there are lots and lots of groups to be killed, we use
3499 ;; this thing instead.
3500 (dolist (group (nreverse groups))
3501 (gnus-group-remove-mark group)
3503 (push group gnus-killed-list)
3504 (setq gnus-newsrc-alist
3505 (delq (assoc group gnus-newsrc-alist)
3507 (when gnus-group-change-level-function
3508 (funcall gnus-group-change-level-function
3509 group gnus-level-killed 3))
3511 ((setq entry (gnus-group-entry group))
3512 (push (cons (car entry) (nth 2 entry))
3513 gnus-list-of-killed-groups)
3514 (setcdr (cdr entry) (cdddr entry)))
3515 ((member group gnus-zombie-list)
3516 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3517 ;; There may be more than one instance displayed.
3518 (while (gnus-group-goto-group group)
3519 (gnus-delete-line)))
3520 (gnus-make-hashtable-from-newsrc-alist))
3522 (gnus-group-position-point)
3523 (if (< (length out) 2) (car out) (nreverse out))))
3525 (defun gnus-group-yank-group (&optional arg)
3526 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3527 The numeric ARG specifies how many newsgroups are to be yanked. The
3528 name of the newsgroup yanked is returned, or (if several groups are
3529 yanked) a list of yanked groups is returned."
3531 (setq arg (or arg 1))
3532 (let (info group prev out)
3533 (while (>= (decf arg) 0)
3534 (when (not (setq info (pop gnus-list-of-killed-groups)))
3535 (error "No more newsgroups to yank"))
3536 (push (setq group (nth 1 info)) out)
3537 ;; Find which newsgroup to insert this one before - search
3538 ;; backward until something suitable is found. If there are no
3539 ;; other newsgroups in this buffer, just make this newsgroup the
3541 (setq prev (gnus-group-group-name))
3542 (gnus-group-change-level
3543 info (gnus-info-level (cdr info)) gnus-level-killed
3544 (and prev (gnus-group-entry prev))
3546 (gnus-group-insert-group-line-info group)
3548 `(when (gnus-group-goto-group ,group)
3549 (gnus-group-kill-group 1))))
3551 (gnus-group-position-point)
3552 (if (< (length out) 2) (car out) (nreverse out))))
3554 (defun gnus-group-kill-level (level)
3555 "Kill all groups that is on a certain LEVEL."
3556 (interactive "nKill all groups on level: ")
3558 ((= level gnus-level-zombie)
3559 (setq gnus-killed-list
3560 (nconc gnus-zombie-list gnus-killed-list))
3561 (setq gnus-zombie-list nil))
3562 ((and (< level gnus-level-zombie)
3564 (or gnus-expert-user
3567 "Do you really want to kill all groups on level %d? "
3569 (let* ((prev gnus-newsrc-alist)
3572 (if (= (gnus-info-level (car alist)) level)
3574 (push (gnus-info-group (car alist)) gnus-killed-list)
3575 (setcdr prev (cdr alist)))
3577 (setq alist (cdr alist)))
3578 (gnus-make-hashtable-from-newsrc-alist)
3579 (gnus-group-list-groups)))
3581 (error "Can't kill; invalid level: %d" level))))
3583 (defun gnus-group-list-all-groups (&optional arg)
3584 "List all newsgroups with level ARG or lower.
3585 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3586 unsubscribed groups."
3588 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3590 ;; Redefine this to list ALL killed groups if prefix arg used.
3591 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3592 (defun gnus-group-list-killed (&optional arg)
3593 "List all killed newsgroups in the group buffer.
3594 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3595 entail asking the server for the groups."
3597 ;; Find all possible killed newsgroups if arg.
3599 (gnus-get-killed-groups))
3600 (if (not gnus-killed-list)
3601 (gnus-message 6 "No killed groups")
3602 (let (gnus-group-list-mode)
3603 (funcall gnus-group-prepare-function
3604 gnus-level-killed t gnus-level-killed))
3605 (goto-char (point-min)))
3606 (gnus-group-position-point))
3608 (defun gnus-group-list-zombies ()
3609 "List all zombie newsgroups in the group buffer."
3611 (if (not gnus-zombie-list)
3612 (gnus-message 6 "No zombie groups")
3613 (let (gnus-group-list-mode)
3614 (funcall gnus-group-prepare-function
3615 gnus-level-zombie t gnus-level-zombie))
3616 (goto-char (point-min)))
3617 (gnus-group-position-point))
3619 (defun gnus-group-list-active ()
3620 "List all groups that are available from the server(s)."
3622 ;; First we make sure that we have really read the active file.
3623 (unless (gnus-read-active-file-p)
3624 (let ((gnus-read-active-file t)
3625 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3626 (gnus-read-active-file)))
3627 ;; Find all groups and sort them.
3635 (push (symbol-name sym) list)))
3639 (buffer-read-only nil)
3643 (setq group (pop groups))
3644 (gnus-add-text-properties
3645 (point) (prog1 (1+ (point))
3647 (gnus-group-decoded-name group)
3649 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3651 'gnus-level (inline (gnus-group-level group)))))
3652 (goto-char (point-min))))
3654 (defun gnus-activate-all-groups (level)
3655 "Activate absolutely all groups."
3656 (interactive (list gnus-level-unsubscribed))
3657 (let ((gnus-activate-level level)
3658 (gnus-activate-foreign-newsgroups level))
3659 (gnus-group-get-new-news)))
3661 (defun gnus-group-get-new-news (&optional arg)
3662 "Get newly arrived articles.
3663 If ARG is a number, it specifies which levels you are interested in
3664 re-scanning. If ARG is non-nil and not a number, this will force
3665 \"hard\" re-reading of the active files from all servers."
3668 (let ((gnus-inhibit-demon t)
3669 ;; Binding this variable will inhibit multiple fetchings
3670 ;; of the same mail source.
3671 (nnmail-fetched-sources (list t)))
3672 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3673 (gnus-run-hooks 'gnus-get-new-news-hook)
3675 ;; Read any slave files.
3677 (gnus-master-read-slave-newsrc))
3679 ;; We might read in new NoCeM messages here.
3680 (when (and gnus-use-nocem
3682 (gnus-nocem-scan-groups))
3683 ;; If ARG is not a number, then we read the active file.
3684 (when (and arg (not (numberp arg)))
3685 (let ((gnus-read-active-file t))
3686 (gnus-read-active-file))
3689 ;; If the user wants it, we scan for new groups.
3690 (when (eq gnus-check-new-newsgroups 'always)
3691 (gnus-find-new-newsgroups)))
3693 (setq arg (gnus-group-default-level arg t))
3694 (if (and gnus-read-active-file (not arg))
3696 (gnus-read-active-file)
3697 (gnus-get-unread-articles arg))
3698 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3699 (gnus-get-unread-articles arg)))
3700 (gnus-check-reasonable-setup)
3701 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3702 (gnus-group-list-groups (and (numberp arg)
3703 (max (car gnus-group-list-mode) arg))))
3705 (when (and gnus-agent (not (interactive-p)))
3706 (gnus-agent-toggle-plugged gnus-plugged)))
3708 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3709 "Check for newly arrived news in the current group (and the N-1 next groups).
3710 The difference between N and the number of newsgroup checked is returned.
3711 If N is negative, this group and the N-1 previous groups will be checked.
3712 If DONT-SCAN is non-nil, scan non-activated groups as well."
3714 (let* ((groups (gnus-group-process-prefix n))
3715 (ret (if (numberp n) (- n (length groups)) 0))
3719 (gnus-inhibit-demon t)
3720 ;; Binding this variable will inhibit multiple fetchings
3721 ;; of the same mail source.
3722 (nnmail-fetched-sources (list t)))
3723 (gnus-run-hooks 'gnus-get-new-news-hook)
3724 (while (setq group (pop groups))
3725 (gnus-group-remove-mark group)
3726 ;; Bypass any previous denials from the server.
3727 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3728 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3729 (let ((info (gnus-get-info group))
3730 (active (gnus-active group)))
3732 (gnus-request-update-info info method))
3733 (gnus-get-unread-articles-in-group info active)
3734 (unless (gnus-virtual-group-p group)
3735 (gnus-close-group group))
3737 (gnus-agent-save-group-info
3738 method (gnus-group-real-name group) active))
3739 (gnus-group-update-group group))
3740 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3742 (gnus-error 3 "Server denied access")
3743 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3746 (when gnus-goto-next-group-when-activating
3747 (gnus-group-next-unread-group 1 t))
3748 (gnus-summary-position-point)
3751 (defun gnus-group-fetch-faq (group &optional faq-dir)
3752 "Fetch the FAQ for the current group.
3753 If given a prefix argument, prompt for the FAQ dir
3757 (gnus-group-group-name)
3758 (when current-prefix-arg
3760 "FAQ dir: " (and (listp gnus-group-faq-directory)
3762 gnus-group-faq-directory))))))
3764 (error "No group name given"))
3765 (let ((dirs (or faq-dir gnus-group-faq-directory))
3767 (unless (listp dirs)
3768 (setq dirs (list dirs)))
3769 (while (and (not found)
3770 (setq dir (pop dirs)))
3771 (let ((name (gnus-group-real-name group)))
3772 (setq file (expand-file-name name dir)))
3773 (if (not (file-exists-p file))
3774 (gnus-message 1 "No such file: %s" file)
3775 (let ((enable-local-variables nil))
3779 (defun gnus-group-fetch-charter (group)
3780 "Fetch the charter for the current group.
3781 If given a prefix argument, prompt for a group."
3783 (list (or (when current-prefix-arg
3784 (completing-read "Group: " gnus-active-hashtb))
3785 (gnus-group-group-name)
3786 gnus-newsgroup-name)))
3788 (error "No group name given"))
3790 (condition-case nil (require 'url-http) (error nil))
3791 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3793 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3794 (setq hierarchy (match-string 1 name))
3795 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3796 (if (fboundp 'url-http-file-exists-p)
3797 (url-http-file-exists-p (eval url))
3799 (browse-url (eval url))
3800 (setq url (concat "http://" hierarchy
3801 ".news-admin.org/charters/" name))
3802 (if (and (fboundp 'url-http-file-exists-p)
3803 (url-http-file-exists-p url))
3805 (gnus-group-fetch-control group))))))
3807 (defun gnus-group-fetch-control (group)
3808 "Fetch the archived control messages for the current group.
3809 If given a prefix argument, prompt for a group."
3811 (list (or (when current-prefix-arg
3812 (completing-read "Group: " gnus-active-hashtb))
3813 (gnus-group-group-name)
3814 gnus-newsgroup-name)))
3816 (error "No group name given"))
3817 (let ((name (gnus-group-real-name group))
3819 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3820 (setq hierarchy (match-string 1 name))
3821 (if gnus-group-fetch-control-use-browse-url
3822 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3823 hierarchy "/" name ".gz"))
3824 (let ((enable-local-variables nil))
3825 (gnus-group-read-ephemeral-group
3827 `(nndoc ,group (nndoc-address
3828 ,(find-file-noselect
3829 (concat "/ftp@ftp.isc.org:/usenet/control/"
3830 hierarchy "/" name ".gz")))
3831 (nndoc-article-type mbox)) t nil nil))))))
3833 (defun gnus-group-describe-group (force &optional group)
3834 "Display a description of the current newsgroup."
3835 (interactive (list current-prefix-arg (gnus-group-group-name)))
3836 (let* ((method (gnus-find-method-for-group group))
3837 (mname (gnus-group-prefixed-name "" method))
3840 gnus-description-hashtb)
3841 (gnus-sethash mname nil gnus-description-hashtb))
3843 (error "No group name given"))
3844 (when (or (and gnus-description-hashtb
3845 ;; We check whether this group's method has been
3846 ;; queried for a description file.
3847 (gnus-gethash mname gnus-description-hashtb))
3848 (setq desc (gnus-group-get-description group))
3849 (gnus-read-descriptions-file method))
3851 (or desc (gnus-gethash group gnus-description-hashtb)
3852 "No description available")))))
3854 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3855 (defun gnus-group-describe-all-groups (&optional force)
3856 "Pop up a buffer with descriptions of all newsgroups."
3859 (setq gnus-description-hashtb nil))
3860 (when (not (or gnus-description-hashtb
3861 (gnus-read-all-descriptions-files)))
3862 (error "Couldn't request descriptions file"))
3863 (let ((buffer-read-only nil)
3869 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3870 (insert (format " *: %-20s %s\n"
3871 (gnus-group-name-decode
3872 (symbol-name group) charset)
3873 (gnus-group-name-decode
3874 (symbol-value group) charset))))
3875 (gnus-add-text-properties
3876 b (1+ b) (list 'gnus-group group
3877 'gnus-unread t 'gnus-marked nil
3878 'gnus-level (1+ gnus-level-subscribed))))
3879 gnus-description-hashtb)
3880 (goto-char (point-min))
3881 (gnus-group-position-point)))
3883 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3884 (defun gnus-group-apropos (regexp &optional search-description)
3885 "List all newsgroups that have names that match a regexp."
3886 (interactive "sGnus apropos (regexp): ")
3888 (obuf (current-buffer))
3890 ;; Go through all newsgroups that are known to Gnus.
3893 (and (symbol-name group)
3894 (string-match regexp (symbol-name group))
3895 (symbol-value group)
3896 (push (symbol-name group) groups)))
3898 ;; Also go through all descriptions that are known to Gnus.
3899 (when search-description
3902 (and (string-match regexp (symbol-value group))
3903 (push (symbol-name group) groups)))
3904 gnus-description-hashtb))
3906 (gnus-message 3 "No groups matched \"%s\"." regexp)
3907 ;; Print out all the groups.
3909 (pop-to-buffer "*Gnus Help*")
3910 (buffer-disable-undo)
3912 (setq groups (sort groups 'string<))
3914 ;; Groups may be entered twice into the list of groups.
3915 (when (not (string= (car groups) prev))
3916 (setq prev (car groups))
3917 (let ((charset (gnus-group-name-charset nil prev)))
3918 (insert (gnus-group-name-decode prev charset) "\n")
3919 (when (and gnus-description-hashtb
3920 (setq des (gnus-gethash (car groups)
3921 gnus-description-hashtb)))
3922 (insert " " (gnus-group-name-decode des charset) "\n"))))
3923 (setq groups (cdr groups)))
3924 (goto-char (point-min))))
3925 (pop-to-buffer obuf)))
3927 (defun gnus-group-description-apropos (regexp)
3928 "List all newsgroups that have names or descriptions that match REGEXP."
3929 (interactive "sGnus description apropos (regexp): ")
3930 (when (not (or gnus-description-hashtb
3931 (gnus-read-all-descriptions-files)))
3932 (error "Couldn't request descriptions file"))
3933 (gnus-group-apropos regexp t))
3935 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3936 (defun gnus-group-list-matching (level regexp &optional all lowest)
3937 "List all groups with unread articles that match REGEXP.
3938 If the prefix LEVEL is non-nil, it should be a number that says which
3939 level to cut off listing groups.
3940 If ALL, also list groups with no unread articles.
3941 If LOWEST, don't list groups with level lower than LOWEST.
3943 This command may read the active file."
3944 (interactive "P\nsList newsgroups matching: ")
3945 ;; First make sure active file has been read.
3947 (> (prefix-numeric-value level) gnus-level-killed))
3948 (gnus-get-killed-groups))
3949 (funcall gnus-group-prepare-function
3950 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3951 (goto-char (point-min))
3952 (gnus-group-position-point))
3954 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3955 "List all groups that match REGEXP.
3956 If the prefix LEVEL is non-nil, it should be a number that says which
3957 level to cut off listing groups.
3958 If LOWEST, don't list groups with level lower than LOWEST."
3959 (interactive "P\nsList newsgroups matching: ")
3961 (setq level (prefix-numeric-value level)))
3962 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3964 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3965 (defun gnus-group-save-newsrc (&optional force)
3966 "Save the Gnus startup files.
3967 If FORCE, force saving whether it is necessary or not."
3969 (gnus-save-newsrc-file force))
3971 (defun gnus-group-restart (&optional arg)
3972 "Force Gnus to read the .newsrc file."
3974 (when (gnus-yes-or-no-p
3975 (format "Are you sure you want to restart Gnus? "))
3976 (gnus-save-newsrc-file)
3980 (defun gnus-group-read-init-file ()
3981 "Read the Gnus elisp init file."
3983 (gnus-read-init-file)
3984 (gnus-message 5 "Read %s" gnus-init-file))
3986 (defun gnus-group-check-bogus-groups (&optional silent)
3987 "Check bogus newsgroups.
3988 If given a prefix, don't ask for confirmation before removing a bogus
3991 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3992 (gnus-group-list-groups))
3994 (defun gnus-group-find-new-groups (&optional arg)
3995 "Search for new groups and add them.
3996 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3997 With 1 C-u, use the `ask-server' method to query the server for new
3999 With 2 C-u's, use most complete method possible to query the server
4000 for new groups, and subscribe the new groups as zombies."
4002 (gnus-find-new-newsgroups (or arg 1))
4003 (gnus-group-list-groups))
4005 (defun gnus-group-edit-global-kill (&optional article group)
4006 "Edit the global kill file.
4007 If GROUP, edit that local kill file instead."
4009 (setq gnus-current-kill-article article)
4010 (gnus-kill-file-edit-file group)
4013 (substitute-command-keys
4014 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4015 (if group "local" "global")))))
4017 (defun gnus-group-edit-local-kill (article group)
4018 "Edit a local kill file."
4019 (interactive (list nil (gnus-group-group-name)))
4020 (gnus-group-edit-global-kill article group))
4022 (defun gnus-group-force-update ()
4023 "Update `.newsrc' file."
4025 (gnus-save-newsrc-file))
4027 (defvar gnus-backlog-articles)
4029 (defun gnus-group-suspend ()
4030 "Suspend the current Gnus session.
4031 In fact, cleanup buffers except for group mode buffer.
4032 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4034 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4035 (gnus-offer-save-summaries)
4036 ;; Kill Gnus buffers except for group mode buffer.
4037 (let ((group-buf (get-buffer gnus-group-buffer)))
4038 (mapcar (lambda (buf)
4039 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4040 (with-current-buffer buf
4041 (eq major-mode 'message-mode)))
4042 (gnus-kill-buffer buf)))
4044 (setq gnus-backlog-articles nil)
4045 (gnus-kill-gnus-frames)
4047 (bury-buffer group-buf)
4048 (delete-windows-on group-buf t))))
4050 (defun gnus-group-clear-dribble ()
4051 "Clear all information from the dribble buffer."
4053 (gnus-dribble-clear)
4054 (gnus-message 7 "Cleared dribble buffer"))
4056 (defun gnus-group-exit ()
4057 "Quit reading news after updating .newsrc.eld and .newsrc.
4058 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4061 (or noninteractive ;For gnus-batch-kill
4062 (not gnus-interactive-exit) ;Without confirmation
4064 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4065 (gnus-run-hooks 'gnus-exit-gnus-hook)
4066 ;; Offer to save data from non-quitted summary buffers.
4067 (gnus-offer-save-summaries)
4068 ;; Save the newsrc file(s).
4069 (gnus-save-newsrc-file)
4071 (gnus-close-backends)
4072 ;; Reset everything.
4074 ;; Allow the user to do things after cleaning up.
4075 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4077 (defun gnus-group-quit ()
4078 "Quit reading news without updating .newsrc.eld or .newsrc.
4079 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4081 (when (or noninteractive ;For gnus-batch-kill
4082 (zerop (buffer-size))
4083 (not (gnus-server-opened gnus-select-method))
4085 (not gnus-current-startup-file)
4087 (format "Quit reading news without saving %s? "
4088 (file-name-nondirectory gnus-current-startup-file))))
4089 (gnus-run-hooks 'gnus-exit-gnus-hook)
4090 (gnus-configure-windows 'group t)
4091 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4092 (not (zerop (save-excursion
4093 (set-buffer gnus-dribble-buffer)
4096 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4098 (gnus-close-backends)
4100 (gnus-kill-buffer gnus-group-buffer)
4101 ;; Allow the user to do things after cleaning up.
4102 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4104 (defun gnus-group-describe-briefly ()
4105 "Give a one line description of the group mode commands."
4107 (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")))
4109 (defun gnus-group-browse-foreign-server (method)
4110 "Browse a foreign news server.
4111 If called interactively, this function will ask for a select method
4112 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4113 If not, METHOD should be a list where the first element is the method
4114 and the second element is the address."
4116 (list (let ((how (completing-read
4118 (append gnus-valid-select-methods gnus-server-alist)
4119 nil t (cons "nntp" 0) 'gnus-method-history)))
4120 ;; We either got a back end name or a virtual server name.
4121 ;; If the first, we also need an address.
4122 (if (assoc how gnus-valid-select-methods)
4124 ;; Suggested by mapjph@bath.ac.uk.
4127 (mapcar 'list gnus-secondary-servers)))
4128 ;; We got a server name.
4130 (gnus-browse-foreign-server method))
4132 (defun gnus-group-set-info (info &optional method-only-group part)
4133 (when (or info part)
4134 (let* ((entry (gnus-group-entry
4135 (or method-only-group (gnus-info-group info))))
4137 (info (if method-only-group (nth 2 entry) info))
4139 (when method-only-group
4141 (error "Trying to change non-existent group %s" method-only-group))
4142 ;; We have received parts of the actual group info - either the
4143 ;; select method or the group parameters. We first check
4144 ;; whether we have to extend the info, and if so, do that.
4145 (let ((len (length info))
4146 (total (if (eq part 'method) 5 6)))
4148 (setcdr (nthcdr (1- len) info)
4149 (make-list (- total len) nil)))
4150 ;; Then we enter the new info.
4151 (setcar (nthcdr (1- total) info) part-info)))
4153 ;; This is a new group, so we just create it.
4155 (set-buffer gnus-group-buffer)
4156 (setq method (gnus-info-method info))
4157 (when (gnus-server-equal method "native")
4160 (set-buffer gnus-group-buffer)
4162 ;; It's a foreign group...
4163 (gnus-group-make-group
4164 (gnus-group-real-name (gnus-info-group info))
4165 (if (stringp method) method
4166 (prin1-to-string (car method)))
4168 (nth 1 (gnus-info-method info))))
4169 ;; It's a native group.
4170 (gnus-group-make-group (gnus-info-group info))))
4171 (gnus-message 6 "Note: New group created")
4173 (gnus-group-entry (gnus-group-prefixed-name
4174 (gnus-group-real-name (gnus-info-group info))
4175 (or (gnus-info-method info) gnus-select-method))))))
4176 ;; Whether it was a new group or not, we now have the entry, so we
4177 ;; can do the update.
4180 (setcar (nthcdr 2 entry) info)
4181 (when (and (not (eq (car entry) t))
4182 (gnus-active (gnus-info-group info)))
4183 (setcar entry (length
4184 (gnus-list-of-unread-articles (car info))))))
4185 (error "No such group: %s" (gnus-info-group info))))))
4187 (defun gnus-group-set-method-info (group select-method)
4188 (gnus-group-set-info select-method group 'method))
4190 (defun gnus-group-set-params-info (group params)
4191 (gnus-group-set-info params group 'params))
4193 (defun gnus-add-marked-articles (group type articles &optional info force)
4194 ;; Add ARTICLES of TYPE to the info of GROUP.
4195 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4196 ;; add, but replace marked articles of TYPE with ARTICLES.
4197 (let ((info (or info (gnus-get-info group)))
4200 (and (not (setq marked (nthcdr 3 info)))
4202 (setcdr (nthcdr 2 info)
4203 (list (list (cons type (gnus-compress-sequence
4205 (and (not (setq m (assq type (car marked))))
4208 (cons (cons type (gnus-compress-sequence articles t) )
4212 (setcar (nthcdr 3 info)
4213 (gnus-delete-alist type (car marked)))
4214 (setcdr m (gnus-compress-sequence articles t)))
4215 (setcdr m (gnus-compress-sequence
4216 (sort (nconc (gnus-uncompress-range (cdr m))
4217 (copy-sequence articles)) '<) t))))))
4219 (defun gnus-add-mark (group mark article)
4220 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4221 (let ((buffer (gnus-summary-buffer-name group)))
4222 (if (gnus-buffer-live-p buffer)
4224 (set-buffer (get-buffer buffer))
4225 (gnus-summary-add-mark article mark))
4226 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4230 ;;; Group timestamps
4233 (defun gnus-group-set-timestamp ()
4234 "Change the timestamp of the current group to the current time.
4235 This function can be used in hooks like `gnus-select-group-hook'
4236 or `gnus-group-catchup-group-hook'."
4237 (when gnus-newsgroup-name
4238 (let ((time (current-time)))
4239 (setcdr (cdr time) nil)
4240 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4242 (defsubst gnus-group-timestamp (group)
4243 "Return the timestamp for GROUP."
4244 (gnus-group-get-parameter group 'timestamp t))
4246 (defun gnus-group-timestamp-delta (group)
4247 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4248 (let* ((time (or (gnus-group-timestamp group)
4250 (delta (subtract-time (current-time) time)))
4251 (+ (* (nth 0 delta) 65536.0)
4254 (defun gnus-group-timestamp-string (group)
4255 "Return a string of the timestamp for GROUP."
4256 (let ((time (gnus-group-timestamp group)))
4259 (gnus-time-iso8601 time))))
4261 (defun gnus-group-list-cached (level &optional lowest)
4262 "List all groups with cached articles.
4263 If the prefix LEVEL is non-nil, it should be a number that says which
4264 level to cut off listing groups.
4265 If LOWEST, don't list groups with level lower than LOWEST.
4267 This command may read the active file."
4270 (setq level (prefix-numeric-value level)))
4271 (when (or (not level) (>= level gnus-level-zombie))
4273 (funcall gnus-group-prepare-function
4274 (or level gnus-level-subscribed)
4276 (let ((marks (gnus-info-marks info)))
4277 (assq 'cache marks)))
4280 (or (gnus-gethash group
4281 gnus-cache-active-hashtb)
4282 ;; Cache active file might use "."
4285 (mapconcat 'identity
4286 (split-string group ":")
4288 gnus-cache-active-hashtb))))
4289 (goto-char (point-min))
4290 (gnus-group-position-point))
4292 (defun gnus-group-list-dormant (level &optional lowest)
4293 "List all groups with dormant articles.
4294 If the prefix LEVEL is non-nil, it should be a number that says which
4295 level to cut off listing groups.
4296 If LOWEST, don't list groups with level lower than LOWEST.
4298 This command may read the active file."
4301 (setq level (prefix-numeric-value level)))
4302 (when (or (not level) (>= level gnus-level-zombie))
4304 (funcall gnus-group-prepare-function
4305 (or level gnus-level-subscribed)
4307 (let ((marks (gnus-info-marks info)))
4308 (assq 'dormant marks)))
4311 (goto-char (point-min))
4312 (gnus-group-position-point))
4314 (defun gnus-group-listed-groups ()
4315 "Return a list of listed groups."
4317 (goto-char (point-min))
4318 (while (setq point (text-property-not-all (point) (point-max)
4321 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4325 (defun gnus-group-list-plus (&optional args)
4326 "List groups plus the current selection."
4328 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4329 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4331 (push last-command-event unread-command-events)
4332 (if (featurep 'xemacs)
4333 (push (make-event 'key-press '(key ?A)) unread-command-events)
4334 (push ?A unread-command-events))
4335 (let (gnus-pick-mode keys)
4336 (setq keys (if (featurep 'xemacs)
4337 (events-to-keys (read-key-sequence nil))
4338 (read-key-sequence nil)))
4339 (setq func (lookup-key (current-local-map) keys)))
4343 (call-interactively func))))
4345 (defun gnus-group-list-flush (&optional args)
4346 "Flush groups from the current selection."
4348 (let ((gnus-group-list-option 'flush))
4349 (gnus-group-list-plus args)))
4351 (defun gnus-group-list-limit (&optional args)
4352 "List groups limited within the current selection."
4354 (let ((gnus-group-list-option 'limit))
4355 (gnus-group-list-plus args)))
4357 (defun gnus-group-mark-article-read (group article)
4358 "Mark ARTICLE read."
4359 (let ((buffer (gnus-summary-buffer-name group))
4360 (mark gnus-read-mark)
4362 (if (get-buffer buffer)
4363 (with-current-buffer buffer
4364 (setq active gnus-newsgroup-active)
4365 (gnus-activate-group group)
4366 (when gnus-newsgroup-prepared
4367 (when (and gnus-newsgroup-auto-expire
4368 (memq mark gnus-auto-expirable-marks))
4369 (setq mark gnus-expirable-mark))
4370 (setq mark (gnus-request-update-mark
4371 group article mark))
4372 (gnus-mark-article-as-read article mark)
4373 (setq gnus-newsgroup-active (gnus-active group))
4375 (setq n (1+ (cdr active)))
4376 (while (<= n (cdr gnus-newsgroup-active))
4377 (unless (eq n article)
4378 (push n gnus-newsgroup-unselected))
4380 (setq gnus-newsgroup-unselected
4381 (nreverse gnus-newsgroup-unselected)))))
4382 (gnus-activate-group group)
4383 (gnus-group-make-articles-read group (list article))
4384 (when (gnus-group-auto-expirable-p group)
4385 (gnus-add-marked-articles
4386 group 'expire (list article))))))
4388 (provide 'gnus-group)
4390 ;;; gnus-group.el ends here