1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %t Estimated total number of articles (integer)
160 %y Number of unread, unticked articles (integer)
161 %G Group name (string)
162 %g Qualified group name (string)
163 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
164 %C Group comment (string)
165 %D Group description (string)
166 %s Select method (string)
167 %o Moderated group (char, \"m\")
168 %p Process mark (char)
169 %B Whether a summary buffer for the group is open (char, \"*\")
170 %O Moderated group (string, \"(m)\" or \"\")
171 %P Topic indentation (string)
172 %m Whether there is new(ish) mail in the group (char, \"%\")
173 %w Number of new(ish) mails in the group (integer)
174 %l Whether there are GroupLens predictions for this group (string)
175 %n Select from where (string)
176 %z A string that look like `<%s:%n>' if a foreign select method is used
177 %d The date the group was last entered.
178 %E Icon as defined by `gnus-group-icon-list'.
179 %u User defined specifier. The next character in the format string should
180 be a letter. Gnus will call the function gnus-user-format-function-X,
181 where X is the letter following %u. The function will be passed a
182 single dummy parameter as argument.. The function should return a
183 string, which will be inserted into the buffer just like information
184 from any other group specifier.
186 Note that this format specification is not always respected. For
187 reasons of efficiency, when listing killed groups, this specification
188 is ignored altogether. If the spec is changed considerably, your
189 output may end up looking strange when listing both alive and killed
192 If you use %o or %O, reading the active file will be slower and quite
193 a bit of extra memory will be used. %D will also worsen performance.
194 Also note that if you change the format specification to include any
195 of these specs, you must probably re-start Gnus to see them go into
198 General format specifiers can also be used.
199 See Info node `(gnus)Formatting Variables'."
200 :link '(custom-manual "(gnus)Formatting Variables")
201 :group 'gnus-group-visual
204 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
205 "*The format specification for the group mode line.
206 It works along the same lines as a normal formatting string,
207 with some simple extensions:
209 %S The native news server.
210 %M The native select method.
211 %: \":\" if %S isn't \"\"."
212 :group 'gnus-group-visual
215 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
216 (when (featurep 'xemacs)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
218 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
220 (defcustom gnus-group-menu-hook nil
221 "Hook run after the creation of the group mode menu."
222 :group 'gnus-group-various
225 (defcustom gnus-group-catchup-group-hook nil
226 "Hook run when catching up a group from the group buffer."
227 :group 'gnus-group-various
228 :link '(custom-manual "(gnus)Group Data")
231 (defcustom gnus-group-update-group-hook nil
232 "Hook called when updating group lines."
233 :group 'gnus-group-visual
236 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
237 "*A function that is called to generate the group buffer.
238 The function is called with three arguments: The first is a number;
239 all group with a level less or equal to that number should be listed,
240 if the second is non-nil, empty groups should also be displayed. If
241 the third is non-nil, it is a number. No groups with a level lower
242 than this number should be displayed.
244 The only current function implemented is `gnus-group-prepare-flat'."
245 :group 'gnus-group-listing
248 (defcustom gnus-group-prepare-hook nil
249 "Hook called after the group buffer has been generated.
250 If you want to modify the group buffer, you can use this hook."
251 :group 'gnus-group-listing
254 (defcustom gnus-suspend-gnus-hook nil
255 "Hook called when suspending (not exiting) Gnus."
259 (defcustom gnus-exit-gnus-hook nil
260 "Hook called when exiting Gnus."
264 (defcustom gnus-after-exiting-gnus-hook nil
265 "Hook called after exiting Gnus."
269 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
270 "Hook called when a group line is changed.
271 The hook will not be called if `gnus-visual' is nil.
273 The default function `gnus-group-highlight-line' will
274 highlight the line according to the `gnus-group-highlight'
276 :group 'gnus-group-visual
279 (defcustom gnus-useful-groups
280 '(("(ding) mailing list mirrored at sunsite.auc.dk"
282 (nntp "sunsite.auc.dk"
283 (nntp-address "sunsite.auc.dk")))
286 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
290 (nndoc-article-type mbox)
291 (eval `(nndoc-address
292 ,(let ((file (nnheader-find-etc-directory
295 (error "Couldn't find doc group"))
297 "*Alist of useful group-server pairs."
298 :group 'gnus-group-listing
299 :type '(repeat (list (string :tag "Description")
301 (sexp :tag "Method"))))
303 (defcustom gnus-group-highlight
305 ((and mailp (= unread 0) (eq level 1)) .
306 gnus-group-mail-1-empty-face)
307 ((and mailp (eq level 1)) .
308 gnus-group-mail-1-face)
309 ((and mailp (= unread 0) (eq level 2)) .
310 gnus-group-mail-2-empty-face)
311 ((and mailp (eq level 2)) .
312 gnus-group-mail-2-face)
313 ((and mailp (= unread 0) (eq level 3)) .
314 gnus-group-mail-3-empty-face)
315 ((and mailp (eq level 3)) .
316 gnus-group-mail-3-face)
317 ((and mailp (= unread 0)) .
318 gnus-group-mail-low-empty-face)
320 gnus-group-mail-low-face)
322 ((and (= unread 0) (eq level 1)) .
323 gnus-group-news-1-empty-face)
324 ((and (eq level 1)) .
325 gnus-group-news-1-face)
326 ((and (= unread 0) (eq level 2)) .
327 gnus-group-news-2-empty-face)
328 ((and (eq level 2)) .
329 gnus-group-news-2-face)
330 ((and (= unread 0) (eq level 3)) .
331 gnus-group-news-3-empty-face)
332 ((and (eq level 3)) .
333 gnus-group-news-3-face)
334 ((and (= unread 0) (eq level 4)) .
335 gnus-group-news-4-empty-face)
336 ((and (eq level 4)) .
337 gnus-group-news-4-face)
338 ((and (= unread 0) (eq level 5)) .
339 gnus-group-news-5-empty-face)
340 ((and (eq level 5)) .
341 gnus-group-news-5-face)
342 ((and (= unread 0) (eq level 6)) .
343 gnus-group-news-6-empty-face)
344 ((and (eq level 6)) .
345 gnus-group-news-6-face)
346 ((and (= unread 0)) .
347 gnus-group-news-low-empty-face)
349 gnus-group-news-low-face))
350 "*Controls the highlighting of group buffer lines.
352 Below is a list of `Form'/`Face' pairs. When deciding how a a
353 particular group line should be displayed, each form is
354 evaluated. The content of the face field after the first true form is
355 used. You can change how those group lines are displayed by
356 editing the face field.
358 It is also possible to change and add form fields, but currently that
359 requires an understanding of Lisp expressions. Hopefully this will
360 change in a future release. For now, you can use the following
361 variables in the Lisp expression:
363 group: The name of the group.
364 unread: The number of unread articles in the group.
365 method: The select method used.
366 mailp: Whether it's a mail group or not.
367 level: The level of the group.
368 score: The score of the group.
369 ticked: The number of ticked articles."
370 :group 'gnus-group-visual
371 :type '(repeat (cons (sexp :tag "Form") face)))
373 (defcustom gnus-new-mail-mark ?%
374 "Mark used for groups with new mail."
375 :group 'gnus-group-visual
378 (defgroup gnus-group-icons nil
379 "Add Icons to your group buffer. "
380 :group 'gnus-group-visual)
382 (defcustom gnus-group-icon-list
384 "*Controls the insertion of icons into group buffer lines.
386 Below is a list of `Form'/`File' pairs. When deciding how a
387 particular group line should be displayed, each form is evaluated.
388 The icon from the file field after the first true form is used. You
389 can change how those group lines are displayed by editing the file
390 field. The File will either be found in the
391 `gnus-group-glyph-directory' or by designating absolute path to the
394 It is also possible to change and add form fields, but currently that
395 requires an understanding of Lisp expressions. Hopefully this will
396 change in a future release. For now, you can use the following
397 variables in the Lisp expression:
399 group: The name of the group.
400 unread: The number of unread articles in the group.
401 method: The select method used.
402 mailp: Whether it's a mail group or not.
403 newsp: Whether it's a news group or not
404 level: The level of the group.
405 score: The score of the group.
406 ticked: The number of ticked articles."
407 :group 'gnus-group-icons
408 :type '(repeat (cons (sexp :tag "Form") file)))
410 (defcustom gnus-group-name-charset-method-alist nil
411 "Alist of method and the charset for group names.
414 (((nntp \"news.com.cn\") . cn-gb-2312))"
417 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
419 (defcustom gnus-group-name-charset-group-alist
420 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
421 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
422 '(("[^\000-\177]" . utf-8))
424 "Alist of group regexp and the charset for group names.
427 ((\"\\.com\\.cn:\" . cn-gb-2312))"
429 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
431 (defcustom gnus-group-jump-to-group-prompt nil
432 "Default prompt for `gnus-group-jump-to-group'.
433 If non-nil, the value should be a string, e.g. \"nnml:\",
434 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
435 in the minibuffer prompt."
436 :group 'gnus-group-various
437 :type '(choice (string :tag "Prompt string")
438 (const :tag "Empty" nil)))
440 (defvar gnus-group-listing-limit 1000
441 "*A limit of the number of groups when listing.
442 If the number of groups is larger than the limit, list them in a
445 ;;; Internal variables
447 (defvar gnus-group-is-exiting-p nil)
448 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
449 "Function for sorting the group buffer.")
451 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
452 "Function for sorting the selected groups in the group buffer.")
454 (defvar gnus-group-indentation-function nil)
455 (defvar gnus-goto-missing-group-function nil)
456 (defvar gnus-group-update-group-function nil)
457 (defvar gnus-group-goto-next-group-function nil
458 "Function to override finding the next group after listing groups.")
460 (defvar gnus-group-edit-buffer nil)
462 (defvar gnus-group-line-format-alist
463 `((?M gnus-tmp-marked-mark ?c)
464 (?S gnus-tmp-subscribed ?c)
465 (?L gnus-tmp-level ?d)
466 (?N (cond ((eq number t) "*" )
470 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
471 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
473 (?R gnus-tmp-number-of-read ?s)
474 (?t gnus-tmp-number-total ?d)
475 (?y gnus-tmp-number-of-unread ?s)
476 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
477 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
478 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
479 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
480 (?g gnus-tmp-group ?s)
481 (?G gnus-tmp-qualified-group ?s)
482 (?c (gnus-short-group-name gnus-tmp-group) ?s)
483 (?C gnus-tmp-comment ?s)
484 (?D gnus-tmp-newsgroup-description ?s)
485 (?o gnus-tmp-moderated ?c)
486 (?O gnus-tmp-moderated-string ?s)
487 (?p gnus-tmp-process-marked ?c)
488 (?s gnus-tmp-news-server ?s)
489 (?n gnus-tmp-news-method ?s)
490 (?P gnus-group-indentation ?s)
491 (?E gnus-tmp-group-icon ?s)
492 (?B gnus-tmp-summary-live ?c)
493 (?l gnus-tmp-grouplens ?s)
494 (?z gnus-tmp-news-method-string ?s)
495 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
496 (?w (if (gnus-news-group-p gnus-tmp-group)
500 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
503 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
504 (?u gnus-tmp-user-defined ?s)))
506 (defvar gnus-group-mode-line-format-alist
507 `((?S gnus-tmp-news-server ?s)
508 (?M gnus-tmp-news-method ?s)
509 (?u gnus-tmp-user-defined ?s)
510 (?: gnus-tmp-colon ?s)))
512 (defvar gnus-topic-topology nil
513 "The complete topic hierarchy.")
515 (defvar gnus-topic-alist nil
516 "The complete topic-group alist.")
518 (defvar gnus-group-marked nil)
520 (defvar gnus-group-list-mode nil)
523 (defvar gnus-group-icon-cache nil)
525 (defvar gnus-group-listed-groups nil)
526 (defvar gnus-group-list-option nil)
532 (put 'gnus-group-mode 'mode-class 'special)
535 (gnus-define-keys gnus-group-mode-map
536 " " gnus-group-read-group
537 "=" gnus-group-select-group
538 "\r" gnus-group-select-group
539 "\M-\r" gnus-group-quick-select-group
540 "\M- " gnus-group-visible-select-group
541 [(meta control return)] gnus-group-select-group-ephemerally
542 "j" gnus-group-jump-to-group
543 "n" gnus-group-next-unread-group
544 "p" gnus-group-prev-unread-group
545 "\177" gnus-group-prev-unread-group
546 [delete] gnus-group-prev-unread-group
547 [backspace] gnus-group-prev-unread-group
548 "N" gnus-group-next-group
549 "P" gnus-group-prev-group
550 "\M-n" gnus-group-next-unread-group-same-level
551 "\M-p" gnus-group-prev-unread-group-same-level
552 "," gnus-group-best-unread-group
553 "." gnus-group-first-unread-group
554 "u" gnus-group-unsubscribe-current-group
555 "U" gnus-group-unsubscribe-group
556 "c" gnus-group-catchup-current
557 "C" gnus-group-catchup-current-all
558 "\M-c" gnus-group-clear-data
559 "l" gnus-group-list-groups
560 "L" gnus-group-list-all-groups
563 "g" gnus-group-get-new-news
564 "\M-g" gnus-group-get-new-news-this-group
565 "R" gnus-group-restart
566 "r" gnus-group-read-init-file
567 "B" gnus-group-browse-foreign-server
568 "b" gnus-group-check-bogus-groups
569 "F" gnus-group-find-new-groups
570 "\C-c\C-d" gnus-group-describe-group
571 "\M-d" gnus-group-describe-all-groups
572 "\C-c\C-a" gnus-group-apropos
573 "\C-c\M-\C-a" gnus-group-description-apropos
574 "a" gnus-group-post-news
575 "\ek" gnus-group-edit-local-kill
576 "\eK" gnus-group-edit-global-kill
577 "\C-k" gnus-group-kill-group
578 "\C-y" gnus-group-yank-group
579 "\C-w" gnus-group-kill-region
580 "\C-x\C-t" gnus-group-transpose-groups
581 "\C-c\C-l" gnus-group-list-killed
582 "\C-c\C-x" gnus-group-expire-articles
583 "\C-c\M-\C-x" gnus-group-expire-all-groups
585 "s" gnus-group-save-newsrc
586 "z" gnus-group-suspend
589 "?" gnus-group-describe-briefly
590 "\C-c\C-i" gnus-info-find-node
591 "\M-e" gnus-group-edit-group-method
592 "^" gnus-group-enter-server-mode
593 gnus-mouse-2 gnus-mouse-pick-group
594 "<" beginning-of-buffer
597 "\C-c\C-n" gnus-namazu-search
598 "\C-c\C-s" gnus-group-sort-groups
600 "\C-c\M-g" gnus-activate-all-groups
601 "\M-&" gnus-group-universal-argument
602 "#" gnus-group-mark-group
603 "\M-#" gnus-group-unmark-group)
605 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
606 "m" gnus-group-mark-group
607 "u" gnus-group-unmark-group
608 "w" gnus-group-mark-region
609 "b" gnus-group-mark-buffer
610 "r" gnus-group-mark-regexp
611 "U" gnus-group-unmark-all-groups)
613 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
614 "u" gnus-sieve-update
615 "g" gnus-sieve-generate)
617 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
618 "d" gnus-group-make-directory-group
619 "h" gnus-group-make-help-group
620 "u" gnus-group-make-useful-group
621 "a" gnus-group-make-archive-group
622 "k" gnus-group-make-kiboze-group
623 "l" gnus-group-nnimap-edit-acl
624 "m" gnus-group-make-group
625 "n" gnus-group-make-shimbun-group
626 "E" gnus-group-edit-group
627 "e" gnus-group-edit-group-method
628 "p" gnus-group-edit-group-parameters
629 "v" gnus-group-add-to-virtual
630 "V" gnus-group-make-empty-virtual
631 "D" gnus-group-enter-directory
632 "f" gnus-group-make-doc-group
633 "G" gnus-group-make-nnir-group
634 "w" gnus-group-make-web-group
635 "r" gnus-group-rename-group
636 "c" gnus-group-customize
637 "x" gnus-group-nnimap-expunge
638 "\177" gnus-group-delete-group
639 [delete] gnus-group-delete-group)
641 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
642 "b" gnus-group-brew-soup
643 "w" gnus-soup-save-areas
644 "s" gnus-soup-send-replies
645 "p" gnus-soup-pack-packet
646 "r" nnsoup-pack-replies)
648 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
649 "s" gnus-group-sort-groups
650 "a" gnus-group-sort-groups-by-alphabet
651 "u" gnus-group-sort-groups-by-unread
652 "l" gnus-group-sort-groups-by-level
653 "v" gnus-group-sort-groups-by-score
654 "r" gnus-group-sort-groups-by-rank
655 "m" gnus-group-sort-groups-by-method
656 "n" gnus-group-sort-groups-by-real-name)
658 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
659 "s" gnus-group-sort-selected-groups
660 "a" gnus-group-sort-selected-groups-by-alphabet
661 "u" gnus-group-sort-selected-groups-by-unread
662 "l" gnus-group-sort-selected-groups-by-level
663 "v" gnus-group-sort-selected-groups-by-score
664 "r" gnus-group-sort-selected-groups-by-rank
665 "m" gnus-group-sort-selected-groups-by-method
666 "n" gnus-group-sort-selected-groups-by-real-name)
668 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
669 "k" gnus-group-list-killed
670 "z" gnus-group-list-zombies
671 "s" gnus-group-list-groups
672 "u" gnus-group-list-all-groups
673 "A" gnus-group-list-active
674 "a" gnus-group-apropos
675 "d" gnus-group-description-apropos
676 "m" gnus-group-list-matching
677 "M" gnus-group-list-all-matching
678 "l" gnus-group-list-level
679 "c" gnus-group-list-cached
680 "?" gnus-group-list-dormant)
682 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
683 "k" gnus-group-list-limit
684 "z" gnus-group-list-limit
685 "s" gnus-group-list-limit
686 "u" gnus-group-list-limit
687 "A" gnus-group-list-limit
688 "m" gnus-group-list-limit
689 "M" gnus-group-list-limit
690 "l" gnus-group-list-limit
691 "c" gnus-group-list-limit
692 "?" gnus-group-list-limit)
694 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
695 "k" gnus-group-list-flush
696 "z" gnus-group-list-flush
697 "s" gnus-group-list-flush
698 "u" gnus-group-list-flush
699 "A" gnus-group-list-flush
700 "m" gnus-group-list-flush
701 "M" gnus-group-list-flush
702 "l" gnus-group-list-flush
703 "c" gnus-group-list-flush
704 "?" gnus-group-list-flush)
706 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
707 "k" gnus-group-list-plus
708 "z" gnus-group-list-plus
709 "s" gnus-group-list-plus
710 "u" gnus-group-list-plus
711 "A" gnus-group-list-plus
712 "m" gnus-group-list-plus
713 "M" gnus-group-list-plus
714 "l" gnus-group-list-plus
715 "c" gnus-group-list-plus
716 "?" gnus-group-list-plus)
718 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
719 "f" gnus-score-flush-cache)
721 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
722 "c" gnus-group-fetch-charter
723 "C" gnus-group-fetch-control
724 "d" gnus-group-describe-group
725 "f" gnus-group-fetch-faq
728 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
729 "l" gnus-group-set-current-level
730 "t" gnus-group-unsubscribe-current-group
731 "s" gnus-group-unsubscribe-group
732 "k" gnus-group-kill-group
733 "y" gnus-group-yank-group
734 "w" gnus-group-kill-region
735 "\C-k" gnus-group-kill-level
736 "z" gnus-group-kill-all-zombies))
738 (defun gnus-group-make-menu-bar ()
739 (gnus-turn-off-edit-menu 'group)
740 (unless (boundp 'gnus-group-reading-menu)
743 gnus-group-reading-menu gnus-group-mode-map ""
745 ["Read" gnus-group-read-group (gnus-group-group-name)]
746 ["Select" gnus-group-select-group (gnus-group-group-name)]
747 ["See old articles" (gnus-group-select-group 'all)
748 :keys "C-u SPC" :active (gnus-group-group-name)]
749 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
750 ,@(if (featurep 'xemacs) nil
751 '(:help "Mark unread articles in the current group as read"))]
752 ["Catch up all articles" gnus-group-catchup-current-all
753 (gnus-group-group-name)]
754 ["Check for new articles" gnus-group-get-new-news-this-group
755 :active (gnus-group-group-name)
756 ,@(if (featurep 'xemacs) nil
757 '(:help "Check for new messages in current group"))]
758 ["Toggle subscription" gnus-group-unsubscribe-current-group
759 (gnus-group-group-name)]
760 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
761 ,@(if (featurep 'xemacs) nil
762 '(:help "Kill (remove) current group"))]
763 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
764 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
765 ,@(if (featurep 'xemacs) nil
766 '(:help "Display description of the current group"))]
767 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
768 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
769 ,@(if (featurep 'xemacs) nil
770 '(:help "Display the charter of the current group"))]
771 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
772 ,@(if (featurep 'xemacs) nil
773 '(:help "Display the archived control message for the current group"))]
774 ;; Actually one should check, if any of the marked groups gives t for
775 ;; (gnus-check-backend-function 'request-expire-articles ...)
776 ["Expire articles" gnus-group-expire-articles
777 (or (and (gnus-group-group-name)
778 (gnus-check-backend-function
779 'request-expire-articles
780 (gnus-group-group-name))) gnus-group-marked)]
781 ["Set group level..." gnus-group-set-current-level
782 (gnus-group-group-name)]
783 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
784 ["Customize" gnus-group-customize (gnus-group-group-name)]
786 ["Parameters" gnus-group-edit-group-parameters
787 (gnus-group-group-name)]
788 ["Select method" gnus-group-edit-group-method
789 (gnus-group-group-name)]
790 ["Info" gnus-group-edit-group (gnus-group-group-name)]
791 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
792 ["Global kill file" gnus-group-edit-global-kill t])))
795 gnus-group-group-menu gnus-group-mode-map ""
798 ["List unread subscribed groups" gnus-group-list-groups t]
799 ["List (un)subscribed groups" gnus-group-list-all-groups t]
800 ["List killed groups" gnus-group-list-killed gnus-killed-list]
801 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
802 ["List level..." gnus-group-list-level t]
803 ["Describe all groups" gnus-group-describe-all-groups t]
804 ["Group apropos..." gnus-group-apropos t]
805 ["Group and description apropos..." gnus-group-description-apropos t]
806 ["List groups matching..." gnus-group-list-matching t]
807 ["List all groups matching..." gnus-group-list-all-matching t]
808 ["List active file" gnus-group-list-active t]
809 ["List groups with cached" gnus-group-list-cached t]
810 ["List groups with dormant" gnus-group-list-dormant t])
812 ["Default sort" gnus-group-sort-groups t]
813 ["Sort by method" gnus-group-sort-groups-by-method t]
814 ["Sort by rank" gnus-group-sort-groups-by-rank t]
815 ["Sort by score" gnus-group-sort-groups-by-score t]
816 ["Sort by level" gnus-group-sort-groups-by-level t]
817 ["Sort by unread" gnus-group-sort-groups-by-unread t]
818 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
819 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
820 ("Sort process/prefixed"
821 ["Default sort" gnus-group-sort-selected-groups
822 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
823 ["Sort by method" gnus-group-sort-selected-groups-by-method
824 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
825 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
826 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
827 ["Sort by score" gnus-group-sort-selected-groups-by-score
828 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
829 ["Sort by level" gnus-group-sort-selected-groups-by-level
830 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
831 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
832 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
833 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
834 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
835 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
836 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
838 ["Mark group" gnus-group-mark-group
839 (and (gnus-group-group-name)
840 (not (memq (gnus-group-group-name) gnus-group-marked)))]
841 ["Unmark group" gnus-group-unmark-group
842 (and (gnus-group-group-name)
843 (memq (gnus-group-group-name) gnus-group-marked))]
844 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
845 ["Mark regexp..." gnus-group-mark-regexp t]
846 ["Mark region" gnus-group-mark-region t]
847 ["Mark buffer" gnus-group-mark-buffer t]
848 ["Execute command" gnus-group-universal-argument
849 (or gnus-group-marked (gnus-group-group-name))])
851 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
852 ["Kill all newsgroups in region" gnus-group-kill-region t]
853 ["Kill all zombie groups" gnus-group-kill-all-zombies
855 ["Kill all groups on level..." gnus-group-kill-level t])
857 ["Make a foreign group..." gnus-group-make-group t]
858 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
859 ["Add a directory group..." gnus-group-make-directory-group t]
860 ["Add the help group" gnus-group-make-help-group t]
861 ["Add the archive group" gnus-group-make-archive-group t]
862 ["Make a doc group..." gnus-group-make-doc-group t]
863 ["Make a web group..." gnus-group-make-web-group t]
864 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
865 ["Make a virtual group..." gnus-group-make-empty-virtual t]
866 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
867 ["Rename group..." gnus-group-rename-group
868 (gnus-check-backend-function
869 'request-rename-group (gnus-group-group-name))]
870 ["Delete group" gnus-group-delete-group
871 (gnus-check-backend-function
872 'request-delete-group (gnus-group-group-name))])
874 ["Next" gnus-group-next-group t]
875 ["Previous" gnus-group-prev-group t]
876 ["Next unread" gnus-group-next-unread-group t]
877 ["Previous unread" gnus-group-prev-unread-group t]
878 ["Next unread same level" gnus-group-next-unread-group-same-level t]
879 ["Previous unread same level"
880 gnus-group-prev-unread-group-same-level t]
881 ["Jump to group..." gnus-group-jump-to-group t]
882 ["First unread group" gnus-group-first-unread-group t]
883 ["Best unread group" gnus-group-best-unread-group t])
885 ["Generate" gnus-sieve-generate t]
886 ["Generate and update" gnus-sieve-update t])
887 ["Delete bogus groups" gnus-group-check-bogus-groups t]
888 ["Find new newsgroups" gnus-group-find-new-groups t]
889 ["Transpose" gnus-group-transpose-groups
890 (gnus-group-group-name)]
891 ["Read a directory as a group..." gnus-group-enter-directory t]))
894 gnus-group-misc-menu gnus-group-mode-map ""
897 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
898 ["Send replies" gnus-soup-send-replies
899 (fboundp 'gnus-soup-pack-packet)]
900 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
901 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
902 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
903 ["Send a mail" gnus-group-mail t]
904 ["Send a message (mail or news)" gnus-group-post-news t]
905 ["Create a local message" gnus-group-news t]
906 ["Check for new news" gnus-group-get-new-news
907 ,@(if (featurep 'xemacs) '(t)
908 '(:help "Get newly arrived articles"))
910 ["Send queued messages" gnus-delay-send-queue
911 ,@(if (featurep 'xemacs) '(t)
912 '(:help "Send all messages that are scheduled to be sent now"))
914 ["Activate all groups" gnus-activate-all-groups t]
915 ["Restart Gnus" gnus-group-restart t]
916 ["Read init file" gnus-group-read-init-file t]
917 ["Browse foreign server..." gnus-group-browse-foreign-server t]
918 ["Enter server buffer" gnus-group-enter-server-mode t]
919 ["Expire all expirable articles" gnus-group-expire-all-groups t]
920 ["Generate any kiboze groups" nnkiboze-generate-groups t]
921 ["Gnus version" gnus-version t]
922 ["Save .newsrc files" gnus-group-save-newsrc t]
923 ["Suspend Gnus" gnus-group-suspend t]
924 ["Clear dribble buffer" gnus-group-clear-dribble t]
925 ["Read manual" gnus-info-find-node t]
926 ["Flush score cache" gnus-score-flush-cache t]
927 ["Toggle topics" gnus-topic-mode t]
928 ["Send a bug report" gnus-bug t]
929 ["Exit from Gnus" gnus-group-exit
930 ,@(if (featurep 'xemacs) '(t)
931 '(:help "Quit reading news"))]
932 ["Exit without saving" gnus-group-quit t]))
934 (gnus-run-hooks 'gnus-group-menu-hook)))
936 (defvar gnus-group-toolbar-map nil)
938 ;; Emacs 21 tool bar. Should be no-op otherwise.
939 (defun gnus-group-make-tool-bar ()
941 (condition-case nil (require 'tool-bar) (error nil))
942 (fboundp 'tool-bar-add-item-from-menu)
943 (default-value 'tool-bar-mode)
944 (not gnus-group-toolbar-map))
945 (setq gnus-group-toolbar-map
946 (let ((tool-bar-map (make-sparse-keymap))
947 (load-path (mm-image-load-path)))
948 (tool-bar-add-item-from-menu
949 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
950 (tool-bar-add-item-from-menu
951 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
952 (tool-bar-add-item-from-menu
953 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
954 (tool-bar-add-item-from-menu
955 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
956 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
957 :help "Subscribe to the current group")
958 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
960 :help "Unsubscribe from the current group")
961 (tool-bar-add-item-from-menu
962 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
964 (if gnus-group-toolbar-map
965 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
967 (defun gnus-group-mode ()
968 "Major mode for reading news.
970 All normal editing commands are switched off.
971 \\<gnus-group-mode-map>
972 The group buffer lists (some of) the groups available. For instance,
973 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
974 lists all zombie groups.
976 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
977 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
979 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
981 The following commands are available:
983 \\{gnus-group-mode-map}"
985 (kill-all-local-variables)
986 (when (gnus-visual-p 'group-menu 'menu)
987 (gnus-group-make-menu-bar)
988 (gnus-group-make-tool-bar))
989 (gnus-simplify-mode-line)
990 (setq major-mode 'gnus-group-mode)
991 (setq mode-name "Group")
992 (gnus-group-set-mode-line)
993 (setq mode-line-process nil)
994 (use-local-map gnus-group-mode-map)
995 (buffer-disable-undo)
996 (setq truncate-lines t)
997 (setq buffer-read-only t)
998 (gnus-set-default-directory)
999 (gnus-update-format-specifications nil 'group 'group-mode)
1000 (gnus-update-group-mark-positions)
1005 (gnus-run-hooks 'gnus-group-mode-hook))
1007 (defun gnus-update-group-mark-positions ()
1009 (let ((gnus-process-mark ?\200)
1010 (gnus-group-update-hook nil)
1011 (gnus-group-marked '("dummy.group"))
1012 (gnus-active-hashtb (make-vector 10 0))
1014 (gnus-set-active "dummy.group" '(0 . 0))
1015 (gnus-set-work-buffer)
1016 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1017 (goto-char (point-min))
1018 (setq gnus-group-mark-positions
1019 (list (cons 'process (and (search-forward "\200" nil t)
1020 (- (point) 2))))))))
1022 (defun gnus-mouse-pick-group (e)
1023 "Enter the group under the mouse pointer."
1026 (gnus-group-read-group nil))
1028 ;; Look at LEVEL and find out what the level is really supposed to be.
1029 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1030 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1031 (defun gnus-group-default-level (&optional level number-or-nil)
1033 (gnus-group-use-permanent-levels
1034 (or (setq gnus-group-use-permanent-levels
1035 (or level (if (numberp gnus-group-use-permanent-levels)
1036 gnus-group-use-permanent-levels
1037 (or gnus-group-default-list-level
1038 gnus-level-subscribed))))
1039 gnus-group-default-list-level gnus-level-subscribed))
1043 (or level gnus-group-default-list-level gnus-level-subscribed))))
1045 (defun gnus-group-setup-buffer ()
1046 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1047 (unless (eq major-mode 'gnus-group-mode)
1050 (gnus-carpal-setup-buffer 'group))))
1052 (defun gnus-group-name-charset (method group)
1054 (setq method (gnus-find-method-for-group group)))
1055 (let ((item (assoc method gnus-group-name-charset-method-alist))
1056 (alist gnus-group-name-charset-group-alist)
1060 (while (setq item (pop alist))
1061 (if (string-match (car item) group)
1063 result (cdr item))))
1066 (defun gnus-group-name-decode (string charset)
1067 (if (and string charset (featurep 'mule))
1068 (decode-coding-string string charset)
1071 (defun gnus-group-decoded-name (string)
1072 (let ((charset (gnus-group-name-charset nil string)))
1073 (gnus-group-name-decode string charset)))
1075 (defun gnus-group-name-encode (string charset)
1076 (if (and string charset (featurep 'mule))
1077 (encode-coding-string string charset)
1080 (defun gnus-group-encoded-name (string)
1081 (let ((charset (gnus-group-name-charset nil string)))
1082 (gnus-group-name-encode string charset)))
1084 (defun gnus-group-completing-read-group-name
1085 (prompt table &optional predicate require-match initial-contents history)
1089 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1093 (dolist (entry (prog1
1096 (push (list (gnus-group-decoded-name (car entry))) table)))
1097 (gnus-group-encoded-name
1099 prompt table predicate
1104 (defun gnus-group-list-groups (&optional level unread lowest)
1105 "List newsgroups with level LEVEL or lower that have unread articles.
1106 Default is all subscribed groups.
1107 If argument UNREAD is non-nil, groups with no unread articles are also
1110 Also see the `gnus-group-use-permanent-levels' variable."
1112 (list (if current-prefix-arg
1113 (prefix-numeric-value current-prefix-arg)
1115 (gnus-group-default-level nil t)
1116 gnus-group-default-list-level
1117 gnus-level-subscribed))))
1119 (setq level (car gnus-group-list-mode)
1120 unread (cdr gnus-group-list-mode)))
1121 (setq level (gnus-group-default-level level))
1122 (gnus-group-setup-buffer)
1123 (gnus-update-format-specifications nil 'group 'group-mode)
1124 (let ((case-fold-search nil)
1125 (props (text-properties-at (gnus-point-at-bol)))
1126 (empty (= (point-min) (point-max)))
1127 (group (gnus-group-group-name))
1129 (set-buffer gnus-group-buffer)
1130 (setq number (funcall gnus-group-prepare-function level unread lowest))
1131 (when (or (and (numberp number)
1133 (zerop (buffer-size)))
1134 ;; No groups in the buffer.
1135 (gnus-message 5 gnus-no-groups-message))
1136 ;; We have some groups displayed.
1137 (goto-char (point-max))
1138 (when (or (not gnus-group-goto-next-group-function)
1139 (not (funcall gnus-group-goto-next-group-function
1143 (goto-char (point-min)))
1145 ;; Go to the first group with unread articles.
1146 (gnus-group-search-forward t))
1148 ;; Find the right group to put point on. If the current group
1149 ;; has disappeared in the new listing, try to find the next
1150 ;; one. If no next one can be found, just leave point at the
1151 ;; first newsgroup in the buffer.
1152 (when (not (gnus-goto-char
1154 (point-min) (point-max)
1155 'gnus-group (gnus-intern-safe
1156 group gnus-active-hashtb))))
1157 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1159 (not (gnus-goto-char
1161 (point-min) (point-max) 'gnus-group
1163 (caar newsrc) gnus-active-hashtb)))))
1164 (setq newsrc (cdr newsrc)))
1166 (goto-char (point-max))
1167 (forward-line -1)))))))
1168 ;; Adjust cursor point.
1169 (gnus-group-position-point)))
1171 (defun gnus-group-list-level (level &optional all)
1172 "List groups on LEVEL.
1173 If ALL (the prefix), also list groups that have no unread articles."
1174 (interactive "nList groups on level: \nP")
1175 (gnus-group-list-groups level all level))
1177 (defun gnus-group-prepare-logic (group test)
1178 (or (and gnus-group-listed-groups
1179 (null gnus-group-list-option)
1180 (member group gnus-group-listed-groups))
1182 ((null gnus-group-listed-groups) test)
1183 ((null gnus-group-list-option) test)
1184 (t (and (member group gnus-group-listed-groups)
1185 (if (eq gnus-group-list-option 'flush)
1189 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1190 "List all newsgroups with unread articles of level LEVEL or lower.
1191 If PREDICATE is a function, list groups that the function returns non-nil;
1192 if it is t, list groups that have no unread articles.
1193 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1194 If REGEXP is a function, list dead groups that the function returns non-nil;
1195 if it is a string, only list groups matching REGEXP."
1196 (set-buffer gnus-group-buffer)
1197 (let ((buffer-read-only nil)
1198 (newsrc (cdr gnus-newsrc-alist))
1199 (lowest (or lowest 1))
1200 (not-in-list (and gnus-group-listed-groups
1201 (copy-sequence gnus-group-listed-groups)))
1202 info clevel unread group params)
1204 (when (or (< lowest gnus-level-zombie)
1205 gnus-group-listed-groups)
1206 ;; List living groups.
1208 (setq info (car newsrc)
1209 group (gnus-info-group info)
1210 params (gnus-info-params info)
1212 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1214 (setq not-in-list (delete group not-in-list)))
1215 (when (gnus-group-prepare-logic
1217 (and unread ; This group might be unchecked
1218 (or (not (stringp regexp))
1219 (string-match regexp group))
1220 (<= (setq clevel (gnus-info-level info)) level)
1223 ((functionp predicate)
1224 (funcall predicate info))
1225 (predicate t) ; We list all groups?
1228 (if (eq unread t) ; Unactivated?
1229 gnus-group-list-inactive-groups
1230 ; We list unactivated
1232 ; We list groups with unread articles
1233 (and gnus-list-groups-with-ticked-articles
1234 (cdr (assq 'tick (gnus-info-marks info))))
1235 ; And groups with tickeds
1236 ;; Check for permanent visibility.
1237 (and gnus-permanently-visible-groups
1238 (string-match gnus-permanently-visible-groups
1240 (memq 'visible params)
1241 (cdr (assq 'visible params)))))))
1242 (gnus-group-insert-group-line
1243 group (gnus-info-level info)
1244 (gnus-info-marks info) unread (gnus-info-method info)))))
1246 ;; List dead groups.
1247 (when (or gnus-group-listed-groups
1248 (and (>= level gnus-level-zombie)
1249 (<= lowest gnus-level-zombie)))
1250 (gnus-group-prepare-flat-list-dead
1251 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1252 gnus-level-zombie ?Z
1255 (dolist (group gnus-zombie-list)
1256 (setq not-in-list (delete group not-in-list))))
1257 (when (or gnus-group-listed-groups
1258 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1259 (gnus-group-prepare-flat-list-dead
1262 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1263 gnus-level-killed ?K regexp))
1265 (gnus-group-set-mode-line)
1266 (setq gnus-group-list-mode (cons level predicate))
1267 (gnus-run-hooks 'gnus-group-prepare-hook)
1270 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1271 ;; List zombies and killed lists somewhat faster, which was
1272 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1273 ;; this by ignoring the group format specification altogether.
1275 (if (> (length groups) gnus-group-listing-limit)
1277 (setq group (pop groups))
1278 (when (gnus-group-prepare-logic
1281 (and (stringp regexp) (string-match regexp group))
1282 (and (functionp regexp) (funcall regexp group))))
1283 (gnus-add-text-properties
1284 (point) (prog1 (1+ (point))
1285 (insert " " mark " *: "
1286 (gnus-group-decoded-name group)
1288 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1290 'gnus-level level))))
1292 (setq group (pop groups))
1293 (when (gnus-group-prepare-logic
1296 (and (stringp regexp) (string-match regexp group))
1297 (and (functionp regexp) (funcall regexp group))))
1298 (gnus-group-insert-group-line
1300 (let ((active (gnus-active group)))
1302 (if (zerop (cdr active))
1304 (- (1+ (cdr active)) (car active)))
1306 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1308 (defun gnus-group-update-group-line ()
1309 "Update the current line in the group buffer."
1310 (let* ((buffer-read-only nil)
1311 (group (gnus-group-group-name))
1312 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1313 gnus-group-indentation)
1316 (not (gnus-ephemeral-group-p group))
1318 (concat "(gnus-group-set-info '"
1319 (gnus-prin1-to-string (nth 2 entry))
1321 (setq gnus-group-indentation (gnus-group-group-indentation))
1323 (gnus-group-insert-group-line-info group)
1325 (gnus-group-position-point))))
1327 (defun gnus-group-insert-group-line-info (group)
1328 "Insert GROUP on the current line."
1329 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1330 (gnus-group-indentation (gnus-group-group-indentation))
1334 ;; (Un)subscribed group.
1335 (setq info (nth 2 entry))
1336 (gnus-group-insert-group-line
1337 group (gnus-info-level info) (gnus-info-marks info)
1338 (or (car entry) t) (gnus-info-method info)))
1339 ;; This group is dead.
1340 (gnus-group-insert-group-line
1342 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1344 (if (setq active (gnus-active group))
1345 (if (zerop (cdr active))
1347 (- (1+ (cdr active)) (car active)))
1349 (gnus-method-simplify (gnus-find-method-for-group group))))))
1351 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1352 gnus-tmp-marked number
1354 "Insert a group line in the group buffer."
1355 (let* ((gnus-tmp-method
1356 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1357 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1359 (gnus-tmp-active (gnus-active gnus-tmp-group))
1360 (gnus-tmp-number-total
1362 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1364 (gnus-tmp-number-of-unread
1365 (if (numberp number) (int-to-string (max 0 number))
1367 (gnus-tmp-number-of-read
1368 (if (numberp number)
1369 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1371 (gnus-tmp-subscribed
1372 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1373 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1374 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1376 (gnus-tmp-qualified-group
1377 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1378 group-name-charset))
1380 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1382 (gnus-tmp-newsgroup-description
1383 (if gnus-description-hashtb
1384 (or (gnus-group-name-decode
1385 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1386 group-name-charset) "")
1389 (if (and gnus-moderated-hashtb
1390 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1392 (gnus-tmp-moderated-string
1393 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1394 (gnus-tmp-group-icon "==&&==")
1395 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1396 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1397 (gnus-tmp-news-method-string
1399 (format "(%s:%s)" (car gnus-tmp-method)
1400 (cadr gnus-tmp-method)) ""))
1401 (gnus-tmp-marked-mark
1402 (if (and (numberp number)
1404 (cdr (assq 'tick gnus-tmp-marked)))
1406 (gnus-tmp-summary-live
1407 (if (and (not gnus-group-is-exiting-p)
1408 (gnus-buffer-live-p (gnus-summary-buffer-name
1411 (gnus-tmp-process-marked
1412 (if (member gnus-tmp-group gnus-group-marked)
1413 gnus-process-mark ? ))
1415 (or (and gnus-use-grouplens
1416 (bbb-grouplens-group-p gnus-tmp-group))
1418 (buffer-read-only nil)
1419 header gnus-tmp-header) ; passed as parameter to user-funcs.
1421 (gnus-add-text-properties
1425 (let ((gnus-tmp-group (gnus-group-name-decode
1426 gnus-tmp-group group-name-charset)))
1427 (eval gnus-group-line-format-spec)))
1428 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1429 gnus-unread ,(if (numberp number)
1430 (string-to-int gnus-tmp-number-of-unread)
1432 gnus-marked ,gnus-tmp-marked-mark
1433 gnus-indentation ,gnus-group-indentation
1434 gnus-level ,gnus-tmp-level))
1436 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1437 (gnus-run-hooks 'gnus-group-update-hook))
1439 ;; Allow XEmacs to remove front-sticky text properties.
1440 (gnus-group-remove-excess-properties)))
1442 (defun gnus-group-highlight-line ()
1443 "Highlight the current line according to `gnus-group-highlight'."
1444 (let* ((list gnus-group-highlight)
1446 (end (progn (end-of-line) (point)))
1447 ;; now find out where the line starts and leave point there.
1448 (beg (progn (beginning-of-line) (point)))
1449 (group (gnus-group-group-name))
1450 (entry (gnus-group-entry group))
1451 (unread (if (numberp (car entry)) (car entry) 0))
1452 (active (gnus-active group))
1453 (total (if active (1+ (- (cdr active) (car active))) 0))
1454 (info (nth 2 entry))
1455 (method (gnus-server-get-method group (gnus-info-method info)))
1456 (marked (gnus-info-marks info))
1457 (mailp (apply 'append
1460 (memq x (assoc (symbol-name
1461 (car (or method gnus-select-method)))
1462 gnus-valid-select-methods)))
1463 '(mail post-mail))))
1464 (level (or (gnus-info-level info) gnus-level-killed))
1465 (score (or (gnus-info-score info) 0))
1466 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1467 (group-age (gnus-group-timestamp-delta group))
1468 (inhibit-read-only t))
1469 ;; Eval the cars of the lists until we find a match.
1471 (not (eval (caar list))))
1472 (setq list (cdr list)))
1473 (let ((face (cdar list)))
1474 (unless (eq face (get-text-property beg 'face))
1475 (gnus-put-text-property-excluding-characters-with-faces
1477 (setq face (if (boundp face) (symbol-value face) face)))
1478 (gnus-extent-start-open beg)))
1481 (defun gnus-group-update-group (group &optional visible-only)
1482 "Update all lines where GROUP appear.
1483 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1485 ;; Can't use `save-excursion' here, so we do it manually.
1486 (let ((buf (current-buffer))
1488 (set-buffer gnus-group-buffer)
1489 (setq mark (point-marker))
1490 ;; The buffer may be narrowed.
1493 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1495 found buffer-read-only)
1496 ;; Enter the current status into the dribble buffer.
1497 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1499 (not (gnus-ephemeral-group-p group)))
1501 (concat "(gnus-group-set-info '"
1502 (gnus-prin1-to-string (nth 2 entry))
1504 ;; Find all group instances. If topics are in use, each group
1505 ;; may be listed in more than once.
1506 (while (setq loc (text-property-any
1507 loc (point-max) 'gnus-group ident))
1510 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1512 (gnus-group-insert-group-line-info group)
1515 (gnus-run-hooks 'gnus-group-update-group-hook)))
1516 (setq loc (1+ loc)))
1517 (unless (or found visible-only)
1518 ;; No such line in the buffer, find out where it's supposed to
1519 ;; go, and insert it there (or at the end of the buffer).
1520 (if gnus-goto-missing-group-function
1521 (funcall gnus-goto-missing-group-function group)
1522 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1523 (while (and entry (car entry)
1527 (point-min) (point-max)
1528 'gnus-group (gnus-intern-safe
1529 (caar entry) gnus-active-hashtb)))))
1530 (setq entry (cdr entry)))
1531 (or entry (goto-char (point-max)))))
1532 ;; Finally insert the line.
1533 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1534 (gnus-group-insert-group-line-info group)
1537 (gnus-run-hooks 'gnus-group-update-group-hook))))
1538 (when gnus-group-update-group-function
1539 (funcall gnus-group-update-group-function group))
1540 (gnus-group-set-mode-line)))
1542 (set-marker mark nil)
1545 (defun gnus-group-set-mode-line ()
1546 "Update the mode line in the group buffer."
1547 (when (memq 'group gnus-updated-mode-lines)
1548 ;; Yes, we want to keep this mode line updated.
1550 (set-buffer gnus-group-buffer)
1551 (let* ((gformat (or gnus-group-mode-line-format-spec
1552 (gnus-set-format 'group-mode)))
1553 (gnus-tmp-news-server (cadr gnus-select-method))
1554 (gnus-tmp-news-method (car gnus-select-method))
1555 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1557 gnus-tmp-header ;Dummy binding for user-defined formats
1558 ;; Get the resulting string.
1560 (and gnus-dribble-buffer
1561 (buffer-name gnus-dribble-buffer)
1562 (buffer-modified-p gnus-dribble-buffer)
1564 (set-buffer gnus-dribble-buffer)
1565 (not (zerop (buffer-size))))))
1566 (mode-string (eval gformat)))
1567 ;; Say whether the dribble buffer has been modified.
1568 (setq mode-line-modified
1569 (if modified (car gnus-mode-line-modified)
1570 (cdr gnus-mode-line-modified)))
1571 ;; If the line is too long, we chop it off.
1572 (when (> (length mode-string) max-len)
1573 (setq mode-string (substring mode-string 0 (- max-len 4))))
1575 (setq mode-line-buffer-identification
1576 (gnus-mode-line-buffer-identification
1577 (list mode-string)))
1578 (set-buffer-modified-p modified))))))
1580 (defun gnus-group-group-name ()
1581 "Get the name of the newsgroup on the current line."
1582 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1584 (symbol-name group))))
1586 (defun gnus-group-group-level ()
1587 "Get the level of the newsgroup on the current line."
1588 (get-text-property (gnus-point-at-bol) 'gnus-level))
1590 (defun gnus-group-group-indentation ()
1591 "Get the indentation of the newsgroup on the current line."
1592 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1593 (and gnus-group-indentation-function
1594 (funcall gnus-group-indentation-function))
1597 (defun gnus-group-group-unread ()
1598 "Get the number of unread articles of the newsgroup on the current line."
1599 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1601 (defun gnus-group-new-mail (group)
1602 (if (nnmail-new-mail-p (gnus-group-real-name group))
1606 (defun gnus-group-level (group)
1607 "Return the estimated level of GROUP."
1608 (or (gnus-info-level (gnus-get-info group))
1609 (and (member group gnus-zombie-list) gnus-level-zombie)
1612 (defun gnus-group-search-forward (&optional backward all level first-too)
1613 "Find the next newsgroup with unread articles.
1614 If BACKWARD is non-nil, find the previous newsgroup instead.
1615 If ALL is non-nil, just find any newsgroup.
1616 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1618 If FIRST-TOO, the current line is also eligible as a target."
1619 (let ((way (if backward -1 1))
1620 (low gnus-level-killed)
1623 (if (and backward (progn (beginning-of-line)) (bobp))
1632 (get-text-property (point) 'gnus-group)
1636 (get-text-property (point) 'gnus-unread)))
1637 (and (numberp unread) (> unread 0)))
1638 (setq lev (get-text-property (point)
1640 (<= lev gnus-level-subscribed)))
1642 (and (setq lev (get-text-property (point)
1651 (zerop (forward-line way)))))
1653 (progn (gnus-group-position-point) t)
1654 (goto-char (or pos beg))
1657 ;;; Gnus group mode commands
1661 (defun gnus-group-mark-line-p ()
1664 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1665 (eq (char-after) gnus-process-mark)))
1667 (defun gnus-group-mark-group (n &optional unmark no-advance)
1668 "Mark the current group."
1670 (let ((buffer-read-only nil)
1674 (when (setq group (gnus-group-group-name))
1675 ;; Go to the mark position.
1677 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1678 (subst-char-in-region
1679 (point) (1+ (point)) (char-after)
1682 (setq gnus-group-marked (delete group gnus-group-marked))
1684 (setq gnus-group-marked
1685 (cons group (delete group gnus-group-marked)))
1686 gnus-process-mark)))
1688 (gnus-group-next-group 1))
1690 (gnus-summary-position-point)
1693 (defun gnus-group-unmark-group (n)
1694 "Remove the mark from the current group."
1696 (gnus-group-mark-group n 'unmark)
1697 (gnus-group-position-point))
1699 (defun gnus-group-unmark-all-groups ()
1700 "Unmark all groups."
1702 (let ((groups gnus-group-marked))
1705 (gnus-group-remove-mark (pop groups)))))
1706 (gnus-group-position-point))
1708 (defun gnus-group-mark-region (unmark beg end)
1709 "Mark all groups between point and mark.
1710 If UNMARK, remove the mark instead."
1711 (interactive "P\nr")
1712 (let ((num (count-lines beg end)))
1715 (- num (gnus-group-mark-group num unmark)))))
1717 (defun gnus-group-mark-buffer (&optional unmark)
1718 "Mark all groups in the buffer.
1719 If UNMARK, remove the mark instead."
1721 (gnus-group-mark-region unmark (point-min) (point-max)))
1723 (defun gnus-group-mark-regexp (regexp)
1724 "Mark all groups that match some regexp."
1725 (interactive "sMark (regexp): ")
1726 (let ((alist (cdr gnus-newsrc-alist))
1729 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1730 (gnus-group-set-mark group))))
1731 (gnus-group-position-point))
1733 (defun gnus-group-remove-mark (group &optional test-marked)
1734 "Remove the process mark from GROUP and move point there.
1735 Return nil if the group isn't displayed."
1736 (if (gnus-group-goto-group group nil test-marked)
1738 (gnus-group-mark-group 1 'unmark t)
1740 (setq gnus-group-marked
1741 (delete group gnus-group-marked))
1744 (defun gnus-group-set-mark (group)
1745 "Set the process mark on GROUP."
1746 (if (gnus-group-goto-group group)
1748 (gnus-group-mark-group 1 nil t))
1749 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1751 (defun gnus-group-universal-argument (arg &optional groups func)
1752 "Perform any command on all groups according to the process/prefix convention."
1754 (if (eq (setq func (or func
1757 (substitute-command-keys
1758 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1760 (gnus-error 1 "Undefined key")
1761 (gnus-group-iterate arg
1763 (command-execute func))))
1764 (gnus-group-position-point))
1766 (defun gnus-group-process-prefix (n)
1767 "Return a list of groups to work on.
1768 Take into consideration N (the prefix) and the list of marked groups."
1771 (setq n (prefix-numeric-value n))
1772 ;; There is a prefix, so we return a list of the N next
1774 (let ((way (if (< n 0) -1 1))
1779 (if (setq group (gnus-group-group-name))
1780 (push group groups))
1782 (gnus-group-next-group way)))
1784 ((and (gnus-region-active-p) (mark))
1785 ;; Work on the region between point and mark.
1786 (let ((max (max (point) (mark)))
1789 (goto-char (min (point) (mark)))
1792 (push (gnus-group-group-name) groups)
1793 (zerop (gnus-group-next-group 1))
1795 (nreverse groups))))
1797 ;; No prefix, but a list of marked articles.
1798 (reverse gnus-group-marked))
1800 ;; Neither marked articles or a prefix, so we return the
1802 (let ((group (gnus-group-group-name)))
1803 (and group (list group))))))
1805 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1806 ;;; imagine why I went through these contortions...
1808 (let ((function (make-symbol "gnus-group-iterate-function"))
1809 (window (make-symbol "gnus-group-iterate-window"))
1810 (groups (make-symbol "gnus-group-iterate-groups"))
1811 (group (make-symbol "gnus-group-iterate-group")))
1813 `(defun gnus-group-iterate (arg ,function)
1814 "Iterate FUNCTION over all process/prefixed groups.
1815 FUNCTION will be called with the group name as the parameter
1816 and with point over the group in question."
1817 (let ((,groups (gnus-group-process-prefix arg))
1818 (,window (selected-window))
1821 (setq ,group (car ,groups)
1822 ,groups (cdr ,groups))
1823 (select-window ,window)
1824 (gnus-group-remove-mark ,group)
1825 (save-selected-window
1827 (funcall ,function ,group)))))))))
1829 (put 'gnus-group-iterate 'lisp-indent-function 1)
1831 ;; Selecting groups.
1833 (defun gnus-group-read-group (&optional all no-article group select-articles)
1834 "Read news in this newsgroup.
1835 If the prefix argument ALL is non-nil, already read articles become
1836 readable. IF ALL is a number, fetch this number of articles. If the
1837 optional argument NO-ARTICLE is non-nil, no article will be
1838 auto-selected upon group entry. If GROUP is non-nil, fetch that
1841 (let ((no-display (eq all 0))
1842 (group (or group (gnus-group-group-name)))
1843 number active marked entry)
1847 (error "No group on current line"))
1848 (setq marked (gnus-info-marks
1849 (nth 2 (setq entry (gnus-gethash
1850 group gnus-newsrc-hashtb)))))
1851 ;; This group might be a dead group. In that case we have to get
1852 ;; the number of unread articles from `gnus-active-hashtb'.
1854 (cond ((numberp all) all)
1856 ((setq active (gnus-active group))
1857 (- (1+ (cdr active)) (car active)))))
1858 (gnus-summary-read-group
1859 group (or all (and (numberp number)
1860 (zerop (+ number (gnus-range-length
1861 (cdr (assq 'tick marked)))
1863 (cdr (assq 'dormant marked)))))))
1864 no-article nil no-display nil select-articles)))
1866 (defun gnus-group-select-group (&optional all)
1867 "Select this newsgroup.
1868 No article is selected automatically.
1869 If the group is opened, just switch the summary buffer.
1870 If ALL is non-nil, already read articles become readable.
1871 If ALL is a number, fetch this number of articles."
1873 (gnus-group-read-group all t))
1875 (defun gnus-group-quick-select-group (&optional all)
1876 "Select the current group \"quickly\".
1877 This means that no highlighting or scoring will be performed.
1878 If ALL (the prefix argument) is 0, don't even generate the summary
1881 This might be useful if you want to toggle threading
1882 before entering the group."
1884 (require 'gnus-score)
1886 gnus-score-find-score-files-function
1887 gnus-home-score-file
1888 gnus-apply-kill-hook
1889 gnus-summary-expunge-below)
1890 (gnus-group-read-group all t)))
1892 (defun gnus-group-visible-select-group (&optional all)
1893 "Select the current group without hiding any articles."
1895 (let ((gnus-inhibit-limiting t))
1896 (gnus-group-read-group all t)))
1898 (defun gnus-group-select-group-ephemerally ()
1899 "Select the current group without doing any processing whatsoever.
1900 You will actually be entered into a group that's a copy of
1901 the current group; no changes you make while in this group will
1904 (require 'gnus-score)
1906 gnus-score-find-score-files-function gnus-apply-kill-hook
1907 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1908 gnus-summary-mode-hook gnus-select-group-hook
1909 (group (gnus-group-group-name))
1910 (method (gnus-find-method-for-group group)))
1911 (gnus-group-read-ephemeral-group
1912 (gnus-group-prefixed-name group method) method)))
1915 (defun gnus-fetch-group (group &optional articles)
1916 "Start Gnus if necessary and enter GROUP.
1917 Returns whether the fetching was successful or not."
1918 (interactive (list (gnus-group-completing-read-group-name
1919 "Group name: " gnus-active-hashtb)))
1920 (unless (get-buffer gnus-group-buffer)
1922 (gnus-group-read-group articles nil group))
1925 (defun gnus-fetch-group-other-frame (group)
1926 "Pop up a frame and enter GROUP."
1928 (let ((window (get-buffer-window gnus-group-buffer)))
1930 (select-frame (window-frame window)))
1931 ((= (length (frame-list)) 1)
1932 (select-frame (make-frame)))
1935 (gnus-fetch-group group))
1937 (defvar gnus-ephemeral-group-server 0)
1939 ;; Enter a group that is not in the group buffer. Non-nil is returned
1940 ;; if selection was successful.
1941 (defun gnus-group-read-ephemeral-group (group method &optional activate
1942 quit-config request-only
1945 "Read GROUP from METHOD as an ephemeral group.
1946 If ACTIVATE, request the group first.
1947 If QUIT-CONFIG, use that window configuration when exiting from the
1949 If REQUEST-ONLY, don't actually read the group; just request it.
1950 If SELECT-ARTICLES, only select those articles.
1951 If PARAMETERS, use those as the group parameters.
1953 Return the name of the group if selection was successful."
1954 ;; Transform the select method into a unique server.
1955 (when (stringp method)
1956 (setq method (gnus-server-to-method method)))
1958 `(,(car method) ,(concat (cadr method) "-ephemeral")
1959 (,(intern (format "%s-address" (car method))) ,(cadr method))
1961 (let ((group (if (gnus-group-foreign-p group) group
1962 (gnus-group-prefixed-name (gnus-group-real-name group)
1967 ,gnus-level-default-subscribed nil nil ,method
1970 (cons 'quit-config quit-config)
1972 (cons gnus-summary-buffer
1973 gnus-current-window-configuration)))
1976 (push method gnus-ephemeral-servers)
1977 (set-buffer gnus-group-buffer)
1978 (unless (gnus-check-server method)
1979 (error "Unable to contact server: %s" (gnus-status-message method)))
1981 (gnus-activate-group group 'scan)
1982 (unless (gnus-request-group group)
1983 (error "Couldn't request group: %s"
1984 (nnheader-get-report (car method)))))
1988 (when (gnus-group-read-group t t group select-articles)
1992 (message "Quit reading the ephemeral group")
1995 (defun gnus-group-jump-to-group (group)
1996 "Jump to newsgroup GROUP."
1998 (list (gnus-group-completing-read-group-name
1999 "Group: " gnus-active-hashtb nil
2000 (gnus-read-active-file-p)
2001 gnus-group-jump-to-group-prompt
2002 'gnus-group-history)))
2004 (when (equal group "")
2005 (error "Empty group name"))
2007 (unless (gnus-ephemeral-group-p group)
2008 ;; Either go to the line in the group buffer...
2009 (unless (gnus-group-goto-group group)
2010 ;; ... or insert the line.
2011 (gnus-group-update-group group)
2012 (gnus-group-goto-group group)))
2013 ;; Adjust cursor point.
2014 (gnus-group-position-point))
2016 (defun gnus-group-goto-group (group &optional far test-marked)
2017 "Goto to newsgroup GROUP.
2018 If FAR, it is likely that the group is not on the current line.
2019 If TEST-MARKED, the line must be marked."
2023 ;; It's quite likely that we are on the right line, so
2024 ;; we check the current line first.
2026 (eq (get-text-property (point) 'gnus-group)
2027 (gnus-intern-safe group gnus-active-hashtb))
2028 (or (not test-marked) (gnus-group-mark-line-p)))
2030 ;; Previous and next line are also likely, so we check them as well.
2034 (and (eq (get-text-property (point) 'gnus-group)
2035 (gnus-intern-safe group gnus-active-hashtb))
2036 (or (not test-marked) (gnus-group-mark-line-p)))))
2042 (and (eq (get-text-property (point) 'gnus-group)
2043 (gnus-intern-safe group gnus-active-hashtb))
2044 (or (not test-marked) (gnus-group-mark-line-p)))))
2048 (goto-char (point-min))
2050 (while (and (not found)
2055 (gnus-intern-safe group gnus-active-hashtb))))
2056 (if (gnus-group-mark-line-p)
2061 ;; Search through the entire buffer.
2064 (point-min) (point-max)
2065 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2067 (defun gnus-group-next-group (n &optional silent)
2068 "Go to next N'th newsgroup.
2069 If N is negative, search backward instead.
2070 Returns the difference between N and the number of skips actually
2073 (gnus-group-next-unread-group n t nil silent))
2075 (defun gnus-group-next-unread-group (n &optional all level silent)
2076 "Go to next N'th unread newsgroup.
2077 If N is negative, search backward instead.
2078 If ALL is non-nil, choose any newsgroup, unread or not.
2079 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2080 such group can be found, the next group with a level higher than
2082 Returns the difference between N and the number of skips actually
2085 (let ((backward (< n 0))
2088 (gnus-group-search-forward
2089 backward (or (not gnus-group-goto-unread) all) level))
2093 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2094 (if level " on this level or higher" "")))
2097 (defun gnus-group-prev-group (n)
2098 "Go to previous N'th newsgroup.
2099 Returns the difference between N and the number of skips actually
2102 (gnus-group-next-unread-group (- n) t))
2104 (defun gnus-group-prev-unread-group (n)
2105 "Go to previous N'th unread newsgroup.
2106 Returns the difference between N and the number of skips actually
2109 (gnus-group-next-unread-group (- n)))
2111 (defun gnus-group-next-unread-group-same-level (n)
2112 "Go to next N'th unread newsgroup on the same level.
2113 If N is negative, search backward instead.
2114 Returns the difference between N and the number of skips actually
2117 (gnus-group-next-unread-group n t (gnus-group-group-level))
2118 (gnus-group-position-point))
2120 (defun gnus-group-prev-unread-group-same-level (n)
2121 "Go to next N'th unread newsgroup on the same level.
2122 Returns the difference between N and the number of skips actually
2125 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2126 (gnus-group-position-point))
2128 (defun gnus-group-best-unread-group (&optional exclude-group)
2129 "Go to the group with the highest level.
2130 If EXCLUDE-GROUP, do not go to that group."
2132 (goto-char (point-min))
2136 (setq unread (get-text-property (point) 'gnus-unread))
2137 (when (and (numberp unread) (> unread 0))
2138 (when (and (get-text-property (point) 'gnus-level)
2139 (< (get-text-property (point) 'gnus-level) best)
2140 (or (not exclude-group)
2141 (not (equal exclude-group (gnus-group-group-name)))))
2142 (setq best (get-text-property (point) 'gnus-level))
2143 (setq best-point (point))))
2146 (goto-char best-point))
2147 (gnus-group-position-point)
2148 (and best-point (gnus-group-group-name))))
2150 (defun gnus-group-first-unread-group ()
2151 "Go to the first group with unread articles."
2154 (let ((opoint (point))
2156 (goto-char (point-min))
2157 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2158 (and (numberp unread) ; Not a topic.
2159 (not (zerop unread))) ; Has unread articles.
2160 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2163 nil)) ; Not success.
2164 (gnus-group-position-point)))
2166 (defun gnus-group-enter-server-mode ()
2167 "Jump to the server buffer."
2169 (gnus-enter-server-buffer))
2171 (defun gnus-group-make-group (name &optional method address args)
2172 "Add a new newsgroup.
2173 The user will be prompted for a NAME, for a select METHOD, and an
2177 (gnus-read-group "Group name: ")
2178 (gnus-read-method "From method: ")))
2180 (when (stringp method)
2181 (setq method (or (gnus-server-to-method method) method)))
2182 (let* ((meth (gnus-method-simplify
2184 (not (gnus-server-equal method gnus-select-method)))
2185 (if address (list (intern method) address)
2187 (nname (if method (gnus-group-prefixed-name name meth) name))
2189 (when (gnus-gethash nname gnus-newsrc-hashtb)
2190 (error "Group %s already exists" nname))
2191 ;; Subscribe to the new group.
2192 (gnus-group-change-level
2193 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2194 gnus-level-default-subscribed gnus-level-killed
2195 (and (gnus-group-group-name)
2196 (gnus-gethash (gnus-group-group-name)
2197 gnus-newsrc-hashtb))
2200 (gnus-set-active nname (cons 1 0))
2201 (unless (gnus-ephemeral-group-p name)
2203 (concat "(gnus-group-set-info '"
2204 (gnus-prin1-to-string (cdr info)) ")")))
2206 (gnus-group-insert-group-line-info nname)
2208 (gnus-group-position-point)
2210 ;; Load the backend and try to make the backend create
2211 ;; the group as well.
2212 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2214 gnus-valid-select-methods)
2216 (gnus-check-server meth)
2217 (when (gnus-check-backend-function 'request-create-group nname)
2218 (gnus-request-create-group nname nil args))
2221 (defun gnus-group-delete-groups (&optional arg)
2222 "Delete the current group. Only meaningful with editable groups."
2224 (let ((n (length (gnus-group-process-prefix arg))))
2225 (when (gnus-yes-or-no-p
2227 "Delete this 1 group? "
2228 (format "Delete these %d groups? " n)))
2229 (gnus-group-iterate arg
2231 (gnus-group-delete-group group nil t))))))
2233 (defun gnus-group-delete-group (group &optional force no-prompt)
2234 "Delete the current group. Only meaningful with editable groups.
2235 If FORCE (the prefix) is non-nil, all the articles in the group will
2236 be deleted. This is \"deleted\" as in \"removed forever from the face
2237 of the Earth\". There is no undo. The user will be prompted before
2238 doing the deletion."
2240 (list (gnus-group-group-name)
2241 current-prefix-arg))
2243 (error "No group to delete"))
2244 (unless (gnus-check-backend-function 'request-delete-group group)
2245 (error "This backend does not support group deletion"))
2247 (if (and (not no-prompt)
2248 (not (gnus-yes-or-no-p
2250 "Do you really want to delete %s%s? "
2251 group (if force " and all its contents" "")))))
2253 (gnus-message 6 "Deleting group %s..." group)
2254 (if (not (gnus-request-delete-group group force))
2255 (gnus-error 3 "Couldn't delete group %s" group)
2256 (gnus-message 6 "Deleting group %s...done" group)
2257 (gnus-group-goto-group group)
2258 (gnus-group-kill-group 1 t)
2259 (gnus-sethash group nil gnus-active-hashtb)
2260 (when (and (boundp 'gnus-cache-active-hashtb)
2261 gnus-cache-active-hashtb)
2262 (gnus-sethash group nil gnus-cache-active-hashtb)
2263 (setq gnus-cache-active-altered t))
2265 (gnus-group-position-point)))
2267 (defun gnus-group-rename-group (group new-name)
2268 "Rename group from GROUP to NEW-NAME.
2269 When used interactively, GROUP is the group under point
2270 and NEW-NAME will be prompted for."
2273 (gnus-group-group-name)
2275 (unless (gnus-check-backend-function
2276 'request-rename-group (gnus-group-group-name))
2277 (error "This backend does not support renaming groups"))
2278 (gnus-read-group "Rename group to: "
2279 (gnus-group-real-name (gnus-group-group-name))))))
2281 (unless (gnus-check-backend-function 'request-rename-group group)
2282 (error "This backend does not support renaming groups"))
2284 (error "No group to rename"))
2285 (when (equal (gnus-group-real-name group) new-name)
2286 (error "Can't rename to the same name"))
2288 ;; We find the proper prefixed name.
2290 (if (gnus-group-native-p group)
2294 (gnus-group-prefixed-name
2295 (gnus-group-real-name new-name)
2296 (gnus-info-method (gnus-get-info group)))))
2298 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2301 (gnus-group-goto-group group)
2302 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2303 (gnus-request-rename-group group new-name))))
2304 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2305 ;; We rename the group internally by killing it...
2306 (gnus-group-kill-group)
2307 ;; ... changing its name ...
2308 (setcar (cdar gnus-list-of-killed-groups) new-name)
2309 ;; ... and then yanking it. Magic!
2310 (gnus-group-yank-group)
2311 (gnus-set-active new-name (gnus-active group))
2312 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2314 (setq gnus-killed-list (delete group gnus-killed-list))
2315 (gnus-set-active group nil)
2316 (gnus-dribble-touch)
2317 (gnus-group-position-point)))
2319 (defun gnus-group-edit-group (group &optional part)
2320 "Edit the group on the current line."
2321 (interactive (list (gnus-group-group-name)))
2322 (let ((part (or part 'info))
2325 (error "No group on current line"))
2326 (unless (setq info (gnus-get-info group))
2327 (error "Killed group; can't be edited"))
2329 (gnus-close-group group))
2331 ;; Find the proper form to edit.
2332 (cond ((eq part 'method)
2333 (or (gnus-info-method info) "native"))
2335 (gnus-info-params info))
2337 ;; The proper documentation.
2339 "Editing the %s for `%s'."
2341 ((eq part 'method) "select method")
2342 ((eq part 'params) "group parameters")
2344 (gnus-group-decoded-name group))
2346 (gnus-group-edit-group-done ',part ,group form)))
2349 (gnus-create-info-command
2352 "(gnus)Select Methods")
2354 "(gnus)Group Parameters")
2356 "(gnus)Group Info"))))))
2358 (defun gnus-group-edit-group-method (group)
2359 "Edit the select method of GROUP."
2360 (interactive (list (gnus-group-group-name)))
2361 (gnus-group-edit-group group 'method))
2363 (defun gnus-group-edit-group-parameters (group)
2364 "Edit the group parameters of GROUP."
2365 (interactive (list (gnus-group-group-name)))
2366 (gnus-group-edit-group group 'params))
2368 (defun gnus-group-edit-group-done (part group form)
2370 (let* ((method (cond ((eq part 'info) (nth 4 form))
2371 ((eq part 'method) form)
2373 (info (cond ((eq part 'info) form)
2374 ((eq part 'method) (gnus-get-info group))
2377 (if (or (not method)
2379 gnus-select-method method))
2380 (gnus-group-real-name (car info))
2381 (gnus-group-prefixed-name
2382 (gnus-group-real-name (car info)) method))
2384 (when (and new-group
2385 (not (equal new-group group)))
2386 (when (gnus-group-goto-group group)
2387 (gnus-group-kill-group 1))
2388 (gnus-activate-group new-group))
2390 (if (not (and info new-group))
2391 (gnus-group-set-info form (or new-group group) part)
2392 (setq info (gnus-copy-sequence info))
2393 (setcar info new-group)
2394 (unless (gnus-server-equal method "native")
2395 (unless (nthcdr 3 info)
2396 (nconc info (list nil nil)))
2397 (unless (nthcdr 4 info)
2398 (nconc info (list nil)))
2399 (gnus-info-set-method info method))
2400 (gnus-group-set-info info))
2401 (gnus-group-update-group (or new-group group))
2402 (gnus-group-position-point)))
2404 (defun gnus-group-make-useful-group (group method)
2405 "Create one of the groups described in `gnus-useful-groups'."
2407 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2409 gnus-useful-groups)))
2410 (list (cadr entry) (caddr entry))))
2411 (setq method (gnus-copy-sequence method))
2413 (while (setq entry (memq (assq 'eval method) method))
2414 (setcar entry (eval (cadar entry)))))
2415 (gnus-group-make-group group method))
2417 (defun gnus-group-make-help-group (&optional noerror)
2418 "Create the Gnus documentation group.
2419 Optional argument NOERROR modifies the behavior of this function when the
2420 group already exists:
2421 - if not given, and error is signaled,
2422 - if t, stay silent,
2423 - if anything else, just print a message."
2425 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2426 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2427 (if (gnus-gethash name gnus-newsrc-hashtb)
2428 (cond ((eq noerror nil)
2429 (error "Documentation group already exists"))
2434 (gnus-message 1 "Documentation group already exists")))
2437 (gnus-message 1 "Couldn't find doc group")
2438 (gnus-group-make-group
2439 (gnus-group-real-name name)
2440 (list 'nndoc "gnus-help"
2441 (list 'nndoc-address file)
2442 (list 'nndoc-article-type 'mbox))))
2444 (gnus-group-position-point))
2446 (defun gnus-group-make-doc-group (file type)
2447 "Create a group that uses a single file as the source."
2449 (list (read-file-name "File name: ")
2450 (and current-prefix-arg 'ask)))
2451 (when (eq type 'ask)
2456 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2458 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2459 ((= char ?b) 'babyl)
2460 ((= char ?d) 'digest)
2461 ((= char ?f) 'forward)
2463 ((= char ?g) 'guess)
2464 (t (setq err (format "%c unknown. " char))
2467 (let* ((file (expand-file-name file))
2468 (name (gnus-generate-new-group-name
2469 (gnus-group-prefixed-name
2470 (file-name-nondirectory file) '(nndoc "")))))
2471 (gnus-group-make-group
2472 (gnus-group-real-name name)
2474 (list 'nndoc-address file)
2475 (list 'nndoc-article-type (or type 'guess))))))
2477 (defvar nnweb-type-definition)
2478 (defvar gnus-group-web-type-history nil)
2479 (defvar gnus-group-web-search-history nil)
2480 (defun gnus-group-make-web-group (&optional solid)
2481 "Create an ephemeral nnweb group.
2482 If SOLID (the prefix), create a solid group."
2486 (if solid (gnus-read-group "Group name: ")
2487 (message-unique-id)))
2488 (default-type (or (car gnus-group-web-type-history)
2489 (symbol-name (caar nnweb-type-definition))))
2493 (format "Search engine type (default %s): " default-type)
2494 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2495 nnweb-type-definition)
2496 nil t nil 'gnus-group-web-type-history)
2501 (cons (or (car gnus-group-web-search-history) "") 0)
2502 'gnus-group-web-search-history))
2504 `(nnweb ,group (nnweb-search ,search)
2505 (nnweb-type ,(intern type))
2506 (nnweb-ephemeral-p t))))
2508 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2509 (gnus-group-read-ephemeral-group
2511 (cons (current-buffer)
2512 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2514 (defvar nnwarchive-type-definition)
2515 (defvar gnus-group-warchive-type-history nil)
2516 (defvar gnus-group-warchive-login-history nil)
2517 (defvar gnus-group-warchive-address-history nil)
2519 (defun gnus-group-make-warchive-group ()
2520 "Create a nnwarchive group."
2522 (require 'nnwarchive)
2523 (let* ((group (gnus-read-group "Group name: "))
2524 (default-type (or (car gnus-group-warchive-type-history)
2525 (symbol-name (caar nnwarchive-type-definition))))
2529 (format "Warchive type (default %s): " default-type)
2530 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2531 nnwarchive-type-definition)
2532 nil t nil 'gnus-group-warchive-type-history)
2534 (address (read-string "Warchive address: "
2535 nil 'gnus-group-warchive-address-history))
2536 (default-login (or (car gnus-group-warchive-login-history)
2541 (format "Warchive login (default %s): " user-mail-address)
2542 default-login 'gnus-group-warchive-login-history)
2545 `(nnwarchive ,address
2546 (nnwarchive-type ,(intern type))
2547 (nnwarchive-login ,login))))
2548 (gnus-group-make-group group method)))
2550 (defun gnus-group-make-archive-group (&optional all)
2551 "Create the (ding) Gnus archive group of the most recent articles.
2552 Given a prefix, create a full group."
2554 (let ((group (gnus-group-prefixed-name
2555 (if all "ding.archives" "ding.recent") '(nndir ""))))
2556 (when (gnus-gethash group gnus-newsrc-hashtb)
2557 (error "Archive group already exists"))
2558 (gnus-group-make-group
2559 (gnus-group-real-name group)
2560 (list 'nndir (if all "hpc" "edu")
2561 (list 'nndir-directory
2562 (if all gnus-group-archive-directory
2563 gnus-group-recent-archive-directory))))
2564 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2566 (defun gnus-group-make-directory-group (dir)
2567 "Create an nndir group.
2568 The user will be prompted for a directory. The contents of this
2569 directory will be used as a newsgroup. The directory should contain
2570 mail messages or news articles in files that have numeric names."
2572 (list (read-file-name "Create group from directory: ")))
2573 (unless (file-exists-p dir)
2574 (error "No such directory"))
2575 (unless (file-directory-p dir)
2576 (error "Not a directory"))
2580 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2582 (gnus-group-prefixed-name
2583 (expand-file-name ext dir)
2585 (setq ext (format "<%d>" (setq i (1+ i)))))
2586 (gnus-group-make-group
2587 (gnus-group-real-name group)
2588 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2590 (eval-when-compile (defvar nnkiboze-score-file))
2591 (defun gnus-group-make-kiboze-group (group address scores)
2592 "Create an nnkiboze group.
2593 The user will be prompted for a name, a regexp to match groups, and
2594 score file entries for articles to include in the group."
2597 (read-string "nnkiboze group name: ")
2598 (read-string "Source groups (regexp): ")
2599 (let ((headers (mapcar (lambda (group) (list group))
2600 '("subject" "from" "number" "date" "message-id"
2601 "references" "chars" "lines" "xref"
2602 "followup" "all" "body" "head")))
2603 scores header regexp regexps)
2604 (while (not (equal "" (setq header (completing-read
2605 "Match on header: " headers nil t))))
2607 (while (not (equal "" (setq regexp (read-string
2608 (format "Match on %s (regexp): "
2610 (push (list regexp nil nil 'r) regexps))
2611 (push (cons header regexps) scores))
2613 (gnus-group-make-group group "nnkiboze" address)
2614 (let* ((nnkiboze-current-group group)
2615 (score-file (car (nnkiboze-score-file "")))
2616 (score-dir (file-name-directory score-file)))
2617 (unless (file-exists-p score-dir)
2618 (make-directory score-dir))
2619 (with-temp-file score-file
2620 (let (emacs-lisp-mode-hook)
2621 (pp scores (current-buffer))))))
2623 (defun gnus-group-add-to-virtual (n vgroup)
2624 "Add the current group to a virtual group."
2626 (list current-prefix-arg
2627 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2629 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2630 (error "%s is not an nnvirtual group" vgroup))
2631 (gnus-close-group vgroup)
2632 (let* ((groups (gnus-group-process-prefix n))
2633 (method (gnus-info-method (gnus-get-info vgroup))))
2634 (setcar (cdr method)
2636 (nth 1 method) "\\|"
2639 (gnus-group-remove-mark s)
2640 (concat "\\(^" (regexp-quote s) "$\\)"))
2642 (gnus-group-position-point))
2644 (defun gnus-group-make-empty-virtual (group)
2645 "Create a new, fresh, empty virtual group."
2646 (interactive "sCreate new, empty virtual group: ")
2647 (let* ((method (list 'nnvirtual "^$"))
2648 (pgroup (gnus-group-prefixed-name group method)))
2649 ;; Check whether it exists already.
2650 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2651 (error "Group %s already exists" pgroup))
2652 ;; Subscribe the new group after the group on the current line.
2653 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2654 (gnus-group-update-group pgroup)
2656 (gnus-group-position-point)))
2658 (defun gnus-group-enter-directory (dir)
2659 "Enter an ephemeral nneething group."
2660 (interactive "DDirectory to read: ")
2661 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2662 (leaf (gnus-group-prefixed-name
2663 (file-name-nondirectory (directory-file-name dir))
2665 (name (gnus-generate-new-group-name leaf)))
2666 (unless (gnus-group-read-ephemeral-group
2668 (cons (current-buffer)
2669 (if (eq major-mode 'gnus-summary-mode)
2671 (error "Couldn't enter %s" dir))))
2674 (autoload 'nnimap-expunge "nnimap")
2675 (autoload 'nnimap-acl-get "nnimap")
2676 (autoload 'nnimap-acl-edit "nnimap"))
2678 (defun gnus-group-nnimap-expunge (group)
2679 "Expunge deleted articles in current nnimap GROUP."
2680 (interactive (list (gnus-group-group-name)))
2681 (let ((mailbox (gnus-group-real-name group)) method)
2683 (error "No group on current line"))
2684 (unless (gnus-get-info group)
2685 (error "Killed group; can't be edited"))
2686 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2687 (error "%s is not an nnimap group" group))
2688 (nnimap-expunge mailbox (cadr method))))
2690 (defun gnus-group-nnimap-edit-acl (group)
2691 "Edit the Access Control List of current nnimap GROUP."
2692 (interactive (list (gnus-group-group-name)))
2693 (let ((mailbox (gnus-group-real-name group)) method acl)
2695 (error "No group on current line"))
2696 (unless (gnus-get-info group)
2697 (error "Killed group; can't be edited"))
2698 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2699 (error "%s is not an nnimap group" group))
2700 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2701 (error "Server does not support ACL's"))
2702 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2704 An access control list is a list of (identifier . rights) elements.
2706 The identifier string specifies the corresponding user. The
2707 identifier \"anyone\" is reserved to refer to the universal identity.
2709 Rights is a string listing a (possibly empty) set of alphanumeric
2710 characters, each character listing a set of operations which is being
2711 controlled. Letters are reserved for ``standard'' rights, listed
2712 below. Digits are reserved for implementation or site defined rights.
2714 l - lookup (mailbox is visible to LIST/LSUB commands)
2715 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2716 SEARCH, COPY from mailbox)
2717 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2718 w - write (STORE flags other than \\SEEN and \\DELETED)
2719 i - insert (perform APPEND, COPY into mailbox)
2720 p - post (send mail to submission address for mailbox,
2721 not enforced by IMAP4 itself)
2722 c - create and delete mailbox (CREATE new sub-mailboxes in any
2723 implementation-defined hierarchy, RENAME or DELETE mailbox)
2724 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2725 a - administer (perform SETACL)" group)
2728 ,mailbox ',method ',acl form)))))
2730 ;; Group sorting commands
2731 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2733 (defun gnus-group-sort-groups (func &optional reverse)
2734 "Sort the group buffer according to FUNC.
2735 When used interactively, the sorting function used will be
2736 determined by the `gnus-group-sort-function' variable.
2737 If REVERSE (the prefix), reverse the sorting order."
2738 (interactive (list gnus-group-sort-function current-prefix-arg))
2739 (funcall gnus-group-sort-alist-function
2740 (gnus-make-sort-function func) reverse)
2741 (gnus-group-unmark-all-groups)
2742 (gnus-group-list-groups)
2743 (gnus-dribble-touch))
2745 (defun gnus-group-sort-flat (func reverse)
2746 ;; We peel off the dummy group from the alist.
2748 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2749 (pop gnus-newsrc-alist))
2751 (setq gnus-newsrc-alist
2752 (sort gnus-newsrc-alist func))
2754 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2755 ;; Regenerate the hash table.
2756 (gnus-make-hashtable-from-newsrc-alist)))
2758 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2759 "Sort the group buffer alphabetically by group name.
2760 If REVERSE, sort in reverse order."
2762 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2764 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2765 "Sort the group buffer alphabetically by real (unprefixed) group name.
2766 If REVERSE, sort in reverse order."
2768 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2770 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2771 "Sort the group buffer by number of unread articles.
2772 If REVERSE, sort in reverse order."
2774 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2776 (defun gnus-group-sort-groups-by-level (&optional reverse)
2777 "Sort the group buffer by group level.
2778 If REVERSE, sort in reverse order."
2780 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2782 (defun gnus-group-sort-groups-by-score (&optional reverse)
2783 "Sort the group buffer by group score.
2784 If REVERSE, sort in reverse order."
2786 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2788 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2789 "Sort the group buffer by group rank.
2790 If REVERSE, sort in reverse order."
2792 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2794 (defun gnus-group-sort-groups-by-method (&optional reverse)
2795 "Sort the group buffer alphabetically by backend name.
2796 If REVERSE, sort in reverse order."
2798 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2800 (defun gnus-group-sort-groups-by-server (&optional reverse)
2801 "Sort the group buffer alphabetically by server name.
2802 If REVERSE, sort in reverse order."
2804 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2806 ;;; Selected group sorting.
2808 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2809 "Sort the process/prefixed groups."
2810 (interactive (list current-prefix-arg gnus-group-sort-function))
2811 (let ((groups (gnus-group-process-prefix n)))
2812 (funcall gnus-group-sort-selected-function
2813 groups (gnus-make-sort-function func) reverse)
2814 (gnus-group-unmark-all-groups)
2815 (gnus-group-list-groups)
2816 (gnus-dribble-touch)))
2818 (defun gnus-group-sort-selected-flat (groups func reverse)
2819 (let (entries infos)
2820 ;; First find all the group entries for these groups.
2822 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2824 ;; Then sort the infos.
2828 (lambda (entry) (car entry))
2829 (setq entries (nreverse entries)))
2832 (setq infos (nreverse infos)))
2833 ;; Go through all the infos and replace the old entries
2834 ;; with the new infos.
2836 (setcar (car entries) (pop infos))
2838 ;; Update the hashtable.
2839 (gnus-make-hashtable-from-newsrc-alist)))
2841 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2842 "Sort the group buffer alphabetically by group name.
2843 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2844 sort in reverse order."
2845 (interactive (gnus-interactive "P\ny"))
2846 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2848 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2849 "Sort the group buffer alphabetically by real group name.
2850 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2851 sort in reverse order."
2852 (interactive (gnus-interactive "P\ny"))
2853 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2855 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2856 "Sort the group buffer by number of unread articles.
2857 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2858 sort in reverse order."
2859 (interactive (gnus-interactive "P\ny"))
2860 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2862 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2863 "Sort the group buffer by group level.
2864 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2865 sort in reverse order."
2866 (interactive (gnus-interactive "P\ny"))
2867 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2869 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2870 "Sort the group buffer by group score.
2871 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2872 sort in reverse order."
2873 (interactive (gnus-interactive "P\ny"))
2874 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2876 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2877 "Sort the group buffer by group rank.
2878 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2879 sort in reverse order."
2880 (interactive (gnus-interactive "P\ny"))
2881 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2883 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2884 "Sort the group buffer alphabetically by backend name.
2885 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2886 sort in reverse order."
2887 (interactive (gnus-interactive "P\ny"))
2888 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2890 ;;; Sorting predicates.
2892 (defun gnus-group-sort-by-alphabet (info1 info2)
2893 "Sort alphabetically."
2894 (string< (gnus-info-group info1) (gnus-info-group info2)))
2896 (defun gnus-group-sort-by-real-name (info1 info2)
2897 "Sort alphabetically on real (unprefixed) names."
2898 (string< (gnus-group-real-name (gnus-info-group info1))
2899 (gnus-group-real-name (gnus-info-group info2))))
2901 (defun gnus-group-sort-by-unread (info1 info2)
2902 "Sort by number of unread articles."
2903 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2904 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2905 (< (or (and (numberp n1) n1) 0)
2906 (or (and (numberp n2) n2) 0))))
2908 (defun gnus-group-sort-by-level (info1 info2)
2910 (< (gnus-info-level info1) (gnus-info-level info2)))
2912 (defun gnus-group-sort-by-method (info1 info2)
2913 "Sort alphabetically by backend name."
2914 (string< (car (gnus-find-method-for-group
2915 (gnus-info-group info1) info1))
2916 (car (gnus-find-method-for-group
2917 (gnus-info-group info2) info2))))
2919 (defun gnus-group-sort-by-server (info1 info2)
2920 "Sort alphabetically by server name."
2921 (string< (gnus-method-to-full-server-name
2922 (gnus-find-method-for-group
2923 (gnus-info-group info1) info1))
2924 (gnus-method-to-full-server-name
2925 (gnus-find-method-for-group
2926 (gnus-info-group info2) info2))))
2928 (defun gnus-group-sort-by-score (info1 info2)
2929 "Sort by group score."
2930 (> (gnus-info-score info1) (gnus-info-score info2)))
2932 (defun gnus-group-sort-by-rank (info1 info2)
2933 "Sort by level and score."
2934 (let ((level1 (gnus-info-level info1))
2935 (level2 (gnus-info-level info2)))
2936 (or (< level1 level2)
2937 (and (= level1 level2)
2938 (> (gnus-info-score info1) (gnus-info-score info2))))))
2942 (defun gnus-group-clear-data (&optional arg)
2943 "Clear all marks and read ranges from the current group."
2945 (gnus-group-iterate arg
2948 (gnus-info-clear-data (setq info (gnus-get-info group)))
2949 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2950 (when (gnus-group-goto-group group)
2951 (gnus-group-update-group-line))))))
2953 (defun gnus-group-clear-data-on-native-groups ()
2954 "Clear all marks and read ranges from all native groups."
2956 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2957 (let ((alist (cdr gnus-newsrc-alist))
2959 (while (setq info (pop alist))
2960 (when (gnus-group-native-p (gnus-info-group info))
2961 (gnus-info-clear-data info)))
2962 (gnus-get-unread-articles)
2963 (gnus-dribble-touch)
2964 (when (gnus-y-or-n-p
2965 "Move the cache away to avoid problems in the future? ")
2966 (call-interactively 'gnus-cache-move-cache)))))
2968 (defun gnus-info-clear-data (info)
2969 "Clear all marks and read ranges from INFO."
2970 (let ((group (gnus-info-group info))
2972 (dolist (el (gnus-info-marks info))
2973 (push `(,(cdr el) add (,(car el))) action))
2974 (push `(,(gnus-info-read info) add (read)) action)
2977 (gnus-request-set-mark ,group ',action)
2978 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2979 (gnus-info-set-read ',info ',(gnus-info-read info))
2980 (when (gnus-group-goto-group ,group)
2981 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2982 (gnus-group-update-group-line))))
2983 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2985 (gnus-request-set-mark group action)
2986 (gnus-info-set-read info nil)
2987 (when (gnus-info-marks info)
2988 (gnus-info-set-marks info nil))))
2990 ;; Group catching up.
2992 (defun gnus-group-catchup-current (&optional n all)
2993 "Mark all unread articles in the current newsgroup as read.
2994 If prefix argument N is numeric, the next N newsgroups will be
2995 caught up. If ALL is non-nil, marked articles will also be marked as
2996 read. Cross references (Xref: header) of articles are ignored.
2997 The number of newsgroups that this function was unable to catch
3000 (let ((groups (gnus-group-process-prefix n))
3003 (unless groups (error "No groups selected"))
3005 (or (not gnus-interactive-catchup) ;Without confirmation?
3010 "Do you really want to mark all articles in %s as read? "
3011 "Mark all unread articles in %s as read? ")
3012 (if (= (length groups) 1)
3014 (format "these %d groups" (length groups)))))))
3016 (while (setq group (pop groups))
3017 (gnus-group-remove-mark group)
3018 ;; Virtual groups have to be given special treatment.
3019 (let ((method (gnus-find-method-for-group group)))
3020 (when (eq 'nnvirtual (car method))
3021 (nnvirtual-catchup-group
3022 (gnus-group-real-name group) (nth 1 method) all)))
3023 (if (>= (gnus-group-level group) gnus-level-zombie)
3024 (gnus-message 2 "Dead groups can't be caught up")
3026 (gnus-group-goto-group group)
3027 (gnus-group-catchup group all))
3028 (gnus-group-update-group-line)
3029 (setq ret (1+ ret)))))
3030 (gnus-group-next-unread-group 1)
3033 (defun gnus-group-catchup-current-all (&optional n)
3034 "Mark all articles in current newsgroup as read.
3035 Cross references (Xref: header) of articles are ignored."
3037 (gnus-group-catchup-current n 'all))
3039 (defun gnus-group-catchup (group &optional all)
3040 "Mark all articles in GROUP as read.
3041 If ALL is non-nil, all articles are marked as read.
3042 The return value is the number of articles that were marked as read,
3043 or nil if no action could be taken."
3044 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3046 (marks (nth 3 (nth 2 entry)))
3047 (unread (gnus-list-of-unread-articles group)))
3048 ;; Remove entries for this group.
3049 (nnmail-purge-split-history (gnus-group-real-name group))
3050 ;; Do the updating only if the newsgroup isn't killed.
3051 (if (not (numberp (car entry)))
3052 (gnus-message 1 "Can't catch up %s; non-active group" group)
3053 (gnus-update-read-articles group nil)
3055 ;; Nix out the lists of marks and dormants.
3056 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3058 (list (cdr (assq 'dormant marks))
3060 (setq unread (gnus-uncompress-range
3061 (gnus-range-add (gnus-range-add
3062 unread (cdr (assq 'dormant marks)))
3063 (cdr (assq 'tick marks)))))
3064 (gnus-add-marked-articles group 'tick nil nil 'force)
3065 (gnus-add-marked-articles group 'dormant nil nil 'force))
3066 ;; Do auto-expirable marks if that's required.
3067 (when (gnus-group-auto-expirable-p group)
3068 (gnus-add-marked-articles group 'expire unread)
3069 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3070 (let ((gnus-newsgroup-name group))
3071 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3074 (defun gnus-group-expire-articles (&optional n)
3075 "Expire all expirable articles in the current newsgroup."
3077 (let ((groups (gnus-group-process-prefix n))
3080 (error "No groups to expire"))
3081 (while (setq group (pop groups))
3082 (gnus-group-remove-mark group)
3083 (gnus-group-expire-articles-1 group)
3084 (gnus-dribble-touch)
3085 (gnus-group-position-point))))
3087 (defun gnus-group-expire-articles-1 (group)
3088 (when (gnus-check-backend-function 'request-expire-articles group)
3089 (gnus-message 6 "Expiring articles in %s..." group)
3090 (let* ((info (gnus-get-info group))
3091 (expirable (if (gnus-group-total-expirable-p group)
3092 (cons nil (gnus-list-of-read-articles group))
3093 (assq 'expire (gnus-info-marks info))))
3094 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3095 (nnmail-expiry-target
3096 (or (gnus-group-find-parameter group 'expiry-target)
3097 nnmail-expiry-target)))
3099 (gnus-check-group group)
3102 (gnus-compress-sequence
3104 ;; We set the expiry variables to the group
3106 (let ((nnmail-expiry-wait-function nil)
3107 (nnmail-expiry-wait expiry-wait))
3108 (gnus-request-expire-articles
3109 (gnus-uncompress-sequence (cdr expirable)) group))
3110 ;; Just expire using the normal expiry values.
3111 (gnus-request-expire-articles
3112 (gnus-uncompress-sequence (cdr expirable)) group))))
3113 (gnus-close-group group))
3114 (gnus-message 6 "Expiring articles in %s...done" group)
3115 ;; Return the list of un-expired articles.
3118 (defun gnus-group-expire-all-groups ()
3119 "Expire all expirable articles in all newsgroups."
3122 (gnus-message 5 "Expiring...")
3123 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3124 (cdr gnus-newsrc-alist))))
3125 (gnus-group-expire-articles nil)))
3126 (gnus-group-position-point)
3127 (gnus-message 5 "Expiring...done"))
3129 (defun gnus-group-set-current-level (n level)
3130 "Set the level of the next N groups to LEVEL."
3135 (let ((s (read-string
3136 (format "Level (default %s): "
3137 (or (gnus-group-group-level)
3138 gnus-level-default-subscribed)))))
3139 (if (string-match "^\\s-*$" s)
3140 (int-to-string (or (gnus-group-group-level)
3141 gnus-level-default-subscribed))
3143 (unless (and (>= level 1) (<= level gnus-level-killed))
3144 (error "Invalid level: %d" level))
3145 (let ((groups (gnus-group-process-prefix n))
3147 (while (setq group (pop groups))
3148 (gnus-group-remove-mark group)
3149 (gnus-message 6 "Changed level of %s from %d to %d"
3150 group (or (gnus-group-group-level) gnus-level-killed)
3152 (gnus-group-change-level
3153 group level (or (gnus-group-group-level) gnus-level-killed))
3154 (gnus-group-update-group-line)))
3155 (gnus-group-position-point))
3157 (defun gnus-group-unsubscribe (&optional n)
3158 "Unsubscribe the current group."
3160 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3162 (defun gnus-group-subscribe (&optional n)
3163 "Subscribe the current group."
3165 (gnus-group-unsubscribe-current-group n 'subscribe))
3167 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3168 "Toggle subscription of the current group.
3169 If given numerical prefix, toggle the N next groups."
3171 (let ((groups (gnus-group-process-prefix n))
3174 (setq group (car groups)
3175 groups (cdr groups))
3176 (gnus-group-remove-mark group)
3177 (gnus-group-unsubscribe-group
3180 ((eq do-sub 'unsubscribe)
3181 gnus-level-default-unsubscribed)
3182 ((eq do-sub 'subscribe)
3183 gnus-level-default-subscribed)
3184 ((<= (gnus-group-group-level) gnus-level-subscribed)
3185 gnus-level-default-unsubscribed)
3187 gnus-level-default-subscribed))
3189 (gnus-group-update-group-line))
3190 (gnus-group-next-group 1)))
3192 (defun gnus-group-unsubscribe-group (group &optional level silent)
3193 "Toggle subscription to GROUP.
3194 Killed newsgroups are subscribed. If SILENT, don't try to update the
3197 (list (gnus-group-completing-read-group-name
3198 "Group: " gnus-active-hashtb nil
3199 (gnus-read-active-file-p)
3201 'gnus-group-history)))
3202 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3204 ((string-match "^[ \t]*$" group)
3205 (error "Empty group name"))
3207 ;; Toggle subscription flag.
3208 (gnus-group-change-level
3209 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3210 gnus-level-subscribed)
3211 (1+ gnus-level-subscribed)
3212 gnus-level-default-subscribed)))
3214 (gnus-group-update-group group)))
3215 ((and (stringp group)
3216 (or (not (gnus-read-active-file-p))
3217 (gnus-active group)))
3218 ;; Add new newsgroup.
3219 (gnus-group-change-level
3221 (if level level gnus-level-default-subscribed)
3222 (or (and (member group gnus-zombie-list)
3225 (when (gnus-group-group-name)
3226 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3228 (gnus-group-update-group group)))
3229 (t (error "No such newsgroup: %s" group)))
3230 (gnus-group-position-point)))
3232 (defun gnus-group-transpose-groups (n)
3233 "Move the current newsgroup up N places.
3234 If given a negative prefix, move down instead. The difference between
3235 N and the number of steps taken is returned."
3237 (unless (gnus-group-group-name)
3238 (error "No group on current line"))
3239 (gnus-group-kill-group 1)
3241 (forward-line (- n))
3242 (gnus-group-yank-group)
3243 (gnus-group-position-point)))
3245 (defun gnus-group-kill-all-zombies (&optional dummy)
3246 "Kill all zombie newsgroups.
3247 The optional DUMMY should always be nil."
3248 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3250 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3251 (setq gnus-zombie-list nil)
3252 (gnus-dribble-touch)
3253 (gnus-group-list-groups)))
3255 (defun gnus-group-kill-region (begin end)
3256 "Kill newsgroups in current region (excluding current point).
3257 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3272 (beginning-of-line) ;Important when LINES < 1
3273 (gnus-group-kill-group lines)))
3275 (defun gnus-group-kill-group (&optional n discard)
3276 "Kill the next N groups.
3277 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3278 However, only groups that were alive can be yanked; already killed
3279 groups or zombie groups can't be yanked.
3280 The return value is the name of the group that was killed, or a list
3283 (let ((buffer-read-only nil)
3284 (groups (gnus-group-process-prefix n))
3285 group entry level out)
3286 (if (< (length groups) 10)
3287 ;; This is faster when there are few groups.
3289 (push (setq group (pop groups)) out)
3290 (gnus-group-remove-mark group)
3291 (setq level (gnus-group-group-level))
3293 (when (and (not discard)
3294 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3297 (gnus-group-goto-group ,(gnus-group-group-name))
3298 (gnus-group-yank-group)))
3299 (push (cons (car entry) (nth 2 entry))
3300 gnus-list-of-killed-groups))
3301 (gnus-group-change-level
3302 (if entry entry group) gnus-level-killed (if entry nil level))
3303 (message "Killed group %s" group))
3304 ;; If there are lots and lots of groups to be killed, we use
3305 ;; this thing instead.
3307 (setq groups (nreverse groups))
3309 (gnus-group-remove-mark (setq group (pop groups)))
3311 (push group gnus-killed-list)
3312 (setq gnus-newsrc-alist
3313 (delq (assoc group gnus-newsrc-alist)
3315 (when gnus-group-change-level-function
3316 (funcall gnus-group-change-level-function
3317 group gnus-level-killed 3))
3319 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3320 (push (cons (car entry) (nth 2 entry))
3321 gnus-list-of-killed-groups)
3322 (setcdr (cdr entry) (cdddr entry)))
3323 ((member group gnus-zombie-list)
3324 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3325 ;; There may be more than one instance displayed.
3326 (while (gnus-group-goto-group group)
3327 (gnus-delete-line)))
3328 (gnus-make-hashtable-from-newsrc-alist)))
3330 (gnus-group-position-point)
3331 (if (< (length out) 2) (car out) (nreverse out))))
3333 (defun gnus-group-yank-group (&optional arg)
3334 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3335 The numeric ARG specifies how many newsgroups are to be yanked. The
3336 name of the newsgroup yanked is returned, or (if several groups are
3337 yanked) a list of yanked groups is returned."
3339 (setq arg (or arg 1))
3340 (let (info group prev out)
3341 (while (>= (decf arg) 0)
3342 (when (not (setq info (pop gnus-list-of-killed-groups)))
3343 (error "No more newsgroups to yank"))
3344 (push (setq group (nth 1 info)) out)
3345 ;; Find which newsgroup to insert this one before - search
3346 ;; backward until something suitable is found. If there are no
3347 ;; other newsgroups in this buffer, just make this newsgroup the
3349 (setq prev (gnus-group-group-name))
3350 (gnus-group-change-level
3351 info (gnus-info-level (cdr info)) gnus-level-killed
3352 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3354 (gnus-group-insert-group-line-info group)
3356 `(when (gnus-group-goto-group ,group)
3357 (gnus-group-kill-group 1))))
3359 (gnus-group-position-point)
3360 (if (< (length out) 2) (car out) (nreverse out))))
3362 (defun gnus-group-kill-level (level)
3363 "Kill all groups that is on a certain LEVEL."
3364 (interactive "nKill all groups on level: ")
3366 ((= level gnus-level-zombie)
3367 (setq gnus-killed-list
3368 (nconc gnus-zombie-list gnus-killed-list))
3369 (setq gnus-zombie-list nil))
3370 ((and (< level gnus-level-zombie)
3372 (or gnus-expert-user
3375 "Do you really want to kill all groups on level %d? "
3377 (let* ((prev gnus-newsrc-alist)
3380 (if (= (gnus-info-level (car alist)) level)
3382 (push (gnus-info-group (car alist)) gnus-killed-list)
3383 (setcdr prev (cdr alist)))
3385 (setq alist (cdr alist)))
3386 (gnus-make-hashtable-from-newsrc-alist)
3387 (gnus-group-list-groups)))
3389 (error "Can't kill; invalid level: %d" level))))
3391 (defun gnus-group-list-all-groups (&optional arg)
3392 "List all newsgroups with level ARG or lower.
3393 Default is gnus-level-unsubscribed, which lists all subscribed and most
3394 unsubscribed groups."
3396 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3398 ;; Redefine this to list ALL killed groups if prefix arg used.
3399 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3400 (defun gnus-group-list-killed (&optional arg)
3401 "List all killed newsgroups in the group buffer.
3402 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3403 entail asking the server for the groups."
3405 ;; Find all possible killed newsgroups if arg.
3407 (gnus-get-killed-groups))
3408 (if (not gnus-killed-list)
3409 (gnus-message 6 "No killed groups")
3410 (let (gnus-group-list-mode)
3411 (funcall gnus-group-prepare-function
3412 gnus-level-killed t gnus-level-killed))
3413 (goto-char (point-min)))
3414 (gnus-group-position-point))
3416 (defun gnus-group-list-zombies ()
3417 "List all zombie newsgroups in the group buffer."
3419 (if (not gnus-zombie-list)
3420 (gnus-message 6 "No zombie groups")
3421 (let (gnus-group-list-mode)
3422 (funcall gnus-group-prepare-function
3423 gnus-level-zombie t gnus-level-zombie))
3424 (goto-char (point-min)))
3425 (gnus-group-position-point))
3427 (defun gnus-group-list-active ()
3428 "List all groups that are available from the server(s)."
3430 ;; First we make sure that we have really read the active file.
3431 (unless (gnus-read-active-file-p)
3432 (let ((gnus-read-active-file t)
3433 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3434 (gnus-read-active-file)))
3435 ;; Find all groups and sort them.
3443 (push (symbol-name sym) list)))
3447 (buffer-read-only nil)
3451 (setq group (pop groups))
3452 (gnus-add-text-properties
3453 (point) (prog1 (1+ (point))
3455 (gnus-group-decoded-name group)
3457 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3459 'gnus-level (inline (gnus-group-level group)))))
3460 (goto-char (point-min))))
3462 (defun gnus-activate-all-groups (level)
3463 "Activate absolutely all groups."
3464 (interactive (list gnus-level-unsubscribed))
3465 (let ((gnus-activate-level level)
3466 (gnus-activate-foreign-newsgroups level))
3467 (gnus-group-get-new-news)))
3469 (defun gnus-group-get-new-news (&optional arg)
3470 "Get newly arrived articles.
3471 If ARG is a number, it specifies which levels you are interested in
3472 re-scanning. If ARG is non-nil and not a number, this will force
3473 \"hard\" re-reading of the active files from all servers."
3476 (let ((gnus-inhibit-demon t)
3477 ;; Binding this variable will inhibit multiple fetchings
3478 ;; of the same mail source.
3479 (nnmail-fetched-sources (list t)))
3480 (gnus-run-hooks 'gnus-get-new-news-hook)
3482 ;; Read any slave files.
3484 (gnus-master-read-slave-newsrc))
3486 ;; We might read in new NoCeM messages here.
3487 (when (and gnus-use-nocem
3489 (gnus-nocem-scan-groups))
3490 ;; If ARG is not a number, then we read the active file.
3491 (when (and arg (not (numberp arg)))
3492 (let ((gnus-read-active-file t))
3493 (gnus-read-active-file))
3496 ;; If the user wants it, we scan for new groups.
3497 (when (eq gnus-check-new-newsgroups 'always)
3498 (gnus-find-new-newsgroups)))
3500 (setq arg (gnus-group-default-level arg t))
3501 (if (and gnus-read-active-file (not arg))
3503 (gnus-read-active-file)
3504 (gnus-get-unread-articles arg))
3505 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3506 (gnus-get-unread-articles arg)))
3507 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3508 (gnus-group-list-groups (and (numberp arg)
3509 (max (car gnus-group-list-mode) arg))))
3511 (when (and gnus-agent (not (interactive-p)))
3512 (gnus-agent-toggle-plugged gnus-plugged)))
3514 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3515 "Check for newly arrived news in the current group (and the N-1 next groups).
3516 The difference between N and the number of newsgroup checked is returned.
3517 If N is negative, this group and the N-1 previous groups will be checked."
3519 (let* ((groups (gnus-group-process-prefix n))
3520 (ret (if (numberp n) (- n (length groups)) 0))
3524 (gnus-inhibit-demon t)
3525 ;; Binding this variable will inhibit multiple fetchings
3526 ;; of the same mail source.
3527 (nnmail-fetched-sources (list t)))
3528 (gnus-run-hooks 'gnus-get-new-news-hook)
3529 (while (setq group (pop groups))
3530 (gnus-group-remove-mark group)
3531 ;; Bypass any previous denials from the server.
3532 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3533 (if (gnus-activate-group group (if dont-scan nil 'scan))
3535 (gnus-get-unread-articles-in-group
3536 (gnus-get-info group) (gnus-active group) t)
3537 (unless (gnus-virtual-group-p group)
3538 (gnus-close-group group))
3540 (gnus-agent-save-group-info
3541 method (gnus-group-real-name group) (gnus-active group)))
3542 (gnus-group-update-group group))
3543 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3545 (gnus-error 3 "Server denied access")
3546 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3549 (when gnus-goto-next-group-when-activating
3550 (gnus-group-next-unread-group 1 t))
3551 (gnus-summary-position-point)
3554 (defun gnus-group-fetch-faq (group &optional faq-dir)
3555 "Fetch the FAQ for the current group.
3556 If given a prefix argument, prompt for the FAQ dir
3560 (gnus-group-group-name)
3561 (when current-prefix-arg
3563 "FAQ dir: " (and (listp gnus-group-faq-directory)
3565 gnus-group-faq-directory))))))
3567 (error "No group name given"))
3568 (let ((dirs (or faq-dir gnus-group-faq-directory))
3570 (unless (listp dirs)
3571 (setq dirs (list dirs)))
3572 (while (and (not found)
3573 (setq dir (pop dirs)))
3574 (let ((name (gnus-group-real-name group)))
3575 (setq file (expand-file-name name dir)))
3576 (if (not (file-exists-p file))
3577 (gnus-message 1 "No such file: %s" file)
3578 (let ((enable-local-variables nil))
3582 (defun gnus-group-fetch-charter (group)
3583 "Fetch the charter for the current group.
3584 If given a prefix argument, prompt for a group."
3586 (list (or (when current-prefix-arg
3587 (completing-read "Group: " gnus-active-hashtb))
3588 (gnus-group-group-name)
3589 gnus-newsgroup-name)))
3591 (error "No group name given"))
3593 (condition-case nil (require 'url-http) (error nil))
3594 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3596 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3597 (setq hierarchy (match-string 1 name))
3598 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3599 (if (fboundp 'url-http-file-exists-p)
3600 (url-http-file-exists-p (eval url))
3602 (browse-url (eval url))
3603 (setq url (concat "http://" hierarchy
3604 ".news-admin.org/charters/" name))
3605 (if (and (fboundp 'url-http-file-exists-p)
3606 (url-http-file-exists-p url))
3608 (gnus-group-fetch-control group))))))
3610 (defun gnus-group-fetch-control (group)
3611 "Fetch the archived control messages for the current group.
3612 If given a prefix argument, prompt for a group."
3614 (list (or (when current-prefix-arg
3615 (completing-read "Group: " gnus-active-hashtb))
3616 (gnus-group-group-name)
3617 gnus-newsgroup-name)))
3619 (error "No group name given"))
3620 (let ((name (gnus-group-real-name group))
3622 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3623 (setq hierarchy (match-string 1 name))
3624 (if gnus-group-fetch-control-use-browse-url
3625 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3626 hierarchy "/" name ".Z"))
3627 (let ((enable-local-variables nil))
3628 (gnus-group-read-ephemeral-group
3630 `(nndoc ,group (nndoc-address
3631 ,(find-file-noselect
3632 (concat "/ftp@ftp.isc.org:/usenet/control/"
3633 hierarchy "/" name ".Z")))
3634 (nndoc-article-type mbox)) t nil nil))))))
3636 (defun gnus-group-describe-group (force &optional group)
3637 "Display a description of the current newsgroup."
3638 (interactive (list current-prefix-arg (gnus-group-group-name)))
3639 (let* ((method (gnus-find-method-for-group group))
3640 (mname (gnus-group-prefixed-name "" method))
3643 gnus-description-hashtb)
3644 (gnus-sethash mname nil gnus-description-hashtb))
3646 (error "No group name given"))
3647 (when (or (and gnus-description-hashtb
3648 ;; We check whether this group's method has been
3649 ;; queried for a description file.
3650 (gnus-gethash mname gnus-description-hashtb))
3651 (setq desc (gnus-group-get-description group))
3652 (gnus-read-descriptions-file method))
3654 (or desc (gnus-gethash group gnus-description-hashtb)
3655 "No description available")))))
3657 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3658 (defun gnus-group-describe-all-groups (&optional force)
3659 "Pop up a buffer with descriptions of all newsgroups."
3662 (setq gnus-description-hashtb nil))
3663 (when (not (or gnus-description-hashtb
3664 (gnus-read-all-descriptions-files)))
3665 (error "Couldn't request descriptions file"))
3666 (let ((buffer-read-only nil)
3672 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3673 (insert (format " *: %-20s %s\n"
3674 (gnus-group-name-decode
3675 (symbol-name group) charset)
3676 (gnus-group-name-decode
3677 (symbol-value group) charset))))
3678 (gnus-add-text-properties
3679 b (1+ b) (list 'gnus-group group
3680 'gnus-unread t 'gnus-marked nil
3681 'gnus-level (1+ gnus-level-subscribed))))
3682 gnus-description-hashtb)
3683 (goto-char (point-min))
3684 (gnus-group-position-point)))
3686 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3687 (defun gnus-group-apropos (regexp &optional search-description)
3688 "List all newsgroups that have names that match a regexp."
3689 (interactive "sGnus apropos (regexp): ")
3691 (obuf (current-buffer))
3693 ;; Go through all newsgroups that are known to Gnus.
3696 (and (symbol-name group)
3697 (string-match regexp (symbol-name group))
3698 (symbol-value group)
3699 (push (symbol-name group) groups)))
3701 ;; Also go through all descriptions that are known to Gnus.
3702 (when search-description
3705 (and (string-match regexp (symbol-value group))
3706 (push (symbol-name group) groups)))
3707 gnus-description-hashtb))
3709 (gnus-message 3 "No groups matched \"%s\"." regexp)
3710 ;; Print out all the groups.
3712 (pop-to-buffer "*Gnus Help*")
3713 (buffer-disable-undo)
3715 (setq groups (sort groups 'string<))
3717 ;; Groups may be entered twice into the list of groups.
3718 (when (not (string= (car groups) prev))
3719 (setq prev (car groups))
3720 (let ((charset (gnus-group-name-charset nil prev)))
3721 (insert (gnus-group-name-decode prev charset) "\n")
3722 (when (and gnus-description-hashtb
3723 (setq des (gnus-gethash (car groups)
3724 gnus-description-hashtb)))
3725 (insert " " (gnus-group-name-decode des charset) "\n"))))
3726 (setq groups (cdr groups)))
3727 (goto-char (point-min))))
3728 (pop-to-buffer obuf)))
3730 (defun gnus-group-description-apropos (regexp)
3731 "List all newsgroups that have names or descriptions that match a regexp."
3732 (interactive "sGnus description apropos (regexp): ")
3733 (when (not (or gnus-description-hashtb
3734 (gnus-read-all-descriptions-files)))
3735 (error "Couldn't request descriptions file"))
3736 (gnus-group-apropos regexp t))
3738 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3739 (defun gnus-group-list-matching (level regexp &optional all lowest)
3740 "List all groups with unread articles that match REGEXP.
3741 If the prefix LEVEL is non-nil, it should be a number that says which
3742 level to cut off listing groups.
3743 If ALL, also list groups with no unread articles.
3744 If LOWEST, don't list groups with level lower than LOWEST.
3746 This command may read the active file."
3747 (interactive "P\nsList newsgroups matching: ")
3748 ;; First make sure active file has been read.
3750 (> (prefix-numeric-value level) gnus-level-killed))
3751 (gnus-get-killed-groups))
3752 (funcall gnus-group-prepare-function
3753 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3754 (goto-char (point-min))
3755 (gnus-group-position-point))
3757 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3758 "List all groups that match REGEXP.
3759 If the prefix LEVEL is non-nil, it should be a number that says which
3760 level to cut off listing groups.
3761 If LOWEST, don't list groups with level lower than LOWEST."
3762 (interactive "P\nsList newsgroups matching: ")
3764 (setq level (prefix-numeric-value level)))
3765 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3767 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3768 (defun gnus-group-save-newsrc (&optional force)
3769 "Save the Gnus startup files.
3770 If FORCE, force saving whether it is necessary or not."
3772 (gnus-save-newsrc-file force))
3774 (defun gnus-group-restart (&optional arg)
3775 "Force Gnus to read the .newsrc file."
3777 (when (gnus-yes-or-no-p
3778 (format "Are you sure you want to restart Gnus? "))
3779 (gnus-save-newsrc-file)
3783 (defun gnus-group-read-init-file ()
3784 "Read the Gnus elisp init file."
3786 (gnus-read-init-file)
3787 (gnus-message 5 "Read %s" gnus-init-file))
3789 (defun gnus-group-check-bogus-groups (&optional silent)
3790 "Check bogus newsgroups.
3791 If given a prefix, don't ask for confirmation before removing a bogus
3794 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3795 (gnus-group-list-groups))
3797 (defun gnus-group-find-new-groups (&optional arg)
3798 "Search for new groups and add them.
3799 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3800 With 1 C-u, use the `ask-server' method to query the server for new
3802 With 2 C-u's, use most complete method possible to query the server
3803 for new groups, and subscribe the new groups as zombies."
3805 (gnus-find-new-newsgroups (or arg 1))
3806 (gnus-group-list-groups))
3808 (defun gnus-group-edit-global-kill (&optional article group)
3809 "Edit the global kill file.
3810 If GROUP, edit that local kill file instead."
3812 (setq gnus-current-kill-article article)
3813 (gnus-kill-file-edit-file group)
3816 (substitute-command-keys
3817 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3818 (if group "local" "global")))))
3820 (defun gnus-group-edit-local-kill (article group)
3821 "Edit a local kill file."
3822 (interactive (list nil (gnus-group-group-name)))
3823 (gnus-group-edit-global-kill article group))
3825 (defun gnus-group-force-update ()
3826 "Update `.newsrc' file."
3828 (gnus-save-newsrc-file))
3830 (defun gnus-group-suspend ()
3831 "Suspend the current Gnus session.
3832 In fact, cleanup buffers except for group mode buffer.
3833 The hook gnus-suspend-gnus-hook is called before actually suspending."
3835 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3836 (gnus-offer-save-summaries)
3837 ;; Kill Gnus buffers except for group mode buffer.
3838 (let ((group-buf (get-buffer gnus-group-buffer)))
3839 (mapcar (lambda (buf)
3840 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3844 (eq major-mode 'message-mode))))
3845 (gnus-kill-buffer buf)))
3847 (gnus-kill-gnus-frames)
3849 (bury-buffer group-buf)
3850 (delete-windows-on group-buf t))))
3852 (defun gnus-group-clear-dribble ()
3853 "Clear all information from the dribble buffer."
3855 (gnus-dribble-clear)
3856 (gnus-message 7 "Cleared dribble buffer"))
3858 (defun gnus-group-exit ()
3859 "Quit reading news after updating .newsrc.eld and .newsrc.
3860 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3863 (or noninteractive ;For gnus-batch-kill
3864 (not gnus-interactive-exit) ;Without confirmation
3866 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3867 (gnus-run-hooks 'gnus-exit-gnus-hook)
3868 ;; Offer to save data from non-quitted summary buffers.
3869 (gnus-offer-save-summaries)
3870 ;; Save the newsrc file(s).
3871 (gnus-save-newsrc-file)
3873 (gnus-close-backends)
3874 ;; Reset everything.
3876 ;; Allow the user to do things after cleaning up.
3877 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3879 (defun gnus-group-quit ()
3880 "Quit reading news without updating .newsrc.eld or .newsrc.
3881 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3883 (when (or noninteractive ;For gnus-batch-kill
3884 (zerop (buffer-size))
3885 (not (gnus-server-opened gnus-select-method))
3887 (not gnus-current-startup-file)
3889 (format "Quit reading news without saving %s? "
3890 (file-name-nondirectory gnus-current-startup-file))))
3891 (gnus-run-hooks 'gnus-exit-gnus-hook)
3892 (gnus-configure-windows 'group t)
3893 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3894 (not (zerop (save-excursion
3895 (set-buffer gnus-dribble-buffer)
3898 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3900 (gnus-close-backends)
3902 (gnus-kill-buffer gnus-group-buffer)
3903 ;; Allow the user to do things after cleaning up.
3904 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3906 (defun gnus-group-describe-briefly ()
3907 "Give a one line description of the group mode commands."
3909 (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")))
3911 (defun gnus-group-browse-foreign-server (method)
3912 "Browse a foreign news server.
3913 If called interactively, this function will ask for a select method
3914 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3915 If not, METHOD should be a list where the first element is the method
3916 and the second element is the address."
3918 (list (let ((how (completing-read
3920 (append gnus-valid-select-methods gnus-server-alist)
3921 nil t (cons "nntp" 0) 'gnus-method-history)))
3922 ;; We either got a backend name or a virtual server name.
3923 ;; If the first, we also need an address.
3924 (if (assoc how gnus-valid-select-methods)
3926 ;; Suggested by mapjph@bath.ac.uk.
3929 (mapcar (lambda (server) (list server))
3930 gnus-secondary-servers)))
3931 ;; We got a server name.
3933 (gnus-browse-foreign-server method))
3935 (defun gnus-group-set-info (info &optional method-only-group part)
3936 (when (or info part)
3937 (let* ((entry (gnus-gethash
3938 (or method-only-group (gnus-info-group info))
3939 gnus-newsrc-hashtb))
3941 (info (if method-only-group (nth 2 entry) info))
3943 (when method-only-group
3945 (error "Trying to change non-existent group %s" method-only-group))
3946 ;; We have received parts of the actual group info - either the
3947 ;; select method or the group parameters. We first check
3948 ;; whether we have to extend the info, and if so, do that.
3949 (let ((len (length info))
3950 (total (if (eq part 'method) 5 6)))
3952 (setcdr (nthcdr (1- len) info)
3953 (make-list (- total len) nil)))
3954 ;; Then we enter the new info.
3955 (setcar (nthcdr (1- total) info) part-info)))
3957 ;; This is a new group, so we just create it.
3959 (set-buffer gnus-group-buffer)
3960 (setq method (gnus-info-method info))
3961 (when (gnus-server-equal method "native")
3964 (set-buffer gnus-group-buffer)
3966 ;; It's a foreign group...
3967 (gnus-group-make-group
3968 (gnus-group-real-name (gnus-info-group info))
3969 (if (stringp method) method
3970 (prin1-to-string (car method)))
3972 (nth 1 (gnus-info-method info))))
3973 ;; It's a native group.
3974 (gnus-group-make-group (gnus-info-group info))))
3975 (gnus-message 6 "Note: New group created")
3977 (gnus-gethash (gnus-group-prefixed-name
3978 (gnus-group-real-name (gnus-info-group info))
3979 (or (gnus-info-method info) gnus-select-method))
3980 gnus-newsrc-hashtb))))
3981 ;; Whether it was a new group or not, we now have the entry, so we
3982 ;; can do the update.
3985 (setcar (nthcdr 2 entry) info)
3986 (when (and (not (eq (car entry) t))
3987 (gnus-active (gnus-info-group info)))
3988 (setcar entry (length
3989 (gnus-list-of-unread-articles (car info))))))
3990 (error "No such group: %s" (gnus-info-group info))))))
3992 (defun gnus-group-set-method-info (group select-method)
3993 (gnus-group-set-info select-method group 'method))
3995 (defun gnus-group-set-params-info (group params)
3996 (gnus-group-set-info params group 'params))
3998 (defun gnus-add-marked-articles (group type articles &optional info force)
3999 ;; Add ARTICLES of TYPE to the info of GROUP.
4000 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4001 ;; add, but replace marked articles of TYPE with ARTICLES.
4002 (let ((info (or info (gnus-get-info group)))
4005 (and (not (setq marked (nthcdr 3 info)))
4007 (setcdr (nthcdr 2 info)
4008 (list (list (cons type (gnus-compress-sequence
4010 (and (not (setq m (assq type (car marked))))
4013 (cons (cons type (gnus-compress-sequence articles t) )
4017 (setcar (nthcdr 3 info)
4018 (gnus-delete-alist type (car marked)))
4019 (setcdr m (gnus-compress-sequence articles t)))
4020 (setcdr m (gnus-compress-sequence
4021 (sort (nconc (gnus-uncompress-range (cdr m))
4022 (copy-sequence articles)) '<) t))))))
4024 (defun gnus-add-mark (group mark article)
4025 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4026 (let ((buffer (gnus-summary-buffer-name group)))
4027 (if (gnus-buffer-live-p buffer)
4029 (set-buffer (get-buffer buffer))
4030 (gnus-summary-add-mark article mark))
4031 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4035 ;;; Group timestamps
4038 (defun gnus-group-set-timestamp ()
4039 "Change the timestamp of the current group to the current time.
4040 This function can be used in hooks like `gnus-select-group-hook'
4041 or `gnus-group-catchup-group-hook'."
4042 (when gnus-newsgroup-name
4043 (let ((time (current-time)))
4044 (setcdr (cdr time) nil)
4045 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4047 (defsubst gnus-group-timestamp (group)
4048 "Return the timestamp for GROUP."
4049 (gnus-group-get-parameter group 'timestamp t))
4051 (defun gnus-group-timestamp-delta (group)
4052 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4053 (let* ((time (or (gnus-group-timestamp group)
4055 (delta (subtract-time (current-time) time)))
4056 (+ (* (nth 0 delta) 65536.0)
4059 (defun gnus-group-timestamp-string (group)
4060 "Return a string of the timestamp for GROUP."
4061 (let ((time (gnus-group-timestamp group)))
4064 (gnus-time-iso8601 time))))
4066 (defun gnus-group-list-cached (level &optional lowest)
4067 "List all groups with cached articles.
4068 If the prefix LEVEL is non-nil, it should be a number that says which
4069 level to cut off listing groups.
4070 If LOWEST, don't list groups with level lower than LOWEST.
4072 This command may read the active file."
4075 (setq level (prefix-numeric-value level)))
4076 (when (or (not level) (>= level gnus-level-zombie))
4078 (funcall gnus-group-prepare-function
4079 (or level gnus-level-subscribed)
4081 (let ((marks (gnus-info-marks info)))
4082 (assq 'cache marks)))
4085 (or (gnus-gethash group
4086 gnus-cache-active-hashtb)
4087 ;; Cache active file might use "."
4090 (mapconcat 'identity
4091 (split-string group ":")
4093 gnus-cache-active-hashtb))))
4094 (goto-char (point-min))
4095 (gnus-group-position-point))
4097 (defun gnus-group-list-dormant (level &optional lowest)
4098 "List all groups with dormant articles.
4099 If the prefix LEVEL is non-nil, it should be a number that says which
4100 level to cut off listing groups.
4101 If LOWEST, don't list groups with level lower than LOWEST.
4103 This command may read the active file."
4106 (setq level (prefix-numeric-value level)))
4107 (when (or (not level) (>= level gnus-level-zombie))
4109 (funcall gnus-group-prepare-function
4110 (or level gnus-level-subscribed)
4112 (let ((marks (gnus-info-marks info)))
4113 (assq 'dormant marks)))
4116 (goto-char (point-min))
4117 (gnus-group-position-point))
4119 (defun gnus-group-listed-groups ()
4120 "Return a list of listed groups."
4122 (goto-char (point-min))
4123 (while (setq point (text-property-not-all (point) (point-max)
4126 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4130 (defun gnus-group-list-plus (&optional args)
4131 "List groups plus the current selection."
4133 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4134 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4136 (push last-command-event unread-command-events)
4137 (if (featurep 'xemacs)
4138 (push (make-event 'key-press '(key ?A)) unread-command-events)
4139 (push ?A unread-command-events))
4140 (let (gnus-pick-mode keys)
4141 (setq keys (if (featurep 'xemacs)
4142 (events-to-keys (read-key-sequence nil))
4143 (read-key-sequence nil)))
4144 (setq func (lookup-key (current-local-map) keys)))
4148 (call-interactively func))))
4150 (defun gnus-group-list-flush (&optional args)
4151 "Flush groups from the current selection."
4153 (let ((gnus-group-list-option 'flush))
4154 (gnus-group-list-plus args)))
4156 (defun gnus-group-list-limit (&optional args)
4157 "List groups limited within the current selection."
4159 (let ((gnus-group-list-option 'limit))
4160 (gnus-group-list-plus args)))
4162 (defun gnus-group-mark-article-read (group article)
4163 "Mark ARTICLE read."
4164 (let ((buffer (gnus-summary-buffer-name group))
4165 (mark gnus-read-mark)
4167 (if (get-buffer buffer)
4168 (with-current-buffer buffer
4169 (setq active gnus-newsgroup-active)
4170 (gnus-activate-group group)
4171 (when gnus-newsgroup-prepared
4172 (when (and gnus-newsgroup-auto-expire
4173 (memq mark gnus-auto-expirable-marks))
4174 (setq mark gnus-expirable-mark))
4175 (setq mark (gnus-request-update-mark
4176 group article mark))
4177 (gnus-mark-article-as-read article mark)
4178 (setq gnus-newsgroup-active (gnus-active group))
4180 (setq n (1+ (cdr active)))
4181 (while (<= n (cdr gnus-newsgroup-active))
4182 (unless (eq n article)
4183 (push n gnus-newsgroup-unselected))
4185 (setq gnus-newsgroup-unselected
4186 (nreverse gnus-newsgroup-unselected)))))
4187 (gnus-activate-group group)
4188 (gnus-group-make-articles-read group (list article))
4189 (when (gnus-group-auto-expirable-p group)
4190 (gnus-add-marked-articles
4191 group 'expire (list article))))))
4193 (provide 'gnus-group)
4195 ;;; gnus-group.el ends here