1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
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: %(%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 %O Moderated group (string, \"(m)\" or \"\")
170 %P Topic indentation (string)
171 %m Whether there is new(ish) mail in the group (char, \"%\")
172 %w Number of new(ish) mails in the group (integer)
173 %l Whether there are GroupLens predictions for this group (string)
174 %n Select from where (string)
175 %z A string that look like `<%s:%n>' if a foreign select method is used
176 %d The date the group was last entered.
177 %E Icon as defined by `gnus-group-icon-list'.
178 %u User defined specifier. The next character in the format string should
179 be a letter. Gnus will call the function gnus-user-format-function-X,
180 where X is the letter following %u. The function will be passed a
181 single dummy parameter as argument.. The function should return a
182 string, which will be inserted into the buffer just like information
183 from any other group specifier.
185 Note that this format specification is not always respected. For
186 reasons of efficiency, when listing killed groups, this specification
187 is ignored altogether. If the spec is changed considerably, your
188 output may end up looking strange when listing both alive and killed
191 If you use %o or %O, reading the active file will be slower and quite
192 a bit of extra memory will be used. %D will also worsen performance.
193 Also note that if you change the format specification to include any
194 of these specs, you must probably re-start Gnus to see them go into
197 General format specifiers can also be used.
198 See Info node `(gnus)Formatting Variables'."
199 :link '(custom-manual "(gnus)Formatting Variables")
200 :group 'gnus-group-visual
203 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
204 "*The format specification for the group mode line.
205 It works along the same lines as a normal formatting string,
206 with some simple extensions:
208 %S The native news server.
209 %M The native select method.
210 %: \":\" if %S isn't \"\"."
211 :group 'gnus-group-visual
214 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
215 (when (featurep 'xemacs)
216 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
219 (defcustom gnus-group-menu-hook nil
220 "Hook run after the creation of the group mode menu."
221 :group 'gnus-group-various
224 (defcustom gnus-group-catchup-group-hook nil
225 "Hook run when catching up a group from the group buffer."
226 :group 'gnus-group-various
227 :link '(custom-manual "(gnus)Group Data")
230 (defcustom gnus-group-update-group-hook nil
231 "Hook called when updating group lines."
232 :group 'gnus-group-visual
235 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
236 "*A function that is called to generate the group buffer.
237 The function is called with three arguments: The first is a number;
238 all group with a level less or equal to that number should be listed,
239 if the second is non-nil, empty groups should also be displayed. If
240 the third is non-nil, it is a number. No groups with a level lower
241 than this number should be displayed.
243 The only current function implemented is `gnus-group-prepare-flat'."
244 :group 'gnus-group-listing
247 (defcustom gnus-group-prepare-hook nil
248 "Hook called after the group buffer has been generated.
249 If you want to modify the group buffer, you can use this hook."
250 :group 'gnus-group-listing
253 (defcustom gnus-suspend-gnus-hook nil
254 "Hook called when suspending (not exiting) Gnus."
258 (defcustom gnus-exit-gnus-hook nil
259 "Hook called when exiting Gnus."
263 (defcustom gnus-after-exiting-gnus-hook nil
264 "Hook called after exiting Gnus."
268 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
269 "Hook called when a group line is changed.
270 The hook will not be called if `gnus-visual' is nil.
272 The default function `gnus-group-highlight-line' will
273 highlight the line according to the `gnus-group-highlight'
275 :group 'gnus-group-visual
278 (defcustom gnus-useful-groups
279 '(("(ding) mailing list mirrored at sunsite.auc.dk"
281 (nntp "sunsite.auc.dk"
282 (nntp-address "sunsite.auc.dk")))
285 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
289 (nndoc-article-type mbox)
290 (eval `(nndoc-address
291 ,(let ((file (nnheader-find-etc-directory
294 (error "Couldn't find doc group"))
296 "*Alist of useful group-server pairs."
297 :group 'gnus-group-listing
298 :type '(repeat (list (string :tag "Description")
300 (sexp :tag "Method"))))
302 (defcustom gnus-group-highlight
304 ((and mailp (= unread 0) (eq level 1)) .
305 gnus-group-mail-1-empty-face)
306 ((and mailp (eq level 1)) .
307 gnus-group-mail-1-face)
308 ((and mailp (= unread 0) (eq level 2)) .
309 gnus-group-mail-2-empty-face)
310 ((and mailp (eq level 2)) .
311 gnus-group-mail-2-face)
312 ((and mailp (= unread 0) (eq level 3)) .
313 gnus-group-mail-3-empty-face)
314 ((and mailp (eq level 3)) .
315 gnus-group-mail-3-face)
316 ((and mailp (= unread 0)) .
317 gnus-group-mail-low-empty-face)
319 gnus-group-mail-low-face)
321 ((and (= unread 0) (eq level 1)) .
322 gnus-group-news-1-empty-face)
323 ((and (eq level 1)) .
324 gnus-group-news-1-face)
325 ((and (= unread 0) (eq level 2)) .
326 gnus-group-news-2-empty-face)
327 ((and (eq level 2)) .
328 gnus-group-news-2-face)
329 ((and (= unread 0) (eq level 3)) .
330 gnus-group-news-3-empty-face)
331 ((and (eq level 3)) .
332 gnus-group-news-3-face)
333 ((and (= unread 0) (eq level 4)) .
334 gnus-group-news-4-empty-face)
335 ((and (eq level 4)) .
336 gnus-group-news-4-face)
337 ((and (= unread 0) (eq level 5)) .
338 gnus-group-news-5-empty-face)
339 ((and (eq level 5)) .
340 gnus-group-news-5-face)
341 ((and (= unread 0) (eq level 6)) .
342 gnus-group-news-6-empty-face)
343 ((and (eq level 6)) .
344 gnus-group-news-6-face)
345 ((and (= unread 0)) .
346 gnus-group-news-low-empty-face)
348 gnus-group-news-low-face))
349 "*Controls the highlighting of group buffer lines.
351 Below is a list of `Form'/`Face' pairs. When deciding how a a
352 particular group line should be displayed, each form is
353 evaluated. The content of the face field after the first true form is
354 used. You can change how those group lines are displayed by
355 editing the face field.
357 It is also possible to change and add form fields, but currently that
358 requires an understanding of Lisp expressions. Hopefully this will
359 change in a future release. For now, you can use the following
360 variables in the Lisp expression:
362 group: The name of the group.
363 unread: The number of unread articles in the group.
364 method: The select method used.
365 mailp: Whether it's a mail group or not.
366 level: The level of the group.
367 score: The score of the group.
368 ticked: The number of ticked articles."
369 :group 'gnus-group-visual
370 :type '(repeat (cons (sexp :tag "Form") face)))
372 (defcustom gnus-new-mail-mark ?%
373 "Mark used for groups with new mail."
374 :group 'gnus-group-visual
377 (defgroup gnus-group-icons nil
378 "Add Icons to your group buffer. "
379 :group 'gnus-group-visual)
381 (defcustom gnus-group-icon-list
383 "*Controls the insertion of icons into group buffer lines.
385 Below is a list of `Form'/`File' pairs. When deciding how a
386 particular group line should be displayed, each form is evaluated.
387 The icon from the file field after the first true form is used. You
388 can change how those group lines are displayed by editing the file
389 field. The File will either be found in the
390 `gnus-group-glyph-directory' or by designating absolute path to the
393 It is also possible to change and add form fields, but currently that
394 requires an understanding of Lisp expressions. Hopefully this will
395 change in a future release. For now, you can use the following
396 variables in the Lisp expression:
398 group: The name of the group.
399 unread: The number of unread articles in the group.
400 method: The select method used.
401 mailp: Whether it's a mail group or not.
402 newsp: Whether it's a news group or not
403 level: The level of the group.
404 score: The score of the group.
405 ticked: The number of ticked articles."
406 :group 'gnus-group-icons
407 :type '(repeat (cons (sexp :tag "Form") file)))
409 (defcustom gnus-group-name-charset-method-alist nil
410 "Alist of method and the charset for group names.
413 (((nntp \"news.com.cn\") . cn-gb-2312))"
416 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
418 (defcustom gnus-group-name-charset-group-alist
419 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
420 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
421 '(("[^\000-\177]" . utf-8))
423 "Alist of group regexp and the charset for group names.
426 ((\"\\.com\\.cn:\" . cn-gb-2312))"
428 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
430 (defcustom gnus-group-jump-to-group-prompt nil
431 "Default prompt for `gnus-group-jump-to-group'.
432 If non-nil, the value should be a string, e.g. \"nnml:\",
433 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
434 in the minibuffer prompt."
435 :group 'gnus-group-various
436 :type '(choice (string :tag "Prompt string")
437 (const :tag "Empty" nil)))
439 (defvar gnus-group-listing-limit 1000
440 "*A limit of the number of groups when listing.
441 If the number of groups is larger than the limit, list them in a
444 ;;; Internal variables
446 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
447 "Function for sorting the group buffer.")
449 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
450 "Function for sorting the selected groups in the group buffer.")
452 (defvar gnus-group-indentation-function nil)
453 (defvar gnus-goto-missing-group-function nil)
454 (defvar gnus-group-update-group-function nil)
455 (defvar gnus-group-goto-next-group-function nil
456 "Function to override finding the next group after listing groups.")
458 (defvar gnus-group-edit-buffer nil)
460 (defvar gnus-group-line-format-alist
461 `((?M gnus-tmp-marked-mark ?c)
462 (?S gnus-tmp-subscribed ?c)
463 (?L gnus-tmp-level ?d)
464 (?N (cond ((eq number t) "*" )
468 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
469 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
471 (?R gnus-tmp-number-of-read ?s)
472 (?t gnus-tmp-number-total ?d)
473 (?y gnus-tmp-number-of-unread ?s)
474 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
475 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
476 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
477 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
478 (?g gnus-tmp-group ?s)
479 (?G gnus-tmp-qualified-group ?s)
480 (?c (gnus-short-group-name gnus-tmp-group) ?s)
481 (?C gnus-tmp-comment ?s)
482 (?D gnus-tmp-newsgroup-description ?s)
483 (?o gnus-tmp-moderated ?c)
484 (?O gnus-tmp-moderated-string ?s)
485 (?p gnus-tmp-process-marked ?c)
486 (?s gnus-tmp-news-server ?s)
487 (?n gnus-tmp-news-method ?s)
488 (?P gnus-group-indentation ?s)
489 (?E gnus-tmp-group-icon ?s)
490 (?l gnus-tmp-grouplens ?s)
491 (?z gnus-tmp-news-method-string ?s)
492 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
493 (?w (if (gnus-news-group-p gnus-tmp-group)
497 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
500 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
501 (?u gnus-tmp-user-defined ?s)))
503 (defvar gnus-group-mode-line-format-alist
504 `((?S gnus-tmp-news-server ?s)
505 (?M gnus-tmp-news-method ?s)
506 (?u gnus-tmp-user-defined ?s)
507 (?: gnus-tmp-colon ?s)))
509 (defvar gnus-topic-topology nil
510 "The complete topic hierarchy.")
512 (defvar gnus-topic-alist nil
513 "The complete topic-group alist.")
515 (defvar gnus-group-marked nil)
517 (defvar gnus-group-list-mode nil)
520 (defvar gnus-group-icon-cache nil)
522 (defvar gnus-group-listed-groups nil)
523 (defvar gnus-group-list-option nil)
529 (put 'gnus-group-mode 'mode-class 'special)
532 (gnus-define-keys gnus-group-mode-map
533 " " gnus-group-read-group
534 "=" gnus-group-select-group
535 "\r" gnus-group-select-group
536 "\M-\r" gnus-group-quick-select-group
537 "\M- " gnus-group-visible-select-group
538 [(meta control return)] gnus-group-select-group-ephemerally
539 "j" gnus-group-jump-to-group
540 "n" gnus-group-next-unread-group
541 "p" gnus-group-prev-unread-group
542 "\177" gnus-group-prev-unread-group
543 [delete] gnus-group-prev-unread-group
544 [backspace] gnus-group-prev-unread-group
545 "N" gnus-group-next-group
546 "P" gnus-group-prev-group
547 "\M-n" gnus-group-next-unread-group-same-level
548 "\M-p" gnus-group-prev-unread-group-same-level
549 "," gnus-group-best-unread-group
550 "." gnus-group-first-unread-group
551 "u" gnus-group-unsubscribe-current-group
552 "U" gnus-group-unsubscribe-group
553 "c" gnus-group-catchup-current
554 "C" gnus-group-catchup-current-all
555 "\M-c" gnus-group-clear-data
556 "l" gnus-group-list-groups
557 "L" gnus-group-list-all-groups
560 "g" gnus-group-get-new-news
561 "\M-g" gnus-group-get-new-news-this-group
562 "R" gnus-group-restart
563 "r" gnus-group-read-init-file
564 "B" gnus-group-browse-foreign-server
565 "b" gnus-group-check-bogus-groups
566 "F" gnus-group-find-new-groups
567 "\C-c\C-d" gnus-group-describe-group
568 "\M-d" gnus-group-describe-all-groups
569 "\C-c\C-a" gnus-group-apropos
570 "\C-c\M-\C-a" gnus-group-description-apropos
571 "a" gnus-group-post-news
572 "\ek" gnus-group-edit-local-kill
573 "\eK" gnus-group-edit-global-kill
574 "\C-k" gnus-group-kill-group
575 "\C-y" gnus-group-yank-group
576 "\C-w" gnus-group-kill-region
577 "\C-x\C-t" gnus-group-transpose-groups
578 "\C-c\C-l" gnus-group-list-killed
579 "\C-c\C-x" gnus-group-expire-articles
580 "\C-c\M-\C-x" gnus-group-expire-all-groups
582 "s" gnus-group-save-newsrc
583 "z" gnus-group-suspend
586 "?" gnus-group-describe-briefly
587 "\C-c\C-i" gnus-info-find-node
588 "\M-e" gnus-group-edit-group-method
589 "^" gnus-group-enter-server-mode
590 gnus-mouse-2 gnus-mouse-pick-group
591 "<" beginning-of-buffer
594 "\C-c\C-n" gnus-namazu-search
595 "\C-c\C-s" gnus-group-sort-groups
597 "\C-c\M-g" gnus-activate-all-groups
598 "\M-&" gnus-group-universal-argument
599 "#" gnus-group-mark-group
600 "\M-#" gnus-group-unmark-group)
602 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
603 "m" gnus-group-mark-group
604 "u" gnus-group-unmark-group
605 "w" gnus-group-mark-region
606 "b" gnus-group-mark-buffer
607 "r" gnus-group-mark-regexp
608 "U" gnus-group-unmark-all-groups)
610 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
611 "u" gnus-sieve-update
612 "g" gnus-sieve-generate)
614 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
615 "d" gnus-group-make-directory-group
616 "h" gnus-group-make-help-group
617 "u" gnus-group-make-useful-group
618 "a" gnus-group-make-archive-group
619 "k" gnus-group-make-kiboze-group
620 "l" gnus-group-nnimap-edit-acl
621 "m" gnus-group-make-group
622 "n" gnus-group-make-shimbun-group
623 "E" gnus-group-edit-group
624 "e" gnus-group-edit-group-method
625 "p" gnus-group-edit-group-parameters
626 "v" gnus-group-add-to-virtual
627 "V" gnus-group-make-empty-virtual
628 "D" gnus-group-enter-directory
629 "f" gnus-group-make-doc-group
630 "G" gnus-group-make-nnir-group
631 "w" gnus-group-make-web-group
632 "r" gnus-group-rename-group
633 "c" gnus-group-customize
634 "x" gnus-group-nnimap-expunge
635 "\177" gnus-group-delete-group
636 [delete] gnus-group-delete-group)
638 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
639 "b" gnus-group-brew-soup
640 "w" gnus-soup-save-areas
641 "s" gnus-soup-send-replies
642 "p" gnus-soup-pack-packet
643 "r" nnsoup-pack-replies)
645 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
646 "s" gnus-group-sort-groups
647 "a" gnus-group-sort-groups-by-alphabet
648 "u" gnus-group-sort-groups-by-unread
649 "l" gnus-group-sort-groups-by-level
650 "v" gnus-group-sort-groups-by-score
651 "r" gnus-group-sort-groups-by-rank
652 "m" gnus-group-sort-groups-by-method
653 "n" gnus-group-sort-groups-by-real-name)
655 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
656 "s" gnus-group-sort-selected-groups
657 "a" gnus-group-sort-selected-groups-by-alphabet
658 "u" gnus-group-sort-selected-groups-by-unread
659 "l" gnus-group-sort-selected-groups-by-level
660 "v" gnus-group-sort-selected-groups-by-score
661 "r" gnus-group-sort-selected-groups-by-rank
662 "m" gnus-group-sort-selected-groups-by-method
663 "n" gnus-group-sort-selected-groups-by-real-name)
665 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
666 "k" gnus-group-list-killed
667 "z" gnus-group-list-zombies
668 "s" gnus-group-list-groups
669 "u" gnus-group-list-all-groups
670 "A" gnus-group-list-active
671 "a" gnus-group-apropos
672 "d" gnus-group-description-apropos
673 "m" gnus-group-list-matching
674 "M" gnus-group-list-all-matching
675 "l" gnus-group-list-level
676 "c" gnus-group-list-cached
677 "?" gnus-group-list-dormant)
679 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
680 "k" gnus-group-list-limit
681 "z" gnus-group-list-limit
682 "s" gnus-group-list-limit
683 "u" gnus-group-list-limit
684 "A" gnus-group-list-limit
685 "m" gnus-group-list-limit
686 "M" gnus-group-list-limit
687 "l" gnus-group-list-limit
688 "c" gnus-group-list-limit
689 "?" gnus-group-list-limit)
691 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
692 "k" gnus-group-list-flush
693 "z" gnus-group-list-flush
694 "s" gnus-group-list-flush
695 "u" gnus-group-list-flush
696 "A" gnus-group-list-flush
697 "m" gnus-group-list-flush
698 "M" gnus-group-list-flush
699 "l" gnus-group-list-flush
700 "c" gnus-group-list-flush
701 "?" gnus-group-list-flush)
703 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
704 "k" gnus-group-list-plus
705 "z" gnus-group-list-plus
706 "s" gnus-group-list-plus
707 "u" gnus-group-list-plus
708 "A" gnus-group-list-plus
709 "m" gnus-group-list-plus
710 "M" gnus-group-list-plus
711 "l" gnus-group-list-plus
712 "c" gnus-group-list-plus
713 "?" gnus-group-list-plus)
715 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
716 "f" gnus-score-flush-cache)
718 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
719 "c" gnus-group-fetch-charter
720 "C" gnus-group-fetch-control
721 "d" gnus-group-describe-group
722 "f" gnus-group-fetch-faq
725 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
726 "l" gnus-group-set-current-level
727 "t" gnus-group-unsubscribe-current-group
728 "s" gnus-group-unsubscribe-group
729 "k" gnus-group-kill-group
730 "y" gnus-group-yank-group
731 "w" gnus-group-kill-region
732 "\C-k" gnus-group-kill-level
733 "z" gnus-group-kill-all-zombies))
735 (defun gnus-group-make-menu-bar ()
736 (gnus-turn-off-edit-menu 'group)
737 (unless (boundp 'gnus-group-reading-menu)
740 gnus-group-reading-menu gnus-group-mode-map ""
742 ["Read" gnus-group-read-group (gnus-group-group-name)]
743 ["Select" gnus-group-select-group (gnus-group-group-name)]
744 ["See old articles" (gnus-group-select-group 'all)
745 :keys "C-u SPC" :active (gnus-group-group-name)]
746 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
747 ,@(if (featurep 'xemacs) nil
748 '(:help "Mark unread articles in the current group as read"))]
749 ["Catch up all articles" gnus-group-catchup-current-all
750 (gnus-group-group-name)]
751 ["Check for new articles" gnus-group-get-new-news-this-group
752 :active (gnus-group-group-name)
753 ,@(if (featurep 'xemacs) nil
754 '(:help "Check for new messages in current group"))]
755 ["Toggle subscription" gnus-group-unsubscribe-current-group
756 (gnus-group-group-name)]
757 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
758 ,@(if (featurep 'xemacs) nil
759 '(:help "Kill (remove) current group"))]
760 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
761 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
762 ,@(if (featurep 'xemacs) nil
763 '(:help "Display description of the current group"))]
764 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
765 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
766 ,@(if (featurep 'xemacs) nil
767 '(:help "Display the charter of the current group"))]
768 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
769 ,@(if (featurep 'xemacs) nil
770 '(:help "Display the archived control message for the current group"))]
771 ;; Actually one should check, if any of the marked groups gives t for
772 ;; (gnus-check-backend-function 'request-expire-articles ...)
773 ["Expire articles" gnus-group-expire-articles
774 (or (and (gnus-group-group-name)
775 (gnus-check-backend-function
776 'request-expire-articles
777 (gnus-group-group-name))) gnus-group-marked)]
778 ["Set group level..." gnus-group-set-current-level
779 (gnus-group-group-name)]
780 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
781 ["Customize" gnus-group-customize (gnus-group-group-name)]
783 ["Parameters" gnus-group-edit-group-parameters
784 (gnus-group-group-name)]
785 ["Select method" gnus-group-edit-group-method
786 (gnus-group-group-name)]
787 ["Info" gnus-group-edit-group (gnus-group-group-name)]
788 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
789 ["Global kill file" gnus-group-edit-global-kill t])))
792 gnus-group-group-menu gnus-group-mode-map ""
795 ["List unread subscribed groups" gnus-group-list-groups t]
796 ["List (un)subscribed groups" gnus-group-list-all-groups t]
797 ["List killed groups" gnus-group-list-killed gnus-killed-list]
798 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
799 ["List level..." gnus-group-list-level t]
800 ["Describe all groups" gnus-group-describe-all-groups t]
801 ["Group apropos..." gnus-group-apropos t]
802 ["Group and description apropos..." gnus-group-description-apropos t]
803 ["List groups matching..." gnus-group-list-matching t]
804 ["List all groups matching..." gnus-group-list-all-matching t]
805 ["List active file" gnus-group-list-active t]
806 ["List groups with cached" gnus-group-list-cached t]
807 ["List groups with dormant" gnus-group-list-dormant t])
809 ["Default sort" gnus-group-sort-groups t]
810 ["Sort by method" gnus-group-sort-groups-by-method t]
811 ["Sort by rank" gnus-group-sort-groups-by-rank t]
812 ["Sort by score" gnus-group-sort-groups-by-score t]
813 ["Sort by level" gnus-group-sort-groups-by-level t]
814 ["Sort by unread" gnus-group-sort-groups-by-unread t]
815 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
816 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
817 ("Sort process/prefixed"
818 ["Default sort" gnus-group-sort-selected-groups
819 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
820 ["Sort by method" gnus-group-sort-selected-groups-by-method
821 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
822 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
823 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
824 ["Sort by score" gnus-group-sort-selected-groups-by-score
825 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
826 ["Sort by level" gnus-group-sort-selected-groups-by-level
827 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
828 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
829 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
830 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
831 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
832 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
833 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
835 ["Mark group" gnus-group-mark-group
836 (and (gnus-group-group-name)
837 (not (memq (gnus-group-group-name) gnus-group-marked)))]
838 ["Unmark group" gnus-group-unmark-group
839 (and (gnus-group-group-name)
840 (memq (gnus-group-group-name) gnus-group-marked))]
841 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
842 ["Mark regexp..." gnus-group-mark-regexp t]
843 ["Mark region" gnus-group-mark-region t]
844 ["Mark buffer" gnus-group-mark-buffer t]
845 ["Execute command" gnus-group-universal-argument
846 (or gnus-group-marked (gnus-group-group-name))])
848 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
849 ["Kill all newsgroups in region" gnus-group-kill-region t]
850 ["Kill all zombie groups" gnus-group-kill-all-zombies
852 ["Kill all groups on level..." gnus-group-kill-level t])
854 ["Make a foreign group..." gnus-group-make-group t]
855 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
856 ["Add a directory group..." gnus-group-make-directory-group t]
857 ["Add the help group" gnus-group-make-help-group t]
858 ["Add the archive group" gnus-group-make-archive-group t]
859 ["Make a doc group..." gnus-group-make-doc-group t]
860 ["Make a web group..." gnus-group-make-web-group t]
861 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
862 ["Make a virtual group..." gnus-group-make-empty-virtual t]
863 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
864 ["Rename group..." gnus-group-rename-group
865 (gnus-check-backend-function
866 'request-rename-group (gnus-group-group-name))]
867 ["Delete group" gnus-group-delete-group
868 (gnus-check-backend-function
869 'request-delete-group (gnus-group-group-name))])
871 ["Next" gnus-group-next-group t]
872 ["Previous" gnus-group-prev-group t]
873 ["Next unread" gnus-group-next-unread-group t]
874 ["Previous unread" gnus-group-prev-unread-group t]
875 ["Next unread same level" gnus-group-next-unread-group-same-level t]
876 ["Previous unread same level"
877 gnus-group-prev-unread-group-same-level t]
878 ["Jump to group..." gnus-group-jump-to-group t]
879 ["First unread group" gnus-group-first-unread-group t]
880 ["Best unread group" gnus-group-best-unread-group t])
882 ["Generate" gnus-sieve-generate t]
883 ["Generate and update" gnus-sieve-update t])
884 ["Delete bogus groups" gnus-group-check-bogus-groups t]
885 ["Find new newsgroups" gnus-group-find-new-groups t]
886 ["Transpose" gnus-group-transpose-groups
887 (gnus-group-group-name)]
888 ["Read a directory as a group..." gnus-group-enter-directory t]))
891 gnus-group-misc-menu gnus-group-mode-map ""
894 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
895 ["Send replies" gnus-soup-send-replies
896 (fboundp 'gnus-soup-pack-packet)]
897 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
898 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
899 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
900 ["Send a mail" gnus-group-mail t]
901 ["Send a message (mail or news)" gnus-group-post-news t]
902 ["Create a local message" gnus-group-news t]
903 ["Check for new news" gnus-group-get-new-news
904 ,@(if (featurep 'xemacs) '(t)
905 '(:help "Get newly arrived articles"))
907 ["Send queued messages" gnus-delay-send-queue
908 ,@(if (featurep 'xemacs) '(t)
909 '(:help "Send all messages that are scheduled to be sent now"))
911 ["Activate all groups" gnus-activate-all-groups t]
912 ["Restart Gnus" gnus-group-restart t]
913 ["Read init file" gnus-group-read-init-file t]
914 ["Browse foreign server..." gnus-group-browse-foreign-server t]
915 ["Enter server buffer" gnus-group-enter-server-mode t]
916 ["Expire all expirable articles" gnus-group-expire-all-groups t]
917 ["Generate any kiboze groups" nnkiboze-generate-groups t]
918 ["Gnus version" gnus-version t]
919 ["Save .newsrc files" gnus-group-save-newsrc t]
920 ["Suspend Gnus" gnus-group-suspend t]
921 ["Clear dribble buffer" gnus-group-clear-dribble t]
922 ["Read manual" gnus-info-find-node t]
923 ["Flush score cache" gnus-score-flush-cache t]
924 ["Toggle topics" gnus-topic-mode t]
925 ["Send a bug report" gnus-bug t]
926 ["Exit from Gnus" gnus-group-exit
927 ,@(if (featurep 'xemacs) '(t)
928 '(:help "Quit reading news"))]
929 ["Exit without saving" gnus-group-quit t]))
931 (gnus-run-hooks 'gnus-group-menu-hook)))
933 (defvar gnus-group-toolbar-map nil)
935 ;; Emacs 21 tool bar. Should be no-op otherwise.
936 (defun gnus-group-make-tool-bar ()
938 (condition-case nil (require 'tool-bar) (error nil))
939 (fboundp 'tool-bar-add-item-from-menu)
940 (default-value 'tool-bar-mode)
941 (not gnus-group-toolbar-map))
942 (setq gnus-group-toolbar-map
943 (let ((tool-bar-map (make-sparse-keymap))
944 (load-path (mm-image-load-path)))
945 (tool-bar-add-item-from-menu
946 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
947 (tool-bar-add-item-from-menu
948 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
949 (tool-bar-add-item-from-menu
950 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
951 (tool-bar-add-item-from-menu
952 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
953 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
954 :help "Subscribe to the current group")
955 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
957 :help "Unsubscribe from the current group")
958 (tool-bar-add-item-from-menu
959 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
961 (if gnus-group-toolbar-map
962 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
964 (defun gnus-group-mode ()
965 "Major mode for reading news.
967 All normal editing commands are switched off.
968 \\<gnus-group-mode-map>
969 The group buffer lists (some of) the groups available. For instance,
970 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
971 lists all zombie groups.
973 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
974 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
976 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
978 The following commands are available:
980 \\{gnus-group-mode-map}"
982 (kill-all-local-variables)
983 (when (gnus-visual-p 'group-menu 'menu)
984 (gnus-group-make-menu-bar)
985 (gnus-group-make-tool-bar))
986 (gnus-simplify-mode-line)
987 (setq major-mode 'gnus-group-mode)
988 (setq mode-name "Group")
989 (gnus-group-set-mode-line)
990 (setq mode-line-process nil)
991 (use-local-map gnus-group-mode-map)
992 (buffer-disable-undo)
993 (setq truncate-lines t)
994 (setq buffer-read-only t)
995 (gnus-set-default-directory)
996 (gnus-update-format-specifications nil 'group 'group-mode)
997 (gnus-update-group-mark-positions)
1002 (gnus-run-hooks 'gnus-group-mode-hook))
1004 (defun gnus-update-group-mark-positions ()
1006 (let ((gnus-process-mark ?\200)
1007 (gnus-group-update-hook nil)
1008 (gnus-group-marked '("dummy.group"))
1009 (gnus-active-hashtb (make-vector 10 0))
1011 (gnus-set-active "dummy.group" '(0 . 0))
1012 (gnus-set-work-buffer)
1013 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1014 (goto-char (point-min))
1015 (setq gnus-group-mark-positions
1016 (list (cons 'process (and (search-forward "\200" nil t)
1017 (- (point) 2))))))))
1019 (defun gnus-mouse-pick-group (e)
1020 "Enter the group under the mouse pointer."
1023 (gnus-group-read-group nil))
1025 ;; Look at LEVEL and find out what the level is really supposed to be.
1026 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1027 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1028 (defun gnus-group-default-level (&optional level number-or-nil)
1030 (gnus-group-use-permanent-levels
1031 (or (setq gnus-group-use-permanent-levels
1032 (or level (if (numberp gnus-group-use-permanent-levels)
1033 gnus-group-use-permanent-levels
1034 (or gnus-group-default-list-level
1035 gnus-level-subscribed))))
1036 gnus-group-default-list-level gnus-level-subscribed))
1040 (or level gnus-group-default-list-level gnus-level-subscribed))))
1042 (defun gnus-group-setup-buffer ()
1043 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1044 (unless (eq major-mode 'gnus-group-mode)
1047 (gnus-carpal-setup-buffer 'group))))
1049 (defun gnus-group-name-charset (method group)
1051 (setq method (gnus-find-method-for-group group)))
1052 (let ((item (assoc method gnus-group-name-charset-method-alist))
1053 (alist gnus-group-name-charset-group-alist)
1057 (while (setq item (pop alist))
1058 (if (string-match (car item) group)
1060 result (cdr item))))
1063 (defun gnus-group-name-decode (string charset)
1064 (if (and string charset (featurep 'mule))
1065 (decode-coding-string string charset)
1068 (defun gnus-group-decoded-name (string)
1069 (let ((charset (gnus-group-name-charset nil string)))
1070 (gnus-group-name-decode string charset)))
1072 (defun gnus-group-name-encode (string charset)
1073 (if (and string charset (featurep 'mule))
1074 (encode-coding-string string charset)
1077 (defun gnus-group-encoded-name (string)
1078 (let ((charset (gnus-group-name-charset nil string)))
1079 (gnus-group-name-encode string charset)))
1081 (defun gnus-group-completing-read-group-name
1082 (prompt table &optional predicate require-match initial-contents history)
1086 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1090 (dolist (entry (prog1
1093 (push (list (gnus-group-decoded-name (car entry))) table)))
1094 (gnus-group-encoded-name
1096 prompt table predicate
1101 (defun gnus-group-list-groups (&optional level unread lowest)
1102 "List newsgroups with level LEVEL or lower that have unread articles.
1103 Default is all subscribed groups.
1104 If argument UNREAD is non-nil, groups with no unread articles are also
1107 Also see the `gnus-group-use-permanent-levels' variable."
1109 (list (if current-prefix-arg
1110 (prefix-numeric-value current-prefix-arg)
1112 (gnus-group-default-level nil t)
1113 gnus-group-default-list-level
1114 gnus-level-subscribed))))
1116 (setq level (car gnus-group-list-mode)
1117 unread (cdr gnus-group-list-mode)))
1118 (setq level (gnus-group-default-level level))
1119 (gnus-group-setup-buffer)
1120 (gnus-update-format-specifications nil 'group 'group-mode)
1121 (let ((case-fold-search nil)
1122 (props (text-properties-at (gnus-point-at-bol)))
1123 (empty (= (point-min) (point-max)))
1124 (group (gnus-group-group-name))
1126 (set-buffer gnus-group-buffer)
1127 (setq number (funcall gnus-group-prepare-function level unread lowest))
1128 (when (or (and (numberp number)
1130 (zerop (buffer-size)))
1131 ;; No groups in the buffer.
1132 (gnus-message 5 gnus-no-groups-message))
1133 ;; We have some groups displayed.
1134 (goto-char (point-max))
1135 (when (or (not gnus-group-goto-next-group-function)
1136 (not (funcall gnus-group-goto-next-group-function
1140 (goto-char (point-min)))
1142 ;; Go to the first group with unread articles.
1143 (gnus-group-search-forward t))
1145 ;; Find the right group to put point on. If the current group
1146 ;; has disappeared in the new listing, try to find the next
1147 ;; one. If no next one can be found, just leave point at the
1148 ;; first newsgroup in the buffer.
1149 (when (not (gnus-goto-char
1151 (point-min) (point-max)
1152 'gnus-group (gnus-intern-safe
1153 group gnus-active-hashtb))))
1154 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1156 (not (gnus-goto-char
1158 (point-min) (point-max) 'gnus-group
1160 (caar newsrc) gnus-active-hashtb)))))
1161 (setq newsrc (cdr newsrc)))
1163 (goto-char (point-max))
1164 (forward-line -1)))))))
1165 ;; Adjust cursor point.
1166 (gnus-group-position-point)))
1168 (defun gnus-group-list-level (level &optional all)
1169 "List groups on LEVEL.
1170 If ALL (the prefix), also list groups that have no unread articles."
1171 (interactive "nList groups on level: \nP")
1172 (gnus-group-list-groups level all level))
1174 (defun gnus-group-prepare-logic (group test)
1175 (or (and gnus-group-listed-groups
1176 (null gnus-group-list-option)
1177 (member group gnus-group-listed-groups))
1179 ((null gnus-group-listed-groups) test)
1180 ((null gnus-group-list-option) test)
1181 (t (and (member group gnus-group-listed-groups)
1182 (if (eq gnus-group-list-option 'flush)
1186 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1187 "List all newsgroups with unread articles of level LEVEL or lower.
1188 If PREDICATE is a function, list groups that the function returns non-nil;
1189 if it is t, list groups that have no unread articles.
1190 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1191 If REGEXP is a function, list dead groups that the function returns non-nil;
1192 if it is a string, only list groups matching REGEXP."
1193 (set-buffer gnus-group-buffer)
1194 (let ((buffer-read-only nil)
1195 (newsrc (cdr gnus-newsrc-alist))
1196 (lowest (or lowest 1))
1197 (not-in-list (and gnus-group-listed-groups
1198 (copy-sequence gnus-group-listed-groups)))
1199 info clevel unread group params)
1201 (when (or (< lowest gnus-level-zombie)
1202 gnus-group-listed-groups)
1203 ;; List living groups.
1205 (setq info (car newsrc)
1206 group (gnus-info-group info)
1207 params (gnus-info-params info)
1209 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1211 (setq not-in-list (delete group not-in-list)))
1213 (gnus-group-prepare-logic
1215 (and unread ; This group might be unchecked
1216 (or (not (stringp regexp))
1217 (string-match regexp group))
1218 (<= (setq clevel (gnus-info-level info)) level)
1221 ((functionp predicate)
1222 (funcall predicate info))
1223 (predicate t) ; We list all groups?
1226 (if (eq unread t) ; Unactivated?
1227 gnus-group-list-inactive-groups
1228 ; We list unactivated
1230 ; We list groups with unread articles
1231 (and gnus-list-groups-with-ticked-articles
1232 (cdr (assq 'tick (gnus-info-marks info))))
1233 ; And groups with tickeds
1234 ;; Check for permanent visibility.
1235 (and gnus-permanently-visible-groups
1236 (string-match gnus-permanently-visible-groups group))
1237 (memq 'visible params)
1238 (cdr (assq 'visible params)))))))
1239 (gnus-group-insert-group-line
1240 group (gnus-info-level info)
1241 (gnus-info-marks info) unread (gnus-info-method info)))))
1243 ;; List dead groups.
1244 (if (or gnus-group-listed-groups
1245 (and (>= level gnus-level-zombie)
1246 (<= lowest gnus-level-zombie)))
1247 (gnus-group-prepare-flat-list-dead
1248 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1249 gnus-level-zombie ?Z
1252 (dolist (group gnus-zombie-list)
1253 (setq not-in-list (delete group not-in-list))))
1254 (if (or gnus-group-listed-groups
1255 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1256 (gnus-group-prepare-flat-list-dead
1259 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1260 gnus-level-killed ?K regexp))
1262 (gnus-group-set-mode-line)
1263 (setq gnus-group-list-mode (cons level predicate))
1264 (gnus-run-hooks 'gnus-group-prepare-hook)
1267 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1268 ;; List zombies and killed lists somewhat faster, which was
1269 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1270 ;; this by ignoring the group format specification altogether.
1272 (if (> (length groups) gnus-group-listing-limit)
1274 (setq group (pop groups))
1275 (when (gnus-group-prepare-logic
1278 (and (stringp regexp) (string-match regexp group))
1279 (and (functionp regexp) (funcall regexp group))))
1280 (gnus-add-text-properties
1281 (point) (prog1 (1+ (point))
1282 (insert " " mark " *: "
1283 (gnus-group-decoded-name group)
1285 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1287 'gnus-level level))))
1289 (setq group (pop groups))
1290 (when (gnus-group-prepare-logic
1293 (and (stringp regexp) (string-match regexp group))
1294 (and (functionp regexp) (funcall regexp group))))
1295 (gnus-group-insert-group-line
1297 (let ((active (gnus-active group)))
1299 (if (zerop (cdr active))
1301 (- (1+ (cdr active)) (car active)))
1303 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1305 (defun gnus-group-update-group-line ()
1306 "Update the current line in the group buffer."
1307 (let* ((buffer-read-only nil)
1308 (group (gnus-group-group-name))
1309 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1310 gnus-group-indentation)
1313 (not (gnus-ephemeral-group-p group))
1315 (concat "(gnus-group-set-info '"
1316 (gnus-prin1-to-string (nth 2 entry))
1318 (setq gnus-group-indentation (gnus-group-group-indentation))
1320 (gnus-group-insert-group-line-info group)
1322 (gnus-group-position-point))))
1324 (defun gnus-group-insert-group-line-info (group)
1325 "Insert GROUP on the current line."
1326 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1327 (gnus-group-indentation (gnus-group-group-indentation))
1331 ;; (Un)subscribed group.
1332 (setq info (nth 2 entry))
1333 (gnus-group-insert-group-line
1334 group (gnus-info-level info) (gnus-info-marks info)
1335 (or (car entry) t) (gnus-info-method info)))
1336 ;; This group is dead.
1337 (gnus-group-insert-group-line
1339 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1341 (if (setq active (gnus-active group))
1342 (if (zerop (cdr active))
1344 (- (1+ (cdr active)) (car active)))
1346 (gnus-method-simplify (gnus-find-method-for-group group))))))
1348 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1349 gnus-tmp-marked number
1351 "Insert a group line in the group buffer."
1352 (let* ((gnus-tmp-method
1353 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1354 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1356 (gnus-tmp-active (gnus-active gnus-tmp-group))
1357 (gnus-tmp-number-total
1359 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1361 (gnus-tmp-number-of-unread
1362 (if (numberp number) (int-to-string (max 0 number))
1364 (gnus-tmp-number-of-read
1365 (if (numberp number)
1366 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1368 (gnus-tmp-subscribed
1369 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1370 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1371 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1373 (gnus-tmp-qualified-group
1374 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1375 group-name-charset))
1377 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1379 (gnus-tmp-newsgroup-description
1380 (if gnus-description-hashtb
1381 (or (gnus-group-name-decode
1382 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1383 group-name-charset) "")
1386 (if (and gnus-moderated-hashtb
1387 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1389 (gnus-tmp-moderated-string
1390 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1391 (gnus-tmp-group-icon "==&&==")
1392 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1393 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1394 (gnus-tmp-news-method-string
1396 (format "(%s:%s)" (car gnus-tmp-method)
1397 (cadr gnus-tmp-method)) ""))
1398 (gnus-tmp-marked-mark
1399 (if (and (numberp number)
1401 (cdr (assq 'tick gnus-tmp-marked)))
1403 (gnus-tmp-process-marked
1404 (if (member gnus-tmp-group gnus-group-marked)
1405 gnus-process-mark ? ))
1407 (or (and gnus-use-grouplens
1408 (bbb-grouplens-group-p gnus-tmp-group))
1410 (buffer-read-only nil)
1411 header gnus-tmp-header) ; passed as parameter to user-funcs.
1413 (gnus-add-text-properties
1417 (let ((gnus-tmp-group (gnus-group-name-decode
1418 gnus-tmp-group group-name-charset)))
1419 (eval gnus-group-line-format-spec)))
1420 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1421 gnus-unread ,(if (numberp number)
1422 (string-to-int gnus-tmp-number-of-unread)
1424 gnus-marked ,gnus-tmp-marked-mark
1425 gnus-indentation ,gnus-group-indentation
1426 gnus-level ,gnus-tmp-level))
1428 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1429 (gnus-run-hooks 'gnus-group-update-hook))
1431 ;; Allow XEmacs to remove front-sticky text properties.
1432 (gnus-group-remove-excess-properties)))
1434 (defun gnus-group-highlight-line ()
1435 "Highlight the current line according to `gnus-group-highlight'."
1436 (let* ((list gnus-group-highlight)
1438 (end (progn (end-of-line) (point)))
1439 ;; now find out where the line starts and leave point there.
1440 (beg (progn (beginning-of-line) (point)))
1441 (group (gnus-group-group-name))
1442 (entry (gnus-group-entry group))
1443 (unread (if (numberp (car entry)) (car entry) 0))
1444 (active (gnus-active group))
1445 (total (if active (1+ (- (cdr active) (car active))) 0))
1446 (info (nth 2 entry))
1447 (method (gnus-server-get-method group (gnus-info-method info)))
1448 (marked (gnus-info-marks info))
1449 (mailp (apply 'append
1452 (memq x (assoc (symbol-name
1453 (car (or method gnus-select-method)))
1454 gnus-valid-select-methods)))
1455 '(mail post-mail))))
1456 (level (or (gnus-info-level info) gnus-level-killed))
1457 (score (or (gnus-info-score info) 0))
1458 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1459 (group-age (gnus-group-timestamp-delta group))
1460 (inhibit-read-only t))
1461 ;; Eval the cars of the lists until we find a match.
1463 (not (eval (caar list))))
1464 (setq list (cdr list)))
1465 (let ((face (cdar list)))
1466 (unless (eq face (get-text-property beg 'face))
1467 (gnus-put-text-property-excluding-characters-with-faces
1469 (setq face (if (boundp face) (symbol-value face) face)))
1470 (gnus-extent-start-open beg)))
1473 (defun gnus-group-update-group (group &optional visible-only)
1474 "Update all lines where GROUP appear.
1475 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1477 ;; Can't use `save-excursion' here, so we do it manually.
1478 (let ((buf (current-buffer))
1480 (set-buffer gnus-group-buffer)
1481 (setq mark (point-marker))
1482 ;; The buffer may be narrowed.
1485 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1487 found buffer-read-only)
1488 ;; Enter the current status into the dribble buffer.
1489 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1491 (not (gnus-ephemeral-group-p group)))
1493 (concat "(gnus-group-set-info '"
1494 (gnus-prin1-to-string (nth 2 entry))
1496 ;; Find all group instances. If topics are in use, each group
1497 ;; may be listed in more than once.
1498 (while (setq loc (text-property-any
1499 loc (point-max) 'gnus-group ident))
1502 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1504 (gnus-group-insert-group-line-info group)
1507 (gnus-run-hooks 'gnus-group-update-group-hook)))
1508 (setq loc (1+ loc)))
1509 (unless (or found visible-only)
1510 ;; No such line in the buffer, find out where it's supposed to
1511 ;; go, and insert it there (or at the end of the buffer).
1512 (if gnus-goto-missing-group-function
1513 (funcall gnus-goto-missing-group-function group)
1514 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1515 (while (and entry (car entry)
1519 (point-min) (point-max)
1520 'gnus-group (gnus-intern-safe
1521 (caar entry) gnus-active-hashtb)))))
1522 (setq entry (cdr entry)))
1523 (or entry (goto-char (point-max)))))
1524 ;; Finally insert the line.
1525 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1526 (gnus-group-insert-group-line-info group)
1529 (gnus-run-hooks 'gnus-group-update-group-hook))))
1530 (when gnus-group-update-group-function
1531 (funcall gnus-group-update-group-function group))
1532 (gnus-group-set-mode-line)))
1534 (set-marker mark nil)
1537 (defun gnus-group-set-mode-line ()
1538 "Update the mode line in the group buffer."
1539 (when (memq 'group gnus-updated-mode-lines)
1540 ;; Yes, we want to keep this mode line updated.
1542 (set-buffer gnus-group-buffer)
1543 (let* ((gformat (or gnus-group-mode-line-format-spec
1544 (gnus-set-format 'group-mode)))
1545 (gnus-tmp-news-server (cadr gnus-select-method))
1546 (gnus-tmp-news-method (car gnus-select-method))
1547 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1549 gnus-tmp-header ;Dummy binding for user-defined formats
1550 ;; Get the resulting string.
1552 (and gnus-dribble-buffer
1553 (buffer-name gnus-dribble-buffer)
1554 (buffer-modified-p gnus-dribble-buffer)
1556 (set-buffer gnus-dribble-buffer)
1557 (not (zerop (buffer-size))))))
1558 (mode-string (eval gformat)))
1559 ;; Say whether the dribble buffer has been modified.
1560 (setq mode-line-modified
1561 (if modified (car gnus-mode-line-modified)
1562 (cdr gnus-mode-line-modified)))
1563 ;; If the line is too long, we chop it off.
1564 (when (> (length mode-string) max-len)
1565 (setq mode-string (substring mode-string 0 (- max-len 4))))
1567 (setq mode-line-buffer-identification
1568 (gnus-mode-line-buffer-identification
1569 (list mode-string)))
1570 (set-buffer-modified-p modified))))))
1572 (defun gnus-group-group-name ()
1573 "Get the name of the newsgroup on the current line."
1574 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1576 (symbol-name group))))
1578 (defun gnus-group-group-level ()
1579 "Get the level of the newsgroup on the current line."
1580 (get-text-property (gnus-point-at-bol) 'gnus-level))
1582 (defun gnus-group-group-indentation ()
1583 "Get the indentation of the newsgroup on the current line."
1584 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1585 (and gnus-group-indentation-function
1586 (funcall gnus-group-indentation-function))
1589 (defun gnus-group-group-unread ()
1590 "Get the number of unread articles of the newsgroup on the current line."
1591 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1593 (defun gnus-group-new-mail (group)
1594 (if (nnmail-new-mail-p (gnus-group-real-name group))
1598 (defun gnus-group-level (group)
1599 "Return the estimated level of GROUP."
1600 (or (gnus-info-level (gnus-get-info group))
1601 (and (member group gnus-zombie-list) gnus-level-zombie)
1604 (defun gnus-group-search-forward (&optional backward all level first-too)
1605 "Find the next newsgroup with unread articles.
1606 If BACKWARD is non-nil, find the previous newsgroup instead.
1607 If ALL is non-nil, just find any newsgroup.
1608 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1610 If FIRST-TOO, the current line is also eligible as a target."
1611 (let ((way (if backward -1 1))
1612 (low gnus-level-killed)
1615 (if (and backward (progn (beginning-of-line)) (bobp))
1624 (get-text-property (point) 'gnus-group)
1628 (get-text-property (point) 'gnus-unread)))
1629 (and (numberp unread) (> unread 0)))
1630 (setq lev (get-text-property (point)
1632 (<= lev gnus-level-subscribed)))
1634 (and (setq lev (get-text-property (point)
1643 (zerop (forward-line way)))))
1645 (progn (gnus-group-position-point) t)
1646 (goto-char (or pos beg))
1649 ;;; Gnus group mode commands
1653 (defun gnus-group-mark-line-p ()
1656 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1657 (eq (char-after) gnus-process-mark)))
1659 (defun gnus-group-mark-group (n &optional unmark no-advance)
1660 "Mark the current group."
1662 (let ((buffer-read-only nil)
1666 (when (setq group (gnus-group-group-name))
1667 ;; Go to the mark position.
1669 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1670 (subst-char-in-region
1671 (point) (1+ (point)) (char-after)
1674 (setq gnus-group-marked (delete group gnus-group-marked))
1676 (setq gnus-group-marked
1677 (cons group (delete group gnus-group-marked)))
1678 gnus-process-mark)))
1680 (gnus-group-next-group 1))
1682 (gnus-summary-position-point)
1685 (defun gnus-group-unmark-group (n)
1686 "Remove the mark from the current group."
1688 (gnus-group-mark-group n 'unmark)
1689 (gnus-group-position-point))
1691 (defun gnus-group-unmark-all-groups ()
1692 "Unmark all groups."
1694 (let ((groups gnus-group-marked))
1697 (gnus-group-remove-mark (pop groups)))))
1698 (gnus-group-position-point))
1700 (defun gnus-group-mark-region (unmark beg end)
1701 "Mark all groups between point and mark.
1702 If UNMARK, remove the mark instead."
1703 (interactive "P\nr")
1704 (let ((num (count-lines beg end)))
1707 (- num (gnus-group-mark-group num unmark)))))
1709 (defun gnus-group-mark-buffer (&optional unmark)
1710 "Mark all groups in the buffer.
1711 If UNMARK, remove the mark instead."
1713 (gnus-group-mark-region unmark (point-min) (point-max)))
1715 (defun gnus-group-mark-regexp (regexp)
1716 "Mark all groups that match some regexp."
1717 (interactive "sMark (regexp): ")
1718 (let ((alist (cdr gnus-newsrc-alist))
1721 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1722 (gnus-group-set-mark group))))
1723 (gnus-group-position-point))
1725 (defun gnus-group-remove-mark (group &optional test-marked)
1726 "Remove the process mark from GROUP and move point there.
1727 Return nil if the group isn't displayed."
1728 (if (gnus-group-goto-group group nil test-marked)
1730 (gnus-group-mark-group 1 'unmark t)
1732 (setq gnus-group-marked
1733 (delete group gnus-group-marked))
1736 (defun gnus-group-set-mark (group)
1737 "Set the process mark on GROUP."
1738 (if (gnus-group-goto-group group)
1740 (gnus-group-mark-group 1 nil t))
1741 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1743 (defun gnus-group-universal-argument (arg &optional groups func)
1744 "Perform any command on all groups according to the process/prefix convention."
1746 (if (eq (setq func (or func
1749 (substitute-command-keys
1750 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1752 (gnus-error 1 "Undefined key")
1753 (gnus-group-iterate arg
1755 (command-execute func))))
1756 (gnus-group-position-point))
1758 (defun gnus-group-process-prefix (n)
1759 "Return a list of groups to work on.
1760 Take into consideration N (the prefix) and the list of marked groups."
1763 (setq n (prefix-numeric-value n))
1764 ;; There is a prefix, so we return a list of the N next
1766 (let ((way (if (< n 0) -1 1))
1771 (if (setq group (gnus-group-group-name))
1772 (push group groups))
1774 (gnus-group-next-group way)))
1776 ((and (gnus-region-active-p) (mark))
1777 ;; Work on the region between point and mark.
1778 (let ((max (max (point) (mark)))
1781 (goto-char (min (point) (mark)))
1784 (push (gnus-group-group-name) groups)
1785 (zerop (gnus-group-next-group 1))
1787 (nreverse groups))))
1789 ;; No prefix, but a list of marked articles.
1790 (reverse gnus-group-marked))
1792 ;; Neither marked articles or a prefix, so we return the
1794 (let ((group (gnus-group-group-name)))
1795 (and group (list group))))))
1797 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1798 ;;; imagine why I went through these contortions...
1800 (let ((function (make-symbol "gnus-group-iterate-function"))
1801 (window (make-symbol "gnus-group-iterate-window"))
1802 (groups (make-symbol "gnus-group-iterate-groups"))
1803 (group (make-symbol "gnus-group-iterate-group")))
1805 `(defun gnus-group-iterate (arg ,function)
1806 "Iterate FUNCTION over all process/prefixed groups.
1807 FUNCTION will be called with the group name as the parameter
1808 and with point over the group in question."
1809 (let ((,groups (gnus-group-process-prefix arg))
1810 (,window (selected-window))
1813 (setq ,group (car ,groups)
1814 ,groups (cdr ,groups))
1815 (select-window ,window)
1816 (gnus-group-remove-mark ,group)
1817 (save-selected-window
1819 (funcall ,function ,group)))))))))
1821 (put 'gnus-group-iterate 'lisp-indent-function 1)
1823 ;; Selecting groups.
1825 (defun gnus-group-read-group (&optional all no-article group select-articles)
1826 "Read news in this newsgroup.
1827 If the prefix argument ALL is non-nil, already read articles become
1828 readable. IF ALL is a number, fetch this number of articles. If the
1829 optional argument NO-ARTICLE is non-nil, no article will be
1830 auto-selected upon group entry. If GROUP is non-nil, fetch that
1833 (let ((no-display (eq all 0))
1834 (group (or group (gnus-group-group-name)))
1835 number active marked entry)
1839 (error "No group on current line"))
1840 (setq marked (gnus-info-marks
1841 (nth 2 (setq entry (gnus-gethash
1842 group gnus-newsrc-hashtb)))))
1843 ;; This group might be a dead group. In that case we have to get
1844 ;; the number of unread articles from `gnus-active-hashtb'.
1846 (cond ((numberp all) all)
1848 ((setq active (gnus-active group))
1849 (- (1+ (cdr active)) (car active)))))
1850 (gnus-summary-read-group
1851 group (or all (and (numberp number)
1852 (zerop (+ number (gnus-range-length
1853 (cdr (assq 'tick marked)))
1855 (cdr (assq 'dormant marked)))))))
1856 no-article nil no-display nil select-articles)))
1858 (defun gnus-group-select-group (&optional all)
1859 "Select this newsgroup.
1860 No article is selected automatically.
1861 If the group is opened, just switch the summary buffer.
1862 If ALL is non-nil, already read articles become readable.
1863 If ALL is a number, fetch this number of articles."
1865 (gnus-group-read-group all t))
1867 (defun gnus-group-quick-select-group (&optional all)
1868 "Select the current group \"quickly\".
1869 This means that no highlighting or scoring will be performed.
1870 If ALL (the prefix argument) is 0, don't even generate the summary
1873 This might be useful if you want to toggle threading
1874 before entering the group."
1876 (require 'gnus-score)
1878 gnus-score-find-score-files-function
1879 gnus-home-score-file
1880 gnus-apply-kill-hook
1881 gnus-summary-expunge-below)
1882 (gnus-group-read-group all t)))
1884 (defun gnus-group-visible-select-group (&optional all)
1885 "Select the current group without hiding any articles."
1887 (let ((gnus-inhibit-limiting t))
1888 (gnus-group-read-group all t)))
1890 (defun gnus-group-select-group-ephemerally ()
1891 "Select the current group without doing any processing whatsoever.
1892 You will actually be entered into a group that's a copy of
1893 the current group; no changes you make while in this group will
1896 (require 'gnus-score)
1898 gnus-score-find-score-files-function gnus-apply-kill-hook
1899 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1900 gnus-summary-mode-hook gnus-select-group-hook
1901 (group (gnus-group-group-name))
1902 (method (gnus-find-method-for-group group)))
1903 (gnus-group-read-ephemeral-group
1904 (gnus-group-prefixed-name group method) method)))
1907 (defun gnus-fetch-group (group &optional articles)
1908 "Start Gnus if necessary and enter GROUP.
1909 Returns whether the fetching was successful or not."
1910 (interactive (list (gnus-group-completing-read-group-name
1911 "Group name: " gnus-active-hashtb)))
1912 (unless (get-buffer gnus-group-buffer)
1914 (gnus-group-read-group articles nil group))
1917 (defun gnus-fetch-group-other-frame (group)
1918 "Pop up a frame and enter GROUP."
1920 (let ((window (get-buffer-window gnus-group-buffer)))
1922 (select-frame (window-frame window)))
1923 ((= (length (frame-list)) 1)
1924 (select-frame (make-frame)))
1927 (gnus-fetch-group group))
1929 (defvar gnus-ephemeral-group-server 0)
1931 ;; Enter a group that is not in the group buffer. Non-nil is returned
1932 ;; if selection was successful.
1933 (defun gnus-group-read-ephemeral-group (group method &optional activate
1934 quit-config request-only
1937 "Read GROUP from METHOD as an ephemeral group.
1938 If ACTIVATE, request the group first.
1939 If QUIT-CONFIG, use that window configuration when exiting from the
1941 If REQUEST-ONLY, don't actually read the group; just request it.
1942 If SELECT-ARTICLES, only select those articles.
1943 If PARAMETERS, use those as the group parameters.
1945 Return the name of the group if selection was successful."
1946 ;; Transform the select method into a unique server.
1947 (when (stringp method)
1948 (setq method (gnus-server-to-method method)))
1950 `(,(car method) ,(concat (cadr method) "-ephemeral")
1951 (,(intern (format "%s-address" (car method))) ,(cadr method))
1953 (let ((group (if (gnus-group-foreign-p group) group
1954 (gnus-group-prefixed-name (gnus-group-real-name group)
1959 ,gnus-level-default-subscribed nil nil ,method
1962 (cons 'quit-config quit-config)
1964 (cons gnus-summary-buffer
1965 gnus-current-window-configuration)))
1968 (push method gnus-ephemeral-servers)
1969 (set-buffer gnus-group-buffer)
1970 (unless (gnus-check-server method)
1971 (error "Unable to contact server: %s" (gnus-status-message method)))
1973 (gnus-activate-group group 'scan)
1974 (unless (gnus-request-group group)
1975 (error "Couldn't request group: %s"
1976 (nnheader-get-report (car method)))))
1980 (when (gnus-group-read-group t t group select-articles)
1984 (message "Quit reading the ephemeral group")
1987 (defun gnus-group-jump-to-group (group)
1988 "Jump to newsgroup GROUP."
1990 (list (gnus-group-completing-read-group-name
1991 "Group: " gnus-active-hashtb nil
1992 (gnus-read-active-file-p)
1993 gnus-group-jump-to-group-prompt
1994 'gnus-group-history)))
1996 (when (equal group "")
1997 (error "Empty group name"))
1999 (unless (gnus-ephemeral-group-p group)
2000 ;; Either go to the line in the group buffer...
2001 (unless (gnus-group-goto-group group)
2002 ;; ... or insert the line.
2003 (gnus-group-update-group group)
2004 (gnus-group-goto-group group)))
2005 ;; Adjust cursor point.
2006 (gnus-group-position-point))
2008 (defun gnus-group-goto-group (group &optional far test-marked)
2009 "Goto to newsgroup GROUP.
2010 If FAR, it is likely that the group is not on the current line.
2011 If TEST-MARKED, the line must be marked."
2015 ;; It's quite likely that we are on the right line, so
2016 ;; we check the current line first.
2018 (eq (get-text-property (point) 'gnus-group)
2019 (gnus-intern-safe group gnus-active-hashtb))
2020 (or (not test-marked) (gnus-group-mark-line-p)))
2022 ;; Previous and next line are also likely, so we check them as well.
2026 (and (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)))))
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)))))
2040 (goto-char (point-min))
2042 (while (and (not found)
2047 (gnus-intern-safe group gnus-active-hashtb))))
2048 (if (gnus-group-mark-line-p)
2053 ;; Search through the entire buffer.
2056 (point-min) (point-max)
2057 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2059 (defun gnus-group-next-group (n &optional silent)
2060 "Go to next N'th newsgroup.
2061 If N is negative, search backward instead.
2062 Returns the difference between N and the number of skips actually
2065 (gnus-group-next-unread-group n t nil silent))
2067 (defun gnus-group-next-unread-group (n &optional all level silent)
2068 "Go to next N'th unread newsgroup.
2069 If N is negative, search backward instead.
2070 If ALL is non-nil, choose any newsgroup, unread or not.
2071 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2072 such group can be found, the next group with a level higher than
2074 Returns the difference between N and the number of skips actually
2077 (let ((backward (< n 0))
2080 (gnus-group-search-forward
2081 backward (or (not gnus-group-goto-unread) all) level))
2085 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2086 (if level " on this level or higher" "")))
2089 (defun gnus-group-prev-group (n)
2090 "Go to previous N'th newsgroup.
2091 Returns the difference between N and the number of skips actually
2094 (gnus-group-next-unread-group (- n) t))
2096 (defun gnus-group-prev-unread-group (n)
2097 "Go to previous N'th unread newsgroup.
2098 Returns the difference between N and the number of skips actually
2101 (gnus-group-next-unread-group (- n)))
2103 (defun gnus-group-next-unread-group-same-level (n)
2104 "Go to next N'th unread newsgroup on the same level.
2105 If N is negative, search backward instead.
2106 Returns the difference between N and the number of skips actually
2109 (gnus-group-next-unread-group n t (gnus-group-group-level))
2110 (gnus-group-position-point))
2112 (defun gnus-group-prev-unread-group-same-level (n)
2113 "Go to next N'th unread newsgroup on the same level.
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-best-unread-group (&optional exclude-group)
2121 "Go to the group with the highest level.
2122 If EXCLUDE-GROUP, do not go to that group."
2124 (goto-char (point-min))
2128 (setq unread (get-text-property (point) 'gnus-unread))
2129 (when (and (numberp unread) (> unread 0))
2130 (when (and (get-text-property (point) 'gnus-level)
2131 (< (get-text-property (point) 'gnus-level) best)
2132 (or (not exclude-group)
2133 (not (equal exclude-group (gnus-group-group-name)))))
2134 (setq best (get-text-property (point) 'gnus-level))
2135 (setq best-point (point))))
2138 (goto-char best-point))
2139 (gnus-group-position-point)
2140 (and best-point (gnus-group-group-name))))
2142 (defun gnus-group-first-unread-group ()
2143 "Go to the first group with unread articles."
2146 (let ((opoint (point))
2148 (goto-char (point-min))
2149 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2150 (and (numberp unread) ; Not a topic.
2151 (not (zerop unread))) ; Has unread articles.
2152 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2155 nil)) ; Not success.
2156 (gnus-group-position-point)))
2158 (defun gnus-group-enter-server-mode ()
2159 "Jump to the server buffer."
2161 (gnus-enter-server-buffer))
2163 (defun gnus-group-make-group (name &optional method address args)
2164 "Add a new newsgroup.
2165 The user will be prompted for a NAME, for a select METHOD, and an
2169 (gnus-read-group "Group name: ")
2170 (gnus-read-method "From method: ")))
2172 (when (stringp method)
2173 (setq method (or (gnus-server-to-method method) method)))
2174 (let* ((meth (gnus-method-simplify
2176 (not (gnus-server-equal method gnus-select-method)))
2177 (if address (list (intern method) address)
2179 (nname (if method (gnus-group-prefixed-name name meth) name))
2181 (when (gnus-gethash nname gnus-newsrc-hashtb)
2182 (error "Group %s already exists" nname))
2183 ;; Subscribe to the new group.
2184 (gnus-group-change-level
2185 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2186 gnus-level-default-subscribed gnus-level-killed
2187 (and (gnus-group-group-name)
2188 (gnus-gethash (gnus-group-group-name)
2189 gnus-newsrc-hashtb))
2192 (gnus-set-active nname (cons 1 0))
2193 (unless (gnus-ephemeral-group-p name)
2195 (concat "(gnus-group-set-info '"
2196 (gnus-prin1-to-string (cdr info)) ")")))
2198 (gnus-group-insert-group-line-info nname)
2200 (gnus-group-position-point)
2202 ;; Load the backend and try to make the backend create
2203 ;; the group as well.
2204 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2206 gnus-valid-select-methods)
2208 (gnus-check-server meth)
2209 (when (gnus-check-backend-function 'request-create-group nname)
2210 (gnus-request-create-group nname nil args))
2213 (defun gnus-group-delete-groups (&optional arg)
2214 "Delete the current group. Only meaningful with editable groups."
2216 (let ((n (length (gnus-group-process-prefix arg))))
2217 (when (gnus-yes-or-no-p
2219 "Delete this 1 group? "
2220 (format "Delete these %d groups? " n)))
2221 (gnus-group-iterate arg
2223 (gnus-group-delete-group group nil t))))))
2225 (defun gnus-group-delete-group (group &optional force no-prompt)
2226 "Delete the current group. Only meaningful with editable groups.
2227 If FORCE (the prefix) is non-nil, all the articles in the group will
2228 be deleted. This is \"deleted\" as in \"removed forever from the face
2229 of the Earth\". There is no undo. The user will be prompted before
2230 doing the deletion."
2232 (list (gnus-group-group-name)
2233 current-prefix-arg))
2235 (error "No group to delete"))
2236 (unless (gnus-check-backend-function 'request-delete-group group)
2237 (error "This backend does not support group deletion"))
2239 (if (and (not no-prompt)
2240 (not (gnus-yes-or-no-p
2242 "Do you really want to delete %s%s? "
2243 group (if force " and all its contents" "")))))
2245 (gnus-message 6 "Deleting group %s..." group)
2246 (if (not (gnus-request-delete-group group force))
2247 (gnus-error 3 "Couldn't delete group %s" group)
2248 (gnus-message 6 "Deleting group %s...done" group)
2249 (gnus-group-goto-group group)
2250 (gnus-group-kill-group 1 t)
2251 (gnus-sethash group nil gnus-active-hashtb)
2252 (when (and (boundp 'gnus-cache-active-hashtb)
2253 gnus-cache-active-hashtb)
2254 (gnus-sethash group nil gnus-cache-active-hashtb)
2255 (setq gnus-cache-active-altered t))
2257 (gnus-group-position-point)))
2259 (defun gnus-group-rename-group (group new-name)
2260 "Rename group from GROUP to NEW-NAME.
2261 When used interactively, GROUP is the group under point
2262 and NEW-NAME will be prompted for."
2265 (gnus-group-group-name)
2267 (unless (gnus-check-backend-function
2268 'request-rename-group (gnus-group-group-name))
2269 (error "This backend does not support renaming groups"))
2270 (gnus-read-group "Rename group to: "
2271 (gnus-group-real-name (gnus-group-group-name))))))
2273 (unless (gnus-check-backend-function 'request-rename-group group)
2274 (error "This backend does not support renaming groups"))
2276 (error "No group to rename"))
2277 (when (equal (gnus-group-real-name group) new-name)
2278 (error "Can't rename to the same name"))
2280 ;; We find the proper prefixed name.
2282 (if (gnus-group-native-p group)
2286 (gnus-group-prefixed-name
2287 (gnus-group-real-name new-name)
2288 (gnus-info-method (gnus-get-info group)))))
2290 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2293 (gnus-group-goto-group group)
2294 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2295 (gnus-request-rename-group group new-name))))
2296 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2297 ;; We rename the group internally by killing it...
2298 (gnus-group-kill-group)
2299 ;; ... changing its name ...
2300 (setcar (cdar gnus-list-of-killed-groups) new-name)
2301 ;; ... and then yanking it. Magic!
2302 (gnus-group-yank-group)
2303 (gnus-set-active new-name (gnus-active group))
2304 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2306 (setq gnus-killed-list (delete group gnus-killed-list))
2307 (gnus-set-active group nil)
2308 (gnus-dribble-touch)
2309 (gnus-group-position-point)))
2311 (defun gnus-group-edit-group (group &optional part)
2312 "Edit the group on the current line."
2313 (interactive (list (gnus-group-group-name)))
2314 (let ((part (or part 'info))
2317 (error "No group on current line"))
2318 (unless (setq info (gnus-get-info group))
2319 (error "Killed group; can't be edited"))
2321 (gnus-close-group group))
2323 ;; Find the proper form to edit.
2324 (cond ((eq part 'method)
2325 (or (gnus-info-method info) "native"))
2327 (gnus-info-params info))
2329 ;; The proper documentation.
2331 "Editing the %s for `%s'."
2333 ((eq part 'method) "select method")
2334 ((eq part 'params) "group parameters")
2336 (gnus-group-decoded-name group))
2338 (gnus-group-edit-group-done ',part ,group form)))
2341 (gnus-create-info-command
2344 "(gnus)Select Methods")
2346 "(gnus)Group Parameters")
2348 "(gnus)Group Info"))))))
2350 (defun gnus-group-edit-group-method (group)
2351 "Edit the select method of GROUP."
2352 (interactive (list (gnus-group-group-name)))
2353 (gnus-group-edit-group group 'method))
2355 (defun gnus-group-edit-group-parameters (group)
2356 "Edit the group parameters of GROUP."
2357 (interactive (list (gnus-group-group-name)))
2358 (gnus-group-edit-group group 'params))
2360 (defun gnus-group-edit-group-done (part group form)
2362 (let* ((method (cond ((eq part 'info) (nth 4 form))
2363 ((eq part 'method) form)
2365 (info (cond ((eq part 'info) form)
2366 ((eq part 'method) (gnus-get-info group))
2369 (if (or (not method)
2371 gnus-select-method method))
2372 (gnus-group-real-name (car info))
2373 (gnus-group-prefixed-name
2374 (gnus-group-real-name (car info)) method))
2376 (when (and new-group
2377 (not (equal new-group group)))
2378 (when (gnus-group-goto-group group)
2379 (gnus-group-kill-group 1))
2380 (gnus-activate-group new-group))
2382 (if (not (and info new-group))
2383 (gnus-group-set-info form (or new-group group) part)
2384 (setq info (gnus-copy-sequence info))
2385 (setcar info new-group)
2386 (unless (gnus-server-equal method "native")
2387 (unless (nthcdr 3 info)
2388 (nconc info (list nil nil)))
2389 (unless (nthcdr 4 info)
2390 (nconc info (list nil)))
2391 (gnus-info-set-method info method))
2392 (gnus-group-set-info info))
2393 (gnus-group-update-group (or new-group group))
2394 (gnus-group-position-point)))
2396 (defun gnus-group-make-useful-group (group method)
2397 "Create one of the groups described in `gnus-useful-groups'."
2399 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2401 gnus-useful-groups)))
2402 (list (cadr entry) (caddr entry))))
2403 (setq method (gnus-copy-sequence method))
2405 (while (setq entry (memq (assq 'eval method) method))
2406 (setcar entry (eval (cadar entry)))))
2407 (gnus-group-make-group group method))
2409 (defun gnus-group-make-help-group (&optional noerror)
2410 "Create the Gnus documentation group.
2411 Optional argument NOERROR modifies the behavior of this function when the
2412 group already exists:
2413 - if not given, and error is signaled,
2414 - if t, stay silent,
2415 - if anything else, just print a message."
2417 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2418 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2419 (if (gnus-gethash name gnus-newsrc-hashtb)
2420 (cond ((eq noerror nil)
2421 (error "Documentation group already exists"))
2426 (gnus-message 1 "Documentation group already exists")))
2429 (gnus-message 1 "Couldn't find doc group")
2430 (gnus-group-make-group
2431 (gnus-group-real-name name)
2432 (list 'nndoc "gnus-help"
2433 (list 'nndoc-address file)
2434 (list 'nndoc-article-type 'mbox))))
2436 (gnus-group-position-point))
2438 (defun gnus-group-make-doc-group (file type)
2439 "Create a group that uses a single file as the source."
2441 (list (read-file-name "File name: ")
2442 (and current-prefix-arg 'ask)))
2443 (when (eq type 'ask)
2448 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2450 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2451 ((= char ?b) 'babyl)
2452 ((= char ?d) 'digest)
2453 ((= char ?f) 'forward)
2455 ((= char ?g) 'guess)
2456 (t (setq err (format "%c unknown. " char))
2459 (let* ((file (expand-file-name file))
2460 (name (gnus-generate-new-group-name
2461 (gnus-group-prefixed-name
2462 (file-name-nondirectory file) '(nndoc "")))))
2463 (gnus-group-make-group
2464 (gnus-group-real-name name)
2466 (list 'nndoc-address file)
2467 (list 'nndoc-article-type (or type 'guess))))))
2469 (defvar nnweb-type-definition)
2470 (defvar gnus-group-web-type-history nil)
2471 (defvar gnus-group-web-search-history nil)
2472 (defun gnus-group-make-web-group (&optional solid)
2473 "Create an ephemeral nnweb group.
2474 If SOLID (the prefix), create a solid group."
2478 (if solid (gnus-read-group "Group name: ")
2479 (message-unique-id)))
2480 (default-type (or (car gnus-group-web-type-history)
2481 (symbol-name (caar nnweb-type-definition))))
2485 (format "Search engine type (default %s): " default-type)
2486 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2487 nnweb-type-definition)
2488 nil t nil 'gnus-group-web-type-history)
2493 (cons (or (car gnus-group-web-search-history) "") 0)
2494 'gnus-group-web-search-history))
2496 `(nnweb ,group (nnweb-search ,search)
2497 (nnweb-type ,(intern type))
2498 (nnweb-ephemeral-p t))))
2500 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2501 (gnus-group-read-ephemeral-group
2503 (cons (current-buffer)
2504 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2506 (defvar nnwarchive-type-definition)
2507 (defvar gnus-group-warchive-type-history nil)
2508 (defvar gnus-group-warchive-login-history nil)
2509 (defvar gnus-group-warchive-address-history nil)
2511 (defun gnus-group-make-warchive-group ()
2512 "Create a nnwarchive group."
2514 (require 'nnwarchive)
2515 (let* ((group (gnus-read-group "Group name: "))
2516 (default-type (or (car gnus-group-warchive-type-history)
2517 (symbol-name (caar nnwarchive-type-definition))))
2521 (format "Warchive type (default %s): " default-type)
2522 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2523 nnwarchive-type-definition)
2524 nil t nil 'gnus-group-warchive-type-history)
2526 (address (read-string "Warchive address: "
2527 nil 'gnus-group-warchive-address-history))
2528 (default-login (or (car gnus-group-warchive-login-history)
2533 (format "Warchive login (default %s): " user-mail-address)
2534 default-login 'gnus-group-warchive-login-history)
2537 `(nnwarchive ,address
2538 (nnwarchive-type ,(intern type))
2539 (nnwarchive-login ,login))))
2540 (gnus-group-make-group group method)))
2542 (defun gnus-group-make-archive-group (&optional all)
2543 "Create the (ding) Gnus archive group of the most recent articles.
2544 Given a prefix, create a full group."
2546 (let ((group (gnus-group-prefixed-name
2547 (if all "ding.archives" "ding.recent") '(nndir ""))))
2548 (when (gnus-gethash group gnus-newsrc-hashtb)
2549 (error "Archive group already exists"))
2550 (gnus-group-make-group
2551 (gnus-group-real-name group)
2552 (list 'nndir (if all "hpc" "edu")
2553 (list 'nndir-directory
2554 (if all gnus-group-archive-directory
2555 gnus-group-recent-archive-directory))))
2556 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2558 (defun gnus-group-make-directory-group (dir)
2559 "Create an nndir group.
2560 The user will be prompted for a directory. The contents of this
2561 directory will be used as a newsgroup. The directory should contain
2562 mail messages or news articles in files that have numeric names."
2564 (list (read-file-name "Create group from directory: ")))
2565 (unless (file-exists-p dir)
2566 (error "No such directory"))
2567 (unless (file-directory-p dir)
2568 (error "Not a directory"))
2572 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2574 (gnus-group-prefixed-name
2575 (expand-file-name ext dir)
2577 (setq ext (format "<%d>" (setq i (1+ i)))))
2578 (gnus-group-make-group
2579 (gnus-group-real-name group)
2580 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2582 (eval-when-compile (defvar nnkiboze-score-file))
2583 (defun gnus-group-make-kiboze-group (group address scores)
2584 "Create an nnkiboze group.
2585 The user will be prompted for a name, a regexp to match groups, and
2586 score file entries for articles to include in the group."
2589 (read-string "nnkiboze group name: ")
2590 (read-string "Source groups (regexp): ")
2591 (let ((headers (mapcar (lambda (group) (list group))
2592 '("subject" "from" "number" "date" "message-id"
2593 "references" "chars" "lines" "xref"
2594 "followup" "all" "body" "head")))
2595 scores header regexp regexps)
2596 (while (not (equal "" (setq header (completing-read
2597 "Match on header: " headers nil t))))
2599 (while (not (equal "" (setq regexp (read-string
2600 (format "Match on %s (regexp): "
2602 (push (list regexp nil nil 'r) regexps))
2603 (push (cons header regexps) scores))
2605 (gnus-group-make-group group "nnkiboze" address)
2606 (let* ((nnkiboze-current-group group)
2607 (score-file (car (nnkiboze-score-file "")))
2608 (score-dir (file-name-directory score-file)))
2609 (unless (file-exists-p score-dir)
2610 (make-directory score-dir))
2611 (with-temp-file score-file
2612 (let (emacs-lisp-mode-hook)
2613 (pp scores (current-buffer))))))
2615 (defun gnus-group-add-to-virtual (n vgroup)
2616 "Add the current group to a virtual group."
2618 (list current-prefix-arg
2619 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2621 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2622 (error "%s is not an nnvirtual group" vgroup))
2623 (gnus-close-group vgroup)
2624 (let* ((groups (gnus-group-process-prefix n))
2625 (method (gnus-info-method (gnus-get-info vgroup))))
2626 (setcar (cdr method)
2628 (nth 1 method) "\\|"
2631 (gnus-group-remove-mark s)
2632 (concat "\\(^" (regexp-quote s) "$\\)"))
2634 (gnus-group-position-point))
2636 (defun gnus-group-make-empty-virtual (group)
2637 "Create a new, fresh, empty virtual group."
2638 (interactive "sCreate new, empty virtual group: ")
2639 (let* ((method (list 'nnvirtual "^$"))
2640 (pgroup (gnus-group-prefixed-name group method)))
2641 ;; Check whether it exists already.
2642 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2643 (error "Group %s already exists" pgroup))
2644 ;; Subscribe the new group after the group on the current line.
2645 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2646 (gnus-group-update-group pgroup)
2648 (gnus-group-position-point)))
2650 (defun gnus-group-enter-directory (dir)
2651 "Enter an ephemeral nneething group."
2652 (interactive "DDirectory to read: ")
2653 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2654 (leaf (gnus-group-prefixed-name
2655 (file-name-nondirectory (directory-file-name dir))
2657 (name (gnus-generate-new-group-name leaf)))
2658 (unless (gnus-group-read-ephemeral-group
2660 (cons (current-buffer)
2661 (if (eq major-mode 'gnus-summary-mode)
2663 (error "Couldn't enter %s" dir))))
2666 (autoload 'nnimap-expunge "nnimap")
2667 (autoload 'nnimap-acl-get "nnimap")
2668 (autoload 'nnimap-acl-edit "nnimap"))
2670 (defun gnus-group-nnimap-expunge (group)
2671 "Expunge deleted articles in current nnimap GROUP."
2672 (interactive (list (gnus-group-group-name)))
2673 (let ((mailbox (gnus-group-real-name group)) method)
2675 (error "No group on current line"))
2676 (unless (gnus-get-info group)
2677 (error "Killed group; can't be edited"))
2678 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2679 (error "%s is not an nnimap group" group))
2680 (nnimap-expunge mailbox (cadr method))))
2682 (defun gnus-group-nnimap-edit-acl (group)
2683 "Edit the Access Control List of current nnimap GROUP."
2684 (interactive (list (gnus-group-group-name)))
2685 (let ((mailbox (gnus-group-real-name group)) method acl)
2687 (error "No group on current line"))
2688 (unless (gnus-get-info group)
2689 (error "Killed group; can't be edited"))
2690 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2691 (error "%s is not an nnimap group" group))
2692 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2693 (error "Server does not support ACL's"))
2694 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2696 An access control list is a list of (identifier . rights) elements.
2698 The identifier string specifies the corresponding user. The
2699 identifier \"anyone\" is reserved to refer to the universal identity.
2701 Rights is a string listing a (possibly empty) set of alphanumeric
2702 characters, each character listing a set of operations which is being
2703 controlled. Letters are reserved for ``standard'' rights, listed
2704 below. Digits are reserved for implementation or site defined rights.
2706 l - lookup (mailbox is visible to LIST/LSUB commands)
2707 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2708 SEARCH, COPY from mailbox)
2709 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2710 w - write (STORE flags other than \\SEEN and \\DELETED)
2711 i - insert (perform APPEND, COPY into mailbox)
2712 p - post (send mail to submission address for mailbox,
2713 not enforced by IMAP4 itself)
2714 c - create and delete mailbox (CREATE new sub-mailboxes in any
2715 implementation-defined hierarchy, RENAME or DELETE mailbox)
2716 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2717 a - administer (perform SETACL)" group)
2720 ,mailbox ',method ',acl form)))))
2722 ;; Group sorting commands
2723 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2725 (defun gnus-group-sort-groups (func &optional reverse)
2726 "Sort the group buffer according to FUNC.
2727 When used interactively, the sorting function used will be
2728 determined by the `gnus-group-sort-function' variable.
2729 If REVERSE (the prefix), reverse the sorting order."
2730 (interactive (list gnus-group-sort-function current-prefix-arg))
2731 (funcall gnus-group-sort-alist-function
2732 (gnus-make-sort-function func) reverse)
2733 (gnus-group-unmark-all-groups)
2734 (gnus-group-list-groups)
2735 (gnus-dribble-touch))
2737 (defun gnus-group-sort-flat (func reverse)
2738 ;; We peel off the dummy group from the alist.
2740 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2741 (pop gnus-newsrc-alist))
2743 (setq gnus-newsrc-alist
2744 (sort gnus-newsrc-alist func))
2746 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2747 ;; Regenerate the hash table.
2748 (gnus-make-hashtable-from-newsrc-alist)))
2750 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2751 "Sort the group buffer alphabetically by group name.
2752 If REVERSE, sort in reverse order."
2754 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2756 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2757 "Sort the group buffer alphabetically by real (unprefixed) group name.
2758 If REVERSE, sort in reverse order."
2760 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2762 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2763 "Sort the group buffer by number of unread articles.
2764 If REVERSE, sort in reverse order."
2766 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2768 (defun gnus-group-sort-groups-by-level (&optional reverse)
2769 "Sort the group buffer by group level.
2770 If REVERSE, sort in reverse order."
2772 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2774 (defun gnus-group-sort-groups-by-score (&optional reverse)
2775 "Sort the group buffer by group score.
2776 If REVERSE, sort in reverse order."
2778 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2780 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2781 "Sort the group buffer by group rank.
2782 If REVERSE, sort in reverse order."
2784 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2786 (defun gnus-group-sort-groups-by-method (&optional reverse)
2787 "Sort the group buffer alphabetically by backend name.
2788 If REVERSE, sort in reverse order."
2790 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2792 (defun gnus-group-sort-groups-by-server (&optional reverse)
2793 "Sort the group buffer alphabetically by server name.
2794 If REVERSE, sort in reverse order."
2796 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2798 ;;; Selected group sorting.
2800 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2801 "Sort the process/prefixed groups."
2802 (interactive (list current-prefix-arg gnus-group-sort-function))
2803 (let ((groups (gnus-group-process-prefix n)))
2804 (funcall gnus-group-sort-selected-function
2805 groups (gnus-make-sort-function func) reverse)
2806 (gnus-group-unmark-all-groups)
2807 (gnus-group-list-groups)
2808 (gnus-dribble-touch)))
2810 (defun gnus-group-sort-selected-flat (groups func reverse)
2811 (let (entries infos)
2812 ;; First find all the group entries for these groups.
2814 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2816 ;; Then sort the infos.
2820 (lambda (entry) (car entry))
2821 (setq entries (nreverse entries)))
2824 (setq infos (nreverse infos)))
2825 ;; Go through all the infos and replace the old entries
2826 ;; with the new infos.
2828 (setcar (car entries) (pop infos))
2830 ;; Update the hashtable.
2831 (gnus-make-hashtable-from-newsrc-alist)))
2833 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2834 "Sort the group buffer alphabetically by group name.
2835 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2836 sort in reverse order."
2837 (interactive (gnus-interactive "P\ny"))
2838 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2840 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2841 "Sort the group buffer alphabetically by real group name.
2842 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2843 sort in reverse order."
2844 (interactive (gnus-interactive "P\ny"))
2845 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2847 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2848 "Sort the group buffer by number of unread articles.
2849 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2850 sort in reverse order."
2851 (interactive (gnus-interactive "P\ny"))
2852 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2854 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2855 "Sort the group buffer by group level.
2856 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2857 sort in reverse order."
2858 (interactive (gnus-interactive "P\ny"))
2859 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2861 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2862 "Sort the group buffer by group score.
2863 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2864 sort in reverse order."
2865 (interactive (gnus-interactive "P\ny"))
2866 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2868 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2869 "Sort the group buffer by group rank.
2870 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2871 sort in reverse order."
2872 (interactive (gnus-interactive "P\ny"))
2873 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2875 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2876 "Sort the group buffer alphabetically by backend name.
2877 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2878 sort in reverse order."
2879 (interactive (gnus-interactive "P\ny"))
2880 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2882 ;;; Sorting predicates.
2884 (defun gnus-group-sort-by-alphabet (info1 info2)
2885 "Sort alphabetically."
2886 (string< (gnus-info-group info1) (gnus-info-group info2)))
2888 (defun gnus-group-sort-by-real-name (info1 info2)
2889 "Sort alphabetically on real (unprefixed) names."
2890 (string< (gnus-group-real-name (gnus-info-group info1))
2891 (gnus-group-real-name (gnus-info-group info2))))
2893 (defun gnus-group-sort-by-unread (info1 info2)
2894 "Sort by number of unread articles."
2895 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2896 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2897 (< (or (and (numberp n1) n1) 0)
2898 (or (and (numberp n2) n2) 0))))
2900 (defun gnus-group-sort-by-level (info1 info2)
2902 (< (gnus-info-level info1) (gnus-info-level info2)))
2904 (defun gnus-group-sort-by-method (info1 info2)
2905 "Sort alphabetically by backend name."
2906 (string< (car (gnus-find-method-for-group
2907 (gnus-info-group info1) info1))
2908 (car (gnus-find-method-for-group
2909 (gnus-info-group info2) info2))))
2911 (defun gnus-group-sort-by-server (info1 info2)
2912 "Sort alphabetically by server name."
2913 (string< (gnus-method-to-full-server-name
2914 (gnus-find-method-for-group
2915 (gnus-info-group info1) info1))
2916 (gnus-method-to-full-server-name
2917 (gnus-find-method-for-group
2918 (gnus-info-group info2) info2))))
2920 (defun gnus-group-sort-by-score (info1 info2)
2921 "Sort by group score."
2922 (> (gnus-info-score info1) (gnus-info-score info2)))
2924 (defun gnus-group-sort-by-rank (info1 info2)
2925 "Sort by level and score."
2926 (let ((level1 (gnus-info-level info1))
2927 (level2 (gnus-info-level info2)))
2928 (or (< level1 level2)
2929 (and (= level1 level2)
2930 (> (gnus-info-score info1) (gnus-info-score info2))))))
2934 (defun gnus-group-clear-data (&optional arg)
2935 "Clear all marks and read ranges from the current group."
2937 (gnus-group-iterate arg
2940 (gnus-info-clear-data (setq info (gnus-get-info group)))
2941 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2942 (when (gnus-group-goto-group group)
2943 (gnus-group-update-group-line))))))
2945 (defun gnus-group-clear-data-on-native-groups ()
2946 "Clear all marks and read ranges from all native groups."
2948 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2949 (let ((alist (cdr gnus-newsrc-alist))
2951 (while (setq info (pop alist))
2952 (when (gnus-group-native-p (gnus-info-group info))
2953 (gnus-info-clear-data info)))
2954 (gnus-get-unread-articles)
2955 (gnus-dribble-touch)
2956 (when (gnus-y-or-n-p
2957 "Move the cache away to avoid problems in the future? ")
2958 (call-interactively 'gnus-cache-move-cache)))))
2960 (defun gnus-info-clear-data (info)
2961 "Clear all marks and read ranges from INFO."
2962 (let ((group (gnus-info-group info))
2964 (dolist (el (gnus-info-marks info))
2965 (push `(,(cdr el) add (,(car el))) action))
2966 (push `(,(gnus-info-read info) add (read)) action)
2969 (gnus-request-set-mark ,group ',action)
2970 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2971 (gnus-info-set-read ',info ',(gnus-info-read info))
2972 (when (gnus-group-goto-group ,group)
2973 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2974 (gnus-group-update-group-line))))
2975 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2977 (gnus-request-set-mark group action)
2978 (gnus-info-set-read info nil)
2979 (when (gnus-info-marks info)
2980 (gnus-info-set-marks info nil))))
2982 ;; Group catching up.
2984 (defun gnus-group-catchup-current (&optional n all)
2985 "Mark all unread articles in the current newsgroup as read.
2986 If prefix argument N is numeric, the next N newsgroups will be
2987 caught up. If ALL is non-nil, marked articles will also be marked as
2988 read. Cross references (Xref: header) of articles are ignored.
2989 The number of newsgroups that this function was unable to catch
2992 (let ((groups (gnus-group-process-prefix n))
2995 (unless groups (error "No groups selected"))
2997 (or (not gnus-interactive-catchup) ;Without confirmation?
3002 "Do you really want to mark all articles in %s as read? "
3003 "Mark all unread articles in %s as read? ")
3004 (if (= (length groups) 1)
3006 (format "these %d groups" (length groups)))))))
3008 (while (setq group (pop groups))
3009 (gnus-group-remove-mark group)
3010 ;; Virtual groups have to be given special treatment.
3011 (let ((method (gnus-find-method-for-group group)))
3012 (when (eq 'nnvirtual (car method))
3013 (nnvirtual-catchup-group
3014 (gnus-group-real-name group) (nth 1 method) all)))
3015 (if (>= (gnus-group-level group) gnus-level-zombie)
3016 (gnus-message 2 "Dead groups can't be caught up")
3018 (gnus-group-goto-group group)
3019 (gnus-group-catchup group all))
3020 (gnus-group-update-group-line)
3021 (setq ret (1+ ret)))))
3022 (gnus-group-next-unread-group 1)
3025 (defun gnus-group-catchup-current-all (&optional n)
3026 "Mark all articles in current newsgroup as read.
3027 Cross references (Xref: header) of articles are ignored."
3029 (gnus-group-catchup-current n 'all))
3031 (defun gnus-group-catchup (group &optional all)
3032 "Mark all articles in GROUP as read.
3033 If ALL is non-nil, all articles are marked as read.
3034 The return value is the number of articles that were marked as read,
3035 or nil if no action could be taken."
3036 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3038 (marks (nth 3 (nth 2 entry)))
3039 (unread (gnus-list-of-unread-articles group)))
3040 ;; Remove entries for this group.
3041 (nnmail-purge-split-history (gnus-group-real-name group))
3042 ;; Do the updating only if the newsgroup isn't killed.
3043 (if (not (numberp (car entry)))
3044 (gnus-message 1 "Can't catch up %s; non-active group" group)
3045 (gnus-update-read-articles group nil)
3047 ;; Nix out the lists of marks and dormants.
3048 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3050 (list (cdr (assq 'dormant marks))
3052 (setq unread (gnus-uncompress-range
3053 (gnus-range-add (gnus-range-add
3054 unread (cdr (assq 'dormant marks)))
3055 (cdr (assq 'tick marks)))))
3056 (gnus-add-marked-articles group 'tick nil nil 'force)
3057 (gnus-add-marked-articles group 'dormant nil nil 'force))
3058 ;; Do auto-expirable marks if that's required.
3059 (when (gnus-group-auto-expirable-p group)
3060 (gnus-add-marked-articles group 'expire unread)
3061 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3062 (let ((gnus-newsgroup-name group))
3063 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3066 (defun gnus-group-expire-articles (&optional n)
3067 "Expire all expirable articles in the current newsgroup."
3069 (let ((groups (gnus-group-process-prefix n))
3072 (error "No groups to expire"))
3073 (while (setq group (pop groups))
3074 (gnus-group-remove-mark group)
3075 (gnus-group-expire-articles-1 group)
3076 (gnus-dribble-touch)
3077 (gnus-group-position-point))))
3079 (defun gnus-group-expire-articles-1 (group)
3080 (when (gnus-check-backend-function 'request-expire-articles group)
3081 (gnus-message 6 "Expiring articles in %s..." group)
3082 (let* ((info (gnus-get-info group))
3083 (expirable (if (gnus-group-total-expirable-p group)
3084 (cons nil (gnus-list-of-read-articles group))
3085 (assq 'expire (gnus-info-marks info))))
3086 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3087 (nnmail-expiry-target
3088 (or (gnus-group-find-parameter group 'expiry-target)
3089 nnmail-expiry-target)))
3091 (gnus-check-group group)
3094 (gnus-compress-sequence
3096 ;; We set the expiry variables to the group
3098 (let ((nnmail-expiry-wait-function nil)
3099 (nnmail-expiry-wait expiry-wait))
3100 (gnus-request-expire-articles
3101 (gnus-uncompress-sequence (cdr expirable)) group))
3102 ;; Just expire using the normal expiry values.
3103 (gnus-request-expire-articles
3104 (gnus-uncompress-sequence (cdr expirable)) group))))
3105 (gnus-close-group group))
3106 (gnus-message 6 "Expiring articles in %s...done" group)
3107 ;; Return the list of un-expired articles.
3110 (defun gnus-group-expire-all-groups ()
3111 "Expire all expirable articles in all newsgroups."
3114 (gnus-message 5 "Expiring...")
3115 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3116 (cdr gnus-newsrc-alist))))
3117 (gnus-group-expire-articles nil)))
3118 (gnus-group-position-point)
3119 (gnus-message 5 "Expiring...done"))
3121 (defun gnus-group-set-current-level (n level)
3122 "Set the level of the next N groups to LEVEL."
3127 (let ((s (read-string
3128 (format "Level (default %s): "
3129 (or (gnus-group-group-level)
3130 gnus-level-default-subscribed)))))
3131 (if (string-match "^\\s-*$" s)
3132 (int-to-string (or (gnus-group-group-level)
3133 gnus-level-default-subscribed))
3135 (unless (and (>= level 1) (<= level gnus-level-killed))
3136 (error "Invalid level: %d" level))
3137 (let ((groups (gnus-group-process-prefix n))
3139 (while (setq group (pop groups))
3140 (gnus-group-remove-mark group)
3141 (gnus-message 6 "Changed level of %s from %d to %d"
3142 group (or (gnus-group-group-level) gnus-level-killed)
3144 (gnus-group-change-level
3145 group level (or (gnus-group-group-level) gnus-level-killed))
3146 (gnus-group-update-group-line)))
3147 (gnus-group-position-point))
3149 (defun gnus-group-unsubscribe (&optional n)
3150 "Unsubscribe the current group."
3152 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3154 (defun gnus-group-subscribe (&optional n)
3155 "Subscribe the current group."
3157 (gnus-group-unsubscribe-current-group n 'subscribe))
3159 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3160 "Toggle subscription of the current group.
3161 If given numerical prefix, toggle the N next groups."
3163 (let ((groups (gnus-group-process-prefix n))
3166 (setq group (car groups)
3167 groups (cdr groups))
3168 (gnus-group-remove-mark group)
3169 (gnus-group-unsubscribe-group
3172 ((eq do-sub 'unsubscribe)
3173 gnus-level-default-unsubscribed)
3174 ((eq do-sub 'subscribe)
3175 gnus-level-default-subscribed)
3176 ((<= (gnus-group-group-level) gnus-level-subscribed)
3177 gnus-level-default-unsubscribed)
3179 gnus-level-default-subscribed))
3181 (gnus-group-update-group-line))
3182 (gnus-group-next-group 1)))
3184 (defun gnus-group-unsubscribe-group (group &optional level silent)
3185 "Toggle subscription to GROUP.
3186 Killed newsgroups are subscribed. If SILENT, don't try to update the
3189 (list (gnus-group-completing-read-group-name
3190 "Group: " gnus-active-hashtb nil
3191 (gnus-read-active-file-p)
3193 'gnus-group-history)))
3194 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3196 ((string-match "^[ \t]*$" group)
3197 (error "Empty group name"))
3199 ;; Toggle subscription flag.
3200 (gnus-group-change-level
3201 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3202 gnus-level-subscribed)
3203 (1+ gnus-level-subscribed)
3204 gnus-level-default-subscribed)))
3206 (gnus-group-update-group group)))
3207 ((and (stringp group)
3208 (or (not (gnus-read-active-file-p))
3209 (gnus-active group)))
3210 ;; Add new newsgroup.
3211 (gnus-group-change-level
3213 (if level level gnus-level-default-subscribed)
3214 (or (and (member group gnus-zombie-list)
3217 (when (gnus-group-group-name)
3218 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3220 (gnus-group-update-group group)))
3221 (t (error "No such newsgroup: %s" group)))
3222 (gnus-group-position-point)))
3224 (defun gnus-group-transpose-groups (n)
3225 "Move the current newsgroup up N places.
3226 If given a negative prefix, move down instead. The difference between
3227 N and the number of steps taken is returned."
3229 (unless (gnus-group-group-name)
3230 (error "No group on current line"))
3231 (gnus-group-kill-group 1)
3233 (forward-line (- n))
3234 (gnus-group-yank-group)
3235 (gnus-group-position-point)))
3237 (defun gnus-group-kill-all-zombies (&optional dummy)
3238 "Kill all zombie newsgroups.
3239 The optional DUMMY should always be nil."
3240 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3242 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3243 (setq gnus-zombie-list nil)
3244 (gnus-dribble-touch)
3245 (gnus-group-list-groups)))
3247 (defun gnus-group-kill-region (begin end)
3248 "Kill newsgroups in current region (excluding current point).
3249 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3264 (beginning-of-line) ;Important when LINES < 1
3265 (gnus-group-kill-group lines)))
3267 (defun gnus-group-kill-group (&optional n discard)
3268 "Kill the next N groups.
3269 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3270 However, only groups that were alive can be yanked; already killed
3271 groups or zombie groups can't be yanked.
3272 The return value is the name of the group that was killed, or a list
3275 (let ((buffer-read-only nil)
3276 (groups (gnus-group-process-prefix n))
3277 group entry level out)
3278 (if (< (length groups) 10)
3279 ;; This is faster when there are few groups.
3281 (push (setq group (pop groups)) out)
3282 (gnus-group-remove-mark group)
3283 (setq level (gnus-group-group-level))
3285 (when (and (not discard)
3286 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3289 (gnus-group-goto-group ,(gnus-group-group-name))
3290 (gnus-group-yank-group)))
3291 (push (cons (car entry) (nth 2 entry))
3292 gnus-list-of-killed-groups))
3293 (gnus-group-change-level
3294 (if entry entry group) gnus-level-killed (if entry nil level))
3295 (message "Killed group %s" group))
3296 ;; If there are lots and lots of groups to be killed, we use
3297 ;; this thing instead.
3299 (setq groups (nreverse groups))
3301 (gnus-group-remove-mark (setq group (pop groups)))
3303 (push group gnus-killed-list)
3304 (setq gnus-newsrc-alist
3305 (delq (assoc group gnus-newsrc-alist)
3307 (when gnus-group-change-level-function
3308 (funcall gnus-group-change-level-function
3309 group gnus-level-killed 3))
3311 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3312 (push (cons (car entry) (nth 2 entry))
3313 gnus-list-of-killed-groups)
3314 (setcdr (cdr entry) (cdddr entry)))
3315 ((member group gnus-zombie-list)
3316 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3317 ;; There may be more than one instance displayed.
3318 (while (gnus-group-goto-group group)
3319 (gnus-delete-line)))
3320 (gnus-make-hashtable-from-newsrc-alist)))
3322 (gnus-group-position-point)
3323 (if (< (length out) 2) (car out) (nreverse out))))
3325 (defun gnus-group-yank-group (&optional arg)
3326 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3327 The numeric ARG specifies how many newsgroups are to be yanked. The
3328 name of the newsgroup yanked is returned, or (if several groups are
3329 yanked) a list of yanked groups is returned."
3331 (setq arg (or arg 1))
3332 (let (info group prev out)
3333 (while (>= (decf arg) 0)
3334 (when (not (setq info (pop gnus-list-of-killed-groups)))
3335 (error "No more newsgroups to yank"))
3336 (push (setq group (nth 1 info)) out)
3337 ;; Find which newsgroup to insert this one before - search
3338 ;; backward until something suitable is found. If there are no
3339 ;; other newsgroups in this buffer, just make this newsgroup the
3341 (setq prev (gnus-group-group-name))
3342 (gnus-group-change-level
3343 info (gnus-info-level (cdr info)) gnus-level-killed
3344 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3346 (gnus-group-insert-group-line-info group)
3348 `(when (gnus-group-goto-group ,group)
3349 (gnus-group-kill-group 1))))
3351 (gnus-group-position-point)
3352 (if (< (length out) 2) (car out) (nreverse out))))
3354 (defun gnus-group-kill-level (level)
3355 "Kill all groups that is on a certain LEVEL."
3356 (interactive "nKill all groups on level: ")
3358 ((= level gnus-level-zombie)
3359 (setq gnus-killed-list
3360 (nconc gnus-zombie-list gnus-killed-list))
3361 (setq gnus-zombie-list nil))
3362 ((and (< level gnus-level-zombie)
3364 (or gnus-expert-user
3367 "Do you really want to kill all groups on level %d? "
3369 (let* ((prev gnus-newsrc-alist)
3372 (if (= (gnus-info-level (car alist)) level)
3374 (push (gnus-info-group (car alist)) gnus-killed-list)
3375 (setcdr prev (cdr alist)))
3377 (setq alist (cdr alist)))
3378 (gnus-make-hashtable-from-newsrc-alist)
3379 (gnus-group-list-groups)))
3381 (error "Can't kill; invalid level: %d" level))))
3383 (defun gnus-group-list-all-groups (&optional arg)
3384 "List all newsgroups with level ARG or lower.
3385 Default is gnus-level-unsubscribed, which lists all subscribed and most
3386 unsubscribed groups."
3388 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3390 ;; Redefine this to list ALL killed groups if prefix arg used.
3391 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3392 (defun gnus-group-list-killed (&optional arg)
3393 "List all killed newsgroups in the group buffer.
3394 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3395 entail asking the server for the groups."
3397 ;; Find all possible killed newsgroups if arg.
3399 (gnus-get-killed-groups))
3400 (if (not gnus-killed-list)
3401 (gnus-message 6 "No killed groups")
3402 (let (gnus-group-list-mode)
3403 (funcall gnus-group-prepare-function
3404 gnus-level-killed t gnus-level-killed))
3405 (goto-char (point-min)))
3406 (gnus-group-position-point))
3408 (defun gnus-group-list-zombies ()
3409 "List all zombie newsgroups in the group buffer."
3411 (if (not gnus-zombie-list)
3412 (gnus-message 6 "No zombie groups")
3413 (let (gnus-group-list-mode)
3414 (funcall gnus-group-prepare-function
3415 gnus-level-zombie t gnus-level-zombie))
3416 (goto-char (point-min)))
3417 (gnus-group-position-point))
3419 (defun gnus-group-list-active ()
3420 "List all groups that are available from the server(s)."
3422 ;; First we make sure that we have really read the active file.
3423 (unless (gnus-read-active-file-p)
3424 (let ((gnus-read-active-file t)
3425 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3426 (gnus-read-active-file)))
3427 ;; Find all groups and sort them.
3435 (push (symbol-name sym) list)))
3439 (buffer-read-only nil)
3443 (setq group (pop groups))
3444 (gnus-add-text-properties
3445 (point) (prog1 (1+ (point))
3447 (gnus-group-decoded-name group)
3449 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3451 'gnus-level (inline (gnus-group-level group)))))
3452 (goto-char (point-min))))
3454 (defun gnus-activate-all-groups (level)
3455 "Activate absolutely all groups."
3456 (interactive (list gnus-level-unsubscribed))
3457 (let ((gnus-activate-level level)
3458 (gnus-activate-foreign-newsgroups level))
3459 (gnus-group-get-new-news)))
3461 (defun gnus-group-get-new-news (&optional arg)
3462 "Get newly arrived articles.
3463 If ARG is a number, it specifies which levels you are interested in
3464 re-scanning. If ARG is non-nil and not a number, this will force
3465 \"hard\" re-reading of the active files from all servers."
3468 (let ((gnus-inhibit-demon t)
3469 ;; Binding this variable will inhibit multiple fetchings
3470 ;; of the same mail source.
3471 (nnmail-fetched-sources (list t)))
3472 (gnus-run-hooks 'gnus-get-new-news-hook)
3474 ;; Read any slave files.
3476 (gnus-master-read-slave-newsrc))
3478 ;; We might read in new NoCeM messages here.
3479 (when (and gnus-use-nocem
3481 (gnus-nocem-scan-groups))
3482 ;; If ARG is not a number, then we read the active file.
3483 (when (and arg (not (numberp arg)))
3484 (let ((gnus-read-active-file t))
3485 (gnus-read-active-file))
3488 ;; If the user wants it, we scan for new groups.
3489 (when (eq gnus-check-new-newsgroups 'always)
3490 (gnus-find-new-newsgroups)))
3492 (setq arg (gnus-group-default-level arg t))
3493 (if (and gnus-read-active-file (not arg))
3495 (gnus-read-active-file)
3496 (gnus-get-unread-articles arg))
3497 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3498 (gnus-get-unread-articles arg)))
3499 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3500 (gnus-group-list-groups (and (numberp arg)
3501 (max (car gnus-group-list-mode) arg))))
3503 (when (and gnus-agent (not (interactive-p)))
3504 (gnus-agent-toggle-plugged gnus-plugged)))
3506 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3507 "Check for newly arrived news in the current group (and the N-1 next groups).
3508 The difference between N and the number of newsgroup checked is returned.
3509 If N is negative, this group and the N-1 previous groups will be checked."
3511 (let* ((groups (gnus-group-process-prefix n))
3512 (ret (if (numberp n) (- n (length groups)) 0))
3516 (gnus-inhibit-demon t)
3517 ;; Binding this variable will inhibit multiple fetchings
3518 ;; of the same mail source.
3519 (nnmail-fetched-sources (list t)))
3520 (gnus-run-hooks 'gnus-get-new-news-hook)
3521 (while (setq group (pop groups))
3522 (gnus-group-remove-mark group)
3523 ;; Bypass any previous denials from the server.
3524 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3525 (if (gnus-activate-group group (if dont-scan nil 'scan))
3527 (gnus-get-unread-articles-in-group
3528 (gnus-get-info group) (gnus-active group) t)
3529 (unless (gnus-virtual-group-p group)
3530 (gnus-close-group group))
3532 (gnus-agent-save-group-info
3533 method (gnus-group-real-name group) (gnus-active group)))
3534 (gnus-group-update-group group))
3535 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3537 (gnus-error 3 "Server denied access")
3538 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3541 (when gnus-goto-next-group-when-activating
3542 (gnus-group-next-unread-group 1 t))
3543 (gnus-summary-position-point)
3546 (defun gnus-group-fetch-faq (group &optional faq-dir)
3547 "Fetch the FAQ for the current group.
3548 If given a prefix argument, prompt for the FAQ dir
3552 (gnus-group-group-name)
3553 (when current-prefix-arg
3555 "FAQ dir: " (and (listp gnus-group-faq-directory)
3557 gnus-group-faq-directory))))))
3559 (error "No group name given"))
3560 (let ((dirs (or faq-dir gnus-group-faq-directory))
3562 (unless (listp dirs)
3563 (setq dirs (list dirs)))
3564 (while (and (not found)
3565 (setq dir (pop dirs)))
3566 (let ((name (gnus-group-real-name group)))
3567 (setq file (expand-file-name name dir)))
3568 (if (not (file-exists-p file))
3569 (gnus-message 1 "No such file: %s" file)
3570 (let ((enable-local-variables nil))
3574 (defun gnus-group-fetch-charter (group)
3575 "Fetch the charter for the current group.
3576 If given a prefix argument, prompt for a group."
3578 (list (or (when current-prefix-arg
3579 (completing-read "Group: " gnus-active-hashtb))
3580 (gnus-group-group-name)
3581 gnus-newsgroup-name)))
3583 (error "No group name given"))
3585 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3587 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3588 (setq hierarchy (match-string 1 name))
3589 (if (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3590 (browse-url (eval url))
3591 (gnus-group-fetch-control group)))))
3593 (defun gnus-group-fetch-control (group)
3594 "Fetch the archived control messages for the current group.
3595 If given a prefix argument, prompt for a group."
3597 (list (or (when current-prefix-arg
3598 (completing-read "Group: " gnus-active-hashtb))
3599 (gnus-group-group-name)
3600 gnus-newsgroup-name)))
3602 (error "No group name given"))
3603 (let ((name (gnus-group-real-name group))
3605 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3606 (setq hierarchy (match-string 1 name))
3607 (if gnus-group-fetch-control-use-browse-url
3608 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3609 hierarchy "/" name ".Z"))
3610 (let ((enable-local-variables nil))
3611 (gnus-group-read-ephemeral-group
3613 `(nndoc ,group (nndoc-address
3614 ,(find-file-noselect
3615 (concat "/ftp@ftp.isc.org:/usenet/control/"
3616 hierarchy "/" name ".Z")))
3617 (nndoc-article-type mbox)) t nil nil))))))
3619 (defun gnus-group-describe-group (force &optional group)
3620 "Display a description of the current newsgroup."
3621 (interactive (list current-prefix-arg (gnus-group-group-name)))
3622 (let* ((method (gnus-find-method-for-group group))
3623 (mname (gnus-group-prefixed-name "" method))
3626 gnus-description-hashtb)
3627 (gnus-sethash mname nil gnus-description-hashtb))
3629 (error "No group name given"))
3630 (when (or (and gnus-description-hashtb
3631 ;; We check whether this group's method has been
3632 ;; queried for a description file.
3633 (gnus-gethash mname gnus-description-hashtb))
3634 (setq desc (gnus-group-get-description group))
3635 (gnus-read-descriptions-file method))
3637 (or desc (gnus-gethash group gnus-description-hashtb)
3638 "No description available")))))
3640 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3641 (defun gnus-group-describe-all-groups (&optional force)
3642 "Pop up a buffer with descriptions of all newsgroups."
3645 (setq gnus-description-hashtb nil))
3646 (when (not (or gnus-description-hashtb
3647 (gnus-read-all-descriptions-files)))
3648 (error "Couldn't request descriptions file"))
3649 (let ((buffer-read-only nil)
3655 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3656 (insert (format " *: %-20s %s\n"
3657 (gnus-group-name-decode
3658 (symbol-name group) charset)
3659 (gnus-group-name-decode
3660 (symbol-value group) charset))))
3661 (gnus-add-text-properties
3662 b (1+ b) (list 'gnus-group group
3663 'gnus-unread t 'gnus-marked nil
3664 'gnus-level (1+ gnus-level-subscribed))))
3665 gnus-description-hashtb)
3666 (goto-char (point-min))
3667 (gnus-group-position-point)))
3669 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3670 (defun gnus-group-apropos (regexp &optional search-description)
3671 "List all newsgroups that have names that match a regexp."
3672 (interactive "sGnus apropos (regexp): ")
3674 (obuf (current-buffer))
3676 ;; Go through all newsgroups that are known to Gnus.
3679 (and (symbol-name group)
3680 (string-match regexp (symbol-name group))
3681 (symbol-value group)
3682 (push (symbol-name group) groups)))
3684 ;; Also go through all descriptions that are known to Gnus.
3685 (when search-description
3688 (and (string-match regexp (symbol-value group))
3689 (push (symbol-name group) groups)))
3690 gnus-description-hashtb))
3692 (gnus-message 3 "No groups matched \"%s\"." regexp)
3693 ;; Print out all the groups.
3695 (pop-to-buffer "*Gnus Help*")
3696 (buffer-disable-undo)
3698 (setq groups (sort groups 'string<))
3700 ;; Groups may be entered twice into the list of groups.
3701 (when (not (string= (car groups) prev))
3702 (setq prev (car groups))
3703 (let ((charset (gnus-group-name-charset nil prev)))
3704 (insert (gnus-group-name-decode prev charset) "\n")
3705 (when (and gnus-description-hashtb
3706 (setq des (gnus-gethash (car groups)
3707 gnus-description-hashtb)))
3708 (insert " " (gnus-group-name-decode des charset) "\n"))))
3709 (setq groups (cdr groups)))
3710 (goto-char (point-min))))
3711 (pop-to-buffer obuf)))
3713 (defun gnus-group-description-apropos (regexp)
3714 "List all newsgroups that have names or descriptions that match a regexp."
3715 (interactive "sGnus description apropos (regexp): ")
3716 (when (not (or gnus-description-hashtb
3717 (gnus-read-all-descriptions-files)))
3718 (error "Couldn't request descriptions file"))
3719 (gnus-group-apropos regexp t))
3721 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3722 (defun gnus-group-list-matching (level regexp &optional all lowest)
3723 "List all groups with unread articles that match REGEXP.
3724 If the prefix LEVEL is non-nil, it should be a number that says which
3725 level to cut off listing groups.
3726 If ALL, also list groups with no unread articles.
3727 If LOWEST, don't list groups with level lower than LOWEST.
3729 This command may read the active file."
3730 (interactive "P\nsList newsgroups matching: ")
3731 ;; First make sure active file has been read.
3733 (> (prefix-numeric-value level) gnus-level-killed))
3734 (gnus-get-killed-groups))
3735 (funcall gnus-group-prepare-function
3736 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3737 (goto-char (point-min))
3738 (gnus-group-position-point))
3740 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3741 "List all groups that match REGEXP.
3742 If the prefix LEVEL is non-nil, it should be a number that says which
3743 level to cut off listing groups.
3744 If LOWEST, don't list groups with level lower than LOWEST."
3745 (interactive "P\nsList newsgroups matching: ")
3747 (setq level (prefix-numeric-value level)))
3748 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3750 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3751 (defun gnus-group-save-newsrc (&optional force)
3752 "Save the Gnus startup files.
3753 If FORCE, force saving whether it is necessary or not."
3755 (gnus-save-newsrc-file force))
3757 (defun gnus-group-restart (&optional arg)
3758 "Force Gnus to read the .newsrc file."
3760 (when (gnus-yes-or-no-p
3761 (format "Are you sure you want to restart Gnus? "))
3762 (gnus-save-newsrc-file)
3766 (defun gnus-group-read-init-file ()
3767 "Read the Gnus elisp init file."
3769 (gnus-read-init-file)
3770 (gnus-message 5 "Read %s" gnus-init-file))
3772 (defun gnus-group-check-bogus-groups (&optional silent)
3773 "Check bogus newsgroups.
3774 If given a prefix, don't ask for confirmation before removing a bogus
3777 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3778 (gnus-group-list-groups))
3780 (defun gnus-group-find-new-groups (&optional arg)
3781 "Search for new groups and add them.
3782 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3783 With 1 C-u, use the `ask-server' method to query the server for new
3785 With 2 C-u's, use most complete method possible to query the server
3786 for new groups, and subscribe the new groups as zombies."
3788 (gnus-find-new-newsgroups (or arg 1))
3789 (gnus-group-list-groups))
3791 (defun gnus-group-edit-global-kill (&optional article group)
3792 "Edit the global kill file.
3793 If GROUP, edit that local kill file instead."
3795 (setq gnus-current-kill-article article)
3796 (gnus-kill-file-edit-file group)
3799 (substitute-command-keys
3800 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3801 (if group "local" "global")))))
3803 (defun gnus-group-edit-local-kill (article group)
3804 "Edit a local kill file."
3805 (interactive (list nil (gnus-group-group-name)))
3806 (gnus-group-edit-global-kill article group))
3808 (defun gnus-group-force-update ()
3809 "Update `.newsrc' file."
3811 (gnus-save-newsrc-file))
3813 (defun gnus-group-suspend ()
3814 "Suspend the current Gnus session.
3815 In fact, cleanup buffers except for group mode buffer.
3816 The hook gnus-suspend-gnus-hook is called before actually suspending."
3818 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3819 (gnus-offer-save-summaries)
3820 ;; Kill Gnus buffers except for group mode buffer.
3821 (let ((group-buf (get-buffer gnus-group-buffer)))
3822 (mapcar (lambda (buf)
3823 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3827 (eq major-mode 'message-mode))))
3828 (gnus-kill-buffer buf)))
3830 (gnus-kill-gnus-frames)
3832 (bury-buffer group-buf)
3833 (delete-windows-on group-buf t))))
3835 (defun gnus-group-clear-dribble ()
3836 "Clear all information from the dribble buffer."
3838 (gnus-dribble-clear)
3839 (gnus-message 7 "Cleared dribble buffer"))
3841 (defun gnus-group-exit ()
3842 "Quit reading news after updating .newsrc.eld and .newsrc.
3843 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3846 (or noninteractive ;For gnus-batch-kill
3847 (not gnus-interactive-exit) ;Without confirmation
3849 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3850 (gnus-run-hooks 'gnus-exit-gnus-hook)
3851 ;; Offer to save data from non-quitted summary buffers.
3852 (gnus-offer-save-summaries)
3853 ;; Save the newsrc file(s).
3854 (gnus-save-newsrc-file)
3856 (gnus-close-backends)
3857 ;; Reset everything.
3859 ;; Allow the user to do things after cleaning up.
3860 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3862 (defun gnus-group-quit ()
3863 "Quit reading news without updating .newsrc.eld or .newsrc.
3864 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3866 (when (or noninteractive ;For gnus-batch-kill
3867 (zerop (buffer-size))
3868 (not (gnus-server-opened gnus-select-method))
3870 (not gnus-current-startup-file)
3872 (format "Quit reading news without saving %s? "
3873 (file-name-nondirectory gnus-current-startup-file))))
3874 (gnus-run-hooks 'gnus-exit-gnus-hook)
3875 (gnus-configure-windows 'group t)
3876 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3877 (not (zerop (save-excursion
3878 (set-buffer gnus-dribble-buffer)
3881 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3883 (gnus-close-backends)
3885 (gnus-kill-buffer gnus-group-buffer)
3886 ;; Allow the user to do things after cleaning up.
3887 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3889 (defun gnus-group-describe-briefly ()
3890 "Give a one line description of the group mode commands."
3892 (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")))
3894 (defun gnus-group-browse-foreign-server (method)
3895 "Browse a foreign news server.
3896 If called interactively, this function will ask for a select method
3897 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3898 If not, METHOD should be a list where the first element is the method
3899 and the second element is the address."
3901 (list (let ((how (completing-read
3903 (append gnus-valid-select-methods gnus-server-alist)
3904 nil t (cons "nntp" 0) 'gnus-method-history)))
3905 ;; We either got a backend name or a virtual server name.
3906 ;; If the first, we also need an address.
3907 (if (assoc how gnus-valid-select-methods)
3909 ;; Suggested by mapjph@bath.ac.uk.
3912 (mapcar (lambda (server) (list server))
3913 gnus-secondary-servers)))
3914 ;; We got a server name.
3916 (gnus-browse-foreign-server method))
3918 (defun gnus-group-set-info (info &optional method-only-group part)
3919 (when (or info part)
3920 (let* ((entry (gnus-gethash
3921 (or method-only-group (gnus-info-group info))
3922 gnus-newsrc-hashtb))
3924 (info (if method-only-group (nth 2 entry) info))
3926 (when method-only-group
3928 (error "Trying to change non-existent group %s" method-only-group))
3929 ;; We have received parts of the actual group info - either the
3930 ;; select method or the group parameters. We first check
3931 ;; whether we have to extend the info, and if so, do that.
3932 (let ((len (length info))
3933 (total (if (eq part 'method) 5 6)))
3935 (setcdr (nthcdr (1- len) info)
3936 (make-list (- total len) nil)))
3937 ;; Then we enter the new info.
3938 (setcar (nthcdr (1- total) info) part-info)))
3940 ;; This is a new group, so we just create it.
3942 (set-buffer gnus-group-buffer)
3943 (setq method (gnus-info-method info))
3944 (when (gnus-server-equal method "native")
3947 (set-buffer gnus-group-buffer)
3949 ;; It's a foreign group...
3950 (gnus-group-make-group
3951 (gnus-group-real-name (gnus-info-group info))
3952 (if (stringp method) method
3953 (prin1-to-string (car method)))
3955 (nth 1 (gnus-info-method info))))
3956 ;; It's a native group.
3957 (gnus-group-make-group (gnus-info-group info))))
3958 (gnus-message 6 "Note: New group created")
3960 (gnus-gethash (gnus-group-prefixed-name
3961 (gnus-group-real-name (gnus-info-group info))
3962 (or (gnus-info-method info) gnus-select-method))
3963 gnus-newsrc-hashtb))))
3964 ;; Whether it was a new group or not, we now have the entry, so we
3965 ;; can do the update.
3968 (setcar (nthcdr 2 entry) info)
3969 (when (and (not (eq (car entry) t))
3970 (gnus-active (gnus-info-group info)))
3971 (setcar entry (length
3972 (gnus-list-of-unread-articles (car info))))))
3973 (error "No such group: %s" (gnus-info-group info))))))
3975 (defun gnus-group-set-method-info (group select-method)
3976 (gnus-group-set-info select-method group 'method))
3978 (defun gnus-group-set-params-info (group params)
3979 (gnus-group-set-info params group 'params))
3981 (defun gnus-add-marked-articles (group type articles &optional info force)
3982 ;; Add ARTICLES of TYPE to the info of GROUP.
3983 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3984 ;; add, but replace marked articles of TYPE with ARTICLES.
3985 (let ((info (or info (gnus-get-info group)))
3988 (and (not (setq marked (nthcdr 3 info)))
3990 (setcdr (nthcdr 2 info)
3991 (list (list (cons type (gnus-compress-sequence
3993 (and (not (setq m (assq type (car marked))))
3996 (cons (cons type (gnus-compress-sequence articles t) )
4000 (setcar (nthcdr 3 info)
4001 (gnus-delete-alist type (car marked)))
4002 (setcdr m (gnus-compress-sequence articles t)))
4003 (setcdr m (gnus-compress-sequence
4004 (sort (nconc (gnus-uncompress-range (cdr m))
4005 (copy-sequence articles)) '<) t))))))
4007 (defun gnus-add-mark (group mark article)
4008 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4009 (let ((buffer (gnus-summary-buffer-name group)))
4010 (if (gnus-buffer-live-p buffer)
4012 (set-buffer (get-buffer buffer))
4013 (gnus-summary-add-mark article mark))
4014 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4018 ;;; Group timestamps
4021 (defun gnus-group-set-timestamp ()
4022 "Change the timestamp of the current group to the current time.
4023 This function can be used in hooks like `gnus-select-group-hook'
4024 or `gnus-group-catchup-group-hook'."
4025 (when gnus-newsgroup-name
4026 (let ((time (current-time)))
4027 (setcdr (cdr time) nil)
4028 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4030 (defsubst gnus-group-timestamp (group)
4031 "Return the timestamp for GROUP."
4032 (gnus-group-get-parameter group 'timestamp t))
4034 (defun gnus-group-timestamp-delta (group)
4035 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4036 (let* ((time (or (gnus-group-timestamp group)
4038 (delta (subtract-time (current-time) time)))
4039 (+ (* (nth 0 delta) 65536.0)
4042 (defun gnus-group-timestamp-string (group)
4043 "Return a string of the timestamp for GROUP."
4044 (let ((time (gnus-group-timestamp group)))
4047 (gnus-time-iso8601 time))))
4049 (defun gnus-group-list-cached (level &optional lowest)
4050 "List all groups with cached articles.
4051 If the prefix LEVEL is non-nil, it should be a number that says which
4052 level to cut off listing groups.
4053 If LOWEST, don't list groups with level lower than LOWEST.
4055 This command may read the active file."
4058 (setq level (prefix-numeric-value level)))
4059 (when (or (not level) (>= level gnus-level-zombie))
4061 (funcall gnus-group-prepare-function
4062 (or level gnus-level-subscribed)
4064 (let ((marks (gnus-info-marks info)))
4065 (assq 'cache marks)))
4068 (or (gnus-gethash group
4069 gnus-cache-active-hashtb)
4070 ;; Cache active file might use "."
4073 (mapconcat 'identity
4074 (split-string group ":")
4076 gnus-cache-active-hashtb))))
4077 (goto-char (point-min))
4078 (gnus-group-position-point))
4080 (defun gnus-group-list-dormant (level &optional lowest)
4081 "List all groups with dormant articles.
4082 If the prefix LEVEL is non-nil, it should be a number that says which
4083 level to cut off listing groups.
4084 If LOWEST, don't list groups with level lower than LOWEST.
4086 This command may read the active file."
4089 (setq level (prefix-numeric-value level)))
4090 (when (or (not level) (>= level gnus-level-zombie))
4092 (funcall gnus-group-prepare-function
4093 (or level gnus-level-subscribed)
4095 (let ((marks (gnus-info-marks info)))
4096 (assq 'dormant marks)))
4099 (goto-char (point-min))
4100 (gnus-group-position-point))
4102 (defun gnus-group-listed-groups ()
4103 "Return a list of listed groups."
4105 (goto-char (point-min))
4106 (while (setq point (text-property-not-all (point) (point-max)
4109 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4113 (defun gnus-group-list-plus (&optional args)
4114 "List groups plus the current selection."
4116 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4117 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4119 (push last-command-event unread-command-events)
4120 (if (featurep 'xemacs)
4121 (push (make-event 'key-press '(key ?A)) unread-command-events)
4122 (push ?A unread-command-events))
4123 (let (gnus-pick-mode keys)
4124 (setq keys (if (featurep 'xemacs)
4125 (events-to-keys (read-key-sequence nil))
4126 (read-key-sequence nil)))
4127 (setq func (lookup-key (current-local-map) keys)))
4131 (call-interactively func))))
4133 (defun gnus-group-list-flush (&optional args)
4134 "Flush groups from the current selection."
4136 (let ((gnus-group-list-option 'flush))
4137 (gnus-group-list-plus args)))
4139 (defun gnus-group-list-limit (&optional args)
4140 "List groups limited within the current selection."
4142 (let ((gnus-group-list-option 'limit))
4143 (gnus-group-list-plus args)))
4145 (defun gnus-group-mark-article-read (group article)
4146 "Mark ARTICLE read."
4147 (let ((buffer (gnus-summary-buffer-name group))
4148 (mark gnus-read-mark)
4150 (if (get-buffer buffer)
4151 (with-current-buffer buffer
4152 (setq active gnus-newsgroup-active)
4153 (gnus-activate-group group)
4154 (when gnus-newsgroup-prepared
4155 (when (and gnus-newsgroup-auto-expire
4156 (memq mark gnus-auto-expirable-marks))
4157 (setq mark gnus-expirable-mark))
4158 (setq mark (gnus-request-update-mark
4159 group article mark))
4160 (gnus-mark-article-as-read article mark)
4161 (setq gnus-newsgroup-active (gnus-active group))
4163 (setq n (1+ (cdr active)))
4164 (while (<= n (cdr gnus-newsgroup-active))
4165 (unless (eq n article)
4166 (push n gnus-newsgroup-unselected))
4168 (setq gnus-newsgroup-unselected
4169 (nreverse gnus-newsgroup-unselected)))))
4170 (gnus-activate-group group)
4171 (gnus-group-make-articles-read group
4173 (when (gnus-group-auto-expirable-p group)
4174 (gnus-add-marked-articles
4175 group 'expire (list article))))))
4177 (provide 'gnus-group)
4179 ;;; gnus-group.el ends here