1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (unless (boundp 'gnus-cache-active-hashtb)
49 (defvar gnus-cache-active-hashtb nil)))
51 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
52 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54 (defcustom gnus-group-archive-directory
55 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
56 "*The address of the (ding) archives."
57 :group 'gnus-group-foreign
60 (defcustom gnus-group-recent-archive-directory
61 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
62 "*The address of the most recent (ding) articles."
63 :group 'gnus-group-foreign
66 (defcustom gnus-no-groups-message "No Gnus is good news"
67 "*Message displayed by Gnus when no groups are available."
71 (defcustom gnus-keep-same-level nil
72 "*Non-nil means that the next newsgroup after the current will be on the same level.
73 When you type, for instance, `n' after reading the last article in the
74 current newsgroup, you will go to the next newsgroup. If this variable
75 is nil, the next newsgroup will be the next from the group
77 If this variable is non-nil, Gnus will either put you in the
78 next newsgroup with the same level, or, if no such newsgroup is
79 available, the next newsgroup with the lowest possible level higher
80 than the current level.
81 If this variable is `best', Gnus will make the next newsgroup the one
83 :group 'gnus-group-levels
84 :type '(choice (const nil)
86 (sexp :tag "other" t)))
88 (defcustom gnus-group-goto-unread t
89 "*If non-nil, movement commands will go to the next unread and subscribed group."
90 :link '(custom-manual "(gnus)Group Maneuvering")
91 :group 'gnus-group-various
94 (defcustom gnus-goto-next-group-when-activating t
95 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
96 :link '(custom-manual "(gnus)Scanning New Messages")
97 :group 'gnus-group-various
100 (defcustom gnus-permanently-visible-groups nil
101 "*Regexp to match groups that should always be listed in the group buffer.
102 This means that they will still be listed even when there are no
103 unread articles in the groups.
105 If nil, no groups are permanently visible."
106 :group 'gnus-group-listing
107 :type '(choice regexp (const nil)))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "*If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "*Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
121 (defcustom gnus-group-list-inactive-groups t
122 "*If non-nil, inactive groups will be listed."
123 :group 'gnus-group-listing
124 :group 'gnus-group-levels
127 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
128 "*Function used for sorting the group buffer.
129 This function will be called with group info entries as the arguments
130 for the groups to be sorted. Pre-made functions include
131 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
132 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
133 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
134 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136 This variable can also be a list of sorting functions. In that case,
137 the most significant sort function should be the last function in the
139 :group 'gnus-group-listing
140 :link '(custom-manual "(gnus)Sorting Groups")
141 :type '(repeat :value-to-internal (lambda (widget value)
142 (if (listp value) value (list value)))
143 :match (lambda (widget value)
145 (widget-editable-list-match widget value)))
146 (choice (function-item gnus-group-sort-by-alphabet)
147 (function-item gnus-group-sort-by-real-name)
148 (function-item gnus-group-sort-by-unread)
149 (function-item gnus-group-sort-by-level)
150 (function-item gnus-group-sort-by-score)
151 (function-item gnus-group-sort-by-method)
152 (function-item gnus-group-sort-by-server)
153 (function-item gnus-group-sort-by-rank)
154 (function :tag "other" nil))))
156 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
157 "*Format of group lines.
158 It works along the same lines as a normal formatting string,
159 with some simple extensions.
161 %M Only marked articles (character, \"*\" or \" \")
162 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
163 %L Level of subscribedness (integer)
164 %N Number of unread articles (integer)
165 %I Number of dormant articles (integer)
166 %i Number of ticked and dormant (integer)
167 %T Number of ticked articles (integer)
168 %R Number of read articles (integer)
169 %U Number of unseen articles (integer)
170 %t Estimated total number of articles (integer)
171 %y Number of unread, unticked articles (integer)
172 %G Group name (string)
173 %g Qualified group name (string)
174 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
175 %C Group comment (string)
176 %D Group description (string)
177 %s Select method (string)
178 %o Moderated group (char, \"m\")
179 %p Process mark (char)
180 %B Whether a summary buffer for the group is open (char, \"*\")
181 %O Moderated group (string, \"(m)\" or \"\")
182 %P Topic indentation (string)
183 %m Whether there is new(ish) mail in the group (char, \"%\")
184 %n Select from where (string)
185 %z A string that look like `<%s:%n>' if a foreign select method is used
186 %d The date the group was last entered.
187 %E Icon as defined by `gnus-group-icon-list'.
188 %F The disk space used by the articles fetched by both the cache and agent.
189 %u User defined specifier. The next character in the format string should
190 be a letter. Gnus will call the function gnus-user-format-function-X,
191 where X is the letter following %u. The function will be passed a
192 single dummy parameter as argument. The function should return a
193 string, which will be inserted into the buffer just like information
194 from any other group specifier.
196 Note that this format specification is not always respected. For
197 reasons of efficiency, when listing killed groups, this specification
198 is ignored altogether. If the spec is changed considerably, your
199 output may end up looking strange when listing both alive and killed
202 If you use %o or %O, reading the active file will be slower and quite
203 a bit of extra memory will be used. %D and %F will also worsen
204 performance. Also note that if you change the format specification to
205 include any of these specs, you must probably re-start Gnus to see
208 General format specifiers can also be used.
209 See Info node `(gnus)Formatting Variables'."
210 :link '(custom-manual "(gnus)Formatting Variables")
211 :group 'gnus-group-visual
214 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
215 "*The format specification for the group mode line.
216 It works along the same lines as a normal formatting string,
217 with some simple extensions:
219 %S The native news server.
220 %M The native select method.
221 %: \":\" if %S isn't \"\"."
222 :group 'gnus-group-visual
225 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
226 (when (featurep 'xemacs)
227 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
230 (defcustom gnus-group-menu-hook nil
231 "Hook run after the creation of the group mode menu."
232 :group 'gnus-group-various
235 (defcustom gnus-group-catchup-group-hook nil
236 "Hook run when catching up a group from the group buffer."
237 :group 'gnus-group-various
238 :link '(custom-manual "(gnus)Group Data")
241 (defcustom gnus-group-update-group-hook nil
242 "Hook called when updating group lines."
243 :group 'gnus-group-visual
246 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
247 "*A function that is called to generate the group buffer.
248 The function is called with three arguments: The first is a number;
249 all group with a level less or equal to that number should be listed,
250 if the second is non-nil, empty groups should also be displayed. If
251 the third is non-nil, it is a number. No groups with a level lower
252 than this number should be displayed.
254 The only current function implemented is `gnus-group-prepare-flat'."
255 :group 'gnus-group-listing
258 (defcustom gnus-group-prepare-hook nil
259 "Hook called after the group buffer has been generated.
260 If you want to modify the group buffer, you can use this hook."
261 :group 'gnus-group-listing
264 (defcustom gnus-suspend-gnus-hook nil
265 "Hook called when suspending (not exiting) Gnus."
269 (defcustom gnus-exit-gnus-hook nil
270 "Hook called when exiting Gnus."
274 (defcustom gnus-after-exiting-gnus-hook nil
275 "Hook called after exiting Gnus."
279 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
280 "Hook called when a group line is changed.
281 The hook will not be called if `gnus-visual' is nil.
283 The default function `gnus-group-highlight-line' will
284 highlight the line according to the `gnus-group-highlight'
286 :group 'gnus-group-visual
289 (defcustom gnus-useful-groups
290 '(("(ding) mailing list mirrored at sunsite.auc.dk"
292 (nntp "sunsite.auc.dk"
293 (nntp-address "sunsite.auc.dk")))
296 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
300 (nndoc-article-type mbox)
301 (eval `(nndoc-address
302 ,(let ((file (nnheader-find-etc-directory
305 (error "Couldn't find doc group"))
307 "*Alist of useful group-server pairs."
308 :group 'gnus-group-listing
309 :type '(repeat (list (string :tag "Description")
311 (sexp :tag "Method"))))
313 (defcustom gnus-group-highlight
315 ((and mailp (= unread 0) (eq level 1)) .
316 gnus-group-mail-1-empty-face)
317 ((and mailp (eq level 1)) .
318 gnus-group-mail-1-face)
319 ((and mailp (= unread 0) (eq level 2)) .
320 gnus-group-mail-2-empty-face)
321 ((and mailp (eq level 2)) .
322 gnus-group-mail-2-face)
323 ((and mailp (= unread 0) (eq level 3)) .
324 gnus-group-mail-3-empty-face)
325 ((and mailp (eq level 3)) .
326 gnus-group-mail-3-face)
327 ((and mailp (= unread 0)) .
328 gnus-group-mail-low-empty-face)
330 gnus-group-mail-low-face)
332 ((and (= unread 0) (eq level 1)) .
333 gnus-group-news-1-empty-face)
334 ((and (eq level 1)) .
335 gnus-group-news-1-face)
336 ((and (= unread 0) (eq level 2)) .
337 gnus-group-news-2-empty-face)
338 ((and (eq level 2)) .
339 gnus-group-news-2-face)
340 ((and (= unread 0) (eq level 3)) .
341 gnus-group-news-3-empty-face)
342 ((and (eq level 3)) .
343 gnus-group-news-3-face)
344 ((and (= unread 0) (eq level 4)) .
345 gnus-group-news-4-empty-face)
346 ((and (eq level 4)) .
347 gnus-group-news-4-face)
348 ((and (= unread 0) (eq level 5)) .
349 gnus-group-news-5-empty-face)
350 ((and (eq level 5)) .
351 gnus-group-news-5-face)
352 ((and (= unread 0) (eq level 6)) .
353 gnus-group-news-6-empty-face)
354 ((and (eq level 6)) .
355 gnus-group-news-6-face)
356 ((and (= unread 0)) .
357 gnus-group-news-low-empty-face)
359 gnus-group-news-low-face))
360 "*Controls the highlighting of group buffer lines.
362 Below is a list of `Form'/`Face' pairs. When deciding how a a
363 particular group line should be displayed, each form is
364 evaluated. The content of the face field after the first true form is
365 used. You can change how those group lines are displayed by
366 editing the face field.
368 It is also possible to change and add form fields, but currently that
369 requires an understanding of Lisp expressions. Hopefully this will
370 change in a future release. For now, you can use the following
371 variables in the Lisp expression:
373 group: The name of the group.
374 unread: The number of unread articles in the group.
375 method: The select method used.
376 mailp: Whether it's a mail group or not.
377 level: The level of the group.
378 score: The score of the group.
379 ticked: The number of ticked articles."
380 :group 'gnus-group-visual
381 :type '(repeat (cons (sexp :tag "Form") face)))
383 (defcustom gnus-new-mail-mark ?%
384 "Mark used for groups with new mail."
385 :group 'gnus-group-visual
388 (defgroup gnus-group-icons nil
389 "Add Icons to your group buffer. "
390 :group 'gnus-group-visual)
392 (defcustom gnus-group-icon-list
394 "*Controls the insertion of icons into group buffer lines.
396 Below is a list of `Form'/`File' pairs. When deciding how a
397 particular group line should be displayed, each form is evaluated.
398 The icon from the file field after the first true form is used. You
399 can change how those group lines are displayed by editing the file
400 field. The File will either be found in the
401 `gnus-group-glyph-directory' or by designating absolute name of the
404 It is also possible to change and add form fields, but currently that
405 requires an understanding of Lisp expressions. Hopefully this will
406 change in a future release. For now, you can use the following
407 variables in the Lisp expression:
409 group: The name of the group.
410 unread: The number of unread articles in the group.
411 method: The select method used.
412 mailp: Whether it's a mail group or not.
413 newsp: Whether it's a news group or not
414 level: The level of the group.
415 score: The score of the group.
416 ticked: The number of ticked articles."
417 :group 'gnus-group-icons
418 :type '(repeat (cons (sexp :tag "Form") file)))
420 (defcustom gnus-group-name-charset-method-alist nil
421 "Alist of method and the charset for group names.
424 (((nntp \"news.com.cn\") . cn-gb-2312))"
427 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
429 (defcustom gnus-group-name-charset-group-alist
430 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
431 (mm-coding-system-p 'utf-8))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
444 If non-nil, the value should be a string or an alist. If it is a string,
445 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
446 nnml:\" in the minibuffer prompt.
448 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
449 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
450 used when no prefix argument is given to `gnus-group-jump-to-group'."
452 :group 'gnus-group-various
453 :type '(choice (string :tag "Prompt string")
454 (const :tag "Empty" nil)
455 (repeat (cons (integer :tag "Argument")
456 (string :tag "Prompt string")))))
458 (defvar gnus-group-listing-limit 1000
459 "*A limit of the number of groups when listing.
460 If the number of groups is larger than the limit, list them in a
463 ;;; Internal variables
465 (defvar gnus-group-is-exiting-p nil)
466 (defvar gnus-group-is-exiting-without-update-p nil)
467 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
468 "Function for sorting the group buffer.")
470 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
471 "Function for sorting the selected groups in the group buffer.")
473 (defvar gnus-group-indentation-function nil)
474 (defvar gnus-goto-missing-group-function nil)
475 (defvar gnus-group-update-group-function nil)
476 (defvar gnus-group-goto-next-group-function nil
477 "Function to override finding the next group after listing groups.")
479 (defvar gnus-group-edit-buffer nil)
481 (defvar gnus-group-line-format-alist
482 `((?M gnus-tmp-marked-mark ?c)
483 (?S gnus-tmp-subscribed ?c)
484 (?L gnus-tmp-level ?d)
485 (?N (cond ((eq number t) "*" )
489 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
490 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
492 (?R gnus-tmp-number-of-read ?s)
493 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
494 (?t gnus-tmp-number-total ?d)
495 (?y gnus-tmp-number-of-unread ?s)
496 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
497 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
498 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
499 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
500 (?g gnus-tmp-group ?s)
501 (?G gnus-tmp-qualified-group ?s)
502 (?c (gnus-short-group-name gnus-tmp-group) ?s)
503 (?C gnus-tmp-comment ?s)
504 (?D gnus-tmp-newsgroup-description ?s)
505 (?o gnus-tmp-moderated ?c)
506 (?O gnus-tmp-moderated-string ?s)
507 (?p gnus-tmp-process-marked ?c)
508 (?s gnus-tmp-news-server ?s)
509 (?n ,(if (featurep 'xemacs)
510 '(symbol-name gnus-tmp-news-method)
511 'gnus-tmp-news-method)
513 (?P gnus-group-indentation ?s)
514 (?E gnus-tmp-group-icon ?s)
515 (?B gnus-tmp-summary-live ?c)
516 (?z gnus-tmp-news-method-string ?s)
517 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
518 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
519 (?u gnus-tmp-user-defined ?s)
520 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
523 (defvar gnus-group-mode-line-format-alist
524 `((?S gnus-tmp-news-server ?s)
525 (?M gnus-tmp-news-method ?s)
526 (?u gnus-tmp-user-defined ?s)
527 (?: gnus-tmp-colon ?s)))
529 (defvar gnus-topic-topology nil
530 "The complete topic hierarchy.")
532 (defvar gnus-topic-alist nil
533 "The complete topic-group alist.")
535 (defvar gnus-group-marked nil)
537 (defvar gnus-group-list-mode nil)
540 (defvar gnus-group-icon-cache nil)
542 (defvar gnus-group-listed-groups nil)
543 (defvar gnus-group-list-option nil)
549 (put 'gnus-group-mode 'mode-class 'special)
551 (gnus-define-keys gnus-group-mode-map
552 " " gnus-group-read-group
553 "=" gnus-group-select-group
554 "\r" gnus-group-select-group
555 "\M-\r" gnus-group-quick-select-group
556 "\M- " gnus-group-visible-select-group
557 [(meta control return)] gnus-group-select-group-ephemerally
558 "j" gnus-group-jump-to-group
559 "n" gnus-group-next-unread-group
560 "p" gnus-group-prev-unread-group
561 "\177" gnus-group-prev-unread-group
562 [delete] gnus-group-prev-unread-group
563 [backspace] gnus-group-prev-unread-group
564 "N" gnus-group-next-group
565 "P" gnus-group-prev-group
566 "\M-n" gnus-group-next-unread-group-same-level
567 "\M-p" gnus-group-prev-unread-group-same-level
568 "," gnus-group-best-unread-group
569 "." gnus-group-first-unread-group
570 "u" gnus-group-unsubscribe-current-group
571 "U" gnus-group-unsubscribe-group
572 "c" gnus-group-catchup-current
573 "C" gnus-group-catchup-current-all
574 "\M-c" gnus-group-clear-data
575 "l" gnus-group-list-groups
576 "L" gnus-group-list-all-groups
579 "g" gnus-group-get-new-news
580 "\M-g" gnus-group-get-new-news-this-group
581 "R" gnus-group-restart
582 "r" gnus-group-read-init-file
583 "B" gnus-group-browse-foreign-server
584 "b" gnus-group-check-bogus-groups
585 "F" gnus-group-find-new-groups
586 "\C-c\C-d" gnus-group-describe-group
587 "\M-d" gnus-group-describe-all-groups
588 "\C-c\C-a" gnus-group-apropos
589 "\C-c\M-\C-a" gnus-group-description-apropos
590 "a" gnus-group-post-news
591 "\ek" gnus-group-edit-local-kill
592 "\eK" gnus-group-edit-global-kill
593 "\C-k" gnus-group-kill-group
594 "\C-y" gnus-group-yank-group
595 "\C-w" gnus-group-kill-region
596 "\C-x\C-t" gnus-group-transpose-groups
597 "\C-c\C-l" gnus-group-list-killed
598 "\C-c\C-x" gnus-group-expire-articles
599 "\C-c\M-\C-x" gnus-group-expire-all-groups
601 "s" gnus-group-save-newsrc
602 "z" gnus-group-suspend
605 "?" gnus-group-describe-briefly
606 "\C-c\C-i" gnus-info-find-node
607 "\M-e" gnus-group-edit-group-method
608 "^" gnus-group-enter-server-mode
609 gnus-mouse-2 gnus-mouse-pick-group
610 "<" beginning-of-buffer
613 "\C-c\C-s" gnus-group-sort-groups
615 "\C-c\M-g" gnus-activate-all-groups
616 "\M-&" gnus-group-universal-argument
617 "#" gnus-group-mark-group
618 "\M-#" gnus-group-unmark-group)
620 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
621 "m" gnus-group-mark-group
622 "u" gnus-group-unmark-group
623 "w" gnus-group-mark-region
624 "b" gnus-group-mark-buffer
625 "r" gnus-group-mark-regexp
626 "U" gnus-group-unmark-all-groups)
628 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
629 "u" gnus-sieve-update
630 "g" gnus-sieve-generate)
632 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
633 "d" gnus-group-make-directory-group
634 "h" gnus-group-make-help-group
635 "u" gnus-group-make-useful-group
636 "a" gnus-group-make-archive-group
637 "k" gnus-group-make-kiboze-group
638 "l" gnus-group-nnimap-edit-acl
639 "m" gnus-group-make-group
640 "E" gnus-group-edit-group
641 "e" gnus-group-edit-group-method
642 "p" gnus-group-edit-group-parameters
643 "v" gnus-group-add-to-virtual
644 "V" gnus-group-make-empty-virtual
645 "D" gnus-group-enter-directory
646 "f" gnus-group-make-doc-group
647 "w" gnus-group-make-web-group
648 "M" gnus-group-read-ephemeral-group
649 "r" gnus-group-rename-group
650 "R" gnus-group-make-rss-group
651 "c" gnus-group-customize
652 "x" gnus-group-nnimap-expunge
653 "\177" gnus-group-delete-group
654 [delete] gnus-group-delete-group)
656 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
657 "b" gnus-group-brew-soup
658 "w" gnus-soup-save-areas
659 "s" gnus-soup-send-replies
660 "p" gnus-soup-pack-packet
661 "r" nnsoup-pack-replies)
663 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
664 "s" gnus-group-sort-groups
665 "a" gnus-group-sort-groups-by-alphabet
666 "u" gnus-group-sort-groups-by-unread
667 "l" gnus-group-sort-groups-by-level
668 "v" gnus-group-sort-groups-by-score
669 "r" gnus-group-sort-groups-by-rank
670 "m" gnus-group-sort-groups-by-method
671 "n" gnus-group-sort-groups-by-real-name)
673 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
674 "s" gnus-group-sort-selected-groups
675 "a" gnus-group-sort-selected-groups-by-alphabet
676 "u" gnus-group-sort-selected-groups-by-unread
677 "l" gnus-group-sort-selected-groups-by-level
678 "v" gnus-group-sort-selected-groups-by-score
679 "r" gnus-group-sort-selected-groups-by-rank
680 "m" gnus-group-sort-selected-groups-by-method
681 "n" gnus-group-sort-selected-groups-by-real-name)
683 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
684 "k" gnus-group-list-killed
685 "z" gnus-group-list-zombies
686 "s" gnus-group-list-groups
687 "u" gnus-group-list-all-groups
688 "A" gnus-group-list-active
689 "a" gnus-group-apropos
690 "d" gnus-group-description-apropos
691 "m" gnus-group-list-matching
692 "M" gnus-group-list-all-matching
693 "l" gnus-group-list-level
694 "c" gnus-group-list-cached
695 "?" gnus-group-list-dormant)
697 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
698 "k" gnus-group-list-limit
699 "z" gnus-group-list-limit
700 "s" gnus-group-list-limit
701 "u" gnus-group-list-limit
702 "A" gnus-group-list-limit
703 "m" gnus-group-list-limit
704 "M" gnus-group-list-limit
705 "l" gnus-group-list-limit
706 "c" gnus-group-list-limit
707 "?" gnus-group-list-limit)
709 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
710 "k" gnus-group-list-flush
711 "z" gnus-group-list-flush
712 "s" gnus-group-list-flush
713 "u" gnus-group-list-flush
714 "A" gnus-group-list-flush
715 "m" gnus-group-list-flush
716 "M" gnus-group-list-flush
717 "l" gnus-group-list-flush
718 "c" gnus-group-list-flush
719 "?" gnus-group-list-flush)
721 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
722 "k" gnus-group-list-plus
723 "z" gnus-group-list-plus
724 "s" gnus-group-list-plus
725 "u" gnus-group-list-plus
726 "A" gnus-group-list-plus
727 "m" gnus-group-list-plus
728 "M" gnus-group-list-plus
729 "l" gnus-group-list-plus
730 "c" gnus-group-list-plus
731 "?" gnus-group-list-plus)
733 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
734 "f" gnus-score-flush-cache
735 "e" gnus-score-edit-all-score)
737 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
738 "c" gnus-group-fetch-charter
739 "C" gnus-group-fetch-control
740 "d" gnus-group-describe-group
741 "f" gnus-group-fetch-faq
744 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
745 "l" gnus-group-set-current-level
746 "t" gnus-group-unsubscribe-current-group
747 "s" gnus-group-unsubscribe-group
748 "k" gnus-group-kill-group
749 "y" gnus-group-yank-group
750 "w" gnus-group-kill-region
751 "\C-k" gnus-group-kill-level
752 "z" gnus-group-kill-all-zombies)
754 (defun gnus-topic-mode-p ()
755 "Return non-nil in `gnus-topic-mode'."
756 (and (boundp 'gnus-topic-mode)
757 (symbol-value 'gnus-topic-mode)))
759 (defun gnus-group-make-menu-bar ()
760 (gnus-turn-off-edit-menu 'group)
761 (unless (boundp 'gnus-group-reading-menu)
764 gnus-group-reading-menu gnus-group-mode-map ""
766 ["Read" gnus-group-read-group
767 :included (not (gnus-topic-mode-p))
768 :active (gnus-group-group-name)]
769 ["Read " gnus-topic-read-group
770 :included (gnus-topic-mode-p)]
771 ["Select" gnus-group-select-group
772 :included (not (gnus-topic-mode-p))
773 :active (gnus-group-group-name)]
774 ["Select " gnus-topic-select-group
775 :included (gnus-topic-mode-p)]
776 ["See old articles" (gnus-group-select-group 'all)
777 :keys "C-u SPC" :active (gnus-group-group-name)]
778 ["Catch up" gnus-group-catchup-current
779 :included (not (gnus-topic-mode-p))
780 :active (gnus-group-group-name)
781 ,@(if (featurep 'xemacs) nil
782 '(:help "Mark unread articles in the current group as read"))]
783 ["Catch up " gnus-topic-catchup-articles
784 :included (gnus-topic-mode-p)
785 ,@(if (featurep 'xemacs) nil
786 '(:help "Mark unread articles in the current group or topic as read"))]
787 ["Catch up all articles" gnus-group-catchup-current-all
788 (gnus-group-group-name)]
789 ["Check for new articles" gnus-group-get-new-news-this-group
790 :included (not (gnus-topic-mode-p))
791 :active (gnus-group-group-name)
792 ,@(if (featurep 'xemacs) nil
793 '(:help "Check for new messages in current group"))]
794 ["Check for new articles " gnus-topic-get-new-news-this-topic
795 :included (gnus-topic-mode-p)
796 ,@(if (featurep 'xemacs) nil
797 '(:help "Check for new messages in current group or topic"))]
798 ["Toggle subscription" gnus-group-unsubscribe-current-group
799 (gnus-group-group-name)]
800 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
801 ,@(if (featurep 'xemacs) nil
802 '(:help "Kill (remove) current group"))]
803 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
804 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
805 ,@(if (featurep 'xemacs) nil
806 '(:help "Display description of the current group"))]
807 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
808 ["Fetch charter" gnus-group-fetch-charter
809 :active (gnus-group-group-name)
810 ,@(if (featurep 'xemacs) nil
811 '(:help "Display the charter of the current group"))]
812 ["Fetch control message" gnus-group-fetch-control
813 :active (gnus-group-group-name)
814 ,@(if (featurep 'xemacs) nil
815 '(:help "Display the archived control message for the current group"))]
816 ;; Actually one should check, if any of the marked groups gives t for
817 ;; (gnus-check-backend-function 'request-expire-articles ...)
818 ["Expire articles" gnus-group-expire-articles
819 :included (not (gnus-topic-mode-p))
820 :active (or (and (gnus-group-group-name)
821 (gnus-check-backend-function
822 'request-expire-articles
823 (gnus-group-group-name))) gnus-group-marked)]
824 ["Expire articles " gnus-topic-expire-articles
825 :included (gnus-topic-mode-p)]
826 ["Set group level..." gnus-group-set-current-level
827 (gnus-group-group-name)]
828 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
829 ["Customize" gnus-group-customize (gnus-group-group-name)]
831 ["Parameters" gnus-group-edit-group-parameters
832 :included (not (gnus-topic-mode-p))
833 :active (gnus-group-group-name)]
834 ["Parameters " gnus-topic-edit-parameters
835 :included (gnus-topic-mode-p)]
836 ["Select method" gnus-group-edit-group-method
837 (gnus-group-group-name)]
838 ["Info" gnus-group-edit-group (gnus-group-group-name)]
839 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
840 ["Global kill file" gnus-group-edit-global-kill t])))
843 gnus-group-group-menu gnus-group-mode-map ""
846 ["List unread subscribed groups" gnus-group-list-groups t]
847 ["List (un)subscribed groups" gnus-group-list-all-groups t]
848 ["List killed groups" gnus-group-list-killed gnus-killed-list]
849 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
850 ["List level..." gnus-group-list-level t]
851 ["Describe all groups" gnus-group-describe-all-groups t]
852 ["Group apropos..." gnus-group-apropos t]
853 ["Group and description apropos..." gnus-group-description-apropos t]
854 ["List groups matching..." gnus-group-list-matching t]
855 ["List all groups matching..." gnus-group-list-all-matching t]
856 ["List active file" gnus-group-list-active t]
857 ["List groups with cached" gnus-group-list-cached t]
858 ["List groups with dormant" gnus-group-list-dormant t])
860 ["Default sort" gnus-group-sort-groups t]
861 ["Sort by method" gnus-group-sort-groups-by-method t]
862 ["Sort by rank" gnus-group-sort-groups-by-rank t]
863 ["Sort by score" gnus-group-sort-groups-by-score t]
864 ["Sort by level" gnus-group-sort-groups-by-level t]
865 ["Sort by unread" gnus-group-sort-groups-by-unread t]
866 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
867 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
868 ("Sort process/prefixed"
869 ["Default sort" gnus-group-sort-selected-groups
870 (not (gnus-topic-mode-p))]
871 ["Sort by method" gnus-group-sort-selected-groups-by-method
872 (not (gnus-topic-mode-p))]
873 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
874 (not (gnus-topic-mode-p))]
875 ["Sort by score" gnus-group-sort-selected-groups-by-score
876 (not (gnus-topic-mode-p))]
877 ["Sort by level" gnus-group-sort-selected-groups-by-level
878 (not (gnus-topic-mode-p))]
879 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
880 (not (gnus-topic-mode-p))]
881 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
882 (not (gnus-topic-mode-p))]
883 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
884 (not (gnus-topic-mode-p))])
886 ["Mark group" gnus-group-mark-group
887 (and (gnus-group-group-name)
888 (not (memq (gnus-group-group-name) gnus-group-marked)))]
889 ["Unmark group" gnus-group-unmark-group
890 (and (gnus-group-group-name)
891 (memq (gnus-group-group-name) gnus-group-marked))]
892 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
893 ["Mark regexp..." gnus-group-mark-regexp t]
894 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
895 ["Mark buffer" gnus-group-mark-buffer t]
896 ["Execute command" gnus-group-universal-argument
897 (or gnus-group-marked (gnus-group-group-name))])
899 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
900 ["Kill all newsgroups in region" gnus-group-kill-region
901 :active (gnus-mark-active-p)]
902 ["Kill all zombie groups" gnus-group-kill-all-zombies
904 ["Kill all groups on level..." gnus-group-kill-level t])
906 ["Make a foreign group..." gnus-group-make-group t]
907 ["Add a directory group..." gnus-group-make-directory-group t]
908 ["Add the help group" gnus-group-make-help-group t]
909 ["Add the archive group" gnus-group-make-archive-group t]
910 ["Make a doc group..." gnus-group-make-doc-group t]
911 ["Make a web group..." gnus-group-make-web-group t]
912 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
913 ["Make a virtual group..." gnus-group-make-empty-virtual t]
914 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
915 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
916 ["Make an RSS group..." gnus-group-make-rss-group t]
917 ["Rename group..." gnus-group-rename-group
918 (gnus-check-backend-function
919 'request-rename-group (gnus-group-group-name))]
920 ["Delete group" gnus-group-delete-group
921 (gnus-check-backend-function
922 'request-delete-group (gnus-group-group-name))])
924 ["Next" gnus-group-next-group t]
925 ["Previous" gnus-group-prev-group t]
926 ["Next unread" gnus-group-next-unread-group t]
927 ["Previous unread" gnus-group-prev-unread-group t]
928 ["Next unread same level" gnus-group-next-unread-group-same-level t]
929 ["Previous unread same level"
930 gnus-group-prev-unread-group-same-level t]
931 ["Jump to group..." gnus-group-jump-to-group t]
932 ["First unread group" gnus-group-first-unread-group t]
933 ["Best unread group" gnus-group-best-unread-group t])
935 ["Generate" gnus-sieve-generate t]
936 ["Generate and update" gnus-sieve-update t])
937 ["Delete bogus groups" gnus-group-check-bogus-groups t]
938 ["Find new newsgroups" gnus-group-find-new-groups t]
939 ["Transpose" gnus-group-transpose-groups
940 (gnus-group-group-name)]
941 ["Read a directory as a group..." gnus-group-enter-directory t]))
944 gnus-group-misc-menu gnus-group-mode-map ""
947 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
948 ["Send replies" gnus-soup-send-replies
949 (fboundp 'gnus-soup-pack-packet)]
950 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
951 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
952 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
953 ["Send a mail" gnus-group-mail t]
954 ["Send a message (mail or news)" gnus-group-post-news t]
955 ["Create a local message" gnus-group-news t]
956 ["Check for new news" gnus-group-get-new-news
957 ,@(if (featurep 'xemacs) '(t)
958 '(:help "Get newly arrived articles"))
960 ["Send queued messages" gnus-delay-send-queue
961 ,@(if (featurep 'xemacs) '(t)
962 '(:help "Send all messages that are scheduled to be sent now"))
964 ["Activate all groups" gnus-activate-all-groups t]
965 ["Restart Gnus" gnus-group-restart t]
966 ["Read init file" gnus-group-read-init-file t]
967 ["Browse foreign server..." gnus-group-browse-foreign-server t]
968 ["Enter server buffer" gnus-group-enter-server-mode t]
969 ["Expire all expirable articles" gnus-group-expire-all-groups t]
970 ["Generate any kiboze groups" nnkiboze-generate-groups t]
971 ["Gnus version" gnus-version t]
972 ["Save .newsrc files" gnus-group-save-newsrc t]
973 ["Suspend Gnus" gnus-group-suspend t]
974 ["Clear dribble buffer" gnus-group-clear-dribble t]
975 ["Read manual" gnus-info-find-node t]
976 ["Flush score cache" gnus-score-flush-cache t]
977 ["Toggle topics" gnus-topic-mode t]
978 ["Send a bug report" gnus-bug t]
979 ["Exit from Gnus" gnus-group-exit
980 ,@(if (featurep 'xemacs) '(t)
981 '(:help "Quit reading news"))]
982 ["Exit without saving" gnus-group-quit t]))
984 (gnus-run-hooks 'gnus-group-menu-hook)))
986 (defvar gnus-group-toolbar-map nil)
988 ;; Emacs 21 tool bar. Should be no-op otherwise.
989 (defun gnus-group-make-tool-bar ()
991 (condition-case nil (require 'tool-bar) (error nil))
992 (fboundp 'tool-bar-add-item-from-menu)
993 (default-value 'tool-bar-mode)
994 (not gnus-group-toolbar-map))
995 (setq gnus-group-toolbar-map
996 (let ((tool-bar-map (make-sparse-keymap))
997 (load-path (mm-image-load-path)))
998 (tool-bar-add-item-from-menu
999 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1000 (tool-bar-add-item-from-menu
1001 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1002 (tool-bar-add-item-from-menu
1003 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1004 (tool-bar-add-item-from-menu
1005 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1006 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1007 :help "Subscribe to the current group")
1008 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1010 :help "Unsubscribe from the current group")
1011 (tool-bar-add-item-from-menu
1012 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1014 (if gnus-group-toolbar-map
1015 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1017 (defun gnus-group-mode ()
1018 "Major mode for reading news.
1020 All normal editing commands are switched off.
1021 \\<gnus-group-mode-map>
1022 The group buffer lists (some of) the groups available. For instance,
1023 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1024 lists all zombie groups.
1026 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1027 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1029 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1031 The following commands are available:
1033 \\{gnus-group-mode-map}"
1035 (kill-all-local-variables)
1036 (when (gnus-visual-p 'group-menu 'menu)
1037 (gnus-group-make-menu-bar)
1038 (gnus-group-make-tool-bar))
1039 (gnus-simplify-mode-line)
1040 (setq major-mode 'gnus-group-mode)
1041 (setq mode-name "Group")
1042 (gnus-group-set-mode-line)
1043 (setq mode-line-process nil)
1044 (use-local-map gnus-group-mode-map)
1045 (buffer-disable-undo)
1046 (setq truncate-lines t)
1047 (setq buffer-read-only t
1048 show-trailing-whitespace nil)
1049 (gnus-set-default-directory)
1050 (gnus-update-format-specifications nil 'group 'group-mode)
1051 (gnus-update-group-mark-positions)
1056 (gnus-run-hooks 'gnus-group-mode-hook))
1058 (defun gnus-update-group-mark-positions ()
1060 (let ((gnus-process-mark ?\200)
1061 (gnus-group-update-hook nil)
1062 (gnus-group-marked '("dummy.group"))
1063 (gnus-active-hashtb (make-vector 10 0))
1065 (gnus-set-active "dummy.group" '(0 . 0))
1066 (gnus-set-work-buffer)
1067 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1068 (goto-char (point-min))
1069 (setq gnus-group-mark-positions
1070 (list (cons 'process (and (search-forward
1071 (string-as-multibyte "\200") nil t)
1072 (- (point) 2))))))))
1074 (defun gnus-mouse-pick-group (e)
1075 "Enter the group under the mouse pointer."
1078 (gnus-group-read-group nil))
1080 ;; Look at LEVEL and find out what the level is really supposed to be.
1081 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1082 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1083 (defun gnus-group-default-level (&optional level number-or-nil)
1085 (gnus-group-use-permanent-levels
1086 (or (setq gnus-group-use-permanent-levels
1087 (or level (if (numberp gnus-group-use-permanent-levels)
1088 gnus-group-use-permanent-levels
1089 (or gnus-group-default-list-level
1090 gnus-level-subscribed))))
1091 gnus-group-default-list-level gnus-level-subscribed))
1095 (or level gnus-group-default-list-level gnus-level-subscribed))))
1097 (defun gnus-group-setup-buffer ()
1098 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1099 (unless (eq major-mode 'gnus-group-mode)
1102 (gnus-carpal-setup-buffer 'group))))
1104 (defun gnus-group-name-charset (method group)
1106 (setq method (gnus-find-method-for-group group)))
1107 (let ((item (assoc method gnus-group-name-charset-method-alist))
1108 (alist gnus-group-name-charset-group-alist)
1112 (while (setq item (pop alist))
1113 (if (string-match (car item) group)
1115 result (cdr item))))
1118 (defun gnus-group-name-decode (string charset)
1119 ;; Fixme: Don't decode in unibyte mode.
1120 (if (and string charset (featurep 'mule))
1121 (mm-decode-coding-string string charset)
1124 (defun gnus-group-decoded-name (string)
1125 (let ((charset (gnus-group-name-charset nil string)))
1126 (gnus-group-name-decode string charset)))
1128 (defun gnus-group-list-groups (&optional level unread lowest)
1129 "List newsgroups with level LEVEL or lower that have unread articles.
1130 Default is all subscribed groups.
1131 If argument UNREAD is non-nil, groups with no unread articles are also
1134 Also see the `gnus-group-use-permanent-levels' variable."
1136 (list (if current-prefix-arg
1137 (prefix-numeric-value current-prefix-arg)
1139 (gnus-group-default-level nil t)
1140 gnus-group-default-list-level
1141 gnus-level-subscribed))))
1143 (setq level (car gnus-group-list-mode)
1144 unread (cdr gnus-group-list-mode)))
1145 (setq level (gnus-group-default-level level))
1146 (gnus-group-setup-buffer)
1147 (gnus-update-format-specifications nil 'group 'group-mode)
1148 (let ((case-fold-search nil)
1149 (props (text-properties-at (point-at-bol)))
1150 (empty (= (point-min) (point-max)))
1151 (group (gnus-group-group-name))
1153 (set-buffer gnus-group-buffer)
1154 (setq number (funcall gnus-group-prepare-function level unread lowest))
1155 (when (or (and (numberp number)
1157 (zerop (buffer-size)))
1158 ;; No groups in the buffer.
1159 (gnus-message 5 gnus-no-groups-message))
1160 ;; We have some groups displayed.
1161 (goto-char (point-max))
1162 (when (or (not gnus-group-goto-next-group-function)
1163 (not (funcall gnus-group-goto-next-group-function
1167 (goto-char (point-min)))
1169 ;; Go to the first group with unread articles.
1170 (gnus-group-search-forward t))
1172 ;; Find the right group to put point on. If the current group
1173 ;; has disappeared in the new listing, try to find the next
1174 ;; one. If no next one can be found, just leave point at the
1175 ;; first newsgroup in the buffer.
1176 (when (not (gnus-goto-char
1178 (point-min) (point-max)
1179 'gnus-group (gnus-intern-safe
1180 group gnus-active-hashtb))))
1181 (let ((newsrc (cdddr (gnus-group-entry group))))
1183 (not (gnus-goto-char
1185 (point-min) (point-max) 'gnus-group
1187 (caar newsrc) gnus-active-hashtb)))))
1188 (setq newsrc (cdr newsrc)))
1190 (goto-char (point-max))
1191 (forward-line -1)))))))
1192 ;; Adjust cursor point.
1193 (gnus-group-position-point)))
1195 (defun gnus-group-list-level (level &optional all)
1196 "List groups on LEVEL.
1197 If ALL (the prefix), also list groups that have no unread articles."
1198 (interactive "nList groups on level: \nP")
1199 (gnus-group-list-groups level all level))
1201 (defun gnus-group-prepare-logic (group test)
1202 (or (and gnus-group-listed-groups
1203 (null gnus-group-list-option)
1204 (member group gnus-group-listed-groups))
1206 ((null gnus-group-listed-groups) test)
1207 ((null gnus-group-list-option) test)
1208 (t (and (member group gnus-group-listed-groups)
1209 (if (eq gnus-group-list-option 'flush)
1213 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1214 "List all newsgroups with unread articles of level LEVEL or lower.
1215 If PREDICATE is a function, list groups that the function returns non-nil;
1216 if it is t, list groups that have no unread articles.
1217 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1218 If REGEXP is a function, list dead groups that the function returns non-nil;
1219 if it is a string, only list groups matching REGEXP."
1220 (set-buffer gnus-group-buffer)
1221 (let ((buffer-read-only nil)
1222 (newsrc (cdr gnus-newsrc-alist))
1223 (lowest (or lowest 1))
1224 (not-in-list (and gnus-group-listed-groups
1225 (copy-sequence gnus-group-listed-groups)))
1226 info clevel unread group params)
1228 (when (or (< lowest gnus-level-zombie)
1229 gnus-group-listed-groups)
1230 ;; List living groups.
1232 (setq info (car newsrc)
1233 group (gnus-info-group info)
1234 params (gnus-info-params info)
1236 unread (gnus-group-unread group))
1238 (setq not-in-list (delete group not-in-list)))
1239 (when (gnus-group-prepare-logic
1241 (and unread ; This group might be unchecked
1242 (or (not (stringp regexp))
1243 (string-match regexp group))
1244 (<= (setq clevel (gnus-info-level info)) level)
1247 ((functionp predicate)
1248 (funcall predicate info))
1249 (predicate t) ; We list all groups?
1252 (if (eq unread t) ; Unactivated?
1253 gnus-group-list-inactive-groups
1254 ; We list unactivated
1256 ; We list groups with unread articles
1257 (and gnus-list-groups-with-ticked-articles
1258 (cdr (assq 'tick (gnus-info-marks info))))
1259 ; And groups with tickeds
1260 ;; Check for permanent visibility.
1261 (and gnus-permanently-visible-groups
1262 (string-match gnus-permanently-visible-groups
1264 (memq 'visible params)
1265 (cdr (assq 'visible params)))))))
1266 (gnus-group-insert-group-line
1267 group (gnus-info-level info)
1268 (gnus-info-marks info) unread (gnus-info-method info)))))
1270 ;; List dead groups.
1271 (when (or gnus-group-listed-groups
1272 (and (>= level gnus-level-zombie)
1273 (<= lowest gnus-level-zombie)))
1274 (gnus-group-prepare-flat-list-dead
1275 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1276 gnus-level-zombie ?Z
1279 (dolist (group gnus-zombie-list)
1280 (setq not-in-list (delete group not-in-list))))
1281 (when (or gnus-group-listed-groups
1282 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1283 (gnus-group-prepare-flat-list-dead
1286 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1287 gnus-level-killed ?K regexp))
1289 (gnus-group-set-mode-line)
1290 (setq gnus-group-list-mode (cons level predicate))
1291 (gnus-run-hooks 'gnus-group-prepare-hook)
1294 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1295 ;; List zombies and killed lists somewhat faster, which was
1296 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1297 ;; this by ignoring the group format specification altogether.
1299 (if (> (length groups) gnus-group-listing-limit)
1301 (setq group (pop groups))
1302 (when (gnus-group-prepare-logic
1305 (and (stringp regexp) (string-match regexp group))
1306 (and (functionp regexp) (funcall regexp group))))
1307 (gnus-add-text-properties
1308 (point) (prog1 (1+ (point))
1309 (insert " " mark " *: "
1310 (gnus-group-decoded-name group)
1312 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1314 'gnus-level level))))
1316 (setq group (pop groups))
1317 (when (gnus-group-prepare-logic
1320 (and (stringp regexp) (string-match regexp group))
1321 (and (functionp regexp) (funcall regexp group))))
1322 (gnus-group-insert-group-line
1324 (let ((active (gnus-active group)))
1326 (if (zerop (cdr active))
1328 (- (1+ (cdr active)) (car active)))
1330 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1332 (defun gnus-group-update-group-line ()
1333 "Update the current line in the group buffer."
1334 (let* ((buffer-read-only nil)
1335 (group (gnus-group-group-name))
1336 (entry (and group (gnus-group-entry group)))
1337 gnus-group-indentation)
1340 (not (gnus-ephemeral-group-p group))
1342 (concat "(gnus-group-set-info '"
1343 (gnus-prin1-to-string (nth 2 entry))
1345 (setq gnus-group-indentation (gnus-group-group-indentation))
1347 (gnus-group-insert-group-line-info group)
1349 (gnus-group-position-point))))
1351 (defun gnus-group-insert-group-line-info (group)
1352 "Insert GROUP on the current line."
1353 (let ((entry (gnus-group-entry group))
1354 (gnus-group-indentation (gnus-group-group-indentation))
1358 ;; (Un)subscribed group.
1359 (setq info (nth 2 entry))
1360 (gnus-group-insert-group-line
1361 group (gnus-info-level info) (gnus-info-marks info)
1362 (or (car entry) t) (gnus-info-method info)))
1363 ;; This group is dead.
1364 (gnus-group-insert-group-line
1366 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1368 (if (setq active (gnus-active group))
1369 (if (zerop (cdr active))
1371 (- (1+ (cdr active)) (car active)))
1373 (gnus-method-simplify (gnus-find-method-for-group group))))))
1375 (defun gnus-number-of-unseen-articles-in-group (group)
1376 (let* ((info (nth 2 (gnus-group-entry group)))
1377 (marked (gnus-info-marks info))
1378 (seen (cdr (assq 'seen marked)))
1379 (active (gnus-active group)))
1382 (length (gnus-uncompress-range
1383 (gnus-range-difference
1384 (gnus-range-difference (list active) (gnus-info-read info))
1387 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1388 gnus-tmp-marked number
1390 "Insert a group line in the group buffer."
1391 (let* ((gnus-tmp-method
1392 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1393 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1395 (gnus-tmp-active (gnus-active gnus-tmp-group))
1396 (gnus-tmp-number-total
1398 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1400 (gnus-tmp-number-of-unread
1401 (if (numberp number) (int-to-string (max 0 number))
1403 (gnus-tmp-number-of-read
1404 (if (numberp number)
1405 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1407 (gnus-tmp-subscribed
1408 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1409 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1410 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1412 (gnus-tmp-qualified-group
1413 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1414 group-name-charset))
1416 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1418 (gnus-tmp-newsgroup-description
1419 (if gnus-description-hashtb
1420 (or (gnus-group-name-decode
1421 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1422 group-name-charset) "")
1425 (if (and gnus-moderated-hashtb
1426 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1428 (gnus-tmp-moderated-string
1429 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1430 (gnus-tmp-group-icon "==&&==")
1431 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1432 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1433 (gnus-tmp-news-method-string
1435 (format "(%s:%s)" (car gnus-tmp-method)
1436 (cadr gnus-tmp-method)) ""))
1437 (gnus-tmp-marked-mark
1438 (if (and (numberp number)
1440 (cdr (assq 'tick gnus-tmp-marked)))
1442 (gnus-tmp-summary-live
1443 (if (and (not gnus-group-is-exiting-p)
1444 (gnus-buffer-live-p (gnus-summary-buffer-name
1447 (gnus-tmp-process-marked
1448 (if (member gnus-tmp-group gnus-group-marked)
1449 gnus-process-mark ? ))
1450 (buffer-read-only nil)
1451 header gnus-tmp-header) ; passed as parameter to user-funcs.
1453 (gnus-add-text-properties
1457 (let ((gnus-tmp-group (gnus-group-name-decode
1458 gnus-tmp-group group-name-charset)))
1459 (eval gnus-group-line-format-spec)))
1460 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1461 gnus-unread ,(if (numberp number)
1462 (string-to-int gnus-tmp-number-of-unread)
1464 gnus-marked ,gnus-tmp-marked-mark
1465 gnus-indentation ,gnus-group-indentation
1466 gnus-level ,gnus-tmp-level))
1468 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1469 (gnus-run-hooks 'gnus-group-update-hook))
1471 ;; Allow XEmacs to remove front-sticky text properties.
1472 (gnus-group-remove-excess-properties)))
1474 (defun gnus-group-highlight-line ()
1475 "Highlight the current line according to `gnus-group-highlight'."
1476 (let* ((list gnus-group-highlight)
1478 (end (point-at-eol))
1479 ;; now find out where the line starts and leave point there.
1480 (beg (progn (beginning-of-line) (point)))
1481 (group (gnus-group-group-name))
1482 (entry (gnus-group-entry group))
1483 (unread (if (numberp (car entry)) (car entry) 0))
1484 (active (gnus-active group))
1485 (total (if active (1+ (- (cdr active) (car active))) 0))
1486 (info (nth 2 entry))
1487 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1488 (marked (gnus-info-marks info))
1489 (mailp (apply 'append
1492 (memq x (assoc (symbol-name
1493 (car (or method gnus-select-method)))
1494 gnus-valid-select-methods)))
1495 '(mail post-mail))))
1496 (level (or (gnus-info-level info) gnus-level-killed))
1497 (score (or (gnus-info-score info) 0))
1498 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1499 (group-age (gnus-group-timestamp-delta group))
1500 (inhibit-read-only t))
1501 ;; Eval the cars of the lists until we find a match.
1503 (not (eval (caar list))))
1504 (setq list (cdr list)))
1505 (let ((face (cdar list)))
1506 (unless (eq face (get-text-property beg 'face))
1507 (gnus-put-text-property-excluding-characters-with-faces
1509 (setq face (if (boundp face) (symbol-value face) face)))
1510 (gnus-extent-start-open beg)))
1513 (defun gnus-group-update-group (group &optional visible-only)
1514 "Update all lines where GROUP appear.
1515 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1517 ;; Can't use `save-excursion' here, so we do it manually.
1518 (let ((buf (current-buffer))
1520 (set-buffer gnus-group-buffer)
1521 (setq mark (point-marker))
1522 ;; The buffer may be narrowed.
1525 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1527 found buffer-read-only)
1528 ;; Enter the current status into the dribble buffer.
1529 (let ((entry (gnus-group-entry group)))
1531 (not (gnus-ephemeral-group-p group)))
1533 (concat "(gnus-group-set-info '"
1534 (gnus-prin1-to-string (nth 2 entry))
1536 ;; Find all group instances. If topics are in use, each group
1537 ;; may be listed in more than once.
1538 (while (setq loc (text-property-any
1539 loc (point-max) 'gnus-group ident))
1542 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1544 (gnus-group-insert-group-line-info group)
1547 (gnus-run-hooks 'gnus-group-update-group-hook)))
1548 (setq loc (1+ loc)))
1549 (unless (or found visible-only)
1550 ;; No such line in the buffer, find out where it's supposed to
1551 ;; go, and insert it there (or at the end of the buffer).
1552 (if gnus-goto-missing-group-function
1553 (funcall gnus-goto-missing-group-function group)
1554 (let ((entry (cddr (gnus-group-entry group))))
1555 (while (and entry (car entry)
1559 (point-min) (point-max)
1560 'gnus-group (gnus-intern-safe
1561 (caar entry) gnus-active-hashtb)))))
1562 (setq entry (cdr entry)))
1563 (or entry (goto-char (point-max)))))
1564 ;; Finally insert the line.
1565 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1566 (gnus-group-insert-group-line-info group)
1569 (gnus-run-hooks 'gnus-group-update-group-hook))))
1570 (when gnus-group-update-group-function
1571 (funcall gnus-group-update-group-function group))
1572 (gnus-group-set-mode-line)))
1574 (set-marker mark nil)
1577 (defun gnus-group-set-mode-line ()
1578 "Update the mode line in the group buffer."
1579 (when (memq 'group gnus-updated-mode-lines)
1580 ;; Yes, we want to keep this mode line updated.
1582 (set-buffer gnus-group-buffer)
1583 (let* ((gformat (or gnus-group-mode-line-format-spec
1584 (gnus-set-format 'group-mode)))
1585 (gnus-tmp-news-server (cadr gnus-select-method))
1586 (gnus-tmp-news-method (car gnus-select-method))
1587 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1589 gnus-tmp-header ;Dummy binding for user-defined formats
1590 ;; Get the resulting string.
1592 (and gnus-dribble-buffer
1593 (buffer-name gnus-dribble-buffer)
1594 (buffer-modified-p gnus-dribble-buffer)
1596 (set-buffer gnus-dribble-buffer)
1597 (not (zerop (buffer-size))))))
1598 (mode-string (eval gformat)))
1599 ;; Say whether the dribble buffer has been modified.
1600 (setq mode-line-modified
1601 (if modified (car gnus-mode-line-modified)
1602 (cdr gnus-mode-line-modified)))
1603 ;; If the line is too long, we chop it off.
1604 (when (> (length mode-string) max-len)
1605 (setq mode-string (substring mode-string 0 (- max-len 4))))
1607 (setq mode-line-buffer-identification
1608 (gnus-mode-line-buffer-identification
1609 (list mode-string)))
1610 (set-buffer-modified-p modified))))))
1612 (defun gnus-group-group-name ()
1613 "Get the name of the newsgroup on the current line."
1614 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1616 (symbol-name group))))
1618 (defun gnus-group-group-level ()
1619 "Get the level of the newsgroup on the current line."
1620 (get-text-property (point-at-bol) 'gnus-level))
1622 (defun gnus-group-group-indentation ()
1623 "Get the indentation of the newsgroup on the current line."
1624 (or (get-text-property (point-at-bol) 'gnus-indentation)
1625 (and gnus-group-indentation-function
1626 (funcall gnus-group-indentation-function))
1629 (defun gnus-group-group-unread ()
1630 "Get the number of unread articles of the newsgroup on the current line."
1631 (get-text-property (point-at-bol) 'gnus-unread))
1633 (defun gnus-group-new-mail (group)
1634 (if (nnmail-new-mail-p (gnus-group-real-name group))
1638 (defun gnus-group-level (group)
1639 "Return the estimated level of GROUP."
1640 (or (gnus-info-level (gnus-get-info group))
1641 (and (member group gnus-zombie-list) gnus-level-zombie)
1644 (defun gnus-group-search-forward (&optional backward all level first-too)
1645 "Find the next newsgroup with unread articles.
1646 If BACKWARD is non-nil, find the previous newsgroup instead.
1647 If ALL is non-nil, just find any newsgroup.
1648 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1650 If FIRST-TOO, the current line is also eligible as a target."
1651 (let ((way (if backward -1 1))
1652 (low gnus-level-killed)
1655 (if (and backward (progn (beginning-of-line)) (bobp))
1664 (get-text-property (point) 'gnus-group)
1668 (get-text-property (point) 'gnus-unread)))
1669 (and (numberp unread) (> unread 0)))
1670 (setq lev (get-text-property (point)
1672 (<= lev gnus-level-subscribed)))
1674 (and (setq lev (get-text-property (point)
1683 (zerop (forward-line way)))))
1685 (progn (gnus-group-position-point) t)
1686 (goto-char (or pos beg))
1689 (defun gnus-total-fetched-for (group)
1690 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1691 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1692 (size (+ size-in-cache size-in-agent))
1693 (suffix '("B" "K" "M" "G"))
1695 (cutoff (* 10 scale)))
1696 (while (> size cutoff)
1697 (setq size (/ size scale)
1698 suffix (cdr suffix)))
1699 (format "%5.1f%s" size (car suffix))))
1701 ;;; Gnus group mode commands
1705 (defun gnus-group-mark-line-p ()
1708 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1709 (eq (char-after) gnus-process-mark)))
1711 (defun gnus-group-mark-group (n &optional unmark no-advance)
1712 "Mark the current group."
1714 (let ((buffer-read-only nil)
1718 (when (setq group (gnus-group-group-name))
1719 ;; Go to the mark position.
1721 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1725 (setq gnus-group-marked (delete group gnus-group-marked))
1726 (insert-char ? 1 t))
1727 (setq gnus-group-marked
1728 (cons group (delete group gnus-group-marked)))
1729 (insert-char gnus-process-mark 1 t)))
1731 (gnus-group-next-group 1))
1733 (gnus-summary-position-point)
1736 (defun gnus-group-unmark-group (n)
1737 "Remove the mark from the current group."
1739 (gnus-group-mark-group n 'unmark)
1740 (gnus-group-position-point))
1742 (defun gnus-group-unmark-all-groups ()
1743 "Unmark all groups."
1746 (mapc 'gnus-group-remove-mark gnus-group-marked))
1747 (gnus-group-position-point))
1749 (defun gnus-group-mark-region (unmark beg end)
1750 "Mark all groups between point and mark.
1751 If UNMARK, remove the mark instead."
1752 (interactive "P\nr")
1753 (let ((num (count-lines beg end)))
1756 (- num (gnus-group-mark-group num unmark)))))
1758 (defun gnus-group-mark-buffer (&optional unmark)
1759 "Mark all groups in the buffer.
1760 If UNMARK, remove the mark instead."
1762 (gnus-group-mark-region unmark (point-min) (point-max)))
1764 (defun gnus-group-mark-regexp (regexp)
1765 "Mark all groups that match some regexp."
1766 (interactive "sMark (regexp): ")
1767 (let ((alist (cdr gnus-newsrc-alist))
1771 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1772 (gnus-group-jump-to-group group)
1773 (gnus-group-set-mark group)))))
1774 (gnus-group-position-point))
1776 (defun gnus-group-remove-mark (group &optional test-marked)
1777 "Remove the process mark from GROUP and move point there.
1778 Return nil if the group isn't displayed."
1779 (if (gnus-group-goto-group group nil test-marked)
1781 (gnus-group-mark-group 1 'unmark t)
1783 (setq gnus-group-marked
1784 (delete group gnus-group-marked))
1787 (defun gnus-group-set-mark (group)
1788 "Set the process mark on GROUP."
1789 (if (gnus-group-goto-group group)
1791 (gnus-group-mark-group 1 nil t))
1792 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1794 (defun gnus-group-universal-argument (arg &optional groups func)
1795 "Perform any command on all groups according to the process/prefix convention."
1797 (if (eq (setq func (or func
1800 (substitute-command-keys
1801 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1803 (gnus-error 1 "Undefined key")
1804 (gnus-group-iterate arg
1806 (command-execute func))))
1807 (gnus-group-position-point))
1809 (defun gnus-group-process-prefix (n)
1810 "Return a list of groups to work on.
1811 Take into consideration N (the prefix) and the list of marked groups."
1814 (setq n (prefix-numeric-value n))
1815 ;; There is a prefix, so we return a list of the N next
1817 (let ((way (if (< n 0) -1 1))
1822 (if (setq group (gnus-group-group-name))
1823 (push group groups))
1825 (gnus-group-next-group way)))
1827 ((and (gnus-region-active-p) (mark))
1828 ;; Work on the region between point and mark.
1829 (let ((max (max (point) (mark)))
1832 (goto-char (min (point) (mark)))
1835 (push (gnus-group-group-name) groups)
1836 (zerop (gnus-group-next-group 1))
1838 (nreverse groups))))
1840 ;; No prefix, but a list of marked articles.
1841 (reverse gnus-group-marked))
1843 ;; Neither marked articles or a prefix, so we return the
1845 (let ((group (gnus-group-group-name)))
1846 (and group (list group))))))
1848 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1849 ;;; imagine why I went through these contortions...
1851 (let ((function (make-symbol "gnus-group-iterate-function"))
1852 (window (make-symbol "gnus-group-iterate-window"))
1853 (groups (make-symbol "gnus-group-iterate-groups"))
1854 (group (make-symbol "gnus-group-iterate-group")))
1856 `(defun gnus-group-iterate (arg ,function)
1857 "Iterate FUNCTION over all process/prefixed groups.
1858 FUNCTION will be called with the group name as the parameter
1859 and with point over the group in question."
1860 (let ((,groups (gnus-group-process-prefix arg))
1861 (,window (selected-window))
1864 (setq ,group (car ,groups)
1865 ,groups (cdr ,groups))
1866 (select-window ,window)
1867 (gnus-group-remove-mark ,group)
1868 (save-selected-window
1870 (funcall ,function ,group)))))))))
1872 (put 'gnus-group-iterate 'lisp-indent-function 1)
1874 ;; Selecting groups.
1876 (defun gnus-group-read-group (&optional all no-article group select-articles)
1877 "Read news in this newsgroup.
1878 If the prefix argument ALL is non-nil, already read articles become
1879 readable. IF ALL is a number, fetch this number of articles. If the
1880 optional argument NO-ARTICLE is non-nil, no article will be
1881 auto-selected upon group entry. If GROUP is non-nil, fetch that
1884 (let ((no-display (eq all 0))
1885 (group (or group (gnus-group-group-name)))
1886 number active marked entry)
1890 (error "No group on current line"))
1891 (setq marked (gnus-info-marks
1892 (nth 2 (setq entry (gnus-group-entry group)))))
1893 ;; This group might be a dead group. In that case we have to get
1894 ;; the number of unread articles from `gnus-active-hashtb'.
1896 (cond ((numberp all) all)
1898 ((setq active (gnus-active group))
1899 (- (1+ (cdr active)) (car active)))))
1900 (gnus-summary-read-group
1901 group (or all (and (numberp number)
1902 (zerop (+ number (gnus-range-length
1903 (cdr (assq 'tick marked)))
1905 (cdr (assq 'dormant marked)))))))
1906 no-article nil no-display nil select-articles)))
1908 (defun gnus-group-select-group (&optional all)
1909 "Select this newsgroup.
1910 No article is selected automatically.
1911 If the group is opened, just switch the summary buffer.
1912 If ALL is non-nil, already read articles become readable.
1913 If ALL is a positive number, fetch this number of the latest
1914 articles in the group.
1915 If ALL is a negative number, fetch this number of the earliest
1916 articles in the group."
1918 (when (and (eobp) (not (gnus-group-group-name)))
1920 (gnus-group-read-group all t))
1922 (defun gnus-group-quick-select-group (&optional all)
1923 "Select the current group \"quickly\".
1924 This means that no highlighting or scoring will be performed.
1925 If ALL (the prefix argument) is 0, don't even generate the summary
1928 This might be useful if you want to toggle threading
1929 before entering the group."
1931 (require 'gnus-score)
1933 gnus-score-find-score-files-function
1934 gnus-home-score-file
1935 gnus-apply-kill-hook
1936 gnus-summary-expunge-below)
1937 (gnus-group-read-group all t)))
1939 (defun gnus-group-visible-select-group (&optional all)
1940 "Select the current group without hiding any articles."
1942 (let ((gnus-inhibit-limiting t))
1943 (gnus-group-read-group all t)))
1945 (defun gnus-group-select-group-ephemerally ()
1946 "Select the current group without doing any processing whatsoever.
1947 You will actually be entered into a group that's a copy of
1948 the current group; no changes you make while in this group will
1951 (require 'gnus-score)
1953 gnus-score-find-score-files-function gnus-apply-kill-hook
1954 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1955 gnus-summary-mode-hook gnus-select-group-hook
1956 (group (gnus-group-group-name))
1957 (method (gnus-find-method-for-group group)))
1958 (gnus-group-read-ephemeral-group
1959 (gnus-group-prefixed-name group method) method)))
1962 (defun gnus-fetch-group (group &optional articles)
1963 "Start Gnus if necessary and enter GROUP.
1964 Returns whether the fetching was successful or not."
1965 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1966 (unless (get-buffer gnus-group-buffer)
1968 (gnus-group-read-group articles nil group))
1971 (defun gnus-fetch-group-other-frame (group)
1972 "Pop up a frame and enter GROUP."
1974 (let ((window (get-buffer-window gnus-group-buffer)))
1976 (select-frame (window-frame window)))
1977 ((= (length (frame-list)) 1)
1978 (select-frame (make-frame)))
1981 (gnus-fetch-group group))
1983 (defvar gnus-ephemeral-group-server 0)
1985 (defcustom gnus-large-ephemeral-newsgroup 200
1986 "The number of articles which indicates a large ephemeral newsgroup.
1987 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1989 If the number of articles in a newsgroup is greater than this value,
1990 confirmation is required for selecting the newsgroup. If it is nil, no
1991 confirmation is required."
1993 :group 'gnus-group-select
1994 :type '(choice (const :tag "No limit" nil)
1997 (defcustom gnus-fetch-old-ephemeral-headers nil
1998 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2001 :type '(choice (const :tag "off" nil)
2004 (sexp :menu-tag "other" t)))
2006 ;; Enter a group that is not in the group buffer. Non-nil is returned
2007 ;; if selection was successful.
2008 (defun gnus-group-read-ephemeral-group (group method &optional activate
2009 quit-config request-only
2012 "Read GROUP from METHOD as an ephemeral group.
2013 If ACTIVATE, request the group first.
2014 If QUIT-CONFIG, use that window configuration when exiting from the
2016 If REQUEST-ONLY, don't actually read the group; just request it.
2017 If SELECT-ARTICLES, only select those articles.
2018 If PARAMETERS, use those as the group parameters.
2020 Return the name of the group if selection was successful."
2023 ;; (gnus-read-group "Group name: ")
2025 "Group: " gnus-active-hashtb
2027 'gnus-group-history)
2028 (gnus-read-method "From method: ")))
2029 ;; Transform the select method into a unique server.
2030 (when (stringp method)
2031 (setq method (gnus-server-to-method method)))
2033 `(,(car method) ,(concat (cadr method) "-ephemeral")
2034 (,(intern (format "%s-address" (car method))) ,(cadr method))
2036 (let ((group (if (gnus-group-foreign-p group) group
2037 (gnus-group-prefixed-name (gnus-group-real-name group)
2042 ,gnus-level-default-subscribed nil nil ,method
2045 (cons 'quit-config quit-config)
2047 (cons gnus-summary-buffer
2048 gnus-current-window-configuration)))
2051 (push method gnus-ephemeral-servers)
2052 (set-buffer gnus-group-buffer)
2053 (unless (gnus-check-server method)
2054 (error "Unable to contact server: %s" (gnus-status-message method)))
2056 (gnus-activate-group group 'scan)
2057 (unless (gnus-request-group group)
2058 (error "Couldn't request group: %s"
2059 (nnheader-get-report (car method)))))
2063 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2064 (gnus-fetch-old-headers
2065 gnus-fetch-old-ephemeral-headers))
2066 (gnus-group-read-group t t group select-articles))
2070 (message "Quit reading the ephemeral group")
2073 (defun gnus-group-jump-to-group (group &optional prompt)
2074 "Jump to newsgroup GROUP.
2076 If PROMPT (the prefix) is a number, use the prompt specified in
2077 `gnus-group-jump-to-group-prompt'."
2079 (list (mm-string-make-unibyte
2081 "Group: " gnus-active-hashtb nil
2082 (gnus-read-active-file-p)
2083 (if current-prefix-arg
2084 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2085 (or (and (stringp gnus-group-jump-to-group-prompt)
2086 gnus-group-jump-to-group-prompt)
2087 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2088 (and (stringp p) p))))
2089 'gnus-group-history))))
2091 (when (equal group "")
2092 (error "Empty group name"))
2094 (unless (gnus-ephemeral-group-p group)
2095 ;; Either go to the line in the group buffer...
2096 (unless (gnus-group-goto-group group)
2097 ;; ... or insert the line.
2098 (gnus-group-update-group group)
2099 (gnus-group-goto-group group)))
2100 ;; Adjust cursor point.
2101 (gnus-group-position-point))
2103 (defun gnus-group-goto-group (group &optional far test-marked)
2104 "Goto to newsgroup GROUP.
2105 If FAR, it is likely that the group is not on the current line.
2106 If TEST-MARKED, the line must be marked."
2110 ;; It's quite likely that we are on the right line, so
2111 ;; we check the current line first.
2113 (eq (get-text-property (point) 'gnus-group)
2114 (gnus-intern-safe group gnus-active-hashtb))
2115 (or (not test-marked) (gnus-group-mark-line-p)))
2117 ;; Previous and next line are also likely, so we check them as well.
2121 (and (eq (get-text-property (point) 'gnus-group)
2122 (gnus-intern-safe group gnus-active-hashtb))
2123 (or (not test-marked) (gnus-group-mark-line-p)))))
2129 (and (eq (get-text-property (point) 'gnus-group)
2130 (gnus-intern-safe group gnus-active-hashtb))
2131 (or (not test-marked) (gnus-group-mark-line-p)))))
2135 (goto-char (point-min))
2137 (while (and (not found)
2142 (gnus-intern-safe group gnus-active-hashtb))))
2143 (if (gnus-group-mark-line-p)
2148 ;; Search through the entire buffer.
2151 (point-min) (point-max)
2152 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2154 (defun gnus-group-next-group (n &optional silent)
2155 "Go to next N'th newsgroup.
2156 If N is negative, search backward instead.
2157 Returns the difference between N and the number of skips actually
2160 (gnus-group-next-unread-group n t nil silent))
2162 (defun gnus-group-next-unread-group (n &optional all level silent)
2163 "Go to next N'th unread newsgroup.
2164 If N is negative, search backward instead.
2165 If ALL is non-nil, choose any newsgroup, unread or not.
2166 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2167 such group can be found, the next group with a level higher than
2169 Returns the difference between N and the number of skips actually
2172 (let ((backward (< n 0))
2175 (gnus-group-search-forward
2176 backward (or (not gnus-group-goto-unread) all) level))
2180 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2181 (if level " on this level or higher" "")))
2184 (defun gnus-group-prev-group (n)
2185 "Go to previous N'th newsgroup.
2186 Returns the difference between N and the number of skips actually
2189 (gnus-group-next-unread-group (- n) t))
2191 (defun gnus-group-prev-unread-group (n)
2192 "Go to previous N'th unread newsgroup.
2193 Returns the difference between N and the number of skips actually
2196 (gnus-group-next-unread-group (- n)))
2198 (defun gnus-group-next-unread-group-same-level (n)
2199 "Go to next N'th unread newsgroup on the same level.
2200 If N is negative, search backward instead.
2201 Returns the difference between N and the number of skips actually
2204 (gnus-group-next-unread-group n t (gnus-group-group-level))
2205 (gnus-group-position-point))
2207 (defun gnus-group-prev-unread-group-same-level (n)
2208 "Go to next N'th unread newsgroup on the same level.
2209 Returns the difference between N and the number of skips actually
2212 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2213 (gnus-group-position-point))
2215 (defun gnus-group-best-unread-group (&optional exclude-group)
2216 "Go to the group with the highest level.
2217 If EXCLUDE-GROUP, do not go to that group."
2219 (goto-char (point-min))
2223 (setq unread (get-text-property (point) 'gnus-unread))
2224 (when (and (numberp unread) (> unread 0))
2225 (when (and (get-text-property (point) 'gnus-level)
2226 (< (get-text-property (point) 'gnus-level) best)
2227 (or (not exclude-group)
2228 (not (equal exclude-group (gnus-group-group-name)))))
2229 (setq best (get-text-property (point) 'gnus-level))
2230 (setq best-point (point))))
2233 (goto-char best-point))
2234 (gnus-group-position-point)
2235 (and best-point (gnus-group-group-name))))
2237 (defun gnus-group-first-unread-group ()
2238 "Go to the first group with unread articles."
2241 (let ((opoint (point))
2243 (goto-char (point-min))
2244 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2245 (and (numberp unread) ; Not a topic.
2246 (not (zerop unread))) ; Has unread articles.
2247 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2250 nil)) ; Not success.
2251 (gnus-group-position-point)))
2253 (defun gnus-group-enter-server-mode ()
2254 "Jump to the server buffer."
2256 (gnus-enter-server-buffer))
2258 (defun gnus-group-make-group-simple (&optional group)
2259 "Add a new newsgroup.
2260 The user will be prompted for GROUP."
2262 (list (completing-read "Group: " gnus-active-hashtb
2263 nil nil nil 'gnus-group-history)))
2264 (gnus-group-make-group
2265 (gnus-group-real-name group)
2266 (gnus-group-server group)))
2268 (defun gnus-group-make-group (name &optional method address args)
2269 "Add a new newsgroup.
2270 The user will be prompted for a NAME, for a select METHOD, and an
2274 (gnus-read-group "Group name: ")
2275 (gnus-read-method "From method: ")))
2277 (when (stringp method)
2278 (setq method (or (gnus-server-to-method method) method)))
2279 (let* ((meth (gnus-method-simplify
2281 (not (gnus-server-equal method gnus-select-method)))
2282 (if address (list (intern method) address)
2284 (nname (if method (gnus-group-prefixed-name name meth) name))
2286 (when (gnus-group-entry nname)
2287 (error "Group %s already exists" nname))
2288 ;; Subscribe to the new group.
2289 (gnus-group-change-level
2290 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2291 gnus-level-default-subscribed gnus-level-killed
2292 (and (gnus-group-group-name)
2293 (gnus-group-entry (gnus-group-group-name)))
2296 (gnus-set-active nname (cons 1 0))
2297 (unless (gnus-ephemeral-group-p name)
2299 (concat "(gnus-group-set-info '"
2300 (gnus-prin1-to-string (cdr info)) ")")))
2302 (gnus-group-insert-group-line-info nname)
2304 (gnus-group-position-point)
2306 ;; Load the back end and try to make the back end create
2307 ;; the group as well.
2308 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2310 gnus-valid-select-methods)
2312 (gnus-check-server meth)
2313 (when (gnus-check-backend-function 'request-create-group nname)
2314 (unless (gnus-request-create-group nname nil args)
2315 (error "Could not create group on server: %s"
2316 (nnheader-get-report backend))))
2319 (defun gnus-group-delete-groups (&optional arg)
2320 "Delete the current group. Only meaningful with editable groups."
2322 (let ((n (length (gnus-group-process-prefix arg))))
2323 (when (gnus-yes-or-no-p
2325 "Delete this 1 group? "
2326 (format "Delete these %d groups? " n)))
2327 (gnus-group-iterate arg
2329 (gnus-group-delete-group group nil t))))))
2331 (defun gnus-group-delete-group (group &optional force no-prompt)
2332 "Delete the current group. Only meaningful with editable groups.
2333 If FORCE (the prefix) is non-nil, all the articles in the group will
2334 be deleted. This is \"deleted\" as in \"removed forever from the face
2335 of the Earth\". There is no undo. The user will be prompted before
2337 Note that you also have to specify FORCE if you want the group to
2338 be removed from the server, even when it's empty."
2340 (list (gnus-group-group-name)
2341 current-prefix-arg))
2343 (error "No group to delete"))
2344 (unless (gnus-check-backend-function 'request-delete-group group)
2345 (error "This back end does not support group deletion"))
2347 (if (and (not no-prompt)
2348 (not (gnus-yes-or-no-p
2350 "Do you really want to delete %s%s? "
2351 group (if force " and all its contents" "")))))
2353 (gnus-message 6 "Deleting group %s..." group)
2354 (if (not (gnus-request-delete-group group force))
2355 (gnus-error 3 "Couldn't delete group %s" group)
2356 (gnus-message 6 "Deleting group %s...done" group)
2357 (gnus-group-goto-group group)
2358 (gnus-group-kill-group 1 t)
2359 (gnus-set-active group nil)
2361 (gnus-group-position-point)))
2363 (defun gnus-group-rename-group (group new-name)
2364 "Rename group from GROUP to NEW-NAME.
2365 When used interactively, GROUP is the group under point
2366 and NEW-NAME will be prompted for."
2369 (gnus-group-group-name)
2371 (unless (gnus-check-backend-function
2372 'request-rename-group (gnus-group-group-name))
2373 (error "This back end does not support renaming groups"))
2374 (gnus-read-group "Rename group to: "
2375 (gnus-group-real-name (gnus-group-group-name))))))
2377 (unless (gnus-check-backend-function 'request-rename-group group)
2378 (error "This back end does not support renaming groups"))
2380 (error "No group to rename"))
2381 (when (equal (gnus-group-real-name group) new-name)
2382 (error "Can't rename to the same name"))
2384 ;; We find the proper prefixed name.
2386 (if (gnus-group-native-p group)
2390 (gnus-group-prefixed-name
2391 (gnus-group-real-name new-name)
2392 (gnus-info-method (gnus-get-info group)))))
2394 (when (gnus-active new-name)
2395 (error "The group %s already exists" new-name))
2397 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2400 (gnus-group-goto-group group)
2401 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2402 (gnus-request-rename-group group new-name))))
2403 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2404 ;; We rename the group internally by killing it...
2405 (gnus-group-kill-group)
2406 ;; ... changing its name ...
2407 (setcar (cdar gnus-list-of-killed-groups) new-name)
2408 ;; ... and then yanking it. Magic!
2409 (gnus-group-yank-group)
2410 (gnus-set-active new-name (gnus-active group))
2411 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2413 (setq gnus-killed-list (delete group gnus-killed-list))
2414 (gnus-set-active group nil)
2415 (gnus-dribble-touch)
2416 (gnus-group-position-point)))
2418 (defun gnus-group-edit-group (group &optional part)
2419 "Edit the group on the current line."
2420 (interactive (list (gnus-group-group-name)))
2421 (let ((part (or part 'info))
2424 (error "No group on current line"))
2425 (unless (setq info (gnus-get-info group))
2426 (error "Killed group; can't be edited"))
2428 (gnus-close-group group))
2430 ;; Find the proper form to edit.
2431 (cond ((eq part 'method)
2432 (or (gnus-info-method info) "native"))
2434 (gnus-info-params info))
2436 ;; The proper documentation.
2438 "Editing the %s for `%s'."
2440 ((eq part 'method) "select method")
2441 ((eq part 'params) "group parameters")
2443 (gnus-group-decoded-name group))
2445 (gnus-group-edit-group-done ',part ,group form)))
2448 (gnus-create-info-command
2451 "(gnus)Select Methods")
2453 "(gnus)Group Parameters")
2455 "(gnus)Group Info"))))))
2457 (defun gnus-group-edit-group-method (group)
2458 "Edit the select method of GROUP."
2459 (interactive (list (gnus-group-group-name)))
2460 (gnus-group-edit-group group 'method))
2462 (defun gnus-group-edit-group-parameters (group)
2463 "Edit the group parameters of GROUP."
2464 (interactive (list (gnus-group-group-name)))
2465 (gnus-group-edit-group group 'params))
2467 (defun gnus-group-edit-group-done (part group form)
2469 (let* ((method (cond ((eq part 'info) (nth 4 form))
2470 ((eq part 'method) form)
2472 (info (cond ((eq part 'info) form)
2473 ((eq part 'method) (gnus-get-info group))
2476 (if (or (not method)
2478 gnus-select-method method))
2479 (gnus-group-real-name (car info))
2480 (gnus-group-prefixed-name
2481 (gnus-group-real-name (car info)) method))
2483 (when (and new-group
2484 (not (equal new-group group)))
2485 (when (gnus-group-goto-group group)
2486 (gnus-group-kill-group 1))
2487 (gnus-activate-group new-group))
2489 (if (not (and info new-group))
2490 (gnus-group-set-info form (or new-group group) part)
2491 (setq info (gnus-copy-sequence info))
2492 (setcar info new-group)
2493 (unless (gnus-server-equal method "native")
2494 (unless (nthcdr 3 info)
2495 (nconc info (list nil nil)))
2496 (unless (nthcdr 4 info)
2497 (nconc info (list nil)))
2498 (gnus-info-set-method info method))
2499 (gnus-group-set-info info))
2500 (gnus-group-update-group (or new-group group))
2501 (gnus-group-position-point)))
2503 (defun gnus-group-make-useful-group (group method)
2504 "Create one of the groups described in `gnus-useful-groups'."
2506 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2508 gnus-useful-groups)))
2509 (list (cadr entry) (caddr entry))))
2510 (setq method (gnus-copy-sequence method))
2512 (while (setq entry (memq (assq 'eval method) method))
2513 (setcar entry (eval (cadar entry)))))
2514 (gnus-group-make-group group method))
2516 (defun gnus-group-make-help-group (&optional noerror)
2517 "Create the Gnus documentation group.
2518 Optional argument NOERROR modifies the behavior of this function when the
2519 group already exists:
2520 - if not given, and error is signaled,
2521 - if t, stay silent,
2522 - if anything else, just print a message."
2524 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2525 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2526 (if (gnus-group-entry name)
2527 (cond ((eq noerror nil)
2528 (error "Documentation group already exists"))
2533 (gnus-message 1 "Documentation group already exists")))
2536 (gnus-message 1 "Couldn't find doc group")
2537 (gnus-group-make-group
2538 (gnus-group-real-name name)
2539 (list 'nndoc "gnus-help"
2540 (list 'nndoc-address file)
2541 (list 'nndoc-article-type 'mbox))))
2543 (gnus-group-position-point))
2545 (defun gnus-group-make-doc-group (file type)
2546 "Create a group that uses a single file as the source."
2548 (list (read-file-name "File name: ")
2549 (and current-prefix-arg 'ask)))
2550 (when (eq type 'ask)
2555 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2557 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2558 ((= char ?b) 'babyl)
2559 ((= char ?d) 'digest)
2560 ((= char ?f) 'forward)
2562 ((= char ?g) 'guess)
2563 (t (setq err (format "%c unknown. " char))
2566 (let* ((file (expand-file-name file))
2567 (name (gnus-generate-new-group-name
2568 (gnus-group-prefixed-name
2569 (file-name-nondirectory file) '(nndoc "")))))
2570 (gnus-group-make-group
2571 (gnus-group-real-name name)
2573 (list 'nndoc-address file)
2574 (list 'nndoc-article-type (or type 'guess))))))
2576 (defvar nnweb-type-definition)
2577 (defvar gnus-group-web-type-history nil)
2578 (defvar gnus-group-web-search-history nil)
2579 (defun gnus-group-make-web-group (&optional solid)
2580 "Create an ephemeral nnweb group.
2581 If SOLID (the prefix), create a solid group."
2585 (if solid (gnus-read-group "Group name: ")
2586 (message-unique-id)))
2587 (default-type (or (car gnus-group-web-type-history)
2588 (symbol-name (caar nnweb-type-definition))))
2592 (format "Search engine type (default %s): " default-type)
2593 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2594 nnweb-type-definition)
2595 nil t nil 'gnus-group-web-type-history)
2600 (cons (or (car gnus-group-web-search-history) "") 0)
2601 'gnus-group-web-search-history))
2603 `(nnweb ,group (nnweb-search ,search)
2604 (nnweb-type ,(intern type))
2605 (nnweb-ephemeral-p t))))
2608 (gnus-pull 'nnweb-ephemeral-p method)
2609 (gnus-group-make-group group method))
2610 (gnus-group-read-ephemeral-group
2612 (cons (current-buffer)
2613 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2616 (defvar nnrss-group-alist)
2617 (defun nnrss-discover-feed (arg))
2618 (defun nnrss-save-server-data (arg)))
2619 (defun gnus-group-make-rss-group (&optional url)
2620 "Given a URL, discover if there is an RSS feed.
2621 If there is, use Gnus to create an nnrss group"
2625 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2626 (let ((feedinfo (nnrss-discover-feed url)))
2628 (let ((title (read-from-minibuffer "Title: "
2631 (desc (read-from-minibuffer "Description: "
2632 (cdr (assoc 'description
2634 (href (cdr (assoc 'href feedinfo))))
2635 (push (list title href desc)
2637 (gnus-group-unsubscribe-group
2638 (concat "nnrss:" title))
2639 (nnrss-save-server-data nil))
2640 (error "No feeds found for %s" url))))
2642 (defvar nnwarchive-type-definition)
2643 (defvar gnus-group-warchive-type-history nil)
2644 (defvar gnus-group-warchive-login-history nil)
2645 (defvar gnus-group-warchive-address-history nil)
2647 (defun gnus-group-make-warchive-group ()
2648 "Create a nnwarchive group."
2650 (require 'nnwarchive)
2651 (let* ((group (gnus-read-group "Group name: "))
2652 (default-type (or (car gnus-group-warchive-type-history)
2653 (symbol-name (caar nnwarchive-type-definition))))
2657 (format "Warchive type (default %s): " default-type)
2658 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2659 nnwarchive-type-definition)
2660 nil t nil 'gnus-group-warchive-type-history)
2662 (address (read-string "Warchive address: "
2663 nil 'gnus-group-warchive-address-history))
2664 (default-login (or (car gnus-group-warchive-login-history)
2669 (format "Warchive login (default %s): " user-mail-address)
2670 default-login 'gnus-group-warchive-login-history)
2673 `(nnwarchive ,address
2674 (nnwarchive-type ,(intern type))
2675 (nnwarchive-login ,login))))
2676 (gnus-group-make-group group method)))
2678 (defun gnus-group-make-archive-group (&optional all)
2679 "Create the (ding) Gnus archive group of the most recent articles.
2680 Given a prefix, create a full group."
2682 (let ((group (gnus-group-prefixed-name
2683 (if all "ding.archives" "ding.recent") '(nndir ""))))
2684 (when (gnus-group-entry group)
2685 (error "Archive group already exists"))
2686 (gnus-group-make-group
2687 (gnus-group-real-name group)
2688 (list 'nndir (if all "hpc" "edu")
2689 (list 'nndir-directory
2690 (if all gnus-group-archive-directory
2691 gnus-group-recent-archive-directory))))
2692 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2694 (defun gnus-group-make-directory-group (dir)
2695 "Create an nndir group.
2696 The user will be prompted for a directory. The contents of this
2697 directory will be used as a newsgroup. The directory should contain
2698 mail messages or news articles in files that have numeric names."
2700 (list (read-file-name "Create group from directory: ")))
2701 (unless (file-exists-p dir)
2702 (error "No such directory"))
2703 (unless (file-directory-p dir)
2704 (error "Not a directory"))
2708 (while (or (not group) (gnus-group-entry group))
2710 (gnus-group-prefixed-name
2711 (expand-file-name ext dir)
2713 (setq ext (format "<%d>" (setq i (1+ i)))))
2714 (gnus-group-make-group
2715 (gnus-group-real-name group)
2716 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2718 (defvar nnkiboze-score-file)
2719 (defun gnus-group-make-kiboze-group (group address scores)
2720 "Create an nnkiboze group.
2721 The user will be prompted for a name, a regexp to match groups, and
2722 score file entries for articles to include in the group."
2725 (read-string "nnkiboze group name: ")
2726 (read-string "Source groups (regexp): ")
2727 (let ((headers (mapcar 'list
2728 '("subject" "from" "number" "date" "message-id"
2729 "references" "chars" "lines" "xref"
2730 "followup" "all" "body" "head")))
2731 scores header regexp regexps)
2732 (while (not (equal "" (setq header (completing-read
2733 "Match on header: " headers nil t))))
2735 (while (not (equal "" (setq regexp (read-string
2736 (format "Match on %s (regexp): "
2738 (push (list regexp nil nil 'r) regexps))
2739 (push (cons header regexps) scores))
2741 (gnus-group-make-group group "nnkiboze" address)
2742 (let* ((nnkiboze-current-group group)
2743 (score-file (car (nnkiboze-score-file "")))
2744 (score-dir (file-name-directory score-file)))
2745 (unless (file-exists-p score-dir)
2746 (make-directory score-dir))
2747 (with-temp-file score-file
2748 (let (emacs-lisp-mode-hook)
2749 (gnus-pp scores)))))
2751 (defun gnus-group-add-to-virtual (n vgroup)
2752 "Add the current group to a virtual group."
2754 (list current-prefix-arg
2755 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2757 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2758 (error "%s is not an nnvirtual group" vgroup))
2759 (gnus-close-group vgroup)
2760 (let* ((groups (gnus-group-process-prefix n))
2761 (method (gnus-info-method (gnus-get-info vgroup))))
2762 (setcar (cdr method)
2764 (nth 1 method) "\\|"
2767 (gnus-group-remove-mark s)
2768 (concat "\\(^" (regexp-quote s) "$\\)"))
2770 (gnus-group-position-point))
2772 (defun gnus-group-make-empty-virtual (group)
2773 "Create a new, fresh, empty virtual group."
2774 (interactive "sCreate new, empty virtual group: ")
2775 (let* ((method (list 'nnvirtual "^$"))
2776 (pgroup (gnus-group-prefixed-name group method)))
2777 ;; Check whether it exists already.
2778 (when (gnus-group-entry pgroup)
2779 (error "Group %s already exists" pgroup))
2780 ;; Subscribe the new group after the group on the current line.
2781 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2782 (gnus-group-update-group pgroup)
2784 (gnus-group-position-point)))
2786 (defun gnus-group-enter-directory (dir)
2787 "Enter an ephemeral nneething group."
2788 (interactive "DDirectory to read: ")
2789 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2790 (leaf (gnus-group-prefixed-name
2791 (file-name-nondirectory (directory-file-name dir))
2793 (name (gnus-generate-new-group-name leaf)))
2794 (unless (gnus-group-read-ephemeral-group
2796 (cons (current-buffer)
2797 (if (eq major-mode 'gnus-summary-mode)
2799 (error "Couldn't enter %s" dir))))
2802 (autoload 'nnimap-expunge "nnimap")
2803 (autoload 'nnimap-acl-get "nnimap")
2804 (autoload 'nnimap-acl-edit "nnimap"))
2806 (defun gnus-group-nnimap-expunge (group)
2807 "Expunge deleted articles in current nnimap GROUP."
2808 (interactive (list (gnus-group-group-name)))
2809 (let ((mailbox (gnus-group-real-name group)) method)
2811 (error "No group on current line"))
2812 (unless (gnus-get-info group)
2813 (error "Killed group; can't be edited"))
2814 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2815 (error "%s is not an nnimap group" group))
2816 (nnimap-expunge mailbox (cadr method))))
2818 (defun gnus-group-nnimap-edit-acl (group)
2819 "Edit the Access Control List of current nnimap GROUP."
2820 (interactive (list (gnus-group-group-name)))
2821 (let ((mailbox (gnus-group-real-name group)) method acl)
2823 (error "No group on current line"))
2824 (unless (gnus-get-info group)
2825 (error "Killed group; can't be edited"))
2826 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2827 (error "%s is not an nnimap group" group))
2828 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2829 (error "Server does not support ACL's"))
2830 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2832 An access control list is a list of (identifier . rights) elements.
2834 The identifier string specifies the corresponding user. The
2835 identifier \"anyone\" is reserved to refer to the universal identity.
2837 Rights is a string listing a (possibly empty) set of alphanumeric
2838 characters, each character listing a set of operations which is being
2839 controlled. Letters are reserved for ``standard'' rights, listed
2840 below. Digits are reserved for implementation or site defined rights.
2842 l - lookup (mailbox is visible to LIST/LSUB commands)
2843 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2844 SEARCH, COPY from mailbox)
2845 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2846 w - write (STORE flags other than \\SEEN and \\DELETED)
2847 i - insert (perform APPEND, COPY into mailbox)
2848 p - post (send mail to submission address for mailbox,
2849 not enforced by IMAP4 itself)
2850 c - create and delete mailbox (CREATE new sub-mailboxes in any
2851 implementation-defined hierarchy, RENAME or DELETE mailbox)
2852 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2853 a - administer (perform SETACL)" group)
2856 ,mailbox ',method ',acl form)))))
2858 ;; Group sorting commands
2859 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2861 (defun gnus-group-sort-groups (func &optional reverse)
2862 "Sort the group buffer according to FUNC.
2863 When used interactively, the sorting function used will be
2864 determined by the `gnus-group-sort-function' variable.
2865 If REVERSE (the prefix), reverse the sorting order."
2866 (interactive (list gnus-group-sort-function current-prefix-arg))
2867 (funcall gnus-group-sort-alist-function
2868 (gnus-make-sort-function func) reverse)
2869 (gnus-group-unmark-all-groups)
2870 (gnus-group-list-groups)
2871 (gnus-dribble-touch))
2873 (defun gnus-group-sort-flat (func reverse)
2874 ;; We peel off the dummy group from the alist.
2876 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2877 (pop gnus-newsrc-alist))
2879 (setq gnus-newsrc-alist
2880 (sort gnus-newsrc-alist func))
2882 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2883 ;; Regenerate the hash table.
2884 (gnus-make-hashtable-from-newsrc-alist)))
2886 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2887 "Sort the group buffer alphabetically by group name.
2888 If REVERSE, sort in reverse order."
2890 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2892 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2893 "Sort the group buffer alphabetically by real (unprefixed) group name.
2894 If REVERSE, sort in reverse order."
2896 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2898 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2899 "Sort the group buffer by number of unread articles.
2900 If REVERSE, sort in reverse order."
2902 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2904 (defun gnus-group-sort-groups-by-level (&optional reverse)
2905 "Sort the group buffer by group level.
2906 If REVERSE, sort in reverse order."
2908 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2910 (defun gnus-group-sort-groups-by-score (&optional reverse)
2911 "Sort the group buffer by group score.
2912 If REVERSE, sort in reverse order."
2914 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2916 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2917 "Sort the group buffer by group rank.
2918 If REVERSE, sort in reverse order."
2920 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2922 (defun gnus-group-sort-groups-by-method (&optional reverse)
2923 "Sort the group buffer alphabetically by back end name.
2924 If REVERSE, sort in reverse order."
2926 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2928 (defun gnus-group-sort-groups-by-server (&optional reverse)
2929 "Sort the group buffer alphabetically by server name.
2930 If REVERSE, sort in reverse order."
2932 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2934 ;;; Selected group sorting.
2936 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2937 "Sort the process/prefixed groups."
2938 (interactive (list current-prefix-arg gnus-group-sort-function))
2939 (let ((groups (gnus-group-process-prefix n)))
2940 (funcall gnus-group-sort-selected-function
2941 groups (gnus-make-sort-function func) reverse)
2942 (gnus-group-unmark-all-groups)
2943 (gnus-group-list-groups)
2944 (gnus-dribble-touch)))
2946 (defun gnus-group-sort-selected-flat (groups func reverse)
2947 (let (entries infos)
2948 ;; First find all the group entries for these groups.
2950 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2952 ;; Then sort the infos.
2956 (lambda (entry) (car entry))
2957 (setq entries (nreverse entries)))
2960 (setq infos (nreverse infos)))
2961 ;; Go through all the infos and replace the old entries
2962 ;; with the new infos.
2964 (setcar (car entries) (pop infos))
2966 ;; Update the hashtable.
2967 (gnus-make-hashtable-from-newsrc-alist)))
2969 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2970 "Sort the group buffer alphabetically by group name.
2971 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2972 sort in reverse order."
2973 (interactive (gnus-interactive "P\ny"))
2974 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2976 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2977 "Sort the group buffer alphabetically by real group name.
2978 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2979 sort in reverse order."
2980 (interactive (gnus-interactive "P\ny"))
2981 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2983 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2984 "Sort the group buffer by number of unread articles.
2985 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2986 sort in reverse order."
2987 (interactive (gnus-interactive "P\ny"))
2988 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2990 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2991 "Sort the group buffer by group level.
2992 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2993 sort in reverse order."
2994 (interactive (gnus-interactive "P\ny"))
2995 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2997 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2998 "Sort the group buffer by group score.
2999 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3000 sort in reverse order."
3001 (interactive (gnus-interactive "P\ny"))
3002 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3004 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3005 "Sort the group buffer by group rank.
3006 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3007 sort in reverse order."
3008 (interactive (gnus-interactive "P\ny"))
3009 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3011 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3012 "Sort the group buffer alphabetically by back end name.
3013 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3014 sort in reverse order."
3015 (interactive (gnus-interactive "P\ny"))
3016 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3018 ;;; Sorting predicates.
3020 (defun gnus-group-sort-by-alphabet (info1 info2)
3021 "Sort alphabetically."
3022 (string< (gnus-info-group info1) (gnus-info-group info2)))
3024 (defun gnus-group-sort-by-real-name (info1 info2)
3025 "Sort alphabetically on real (unprefixed) names."
3026 (string< (gnus-group-real-name (gnus-info-group info1))
3027 (gnus-group-real-name (gnus-info-group info2))))
3029 (defun gnus-group-sort-by-unread (info1 info2)
3030 "Sort by number of unread articles."
3031 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3032 (n2 (gnus-group-unread (gnus-info-group info1))))
3033 (< (or (and (numberp n1) n1) 0)
3034 (or (and (numberp n2) n2) 0))))
3036 (defun gnus-group-sort-by-level (info1 info2)
3038 (< (gnus-info-level info1) (gnus-info-level info2)))
3040 (defun gnus-group-sort-by-method (info1 info2)
3041 "Sort alphabetically by back end name."
3042 (string< (car (gnus-find-method-for-group
3043 (gnus-info-group info1) info1))
3044 (car (gnus-find-method-for-group
3045 (gnus-info-group info2) info2))))
3047 (defun gnus-group-sort-by-server (info1 info2)
3048 "Sort alphabetically by server name."
3049 (string< (gnus-method-to-full-server-name
3050 (gnus-find-method-for-group
3051 (gnus-info-group info1) info1))
3052 (gnus-method-to-full-server-name
3053 (gnus-find-method-for-group
3054 (gnus-info-group info2) info2))))
3056 (defun gnus-group-sort-by-score (info1 info2)
3057 "Sort by group score."
3058 (> (gnus-info-score info1) (gnus-info-score info2)))
3060 (defun gnus-group-sort-by-rank (info1 info2)
3061 "Sort by level and score."
3062 (let ((level1 (gnus-info-level info1))
3063 (level2 (gnus-info-level info2)))
3064 (or (< level1 level2)
3065 (and (= level1 level2)
3066 (> (gnus-info-score info1) (gnus-info-score info2))))))
3070 (defun gnus-group-clear-data (&optional arg)
3071 "Clear all marks and read ranges from the current group."
3073 (gnus-group-iterate arg
3076 (gnus-info-clear-data (setq info (gnus-get-info group)))
3077 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3078 (when (gnus-group-goto-group group)
3079 (gnus-group-update-group-line))))))
3081 (defun gnus-group-clear-data-on-native-groups ()
3082 "Clear all marks and read ranges from all native groups."
3084 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3085 (let ((alist (cdr gnus-newsrc-alist))
3087 (while (setq info (pop alist))
3088 (when (gnus-group-native-p (gnus-info-group info))
3089 (gnus-info-clear-data info)))
3090 (gnus-get-unread-articles)
3091 (gnus-dribble-touch)
3092 (when (gnus-y-or-n-p
3093 "Move the cache away to avoid problems in the future? ")
3094 (call-interactively 'gnus-cache-move-cache)))))
3096 (defun gnus-info-clear-data (info)
3097 "Clear all marks and read ranges from INFO."
3098 (let ((group (gnus-info-group info))
3100 (dolist (el (gnus-info-marks info))
3101 (push `(,(cdr el) add (,(car el))) action))
3102 (push `(,(gnus-info-read info) add (read)) action)
3105 (gnus-request-set-mark ,group ',action)
3106 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3107 (gnus-info-set-read ',info ',(gnus-info-read info))
3108 (when (gnus-group-goto-group ,group)
3109 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3110 (gnus-group-update-group-line))))
3111 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3113 (gnus-request-set-mark group action)
3114 (gnus-info-set-read info nil)
3115 (when (gnus-info-marks info)
3116 (gnus-info-set-marks info nil))))
3118 ;; Group catching up.
3120 (defun gnus-group-catchup-current (&optional n all)
3121 "Mark all unread articles in the current newsgroup as read.
3122 If prefix argument N is numeric, the next N newsgroups will be
3123 caught up. If ALL is non-nil, marked articles will also be marked as
3124 read. Cross references (Xref: header) of articles are ignored.
3125 The number of newsgroups that this function was unable to catch
3128 (let ((groups (gnus-group-process-prefix n))
3131 (unless groups (error "No groups selected"))
3133 (or (not gnus-interactive-catchup) ;Without confirmation?
3138 "Do you really want to mark all articles in %s as read? "
3139 "Mark all unread articles in %s as read? ")
3140 (if (= (length groups) 1)
3142 (format "these %d groups" (length groups)))))))
3144 (while (setq group (pop groups))
3145 (gnus-group-remove-mark group)
3146 ;; Virtual groups have to be given special treatment.
3147 (let ((method (gnus-find-method-for-group group)))
3148 (when (eq 'nnvirtual (car method))
3149 (nnvirtual-catchup-group
3150 (gnus-group-real-name group) (nth 1 method) all)))
3151 (if (>= (gnus-group-level group) gnus-level-zombie)
3152 (gnus-message 2 "Dead groups can't be caught up")
3154 (gnus-group-goto-group group)
3155 (gnus-group-catchup group all))
3156 (gnus-group-update-group-line)
3157 (setq ret (1+ ret)))))
3158 (gnus-group-next-unread-group 1)
3161 (defun gnus-group-catchup-current-all (&optional n)
3162 "Mark all articles in current newsgroup as read.
3163 Cross references (Xref: header) of articles are ignored."
3165 (gnus-group-catchup-current n 'all))
3167 (defun gnus-group-catchup (group &optional all)
3168 "Mark all articles in GROUP as read.
3169 If ALL is non-nil, all articles are marked as read.
3170 The return value is the number of articles that were marked as read,
3171 or nil if no action could be taken."
3172 (let* ((entry (gnus-group-entry group))
3174 (marks (gnus-info-marks (nth 2 entry)))
3175 (unread (gnus-sequence-of-unread-articles group)))
3176 ;; Remove entries for this group.
3177 (nnmail-purge-split-history (gnus-group-real-name group))
3178 ;; Do the updating only if the newsgroup isn't killed.
3179 (if (not (numberp (car entry)))
3180 (gnus-message 1 "Can't catch up %s; non-active group" group)
3181 (gnus-update-read-articles group nil)
3183 ;; Nix out the lists of marks and dormants.
3184 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3186 (list (cdr (assq 'dormant marks))
3188 (setq unread (gnus-range-add (gnus-range-add
3189 unread (cdr (assq 'dormant marks)))
3190 (cdr (assq 'tick marks))))
3191 (gnus-add-marked-articles group 'tick nil nil 'force)
3192 (gnus-add-marked-articles group 'dormant nil nil 'force))
3193 ;; Do auto-expirable marks if that's required.
3194 (when (gnus-group-auto-expirable-p group)
3195 (gnus-range-map (lambda (article)
3196 (gnus-add-marked-articles group 'expire (list article))
3197 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3199 (let ((gnus-newsgroup-name group))
3200 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3203 (defun gnus-group-expire-articles (&optional n)
3204 "Expire all expirable articles in the current newsgroup.
3205 Uses the process/prefix convention."
3207 (let ((groups (gnus-group-process-prefix n))
3210 (error "No groups to expire"))
3211 (while (setq group (pop groups))
3212 (gnus-group-remove-mark group)
3213 (gnus-group-expire-articles-1 group)
3214 (gnus-dribble-touch)
3215 (gnus-group-position-point))))
3217 (defun gnus-group-expire-articles-1 (group)
3218 (when (gnus-check-backend-function 'request-expire-articles group)
3219 (gnus-message 6 "Expiring articles in %s..." group)
3220 (let* ((info (gnus-get-info group))
3221 (expirable (if (gnus-group-total-expirable-p group)
3222 (cons nil (gnus-list-of-read-articles group))
3223 (assq 'expire (gnus-info-marks info))))
3224 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3225 (nnmail-expiry-target
3226 (or (gnus-group-find-parameter group 'expiry-target)
3227 nnmail-expiry-target)))
3229 (gnus-check-group group)
3232 (gnus-compress-sequence
3234 ;; We set the expiry variables to the group
3236 (let ((nnmail-expiry-wait-function nil)
3237 (nnmail-expiry-wait expiry-wait))
3238 (gnus-request-expire-articles
3239 (gnus-uncompress-sequence (cdr expirable)) group))
3240 ;; Just expire using the normal expiry values.
3241 (gnus-request-expire-articles
3242 (gnus-uncompress-sequence (cdr expirable)) group))))
3243 (gnus-close-group group))
3244 (gnus-message 6 "Expiring articles in %s...done" group)
3245 ;; Return the list of un-expired articles.
3248 (defun gnus-group-expire-all-groups ()
3249 "Expire all expirable articles in all newsgroups."
3252 (gnus-message 5 "Expiring...")
3253 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3254 (cdr gnus-newsrc-alist))))
3255 (gnus-group-expire-articles nil)))
3256 (gnus-group-position-point)
3257 (gnus-message 5 "Expiring...done"))
3259 (defun gnus-group-set-current-level (n level)
3260 "Set the level of the next N groups to LEVEL."
3265 (unless (gnus-group-process-prefix current-prefix-arg)
3266 (error "No group on the current line"))
3268 (let ((s (read-string
3269 (format "Level (default %s): "
3270 (or (gnus-group-group-level)
3271 gnus-level-default-subscribed)))))
3272 (if (string-match "^\\s-*$" s)
3273 (int-to-string (or (gnus-group-group-level)
3274 gnus-level-default-subscribed))
3276 (unless (and (>= level 1) (<= level gnus-level-killed))
3277 (error "Invalid level: %d" level))
3278 (dolist (group (gnus-group-process-prefix n))
3279 (gnus-group-remove-mark group)
3280 (gnus-message 6 "Changed level of %s from %d to %d"
3281 group (or (gnus-group-group-level) gnus-level-killed)
3283 (gnus-group-change-level
3284 group level (or (gnus-group-group-level) gnus-level-killed))
3285 (gnus-group-update-group-line))
3286 (gnus-group-position-point))
3288 (defun gnus-group-unsubscribe (&optional n)
3289 "Unsubscribe the current group."
3291 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3293 (defun gnus-group-subscribe (&optional n)
3294 "Subscribe the current group."
3296 (gnus-group-unsubscribe-current-group n 'subscribe))
3298 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3299 "Toggle subscription of the current group.
3300 If given numerical prefix, toggle the N next groups."
3302 (dolist (group (gnus-group-process-prefix n))
3303 (gnus-group-remove-mark group)
3304 (gnus-group-unsubscribe-group
3307 ((eq do-sub 'unsubscribe)
3308 gnus-level-default-unsubscribed)
3309 ((eq do-sub 'subscribe)
3310 gnus-level-default-subscribed)
3311 ((<= (gnus-group-group-level) gnus-level-subscribed)
3312 gnus-level-default-unsubscribed)
3314 gnus-level-default-subscribed))
3316 (gnus-group-update-group-line))
3317 (gnus-group-next-group 1))
3319 (defun gnus-group-unsubscribe-group (group &optional level silent)
3320 "Toggle subscription to GROUP.
3321 Killed newsgroups are subscribed. If SILENT, don't try to update the
3324 (list (completing-read
3325 "Group: " gnus-active-hashtb nil
3326 (gnus-read-active-file-p)
3328 'gnus-group-history)))
3329 (let ((newsrc (gnus-group-entry group)))
3331 ((string-match "^[ \t]*$" group)
3332 (error "Empty group name"))
3334 ;; Toggle subscription flag.
3335 (gnus-group-change-level
3336 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3337 gnus-level-subscribed)
3338 (1+ gnus-level-subscribed)
3339 gnus-level-default-subscribed)))
3341 (gnus-group-update-group group)))
3342 ((and (stringp group)
3343 (or (not (gnus-read-active-file-p))
3344 (gnus-active group)))
3345 ;; Add new newsgroup.
3346 (gnus-group-change-level
3348 (if level level gnus-level-default-subscribed)
3349 (or (and (member group gnus-zombie-list)
3352 (when (gnus-group-group-name)
3353 (gnus-group-entry (gnus-group-group-name))))
3355 (gnus-group-update-group group)))
3356 (t (error "No such newsgroup: %s" group)))
3357 (gnus-group-position-point)))
3359 (defun gnus-group-transpose-groups (n)
3360 "Move the current newsgroup up N places.
3361 If given a negative prefix, move down instead. The difference between
3362 N and the number of steps taken is returned."
3364 (unless (gnus-group-group-name)
3365 (error "No group on current line"))
3366 (gnus-group-kill-group 1)
3368 (forward-line (- n))
3369 (gnus-group-yank-group)
3370 (gnus-group-position-point)))
3372 (defun gnus-group-kill-all-zombies (&optional dummy)
3373 "Kill all zombie newsgroups.
3374 The optional DUMMY should always be nil."
3375 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3377 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3378 (setq gnus-zombie-list nil)
3379 (gnus-dribble-touch)
3380 (gnus-group-list-groups)))
3382 (defun gnus-group-kill-region (begin end)
3383 "Kill newsgroups in current region (excluding current point).
3384 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3397 (beginning-of-line) ;Important when LINES < 1
3398 (gnus-group-kill-group lines)))
3400 (defun gnus-group-kill-group (&optional n discard)
3401 "Kill the next N groups.
3402 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3403 However, only groups that were alive can be yanked; already killed
3404 groups or zombie groups can't be yanked.
3405 The return value is the name of the group that was killed, or a list
3408 (let ((buffer-read-only nil)
3409 (groups (gnus-group-process-prefix n))
3410 group entry level out)
3411 (if (< (length groups) 10)
3412 ;; This is faster when there are few groups.
3414 (push (setq group (pop groups)) out)
3415 (gnus-group-remove-mark group)
3416 (setq level (gnus-group-group-level))
3418 (when (and (not discard)
3419 (setq entry (gnus-group-entry group)))
3422 (gnus-group-goto-group ,(gnus-group-group-name))
3423 (gnus-group-yank-group)))
3424 (push (cons (car entry) (nth 2 entry))
3425 gnus-list-of-killed-groups))
3426 (gnus-group-change-level
3427 (if entry entry group) gnus-level-killed (if entry nil level))
3428 (message "Killed group %s" group))
3429 ;; If there are lots and lots of groups to be killed, we use
3430 ;; this thing instead.
3431 (dolist (group (nreverse groups))
3432 (gnus-group-remove-mark group)
3434 (push group gnus-killed-list)
3435 (setq gnus-newsrc-alist
3436 (delq (assoc group gnus-newsrc-alist)
3438 (when gnus-group-change-level-function
3439 (funcall gnus-group-change-level-function
3440 group gnus-level-killed 3))
3442 ((setq entry (gnus-group-entry group))
3443 (push (cons (car entry) (nth 2 entry))
3444 gnus-list-of-killed-groups)
3445 (setcdr (cdr entry) (cdddr entry)))
3446 ((member group gnus-zombie-list)
3447 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3448 ;; There may be more than one instance displayed.
3449 (while (gnus-group-goto-group group)
3450 (gnus-delete-line)))
3451 (gnus-make-hashtable-from-newsrc-alist))
3453 (gnus-group-position-point)
3454 (if (< (length out) 2) (car out) (nreverse out))))
3456 (defun gnus-group-yank-group (&optional arg)
3457 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3458 The numeric ARG specifies how many newsgroups are to be yanked. The
3459 name of the newsgroup yanked is returned, or (if several groups are
3460 yanked) a list of yanked groups is returned."
3462 (setq arg (or arg 1))
3463 (let (info group prev out)
3464 (while (>= (decf arg) 0)
3465 (when (not (setq info (pop gnus-list-of-killed-groups)))
3466 (error "No more newsgroups to yank"))
3467 (push (setq group (nth 1 info)) out)
3468 ;; Find which newsgroup to insert this one before - search
3469 ;; backward until something suitable is found. If there are no
3470 ;; other newsgroups in this buffer, just make this newsgroup the
3472 (setq prev (gnus-group-group-name))
3473 (gnus-group-change-level
3474 info (gnus-info-level (cdr info)) gnus-level-killed
3475 (and prev (gnus-group-entry prev))
3477 (gnus-group-insert-group-line-info group)
3479 `(when (gnus-group-goto-group ,group)
3480 (gnus-group-kill-group 1))))
3482 (gnus-group-position-point)
3483 (if (< (length out) 2) (car out) (nreverse out))))
3485 (defun gnus-group-kill-level (level)
3486 "Kill all groups that is on a certain LEVEL."
3487 (interactive "nKill all groups on level: ")
3489 ((= level gnus-level-zombie)
3490 (setq gnus-killed-list
3491 (nconc gnus-zombie-list gnus-killed-list))
3492 (setq gnus-zombie-list nil))
3493 ((and (< level gnus-level-zombie)
3495 (or gnus-expert-user
3498 "Do you really want to kill all groups on level %d? "
3500 (let* ((prev gnus-newsrc-alist)
3503 (if (= (gnus-info-level (car alist)) level)
3505 (push (gnus-info-group (car alist)) gnus-killed-list)
3506 (setcdr prev (cdr alist)))
3508 (setq alist (cdr alist)))
3509 (gnus-make-hashtable-from-newsrc-alist)
3510 (gnus-group-list-groups)))
3512 (error "Can't kill; invalid level: %d" level))))
3514 (defun gnus-group-list-all-groups (&optional arg)
3515 "List all newsgroups with level ARG or lower.
3516 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3517 unsubscribed groups."
3519 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3521 ;; Redefine this to list ALL killed groups if prefix arg used.
3522 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3523 (defun gnus-group-list-killed (&optional arg)
3524 "List all killed newsgroups in the group buffer.
3525 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3526 entail asking the server for the groups."
3528 ;; Find all possible killed newsgroups if arg.
3530 (gnus-get-killed-groups))
3531 (if (not gnus-killed-list)
3532 (gnus-message 6 "No killed groups")
3533 (let (gnus-group-list-mode)
3534 (funcall gnus-group-prepare-function
3535 gnus-level-killed t gnus-level-killed))
3536 (goto-char (point-min)))
3537 (gnus-group-position-point))
3539 (defun gnus-group-list-zombies ()
3540 "List all zombie newsgroups in the group buffer."
3542 (if (not gnus-zombie-list)
3543 (gnus-message 6 "No zombie groups")
3544 (let (gnus-group-list-mode)
3545 (funcall gnus-group-prepare-function
3546 gnus-level-zombie t gnus-level-zombie))
3547 (goto-char (point-min)))
3548 (gnus-group-position-point))
3550 (defun gnus-group-list-active ()
3551 "List all groups that are available from the server(s)."
3553 ;; First we make sure that we have really read the active file.
3554 (unless (gnus-read-active-file-p)
3555 (let ((gnus-read-active-file t)
3556 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3557 (gnus-read-active-file)))
3558 ;; Find all groups and sort them.
3566 (push (symbol-name sym) list)))
3570 (buffer-read-only nil)
3574 (setq group (pop groups))
3575 (gnus-add-text-properties
3576 (point) (prog1 (1+ (point))
3578 (gnus-group-decoded-name group)
3580 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3582 'gnus-level (inline (gnus-group-level group)))))
3583 (goto-char (point-min))))
3585 (defun gnus-activate-all-groups (level)
3586 "Activate absolutely all groups."
3587 (interactive (list gnus-level-unsubscribed))
3588 (let ((gnus-activate-level level)
3589 (gnus-activate-foreign-newsgroups level))
3590 (gnus-group-get-new-news)))
3592 (defun gnus-group-get-new-news (&optional arg)
3593 "Get newly arrived articles.
3594 If ARG is a number, it specifies which levels you are interested in
3595 re-scanning. If ARG is non-nil and not a number, this will force
3596 \"hard\" re-reading of the active files from all servers."
3599 (let ((gnus-inhibit-demon t)
3600 ;; Binding this variable will inhibit multiple fetchings
3601 ;; of the same mail source.
3602 (nnmail-fetched-sources (list t)))
3603 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3604 (gnus-run-hooks 'gnus-get-new-news-hook)
3606 ;; Read any slave files.
3608 (gnus-master-read-slave-newsrc))
3610 ;; We might read in new NoCeM messages here.
3611 (when (and gnus-use-nocem
3613 (gnus-nocem-scan-groups))
3614 ;; If ARG is not a number, then we read the active file.
3615 (when (and arg (not (numberp arg)))
3616 (let ((gnus-read-active-file t))
3617 (gnus-read-active-file))
3620 ;; If the user wants it, we scan for new groups.
3621 (when (eq gnus-check-new-newsgroups 'always)
3622 (gnus-find-new-newsgroups)))
3624 (setq arg (gnus-group-default-level arg t))
3625 (if (and gnus-read-active-file (not arg))
3627 (gnus-read-active-file)
3628 (gnus-get-unread-articles arg))
3629 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3630 (gnus-get-unread-articles arg)))
3631 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3632 (gnus-group-list-groups (and (numberp arg)
3633 (max (car gnus-group-list-mode) arg)))))
3635 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3636 "Check for newly arrived news in the current group (and the N-1 next groups).
3637 The difference between N and the number of newsgroup checked is returned.
3638 If N is negative, this group and the N-1 previous groups will be checked.
3639 If DONT-SCAN is non-nil, scan non-activated groups as well."
3641 (let* ((groups (gnus-group-process-prefix n))
3642 (ret (if (numberp n) (- n (length groups)) 0))
3646 (gnus-inhibit-demon t)
3647 ;; Binding this variable will inhibit multiple fetchings
3648 ;; of the same mail source.
3649 (nnmail-fetched-sources (list t)))
3650 (gnus-run-hooks 'gnus-get-new-news-hook)
3651 (while (setq group (pop groups))
3652 (gnus-group-remove-mark group)
3653 ;; Bypass any previous denials from the server.
3654 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3655 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3656 (let ((info (gnus-get-info group))
3657 (active (gnus-active group)))
3659 (gnus-request-update-info info method))
3660 (gnus-get-unread-articles-in-group info active)
3661 (unless (gnus-virtual-group-p group)
3662 (gnus-close-group group))
3664 (gnus-agent-save-group-info
3665 method (gnus-group-real-name group) active))
3666 (gnus-group-update-group group))
3667 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3669 (gnus-error 3 "Server denied access")
3670 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3673 (when gnus-goto-next-group-when-activating
3674 (gnus-group-next-unread-group 1 t))
3675 (gnus-summary-position-point)
3678 (defun gnus-group-fetch-faq (group &optional faq-dir)
3679 "Fetch the FAQ for the current group.
3680 If given a prefix argument, prompt for the FAQ dir
3684 (gnus-group-group-name)
3685 (when current-prefix-arg
3687 "FAQ dir: " (and (listp gnus-group-faq-directory)
3689 gnus-group-faq-directory))))))
3691 (error "No group name given"))
3692 (let ((dirs (or faq-dir gnus-group-faq-directory))
3694 (unless (listp dirs)
3695 (setq dirs (list dirs)))
3696 (while (and (not found)
3697 (setq dir (pop dirs)))
3698 (let ((name (gnus-group-real-name group)))
3699 (setq file (expand-file-name name dir)))
3700 (if (not (file-exists-p file))
3701 (gnus-message 1 "No such file: %s" file)
3702 (let ((enable-local-variables nil))
3706 (defun gnus-group-fetch-charter (group)
3707 "Fetch the charter for the current group.
3708 If given a prefix argument, prompt for a group."
3710 (list (or (when current-prefix-arg
3711 (completing-read "Group: " gnus-active-hashtb))
3712 (gnus-group-group-name)
3713 gnus-newsgroup-name)))
3715 (error "No group name given"))
3717 (condition-case nil (require 'url-http) (error nil))
3718 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3720 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3721 (setq hierarchy (match-string 1 name))
3722 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3723 (if (fboundp 'url-http-file-exists-p)
3724 (url-http-file-exists-p (eval url))
3726 (browse-url (eval url))
3727 (setq url (concat "http://" hierarchy
3728 ".news-admin.org/charters/" name))
3729 (if (and (fboundp 'url-http-file-exists-p)
3730 (url-http-file-exists-p url))
3732 (gnus-group-fetch-control group))))))
3734 (defun gnus-group-fetch-control (group)
3735 "Fetch the archived control messages for the current group.
3736 If given a prefix argument, prompt for a group."
3738 (list (or (when current-prefix-arg
3739 (completing-read "Group: " gnus-active-hashtb))
3740 (gnus-group-group-name)
3741 gnus-newsgroup-name)))
3743 (error "No group name given"))
3744 (let ((name (gnus-group-real-name group))
3746 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3747 (setq hierarchy (match-string 1 name))
3748 (if gnus-group-fetch-control-use-browse-url
3749 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3750 hierarchy "/" name ".gz"))
3751 (let ((enable-local-variables nil))
3752 (gnus-group-read-ephemeral-group
3754 `(nndoc ,group (nndoc-address
3755 ,(find-file-noselect
3756 (concat "/ftp@ftp.isc.org:/usenet/control/"
3757 hierarchy "/" name ".gz")))
3758 (nndoc-article-type mbox)) t nil nil))))))
3760 (defun gnus-group-describe-group (force &optional group)
3761 "Display a description of the current newsgroup."
3762 (interactive (list current-prefix-arg (gnus-group-group-name)))
3763 (let* ((method (gnus-find-method-for-group group))
3764 (mname (gnus-group-prefixed-name "" method))
3767 gnus-description-hashtb)
3768 (gnus-sethash mname nil gnus-description-hashtb))
3770 (error "No group name given"))
3771 (when (or (and gnus-description-hashtb
3772 ;; We check whether this group's method has been
3773 ;; queried for a description file.
3774 (gnus-gethash mname gnus-description-hashtb))
3775 (setq desc (gnus-group-get-description group))
3776 (gnus-read-descriptions-file method))
3778 (or desc (gnus-gethash group gnus-description-hashtb)
3779 "No description available")))))
3781 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3782 (defun gnus-group-describe-all-groups (&optional force)
3783 "Pop up a buffer with descriptions of all newsgroups."
3786 (setq gnus-description-hashtb nil))
3787 (when (not (or gnus-description-hashtb
3788 (gnus-read-all-descriptions-files)))
3789 (error "Couldn't request descriptions file"))
3790 (let ((buffer-read-only nil)
3796 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3797 (insert (format " *: %-20s %s\n"
3798 (gnus-group-name-decode
3799 (symbol-name group) charset)
3800 (gnus-group-name-decode
3801 (symbol-value group) charset))))
3802 (gnus-add-text-properties
3803 b (1+ b) (list 'gnus-group group
3804 'gnus-unread t 'gnus-marked nil
3805 'gnus-level (1+ gnus-level-subscribed))))
3806 gnus-description-hashtb)
3807 (goto-char (point-min))
3808 (gnus-group-position-point)))
3810 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3811 (defun gnus-group-apropos (regexp &optional search-description)
3812 "List all newsgroups that have names that match a regexp."
3813 (interactive "sGnus apropos (regexp): ")
3815 (obuf (current-buffer))
3817 ;; Go through all newsgroups that are known to Gnus.
3820 (and (symbol-name group)
3821 (string-match regexp (symbol-name group))
3822 (symbol-value group)
3823 (push (symbol-name group) groups)))
3825 ;; Also go through all descriptions that are known to Gnus.
3826 (when search-description
3829 (and (string-match regexp (symbol-value group))
3830 (push (symbol-name group) groups)))
3831 gnus-description-hashtb))
3833 (gnus-message 3 "No groups matched \"%s\"." regexp)
3834 ;; Print out all the groups.
3836 (pop-to-buffer "*Gnus Help*")
3837 (buffer-disable-undo)
3839 (setq groups (sort groups 'string<))
3841 ;; Groups may be entered twice into the list of groups.
3842 (when (not (string= (car groups) prev))
3843 (setq prev (car groups))
3844 (let ((charset (gnus-group-name-charset nil prev)))
3845 (insert (gnus-group-name-decode prev charset) "\n")
3846 (when (and gnus-description-hashtb
3847 (setq des (gnus-gethash (car groups)
3848 gnus-description-hashtb)))
3849 (insert " " (gnus-group-name-decode des charset) "\n"))))
3850 (setq groups (cdr groups)))
3851 (goto-char (point-min))))
3852 (pop-to-buffer obuf)))
3854 (defun gnus-group-description-apropos (regexp)
3855 "List all newsgroups that have names or descriptions that match REGEXP."
3856 (interactive "sGnus description apropos (regexp): ")
3857 (when (not (or gnus-description-hashtb
3858 (gnus-read-all-descriptions-files)))
3859 (error "Couldn't request descriptions file"))
3860 (gnus-group-apropos regexp t))
3862 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3863 (defun gnus-group-list-matching (level regexp &optional all lowest)
3864 "List all groups with unread articles that match REGEXP.
3865 If the prefix LEVEL is non-nil, it should be a number that says which
3866 level to cut off listing groups.
3867 If ALL, also list groups with no unread articles.
3868 If LOWEST, don't list groups with level lower than LOWEST.
3870 This command may read the active file."
3871 (interactive "P\nsList newsgroups matching: ")
3872 ;; First make sure active file has been read.
3874 (> (prefix-numeric-value level) gnus-level-killed))
3875 (gnus-get-killed-groups))
3876 (funcall gnus-group-prepare-function
3877 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3878 (goto-char (point-min))
3879 (gnus-group-position-point))
3881 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3882 "List all groups that match REGEXP.
3883 If the prefix LEVEL is non-nil, it should be a number that says which
3884 level to cut off listing groups.
3885 If LOWEST, don't list groups with level lower than LOWEST."
3886 (interactive "P\nsList newsgroups matching: ")
3888 (setq level (prefix-numeric-value level)))
3889 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3891 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3892 (defun gnus-group-save-newsrc (&optional force)
3893 "Save the Gnus startup files.
3894 If FORCE, force saving whether it is necessary or not."
3896 (gnus-save-newsrc-file force))
3898 (defun gnus-group-restart (&optional arg)
3899 "Force Gnus to read the .newsrc file."
3901 (when (gnus-yes-or-no-p
3902 (format "Are you sure you want to restart Gnus? "))
3903 (gnus-save-newsrc-file)
3907 (defun gnus-group-read-init-file ()
3908 "Read the Gnus elisp init file."
3910 (gnus-read-init-file)
3911 (gnus-message 5 "Read %s" gnus-init-file))
3913 (defun gnus-group-check-bogus-groups (&optional silent)
3914 "Check bogus newsgroups.
3915 If given a prefix, don't ask for confirmation before removing a bogus
3918 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3919 (gnus-group-list-groups))
3921 (defun gnus-group-find-new-groups (&optional arg)
3922 "Search for new groups and add them.
3923 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3924 With 1 C-u, use the `ask-server' method to query the server for new
3926 With 2 C-u's, use most complete method possible to query the server
3927 for new groups, and subscribe the new groups as zombies."
3929 (gnus-find-new-newsgroups (or arg 1))
3930 (gnus-group-list-groups))
3932 (defun gnus-group-edit-global-kill (&optional article group)
3933 "Edit the global kill file.
3934 If GROUP, edit that local kill file instead."
3936 (setq gnus-current-kill-article article)
3937 (gnus-kill-file-edit-file group)
3940 (substitute-command-keys
3941 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3942 (if group "local" "global")))))
3944 (defun gnus-group-edit-local-kill (article group)
3945 "Edit a local kill file."
3946 (interactive (list nil (gnus-group-group-name)))
3947 (gnus-group-edit-global-kill article group))
3949 (defun gnus-group-force-update ()
3950 "Update `.newsrc' file."
3952 (gnus-save-newsrc-file))
3954 (defvar gnus-backlog-articles)
3956 (defun gnus-group-suspend ()
3957 "Suspend the current Gnus session.
3958 In fact, cleanup buffers except for group mode buffer.
3959 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3961 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3962 (gnus-offer-save-summaries)
3963 ;; Kill Gnus buffers except for group mode buffer.
3964 (let ((group-buf (get-buffer gnus-group-buffer)))
3965 (mapcar (lambda (buf)
3966 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3967 (with-current-buffer buf
3968 (eq major-mode 'message-mode)))
3969 (gnus-kill-buffer buf)))
3971 (setq gnus-backlog-articles nil)
3972 (gnus-kill-gnus-frames)
3974 (bury-buffer group-buf)
3975 (delete-windows-on group-buf t))))
3977 (defun gnus-group-clear-dribble ()
3978 "Clear all information from the dribble buffer."
3980 (gnus-dribble-clear)
3981 (gnus-message 7 "Cleared dribble buffer"))
3983 (defun gnus-group-exit ()
3984 "Quit reading news after updating .newsrc.eld and .newsrc.
3985 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3988 (or noninteractive ;For gnus-batch-kill
3989 (not gnus-interactive-exit) ;Without confirmation
3991 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3992 (gnus-run-hooks 'gnus-exit-gnus-hook)
3993 ;; Offer to save data from non-quitted summary buffers.
3994 (gnus-offer-save-summaries)
3995 ;; Save the newsrc file(s).
3996 (gnus-save-newsrc-file)
3998 (gnus-close-backends)
3999 ;; Reset everything.
4001 ;; Allow the user to do things after cleaning up.
4002 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4004 (defun gnus-group-quit ()
4005 "Quit reading news without updating .newsrc.eld or .newsrc.
4006 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4008 (when (or noninteractive ;For gnus-batch-kill
4009 (zerop (buffer-size))
4010 (not (gnus-server-opened gnus-select-method))
4012 (not gnus-current-startup-file)
4014 (format "Quit reading news without saving %s? "
4015 (file-name-nondirectory gnus-current-startup-file))))
4016 (gnus-run-hooks 'gnus-exit-gnus-hook)
4017 (gnus-configure-windows 'group t)
4018 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4019 (not (zerop (save-excursion
4020 (set-buffer gnus-dribble-buffer)
4023 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4025 (gnus-close-backends)
4027 (gnus-kill-buffer gnus-group-buffer)
4028 ;; Allow the user to do things after cleaning up.
4029 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4031 (defun gnus-group-describe-briefly ()
4032 "Give a one line description of the group mode commands."
4034 (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")))
4036 (defun gnus-group-browse-foreign-server (method)
4037 "Browse a foreign news server.
4038 If called interactively, this function will ask for a select method
4039 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4040 If not, METHOD should be a list where the first element is the method
4041 and the second element is the address."
4043 (list (let ((how (completing-read
4045 (append gnus-valid-select-methods gnus-server-alist)
4046 nil t (cons "nntp" 0) 'gnus-method-history)))
4047 ;; We either got a back end name or a virtual server name.
4048 ;; If the first, we also need an address.
4049 (if (assoc how gnus-valid-select-methods)
4051 ;; Suggested by mapjph@bath.ac.uk.
4054 (mapcar 'list gnus-secondary-servers)))
4055 ;; We got a server name.
4057 (gnus-browse-foreign-server method))
4059 (defun gnus-group-set-info (info &optional method-only-group part)
4060 (when (or info part)
4061 (let* ((entry (gnus-group-entry
4062 (or method-only-group (gnus-info-group info))))
4064 (info (if method-only-group (nth 2 entry) info))
4066 (when method-only-group
4068 (error "Trying to change non-existent group %s" method-only-group))
4069 ;; We have received parts of the actual group info - either the
4070 ;; select method or the group parameters. We first check
4071 ;; whether we have to extend the info, and if so, do that.
4072 (let ((len (length info))
4073 (total (if (eq part 'method) 5 6)))
4075 (setcdr (nthcdr (1- len) info)
4076 (make-list (- total len) nil)))
4077 ;; Then we enter the new info.
4078 (setcar (nthcdr (1- total) info) part-info)))
4080 ;; This is a new group, so we just create it.
4082 (set-buffer gnus-group-buffer)
4083 (setq method (gnus-info-method info))
4084 (when (gnus-server-equal method "native")
4087 (set-buffer gnus-group-buffer)
4089 ;; It's a foreign group...
4090 (gnus-group-make-group
4091 (gnus-group-real-name (gnus-info-group info))
4092 (if (stringp method) method
4093 (prin1-to-string (car method)))
4095 (nth 1 (gnus-info-method info))))
4096 ;; It's a native group.
4097 (gnus-group-make-group (gnus-info-group info))))
4098 (gnus-message 6 "Note: New group created")
4100 (gnus-group-entry (gnus-group-prefixed-name
4101 (gnus-group-real-name (gnus-info-group info))
4102 (or (gnus-info-method info) gnus-select-method))))))
4103 ;; Whether it was a new group or not, we now have the entry, so we
4104 ;; can do the update.
4107 (setcar (nthcdr 2 entry) info)
4108 (when (and (not (eq (car entry) t))
4109 (gnus-active (gnus-info-group info)))
4110 (setcar entry (length
4111 (gnus-list-of-unread-articles (car info))))))
4112 (error "No such group: %s" (gnus-info-group info))))))
4114 (defun gnus-group-set-method-info (group select-method)
4115 (gnus-group-set-info select-method group 'method))
4117 (defun gnus-group-set-params-info (group params)
4118 (gnus-group-set-info params group 'params))
4120 (defun gnus-add-marked-articles (group type articles &optional info force)
4121 ;; Add ARTICLES of TYPE to the info of GROUP.
4122 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4123 ;; add, but replace marked articles of TYPE with ARTICLES.
4124 (let ((info (or info (gnus-get-info group)))
4127 (and (not (setq marked (nthcdr 3 info)))
4129 (setcdr (nthcdr 2 info)
4130 (list (list (cons type (gnus-compress-sequence
4132 (and (not (setq m (assq type (car marked))))
4135 (cons (cons type (gnus-compress-sequence articles t) )
4139 (setcar (nthcdr 3 info)
4140 (gnus-delete-alist type (car marked)))
4141 (setcdr m (gnus-compress-sequence articles t)))
4142 (setcdr m (gnus-compress-sequence
4143 (sort (nconc (gnus-uncompress-range (cdr m))
4144 (copy-sequence articles)) '<) t))))))
4146 (defun gnus-add-mark (group mark article)
4147 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4148 (let ((buffer (gnus-summary-buffer-name group)))
4149 (if (gnus-buffer-live-p buffer)
4151 (set-buffer (get-buffer buffer))
4152 (gnus-summary-add-mark article mark))
4153 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4157 ;;; Group timestamps
4160 (defun gnus-group-set-timestamp ()
4161 "Change the timestamp of the current group to the current time.
4162 This function can be used in hooks like `gnus-select-group-hook'
4163 or `gnus-group-catchup-group-hook'."
4164 (when gnus-newsgroup-name
4165 (let ((time (current-time)))
4166 (setcdr (cdr time) nil)
4167 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4169 (defsubst gnus-group-timestamp (group)
4170 "Return the timestamp for GROUP."
4171 (gnus-group-get-parameter group 'timestamp t))
4173 (defun gnus-group-timestamp-delta (group)
4174 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4175 (let* ((time (or (gnus-group-timestamp group)
4177 (delta (subtract-time (current-time) time)))
4178 (+ (* (nth 0 delta) 65536.0)
4181 (defun gnus-group-timestamp-string (group)
4182 "Return a string of the timestamp for GROUP."
4183 (let ((time (gnus-group-timestamp group)))
4186 (gnus-time-iso8601 time))))
4188 (defun gnus-group-list-cached (level &optional lowest)
4189 "List all groups with cached articles.
4190 If the prefix LEVEL is non-nil, it should be a number that says which
4191 level to cut off listing groups.
4192 If LOWEST, don't list groups with level lower than LOWEST.
4194 This command may read the active file."
4197 (setq level (prefix-numeric-value level)))
4198 (when (or (not level) (>= level gnus-level-zombie))
4200 (funcall gnus-group-prepare-function
4201 (or level gnus-level-subscribed)
4203 (let ((marks (gnus-info-marks info)))
4204 (assq 'cache marks)))
4207 (or (gnus-gethash group
4208 gnus-cache-active-hashtb)
4209 ;; Cache active file might use "."
4212 (mapconcat 'identity
4213 (split-string group ":")
4215 gnus-cache-active-hashtb))))
4216 (goto-char (point-min))
4217 (gnus-group-position-point))
4219 (defun gnus-group-list-dormant (level &optional lowest)
4220 "List all groups with dormant articles.
4221 If the prefix LEVEL is non-nil, it should be a number that says which
4222 level to cut off listing groups.
4223 If LOWEST, don't list groups with level lower than LOWEST.
4225 This command may read the active file."
4228 (setq level (prefix-numeric-value level)))
4229 (when (or (not level) (>= level gnus-level-zombie))
4231 (funcall gnus-group-prepare-function
4232 (or level gnus-level-subscribed)
4234 (let ((marks (gnus-info-marks info)))
4235 (assq 'dormant marks)))
4238 (goto-char (point-min))
4239 (gnus-group-position-point))
4241 (defun gnus-group-listed-groups ()
4242 "Return a list of listed groups."
4244 (goto-char (point-min))
4245 (while (setq point (text-property-not-all (point) (point-max)
4248 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4252 (defun gnus-group-list-plus (&optional args)
4253 "List groups plus the current selection."
4255 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4256 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4258 (push last-command-event unread-command-events)
4259 (if (featurep 'xemacs)
4260 (push (make-event 'key-press '(key ?A)) unread-command-events)
4261 (push ?A unread-command-events))
4262 (let (gnus-pick-mode keys)
4263 (setq keys (if (featurep 'xemacs)
4264 (events-to-keys (read-key-sequence nil))
4265 (read-key-sequence nil)))
4266 (setq func (lookup-key (current-local-map) keys)))
4270 (call-interactively func))))
4272 (defun gnus-group-list-flush (&optional args)
4273 "Flush groups from the current selection."
4275 (let ((gnus-group-list-option 'flush))
4276 (gnus-group-list-plus args)))
4278 (defun gnus-group-list-limit (&optional args)
4279 "List groups limited within the current selection."
4281 (let ((gnus-group-list-option 'limit))
4282 (gnus-group-list-plus args)))
4284 (defun gnus-group-mark-article-read (group article)
4285 "Mark ARTICLE read."
4286 (let ((buffer (gnus-summary-buffer-name group))
4287 (mark gnus-read-mark)
4289 (if (get-buffer buffer)
4290 (with-current-buffer buffer
4291 (setq active gnus-newsgroup-active)
4292 (gnus-activate-group group)
4293 (when gnus-newsgroup-prepared
4294 (when (and gnus-newsgroup-auto-expire
4295 (memq mark gnus-auto-expirable-marks))
4296 (setq mark gnus-expirable-mark))
4297 (setq mark (gnus-request-update-mark
4298 group article mark))
4299 (gnus-mark-article-as-read article mark)
4300 (setq gnus-newsgroup-active (gnus-active group))
4302 (setq n (1+ (cdr active)))
4303 (while (<= n (cdr gnus-newsgroup-active))
4304 (unless (eq n article)
4305 (push n gnus-newsgroup-unselected))
4307 (setq gnus-newsgroup-unselected
4308 (nreverse gnus-newsgroup-unselected)))))
4309 (gnus-activate-group group)
4310 (gnus-group-make-articles-read group (list article))
4311 (when (gnus-group-auto-expirable-p group)
4312 (gnus-add-marked-articles
4313 group 'expire (list article))))))
4315 (provide 'gnus-group)
4317 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4318 ;;; gnus-group.el ends here