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))
43 (defcustom gnus-group-archive-directory
44 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
45 "*The address of the (ding) archives."
46 :group 'gnus-group-foreign
49 (defcustom gnus-group-recent-archive-directory
50 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
51 "*The address of the most recent (ding) articles."
52 :group 'gnus-group-foreign
55 (defcustom gnus-no-groups-message "No gnus is bad news"
56 "*Message displayed by Gnus when no groups are available."
60 (defcustom gnus-keep-same-level nil
61 "*Non-nil means that the next newsgroup after the current will be on the same level.
62 When you type, for instance, `n' after reading the last article in the
63 current newsgroup, you will go to the next newsgroup. If this variable
64 is nil, the next newsgroup will be the next from the group
66 If this variable is non-nil, Gnus will either put you in the
67 next newsgroup with the same level, or, if no such newsgroup is
68 available, the next newsgroup with the lowest possible level higher
69 than the current level.
70 If this variable is `best', Gnus will make the next newsgroup the one
72 :group 'gnus-group-levels
73 :type '(choice (const nil)
75 (sexp :tag "other" t)))
77 (defcustom gnus-group-goto-unread t
78 "*If non-nil, movement commands will go to the next unread and subscribed group."
79 :link '(custom-manual "(gnus)Group Maneuvering")
80 :group 'gnus-group-various
83 (defcustom gnus-goto-next-group-when-activating t
84 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
85 :link '(custom-manual "(gnus)Scanning New Messages")
86 :group 'gnus-group-various
89 (defcustom gnus-permanently-visible-groups nil
90 "*Regexp to match groups that should always be listed in the group buffer.
91 This means that they will still be listed even when there are no
92 unread articles in the groups.
94 If nil, no groups are permanently visible."
95 :group 'gnus-group-listing
96 :type '(choice regexp (const nil)))
98 (defcustom gnus-list-groups-with-ticked-articles t
99 "*If non-nil, list groups that have only ticked articles.
100 If nil, only list groups that have unread articles."
101 :group 'gnus-group-listing
104 (defcustom gnus-group-default-list-level gnus-level-subscribed
105 "*Default listing level.
106 Ignored if `gnus-group-use-permanent-levels' is non-nil."
107 :group 'gnus-group-listing
110 (defcustom gnus-group-list-inactive-groups t
111 "*If non-nil, inactive groups will be listed."
112 :group 'gnus-group-listing
113 :group 'gnus-group-levels
116 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
117 "*Function used for sorting the group buffer.
118 This function will be called with group info entries as the arguments
119 for the groups to be sorted. Pre-made functions include
120 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
121 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
122 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
123 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
125 This variable can also be a list of sorting functions. In that case,
126 the most significant sort function should be the last function in the
128 :group 'gnus-group-listing
129 :link '(custom-manual "(gnus)Sorting Groups")
130 :type '(repeat :value-to-internal (lambda (widget value)
131 (if (listp value) value (list value)))
132 :match (lambda (widget value)
134 (widget-editable-list-match widget value)))
135 (choice (function-item gnus-group-sort-by-alphabet)
136 (function-item gnus-group-sort-by-real-name)
137 (function-item gnus-group-sort-by-unread)
138 (function-item gnus-group-sort-by-level)
139 (function-item gnus-group-sort-by-score)
140 (function-item gnus-group-sort-by-method)
141 (function-item gnus-group-sort-by-server)
142 (function-item gnus-group-sort-by-rank)
143 (function :tag "other" nil))))
145 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l %O\n"
146 "*Format of group lines.
147 It works along the same lines as a normal formatting string,
148 with some simple extensions.
150 %M Only marked articles (character, \"*\" or \" \")
151 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
152 %L Level of subscribedness (integer)
153 %N Number of unread articles (integer)
154 %I Number of dormant articles (integer)
155 %i Number of ticked and dormant (integer)
156 %T Number of ticked articles (integer)
157 %R Number of read articles (integer)
158 %t Estimated total number of articles (integer)
159 %y Number of unread, unticked articles (integer)
160 %G Group name (string)
161 %g Qualified group name (string)
162 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
163 %C Group comment (string)
164 %D Group description (string)
165 %s Select method (string)
166 %o Moderated group (char, \"m\")
167 %p Process mark (char)
168 %O Moderated group (string, \"(m)\" or \"\")
169 %P Topic indentation (string)
170 %m Whether there is new(ish) mail in the group (char, \"%\")
171 %l Whether there are GroupLens predictions for this group (string)
172 %n Select from where (string)
173 %z A string that look like `<%s:%n>' if a foreign select method is used
174 %d The date the group was last entered.
175 %E Icon as defined by `gnus-group-icon-list'.
176 %u User defined specifier. The next character in the format string should
177 be a letter. Gnus will call the function gnus-user-format-function-X,
178 where X is the letter following %u. The function will be passed a
179 single dummy parameter as argument.. The function should return a
180 string, which will be inserted into the buffer just like information
181 from any other group specifier.
183 Note that this format specification is not always respected. For
184 reasons of efficiency, when listing killed groups, this specification
185 is ignored altogether. If the spec is changed considerably, your
186 output may end up looking strange when listing both alive and killed
189 If you use %o or %O, reading the active file will be slower and quite
190 a bit of extra memory will be used. %D will also worsen performance.
191 Also note that if you change the format specification to include any
192 of these specs, you must probably re-start Gnus to see them go into
195 General format specifiers can also be used.
196 See `(gnus)Formatting Variables'."
197 :link '(custom-manual "(gnus)Formatting Variables")
198 :group 'gnus-group-visual
201 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
202 "*The format specification for the group mode line.
203 It works along the same lines as a normal formatting string,
204 with some simple extensions:
206 %S The native news server.
207 %M The native select method.
208 %: \":\" if %S isn't \"\"."
209 :group 'gnus-group-visual
212 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
213 (when (featurep 'xemacs)
214 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
215 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
217 (defcustom gnus-group-menu-hook nil
218 "Hook run after the creation of the group mode menu."
219 :group 'gnus-group-various
222 (defcustom gnus-group-catchup-group-hook nil
223 "Hook run when catching up a group from the group buffer."
224 :group 'gnus-group-various
225 :link '(custom-manual "(gnus)Group Data")
228 (defcustom gnus-group-update-group-hook nil
229 "Hook called when updating group lines."
230 :group 'gnus-group-visual
233 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
234 "*A function that is called to generate the group buffer.
235 The function is called with three arguments: The first is a number;
236 all group with a level less or equal to that number should be listed,
237 if the second is non-nil, empty groups should also be displayed. If
238 the third is non-nil, it is a number. No groups with a level lower
239 than this number should be displayed.
241 The only current function implemented is `gnus-group-prepare-flat'."
242 :group 'gnus-group-listing
245 (defcustom gnus-group-prepare-hook nil
246 "Hook called after the group buffer has been generated.
247 If you want to modify the group buffer, you can use this hook."
248 :group 'gnus-group-listing
251 (defcustom gnus-suspend-gnus-hook nil
252 "Hook called when suspending (not exiting) Gnus."
256 (defcustom gnus-exit-gnus-hook nil
257 "Hook called when exiting Gnus."
261 (defcustom gnus-after-exiting-gnus-hook nil
262 "Hook called after exiting Gnus."
266 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
267 "Hook called when a group line is changed.
268 The hook will not be called if `gnus-visual' is nil.
270 The default function `gnus-group-highlight-line' will
271 highlight the line according to the `gnus-group-highlight'
273 :group 'gnus-group-visual
276 (defcustom gnus-useful-groups
277 '(("(ding) mailing list mirrored at sunsite.auc.dk"
279 (nntp "sunsite.auc.dk"
280 (nntp-address "sunsite.auc.dk")))
283 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
287 (nndoc-article-type mbox)
288 (eval `(nndoc-address
289 ,(let ((file (nnheader-find-etc-directory
292 (error "Couldn't find doc group"))
294 "*Alist of useful group-server pairs."
295 :group 'gnus-group-listing
296 :type '(repeat (list (string :tag "Description")
298 (sexp :tag "Method"))))
300 (defcustom gnus-group-highlight
302 ((and mailp (= unread 0) (eq level 1)) .
303 gnus-group-mail-1-empty-face)
304 ((and mailp (eq level 1)) .
305 gnus-group-mail-1-face)
306 ((and mailp (= unread 0) (eq level 2)) .
307 gnus-group-mail-2-empty-face)
308 ((and mailp (eq level 2)) .
309 gnus-group-mail-2-face)
310 ((and mailp (= unread 0) (eq level 3)) .
311 gnus-group-mail-3-empty-face)
312 ((and mailp (eq level 3)) .
313 gnus-group-mail-3-face)
314 ((and mailp (= unread 0)) .
315 gnus-group-mail-low-empty-face)
317 gnus-group-mail-low-face)
319 ((and (= unread 0) (eq level 1)) .
320 gnus-group-news-1-empty-face)
321 ((and (eq level 1)) .
322 gnus-group-news-1-face)
323 ((and (= unread 0) (eq level 2)) .
324 gnus-group-news-2-empty-face)
325 ((and (eq level 2)) .
326 gnus-group-news-2-face)
327 ((and (= unread 0) (eq level 3)) .
328 gnus-group-news-3-empty-face)
329 ((and (eq level 3)) .
330 gnus-group-news-3-face)
331 ((and (= unread 0) (eq level 4)) .
332 gnus-group-news-4-empty-face)
333 ((and (eq level 4)) .
334 gnus-group-news-4-face)
335 ((and (= unread 0) (eq level 5)) .
336 gnus-group-news-5-empty-face)
337 ((and (eq level 5)) .
338 gnus-group-news-5-face)
339 ((and (= unread 0) (eq level 6)) .
340 gnus-group-news-6-empty-face)
341 ((and (eq level 6)) .
342 gnus-group-news-6-face)
343 ((and (= unread 0)) .
344 gnus-group-news-low-empty-face)
346 gnus-group-news-low-face))
347 "*Controls the highlighting of group buffer lines.
349 Below is a list of `Form'/`Face' pairs. When deciding how a a
350 particular group line should be displayed, each form is
351 evaluated. The content of the face field after the first true form is
352 used. You can change how those group lines are displayed by
353 editing the face field.
355 It is also possible to change and add form fields, but currently that
356 requires an understanding of Lisp expressions. Hopefully this will
357 change in a future release. For now, you can use the following
358 variables in the Lisp expression:
360 group: The name of the group.
361 unread: The number of unread articles in the group.
362 method: The select method used.
363 mailp: Whether it's a mail group or not.
364 level: The level of the group.
365 score: The score of the group.
366 ticked: The number of ticked articles."
367 :group 'gnus-group-visual
368 :type '(repeat (cons (sexp :tag "Form") face)))
370 (defcustom gnus-new-mail-mark ?%
371 "Mark used for groups with new mail."
372 :group 'gnus-group-visual
375 (defgroup gnus-group-icons nil
376 "Add Icons to your group buffer. "
377 :group 'gnus-group-visual)
379 (defcustom gnus-group-icon-list
381 "*Controls the insertion of icons into group buffer lines.
383 Below is a list of `Form'/`File' pairs. When deciding how a
384 particular group line should be displayed, each form is evaluated.
385 The icon from the file field after the first true form is used. You
386 can change how those group lines are displayed by editing the file
387 field. The File will either be found in the
388 `gnus-group-glyph-directory' or by designating absolute path to the
391 It is also possible to change and add form fields, but currently that
392 requires an understanding of Lisp expressions. Hopefully this will
393 change in a future release. For now, you can use the following
394 variables in the Lisp expression:
396 group: The name of the group.
397 unread: The number of unread articles in the group.
398 method: The select method used.
399 mailp: Whether it's a mail group or not.
400 newsp: Whether it's a news group or not
401 level: The level of the group.
402 score: The score of the group.
403 ticked: The number of ticked articles."
404 :group 'gnus-group-icons
405 :type '(repeat (cons (sexp :tag "Form") file)))
407 (defcustom gnus-group-name-charset-method-alist nil
408 "Alist of method and the charset for group names.
411 (((nntp \"news.com.cn\") . cn-gb-2312))"
414 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
416 (defcustom gnus-group-name-charset-group-alist
417 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
418 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
421 "Alist of group regexp and the charset for group names.
424 ((\"\\.com\\.cn:\" . cn-gb-2312))"
426 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
428 (defcustom gnus-group-jump-to-group-prompt nil
429 "Default prompt for `gnus-group-jump-to-group'.
430 If non-nil, the value should be a string, e.g. \"nnml:\",
431 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
432 in the minibuffer prompt."
433 :group 'gnus-group-various
434 :type '(choice (string :tag "Prompt string")
435 (const :tag "Empty" nil)))
437 (defvar gnus-group-listing-limit 1000
438 "*A limit of the number of groups when listing.
439 If the number of groups is larger than the limit, list them in a
442 ;;; Internal variables
444 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
445 "Function for sorting the group buffer.")
447 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
448 "Function for sorting the selected groups in the group buffer.")
450 (defvar gnus-group-indentation-function nil)
451 (defvar gnus-goto-missing-group-function nil)
452 (defvar gnus-group-update-group-function nil)
453 (defvar gnus-group-goto-next-group-function nil
454 "Function to override finding the next group after listing groups.")
456 (defvar gnus-group-edit-buffer nil)
458 (defvar gnus-group-line-format-alist
459 `((?M gnus-tmp-marked-mark ?c)
460 (?S gnus-tmp-subscribed ?c)
461 (?L gnus-tmp-level ?d)
462 (?N (cond ((eq number t) "*" )
466 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
467 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
469 (?R gnus-tmp-number-of-read ?s)
470 (?t gnus-tmp-number-total ?d)
471 (?y gnus-tmp-number-of-unread ?s)
472 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
473 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
474 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
475 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
476 (?g gnus-tmp-group ?s)
477 (?G gnus-tmp-qualified-group ?s)
478 (?c (gnus-short-group-name gnus-tmp-group) ?s)
479 (?C gnus-tmp-comment ?s)
480 (?D gnus-tmp-newsgroup-description ?s)
481 (?o gnus-tmp-moderated ?c)
482 (?O gnus-tmp-moderated-string ?s)
483 (?p gnus-tmp-process-marked ?c)
484 (?s gnus-tmp-news-server ?s)
485 (?n gnus-tmp-news-method ?s)
486 (?P gnus-group-indentation ?s)
487 (?E gnus-tmp-group-icon ?s)
488 (?l gnus-tmp-grouplens ?s)
489 (?z gnus-tmp-news-method-string ?s)
490 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
491 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
492 (?u gnus-tmp-user-defined ?s)))
494 (defvar gnus-group-mode-line-format-alist
495 `((?S gnus-tmp-news-server ?s)
496 (?M gnus-tmp-news-method ?s)
497 (?u gnus-tmp-user-defined ?s)
498 (?: gnus-tmp-colon ?s)))
500 (defvar gnus-topic-topology nil
501 "The complete topic hierarchy.")
503 (defvar gnus-topic-alist nil
504 "The complete topic-group alist.")
506 (defvar gnus-group-marked nil)
508 (defvar gnus-group-list-mode nil)
511 (defvar gnus-group-icon-cache nil)
513 (defvar gnus-group-listed-groups nil)
514 (defvar gnus-group-list-option nil)
520 (put 'gnus-group-mode 'mode-class 'special)
523 (gnus-define-keys gnus-group-mode-map
524 " " gnus-group-read-group
525 "=" gnus-group-select-group
526 "\r" gnus-group-select-group
527 "\M-\r" gnus-group-quick-select-group
528 "\M- " gnus-group-visible-select-group
529 [(meta control return)] gnus-group-select-group-ephemerally
530 "j" gnus-group-jump-to-group
531 "n" gnus-group-next-unread-group
532 "p" gnus-group-prev-unread-group
533 "\177" gnus-group-prev-unread-group
534 [delete] gnus-group-prev-unread-group
535 [backspace] gnus-group-prev-unread-group
536 "N" gnus-group-next-group
537 "P" gnus-group-prev-group
538 "\M-n" gnus-group-next-unread-group-same-level
539 "\M-p" gnus-group-prev-unread-group-same-level
540 "," gnus-group-best-unread-group
541 "." gnus-group-first-unread-group
542 "u" gnus-group-unsubscribe-current-group
543 "U" gnus-group-unsubscribe-group
544 "c" gnus-group-catchup-current
545 "C" gnus-group-catchup-current-all
546 "\M-c" gnus-group-clear-data
547 "l" gnus-group-list-groups
548 "L" gnus-group-list-all-groups
551 "g" gnus-group-get-new-news
552 "\M-g" gnus-group-get-new-news-this-group
553 "R" gnus-group-restart
554 "r" gnus-group-read-init-file
555 "B" gnus-group-browse-foreign-server
556 "b" gnus-group-check-bogus-groups
557 "F" gnus-group-find-new-groups
558 "\C-c\C-d" gnus-group-describe-group
559 "\M-d" gnus-group-describe-all-groups
560 "\C-c\C-a" gnus-group-apropos
561 "\C-c\M-\C-a" gnus-group-description-apropos
562 "a" gnus-group-post-news
563 "\ek" gnus-group-edit-local-kill
564 "\eK" gnus-group-edit-global-kill
565 "\C-k" gnus-group-kill-group
566 "\C-y" gnus-group-yank-group
567 "\C-w" gnus-group-kill-region
568 "\C-x\C-t" gnus-group-transpose-groups
569 "\C-c\C-l" gnus-group-list-killed
570 "\C-c\C-x" gnus-group-expire-articles
571 "\C-c\M-\C-x" gnus-group-expire-all-groups
573 "s" gnus-group-save-newsrc
574 "z" gnus-group-suspend
577 "?" gnus-group-describe-briefly
578 "\C-c\C-i" gnus-info-find-node
579 "\M-e" gnus-group-edit-group-method
580 "^" gnus-group-enter-server-mode
581 gnus-mouse-2 gnus-mouse-pick-group
582 "<" beginning-of-buffer
585 "\C-c\C-s" gnus-group-sort-groups
587 "\C-c\M-g" gnus-activate-all-groups
588 "\M-&" gnus-group-universal-argument
589 "#" gnus-group-mark-group
590 "\M-#" gnus-group-unmark-group)
592 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
593 "m" gnus-group-mark-group
594 "u" gnus-group-unmark-group
595 "w" gnus-group-mark-region
596 "b" gnus-group-mark-buffer
597 "r" gnus-group-mark-regexp
598 "U" gnus-group-unmark-all-groups)
600 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
601 "u" gnus-sieve-update
602 "g" gnus-sieve-generate)
604 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
605 "d" gnus-group-make-directory-group
606 "h" gnus-group-make-help-group
607 "u" gnus-group-make-useful-group
608 "a" gnus-group-make-archive-group
609 "k" gnus-group-make-kiboze-group
610 "l" gnus-group-nnimap-edit-acl
611 "m" gnus-group-make-group
612 "E" gnus-group-edit-group
613 "e" gnus-group-edit-group-method
614 "p" gnus-group-edit-group-parameters
615 "v" gnus-group-add-to-virtual
616 "V" gnus-group-make-empty-virtual
617 "D" gnus-group-enter-directory
618 "f" gnus-group-make-doc-group
619 "w" gnus-group-make-web-group
620 "r" gnus-group-rename-group
621 "c" gnus-group-customize
622 "x" gnus-group-nnimap-expunge
623 "\177" gnus-group-delete-group
624 [delete] gnus-group-delete-group)
626 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
627 "b" gnus-group-brew-soup
628 "w" gnus-soup-save-areas
629 "s" gnus-soup-send-replies
630 "p" gnus-soup-pack-packet
631 "r" nnsoup-pack-replies)
633 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
634 "s" gnus-group-sort-groups
635 "a" gnus-group-sort-groups-by-alphabet
636 "u" gnus-group-sort-groups-by-unread
637 "l" gnus-group-sort-groups-by-level
638 "v" gnus-group-sort-groups-by-score
639 "r" gnus-group-sort-groups-by-rank
640 "m" gnus-group-sort-groups-by-method)
642 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
643 "s" gnus-group-sort-selected-groups
644 "a" gnus-group-sort-selected-groups-by-alphabet
645 "u" gnus-group-sort-selected-groups-by-unread
646 "l" gnus-group-sort-selected-groups-by-level
647 "v" gnus-group-sort-selected-groups-by-score
648 "r" gnus-group-sort-selected-groups-by-rank
649 "m" gnus-group-sort-selected-groups-by-method)
651 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
652 "k" gnus-group-list-killed
653 "z" gnus-group-list-zombies
654 "s" gnus-group-list-groups
655 "u" gnus-group-list-all-groups
656 "A" gnus-group-list-active
657 "a" gnus-group-apropos
658 "d" gnus-group-description-apropos
659 "m" gnus-group-list-matching
660 "M" gnus-group-list-all-matching
661 "l" gnus-group-list-level
662 "c" gnus-group-list-cached
663 "?" gnus-group-list-dormant)
665 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
666 "k" gnus-group-list-limit
667 "z" gnus-group-list-limit
668 "s" gnus-group-list-limit
669 "u" gnus-group-list-limit
670 "A" gnus-group-list-limit
671 "m" gnus-group-list-limit
672 "M" gnus-group-list-limit
673 "l" gnus-group-list-limit
674 "c" gnus-group-list-limit
675 "?" gnus-group-list-limit)
677 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
678 "k" gnus-group-list-flush
679 "z" gnus-group-list-flush
680 "s" gnus-group-list-flush
681 "u" gnus-group-list-flush
682 "A" gnus-group-list-flush
683 "m" gnus-group-list-flush
684 "M" gnus-group-list-flush
685 "l" gnus-group-list-flush
686 "c" gnus-group-list-flush
687 "?" gnus-group-list-flush)
689 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
690 "k" gnus-group-list-plus
691 "z" gnus-group-list-plus
692 "s" gnus-group-list-plus
693 "u" gnus-group-list-plus
694 "A" gnus-group-list-plus
695 "m" gnus-group-list-plus
696 "M" gnus-group-list-plus
697 "l" gnus-group-list-plus
698 "c" gnus-group-list-plus
699 "?" gnus-group-list-plus)
701 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
702 "f" gnus-score-flush-cache)
704 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
705 "c" gnus-group-fetch-charter
706 "C" gnus-group-fetch-control
707 "d" gnus-group-describe-group
708 "f" gnus-group-fetch-faq
711 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
712 "l" gnus-group-set-current-level
713 "t" gnus-group-unsubscribe-current-group
714 "s" gnus-group-unsubscribe-group
715 "k" gnus-group-kill-group
716 "y" gnus-group-yank-group
717 "w" gnus-group-kill-region
718 "\C-k" gnus-group-kill-level
719 "z" gnus-group-kill-all-zombies))
721 (defun gnus-group-make-menu-bar ()
722 (gnus-turn-off-edit-menu 'group)
723 (unless (boundp 'gnus-group-reading-menu)
726 gnus-group-reading-menu gnus-group-mode-map ""
728 ["Read" gnus-group-read-group (gnus-group-group-name)]
729 ["Select" gnus-group-select-group (gnus-group-group-name)]
730 ["See old articles" (gnus-group-select-group 'all)
731 :keys "C-u SPC" :active (gnus-group-group-name)]
732 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
733 ,@(if (featurep 'xemacs) nil
734 '(:help "Mark unread articles in the current group as read"))]
735 ["Catch up all articles" gnus-group-catchup-current-all
736 (gnus-group-group-name)]
737 ["Check for new articles" gnus-group-get-new-news-this-group
738 :active (gnus-group-group-name)
739 ,@(if (featurep 'xemacs) nil
740 '(:help "Check for new messages in current group"))]
741 ["Toggle subscription" gnus-group-unsubscribe-current-group
742 (gnus-group-group-name)]
743 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
744 ,@(if (featurep 'xemacs) nil
745 '(:help "Kill (remove) current group"))]
746 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
747 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
748 ,@(if (featurep 'xemacs) nil
749 '(:help "Display description of the current group"))]
750 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
751 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
752 ,@(if (featurep 'xemacs) nil
753 '(:help "Display the charter of the current group"))]
754 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
755 ,@(if (featurep 'xemacs) nil
756 '(:help "Display the archived control message for the current group"))]
757 ;; Actually one should check, if any of the marked groups gives t for
758 ;; (gnus-check-backend-function 'request-expire-articles ...)
759 ["Expire articles" gnus-group-expire-articles
760 (or (and (gnus-group-group-name)
761 (gnus-check-backend-function
762 'request-expire-articles
763 (gnus-group-group-name))) gnus-group-marked)]
764 ["Set group level..." gnus-group-set-current-level
765 (gnus-group-group-name)]
766 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
767 ["Customize" gnus-group-customize (gnus-group-group-name)]
769 ["Parameters" gnus-group-edit-group-parameters
770 (gnus-group-group-name)]
771 ["Select method" gnus-group-edit-group-method
772 (gnus-group-group-name)]
773 ["Info" gnus-group-edit-group (gnus-group-group-name)]
774 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
775 ["Global kill file" gnus-group-edit-global-kill t])))
778 gnus-group-group-menu gnus-group-mode-map ""
781 ["List unread subscribed groups" gnus-group-list-groups t]
782 ["List (un)subscribed groups" gnus-group-list-all-groups t]
783 ["List killed groups" gnus-group-list-killed gnus-killed-list]
784 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
785 ["List level..." gnus-group-list-level t]
786 ["Describe all groups" gnus-group-describe-all-groups t]
787 ["Group apropos..." gnus-group-apropos t]
788 ["Group and description apropos..." gnus-group-description-apropos t]
789 ["List groups matching..." gnus-group-list-matching t]
790 ["List all groups matching..." gnus-group-list-all-matching t]
791 ["List active file" gnus-group-list-active t]
792 ["List groups with cached" gnus-group-list-cached t]
793 ["List groups with dormant" gnus-group-list-dormant t])
795 ["Default sort" gnus-group-sort-groups t]
796 ["Sort by method" gnus-group-sort-groups-by-method t]
797 ["Sort by rank" gnus-group-sort-groups-by-rank t]
798 ["Sort by score" gnus-group-sort-groups-by-score t]
799 ["Sort by level" gnus-group-sort-groups-by-level t]
800 ["Sort by unread" gnus-group-sort-groups-by-unread t]
801 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
802 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
803 ("Sort process/prefixed"
804 ["Default sort" gnus-group-sort-selected-groups
805 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
806 ["Sort by method" gnus-group-sort-selected-groups-by-method
807 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
808 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
809 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
810 ["Sort by score" gnus-group-sort-selected-groups-by-score
811 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
812 ["Sort by level" gnus-group-sort-selected-groups-by-level
813 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
814 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
815 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
816 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
817 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
818 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
819 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
821 ["Mark group" gnus-group-mark-group
822 (and (gnus-group-group-name)
823 (not (memq (gnus-group-group-name) gnus-group-marked)))]
824 ["Unmark group" gnus-group-unmark-group
825 (and (gnus-group-group-name)
826 (memq (gnus-group-group-name) gnus-group-marked))]
827 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
828 ["Mark regexp..." gnus-group-mark-regexp t]
829 ["Mark region" gnus-group-mark-region t]
830 ["Mark buffer" gnus-group-mark-buffer t]
831 ["Execute command" gnus-group-universal-argument
832 (or gnus-group-marked (gnus-group-group-name))])
834 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
835 ["Kill all newsgroups in region" gnus-group-kill-region t]
836 ["Kill all zombie groups" gnus-group-kill-all-zombies
838 ["Kill all groups on level..." gnus-group-kill-level t])
840 ["Make a foreign group..." gnus-group-make-group t]
841 ["Add a directory group..." gnus-group-make-directory-group t]
842 ["Add the help group" gnus-group-make-help-group t]
843 ["Add the archive group" gnus-group-make-archive-group t]
844 ["Make a doc group..." gnus-group-make-doc-group t]
845 ["Make a web group..." gnus-group-make-web-group t]
846 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
847 ["Make a virtual group..." gnus-group-make-empty-virtual t]
848 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
849 ["Rename group..." gnus-group-rename-group
850 (gnus-check-backend-function
851 'request-rename-group (gnus-group-group-name))]
852 ["Delete group" gnus-group-delete-group
853 (gnus-check-backend-function
854 'request-delete-group (gnus-group-group-name))])
856 ["Next" gnus-group-next-group t]
857 ["Previous" gnus-group-prev-group t]
858 ["Next unread" gnus-group-next-unread-group t]
859 ["Previous unread" gnus-group-prev-unread-group t]
860 ["Next unread same level" gnus-group-next-unread-group-same-level t]
861 ["Previous unread same level"
862 gnus-group-prev-unread-group-same-level t]
863 ["Jump to group..." gnus-group-jump-to-group t]
864 ["First unread group" gnus-group-first-unread-group t]
865 ["Best unread group" gnus-group-best-unread-group t])
867 ["Generate" gnus-sieve-generate t]
868 ["Generate and update" gnus-sieve-update t])
869 ["Delete bogus groups" gnus-group-check-bogus-groups t]
870 ["Find new newsgroups" gnus-group-find-new-groups t]
871 ["Transpose" gnus-group-transpose-groups
872 (gnus-group-group-name)]
873 ["Read a directory as a group..." gnus-group-enter-directory t]))
876 gnus-group-misc-menu gnus-group-mode-map ""
879 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
880 ["Send replies" gnus-soup-send-replies
881 (fboundp 'gnus-soup-pack-packet)]
882 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
883 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
884 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
885 ["Send a mail" gnus-group-mail t]
886 ["Send a message (mail or news)" gnus-group-post-news t]
887 ["Create a local message" gnus-group-news t]
888 ["Check for new news" gnus-group-get-new-news
889 ,@(if (featurep 'xemacs) '(t)
890 '(:help "Get newly arrived articles"))
892 ["Send queued messages" gnus-delay-send-queue
893 ,@(if (featurep 'xemacs) '(t)
894 '(:help "Send all messages that are scheduled to be sent now"))
896 ["Activate all groups" gnus-activate-all-groups t]
897 ["Restart Gnus" gnus-group-restart t]
898 ["Read init file" gnus-group-read-init-file t]
899 ["Browse foreign server..." gnus-group-browse-foreign-server t]
900 ["Enter server buffer" gnus-group-enter-server-mode t]
901 ["Expire all expirable articles" gnus-group-expire-all-groups t]
902 ["Generate any kiboze groups" nnkiboze-generate-groups t]
903 ["Gnus version" gnus-version t]
904 ["Save .newsrc files" gnus-group-save-newsrc t]
905 ["Suspend Gnus" gnus-group-suspend t]
906 ["Clear dribble buffer" gnus-group-clear-dribble t]
907 ["Read manual" gnus-info-find-node t]
908 ["Flush score cache" gnus-score-flush-cache t]
909 ["Toggle topics" gnus-topic-mode t]
910 ["Send a bug report" gnus-bug t]
911 ["Exit from Gnus" gnus-group-exit
912 ,@(if (featurep 'xemacs) '(t)
913 '(:help "Quit reading news"))]
914 ["Exit without saving" gnus-group-quit t]))
916 (gnus-run-hooks 'gnus-group-menu-hook)))
918 (defvar gnus-group-toolbar-map nil)
920 ;; Emacs 21 tool bar. Should be no-op otherwise.
921 (defun gnus-group-make-tool-bar ()
923 (condition-case nil (require 'tool-bar) (error nil))
924 (fboundp 'tool-bar-add-item-from-menu)
925 (default-value 'tool-bar-mode)
926 (not gnus-group-toolbar-map))
927 (setq gnus-group-toolbar-map
928 (let ((tool-bar-map (make-sparse-keymap))
929 (load-path (mm-image-load-path)))
930 (tool-bar-add-item-from-menu
931 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
932 (tool-bar-add-item-from-menu
933 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
934 (tool-bar-add-item-from-menu
935 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
936 (tool-bar-add-item-from-menu
937 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
938 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
939 :help "Subscribe to the current group")
940 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
942 :help "Unsubscribe from the current group")
943 (tool-bar-add-item-from-menu
944 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
946 (if gnus-group-toolbar-map
947 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
949 (defun gnus-group-mode ()
950 "Major mode for reading news.
952 All normal editing commands are switched off.
953 \\<gnus-group-mode-map>
954 The group buffer lists (some of) the groups available. For instance,
955 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
956 lists all zombie groups.
958 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
959 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
961 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
963 The following commands are available:
965 \\{gnus-group-mode-map}"
967 (kill-all-local-variables)
968 (when (gnus-visual-p 'group-menu 'menu)
969 (gnus-group-make-menu-bar)
970 (gnus-group-make-tool-bar))
971 (gnus-simplify-mode-line)
972 (setq major-mode 'gnus-group-mode)
973 (setq mode-name "Group")
974 (gnus-group-set-mode-line)
975 (setq mode-line-process nil)
976 (use-local-map gnus-group-mode-map)
977 (buffer-disable-undo)
978 (setq truncate-lines t)
979 (setq buffer-read-only t)
980 (gnus-set-default-directory)
981 (gnus-update-format-specifications nil 'group 'group-mode)
982 (gnus-update-group-mark-positions)
987 (gnus-run-hooks 'gnus-group-mode-hook))
989 (defun gnus-update-group-mark-positions ()
991 (let ((gnus-process-mark ?\200)
992 (gnus-group-update-hook nil)
993 (gnus-group-marked '("dummy.group"))
994 (gnus-active-hashtb (make-vector 10 0))
996 (gnus-set-active "dummy.group" '(0 . 0))
997 (gnus-set-work-buffer)
998 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
999 (goto-char (point-min))
1000 (setq gnus-group-mark-positions
1001 (list (cons 'process (and (search-forward "\200" nil t)
1002 (- (point) 2))))))))
1004 (defun gnus-mouse-pick-group (e)
1005 "Enter the group under the mouse pointer."
1008 (gnus-group-read-group nil))
1010 ;; Look at LEVEL and find out what the level is really supposed to be.
1011 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1012 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1013 (defun gnus-group-default-level (&optional level number-or-nil)
1015 (gnus-group-use-permanent-levels
1016 (or (setq gnus-group-use-permanent-levels
1017 (or level (if (numberp gnus-group-use-permanent-levels)
1018 gnus-group-use-permanent-levels
1019 (or gnus-group-default-list-level
1020 gnus-level-subscribed))))
1021 gnus-group-default-list-level gnus-level-subscribed))
1025 (or level gnus-group-default-list-level gnus-level-subscribed))))
1027 (defun gnus-group-setup-buffer ()
1028 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1029 (unless (eq major-mode 'gnus-group-mode)
1032 (gnus-carpal-setup-buffer 'group))))
1034 (defun gnus-group-name-charset (method group)
1036 (setq method (gnus-find-method-for-group group)))
1037 (let ((item (assoc method gnus-group-name-charset-method-alist))
1038 (alist gnus-group-name-charset-group-alist)
1042 (while (setq item (pop alist))
1043 (if (string-match (car item) group)
1045 result (cdr item))))
1048 (defun gnus-group-name-decode (string charset)
1049 (if (and string charset (featurep 'mule))
1050 (mm-decode-coding-string string charset)
1053 (defun gnus-group-decoded-name (string)
1054 (let ((charset (gnus-group-name-charset nil string)))
1055 (gnus-group-name-decode string charset)))
1057 (defun gnus-group-list-groups (&optional level unread lowest)
1058 "List newsgroups with level LEVEL or lower that have unread articles.
1059 Default is all subscribed groups.
1060 If argument UNREAD is non-nil, groups with no unread articles are also
1063 Also see the `gnus-group-use-permanent-levels' variable."
1065 (list (if current-prefix-arg
1066 (prefix-numeric-value current-prefix-arg)
1068 (gnus-group-default-level nil t)
1069 gnus-group-default-list-level
1070 gnus-level-subscribed))))
1072 (setq level (car gnus-group-list-mode)
1073 unread (cdr gnus-group-list-mode)))
1074 (setq level (gnus-group-default-level level))
1075 (gnus-group-setup-buffer)
1076 (gnus-update-format-specifications nil 'group 'group-mode)
1077 (let ((case-fold-search nil)
1078 (props (text-properties-at (gnus-point-at-bol)))
1079 (empty (= (point-min) (point-max)))
1080 (group (gnus-group-group-name))
1082 (set-buffer gnus-group-buffer)
1083 (setq number (funcall gnus-group-prepare-function level unread lowest))
1084 (when (or (and (numberp number)
1086 (zerop (buffer-size)))
1087 ;; No groups in the buffer.
1088 (gnus-message 5 gnus-no-groups-message))
1089 ;; We have some groups displayed.
1090 (goto-char (point-max))
1091 (when (or (not gnus-group-goto-next-group-function)
1092 (not (funcall gnus-group-goto-next-group-function
1096 (goto-char (point-min)))
1098 ;; Go to the first group with unread articles.
1099 (gnus-group-search-forward t))
1101 ;; Find the right group to put point on. If the current group
1102 ;; has disappeared in the new listing, try to find the next
1103 ;; one. If no next one can be found, just leave point at the
1104 ;; first newsgroup in the buffer.
1105 (when (not (gnus-goto-char
1107 (point-min) (point-max)
1108 'gnus-group (gnus-intern-safe
1109 group gnus-active-hashtb))))
1110 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1112 (not (gnus-goto-char
1114 (point-min) (point-max) 'gnus-group
1116 (caar newsrc) gnus-active-hashtb)))))
1117 (setq newsrc (cdr newsrc)))
1119 (goto-char (point-max))
1120 (forward-line -1)))))))
1121 ;; Adjust cursor point.
1122 (gnus-group-position-point)))
1124 (defun gnus-group-list-level (level &optional all)
1125 "List groups on LEVEL.
1126 If ALL (the prefix), also list groups that have no unread articles."
1127 (interactive "nList groups on level: \nP")
1128 (gnus-group-list-groups level all level))
1130 (defun gnus-group-prepare-logic (group test)
1131 (or (and gnus-group-listed-groups
1132 (null gnus-group-list-option)
1133 (member group gnus-group-listed-groups))
1135 ((null gnus-group-listed-groups) test)
1136 ((null gnus-group-list-option) test)
1137 (t (and (member group gnus-group-listed-groups)
1138 (if (eq gnus-group-list-option 'flush)
1142 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1143 "List all newsgroups with unread articles of level LEVEL or lower.
1144 If PREDICATE is a function, list groups that the function returns non-nil;
1145 if it is t, list groups that have no unread articles.
1146 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1147 If REGEXP is a function, list dead groups that the function returns non-nil;
1148 if it is a string, only list groups matching REGEXP."
1149 (set-buffer gnus-group-buffer)
1150 (let ((buffer-read-only nil)
1151 (newsrc (cdr gnus-newsrc-alist))
1152 (lowest (or lowest 1))
1153 (not-in-list (and gnus-group-listed-groups
1154 (copy-sequence gnus-group-listed-groups)))
1155 info clevel unread group params)
1157 (when (or (< lowest gnus-level-zombie)
1158 gnus-group-listed-groups)
1159 ;; List living groups.
1161 (setq info (car newsrc)
1162 group (gnus-info-group info)
1163 params (gnus-info-params info)
1165 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1167 (setq not-in-list (delete group not-in-list)))
1169 (gnus-group-prepare-logic
1171 (and unread ; This group might be unchecked
1172 (or (not (stringp regexp))
1173 (string-match regexp group))
1174 (<= (setq clevel (gnus-info-level info)) level)
1177 ((functionp predicate)
1178 (funcall predicate info))
1179 (predicate t) ; We list all groups?
1182 (if (eq unread t) ; Unactivated?
1183 gnus-group-list-inactive-groups
1184 ; We list unactivated
1186 ; We list groups with unread articles
1187 (and gnus-list-groups-with-ticked-articles
1188 (cdr (assq 'tick (gnus-info-marks info))))
1189 ; And groups with tickeds
1190 ;; Check for permanent visibility.
1191 (and gnus-permanently-visible-groups
1192 (string-match gnus-permanently-visible-groups group))
1193 (memq 'visible params)
1194 (cdr (assq 'visible params)))))))
1195 (gnus-group-insert-group-line
1196 group (gnus-info-level info)
1197 (gnus-info-marks info) unread (gnus-info-method info)))))
1199 ;; List dead groups.
1200 (if (or gnus-group-listed-groups
1201 (and (>= level gnus-level-zombie)
1202 (<= lowest gnus-level-zombie)))
1203 (gnus-group-prepare-flat-list-dead
1204 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1205 gnus-level-zombie ?Z
1208 (dolist (group gnus-zombie-list)
1209 (setq not-in-list (delete group not-in-list))))
1210 (if (or gnus-group-listed-groups
1211 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1212 (gnus-group-prepare-flat-list-dead
1215 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1216 gnus-level-killed ?K regexp))
1218 (gnus-group-set-mode-line)
1219 (setq gnus-group-list-mode (cons level predicate))
1220 (gnus-run-hooks 'gnus-group-prepare-hook)
1223 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1224 ;; List zombies and killed lists somewhat faster, which was
1225 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1226 ;; this by ignoring the group format specification altogether.
1228 (if (> (length groups) gnus-group-listing-limit)
1230 (setq group (pop groups))
1231 (when (gnus-group-prepare-logic
1234 (and (stringp regexp) (string-match regexp group))
1235 (and (functionp regexp) (funcall regexp group))))
1236 (gnus-add-text-properties
1237 (point) (prog1 (1+ (point))
1238 (insert " " mark " *: "
1239 (gnus-group-decoded-name group)
1241 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1243 'gnus-level level))))
1245 (setq group (pop groups))
1246 (when (gnus-group-prepare-logic
1249 (and (stringp regexp) (string-match regexp group))
1250 (and (functionp regexp) (funcall regexp group))))
1251 (gnus-group-insert-group-line
1253 (let ((active (gnus-active group)))
1255 (if (zerop (cdr active))
1257 (- (1+ (cdr active)) (car active)))
1259 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1261 (defun gnus-group-update-group-line ()
1262 "Update the current line in the group buffer."
1263 (let* ((buffer-read-only nil)
1264 (group (gnus-group-group-name))
1265 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1266 gnus-group-indentation)
1269 (not (gnus-ephemeral-group-p group))
1271 (concat "(gnus-group-set-info '"
1272 (gnus-prin1-to-string (nth 2 entry))
1274 (setq gnus-group-indentation (gnus-group-group-indentation))
1276 (gnus-group-insert-group-line-info group)
1278 (gnus-group-position-point))))
1280 (defun gnus-group-insert-group-line-info (group)
1281 "Insert GROUP on the current line."
1282 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1283 (gnus-group-indentation (gnus-group-group-indentation))
1287 ;; (Un)subscribed group.
1288 (setq info (nth 2 entry))
1289 (gnus-group-insert-group-line
1290 group (gnus-info-level info) (gnus-info-marks info)
1291 (or (car entry) t) (gnus-info-method info)))
1292 ;; This group is dead.
1293 (gnus-group-insert-group-line
1295 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1297 (if (setq active (gnus-active group))
1298 (if (zerop (cdr active))
1300 (- (1+ (cdr active)) (car active)))
1302 (gnus-method-simplify (gnus-find-method-for-group group))))))
1304 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1305 gnus-tmp-marked number
1307 "Insert a group line in the group buffer."
1308 (let* ((gnus-tmp-method
1309 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1310 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1312 (gnus-tmp-active (gnus-active gnus-tmp-group))
1313 (gnus-tmp-number-total
1315 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1317 (gnus-tmp-number-of-unread
1318 (if (numberp number) (int-to-string (max 0 number))
1320 (gnus-tmp-number-of-read
1321 (if (numberp number)
1322 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1324 (gnus-tmp-subscribed
1325 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1326 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1327 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1329 (gnus-tmp-qualified-group
1330 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1331 group-name-charset))
1333 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1335 (gnus-tmp-newsgroup-description
1336 (if gnus-description-hashtb
1337 (or (gnus-group-name-decode
1338 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1339 group-name-charset) "")
1342 (if (and gnus-moderated-hashtb
1343 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1345 (gnus-tmp-moderated-string
1346 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1347 (gnus-tmp-group-icon "==&&==")
1348 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1349 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1350 (gnus-tmp-news-method-string
1352 (format "(%s:%s)" (car gnus-tmp-method)
1353 (cadr gnus-tmp-method)) ""))
1354 (gnus-tmp-marked-mark
1355 (if (and (numberp number)
1357 (cdr (assq 'tick gnus-tmp-marked)))
1359 (gnus-tmp-process-marked
1360 (if (member gnus-tmp-group gnus-group-marked)
1361 gnus-process-mark ? ))
1363 (or (and gnus-use-grouplens
1364 (bbb-grouplens-group-p gnus-tmp-group))
1366 (buffer-read-only nil)
1367 header gnus-tmp-header) ; passed as parameter to user-funcs.
1369 (gnus-add-text-properties
1373 (let ((gnus-tmp-group (gnus-group-name-decode
1374 gnus-tmp-group group-name-charset)))
1375 (eval gnus-group-line-format-spec)))
1376 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1377 gnus-unread ,(if (numberp number)
1378 (string-to-int gnus-tmp-number-of-unread)
1380 gnus-marked ,gnus-tmp-marked-mark
1381 gnus-indentation ,gnus-group-indentation
1382 gnus-level ,gnus-tmp-level))
1384 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1385 (gnus-run-hooks 'gnus-group-update-hook))
1387 ;; Allow XEmacs to remove front-sticky text properties.
1388 (gnus-group-remove-excess-properties)))
1390 (defun gnus-group-highlight-line ()
1391 "Highlight the current line according to `gnus-group-highlight'."
1392 (let* ((list gnus-group-highlight)
1394 (end (progn (end-of-line) (point)))
1395 ;; now find out where the line starts and leave point there.
1396 (beg (progn (beginning-of-line) (point)))
1397 (group (gnus-group-group-name))
1398 (entry (gnus-group-entry group))
1399 (unread (if (numberp (car entry)) (car entry) 0))
1400 (active (gnus-active group))
1401 (total (if active (1+ (- (cdr active) (car active))) 0))
1402 (info (nth 2 entry))
1403 (method (gnus-server-get-method group (gnus-info-method info)))
1404 (marked (gnus-info-marks info))
1405 (mailp (apply 'append
1408 (memq x (assoc (symbol-name
1409 (car (or method gnus-select-method)))
1410 gnus-valid-select-methods)))
1411 '(mail post-mail))))
1412 (level (or (gnus-info-level info) gnus-level-killed))
1413 (score (or (gnus-info-score info) 0))
1414 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1415 (group-age (gnus-group-timestamp-delta group))
1416 (inhibit-read-only t))
1417 ;; Eval the cars of the lists until we find a match.
1419 (not (eval (caar list))))
1420 (setq list (cdr list)))
1421 (let ((face (cdar list)))
1422 (unless (eq face (get-text-property beg 'face))
1423 (gnus-put-text-property-excluding-characters-with-faces
1425 (setq face (if (boundp face) (symbol-value face) face)))
1426 (gnus-extent-start-open beg)))
1429 (defun gnus-group-update-group (group &optional visible-only)
1430 "Update all lines where GROUP appear.
1431 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1433 ;; Can't use `save-excursion' here, so we do it manually.
1434 (let ((buf (current-buffer))
1436 (set-buffer gnus-group-buffer)
1437 (setq mark (point-marker))
1438 ;; The buffer may be narrowed.
1441 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1443 found buffer-read-only)
1444 ;; Enter the current status into the dribble buffer.
1445 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1447 (not (gnus-ephemeral-group-p group)))
1449 (concat "(gnus-group-set-info '"
1450 (gnus-prin1-to-string (nth 2 entry))
1452 ;; Find all group instances. If topics are in use, each group
1453 ;; may be listed in more than once.
1454 (while (setq loc (text-property-any
1455 loc (point-max) 'gnus-group ident))
1458 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1460 (gnus-group-insert-group-line-info group)
1463 (gnus-run-hooks 'gnus-group-update-group-hook)))
1464 (setq loc (1+ loc)))
1465 (unless (or found visible-only)
1466 ;; No such line in the buffer, find out where it's supposed to
1467 ;; go, and insert it there (or at the end of the buffer).
1468 (if gnus-goto-missing-group-function
1469 (funcall gnus-goto-missing-group-function group)
1470 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1471 (while (and entry (car entry)
1475 (point-min) (point-max)
1476 'gnus-group (gnus-intern-safe
1477 (caar entry) gnus-active-hashtb)))))
1478 (setq entry (cdr entry)))
1479 (or entry (goto-char (point-max)))))
1480 ;; Finally insert the line.
1481 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1482 (gnus-group-insert-group-line-info group)
1485 (gnus-run-hooks 'gnus-group-update-group-hook))))
1486 (when gnus-group-update-group-function
1487 (funcall gnus-group-update-group-function group))
1488 (gnus-group-set-mode-line)))
1490 (set-marker mark nil)
1493 (defun gnus-group-set-mode-line ()
1494 "Update the mode line in the group buffer."
1495 (when (memq 'group gnus-updated-mode-lines)
1496 ;; Yes, we want to keep this mode line updated.
1498 (set-buffer gnus-group-buffer)
1499 (let* ((gformat (or gnus-group-mode-line-format-spec
1500 (gnus-set-format 'group-mode)))
1501 (gnus-tmp-news-server (cadr gnus-select-method))
1502 (gnus-tmp-news-method (car gnus-select-method))
1503 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1505 gnus-tmp-header ;Dummy binding for user-defined formats
1506 ;; Get the resulting string.
1508 (and gnus-dribble-buffer
1509 (buffer-name gnus-dribble-buffer)
1510 (buffer-modified-p gnus-dribble-buffer)
1512 (set-buffer gnus-dribble-buffer)
1513 (not (zerop (buffer-size))))))
1514 (mode-string (eval gformat)))
1515 ;; Say whether the dribble buffer has been modified.
1516 (setq mode-line-modified
1517 (if modified (car gnus-mode-line-modified)
1518 (cdr gnus-mode-line-modified)))
1519 ;; If the line is too long, we chop it off.
1520 (when (> (length mode-string) max-len)
1521 (setq mode-string (substring mode-string 0 (- max-len 4))))
1523 (setq mode-line-buffer-identification
1524 (gnus-mode-line-buffer-identification
1525 (list mode-string)))
1526 (set-buffer-modified-p modified))))))
1528 (defun gnus-group-group-name ()
1529 "Get the name of the newsgroup on the current line."
1530 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1532 (symbol-name group))))
1534 (defun gnus-group-group-level ()
1535 "Get the level of the newsgroup on the current line."
1536 (get-text-property (gnus-point-at-bol) 'gnus-level))
1538 (defun gnus-group-group-indentation ()
1539 "Get the indentation of the newsgroup on the current line."
1540 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1541 (and gnus-group-indentation-function
1542 (funcall gnus-group-indentation-function))
1545 (defun gnus-group-group-unread ()
1546 "Get the number of unread articles of the newsgroup on the current line."
1547 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1549 (defun gnus-group-new-mail (group)
1550 (if (nnmail-new-mail-p (gnus-group-real-name group))
1554 (defun gnus-group-level (group)
1555 "Return the estimated level of GROUP."
1556 (or (gnus-info-level (gnus-get-info group))
1557 (and (member group gnus-zombie-list) gnus-level-zombie)
1560 (defun gnus-group-search-forward (&optional backward all level first-too)
1561 "Find the next newsgroup with unread articles.
1562 If BACKWARD is non-nil, find the previous newsgroup instead.
1563 If ALL is non-nil, just find any newsgroup.
1564 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1566 If FIRST-TOO, the current line is also eligible as a target."
1567 (let ((way (if backward -1 1))
1568 (low gnus-level-killed)
1571 (if (and backward (progn (beginning-of-line)) (bobp))
1580 (get-text-property (point) 'gnus-group)
1584 (get-text-property (point) 'gnus-unread)))
1585 (and (numberp unread) (> unread 0)))
1586 (setq lev (get-text-property (point)
1588 (<= lev gnus-level-subscribed)))
1590 (and (setq lev (get-text-property (point)
1599 (zerop (forward-line way)))))
1601 (progn (gnus-group-position-point) t)
1602 (goto-char (or pos beg))
1605 ;;; Gnus group mode commands
1609 (defun gnus-group-mark-line-p ()
1612 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1613 (eq (char-after) gnus-process-mark)))
1615 (defun gnus-group-mark-group (n &optional unmark no-advance)
1616 "Mark the current group."
1618 (let ((buffer-read-only nil)
1622 (when (setq group (gnus-group-group-name))
1623 ;; Go to the mark position.
1625 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1626 (subst-char-in-region
1627 (point) (1+ (point)) (char-after)
1630 (setq gnus-group-marked (delete group gnus-group-marked))
1632 (setq gnus-group-marked
1633 (cons group (delete group gnus-group-marked)))
1634 gnus-process-mark)))
1636 (gnus-group-next-group 1))
1638 (gnus-summary-position-point)
1641 (defun gnus-group-unmark-group (n)
1642 "Remove the mark from the current group."
1644 (gnus-group-mark-group n 'unmark)
1645 (gnus-group-position-point))
1647 (defun gnus-group-unmark-all-groups ()
1648 "Unmark all groups."
1650 (let ((groups gnus-group-marked))
1653 (gnus-group-remove-mark (pop groups)))))
1654 (gnus-group-position-point))
1656 (defun gnus-group-mark-region (unmark beg end)
1657 "Mark all groups between point and mark.
1658 If UNMARK, remove the mark instead."
1659 (interactive "P\nr")
1660 (let ((num (count-lines beg end)))
1663 (- num (gnus-group-mark-group num unmark)))))
1665 (defun gnus-group-mark-buffer (&optional unmark)
1666 "Mark all groups in the buffer.
1667 If UNMARK, remove the mark instead."
1669 (gnus-group-mark-region unmark (point-min) (point-max)))
1671 (defun gnus-group-mark-regexp (regexp)
1672 "Mark all groups that match some regexp."
1673 (interactive "sMark (regexp): ")
1674 (let ((alist (cdr gnus-newsrc-alist))
1677 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1678 (gnus-group-set-mark group))))
1679 (gnus-group-position-point))
1681 (defun gnus-group-remove-mark (group &optional test-marked)
1682 "Remove the process mark from GROUP and move point there.
1683 Return nil if the group isn't displayed."
1684 (if (gnus-group-goto-group group nil test-marked)
1686 (gnus-group-mark-group 1 'unmark t)
1688 (setq gnus-group-marked
1689 (delete group gnus-group-marked))
1692 (defun gnus-group-set-mark (group)
1693 "Set the process mark on GROUP."
1694 (if (gnus-group-goto-group group)
1696 (gnus-group-mark-group 1 nil t))
1697 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1699 (defun gnus-group-universal-argument (arg &optional groups func)
1700 "Perform any command on all groups according to the process/prefix convention."
1702 (if (eq (setq func (or func
1705 (substitute-command-keys
1706 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1708 (gnus-error 1 "Undefined key")
1709 (gnus-group-iterate arg
1711 (command-execute func))))
1712 (gnus-group-position-point))
1714 (defun gnus-group-process-prefix (n)
1715 "Return a list of groups to work on.
1716 Take into consideration N (the prefix) and the list of marked groups."
1719 (setq n (prefix-numeric-value n))
1720 ;; There is a prefix, so we return a list of the N next
1722 (let ((way (if (< n 0) -1 1))
1727 (if (setq group (gnus-group-group-name))
1728 (push group groups))
1730 (gnus-group-next-group way)))
1732 ((and (gnus-region-active-p) (mark))
1733 ;; Work on the region between point and mark.
1734 (let ((max (max (point) (mark)))
1737 (goto-char (min (point) (mark)))
1740 (push (gnus-group-group-name) groups)
1741 (zerop (gnus-group-next-group 1))
1743 (nreverse groups))))
1745 ;; No prefix, but a list of marked articles.
1746 (reverse gnus-group-marked))
1748 ;; Neither marked articles or a prefix, so we return the
1750 (let ((group (gnus-group-group-name)))
1751 (and group (list group))))))
1753 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1754 ;;; imagine why I went through these contortions...
1756 (let ((function (make-symbol "gnus-group-iterate-function"))
1757 (window (make-symbol "gnus-group-iterate-window"))
1758 (groups (make-symbol "gnus-group-iterate-groups"))
1759 (group (make-symbol "gnus-group-iterate-group")))
1761 `(defun gnus-group-iterate (arg ,function)
1762 "Iterate FUNCTION over all process/prefixed groups.
1763 FUNCTION will be called with the group name as the parameter
1764 and with point over the group in question."
1765 (let ((,groups (gnus-group-process-prefix arg))
1766 (,window (selected-window))
1769 (setq ,group (car ,groups)
1770 ,groups (cdr ,groups))
1771 (select-window ,window)
1772 (gnus-group-remove-mark ,group)
1773 (save-selected-window
1775 (funcall ,function ,group)))))))))
1777 (put 'gnus-group-iterate 'lisp-indent-function 1)
1779 ;; Selecting groups.
1781 (defun gnus-group-read-group (&optional all no-article group select-articles)
1782 "Read news in this newsgroup.
1783 If the prefix argument ALL is non-nil, already read articles become
1784 readable. IF ALL is a number, fetch this number of articles. If the
1785 optional argument NO-ARTICLE is non-nil, no article will be
1786 auto-selected upon group entry. If GROUP is non-nil, fetch that
1789 (let ((no-display (eq all 0))
1790 (group (or group (gnus-group-group-name)))
1791 number active marked entry)
1795 (error "No group on current line"))
1796 (setq marked (gnus-info-marks
1797 (nth 2 (setq entry (gnus-gethash
1798 group gnus-newsrc-hashtb)))))
1799 ;; This group might be a dead group. In that case we have to get
1800 ;; the number of unread articles from `gnus-active-hashtb'.
1802 (cond ((numberp all) all)
1804 ((setq active (gnus-active group))
1805 (- (1+ (cdr active)) (car active)))))
1806 (gnus-summary-read-group
1807 group (or all (and (numberp number)
1808 (zerop (+ number (gnus-range-length
1809 (cdr (assq 'tick marked)))
1811 (cdr (assq 'dormant marked)))))))
1812 no-article nil no-display nil select-articles)))
1814 (defun gnus-group-select-group (&optional all)
1815 "Select this newsgroup.
1816 No article is selected automatically.
1817 If the group is opened, just switch the summary buffer.
1818 If ALL is non-nil, already read articles become readable.
1819 If ALL is a number, fetch this number of articles."
1821 (gnus-group-read-group all t))
1823 (defun gnus-group-quick-select-group (&optional all)
1824 "Select the current group \"quickly\".
1825 This means that no highlighting or scoring will be performed.
1826 If ALL (the prefix argument) is 0, don't even generate the summary
1829 This might be useful if you want to toggle threading
1830 before entering the group."
1832 (require 'gnus-score)
1834 gnus-score-find-score-files-function
1835 gnus-home-score-file
1836 gnus-apply-kill-hook
1837 gnus-summary-expunge-below)
1838 (gnus-group-read-group all t)))
1840 (defun gnus-group-visible-select-group (&optional all)
1841 "Select the current group without hiding any articles."
1843 (let ((gnus-inhibit-limiting t))
1844 (gnus-group-read-group all t)))
1846 (defun gnus-group-select-group-ephemerally ()
1847 "Select the current group without doing any processing whatsoever.
1848 You will actually be entered into a group that's a copy of
1849 the current group; no changes you make while in this group will
1852 (require 'gnus-score)
1854 gnus-score-find-score-files-function gnus-apply-kill-hook
1855 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1856 gnus-summary-mode-hook gnus-select-group-hook
1857 (group (gnus-group-group-name))
1858 (method (gnus-find-method-for-group group)))
1859 (gnus-group-read-ephemeral-group
1860 (gnus-group-prefixed-name group method) method)))
1863 (defun gnus-fetch-group (group)
1864 "Start Gnus if necessary and enter GROUP.
1865 Returns whether the fetching was successful or not."
1866 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1867 (unless (get-buffer gnus-group-buffer)
1869 (gnus-group-read-group nil nil group))
1872 (defun gnus-fetch-group-other-frame (group)
1873 "Pop up a frame and enter GROUP."
1875 (let ((window (get-buffer-window gnus-group-buffer)))
1877 (select-frame (window-frame window)))
1878 ((= (length (frame-list)) 1)
1879 (select-frame (make-frame)))
1882 (gnus-fetch-group group))
1884 (defvar gnus-ephemeral-group-server 0)
1886 ;; Enter a group that is not in the group buffer. Non-nil is returned
1887 ;; if selection was successful.
1888 (defun gnus-group-read-ephemeral-group (group method &optional activate
1889 quit-config request-only
1892 "Read GROUP from METHOD as an ephemeral group.
1893 If ACTIVATE, request the group first.
1894 If QUIT-CONFIG, use that window configuration when exiting from the
1896 If REQUEST-ONLY, don't actually read the group; just request it.
1897 If SELECT-ARTICLES, only select those articles.
1898 If PARAMETERS, use those as the group parameters.
1900 Return the name of the group if selection was successful."
1901 ;; Transform the select method into a unique server.
1902 (when (stringp method)
1903 (setq method (gnus-server-to-method method)))
1905 `(,(car method) ,(concat (cadr method) "-ephemeral")
1906 (,(intern (format "%s-address" (car method))) ,(cadr method))
1908 (let ((group (if (gnus-group-foreign-p group) group
1909 (gnus-group-prefixed-name (gnus-group-real-name group)
1914 ,gnus-level-default-subscribed nil nil ,method
1917 (cons 'quit-config quit-config)
1919 (cons gnus-summary-buffer
1920 gnus-current-window-configuration)))
1923 (push method gnus-ephemeral-servers)
1924 (set-buffer gnus-group-buffer)
1925 (unless (gnus-check-server method)
1926 (error "Unable to contact server: %s" (gnus-status-message method)))
1928 (gnus-activate-group group 'scan)
1929 (unless (gnus-request-group group)
1930 (error "Couldn't request group: %s"
1931 (nnheader-get-report (car method)))))
1935 (when (gnus-group-read-group t t group select-articles)
1939 (message "Quit reading the ephemeral group")
1942 (defun gnus-group-jump-to-group (group)
1943 "Jump to newsgroup GROUP."
1945 (list (completing-read
1946 "Group: " gnus-active-hashtb nil
1947 (gnus-read-active-file-p)
1948 gnus-group-jump-to-group-prompt
1949 'gnus-group-history)))
1951 (when (equal group "")
1952 (error "Empty group name"))
1954 (unless (gnus-ephemeral-group-p group)
1955 ;; Either go to the line in the group buffer...
1956 (unless (gnus-group-goto-group group)
1957 ;; ... or insert the line.
1958 (gnus-group-update-group group)
1959 (gnus-group-goto-group group)))
1960 ;; Adjust cursor point.
1961 (gnus-group-position-point))
1963 (defun gnus-group-goto-group (group &optional far test-marked)
1964 "Goto to newsgroup GROUP.
1965 If FAR, it is likely that the group is not on the current line.
1966 If TEST-MARKED, the line must be marked."
1970 ;; It's quite likely that we are on the right line, so
1971 ;; we check the current line first.
1973 (eq (get-text-property (point) 'gnus-group)
1974 (gnus-intern-safe group gnus-active-hashtb))
1975 (or (not test-marked) (gnus-group-mark-line-p)))
1977 ;; Previous and next line are also likely, so we check them as well.
1981 (and (eq (get-text-property (point) 'gnus-group)
1982 (gnus-intern-safe group gnus-active-hashtb))
1983 (or (not test-marked) (gnus-group-mark-line-p)))))
1989 (and (eq (get-text-property (point) 'gnus-group)
1990 (gnus-intern-safe group gnus-active-hashtb))
1991 (or (not test-marked) (gnus-group-mark-line-p)))))
1995 (goto-char (point-min))
1997 (while (and (not found)
2002 (gnus-intern-safe group gnus-active-hashtb))))
2003 (if (gnus-group-mark-line-p)
2008 ;; Search through the entire buffer.
2011 (point-min) (point-max)
2012 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2014 (defun gnus-group-next-group (n &optional silent)
2015 "Go to next N'th newsgroup.
2016 If N is negative, search backward instead.
2017 Returns the difference between N and the number of skips actually
2020 (gnus-group-next-unread-group n t nil silent))
2022 (defun gnus-group-next-unread-group (n &optional all level silent)
2023 "Go to next N'th unread newsgroup.
2024 If N is negative, search backward instead.
2025 If ALL is non-nil, choose any newsgroup, unread or not.
2026 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2027 such group can be found, the next group with a level higher than
2029 Returns the difference between N and the number of skips actually
2032 (let ((backward (< n 0))
2035 (gnus-group-search-forward
2036 backward (or (not gnus-group-goto-unread) all) level))
2040 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2041 (if level " on this level or higher" "")))
2044 (defun gnus-group-prev-group (n)
2045 "Go to previous N'th newsgroup.
2046 Returns the difference between N and the number of skips actually
2049 (gnus-group-next-unread-group (- n) t))
2051 (defun gnus-group-prev-unread-group (n)
2052 "Go to previous N'th unread newsgroup.
2053 Returns the difference between N and the number of skips actually
2056 (gnus-group-next-unread-group (- n)))
2058 (defun gnus-group-next-unread-group-same-level (n)
2059 "Go to next N'th unread newsgroup on the same level.
2060 If N is negative, search backward instead.
2061 Returns the difference between N and the number of skips actually
2064 (gnus-group-next-unread-group n t (gnus-group-group-level))
2065 (gnus-group-position-point))
2067 (defun gnus-group-prev-unread-group-same-level (n)
2068 "Go to next N'th unread newsgroup on the same level.
2069 Returns the difference between N and the number of skips actually
2072 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2073 (gnus-group-position-point))
2075 (defun gnus-group-best-unread-group (&optional exclude-group)
2076 "Go to the group with the highest level.
2077 If EXCLUDE-GROUP, do not go to that group."
2079 (goto-char (point-min))
2083 (setq unread (get-text-property (point) 'gnus-unread))
2084 (when (and (numberp unread) (> unread 0))
2085 (when (and (get-text-property (point) 'gnus-level)
2086 (< (get-text-property (point) 'gnus-level) best)
2087 (or (not exclude-group)
2088 (not (equal exclude-group (gnus-group-group-name)))))
2089 (setq best (get-text-property (point) 'gnus-level))
2090 (setq best-point (point))))
2093 (goto-char best-point))
2094 (gnus-group-position-point)
2095 (and best-point (gnus-group-group-name))))
2097 (defun gnus-group-first-unread-group ()
2098 "Go to the first group with unread articles."
2101 (let ((opoint (point))
2103 (goto-char (point-min))
2104 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2105 (and (numberp unread) ; Not a topic.
2106 (not (zerop unread))) ; Has unread articles.
2107 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2110 nil)) ; Not success.
2111 (gnus-group-position-point)))
2113 (defun gnus-group-enter-server-mode ()
2114 "Jump to the server buffer."
2116 (gnus-enter-server-buffer))
2118 (defun gnus-group-make-group (name &optional method address args)
2119 "Add a new newsgroup.
2120 The user will be prompted for a NAME, for a select METHOD, and an
2124 (gnus-read-group "Group name: ")
2125 (gnus-read-method "From method: ")))
2127 (when (stringp method)
2128 (setq method (or (gnus-server-to-method method) method)))
2129 (let* ((meth (gnus-method-simplify
2131 (not (gnus-server-equal method gnus-select-method)))
2132 (if address (list (intern method) address)
2134 (nname (if method (gnus-group-prefixed-name name meth) name))
2136 (when (gnus-gethash nname gnus-newsrc-hashtb)
2137 (error "Group %s already exists" nname))
2138 ;; Subscribe to the new group.
2139 (gnus-group-change-level
2140 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2141 gnus-level-default-subscribed gnus-level-killed
2142 (and (gnus-group-group-name)
2143 (gnus-gethash (gnus-group-group-name)
2144 gnus-newsrc-hashtb))
2147 (gnus-set-active nname (cons 1 0))
2148 (unless (gnus-ephemeral-group-p name)
2150 (concat "(gnus-group-set-info '"
2151 (gnus-prin1-to-string (cdr info)) ")")))
2153 (gnus-group-insert-group-line-info nname)
2155 (gnus-group-position-point)
2157 ;; Load the backend and try to make the backend create
2158 ;; the group as well.
2159 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2161 gnus-valid-select-methods)
2163 (gnus-check-server meth)
2164 (when (gnus-check-backend-function 'request-create-group nname)
2165 (gnus-request-create-group nname nil args))
2168 (defun gnus-group-delete-groups (&optional arg)
2169 "Delete the current group. Only meaningful with editable groups."
2171 (let ((n (length (gnus-group-process-prefix arg))))
2172 (when (gnus-yes-or-no-p
2174 "Delete this 1 group? "
2175 (format "Delete these %d groups? " n)))
2176 (gnus-group-iterate arg
2178 (gnus-group-delete-group group nil t))))))
2180 (defun gnus-group-delete-group (group &optional force no-prompt)
2181 "Delete the current group. Only meaningful with editable groups.
2182 If FORCE (the prefix) is non-nil, all the articles in the group will
2183 be deleted. This is \"deleted\" as in \"removed forever from the face
2184 of the Earth\". There is no undo. The user will be prompted before
2185 doing the deletion."
2187 (list (gnus-group-group-name)
2188 current-prefix-arg))
2190 (error "No group to delete"))
2191 (unless (gnus-check-backend-function 'request-delete-group group)
2192 (error "This backend does not support group deletion"))
2194 (if (and (not no-prompt)
2195 (not (gnus-yes-or-no-p
2197 "Do you really want to delete %s%s? "
2198 group (if force " and all its contents" "")))))
2200 (gnus-message 6 "Deleting group %s..." group)
2201 (if (not (gnus-request-delete-group group force))
2202 (gnus-error 3 "Couldn't delete group %s" group)
2203 (gnus-message 6 "Deleting group %s...done" group)
2204 (gnus-group-goto-group group)
2205 (gnus-group-kill-group 1 t)
2206 (gnus-sethash group nil gnus-active-hashtb)
2207 (when gnus-cache-active-hashtb
2208 (gnus-sethash group nil gnus-cache-active-hashtb)
2209 (setq gnus-cache-active-altered t))
2211 (gnus-group-position-point)))
2213 (defun gnus-group-rename-group (group new-name)
2214 "Rename group from GROUP to NEW-NAME.
2215 When used interactively, GROUP is the group under point
2216 and NEW-NAME will be prompted for."
2219 (gnus-group-group-name)
2221 (unless (gnus-check-backend-function
2222 'request-rename-group (gnus-group-group-name))
2223 (error "This backend does not support renaming groups"))
2224 (gnus-read-group "Rename group to: "
2225 (gnus-group-real-name (gnus-group-group-name))))))
2227 (unless (gnus-check-backend-function 'request-rename-group group)
2228 (error "This backend does not support renaming groups"))
2230 (error "No group to rename"))
2231 (when (equal (gnus-group-real-name group) new-name)
2232 (error "Can't rename to the same name"))
2234 ;; We find the proper prefixed name.
2236 (if (gnus-group-native-p group)
2240 (gnus-group-prefixed-name
2241 (gnus-group-real-name new-name)
2242 (gnus-info-method (gnus-get-info group)))))
2244 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2247 (gnus-group-goto-group group)
2248 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2249 (gnus-request-rename-group group new-name))))
2250 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2251 ;; We rename the group internally by killing it...
2252 (gnus-group-kill-group)
2253 ;; ... changing its name ...
2254 (setcar (cdar gnus-list-of-killed-groups) new-name)
2255 ;; ... and then yanking it. Magic!
2256 (gnus-group-yank-group)
2257 (gnus-set-active new-name (gnus-active group))
2258 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2260 (setq gnus-killed-list (delete group gnus-killed-list))
2261 (gnus-set-active group nil)
2262 (gnus-dribble-touch)
2263 (gnus-group-position-point)))
2265 (defun gnus-group-edit-group (group &optional part)
2266 "Edit the group on the current line."
2267 (interactive (list (gnus-group-group-name)))
2268 (let ((part (or part 'info))
2271 (error "No group on current line"))
2272 (unless (setq info (gnus-get-info group))
2273 (error "Killed group; can't be edited"))
2275 (gnus-close-group group))
2277 ;; Find the proper form to edit.
2278 (cond ((eq part 'method)
2279 (or (gnus-info-method info) "native"))
2281 (gnus-info-params info))
2283 ;; The proper documentation.
2285 "Editing the %s for `%s'."
2287 ((eq part 'method) "select method")
2288 ((eq part 'params) "group parameters")
2290 (gnus-group-decoded-name group))
2292 (gnus-group-edit-group-done ',part ,group form)))
2295 (gnus-create-info-command
2298 "(gnus)Select Methods")
2300 "(gnus)Group Parameters")
2302 "(gnus)Group Info"))))))
2304 (defun gnus-group-edit-group-method (group)
2305 "Edit the select method of GROUP."
2306 (interactive (list (gnus-group-group-name)))
2307 (gnus-group-edit-group group 'method))
2309 (defun gnus-group-edit-group-parameters (group)
2310 "Edit the group parameters of GROUP."
2311 (interactive (list (gnus-group-group-name)))
2312 (gnus-group-edit-group group 'params))
2314 (defun gnus-group-edit-group-done (part group form)
2316 (let* ((method (cond ((eq part 'info) (nth 4 form))
2317 ((eq part 'method) form)
2319 (info (cond ((eq part 'info) form)
2320 ((eq part 'method) (gnus-get-info group))
2323 (if (or (not method)
2325 gnus-select-method method))
2326 (gnus-group-real-name (car info))
2327 (gnus-group-prefixed-name
2328 (gnus-group-real-name (car info)) method))
2330 (when (and new-group
2331 (not (equal new-group group)))
2332 (when (gnus-group-goto-group group)
2333 (gnus-group-kill-group 1))
2334 (gnus-activate-group new-group))
2336 (if (not (and info new-group))
2337 (gnus-group-set-info form (or new-group group) part)
2338 (setq info (gnus-copy-sequence info))
2339 (setcar info new-group)
2340 (unless (gnus-server-equal method "native")
2341 (unless (nthcdr 3 info)
2342 (nconc info (list nil nil)))
2343 (unless (nthcdr 4 info)
2344 (nconc info (list nil)))
2345 (gnus-info-set-method info method))
2346 (gnus-group-set-info info))
2347 (gnus-group-update-group (or new-group group))
2348 (gnus-group-position-point)))
2350 (defun gnus-group-make-useful-group (group method)
2351 "Create one of the groups described in `gnus-useful-groups'."
2353 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2355 gnus-useful-groups)))
2356 (list (cadr entry) (caddr entry))))
2357 (setq method (gnus-copy-sequence method))
2359 (while (setq entry (memq (assq 'eval method) method))
2360 (setcar entry (eval (cadar entry)))))
2361 (gnus-group-make-group group method))
2363 (defun gnus-group-make-help-group (&optional noerror)
2364 "Create the Gnus documentation group.
2365 Optional argument NOERROR modifies the behavior of this function when the
2366 group already exists:
2367 - if not given, and error is signaled,
2368 - if t, stay silent,
2369 - if anything else, just print a message."
2371 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2372 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2373 (if (gnus-gethash name gnus-newsrc-hashtb)
2374 (cond ((eq noerror nil)
2375 (error "Documentation group already exists"))
2380 (gnus-message 1 "Documentation group already exists")))
2383 (gnus-message 1 "Couldn't find doc group")
2384 (gnus-group-make-group
2385 (gnus-group-real-name name)
2386 (list 'nndoc "gnus-help"
2387 (list 'nndoc-address file)
2388 (list 'nndoc-article-type 'mbox))))
2390 (gnus-group-position-point))
2392 (defun gnus-group-make-doc-group (file type)
2393 "Create a group that uses a single file as the source."
2395 (list (read-file-name "File name: ")
2396 (and current-prefix-arg 'ask)))
2397 (when (eq type 'ask)
2402 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2404 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2405 ((= char ?b) 'babyl)
2406 ((= char ?d) 'digest)
2407 ((= char ?f) 'forward)
2409 ((= char ?g) 'guess)
2410 (t (setq err (format "%c unknown. " char))
2413 (let* ((file (expand-file-name file))
2414 (name (gnus-generate-new-group-name
2415 (gnus-group-prefixed-name
2416 (file-name-nondirectory file) '(nndoc "")))))
2417 (gnus-group-make-group
2418 (gnus-group-real-name name)
2420 (list 'nndoc-address file)
2421 (list 'nndoc-article-type (or type 'guess))))))
2423 (defvar nnweb-type-definition)
2424 (defvar gnus-group-web-type-history nil)
2425 (defvar gnus-group-web-search-history nil)
2426 (defun gnus-group-make-web-group (&optional solid)
2427 "Create an ephemeral nnweb group.
2428 If SOLID (the prefix), create a solid group."
2432 (if solid (gnus-read-group "Group name: ")
2433 (message-unique-id)))
2434 (default-type (or (car gnus-group-web-type-history)
2435 (symbol-name (caar nnweb-type-definition))))
2439 (format "Search engine type (default %s): " default-type)
2440 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2441 nnweb-type-definition)
2442 nil t nil 'gnus-group-web-type-history)
2447 (cons (or (car gnus-group-web-search-history) "") 0)
2448 'gnus-group-web-search-history))
2450 `(nnweb ,group (nnweb-search ,search)
2451 (nnweb-type ,(intern type))
2452 (nnweb-ephemeral-p t))))
2454 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2455 (gnus-group-read-ephemeral-group
2457 (cons (current-buffer)
2458 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2460 (defvar nnwarchive-type-definition)
2461 (defvar gnus-group-warchive-type-history nil)
2462 (defvar gnus-group-warchive-login-history nil)
2463 (defvar gnus-group-warchive-address-history nil)
2465 (defun gnus-group-make-warchive-group ()
2466 "Create a nnwarchive group."
2468 (require 'nnwarchive)
2469 (let* ((group (gnus-read-group "Group name: "))
2470 (default-type (or (car gnus-group-warchive-type-history)
2471 (symbol-name (caar nnwarchive-type-definition))))
2475 (format "Warchive type (default %s): " default-type)
2476 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2477 nnwarchive-type-definition)
2478 nil t nil 'gnus-group-warchive-type-history)
2480 (address (read-string "Warchive address: "
2481 nil 'gnus-group-warchive-address-history))
2482 (default-login (or (car gnus-group-warchive-login-history)
2487 (format "Warchive login (default %s): " user-mail-address)
2488 default-login 'gnus-group-warchive-login-history)
2491 `(nnwarchive ,address
2492 (nnwarchive-type ,(intern type))
2493 (nnwarchive-login ,login))))
2494 (gnus-group-make-group group method)))
2496 (defun gnus-group-make-archive-group (&optional all)
2497 "Create the (ding) Gnus archive group of the most recent articles.
2498 Given a prefix, create a full group."
2500 (let ((group (gnus-group-prefixed-name
2501 (if all "ding.archives" "ding.recent") '(nndir ""))))
2502 (when (gnus-gethash group gnus-newsrc-hashtb)
2503 (error "Archive group already exists"))
2504 (gnus-group-make-group
2505 (gnus-group-real-name group)
2506 (list 'nndir (if all "hpc" "edu")
2507 (list 'nndir-directory
2508 (if all gnus-group-archive-directory
2509 gnus-group-recent-archive-directory))))
2510 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2512 (defun gnus-group-make-directory-group (dir)
2513 "Create an nndir group.
2514 The user will be prompted for a directory. The contents of this
2515 directory will be used as a newsgroup. The directory should contain
2516 mail messages or news articles in files that have numeric names."
2518 (list (read-file-name "Create group from directory: ")))
2519 (unless (file-exists-p dir)
2520 (error "No such directory"))
2521 (unless (file-directory-p dir)
2522 (error "Not a directory"))
2526 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2528 (gnus-group-prefixed-name
2529 (expand-file-name ext dir)
2531 (setq ext (format "<%d>" (setq i (1+ i)))))
2532 (gnus-group-make-group
2533 (gnus-group-real-name group)
2534 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2536 (eval-when-compile (defvar nnkiboze-score-file))
2537 (defun gnus-group-make-kiboze-group (group address scores)
2538 "Create an nnkiboze group.
2539 The user will be prompted for a name, a regexp to match groups, and
2540 score file entries for articles to include in the group."
2543 (read-string "nnkiboze group name: ")
2544 (read-string "Source groups (regexp): ")
2545 (let ((headers (mapcar (lambda (group) (list group))
2546 '("subject" "from" "number" "date" "message-id"
2547 "references" "chars" "lines" "xref"
2548 "followup" "all" "body" "head")))
2549 scores header regexp regexps)
2550 (while (not (equal "" (setq header (completing-read
2551 "Match on header: " headers nil t))))
2553 (while (not (equal "" (setq regexp (read-string
2554 (format "Match on %s (regexp): "
2556 (push (list regexp nil nil 'r) regexps))
2557 (push (cons header regexps) scores))
2559 (gnus-group-make-group group "nnkiboze" address)
2560 (let* ((nnkiboze-current-group group)
2561 (score-file (car (nnkiboze-score-file "")))
2562 (score-dir (file-name-directory score-file)))
2563 (unless (file-exists-p score-dir)
2564 (make-directory score-dir))
2565 (with-temp-file score-file
2566 (let (emacs-lisp-mode-hook)
2567 (pp scores (current-buffer))))))
2569 (defun gnus-group-add-to-virtual (n vgroup)
2570 "Add the current group to a virtual group."
2572 (list current-prefix-arg
2573 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2575 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2576 (error "%s is not an nnvirtual group" vgroup))
2577 (gnus-close-group vgroup)
2578 (let* ((groups (gnus-group-process-prefix n))
2579 (method (gnus-info-method (gnus-get-info vgroup))))
2580 (setcar (cdr method)
2582 (nth 1 method) "\\|"
2585 (gnus-group-remove-mark s)
2586 (concat "\\(^" (regexp-quote s) "$\\)"))
2588 (gnus-group-position-point))
2590 (defun gnus-group-make-empty-virtual (group)
2591 "Create a new, fresh, empty virtual group."
2592 (interactive "sCreate new, empty virtual group: ")
2593 (let* ((method (list 'nnvirtual "^$"))
2594 (pgroup (gnus-group-prefixed-name group method)))
2595 ;; Check whether it exists already.
2596 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2597 (error "Group %s already exists" pgroup))
2598 ;; Subscribe the new group after the group on the current line.
2599 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2600 (gnus-group-update-group pgroup)
2602 (gnus-group-position-point)))
2604 (defun gnus-group-enter-directory (dir)
2605 "Enter an ephemeral nneething group."
2606 (interactive "DDirectory to read: ")
2607 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2608 (leaf (gnus-group-prefixed-name
2609 (file-name-nondirectory (directory-file-name dir))
2611 (name (gnus-generate-new-group-name leaf)))
2612 (unless (gnus-group-read-ephemeral-group
2614 (cons (current-buffer)
2615 (if (eq major-mode 'gnus-summary-mode)
2617 (error "Couldn't enter %s" dir))))
2620 (autoload 'nnimap-expunge "nnimap")
2621 (autoload 'nnimap-acl-get "nnimap")
2622 (autoload 'nnimap-acl-edit "nnimap"))
2624 (defun gnus-group-nnimap-expunge (group)
2625 "Expunge deleted articles in current nnimap GROUP."
2626 (interactive (list (gnus-group-group-name)))
2627 (let ((mailbox (gnus-group-real-name group)) method)
2629 (error "No group on current line"))
2630 (unless (gnus-get-info group)
2631 (error "Killed group; can't be edited"))
2632 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2633 (error "%s is not an nnimap group" group))
2634 (nnimap-expunge mailbox (cadr method))))
2636 (defun gnus-group-nnimap-edit-acl (group)
2637 "Edit the Access Control List of current nnimap GROUP."
2638 (interactive (list (gnus-group-group-name)))
2639 (let ((mailbox (gnus-group-real-name group)) method acl)
2641 (error "No group on current line"))
2642 (unless (gnus-get-info group)
2643 (error "Killed group; can't be edited"))
2644 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2645 (error "%s is not an nnimap group" group))
2646 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2647 (error "Server does not support ACL's"))
2648 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2650 An access control list is a list of (identifier . rights) elements.
2652 The identifier string specifies the corresponding user. The
2653 identifier \"anyone\" is reserved to refer to the universal identity.
2655 Rights is a string listing a (possibly empty) set of alphanumeric
2656 characters, each character listing a set of operations which is being
2657 controlled. Letters are reserved for ``standard'' rights, listed
2658 below. Digits are reserved for implementation or site defined rights.
2660 l - lookup (mailbox is visible to LIST/LSUB commands)
2661 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2662 SEARCH, COPY from mailbox)
2663 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2664 w - write (STORE flags other than \\SEEN and \\DELETED)
2665 i - insert (perform APPEND, COPY into mailbox)
2666 p - post (send mail to submission address for mailbox,
2667 not enforced by IMAP4 itself)
2668 c - create and delete mailbox (CREATE new sub-mailboxes in any
2669 implementation-defined hierarchy, RENAME or DELETE mailbox)
2670 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2671 a - administer (perform SETACL)" group)
2674 ,mailbox ',method ',acl form)))))
2676 ;; Group sorting commands
2677 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2679 (defun gnus-group-sort-groups (func &optional reverse)
2680 "Sort the group buffer according to FUNC.
2681 When used interactively, the sorting function used will be
2682 determined by the `gnus-group-sort-function' variable.
2683 If REVERSE (the prefix), reverse the sorting order."
2684 (interactive (list gnus-group-sort-function current-prefix-arg))
2685 (funcall gnus-group-sort-alist-function
2686 (gnus-make-sort-function func) reverse)
2687 (gnus-group-unmark-all-groups)
2688 (gnus-group-list-groups)
2689 (gnus-dribble-touch))
2691 (defun gnus-group-sort-flat (func reverse)
2692 ;; We peel off the dummy group from the alist.
2694 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2695 (pop gnus-newsrc-alist))
2697 (setq gnus-newsrc-alist
2698 (sort gnus-newsrc-alist func))
2700 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2701 ;; Regenerate the hash table.
2702 (gnus-make-hashtable-from-newsrc-alist)))
2704 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2705 "Sort the group buffer alphabetically by group name.
2706 If REVERSE, sort in reverse order."
2708 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2710 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2711 "Sort the group buffer alphabetically by real (unprefixed) group name.
2712 If REVERSE, sort in reverse order."
2714 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2716 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2717 "Sort the group buffer by number of unread articles.
2718 If REVERSE, sort in reverse order."
2720 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2722 (defun gnus-group-sort-groups-by-level (&optional reverse)
2723 "Sort the group buffer by group level.
2724 If REVERSE, sort in reverse order."
2726 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2728 (defun gnus-group-sort-groups-by-score (&optional reverse)
2729 "Sort the group buffer by group score.
2730 If REVERSE, sort in reverse order."
2732 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2734 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2735 "Sort the group buffer by group rank.
2736 If REVERSE, sort in reverse order."
2738 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2740 (defun gnus-group-sort-groups-by-method (&optional reverse)
2741 "Sort the group buffer alphabetically by backend name.
2742 If REVERSE, sort in reverse order."
2744 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2746 (defun gnus-group-sort-groups-by-server (&optional reverse)
2747 "Sort the group buffer alphabetically by server name.
2748 If REVERSE, sort in reverse order."
2750 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2752 ;;; Selected group sorting.
2754 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2755 "Sort the process/prefixed groups."
2756 (interactive (list current-prefix-arg gnus-group-sort-function))
2757 (let ((groups (gnus-group-process-prefix n)))
2758 (funcall gnus-group-sort-selected-function
2759 groups (gnus-make-sort-function func) reverse)
2760 (gnus-group-unmark-all-groups)
2761 (gnus-group-list-groups)
2762 (gnus-dribble-touch)))
2764 (defun gnus-group-sort-selected-flat (groups func reverse)
2765 (let (entries infos)
2766 ;; First find all the group entries for these groups.
2768 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2770 ;; Then sort the infos.
2774 (lambda (entry) (car entry))
2775 (setq entries (nreverse entries)))
2778 (setq infos (nreverse infos)))
2779 ;; Go through all the infos and replace the old entries
2780 ;; with the new infos.
2782 (setcar (car entries) (pop infos))
2784 ;; Update the hashtable.
2785 (gnus-make-hashtable-from-newsrc-alist)))
2787 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2788 "Sort the group buffer alphabetically by group name.
2789 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2790 sort in reverse order."
2791 (interactive (gnus-interactive "P\ny"))
2792 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2794 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2795 "Sort the group buffer alphabetically by real group name.
2796 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2797 sort in reverse order."
2798 (interactive (gnus-interactive "P\ny"))
2799 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2801 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2802 "Sort the group buffer by number of unread articles.
2803 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2804 sort in reverse order."
2805 (interactive (gnus-interactive "P\ny"))
2806 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2808 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2809 "Sort the group buffer by group level.
2810 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2811 sort in reverse order."
2812 (interactive (gnus-interactive "P\ny"))
2813 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2815 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2816 "Sort the group buffer by group score.
2817 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2818 sort in reverse order."
2819 (interactive (gnus-interactive "P\ny"))
2820 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2822 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2823 "Sort the group buffer by group rank.
2824 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2825 sort in reverse order."
2826 (interactive (gnus-interactive "P\ny"))
2827 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2829 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2830 "Sort the group buffer alphabetically by backend name.
2831 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2832 sort in reverse order."
2833 (interactive (gnus-interactive "P\ny"))
2834 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2836 ;;; Sorting predicates.
2838 (defun gnus-group-sort-by-alphabet (info1 info2)
2839 "Sort alphabetically."
2840 (string< (gnus-info-group info1) (gnus-info-group info2)))
2842 (defun gnus-group-sort-by-real-name (info1 info2)
2843 "Sort alphabetically on real (unprefixed) names."
2844 (string< (gnus-group-real-name (gnus-info-group info1))
2845 (gnus-group-real-name (gnus-info-group info2))))
2847 (defun gnus-group-sort-by-unread (info1 info2)
2848 "Sort by number of unread articles."
2849 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2850 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2851 (< (or (and (numberp n1) n1) 0)
2852 (or (and (numberp n2) n2) 0))))
2854 (defun gnus-group-sort-by-level (info1 info2)
2856 (< (gnus-info-level info1) (gnus-info-level info2)))
2858 (defun gnus-group-sort-by-method (info1 info2)
2859 "Sort alphabetically by backend name."
2860 (string< (symbol-name (car (gnus-find-method-for-group
2861 (gnus-info-group info1) info1)))
2862 (symbol-name (car (gnus-find-method-for-group
2863 (gnus-info-group info2) info2)))))
2865 (defun gnus-group-sort-by-server (info1 info2)
2866 "Sort alphabetically by server name."
2867 (string< (gnus-method-to-full-server-name
2868 (gnus-find-method-for-group
2869 (gnus-info-group info1) info1))
2870 (gnus-method-to-full-server-name
2871 (gnus-find-method-for-group
2872 (gnus-info-group info2) info2))))
2874 (defun gnus-group-sort-by-score (info1 info2)
2875 "Sort by group score."
2876 (> (gnus-info-score info1) (gnus-info-score info2)))
2878 (defun gnus-group-sort-by-rank (info1 info2)
2879 "Sort by level and score."
2880 (let ((level1 (gnus-info-level info1))
2881 (level2 (gnus-info-level info2)))
2882 (or (< level1 level2)
2883 (and (= level1 level2)
2884 (> (gnus-info-score info1) (gnus-info-score info2))))))
2888 (defun gnus-group-clear-data (&optional arg)
2889 "Clear all marks and read ranges from the current group."
2891 (gnus-group-iterate arg
2894 (gnus-info-clear-data (setq info (gnus-get-info group)))
2895 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2896 (when (gnus-group-goto-group group)
2897 (gnus-group-update-group-line))))))
2899 (defun gnus-group-clear-data-on-native-groups ()
2900 "Clear all marks and read ranges from all native groups."
2902 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2903 (let ((alist (cdr gnus-newsrc-alist))
2905 (while (setq info (pop alist))
2906 (when (gnus-group-native-p (gnus-info-group info))
2907 (gnus-info-clear-data info)))
2908 (gnus-get-unread-articles)
2909 (gnus-dribble-touch)
2910 (when (gnus-y-or-n-p
2911 "Move the cache away to avoid problems in the future? ")
2912 (call-interactively 'gnus-cache-move-cache)))))
2914 (defun gnus-info-clear-data (info)
2915 "Clear all marks and read ranges from INFO."
2916 (let ((group (gnus-info-group info))
2918 (dolist (el (gnus-info-marks info))
2919 (push `(,(cdr el) add (,(car el))) action))
2920 (push `(,(gnus-info-read info) add (read)) action)
2923 (gnus-request-set-mark ,group ',action)
2924 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2925 (gnus-info-set-read ',info ',(gnus-info-read info))
2926 (when (gnus-group-goto-group ,group)
2927 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2928 (gnus-group-update-group-line))))
2929 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2931 (gnus-request-set-mark group action)
2932 (gnus-info-set-read info nil)
2933 (when (gnus-info-marks info)
2934 (gnus-info-set-marks info nil))))
2936 ;; Group catching up.
2938 (defun gnus-group-catchup-current (&optional n all)
2939 "Mark all unread articles in the current newsgroup as read.
2940 If prefix argument N is numeric, the next N newsgroups will be
2941 caught up. If ALL is non-nil, marked articles will also be marked as
2942 read. Cross references (Xref: header) of articles are ignored.
2943 The number of newsgroups that this function was unable to catch
2946 (let ((groups (gnus-group-process-prefix n))
2949 (unless groups (error "No groups selected"))
2951 (or (not gnus-interactive-catchup) ;Without confirmation?
2956 "Do you really want to mark all articles in %s as read? "
2957 "Mark all unread articles in %s as read? ")
2958 (if (= (length groups) 1)
2960 (format "these %d groups" (length groups)))))))
2962 (while (setq group (pop groups))
2963 (gnus-group-remove-mark group)
2964 ;; Virtual groups have to be given special treatment.
2965 (let ((method (gnus-find-method-for-group group)))
2966 (when (eq 'nnvirtual (car method))
2967 (nnvirtual-catchup-group
2968 (gnus-group-real-name group) (nth 1 method) all)))
2969 (if (>= (gnus-group-level group) gnus-level-zombie)
2970 (gnus-message 2 "Dead groups can't be caught up")
2972 (gnus-group-goto-group group)
2973 (gnus-group-catchup group all))
2974 (gnus-group-update-group-line)
2975 (setq ret (1+ ret)))))
2976 (gnus-group-next-unread-group 1)
2979 (defun gnus-group-catchup-current-all (&optional n)
2980 "Mark all articles in current newsgroup as read.
2981 Cross references (Xref: header) of articles are ignored."
2983 (gnus-group-catchup-current n 'all))
2985 (defun gnus-group-catchup (group &optional all)
2986 "Mark all articles in GROUP as read.
2987 If ALL is non-nil, all articles are marked as read.
2988 The return value is the number of articles that were marked as read,
2989 or nil if no action could be taken."
2990 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2992 (marks (nth 3 (nth 2 entry)))
2993 (unread (gnus-list-of-unread-articles group)))
2994 ;; Remove entries for this group.
2995 (nnmail-purge-split-history (gnus-group-real-name group))
2996 ;; Do the updating only if the newsgroup isn't killed.
2997 (if (not (numberp (car entry)))
2998 (gnus-message 1 "Can't catch up %s; non-active group" group)
2999 (gnus-update-read-articles group nil)
3001 ;; Nix out the lists of marks and dormants.
3002 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3004 (list (cdr (assq 'dormant marks))
3006 (setq unread (gnus-uncompress-range
3007 (gnus-range-add (gnus-range-add
3008 unread (cdr (assq 'dormant marks)))
3009 (cdr (assq 'tick marks)))))
3010 (gnus-add-marked-articles group 'tick nil nil 'force)
3011 (gnus-add-marked-articles group 'dormant nil nil 'force))
3012 ;; Do auto-expirable marks if that's required.
3013 (when (gnus-group-auto-expirable-p group)
3014 (gnus-add-marked-articles group 'expire unread)
3015 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3016 (let ((gnus-newsgroup-name group))
3017 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3020 (defun gnus-group-expire-articles (&optional n)
3021 "Expire all expirable articles in the current newsgroup."
3023 (let ((groups (gnus-group-process-prefix n))
3026 (error "No groups to expire"))
3027 (while (setq group (pop groups))
3028 (gnus-group-remove-mark group)
3029 (gnus-group-expire-articles-1 group)
3030 (gnus-dribble-touch)
3031 (gnus-group-position-point))))
3033 (defun gnus-group-expire-articles-1 (group)
3034 (when (gnus-check-backend-function 'request-expire-articles group)
3035 (gnus-message 6 "Expiring articles in %s..." group)
3036 (let* ((info (gnus-get-info group))
3037 (expirable (if (gnus-group-total-expirable-p group)
3038 (cons nil (gnus-list-of-read-articles group))
3039 (assq 'expire (gnus-info-marks info))))
3040 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3041 (nnmail-expiry-target
3042 (or (gnus-group-find-parameter group 'expiry-target)
3043 nnmail-expiry-target)))
3045 (gnus-check-group group)
3048 (gnus-compress-sequence
3050 ;; We set the expiry variables to the group
3052 (let ((nnmail-expiry-wait-function nil)
3053 (nnmail-expiry-wait expiry-wait))
3054 (gnus-request-expire-articles
3055 (gnus-uncompress-sequence (cdr expirable)) group))
3056 ;; Just expire using the normal expiry values.
3057 (gnus-request-expire-articles
3058 (gnus-uncompress-sequence (cdr expirable)) group))))
3059 (gnus-close-group group))
3060 (gnus-message 6 "Expiring articles in %s...done" group)
3061 ;; Return the list of un-expired articles.
3064 (defun gnus-group-expire-all-groups ()
3065 "Expire all expirable articles in all newsgroups."
3068 (gnus-message 5 "Expiring...")
3069 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3070 (cdr gnus-newsrc-alist))))
3071 (gnus-group-expire-articles nil)))
3072 (gnus-group-position-point)
3073 (gnus-message 5 "Expiring...done"))
3075 (defun gnus-group-set-current-level (n level)
3076 "Set the level of the next N groups to LEVEL."
3081 (let ((s (read-string
3082 (format "Level (default %s): "
3083 (or (gnus-group-group-level)
3084 gnus-level-default-subscribed)))))
3085 (if (string-match "^\\s-*$" s)
3086 (int-to-string (or (gnus-group-group-level)
3087 gnus-level-default-subscribed))
3089 (unless (and (>= level 1) (<= level gnus-level-killed))
3090 (error "Invalid level: %d" level))
3091 (let ((groups (gnus-group-process-prefix n))
3093 (while (setq group (pop groups))
3094 (gnus-group-remove-mark group)
3095 (gnus-message 6 "Changed level of %s from %d to %d"
3096 group (or (gnus-group-group-level) gnus-level-killed)
3098 (gnus-group-change-level
3099 group level (or (gnus-group-group-level) gnus-level-killed))
3100 (gnus-group-update-group-line)))
3101 (gnus-group-position-point))
3103 (defun gnus-group-unsubscribe (&optional n)
3104 "Unsubscribe the current group."
3106 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3108 (defun gnus-group-subscribe (&optional n)
3109 "Subscribe the current group."
3111 (gnus-group-unsubscribe-current-group n 'subscribe))
3113 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3114 "Toggle subscription of the current group.
3115 If given numerical prefix, toggle the N next groups."
3117 (let ((groups (gnus-group-process-prefix n))
3120 (setq group (car groups)
3121 groups (cdr groups))
3122 (gnus-group-remove-mark group)
3123 (gnus-group-unsubscribe-group
3126 ((eq do-sub 'unsubscribe)
3127 gnus-level-default-unsubscribed)
3128 ((eq do-sub 'subscribe)
3129 gnus-level-default-subscribed)
3130 ((<= (gnus-group-group-level) gnus-level-subscribed)
3131 gnus-level-default-unsubscribed)
3133 gnus-level-default-subscribed))
3135 (gnus-group-update-group-line))
3136 (gnus-group-next-group 1)))
3138 (defun gnus-group-unsubscribe-group (group &optional level silent)
3139 "Toggle subscription to GROUP.
3140 Killed newsgroups are subscribed. If SILENT, don't try to update the
3143 (list (completing-read
3144 "Group: " gnus-active-hashtb nil
3145 (gnus-read-active-file-p)
3147 'gnus-group-history)))
3148 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3150 ((string-match "^[ \t]*$" group)
3151 (error "Empty group name"))
3153 ;; Toggle subscription flag.
3154 (gnus-group-change-level
3155 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3156 gnus-level-subscribed)
3157 (1+ gnus-level-subscribed)
3158 gnus-level-default-subscribed)))
3160 (gnus-group-update-group group)))
3161 ((and (stringp group)
3162 (or (not (gnus-read-active-file-p))
3163 (gnus-active group)))
3164 ;; Add new newsgroup.
3165 (gnus-group-change-level
3167 (if level level gnus-level-default-subscribed)
3168 (or (and (member group gnus-zombie-list)
3171 (when (gnus-group-group-name)
3172 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3174 (gnus-group-update-group group)))
3175 (t (error "No such newsgroup: %s" group)))
3176 (gnus-group-position-point)))
3178 (defun gnus-group-transpose-groups (n)
3179 "Move the current newsgroup up N places.
3180 If given a negative prefix, move down instead. The difference between
3181 N and the number of steps taken is returned."
3183 (unless (gnus-group-group-name)
3184 (error "No group on current line"))
3185 (gnus-group-kill-group 1)
3187 (forward-line (- n))
3188 (gnus-group-yank-group)
3189 (gnus-group-position-point)))
3191 (defun gnus-group-kill-all-zombies (&optional dummy)
3192 "Kill all zombie newsgroups.
3193 The optional DUMMY should always be nil."
3194 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3196 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3197 (setq gnus-zombie-list nil)
3198 (gnus-dribble-touch)
3199 (gnus-group-list-groups)))
3201 (defun gnus-group-kill-region (begin end)
3202 "Kill newsgroups in current region (excluding current point).
3203 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3218 (beginning-of-line) ;Important when LINES < 1
3219 (gnus-group-kill-group lines)))
3221 (defun gnus-group-kill-group (&optional n discard)
3222 "Kill the next N groups.
3223 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3224 However, only groups that were alive can be yanked; already killed
3225 groups or zombie groups can't be yanked.
3226 The return value is the name of the group that was killed, or a list
3229 (let ((buffer-read-only nil)
3230 (groups (gnus-group-process-prefix n))
3231 group entry level out)
3232 (if (< (length groups) 10)
3233 ;; This is faster when there are few groups.
3235 (push (setq group (pop groups)) out)
3236 (gnus-group-remove-mark group)
3237 (setq level (gnus-group-group-level))
3239 (when (and (not discard)
3240 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3243 (gnus-group-goto-group ,(gnus-group-group-name))
3244 (gnus-group-yank-group)))
3245 (push (cons (car entry) (nth 2 entry))
3246 gnus-list-of-killed-groups))
3247 (gnus-group-change-level
3248 (if entry entry group) gnus-level-killed (if entry nil level))
3249 (message "Killed group %s" group))
3250 ;; If there are lots and lots of groups to be killed, we use
3251 ;; this thing instead.
3253 (setq groups (nreverse groups))
3255 (gnus-group-remove-mark (setq group (pop groups)))
3257 (push group gnus-killed-list)
3258 (setq gnus-newsrc-alist
3259 (delq (assoc group gnus-newsrc-alist)
3261 (when gnus-group-change-level-function
3262 (funcall gnus-group-change-level-function
3263 group gnus-level-killed 3))
3265 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3266 (push (cons (car entry) (nth 2 entry))
3267 gnus-list-of-killed-groups)
3268 (setcdr (cdr entry) (cdddr entry)))
3269 ((member group gnus-zombie-list)
3270 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3271 ;; There may be more than one instance displayed.
3272 (while (gnus-group-goto-group group)
3273 (gnus-delete-line)))
3274 (gnus-make-hashtable-from-newsrc-alist)))
3276 (gnus-group-position-point)
3277 (if (< (length out) 2) (car out) (nreverse out))))
3279 (defun gnus-group-yank-group (&optional arg)
3280 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3281 The numeric ARG specifies how many newsgroups are to be yanked. The
3282 name of the newsgroup yanked is returned, or (if several groups are
3283 yanked) a list of yanked groups is returned."
3285 (setq arg (or arg 1))
3286 (let (info group prev out)
3287 (while (>= (decf arg) 0)
3288 (when (not (setq info (pop gnus-list-of-killed-groups)))
3289 (error "No more newsgroups to yank"))
3290 (push (setq group (nth 1 info)) out)
3291 ;; Find which newsgroup to insert this one before - search
3292 ;; backward until something suitable is found. If there are no
3293 ;; other newsgroups in this buffer, just make this newsgroup the
3295 (setq prev (gnus-group-group-name))
3296 (gnus-group-change-level
3297 info (gnus-info-level (cdr info)) gnus-level-killed
3298 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3300 (gnus-group-insert-group-line-info group)
3302 `(when (gnus-group-goto-group ,group)
3303 (gnus-group-kill-group 1))))
3305 (gnus-group-position-point)
3306 (if (< (length out) 2) (car out) (nreverse out))))
3308 (defun gnus-group-kill-level (level)
3309 "Kill all groups that is on a certain LEVEL."
3310 (interactive "nKill all groups on level: ")
3312 ((= level gnus-level-zombie)
3313 (setq gnus-killed-list
3314 (nconc gnus-zombie-list gnus-killed-list))
3315 (setq gnus-zombie-list nil))
3316 ((and (< level gnus-level-zombie)
3318 (or gnus-expert-user
3321 "Do you really want to kill all groups on level %d? "
3323 (let* ((prev gnus-newsrc-alist)
3326 (if (= (gnus-info-level (car alist)) level)
3328 (push (gnus-info-group (car alist)) gnus-killed-list)
3329 (setcdr prev (cdr alist)))
3331 (setq alist (cdr alist)))
3332 (gnus-make-hashtable-from-newsrc-alist)
3333 (gnus-group-list-groups)))
3335 (error "Can't kill; invalid level: %d" level))))
3337 (defun gnus-group-list-all-groups (&optional arg)
3338 "List all newsgroups with level ARG or lower.
3339 Default is gnus-level-unsubscribed, which lists all subscribed and most
3340 unsubscribed groups."
3342 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3344 ;; Redefine this to list ALL killed groups if prefix arg used.
3345 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3346 (defun gnus-group-list-killed (&optional arg)
3347 "List all killed newsgroups in the group buffer.
3348 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3349 entail asking the server for the groups."
3351 ;; Find all possible killed newsgroups if arg.
3353 (gnus-get-killed-groups))
3354 (if (not gnus-killed-list)
3355 (gnus-message 6 "No killed groups")
3356 (let (gnus-group-list-mode)
3357 (funcall gnus-group-prepare-function
3358 gnus-level-killed t gnus-level-killed))
3359 (goto-char (point-min)))
3360 (gnus-group-position-point))
3362 (defun gnus-group-list-zombies ()
3363 "List all zombie newsgroups in the group buffer."
3365 (if (not gnus-zombie-list)
3366 (gnus-message 6 "No zombie groups")
3367 (let (gnus-group-list-mode)
3368 (funcall gnus-group-prepare-function
3369 gnus-level-zombie t gnus-level-zombie))
3370 (goto-char (point-min)))
3371 (gnus-group-position-point))
3373 (defun gnus-group-list-active ()
3374 "List all groups that are available from the server(s)."
3376 ;; First we make sure that we have really read the active file.
3377 (unless (gnus-read-active-file-p)
3378 (let ((gnus-read-active-file t)
3379 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3380 (gnus-read-active-file)))
3381 ;; Find all groups and sort them.
3389 (push (symbol-name sym) list)))
3393 (buffer-read-only nil)
3397 (setq group (pop groups))
3398 (gnus-add-text-properties
3399 (point) (prog1 (1+ (point))
3401 (gnus-group-decoded-name group)
3403 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3405 'gnus-level (inline (gnus-group-level group)))))
3406 (goto-char (point-min))))
3408 (defun gnus-activate-all-groups (level)
3409 "Activate absolutely all groups."
3410 (interactive (list gnus-level-unsubscribed))
3411 (let ((gnus-activate-level level)
3412 (gnus-activate-foreign-newsgroups level))
3413 (gnus-group-get-new-news)))
3415 (defun gnus-group-get-new-news (&optional arg)
3416 "Get newly arrived articles.
3417 If ARG is a number, it specifies which levels you are interested in
3418 re-scanning. If ARG is non-nil and not a number, this will force
3419 \"hard\" re-reading of the active files from all servers."
3422 (let ((gnus-inhibit-demon t)
3423 ;; Binding this variable will inhibit multiple fetchings
3424 ;; of the same mail source.
3425 (nnmail-fetched-sources (list t)))
3426 (gnus-run-hooks 'gnus-get-new-news-hook)
3428 ;; Read any slave files.
3430 (gnus-master-read-slave-newsrc))
3432 ;; We might read in new NoCeM messages here.
3433 (when (and gnus-use-nocem
3435 (gnus-nocem-scan-groups))
3436 ;; If ARG is not a number, then we read the active file.
3437 (when (and arg (not (numberp arg)))
3438 (let ((gnus-read-active-file t))
3439 (gnus-read-active-file))
3442 ;; If the user wants it, we scan for new groups.
3443 (when (eq gnus-check-new-newsgroups 'always)
3444 (gnus-find-new-newsgroups)))
3446 (setq arg (gnus-group-default-level arg t))
3447 (if (and gnus-read-active-file (not arg))
3449 (gnus-read-active-file)
3450 (gnus-get-unread-articles arg))
3451 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3452 (gnus-get-unread-articles arg)))
3453 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3454 (gnus-group-list-groups (and (numberp arg)
3455 (max (car gnus-group-list-mode) arg)))))
3457 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3458 "Check for newly arrived news in the current group (and the N-1 next groups).
3459 The difference between N and the number of newsgroup checked is returned.
3460 If N is negative, this group and the N-1 previous groups will be checked."
3462 (let* ((groups (gnus-group-process-prefix n))
3463 (ret (if (numberp n) (- n (length groups)) 0))
3467 (gnus-inhibit-demon t)
3468 ;; Binding this variable will inhibit multiple fetchings
3469 ;; of the same mail source.
3470 (nnmail-fetched-sources (list t)))
3471 (gnus-run-hooks 'gnus-get-new-news-hook)
3472 (while (setq group (pop groups))
3473 (gnus-group-remove-mark group)
3474 ;; Bypass any previous denials from the server.
3475 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3476 (if (gnus-activate-group group (if dont-scan nil 'scan))
3478 (gnus-get-unread-articles-in-group
3479 (gnus-get-info group) (gnus-active group) t)
3480 (unless (gnus-virtual-group-p group)
3481 (gnus-close-group group))
3483 (gnus-agent-save-group-info
3484 method (gnus-group-real-name group) (gnus-active group)))
3485 (gnus-group-update-group group))
3486 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3488 (gnus-error 3 "Server denied access")
3489 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3492 (when gnus-goto-next-group-when-activating
3493 (gnus-group-next-unread-group 1 t))
3494 (gnus-summary-position-point)
3497 (defun gnus-group-fetch-faq (group &optional faq-dir)
3498 "Fetch the FAQ for the current group.
3499 If given a prefix argument, prompt for the FAQ dir
3503 (gnus-group-group-name)
3504 (when current-prefix-arg
3506 "Faq dir: " (and (listp gnus-group-faq-directory)
3508 gnus-group-faq-directory))))))
3510 (error "No group name given"))
3511 (let ((dirs (or faq-dir gnus-group-faq-directory))
3513 (unless (listp dirs)
3514 (setq dirs (list dirs)))
3515 (while (and (not found)
3516 (setq dir (pop dirs)))
3517 (let ((name (gnus-group-real-name group)))
3518 (setq file (expand-file-name name dir)))
3519 (if (not (file-exists-p file))
3520 (gnus-message 1 "No such file: %s" file)
3521 (let ((enable-local-variables nil))
3525 (defun gnus-group-fetch-charter (group)
3526 "Fetch the charter for the current group."
3528 (list (or (gnus-group-group-name)
3529 gnus-newsgroup-name)))
3531 (error "No group name given"))
3532 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3534 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3535 (setq hierarchy (match-string 1 name))
3536 (if (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3537 (browse-url (eval url))
3538 (gnus-group-fetch-control group)))))
3540 (defun gnus-group-fetch-control (group)
3541 "Fetch the archived control messages for the current group."
3543 (list (or (gnus-group-group-name)
3544 gnus-newsgroup-name)))
3546 (error "No group name given"))
3547 (let ((name (gnus-group-real-name group))
3549 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3550 (setq hierarchy (match-string 1 name))
3551 (if gnus-group-fetch-control-use-browse-url
3552 (browse-url (concat "ftp://ftp.isc.org:/usenet/control/"
3553 hierarchy "/" name ".Z"))
3554 (let ((enable-local-variables nil))
3555 (gnus-group-read-ephemeral-group
3557 `(nndoc ,group (nndoc-address
3558 ,(find-file-noselect
3559 (concat "/ftp@ftp.isc.org:/usenet/control/"
3560 hierarchy "/" name ".Z")))
3561 (nndoc-article-type mbox)) t nil nil))))))
3563 (defun gnus-group-describe-group (force &optional group)
3564 "Display a description of the current newsgroup."
3565 (interactive (list current-prefix-arg (gnus-group-group-name)))
3566 (let* ((method (gnus-find-method-for-group group))
3567 (mname (gnus-group-prefixed-name "" method))
3570 gnus-description-hashtb)
3571 (gnus-sethash mname nil gnus-description-hashtb))
3573 (error "No group name given"))
3574 (when (or (and gnus-description-hashtb
3575 ;; We check whether this group's method has been
3576 ;; queried for a description file.
3577 (gnus-gethash mname gnus-description-hashtb))
3578 (setq desc (gnus-group-get-description group))
3579 (gnus-read-descriptions-file method))
3581 (or desc (gnus-gethash group gnus-description-hashtb)
3582 "No description available")))))
3584 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3585 (defun gnus-group-describe-all-groups (&optional force)
3586 "Pop up a buffer with descriptions of all newsgroups."
3589 (setq gnus-description-hashtb nil))
3590 (when (not (or gnus-description-hashtb
3591 (gnus-read-all-descriptions-files)))
3592 (error "Couldn't request descriptions file"))
3593 (let ((buffer-read-only nil)
3599 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3600 (insert (format " *: %-20s %s\n"
3601 (gnus-group-name-decode
3602 (symbol-name group) charset)
3603 (gnus-group-name-decode
3604 (symbol-value group) charset))))
3605 (gnus-add-text-properties
3606 b (1+ b) (list 'gnus-group group
3607 'gnus-unread t 'gnus-marked nil
3608 'gnus-level (1+ gnus-level-subscribed))))
3609 gnus-description-hashtb)
3610 (goto-char (point-min))
3611 (gnus-group-position-point)))
3613 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3614 (defun gnus-group-apropos (regexp &optional search-description)
3615 "List all newsgroups that have names that match a regexp."
3616 (interactive "sGnus apropos (regexp): ")
3618 (obuf (current-buffer))
3620 ;; Go through all newsgroups that are known to Gnus.
3623 (and (symbol-name group)
3624 (string-match regexp (symbol-name group))
3625 (symbol-value group)
3626 (push (symbol-name group) groups)))
3628 ;; Also go through all descriptions that are known to Gnus.
3629 (when search-description
3632 (and (string-match regexp (symbol-value group))
3633 (push (symbol-name group) groups)))
3634 gnus-description-hashtb))
3636 (gnus-message 3 "No groups matched \"%s\"." regexp)
3637 ;; Print out all the groups.
3639 (pop-to-buffer "*Gnus Help*")
3640 (buffer-disable-undo)
3642 (setq groups (sort groups 'string<))
3644 ;; Groups may be entered twice into the list of groups.
3645 (when (not (string= (car groups) prev))
3646 (setq prev (car groups))
3647 (let ((charset (gnus-group-name-charset nil prev)))
3648 (insert (gnus-group-name-decode prev charset) "\n")
3649 (when (and gnus-description-hashtb
3650 (setq des (gnus-gethash (car groups)
3651 gnus-description-hashtb)))
3652 (insert " " (gnus-group-name-decode des charset) "\n"))))
3653 (setq groups (cdr groups)))
3654 (goto-char (point-min))))
3655 (pop-to-buffer obuf)))
3657 (defun gnus-group-description-apropos (regexp)
3658 "List all newsgroups that have names or descriptions that match a regexp."
3659 (interactive "sGnus description apropos (regexp): ")
3660 (when (not (or gnus-description-hashtb
3661 (gnus-read-all-descriptions-files)))
3662 (error "Couldn't request descriptions file"))
3663 (gnus-group-apropos regexp t))
3665 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3666 (defun gnus-group-list-matching (level regexp &optional all lowest)
3667 "List all groups with unread articles that match REGEXP.
3668 If the prefix LEVEL is non-nil, it should be a number that says which
3669 level to cut off listing groups.
3670 If ALL, also list groups with no unread articles.
3671 If LOWEST, don't list groups with level lower than LOWEST.
3673 This command may read the active file."
3674 (interactive "P\nsList newsgroups matching: ")
3675 ;; First make sure active file has been read.
3677 (> (prefix-numeric-value level) gnus-level-killed))
3678 (gnus-get-killed-groups))
3679 (funcall gnus-group-prepare-function
3680 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3681 (goto-char (point-min))
3682 (gnus-group-position-point))
3684 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3685 "List all groups that match REGEXP.
3686 If the prefix LEVEL is non-nil, it should be a number that says which
3687 level to cut off listing groups.
3688 If LOWEST, don't list groups with level lower than LOWEST."
3689 (interactive "P\nsList newsgroups matching: ")
3691 (setq level (prefix-numeric-value level)))
3692 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3694 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3695 (defun gnus-group-save-newsrc (&optional force)
3696 "Save the Gnus startup files.
3697 If FORCE, force saving whether it is necessary or not."
3699 (gnus-save-newsrc-file force))
3701 (defun gnus-group-restart (&optional arg)
3702 "Force Gnus to read the .newsrc file."
3704 (when (gnus-yes-or-no-p
3705 (format "Are you sure you want to restart Gnus? "))
3706 (gnus-save-newsrc-file)
3710 (defun gnus-group-read-init-file ()
3711 "Read the Gnus elisp init file."
3713 (gnus-read-init-file)
3714 (gnus-message 5 "Read %s" gnus-init-file))
3716 (defun gnus-group-check-bogus-groups (&optional silent)
3717 "Check bogus newsgroups.
3718 If given a prefix, don't ask for confirmation before removing a bogus
3721 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3722 (gnus-group-list-groups))
3724 (defun gnus-group-find-new-groups (&optional arg)
3725 "Search for new groups and add them.
3726 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3727 With 1 C-u, use the `ask-server' method to query the server for new
3729 With 2 C-u's, use most complete method possible to query the server
3730 for new groups, and subscribe the new groups as zombies."
3732 (gnus-find-new-newsgroups (or arg 1))
3733 (gnus-group-list-groups))
3735 (defun gnus-group-edit-global-kill (&optional article group)
3736 "Edit the global kill file.
3737 If GROUP, edit that local kill file instead."
3739 (setq gnus-current-kill-article article)
3740 (gnus-kill-file-edit-file group)
3743 (substitute-command-keys
3744 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3745 (if group "local" "global")))))
3747 (defun gnus-group-edit-local-kill (article group)
3748 "Edit a local kill file."
3749 (interactive (list nil (gnus-group-group-name)))
3750 (gnus-group-edit-global-kill article group))
3752 (defun gnus-group-force-update ()
3753 "Update `.newsrc' file."
3755 (gnus-save-newsrc-file))
3757 (defun gnus-group-suspend ()
3758 "Suspend the current Gnus session.
3759 In fact, cleanup buffers except for group mode buffer.
3760 The hook gnus-suspend-gnus-hook is called before actually suspending."
3762 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3763 (gnus-offer-save-summaries)
3764 ;; Kill Gnus buffers except for group mode buffer.
3765 (let ((group-buf (get-buffer gnus-group-buffer)))
3766 (mapcar (lambda (buf)
3767 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3771 (eq major-mode 'message-mode))))
3772 (gnus-kill-buffer buf)))
3774 (gnus-kill-gnus-frames)
3776 (bury-buffer group-buf)
3777 (delete-windows-on group-buf t))))
3779 (defun gnus-group-clear-dribble ()
3780 "Clear all information from the dribble buffer."
3782 (gnus-dribble-clear)
3783 (gnus-message 7 "Cleared dribble buffer"))
3785 (defun gnus-group-exit ()
3786 "Quit reading news after updating .newsrc.eld and .newsrc.
3787 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3790 (or noninteractive ;For gnus-batch-kill
3791 (not gnus-interactive-exit) ;Without confirmation
3793 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3794 (gnus-run-hooks 'gnus-exit-gnus-hook)
3795 ;; Offer to save data from non-quitted summary buffers.
3796 (gnus-offer-save-summaries)
3797 ;; Save the newsrc file(s).
3798 (gnus-save-newsrc-file)
3800 (gnus-close-backends)
3801 ;; Reset everything.
3803 ;; Allow the user to do things after cleaning up.
3804 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3806 (defun gnus-group-quit ()
3807 "Quit reading news without updating .newsrc.eld or .newsrc.
3808 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3810 (when (or noninteractive ;For gnus-batch-kill
3811 (zerop (buffer-size))
3812 (not (gnus-server-opened gnus-select-method))
3814 (not gnus-current-startup-file)
3816 (format "Quit reading news without saving %s? "
3817 (file-name-nondirectory gnus-current-startup-file))))
3818 (gnus-run-hooks 'gnus-exit-gnus-hook)
3819 (gnus-configure-windows 'group t)
3820 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3821 (not (zerop (save-excursion
3822 (set-buffer gnus-dribble-buffer)
3825 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3827 (gnus-close-backends)
3829 (gnus-kill-buffer gnus-group-buffer)
3830 ;; Allow the user to do things after cleaning up.
3831 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3833 (defun gnus-group-describe-briefly ()
3834 "Give a one line description of the group mode commands."
3836 (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")))
3838 (defun gnus-group-browse-foreign-server (method)
3839 "Browse a foreign news server.
3840 If called interactively, this function will ask for a select method
3841 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3842 If not, METHOD should be a list where the first element is the method
3843 and the second element is the address."
3845 (list (let ((how (completing-read
3847 (append gnus-valid-select-methods gnus-server-alist)
3848 nil t (cons "nntp" 0) 'gnus-method-history)))
3849 ;; We either got a backend name or a virtual server name.
3850 ;; If the first, we also need an address.
3851 (if (assoc how gnus-valid-select-methods)
3853 ;; Suggested by mapjph@bath.ac.uk.
3856 (mapcar (lambda (server) (list server))
3857 gnus-secondary-servers)))
3858 ;; We got a server name.
3860 (gnus-browse-foreign-server method))
3862 (defun gnus-group-set-info (info &optional method-only-group part)
3863 (when (or info part)
3864 (let* ((entry (gnus-gethash
3865 (or method-only-group (gnus-info-group info))
3866 gnus-newsrc-hashtb))
3868 (info (if method-only-group (nth 2 entry) info))
3870 (when method-only-group
3872 (error "Trying to change non-existent group %s" method-only-group))
3873 ;; We have received parts of the actual group info - either the
3874 ;; select method or the group parameters. We first check
3875 ;; whether we have to extend the info, and if so, do that.
3876 (let ((len (length info))
3877 (total (if (eq part 'method) 5 6)))
3879 (setcdr (nthcdr (1- len) info)
3880 (make-list (- total len) nil)))
3881 ;; Then we enter the new info.
3882 (setcar (nthcdr (1- total) info) part-info)))
3884 ;; This is a new group, so we just create it.
3886 (set-buffer gnus-group-buffer)
3887 (setq method (gnus-info-method info))
3888 (when (gnus-server-equal method "native")
3891 (set-buffer gnus-group-buffer)
3893 ;; It's a foreign group...
3894 (gnus-group-make-group
3895 (gnus-group-real-name (gnus-info-group info))
3896 (if (stringp method) method
3897 (prin1-to-string (car method)))
3899 (nth 1 (gnus-info-method info))))
3900 ;; It's a native group.
3901 (gnus-group-make-group (gnus-info-group info))))
3902 (gnus-message 6 "Note: New group created")
3904 (gnus-gethash (gnus-group-prefixed-name
3905 (gnus-group-real-name (gnus-info-group info))
3906 (or (gnus-info-method info) gnus-select-method))
3907 gnus-newsrc-hashtb))))
3908 ;; Whether it was a new group or not, we now have the entry, so we
3909 ;; can do the update.
3912 (setcar (nthcdr 2 entry) info)
3913 (when (and (not (eq (car entry) t))
3914 (gnus-active (gnus-info-group info)))
3915 (setcar entry (length
3916 (gnus-list-of-unread-articles (car info))))))
3917 (error "No such group: %s" (gnus-info-group info))))))
3919 (defun gnus-group-set-method-info (group select-method)
3920 (gnus-group-set-info select-method group 'method))
3922 (defun gnus-group-set-params-info (group params)
3923 (gnus-group-set-info params group 'params))
3925 (defun gnus-add-marked-articles (group type articles &optional info force)
3926 ;; Add ARTICLES of TYPE to the info of GROUP.
3927 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3928 ;; add, but replace marked articles of TYPE with ARTICLES.
3929 (let ((info (or info (gnus-get-info group)))
3932 (and (not (setq marked (nthcdr 3 info)))
3934 (setcdr (nthcdr 2 info)
3935 (list (list (cons type (gnus-compress-sequence
3937 (and (not (setq m (assq type (car marked))))
3940 (cons (cons type (gnus-compress-sequence articles t) )
3944 (setcar (nthcdr 3 info)
3945 (gnus-delete-alist type (car marked)))
3946 (setcdr m (gnus-compress-sequence articles t)))
3947 (setcdr m (gnus-compress-sequence
3948 (sort (nconc (gnus-uncompress-range (cdr m))
3949 (copy-sequence articles)) '<) t))))))
3951 (defun gnus-add-mark (group mark article)
3952 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3953 (let ((buffer (gnus-summary-buffer-name group)))
3954 (if (gnus-buffer-live-p buffer)
3956 (set-buffer (get-buffer buffer))
3957 (gnus-summary-add-mark article mark))
3958 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3962 ;;; Group timestamps
3965 (defun gnus-group-set-timestamp ()
3966 "Change the timestamp of the current group to the current time.
3967 This function can be used in hooks like `gnus-select-group-hook'
3968 or `gnus-group-catchup-group-hook'."
3969 (when gnus-newsgroup-name
3970 (let ((time (current-time)))
3971 (setcdr (cdr time) nil)
3972 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3974 (defsubst gnus-group-timestamp (group)
3975 "Return the timestamp for GROUP."
3976 (gnus-group-get-parameter group 'timestamp t))
3978 (defun gnus-group-timestamp-delta (group)
3979 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3980 (let* ((time (or (gnus-group-timestamp group)
3982 (delta (subtract-time (current-time) time)))
3983 (+ (* (nth 0 delta) 65536.0)
3986 (defun gnus-group-timestamp-string (group)
3987 "Return a string of the timestamp for GROUP."
3988 (let ((time (gnus-group-timestamp group)))
3991 (gnus-time-iso8601 time))))
3993 (defun gnus-group-list-cached (level &optional lowest)
3994 "List all groups with cached articles.
3995 If the prefix LEVEL is non-nil, it should be a number that says which
3996 level to cut off listing groups.
3997 If LOWEST, don't list groups with level lower than LOWEST.
3999 This command may read the active file."
4002 (setq level (prefix-numeric-value level)))
4003 (when (or (not level) (>= level gnus-level-zombie))
4005 (funcall gnus-group-prepare-function
4006 (or level gnus-level-subscribed)
4008 (let ((marks (gnus-info-marks info)))
4009 (assq 'cache marks)))
4012 (or (gnus-gethash group
4013 gnus-cache-active-hashtb)
4014 ;; Cache active file might use "."
4017 (mapconcat 'identity
4018 (split-string group ":")
4020 gnus-cache-active-hashtb))))
4021 (goto-char (point-min))
4022 (gnus-group-position-point))
4024 (defun gnus-group-list-dormant (level &optional lowest)
4025 "List all groups with dormant articles.
4026 If the prefix LEVEL is non-nil, it should be a number that says which
4027 level to cut off listing groups.
4028 If LOWEST, don't list groups with level lower than LOWEST.
4030 This command may read the active file."
4033 (setq level (prefix-numeric-value level)))
4034 (when (or (not level) (>= level gnus-level-zombie))
4036 (funcall gnus-group-prepare-function
4037 (or level gnus-level-subscribed)
4039 (let ((marks (gnus-info-marks info)))
4040 (assq 'dormant marks)))
4043 (goto-char (point-min))
4044 (gnus-group-position-point))
4046 (defun gnus-group-listed-groups ()
4047 "Return a list of listed groups."
4049 (goto-char (point-min))
4050 (while (setq point (text-property-not-all (point) (point-max)
4053 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4057 (defun gnus-group-list-plus (&optional args)
4058 "List groups plus the current selection."
4060 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4061 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4063 (push last-command-event unread-command-events)
4064 (if (featurep 'xemacs)
4065 (push (make-event 'key-press '(key ?A)) unread-command-events)
4066 (push ?A unread-command-events))
4067 (let (gnus-pick-mode keys)
4068 (setq keys (if (featurep 'xemacs)
4069 (events-to-keys (read-key-sequence nil))
4070 (read-key-sequence nil)))
4071 (setq func (lookup-key (current-local-map) keys)))
4075 (call-interactively func))))
4077 (defun gnus-group-list-flush (&optional args)
4078 "Flush groups from the current selection."
4080 (let ((gnus-group-list-option 'flush))
4081 (gnus-group-list-plus args)))
4083 (defun gnus-group-list-limit (&optional args)
4084 "List groups limited within the current selection."
4086 (let ((gnus-group-list-option 'limit))
4087 (gnus-group-list-plus args)))
4089 (defun gnus-group-mark-article-read (group article)
4090 "Mark ARTICLE read."
4091 (let ((buffer (gnus-summary-buffer-name group))
4092 (mark gnus-read-mark)
4094 (if (get-buffer buffer)
4095 (with-current-buffer buffer
4096 (setq active gnus-newsgroup-active)
4097 (gnus-activate-group group)
4098 (when gnus-newsgroup-prepared
4099 (when (and gnus-newsgroup-auto-expire
4100 (memq mark gnus-auto-expirable-marks))
4101 (setq mark gnus-expirable-mark))
4102 (setq mark (gnus-request-update-mark
4103 group article mark))
4104 (gnus-mark-article-as-read article mark)
4105 (setq gnus-newsgroup-active (gnus-active group))
4107 (setq n (1+ (cdr active)))
4108 (while (<= n (cdr gnus-newsgroup-active))
4109 (unless (eq n article)
4110 (push n gnus-newsgroup-unselected))
4112 (setq gnus-newsgroup-unselected
4113 (nreverse gnus-newsgroup-unselected)))))
4114 (gnus-activate-group group)
4115 (gnus-group-make-articles-read group
4117 (when (gnus-group-auto-expirable-p group)
4118 (gnus-add-marked-articles
4119 group 'expire (list article))))))
4121 (provide 'gnus-group)
4123 ;;; gnus-group.el ends here