1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (defcustom gnus-group-archive-directory
43 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
44 "*The address of the (ding) archives."
45 :group 'gnus-group-foreign
48 (defcustom gnus-group-recent-archive-directory
49 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
50 "*The address of the most recent (ding) articles."
51 :group 'gnus-group-foreign
54 (defcustom gnus-no-groups-message "No gnus is bad news"
55 "*Message displayed by Gnus when no groups are available."
59 (defcustom gnus-keep-same-level nil
60 "*Non-nil means that the next newsgroup after the current will be on the same level.
61 When you type, for instance, `n' after reading the last article in the
62 current newsgroup, you will go to the next newsgroup. If this variable
63 is nil, the next newsgroup will be the next from the group
65 If this variable is non-nil, Gnus will either put you in the
66 next newsgroup with the same level, or, if no such newsgroup is
67 available, the next newsgroup with the lowest possible level higher
68 than the current level.
69 If this variable is `best', Gnus will make the next newsgroup the one
71 :group 'gnus-group-levels
72 :type '(choice (const nil)
74 (sexp :tag "other" t)))
76 (defcustom gnus-group-goto-unread t
77 "*If non-nil, movement commands will go to the next unread and subscribed group."
78 :link '(custom-manual "(gnus)Group Maneuvering")
79 :group 'gnus-group-various
82 (defcustom gnus-goto-next-group-when-activating t
83 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
84 :link '(custom-manual "(gnus)Scanning New Messages")
85 :group 'gnus-group-various
88 (defcustom gnus-permanently-visible-groups nil
89 "*Regexp to match groups that should always be listed in the group buffer.
90 This means that they will still be listed even when there are no
91 unread articles in the groups.
93 If nil, no groups are permanently visible."
94 :group 'gnus-group-listing
95 :type '(choice regexp (const nil)))
97 (defcustom gnus-list-groups-with-ticked-articles t
98 "*If non-nil, list groups that have only ticked articles.
99 If nil, only list groups that have unread articles."
100 :group 'gnus-group-listing
103 (defcustom gnus-group-default-list-level gnus-level-subscribed
104 "*Default listing level.
105 Ignored if `gnus-group-use-permanent-levels' is non-nil."
106 :group 'gnus-group-listing
109 (defcustom gnus-group-list-inactive-groups t
110 "*If non-nil, inactive groups will be listed."
111 :group 'gnus-group-listing
112 :group 'gnus-group-levels
115 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
116 "*Function used for sorting the group buffer.
117 This function will be called with group info entries as the arguments
118 for the groups to be sorted. Pre-made functions include
119 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
120 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
121 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
122 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
124 This variable can also be a list of sorting functions. In that case,
125 the most significant sort function should be the last function in the
127 :group 'gnus-group-listing
128 :link '(custom-manual "(gnus)Sorting Groups")
129 :type '(repeat :value-to-internal (lambda (widget value)
130 (if (listp value) value (list value)))
131 :match (lambda (widget value)
133 (widget-editable-list-match widget value)))
134 (choice (function-item gnus-group-sort-by-alphabet)
135 (function-item gnus-group-sort-by-real-name)
136 (function-item gnus-group-sort-by-unread)
137 (function-item gnus-group-sort-by-level)
138 (function-item gnus-group-sort-by-score)
139 (function-item gnus-group-sort-by-method)
140 (function-item gnus-group-sort-by-server)
141 (function-item gnus-group-sort-by-rank)
142 (function :tag "other" nil))))
144 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l %O\n"
145 "*Format of group lines.
146 It works along the same lines as a normal formatting string,
147 with some simple extensions.
149 %M Only marked articles (character, \"*\" or \" \")
150 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
151 %L Level of subscribedness (integer)
152 %N Number of unread articles (integer)
153 %I Number of dormant articles (integer)
154 %i Number of ticked and dormant (integer)
155 %T Number of ticked articles (integer)
156 %R Number of read articles (integer)
157 %t Estimated total number of articles (integer)
158 %y Number of unread, unticked articles (integer)
159 %G Group name (string)
160 %g Qualified group name (string)
161 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
162 %D Group description (string)
163 %s Select method (string)
164 %o Moderated group (char, \"m\")
165 %p Process mark (char)
166 %O Moderated group (string, \"(m)\" or \"\")
167 %P Topic indentation (string)
168 %m Whether there is new(ish) mail in the group (char, \"%\")
169 %w Number of new(ish) mails in the group (integer)
170 %l Whether there are GroupLens predictions for this group (string)
171 %n Select from where (string)
172 %z A string that look like `<%s:%n>' if a foreign select method is used
173 %d The date the group was last entered.
174 %E Icon as defined by `gnus-group-icon-list'.
175 %u User defined specifier. The next character in the format string should
176 be a letter. Gnus will call the function gnus-user-format-function-X,
177 where X is the letter following %u. The function will be passed the
178 current header as argument. The function should return a string, which
179 will be inserted into the buffer just like information from any other
182 Note that this format specification is not always respected. For
183 reasons of efficiency, when listing killed groups, this specification
184 is ignored altogether. If the spec is changed considerably, your
185 output may end up looking strange when listing both alive and killed
188 If you use %o or %O, reading the active file will be slower and quite
189 a bit of extra memory will be used. %D will also worsen performance.
190 Also note that if you change the format specification to include any
191 of these specs, you must probably re-start Gnus to see them go into
194 General format specifiers can also be used.
195 See (gnus)Formatting Variables."
196 :link '(custom-manual "(gnus)Formatting Variables")
197 :group 'gnus-group-visual
200 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
201 "*The format specification for the group mode line.
202 It works along the same lines as a normal formatting string,
203 with some simple extensions:
205 %S The native news server.
206 %M The native select method.
207 %: \":\" if %S isn't \"\"."
208 :group 'gnus-group-visual
211 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
212 (when (featurep 'xemacs)
213 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
214 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
216 (defcustom gnus-group-menu-hook nil
217 "Hook run after the creation of the group mode menu."
218 :group 'gnus-group-various
221 (defcustom gnus-group-catchup-group-hook nil
222 "Hook run when catching up a group from the group buffer."
223 :group 'gnus-group-various
224 :link '(custom-manual "(gnus)Group Data")
227 (defcustom gnus-group-update-group-hook nil
228 "Hook called when updating group lines."
229 :group 'gnus-group-visual
232 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
233 "*A function that is called to generate the group buffer.
234 The function is called with three arguments: The first is a number;
235 all group with a level less or equal to that number should be listed,
236 if the second is non-nil, empty groups should also be displayed. If
237 the third is non-nil, it is a number. No groups with a level lower
238 than this number should be displayed.
240 The only current function implemented is `gnus-group-prepare-flat'."
241 :group 'gnus-group-listing
244 (defcustom gnus-group-prepare-hook nil
245 "Hook called after the group buffer has been generated.
246 If you want to modify the group buffer, you can use this hook."
247 :group 'gnus-group-listing
250 (defcustom gnus-suspend-gnus-hook nil
251 "Hook called when suspending (not exiting) Gnus."
255 (defcustom gnus-exit-gnus-hook nil
256 "Hook called when exiting Gnus."
260 (defcustom gnus-after-exiting-gnus-hook nil
261 "Hook called after exiting Gnus."
265 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
266 "Hook called when a group line is changed.
267 The hook will not be called if `gnus-visual' is nil.
269 The default function `gnus-group-highlight-line' will
270 highlight the line according to the `gnus-group-highlight'
272 :group 'gnus-group-visual
275 (defcustom gnus-useful-groups
276 '(("(ding) mailing list mirrored at sunsite.auc.dk"
278 (nntp "sunsite.auc.dk"
279 (nntp-address "sunsite.auc.dk")))
282 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
286 (nndoc-article-type mbox)
287 (eval `(nndoc-address
288 ,(let ((file (nnheader-find-etc-directory
291 (error "Couldn't find doc group"))
293 "*Alist of useful group-server pairs."
294 :group 'gnus-group-listing
295 :type '(repeat (list (string :tag "Description")
297 (sexp :tag "Method"))))
299 (defcustom gnus-group-highlight
301 ((and mailp (= unread 0) (eq level 1)) .
302 gnus-group-mail-1-empty-face)
303 ((and mailp (eq level 1)) .
304 gnus-group-mail-1-face)
305 ((and mailp (= unread 0) (eq level 2)) .
306 gnus-group-mail-2-empty-face)
307 ((and mailp (eq level 2)) .
308 gnus-group-mail-2-face)
309 ((and mailp (= unread 0) (eq level 3)) .
310 gnus-group-mail-3-empty-face)
311 ((and mailp (eq level 3)) .
312 gnus-group-mail-3-face)
313 ((and mailp (= unread 0)) .
314 gnus-group-mail-low-empty-face)
316 gnus-group-mail-low-face)
318 ((and (= unread 0) (eq level 1)) .
319 gnus-group-news-1-empty-face)
320 ((and (eq level 1)) .
321 gnus-group-news-1-face)
322 ((and (= unread 0) (eq level 2)) .
323 gnus-group-news-2-empty-face)
324 ((and (eq level 2)) .
325 gnus-group-news-2-face)
326 ((and (= unread 0) (eq level 3)) .
327 gnus-group-news-3-empty-face)
328 ((and (eq level 3)) .
329 gnus-group-news-3-face)
330 ((and (= unread 0) (eq level 4)) .
331 gnus-group-news-4-empty-face)
332 ((and (eq level 4)) .
333 gnus-group-news-4-face)
334 ((and (= unread 0) (eq level 5)) .
335 gnus-group-news-5-empty-face)
336 ((and (eq level 5)) .
337 gnus-group-news-5-face)
338 ((and (= unread 0) (eq level 6)) .
339 gnus-group-news-6-empty-face)
340 ((and (eq level 6)) .
341 gnus-group-news-6-face)
342 ((and (= unread 0)) .
343 gnus-group-news-low-empty-face)
345 gnus-group-news-low-face))
346 "*Controls the highlighting of group buffer lines.
348 Below is a list of `Form'/`Face' pairs. When deciding how a a
349 particular group line should be displayed, each form is
350 evaluated. The content of the face field after the first true form is
351 used. You can change how those group lines are displayed by
352 editing the face field.
354 It is also possible to change and add form fields, but currently that
355 requires an understanding of Lisp expressions. Hopefully this will
356 change in a future release. For now, you can use the following
357 variables in the Lisp expression:
359 group: The name of the group.
360 unread: The number of unread articles in the group.
361 method: The select method used.
362 mailp: Whether it's a mail group or not.
363 level: The level of the group.
364 score: The score of the group.
365 ticked: The number of ticked articles."
366 :group 'gnus-group-visual
367 :type '(repeat (cons (sexp :tag "Form") face)))
369 (defcustom gnus-new-mail-mark ?%
370 "Mark used for groups with new mail."
371 :group 'gnus-group-visual
374 (defgroup gnus-group-icons nil
375 "Add Icons to your group buffer. "
376 :group 'gnus-group-visual)
378 (defcustom gnus-group-icon-list
380 "*Controls the insertion of icons into group buffer lines.
382 Below is a list of `Form'/`File' pairs. When deciding how a
383 particular group line should be displayed, each form is evaluated.
384 The icon from the file field after the first true form is used. You
385 can change how those group lines are displayed by editing the file
386 field. The File will either be found in the
387 `gnus-group-glyph-directory' or by designating absolute path to the
390 It is also possible to change and add form fields, but currently that
391 requires an understanding of Lisp expressions. Hopefully this will
392 change in a future release. For now, you can use the following
393 variables in the Lisp expression:
395 group: The name of the group.
396 unread: The number of unread articles in the group.
397 method: The select method used.
398 mailp: Whether it's a mail group or not.
399 newsp: Whether it's a news group or not
400 level: The level of the group.
401 score: The score of the group.
402 ticked: The number of ticked articles."
403 :group 'gnus-group-icons
404 :type '(repeat (cons (sexp :tag "Form") file)))
406 (defcustom gnus-group-name-charset-method-alist nil
407 "Alist of method and the charset for group names.
410 (((nntp \"news.com.cn\") . cn-gb-2312))"
413 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
415 (defcustom gnus-group-name-charset-group-alist
416 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
417 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
420 "Alist of group regexp and the charset for group names.
423 ((\"\\.com\\.cn:\" . cn-gb-2312))"
425 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
427 (defcustom gnus-group-jump-to-group-prompt nil
428 "Default prompt for `gnus-group-jump-to-group'.
429 If non-nil, the value should be a string, e.g. \"nnml:\",
430 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
431 in the minibuffer prompt."
432 :group 'gnus-group-various
433 :type '(choice (string :tag "Prompt string")
434 (const :tag "Empty" nil)))
436 (defvar gnus-group-listing-limit 1000
437 "*A limit of the number of groups when listing.
438 If the number of groups is larger than the limit, list them in a
441 ;;; Internal variables
443 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
444 "Function for sorting the group buffer.")
446 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
447 "Function for sorting the selected groups in the group buffer.")
449 (defvar gnus-group-indentation-function nil)
450 (defvar gnus-goto-missing-group-function nil)
451 (defvar gnus-group-update-group-function nil)
452 (defvar gnus-group-goto-next-group-function nil
453 "Function to override finding the next group after listing groups.")
455 (defvar gnus-group-edit-buffer nil)
457 (defvar gnus-group-line-format-alist
458 `((?M gnus-tmp-marked-mark ?c)
459 (?S gnus-tmp-subscribed ?c)
460 (?L gnus-tmp-level ?d)
461 (?N (cond ((eq number t) "*" )
465 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
466 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
468 (?R gnus-tmp-number-of-read ?s)
469 (?t gnus-tmp-number-total ?d)
470 (?y gnus-tmp-number-of-unread ?s)
471 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
472 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
473 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
474 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
475 (?g gnus-tmp-group ?s)
476 (?G gnus-tmp-qualified-group ?s)
477 (?c (gnus-short-group-name gnus-tmp-group) ?s)
478 (?D gnus-tmp-newsgroup-description ?s)
479 (?o gnus-tmp-moderated ?c)
480 (?O gnus-tmp-moderated-string ?s)
481 (?p gnus-tmp-process-marked ?c)
482 (?s gnus-tmp-news-server ?s)
483 (?n gnus-tmp-news-method ?s)
484 (?P gnus-group-indentation ?s)
485 (?E gnus-tmp-group-icon ?s)
486 (?l gnus-tmp-grouplens ?s)
487 (?z gnus-tmp-news-method-string ?s)
488 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
489 (?w (if (gnus-news-group-p gnus-tmp-group)
493 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
496 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
497 (?u gnus-tmp-user-defined ?s)))
499 (defvar gnus-group-mode-line-format-alist
500 `((?S gnus-tmp-news-server ?s)
501 (?M gnus-tmp-news-method ?s)
502 (?u gnus-tmp-user-defined ?s)
503 (?: gnus-tmp-colon ?s)))
505 (defvar gnus-topic-topology nil
506 "The complete topic hierarchy.")
508 (defvar gnus-topic-alist nil
509 "The complete topic-group alist.")
511 (defvar gnus-group-marked nil)
513 (defvar gnus-group-list-mode nil)
516 (defvar gnus-group-icon-cache nil)
518 (defvar gnus-group-listed-groups nil)
519 (defvar gnus-group-list-option nil)
525 (put 'gnus-group-mode 'mode-class 'special)
528 (gnus-define-keys gnus-group-mode-map
529 " " gnus-group-read-group
530 "=" gnus-group-select-group
531 "\r" gnus-group-select-group
532 "\M-\r" gnus-group-quick-select-group
533 "\M- " gnus-group-visible-select-group
534 [(meta control return)] gnus-group-select-group-ephemerally
535 "j" gnus-group-jump-to-group
536 "n" gnus-group-next-unread-group
537 "p" gnus-group-prev-unread-group
538 "\177" gnus-group-prev-unread-group
539 [delete] gnus-group-prev-unread-group
540 [backspace] gnus-group-prev-unread-group
541 "N" gnus-group-next-group
542 "P" gnus-group-prev-group
543 "\M-n" gnus-group-next-unread-group-same-level
544 "\M-p" gnus-group-prev-unread-group-same-level
545 "," gnus-group-best-unread-group
546 "." gnus-group-first-unread-group
547 "u" gnus-group-unsubscribe-current-group
548 "U" gnus-group-unsubscribe-group
549 "c" gnus-group-catchup-current
550 "C" gnus-group-catchup-current-all
551 "\M-c" gnus-group-clear-data
552 "l" gnus-group-list-groups
553 "L" gnus-group-list-all-groups
556 "g" gnus-group-get-new-news
557 "\M-g" gnus-group-get-new-news-this-group
558 "R" gnus-group-restart
559 "r" gnus-group-read-init-file
560 "B" gnus-group-browse-foreign-server
561 "b" gnus-group-check-bogus-groups
562 "F" gnus-group-find-new-groups
563 "\C-c\C-d" gnus-group-describe-group
564 "\M-d" gnus-group-describe-all-groups
565 "\C-c\C-a" gnus-group-apropos
566 "\C-c\M-\C-a" gnus-group-description-apropos
567 "a" gnus-group-post-news
568 "\ek" gnus-group-edit-local-kill
569 "\eK" gnus-group-edit-global-kill
570 "\C-k" gnus-group-kill-group
571 "\C-y" gnus-group-yank-group
572 "\C-w" gnus-group-kill-region
573 "\C-x\C-t" gnus-group-transpose-groups
574 "\C-c\C-l" gnus-group-list-killed
575 "\C-c\C-x" gnus-group-expire-articles
576 "\C-c\M-\C-x" gnus-group-expire-all-groups
578 "s" gnus-group-save-newsrc
579 "z" gnus-group-suspend
582 "?" gnus-group-describe-briefly
583 "\C-c\C-i" gnus-info-find-node
584 "\M-e" gnus-group-edit-group-method
585 "^" gnus-group-enter-server-mode
586 gnus-mouse-2 gnus-mouse-pick-group
587 "<" beginning-of-buffer
590 "\C-c\C-n" gnus-namazu-search
591 "\C-c\C-s" gnus-group-sort-groups
593 "\C-c\M-g" gnus-activate-all-groups
594 "\M-&" gnus-group-universal-argument
595 "#" gnus-group-mark-group
596 "\M-#" gnus-group-unmark-group)
598 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
599 "m" gnus-group-mark-group
600 "u" gnus-group-unmark-group
601 "w" gnus-group-mark-region
602 "b" gnus-group-mark-buffer
603 "r" gnus-group-mark-regexp
604 "U" gnus-group-unmark-all-groups)
606 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
607 "u" gnus-sieve-update
608 "g" gnus-sieve-generate)
610 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
611 "d" gnus-group-make-directory-group
612 "h" gnus-group-make-help-group
613 "u" gnus-group-make-useful-group
614 "a" gnus-group-make-archive-group
615 "k" gnus-group-make-kiboze-group
616 "l" gnus-group-nnimap-edit-acl
617 "m" gnus-group-make-group
618 "n" gnus-group-make-shimbun-group
619 "E" gnus-group-edit-group
620 "e" gnus-group-edit-group-method
621 "p" gnus-group-edit-group-parameters
622 "v" gnus-group-add-to-virtual
623 "V" gnus-group-make-empty-virtual
624 "D" gnus-group-enter-directory
625 "f" gnus-group-make-doc-group
626 "G" gnus-group-make-nnir-group
627 "w" gnus-group-make-web-group
628 "r" gnus-group-rename-group
629 "c" gnus-group-customize
630 "x" gnus-group-nnimap-expunge
631 "\177" gnus-group-delete-group
632 [delete] gnus-group-delete-group)
634 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
635 "b" gnus-group-brew-soup
636 "w" gnus-soup-save-areas
637 "s" gnus-soup-send-replies
638 "p" gnus-soup-pack-packet
639 "r" nnsoup-pack-replies)
641 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
642 "s" gnus-group-sort-groups
643 "a" gnus-group-sort-groups-by-alphabet
644 "u" gnus-group-sort-groups-by-unread
645 "l" gnus-group-sort-groups-by-level
646 "v" gnus-group-sort-groups-by-score
647 "r" gnus-group-sort-groups-by-rank
648 "m" gnus-group-sort-groups-by-method)
650 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
651 "s" gnus-group-sort-selected-groups
652 "a" gnus-group-sort-selected-groups-by-alphabet
653 "u" gnus-group-sort-selected-groups-by-unread
654 "l" gnus-group-sort-selected-groups-by-level
655 "v" gnus-group-sort-selected-groups-by-score
656 "r" gnus-group-sort-selected-groups-by-rank
657 "m" gnus-group-sort-selected-groups-by-method)
659 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
660 "k" gnus-group-list-killed
661 "z" gnus-group-list-zombies
662 "s" gnus-group-list-groups
663 "u" gnus-group-list-all-groups
664 "A" gnus-group-list-active
665 "a" gnus-group-apropos
666 "d" gnus-group-description-apropos
667 "m" gnus-group-list-matching
668 "M" gnus-group-list-all-matching
669 "l" gnus-group-list-level
670 "c" gnus-group-list-cached
671 "?" gnus-group-list-dormant)
673 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
674 "k" gnus-group-list-limit
675 "z" gnus-group-list-limit
676 "s" gnus-group-list-limit
677 "u" gnus-group-list-limit
678 "A" gnus-group-list-limit
679 "m" gnus-group-list-limit
680 "M" gnus-group-list-limit
681 "l" gnus-group-list-limit
682 "c" gnus-group-list-limit
683 "?" gnus-group-list-limit)
685 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
686 "k" gnus-group-list-flush
687 "z" gnus-group-list-flush
688 "s" gnus-group-list-flush
689 "u" gnus-group-list-flush
690 "A" gnus-group-list-flush
691 "m" gnus-group-list-flush
692 "M" gnus-group-list-flush
693 "l" gnus-group-list-flush
694 "c" gnus-group-list-flush
695 "?" gnus-group-list-flush)
697 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
698 "k" gnus-group-list-plus
699 "z" gnus-group-list-plus
700 "s" gnus-group-list-plus
701 "u" gnus-group-list-plus
702 "A" gnus-group-list-plus
703 "m" gnus-group-list-plus
704 "M" gnus-group-list-plus
705 "l" gnus-group-list-plus
706 "c" gnus-group-list-plus
707 "?" gnus-group-list-plus)
709 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
710 "f" gnus-score-flush-cache)
712 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
713 "d" gnus-group-describe-group
714 "f" gnus-group-fetch-faq
717 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
718 "l" gnus-group-set-current-level
719 "t" gnus-group-unsubscribe-current-group
720 "s" gnus-group-unsubscribe-group
721 "k" gnus-group-kill-group
722 "y" gnus-group-yank-group
723 "w" gnus-group-kill-region
724 "\C-k" gnus-group-kill-level
725 "z" gnus-group-kill-all-zombies))
727 (defun gnus-group-make-menu-bar ()
728 (gnus-turn-off-edit-menu 'group)
729 (unless (boundp 'gnus-group-reading-menu)
732 gnus-group-reading-menu gnus-group-mode-map ""
734 ["Read" gnus-group-read-group (gnus-group-group-name)]
735 ["Select" gnus-group-select-group (gnus-group-group-name)]
736 ["See old articles" (gnus-group-select-group 'all)
737 :keys "C-u SPC" :active (gnus-group-group-name)]
738 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
739 ,@(if (featurep 'xemacs) nil
740 '(:help "Mark unread articles in the current group as read"))]
741 ["Catch up all articles" gnus-group-catchup-current-all
742 (gnus-group-group-name)]
743 ["Check for new articles" gnus-group-get-new-news-this-group
744 :active (gnus-group-group-name)
745 ,@(if (featurep 'xemacs) nil
746 '(:help "Check for new messages in current group"))]
747 ["Toggle subscription" gnus-group-unsubscribe-current-group
748 (gnus-group-group-name)]
749 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
750 ,@(if (featurep 'xemacs) nil
751 '(:help "Kill (remove) current group"))]
752 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
753 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
754 ,@(if (featurep 'xemacs) nil
755 '(:help "Display description of the current group"))]
756 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
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 process/prefixed"
803 ["Default sort" gnus-group-sort-selected-groups
804 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
805 ["Sort by method" gnus-group-sort-selected-groups-by-method
806 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
807 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
808 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
809 ["Sort by score" gnus-group-sort-selected-groups-by-score
810 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
811 ["Sort by level" gnus-group-sort-selected-groups-by-level
812 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
813 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
814 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
815 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
816 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
818 ["Mark group" gnus-group-mark-group
819 (and (gnus-group-group-name)
820 (not (memq (gnus-group-group-name) gnus-group-marked)))]
821 ["Unmark group" gnus-group-unmark-group
822 (and (gnus-group-group-name)
823 (memq (gnus-group-group-name) gnus-group-marked))]
824 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
825 ["Mark regexp..." gnus-group-mark-regexp t]
826 ["Mark region" gnus-group-mark-region t]
827 ["Mark buffer" gnus-group-mark-buffer t]
828 ["Execute command" gnus-group-universal-argument
829 (or gnus-group-marked (gnus-group-group-name))])
831 ["Subscribe to a group" gnus-group-unsubscribe-group t]
832 ["Kill all newsgroups in region" gnus-group-kill-region t]
833 ["Kill all zombie groups" gnus-group-kill-all-zombies
835 ["Kill all groups on level..." gnus-group-kill-level t])
837 ["Make a foreign group" gnus-group-make-group t]
838 ["Make a shimbun group" gnus-group-make-shimbun-group t]
839 ["Add a directory group" gnus-group-make-directory-group t]
840 ["Add the help group" gnus-group-make-help-group t]
841 ["Add the archive group" gnus-group-make-archive-group t]
842 ["Make a doc group" gnus-group-make-doc-group t]
843 ["Make a web group" gnus-group-make-web-group t]
844 ["Make a kiboze group" gnus-group-make-kiboze-group t]
845 ["Make a virtual group" gnus-group-make-empty-virtual t]
846 ["Add a group to a virtual" gnus-group-add-to-virtual t]
847 ["Rename group" gnus-group-rename-group
848 (gnus-check-backend-function
849 'request-rename-group (gnus-group-group-name))]
850 ["Delete group" gnus-group-delete-group
851 (gnus-check-backend-function
852 'request-delete-group (gnus-group-group-name))])
854 ["Next" gnus-group-next-group t]
855 ["Previous" gnus-group-prev-group t]
856 ["Next unread" gnus-group-next-unread-group t]
857 ["Previous unread" gnus-group-prev-unread-group t]
858 ["Next unread same level" gnus-group-next-unread-group-same-level t]
859 ["Previous unread same level"
860 gnus-group-prev-unread-group-same-level t]
861 ["Jump to group" gnus-group-jump-to-group t]
862 ["First unread group" gnus-group-first-unread-group t]
863 ["Best unread group" gnus-group-best-unread-group t])
865 ["Generate" gnus-sieve-generate t]
866 ["Generate and update" gnus-sieve-update t])
867 ["Delete bogus groups" gnus-group-check-bogus-groups t]
868 ["Find new newsgroups" gnus-group-find-new-groups t]
869 ["Transpose" gnus-group-transpose-groups
870 (gnus-group-group-name)]
871 ["Read a directory as a group..." gnus-group-enter-directory t]))
874 gnus-group-misc-menu gnus-group-mode-map ""
877 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
878 ["Send replies" gnus-soup-send-replies
879 (fboundp 'gnus-soup-pack-packet)]
880 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
881 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
882 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
883 ["Send a mail" gnus-group-mail t]
884 ["Send a message (mail or news)" gnus-group-post-news t]
885 ["Create a local message" gnus-group-news t]
886 ["Check for new news" gnus-group-get-new-news
887 ,@(if (featurep 'xemacs) '(t)
888 '(:help "Get newly arrived articles"))
890 ["Send queued messages" gnus-delay-send-queue
891 ,@(if (featurep 'xemacs) '(t)
892 '(:help "Send all messages that are scheduled to be sent now"))
894 ["Activate all groups" gnus-activate-all-groups t]
895 ["Restart Gnus" gnus-group-restart t]
896 ["Read init file" gnus-group-read-init-file t]
897 ["Browse foreign server" gnus-group-browse-foreign-server t]
898 ["Enter server buffer" gnus-group-enter-server-mode t]
899 ["Expire all expirable articles" gnus-group-expire-all-groups t]
900 ["Generate any kiboze groups" nnkiboze-generate-groups t]
901 ["Gnus version" gnus-version t]
902 ["Save .newsrc files" gnus-group-save-newsrc t]
903 ["Suspend Gnus" gnus-group-suspend t]
904 ["Clear dribble buffer" gnus-group-clear-dribble t]
905 ["Read manual" gnus-info-find-node t]
906 ["Flush score cache" gnus-score-flush-cache t]
907 ["Toggle topics" gnus-topic-mode t]
908 ["Send a bug report" gnus-bug t]
909 ["Exit from Gnus" gnus-group-exit
910 ,@(if (featurep 'xemacs) '(t)
911 '(:help "Quit reading news"))]
912 ["Exit without saving" gnus-group-quit t]))
914 (gnus-run-hooks 'gnus-group-menu-hook)))
916 (defvar gnus-group-toolbar-map nil)
918 ;; Emacs 21 tool bar. Should be no-op otherwise.
919 (defun gnus-group-make-tool-bar ()
920 (if (and (fboundp 'tool-bar-add-item-from-menu)
921 (default-value 'tool-bar-mode)
922 (not gnus-group-toolbar-map))
923 (setq gnus-group-toolbar-map
924 (let ((tool-bar-map (make-sparse-keymap))
925 (load-path (mm-image-load-path)))
926 (tool-bar-add-item-from-menu
927 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
928 (tool-bar-add-item-from-menu
929 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
930 (tool-bar-add-item-from-menu
931 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
932 (tool-bar-add-item-from-menu
933 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
934 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
935 :help "Subscribe to the current group")
936 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
938 :help "Unsubscribe from the current group")
939 (tool-bar-add-item-from-menu
940 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
942 (if gnus-group-toolbar-map
943 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
945 (defun gnus-group-mode ()
946 "Major mode for reading news.
948 All normal editing commands are switched off.
949 \\<gnus-group-mode-map>
950 The group buffer lists (some of) the groups available. For instance,
951 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
952 lists all zombie groups.
954 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
955 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
957 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
959 The following commands are available:
961 \\{gnus-group-mode-map}"
963 (kill-all-local-variables)
964 (when (gnus-visual-p 'group-menu 'menu)
965 (gnus-group-make-menu-bar)
966 (gnus-group-make-tool-bar))
967 (gnus-simplify-mode-line)
968 (setq major-mode 'gnus-group-mode)
969 (setq mode-name "Group")
970 (gnus-group-set-mode-line)
971 (setq mode-line-process nil)
972 (use-local-map gnus-group-mode-map)
973 (buffer-disable-undo)
974 (setq truncate-lines t)
975 (setq buffer-read-only t)
976 (gnus-set-default-directory)
977 (gnus-update-format-specifications nil 'group 'group-mode)
978 (gnus-update-group-mark-positions)
983 (gnus-run-hooks 'gnus-group-mode-hook))
985 (defun gnus-update-group-mark-positions ()
987 (let ((gnus-process-mark ?\200)
988 (gnus-group-update-hook nil)
989 (gnus-group-marked '("dummy.group"))
990 (gnus-active-hashtb (make-vector 10 0))
992 (gnus-set-active "dummy.group" '(0 . 0))
993 (gnus-set-work-buffer)
994 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
995 (goto-char (point-min))
996 (setq gnus-group-mark-positions
997 (list (cons 'process (and (search-forward "\200" nil t)
1000 (defun gnus-mouse-pick-group (e)
1001 "Enter the group under the mouse pointer."
1004 (gnus-group-read-group nil))
1006 ;; Look at LEVEL and find out what the level is really supposed to be.
1007 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1008 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1009 (defun gnus-group-default-level (&optional level number-or-nil)
1011 (gnus-group-use-permanent-levels
1012 (or (setq gnus-group-use-permanent-levels
1013 (or level (if (numberp gnus-group-use-permanent-levels)
1014 gnus-group-use-permanent-levels
1015 (or gnus-group-default-list-level
1016 gnus-level-subscribed))))
1017 gnus-group-default-list-level gnus-level-subscribed))
1021 (or level gnus-group-default-list-level gnus-level-subscribed))))
1023 (defun gnus-group-setup-buffer ()
1024 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1025 (unless (eq major-mode 'gnus-group-mode)
1028 (gnus-carpal-setup-buffer 'group))))
1030 (defun gnus-group-name-charset (method group)
1032 (setq method (gnus-find-method-for-group group)))
1033 (let ((item (assoc method gnus-group-name-charset-method-alist))
1034 (alist gnus-group-name-charset-group-alist)
1038 (while (setq item (pop alist))
1039 (if (string-match (car item) group)
1041 result (cdr item))))
1044 (defun gnus-group-name-decode (string charset)
1045 (if (and string charset (featurep 'mule)
1046 (not (mm-multibyte-string-p string)))
1047 (decode-coding-string string charset)
1050 (defun gnus-group-decoded-name (string)
1051 (let ((charset (gnus-group-name-charset nil string)))
1052 (gnus-group-name-decode string charset)))
1054 (defun gnus-group-list-groups (&optional level unread lowest)
1055 "List newsgroups with level LEVEL or lower that have unread articles.
1056 Default is all subscribed groups.
1057 If argument UNREAD is non-nil, groups with no unread articles are also
1060 Also see the `gnus-group-use-permanent-levels' variable."
1062 (list (if current-prefix-arg
1063 (prefix-numeric-value current-prefix-arg)
1065 (gnus-group-default-level nil t)
1066 gnus-group-default-list-level
1067 gnus-level-subscribed))))
1069 (setq level (car gnus-group-list-mode)
1070 unread (cdr gnus-group-list-mode)))
1071 (setq level (gnus-group-default-level level))
1072 (gnus-group-setup-buffer)
1073 (gnus-update-format-specifications nil 'group 'group-mode)
1074 (let ((case-fold-search nil)
1075 (props (text-properties-at (gnus-point-at-bol)))
1076 (empty (= (point-min) (point-max)))
1077 (group (gnus-group-group-name))
1079 (set-buffer gnus-group-buffer)
1080 (setq number (funcall gnus-group-prepare-function level unread lowest))
1081 (when (or (and (numberp number)
1083 (zerop (buffer-size)))
1084 ;; No groups in the buffer.
1085 (gnus-message 5 gnus-no-groups-message))
1086 ;; We have some groups displayed.
1087 (goto-char (point-max))
1088 (when (or (not gnus-group-goto-next-group-function)
1089 (not (funcall gnus-group-goto-next-group-function
1093 (goto-char (point-min)))
1095 ;; Go to the first group with unread articles.
1096 (gnus-group-search-forward t))
1098 ;; Find the right group to put point on. If the current group
1099 ;; has disappeared in the new listing, try to find the next
1100 ;; one. If no next one can be found, just leave point at the
1101 ;; first newsgroup in the buffer.
1102 (when (not (gnus-goto-char
1104 (point-min) (point-max)
1105 'gnus-group (gnus-intern-safe
1106 group gnus-active-hashtb))))
1107 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1109 (not (gnus-goto-char
1111 (point-min) (point-max) 'gnus-group
1113 (caar newsrc) gnus-active-hashtb)))))
1114 (setq newsrc (cdr newsrc)))
1116 (goto-char (point-max))
1117 (forward-line -1)))))))
1118 ;; Adjust cursor point.
1119 (gnus-group-position-point)))
1121 (defun gnus-group-list-level (level &optional all)
1122 "List groups on LEVEL.
1123 If ALL (the prefix), also list groups that have no unread articles."
1124 (interactive "nList groups on level: \nP")
1125 (gnus-group-list-groups level all level))
1127 (defun gnus-group-prepare-logic (group test)
1128 (or (and gnus-group-listed-groups
1129 (null gnus-group-list-option)
1130 (member group gnus-group-listed-groups))
1132 ((null gnus-group-listed-groups) test)
1133 ((null gnus-group-list-option) test)
1134 (t (and (member group gnus-group-listed-groups)
1135 (if (eq gnus-group-list-option 'flush)
1139 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1140 "List all newsgroups with unread articles of level LEVEL or lower.
1141 If PREDICATE is a function, list groups that the function returns non-nil;
1142 if it is t, list groups that have no unread articles.
1143 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1144 If REGEXP is a function, list dead groups that the function returns non-nil;
1145 if it is a string, only list groups matching REGEXP."
1146 (set-buffer gnus-group-buffer)
1147 (let ((buffer-read-only nil)
1148 (newsrc (cdr gnus-newsrc-alist))
1149 (lowest (or lowest 1))
1150 (not-in-list (and gnus-group-listed-groups
1151 (copy-sequence gnus-group-listed-groups)))
1152 info clevel unread group params)
1154 (when (or (< lowest gnus-level-zombie)
1155 gnus-group-listed-groups)
1156 ;; List living groups.
1158 (setq info (car newsrc)
1159 group (gnus-info-group info)
1160 params (gnus-info-params info)
1162 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1164 (setq not-in-list (delete group not-in-list)))
1166 (gnus-group-prepare-logic
1168 (and unread ; This group might be unchecked
1169 (or (not (stringp regexp))
1170 (string-match regexp group))
1171 (<= (setq clevel (gnus-info-level info)) level)
1174 ((functionp predicate)
1175 (funcall predicate info))
1176 (predicate t) ; We list all groups?
1179 (if (eq unread t) ; Unactivated?
1180 gnus-group-list-inactive-groups
1181 ; We list unactivated
1183 ; We list groups with unread articles
1184 (and gnus-list-groups-with-ticked-articles
1185 (cdr (assq 'tick (gnus-info-marks info))))
1186 ; And groups with tickeds
1187 ;; Check for permanent visibility.
1188 (and gnus-permanently-visible-groups
1189 (string-match gnus-permanently-visible-groups group))
1190 (memq 'visible params)
1191 (cdr (assq 'visible params)))))))
1192 (gnus-group-insert-group-line
1193 group (gnus-info-level info)
1194 (gnus-info-marks info) unread (gnus-info-method info)))))
1196 ;; List dead groups.
1197 (if (or gnus-group-listed-groups
1198 (and (>= level gnus-level-zombie)
1199 (<= lowest gnus-level-zombie)))
1200 (gnus-group-prepare-flat-list-dead
1201 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1202 gnus-level-zombie ?Z
1205 (dolist (group gnus-zombie-list)
1206 (setq not-in-list (delete group not-in-list))))
1207 (if (or gnus-group-listed-groups
1208 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1209 (gnus-group-prepare-flat-list-dead
1212 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1213 gnus-level-killed ?K regexp))
1215 (gnus-group-set-mode-line)
1216 (setq gnus-group-list-mode (cons level predicate))
1217 (gnus-run-hooks 'gnus-group-prepare-hook)
1220 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1221 ;; List zombies and killed lists somewhat faster, which was
1222 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1223 ;; this by ignoring the group format specification altogether.
1225 (if (> (length groups) gnus-group-listing-limit)
1227 (setq group (pop groups))
1228 (when (gnus-group-prepare-logic
1231 (and (stringp regexp) (string-match regexp group))
1232 (and (functionp regexp) (funcall regexp group))))
1233 (gnus-add-text-properties
1234 (point) (prog1 (1+ (point))
1235 (insert " " mark " *: "
1236 (gnus-group-decoded-name group)
1238 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1240 'gnus-level level))))
1242 (setq group (pop groups))
1243 (when (gnus-group-prepare-logic
1246 (and (stringp regexp) (string-match regexp group))
1247 (and (functionp regexp) (funcall regexp group))))
1248 (gnus-group-insert-group-line
1250 (let ((active (gnus-active group)))
1252 (if (zerop (cdr active))
1254 (- (1+ (cdr active)) (car active)))
1256 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1258 (defun gnus-group-update-group-line ()
1259 "Update the current line in the group buffer."
1260 (let* ((buffer-read-only nil)
1261 (group (gnus-group-group-name))
1262 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1263 gnus-group-indentation)
1266 (not (gnus-ephemeral-group-p group))
1268 (concat "(gnus-group-set-info '"
1269 (gnus-prin1-to-string (nth 2 entry))
1271 (setq gnus-group-indentation (gnus-group-group-indentation))
1273 (gnus-group-insert-group-line-info group)
1275 (gnus-group-position-point))))
1277 (defun gnus-group-insert-group-line-info (group)
1278 "Insert GROUP on the current line."
1279 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1280 (gnus-group-indentation (gnus-group-group-indentation))
1284 ;; (Un)subscribed group.
1285 (setq info (nth 2 entry))
1286 (gnus-group-insert-group-line
1287 group (gnus-info-level info) (gnus-info-marks info)
1288 (or (car entry) t) (gnus-info-method info)))
1289 ;; This group is dead.
1290 (gnus-group-insert-group-line
1292 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1294 (if (setq active (gnus-active group))
1295 (if (zerop (cdr active))
1297 (- (1+ (cdr active)) (car active)))
1299 (gnus-method-simplify (gnus-find-method-for-group group))))))
1301 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1302 gnus-tmp-marked number
1304 "Insert a group line in the group buffer."
1305 (let* ((gnus-tmp-method
1306 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1307 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1309 (gnus-tmp-active (gnus-active gnus-tmp-group))
1310 (gnus-tmp-number-total
1312 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1314 (gnus-tmp-number-of-unread
1315 (if (numberp number) (int-to-string (max 0 number))
1317 (gnus-tmp-number-of-read
1318 (if (numberp number)
1319 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1321 (gnus-tmp-subscribed
1322 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1323 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1324 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1326 (gnus-tmp-qualified-group
1327 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1328 group-name-charset))
1329 (gnus-tmp-newsgroup-description
1330 (if gnus-description-hashtb
1331 (or (gnus-group-name-decode
1332 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1333 group-name-charset) "")
1336 (if (and gnus-moderated-hashtb
1337 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1339 (gnus-tmp-moderated-string
1340 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1341 (gnus-tmp-group-icon "==&&==")
1342 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1343 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1344 (gnus-tmp-news-method-string
1346 (format "(%s:%s)" (car gnus-tmp-method)
1347 (cadr gnus-tmp-method)) ""))
1348 (gnus-tmp-marked-mark
1349 (if (and (numberp number)
1351 (cdr (assq 'tick gnus-tmp-marked)))
1353 (gnus-tmp-process-marked
1354 (if (member gnus-tmp-group gnus-group-marked)
1355 gnus-process-mark ? ))
1357 (or (and gnus-use-grouplens
1358 (bbb-grouplens-group-p gnus-tmp-group))
1360 (buffer-read-only nil)
1361 header gnus-tmp-header) ; passed as parameter to user-funcs.
1363 (gnus-add-text-properties
1367 (let ((gnus-tmp-group (gnus-group-name-decode
1368 gnus-tmp-group group-name-charset)))
1369 (eval gnus-group-line-format-spec)))
1370 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1371 gnus-unread ,(if (numberp number)
1372 (string-to-int gnus-tmp-number-of-unread)
1374 gnus-marked ,gnus-tmp-marked-mark
1375 gnus-indentation ,gnus-group-indentation
1376 gnus-level ,gnus-tmp-level))
1378 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1379 (gnus-run-hooks 'gnus-group-update-hook))
1381 ;; Allow XEmacs to remove front-sticky text properties.
1382 (gnus-group-remove-excess-properties)))
1384 (defun gnus-group-highlight-line ()
1385 "Highlight the current line according to `gnus-group-highlight'."
1386 (let* ((list gnus-group-highlight)
1388 (end (progn (end-of-line) (point)))
1389 ;; now find out where the line starts and leave point there.
1390 (beg (progn (beginning-of-line) (point)))
1391 (group (gnus-group-group-name))
1392 (entry (gnus-group-entry group))
1393 (unread (if (numberp (car entry)) (car entry) 0))
1394 (active (gnus-active group))
1395 (total (if active (1+ (- (cdr active) (car active))) 0))
1396 (info (nth 2 entry))
1397 (method (gnus-server-get-method group (gnus-info-method info)))
1398 (marked (gnus-info-marks info))
1399 (mailp (apply 'append
1402 (memq x (assoc (symbol-name
1403 (car (or method gnus-select-method)))
1404 gnus-valid-select-methods)))
1405 '(mail post-mail))))
1406 (level (or (gnus-info-level info) gnus-level-killed))
1407 (score (or (gnus-info-score info) 0))
1408 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1409 (group-age (gnus-group-timestamp-delta group))
1410 (inhibit-read-only t))
1411 ;; Eval the cars of the lists until we find a match.
1413 (not (eval (caar list))))
1414 (setq list (cdr list)))
1415 (let ((face (cdar list)))
1416 (unless (eq face (get-text-property beg 'face))
1417 (gnus-put-text-property-excluding-characters-with-faces
1419 (setq face (if (boundp face) (symbol-value face) face)))
1420 (gnus-extent-start-open beg)))
1423 (defun gnus-group-update-group (group &optional visible-only)
1424 "Update all lines where GROUP appear.
1425 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1427 ;; Can't use `save-excursion' here, so we do it manually.
1428 (let ((buf (current-buffer))
1430 (set-buffer gnus-group-buffer)
1431 (setq mark (point-marker))
1432 ;; The buffer may be narrowed.
1435 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1437 found buffer-read-only)
1438 ;; Enter the current status into the dribble buffer.
1439 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1441 (not (gnus-ephemeral-group-p group)))
1443 (concat "(gnus-group-set-info '"
1444 (gnus-prin1-to-string (nth 2 entry))
1446 ;; Find all group instances. If topics are in use, each group
1447 ;; may be listed in more than once.
1448 (while (setq loc (text-property-any
1449 loc (point-max) 'gnus-group ident))
1452 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1454 (gnus-group-insert-group-line-info group)
1457 (gnus-run-hooks 'gnus-group-update-group-hook)))
1458 (setq loc (1+ loc)))
1459 (unless (or found visible-only)
1460 ;; No such line in the buffer, find out where it's supposed to
1461 ;; go, and insert it there (or at the end of the buffer).
1462 (if gnus-goto-missing-group-function
1463 (funcall gnus-goto-missing-group-function group)
1464 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1465 (while (and entry (car entry)
1469 (point-min) (point-max)
1470 'gnus-group (gnus-intern-safe
1471 (caar entry) gnus-active-hashtb)))))
1472 (setq entry (cdr entry)))
1473 (or entry (goto-char (point-max)))))
1474 ;; Finally insert the line.
1475 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1476 (gnus-group-insert-group-line-info group)
1479 (gnus-run-hooks 'gnus-group-update-group-hook))))
1480 (when gnus-group-update-group-function
1481 (funcall gnus-group-update-group-function group))
1482 (gnus-group-set-mode-line)))
1484 (set-marker mark nil)
1487 (defun gnus-group-set-mode-line ()
1488 "Update the mode line in the group buffer."
1489 (when (memq 'group gnus-updated-mode-lines)
1490 ;; Yes, we want to keep this mode line updated.
1492 (set-buffer gnus-group-buffer)
1493 (let* ((gformat (or gnus-group-mode-line-format-spec
1494 (gnus-set-format 'group-mode)))
1495 (gnus-tmp-news-server (cadr gnus-select-method))
1496 (gnus-tmp-news-method (car gnus-select-method))
1497 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1499 gnus-tmp-header ;Dummy binding for user-defined formats
1500 ;; Get the resulting string.
1502 (and gnus-dribble-buffer
1503 (buffer-name gnus-dribble-buffer)
1504 (buffer-modified-p gnus-dribble-buffer)
1506 (set-buffer gnus-dribble-buffer)
1507 (not (zerop (buffer-size))))))
1508 (mode-string (eval gformat)))
1509 ;; Say whether the dribble buffer has been modified.
1510 (setq mode-line-modified
1511 (if modified (car gnus-mode-line-modified)
1512 (cdr gnus-mode-line-modified)))
1513 ;; If the line is too long, we chop it off.
1514 (when (> (length mode-string) max-len)
1515 (setq mode-string (substring mode-string 0 (- max-len 4))))
1517 (setq mode-line-buffer-identification
1518 (gnus-mode-line-buffer-identification
1519 (list mode-string)))
1520 (set-buffer-modified-p modified))))))
1522 (defun gnus-group-group-name ()
1523 "Get the name of the newsgroup on the current line."
1524 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1526 (symbol-name group))))
1528 (defun gnus-group-group-level ()
1529 "Get the level of the newsgroup on the current line."
1530 (get-text-property (gnus-point-at-bol) 'gnus-level))
1532 (defun gnus-group-group-indentation ()
1533 "Get the indentation of the newsgroup on the current line."
1534 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1535 (and gnus-group-indentation-function
1536 (funcall gnus-group-indentation-function))
1539 (defun gnus-group-group-unread ()
1540 "Get the number of unread articles of the newsgroup on the current line."
1541 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1543 (defun gnus-group-new-mail (group)
1544 (if (nnmail-new-mail-p (gnus-group-real-name group))
1548 (defun gnus-group-level (group)
1549 "Return the estimated level of GROUP."
1550 (or (gnus-info-level (gnus-get-info group))
1551 (and (member group gnus-zombie-list) gnus-level-zombie)
1554 (defun gnus-group-search-forward (&optional backward all level first-too)
1555 "Find the next newsgroup with unread articles.
1556 If BACKWARD is non-nil, find the previous newsgroup instead.
1557 If ALL is non-nil, just find any newsgroup.
1558 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1560 If FIRST-TOO, the current line is also eligible as a target."
1561 (let ((way (if backward -1 1))
1562 (low gnus-level-killed)
1565 (if (and backward (progn (beginning-of-line)) (bobp))
1574 (get-text-property (point) 'gnus-group)
1578 (get-text-property (point) 'gnus-unread)))
1579 (and (numberp unread) (> unread 0)))
1580 (setq lev (get-text-property (point)
1582 (<= lev gnus-level-subscribed)))
1584 (and (setq lev (get-text-property (point)
1593 (zerop (forward-line way)))))
1595 (progn (gnus-group-position-point) t)
1596 (goto-char (or pos beg))
1599 ;;; Gnus group mode commands
1603 (defun gnus-group-mark-line-p ()
1606 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1607 (eq (char-after) gnus-process-mark)))
1609 (defun gnus-group-mark-group (n &optional unmark no-advance)
1610 "Mark the current group."
1612 (let ((buffer-read-only nil)
1616 (when (setq group (gnus-group-group-name))
1617 ;; Go to the mark position.
1619 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1620 (subst-char-in-region
1621 (point) (1+ (point)) (char-after)
1624 (setq gnus-group-marked (delete group gnus-group-marked))
1626 (setq gnus-group-marked
1627 (cons group (delete group gnus-group-marked)))
1628 gnus-process-mark)))
1630 (gnus-group-next-group 1))
1632 (gnus-summary-position-point)
1635 (defun gnus-group-unmark-group (n)
1636 "Remove the mark from the current group."
1638 (gnus-group-mark-group n 'unmark)
1639 (gnus-group-position-point))
1641 (defun gnus-group-unmark-all-groups ()
1642 "Unmark all groups."
1644 (let ((groups gnus-group-marked))
1647 (gnus-group-remove-mark (pop groups)))))
1648 (gnus-group-position-point))
1650 (defun gnus-group-mark-region (unmark beg end)
1651 "Mark all groups between point and mark.
1652 If UNMARK, remove the mark instead."
1653 (interactive "P\nr")
1654 (let ((num (count-lines beg end)))
1657 (- num (gnus-group-mark-group num unmark)))))
1659 (defun gnus-group-mark-buffer (&optional unmark)
1660 "Mark all groups in the buffer.
1661 If UNMARK, remove the mark instead."
1663 (gnus-group-mark-region unmark (point-min) (point-max)))
1665 (defun gnus-group-mark-regexp (regexp)
1666 "Mark all groups that match some regexp."
1667 (interactive "sMark (regexp): ")
1668 (let ((alist (cdr gnus-newsrc-alist))
1671 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1672 (gnus-group-set-mark group))))
1673 (gnus-group-position-point))
1675 (defun gnus-group-remove-mark (group &optional test-marked)
1676 "Remove the process mark from GROUP and move point there.
1677 Return nil if the group isn't displayed."
1678 (if (gnus-group-goto-group group nil test-marked)
1680 (gnus-group-mark-group 1 'unmark t)
1682 (setq gnus-group-marked
1683 (delete group gnus-group-marked))
1686 (defun gnus-group-set-mark (group)
1687 "Set the process mark on GROUP."
1688 (if (gnus-group-goto-group group)
1690 (gnus-group-mark-group 1 nil t))
1691 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1693 (defun gnus-group-universal-argument (arg &optional groups func)
1694 "Perform any command on all groups according to the process/prefix convention."
1696 (if (eq (setq func (or func
1699 (substitute-command-keys
1700 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1702 (gnus-error 1 "Undefined key")
1703 (gnus-group-iterate arg
1705 (command-execute func))))
1706 (gnus-group-position-point))
1708 (defun gnus-group-process-prefix (n)
1709 "Return a list of groups to work on.
1710 Take into consideration N (the prefix) and the list of marked groups."
1713 (setq n (prefix-numeric-value n))
1714 ;; There is a prefix, so we return a list of the N next
1716 (let ((way (if (< n 0) -1 1))
1721 (if (setq group (gnus-group-group-name))
1722 (push group groups))
1724 (gnus-group-next-group way)))
1726 ((gnus-region-active-p)
1727 ;; Work on the region between point and mark.
1728 (let ((max (max (point) (mark)))
1731 (goto-char (min (point) (mark)))
1734 (push (gnus-group-group-name) groups)
1735 (zerop (gnus-group-next-group 1))
1737 (nreverse groups))))
1739 ;; No prefix, but a list of marked articles.
1740 (reverse gnus-group-marked))
1742 ;; Neither marked articles or a prefix, so we return the
1744 (let ((group (gnus-group-group-name)))
1745 (and group (list group))))))
1747 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1748 ;;; imagine why I went through these contortions...
1750 (let ((function (make-symbol "gnus-group-iterate-function"))
1751 (window (make-symbol "gnus-group-iterate-window"))
1752 (groups (make-symbol "gnus-group-iterate-groups"))
1753 (group (make-symbol "gnus-group-iterate-group")))
1755 `(defun gnus-group-iterate (arg ,function)
1756 "Iterate FUNCTION over all process/prefixed groups.
1757 FUNCTION will be called with the group name as the parameter
1758 and with point over the group in question."
1759 (let ((,groups (gnus-group-process-prefix arg))
1760 (,window (selected-window))
1763 (setq ,group (car ,groups)
1764 ,groups (cdr ,groups))
1765 (select-window ,window)
1766 (gnus-group-remove-mark ,group)
1767 (save-selected-window
1769 (funcall ,function ,group)))))))))
1771 (put 'gnus-group-iterate 'lisp-indent-function 1)
1773 ;; Selecting groups.
1775 (defun gnus-group-read-group (&optional all no-article group select-articles)
1776 "Read news in this newsgroup.
1777 If the prefix argument ALL is non-nil, already read articles become
1778 readable. IF ALL is a number, fetch this number of articles. If the
1779 optional argument NO-ARTICLE is non-nil, no article will be
1780 auto-selected upon group entry. If GROUP is non-nil, fetch that
1783 (let ((no-display (eq all 0))
1784 (group (or group (gnus-group-group-name)))
1785 number active marked entry)
1789 (error "No group on current line"))
1790 (setq marked (gnus-info-marks
1791 (nth 2 (setq entry (gnus-gethash
1792 group gnus-newsrc-hashtb)))))
1793 ;; This group might be a dead group. In that case we have to get
1794 ;; the number of unread articles from `gnus-active-hashtb'.
1796 (cond ((numberp all) all)
1798 ((setq active (gnus-active group))
1799 (- (1+ (cdr active)) (car active)))))
1800 (gnus-summary-read-group
1801 group (or all (and (numberp number)
1802 (zerop (+ number (gnus-range-length
1803 (cdr (assq 'tick marked)))
1805 (cdr (assq 'dormant marked)))))))
1806 no-article nil no-display nil select-articles)))
1808 (defun gnus-group-select-group (&optional all)
1809 "Select this newsgroup.
1810 No article is selected automatically.
1811 If the group is opened, just switch the summary buffer.
1812 If ALL is non-nil, already read articles become readable.
1813 If ALL is a number, fetch this number of articles."
1815 (gnus-group-read-group all t))
1817 (defun gnus-group-quick-select-group (&optional all)
1818 "Select the current group \"quickly\".
1819 This means that no highlighting or scoring will be performed.
1820 If ALL (the prefix argument) is 0, don't even generate the summary
1823 This might be useful if you want to toggle threading
1824 before entering the group."
1826 (require 'gnus-score)
1828 gnus-score-find-score-files-function
1829 gnus-home-score-file
1830 gnus-apply-kill-hook
1831 gnus-summary-expunge-below)
1832 (gnus-group-read-group all t)))
1834 (defun gnus-group-visible-select-group (&optional all)
1835 "Select the current group without hiding any articles."
1837 (let ((gnus-inhibit-limiting t))
1838 (gnus-group-read-group all t)))
1840 (defun gnus-group-select-group-ephemerally ()
1841 "Select the current group without doing any processing whatsoever.
1842 You will actually be entered into a group that's a copy of
1843 the current group; no changes you make while in this group will
1846 (require 'gnus-score)
1848 gnus-score-find-score-files-function gnus-apply-kill-hook
1849 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1850 gnus-summary-mode-hook gnus-select-group-hook
1851 (group (gnus-group-group-name))
1852 (method (gnus-find-method-for-group group)))
1853 (gnus-group-read-ephemeral-group
1854 (gnus-group-prefixed-name group method) method)))
1857 (defun gnus-fetch-group (group)
1858 "Start Gnus if necessary and enter GROUP.
1859 Returns whether the fetching was successful or not."
1860 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1861 (unless (get-buffer gnus-group-buffer)
1863 (gnus-group-read-group nil nil group))
1866 (defun gnus-fetch-group-other-frame (group)
1867 "Pop up a frame and enter GROUP."
1869 (let ((window (get-buffer-window gnus-group-buffer)))
1871 (select-frame (window-frame window)))
1872 ((= (length (frame-list)) 1)
1873 (select-frame (make-frame)))
1876 (gnus-fetch-group group))
1878 (defvar gnus-ephemeral-group-server 0)
1880 ;; Enter a group that is not in the group buffer. Non-nil is returned
1881 ;; if selection was successful.
1882 (defun gnus-group-read-ephemeral-group (group method &optional activate
1883 quit-config request-only
1886 "Read GROUP from METHOD as an ephemeral group.
1887 If ACTIVATE, request the group first.
1888 If QUIT-CONFIG, use that window configuration when exiting from the
1890 If REQUEST-ONLY, don't actually read the group; just request it.
1891 If SELECT-ARTICLES, only select those articles.
1892 If PARAMETERS, use those as the group parameters.
1894 Return the name of the group if selection was successful."
1895 ;; Transform the select method into a unique server.
1896 (when (stringp method)
1897 (setq method (gnus-server-to-method method)))
1899 `(,(car method) ,(concat (cadr method) "-ephemeral")
1900 (,(intern (format "%s-address" (car method))) ,(cadr method))
1902 (let ((group (if (gnus-group-foreign-p group) group
1903 (gnus-group-prefixed-name (gnus-group-real-name group)
1908 ,gnus-level-default-subscribed nil nil ,method
1911 (cons 'quit-config quit-config)
1913 (cons gnus-summary-buffer
1914 gnus-current-window-configuration)))
1917 (push method gnus-ephemeral-servers)
1918 (set-buffer gnus-group-buffer)
1919 (unless (gnus-check-server method)
1920 (error "Unable to contact server: %s" (gnus-status-message method)))
1922 (gnus-activate-group group 'scan)
1923 (unless (gnus-request-group group)
1924 (error "Couldn't request group: %s"
1925 (nnheader-get-report (car method)))))
1929 (when (gnus-group-read-group t t group select-articles)
1933 (message "Quit reading the ephemeral group")
1936 (defun gnus-group-jump-to-group (group)
1937 "Jump to newsgroup GROUP."
1939 (list (completing-read
1940 "Group: " gnus-active-hashtb nil
1941 (gnus-read-active-file-p)
1942 gnus-group-jump-to-group-prompt
1943 'gnus-group-history)))
1945 (when (equal group "")
1946 (error "Empty group name"))
1948 (unless (gnus-ephemeral-group-p group)
1949 ;; Either go to the line in the group buffer...
1950 (unless (gnus-group-goto-group group)
1951 ;; ... or insert the line.
1952 (gnus-group-update-group group)
1953 (gnus-group-goto-group group)))
1954 ;; Adjust cursor point.
1955 (gnus-group-position-point))
1957 (defun gnus-group-goto-group (group &optional far test-marked)
1958 "Goto to newsgroup GROUP.
1959 If FAR, it is likely that the group is not on the current line.
1960 If TEST-MARKED, the line must be marked."
1964 ;; It's quite likely that we are on the right line, so
1965 ;; we check the current line first.
1967 (eq (get-text-property (point) 'gnus-group)
1968 (gnus-intern-safe group gnus-active-hashtb))
1969 (or (not test-marked) (gnus-group-mark-line-p)))
1971 ;; Previous and next line are also likely, so we check them as well.
1975 (and (eq (get-text-property (point) 'gnus-group)
1976 (gnus-intern-safe group gnus-active-hashtb))
1977 (or (not test-marked) (gnus-group-mark-line-p)))))
1983 (and (eq (get-text-property (point) 'gnus-group)
1984 (gnus-intern-safe group gnus-active-hashtb))
1985 (or (not test-marked) (gnus-group-mark-line-p)))))
1989 (goto-char (point-min))
1991 (while (and (not found)
1996 (gnus-intern-safe group gnus-active-hashtb))))
1997 (if (gnus-group-mark-line-p)
2002 ;; Search through the entire buffer.
2005 (point-min) (point-max)
2006 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2008 (defun gnus-group-next-group (n &optional silent)
2009 "Go to next N'th newsgroup.
2010 If N is negative, search backward instead.
2011 Returns the difference between N and the number of skips actually
2014 (gnus-group-next-unread-group n t nil silent))
2016 (defun gnus-group-next-unread-group (n &optional all level silent)
2017 "Go to next N'th unread newsgroup.
2018 If N is negative, search backward instead.
2019 If ALL is non-nil, choose any newsgroup, unread or not.
2020 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2021 such group can be found, the next group with a level higher than
2023 Returns the difference between N and the number of skips actually
2026 (let ((backward (< n 0))
2029 (gnus-group-search-forward
2030 backward (or (not gnus-group-goto-unread) all) level))
2034 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2035 (if level " on this level or higher" "")))
2038 (defun gnus-group-prev-group (n)
2039 "Go to previous N'th newsgroup.
2040 Returns the difference between N and the number of skips actually
2043 (gnus-group-next-unread-group (- n) t))
2045 (defun gnus-group-prev-unread-group (n)
2046 "Go to previous N'th unread newsgroup.
2047 Returns the difference between N and the number of skips actually
2050 (gnus-group-next-unread-group (- n)))
2052 (defun gnus-group-next-unread-group-same-level (n)
2053 "Go to next N'th unread newsgroup on the same level.
2054 If N is negative, search backward instead.
2055 Returns the difference between N and the number of skips actually
2058 (gnus-group-next-unread-group n t (gnus-group-group-level))
2059 (gnus-group-position-point))
2061 (defun gnus-group-prev-unread-group-same-level (n)
2062 "Go to next N'th unread newsgroup on the same level.
2063 Returns the difference between N and the number of skips actually
2066 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2067 (gnus-group-position-point))
2069 (defun gnus-group-best-unread-group (&optional exclude-group)
2070 "Go to the group with the highest level.
2071 If EXCLUDE-GROUP, do not go to that group."
2073 (goto-char (point-min))
2077 (setq unread (get-text-property (point) 'gnus-unread))
2078 (when (and (numberp unread) (> unread 0))
2079 (when (and (get-text-property (point) 'gnus-level)
2080 (< (get-text-property (point) 'gnus-level) best)
2081 (or (not exclude-group)
2082 (not (equal exclude-group (gnus-group-group-name)))))
2083 (setq best (get-text-property (point) 'gnus-level))
2084 (setq best-point (point))))
2087 (goto-char best-point))
2088 (gnus-summary-position-point)
2089 (and best-point (gnus-group-group-name))))
2091 (defun gnus-group-first-unread-group ()
2092 "Go to the first group with unread articles."
2095 (let ((opoint (point))
2097 (goto-char (point-min))
2098 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2099 (and (numberp unread) ; Not a topic.
2100 (not (zerop unread))) ; Has unread articles.
2101 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2104 nil)) ; Not success.
2105 (gnus-group-position-point)))
2107 (defun gnus-group-enter-server-mode ()
2108 "Jump to the server buffer."
2110 (gnus-enter-server-buffer))
2112 (defun gnus-group-make-group (name &optional method address args)
2113 "Add a new newsgroup.
2114 The user will be prompted for a NAME, for a select METHOD, and an
2118 (gnus-read-group "Group name: ")
2119 (gnus-read-method "From method: ")))
2121 (when (stringp method)
2122 (setq method (or (gnus-server-to-method method) method)))
2123 (let* ((meth (gnus-method-simplify
2125 (not (gnus-server-equal method gnus-select-method)))
2126 (if address (list (intern method) address)
2128 (nname (if method (gnus-group-prefixed-name name meth) name))
2130 (when (gnus-gethash nname gnus-newsrc-hashtb)
2131 (error "Group %s already exists" nname))
2132 ;; Subscribe to the new group.
2133 (gnus-group-change-level
2134 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2135 gnus-level-default-subscribed gnus-level-killed
2136 (and (gnus-group-group-name)
2137 (gnus-gethash (gnus-group-group-name)
2138 gnus-newsrc-hashtb))
2141 (gnus-set-active nname (cons 1 0))
2142 (unless (gnus-ephemeral-group-p name)
2144 (concat "(gnus-group-set-info '"
2145 (gnus-prin1-to-string (cdr info)) ")")))
2147 (gnus-group-insert-group-line-info nname)
2149 (gnus-group-position-point)
2151 ;; Load the backend and try to make the backend create
2152 ;; the group as well.
2153 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2155 gnus-valid-select-methods)
2157 (gnus-check-server meth)
2158 (when (gnus-check-backend-function 'request-create-group nname)
2159 (gnus-request-create-group nname nil args))
2162 (defun gnus-group-delete-groups (&optional arg)
2163 "Delete the current group. Only meaningful with editable groups."
2165 (let ((n (length (gnus-group-process-prefix arg))))
2166 (when (gnus-yes-or-no-p
2168 "Delete this 1 group? "
2169 (format "Delete these %d groups? " n)))
2170 (gnus-group-iterate arg
2172 (gnus-group-delete-group group nil t))))))
2174 (defun gnus-group-delete-group (group &optional force no-prompt)
2175 "Delete the current group. Only meaningful with editable groups.
2176 If FORCE (the prefix) is non-nil, all the articles in the group will
2177 be deleted. This is \"deleted\" as in \"removed forever from the face
2178 of the Earth\". There is no undo. The user will be prompted before
2179 doing the deletion."
2181 (list (gnus-group-group-name)
2182 current-prefix-arg))
2184 (error "No group to delete"))
2185 (unless (gnus-check-backend-function 'request-delete-group group)
2186 (error "This backend does not support group deletion"))
2188 (if (and (not no-prompt)
2189 (not (gnus-yes-or-no-p
2191 "Do you really want to delete %s%s? "
2192 group (if force " and all its contents" "")))))
2194 (gnus-message 6 "Deleting group %s..." group)
2195 (if (not (gnus-request-delete-group group force))
2196 (gnus-error 3 "Couldn't delete group %s" group)
2197 (gnus-message 6 "Deleting group %s...done" group)
2198 (gnus-group-goto-group group)
2199 (gnus-group-kill-group 1 t)
2200 (gnus-sethash group nil gnus-active-hashtb)
2202 (gnus-group-position-point)))
2204 (defun gnus-group-rename-group (group new-name)
2205 "Rename group from GROUP to NEW-NAME.
2206 When used interactively, GROUP is the group under point
2207 and NEW-NAME will be prompted for."
2210 (gnus-group-group-name)
2212 (unless (gnus-check-backend-function
2213 'request-rename-group (gnus-group-group-name))
2214 (error "This backend does not support renaming groups"))
2215 (gnus-read-group "Rename group to: "
2216 (gnus-group-real-name (gnus-group-group-name))))))
2218 (unless (gnus-check-backend-function 'request-rename-group group)
2219 (error "This backend does not support renaming groups"))
2221 (error "No group to rename"))
2222 (when (equal (gnus-group-real-name group) new-name)
2223 (error "Can't rename to the same name"))
2225 ;; We find the proper prefixed name.
2227 (if (gnus-group-native-p group)
2231 (gnus-group-prefixed-name
2232 (gnus-group-real-name new-name)
2233 (gnus-info-method (gnus-get-info group)))))
2235 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2238 (gnus-group-goto-group group)
2239 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2240 (gnus-request-rename-group group new-name))))
2241 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2242 ;; We rename the group internally by killing it...
2243 (gnus-group-kill-group)
2244 ;; ... changing its name ...
2245 (setcar (cdar gnus-list-of-killed-groups) new-name)
2246 ;; ... and then yanking it. Magic!
2247 (gnus-group-yank-group)
2248 (gnus-set-active new-name (gnus-active group))
2249 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2251 (setq gnus-killed-list (delete group gnus-killed-list))
2252 (gnus-set-active group nil)
2253 (gnus-dribble-touch)
2254 (gnus-group-position-point)))
2256 (defun gnus-group-edit-group (group &optional part)
2257 "Edit the group on the current line."
2258 (interactive (list (gnus-group-group-name)))
2259 (let ((part (or part 'info))
2262 (error "No group on current line"))
2263 (unless (setq info (gnus-get-info group))
2264 (error "Killed group; can't be edited"))
2266 (gnus-close-group group))
2268 ;; Find the proper form to edit.
2269 (cond ((eq part 'method)
2270 (or (gnus-info-method info) "native"))
2272 (gnus-info-params info))
2274 ;; The proper documentation.
2276 "Editing the %s for `%s'."
2278 ((eq part 'method) "select method")
2279 ((eq part 'params) "group parameters")
2281 (gnus-group-decoded-name group))
2283 (gnus-group-edit-group-done ',part ,group form)))
2286 (gnus-create-info-command
2289 "(gnus)Select Methods")
2291 "(gnus)Group Parameters")
2293 "(gnus)Group Info"))))))
2295 (defun gnus-group-edit-group-method (group)
2296 "Edit the select method of GROUP."
2297 (interactive (list (gnus-group-group-name)))
2298 (gnus-group-edit-group group 'method))
2300 (defun gnus-group-edit-group-parameters (group)
2301 "Edit the group parameters of GROUP."
2302 (interactive (list (gnus-group-group-name)))
2303 (gnus-group-edit-group group 'params))
2305 (defun gnus-group-edit-group-done (part group form)
2307 (let* ((method (cond ((eq part 'info) (nth 4 form))
2308 ((eq part 'method) form)
2310 (info (cond ((eq part 'info) form)
2311 ((eq part 'method) (gnus-get-info group))
2314 (if (or (not method)
2316 gnus-select-method method))
2317 (gnus-group-real-name (car info))
2318 (gnus-group-prefixed-name
2319 (gnus-group-real-name (car info)) method))
2321 (when (and new-group
2322 (not (equal new-group group)))
2323 (when (gnus-group-goto-group group)
2324 (gnus-group-kill-group 1))
2325 (gnus-activate-group new-group))
2327 (if (not (and info new-group))
2328 (gnus-group-set-info form (or new-group group) part)
2329 (setq info (gnus-copy-sequence info))
2330 (setcar info new-group)
2331 (unless (gnus-server-equal method "native")
2332 (unless (nthcdr 3 info)
2333 (nconc info (list nil nil)))
2334 (unless (nthcdr 4 info)
2335 (nconc info (list nil)))
2336 (gnus-info-set-method info method))
2337 (gnus-group-set-info info))
2338 (gnus-group-update-group (or new-group group))
2339 (gnus-group-position-point)))
2341 (defun gnus-group-make-useful-group (group method)
2342 "Create one of the groups described in `gnus-useful-groups'."
2344 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2346 gnus-useful-groups)))
2347 (list (cadr entry) (caddr entry))))
2348 (setq method (gnus-copy-sequence method))
2350 (while (setq entry (memq (assq 'eval method) method))
2351 (setcar entry (eval (cadar entry)))))
2352 (gnus-group-make-group group method))
2354 (defun gnus-group-make-help-group (&optional noerror)
2355 "Create the Gnus documentation group.
2356 Optional argument NOERROR modifies the behavior of this function when the
2357 group already exists:
2358 - if not given, and error is signaled,
2359 - if t, stay silent,
2360 - if anything else, just print a message."
2362 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2363 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2364 (if (gnus-gethash name gnus-newsrc-hashtb)
2365 (cond ((eq noerror nil)
2366 (error "Documentation group already exists"))
2371 (gnus-message 1 "Documentation group already exists")))
2374 (gnus-message 1 "Couldn't find doc group")
2375 (gnus-group-make-group
2376 (gnus-group-real-name name)
2377 (list 'nndoc "gnus-help"
2378 (list 'nndoc-address file)
2379 (list 'nndoc-article-type 'mbox))))
2381 (gnus-group-position-point))
2383 (defun gnus-group-make-doc-group (file type)
2384 "Create a group that uses a single file as the source."
2386 (list (read-file-name "File name: ")
2387 (and current-prefix-arg 'ask)))
2388 (when (eq type 'ask)
2393 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2395 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2396 ((= char ?b) 'babyl)
2397 ((= char ?d) 'digest)
2398 ((= char ?f) 'forward)
2400 ((= char ?g) 'guess)
2401 (t (setq err (format "%c unknown. " char))
2404 (let* ((file (expand-file-name file))
2405 (name (gnus-generate-new-group-name
2406 (gnus-group-prefixed-name
2407 (file-name-nondirectory file) '(nndoc "")))))
2408 (gnus-group-make-group
2409 (gnus-group-real-name name)
2411 (list 'nndoc-address file)
2412 (list 'nndoc-article-type (or type 'guess))))))
2414 (defvar nnweb-type-definition)
2415 (defvar gnus-group-web-type-history nil)
2416 (defvar gnus-group-web-search-history nil)
2417 (defun gnus-group-make-web-group (&optional solid)
2418 "Create an ephemeral nnweb group.
2419 If SOLID (the prefix), create a solid group."
2423 (if solid (gnus-read-group "Group name: ")
2424 (message-unique-id)))
2425 (default-type (or (car gnus-group-web-type-history)
2426 (symbol-name (caar nnweb-type-definition))))
2430 (format "Search engine type (default %s): " default-type)
2431 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2432 nnweb-type-definition)
2433 nil t nil 'gnus-group-web-type-history)
2438 (cons (or (car gnus-group-web-search-history) "") 0)
2439 'gnus-group-web-search-history))
2441 `(nnweb ,group (nnweb-search ,search)
2442 (nnweb-type ,(intern type))
2443 (nnweb-ephemeral-p t))))
2445 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2446 (gnus-group-read-ephemeral-group
2448 (cons (current-buffer)
2449 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2451 (defvar nnwarchive-type-definition)
2452 (defvar gnus-group-warchive-type-history nil)
2453 (defvar gnus-group-warchive-login-history nil)
2454 (defvar gnus-group-warchive-address-history nil)
2456 (defun gnus-group-make-warchive-group ()
2457 "Create a nnwarchive group."
2459 (require 'nnwarchive)
2460 (let* ((group (gnus-read-group "Group name: "))
2461 (default-type (or (car gnus-group-warchive-type-history)
2462 (symbol-name (caar nnwarchive-type-definition))))
2466 (format "Warchive type (default %s): " default-type)
2467 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2468 nnwarchive-type-definition)
2469 nil t nil 'gnus-group-warchive-type-history)
2471 (address (read-string "Warchive address: "
2472 nil 'gnus-group-warchive-address-history))
2473 (default-login (or (car gnus-group-warchive-login-history)
2478 (format "Warchive login (default %s): " user-mail-address)
2479 default-login 'gnus-group-warchive-login-history)
2482 `(nnwarchive ,address
2483 (nnwarchive-type ,(intern type))
2484 (nnwarchive-login ,login))))
2485 (gnus-group-make-group group method)))
2487 (defun gnus-group-make-archive-group (&optional all)
2488 "Create the (ding) Gnus archive group of the most recent articles.
2489 Given a prefix, create a full group."
2491 (let ((group (gnus-group-prefixed-name
2492 (if all "ding.archives" "ding.recent") '(nndir ""))))
2493 (when (gnus-gethash group gnus-newsrc-hashtb)
2494 (error "Archive group already exists"))
2495 (gnus-group-make-group
2496 (gnus-group-real-name group)
2497 (list 'nndir (if all "hpc" "edu")
2498 (list 'nndir-directory
2499 (if all gnus-group-archive-directory
2500 gnus-group-recent-archive-directory))))
2501 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2503 (defun gnus-group-make-directory-group (dir)
2504 "Create an nndir group.
2505 The user will be prompted for a directory. The contents of this
2506 directory will be used as a newsgroup. The directory should contain
2507 mail messages or news articles in files that have numeric names."
2509 (list (read-file-name "Create group from directory: ")))
2510 (unless (file-exists-p dir)
2511 (error "No such directory"))
2512 (unless (file-directory-p dir)
2513 (error "Not a directory"))
2517 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2519 (gnus-group-prefixed-name
2520 (expand-file-name ext dir)
2522 (setq ext (format "<%d>" (setq i (1+ i)))))
2523 (gnus-group-make-group
2524 (gnus-group-real-name group)
2525 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2527 (eval-when-compile (defvar nnkiboze-score-file))
2528 (defun gnus-group-make-kiboze-group (group address scores)
2529 "Create an nnkiboze group.
2530 The user will be prompted for a name, a regexp to match groups, and
2531 score file entries for articles to include in the group."
2534 (read-string "nnkiboze group name: ")
2535 (read-string "Source groups (regexp): ")
2536 (let ((headers (mapcar (lambda (group) (list group))
2537 '("subject" "from" "number" "date" "message-id"
2538 "references" "chars" "lines" "xref"
2539 "followup" "all" "body" "head")))
2540 scores header regexp regexps)
2541 (while (not (equal "" (setq header (completing-read
2542 "Match on header: " headers nil t))))
2544 (while (not (equal "" (setq regexp (read-string
2545 (format "Match on %s (regexp): "
2547 (push (list regexp nil nil 'r) regexps))
2548 (push (cons header regexps) scores))
2550 (gnus-group-make-group group "nnkiboze" address)
2551 (let* ((nnkiboze-current-group group)
2552 (score-file (car (nnkiboze-score-file "")))
2553 (score-dir (file-name-directory score-file)))
2554 (unless (file-exists-p score-dir)
2555 (make-directory score-dir))
2556 (with-temp-file score-file
2557 (let (emacs-lisp-mode-hook)
2558 (pp scores (current-buffer))))))
2560 (defun gnus-group-add-to-virtual (n vgroup)
2561 "Add the current group to a virtual group."
2563 (list current-prefix-arg
2564 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2566 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2567 (error "%s is not an nnvirtual group" vgroup))
2568 (gnus-close-group vgroup)
2569 (let* ((groups (gnus-group-process-prefix n))
2570 (method (gnus-info-method (gnus-get-info vgroup))))
2571 (setcar (cdr method)
2573 (nth 1 method) "\\|"
2576 (gnus-group-remove-mark s)
2577 (concat "\\(^" (regexp-quote s) "$\\)"))
2579 (gnus-group-position-point))
2581 (defun gnus-group-make-empty-virtual (group)
2582 "Create a new, fresh, empty virtual group."
2583 (interactive "sCreate new, empty virtual group: ")
2584 (let* ((method (list 'nnvirtual "^$"))
2585 (pgroup (gnus-group-prefixed-name group method)))
2586 ;; Check whether it exists already.
2587 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2588 (error "Group %s already exists" pgroup))
2589 ;; Subscribe the new group after the group on the current line.
2590 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2591 (gnus-group-update-group pgroup)
2593 (gnus-group-position-point)))
2595 (defun gnus-group-enter-directory (dir)
2596 "Enter an ephemeral nneething group."
2597 (interactive "DDirectory to read: ")
2598 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2599 (leaf (gnus-group-prefixed-name
2600 (file-name-nondirectory (directory-file-name dir))
2602 (name (gnus-generate-new-group-name leaf)))
2603 (unless (gnus-group-read-ephemeral-group
2605 (cons (current-buffer)
2606 (if (eq major-mode 'gnus-summary-mode)
2608 (error "Couldn't enter %s" dir))))
2611 (autoload 'nnimap-expunge "nnimap")
2612 (autoload 'nnimap-acl-get "nnimap")
2613 (autoload 'nnimap-acl-edit "nnimap"))
2615 (defun gnus-group-nnimap-expunge (group)
2616 "Expunge deleted articles in current nnimap GROUP."
2617 (interactive (list (gnus-group-group-name)))
2618 (let ((mailbox (gnus-group-real-name group)) method)
2620 (error "No group on current line"))
2621 (unless (gnus-get-info group)
2622 (error "Killed group; can't be edited"))
2623 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2624 (error "%s is not an nnimap group" group))
2625 (nnimap-expunge mailbox (cadr method))))
2627 (defun gnus-group-nnimap-edit-acl (group)
2628 "Edit the Access Control List of current nnimap GROUP."
2629 (interactive (list (gnus-group-group-name)))
2630 (let ((mailbox (gnus-group-real-name group)) method acl)
2632 (error "No group on current line"))
2633 (unless (gnus-get-info group)
2634 (error "Killed group; can't be edited"))
2635 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2636 (error "%s is not an nnimap group" group))
2637 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2638 (error "Server does not support ACL's"))
2639 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2641 An access control list is a list of (identifier . rights) elements.
2643 The identifier string specifies the corresponding user. The
2644 identifier \"anyone\" is reserved to refer to the universal identity.
2646 Rights is a string listing a (possibly empty) set of alphanumeric
2647 characters, each character listing a set of operations which is being
2648 controlled. Letters are reserved for ``standard'' rights, listed
2649 below. Digits are reserved for implementation or site defined rights.
2651 l - lookup (mailbox is visible to LIST/LSUB commands)
2652 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2653 SEARCH, COPY from mailbox)
2654 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2655 w - write (STORE flags other than \\SEEN and \\DELETED)
2656 i - insert (perform APPEND, COPY into mailbox)
2657 p - post (send mail to submission address for mailbox,
2658 not enforced by IMAP4 itself)
2659 c - create and delete mailbox (CREATE new sub-mailboxes in any
2660 implementation-defined hierarchy, RENAME or DELETE mailbox)
2661 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2662 a - administer (perform SETACL)" group)
2665 ,mailbox ',method ',acl form)))))
2667 ;; Group sorting commands
2668 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2670 (defun gnus-group-sort-groups (func &optional reverse)
2671 "Sort the group buffer according to FUNC.
2672 When used interactively, the sorting function used will be
2673 determined by the `gnus-group-sort-function' variable.
2674 If REVERSE (the prefix), reverse the sorting order."
2675 (interactive (list gnus-group-sort-function current-prefix-arg))
2676 (funcall gnus-group-sort-alist-function
2677 (gnus-make-sort-function func) reverse)
2678 (gnus-group-unmark-all-groups)
2679 (gnus-group-list-groups)
2680 (gnus-dribble-touch))
2682 (defun gnus-group-sort-flat (func reverse)
2683 ;; We peel off the dummy group from the alist.
2685 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2686 (pop gnus-newsrc-alist))
2688 (setq gnus-newsrc-alist
2689 (sort gnus-newsrc-alist func))
2691 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2692 ;; Regenerate the hash table.
2693 (gnus-make-hashtable-from-newsrc-alist)))
2695 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2696 "Sort the group buffer alphabetically by group name.
2697 If REVERSE, sort in reverse order."
2699 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2701 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2702 "Sort the group buffer by number of unread articles.
2703 If REVERSE, sort in reverse order."
2705 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2707 (defun gnus-group-sort-groups-by-level (&optional reverse)
2708 "Sort the group buffer by group level.
2709 If REVERSE, sort in reverse order."
2711 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2713 (defun gnus-group-sort-groups-by-score (&optional reverse)
2714 "Sort the group buffer by group score.
2715 If REVERSE, sort in reverse order."
2717 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2719 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2720 "Sort the group buffer by group rank.
2721 If REVERSE, sort in reverse order."
2723 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2725 (defun gnus-group-sort-groups-by-method (&optional reverse)
2726 "Sort the group buffer alphabetically by backend name.
2727 If REVERSE, sort in reverse order."
2729 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2731 (defun gnus-group-sort-groups-by-server (&optional reverse)
2732 "Sort the group buffer alphabetically by server name.
2733 If REVERSE, sort in reverse order."
2735 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2737 ;;; Selected group sorting.
2739 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2740 "Sort the process/prefixed groups."
2741 (interactive (list current-prefix-arg gnus-group-sort-function))
2742 (let ((groups (gnus-group-process-prefix n)))
2743 (funcall gnus-group-sort-selected-function
2744 groups (gnus-make-sort-function func) reverse)
2745 (gnus-group-unmark-all-groups)
2746 (gnus-group-list-groups)
2747 (gnus-dribble-touch)))
2749 (defun gnus-group-sort-selected-flat (groups func reverse)
2750 (let (entries infos)
2751 ;; First find all the group entries for these groups.
2753 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2755 ;; Then sort the infos.
2759 (lambda (entry) (car entry))
2760 (setq entries (nreverse entries)))
2763 (setq infos (nreverse infos)))
2764 ;; Go through all the infos and replace the old entries
2765 ;; with the new infos.
2767 (setcar (car entries) (pop infos))
2769 ;; Update the hashtable.
2770 (gnus-make-hashtable-from-newsrc-alist)))
2772 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2773 "Sort the group buffer alphabetically by group name.
2774 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2775 sort in reverse order."
2776 (interactive (gnus-interactive "P\ny"))
2777 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2779 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2780 "Sort the group buffer by number of unread articles.
2781 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2782 sort in reverse order."
2783 (interactive (gnus-interactive "P\ny"))
2784 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2786 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2787 "Sort the group buffer by group level.
2788 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2789 sort in reverse order."
2790 (interactive (gnus-interactive "P\ny"))
2791 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2793 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2794 "Sort the group buffer by group score.
2795 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2796 sort in reverse order."
2797 (interactive (gnus-interactive "P\ny"))
2798 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2800 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2801 "Sort the group buffer by group rank.
2802 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2803 sort in reverse order."
2804 (interactive (gnus-interactive "P\ny"))
2805 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2807 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2808 "Sort the group buffer alphabetically by backend name.
2809 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2810 sort in reverse order."
2811 (interactive (gnus-interactive "P\ny"))
2812 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2814 ;;; Sorting predicates.
2816 (defun gnus-group-sort-by-alphabet (info1 info2)
2817 "Sort alphabetically."
2818 (string< (gnus-info-group info1) (gnus-info-group info2)))
2820 (defun gnus-group-sort-by-real-name (info1 info2)
2821 "Sort alphabetically on real (unprefixed) names."
2822 (string< (gnus-group-real-name (gnus-info-group info1))
2823 (gnus-group-real-name (gnus-info-group info2))))
2825 (defun gnus-group-sort-by-unread (info1 info2)
2826 "Sort by number of unread articles."
2827 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2828 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2829 (< (or (and (numberp n1) n1) 0)
2830 (or (and (numberp n2) n2) 0))))
2832 (defun gnus-group-sort-by-level (info1 info2)
2834 (< (gnus-info-level info1) (gnus-info-level info2)))
2836 (defun gnus-group-sort-by-method (info1 info2)
2837 "Sort alphabetically by backend name."
2838 (string< (symbol-name (car (gnus-find-method-for-group
2839 (gnus-info-group info1) info1)))
2840 (symbol-name (car (gnus-find-method-for-group
2841 (gnus-info-group info2) info2)))))
2843 (defun gnus-group-sort-by-server (info1 info2)
2844 "Sort alphabetically by server name."
2845 (string< (gnus-method-to-full-server-name
2846 (gnus-find-method-for-group
2847 (gnus-info-group info1) info1))
2848 (gnus-method-to-full-server-name
2849 (gnus-find-method-for-group
2850 (gnus-info-group info2) info2))))
2852 (defun gnus-group-sort-by-score (info1 info2)
2853 "Sort by group score."
2854 (> (gnus-info-score info1) (gnus-info-score info2)))
2856 (defun gnus-group-sort-by-rank (info1 info2)
2857 "Sort by level and score."
2858 (let ((level1 (gnus-info-level info1))
2859 (level2 (gnus-info-level info2)))
2860 (or (< level1 level2)
2861 (and (= level1 level2)
2862 (> (gnus-info-score info1) (gnus-info-score info2))))))
2866 (defun gnus-group-clear-data (&optional arg)
2867 "Clear all marks and read ranges from the current group."
2869 (gnus-group-iterate arg
2872 (gnus-info-clear-data (setq info (gnus-get-info group)))
2873 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2874 (when (gnus-group-goto-group group)
2875 (gnus-group-update-group-line))))))
2877 (defun gnus-group-clear-data-on-native-groups ()
2878 "Clear all marks and read ranges from all native groups."
2880 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2881 (let ((alist (cdr gnus-newsrc-alist))
2883 (while (setq info (pop alist))
2884 (when (gnus-group-native-p (gnus-info-group info))
2885 (gnus-info-clear-data info)))
2886 (gnus-get-unread-articles)
2887 (gnus-dribble-touch)
2888 (when (gnus-y-or-n-p
2889 "Move the cache away to avoid problems in the future? ")
2890 (call-interactively 'gnus-cache-move-cache)))))
2892 (defun gnus-info-clear-data (info)
2893 "Clear all marks and read ranges from INFO."
2894 (let ((group (gnus-info-group info))
2896 (dolist (el (gnus-info-marks info))
2897 (push `(,(cdr el) add (,(car el))) action))
2898 (push `(,(gnus-info-read info) add (read)) action)
2901 (gnus-request-set-mark ,group ',action)
2902 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2903 (gnus-info-set-read ',info ',(gnus-info-read info))
2904 (when (gnus-group-goto-group ,group)
2905 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2906 (gnus-group-update-group-line))))
2907 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2909 (gnus-request-set-mark group action)
2910 (gnus-info-set-read info nil)
2911 (when (gnus-info-marks info)
2912 (gnus-info-set-marks info nil))))
2914 ;; Group catching up.
2916 (defun gnus-group-catchup-current (&optional n all)
2917 "Mark all unread articles in the current newsgroup as read.
2918 If prefix argument N is numeric, the next N newsgroups will be
2919 caught up. If ALL is non-nil, marked articles will also be marked as
2920 read. Cross references (Xref: header) of articles are ignored.
2921 The number of newsgroups that this function was unable to catch
2924 (let ((groups (gnus-group-process-prefix n))
2927 (unless groups (error "No groups selected"))
2929 (or (not gnus-interactive-catchup) ;Without confirmation?
2934 "Do you really want to mark all articles in %s as read? "
2935 "Mark all unread articles in %s as read? ")
2936 (if (= (length groups) 1)
2938 (format "these %d groups" (length groups)))))))
2940 (while (setq group (pop groups))
2941 (gnus-group-remove-mark group)
2942 ;; Virtual groups have to be given special treatment.
2943 (let ((method (gnus-find-method-for-group group)))
2944 (when (eq 'nnvirtual (car method))
2945 (nnvirtual-catchup-group
2946 (gnus-group-real-name group) (nth 1 method) all)))
2947 (if (>= (gnus-group-level group) gnus-level-zombie)
2948 (gnus-message 2 "Dead groups can't be caught up")
2950 (gnus-group-goto-group group)
2951 (gnus-group-catchup group all))
2952 (gnus-group-update-group-line)
2953 (setq ret (1+ ret)))))
2954 (gnus-group-next-unread-group 1)
2957 (defun gnus-group-catchup-current-all (&optional n)
2958 "Mark all articles in current newsgroup as read.
2959 Cross references (Xref: header) of articles are ignored."
2961 (gnus-group-catchup-current n 'all))
2963 (defun gnus-group-catchup (group &optional all)
2964 "Mark all articles in GROUP as read.
2965 If ALL is non-nil, all articles are marked as read.
2966 The return value is the number of articles that were marked as read,
2967 or nil if no action could be taken."
2968 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2970 (marks (nth 3 (nth 2 entry)))
2971 (unread (gnus-list-of-unread-articles group)))
2972 ;; Remove entries for this group.
2973 (nnmail-purge-split-history (gnus-group-real-name group))
2974 ;; Do the updating only if the newsgroup isn't killed.
2975 (if (not (numberp (car entry)))
2976 (gnus-message 1 "Can't catch up %s; non-active group" group)
2977 (gnus-update-read-articles group nil)
2979 ;; Nix out the lists of marks and dormants.
2980 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
2982 (list (cdr (assq 'dormant marks))
2984 (setq unread (gnus-uncompress-range
2985 (gnus-range-add (gnus-range-add
2986 unread (cdr (assq 'dormant marks)))
2987 (cdr (assq 'tick marks)))))
2988 (gnus-add-marked-articles group 'tick nil nil 'force)
2989 (gnus-add-marked-articles group 'dormant nil nil 'force))
2990 ;; Do auto-expirable marks if that's required.
2991 (when (gnus-group-auto-expirable-p group)
2992 (gnus-add-marked-articles group 'expire unread)
2993 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
2994 (let ((gnus-newsgroup-name group))
2995 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2998 (defun gnus-group-expire-articles (&optional n)
2999 "Expire all expirable articles in the current newsgroup."
3001 (let ((groups (gnus-group-process-prefix n))
3004 (error "No groups to expire"))
3005 (while (setq group (pop groups))
3006 (gnus-group-remove-mark group)
3007 (gnus-group-expire-articles-1 group)
3008 (gnus-dribble-touch)
3009 (gnus-group-position-point))))
3011 (defun gnus-group-expire-articles-1 (group)
3012 (when (gnus-check-backend-function 'request-expire-articles group)
3013 (gnus-message 6 "Expiring articles in %s..." group)
3014 (let* ((info (gnus-get-info group))
3015 (expirable (if (gnus-group-total-expirable-p group)
3016 (cons nil (gnus-list-of-read-articles group))
3017 (assq 'expire (gnus-info-marks info))))
3018 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3019 (nnmail-expiry-target
3020 (or (gnus-group-find-parameter group 'expiry-target)
3021 nnmail-expiry-target)))
3023 (gnus-check-group group)
3026 (gnus-compress-sequence
3028 ;; We set the expiry variables to the group
3030 (let ((nnmail-expiry-wait-function nil)
3031 (nnmail-expiry-wait expiry-wait))
3032 (gnus-request-expire-articles
3033 (gnus-uncompress-sequence (cdr expirable)) group))
3034 ;; Just expire using the normal expiry values.
3035 (gnus-request-expire-articles
3036 (gnus-uncompress-sequence (cdr expirable)) group))))
3037 (gnus-close-group group))
3038 (gnus-message 6 "Expiring articles in %s...done" group)
3039 ;; Return the list of un-expired articles.
3042 (defun gnus-group-expire-all-groups ()
3043 "Expire all expirable articles in all newsgroups."
3046 (gnus-message 5 "Expiring...")
3047 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3048 (cdr gnus-newsrc-alist))))
3049 (gnus-group-expire-articles nil)))
3050 (gnus-group-position-point)
3051 (gnus-message 5 "Expiring...done"))
3053 (defun gnus-group-set-current-level (n level)
3054 "Set the level of the next N groups to LEVEL."
3059 (let ((s (read-string
3060 (format "Level (default %s): "
3061 (or (gnus-group-group-level)
3062 gnus-level-default-subscribed)))))
3063 (if (string-match "^\\s-*$" s)
3064 (int-to-string (or (gnus-group-group-level)
3065 gnus-level-default-subscribed))
3067 (unless (and (>= level 1) (<= level gnus-level-killed))
3068 (error "Invalid level: %d" level))
3069 (let ((groups (gnus-group-process-prefix n))
3071 (while (setq group (pop groups))
3072 (gnus-group-remove-mark group)
3073 (gnus-message 6 "Changed level of %s from %d to %d"
3074 group (or (gnus-group-group-level) gnus-level-killed)
3076 (gnus-group-change-level
3077 group level (or (gnus-group-group-level) gnus-level-killed))
3078 (gnus-group-update-group-line)))
3079 (gnus-group-position-point))
3081 (defun gnus-group-unsubscribe (&optional n)
3082 "Unsubscribe the current group."
3084 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3086 (defun gnus-group-subscribe (&optional n)
3087 "Subscribe the current group."
3089 (gnus-group-unsubscribe-current-group n 'subscribe))
3091 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3092 "Toggle subscription of the current group.
3093 If given numerical prefix, toggle the N next groups."
3095 (let ((groups (gnus-group-process-prefix n))
3098 (setq group (car groups)
3099 groups (cdr groups))
3100 (gnus-group-remove-mark group)
3101 (gnus-group-unsubscribe-group
3104 ((eq do-sub 'unsubscribe)
3105 gnus-level-default-unsubscribed)
3106 ((eq do-sub 'subscribe)
3107 gnus-level-default-subscribed)
3108 ((<= (gnus-group-group-level) gnus-level-subscribed)
3109 gnus-level-default-unsubscribed)
3111 gnus-level-default-subscribed))
3113 (gnus-group-update-group-line))
3114 (gnus-group-next-group 1)))
3116 (defun gnus-group-unsubscribe-group (group &optional level silent)
3117 "Toggle subscription to GROUP.
3118 Killed newsgroups are subscribed. If SILENT, don't try to update the
3121 (list (completing-read
3122 "Group: " gnus-active-hashtb nil
3123 (gnus-read-active-file-p)
3125 'gnus-group-history)))
3126 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3128 ((string-match "^[ \t]*$" group)
3129 (error "Empty group name"))
3131 ;; Toggle subscription flag.
3132 (gnus-group-change-level
3133 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3134 gnus-level-subscribed)
3135 (1+ gnus-level-subscribed)
3136 gnus-level-default-subscribed)))
3138 (gnus-group-update-group group)))
3139 ((and (stringp group)
3140 (or (not (gnus-read-active-file-p))
3141 (gnus-active group)))
3142 ;; Add new newsgroup.
3143 (gnus-group-change-level
3145 (if level level gnus-level-default-subscribed)
3146 (or (and (member group gnus-zombie-list)
3149 (when (gnus-group-group-name)
3150 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3152 (gnus-group-update-group group)))
3153 (t (error "No such newsgroup: %s" group)))
3154 (gnus-group-position-point)))
3156 (defun gnus-group-transpose-groups (n)
3157 "Move the current newsgroup up N places.
3158 If given a negative prefix, move down instead. The difference between
3159 N and the number of steps taken is returned."
3161 (unless (gnus-group-group-name)
3162 (error "No group on current line"))
3163 (gnus-group-kill-group 1)
3165 (forward-line (- n))
3166 (gnus-group-yank-group)
3167 (gnus-group-position-point)))
3169 (defun gnus-group-kill-all-zombies (&optional dummy)
3170 "Kill all zombie newsgroups.
3171 The optional DUMMY should always be nil."
3172 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3174 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3175 (setq gnus-zombie-list nil)
3176 (gnus-dribble-touch)
3177 (gnus-group-list-groups)))
3179 (defun gnus-group-kill-region (begin end)
3180 "Kill newsgroups in current region (excluding current point).
3181 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3196 (beginning-of-line) ;Important when LINES < 1
3197 (gnus-group-kill-group lines)))
3199 (defun gnus-group-kill-group (&optional n discard)
3200 "Kill the next N groups.
3201 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3202 However, only groups that were alive can be yanked; already killed
3203 groups or zombie groups can't be yanked.
3204 The return value is the name of the group that was killed, or a list
3207 (let ((buffer-read-only nil)
3208 (groups (gnus-group-process-prefix n))
3209 group entry level out)
3210 (if (< (length groups) 10)
3211 ;; This is faster when there are few groups.
3213 (push (setq group (pop groups)) out)
3214 (gnus-group-remove-mark group)
3215 (setq level (gnus-group-group-level))
3217 (when (and (not discard)
3218 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3221 (gnus-group-goto-group ,(gnus-group-group-name))
3222 (gnus-group-yank-group)))
3223 (push (cons (car entry) (nth 2 entry))
3224 gnus-list-of-killed-groups))
3225 (gnus-group-change-level
3226 (if entry entry group) gnus-level-killed (if entry nil level))
3227 (message "Killed group %s" group))
3228 ;; If there are lots and lots of groups to be killed, we use
3229 ;; this thing instead.
3231 (setq groups (nreverse groups))
3233 (gnus-group-remove-mark (setq group (pop groups)))
3235 (push group gnus-killed-list)
3236 (setq gnus-newsrc-alist
3237 (delq (assoc group gnus-newsrc-alist)
3239 (when gnus-group-change-level-function
3240 (funcall gnus-group-change-level-function
3241 group gnus-level-killed 3))
3243 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3244 (push (cons (car entry) (nth 2 entry))
3245 gnus-list-of-killed-groups)
3246 (setcdr (cdr entry) (cdddr entry)))
3247 ((member group gnus-zombie-list)
3248 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3249 ;; There may be more than one instance displayed.
3250 (while (gnus-group-goto-group group)
3251 (gnus-delete-line)))
3252 (gnus-make-hashtable-from-newsrc-alist)))
3254 (gnus-group-position-point)
3255 (if (< (length out) 2) (car out) (nreverse out))))
3257 (defun gnus-group-yank-group (&optional arg)
3258 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3259 The numeric ARG specifies how many newsgroups are to be yanked. The
3260 name of the newsgroup yanked is returned, or (if several groups are
3261 yanked) a list of yanked groups is returned."
3263 (setq arg (or arg 1))
3264 (let (info group prev out)
3265 (while (>= (decf arg) 0)
3266 (when (not (setq info (pop gnus-list-of-killed-groups)))
3267 (error "No more newsgroups to yank"))
3268 (push (setq group (nth 1 info)) out)
3269 ;; Find which newsgroup to insert this one before - search
3270 ;; backward until something suitable is found. If there are no
3271 ;; other newsgroups in this buffer, just make this newsgroup the
3273 (setq prev (gnus-group-group-name))
3274 (gnus-group-change-level
3275 info (gnus-info-level (cdr info)) gnus-level-killed
3276 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3278 (gnus-group-insert-group-line-info group)
3280 `(when (gnus-group-goto-group ,group)
3281 (gnus-group-kill-group 1))))
3283 (gnus-group-position-point)
3284 (if (< (length out) 2) (car out) (nreverse out))))
3286 (defun gnus-group-kill-level (level)
3287 "Kill all groups that is on a certain LEVEL."
3288 (interactive "nKill all groups on level: ")
3290 ((= level gnus-level-zombie)
3291 (setq gnus-killed-list
3292 (nconc gnus-zombie-list gnus-killed-list))
3293 (setq gnus-zombie-list nil))
3294 ((and (< level gnus-level-zombie)
3296 (or gnus-expert-user
3299 "Do you really want to kill all groups on level %d? "
3301 (let* ((prev gnus-newsrc-alist)
3304 (if (= (gnus-info-level (car alist)) level)
3306 (push (gnus-info-group (car alist)) gnus-killed-list)
3307 (setcdr prev (cdr alist)))
3309 (setq alist (cdr alist)))
3310 (gnus-make-hashtable-from-newsrc-alist)
3311 (gnus-group-list-groups)))
3313 (error "Can't kill; invalid level: %d" level))))
3315 (defun gnus-group-list-all-groups (&optional arg)
3316 "List all newsgroups with level ARG or lower.
3317 Default is gnus-level-unsubscribed, which lists all subscribed and most
3318 unsubscribed groups."
3320 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3322 ;; Redefine this to list ALL killed groups if prefix arg used.
3323 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3324 (defun gnus-group-list-killed (&optional arg)
3325 "List all killed newsgroups in the group buffer.
3326 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3327 entail asking the server for the groups."
3329 ;; Find all possible killed newsgroups if arg.
3331 (gnus-get-killed-groups))
3332 (if (not gnus-killed-list)
3333 (gnus-message 6 "No killed groups")
3334 (let (gnus-group-list-mode)
3335 (funcall gnus-group-prepare-function
3336 gnus-level-killed t gnus-level-killed))
3337 (goto-char (point-min)))
3338 (gnus-group-position-point))
3340 (defun gnus-group-list-zombies ()
3341 "List all zombie newsgroups in the group buffer."
3343 (if (not gnus-zombie-list)
3344 (gnus-message 6 "No zombie groups")
3345 (let (gnus-group-list-mode)
3346 (funcall gnus-group-prepare-function
3347 gnus-level-zombie t gnus-level-zombie))
3348 (goto-char (point-min)))
3349 (gnus-group-position-point))
3351 (defun gnus-group-list-active ()
3352 "List all groups that are available from the server(s)."
3354 ;; First we make sure that we have really read the active file.
3355 (unless (gnus-read-active-file-p)
3356 (let ((gnus-read-active-file t)
3357 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3358 (gnus-read-active-file)))
3359 ;; Find all groups and sort them.
3367 (push (symbol-name sym) list)))
3371 (buffer-read-only nil)
3375 (setq group (pop groups))
3376 (gnus-add-text-properties
3377 (point) (prog1 (1+ (point))
3379 (gnus-group-decoded-name group)
3381 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3383 'gnus-level (inline (gnus-group-level group)))))
3384 (goto-char (point-min))))
3386 (defun gnus-activate-all-groups (level)
3387 "Activate absolutely all groups."
3388 (interactive (list gnus-level-unsubscribed))
3389 (let ((gnus-activate-level level)
3390 (gnus-activate-foreign-newsgroups level))
3391 (gnus-group-get-new-news)))
3393 (defun gnus-group-get-new-news (&optional arg)
3394 "Get newly arrived articles.
3395 If ARG is a number, it specifies which levels you are interested in
3396 re-scanning. If ARG is non-nil and not a number, this will force
3397 \"hard\" re-reading of the active files from all servers."
3400 (let ((gnus-inhibit-demon t)
3401 ;; Binding this variable will inhibit multiple fetchings
3402 ;; of the same mail source.
3403 (nnmail-fetched-sources (list t)))
3404 (gnus-run-hooks 'gnus-get-new-news-hook)
3406 ;; Read any slave files.
3408 (gnus-master-read-slave-newsrc))
3410 ;; We might read in new NoCeM messages here.
3411 (when (and gnus-use-nocem
3413 (gnus-nocem-scan-groups))
3414 ;; If ARG is not a number, then we read the active file.
3415 (when (and arg (not (numberp arg)))
3416 (let ((gnus-read-active-file t))
3417 (gnus-read-active-file))
3420 ;; If the user wants it, we scan for new groups.
3421 (when (eq gnus-check-new-newsgroups 'always)
3422 (gnus-find-new-newsgroups)))
3424 (setq arg (gnus-group-default-level arg t))
3425 (if (and gnus-read-active-file (not arg))
3427 (gnus-read-active-file)
3428 (gnus-get-unread-articles arg))
3429 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3430 (gnus-get-unread-articles arg)))
3431 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3432 (gnus-group-list-groups (and (numberp arg)
3433 (max (car gnus-group-list-mode) arg))))
3435 (when (and gnus-agent (not (interactive-p)))
3436 (gnus-agent-toggle-plugged gnus-plugged)))
3438 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3439 "Check for newly arrived news in the current group (and the N-1 next groups).
3440 The difference between N and the number of newsgroup checked is returned.
3441 If N is negative, this group and the N-1 previous groups will be checked."
3443 (let* ((groups (gnus-group-process-prefix n))
3444 (ret (if (numberp n) (- n (length groups)) 0))
3448 (gnus-inhibit-demon t)
3449 ;; Binding this variable will inhibit multiple fetchings
3450 ;; of the same mail source.
3451 (nnmail-fetched-sources (list t)))
3452 (gnus-run-hooks 'gnus-get-new-news-hook)
3453 (while (setq group (pop groups))
3454 (gnus-group-remove-mark group)
3455 ;; Bypass any previous denials from the server.
3456 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3457 (if (gnus-activate-group group (if dont-scan nil 'scan))
3459 (gnus-get-unread-articles-in-group
3460 (gnus-get-info group) (gnus-active group) t)
3461 (unless (gnus-virtual-group-p group)
3462 (gnus-close-group group))
3464 (gnus-agent-save-group-info
3465 method (gnus-group-real-name group) (gnus-active group)))
3466 (gnus-group-update-group group))
3467 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3469 (gnus-error 3 "Server denied access")
3470 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3473 (when gnus-goto-next-group-when-activating
3474 (gnus-group-next-unread-group 1 t))
3475 (gnus-summary-position-point)
3478 (defun gnus-group-fetch-faq (group &optional faq-dir)
3479 "Fetch the FAQ for the current group.
3480 If given a prefix argument, prompt for the FAQ dir
3484 (gnus-group-group-name)
3485 (when current-prefix-arg
3487 "Faq dir: " (and (listp gnus-group-faq-directory)
3489 gnus-group-faq-directory))))))
3491 (error "No group name given"))
3492 (let ((dirs (or faq-dir gnus-group-faq-directory))
3494 (unless (listp dirs)
3495 (setq dirs (list dirs)))
3496 (while (and (not found)
3497 (setq dir (pop dirs)))
3498 (let ((name (gnus-group-real-name group)))
3499 (setq file (expand-file-name name dir)))
3500 (if (not (file-exists-p file))
3501 (gnus-message 1 "No such file: %s" file)
3502 (let ((enable-local-variables nil))
3506 (defun gnus-group-describe-group (force &optional group)
3507 "Display a description of the current newsgroup."
3508 (interactive (list current-prefix-arg (gnus-group-group-name)))
3509 (let* ((method (gnus-find-method-for-group group))
3510 (mname (gnus-group-prefixed-name "" method))
3513 gnus-description-hashtb)
3514 (gnus-sethash mname nil gnus-description-hashtb))
3516 (error "No group name given"))
3517 (when (or (and gnus-description-hashtb
3518 ;; We check whether this group's method has been
3519 ;; queried for a description file.
3520 (gnus-gethash mname gnus-description-hashtb))
3521 (setq desc (gnus-group-get-description group))
3522 (gnus-read-descriptions-file method))
3524 (or desc (gnus-gethash group gnus-description-hashtb)
3525 "No description available")))))
3527 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3528 (defun gnus-group-describe-all-groups (&optional force)
3529 "Pop up a buffer with descriptions of all newsgroups."
3532 (setq gnus-description-hashtb nil))
3533 (when (not (or gnus-description-hashtb
3534 (gnus-read-all-descriptions-files)))
3535 (error "Couldn't request descriptions file"))
3536 (let ((buffer-read-only nil)
3542 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3543 (insert (format " *: %-20s %s\n"
3544 (gnus-group-name-decode
3545 (symbol-name group) charset)
3546 (gnus-group-name-decode
3547 (symbol-value group) charset))))
3548 (gnus-add-text-properties
3549 b (1+ b) (list 'gnus-group group
3550 'gnus-unread t 'gnus-marked nil
3551 'gnus-level (1+ gnus-level-subscribed))))
3552 gnus-description-hashtb)
3553 (goto-char (point-min))
3554 (gnus-group-position-point)))
3556 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3557 (defun gnus-group-apropos (regexp &optional search-description)
3558 "List all newsgroups that have names that match a regexp."
3559 (interactive "sGnus apropos (regexp): ")
3561 (obuf (current-buffer))
3563 ;; Go through all newsgroups that are known to Gnus.
3566 (and (symbol-name group)
3567 (string-match regexp (symbol-name group))
3568 (symbol-value group)
3569 (push (symbol-name group) groups)))
3571 ;; Also go through all descriptions that are known to Gnus.
3572 (when search-description
3575 (and (string-match regexp (symbol-value group))
3576 (push (symbol-name group) groups)))
3577 gnus-description-hashtb))
3579 (gnus-message 3 "No groups matched \"%s\"." regexp)
3580 ;; Print out all the groups.
3582 (pop-to-buffer "*Gnus Help*")
3583 (buffer-disable-undo)
3585 (setq groups (sort groups 'string<))
3587 ;; Groups may be entered twice into the list of groups.
3588 (when (not (string= (car groups) prev))
3589 (setq prev (car groups))
3590 (let ((charset (gnus-group-name-charset nil prev)))
3591 (insert (gnus-group-name-decode prev charset) "\n")
3592 (when (and gnus-description-hashtb
3593 (setq des (gnus-gethash (car groups)
3594 gnus-description-hashtb)))
3595 (insert " " (gnus-group-name-decode des charset) "\n"))))
3596 (setq groups (cdr groups)))
3597 (goto-char (point-min))))
3598 (pop-to-buffer obuf)))
3600 (defun gnus-group-description-apropos (regexp)
3601 "List all newsgroups that have names or descriptions that match a regexp."
3602 (interactive "sGnus description apropos (regexp): ")
3603 (when (not (or gnus-description-hashtb
3604 (gnus-read-all-descriptions-files)))
3605 (error "Couldn't request descriptions file"))
3606 (gnus-group-apropos regexp t))
3608 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3609 (defun gnus-group-list-matching (level regexp &optional all lowest)
3610 "List all groups with unread articles that match REGEXP.
3611 If the prefix LEVEL is non-nil, it should be a number that says which
3612 level to cut off listing groups.
3613 If ALL, also list groups with no unread articles.
3614 If LOWEST, don't list groups with level lower than LOWEST.
3616 This command may read the active file."
3617 (interactive "P\nsList newsgroups matching: ")
3618 ;; First make sure active file has been read.
3620 (> (prefix-numeric-value level) gnus-level-killed))
3621 (gnus-get-killed-groups))
3622 (funcall gnus-group-prepare-function
3623 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3624 (goto-char (point-min))
3625 (gnus-group-position-point))
3627 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3628 "List all groups that match REGEXP.
3629 If the prefix LEVEL is non-nil, it should be a number that says which
3630 level to cut off listing groups.
3631 If LOWEST, don't list groups with level lower than LOWEST."
3632 (interactive "P\nsList newsgroups matching: ")
3634 (setq level (prefix-numeric-value level)))
3635 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3637 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3638 (defun gnus-group-save-newsrc (&optional force)
3639 "Save the Gnus startup files.
3640 If FORCE, force saving whether it is necessary or not."
3642 (gnus-save-newsrc-file force))
3644 (defun gnus-group-restart (&optional arg)
3645 "Force Gnus to read the .newsrc file."
3647 (when (gnus-yes-or-no-p
3648 (format "Are you sure you want to restart Gnus? "))
3649 (gnus-save-newsrc-file)
3653 (defun gnus-group-read-init-file ()
3654 "Read the Gnus elisp init file."
3656 (gnus-read-init-file)
3657 (gnus-message 5 "Read %s" gnus-init-file))
3659 (defun gnus-group-check-bogus-groups (&optional silent)
3660 "Check bogus newsgroups.
3661 If given a prefix, don't ask for confirmation before removing a bogus
3664 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3665 (gnus-group-list-groups))
3667 (defun gnus-group-find-new-groups (&optional arg)
3668 "Search for new groups and add them.
3669 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3670 With 1 C-u, use the `ask-server' method to query the server for new
3672 With 2 C-u's, use most complete method possible to query the server
3673 for new groups, and subscribe the new groups as zombies."
3675 (gnus-find-new-newsgroups (or arg 1))
3676 (gnus-group-list-groups))
3678 (defun gnus-group-edit-global-kill (&optional article group)
3679 "Edit the global kill file.
3680 If GROUP, edit that local kill file instead."
3682 (setq gnus-current-kill-article article)
3683 (gnus-kill-file-edit-file group)
3686 (substitute-command-keys
3687 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3688 (if group "local" "global")))))
3690 (defun gnus-group-edit-local-kill (article group)
3691 "Edit a local kill file."
3692 (interactive (list nil (gnus-group-group-name)))
3693 (gnus-group-edit-global-kill article group))
3695 (defun gnus-group-force-update ()
3696 "Update `.newsrc' file."
3698 (gnus-save-newsrc-file))
3700 (defun gnus-group-suspend ()
3701 "Suspend the current Gnus session.
3702 In fact, cleanup buffers except for group mode buffer.
3703 The hook gnus-suspend-gnus-hook is called before actually suspending."
3705 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3706 (gnus-offer-save-summaries)
3707 ;; Kill Gnus buffers except for group mode buffer.
3708 (let ((group-buf (get-buffer gnus-group-buffer)))
3709 (mapcar (lambda (buf)
3710 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3714 (eq major-mode 'message-mode))))
3715 (gnus-kill-buffer buf)))
3717 (gnus-kill-gnus-frames)
3719 (bury-buffer group-buf)
3720 (delete-windows-on group-buf t))))
3722 (defun gnus-group-clear-dribble ()
3723 "Clear all information from the dribble buffer."
3725 (gnus-dribble-clear)
3726 (gnus-message 7 "Cleared dribble buffer"))
3728 (defun gnus-group-exit ()
3729 "Quit reading news after updating .newsrc.eld and .newsrc.
3730 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3733 (or noninteractive ;For gnus-batch-kill
3734 (not gnus-interactive-exit) ;Without confirmation
3736 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3737 (gnus-run-hooks 'gnus-exit-gnus-hook)
3738 ;; Offer to save data from non-quitted summary buffers.
3739 (gnus-offer-save-summaries)
3740 ;; Save the newsrc file(s).
3741 (gnus-save-newsrc-file)
3743 (gnus-close-backends)
3744 ;; Reset everything.
3746 ;; Allow the user to do things after cleaning up.
3747 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3749 (defun gnus-group-quit ()
3750 "Quit reading news without updating .newsrc.eld or .newsrc.
3751 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3753 (when (or noninteractive ;For gnus-batch-kill
3754 (zerop (buffer-size))
3755 (not (gnus-server-opened gnus-select-method))
3757 (not gnus-current-startup-file)
3759 (format "Quit reading news without saving %s? "
3760 (file-name-nondirectory gnus-current-startup-file))))
3761 (gnus-run-hooks 'gnus-exit-gnus-hook)
3762 (gnus-configure-windows 'group t)
3763 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3764 (not (zerop (save-excursion
3765 (set-buffer gnus-dribble-buffer)
3768 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3770 (gnus-close-backends)
3772 (gnus-kill-buffer gnus-group-buffer)
3773 ;; Allow the user to do things after cleaning up.
3774 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3776 (defun gnus-group-describe-briefly ()
3777 "Give a one line description of the group mode commands."
3779 (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")))
3781 (defun gnus-group-browse-foreign-server (method)
3782 "Browse a foreign news server.
3783 If called interactively, this function will ask for a select method
3784 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3785 If not, METHOD should be a list where the first element is the method
3786 and the second element is the address."
3788 (list (let ((how (completing-read
3790 (append gnus-valid-select-methods gnus-server-alist)
3791 nil t (cons "nntp" 0) 'gnus-method-history)))
3792 ;; We either got a backend name or a virtual server name.
3793 ;; If the first, we also need an address.
3794 (if (assoc how gnus-valid-select-methods)
3796 ;; Suggested by mapjph@bath.ac.uk.
3799 (mapcar (lambda (server) (list server))
3800 gnus-secondary-servers)))
3801 ;; We got a server name.
3803 (gnus-browse-foreign-server method))
3805 (defun gnus-group-set-info (info &optional method-only-group part)
3806 (when (or info part)
3807 (let* ((entry (gnus-gethash
3808 (or method-only-group (gnus-info-group info))
3809 gnus-newsrc-hashtb))
3811 (info (if method-only-group (nth 2 entry) info))
3813 (when method-only-group
3815 (error "Trying to change non-existent group %s" method-only-group))
3816 ;; We have received parts of the actual group info - either the
3817 ;; select method or the group parameters. We first check
3818 ;; whether we have to extend the info, and if so, do that.
3819 (let ((len (length info))
3820 (total (if (eq part 'method) 5 6)))
3822 (setcdr (nthcdr (1- len) info)
3823 (make-list (- total len) nil)))
3824 ;; Then we enter the new info.
3825 (setcar (nthcdr (1- total) info) part-info)))
3827 ;; This is a new group, so we just create it.
3829 (set-buffer gnus-group-buffer)
3830 (setq method (gnus-info-method info))
3831 (when (gnus-server-equal method "native")
3834 (set-buffer gnus-group-buffer)
3836 ;; It's a foreign group...
3837 (gnus-group-make-group
3838 (gnus-group-real-name (gnus-info-group info))
3839 (if (stringp method) method
3840 (prin1-to-string (car method)))
3842 (nth 1 (gnus-info-method info))))
3843 ;; It's a native group.
3844 (gnus-group-make-group (gnus-info-group info))))
3845 (gnus-message 6 "Note: New group created")
3847 (gnus-gethash (gnus-group-prefixed-name
3848 (gnus-group-real-name (gnus-info-group info))
3849 (or (gnus-info-method info) gnus-select-method))
3850 gnus-newsrc-hashtb))))
3851 ;; Whether it was a new group or not, we now have the entry, so we
3852 ;; can do the update.
3855 (setcar (nthcdr 2 entry) info)
3856 (when (and (not (eq (car entry) t))
3857 (gnus-active (gnus-info-group info)))
3858 (setcar entry (length
3859 (gnus-list-of-unread-articles (car info))))))
3860 (error "No such group: %s" (gnus-info-group info))))))
3862 (defun gnus-group-set-method-info (group select-method)
3863 (gnus-group-set-info select-method group 'method))
3865 (defun gnus-group-set-params-info (group params)
3866 (gnus-group-set-info params group 'params))
3868 (defun gnus-add-marked-articles (group type articles &optional info force)
3869 ;; Add ARTICLES of TYPE to the info of GROUP.
3870 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3871 ;; add, but replace marked articles of TYPE with ARTICLES.
3872 (let ((info (or info (gnus-get-info group)))
3875 (and (not (setq marked (nthcdr 3 info)))
3877 (setcdr (nthcdr 2 info)
3878 (list (list (cons type (gnus-compress-sequence
3880 (and (not (setq m (assq type (car marked))))
3883 (cons (cons type (gnus-compress-sequence articles t) )
3887 (setcar (nthcdr 3 info)
3888 (gnus-delete-alist type (car marked)))
3889 (setcdr m (gnus-compress-sequence articles t)))
3890 (setcdr m (gnus-compress-sequence
3891 (sort (nconc (gnus-uncompress-range (cdr m))
3892 (copy-sequence articles)) '<) t))))))
3894 (defun gnus-add-mark (group mark article)
3895 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3896 (let ((buffer (gnus-summary-buffer-name group)))
3897 (if (gnus-buffer-live-p buffer)
3899 (set-buffer (get-buffer buffer))
3900 (gnus-summary-add-mark article mark))
3901 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3905 ;;; Group timestamps
3908 (defun gnus-group-set-timestamp ()
3909 "Change the timestamp of the current group to the current time.
3910 This function can be used in hooks like `gnus-select-group-hook'
3911 or `gnus-group-catchup-group-hook'."
3912 (when gnus-newsgroup-name
3913 (let ((time (current-time)))
3914 (setcdr (cdr time) nil)
3915 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3917 (defsubst gnus-group-timestamp (group)
3918 "Return the timestamp for GROUP."
3919 (gnus-group-get-parameter group 'timestamp t))
3921 (defun gnus-group-timestamp-delta (group)
3922 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3923 (let* ((time (or (gnus-group-timestamp group)
3925 (delta (subtract-time (current-time) time)))
3926 (+ (* (nth 0 delta) 65536.0)
3929 (defun gnus-group-timestamp-string (group)
3930 "Return a string of the timestamp for GROUP."
3931 (let ((time (gnus-group-timestamp group)))
3934 (gnus-time-iso8601 time))))
3936 (defun gnus-group-list-cached (level &optional lowest)
3937 "List all groups with cached articles.
3938 If the prefix LEVEL is non-nil, it should be a number that says which
3939 level to cut off listing groups.
3940 If LOWEST, don't list groups with level lower than LOWEST.
3942 This command may read the active file."
3945 (setq level (prefix-numeric-value level)))
3946 (when (or (not level) (>= level gnus-level-zombie))
3948 (funcall gnus-group-prepare-function
3949 (or level gnus-level-subscribed)
3951 (let ((marks (gnus-info-marks info)))
3952 (assq 'cache marks)))
3955 (or (gnus-gethash group
3956 gnus-cache-active-hashtb)
3957 ;; Cache active file might use "."
3960 (mapconcat 'identity
3961 (split-string group ":")
3963 gnus-cache-active-hashtb))))
3964 (goto-char (point-min))
3965 (gnus-group-position-point))
3967 (defun gnus-group-list-dormant (level &optional lowest)
3968 "List all groups with dormant articles.
3969 If the prefix LEVEL is non-nil, it should be a number that says which
3970 level to cut off listing groups.
3971 If LOWEST, don't list groups with level lower than LOWEST.
3973 This command may read the active file."
3976 (setq level (prefix-numeric-value level)))
3977 (when (or (not level) (>= level gnus-level-zombie))
3979 (funcall gnus-group-prepare-function
3980 (or level gnus-level-subscribed)
3982 (let ((marks (gnus-info-marks info)))
3983 (assq 'dormant marks)))
3986 (goto-char (point-min))
3987 (gnus-group-position-point))
3989 (defun gnus-group-listed-groups ()
3990 "Return a list of listed groups."
3992 (goto-char (point-min))
3993 (while (setq point (text-property-not-all (point) (point-max)
3996 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4000 (defun gnus-group-list-plus (&optional args)
4001 "List groups plus the current selection."
4003 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4004 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4006 (push last-command-event unread-command-events)
4007 (if (featurep 'xemacs)
4008 (push (make-event 'key-press '(key ?A)) unread-command-events)
4009 (push ?A unread-command-events))
4010 (let (gnus-pick-mode keys)
4011 (setq keys (if (featurep 'xemacs)
4012 (events-to-keys (read-key-sequence nil))
4013 (read-key-sequence nil)))
4014 (setq func (lookup-key (current-local-map) keys)))
4018 (call-interactively func))))
4020 (defun gnus-group-list-flush (&optional args)
4021 "Flush groups from the current selection."
4023 (let ((gnus-group-list-option 'flush))
4024 (gnus-group-list-plus args)))
4026 (defun gnus-group-list-limit (&optional args)
4027 "List groups limited within the current selection."
4029 (let ((gnus-group-list-option 'limit))
4030 (gnus-group-list-plus args)))
4032 (defun gnus-group-mark-article-read (group article)
4033 "Mark ARTICLE read."
4034 (let ((buffer (gnus-summary-buffer-name group))
4035 (mark gnus-read-mark)
4037 (if (get-buffer buffer)
4038 (with-current-buffer buffer
4039 (setq active gnus-newsgroup-active)
4040 (gnus-activate-group group)
4041 (when gnus-newsgroup-prepared
4042 (when (and gnus-newsgroup-auto-expire
4043 (memq mark gnus-auto-expirable-marks))
4044 (setq mark gnus-expirable-mark))
4045 (setq mark (gnus-request-update-mark
4046 group article mark))
4047 (gnus-mark-article-as-read article mark)
4048 (setq gnus-newsgroup-active (gnus-active group))
4050 (setq n (1+ (cdr active)))
4051 (while (<= n (cdr gnus-newsgroup-active))
4052 (unless (eq n article)
4053 (push n gnus-newsgroup-unselected))
4055 (gnus-activate-group group)
4056 (gnus-group-make-articles-read group
4058 (when (gnus-group-auto-expirable-p group)
4059 (gnus-add-marked-articles
4060 group 'expire (list article))))))
4062 (provide 'gnus-group)
4064 ;;; gnus-group.el ends here